| 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:core"; | 7 import "dart:core"; |
| 8 import "dart:io"; | 8 import "dart:io"; |
| 9 | 9 |
| 10 import 'android.dart'; | 10 import 'android.dart'; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 | 65 |
| 66 static const List<String> BROWSERS_WITH_WINDOW_SUPPORT = | 66 static const List<String> BROWSERS_WITH_WINDOW_SUPPORT = |
| 67 const ['safari', 'ff', 'firefox', 'chrome']; | 67 const ['safari', 'ff', 'firefox', 'chrome']; |
| 68 | 68 |
| 69 // TODO(kustermann): add standard support for chrome on android | 69 // TODO(kustermann): add standard support for chrome on android |
| 70 static bool supportedBrowser(String name) { | 70 static bool supportedBrowser(String name) { |
| 71 return SUPPORTED_BROWSERS.contains(name); | 71 return SUPPORTED_BROWSERS.contains(name); |
| 72 } | 72 } |
| 73 | 73 |
| 74 void _logEvent(String event) { | 74 void _logEvent(String event) { |
| 75 String toLog = "$this ($id) - ${new DateTime.now()}: $event \n"; | 75 String toLog = "$this ($id) - $event \n"; |
| 76 if (debugPrint) print("usageLog: $toLog"); | 76 if (debugPrint) print("usageLog: $toLog"); |
| 77 if (logger != null) logger(toLog); | 77 if (logger != null) logger(toLog); |
| 78 _usageLog.write(toLog); | 78 _usageLog.write(toLog); |
| 79 } | 79 } |
| 80 | 80 |
| 81 void _addStdout(String output) { | 81 void _addStdout(String output) { |
| 82 if (debugPrint) print("stdout: $output"); | 82 if (debugPrint) print("stdout: $output"); |
| 83 _stdout.write(output); | 83 _stdout.write(output); |
| 84 } | 84 } |
| 85 | 85 |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 } | 555 } |
| 556 browsersCompleter.complete(browsers); | 556 browsersCompleter.complete(browsers); |
| 557 } | 557 } |
| 558 return browsersCompleter.future; | 558 return browsersCompleter.future; |
| 559 } | 559 } |
| 560 | 560 |
| 561 var timedOut = []; | 561 var timedOut = []; |
| 562 | 562 |
| 563 void handleResults(String browserId, String output, int testId) { | 563 void handleResults(String browserId, String output, int testId) { |
| 564 var status = browserStatus[browserId]; | 564 var status = browserStatus[browserId]; |
| 565 DebugLogger.info("${new DateTime.now()}: Handling result for " | 565 DebugLogger.info("Handling result for browser ${browserId}"); |
| 566 "browser ${browserId}"); | |
| 567 if (testCache.containsKey(testId)) { | 566 if (testCache.containsKey(testId)) { |
| 568 doubleReportingTests.add(testId); | 567 doubleReportingTests.add(testId); |
| 569 return; | 568 return; |
| 570 } | 569 } |
| 571 | 570 |
| 572 if (status.timeout) { | 571 if (status.timeout) { |
| 573 // We don't do anything, this browser is currently being killed and | 572 // We don't do anything, this browser is currently being killed and |
| 574 // replaced. | 573 // replaced. |
| 575 } else if (status.currentTest != null) { | 574 } else if (status.currentTest != null) { |
| 576 status.currentTest.timeoutTimer.cancel(); | 575 status.currentTest.timeoutTimer.cancel(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 595 print(output); | 594 print(output); |
| 596 terminate().then((_) { | 595 terminate().then((_) { |
| 597 exit(1); | 596 exit(1); |
| 598 }); | 597 }); |
| 599 } | 598 } |
| 600 } | 599 } |
| 601 | 600 |
| 602 void handleTimeout(BrowserTestingStatus status) { | 601 void handleTimeout(BrowserTestingStatus status) { |
| 603 // We simply kill the browser and starts up a new one! | 602 // We simply kill the browser and starts up a new one! |
| 604 // We could be smarter here, but it does not seems like it is worth it. | 603 // We could be smarter here, but it does not seems like it is worth it. |
| 605 DebugLogger.info("${new DateTime.now()}: Handling timeout for " | 604 DebugLogger.info("Handling timeout for browser ${status.browser.id}"); |
| 606 "browser ${status.browser.id}"); | |
| 607 status.timeout = true; | 605 status.timeout = true; |
| 608 timedOut.add(status.currentTest.url); | 606 timedOut.add(status.currentTest.url); |
| 609 var id = status.browser.id; | 607 var id = status.browser.id; |
| 610 status.browser.close().then((closed) { | 608 status.browser.close().then((closed) { |
| 611 if (!closed) { | 609 if (!closed) { |
| 612 // Very bad, we could not kill the browser. | 610 // Very bad, we could not kill the browser. |
| 613 print("could not kill browser $id"); | 611 print("could not kill browser $id"); |
| 614 return; | 612 return; |
| 615 } | 613 } |
| 616 // We don't want to start a new browser if we are terminating. | 614 // We don't want to start a new browser if we are terminating. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 650 status.currentTest.stopwatch.stop(); | 648 status.currentTest.stopwatch.stop(); |
| 651 status.currentTest.doneCallback("TIMEOUT", | 649 status.currentTest.doneCallback("TIMEOUT", |
| 652 status.currentTest.stopwatch.elapsed); | 650 status.currentTest.stopwatch.elapsed); |
| 653 status.currentTest = null; | 651 status.currentTest = null; |
| 654 } | 652 } |
| 655 | 653 |
| 656 BrowserTest getNextTest(String browserId) { | 654 BrowserTest getNextTest(String browserId) { |
| 657 if (testQueue.isEmpty) return null; | 655 if (testQueue.isEmpty) return null; |
| 658 var status = browserStatus[browserId]; | 656 var status = browserStatus[browserId]; |
| 659 if (status == null) return null; | 657 if (status == null) return null; |
| 660 DebugLogger.info("${new DateTime.now()}: Handling getNext for browser " | 658 DebugLogger.info("Handling getNext for browser " |
| 661 "${browserId} timeout status: ${status.timeout}"); | 659 "${browserId} timeout status: ${status.timeout}"); |
| 662 | 660 |
| 663 // We are currently terminating this browser, don't start a new test. | 661 // We are currently terminating this browser, don't start a new test. |
| 664 if (status.timeout) return null; | 662 if (status.timeout) return null; |
| 665 BrowserTest test = testQueue.removeLast(); | 663 BrowserTest test = testQueue.removeLast(); |
| 666 if (status.currentTest == null) { | 664 if (status.currentTest == null) { |
| 667 status.currentTest = test; | 665 status.currentTest = test; |
| 668 } else { | 666 } else { |
| 669 // TODO(ricow): Handle this better. | 667 // TODO(ricow): Handle this better. |
| 670 print("This is bad, should never happen, getNextTest all full"); | 668 print("This is bad, should never happen, getNextTest all full"); |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 936 </head> | 934 </head> |
| 937 <body onload="startTesting()"> | 935 <body onload="startTesting()"> |
| 938 Dart test driver, number of tests: <div id="number"></div> | 936 Dart test driver, number of tests: <div id="number"></div> |
| 939 <iframe id="embedded_iframe"></iframe> | 937 <iframe id="embedded_iframe"></iframe> |
| 940 </body> | 938 </body> |
| 941 </html> | 939 </html> |
| 942 """; | 940 """; |
| 943 return driverContent; | 941 return driverContent; |
| 944 } | 942 } |
| 945 } | 943 } |
| OLD | NEW |