summaryrefslogtreecommitdiffstats
path: root/chrome/test
diff options
context:
space:
mode:
authorbauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-11 12:42:51 +0000
committerbauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-11 12:42:51 +0000
commit5ea92a92e9fa26334db821da688d3c46e295d19c (patch)
treeac387512f3f23544d62c11c6e95669d5ca158dff /chrome/test
parentf4db3ef5fe811ed8668a05a7be740a9bb60374ac (diff)
downloadchromium_src-5ea92a92e9fa26334db821da688d3c46e295d19c.zip
chromium_src-5ea92a92e9fa26334db821da688d3c46e295d19c.tar.gz
chromium_src-5ea92a92e9fa26334db821da688d3c46e295d19c.tar.bz2
Reland r46681: Use IPC to wait for download in DownloadTest.
Add AutomationMsg_WaitForDownloadShelfVisibilityChange and use it in UITestBase for the download tests. This should decrease flakiness of download tests. TEST=DownloadTest.*, especially DownloadTest.[Dont]CloseNewTab* BUG=43066 Review URL: http://codereview.chromium.org/2051002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@46909 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r--chrome/test/automation/automation_messages_internal.h7
-rw-r--r--chrome/test/automation/browser_proxy.cc13
-rw-r--r--chrome/test/automation/browser_proxy.h3
-rw-r--r--chrome/test/ui/ui_test.cc24
-rw-r--r--chrome/test/ui/ui_test.h17
5 files changed, 23 insertions, 41 deletions
diff --git a/chrome/test/automation/automation_messages_internal.h b/chrome/test/automation/automation_messages_internal.h
index 77f9d56..9f96c5a 100644
--- a/chrome/test/automation/automation_messages_internal.h
+++ b/chrome/test/automation/automation_messages_internal.h
@@ -1396,4 +1396,11 @@ IPC_BEGIN_MESSAGES(Automation)
IPC_SYNC_MESSAGE_ROUTED3_1(AutomationMsg_DeleteCookie, GURL, std::string,
int, bool)
+ // Waits for the download shelf to appear or disappear (depending on
+ // |visibility|) and sets |success| to true on success.
+ IPC_SYNC_MESSAGE_ROUTED2_1(AutomationMsg_WaitForDownloadShelfVisibilityChange,
+ int /* browser handle */,
+ bool /* visibility */,
+ bool /* success */)
+
IPC_END_MESSAGES(Automation)
diff --git a/chrome/test/automation/browser_proxy.cc b/chrome/test/automation/browser_proxy.cc
index 1b275d8..6456cec 100644
--- a/chrome/test/automation/browser_proxy.cc
+++ b/chrome/test/automation/browser_proxy.cc
@@ -398,6 +398,19 @@ bool BrowserProxy::SetShelfVisible(bool is_visible) {
is_visible));
}
+bool BrowserProxy::WaitForDownloadShelfVisibilityChange(bool visibility) {
+ if (!is_valid())
+ return false;
+
+ bool result = false;
+
+ if (!sender_->Send(new AutomationMsg_WaitForDownloadShelfVisibilityChange(
+ 0, handle_, visibility, &result)))
+ return false;
+
+ return result;
+}
+
bool BrowserProxy::SetIntPreference(const std::wstring& name, int value) {
if (!is_valid())
return false;
diff --git a/chrome/test/automation/browser_proxy.h b/chrome/test/automation/browser_proxy.h
index d0bb4d0..198004a 100644
--- a/chrome/test/automation/browser_proxy.h
+++ b/chrome/test/automation/browser_proxy.h
@@ -178,6 +178,9 @@ class BrowserProxy : public AutomationResourceProxy {
// Shows or hides the download shelf.
bool SetShelfVisible(bool is_visible) WARN_UNUSED_RESULT;
+ // Waits for the download shelf to appear or disappear.
+ bool WaitForDownloadShelfVisibilityChange(bool visibility) WARN_UNUSED_RESULT;
+
// Sets the int value of the specified preference.
bool SetIntPreference(const std::wstring& name, int value) WARN_UNUSED_RESULT;
diff --git a/chrome/test/ui/ui_test.cc b/chrome/test/ui/ui_test.cc
index d956478..a0e7f26 100644
--- a/chrome/test/ui/ui_test.cc
+++ b/chrome/test/ui/ui_test.cc
@@ -613,30 +613,6 @@ void UITestBase::NavigateToURLBlockUntilNavigationsComplete(
url, number_of_navigations)) << url.spec();
}
-bool UITestBase::WaitForDownloadShelfVisible(BrowserProxy* browser) {
- return WaitForDownloadShelfVisibilityChange(browser, true);
-}
-
-bool UITestBase::WaitForDownloadShelfInvisible(BrowserProxy* browser) {
- return WaitForDownloadShelfVisibilityChange(browser, false);
-}
-
-bool UITestBase::WaitForDownloadShelfVisibilityChange(BrowserProxy* browser,
- bool wait_for_open) {
- const int kCycles = 10;
- for (int i = 0; i < kCycles; i++) {
- // Give it a chance to catch up.
- PlatformThread::Sleep(sleep_timeout_ms() / kCycles);
-
- bool visible = !wait_for_open;
- if (!browser->IsShelfVisible(&visible))
- continue;
- if (visible == wait_for_open)
- return true; // Got the download shelf.
- }
- return false;
-}
-
bool UITestBase::WaitForFindWindowVisibilityChange(BrowserProxy* browser,
bool wait_for_open) {
const int kCycles = 10;
diff --git a/chrome/test/ui/ui_test.h b/chrome/test/ui/ui_test.h
index 9414808..3aadfac 100644
--- a/chrome/test/ui/ui_test.h
+++ b/chrome/test/ui/ui_test.h
@@ -191,23 +191,6 @@ class UITestBase {
// assert that the tab count is valid at the end of the wait.
void WaitUntilTabCount(int tab_count);
- // Checks whether the download shelf is visible in the current browser, giving
- // it a chance to appear (we don't know the exact timing) while finishing as
- // soon as possible.
- bool WaitForDownloadShelfVisible(BrowserProxy* browser);
-
- // Checks whether the download shelf is invisible in the current browser,
- // giving it a chance to appear (we don't know the exact timing) while
- // finishing as soon as possible.
- bool WaitForDownloadShelfInvisible(BrowserProxy* browser);
-
- private:
- // Waits for download shelf visibility or invisibility.
- bool WaitForDownloadShelfVisibilityChange(BrowserProxy* browser,
- bool wait_for_open);
-
- public:
-
// Waits until the Find window has become fully visible (if |wait_for_open| is
// true) or fully hidden (if |wait_for_open| is false). This function can time
// out (return false) if the window doesn't appear within a specific time.