OLD | NEW |
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 | 4 |
5 import 'dart:async'; | 5 import 'dart:async'; |
6 import 'dart:convert'; | 6 import 'dart:convert'; |
7 import 'dart:core'; | 7 import 'dart:core'; |
8 import 'dart:io'; | 8 import 'dart:io'; |
9 import 'dart:math'; | 9 import 'dart:math'; |
10 | 10 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 factory Browser.byRuntime(Runtime runtime, String executablePath, | 74 factory Browser.byRuntime(Runtime runtime, String executablePath, |
75 [bool checkedMode = false]) { | 75 [bool checkedMode = false]) { |
76 Browser browser; | 76 Browser browser; |
77 switch (runtime) { | 77 switch (runtime) { |
78 case Runtime.firefox: | 78 case Runtime.firefox: |
79 browser = new Firefox(); | 79 browser = new Firefox(); |
80 break; | 80 break; |
81 case Runtime.chrome: | 81 case Runtime.chrome: |
82 browser = new Chrome(); | 82 browser = new Chrome(); |
83 break; | 83 break; |
84 case Runtime.dartium: | |
85 browser = new Dartium(checkedMode); | |
86 break; | |
87 case Runtime.safari: | 84 case Runtime.safari: |
88 browser = new Safari(); | 85 browser = new Safari(); |
89 break; | 86 break; |
90 case Runtime.safariMobileSim: | 87 case Runtime.safariMobileSim: |
91 browser = new SafariMobileSimulator(); | 88 browser = new SafariMobileSimulator(); |
92 break; | 89 break; |
93 case Runtime.ie9: | 90 case Runtime.ie9: |
94 case Runtime.ie10: | 91 case Runtime.ie10: |
95 case Runtime.ie11: | 92 case Runtime.ie11: |
96 browser = new IE(); | 93 browser = new IE(); |
97 break; | 94 break; |
98 default: | 95 default: |
99 throw "unreachable"; | 96 throw "unreachable"; |
100 } | 97 } |
101 | 98 |
102 browser._binary = executablePath; | 99 browser._binary = executablePath; |
103 return browser; | 100 return browser; |
104 } | 101 } |
105 | 102 |
106 static const List<String> SUPPORTED_BROWSERS = const [ | 103 static const List<String> SUPPORTED_BROWSERS = const [ |
107 'safari', | 104 'safari', |
108 'ff', | 105 'ff', |
109 'firefox', | 106 'firefox', |
110 'chrome', | 107 'chrome', |
111 'ie9', | 108 'ie9', |
112 'ie10', | 109 'ie10', |
113 'ie11', | 110 'ie11' |
114 'dartium' | |
115 ]; | 111 ]; |
116 | 112 |
117 static bool requiresFocus(String browserName) { | 113 static bool requiresFocus(String browserName) { |
118 return browserName == "safari"; | 114 return browserName == "safari"; |
119 } | 115 } |
120 | 116 |
121 // TODO(kustermann): add standard support for chrome on android | 117 // TODO(kustermann): add standard support for chrome on android |
122 static bool supportedBrowser(String name) { | 118 static bool supportedBrowser(String name) { |
123 return SUPPORTED_BROWSERS.contains(name); | 119 return SUPPORTED_BROWSERS.contains(name); |
124 } | 120 } |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
577 return startBrowserProcess(_binary, args).catchError((e) { | 573 return startBrowserProcess(_binary, args).catchError((e) { |
578 _logEvent("Running $_binary --version failed with $e"); | 574 _logEvent("Running $_binary --version failed with $e"); |
579 return false; | 575 return false; |
580 }); | 576 }); |
581 }); | 577 }); |
582 } | 578 } |
583 | 579 |
584 String toString() => "SafariMobileSimulator"; | 580 String toString() => "SafariMobileSimulator"; |
585 } | 581 } |
586 | 582 |
587 class Dartium extends Chrome { | |
588 final bool checkedMode; | |
589 | |
590 Dartium(this.checkedMode); | |
591 | |
592 Map<String, String> _getEnvironment() { | |
593 var environment = new Map<String, String>.from(Platform.environment); | |
594 // By setting this environment variable, dartium will forward "print()" | |
595 // calls in dart to the top-level javascript function "dartPrint()" if | |
596 // available. | |
597 environment['DART_FORWARDING_PRINT'] = '1'; | |
598 if (checkedMode) { | |
599 environment['DART_FLAGS'] = '--checked'; | |
600 } | |
601 return environment; | |
602 } | |
603 | |
604 String toString() => "Dartium"; | |
605 } | |
606 | |
607 class IE extends Browser { | 583 class IE extends Browser { |
608 Future<String> getVersion() { | 584 Future<String> getVersion() { |
609 var args = [ | 585 var args = [ |
610 "query", | 586 "query", |
611 "HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Internet Explorer", | 587 "HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Internet Explorer", |
612 "/v", | 588 "/v", |
613 "svcVersion" | 589 "svcVersion" |
614 ]; | 590 ]; |
615 return Process.run("reg", args).then((result) { | 591 return Process.run("reg", args).then((result) { |
616 if (result.exitCode == 0) { | 592 if (result.exitCode == 0) { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 final String action; | 639 final String action; |
664 AndroidBrowserConfig(this.name, this.package, this.activity, this.action); | 640 AndroidBrowserConfig(this.name, this.package, this.activity, this.action); |
665 } | 641 } |
666 | 642 |
667 final contentShellOnAndroidConfig = new AndroidBrowserConfig( | 643 final contentShellOnAndroidConfig = new AndroidBrowserConfig( |
668 'ContentShellOnAndroid', | 644 'ContentShellOnAndroid', |
669 'org.chromium.content_shell_apk', | 645 'org.chromium.content_shell_apk', |
670 '.ContentShellActivity', | 646 '.ContentShellActivity', |
671 'android.intent.action.VIEW'); | 647 'android.intent.action.VIEW'); |
672 | 648 |
673 final dartiumOnAndroidConfig = new AndroidBrowserConfig('DartiumOnAndroid', | |
674 'com.google.android.apps.chrome', '.Main', 'android.intent.action.VIEW'); | |
675 | |
676 class AndroidBrowser extends Browser { | 649 class AndroidBrowser extends Browser { |
677 final bool checkedMode; | 650 final bool checkedMode; |
678 AdbDevice _adbDevice; | 651 AdbDevice _adbDevice; |
679 AndroidBrowserConfig _config; | 652 AndroidBrowserConfig _config; |
680 | 653 |
681 AndroidBrowser( | 654 AndroidBrowser( |
682 this._adbDevice, this._config, this.checkedMode, String apkPath) { | 655 this._adbDevice, this._config, this.checkedMode, String apkPath) { |
683 _binary = apkPath; | 656 _binary = apkPath; |
684 } | 657 } |
685 | 658 |
(...skipping 1259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1945 'exit code: ${result.exitCode}\n' | 1918 'exit code: ${result.exitCode}\n' |
1946 'stdout: ${result.stdout}\n' | 1919 'stdout: ${result.stdout}\n' |
1947 'stderr: ${result.stderr}'); | 1920 'stderr: ${result.stderr}'); |
1948 } else { | 1921 } else { |
1949 print('[$message] Successfully uploaded screenshot to $storageUrl'); | 1922 print('[$message] Successfully uploaded screenshot to $storageUrl'); |
1950 } | 1923 } |
1951 new File(screenshotFile).deleteSync(); | 1924 new File(screenshotFile).deleteSync(); |
1952 } | 1925 } |
1953 print('--------------------------------------------------------------------'); | 1926 print('--------------------------------------------------------------------'); |
1954 } | 1927 } |
OLD | NEW |