Chromium Code Reviews| 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 30 matching lines...) Expand all Loading... | |
| 41 | 41 |
| 42 /** Print everything (stdout, stderr, usageLog) whenever we add to it */ | 42 /** Print everything (stdout, stderr, usageLog) whenever we add to it */ |
| 43 bool debugPrint = false; | 43 bool debugPrint = false; |
| 44 | 44 |
| 45 // This future returns when the process exits. It is also the return value | 45 // This future returns when the process exits. It is also the return value |
| 46 // of close() | 46 // of close() |
| 47 Future done; | 47 Future done; |
| 48 | 48 |
| 49 Browser(); | 49 Browser(); |
| 50 | 50 |
| 51 factory Browser.byName(String name) { | 51 factory Browser.byName(String name, [Map globalConfiguration = const {}]) { |
| 52 if (name == 'ff' || name == 'firefox') { | 52 if (name == 'ff' || name == 'firefox') { |
| 53 return new Firefox(); | 53 return new Firefox(); |
| 54 } else if (name == 'chrome') { | 54 } else if (name == 'chrome') { |
| 55 return new Chrome(); | 55 return new Chrome(); |
| 56 } else if (name == 'dartium') { | 56 } else if (name == 'dartium') { |
| 57 return new Dartium(); | 57 return new Dartium(globalConfiguration); |
| 58 } else if (name == 'safari') { | 58 } else if (name == 'safari') { |
| 59 return new Safari(); | 59 return new Safari(); |
| 60 } else if (name.startsWith('ie')) { | 60 } else if (name.startsWith('ie')) { |
| 61 return new IE(); | 61 return new IE(); |
| 62 } else { | 62 } else { |
| 63 throw "Non supported browser"; | 63 throw "Non supported browser"; |
| 64 } | 64 } |
| 65 } | 65 } |
| 66 | 66 |
| 67 static const List<String> SUPPORTED_BROWSERS = | 67 static const List<String> SUPPORTED_BROWSERS = |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 386 }).catchError((e) { | 386 }).catchError((e) { |
| 387 _logEvent("Running $_binary --version failed with $e"); | 387 _logEvent("Running $_binary --version failed with $e"); |
| 388 return false; | 388 return false; |
| 389 }); | 389 }); |
| 390 } | 390 } |
| 391 | 391 |
| 392 String toString() => "Chrome"; | 392 String toString() => "Chrome"; |
| 393 } | 393 } |
| 394 | 394 |
| 395 class Dartium extends Chrome { | 395 class Dartium extends Chrome { |
| 396 final Map globalConfiguration; | |
| 397 | |
| 398 Dartium(this.globalConfiguration); | |
| 399 | |
| 396 String _getBinary() { | 400 String _getBinary() { |
| 397 if (Platform.operatingSystem == 'macos') { | 401 return Locations.getDartiumLocation(globalConfiguration); |
| 398 return new Path('client/tests/dartium/Chromium.app/Contents/' | |
| 399 'MacOS/Chromium').toNativePath(); | |
| 400 } | |
| 401 return new Path('client/tests/dartium/chrome').toNativePath(); | |
| 402 } | 402 } |
| 403 | 403 |
| 404 Map<String, String> _getEnvironment() { | 404 Map<String, String> _getEnvironment() { |
| 405 var environment = new Map<String,String>.from(Platform.environment); | 405 var environment = new Map<String,String>.from(Platform.environment); |
| 406 // By setting this environment variable, dartium will forward "print()" | 406 // By setting this environment variable, dartium will forward "print()" |
| 407 // calls in dart to the top-level javascript function "dartPrint()" if | 407 // calls in dart to the top-level javascript function "dartPrint()" if |
| 408 // available. | 408 // available. |
| 409 environment['DART_FORWARDING_PRINT'] = '1'; | 409 environment['DART_FORWARDING_PRINT'] = '1'; |
| 410 return environment; | 410 return environment; |
| 411 } | 411 } |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 621 } | 621 } |
| 622 | 622 |
| 623 | 623 |
| 624 /** | 624 /** |
| 625 * Encapsulates all the functionality for running tests in browsers. | 625 * Encapsulates all the functionality for running tests in browsers. |
| 626 * The interface is rather simple. After starting the runner tests | 626 * The interface is rather simple. After starting the runner tests |
| 627 * are simply added to the queue and a the supplied callbacks are called | 627 * are simply added to the queue and a the supplied callbacks are called |
| 628 * whenever a test completes. | 628 * whenever a test completes. |
| 629 */ | 629 */ |
| 630 class BrowserTestRunner { | 630 class BrowserTestRunner { |
| 631 final Map globalConfiguration; | |
| 632 | |
| 631 String local_ip; | 633 String local_ip; |
|
kasperl
2013/10/03 14:14:18
Would it be super painful to change this to localI
kustermann
2013/10/03 14:48:22
Maybe. I'll try to suppress the pain.
| |
| 632 String browserName; | 634 String browserName; |
| 633 int maxNumBrowsers; | 635 int maxNumBrowsers; |
| 634 // Used to send back logs from the browser (start, stop etc) | 636 // Used to send back logs from the browser (start, stop etc) |
| 635 Function logger; | 637 Function logger; |
| 636 int browserIdCount = 0; | 638 int browserIdCount = 0; |
| 637 | 639 |
| 638 bool underTermination = false; | 640 bool underTermination = false; |
| 639 | 641 |
| 640 List<BrowserTest> testQueue = new List<BrowserTest>(); | 642 List<BrowserTest> testQueue = new List<BrowserTest>(); |
| 641 Map<String, BrowserTestingStatus> browserStatus = | 643 Map<String, BrowserTestingStatus> browserStatus = |
| 642 new Map<String, BrowserTestingStatus>(); | 644 new Map<String, BrowserTestingStatus>(); |
| 643 | 645 |
| 644 var adbDeviceMapping = new Map<String, AdbDevice>(); | 646 var adbDeviceMapping = new Map<String, AdbDevice>(); |
| 645 // This cache is used to guarantee that we never see double reporting. | 647 // This cache is used to guarantee that we never see double reporting. |
| 646 // If we do we need to provide developers with this information. | 648 // If we do we need to provide developers with this information. |
| 647 // We don't add urls to the cache until we have run it. | 649 // We don't add urls to the cache until we have run it. |
| 648 Map<int, String> testCache = new Map<int, String>(); | 650 Map<int, String> testCache = new Map<int, String>(); |
| 649 Map<int, String> doubleReportingOutputs = new Map<int, String>(); | 651 Map<int, String> doubleReportingOutputs = new Map<int, String>(); |
| 650 | 652 |
| 651 BrowserTestingServer testingServer; | 653 BrowserTestingServer testingServer; |
| 652 | 654 |
| 653 BrowserTestRunner(this.local_ip, this.browserName, this.maxNumBrowsers); | 655 BrowserTestRunner(this.globalConfiguration, |
| 656 this.local_ip, | |
| 657 this.browserName, | |
| 658 this.maxNumBrowsers); | |
| 654 | 659 |
| 655 Future<bool> start() { | 660 Future<bool> start() { |
| 656 // If [browserName] doesn't support opening new windows, we use new iframes | 661 // If [browserName] doesn't support opening new windows, we use new iframes |
| 657 // instead. | 662 // instead. |
| 658 bool useIframe = | 663 bool useIframe = |
| 659 !Browser.BROWSERS_WITH_WINDOW_SUPPORT.contains(browserName); | 664 !Browser.BROWSERS_WITH_WINDOW_SUPPORT.contains(browserName); |
| 660 testingServer = new BrowserTestingServer(local_ip, useIframe); | 665 testingServer = new BrowserTestingServer(local_ip, useIframe); |
| 661 return testingServer.start().then((_) { | 666 return testingServer.start().then((_) { |
| 662 testingServer.testDoneCallBack = handleResults; | 667 testingServer.testDoneCallBack = handleResults; |
| 663 testingServer.testStartedCallBack = handleStarted; | 668 testingServer.testStartedCallBack = handleStarted; |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 886 } | 891 } |
| 887 return Future.wait(futures).then((values) { | 892 return Future.wait(futures).then((values) { |
| 888 testingServer.httpServer.close(); | 893 testingServer.httpServer.close(); |
| 889 testingServer.errorReportingServer.close(); | 894 testingServer.errorReportingServer.close(); |
| 890 printDoubleReportingTests(); | 895 printDoubleReportingTests(); |
| 891 return !values.contains(false); | 896 return !values.contains(false); |
| 892 }); | 897 }); |
| 893 } | 898 } |
| 894 | 899 |
| 895 Browser getInstance() { | 900 Browser getInstance() { |
| 896 var browser = new Browser.byName(browserName); | 901 var browser = new Browser.byName(browserName, globalConfiguration); |
| 897 browser.logger = logger; | 902 browser.logger = logger; |
| 898 return browser; | 903 return browser; |
| 899 } | 904 } |
| 900 } | 905 } |
| 901 | 906 |
| 902 class BrowserTestingServer { | 907 class BrowserTestingServer { |
| 903 /// Interface of the testing server: | 908 /// Interface of the testing server: |
| 904 /// | 909 /// |
| 905 /// GET /driver/BROWSER_ID -- This will get the driver page to fetch | 910 /// GET /driver/BROWSER_ID -- This will get the driver page to fetch |
| 906 /// and run tests ... | 911 /// and run tests ... |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1212 Dart test driver, number of tests: <div id="number"></div><br> | 1217 Dart test driver, number of tests: <div id="number"></div><br> |
| 1213 Currently executing: <div id="currently_executing"></div><br> | 1218 Currently executing: <div id="currently_executing"></div><br> |
| 1214 Unhandled error: <div id="unhandled_error"></div> | 1219 Unhandled error: <div id="unhandled_error"></div> |
| 1215 <iframe id="embedded_iframe"></iframe> | 1220 <iframe id="embedded_iframe"></iframe> |
| 1216 </body> | 1221 </body> |
| 1217 </html> | 1222 </html> |
| 1218 """; | 1223 """; |
| 1219 return driverContent; | 1224 return driverContent; |
| 1220 } | 1225 } |
| 1221 } | 1226 } |
| OLD | NEW |