summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorhuanr@chromium.org <huanr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-08 23:12:10 +0000
committerhuanr@chromium.org <huanr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-08 23:12:10 +0000
commit11592b698eb4de8e9874e746f796fe6cd8a56bf6 (patch)
tree221148e91d2961d58cccb88e1d16dcd42329849c /chrome
parent04ca1bc65afb76ea30698c25f24599d20119e3d2 (diff)
downloadchromium_src-11592b698eb4de8e9874e746f796fe6cd8a56bf6.zip
chromium_src-11592b698eb4de8e9874e746f796fe6cd8a56bf6.tar.gz
chromium_src-11592b698eb4de8e9874e746f796fe6cd8a56bf6.tar.bz2
Retry r15294. The previous check in exposed bug 11659
and caused a crash spike in ChromeBot. Original change description: Close browser window synchronously during UI test tear down. This is an effor to reduce random failure due to browser crash with multiple window open during shutdown. Review URL: http://codereview.chromium.org/113171 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15693 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/test/ui/ui_test.cc24
-rw-r--r--chrome/test/ui/ui_test.h8
2 files changed, 26 insertions, 6 deletions
diff --git a/chrome/test/ui/ui_test.cc b/chrome/test/ui/ui_test.cc
index 62ba163..4a594c1 100644
--- a/chrome/test/ui/ui_test.cc
+++ b/chrome/test/ui/ui_test.cc
@@ -407,9 +407,12 @@ void UITest::QuitBrowser() {
for (BrowserVector::iterator iter = browsers.begin();
iter != browsers.end(); ++iter) {
- // Use ApplyAccelerator since it doesn't wait
- (*iter)->ApplyAccelerator(IDC_CLOSE_WINDOW);
+ bool application_closed = false;
+ CloseBrowserWithTimeout(*iter, &application_closed,
+ action_timeout_ms(), NULL);
delete (*iter);
+ if (application_closed)
+ break;
}
// Now, drop the automation IPC channel so that the automation provider in
@@ -737,22 +740,31 @@ void UITest::CloseBrowserAsync(BrowserProxy* browser) const {
bool UITest::CloseBrowser(BrowserProxy* browser,
bool* application_closed) const {
+ return CloseBrowserWithTimeout(browser, application_closed,
+ base::kNoTimeout, NULL);
+}
+
+bool UITest::CloseBrowserWithTimeout(BrowserProxy* browser,
+ bool* application_closed,
+ int timeout_ms,
+ bool* is_timeout) const {
DCHECK(application_closed);
if (!browser->is_valid() || !browser->handle())
return false;
bool result = true;
- bool succeeded = server_->Send(new AutomationMsg_CloseBrowser(
- 0, browser->handle(), &result, application_closed));
+ bool succeeded = server_->SendWithTimeout(
+ new AutomationMsg_CloseBrowser(
+ 0, browser->handle(), &result, application_closed),
+ timeout_ms, is_timeout);
if (!succeeded)
return false;
if (*application_closed) {
// Let's wait until the process dies (if it is not gone already).
- bool success = base::WaitForSingleProcess(process_, base::kNoTimeout);
- DCHECK(success);
+ result = base::WaitForSingleProcess(process_, timeout_ms);
}
return result;
diff --git a/chrome/test/ui/ui_test.h b/chrome/test/ui/ui_test.h
index 543f1fd..1196760 100644
--- a/chrome/test/ui/ui_test.h
+++ b/chrome/test/ui/ui_test.h
@@ -201,6 +201,14 @@ class UITest : public testing::Test {
// after the browser process has terminated.
bool CloseBrowser(BrowserProxy* browser, bool* application_closed) const;
+ // Closes the specified browser. Returns true if the browser was closed.
+ // If this was the last browser window, |application_closed| is set to true
+ // and the function returns after the browser process has terminated.
+ // This call blocks on closing until specified timeout_ms is reached. If
+ // timed out, it returns false with is_timeout set to true.
+ bool CloseBrowserWithTimeout(BrowserProxy* browser, bool* application_closed,
+ int timeout_ms, bool* is_timeout) const;
+
// Prints numerical information to stdout in a controlled format, for
// post-processing. |measurement| is a description of the quantity being
// measured, e.g. "vm_peak"; |modifier| is provided as a convenience and