| 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; | 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 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 | 487 |
| 488 | 488 |
| 489 final dartiumOnAndroidConfig = new AndroidBrowserConfig( | 489 final dartiumOnAndroidConfig = new AndroidBrowserConfig( |
| 490 'DartiumOnAndroid', | 490 'DartiumOnAndroid', |
| 491 'com.google.android.apps.chrome', | 491 'com.google.android.apps.chrome', |
| 492 '.Main', | 492 '.Main', |
| 493 'android.intent.action.VIEW'); | 493 'android.intent.action.VIEW'); |
| 494 | 494 |
| 495 | 495 |
| 496 class AndroidBrowser extends Browser { | 496 class AndroidBrowser extends Browser { |
| 497 final bool checkedMode; |
| 497 AdbDevice _adbDevice; | 498 AdbDevice _adbDevice; |
| 498 AndroidBrowserConfig _config; | 499 AndroidBrowserConfig _config; |
| 499 | 500 |
| 500 AndroidBrowser(this._adbDevice, this._config); | 501 AndroidBrowser(this._adbDevice, this._config, this.checkedMode); |
| 501 | 502 |
| 502 Future<bool> start(String url) { | 503 Future<bool> start(String url) { |
| 503 var intent = new Intent( | 504 var intent = new Intent( |
| 504 _config.action, _config.package, _config.activity, url); | 505 _config.action, _config.package, _config.activity, url); |
| 505 return _adbDevice.waitForBootCompleted().then((_) { | 506 return _adbDevice.waitForBootCompleted().then((_) { |
| 506 return _adbDevice.forceStop(_config.package); | 507 return _adbDevice.forceStop(_config.package); |
| 507 }).then((_) { | 508 }).then((_) { |
| 508 return _adbDevice.killAll(); | 509 return _adbDevice.killAll(); |
| 509 }).then((_) { | 510 }).then((_) { |
| 510 return _adbDevice.adbRoot(); | 511 return _adbDevice.adbRoot(); |
| 511 }).then((_) { | 512 }).then((_) { |
| 512 return _adbDevice.setProp("DART_FORWARDING_PRINT", "1"); | 513 return _adbDevice.setProp("DART_FORWARDING_PRINT", "1"); |
| 513 }).then((_) { | 514 }).then((_) { |
| 515 if (checkedMode) { |
| 516 return _adbDevice.setProp("DART_FLAGS", "--checked"); |
| 517 } else { |
| 518 return _adbDevice.setProp("DART_FLAGS", ""); |
| 519 } |
| 520 }).then((_) { |
| 514 return _adbDevice.startActivity(intent).then((_) => true); | 521 return _adbDevice.startActivity(intent).then((_) => true); |
| 515 }); | 522 }); |
| 516 } | 523 } |
| 517 | 524 |
| 518 Future<bool> close() { | 525 Future<bool> close() { |
| 519 if (_adbDevice != null) { | 526 if (_adbDevice != null) { |
| 520 return _adbDevice.forceStop(_config.package).then((_) { | 527 return _adbDevice.forceStop(_config.package).then((_) { |
| 521 return _adbDevice.killAll().then((_) => true); | 528 return _adbDevice.killAll().then((_) => true); |
| 522 }); | 529 }); |
| 523 } | 530 } |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 708 final BrowserOutput browserOutput; | 715 final BrowserOutput browserOutput; |
| 709 final String dom; | 716 final String dom; |
| 710 | 717 |
| 711 BrowserTestOutput( | 718 BrowserTestOutput( |
| 712 this.delayUntilTestStarted, this.duration, this.dom, | 719 this.delayUntilTestStarted, this.duration, this.dom, |
| 713 this.browserOutput, {this.didTimeout: false}); | 720 this.browserOutput, {this.didTimeout: false}); |
| 714 } | 721 } |
| 715 | 722 |
| 716 /** | 723 /** |
| 717 * Encapsulates all the functionality for running tests in browsers. | 724 * Encapsulates all the functionality for running tests in browsers. |
| 718 * The interface is rather simple. After starting the runner tests | 725 * The interface is rather simple. After starting, the runner tests |
| 719 * are simply added to the queue and a the supplied callbacks are called | 726 * are simply added to the queue and a the supplied callbacks are called |
| 720 * whenever a test completes. | 727 * whenever a test completes. |
| 721 */ | 728 */ |
| 722 class BrowserTestRunner { | 729 class BrowserTestRunner { |
| 723 final Map globalConfiguration; | 730 final Map globalConfiguration; |
| 724 final bool checkedMode; // needed for dartium | 731 final bool checkedMode; // needed for dartium |
| 725 | 732 |
| 726 String localIp; | 733 String localIp; |
| 727 String browserName; | 734 String browserName; |
| 728 int maxNumBrowsers; | 735 int maxNumBrowsers; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 781 }); | 788 }); |
| 782 } | 789 } |
| 783 | 790 |
| 784 Future<List<Browser>> getBrowsers() { | 791 Future<List<Browser>> getBrowsers() { |
| 785 // TODO(kustermann): This is a hackisch way to accomplish it and should | 792 // TODO(kustermann): This is a hackisch way to accomplish it and should |
| 786 // be encapsulated | 793 // be encapsulated |
| 787 var browsersCompleter = new Completer(); | 794 var browsersCompleter = new Completer(); |
| 788 var androidBrowserCreationMapping = { | 795 var androidBrowserCreationMapping = { |
| 789 'chromeOnAndroid' : (AdbDevice device) => new AndroidChrome(device), | 796 'chromeOnAndroid' : (AdbDevice device) => new AndroidChrome(device), |
| 790 'ContentShellOnAndroid' : (AdbDevice device) => | 797 'ContentShellOnAndroid' : (AdbDevice device) => |
| 791 new AndroidBrowser(device, contentShellOnAndroidConfig), | 798 new AndroidBrowser(device, contentShellOnAndroidConfig, checkedMode), |
| 792 'DartiumOnAndroid' : (AdbDevice device) => | 799 'DartiumOnAndroid' : (AdbDevice device) => |
| 793 new AndroidBrowser(device, dartiumOnAndroidConfig), | 800 new AndroidBrowser(device, dartiumOnAndroidConfig, checkedMode), |
| 794 }; | 801 }; |
| 795 if (androidBrowserCreationMapping.containsKey(browserName)) { | 802 if (androidBrowserCreationMapping.containsKey(browserName)) { |
| 796 AdbHelper.listDevices().then((deviceIds) { | 803 AdbHelper.listDevices().then((deviceIds) { |
| 797 if (deviceIds.length > 0) { | 804 if (deviceIds.length > 0) { |
| 798 var browsers = []; | 805 var browsers = []; |
| 799 for (int i = 0; i < deviceIds.length; i++) { | 806 for (int i = 0; i < deviceIds.length; i++) { |
| 800 var id = "BROWSER$i"; | 807 var id = "BROWSER$i"; |
| 801 var device = new AdbDevice(deviceIds[i]); | 808 var device = new AdbDevice(deviceIds[i]); |
| 802 adbDeviceMapping[id] = device; | 809 adbDeviceMapping[id] = device; |
| 803 var browser = androidBrowserCreationMapping[browserName](device); | 810 var browser = androidBrowserCreationMapping[browserName](device); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 908 status.currentTest = null; | 915 status.currentTest = null; |
| 909 | 916 |
| 910 // We don't want to start a new browser if we are terminating. | 917 // We don't want to start a new browser if we are terminating. |
| 911 if (underTermination) return; | 918 if (underTermination) return; |
| 912 var browser; | 919 var browser; |
| 913 var new_id = id; | 920 var new_id = id; |
| 914 if (browserName == 'chromeOnAndroid') { | 921 if (browserName == 'chromeOnAndroid') { |
| 915 browser = new AndroidChrome(adbDeviceMapping[id]); | 922 browser = new AndroidChrome(adbDeviceMapping[id]); |
| 916 } else if (browserName == 'ContentShellOnAndroid') { | 923 } else if (browserName == 'ContentShellOnAndroid') { |
| 917 browser = new AndroidBrowser(adbDeviceMapping[id], | 924 browser = new AndroidBrowser(adbDeviceMapping[id], |
| 918 contentShellOnAndroidConfig); | 925 contentShellOnAndroidConfig, |
| 926 checkedMode); |
| 919 } else if (browserName == 'DartiumOnAndroid') { | 927 } else if (browserName == 'DartiumOnAndroid') { |
| 920 browser = new AndroidBrowser(adbDeviceMapping[id], | 928 browser = new AndroidBrowser(adbDeviceMapping[id], |
| 921 dartiumOnAndroidConfig); | 929 dartiumOnAndroidConfig, |
| 930 checkedMode); |
| 922 } else { | 931 } else { |
| 923 browserStatus.remove(id); | 932 browserStatus.remove(id); |
| 924 browser = getInstance(); | 933 browser = getInstance(); |
| 925 new_id = "BROWSER$browserIdCount"; | 934 new_id = "BROWSER$browserIdCount"; |
| 926 browserIdCount++; | 935 browserIdCount++; |
| 927 browserStatus[new_id] = new BrowserTestingStatus(browser); | 936 browserStatus[new_id] = new BrowserTestingStatus(browser); |
| 928 } | 937 } |
| 929 browser.id = new_id; | 938 browser.id = new_id; |
| 930 browser.start(testingServer.getDriverUrl(new_id)).then((success) { | 939 browser.start(testingServer.getDriverUrl(new_id)).then((success) { |
| 931 // We may have started terminating in the mean time. | 940 // We may have started terminating in the mean time. |
| (...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1350 Dart test driver, number of tests: <div id="number"></div><br> | 1359 Dart test driver, number of tests: <div id="number"></div><br> |
| 1351 Currently executing: <div id="currently_executing"></div><br> | 1360 Currently executing: <div id="currently_executing"></div><br> |
| 1352 Unhandled error: <div id="unhandled_error"></div> | 1361 Unhandled error: <div id="unhandled_error"></div> |
| 1353 <iframe id="embedded_iframe"></iframe> | 1362 <iframe id="embedded_iframe"></iframe> |
| 1354 </body> | 1363 </body> |
| 1355 </html> | 1364 </html> |
| 1356 """; | 1365 """; |
| 1357 return driverContent; | 1366 return driverContent; |
| 1358 } | 1367 } |
| 1359 } | 1368 } |
| OLD | NEW |