diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-09 16:50:23 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-09 16:50:23 +0000 |
commit | dedf2055a80cf9d869767bbd0c99f51e4f31260e (patch) | |
tree | 4ff02b6ef242a467d4db73c92ed1afec9a3fdabe /chrome/test/automation | |
parent | 1ef1c66a37fae2707f743c3588f88e893125b82f (diff) | |
download | chromium_src-dedf2055a80cf9d869767bbd0c99f51e4f31260e.zip chromium_src-dedf2055a80cf9d869767bbd0c99f51e4f31260e.tar.gz chromium_src-dedf2055a80cf9d869767bbd0c99f51e4f31260e.tar.bz2 |
Add regression test for bug 7900 and necessary infrastructure.
The test simulates following scenario: user opens a local html page with Chrome when a browser instance is already running. The new Chrome process should notify the existing process about new page and exit. Bug 7900 broke this behavior causing the new process to crash.
I verified that the ui_tests infrastructure would catch this crash and cause the test to fail.
BUG=7900, 8056
Review URL: http://codereview.chromium.org/39257
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11247 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/automation')
-rw-r--r-- | chrome/test/automation/automation_proxy.cc | 36 | ||||
-rw-r--r-- | chrome/test/automation/automation_proxy.h | 4 |
2 files changed, 40 insertions, 0 deletions
diff --git a/chrome/test/automation/automation_proxy.cc b/chrome/test/automation/automation_proxy.cc index 73bb91d..aec886b 100644 --- a/chrome/test/automation/automation_proxy.cc +++ b/chrome/test/automation/automation_proxy.cc @@ -343,6 +343,42 @@ bool AutomationProxy::WaitForAppModalDialog(int wait_timeout) { } #endif // defined(OS_WIN) +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++) { + BrowserProxy* window = GetBrowserWindow(i); + if (!window) + break; + + int tab_count; + if (!window->GetTabCount(&tab_count)) + continue; + + for (int j = 0; j < tab_count; j++) { + TabProxy* tab = window->GetTab(j); + if (!tab) + break; + + GURL tab_url; + if (!tab->GetCurrentURL(&tab_url)) + continue; + + if (tab_url == url) + return true; + } + } + PlatformThread::Sleep(automation::kSleepTime); + } + + return false; +} + bool AutomationProxy::SetFilteredInet(bool enabled) { return Send(new AutomationMsg_SetFilteredInet(0, enabled)); } diff --git a/chrome/test/automation/automation_proxy.h b/chrome/test/automation/automation_proxy.h index ff74db3..fa2d33f 100644 --- a/chrome/test/automation/automation_proxy.h +++ b/chrome/test/automation/automation_proxy.h @@ -119,6 +119,10 @@ 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 the BrowserProxy for the browser window at the given index, // transferring ownership of the pointer to the caller. // On failure, returns NULL. |