summaryrefslogtreecommitdiffstats
path: root/chrome/test/automation
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-08 22:04:40 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-08 22:04:40 +0000
commite04c7eacaa5092fa740c5ac330f4b8f01755fc2d (patch)
tree1cfd82a2b49c98aa26ab83767f821726ed8ad687 /chrome/test/automation
parenta233a64c05fa151f0a9d1eff6839962d23d82b17 (diff)
downloadchromium_src-e04c7eacaa5092fa740c5ac330f4b8f01755fc2d.zip
chromium_src-e04c7eacaa5092fa740c5ac330f4b8f01755fc2d.tar.gz
chromium_src-e04c7eacaa5092fa740c5ac330f4b8f01755fc2d.tar.bz2
GTTF: Make WaitForInfoBarCount not Sleep.
Use an observer instead, to wait more reliably. BUG=none TEST=none Review URL: http://codereview.chromium.org/3344006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@58880 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/automation')
-rw-r--r--chrome/test/automation/automation_messages_internal.h6
-rw-r--r--chrome/test/automation/tab_proxy.cc18
-rw-r--r--chrome/test/automation/tab_proxy.h7
3 files changed, 16 insertions, 15 deletions
diff --git a/chrome/test/automation/automation_messages_internal.h b/chrome/test/automation/automation_messages_internal.h
index 196fe0f..2f413d7 100644
--- a/chrome/test/automation/automation_messages_internal.h
+++ b/chrome/test/automation/automation_messages_internal.h
@@ -1434,4 +1434,10 @@ IPC_BEGIN_MESSAGES(Automation)
int /* target tab count */,
bool /* success */)
+ // Waits for the infobar count to reach given number.
+ IPC_SYNC_MESSAGE_ROUTED2_1(AutomationMsg_WaitForInfoBarCount,
+ int /* tab handle */,
+ int /* target count */,
+ bool /* success */)
+
IPC_END_MESSAGES(Automation)
diff --git a/chrome/test/automation/tab_proxy.cc b/chrome/test/automation/tab_proxy.cc
index cf37561..3888c79 100644
--- a/chrome/test/automation/tab_proxy.cc
+++ b/chrome/test/automation/tab_proxy.cc
@@ -658,17 +658,13 @@ bool TabProxy::GetInfoBarCount(int* count) {
return sender_->Send(new AutomationMsg_GetInfoBarCount(0, handle_, count));
}
-bool TabProxy::WaitForInfoBarCount(int target_count, int wait_timeout) {
- int intervals = std::max(wait_timeout / automation::kSleepTime, 1);
- for (int i = 0; i < intervals; ++i) {
- PlatformThread::Sleep(automation::kSleepTime);
- int new_count = -1;
- if (!GetInfoBarCount(&new_count))
- return false;
- if (target_count == new_count)
- return true;
- }
- return false;
+bool TabProxy::WaitForInfoBarCount(int target_count) {
+ if (!is_valid())
+ return false;
+
+ bool success = false;
+ return sender_->Send(new AutomationMsg_WaitForInfoBarCount(
+ 0, handle_, target_count, &success)) && success;
}
bool TabProxy::ClickInfoBarAccept(int info_bar_index,
diff --git a/chrome/test/automation/tab_proxy.h b/chrome/test/automation/tab_proxy.h
index dd97f26..b360b84 100644
--- a/chrome/test/automation/tab_proxy.h
+++ b/chrome/test/automation/tab_proxy.h
@@ -346,10 +346,9 @@ class TabProxy : public AutomationResourceProxy,
// Retrieves the number of info-bars currently showing in |count|.
bool GetInfoBarCount(int* count) WARN_UNUSED_RESULT;
- // Waits for up to |wait_timeout| ms until the infobar count is |count|.
- // Returns false if a timeout occurred before the count matched, or an
- // error occurred retrieving the count.
- bool WaitForInfoBarCount(int count, int wait_timeout) WARN_UNUSED_RESULT;
+ // Waits until the infobar count is |count|.
+ // Returns true on success.
+ bool WaitForInfoBarCount(int count) WARN_UNUSED_RESULT;
// Causes a click on the "accept" button of the info-bar at |info_bar_index|.
// If |wait_for_navigation| is true, this call does not return until a