| 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 742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 753 | 753 |
| 754 var adbDeviceMapping = new Map<String, AdbDevice>(); | 754 var adbDeviceMapping = new Map<String, AdbDevice>(); |
| 755 // This cache is used to guarantee that we never see double reporting. | 755 // This cache is used to guarantee that we never see double reporting. |
| 756 // If we do we need to provide developers with this information. | 756 // If we do we need to provide developers with this information. |
| 757 // We don't add urls to the cache until we have run it. | 757 // We don't add urls to the cache until we have run it. |
| 758 Map<int, String> testCache = new Map<int, String>(); | 758 Map<int, String> testCache = new Map<int, String>(); |
| 759 Map<int, String> doubleReportingOutputs = new Map<int, String>(); | 759 Map<int, String> doubleReportingOutputs = new Map<int, String>(); |
| 760 | 760 |
| 761 BrowserTestingServer testingServer; | 761 BrowserTestingServer testingServer; |
| 762 | 762 |
| 763 /** |
| 764 * The TestRunner takes the testingServer in as a constructor parameter in |
| 765 * case we wish to have a testing server with different behavior (such as the |
| 766 * case for performance testing. |
| 767 */ |
| 763 BrowserTestRunner(this.globalConfiguration, | 768 BrowserTestRunner(this.globalConfiguration, |
| 764 this.localIp, | 769 this.localIp, |
| 765 this.browserName, | 770 this.browserName, |
| 766 this.maxNumBrowsers, | 771 this.maxNumBrowsers, |
| 767 {bool this.checkedMode: false}); | 772 {bool this.checkedMode: false, |
| 773 BrowserTestingServer this.testingServer}); |
| 768 | 774 |
| 769 Future<bool> start() { | 775 Future<bool> start() { |
| 770 // If [browserName] doesn't support opening new windows, we use new iframes | 776 // If [browserName] doesn't support opening new windows, we use new iframes |
| 771 // instead. | 777 // instead. |
| 772 bool useIframe = | 778 bool useIframe = |
| 773 !Browser.BROWSERS_WITH_WINDOW_SUPPORT.contains(browserName); | 779 !Browser.BROWSERS_WITH_WINDOW_SUPPORT.contains(browserName); |
| 774 testingServer = new BrowserTestingServer( | 780 if (testingServer == null) { |
| 775 globalConfiguration, localIp, useIframe); | 781 testingServer = new BrowserTestingServer( |
| 782 globalConfiguration, localIp, useIframe); |
| 783 } |
| 776 return testingServer.start().then((_) { | 784 return testingServer.start().then((_) { |
| 777 testingServer.testDoneCallBack = handleResults; | 785 testingServer.testDoneCallBack = handleResults; |
| 778 testingServer.testStatusUpdateCallBack = handleStatusUpdate; | 786 testingServer.testStatusUpdateCallBack = handleStatusUpdate; |
| 779 testingServer.testStartedCallBack = handleStarted; | 787 testingServer.testStartedCallBack = handleStarted; |
| 780 testingServer.nextTestCallBack = getNextTest; | 788 testingServer.nextTestCallBack = getNextTest; |
| 781 return getBrowsers().then((browsers) { | 789 return getBrowsers().then((browsers) { |
| 782 var futures = []; | 790 var futures = []; |
| 783 for (var browser in browsers) { | 791 for (var browser in browsers) { |
| 784 var url = testingServer.getDriverUrl(browser.id); | 792 var url = testingServer.getDriverUrl(browser.id); |
| 785 var future = browser.start(url).then((success) { | 793 var future = browser.start(url).then((success) { |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1152 // /favicon.ico requests | 1160 // /favicon.ico requests |
| 1153 } | 1161 } |
| 1154 request.response.write(textResponse); | 1162 request.response.write(textResponse); |
| 1155 request.listen((_) {}, onDone: request.response.close); | 1163 request.listen((_) {}, onDone: request.response.close); |
| 1156 request.response.done.catchError((error) { | 1164 request.response.done.catchError((error) { |
| 1157 if (!underTermination) { | 1165 if (!underTermination) { |
| 1158 print("URI ${request.uri}"); | 1166 print("URI ${request.uri}"); |
| 1159 print("Textresponse $textResponse"); | 1167 print("Textresponse $textResponse"); |
| 1160 throw "Error returning content to browser: $error"; | 1168 throw "Error returning content to browser: $error"; |
| 1161 } | 1169 } |
| 1162 }); | 1170 }); |
| 1163 } | 1171 } |
| 1164 void errorHandler(e) { | 1172 void errorHandler(e) { |
| 1165 if (!underTermination) print("Error occured in httpserver: $e"); | 1173 if (!underTermination) print("Error occured in httpserver: $e"); |
| 1166 }; | 1174 }; |
| 1167 | 1175 |
| 1168 httpServer.listen(handler, onError: errorHandler); | 1176 httpServer.listen(handler, onError: errorHandler); |
| 1169 | 1177 |
| 1170 // Set up the error reporting server that enables us to send back | 1178 // Set up the error reporting server that enables us to send back |
| 1171 // errors from the browser. | 1179 // errors from the browser. |
| 1172 port = globalConfiguration['test_driver_error_port']; | 1180 port = globalConfiguration['test_driver_error_port']; |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1442 Dart test driver, number of tests: <div id="number"></div><br> | 1450 Dart test driver, number of tests: <div id="number"></div><br> |
| 1443 Currently executing: <div id="currently_executing"></div><br> | 1451 Currently executing: <div id="currently_executing"></div><br> |
| 1444 Unhandled error: <div id="unhandled_error"></div> | 1452 Unhandled error: <div id="unhandled_error"></div> |
| 1445 <iframe id="embedded_iframe"></iframe> | 1453 <iframe id="embedded_iframe"></iframe> |
| 1446 </body> | 1454 </body> |
| 1447 </html> | 1455 </html> |
| 1448 """; | 1456 """; |
| 1449 return driverContent; | 1457 return driverContent; |
| 1450 } | 1458 } |
| 1451 } | 1459 } |
| OLD | NEW |