diff options
author | erikwright@chromium.org <erikwright@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-14 05:49:25 +0000 |
---|---|---|
committer | erikwright@chromium.org <erikwright@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-14 05:49:25 +0000 |
commit | 43d2f1788969a4ad6d479c16488093f7b66825e2 (patch) | |
tree | 05854994d8540e2a5d1afebbc2566eaef99e73cd /chrome_frame | |
parent | 27ba45936a068fadbab7f631da29bed7e00f2ac4 (diff) | |
download | chromium_src-43d2f1788969a4ad6d479c16488093f7b66825e2.zip chromium_src-43d2f1788969a4ad6d479c16488093f7b66825e2.tar.gz chromium_src-43d2f1788969a4ad6d479c16488093f7b66825e2.tar.bz2 |
Don't perform or require a successful Chrome shutdown at the end of Chrome Frame Net Tests.
These tests launch Chrome in ways that differ substantially from the norm. Hence, recording and forcing the diagnosis/fixing of failures in Chrome internal code here is an unreasonably high bar.
The middle-term objective is to actually not launch Chrome here at all. This CL supports the short term objective of getting the tests on the waterfall.
BUG=None
TEST=chrome_frame_net_tests.exe
Review URL: http://codereview.chromium.org/9677042
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@126574 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame')
-rw-r--r-- | chrome_frame/test/net/fake_external_tab.cc | 44 | ||||
-rw-r--r-- | chrome_frame/test/net/fake_external_tab.h | 2 | ||||
-rw-r--r-- | chrome_frame/test/net/test_automation_provider.cc | 3 | ||||
-rw-r--r-- | chrome_frame/test/net/test_automation_provider.h | 3 |
4 files changed, 46 insertions, 6 deletions
diff --git a/chrome_frame/test/net/fake_external_tab.cc b/chrome_frame/test/net/fake_external_tab.cc index 8c3d980..dbb28b9 100644 --- a/chrome_frame/test/net/fake_external_tab.cc +++ b/chrome_frame/test/net/fake_external_tab.cc @@ -310,6 +310,12 @@ void FilterDisabledTests() { ::testing::FLAGS_gtest_filter = filter; } +void OnIEShutdownFailure() { + DLOG(ERROR) << "Failed to shutdown IE and npchrome_frame cleanly after test " + "execution."; + ::ExitProcess(1); +} + } // namespace // Same as BrowserProcessImpl, but uses custom profile manager. @@ -415,6 +421,15 @@ BOOL SupplyProxyCredentials::EnumChildren(HWND hwnd, LPARAM param) { FakeExternalTab::FakeExternalTab() { user_data_dir_ = chrome_frame_test::GetProfilePathForIE(); + + if (file_util::PathExists(user_data_dir_)) { + VLOG(1) << __FUNCTION__ << " deleting IE Profile user data directory " + << user_data_dir_.value(); + bool deleted = file_util::Delete(user_data_dir_, true); + LOG_IF(ERROR, !deleted) << "Failed to delete user data directory directory " + << user_data_dir_.value(); + } + PathService::Get(chrome::DIR_USER_DATA, &overridden_user_dir_); PathService::Override(chrome::DIR_USER_DATA, user_data_dir_); process_singleton_.reset(new ProcessSingleton(user_data_dir_)); @@ -483,7 +498,8 @@ CFUrlRequestUnittestRunner::CFUrlRequestUnittestRunner(int argc, char** argv) launch_browser_( !CommandLine::ForCurrentProcess()->HasSwitch(kManualBrowserLaunch)), prompt_after_setup_( - CommandLine::ForCurrentProcess()->HasSwitch(kPromptAfterSetup)) { + CommandLine::ForCurrentProcess()->HasSwitch(kPromptAfterSetup)), + tests_ran_(false) { } CFUrlRequestUnittestRunner::~CFUrlRequestUnittestRunner() { @@ -564,6 +580,17 @@ void CFUrlRequestUnittestRunner::OnInitialTabLoaded() { StartTests(); } +void CFUrlRequestUnittestRunner::OnProviderDestroyed() { + if (tests_ran_) { + if (crash_service_) + base::KillProcess(crash_service_, 0, false); + ::ExitProcess(test_result()); + } else { + DLOG(ERROR) << "Automation Provider shutting down before test execution " + "has completed."; + } +} + void CFUrlRequestUnittestRunner::StartTests() { if (prompt_after_setup_) MessageBoxA(NULL, "click ok to run", "", MB_OK); @@ -580,6 +607,7 @@ DWORD CFUrlRequestUnittestRunner::RunAllUnittests(void* param) { CFUrlRequestUnittestRunner* me = reinterpret_cast<CFUrlRequestUnittestRunner*>(param); me->test_result_ = me->Run(); + me->tests_ran_ = true; BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, @@ -592,11 +620,19 @@ void CFUrlRequestUnittestRunner::TakeDownBrowser() { if (prompt_after_setup_) MessageBoxA(NULL, "click ok to exit", "", MB_OK); + // AddRef to ensure that IE going away does not trigger the Chrome shutdown + // process. + // IE shutting down will, however, trigger the automation channel to shut + // down, at which time we will exit the process (see OnProviderDestroyed). + g_browser_process->AddRefModule(); ShutDownHostBrowser(); + + // In case IE is somehow hung, make sure we don't sit around until a try-bot + // kills us. OnIEShutdownFailure will log and exit with an error. BrowserThread::PostDelayedTask(BrowserThread::UI, FROM_HERE, - MessageLoop::QuitClosure(), - TestTimeouts::tiny_timeout_ms()); + base::Bind(&OnIEShutdownFailure), + TestTimeouts::action_max_timeout_ms()); } void CFUrlRequestUnittestRunner::InitializeLogging() { @@ -700,7 +736,7 @@ void CFUrlRequestUnittestRunner::PostDestroyThreads() { // 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()); + ::ExitProcess(test_result()); #endif } diff --git a/chrome_frame/test/net/fake_external_tab.h b/chrome_frame/test/net/fake_external_tab.h index 4d27295..a6d8f86 100644 --- a/chrome_frame/test/net/fake_external_tab.h +++ b/chrome_frame/test/net/fake_external_tab.h @@ -85,6 +85,7 @@ class CFUrlRequestUnittestRunner // TestAutomationProviderDelegate. virtual void OnInitialTabLoaded(); + virtual void OnProviderDestroyed(); void StartTests(); @@ -143,6 +144,7 @@ class CFUrlRequestUnittestRunner bool launch_browser_; bool prompt_after_setup_; + bool tests_ran_; DISALLOW_COPY_AND_ASSIGN(CFUrlRequestUnittestRunner); }; diff --git a/chrome_frame/test/net/test_automation_provider.cc b/chrome_frame/test/net/test_automation_provider.cc index 9884821..980b3e5 100644 --- a/chrome_frame/test/net/test_automation_provider.cc +++ b/chrome_frame/test/net/test_automation_provider.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -45,6 +45,7 @@ TestAutomationProvider::TestAutomationProvider( } TestAutomationProvider::~TestAutomationProvider() { + delegate_->OnProviderDestroyed(); g_provider_instance_ = NULL; } diff --git a/chrome_frame/test/net/test_automation_provider.h b/chrome_frame/test/net/test_automation_provider.h index 0c00d63..76c74b8 100644 --- a/chrome_frame/test/net/test_automation_provider.h +++ b/chrome_frame/test/net/test_automation_provider.h @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_FRAME_TEST_NET_TEST_AUTOMATION_PROVIDER_H_ @@ -18,6 +18,7 @@ class TestAutomationResourceMessageFilter; class TestAutomationProviderDelegate { public: virtual void OnInitialTabLoaded() = 0; + virtual void OnProviderDestroyed() = 0; }; // A slightly customized version of AutomationProvider. |