summaryrefslogtreecommitdiffstats
path: root/chrome/test/automation/automation_proxy.cc
diff options
context:
space:
mode:
authorjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-05 00:37:20 +0000
committerjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-05 00:37:20 +0000
commitfad84eab5e64996804824f2c7b8fce98da13b2cd (patch)
tree2fce4e91880f94c3e94687e9c0521586c37fa916 /chrome/test/automation/automation_proxy.cc
parent792e3c941a74c48db7454a945260a0e8b288ffce (diff)
downloadchromium_src-fad84eab5e64996804824f2c7b8fce98da13b2cd.zip
chromium_src-fad84eab5e64996804824f2c7b8fce98da13b2cd.tar.gz
chromium_src-fad84eab5e64996804824f2c7b8fce98da13b2cd.tar.bz2
Adding the capacity to interact with modal dialogs to the automation framework.
This change will be used by Ojan to implement some unload handler tests. TEST=Run the ui tests. Review URL: http://codereview.chromium.org/13113 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6402 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/automation/automation_proxy.cc')
-rw-r--r--chrome/test/automation/automation_proxy.cc49
1 files changed, 38 insertions, 11 deletions
diff --git a/chrome/test/automation/automation_proxy.cc b/chrome/test/automation/automation_proxy.cc
index 348ce0f..60806b5 100644
--- a/chrome/test/automation/automation_proxy.cc
+++ b/chrome/test/automation/automation_proxy.cc
@@ -15,6 +15,7 @@
#include "chrome/test/automation/browser_proxy.h"
#include "chrome/test/automation/tab_proxy.h"
#include "chrome/test/automation/window_proxy.h"
+#include "chrome/views/dialog_delegate.h"
using base::TimeDelta;
using base::TimeTicks;
@@ -302,32 +303,56 @@ bool AutomationProxy::WaitForWindowCountToBecome(int count,
return false;
}
-bool AutomationProxy::GetShowingAppModalDialog(bool* showing_app_modal_dialog) {
- if (!showing_app_modal_dialog) {
+bool AutomationProxy::GetShowingAppModalDialog(
+ bool* showing_app_modal_dialog,
+ views::DialogDelegate::DialogButton* button) {
+ if (!showing_app_modal_dialog || !button) {
NOTREACHED();
return false;
}
IPC::Message* response = NULL;
bool is_timeout = true;
- bool succeeded = SendAndWaitForResponseWithTimeout(
- new AutomationMsg_ShowingAppModalDialogRequest(0), &response,
- AutomationMsg_ShowingAppModalDialogResponse::ID,
- kMaxCommandExecutionTime, &is_timeout);
- if (!succeeded)
+ if (!SendAndWaitForResponseWithTimeout(
+ new AutomationMsg_ShowingAppModalDialogRequest(0), &response,
+ AutomationMsg_ShowingAppModalDialogResponse::ID,
+ kMaxCommandExecutionTime, &is_timeout)) {
return false;
+ }
+ scoped_ptr<IPC::Message> response_deleter(response); // Delete on exit.
if (is_timeout) {
DLOG(ERROR) << "ShowingAppModalDialog did not complete in a timely fashion";
return false;
}
void* iter = NULL;
- if (!response->ReadBool(&iter, showing_app_modal_dialog)) {
- succeeded = false;
+ int button_int = 0;
+ if (!response->ReadBool(&iter, showing_app_modal_dialog) ||
+ !response->ReadInt(&iter, &button_int))
+ return false;
+
+ *button = static_cast<views::DialogDelegate::DialogButton>(button_int);
+ return true;
+}
+
+bool AutomationProxy::ClickAppModalDialogButton(
+ views::DialogDelegate::DialogButton button) {
+ IPC::Message* response = NULL;
+ bool is_timeout = true;
+ if (!SendAndWaitForResponseWithTimeout(
+ new AutomationMsg_ClickAppModalDialogButtonRequest(0, button),
+ &response,
+ AutomationMsg_ClickAppModalDialogButtonResponse::ID,
+ kMaxCommandExecutionTime, &is_timeout)) {
+ return false;
}
- delete response;
+ bool succeeded = false;
+ void* iter = NULL;
+ if (!response->ReadBool(&iter, &succeeded))
+ return false;
+
return succeeded;
}
@@ -336,7 +361,9 @@ bool AutomationProxy::WaitForAppModalDialog(int wait_timeout) {
const TimeDelta timeout = TimeDelta::FromMilliseconds(wait_timeout);
while (TimeTicks::Now() - start < timeout) {
bool dialog_shown = false;
- bool succeeded = GetShowingAppModalDialog(&dialog_shown);
+ views::DialogDelegate::DialogButton button =
+ views::DialogDelegate::DIALOGBUTTON_NONE;
+ bool succeeded = GetShowingAppModalDialog(&dialog_shown, &button);
if (!succeeded) {
// Try again next round, but log it.
DLOG(ERROR) << "GetShowingAppModalDialog returned false";