diff options
author | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-05 00:37:20 +0000 |
---|---|---|
committer | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-05 00:37:20 +0000 |
commit | fad84eab5e64996804824f2c7b8fce98da13b2cd (patch) | |
tree | 2fce4e91880f94c3e94687e9c0521586c37fa916 /chrome/browser/automation | |
parent | 792e3c941a74c48db7454a945260a0e8b288ffce (diff) | |
download | chromium_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/browser/automation')
-rw-r--r-- | chrome/browser/automation/automation_provider.cc | 37 | ||||
-rw-r--r-- | chrome/browser/automation/automation_provider.h | 2 |
2 files changed, 37 insertions, 2 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index 146883b..c1d4a15 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -30,6 +30,8 @@ #include "chrome/common/chrome_paths.h" #include "chrome/common/pref_service.h" #include "chrome/test/automation/automation_messages.h" +#include "chrome/views/app_modal_dialog_delegate.h" +#include "chrome/views/window.h" #include "net/base/cookie_monster.h" #include "net/url_request/url_request_filter.h" @@ -811,6 +813,8 @@ void AutomationProvider::OnMessageReceived(const IPC::Message& message) { SetIntPreference) IPC_MESSAGE_HANDLER(AutomationMsg_ShowingAppModalDialogRequest, GetShowingAppModalDialog) + IPC_MESSAGE_HANDLER(AutomationMsg_ClickAppModalDialogButtonRequest, + ClickAppModalDialogButton) IPC_END_MESSAGE_MAP() } @@ -1074,9 +1078,38 @@ void AutomationProvider::GetBrowserWindowCount(const IPC::Message& message) { } void AutomationProvider::GetShowingAppModalDialog(const IPC::Message& message) { + views::AppModalDialogDelegate* dialog_delegate = + BrowserList::GetShowingAppModalDialog(); Send(new AutomationMsg_ShowingAppModalDialogResponse( - message.routing_id(), - static_cast<bool>(BrowserList::IsShowingAppModalDialog()))); + message.routing_id(), dialog_delegate != NULL, + dialog_delegate ? dialog_delegate->GetDialogButtons() : + views::DialogDelegate::DIALOGBUTTON_NONE)); +} + +void AutomationProvider::ClickAppModalDialogButton(const IPC::Message& message, + int button) { + bool success = false; + + views::AppModalDialogDelegate* dialog_delegate = + BrowserList::GetShowingAppModalDialog(); + if (dialog_delegate && + (dialog_delegate->GetDialogButtons() & button) == button) { + views::DialogClientView* client_view = + dialog_delegate->window()->client_view()->AsDialogClientView(); + if ((button & views::DialogDelegate::DIALOGBUTTON_OK) == + views::DialogDelegate::DIALOGBUTTON_OK) { + client_view->AcceptWindow(); + success = true; + } + if ((button & views::DialogDelegate::DIALOGBUTTON_CANCEL) == + views::DialogDelegate::DIALOGBUTTON_CANCEL) { + DCHECK(!success) << "invalid param, OK and CANCEL specified"; + client_view->CancelWindow(); + success = true; + } + } + Send(new AutomationMsg_ClickAppModalDialogButtonResponse( + message.routing_id(), success)); } void AutomationProvider::GetBrowserWindow(const IPC::Message& message, diff --git a/chrome/browser/automation/automation_provider.h b/chrome/browser/automation/automation_provider.h index 401e0b5..b0e21d3 100644 --- a/chrome/browser/automation/automation_provider.h +++ b/chrome/browser/automation/automation_provider.h @@ -106,6 +106,8 @@ class AutomationProvider : public base::RefCounted<AutomationProvider>, int handle); void GetBrowserWindowCount(const IPC::Message& message); void GetShowingAppModalDialog(const IPC::Message& message); + void ClickAppModalDialogButton(const IPC::Message& message, + int button); void GetBrowserWindow(const IPC::Message& message, int index); void GetLastActiveBrowserWindow(const IPC::Message& message); void GetActiveWindow(const IPC::Message& message); |