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

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

Issue 14263024: Logging API in chromedriver2. (Closed) Base URL: https://src.chromium.org/chrome/trunk/src/
Patch Set: Created 7 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 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/chrome_launcher.h" 5 #include "chrome/test/chromedriver/chrome_launcher.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 client->GetWebViewsInfo(&views_info); 170 client->GetWebViewsInfo(&views_info);
171 if (views_info.GetSize()) { 171 if (views_info.GetSize()) {
172 *user_client = client.Pass(); 172 *user_client = client.Pass();
173 return Status(kOk); 173 return Status(kOk);
174 } 174 }
175 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(100)); 175 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(100));
176 } 176 }
177 return Status(kUnknownError, "unable to discover open pages"); 177 return Status(kUnknownError, "unable to discover open pages");
178 } 178 }
179 179
180 Status LaunchDesktopChrome(URLRequestContextGetter* context_getter, 180 Status LaunchDesktopChrome(
181 int port, 181 URLRequestContextGetter* context_getter,
182 const SyncWebSocketFactory& socket_factory, 182 int port,
183 const Capabilities& capabilities, 183 const SyncWebSocketFactory& socket_factory,
184 scoped_ptr<Chrome>* chrome) { 184 const Capabilities& capabilities,
185 const std::list<DevToolsEventLogger*>& devtools_event_loggers,
186 scoped_ptr<Chrome>* chrome) {
185 CommandLine command(CommandLine::NO_PROGRAM); 187 CommandLine command(CommandLine::NO_PROGRAM);
186 base::ScopedTempDir user_data_dir; 188 base::ScopedTempDir user_data_dir;
187 base::ScopedTempDir extension_dir; 189 base::ScopedTempDir extension_dir;
188 PrepareCommandLine(port, capabilities, 190 PrepareCommandLine(port, capabilities,
189 &command, &user_data_dir, &extension_dir); 191 &command, &user_data_dir, &extension_dir);
190 base::LaunchOptions options; 192 base::LaunchOptions options;
191 193
192 #if !defined(OS_WIN) 194 #if !defined(OS_WIN)
193 base::EnvironmentVector environ; 195 base::EnvironmentVector environ;
194 if (!capabilities.log_path.empty()) { 196 if (!capabilities.log_path.empty()) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 } 240 }
239 if (!base::KillProcess(process, 0, true)) { 241 if (!base::KillProcess(process, 0, true)) {
240 int exit_code; 242 int exit_code;
241 if (base::GetTerminationStatus(process, &exit_code) == 243 if (base::GetTerminationStatus(process, &exit_code) ==
242 base::TERMINATION_STATUS_STILL_RUNNING) 244 base::TERMINATION_STATUS_STILL_RUNNING)
243 return Status(kUnknownError, "cannot kill Chrome", status); 245 return Status(kUnknownError, "cannot kill Chrome", status);
244 } 246 }
245 return status; 247 return status;
246 } 248 }
247 chrome->reset(new ChromeDesktopImpl( 249 chrome->reset(new ChromeDesktopImpl(
248 devtools_client.Pass(), version, build_no, process, &user_data_dir, 250 devtools_client.Pass(), version, build_no, devtools_event_loggers,
249 &extension_dir)); 251 process, &user_data_dir, &extension_dir));
250 return Status(kOk); 252 return Status(kOk);
251 } 253 }
252 254
253 Status LaunchAndroidChrome(URLRequestContextGetter* context_getter, 255 Status LaunchAndroidChrome(
254 int port, 256 URLRequestContextGetter* context_getter,
255 const SyncWebSocketFactory& socket_factory, 257 int port,
256 const Capabilities& capabilities, 258 const SyncWebSocketFactory& socket_factory,
257 scoped_ptr<Chrome>* chrome) { 259 const Capabilities& capabilities,
260 const std::list<DevToolsEventLogger*>& devtools_event_loggers,
261 scoped_ptr<Chrome>* chrome) {
258 // TODO(frankf): Figure out how this should be installed to 262 // TODO(frankf): Figure out how this should be installed to
259 // make this work for all platforms. 263 // make this work for all platforms.
260 base::FilePath adb_commands(FILE_PATH_LITERAL("adb_commands.py")); 264 base::FilePath adb_commands(FILE_PATH_LITERAL("adb_commands.py"));
261 CommandLine command(adb_commands); 265 CommandLine command(adb_commands);
262 command.AppendSwitchASCII("package", capabilities.android_package); 266 command.AppendSwitchASCII("package", capabilities.android_package);
263 command.AppendSwitch("launch"); 267 command.AppendSwitch("launch");
264 command.AppendSwitchASCII("port", base::IntToString(port)); 268 command.AppendSwitchASCII("port", base::IntToString(port));
265 269
266 std::string output; 270 std::string output;
267 if (!base::GetAppOutput(command, &output)) { 271 if (!base::GetAppOutput(command, &output)) {
268 if (output.empty()) 272 if (output.empty())
269 return Status( 273 return Status(
270 kUnknownError, 274 kUnknownError,
271 "failed to run adb_commands.py. Make sure it is set in PATH."); 275 "failed to run adb_commands.py. Make sure it is set in PATH.");
272 else 276 else
273 return Status(kUnknownError, "android app failed to start.\n" + output); 277 return Status(kUnknownError, "android app failed to start.\n" + output);
274 } 278 }
275 279
276 scoped_ptr<DevToolsHttpClient> devtools_client; 280 scoped_ptr<DevToolsHttpClient> devtools_client;
277 std::string version; 281 std::string version;
278 int build_no; 282 int build_no;
279 Status status = WaitForDevToolsAndCheckVersion( 283 Status status = WaitForDevToolsAndCheckVersion(
280 port, context_getter, socket_factory, &devtools_client, &version, 284 port, context_getter, socket_factory, &devtools_client, &version,
281 &build_no); 285 &build_no);
282 if (status.IsError()) 286 if (status.IsError())
283 return status; 287 return status;
284 288
285 chrome->reset(new ChromeAndroidImpl( 289 chrome->reset(new ChromeAndroidImpl(
286 devtools_client.Pass(), version, build_no)); 290 devtools_client.Pass(), version, build_no, devtools_event_loggers));
287 return Status(kOk); 291 return Status(kOk);
288 } 292 }
289 293
290 } // namespace 294 } // namespace
291 295
292 Status LaunchChrome(URLRequestContextGetter* context_getter, 296 Status LaunchChrome(
293 int port, 297 URLRequestContextGetter* context_getter,
294 const SyncWebSocketFactory& socket_factory, 298 int port,
295 const Capabilities& capabilities, 299 const SyncWebSocketFactory& socket_factory,
296 scoped_ptr<Chrome>* chrome) { 300 const Capabilities& capabilities,
301 const std::list<DevToolsEventLogger*>& devtools_event_loggers,
302 scoped_ptr<Chrome>* chrome) {
297 if (capabilities.IsAndroid()) { 303 if (capabilities.IsAndroid()) {
298 return LaunchAndroidChrome( 304 return LaunchAndroidChrome(
299 context_getter, port, socket_factory, capabilities, chrome); 305 context_getter, port, socket_factory, capabilities,
306 devtools_event_loggers, chrome);
300 } else { 307 } else {
301 return LaunchDesktopChrome( 308 return LaunchDesktopChrome(
302 context_getter, port, socket_factory, capabilities, chrome); 309 context_getter, port, socket_factory, capabilities,
310 devtools_event_loggers, chrome);
303 } 311 }
304 } 312 }
305 313
306 namespace internal { 314 namespace internal {
307 315
308 Status ProcessExtensions(const std::vector<std::string>& extensions, 316 Status ProcessExtensions(const std::vector<std::string>& extensions,
309 const base::FilePath& temp_dir, 317 const base::FilePath& temp_dir,
310 bool include_automation_extension, 318 bool include_automation_extension,
311 CommandLine* command) { 319 CommandLine* command) {
312 std::vector<base::FilePath::StringType> extension_paths; 320 std::vector<base::FilePath::StringType> extension_paths;
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 // Write empty "First Run" file, otherwise Chrome will wipe the default 419 // Write empty "First Run" file, otherwise Chrome will wipe the default
412 // profile that was written. 420 // profile that was written.
413 if (file_util::WriteFile( 421 if (file_util::WriteFile(
414 user_data_dir.AppendASCII("First Run"), "", 0) != 0) { 422 user_data_dir.AppendASCII("First Run"), "", 0) != 0) {
415 return Status(kUnknownError, "failed to write first run file"); 423 return Status(kUnknownError, "failed to write first run file");
416 } 424 }
417 return Status(kOk); 425 return Status(kOk);
418 } 426 }
419 427
420 } // namespace internal 428 } // namespace internal
OLDNEW
« no previous file with comments | « chrome/test/chromedriver/chrome_launcher.h ('k') | chrome/test/chromedriver/command_executor_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698