summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzori@chromium.org <zori@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-14 00:31:17 +0000
committerzori@chromium.org <zori@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-14 00:31:17 +0000
commit4ad6c3a7125f38123ad525861215f098599e12e5 (patch)
tree9ae3f66a949925444779476d79070c69135bd863
parent64a82a5b9bf3ca133cef8963645416ff3ff4c05b (diff)
downloadchromium_src-4ad6c3a7125f38123ad525861215f098599e12e5.zip
chromium_src-4ad6c3a7125f38123ad525861215f098599e12e5.tar.gz
chromium_src-4ad6c3a7125f38123ad525861215f098599e12e5.tar.bz2
Support maximize window command.
BUG=chromedriver:65 TEST= Review URL: https://chromiumcodereview.appspot.com/10388251 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@142038 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/automation/automation_provider_observers.cc27
-rw-r--r--chrome/browser/automation/automation_provider_observers.h172
-rw-r--r--chrome/browser/automation/testing_automation_provider.cc33
-rw-r--r--chrome/browser/automation/testing_automation_provider.h8
-rw-r--r--chrome/browser/ui/gtk/browser_window_gtk.cc7
-rw-r--r--chrome/common/chrome_notification_types.h8
-rw-r--r--chrome/test/automation/automation_json_requests.cc12
-rw-r--r--chrome/test/automation/automation_json_requests.h6
-rw-r--r--chrome/test/webdriver/commands/window_commands.cc29
-rw-r--r--chrome/test/webdriver/commands/window_commands.h14
-rw-r--r--chrome/test/webdriver/test/chromedriver_tests.py79
-rw-r--r--chrome/test/webdriver/webdriver_automation.cc18
-rw-r--r--chrome/test/webdriver/webdriver_automation.h4
-rw-r--r--chrome/test/webdriver/webdriver_server.cc2
-rw-r--r--chrome/test/webdriver/webdriver_session.cc12
-rw-r--r--chrome/test/webdriver/webdriver_session.h5
16 files changed, 343 insertions, 93 deletions
diff --git a/chrome/browser/automation/automation_provider_observers.cc b/chrome/browser/automation/automation_provider_observers.cc
index aaca274..cf18d7b 100644
--- a/chrome/browser/automation/automation_provider_observers.cc
+++ b/chrome/browser/automation/automation_provider_observers.cc
@@ -3022,3 +3022,30 @@ void ExtensionPopupObserver::Observe(
delete this;
}
}
+
+#if defined(OS_LINUX)
+WindowMaximizedObserver::WindowMaximizedObserver(
+ AutomationProvider* automation,
+ IPC::Message* reply_message)
+ : automation_(automation->AsWeakPtr()),
+ reply_message_(reply_message) {
+ registrar_.Add(this, chrome::NOTIFICATION_BROWSER_WINDOW_MAXIMIZED,
+ content::NotificationService::AllSources());
+}
+
+WindowMaximizedObserver::~WindowMaximizedObserver() {}
+
+void WindowMaximizedObserver::Observe(
+ int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) {
+ DCHECK_EQ(chrome::NOTIFICATION_BROWSER_WINDOW_MAXIMIZED, type);
+
+ if (automation_) {
+ AutomationJSONReply(automation_, reply_message_.release())
+ .SendSuccess(NULL);
+ }
+ delete this;
+}
+#endif // defined(OS_LINUX)
+
diff --git a/chrome/browser/automation/automation_provider_observers.h b/chrome/browser/automation/automation_provider_observers.h
index 8be03fd..12d80f2 100644
--- a/chrome/browser/automation/automation_provider_observers.h
+++ b/chrome/browser/automation/automation_provider_observers.h
@@ -106,9 +106,10 @@ class InitialLoadObserver : public content::NotificationObserver {
InitialLoadObserver(size_t tab_count, AutomationProvider* automation);
virtual ~InitialLoadObserver();
+ // Overridden from content::NotificationObserver:
virtual void Observe(int type,
const content::NotificationSource& source,
- const content::NotificationDetails& details);
+ const content::NotificationDetails& details) OVERRIDE;
// Caller owns the return value and is responsible for deleting it.
// Example return value:
@@ -161,9 +162,11 @@ class NetworkManagerInitObserver
class OOBEWebuiReadyObserver : public content::NotificationObserver {
public:
explicit OOBEWebuiReadyObserver(AutomationProvider* automation);
+
+ // Overridden from content::NotificationObserver:
virtual void Observe(int type,
const content::NotificationSource& source,
- const content::NotificationDetails& details);
+ const content::NotificationDetails& details) OVERRIDE;
private:
void OOBEWebuiReady();
@@ -182,9 +185,10 @@ class NewTabUILoadObserver : public content::NotificationObserver {
Profile* profile);
virtual ~NewTabUILoadObserver();
+ // Overridden from content::NotificationObserver:
virtual void Observe(int type,
const content::NotificationSource& source,
- const content::NotificationDetails& details);
+ const content::NotificationDetails& details) OVERRIDE;
private:
content::NotificationRegistrar registrar_;
@@ -202,9 +206,10 @@ class NavigationControllerRestoredObserver
IPC::Message* reply_message);
virtual ~NavigationControllerRestoredObserver();
+ // Overridden from content::NotificationObserver:
virtual void Observe(int type,
const content::NotificationSource& source,
- const content::NotificationDetails& details);
+ const content::NotificationDetails& details) OVERRIDE;
private:
bool FinishedRestoring();
@@ -228,9 +233,10 @@ class NavigationNotificationObserver : public content::NotificationObserver {
bool use_json_interface);
virtual ~NavigationNotificationObserver();
+ // Overridden from content::NotificationObserver:
virtual void Observe(int type,
const content::NotificationSource& source,
- const content::NotificationDetails& details);
+ const content::NotificationDetails& details) OVERRIDE;
void ConditionMet(AutomationMsg_NavigationResponseValues navigation_result);
@@ -252,9 +258,10 @@ class TabStripNotificationObserver : public content::NotificationObserver {
AutomationProvider* automation);
virtual ~TabStripNotificationObserver();
+ // Overridden from content::NotificationObserver:
virtual void Observe(int type,
const content::NotificationSource& source,
- const content::NotificationDetails& details);
+ const content::NotificationDetails& details) OVERRIDE;
virtual void ObserveTab(content::NavigationController* controller) = 0;
@@ -339,10 +346,10 @@ class ExtensionUninstallObserver : public content::NotificationObserver {
const std::string& id);
virtual ~ExtensionUninstallObserver();
- // Implementation of content::NotificationObserver.
+ // Overridden from content::NotificationObserver:
virtual void Observe(int type,
const content::NotificationSource& source,
- const content::NotificationDetails& details);
+ const content::NotificationDetails& details) OVERRIDE;
private:
content::NotificationRegistrar registrar_;
@@ -365,10 +372,10 @@ class ExtensionReadyNotificationObserver
IPC::Message* reply_message);
virtual ~ExtensionReadyNotificationObserver();
- // Implementation of NotificationObserver.
+ // Overridden from content::NotificationObserver:
virtual void Observe(int type,
const content::NotificationSource& source,
- const content::NotificationDetails& details);
+ const content::NotificationDetails& details) OVERRIDE;
private:
void Init();
@@ -389,10 +396,10 @@ class ExtensionUnloadNotificationObserver
ExtensionUnloadNotificationObserver();
virtual ~ExtensionUnloadNotificationObserver();
- // Implementation of NotificationObserver.
+ // Overridden from content::NotificationObserver:
virtual void Observe(int type,
const content::NotificationSource& source,
- const content::NotificationDetails& details);
+ const content::NotificationDetails& details) OVERRIDE;
bool did_receive_unload_notification() {
return did_receive_unload_notification_;
@@ -416,10 +423,10 @@ class ExtensionsUpdatedObserver : public content::NotificationObserver {
IPC::Message* reply_message);
virtual ~ExtensionsUpdatedObserver();
- // Implementation of NotificationObserver.
+ // Overridden from content::NotificationObserver:
virtual void Observe(int type,
const content::NotificationSource& source,
- const content::NotificationDetails& details);
+ const content::NotificationDetails& details) OVERRIDE;
private:
content::NotificationRegistrar registrar_;
@@ -440,9 +447,10 @@ class BrowserOpenedNotificationObserver : public content::NotificationObserver {
IPC::Message* reply_message);
virtual ~BrowserOpenedNotificationObserver();
+ // Overridden from content::NotificationObserver:
virtual void Observe(int type,
const content::NotificationSource& source,
- const content::NotificationDetails& details);
+ const content::NotificationDetails& details) OVERRIDE;
void set_for_browser_command(bool for_browser_command);
@@ -463,9 +471,10 @@ class BrowserClosedNotificationObserver : public content::NotificationObserver {
IPC::Message* reply_message);
virtual ~BrowserClosedNotificationObserver();
+ // Overridden from content::NotificationObserver:
virtual void Observe(int type,
const content::NotificationSource& source,
- const content::NotificationDetails& details);
+ const content::NotificationDetails& details) OVERRIDE;
void set_for_browser_command(bool for_browser_command);
@@ -486,9 +495,10 @@ class BrowserCountChangeNotificationObserver
IPC::Message* reply_message);
virtual ~BrowserCountChangeNotificationObserver();
+ // Overridden from content::NotificationObserver:
virtual void Observe(int type,
const content::NotificationSource& source,
- const content::NotificationDetails& details);
+ const content::NotificationDetails& details) OVERRIDE;
private:
int target_count_;
@@ -508,9 +518,10 @@ class ExecuteBrowserCommandObserver : public content::NotificationObserver {
int command,
IPC::Message* reply_message);
+ // Overridden from content::NotificationObserver:
virtual void Observe(int type,
const content::NotificationSource& source,
- const content::NotificationDetails& details);
+ const content::NotificationDetails& details) OVERRIDE;
private:
ExecuteBrowserCommandObserver(AutomationProvider* automation,
@@ -536,9 +547,10 @@ class FindInPageNotificationObserver : public content::NotificationObserver {
IPC::Message* reply_message);
virtual ~FindInPageNotificationObserver();
+ // Overridden from content::NotificationObserver:
virtual void Observe(int type,
const content::NotificationSource& source,
- const content::NotificationDetails& details);
+ const content::NotificationDetails& details) OVERRIDE;
// The Find mechanism is over asynchronous IPC, so a search is kicked off and
// we wait for notification to find out what the results are. As the user is
@@ -567,6 +579,7 @@ class DomOperationObserver : public content::NotificationObserver {
explicit DomOperationObserver(int automation_id);
virtual ~DomOperationObserver();
+ // Overridden from content::NotificationObserver:
virtual void Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE;
@@ -612,9 +625,10 @@ class MetricEventDurationObserver : public content::NotificationObserver {
// Get the duration of an event. Returns -1 if we haven't seen the event.
int GetEventDurationMs(const std::string& event_name);
- // NotificationObserver interface.
- virtual void Observe(int type, const content::NotificationSource& source,
- const content::NotificationDetails& details);
+ // Overridden from content::NotificationObserver:
+ virtual void Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) OVERRIDE;
private:
content::NotificationRegistrar registrar_;
@@ -632,10 +646,10 @@ class PageTranslatedObserver : public content::NotificationObserver {
content::WebContents* web_contents);
virtual ~PageTranslatedObserver();
- // content::NotificationObserver interface.
+ // Overridden from content::NotificationObserver:
virtual void Observe(int type,
const content::NotificationSource& source,
- const content::NotificationDetails& details);
+ const content::NotificationDetails& details) OVERRIDE;
private:
content::NotificationRegistrar registrar_;
@@ -653,10 +667,10 @@ class TabLanguageDeterminedObserver : public content::NotificationObserver {
TranslateInfoBarDelegate* translate_bar);
virtual ~TabLanguageDeterminedObserver();
- // content::NotificationObserver interface.
+ // Overridden from content::NotificationObserver:
virtual void Observe(int type,
const content::NotificationSource& source,
- const content::NotificationDetails& details);
+ const content::NotificationDetails& details) OVERRIDE;
private:
content::NotificationRegistrar registrar_;
@@ -676,10 +690,10 @@ class InfoBarCountObserver : public content::NotificationObserver {
size_t target_count);
virtual ~InfoBarCountObserver();
- // content::NotificationObserver interface.
+ // Overridden from content::NotificationObserver:
virtual void Observe(int type,
const content::NotificationSource& source,
- const content::NotificationDetails& details);
+ const content::NotificationDetails& details) OVERRIDE;
private:
// Checks whether the infobar count matches our target, and if so
@@ -769,9 +783,10 @@ class ScreenLockUnlockObserver : public content::NotificationObserver {
bool lock_screen);
virtual ~ScreenLockUnlockObserver();
- // content::NotificationObserver interface.
- virtual void Observe(int type, const content::NotificationSource& source,
- const content::NotificationDetails& details);
+ // Overridden from content::NotificationObserver:
+ virtual void Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) OVERRIDE;
protected:
base::WeakPtr<AutomationProvider> automation_;
@@ -1221,10 +1236,10 @@ class PasswordStoreLoginsChangedObserver
// Schedules a task on the DB thread to register the appropriate observers.
virtual void Init();
- // content::NotificationObserver interface.
+ // Overridden from content::NotificationObserver:
virtual void Observe(int type,
const content::NotificationSource& source,
- const content::NotificationDetails& details);
+ const content::NotificationDetails& details) OVERRIDE;
private:
friend struct content::BrowserThread::DeleteOnThread<
@@ -1280,9 +1295,10 @@ class OmniboxAcceptNotificationObserver : public content::NotificationObserver {
IPC::Message* reply_message);
virtual ~OmniboxAcceptNotificationObserver();
+ // Overridden from content::NotificationObserver:
virtual void Observe(int type,
const content::NotificationSource& source,
- const content::NotificationDetails& details);
+ const content::NotificationDetails& details) OVERRIDE;
private:
content::NotificationRegistrar registrar_;
@@ -1301,9 +1317,10 @@ class SavePackageNotificationObserver : public content::NotificationObserver {
IPC::Message* reply_message);
virtual ~SavePackageNotificationObserver();
+ // Overridden from content::NotificationObserver:
virtual void Observe(int type,
const content::NotificationSource& source,
- const content::NotificationDetails& details);
+ const content::NotificationDetails& details) OVERRIDE;
private:
content::NotificationRegistrar registrar_;
@@ -1327,15 +1344,16 @@ class PageSnapshotTaker : public TabEventObserver,
void Start();
private:
- // TabEventObserver overrides.
+ // Overridden from TabEventObserver:
virtual void OnSnapshotEntirePageACK(
bool success,
const std::vector<unsigned char>& png_data,
const std::string& error_msg) OVERRIDE;
- // NotificationObserver overrides.
+
+ // Overridden from content::NotificationObserver:
virtual void Observe(int type,
const content::NotificationSource& source,
- const content::NotificationDetails& details);
+ const content::NotificationDetails& details) OVERRIDE;
// Helper method to send a response back to the client. Deletes this.
void SendMessage(bool success, const std::string& error_msg);
@@ -1375,11 +1393,11 @@ class AutomationMouseEventProcessor : public content::RenderViewHostObserver,
bool success,
const std::string& error_msg);
- // RenderViewHostObserver overrides.
+ // Overriden from RenderViewHostObserver.
virtual void RenderViewHostDestroyed(content::RenderViewHost* host) OVERRIDE;
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
- // NotificationObserver overrides.
+ // Overridden from content::NotificationObserver:
virtual void Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE;
@@ -1404,9 +1422,10 @@ class NTPInfoObserver : public content::NotificationObserver {
CancelableRequestConsumer* consumer);
virtual ~NTPInfoObserver();
+ // Overridden from content::NotificationObserver:
virtual void Observe(int type,
const content::NotificationSource& source,
- const content::NotificationDetails& details);
+ const content::NotificationDetails& details) OVERRIDE;
private:
void OnTopSitesLoaded();
@@ -1433,9 +1452,10 @@ class AppLaunchObserver : public content::NotificationObserver {
extension_misc::LaunchContainer launch_container);
virtual ~AppLaunchObserver();
+ // Overridden from content::NotificationObserver:
virtual void Observe(int type,
const content::NotificationSource& source,
- const content::NotificationDetails& details);
+ const content::NotificationDetails& details) OVERRIDE;
private:
content::NavigationController* controller_;
@@ -1461,10 +1481,10 @@ class AutofillDisplayedObserver : public content::NotificationObserver {
IPC::Message* reply_message);
virtual ~AutofillDisplayedObserver();
- // content::NotificationObserver interface.
+ // Overridden from content::NotificationObserver:
virtual void Observe(int type,
const content::NotificationSource& source,
- const content::NotificationDetails& details);
+ const content::NotificationDetails& details) OVERRIDE;
private:
int notification_;
@@ -1493,10 +1513,10 @@ class AutofillChangedObserver
// Schedules a task on the DB thread to register the appropriate observers.
virtual void Init();
- // content::NotificationObserver interface.
+ // Overridden from content::NotificationObserver:
virtual void Observe(int type,
const content::NotificationSource& source,
- const content::NotificationDetails& details);
+ const content::NotificationDetails& details) OVERRIDE;
private:
friend struct content::BrowserThread::DeleteOnThread<
@@ -1541,10 +1561,10 @@ class AutofillFormSubmittedObserver
virtual void OnPersonalDataChanged() OVERRIDE;
virtual void OnInsufficientFormData() OVERRIDE;
- // content::NotificationObserver interface.
+ // Overridden from content::NotificationObserver:
virtual void Observe(int type,
const content::NotificationSource& source,
- const content::NotificationDetails& details);
+ const content::NotificationDetails& details) OVERRIDE;
private:
content::NotificationRegistrar registrar_;
@@ -1562,9 +1582,10 @@ class GetAllNotificationsObserver : public content::NotificationObserver {
IPC::Message* reply_message);
virtual ~GetAllNotificationsObserver();
+ // Overridden from content::NotificationObserver:
virtual void Observe(int type,
const content::NotificationSource& source,
- const content::NotificationDetails& details);
+ const content::NotificationDetails& details) OVERRIDE;
private:
// Sends a message via the |AutomationProvider|. |automation_| must be valid.
@@ -1587,9 +1608,11 @@ class NewNotificationBalloonObserver : public content::NotificationObserver {
NewNotificationBalloonObserver(AutomationProvider* provider,
IPC::Message* reply_message);
virtual ~NewNotificationBalloonObserver();
+
+ // Overridden from content::NotificationObserver:
virtual void Observe(int type,
const content::NotificationSource& source,
- const content::NotificationDetails& details);
+ const content::NotificationDetails& details) OVERRIDE;
private:
content::NotificationRegistrar registrar_;
@@ -1614,9 +1637,10 @@ class OnNotificationBalloonCountObserver
// message is sent or if |automation_| is invalid.
void CheckBalloonCount();
+ // Overridden from content::NotificationObserver:
virtual void Observe(int type,
const content::NotificationSource& source,
- const content::NotificationDetails& details);
+ const content::NotificationDetails& details) OVERRIDE;
private:
content::NotificationRegistrar registrar_;
@@ -1637,9 +1661,10 @@ class RendererProcessClosedObserver : public content::NotificationObserver {
IPC::Message* reply_message);
virtual ~RendererProcessClosedObserver();
+ // Overridden from content::NotificationObserver:
virtual void Observe(int type,
const content::NotificationSource& source,
- const content::NotificationDetails& details);
+ const content::NotificationDetails& details) OVERRIDE;
private:
content::NotificationRegistrar registrar_;
@@ -1658,9 +1683,10 @@ class InputEventAckNotificationObserver : public content::NotificationObserver {
int event_type, int count);
virtual ~InputEventAckNotificationObserver();
+ // Overridden from content::NotificationObserver:
virtual void Observe(int type,
const content::NotificationSource& source,
- const content::NotificationDetails& details);
+ const content::NotificationDetails& details) OVERRIDE;
private:
content::NotificationRegistrar registrar_;
@@ -1690,7 +1716,7 @@ class AllViewsStoppedLoadingObserver : public TabEventObserver,
virtual void OnNoMorePendingLoads(
content::WebContents* web_contents) OVERRIDE;
- // content::NotificationObserver implementation.
+ // Overridden from content::NotificationObserver:
virtual void Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE;
@@ -1716,6 +1742,7 @@ class NewTabObserver : public content::NotificationObserver {
public:
NewTabObserver(AutomationProvider* automation, IPC::Message* reply_message);
+ // Overridden from content::NotificationObserver:
virtual void Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE;
@@ -1775,9 +1802,10 @@ class DragTargetDropAckNotificationObserver
IPC::Message* reply_message);
virtual ~DragTargetDropAckNotificationObserver();
+ // Overridden from content::NotificationObserver:
virtual void Observe(int type,
const content::NotificationSource& source,
- const content::NotificationDetails& details);
+ const content::NotificationDetails& details) OVERRIDE;
private:
content::NotificationRegistrar registrar_;
@@ -1812,9 +1840,10 @@ class V8HeapStatsObserver : public content::NotificationObserver {
base::ProcessId renderer_id);
virtual ~V8HeapStatsObserver();
+ // Overridden from content::NotificationObserver:
virtual void Observe(int type,
const content::NotificationSource& source,
- const content::NotificationDetails& details);
+ const content::NotificationDetails& details) OVERRIDE;
private:
content::NotificationRegistrar registrar_;
@@ -1834,9 +1863,10 @@ class FPSObserver : public content::NotificationObserver {
int routing_id);
virtual ~FPSObserver();
+ // Overridden from content::NotificationObserver:
virtual void Observe(int type,
const content::NotificationSource& source,
- const content::NotificationDetails& details);
+ const content::NotificationDetails& details) OVERRIDE;
private:
content::NotificationRegistrar registrar_;
@@ -1863,9 +1893,10 @@ class BrowserOpenedWithNewProfileNotificationObserver
IPC::Message* reply_message);
virtual ~BrowserOpenedWithNewProfileNotificationObserver();
+ // Overridden from content::NotificationObserver:
virtual void Observe(int type,
const content::NotificationSource& source,
- const content::NotificationDetails& details);
+ const content::NotificationDetails& details) OVERRIDE;
private:
content::NotificationRegistrar registrar_;
@@ -1885,6 +1916,7 @@ class ExtensionPopupObserver : public content::NotificationObserver {
const std::string& extension_id);
~ExtensionPopupObserver();
+ // Overridden from content::NotificationObserver:
virtual void Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE;
@@ -1898,4 +1930,28 @@ class ExtensionPopupObserver : public content::NotificationObserver {
DISALLOW_COPY_AND_ASSIGN(ExtensionPopupObserver);
};
+#if defined(OS_LINUX)
+// Allows the automation provider to wait for a WINDOW_MAXIMIZED notification.
+class WindowMaximizedObserver : public content::NotificationObserver {
+ public:
+ WindowMaximizedObserver(AutomationProvider* automation,
+ IPC::Message* reply_message);
+ virtual ~WindowMaximizedObserver();
+
+ // Overridden from content::NotificationObserver:
+ virtual void Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) OVERRIDE;
+
+ private:
+ content::NotificationRegistrar registrar_;
+ base::WeakPtr<AutomationProvider> automation_;
+ scoped_ptr<IPC::Message> reply_message_;
+
+ DISALLOW_COPY_AND_ASSIGN(WindowMaximizedObserver);
+};
+#endif // defined(OS_LINUX)
+
+
+
#endif // CHROME_BROWSER_AUTOMATION_AUTOMATION_PROVIDER_OBSERVERS_H_
diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc
index c74a6eb..2bad87e 100644
--- a/chrome/browser/automation/testing_automation_provider.cc
+++ b/chrome/browser/automation/testing_automation_provider.cc
@@ -1700,6 +1700,8 @@ void TestingAutomationProvider::SendJSONRequest(int handle,
&TestingAutomationProvider::CloseTabJSON;
handler_map["SetViewBounds"] =
&TestingAutomationProvider::SetViewBounds;
+ handler_map["MaximizeView"] =
+ &TestingAutomationProvider::MaximizeView;
handler_map["WebkitMouseMove"] =
&TestingAutomationProvider::WebkitMouseMove;
handler_map["WebkitMouseClick"] =
@@ -6501,10 +6503,39 @@ void TestingAutomationProvider::SetViewBounds(
reply.SendError(Error(automation::kInvalidId, error));
return;
}
- browser->window()->SetBounds(gfx::Rect(x, y, width, height));
+ BrowserWindow* browser_window = browser->window();
+ if (browser_window->IsMaximized()) {
+ browser_window->Restore();
+ }
+ browser_window->SetBounds(gfx::Rect(x, y, width, height));
reply.SendSuccess(NULL);
}
+void TestingAutomationProvider::MaximizeView(
+ base::DictionaryValue* args,
+ IPC::Message* reply_message) {
+ Browser* browser;
+ std::string error;
+ if (!GetBrowserFromJSONArgs(args, &browser, &error)) {
+ AutomationJSONReply(this, reply_message)
+ .SendError(Error(automation::kInvalidId, error));
+ return;
+ }
+
+#if defined(OS_LINUX)
+ // Maximization on Linux is asynchronous, so create an observer object to be
+ // notified upon maximization completion.
+ new WindowMaximizedObserver(this, reply_message);
+#endif // defined(OS_LINUX)
+
+ browser->window()->Maximize();
+
+#if !defined(OS_LINUX)
+ // Send success reply right away for OS's with synchronous maximize command.
+ AutomationJSONReply(this, reply_message).SendSuccess(NULL);
+#endif // !defined(OS_LINUX)
+}
+
void TestingAutomationProvider::ActivateTabJSON(
DictionaryValue* args,
IPC::Message* reply_message) {
diff --git a/chrome/browser/automation/testing_automation_provider.h b/chrome/browser/automation/testing_automation_provider.h
index 255c6a3..f334e25 100644
--- a/chrome/browser/automation/testing_automation_provider.h
+++ b/chrome/browser/automation/testing_automation_provider.h
@@ -1094,6 +1094,14 @@ class TestingAutomationProvider : public AutomationProvider,
// output: none
void SetViewBounds(base::DictionaryValue* args, IPC::Message* reply_message);
+ // Maximizes the web view.
+ // The single |auto_id| must be given to specify the view.
+ // This method currently is only supported for tabs.
+ // Example:
+ // input: { "auto_id": { "type": 0, "id": "awoein" } }
+ // output: none
+ void MaximizeView(base::DictionaryValue* args, IPC::Message* reply_message);
+
// Sends the WebKit events for a mouse click at a given coordinate.
// The pair |windex| and |tab_index| or the single |auto_id| must be given
// to specify the render view.
diff --git a/chrome/browser/ui/gtk/browser_window_gtk.cc b/chrome/browser/ui/gtk/browser_window_gtk.cc
index f7706d5..f8a2ae5 100644
--- a/chrome/browser/ui/gtk/browser_window_gtk.cc
+++ b/chrome/browser/ui/gtk/browser_window_gtk.cc
@@ -1615,6 +1615,13 @@ gboolean BrowserWindowGtk::OnWindowState(GtkWidget* sender,
}
}
+ if (event->changed_mask & GDK_WINDOW_STATE_MAXIMIZED) {
+ content::NotificationService::current()->Notify(
+ chrome::NOTIFICATION_BROWSER_WINDOW_MAXIMIZED,
+ content::Source<BrowserWindow>(this),
+ content::NotificationService::NoDetails());
+ }
+
titlebar_->UpdateCustomFrame(UseCustomFrame() && !IsFullscreen());
UpdateWindowShape(bounds_.width(), bounds_.height());
SaveWindowPosition();
diff --git a/chrome/common/chrome_notification_types.h b/chrome/common/chrome_notification_types.h
index d207e1b..bf61354 100644
--- a/chrome/common/chrome_notification_types.h
+++ b/chrome/common/chrome_notification_types.h
@@ -54,6 +54,14 @@ enum NotificationType {
// that was closed, no details are expected.
NOTIFICATION_WINDOW_CLOSED,
+#if defined(OS_LINUX)
+ // On Linux maximize can be an asynchronous operation. This notification
+ // indicates that the window has been maximized. The source is
+ // a Source<BrowserWindow> containing the BrowserWindow that was maximized.
+ // No details are expected.
+ NOTIFICATION_BROWSER_WINDOW_MAXIMIZED,
+#endif // defined(OS_LINUX)
+
// Sent when the language (English, French...) for a page has been detected.
// The details Details<std::string> contain the ISO 639-1 language code and
// the source is Source<WebContents>.
diff --git a/chrome/test/automation/automation_json_requests.cc b/chrome/test/automation/automation_json_requests.cc
index 3a6fb95..cdb6272 100644
--- a/chrome/test/automation/automation_json_requests.cc
+++ b/chrome/test/automation/automation_json_requests.cc
@@ -712,6 +712,18 @@ bool SendSetViewBoundsJSONRequest(
return SendAutomationJSONRequest(sender, dict, &reply_dict, error);
}
+bool SendMaximizeJSONRequest(
+ AutomationMessageSender* sender,
+ const WebViewId& id,
+ automation::Error* error) {
+ DictionaryValue dict;
+ dict.SetString("command", "MaximizeView");
+ id.UpdateDictionary(&dict, "auto_id");
+
+ DictionaryValue reply_dict;
+ return SendAutomationJSONRequest(sender, dict, &reply_dict, error);
+}
+
bool SendGetAppModalDialogMessageJSONRequest(
AutomationMessageSender* sender,
std::string* message,
diff --git a/chrome/test/automation/automation_json_requests.h b/chrome/test/automation/automation_json_requests.h
index 22fb858..3272859 100644
--- a/chrome/test/automation/automation_json_requests.h
+++ b/chrome/test/automation/automation_json_requests.h
@@ -424,6 +424,12 @@ bool SendSetViewBoundsJSONRequest(
int height,
automation::Error* error) WARN_UNUSED_RESULT;
+// Requests to maximize the given view. Returns true on success.
+bool SendMaximizeJSONRequest(
+ AutomationMessageSender* sender,
+ const WebViewId& id,
+ automation::Error* error) WARN_UNUSED_RESULT;
+
// Requests to get the active JavaScript modal dialog's message. Returns true
// on success.
bool SendGetAppModalDialogMessageJSONRequest(
diff --git a/chrome/test/webdriver/commands/window_commands.cc b/chrome/test/webdriver/commands/window_commands.cc
index e799dd3..f67500b 100644
--- a/chrome/test/webdriver/commands/window_commands.cc
+++ b/chrome/test/webdriver/commands/window_commands.cc
@@ -132,7 +132,7 @@ void WindowPositionCommand::ExecuteGet(Response* const response) {
}
void WindowPositionCommand::ExecutePost(Response* const response) {
- // Path segment: "/session/$sessionId/window/$windowHandle/size"
+ // Path segment: "/session/$sessionId/window/$windowHandle/position"
WebViewId window_id;
WebViewId current_id = session_->current_target().view_id;
if (!GetWindowId(GetPathVariable(4), current_id, &window_id, response))
@@ -158,4 +158,31 @@ void WindowPositionCommand::ExecutePost(Response* const response) {
}
}
+WindowMaximizeCommand::WindowMaximizeCommand(
+ const std::vector<std::string>& path_segments,
+ const base::DictionaryValue* parameters)
+ : WebDriverCommand(path_segments, parameters) {
+}
+
+WindowMaximizeCommand::~WindowMaximizeCommand() {
+}
+
+bool WindowMaximizeCommand::DoesPost() {
+ return true;
+}
+
+void WindowMaximizeCommand::ExecutePost(Response* const response) {
+ // Path segment: "/session/$sessionId/window/$windowHandle/maximize"
+ WebViewId window_id;
+ WebViewId current_id = session_->current_target().view_id;
+ if (!GetWindowId(GetPathVariable(4), current_id, &window_id, response))
+ return;
+
+ Error* error = session_->MaximizeWindow(window_id);
+ if (error) {
+ response->SetError(error);
+ return;
+ }
+}
+
} // namespace webdriver
diff --git a/chrome/test/webdriver/commands/window_commands.h b/chrome/test/webdriver/commands/window_commands.h
index d5df95d..b839009 100644
--- a/chrome/test/webdriver/commands/window_commands.h
+++ b/chrome/test/webdriver/commands/window_commands.h
@@ -48,6 +48,20 @@ class WindowPositionCommand : public WebDriverCommand {
DISALLOW_COPY_AND_ASSIGN(WindowPositionCommand);
};
+class WindowMaximizeCommand : public WebDriverCommand {
+ public:
+ WindowMaximizeCommand(const std::vector<std::string>& path_segments,
+ const base::DictionaryValue* parameters);
+ virtual ~WindowMaximizeCommand();
+
+ virtual bool DoesPost() OVERRIDE;
+ virtual void ExecutePost(Response* const response) OVERRIDE;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(WindowMaximizeCommand);
+};
+
+
} // namespace webdriver
#endif // CHROME_TEST_WEBDRIVER_COMMANDS_WINDOW_COMMANDS_H_
diff --git a/chrome/test/webdriver/test/chromedriver_tests.py b/chrome/test/webdriver/test/chromedriver_tests.py
index 43bb302..3f3a86d 100644
--- a/chrome/test/webdriver/test/chromedriver_tests.py
+++ b/chrome/test/webdriver/test/chromedriver_tests.py
@@ -979,42 +979,59 @@ class AlertTest(ChromeDriverTest):
class WindowTest(ChromeDriverTest):
- def testSizeAndPosition(self):
- driver = self.GetNewDriver()
+ """Tests for WebDriver window commands."""
- # Test size.
- size = driver.get_window_size()
- driver.set_window_size(size['width'], size['height'])
- self.assertEquals(size, driver.get_window_size())
- driver.set_window_size(800, 600)
- self.assertEquals(800, driver.get_window_size()['width'])
- self.assertEquals(600, driver.get_window_size()['height'])
- # Test position.
- pos = driver.get_window_position()
- driver.set_window_position(pos['x'], pos['y'])
- self.assertEquals(pos, driver.get_window_position())
- driver.set_window_position(100, 200)
- self.assertEquals(100, driver.get_window_position()['x'])
- self.assertEquals(200, driver.get_window_position()['y'])
- # Test specifying window handle.
- driver.execute_script(
+ def setUp(self):
+ super(WindowTest, self).setUp()
+ self._driver = self.GetNewDriver()
+
+ def testSize(self):
+ size = self._driver.get_window_size()
+ self._driver.set_window_size(size['width'], size['height'])
+ self.assertEquals(size, self._driver.get_window_size())
+ self._driver.set_window_size(800, 600)
+ self.assertEquals(800, self._driver.get_window_size()['width'])
+ self.assertEquals(600, self._driver.get_window_size()['height'])
+
+ def testPosition(self):
+ pos = self._driver.get_window_position()
+ self._driver.set_window_position(pos['x'], pos['y'])
+ self.assertEquals(pos, self._driver.get_window_position())
+ self._driver.set_window_position(100, 200)
+ self.assertEquals(100, self._driver.get_window_position()['x'])
+ self.assertEquals(200, self._driver.get_window_position()['y'])
+
+ # Systems without window manager (Xvfb, Xvnc) do not implement maximization.
+ @SkipIf(util.IsLinux())
+ def testMaximize(self):
+ old_size = self._driver.get_window_size()
+ self._driver.maximize_window()
+ new_size = self._driver.get_window_size()
+ self.assertTrue(old_size['width'] <= new_size['width'])
+ self.assertTrue(old_size['height'] <= new_size['height'])
+
+ def testWindowHandle(self):
+ """Test specifying window handle."""
+ self._driver.execute_script(
'window.open("about:blank", "name", "height=200, width=200")')
- windows = driver.window_handles
+ windows = self._driver.window_handles
self.assertEquals(2, len(windows))
- driver.set_window_size(400, 300, windows[1])
- self.assertEquals(400, driver.get_window_size(windows[1])['width'])
- self.assertEquals(300, driver.get_window_size(windows[1])['height'])
- self.assertNotEquals(driver.get_window_size(windows[1]),
- driver.get_window_size(windows[0]))
- # Test specifying invalid handle.
+ self._driver.set_window_size(400, 300, windows[1])
+ self.assertEquals(400, self._driver.get_window_size(windows[1])['width'])
+ self.assertEquals(300, self._driver.get_window_size(windows[1])['height'])
+ self.assertNotEquals(self._driver.get_window_size(windows[1]),
+ self._driver.get_window_size(windows[0]))
+
+ def testInvalidWindowHandle(self):
+ """Tests specifying invalid handle."""
invalid_handle = 'f1-120'
- self.assertRaises(WebDriverException, driver.set_window_size, 400, 300,
- invalid_handle)
- self.assertRaises(NoSuchWindowException, driver.get_window_size,
- invalid_handle)
- self.assertRaises(NoSuchWindowException, driver.set_window_position, 1, 1,
+ self.assertRaises(WebDriverException, self._driver.set_window_size,
+ 400, 300, invalid_handle)
+ self.assertRaises(NoSuchWindowException, self._driver.get_window_size,
invalid_handle)
- self.assertRaises(NoSuchWindowException, driver.get_window_position,
+ self.assertRaises(NoSuchWindowException, self._driver.set_window_position,
+ 1, 1, invalid_handle)
+ self.assertRaises(NoSuchWindowException, self._driver.get_window_position,
invalid_handle)
diff --git a/chrome/test/webdriver/webdriver_automation.cc b/chrome/test/webdriver/webdriver_automation.cc
index 3af0033..b78093f 100644
--- a/chrome/test/webdriver/webdriver_automation.cc
+++ b/chrome/test/webdriver/webdriver_automation.cc
@@ -881,6 +881,17 @@ void Automation::SetViewBounds(const WebViewId& view_id,
*error = Error::FromAutomationError(auto_error);
}
+void Automation::MaximizeView(const WebViewId& view_id, Error** error) {
+ *error = CheckMaximizeSupported();
+ if (*error)
+ return;
+
+ automation::Error auto_error;
+ if (!SendMaximizeJSONRequest(
+ automation(), view_id, &auto_error))
+ *error = Error::FromAutomationError(auto_error);
+}
+
void Automation::GetAppModalDialogMessage(std::string* message, Error** error) {
*error = CheckAlertsSupported();
if (*error)
@@ -1159,4 +1170,11 @@ Error* Automation::CheckGeolocationSupported() {
return CheckVersion(1119, message);
}
+Error* Automation::CheckMaximizeSupported() {
+ const char* message =
+ "Maximize automation interface is not supported for this version of "
+ "Chrome.";
+ return CheckVersion(1160, message);
+}
+
} // namespace webdriver
diff --git a/chrome/test/webdriver/webdriver_automation.h b/chrome/test/webdriver/webdriver_automation.h
index 13d4775..9a4afb8 100644
--- a/chrome/test/webdriver/webdriver_automation.h
+++ b/chrome/test/webdriver/webdriver_automation.h
@@ -182,6 +182,9 @@ class Automation {
const Rect& bounds,
Error** error);
+ // Maximizes the given view.
+ void MaximizeView(const WebViewId& view_id, Error** error);
+
// Gets the active JavaScript modal dialog's message.
void GetAppModalDialogMessage(std::string* message, Error** error);
@@ -262,6 +265,7 @@ class Automation {
Error* CheckAdvancedInteractionsSupported();
Error* CheckNewExtensionInterfaceSupported();
Error* CheckGeolocationSupported();
+ Error* CheckMaximizeSupported();
Error* IsNewMouseApiSupported(bool* supports_new_api);
const Logger& logger_;
diff --git a/chrome/test/webdriver/webdriver_server.cc b/chrome/test/webdriver/webdriver_server.cc
index 6587bac..c4b9db9 100644
--- a/chrome/test/webdriver/webdriver_server.cc
+++ b/chrome/test/webdriver/webdriver_server.cc
@@ -146,6 +146,8 @@ void InitCallbacks(Dispatcher* dispatcher,
dispatcher->Add<WindowSizeCommand>( "/session/*/window/*/size");
dispatcher->Add<WindowPositionCommand>(
"/session/*/window/*/position");
+ dispatcher->Add<WindowMaximizeCommand>(
+ "/session/*/window/*/maximize");
dispatcher->Add<SetAsyncScriptTimeoutCommand>(
"/session/*/timeouts/async_script");
dispatcher->Add<ImplicitWaitCommand>( "/session/*/timeouts/implicit_wait");
diff --git a/chrome/test/webdriver/webdriver_session.cc b/chrome/test/webdriver/webdriver_session.cc
index 4e704c8..13e4834 100644
--- a/chrome/test/webdriver/webdriver_session.cc
+++ b/chrome/test/webdriver/webdriver_session.cc
@@ -665,7 +665,7 @@ Error* Session::SwitchToFrameWithIndex(int index) {
// tagName of the frameElement. If child frame N is from another domain, then
// the following will run afoul of the same origin policy:
// window.frames[N].frameElement;
- // Instead of indexing window.frames, we use a an XPath expression to index
+ // Instead of indexing window.frames, we use an XPath expression to index
// into the list of all IFRAME and FRAME elements on the page - if we find
// something, then that XPath expression can be used as the new frame's XPath.
std::string script =
@@ -790,6 +790,16 @@ Error* Session::SetWindowBounds(
return error;
}
+Error* Session::MaximizeWindow(const WebViewId& window) {
+ Error* error = NULL;
+ RunSessionTask(base::Bind(
+ &Automation::MaximizeView,
+ base::Unretained(automation_.get()),
+ window,
+ &error));
+ return error;
+}
+
Error* Session::GetAlertMessage(std::string* text) {
Error* error = NULL;
RunSessionTask(base::Bind(
diff --git a/chrome/test/webdriver/webdriver_session.h b/chrome/test/webdriver/webdriver_session.h
index 71e53e6..6c9b5f0 100644
--- a/chrome/test/webdriver/webdriver_session.h
+++ b/chrome/test/webdriver/webdriver_session.h
@@ -184,6 +184,9 @@ class Session {
// Sets the bounds for the specified window.
Error* SetWindowBounds(const WebViewId& window, const Rect& bounds);
+ // Maximizes the specified window.
+ Error* MaximizeWindow(const WebViewId& window);
+
// Gets the message of the currently active JavaScript modal dialog.
Error* GetAlertMessage(std::string* text);
@@ -367,7 +370,7 @@ class Session {
Error* ClearStorage(StorageType type);
// Gets the keys of all items of the HTML5 localStorage object. If there are
- // no errors, the function sets |value| and the caller takes ownership.
+ // no errors, the function sets |keys| and the caller takes ownership.
Error* GetStorageKeys(StorageType type, base::ListValue** keys);
// Gets the current geolocation.