Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2699)

Unified Diff: chrome/test/chromedriver/session_commands.cc

Issue 2826393002: use devtools command to do window management (Closed)
Patch Set: nit change Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/chromedriver/chrome/chrome_desktop_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/chromedriver/session_commands.cc
diff --git a/chrome/test/chromedriver/session_commands.cc b/chrome/test/chromedriver/session_commands.cc
index c6777a3dd75f3ec7b93088cb875eea8b2e326011..e6bd0bb3679335e77cd5205c1ca4da28bf446f2e 100644
--- a/chrome/test/chromedriver/session_commands.cc
+++ b/chrome/test/chromedriver/session_commands.cc
@@ -40,6 +40,10 @@
namespace {
+// The minimium chrome build no that supports window management devtools
+// commands.
+const int kBrowserWindowDevtoolsBuildNo = 3076;
+
const int kWifiMask = 0x2;
const int k4GMask = 0x8;
const int k3GMask = 0x10;
@@ -656,13 +660,19 @@ Status ExecuteGetWindowPosition(Session* session,
if (status.IsError())
return status;
- AutomationExtension* extension = NULL;
- status = desktop->GetAutomationExtension(&extension, session->w3c_compliant);
- if (status.IsError())
- return status;
-
int x, y;
- status = extension->GetWindowPosition(&x, &y);
+
+ if (desktop->GetBrowserInfo()->build_no >= kBrowserWindowDevtoolsBuildNo) {
+ status = desktop->GetWindowPosition(session->window, &x, &y);
+ } else {
+ AutomationExtension* extension = NULL;
+ status =
+ desktop->GetAutomationExtension(&extension, session->w3c_compliant);
+ if (status.IsError())
+ return status;
+
+ status = extension->GetWindowPosition(&x, &y);
+ }
if (status.IsError())
return status;
@@ -686,6 +696,11 @@ Status ExecuteSetWindowPosition(Session* session,
if (status.IsError())
return status;
+ if (desktop->GetBrowserInfo()->build_no >= kBrowserWindowDevtoolsBuildNo) {
+ return desktop->SetWindowPosition(session->window, static_cast<int>(x),
+ static_cast<int>(y));
+ }
+
AutomationExtension* extension = NULL;
status = desktop->GetAutomationExtension(&extension, session->w3c_compliant);
if (status.IsError())
@@ -702,13 +717,19 @@ Status ExecuteGetWindowSize(Session* session,
if (status.IsError())
return status;
- AutomationExtension* extension = NULL;
- status = desktop->GetAutomationExtension(&extension, session->w3c_compliant);
- if (status.IsError())
- return status;
-
int width, height;
- status = extension->GetWindowSize(&width, &height);
+
+ if (desktop->GetBrowserInfo()->build_no >= kBrowserWindowDevtoolsBuildNo) {
+ status = desktop->GetWindowSize(session->window, &width, &height);
+ } else {
+ AutomationExtension* extension = NULL;
+ status =
+ desktop->GetAutomationExtension(&extension, session->w3c_compliant);
+ if (status.IsError())
+ return status;
+
+ status = extension->GetWindowSize(&width, &height);
+ }
if (status.IsError())
return status;
@@ -733,6 +754,11 @@ Status ExecuteSetWindowSize(Session* session,
if (status.IsError())
return status;
+ if (desktop->GetBrowserInfo()->build_no >= kBrowserWindowDevtoolsBuildNo) {
+ return desktop->SetWindowSize(session->window, static_cast<int>(width),
+ static_cast<int>(height));
+ }
+
AutomationExtension* extension = NULL;
status = desktop->GetAutomationExtension(&extension, session->w3c_compliant);
if (status.IsError())
@@ -750,6 +776,9 @@ Status ExecuteMaximizeWindow(Session* session,
if (status.IsError())
return status;
+ if (desktop->GetBrowserInfo()->build_no >= kBrowserWindowDevtoolsBuildNo)
+ return desktop->MaximizeWindow(session->window);
+
AutomationExtension* extension = NULL;
status = desktop->GetAutomationExtension(&extension, session->w3c_compliant);
if (status.IsError())
« no previous file with comments | « chrome/test/chromedriver/chrome/chrome_desktop_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698