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

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

Issue 23815007: Don't try to get chrome version on windows. (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 | « tools/bots/compiler.py ('k') | 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 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 // Delete the user specific browser cache and profile data. 311 // Delete the user specific browser cache and profile data.
312 // Safari only have one per user, and you can't specify one by command line. 312 // Safari only have one per user, and you can't specify one by command line.
313 static bool deleteCache = false; 313 static bool deleteCache = false;
314 314
315 } 315 }
316 316
317 317
318 class Chrome extends Browser { 318 class Chrome extends Browser {
319 static String _binary = _getBinary(); 319 static String _binary = _getBinary();
320 320
321 String _version = "Version not found yet";
322
321 // This is extracted to a function since we may need to support several 323 // This is extracted to a function since we may need to support several
322 // locations. 324 // locations.
323 static String _getWindowsBinary() { 325 static String _getWindowsBinary() {
324 return "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"; 326 return "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe";
325 } 327 }
326 328
327 static String _getBinary() { 329 static String _getBinary() {
328 if (Platform.isWindows) return _getWindowsBinary(); 330 if (Platform.isWindows) return _getWindowsBinary();
329 if (Platform.isMacOS) { 331 if (Platform.isMacOS) {
330 return "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"; 332 return "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome";
331 } 333 }
332 if (Platform.isLinux) return 'google-chrome'; 334 if (Platform.isLinux) return 'google-chrome';
333 } 335 }
334 336
337 Future<bool> _getVersion() {
338 if (Platform.isWindows) {
339 // The version flag does not work on windows.
340 // See issue:
341 // https://code.google.com/p/chromium/issues/detail?id=158372
342 // The registry hack does not seem to work.
343 _version = "Can't get version on windows";
344 // We still validate that the binary exists so that we can give good
345 // feedback.
346 return new File(_binary).exists().then((exists) {
347 if (!exists) {
348 _logEvent("Chrome binary not available.");
349 _logEvent("Make sure $_binary is a valid program for running chrome");
350 }
351 return exists;
352 });
353 }
354 return Process.run(_binary, ["--version"]).then((var versionResult) {
355 if (versionResult.exitCode != 0) {
356 _logEvent("Failed to chrome get version");
357 _logEvent("Make sure $_binary is a valid program for running chrome");
358 return false;
359 }
360 _version = versionResult.stdout;
361 return true;
362 });
363 }
364
365
335 Future<bool> start(String url) { 366 Future<bool> start(String url) {
336 _logEvent("Starting chrome browser on: $url"); 367 _logEvent("Starting chrome browser on: $url");
337 // Get the version and log that. 368 // Get the version and log that.
338 return Process.run(_binary, ["--version"]).then((var versionResult) { 369 return _getVersion().then((success) {
339 if (versionResult.exitCode != 0) { 370 if (!success) return false;
340 _logEvent("Failed to chrome get version"); 371 _logEvent("Got version: $_version");
341 _logEvent("Make sure $binary is a valid program for running chrome");
342 return new Future.value(false);
343 }
344 version = versionResult.stdout;
345 _logEvent("Got version: $version");
346 372
347 return new Directory('').createTemp().then((userDir) { 373 return new Directory('').createTemp().then((userDir) {
348 _cleanup = () { userDir.deleteSync(recursive: true); }; 374 _cleanup = () { userDir.deleteSync(recursive: true); };
349 var args = ["--user-data-dir=${userDir.path}", url, 375 var args = ["--user-data-dir=${userDir.path}", url,
350 "--disable-extensions", "--disable-popup-blocking", 376 "--disable-extensions", "--disable-popup-blocking",
351 "--bwsi", "--no-first-run"]; 377 "--bwsi", "--no-first-run"];
352 return startBrowser(_binary, args); 378 return startBrowser(_binary, args);
353
354 }); 379 });
355 }).catchError((e) { 380 }).catchError((e) {
356 _logEvent("Running $_binary --version failed with $e"); 381 _logEvent("Running $_binary --version failed with $e");
357 return false; 382 return false;
358 }); 383 });
359 } 384 }
360 385
361 String toString() => "Chrome"; 386 String toString() => "Chrome";
362 } 387 }
363 388
(...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after
1152 Dart test driver, number of tests: <div id="number"></div><br> 1177 Dart test driver, number of tests: <div id="number"></div><br>
1153 Currently executing: <div id="currently_executing"></div><br> 1178 Currently executing: <div id="currently_executing"></div><br>
1154 Unhandled error: <div id="unhandled_error"></div> 1179 Unhandled error: <div id="unhandled_error"></div>
1155 <iframe id="embedded_iframe"></iframe> 1180 <iframe id="embedded_iframe"></iframe>
1156 </body> 1181 </body>
1157 </html> 1182 </html>
1158 """; 1183 """;
1159 return driverContent; 1184 return driverContent;
1160 } 1185 }
1161 } 1186 }
OLDNEW
« no previous file with comments | « tools/bots/compiler.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698