Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(301)

Unified Diff: chrome/test/automation/proxy_launcher.cc

Issue 6794056: Revert 80472 - GTTF: Detect browser crashes on shutdown in UI tests.Previously the automation fra... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/test/automation/proxy_launcher.cc
===================================================================
--- chrome/test/automation/proxy_launcher.cc (revision 80485)
+++ chrome/test/automation/proxy_launcher.cc (working copy)
@@ -206,14 +206,13 @@
return;
}
- base::TimeTicks quit_start = base::TimeTicks::Now();
-
// There's nothing to do here if the browser is not running.
// WARNING: There is a race condition here where the browser may shut down
// after this check but before some later automation call. Your test should
// use WaitForBrowserProcessToQuit() if it intentionally
// causes the browser to shut down.
if (IsBrowserRunning()) {
+ base::TimeTicks quit_start = base::TimeTicks::Now();
EXPECT_TRUE(automation()->SetFilteredInet(false));
if (WINDOW_CLOSE == shutdown_type_) {
@@ -254,24 +253,21 @@
} else {
NOTREACHED() << "Invalid shutdown type " << shutdown_type_;
}
- }
- // Now, drop the automation IPC channel so that the automation provider in
- // the browser notices and drops its reference to the browser process.
- automation()->Disconnect();
+ // Now, drop the automation IPC channel so that the automation provider in
+ // the browser notices and drops its reference to the browser process.
+ automation()->Disconnect();
- // Wait for the browser process to quit. It should quit once all tabs have
- // been closed.
- int exit_code = -1;
- if (WaitForBrowserProcessToQuit(
- TestTimeouts::wait_for_terminate_timeout_ms(), &exit_code)) {
- EXPECT_EQ(0, exit_code); // Expect a clean shutdown.
- } else {
- // We need to force the browser to quit because it didn't quit fast
- // enough. Take no chance and kill every chrome processes.
- CleanupAppProcesses();
+ // Wait for the browser process to quit. It should quit once all tabs have
+ // been closed.
+ if (!WaitForBrowserProcessToQuit(
+ TestTimeouts::wait_for_terminate_timeout_ms())) {
+ // We need to force the browser to quit because it didn't quit fast
+ // enough. Take no chance and kill every chrome processes.
+ CleanupAppProcesses();
+ }
+ browser_quit_time_ = base::TimeTicks::Now() - quit_start;
}
- browser_quit_time_ = base::TimeTicks::Now() - quit_start;
// Don't forget to close the handle
base::CloseProcessHandle(process_);
@@ -280,9 +276,8 @@
}
void ProxyLauncher::TerminateBrowser() {
- base::TimeTicks quit_start = base::TimeTicks::Now();
-
if (IsBrowserRunning()) {
+ base::TimeTicks quit_start = base::TimeTicks::Now();
EXPECT_TRUE(automation()->SetFilteredInet(false));
#if defined(OS_WIN)
scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
@@ -297,18 +292,15 @@
#if defined(OS_POSIX)
EXPECT_EQ(kill(process_, SIGTERM), 0);
#endif // OS_POSIX
- }
- int exit_code = 0;
- if (WaitForBrowserProcessToQuit(
- TestTimeouts::wait_for_terminate_timeout_ms(), &exit_code)) {
- EXPECT_EQ(0, exit_code); // Expect a clean shutdown.
- } else {
- // We need to force the browser to quit because it didn't quit fast
- // enough. Take no chance and kill every chrome processes.
- CleanupAppProcesses();
+ if (!WaitForBrowserProcessToQuit(
+ TestTimeouts::wait_for_terminate_timeout_ms())) {
+ // We need to force the browser to quit because it didn't quit fast
+ // enough. Take no chance and kill every chrome processes.
+ CleanupAppProcesses();
+ }
+ browser_quit_time_ = base::TimeTicks::Now() - quit_start;
}
- browser_quit_time_ = base::TimeTicks::Now() - quit_start;
// Don't forget to close the handle
base::CloseProcessHandle(process_);
@@ -335,20 +327,21 @@
TerminateAllChromeProcesses(process_id_);
}
-bool ProxyLauncher::WaitForBrowserProcessToQuit(int timeout, int* exit_code) {
+bool ProxyLauncher::WaitForBrowserProcessToQuit(int timeout) {
#ifdef WAIT_FOR_DEBUGGER_ON_OPEN
timeout = 500000;
#endif
- return base::WaitForExitCodeWithTimeout(process_, exit_code, timeout);
+ return base::WaitForSingleProcess(process_, timeout);
}
bool ProxyLauncher::IsBrowserRunning() {
- // Send a simple message to the browser. If it comes back, the browser
- // must be alive.
- int window_count;
- return automation_proxy_->GetBrowserWindowCount(&window_count);
+ return CrashAwareSleep(0);
}
+bool ProxyLauncher::CrashAwareSleep(int timeout_ms) {
+ return base::CrashAwareSleep(process_, timeout_ms);
+}
+
void ProxyLauncher::PrepareTestCommandline(CommandLine* command_line,
bool include_testing_id) {
// Propagate commandline settings from test_launcher_utils.
« no previous file with comments | « chrome/test/automation/proxy_launcher.h ('k') | chrome/test/interactive_ui/fast_shutdown_interactive_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698