diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-01 22:25:37 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-01 22:25:37 +0000 |
commit | e143c823ce66af5a83a9a17b6f5938eb16e49392 (patch) | |
tree | edfa1bec03ae2060d6301c490459db20aff2c329 /chrome | |
parent | e6588bdefbda17515f46f2b471873f6b2313fb49 (diff) | |
download | chromium_src-e143c823ce66af5a83a9a17b6f5938eb16e49392.zip chromium_src-e143c823ce66af5a83a9a17b6f5938eb16e49392.tar.gz chromium_src-e143c823ce66af5a83a9a17b6f5938eb16e49392.tar.bz2 |
Avoid an automation call which may induce flakiness in some tests.
After a change in another place this change is now safe to make.
TEST=Covered by ui_tests.
BUG=none
Review URL: http://codereview.chromium.org/173650
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25098 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/app/chrome_main_uitest.cc | 3 | ||||
-rw-r--r-- | chrome/test/automation/automation_proxy.cc | 47 | ||||
-rw-r--r-- | chrome/test/automation/automation_proxy.h | 5 |
3 files changed, 24 insertions, 31 deletions
diff --git a/chrome/app/chrome_main_uitest.cc b/chrome/app/chrome_main_uitest.cc index 0913783..48ef39e 100644 --- a/chrome/app/chrome_main_uitest.cc +++ b/chrome/app/chrome_main_uitest.cc @@ -60,6 +60,5 @@ TEST_F(ChromeMainTest, ReuseBrowserInstanceWhenOpeningFile) { ASSERT_TRUE(LaunchAnotherBrowserBlockUntilClosed(command_line)); - ASSERT_TRUE(automation()->WaitForURLDisplayed( - net::FilePathToFileURL(test_file), action_timeout_ms())); + ASSERT_TRUE(automation()->IsURLDisplayed(net::FilePathToFileURL(test_file))); } diff --git a/chrome/test/automation/automation_proxy.cc b/chrome/test/automation/automation_proxy.cc index 7a42fb8..a039ffb3 100644 --- a/chrome/test/automation/automation_proxy.cc +++ b/chrome/test/automation/automation_proxy.cc @@ -311,37 +311,32 @@ bool AutomationProxy::WaitForAppModalDialog(int wait_timeout) { return wait_success && send_success; } -bool AutomationProxy::WaitForURLDisplayed(GURL url, int wait_timeout) { - const TimeTicks start = TimeTicks::Now(); - const TimeDelta timeout = TimeDelta::FromMilliseconds(wait_timeout); - while (TimeTicks::Now() - start < timeout) { - int window_count; - if (!GetBrowserWindowCount(&window_count)) - return false; - - for (int i = 0; i < window_count; i++) { - scoped_refptr<BrowserProxy> window = GetBrowserWindow(i); - if (!window.get()) - break; +bool AutomationProxy::IsURLDisplayed(GURL url) { + int window_count; + if (!GetBrowserWindowCount(&window_count)) + return false; - int tab_count; - if (!window->GetTabCount(&tab_count)) - continue; + for (int i = 0; i < window_count; i++) { + scoped_refptr<BrowserProxy> window = GetBrowserWindow(i); + if (!window.get()) + break; - for (int j = 0; j < tab_count; j++) { - scoped_refptr<TabProxy> tab = window->GetTab(j); - if (!tab.get()) - break; + int tab_count; + if (!window->GetTabCount(&tab_count)) + continue; - GURL tab_url; - if (!tab->GetCurrentURL(&tab_url)) - continue; + for (int j = 0; j < tab_count; j++) { + scoped_refptr<TabProxy> tab = window->GetTab(j); + if (!tab.get()) + break; - if (tab_url == url) - return true; - } + GURL tab_url; + if (!tab->GetCurrentURL(&tab_url)) + continue; + + if (tab_url == url) + return true; } - PlatformThread::Sleep(automation::kSleepTime); } return false; diff --git a/chrome/test/automation/automation_proxy.h b/chrome/test/automation/automation_proxy.h index f01c5e0..dac3bc3 100644 --- a/chrome/test/automation/automation_proxy.h +++ b/chrome/test/automation/automation_proxy.h @@ -121,9 +121,8 @@ class AutomationProxy : public IPC::Channel::Listener, // success. bool WaitForAppModalDialog(int wait_timeout); - // Block the thread until one of the tabs in any window (including windows - // opened after the call) displays given url. Returns true on success. - bool WaitForURLDisplayed(GURL url, int wait_timeout); + // Returns true if one of the tabs in any window displays given url. + bool IsURLDisplayed(GURL url); // Returns the BrowserProxy for the browser window at the given index, // transferring ownership of the pointer to the caller. |