Chromium Code Reviews| 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..a3c2a29b923ed41b467fb2cbc164fde3aa6d2ac1 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); |
|
stgao
2015/06/26 17:55:47
How do we come to this timeout setting? Should it
samuong
2015/06/26 18:09:26
It's just an attempt at a reasonable default, but
|
| + status = desktop->WaitForNewAppWindow(id, &web_view_id, timeout); |
| + 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( |