OLD | NEW |
---|---|
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/chrome_launcher.h" | 5 #include "chrome/test/chromedriver/chrome_launcher.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/base64.h" | 10 #include "base/base64.h" |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
149 return status; | 149 return status; |
150 switches.AppendToCommandLine(&command); | 150 switches.AppendToCommandLine(&command); |
151 *prepared_command = command; | 151 *prepared_command = command; |
152 return Status(kOk); | 152 return Status(kOk); |
153 } | 153 } |
154 | 154 |
155 Status WaitForDevToolsAndCheckVersion( | 155 Status WaitForDevToolsAndCheckVersion( |
156 const NetAddress& address, | 156 const NetAddress& address, |
157 URLRequestContextGetter* context_getter, | 157 URLRequestContextGetter* context_getter, |
158 const SyncWebSocketFactory& socket_factory, | 158 const SyncWebSocketFactory& socket_factory, |
159 const Capabilities* capabilities, | |
159 scoped_ptr<DevToolsHttpClient>* user_client) { | 160 scoped_ptr<DevToolsHttpClient>* user_client) { |
161 scoped_ptr<DeviceMetrics> device_metrics; | |
162 if (capabilities && capabilities->device_metrics) { | |
163 device_metrics.reset(new DeviceMetrics()); | |
164 *device_metrics = *capabilities->device_metrics; | |
samuong
2014/05/16 23:00:35
Change these two lines to:
device_metrics.reset(n
sam.rawlins
2014/05/16 23:35:51
Done.
| |
165 } | |
166 | |
160 scoped_ptr<DevToolsHttpClient> client(new DevToolsHttpClient( | 167 scoped_ptr<DevToolsHttpClient> client(new DevToolsHttpClient( |
161 address, context_getter, socket_factory)); | 168 address, context_getter, socket_factory, device_metrics.Pass())); |
162 base::TimeTicks deadline = | 169 base::TimeTicks deadline = |
163 base::TimeTicks::Now() + base::TimeDelta::FromSeconds(60); | 170 base::TimeTicks::Now() + base::TimeDelta::FromSeconds(60); |
164 Status status = client->Init(deadline - base::TimeTicks::Now()); | 171 Status status = client->Init(deadline - base::TimeTicks::Now()); |
165 if (status.IsError()) | 172 if (status.IsError()) |
166 return status; | 173 return status; |
167 if (client->browser_info()->build_no < kMinimumSupportedChromeBuildNo) { | 174 if (client->browser_info()->build_no < kMinimumSupportedChromeBuildNo) { |
168 return Status(kUnknownError, "Chrome version must be >= " + | 175 return Status(kUnknownError, "Chrome version must be >= " + |
169 GetMinimumSupportedChromeVersion()); | 176 GetMinimumSupportedChromeVersion()); |
170 } | 177 } |
171 | 178 |
(...skipping 14 matching lines...) Expand all Loading... | |
186 Status LaunchExistingChromeSession( | 193 Status LaunchExistingChromeSession( |
187 URLRequestContextGetter* context_getter, | 194 URLRequestContextGetter* context_getter, |
188 const SyncWebSocketFactory& socket_factory, | 195 const SyncWebSocketFactory& socket_factory, |
189 const Capabilities& capabilities, | 196 const Capabilities& capabilities, |
190 ScopedVector<DevToolsEventListener>& devtools_event_listeners, | 197 ScopedVector<DevToolsEventListener>& devtools_event_listeners, |
191 scoped_ptr<Chrome>* chrome) { | 198 scoped_ptr<Chrome>* chrome) { |
192 Status status(kOk); | 199 Status status(kOk); |
193 scoped_ptr<DevToolsHttpClient> devtools_client; | 200 scoped_ptr<DevToolsHttpClient> devtools_client; |
194 status = WaitForDevToolsAndCheckVersion( | 201 status = WaitForDevToolsAndCheckVersion( |
195 capabilities.debugger_address, context_getter, socket_factory, | 202 capabilities.debugger_address, context_getter, socket_factory, |
196 &devtools_client); | 203 NULL, &devtools_client); |
197 if (status.IsError()) { | 204 if (status.IsError()) { |
198 return Status(kUnknownError, "cannot connect to chrome at " + | 205 return Status(kUnknownError, "cannot connect to chrome at " + |
199 capabilities.debugger_address.ToString(), | 206 capabilities.debugger_address.ToString(), |
200 status); | 207 status); |
201 } | 208 } |
202 chrome->reset(new ChromeExistingImpl(devtools_client.Pass(), | 209 chrome->reset(new ChromeExistingImpl(devtools_client.Pass(), |
203 devtools_event_listeners)); | 210 devtools_event_listeners)); |
204 return Status(kOk); | 211 return Status(kOk); |
205 } | 212 } |
206 | 213 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
270 #else | 277 #else |
271 std::string command_string = command.GetCommandLineString(); | 278 std::string command_string = command.GetCommandLineString(); |
272 #endif | 279 #endif |
273 VLOG(0) << "Launching chrome: " << command_string; | 280 VLOG(0) << "Launching chrome: " << command_string; |
274 base::ProcessHandle process; | 281 base::ProcessHandle process; |
275 if (!base::LaunchProcess(command, options, &process)) | 282 if (!base::LaunchProcess(command, options, &process)) |
276 return Status(kUnknownError, "chrome failed to start"); | 283 return Status(kUnknownError, "chrome failed to start"); |
277 | 284 |
278 scoped_ptr<DevToolsHttpClient> devtools_client; | 285 scoped_ptr<DevToolsHttpClient> devtools_client; |
279 status = WaitForDevToolsAndCheckVersion( | 286 status = WaitForDevToolsAndCheckVersion( |
280 NetAddress(port), context_getter, socket_factory, &devtools_client); | 287 NetAddress(port), context_getter, socket_factory, &capabilities, |
288 &devtools_client); | |
281 | 289 |
282 if (status.IsError()) { | 290 if (status.IsError()) { |
283 int exit_code; | 291 int exit_code; |
284 base::TerminationStatus chrome_status = | 292 base::TerminationStatus chrome_status = |
285 base::GetTerminationStatus(process, &exit_code); | 293 base::GetTerminationStatus(process, &exit_code); |
286 if (chrome_status != base::TERMINATION_STATUS_STILL_RUNNING) { | 294 if (chrome_status != base::TERMINATION_STATUS_STILL_RUNNING) { |
287 std::string termination_reason; | 295 std::string termination_reason; |
288 switch (chrome_status) { | 296 switch (chrome_status) { |
289 case base::TERMINATION_STATUS_NORMAL_TERMINATION: | 297 case base::TERMINATION_STATUS_NORMAL_TERMINATION: |
290 termination_reason = "exited normally"; | 298 termination_reason = "exited normally"; |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
370 port); | 378 port); |
371 if (status.IsError()) { | 379 if (status.IsError()) { |
372 device->TearDown(); | 380 device->TearDown(); |
373 return status; | 381 return status; |
374 } | 382 } |
375 | 383 |
376 scoped_ptr<DevToolsHttpClient> devtools_client; | 384 scoped_ptr<DevToolsHttpClient> devtools_client; |
377 status = WaitForDevToolsAndCheckVersion(NetAddress(port), | 385 status = WaitForDevToolsAndCheckVersion(NetAddress(port), |
378 context_getter, | 386 context_getter, |
379 socket_factory, | 387 socket_factory, |
388 &capabilities, | |
380 &devtools_client); | 389 &devtools_client); |
381 if (status.IsError()) { | 390 if (status.IsError()) { |
382 device->TearDown(); | 391 device->TearDown(); |
383 return status; | 392 return status; |
384 } | 393 } |
385 | 394 |
386 chrome->reset(new ChromeAndroidImpl(devtools_client.Pass(), | 395 chrome->reset(new ChromeAndroidImpl(devtools_client.Pass(), |
387 devtools_event_listeners, | 396 devtools_event_listeners, |
388 port_reservation.Pass(), | 397 port_reservation.Pass(), |
389 device.Pass())); | 398 device.Pass())); |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
685 // Write empty "First Run" file, otherwise Chrome will wipe the default | 694 // Write empty "First Run" file, otherwise Chrome will wipe the default |
686 // profile that was written. | 695 // profile that was written. |
687 if (base::WriteFile( | 696 if (base::WriteFile( |
688 user_data_dir.Append(chrome::kFirstRunSentinel), "", 0) != 0) { | 697 user_data_dir.Append(chrome::kFirstRunSentinel), "", 0) != 0) { |
689 return Status(kUnknownError, "failed to write first run file"); | 698 return Status(kUnknownError, "failed to write first run file"); |
690 } | 699 } |
691 return Status(kOk); | 700 return Status(kOk); |
692 } | 701 } |
693 | 702 |
694 } // namespace internal | 703 } // namespace internal |
OLD | NEW |