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

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.isLinux) return 'google-chrome';
kustermann 2013/09/06 09:24:55 Please add the path for mac as well.
ricow1 2013/09/06 09:40:21 Done.
331 }
325 332
326 Future<bool> start(String url) { 333 Future<bool> start(String url) {
327 _logEvent("Starting chrome browser on: $url"); 334 _logEvent("Starting chrome browser on: $url");
328 // Get the version and log that. 335 // Get the version and log that.
329 return Process.run(binary, ["--version"]).then((var versionResult) { 336 return Process.run(_binary, ["--version"]).then((var versionResult) {
330 if (versionResult.exitCode != 0) { 337 if (versionResult.exitCode != 0) {
331 _logEvent("Failed to chrome get version"); 338 _logEvent("Failed to chrome get version");
332 _logEvent("Make sure $binary is a valid program for running chrome"); 339 _logEvent("Make sure $binary is a valid program for running chrome");
333 return new Future.value(false); 340 return new Future.value(false);
334 } 341 }
335 version = versionResult.stdout; 342 version = versionResult.stdout;
336 _logEvent("Got version: $version"); 343 _logEvent("Got version: $version");
337 344
338 return new Directory('').createTemp().then((userDir) { 345 return new Directory('').createTemp().then((userDir) {
339 _cleanup = () { userDir.deleteSync(recursive: true); }; 346 _cleanup = () { userDir.deleteSync(recursive: true); };
340 var args = ["--user-data-dir=${userDir.path}", url, 347 var args = ["--user-data-dir=${userDir.path}", url,
341 "--disable-extensions", "--disable-popup-blocking", 348 "--disable-extensions", "--disable-popup-blocking",
342 "--bwsi", "--no-first-run"]; 349 "--bwsi", "--no-first-run"];
343 return startBrowser(binary, args); 350 return startBrowser(_binary, args);
344 351
345 }); 352 });
346 }).catchError((e) { 353 }).catchError((e) {
347 _logEvent("Running $binary --version failed with $e"); 354 _logEvent("Running $binary --version failed with $e");
348 return false; 355 return false;
349 }); 356 });
350 } 357 }
351 358
352 String toString() => "Chrome"; 359 String toString() => "Chrome";
353 } 360 }
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 // locations. 484 // locations.
478 static String _getWindowsBinary() { 485 static String _getWindowsBinary() {
479 return "C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe"; 486 return "C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe";
480 } 487 }
481 488
482 static String _getBinary() { 489 static String _getBinary() {
483 if (Platform.isWindows) return _getWindowsBinary(); 490 if (Platform.isWindows) return _getWindowsBinary();
484 if (Platform.isLinux) return 'firefox'; 491 if (Platform.isLinux) return 'firefox';
485 } 492 }
486 493
487
488 Future<bool> start(String url) { 494 Future<bool> start(String url) {
489 _logEvent("Starting firefox browser on: $url"); 495 _logEvent("Starting firefox browser on: $url");
490 // Get the version and log that. 496 // Get the version and log that.
491 return Process.run(_binary, ["--version"]).then((var versionResult) { 497 return Process.run(_binary, ["--version"]).then((var versionResult) {
492 if (versionResult.exitCode != 0) { 498 if (versionResult.exitCode != 0) {
493 _logEvent("Failed to firefox get version"); 499 _logEvent("Failed to firefox get version");
494 _logEvent("Make sure $binary is a valid program for running firefox"); 500 _logEvent("Make sure $binary is a valid program for running firefox");
495 return new Future.value(false); 501 return new Future.value(false);
496 } 502 }
497 version = versionResult.stdout; 503 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> 1150 Dart test driver, number of tests: <div id="number"></div><br>
1145 Currently executing: <div id="currently_executing"></div><br> 1151 Currently executing: <div id="currently_executing"></div><br>
1146 Unhandled error: <div id="unhandled_error"></div> 1152 Unhandled error: <div id="unhandled_error"></div>
1147 <iframe id="embedded_iframe"></iframe> 1153 <iframe id="embedded_iframe"></iframe>
1148 </body> 1154 </body>
1149 </html> 1155 </html>
1150 """; 1156 """;
1151 return driverContent; 1157 return driverContent;
1152 } 1158 }
1153 } 1159 }
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