Index: chrome/browser/unload_uitest.cc |
=================================================================== |
--- chrome/browser/unload_uitest.cc (revision 80485) |
+++ chrome/browser/unload_uitest.cc (working copy) |
@@ -103,13 +103,25 @@ |
UITest::SetUp(); |
} |
+ void WaitForBrowserClosed() { |
+ const int kCheckDelayMs = 100; |
+ for (int max_wait_time = TestTimeouts::action_max_timeout_ms(); |
+ max_wait_time > 0; max_wait_time -= kCheckDelayMs) { |
+ CrashAwareSleep(kCheckDelayMs); |
+ if (!IsBrowserRunning()) |
+ break; |
+ } |
+ |
+ EXPECT_FALSE(IsBrowserRunning()); |
+ } |
+ |
void CheckTitle(const std::wstring& expected_title) { |
const int kCheckDelayMs = 100; |
for (int max_wait_time = TestTimeouts::action_max_timeout_ms(); |
max_wait_time > 0; max_wait_time -= kCheckDelayMs) { |
+ CrashAwareSleep(kCheckDelayMs); |
if (expected_title == GetActiveTabTitle()) |
break; |
- base::PlatformThread::Sleep(kCheckDelayMs); |
} |
EXPECT_EQ(expected_title, GetActiveTabTitle()); |
@@ -289,11 +301,7 @@ |
CloseBrowserAsync(browser.get()); |
ClickModalDialogButton(ui::MessageBoxFlags::DIALOGBUTTON_OK); |
- |
- int exit_code = -1; |
- ASSERT_TRUE(launcher_->WaitForBrowserProcessToQuit( |
- TestTimeouts::action_max_timeout_ms(), &exit_code)); |
- EXPECT_EQ(0, exit_code); // Expect a clean shutown. |
+ WaitForBrowserClosed(); |
} |
// Tests closing the browser with a beforeunload handler and clicking |
@@ -305,19 +313,14 @@ |
CloseBrowserAsync(browser.get()); |
ClickModalDialogButton(ui::MessageBoxFlags::DIALOGBUTTON_CANCEL); |
- |
// There's no real graceful way to wait for something _not_ to happen, so |
// we just wait a short period. |
- base::PlatformThread::Sleep(TestTimeouts::action_timeout_ms()); |
+ CrashAwareSleep(500); |
ASSERT_TRUE(IsBrowserRunning()); |
CloseBrowserAsync(browser.get()); |
ClickModalDialogButton(ui::MessageBoxFlags::DIALOGBUTTON_OK); |
- |
- int exit_code = -1; |
- ASSERT_TRUE(launcher_->WaitForBrowserProcessToQuit( |
- TestTimeouts::action_max_timeout_ms(), &exit_code)); |
- EXPECT_EQ(0, exit_code); // Expect a clean shutdown. |
+ WaitForBrowserClosed(); |
} |
#if defined(OS_LINUX) |
@@ -339,11 +342,7 @@ |
CloseBrowserAsync(browser.get()); |
ClickModalDialogButton(ui::MessageBoxFlags::DIALOGBUTTON_OK); |
- |
- int exit_code = -1; |
- ASSERT_TRUE(launcher_->WaitForBrowserProcessToQuit( |
- TestTimeouts::action_max_timeout_ms(), &exit_code)); |
- EXPECT_EQ(0, exit_code); // Expect a clean shutdown. |
+ WaitForBrowserClosed(); |
} |
// Tests closing the browser with a beforeunload handler that takes |