| 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 library browser; | 4 library browser; |
| 5 | 5 |
| 6 import "dart:async"; | 6 import "dart:async"; |
| 7 import "dart:convert" show LineSplitter, UTF8, JSON; | 7 import "dart:convert" show LineSplitter, UTF8, JSON; |
| 8 import "dart:core"; | 8 import "dart:core"; |
| 9 import "dart:io"; | 9 import "dart:io"; |
| 10 | 10 |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 /** | 240 /** |
| 241 * Get the output that was written so far to stdout/stderr/eventLog. | 241 * Get the output that was written so far to stdout/stderr/eventLog. |
| 242 */ | 242 */ |
| 243 BrowserOutput get allBrowserOutput => _allBrowserOutput; | 243 BrowserOutput get allBrowserOutput => _allBrowserOutput; |
| 244 BrowserOutput get testBrowserOutput => _testBrowserOutput; | 244 BrowserOutput get testBrowserOutput => _testBrowserOutput; |
| 245 | 245 |
| 246 void resetTestBrowserOutput() { | 246 void resetTestBrowserOutput() { |
| 247 _testBrowserOutput = new BrowserOutput(); | 247 _testBrowserOutput = new BrowserOutput(); |
| 248 } | 248 } |
| 249 | 249 |
| 250 /** |
| 251 * Add useful info about the browser to the _testBrowserOutput.stdout, |
| 252 * where it will be reported for failing tests. Used to report which |
| 253 * android device a failing test is running on. |
| 254 */ |
| 255 void logBrowserInfoToTestBrowserOutput() { } |
| 256 |
| 250 String toString(); | 257 String toString(); |
| 251 | 258 |
| 252 /** Starts the browser loading the given url */ | 259 /** Starts the browser loading the given url */ |
| 253 Future<bool> start(String url); | 260 Future<bool> start(String url); |
| 254 } | 261 } |
| 255 | 262 |
| 256 class Safari extends Browser { | 263 class Safari extends Browser { |
| 257 /** | 264 /** |
| 258 * We get the safari version by parsing a version file | 265 * We get the safari version by parsing a version file |
| 259 */ | 266 */ |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 613 | 620 |
| 614 Future<bool> close() { | 621 Future<bool> close() { |
| 615 if (_adbDevice != null) { | 622 if (_adbDevice != null) { |
| 616 return _adbDevice.forceStop(_config.package).then((_) { | 623 return _adbDevice.forceStop(_config.package).then((_) { |
| 617 return _adbDevice.killAll().then((_) => true); | 624 return _adbDevice.killAll().then((_) => true); |
| 618 }); | 625 }); |
| 619 } | 626 } |
| 620 return new Future.value(true); | 627 return new Future.value(true); |
| 621 } | 628 } |
| 622 | 629 |
| 630 void logBrowserInfoToTestBrowserOutput() { |
| 631 _testBrowserOutput.stdout.write( |
| 632 'Android device id: ${_adbDevice.deviceId}\n'); |
| 633 } |
| 634 |
| 623 String toString() => _config.name; | 635 String toString() => _config.name; |
| 624 } | 636 } |
| 625 | 637 |
| 626 | 638 |
| 627 class AndroidChrome extends Browser { | 639 class AndroidChrome extends Browser { |
| 628 static const String viewAction = 'android.intent.action.VIEW'; | 640 static const String viewAction = 'android.intent.action.VIEW'; |
| 629 static const String mainAction = 'android.intent.action.MAIN'; | 641 static const String mainAction = 'android.intent.action.MAIN'; |
| 630 static const String chromePackage = 'com.android.chrome'; | 642 static const String chromePackage = 'com.android.chrome'; |
| 631 static const String browserPackage = 'com.android.browser'; | 643 static const String browserPackage = 'com.android.browser'; |
| 632 static const String firefoxPackage = 'org.mozilla.firefox'; | 644 static const String firefoxPackage = 'org.mozilla.firefox'; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 680 | 692 |
| 681 Future<bool> close() { | 693 Future<bool> close() { |
| 682 if (_adbDevice != null) { | 694 if (_adbDevice != null) { |
| 683 return _adbDevice.forceStop(chromePackage).then((_) { | 695 return _adbDevice.forceStop(chromePackage).then((_) { |
| 684 return _adbDevice.killAll().then((_) => true); | 696 return _adbDevice.killAll().then((_) => true); |
| 685 }); | 697 }); |
| 686 } | 698 } |
| 687 return new Future.value(true); | 699 return new Future.value(true); |
| 688 } | 700 } |
| 689 | 701 |
| 702 void logBrowserInfoToTestBrowserOutput() { |
| 703 _testBrowserOutput.stdout.write( |
| 704 'Android device id: ${_adbDevice.deviceId}\n'); |
| 705 } |
| 706 |
| 690 String toString() => "chromeOnAndroid"; | 707 String toString() => "chromeOnAndroid"; |
| 691 } | 708 } |
| 692 | 709 |
| 693 | 710 |
| 694 class Firefox extends Browser { | 711 class Firefox extends Browser { |
| 695 static const String enablePopUp = | 712 static const String enablePopUp = |
| 696 'user_pref("dom.disable_open_during_load", false);'; | 713 'user_pref("dom.disable_open_during_load", false);'; |
| 697 static const String disableDefaultCheck = | 714 static const String disableDefaultCheck = |
| 698 'user_pref("browser.shell.checkDefaultBrowser", false);'; | 715 'user_pref("browser.shell.checkDefaultBrowser", false);'; |
| 699 static const String disableScriptTimeLimit = | 716 static const String disableScriptTimeLimit = |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1160 for (var v in timedOut) { | 1177 for (var v in timedOut) { |
| 1161 print(" $v"); | 1178 print(" $v"); |
| 1162 } | 1179 } |
| 1163 exit(1); | 1180 exit(1); |
| 1164 } | 1181 } |
| 1165 | 1182 |
| 1166 status.currentTest.timeoutTimer = createTimeoutTimer(test, status); | 1183 status.currentTest.timeoutTimer = createTimeoutTimer(test, status); |
| 1167 status.currentTest.stopwatch = new Stopwatch()..start(); | 1184 status.currentTest.stopwatch = new Stopwatch()..start(); |
| 1168 | 1185 |
| 1169 // Reset the test specific output information (stdout, stderr) on the | 1186 // Reset the test specific output information (stdout, stderr) on the |
| 1170 // browser since a new test is begin started. | 1187 // browser, since a new test is being started. |
| 1171 status.browser.resetTestBrowserOutput(); | 1188 status.browser.resetTestBrowserOutput(); |
| 1189 status.browser.logBrowserInfoToTestBrowserOutput(); |
| 1172 | 1190 |
| 1173 return test; | 1191 return test; |
| 1174 } | 1192 } |
| 1175 | 1193 |
| 1176 Timer createTimeoutTimer(BrowserTest test, BrowserTestingStatus status) { | 1194 Timer createTimeoutTimer(BrowserTest test, BrowserTestingStatus status) { |
| 1177 return new Timer(new Duration(seconds: test.timeout), | 1195 return new Timer(new Duration(seconds: test.timeout), |
| 1178 () { handleTimeout(status); }); | 1196 () { handleTimeout(status); }); |
| 1179 } | 1197 } |
| 1180 | 1198 |
| 1181 Timer createNextTestTimer(BrowserTestingStatus status) { | 1199 Timer createNextTestTimer(BrowserTestingStatus status) { |
| (...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1766 </div> | 1784 </div> |
| 1767 <div id="embedded_iframe_div" class="test box"> | 1785 <div id="embedded_iframe_div" class="test box"> |
| 1768 <iframe style="width:100%;height:100%;" id="embedded_iframe"></iframe> | 1786 <iframe style="width:100%;height:100%;" id="embedded_iframe"></iframe> |
| 1769 </div> | 1787 </div> |
| 1770 </body> | 1788 </body> |
| 1771 </html> | 1789 </html> |
| 1772 """; | 1790 """; |
| 1773 return driverContent; | 1791 return driverContent; |
| 1774 } | 1792 } |
| 1775 } | 1793 } |
| OLD | NEW |