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

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

Issue 1196663005: [chromedriver] When launching a Chrome App, automatically switch to the new window. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add copyright message to test app background.js Created 5 years, 6 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_impl.cc ('k') | chrome/test/chromedriver/test/run_py_tests.py » ('j') | 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 99f5f028eec82e248844c63c060f46159331f4f3..f5d8c52d650abab0c4a72cc2b3f9de4716b4fc97 100644
--- a/chrome/test/chromedriver/session_commands.cc
+++ b/chrome/test/chromedriver/session_commands.cc
@@ -195,6 +195,40 @@ Status InitSessionHelper(
return CheckSessionCreated(session);
}
+Status SwitchToWebView(Session* session, const std::string& web_view_id) {
+ if (session->overridden_geoposition) {
+ WebView* web_view;
+ Status status = session->chrome->GetWebViewById(web_view_id, &web_view);
+ if (status.IsError())
+ return status;
+ status = web_view->ConnectIfNecessary();
+ if (status.IsError())
+ return status;
+ status = web_view->OverrideGeolocation(*session->overridden_geoposition);
+ if (status.IsError())
+ return status;
+ }
+
+ if (session->overridden_network_conditions) {
+ WebView* web_view;
+ Status status = session->chrome->GetWebViewById(web_view_id, &web_view);
+ if (status.IsError())
+ return status;
+ status = web_view->ConnectIfNecessary();
+ if (status.IsError())
+ return status;
+ status = web_view->OverrideNetworkConditions(
+ *session->overridden_network_conditions);
+ if (status.IsError())
+ return status;
+ }
+
+ session->window = web_view_id;
+ session->SwitchToTopFrame();
+ session->mouse_position = WebPoint(0, 0);
+ return Status(kOk);
+}
+
} // namespace
Status ExecuteInitSession(
@@ -263,7 +297,17 @@ Status ExecuteLaunchApp(
if (status.IsError())
return status;
- return extension->LaunchApp(id);
+ status = extension->LaunchApp(id);
+ if (status.IsError())
+ return status;
+
+ std::string web_view_id;
+ base::TimeDelta timeout = base::TimeDelta::FromSeconds(60);
+ status = desktop->WaitForNewAppWindow(timeout, id, &web_view_id);
+ if (status.IsError())
+ return status;
+
+ return SwitchToWebView(session, web_view_id);
}
Status ExecuteClose(
@@ -369,38 +413,7 @@ Status ExecuteSwitchToWindow(
if (!found)
return Status(kNoSuchWindow);
-
- if (session->overridden_geoposition) {
- WebView* web_view;
- status = session->chrome->GetWebViewById(web_view_id, &web_view);
- if (status.IsError())
- return status;
- status = web_view->ConnectIfNecessary();
- if (status.IsError())
- return status;
- status = web_view->OverrideGeolocation(*session->overridden_geoposition);
- if (status.IsError())
- return status;
- }
-
- if (session->overridden_network_conditions) {
- WebView* web_view;
- status = session->chrome->GetWebViewById(web_view_id, &web_view);
- if (status.IsError())
- return status;
- status = web_view->ConnectIfNecessary();
- if (status.IsError())
- return status;
- status = web_view->OverrideNetworkConditions(
- *session->overridden_network_conditions);
- if (status.IsError())
- return status;
- }
-
- session->window = web_view_id;
- session->SwitchToTopFrame();
- session->mouse_position = WebPoint(0, 0);
- return Status(kOk);
+ return SwitchToWebView(session, web_view_id);
}
Status ExecuteSetTimeout(
« no previous file with comments | « chrome/test/chromedriver/chrome/chrome_impl.cc ('k') | chrome/test/chromedriver/test/run_py_tests.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698