Chromium Code Reviews| Index: tools/testing/dart/launch_browser.dart |
| =================================================================== |
| --- tools/testing/dart/launch_browser.dart (revision 0) |
| +++ tools/testing/dart/launch_browser.dart (revision 0) |
| @@ -0,0 +1,45 @@ |
| +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +/** |
| + * Simple command line interface to launcing browsers. |
| + * Uses the browser_controller framework. |
| + * The usage is: |
| + * DARTBIN launch_browser.dart BROWSER_NAME URL |
|
kustermann
2013/05/29 11:02:34
You could add a comment that DARTBIN should be the
ricow1
2013/05/29 11:46:31
Done.
|
| + */ |
| + |
| +import "dart:io"; |
| +import "browser_controller.dart"; |
| + |
| +const List<String> SUPPORTED_BROWSERS = |
| + const ['safari', 'ff', 'chrome']; |
|
kustermann
2013/05/29 11:02:34
Please add a TODO for me to make this work with an
ricow1
2013/05/29 11:46:31
Done.
|
| + |
| +bool supportedBrowser(String browser) { |
| + return SUPPORTED_BROWSERS.contains(browser); |
| +} |
| + |
| +void printHelp() { |
| + print(""" |
| +Usage pattern: |
| +launch_browser browser url |
| +Supported browsers: $SUPPORTED_BROWSERS |
| +"""); |
|
kustermann
2013/05/29 11:02:34
If you use three strings, you can indent then corr
ricow1
2013/05/29 11:46:31
Done.
|
| +} |
| + |
| +void main() { |
| + var args = new Options().arguments; |
| + if (args.length != 2) { |
| + print("Wrong number of arguments, please pass in exactly two arguments"); |
| + printHelp(); |
| + return; |
| + } |
| + if (!supportedBrowser(args[0])) { |
| + print("Specified browser not supported"); |
| + printHelp(); |
| + return; |
| + } |
| + var browser = new Browser.byName(args[0]); |
| + browser.start(args[1]); |
| + |
| +} |