summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--base/process_util.h7
-rw-r--r--base/process_util_posix.cc22
-rw-r--r--base/process_util_win.cc12
-rw-r--r--chrome/browser/process_singleton_linux_uitest.cc15
-rw-r--r--chrome/browser/unload_uitest.cc35
-rw-r--r--chrome/common/service_process_util_unittest.cc3
-rw-r--r--chrome/test/automation/proxy_launcher.cc65
-rw-r--r--chrome/test/automation/proxy_launcher.h9
-rw-r--r--chrome/test/interactive_ui/fast_shutdown_interactive_uitest.cc7
-rw-r--r--chrome/test/out_of_proc_test_runner.cc2
-rw-r--r--chrome/test/ui/ui_test.cc63
-rw-r--r--chrome/test/ui/ui_test.h8
-rw-r--r--chrome_frame/test/perf/chrome_frame_perftest.cc5
13 files changed, 103 insertions, 150 deletions
diff --git a/base/process_util.h b/base/process_util.h
index b3d311e..bdf9b9e 100644
--- a/base/process_util.h
+++ b/base/process_util.h
@@ -373,10 +373,11 @@ BASE_API TerminationStatus GetTerminationStatus(ProcessHandle handle,
BASE_API bool WaitForExitCode(ProcessHandle handle, int* exit_code);
// Waits for process to exit. If it did exit within |timeout_milliseconds|,
-// then puts the exit code in |exit_code|, closes |handle|, and returns true.
+// then puts the exit code in |exit_code|, and returns true.
// In POSIX systems, if the process has been signaled then |exit_code| is set
// to -1. Returns false on failure (the caller is then responsible for closing
// |handle|).
+// The caller is always responsible for closing the |handle|.
BASE_API bool WaitForExitCodeWithTimeout(ProcessHandle handle, int* exit_code,
int64 timeout_milliseconds);
@@ -395,10 +396,6 @@ BASE_API bool WaitForProcessesToExit(
BASE_API bool WaitForSingleProcess(ProcessHandle handle,
int64 wait_milliseconds);
-// Returns true when |wait_milliseconds| have elapsed and the process
-// is still running.
-BASE_API bool CrashAwareSleep(ProcessHandle handle, int64 wait_milliseconds);
-
// Waits a certain amount of time (can be 0) for all the processes with a given
// executable name to exit, then kills off any of them that are still around.
// If filter is non-null, then only processes selected by the filter are waited
diff --git a/base/process_util_posix.cc b/base/process_util_posix.cc
index 6c7a9f6..26301d2 100644
--- a/base/process_util_posix.cc
+++ b/base/process_util_posix.cc
@@ -724,14 +724,15 @@ bool WaitForExitCodeWithTimeout(ProcessHandle handle, int* exit_code,
return false;
if (!waitpid_success)
return false;
- if (!WIFEXITED(status))
- return false;
if (WIFSIGNALED(status)) {
*exit_code = -1;
return true;
}
- *exit_code = WEXITSTATUS(status);
- return true;
+ if (WIFEXITED(status)) {
+ *exit_code = WEXITSTATUS(status);
+ return true;
+ }
+ return false;
}
#if defined(OS_MACOSX)
@@ -821,19 +822,6 @@ bool WaitForSingleProcess(ProcessHandle handle, int64 wait_milliseconds) {
}
}
-bool CrashAwareSleep(ProcessHandle handle, int64 wait_milliseconds) {
- bool waitpid_success;
- int status = WaitpidWithTimeout(handle, wait_milliseconds, &waitpid_success);
- if (status != -1) {
- DCHECK(waitpid_success);
- return !(WIFEXITED(status) || WIFSIGNALED(status));
- } else {
- // If waitpid returned with an error, then the process doesn't exist
- // (which most probably means it didn't exist before our call).
- return waitpid_success;
- }
-}
-
int64 TimeValToMicroseconds(const struct timeval& tv) {
static const int kMicrosecondsPerSecond = 1000000;
int64 ret = tv.tv_sec; // Avoid (int * int) integer overflow.
diff --git a/base/process_util_win.cc b/base/process_util_win.cc
index 895ec3b..8ade06e 100644
--- a/base/process_util_win.cc
+++ b/base/process_util_win.cc
@@ -464,8 +464,7 @@ TerminationStatus GetTerminationStatus(ProcessHandle handle, int* exit_code) {
bool WaitForExitCode(ProcessHandle handle, int* exit_code) {
bool success = WaitForExitCodeWithTimeout(handle, exit_code, INFINITE);
- if (!success)
- CloseProcessHandle(handle);
+ CloseProcessHandle(handle);
return success;
}
@@ -477,10 +476,6 @@ bool WaitForExitCodeWithTimeout(ProcessHandle handle, int* exit_code,
if (!::GetExitCodeProcess(handle, &temp_code))
return false;
- // Only close the handle on success, to give the caller a chance to forcefully
- // terminate the process if he wants to.
- CloseProcessHandle(handle);
-
*exit_code = temp_code;
return true;
}
@@ -544,11 +539,6 @@ bool WaitForSingleProcess(ProcessHandle handle, int64 wait_milliseconds) {
return retval;
}
-bool CrashAwareSleep(ProcessHandle handle, int64 wait_milliseconds) {
- bool retval = WaitForSingleObject(handle, wait_milliseconds) == WAIT_TIMEOUT;
- return retval;
-}
-
bool CleanupProcesses(const std::wstring& executable_name,
int64 wait_milliseconds,
int exit_code,
diff --git a/chrome/browser/process_singleton_linux_uitest.cc b/chrome/browser/process_singleton_linux_uitest.cc
index 6606eb0..2129ed0 100644
--- a/chrome/browser/process_singleton_linux_uitest.cc
+++ b/chrome/browser/process_singleton_linux_uitest.cc
@@ -171,7 +171,10 @@ TEST_F(ProcessSingletonLinuxTest, NotifyOtherProcessFailure) {
NotifyOtherProcess(url, TestTimeouts::action_timeout_ms()));
// Wait for a while to make sure the browser process is actually killed.
- EXPECT_FALSE(CrashAwareSleep(TestTimeouts::action_timeout_ms()));
+ int exit_code = 0;
+ ASSERT_TRUE(launcher_->WaitForBrowserProcessToQuit(
+ TestTimeouts::action_max_timeout_ms(), &exit_code));
+ EXPECT_EQ(-1, exit_code); // Expect unclean shutdown.
}
// Test that we don't kill ourselves by accident if a lockfile with the same pid
@@ -225,7 +228,10 @@ TEST_F(ProcessSingletonLinuxTest, NotifyOtherProcessDifferingHost) {
// Kill the browser process, so that it does not respond on the socket.
kill(pid, SIGKILL);
// Wait for a while to make sure the browser process is actually killed.
- EXPECT_FALSE(CrashAwareSleep(TestTimeouts::action_timeout_ms()));
+ int exit_code = 0;
+ ASSERT_TRUE(launcher_->WaitForBrowserProcessToQuit(
+ TestTimeouts::action_max_timeout_ms(), &exit_code));
+ EXPECT_EQ(-1, exit_code); // Expect unclean shutdown.
EXPECT_EQ(0, unlink(lock_path_.value().c_str()));
EXPECT_EQ(0, symlink("FAKEFOOHOST-1234", lock_path_.value().c_str()));
@@ -247,7 +253,10 @@ TEST_F(ProcessSingletonLinuxTest, NotifyOtherProcessOrCreate_DifferingHost) {
// Kill the browser process, so that it does not respond on the socket.
kill(pid, SIGKILL);
// Wait for a while to make sure the browser process is actually killed.
- EXPECT_FALSE(CrashAwareSleep(TestTimeouts::action_timeout_ms()));
+ int exit_code = 0;
+ ASSERT_TRUE(launcher_->WaitForBrowserProcessToQuit(
+ TestTimeouts::action_max_timeout_ms(), &exit_code));
+ EXPECT_EQ(-1, exit_code); // Expect unclean shutdown.
EXPECT_EQ(0, unlink(lock_path_.value().c_str()));
EXPECT_EQ(0, symlink("FAKEFOOHOST-1234", lock_path_.value().c_str()));
diff --git a/chrome/browser/unload_uitest.cc b/chrome/browser/unload_uitest.cc
index 5ae47bd..002a27d 100644
--- a/chrome/browser/unload_uitest.cc
+++ b/chrome/browser/unload_uitest.cc
@@ -103,25 +103,13 @@ class UnloadTest : public UITest {
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());
@@ -301,7 +289,11 @@ TEST_F(UnloadTest, BrowserCloseBeforeUnloadOK) {
CloseBrowserAsync(browser.get());
ClickModalDialogButton(ui::MessageBoxFlags::DIALOGBUTTON_OK);
- WaitForBrowserClosed();
+
+ int exit_code = -1;
+ ASSERT_TRUE(launcher_->WaitForBrowserProcessToQuit(
+ TestTimeouts::action_max_timeout_ms(), &exit_code));
+ EXPECT_EQ(0, exit_code); // Expect a clean shutown.
}
// Tests closing the browser with a beforeunload handler and clicking
@@ -313,14 +305,19 @@ TEST_F(UnloadTest, BrowserCloseBeforeUnloadCancel) {
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.
- CrashAwareSleep(500);
+ base::PlatformThread::Sleep(TestTimeouts::action_timeout_ms());
ASSERT_TRUE(IsBrowserRunning());
CloseBrowserAsync(browser.get());
ClickModalDialogButton(ui::MessageBoxFlags::DIALOGBUTTON_OK);
- WaitForBrowserClosed();
+
+ int exit_code = -1;
+ ASSERT_TRUE(launcher_->WaitForBrowserProcessToQuit(
+ TestTimeouts::action_max_timeout_ms(), &exit_code));
+ EXPECT_EQ(0, exit_code); // Expect a clean shutdown.
}
#if defined(OS_LINUX)
@@ -342,7 +339,11 @@ TEST_F(UnloadTest, MAYBE_BrowserCloseWithInnerFocusedFrame) {
CloseBrowserAsync(browser.get());
ClickModalDialogButton(ui::MessageBoxFlags::DIALOGBUTTON_OK);
- WaitForBrowserClosed();
+
+ int exit_code = -1;
+ ASSERT_TRUE(launcher_->WaitForBrowserProcessToQuit(
+ TestTimeouts::action_max_timeout_ms(), &exit_code));
+ EXPECT_EQ(0, exit_code); // Expect a clean shutdown.
}
// Tests closing the browser with a beforeunload handler that takes
diff --git a/chrome/common/service_process_util_unittest.cc b/chrome/common/service_process_util_unittest.cc
index 4155bda..58aea81 100644
--- a/chrome/common/service_process_util_unittest.cc
+++ b/chrome/common/service_process_util_unittest.cc
@@ -180,7 +180,8 @@ TEST_F(ServiceProcessStateTest, ForceShutdown) {
ASSERT_TRUE(ForceServiceProcessShutdown(version, pid));
int exit_code = 0;
ASSERT_TRUE(base::WaitForExitCodeWithTimeout(handle,
- &exit_code, TestTimeouts::action_timeout_ms() * 2));
+ &exit_code, TestTimeouts::action_max_timeout_ms()));
+ base::CloseProcessHandle(handle);
ASSERT_EQ(exit_code, 0);
}
diff --git a/chrome/test/automation/proxy_launcher.cc b/chrome/test/automation/proxy_launcher.cc
index 90a62b2..1928902 100644
--- a/chrome/test/automation/proxy_launcher.cc
+++ b/chrome/test/automation/proxy_launcher.cc
@@ -206,13 +206,14 @@ void ProxyLauncher::QuitBrowser() {
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_) {
@@ -253,21 +254,24 @@ void ProxyLauncher::QuitBrowser() {
} 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();
-
- // 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;
+ // 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();
}
+ browser_quit_time_ = base::TimeTicks::Now() - quit_start;
// Don't forget to close the handle
base::CloseProcessHandle(process_);
@@ -276,8 +280,9 @@ void ProxyLauncher::QuitBrowser() {
}
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));
@@ -292,15 +297,18 @@ void ProxyLauncher::TerminateBrowser() {
#if defined(OS_POSIX)
EXPECT_EQ(kill(process_, SIGTERM), 0);
#endif // OS_POSIX
+ }
- 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;
+ 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();
}
+ browser_quit_time_ = base::TimeTicks::Now() - quit_start;
// Don't forget to close the handle
base::CloseProcessHandle(process_);
@@ -327,19 +335,18 @@ void ProxyLauncher::CleanupAppProcesses() {
TerminateAllChromeProcesses(process_id_);
}
-bool ProxyLauncher::WaitForBrowserProcessToQuit(int timeout) {
+bool ProxyLauncher::WaitForBrowserProcessToQuit(int timeout, int* exit_code) {
#ifdef WAIT_FOR_DEBUGGER_ON_OPEN
timeout = 500000;
#endif
- return base::WaitForSingleProcess(process_, timeout);
+ return base::WaitForExitCodeWithTimeout(process_, exit_code, timeout);
}
bool ProxyLauncher::IsBrowserRunning() {
- return CrashAwareSleep(0);
-}
-
-bool ProxyLauncher::CrashAwareSleep(int timeout_ms) {
- return base::CrashAwareSleep(process_, timeout_ms);
+ // 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);
}
void ProxyLauncher::PrepareTestCommandline(CommandLine* command_line,
diff --git a/chrome/test/automation/proxy_launcher.h b/chrome/test/automation/proxy_launcher.h
index 642c539..505c65d 100644
--- a/chrome/test/automation/proxy_launcher.h
+++ b/chrome/test/automation/proxy_launcher.h
@@ -122,13 +122,10 @@ class ProxyLauncher {
// window or if the browser process died by itself.
bool IsBrowserRunning();
- // Returns true when timeout_ms milliseconds have elapsed.
- // Returns false if the browser process died while waiting.
- bool CrashAwareSleep(int timeout_ms);
-
// Wait for the browser process to shut down on its own (i.e. as a result of
- // some action that your test has taken).
- bool WaitForBrowserProcessToQuit(int timeout);
+ // some action that your test has taken). If it has exited within |timeout|,
+ // puts the exit code in |exit_code| and returns true.
+ bool WaitForBrowserProcessToQuit(int timeout, int* exit_code);
AutomationProxy* automation() const;
diff --git a/chrome/test/interactive_ui/fast_shutdown_interactive_uitest.cc b/chrome/test/interactive_ui/fast_shutdown_interactive_uitest.cc
index 15a0ab8..a783f3c 100644
--- a/chrome/test/interactive_ui/fast_shutdown_interactive_uitest.cc
+++ b/chrome/test/interactive_ui/fast_shutdown_interactive_uitest.cc
@@ -54,6 +54,9 @@ TEST_F(FastShutdown, MAYBE_SlowTermination) {
ASSERT_TRUE(automation()->WaitForAppModalDialog());
ASSERT_TRUE(automation()->ClickAppModalDialogButton(
ui::MessageBoxFlags::DIALOGBUTTON_OK));
- ASSERT_TRUE(WaitForBrowserProcessToQuit(
- TestTimeouts::wait_for_terminate_timeout_ms()));
+
+ int exit_code = -1;
+ ASSERT_TRUE(launcher_->WaitForBrowserProcessToQuit(
+ TestTimeouts::wait_for_terminate_timeout_ms(), &exit_code));
+ EXPECT_EQ(0, exit_code); // Expect a clean shutdown.
}
diff --git a/chrome/test/out_of_proc_test_runner.cc b/chrome/test/out_of_proc_test_runner.cc
index db5e54c..6e4bc3b 100644
--- a/chrome/test/out_of_proc_test_runner.cc
+++ b/chrome/test/out_of_proc_test_runner.cc
@@ -401,6 +401,8 @@ int RunTest(const std::string& test_name, int default_timeout_ms) {
}
#endif
+ base::CloseProcessHandle(process_handle);
+
return exit_code;
}
diff --git a/chrome/test/ui/ui_test.cc b/chrome/test/ui/ui_test.cc
index 2e47340..95378d7 100644
--- a/chrome/test/ui/ui_test.cc
+++ b/chrome/test/ui/ui_test.cc
@@ -297,10 +297,6 @@ void UITestBase::NavigateToURLBlockUntilNavigationsComplete(
url, number_of_navigations)) << url.spec();
}
-bool UITestBase::WaitForBrowserProcessToQuit(int timeout) {
- return launcher_->WaitForBrowserProcessToQuit(timeout);
-}
-
bool UITestBase::WaitForBookmarkBarVisibilityChange(BrowserProxy* browser,
bool wait_for_open) {
const int kCycles = 10;
@@ -313,11 +309,7 @@ bool UITestBase::WaitForBookmarkBarVisibilityChange(BrowserProxy* browser,
return true; // Bookmark bar visibility change complete.
// Give it a chance to catch up.
- bool browser_survived = CrashAwareSleep(
- TestTimeouts::action_timeout_ms() / kCycles);
- EXPECT_TRUE(browser_survived);
- if (!browser_survived)
- return false;
+ base::PlatformThread::Sleep(TestTimeouts::action_timeout_ms() / kCycles);
}
ADD_FAILURE() << "Timeout reached in WaitForBookmarkBarVisibilityChange";
@@ -365,10 +357,6 @@ bool UITestBase::IsBrowserRunning() {
return launcher_->IsBrowserRunning();
}
-bool UITestBase::CrashAwareSleep(int timeout_ms) {
- return launcher_->CrashAwareSleep(timeout_ms);
-}
-
int UITestBase::GetTabCount() {
return GetTabCount(0);
}
@@ -391,12 +379,10 @@ void UITestBase::WaitUntilTabCount(int tab_count) {
const int kIntervalMs = TestTimeouts::action_timeout_ms() / kMaxIntervals;
for (int i = 0; i < kMaxIntervals; ++i) {
- bool browser_survived = CrashAwareSleep(kIntervalMs);
- EXPECT_TRUE(browser_survived);
- if (!browser_survived)
- return;
if (GetTabCount() == tab_count)
return;
+
+ base::PlatformThread::Sleep(kIntervalMs);
}
ADD_FAILURE() << "Timeout reached in WaitUntilTabCount";
@@ -727,11 +713,6 @@ bool UITest::WaitUntilJavaScriptCondition(TabProxy* tab,
// Wait until the test signals it has completed.
for (int i = 0; i < kMaxIntervals; ++i) {
- bool browser_survived = CrashAwareSleep(kIntervalMs);
- EXPECT_TRUE(browser_survived);
- if (!browser_survived)
- return false;
-
bool done_value = false;
bool success = tab->ExecuteAndExtractBool(frame_xpath, jscript,
&done_value);
@@ -740,6 +721,8 @@ bool UITest::WaitUntilJavaScriptCondition(TabProxy* tab,
return false;
if (done_value)
return true;
+
+ base::PlatformThread::Sleep(kIntervalMs);
}
ADD_FAILURE() << "Timeout reached in WaitUntilJavaScriptCondition";
@@ -756,14 +739,11 @@ bool UITest::WaitUntilCookieValue(TabProxy* tab,
std::string cookie_value;
for (int i = 0; i < kMaxIntervals; ++i) {
- bool browser_survived = CrashAwareSleep(kIntervalMs);
- EXPECT_TRUE(browser_survived);
- if (!browser_survived)
- return false;
-
EXPECT_TRUE(tab->GetCookieByName(url, cookie_name, &cookie_value));
if (cookie_value == expected_value)
return true;
+
+ base::PlatformThread::Sleep(kIntervalMs);
}
ADD_FAILURE() << "Timeout reached in WaitUntilCookieValue";
@@ -778,15 +758,12 @@ std::string UITest::WaitUntilCookieNonEmpty(TabProxy* tab,
const int kMaxIntervals = timeout_ms / kIntervalMs;
for (int i = 0; i < kMaxIntervals; ++i) {
- bool browser_survived = CrashAwareSleep(kIntervalMs);
- EXPECT_TRUE(browser_survived);
- if (!browser_survived)
- return std::string();
-
std::string cookie_value;
EXPECT_TRUE(tab->GetCookieByName(url, cookie_name, &cookie_value));
if (!cookie_value.empty())
return cookie_value;
+
+ base::PlatformThread::Sleep(kIntervalMs);
}
ADD_FAILURE() << "Timeout reached in WaitUntilCookieNonEmpty";
@@ -812,11 +789,7 @@ bool UITest::WaitForFindWindowVisibilityChange(BrowserProxy* browser,
return true; // Find window visibility change complete.
// Give it a chance to catch up.
- bool browser_survived = CrashAwareSleep(
- TestTimeouts::action_timeout_ms() / kCycles);
- EXPECT_TRUE(browser_survived);
- if (!browser_survived)
- return false;
+ base::PlatformThread::Sleep(TestTimeouts::action_timeout_ms() / kCycles);
}
ADD_FAILURE() << "Timeout reached in WaitForFindWindowVisibilityChange";
@@ -840,19 +813,6 @@ bool UITest::WaitForDownloadShelfVisibilityChange(BrowserProxy* browser,
int incorrect_state_count = 0;
base::Time start = base::Time::Now();
for (int i = 0; i < kCycles; i++) {
- // Give it a chance to catch up.
- bool browser_survived = CrashAwareSleep(
- TestTimeouts::action_timeout_ms() / kCycles);
- EXPECT_TRUE(browser_survived);
- if (!browser_survived) {
- LOG(INFO) << "Elapsed time: " << (base::Time::Now() - start).InSecondsF()
- << " seconds"
- << " call failed " << fail_count << " times"
- << " state was incorrect " << incorrect_state_count << " times";
- ADD_FAILURE() << "Browser failed in " << __FUNCTION__;
- return false;
- }
-
bool visible = !wait_for_open;
if (!browser->IsShelfVisible(&visible)) {
fail_count++;
@@ -866,6 +826,9 @@ bool UITest::WaitForDownloadShelfVisibilityChange(BrowserProxy* browser,
return true; // Got the download shelf.
}
incorrect_state_count++;
+
+ // Give it a chance to catch up.
+ base::PlatformThread::Sleep(TestTimeouts::action_timeout_ms() / kCycles);
}
LOG(INFO) << "Elapsed time: " << (base::Time::Now() - start).InSecondsF()
diff --git a/chrome/test/ui/ui_test.h b/chrome/test/ui/ui_test.h
index f446c6a..5ec4039 100644
--- a/chrome/test/ui/ui_test.h
+++ b/chrome/test/ui/ui_test.h
@@ -139,10 +139,6 @@ class UITestBase {
// window or if the browser process died by itself.
bool IsBrowserRunning();
- // Returns true when timeout_ms milliseconds have elapsed.
- // Returns false if the browser process died while waiting.
- bool CrashAwareSleep(int timeout_ms);
-
// Returns the number of tabs in the first window. If no windows exist,
// causes a test failure and returns 0.
int GetTabCount();
@@ -154,10 +150,6 @@ class UITestBase {
// assert that the tab count is valid at the end of the wait.
void WaitUntilTabCount(int tab_count);
- // Wait for the browser process to shut down on its own (i.e. as a result of
- // some action that your test has taken).
- bool WaitForBrowserProcessToQuit(int timeout);
-
// Waits until the Bookmark bar has stopped animating and become fully visible
// (if |wait_for_open| is true) or fully hidden (if |wait_for_open| is false).
// This function can time out (in which case it returns false).
diff --git a/chrome_frame/test/perf/chrome_frame_perftest.cc b/chrome_frame/test/perf/chrome_frame_perftest.cc
index 4320bff..dac9605 100644
--- a/chrome_frame/test/perf/chrome_frame_perftest.cc
+++ b/chrome_frame/test/perf/chrome_frame_perftest.cc
@@ -1358,7 +1358,8 @@ void PrintResultList(const std::string& measurement,
bool RunSingleTestOutOfProc(const std::string& test_name) {
FilePath path;
- PathService::Get(base::DIR_EXE, &path);
+ if (!PathService::Get(base::DIR_EXE, &path))
+ return false;
path = path.Append(L"chrome_frame_tests.exe");
CommandLine cmd_line(path);
@@ -1384,6 +1385,8 @@ bool RunSingleTestOutOfProc(const std::string& test_name) {
base::KillProcess(process_handle, -1, true);
}
+ base::CloseProcessHandle(process_handle);
+
return exit_code == 0;
}