summaryrefslogtreecommitdiffstats
path: root/chrome/test
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-21 15:32:52 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-21 15:32:52 +0000
commit2949e90da94359207aad945a4c596e5ee975873b (patch)
tree5a02bc4d80bc8c36d4220e0dd66a0d540afe7d71 /chrome/test
parent0a3f254922d322db1d8537d75d15ca85cbfa9009 (diff)
downloadchromium_src-2949e90da94359207aad945a4c596e5ee975873b.zip
chromium_src-2949e90da94359207aad945a4c596e5ee975873b.tar.gz
chromium_src-2949e90da94359207aad945a4c596e5ee975873b.tar.bz2
Move some waiting from AutomationProxy to AutomationProvider.
This way it can wait properly and not poll. TEST=Covered by ui_tests. BUG=none Review URL: http://codereview.chromium.org/173158 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23959 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r--chrome/test/automation/automation_messages_internal.h15
-rw-r--r--chrome/test/automation/automation_proxy.cc42
2 files changed, 26 insertions, 31 deletions
diff --git a/chrome/test/automation/automation_messages_internal.h b/chrome/test/automation/automation_messages_internal.h
index 93ad554..52eeb41 100644
--- a/chrome/test/automation/automation_messages_internal.h
+++ b/chrome/test/automation/automation_messages_internal.h
@@ -1025,4 +1025,19 @@ IPC_BEGIN_MESSAGES(Automation)
IPC_SYNC_MESSAGE_ROUTED2_1(AutomationMsg_NavigateExternalTabAtIndex, int, int,
AutomationMsg_NavigationResponseValues)
+ // This message requests the provider to wait until the window count
+ // reached the specified value.
+ // Request:
+ // - int: target browser window count
+ // Response:
+ // - bool: whether the operation was successful.
+ IPC_SYNC_MESSAGE_ROUTED1_1(AutomationMsg_WaitForBrowserWindowCountToBecome,
+ int, bool)
+
+ // This message requests the provider to wait until an application modal
+ // dialog is shown.
+ // Response:
+ // - bool: whether the operation was successful
+ IPC_SYNC_MESSAGE_ROUTED0_1(AutomationMsg_WaitForAppModalDialogToBeShown, bool)
+
IPC_END_MESSAGES(Automation)
diff --git a/chrome/test/automation/automation_proxy.cc b/chrome/test/automation/automation_proxy.cc
index 70e4b33..7a42fb8 100644
--- a/chrome/test/automation/automation_proxy.cc
+++ b/chrome/test/automation/automation_proxy.cc
@@ -259,21 +259,12 @@ bool AutomationProxy::GetNormalBrowserWindowCount(int* num_windows) {
bool AutomationProxy::WaitForWindowCountToBecome(int count,
int wait_timeout) {
- const TimeTicks start = TimeTicks::Now();
- const TimeDelta timeout = TimeDelta::FromMilliseconds(wait_timeout);
- while (TimeTicks::Now() - start < timeout) {
- int new_count;
- bool succeeded = GetBrowserWindowCount(&new_count);
- if (!succeeded) {
- // Try again next round, but log it.
- DLOG(ERROR) << "GetBrowserWindowCount returned false";
- } else if (count == new_count) {
- return true;
- }
- PlatformThread::Sleep(automation::kSleepTime);
- }
- // Window count never reached the value we sought.
- return false;
+ bool wait_success = false;
+ bool send_success = SendWithTimeout(
+ new AutomationMsg_WaitForBrowserWindowCountToBecome(0, count,
+ &wait_success),
+ wait_timeout, NULL);
+ return wait_success && send_success;
}
bool AutomationProxy::GetShowingAppModalDialog(
@@ -313,22 +304,11 @@ bool AutomationProxy::ClickAppModalDialogButton(
}
bool AutomationProxy::WaitForAppModalDialog(int wait_timeout) {
- const TimeTicks start = TimeTicks::Now();
- const TimeDelta timeout = TimeDelta::FromMilliseconds(wait_timeout);
- while (TimeTicks::Now() - start < timeout) {
- bool dialog_shown = false;
- MessageBoxFlags::DialogButton button = MessageBoxFlags::DIALOGBUTTON_NONE;
- bool succeeded = GetShowingAppModalDialog(&dialog_shown, &button);
- if (!succeeded) {
- // Try again next round, but log it.
- DLOG(ERROR) << "GetShowingAppModalDialog returned false";
- } else if (dialog_shown) {
- return true;
- }
- PlatformThread::Sleep(automation::kSleepTime);
- }
- // Dialog never shown.
- return false;
+ bool wait_success = false;
+ bool send_success = SendWithTimeout(
+ new AutomationMsg_WaitForAppModalDialogToBeShown(0, &wait_success),
+ wait_timeout, NULL);
+ return wait_success && send_success;
}
bool AutomationProxy::WaitForURLDisplayed(GURL url, int wait_timeout) {