diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-23 01:32:15 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-23 01:32:15 +0000 |
commit | 3289a82a55e7dbc9badac7d503e11ba5d5cb334c (patch) | |
tree | 37a614e52cc65256314821bb77a46c723312ab3d /chrome_frame | |
parent | 1680547c393e3be66f7537a950635dd087e088de (diff) | |
download | chromium_src-3289a82a55e7dbc9badac7d503e11ba5d5cb334c.zip chromium_src-3289a82a55e7dbc9badac7d503e11ba5d5cb334c.tar.gz chromium_src-3289a82a55e7dbc9badac7d503e11ba5d5cb334c.tar.bz2 |
Eliminate duplicate COM and OLE initializations.
This is take 2; the original patch ( http://crrev.com/159815 ), which only dealt with OLE, broke a few tests. The OneClickSignIn tests were skipping the RenderViewHostTestHarness SetUp() method, while the Accessibility tests directly muck with Widgets and thus have to manually init OLE.
BUG=none
TEST=Fewer "Multiple OleInitialize..." messages in tests
Review URL: https://codereview.chromium.org/11031059
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@163470 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame')
-rw-r--r-- | chrome_frame/test/net/fake_external_tab.cc | 10 | ||||
-rw-r--r-- | chrome_frame/test/net/fake_external_tab.h | 2 | ||||
-rw-r--r-- | chrome_frame/test/run_all_unittests.cc | 20 | ||||
-rw-r--r-- | chrome_frame/test/url_request_test.cc | 5 |
4 files changed, 14 insertions, 23 deletions
diff --git a/chrome_frame/test/net/fake_external_tab.cc b/chrome_frame/test/net/fake_external_tab.cc index 943bdcde..470b296 100644 --- a/chrome_frame/test/net/fake_external_tab.cc +++ b/chrome_frame/test/net/fake_external_tab.cc @@ -26,7 +26,6 @@ #include "base/test/test_timeouts.h" #include "base/threading/platform_thread.h" #include "base/threading/thread.h" -#include "base/win/scoped_com_initializer.h" #include "base/win/scoped_comptr.h" #include "base/win/scoped_handle.h" #include "chrome/app/chrome_main_delegate.h" @@ -534,7 +533,6 @@ void CFUrlRequestUnittestRunner::StartChromeFrameInHostBrowser() { if (!launch_browser_) return; - base::win::ScopedCOMInitializer com; chrome_frame_test::CloseAllIEWindows(); // Tweak IE settings to make it amenable to testing before launching it. @@ -563,10 +561,8 @@ void CFUrlRequestUnittestRunner::StartChromeFrameInHostBrowser() { } void CFUrlRequestUnittestRunner::ShutDownHostBrowser() { - if (launch_browser_) { - base::win::ScopedCOMInitializer com; + if (launch_browser_) chrome_frame_test::CloseAllIEWindows(); - } } void CFUrlRequestUnittestRunner::OnIEShutdownFailure() { @@ -725,10 +721,8 @@ void CFUrlRequestUnittestRunner::OnInitializationTimeout() { StopFileLogger(true); - if (launch_browser_) { - base::win::ScopedCOMInitializer com; + if (launch_browser_) chrome_frame_test::CloseAllIEWindows(); - } if (ie_configurator_.get() != NULL) ie_configurator_->RevertSettings(); diff --git a/chrome_frame/test/net/fake_external_tab.h b/chrome_frame/test/net/fake_external_tab.h index e4c2749..18e24b0 100644 --- a/chrome_frame/test/net/fake_external_tab.h +++ b/chrome_frame/test/net/fake_external_tab.h @@ -52,7 +52,7 @@ class FakeExternalTab { FakeBrowserProcessImpl* browser_process() const; - protected: + private: scoped_ptr<FakeBrowserProcessImpl> browser_process_; FilePath overridden_user_dir_; FilePath user_data_dir_; diff --git a/chrome_frame/test/run_all_unittests.cc b/chrome_frame/test/run_all_unittests.cc index b0f502e..55e21cc 100644 --- a/chrome_frame/test/run_all_unittests.cc +++ b/chrome_frame/test/run_all_unittests.cc @@ -25,14 +25,13 @@ class ChromeFrameUnittestsModule : public CAtlExeModuleT<ChromeFrameUnittestsModule> { public: - static HRESULT InitializeCom() { - // Note that this only gets called in versions of ATL included in - // VS2008 and earlier. We still need it however since this gets called - // at static initialization time, before the ScopedCOMInitializer in main() - // and the default implementation of InitializeCom CoInitializes into the - // MTA. - return CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); - } + // Called at static init time, for versions of ATL included in VS2008 and + // earlier only. The default implementation initializes COM in MTA mode, + // which we don't want. We could init STA mode here, but since we have to + // init in main() for VS2010 and above anyway, we simply do nothing, since + // nothing needs COM before main() runs. + static HRESULT InitializeCom() { return S_OK; } + static void UninitializeCom() {} }; ChromeFrameUnittestsModule _AtlModule; @@ -46,7 +45,10 @@ void PureCall() { } int main(int argc, char **argv) { - base::win::ScopedCOMInitializer com_initializer; + // For ATL in VS2010 and up, ChromeFrameUnittestsModule::InitializeCom() is + // not called, so we init COM here. + base::win::ScopedCOMInitializer com_initializer_; + ScopedChromeFrameRegistrar::RegisterAndExitProcessIfDirected(); base::EnableTerminationOnHeapCorruption(); base::PlatformThread::SetName("ChromeFrame tests"); diff --git a/chrome_frame/test/url_request_test.cc b/chrome_frame/test/url_request_test.cc index 6c1790f..8da74bc 100644 --- a/chrome_frame/test/url_request_test.cc +++ b/chrome_frame/test/url_request_test.cc @@ -7,7 +7,6 @@ #include "base/bind.h" #include "base/bind_helpers.h" -#include "base/win/scoped_com_initializer.h" #include "chrome/common/automation_messages.h" #include "chrome_frame/test/chrome_frame_test_utils.h" #include "chrome_frame/test/test_server.h" @@ -72,7 +71,6 @@ TEST(UrlmonUrlRequestTest, Simple1) { chrome_frame_test::GetTestDataFolder()); mock_server.ExpectAndServeAnyRequests(CFInvocation(CFInvocation::NONE)); - base::win::ScopedCOMInitializer init_com; CComObjectStackEx<UrlmonUrlRequest> request; request.AddRef(); @@ -121,7 +119,6 @@ TEST(UrlmonUrlRequestTest, Head) { test_server::SimpleResponse head_response("/head", ""); server.AddResponse(&head_response); - base::win::ScopedCOMInitializer init_com; CComObjectStackEx<UrlmonUrlRequest> request; request.AddRef(); @@ -158,7 +155,6 @@ TEST(UrlmonUrlRequestTest, Head) { TEST(UrlmonUrlRequestTest, UnreachableUrl) { MockUrlDelegate mock; chrome_frame_test::TimedMsgLoop loop; - base::win::ScopedCOMInitializer init_com; CComObjectStackEx<UrlmonUrlRequest> request; testing::StrictMock<MockWebServer> mock_server(1337, @@ -206,7 +202,6 @@ TEST(UrlmonUrlRequestTest, ZeroLengthResponse) { chrome_frame_test::GetTestDataFolder()); mock_server.ExpectAndServeAnyRequests(CFInvocation(CFInvocation::NONE)); - base::win::ScopedCOMInitializer init_com; CComObjectStackEx<UrlmonUrlRequest> request; request.AddRef(); |