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

Side by Side Diff: chrome/test/chromedriver/session_commands.cc

Issue 251933005: [ChromeDriver] Support mobile emulation on desktop Chrome. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/test/chromedriver/session_commands.h" 5 #include "chrome/test/chromedriver/session_commands.h"
6 6
7 #include <list> 7 #include <list>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 if (chrome->GetAsDesktop()) { 92 if (chrome->GetAsDesktop()) {
93 chrome_caps->SetString( 93 chrome_caps->SetString(
94 "userDataDir", 94 "userDataDir",
95 chrome->GetAsDesktop()->command().GetSwitchValueNative( 95 chrome->GetAsDesktop()->command().GetSwitchValueNative(
96 "user-data-dir")); 96 "user-data-dir"));
97 } 97 }
98 caps->Set("chrome", chrome_caps.release()); 98 caps->Set("chrome", chrome_caps.release());
99 return caps.Pass(); 99 return caps.Pass();
100 } 100 }
101 101
102 Status InitDeviceMetricsOverride(
103 Session* session,
104 DeviceMetrics* device_metrics)
105 {
106 WebView* web_view;
107 session->chrome->GetWebViewById(session->window, &web_view);
108 Status status = web_view->OverrideDeviceMetrics(*device_metrics);
109 if (status.IsOk())
110 session->overridden_device_metrics.reset(new DeviceMetrics(*device_metrics)) ;
111 return status;
112 }
102 113
103 Status InitSessionHelper( 114 Status InitSessionHelper(
104 const InitSessionParams& bound_params, 115 const InitSessionParams& bound_params,
105 Session* session, 116 Session* session,
106 const base::DictionaryValue& params, 117 const base::DictionaryValue& params,
107 scoped_ptr<base::Value>* value) { 118 scoped_ptr<base::Value>* value) {
108 session->driver_log.reset( 119 session->driver_log.reset(
109 new WebDriverLog(WebDriverLog::kDriverType, Log::kAll)); 120 new WebDriverLog(WebDriverLog::kDriverType, Log::kAll));
110 const base::DictionaryValue* desired_caps; 121 const base::DictionaryValue* desired_caps;
111 if (!params.GetDictionary("desiredCapabilities", &desired_caps)) 122 if (!params.GetDictionary("desiredCapabilities", &desired_caps))
(...skipping 30 matching lines...) Expand all
142 return status; 153 return status;
143 154
144 std::list<std::string> web_view_ids; 155 std::list<std::string> web_view_ids;
145 status = session->chrome->GetWebViewIds(&web_view_ids); 156 status = session->chrome->GetWebViewIds(&web_view_ids);
146 if (status.IsError() || web_view_ids.empty()) { 157 if (status.IsError() || web_view_ids.empty()) {
147 return status.IsError() ? status : 158 return status.IsError() ? status :
148 Status(kUnknownError, "unable to discover open window in chrome"); 159 Status(kUnknownError, "unable to discover open window in chrome");
149 } 160 }
150 161
151 session->window = web_view_ids.front(); 162 session->window = web_view_ids.front();
163
164 if (capabilities.device_metrics.width != 0) {
stgao 2014/05/03 00:15:20 Instead of creating an instance of struct |device_
sam.rawlins 2014/05/06 23:51:46 Done.
165 InitDeviceMetricsOverride(session, &capabilities.device_metrics);
166 }
167
152 session->detach = capabilities.detach; 168 session->detach = capabilities.detach;
153 session->force_devtools_screenshot = capabilities.force_devtools_screenshot; 169 session->force_devtools_screenshot = capabilities.force_devtools_screenshot;
154 session->capabilities = CreateCapabilities(session->chrome.get()); 170 session->capabilities = CreateCapabilities(session->chrome.get());
155 value->reset(session->capabilities->DeepCopy()); 171 value->reset(session->capabilities->DeepCopy());
156 return Status(kOk); 172 return Status(kOk);
157 } 173 }
158 174
159 } // namespace 175 } // namespace
160 176
161 Status ExecuteInitSession( 177 Status ExecuteInitSession(
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 Status ExecuteSetAutoReporting( 660 Status ExecuteSetAutoReporting(
645 Session* session, 661 Session* session,
646 const base::DictionaryValue& params, 662 const base::DictionaryValue& params,
647 scoped_ptr<base::Value>* value) { 663 scoped_ptr<base::Value>* value) {
648 bool enabled; 664 bool enabled;
649 if (!params.GetBoolean("enabled", &enabled)) 665 if (!params.GetBoolean("enabled", &enabled))
650 return Status(kUnknownError, "missing parameter 'enabled'"); 666 return Status(kUnknownError, "missing parameter 'enabled'");
651 session->auto_reporting_enabled = enabled; 667 session->auto_reporting_enabled = enabled;
652 return Status(kOk); 668 return Status(kOk);
653 } 669 }
OLDNEW
« chrome/test/chromedriver/chrome/web_view_impl.cc ('K') | « chrome/test/chromedriver/session.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698