Chromium Code Reviews| Index: tools/testing/dart/browser_controller.dart |
| =================================================================== |
| --- tools/testing/dart/browser_controller.dart (revision 27322) |
| +++ tools/testing/dart/browser_controller.dart (working copy) |
| @@ -40,7 +40,7 @@ |
| String id; |
| /** Print everything (stdout, stderr, usageLog) whenever we add to it */ |
| - bool debugPrint = false; |
| + bool debugPrint = true; |
| // This future returns when the process exits. It is also the return value |
| // of close() |
| @@ -318,6 +318,8 @@ |
| class Chrome extends Browser { |
| static String _binary = _getBinary(); |
| + String _version = "Version not found yet"; |
|
kustermann
2013/09/10 09:27:01
I'm not totally happy about this. You add new inst
ricow1
2013/09/10 10:07:04
Seems like a valid instance variable to me. Could
kustermann
2013/09/10 10:32:43
The issue that _version is not available right fro
|
| + |
| // This is extracted to a function since we may need to support several |
| // locations. |
| static String _getWindowsBinary() { |
| @@ -332,18 +334,42 @@ |
| if (Platform.isLinux) return 'google-chrome'; |
| } |
| - Future<bool> start(String url) { |
| - _logEvent("Starting chrome browser on: $url"); |
| - // Get the version and log that. |
| + Future<String> _getVersion() { |
|
kustermann
2013/09/10 09:27:01
Make it Future<bool>
ricow1
2013/09/10 10:07:04
Done.
|
| + if (Platform.isWindows) { |
| + // The version flag does not work on windows. |
| + // See issue: |
| + // https://code.google.com/p/chromium/issues/detail?id=158372 |
| + // The registry hack does not seem to work. |
| + _version = "Can't get version on windows"; |
| + // We still validate that the binary exists so that we can give good |
| + // feedback. |
| + return new File(_binary).exists().then((exists) { |
| + if (!exists) { |
| + _logEvent("Chrome binary not available."); |
|
kustermann
2013/09/10 09:27:01
How about printing the path (i.e. _binary) here as
ricow1
2013/09/10 10:07:04
I do, in the next line!
|
| + _logEvent("Make sure $_binary is a valid program for running chrome"); |
| + } |
| + return exists; |
| + }); |
| + } |
| return Process.run(_binary, ["--version"]).then((var versionResult) { |
| if (versionResult.exitCode != 0) { |
| _logEvent("Failed to chrome get version"); |
| - _logEvent("Make sure $binary is a valid program for running chrome"); |
| - return new Future.value(false); |
| + _logEvent("Make sure $_binary is a valid program for running chrome"); |
| + return false; |
| } |
| - version = versionResult.stdout; |
| - _logEvent("Got version: $version"); |
| + _version = versionResult.stdout; |
| + return true; |
| + }); |
| + } |
| + |
| + Future<bool> start(String url) { |
| + _logEvent("Starting chrome browser on: $url"); |
| + // Get the version and log that. |
| + return _getVersion().then((success) { |
| + if (!success) return false; |
| + _logEvent("Got version: $_version"); |
| + |
| return new Directory('').createTemp().then((userDir) { |
| _cleanup = () { userDir.deleteSync(recursive: true); }; |
| var args = ["--user-data-dir=${userDir.path}", url, |