diff options
author | stuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-07 22:31:47 +0000 |
---|---|---|
committer | stuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-07 22:31:47 +0000 |
commit | 5c943180e410b2a4e76f93e1612985cdab407e8c (patch) | |
tree | 6aef67f089f4ecbd73fbdac524f7627ecfb6b6a2 /chrome/test/ui/ui_test.cc | |
parent | 23512f4ba83ab011aac513972290aa30b26785cd (diff) | |
download | chromium_src-5c943180e410b2a4e76f93e1612985cdab407e8c.zip chromium_src-5c943180e410b2a4e76f93e1612985cdab407e8c.tar.gz chromium_src-5c943180e410b2a4e76f93e1612985cdab407e8c.tar.bz2 |
Sprinkle some defensiveness into the UI tests so that they don't explode if the proxy doesn't respond (e.g., due to a timeout).
BUG=none
TEST=Hopefully the Mac valgrind bots will more reliably run all their tests (although there are likely more issues like this lurking).
Review URL: http://codereview.chromium.org/149281
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20096 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/ui/ui_test.cc')
-rw-r--r-- | chrome/test/ui/ui_test.cc | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/chrome/test/ui/ui_test.cc b/chrome/test/ui/ui_test.cc index a9e4567..2295781 100644 --- a/chrome/test/ui/ui_test.cc +++ b/chrome/test/ui/ui_test.cc @@ -546,9 +546,12 @@ void UITest::CleanupAppProcesses() { scoped_refptr<TabProxy> UITest::GetActiveTab(int window_index) { EXPECT_GE(window_index, 0); - int window_count; - // Use EXPECT rather than ASSERT here because ASSERT_* returns void. + int window_count = -1; + // We have to use EXPECT rather than ASSERT here because ASSERT_* only works + // in functions that return void. EXPECT_TRUE(automation()->GetBrowserWindowCount(&window_count)); + if (window_count == -1) + return NULL; EXPECT_GT(window_count, window_index); scoped_refptr<BrowserProxy> window_proxy(automation()-> GetBrowserWindow(window_index)); @@ -895,12 +898,14 @@ void UITest::WaitForFinish(const std::string &name, cookie_name.append(test_complete_cookie); scoped_refptr<TabProxy> tab(GetActiveTab()); - - bool test_result = WaitUntilCookieValue(tab.get(), url, - cookie_name.c_str(), - kIntervalMilliSeconds, wait_time, - expected_cookie_value.c_str()); - EXPECT_EQ(true, test_result); + EXPECT_TRUE(tab.get()); + if (tab.get()) { + bool test_result = WaitUntilCookieValue(tab.get(), url, + cookie_name.c_str(), + kIntervalMilliSeconds, wait_time, + expected_cookie_value.c_str()); + EXPECT_EQ(true, test_result); + } } void UITest::PrintResult(const std::string& measurement, |