summaryrefslogtreecommitdiffstats
path: root/chrome/test/automation
diff options
context:
space:
mode:
authortc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-21 22:17:33 +0000
committertc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-21 22:17:33 +0000
commit806aeb954d302328cc75bda71331474d8634675b (patch)
tree9565300c48ab1ea34b66624222ef979734f68b00 /chrome/test/automation
parent8f0a23470f47090c601078952b77c5b520c595c2 (diff)
downloadchromium_src-806aeb954d302328cc75bda71331474d8634675b.zip
chromium_src-806aeb954d302328cc75bda71331474d8634675b.tar.gz
chromium_src-806aeb954d302328cc75bda71331474d8634675b.tar.bz2
Refactor DialogDelegate so the DialogButton enum is in cross platform
code. This is mostly a find & replace in our code to use the new location of the enum. I also deleted some GetDialogButtons methods in child classes because they were identical to the parent version in DialogDelegate. This will allow more code to be enabled on linux/mac in the automation provider. Review URL: http://codereview.chromium.org/88008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14146 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/automation')
-rw-r--r--chrome/test/automation/automation_proxy.cc14
-rw-r--r--chrome/test/automation/automation_proxy.h14
-rw-r--r--chrome/test/automation/automation_proxy_uitest.cc23
3 files changed, 19 insertions, 32 deletions
diff --git a/chrome/test/automation/automation_proxy.cc b/chrome/test/automation/automation_proxy.cc
index 5715aac..fac5001 100644
--- a/chrome/test/automation/automation_proxy.cc
+++ b/chrome/test/automation/automation_proxy.cc
@@ -318,11 +318,9 @@ bool AutomationProxy::WaitForWindowCountToBecome(int count,
return false;
}
-#if defined(OS_WIN)
-// TODO(port): Port when DialogDelegate is ported.
bool AutomationProxy::GetShowingAppModalDialog(
bool* showing_app_modal_dialog,
- views::DialogDelegate::DialogButton* button) {
+ MessageBox::DialogButton* button) {
if (!showing_app_modal_dialog || !button) {
NOTREACHED();
return false;
@@ -338,12 +336,12 @@ bool AutomationProxy::GetShowingAppModalDialog(
return false;
}
- *button = static_cast<views::DialogDelegate::DialogButton>(button_int);
+ *button = static_cast<MessageBox::DialogButton>(button_int);
return true;
}
bool AutomationProxy::ClickAppModalDialogButton(
- views::DialogDelegate::DialogButton button) {
+ MessageBox::DialogButton button) {
bool succeeded = false;
if (!SendWithTimeout(
@@ -361,8 +359,7 @@ bool AutomationProxy::WaitForAppModalDialog(int wait_timeout) {
const TimeDelta timeout = TimeDelta::FromMilliseconds(wait_timeout);
while (TimeTicks::Now() - start < timeout) {
bool dialog_shown = false;
- views::DialogDelegate::DialogButton button =
- views::DialogDelegate::DIALOGBUTTON_NONE;
+ MessageBox::DialogButton button = MessageBox::DIALOGBUTTON_NONE;
bool succeeded = GetShowingAppModalDialog(&dialog_shown, &button);
if (!succeeded) {
// Try again next round, but log it.
@@ -370,12 +367,11 @@ bool AutomationProxy::WaitForAppModalDialog(int wait_timeout) {
} else if (dialog_shown) {
return true;
}
- Sleep(automation::kSleepTime);
+ PlatformThread::Sleep(automation::kSleepTime);
}
// Dialog never shown.
return false;
}
-#endif // defined(OS_WIN)
bool AutomationProxy::WaitForURLDisplayed(GURL url, int wait_timeout) {
const TimeTicks start = TimeTicks::Now();
diff --git a/chrome/test/automation/automation_proxy.h b/chrome/test/automation/automation_proxy.h
index e9d55d1..9b052a8 100644
--- a/chrome/test/automation/automation_proxy.h
+++ b/chrome/test/automation/automation_proxy.h
@@ -16,14 +16,10 @@
#include "chrome/common/ipc_channel_proxy.h"
#include "chrome/common/ipc_message.h"
#include "chrome/common/ipc_sync_channel.h"
+#include "chrome/common/message_box_flags.h"
#include "chrome/test/automation/automation_handle_tracker.h"
#include "chrome/test/automation/automation_messages.h"
-#if defined(OS_WIN)
-// TODO(port): Enable this or equivalent.
-#include "chrome/views/window/dialog_delegate.h"
-#endif
-
class AutomationRequest;
class BrowserProxy;
class TabProxy;
@@ -98,17 +94,13 @@ class AutomationProxy : public IPC::Channel::Listener,
// Returns true on success.
bool WaitForWindowCountToBecome(int target_count, int wait_timeout);
-#if defined(OS_WIN)
- // TODO(port): Enable when we have portable DialogDelegate.
-
// Returns whether an app modal dialog window is showing right now (i.e., a
// javascript alert), and what buttons it contains.
bool GetShowingAppModalDialog(bool* showing_app_modal_dialog,
- views::DialogDelegate::DialogButton* button);
+ MessageBox::DialogButton* button);
// Simulates a click on a dialog button.
- bool ClickAppModalDialogButton(views::DialogDelegate::DialogButton button);
-#endif // defined(OS_WIN)
+ bool ClickAppModalDialogButton(MessageBox::DialogButton button);
// Block the thread until a modal dialog is displayed. Returns true on
// success.
diff --git a/chrome/test/automation/automation_proxy_uitest.cc b/chrome/test/automation/automation_proxy_uitest.cc
index 464fa81..bd5495a 100644
--- a/chrome/test/automation/automation_proxy_uitest.cc
+++ b/chrome/test/automation/automation_proxy_uitest.cc
@@ -1005,12 +1005,11 @@ TEST_F(AutomationProxyTest, DISABLED_AppModalDialogTest) {
ASSERT_TRUE(tab.get());
bool modal_dialog_showing = false;
- views::DialogDelegate::DialogButton button =
- views::DialogDelegate::DIALOGBUTTON_NONE;
+ MessageBox::DialogButton button = MessageBox::DIALOGBUTTON_NONE;
EXPECT_TRUE(automation()->GetShowingAppModalDialog(&modal_dialog_showing,
&button));
EXPECT_FALSE(modal_dialog_showing);
- EXPECT_EQ(views::DialogDelegate::DIALOGBUTTON_NONE, button);
+ EXPECT_EQ(MessageBox::DIALOGBUTTON_NONE, button);
// Show a simple alert.
std::string content =
@@ -1022,19 +1021,19 @@ TEST_F(AutomationProxyTest, DISABLED_AppModalDialogTest) {
EXPECT_TRUE(automation()->GetShowingAppModalDialog(&modal_dialog_showing,
&button));
EXPECT_TRUE(modal_dialog_showing);
- EXPECT_EQ(views::DialogDelegate::DIALOGBUTTON_OK, button);
+ EXPECT_EQ(MessageBox::DIALOGBUTTON_OK, button);
// Test that clicking missing button fails graciously and does not close the
// dialog.
EXPECT_FALSE(automation()->ClickAppModalDialogButton(
- views::DialogDelegate::DIALOGBUTTON_CANCEL));
+ MessageBox::DIALOGBUTTON_CANCEL));
EXPECT_TRUE(automation()->GetShowingAppModalDialog(&modal_dialog_showing,
&button));
EXPECT_TRUE(modal_dialog_showing);
// Now click OK, that should close the dialog.
EXPECT_TRUE(automation()->ClickAppModalDialogButton(
- views::DialogDelegate::DIALOGBUTTON_OK));
+ MessageBox::DIALOGBUTTON_OK));
EXPECT_TRUE(automation()->GetShowingAppModalDialog(&modal_dialog_showing,
&button));
EXPECT_FALSE(modal_dialog_showing);
@@ -1049,12 +1048,12 @@ TEST_F(AutomationProxyTest, DISABLED_AppModalDialogTest) {
EXPECT_TRUE(automation()->GetShowingAppModalDialog(&modal_dialog_showing,
&button));
EXPECT_TRUE(modal_dialog_showing);
- EXPECT_EQ(views::DialogDelegate::DIALOGBUTTON_OK |
- views::DialogDelegate::DIALOGBUTTON_CANCEL, button);
+ EXPECT_EQ(MessageBox::DIALOGBUTTON_OK |
+ MessageBox::DIALOGBUTTON_CANCEL, button);
// Click OK.
EXPECT_TRUE(automation()->ClickAppModalDialogButton(
- views::DialogDelegate::DIALOGBUTTON_OK));
+ MessageBox::DIALOGBUTTON_OK));
EXPECT_TRUE(automation()->GetShowingAppModalDialog(&modal_dialog_showing,
&button));
EXPECT_FALSE(modal_dialog_showing);
@@ -1069,12 +1068,12 @@ TEST_F(AutomationProxyTest, DISABLED_AppModalDialogTest) {
EXPECT_TRUE(automation()->GetShowingAppModalDialog(&modal_dialog_showing,
&button));
EXPECT_TRUE(modal_dialog_showing);
- EXPECT_EQ(views::DialogDelegate::DIALOGBUTTON_OK |
- views::DialogDelegate::DIALOGBUTTON_CANCEL, button);
+ EXPECT_EQ(MessageBox::DIALOGBUTTON_OK |
+ MessageBox::DIALOGBUTTON_CANCEL, button);
// Click Cancel this time.
EXPECT_TRUE(automation()->ClickAppModalDialogButton(
- views::DialogDelegate::DIALOGBUTTON_CANCEL));
+ MessageBox::DIALOGBUTTON_CANCEL));
EXPECT_TRUE(automation()->GetShowingAppModalDialog(&modal_dialog_showing,
&button));
EXPECT_FALSE(modal_dialog_showing);