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

Side by Side Diff: tools/testing/dart/browser_controller.dart

Issue 23625008: Add support for chrome on windows to the new browser controller (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 library browser; 4 library browser;
5 5
6 import "dart:async"; 6 import "dart:async";
7 import "dart:convert" show LineSplitter, UTF8; 7 import "dart:convert" show LineSplitter, UTF8;
8 import "dart:core"; 8 import "dart:core";
9 import "dart:io"; 9 import "dart:io";
10 10
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 String toString() => "Safari"; 310 String toString() => "Safari";
311 311
312 // Delete the user specific browser cache and profile data. 312 // Delete the user specific browser cache and profile data.
313 // Safari only have one per user, and you can't specify one by command line. 313 // Safari only have one per user, and you can't specify one by command line.
314 static bool deleteCache = false; 314 static bool deleteCache = false;
315 315
316 } 316 }
317 317
318 318
319 class Chrome extends Browser { 319 class Chrome extends Browser {
320 /** 320 static String _binary = _getBinary();
321 * The binary used to run chrome - changing this can be nececcary for 321
322 * testing or using non standard chrome installation. 322 // This is extracted to a function since we may need to support several
323 */ 323 // locations.
324 static const String binary = "google-chrome"; 324 static String _getWindowsBinary() {
325 return "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe";
326 }
327
328 static String _getBinary() {
329 if (Platform.isWindows) return _getWindowsBinary();
330 if (Platform.isMacOS) {
331 return "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome";
332 }
333 if (Platform.isLinux) return 'google-chrome';
334 }
325 335
326 Future<bool> start(String url) { 336 Future<bool> start(String url) {
327 _logEvent("Starting chrome browser on: $url"); 337 _logEvent("Starting chrome browser on: $url");
328 // Get the version and log that. 338 // Get the version and log that.
329 return Process.run(binary, ["--version"]).then((var versionResult) { 339 return Process.run(_binary, ["--version"]).then((var versionResult) {
330 if (versionResult.exitCode != 0) { 340 if (versionResult.exitCode != 0) {
331 _logEvent("Failed to chrome get version"); 341 _logEvent("Failed to chrome get version");
332 _logEvent("Make sure $binary is a valid program for running chrome"); 342 _logEvent("Make sure $binary is a valid program for running chrome");
333 return new Future.value(false); 343 return new Future.value(false);
334 } 344 }
335 version = versionResult.stdout; 345 version = versionResult.stdout;
336 _logEvent("Got version: $version"); 346 _logEvent("Got version: $version");
337 347
338 return new Directory('').createTemp().then((userDir) { 348 return new Directory('').createTemp().then((userDir) {
339 _cleanup = () { userDir.deleteSync(recursive: true); }; 349 _cleanup = () { userDir.deleteSync(recursive: true); };
340 var args = ["--user-data-dir=${userDir.path}", url, 350 var args = ["--user-data-dir=${userDir.path}", url,
341 "--disable-extensions", "--disable-popup-blocking", 351 "--disable-extensions", "--disable-popup-blocking",
342 "--bwsi", "--no-first-run"]; 352 "--bwsi", "--no-first-run"];
343 return startBrowser(binary, args); 353 return startBrowser(_binary, args);
344 354
345 }); 355 });
346 }).catchError((e) { 356 }).catchError((e) {
347 _logEvent("Running $binary --version failed with $e"); 357 _logEvent("Running $binary --version failed with $e");
348 return false; 358 return false;
349 }); 359 });
350 } 360 }
351 361
352 String toString() => "Chrome"; 362 String toString() => "Chrome";
353 } 363 }
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 // locations. 487 // locations.
478 static String _getWindowsBinary() { 488 static String _getWindowsBinary() {
479 return "C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe"; 489 return "C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe";
480 } 490 }
481 491
482 static String _getBinary() { 492 static String _getBinary() {
483 if (Platform.isWindows) return _getWindowsBinary(); 493 if (Platform.isWindows) return _getWindowsBinary();
484 if (Platform.isLinux) return 'firefox'; 494 if (Platform.isLinux) return 'firefox';
485 } 495 }
486 496
487
488 Future<bool> start(String url) { 497 Future<bool> start(String url) {
489 _logEvent("Starting firefox browser on: $url"); 498 _logEvent("Starting firefox browser on: $url");
490 // Get the version and log that. 499 // Get the version and log that.
491 return Process.run(_binary, ["--version"]).then((var versionResult) { 500 return Process.run(_binary, ["--version"]).then((var versionResult) {
492 if (versionResult.exitCode != 0) { 501 if (versionResult.exitCode != 0) {
493 _logEvent("Failed to firefox get version"); 502 _logEvent("Failed to firefox get version");
494 _logEvent("Make sure $binary is a valid program for running firefox"); 503 _logEvent("Make sure $binary is a valid program for running firefox");
495 return new Future.value(false); 504 return new Future.value(false);
496 } 505 }
497 version = versionResult.stdout; 506 version = versionResult.stdout;
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after
1144 Dart test driver, number of tests: <div id="number"></div><br> 1153 Dart test driver, number of tests: <div id="number"></div><br>
1145 Currently executing: <div id="currently_executing"></div><br> 1154 Currently executing: <div id="currently_executing"></div><br>
1146 Unhandled error: <div id="unhandled_error"></div> 1155 Unhandled error: <div id="unhandled_error"></div>
1147 <iframe id="embedded_iframe"></iframe> 1156 <iframe id="embedded_iframe"></iframe>
1148 </body> 1157 </body>
1149 </html> 1158 </html>
1150 """; 1159 """;
1151 return driverContent; 1160 return driverContent;
1152 } 1161 }
1153 } 1162 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698