Chromium Code Reviews| Index: chrome_frame/test/net/fake_external_tab.cc |
| diff --git a/chrome_frame/test/net/fake_external_tab.cc b/chrome_frame/test/net/fake_external_tab.cc |
| index 5a7d3714eb49fb90f52898703272c267b0e604b1..04155266c0d2d7cdf0b193108052b7700514bc60 100644 |
| --- a/chrome_frame/test/net/fake_external_tab.cc |
| +++ b/chrome_frame/test/net/fake_external_tab.cc |
| @@ -27,8 +27,8 @@ |
| #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" |
| #include "chrome/browser/automation/automation_provider_list.h" |
| -#include "chrome/browser/browser_process_impl.h" // TODO(joi): Remove |
| #include "chrome/browser/chrome_content_browser_client.h" |
| #include "chrome/browser/prefs/browser_prefs.h" |
| #include "chrome/browser/prefs/pref_service.h" |
| @@ -49,12 +49,15 @@ |
| #include "chrome_frame/test/simulate_input.h" |
| #include "chrome_frame/test/win_event_receiver.h" |
| #include "chrome_frame/utils.h" |
| +#include "content/app/content_main.h" |
| #include "content/browser/plugin_service.h" |
| #include "content/browser/notification_service_impl.h" |
| +#include "content/public/app/startup_helper_win.h" |
| +#include "content/public/browser/browser_thread.h" |
| #include "content/public/browser/render_process_host.h" |
| #include "content/public/common/content_client.h" |
| #include "content/public/common/content_paths.h" |
| -#include "content/test/test_browser_thread.h" // TODO(joi): Remove |
| +#include "sandbox/src/sandbox_types.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| #include "ui/base/resource/resource_bundle.h" |
| #include "ui/base/ui_base_paths.h" |
| @@ -63,6 +66,13 @@ using content::BrowserThread; |
| namespace { |
| +// We must store this globally so that our main delegate can set it. |
| +static CFUrlRequestUnittestRunner* g_test_suite = NULL; |
| + |
| +// Copied here for access by CreateBrowserMainParts and InitGoogleTest. |
| +int g_argc = 0; |
| +char** g_argv = NULL; |
|
robertshield
2011/12/12 04:05:49
nit: should mark these as static
Jói
2011/12/12 14:09:02
Done.
|
| + |
| // A special command line switch to allow developers to manually launch the |
| // browser and debug CF inside the browser. |
| const char kManualBrowserLaunch[] = "manual-browser"; |
| @@ -121,7 +131,9 @@ class FakeBrowserProcessImpl : public BrowserProcessImpl { |
| profiles_dir_.CreateUniqueTempDir(); |
| } |
| - virtual ProfileManager* profile_manager() { |
| + virtual ~FakeBrowserProcessImpl() {} |
| + |
| + virtual ProfileManager* profile_manager() OVERRIDE { |
| if (!profile_manager_.get()) { |
| profile_manager_.reset( |
| new ProfileManagerWithoutInit(profiles_dir_.path())); |
| @@ -129,26 +141,177 @@ class FakeBrowserProcessImpl : public BrowserProcessImpl { |
| return profile_manager_.get(); |
| } |
| - virtual MetricsService* metrics_service() { |
| + virtual MetricsService* metrics_service() OVERRIDE { |
| return NULL; |
| } |
| + void DestroyProfileManager() { |
| + profile_manager_.reset(); |
| + } |
| + |
| private: |
| ScopedTempDir profiles_dir_; |
| scoped_ptr<ProfileManager> profile_manager_; |
| }; |
| +class FakeContentBrowserClient : public chrome::ChromeContentBrowserClient { |
| + public: |
| + virtual ~FakeContentBrowserClient() {} |
| + |
| + virtual content::BrowserMainParts* CreateBrowserMainParts( |
| + const content::MainFunctionParams& parameters) OVERRIDE; |
| +}; |
| + |
| base::LazyInstance<chrome::ChromeContentClient> |
| g_chrome_content_client = LAZY_INSTANCE_INITIALIZER; |
| // Override the default ContentBrowserClient to let Chrome participate in |
| // content logic. Must be done before any tabs are created. |
| -base::LazyInstance<chrome::ChromeContentBrowserClient> |
| +base::LazyInstance<FakeContentBrowserClient> |
| g_browser_client = LAZY_INSTANCE_INITIALIZER; |
| base::LazyInstance<chrome::ChromeContentRendererClient> |
| g_renderer_client = LAZY_INSTANCE_INITIALIZER; |
| +class FakeMainDelegate : public content::ContentMainDelegate { |
| + public: |
| + virtual ~FakeMainDelegate() {} |
| + |
| + virtual bool BasicStartupComplete(int* exit_code) OVERRIDE { |
| + return false; |
| + } |
| + |
| + virtual void PreSandboxStartup() OVERRIDE { |
| + // Initialize the content client which that code uses to talk to Chrome. |
|
robertshield
2011/12/12 04:05:49
nit: which code?
Jói
2011/12/12 14:09:02
Removed the comment, it added nothing to what you
|
| + content::SetContentClient(&g_chrome_content_client.Get()); |
| + |
| + // Override the default ContentBrowserClient to let Chrome participate in |
| + // content logic. Must be done before any tabs are created. |
| + content::GetContentClient()->set_browser(&g_browser_client.Get()); |
| + |
| + content::GetContentClient()->set_renderer(&g_renderer_client.Get()); |
| + } |
| + |
| + virtual void SandboxInitialized(const std::string& process_type) OVERRIDE {} |
| + |
| + virtual int RunProcess( |
| + const std::string& process_type, |
| + const content::MainFunctionParams& main_function_params) OVERRIDE { |
| + return -1; |
| + } |
| + virtual void ProcessExiting(const std::string& process_type) OVERRIDE {} |
| +}; |
| + |
| +void FilterDisabledTests() { |
| + if (::testing::FLAGS_gtest_filter.length() && |
| + ::testing::FLAGS_gtest_filter.Compare("*") != 0) { |
| + // Don't override user specified filters. |
| + return; |
| + } |
| + |
| + const char* disabled_tests[] = { |
| + // Tests disabled since they're testing the same functionality used |
| + // by the TestAutomationProvider. |
| + "URLRequestTest.Intercept", |
| + "URLRequestTest.InterceptNetworkError", |
| + "URLRequestTest.InterceptRestartRequired", |
| + "URLRequestTest.InterceptRespectsCancelMain", |
| + "URLRequestTest.InterceptRespectsCancelRedirect", |
| + "URLRequestTest.InterceptRespectsCancelFinal", |
| + "URLRequestTest.InterceptRespectsCancelInRestart", |
| + "URLRequestTest.InterceptRedirect", |
| + "URLRequestTest.InterceptServerError", |
| + "URLRequestTestFTP.*", |
| + |
| + // Tests that are currently not working: |
| + |
| + // Temporarily disabled because they needs user input (login dialog). |
| + "URLRequestTestHTTP.BasicAuth", |
| + "URLRequestTestHTTP.BasicAuthWithCookies", |
| + |
| + // HTTPS tests temporarily disabled due to the certificate error dialog. |
| + // TODO(tommi): The tests currently fail though, so need to fix. |
| + "HTTPSRequestTest.HTTPSMismatchedTest", |
| + "HTTPSRequestTest.HTTPSExpiredTest", |
| + "HTTPSRequestTest.ClientAuthTest", |
| + |
| + // Tests chrome's network stack's cache (might not apply to CF). |
| + "URLRequestTestHTTP.VaryHeader", |
| + "URLRequestTestHTTP.GetZippedTest", |
| + |
| + // I suspect we can only get this one to work (if at all) on IE8 and |
| + // later by using the new INTERNET_OPTION_SUPPRESS_BEHAVIOR flags |
| + // See http://msdn.microsoft.com/en-us/library/aa385328(VS.85).aspx |
| + "URLRequestTest.DoNotSaveCookies", |
| + "URLRequestTest.DelayedCookieCallback", |
| + |
| + // TODO(ananta): This test has been consistently failing. Disabling it for |
| + // now. |
| + "URLRequestTestHTTP.GetTest_NoCache", |
| + |
| + // These tests have been disabled as the Chrome cookie policies don't make |
| + // sense or have not been implemented for the host network stack. |
| + "URLRequestTest.DoNotSaveCookies_ViaPolicy", |
| + "URLRequestTest.DoNotSendCookies_ViaPolicy", |
| + "URLRequestTest.DoNotSaveCookies_ViaPolicy_Async", |
| + "URLRequestTest.CookiePolicy_ForceSession", |
| + "URLRequestTest.DoNotSendCookies", |
| + "URLRequestTest.DoNotSendCookies_ViaPolicy_Async", |
| + "URLRequestTest.CancelTest_During_OnGetCookies", |
| + "URLRequestTest.CancelTest_During_OnSetCookie", |
| + |
| + // These tests are disabled as the rely on functionality provided by |
| + // Chrome's HTTP stack like the ability to set the proxy for a URL, etc. |
| + "URLRequestTestHTTP.ProxyTunnelRedirectTest", |
| + "URLRequestTestHTTP.UnexpectedServerAuthTest", |
| + |
| + // This test is disabled as it expects an empty UA to be echoed back from |
| + // the server which is not the case in ChromeFrame. |
| + "URLRequestTestHTTP.DefaultUserAgent", |
| + // This test modifies the UploadData object after it has been marshaled to |
| + // ChromeFrame. We don't support this. |
| + "URLRequestTestHTTP.TestPostChunkedDataAfterStart", |
| + |
| + // Do not work in CF, it may well be that IE is unconditionally |
| + // adding Accept-Encoding header by default to outgoing requests. |
| + "URLRequestTestHTTP.DefaultAcceptEncoding", |
| + "URLRequestTestHTTP.OverrideAcceptEncoding", |
| + |
| + // Not supported in ChromeFrame as we use IE's network stack. |
| + "URLRequestTest.NetworkDelegateProxyError", |
| + |
| + // URLRequestAutomationJob needs to support NeedsAuth. |
| + // http://crbug.com/98446 |
| + "URLRequestTestHTTP.NetworkDelegateOnAuthRequiredSyncNoAction", |
| + "URLRequestTestHTTP.NetworkDelegateOnAuthRequiredSyncSetAuth", |
| + "URLRequestTestHTTP.NetworkDelegateOnAuthRequiredSyncCancel", |
| + "URLRequestTestHTTP.NetworkDelegateOnAuthRequiredAsyncNoAction", |
| + "URLRequestTestHTTP.NetworkDelegateOnAuthRequiredAsyncSetAuth", |
| + "URLRequestTestHTTP.NetworkDelegateOnAuthRequiredAsyncCancel", |
| + |
| + // Flaky on the tryservers, http://crbug.com/103097 |
| + "URLRequestTestHTTP.MultipleRedirectTest", |
| + "URLRequestTestHTTP.NetworkDelegateRedirectRequest", |
| + |
| + // These don't work on Joi's box with IE9, http://crbug.com/105435. |
| + // |
| + // Note that URLRequestTestHTTP.CancelTest2 and |
| + // URLRequestTestHTTP.CancelTest3 also frequently hang. |
| + "URLRequestTestHTTP.NetworkDelegateRedirectRequestPost", |
| + "URLRequestTestHTTP.GetTest", |
| + "HTTPSRequestTest.HTTPSPreloadedHSTSTest", |
| + }; |
| + |
| + std::string filter("-"); // All following filters will be negative. |
| + for (int i = 0; i < arraysize(disabled_tests); ++i) { |
| + if (i > 0) |
| + filter += ":"; |
| + filter += disabled_tests[i]; |
| + } |
| + |
| + ::testing::FLAGS_gtest_filter = filter; |
| +} |
| + |
| } // namespace |
| @@ -238,19 +401,8 @@ FakeExternalTab::~FakeExternalTab() { |
| void FakeExternalTab::Initialize() { |
| DCHECK(g_browser_process == NULL); |
| - notificaton_service_.reset(new NotificationServiceImpl); |
| - |
| - base::SystemMonitor system_monitor; |
| - |
| - icu_util::Initialize(); |
| TestTimeouts::Initialize(); |
| - // Do not call chrome::RegisterPathProvider() since it is also called by our |
| - // test runner, CFUrlRequestUnittestRunner, and calling it twice unfortunately |
| - // causes a DCHECK(). |
| - content::RegisterPathProvider(); |
| - ui::RegisterPathProvider(); |
| - |
| // Load Chrome.dll as our resource dll. |
| FilePath dll; |
| PathService::Get(base::DIR_MODULE, &dll); |
| @@ -275,15 +427,6 @@ void FakeExternalTab::Initialize() { |
| browser_process_->local_state()->RegisterBooleanPref( |
| prefs::kMetricsReportingEnabled, false); |
| - |
| - // Initialize the content client which that code uses to talk to Chrome. |
| - content::SetContentClient(&g_chrome_content_client.Get()); |
| - |
| - // Override the default ContentBrowserClient to let Chrome participate in |
| - // content logic. Must be done before any tabs are created. |
| - content::GetContentClient()->set_browser(&g_browser_client.Get()); |
| - |
| - content::GetContentClient()->set_renderer(&g_renderer_client.Get()); |
| } |
| void FakeExternalTab::InitializePostThreadsCreated() { |
| @@ -300,46 +443,14 @@ void FakeExternalTab::Shutdown() { |
| ResourceBundle::CleanupSharedInstance(); |
| } |
| -// TODO(joi): Remove! |
| -class ChromeFrameFriendOfBrowserProcessImpl { |
| - public: |
| - static void CreateIOThreadState() { |
| - reinterpret_cast<BrowserProcessImpl*>( |
| - g_browser_process)->CreateIOThreadState(); |
| - } |
| -}; |
| - |
| CFUrlRequestUnittestRunner::CFUrlRequestUnittestRunner(int argc, char** argv) |
| : NetTestSuite(argc, argv), |
| chrome_frame_html_("/chrome_frame", kChromeFrameHtml), |
| registrar_(chrome_frame_test::GetTestBedType()), |
| test_result_(0) { |
| - // Register the main thread by instantiating it, but don't call any methods. |
| - main_thread_.reset(new content::TestBrowserThread( |
| - BrowserThread::UI, MessageLoop::current())); |
| - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| - fake_chrome_.Initialize(); |
| - |
| - db_thread_.reset(new content::TestBrowserThread(BrowserThread::DB)); |
| - db_thread_->Start(); |
| - |
| - file_thread_.reset(new content::TestBrowserThread(BrowserThread::FILE)); |
| - file_thread_->Start(); |
| - |
| - ChromeFrameFriendOfBrowserProcessImpl::CreateIOThreadState(); |
| - |
| - io_thread_.reset(new content::TestBrowserThread(BrowserThread::IO)); |
| - io_thread_->StartIOThread(); |
| - |
| - fake_chrome_.InitializePostThreadsCreated(); |
| - |
| - pss_subclass_.reset(new ProcessSingletonSubclass(this)); |
| - EXPECT_TRUE(pss_subclass_->Subclass(fake_chrome_.user_data())); |
| - StartChromeFrameInHostBrowser(); |
| } |
| CFUrlRequestUnittestRunner::~CFUrlRequestUnittestRunner() { |
| - fake_chrome_.Shutdown(); |
| } |
| void CFUrlRequestUnittestRunner::StartChromeFrameInHostBrowser() { |
| @@ -382,7 +493,6 @@ void CFUrlRequestUnittestRunner::Initialize() { |
| // directly because it will attempt to initialize some things such as |
| // ICU that have already been initialized for this process. |
| CFUrlRequestUnittestRunner::InitializeLogging(); |
| - base::Time::EnableHighResolutionTimer(true); |
| SuppressErrorDialogs(); |
| base::debug::SetSuppressDebugUI(true); |
| @@ -401,7 +511,7 @@ void CFUrlRequestUnittestRunner::Shutdown() { |
| void CFUrlRequestUnittestRunner::OnConnectAutomationProviderToChannel( |
| const std::string& channel_id) { |
| Profile* profile = g_browser_process->profile_manager()-> |
| - GetDefaultProfile(fake_chrome_.user_data()); |
| + GetDefaultProfile(fake_chrome_->user_data()); |
| AutomationProviderList* list = g_browser_process->GetAutomationProviderList(); |
| DCHECK(list); |
| @@ -414,12 +524,6 @@ void CFUrlRequestUnittestRunner::OnInitialTabLoaded() { |
| StartTests(); |
| } |
| -void CFUrlRequestUnittestRunner::RunMainUIThread() { |
| - DCHECK(MessageLoop::current()); |
| - DCHECK(MessageLoop::current()->type() == MessageLoop::TYPE_UI); |
| - MessageLoop::current()->Run(); |
| -} |
| - |
| void CFUrlRequestUnittestRunner::StartTests() { |
| if (PromptAfterSetup()) |
| MessageBoxA(NULL, "click ok to run", "", MB_OK); |
| @@ -433,13 +537,12 @@ void CFUrlRequestUnittestRunner::StartTests() { |
| // static |
| DWORD CFUrlRequestUnittestRunner::RunAllUnittests(void* param) { |
| base::PlatformThread::SetName("CFUrlRequestUnittestRunner"); |
| - // Needed for some url request tests like the intercept job tests, etc. |
| - NotificationServiceImpl service; |
| CFUrlRequestUnittestRunner* me = |
| reinterpret_cast<CFUrlRequestUnittestRunner*>(param); |
| me->test_result_ = me->Run(); |
| - me->fake_chrome_.ui_loop()->PostTask(FROM_HERE, |
| - base::Bind(TakeDownBrowser, me)); |
| + BrowserThread::PostTask(BrowserThread::UI, |
| + FROM_HERE, |
| + base::Bind(TakeDownBrowser, me)); |
| return 0; |
| } |
| @@ -450,9 +553,10 @@ void CFUrlRequestUnittestRunner::TakeDownBrowser( |
| MessageBoxA(NULL, "click ok to exit", "", MB_OK); |
| me->ShutDownHostBrowser(); |
| - me->fake_chrome_.ui_loop()->PostDelayedTask(FROM_HERE, |
| - new MessageLoop::QuitTask, |
| - TestTimeouts::tiny_timeout_ms()); |
| + BrowserThread::PostDelayedTask(BrowserThread::UI, |
| + FROM_HERE, |
| + new MessageLoop::QuitTask, |
| + TestTimeouts::tiny_timeout_ms()); |
| } |
| void CFUrlRequestUnittestRunner::InitializeLogging() { |
| @@ -470,106 +574,81 @@ void CFUrlRequestUnittestRunner::InitializeLogging() { |
| logging::SetLogItems(true, true, true, true); |
| } |
| -void FilterDisabledTests() { |
| - if (::testing::FLAGS_gtest_filter.length() && |
| - ::testing::FLAGS_gtest_filter.Compare("*") != 0) { |
| - // Don't override user specified filters. |
| - return; |
| - } |
| +void CFUrlRequestUnittestRunner::PreEarlyInitialization() { |
| + testing::InitGoogleTest(&g_argc, g_argv); |
| + FilterDisabledTests(); |
| +} |
| - const char* disabled_tests[] = { |
| - // Tests disabled since they're testing the same functionality used |
| - // by the TestAutomationProvider. |
| - "URLRequestTest.Intercept", |
| - "URLRequestTest.InterceptNetworkError", |
| - "URLRequestTest.InterceptRestartRequired", |
| - "URLRequestTest.InterceptRespectsCancelMain", |
| - "URLRequestTest.InterceptRespectsCancelRedirect", |
| - "URLRequestTest.InterceptRespectsCancelFinal", |
| - "URLRequestTest.InterceptRespectsCancelInRestart", |
| - "URLRequestTest.InterceptRedirect", |
| - "URLRequestTest.InterceptServerError", |
| - "URLRequestTestFTP.*", |
| +void CFUrlRequestUnittestRunner::PreCreateThreads() { |
| + fake_chrome_.reset(new FakeExternalTab()); |
| + fake_chrome_->Initialize(); |
| - // Tests that are currently not working: |
| + pss_subclass_.reset(new ProcessSingletonSubclass(this)); |
| + EXPECT_TRUE(pss_subclass_->Subclass(fake_chrome_->user_data())); |
| + StartChromeFrameInHostBrowser(); |
| +} |
| - // Temporarily disabled because they needs user input (login dialog). |
| - "URLRequestTestHTTP.BasicAuth", |
| - "URLRequestTestHTTP.BasicAuthWithCookies", |
| +void CFUrlRequestUnittestRunner::PreStartThread(BrowserThread::ID identifier) { |
| + reinterpret_cast<FakeBrowserProcessImpl*>(g_browser_process)->PreStartThread( |
|
robertshield
2011/12/12 04:05:49
nit: why the casts here and below?
Jói
2011/12/12 14:09:02
Because g_browser_process (a variable created in t
|
| + identifier); |
| +} |
| - // HTTPS tests temporarily disabled due to the certificate error dialog. |
| - // TODO(tommi): The tests currently fail though, so need to fix. |
| - "HTTPSRequestTest.HTTPSMismatchedTest", |
| - "HTTPSRequestTest.HTTPSExpiredTest", |
| - "HTTPSRequestTest.ClientAuthTest", |
| +void CFUrlRequestUnittestRunner::PostStartThread(BrowserThread::ID identifier) { |
| + reinterpret_cast<FakeBrowserProcessImpl*>(g_browser_process)->PostStartThread( |
| + identifier); |
| +} |
| - // Tests chrome's network stack's cache (might not apply to CF). |
| - "URLRequestTestHTTP.VaryHeader", |
| - "URLRequestTestHTTP.GetZippedTest", |
| +void CFUrlRequestUnittestRunner::PreMainMessageLoopRun() { |
| + fake_chrome_->InitializePostThreadsCreated(); |
| +} |
| - // I suspect we can only get this one to work (if at all) on IE8 and |
| - // later by using the new INTERNET_OPTION_SUPPRESS_BEHAVIOR flags |
| - // See http://msdn.microsoft.com/en-us/library/aa385328(VS.85).aspx |
| - "URLRequestTest.DoNotSaveCookies", |
| - "URLRequestTest.DelayedCookieCallback", |
| +bool CFUrlRequestUnittestRunner::MainMessageLoopRun(int* result_code) { |
| + DCHECK(MessageLoop::current()); |
| + DCHECK(MessageLoop::current()->type() == MessageLoop::TYPE_UI); |
| - // TODO(ananta): This test has been consistently failing. Disabling it for |
| - // now. |
| - "URLRequestTestHTTP.GetTest_NoCache", |
| + // We need to allow IO on the main thread for these tests. |
| + base::ThreadRestrictions::SetIOAllowed(true); |
| - // These tests have been disabled as the Chrome cookie policies don't make |
| - // sense or have not been implemented for the host network stack. |
| - "URLRequestTest.DoNotSaveCookies_ViaPolicy", |
| - "URLRequestTest.DoNotSendCookies_ViaPolicy", |
| - "URLRequestTest.DoNotSaveCookies_ViaPolicy_Async", |
| - "URLRequestTest.CookiePolicy_ForceSession", |
| - "URLRequestTest.DoNotSendCookies", |
| - "URLRequestTest.DoNotSendCookies_ViaPolicy_Async", |
| - "URLRequestTest.CancelTest_During_OnGetCookies", |
| - "URLRequestTest.CancelTest_During_OnSetCookie", |
| + return false; |
| +} |
| - // These tests are disabled as the rely on functionality provided by |
| - // Chrome's HTTP stack like the ability to set the proxy for a URL, etc. |
| - "URLRequestTestHTTP.ProxyTunnelRedirectTest", |
| - "URLRequestTestHTTP.UnexpectedServerAuthTest", |
| +void CFUrlRequestUnittestRunner::PostMainMessageLoopRun() { |
| + reinterpret_cast<FakeBrowserProcessImpl*>(g_browser_process)->StartTearDown(); |
| - // This test is disabled as it expects an empty UA to be echoed back from |
| - // the server which is not the case in ChromeFrame. |
| - "URLRequestTestHTTP.DefaultUserAgent", |
| - // This test modifies the UploadData object after it has been marshaled to |
| - // ChromeFrame. We don't support this. |
| - "URLRequestTestHTTP.TestPostChunkedDataAfterStart", |
| + // Must do this separately as the mock profile_manager_ is not the |
| + // same member as BrowserProcessImpl::StartTearDown resets. |
| + reinterpret_cast<FakeBrowserProcessImpl*>( |
| + g_browser_process)->DestroyProfileManager(); |
| - // Do not work in CF, it may well be that IE is unconditionally |
| - // adding Accept-Encoding header by default to outgoing requests. |
| - "URLRequestTestHTTP.DefaultAcceptEncoding", |
| - "URLRequestTestHTTP.OverrideAcceptEncoding", |
| + if (crash_service_) |
| + base::KillProcess(crash_service_, 0, false); |
| - // Not supported in ChromeFrame as we use IE's network stack. |
| - "URLRequestTest.NetworkDelegateProxyError", |
| + base::KillProcesses(chrome_frame_test::kIEImageName, 0, NULL); |
| + base::KillProcesses(chrome_frame_test::kIEBrokerImageName, 0, NULL); |
| +} |
| - // URLRequestAutomationJob needs to support NeedsAuth. |
| - // http://crbug.com/98446 |
| - "URLRequestTestHTTP.NetworkDelegateOnAuthRequiredSyncNoAction", |
| - "URLRequestTestHTTP.NetworkDelegateOnAuthRequiredSyncSetAuth", |
| - "URLRequestTestHTTP.NetworkDelegateOnAuthRequiredSyncCancel", |
| - "URLRequestTestHTTP.NetworkDelegateOnAuthRequiredAsyncNoAction", |
| - "URLRequestTestHTTP.NetworkDelegateOnAuthRequiredAsyncSetAuth", |
| - "URLRequestTestHTTP.NetworkDelegateOnAuthRequiredAsyncCancel", |
| +void CFUrlRequestUnittestRunner::PreStopThread( |
| + content::BrowserThread::ID identifier) { |
| + reinterpret_cast<FakeBrowserProcessImpl*>(g_browser_process)->PreStopThread( |
| + identifier); |
| +} |
| - // Flaky on the tryservers, http://crbug.com/103097 |
| - "URLRequestTestHTTP.MultipleRedirectTest", |
| - "URLRequestTestHTTP.NetworkDelegateRedirectRequest", |
| - }; |
| +void CFUrlRequestUnittestRunner::PostStopThread( |
| + content::BrowserThread::ID identifier) { |
| + reinterpret_cast<FakeBrowserProcessImpl*>(g_browser_process)->PostStopThread( |
| + identifier); |
| +} |
| - std::string filter("-"); // All following filters will be negative. |
| - for (int i = 0; i < arraysize(disabled_tests); ++i) { |
| - if (i > 0) |
| - filter += ":"; |
| - filter += disabled_tests[i]; |
| - } |
| +void CFUrlRequestUnittestRunner::PostDestroyThreads() { |
| + fake_chrome_->Shutdown(); |
| + fake_chrome_.reset(); |
| - ::testing::FLAGS_gtest_filter = filter; |
| +#ifndef NDEBUG |
| + // Avoid CRT cleanup in debug test runs to ensure that webkit ASSERTs which |
| + // check if globals are created and destroyed on the same thread don't fire. |
| + // Webkit global objects are created on the inproc renderer thread. |
| + ExitProcess(test_result()); |
|
robertshield
2011/12/12 04:05:49
How much more of what is now content is being run
Jói
2011/12/12 14:09:02
I don't think a lot more code gets run than before
|
| +#endif |
| } |
| // We need a module since some of the accessibility code that gets pulled |
| @@ -608,54 +687,55 @@ const char* IEVersionToString(IEVersion version) { |
| } |
| } |
| +content::BrowserMainParts* FakeContentBrowserClient::CreateBrowserMainParts( |
| + const content::MainFunctionParams& parameters) { |
| + // We never delete this, as the content module takes ownership. |
| + // |
| + // We must not construct this earlier, or we will have out-of-order |
| + // AtExitManager creation/destruction. |
| + g_test_suite = new CFUrlRequestUnittestRunner(g_argc, g_argv); |
| + g_test_suite->set_crash_service(chrome_frame_test::StartCrashService()); |
| + return g_test_suite; |
| +} |
| + |
| int main(int argc, char** argv) { |
| - // TODO(joi): Remove the "true" part here and fix the log statement below. |
| - if (true || chrome_frame_test::GetInstalledIEVersion() >= IE_9) { |
| + g_argc = argc; |
| + g_argv = argv; |
| + |
| + if (false && chrome_frame_test::GetInstalledIEVersion() >= IE_9) { |
| // Adding this here as the command line and the logging stuff gets |
| // initialized in the NetTestSuite constructor. Did not want to break that. |
| base::AtExitManager at_exit_manager; |
| CommandLine::Init(argc, argv); |
| CFUrlRequestUnittestRunner::InitializeLogging(); |
| - LOG(INFO) << "Temporarily not running any ChromeFrame " |
| - << "net tests (http://crbug.com/105435)"; |
| + LOG(INFO) << "Not running ChromeFrame net tests on IE9+"; |
| return 0; |
| } |
| + // DO NOT SUBMIT |
| google_breakpad::scoped_ptr<google_breakpad::ExceptionHandler> breakpad( |
| InitializeCrashReporting(HEADLESS)); |
| - // TODO(tommi): Stuff be broke. Needs a fixin'. |
| - // This is awkward: the TestSuite derived CFUrlRequestUnittestRunner contains |
| - // the instance of the AtExitManager that RegisterPathProvider() and others |
| - // below require. So we have to instantiate this first. |
| - CFUrlRequestUnittestRunner test_suite(argc, argv); |
| - |
| // Display the IE version we run with. This must be done after |
| // CFUrlRequestUnittestRunner is constructed since that initializes logging. |
| IEVersion ie_version = chrome_frame_test::GetInstalledIEVersion(); |
| LOG(INFO) << "Running CF net tests with IE version: " |
| << IEVersionToString(ie_version); |
| - base::ProcessHandle crash_service = chrome_frame_test::StartCrashService(); |
| - |
| - WindowWatchdog watchdog; |
| // See url_request_unittest.cc for these credentials. |
| SupplyProxyCredentials credentials("user", "secret"); |
| + WindowWatchdog watchdog; |
| watchdog.AddObserver(&credentials, "Windows Security", ""); |
| - testing::InitGoogleTest(&argc, argv); |
| - FilterDisabledTests(); |
| - test_suite.RunMainUIThread(); |
| - if (crash_service) |
| - base::KillProcess(crash_service, 0, false); |
| - |
| - base::KillProcesses(chrome_frame_test::kIEImageName, 0, NULL); |
| - base::KillProcesses(chrome_frame_test::kIEBrokerImageName, 0, NULL); |
| - // Avoid CRT cleanup in debug test runs to ensure that webkit ASSERTs which |
| - // check if globals are created and destroyed on the same thread don't fire. |
| - // Webkit global objects are created on the inproc renderer thread. |
| -#if !defined(NDEBUG) |
| - ExitProcess(test_suite.test_result()); |
| -#endif // NDEBUG |
| - return test_suite.test_result(); |
| + sandbox::SandboxInterfaceInfo sandbox_info = {0}; |
| + // This would normally be done, but is probably not needed for these tests. |
| + //content::InitializeSandboxInfo(&sandbox_info); |
| + FakeMainDelegate delegate; |
| + content::ContentMain( |
| + reinterpret_cast<HINSTANCE>(GetModuleHandle(NULL)), |
| + &sandbox_info, |
| + &delegate); |
| + |
| + // Note: In debug builds, we ExitProcess during PostDestroyThreads. |
| + return g_test_suite->test_result(); |
| } |