Chromium Code Reviews| Index: dart/tools/testing/dart/browser_controller.dart |
| diff --git a/dart/tools/testing/dart/browser_controller.dart b/dart/tools/testing/dart/browser_controller.dart |
| index 4c1043f1b32f030e0ac5349dd5aa7a39131cec3e..08fd3248f88d0f657377c52405773c3828f1e624 100644 |
| --- a/dart/tools/testing/dart/browser_controller.dart |
| +++ b/dart/tools/testing/dart/browser_controller.dart |
| @@ -7,6 +7,7 @@ import "dart:async"; |
| import "dart:convert" show LineSplitter, UTF8; |
| import "dart:core"; |
| import "dart:io"; |
| +import "dart:convert" as convert; |
| import 'android.dart'; |
| import 'utils.dart'; |
| @@ -73,8 +74,8 @@ abstract class Browser { |
| static const List<String> SUPPORTED_BROWSERS = |
| const ['safari', 'ff', 'firefox', 'chrome', 'ie9', 'ie10', 'dartium']; |
| - static const List<String> BROWSERS_WITH_WINDOW_SUPPORT = |
| - const ['safari', 'ff', 'firefox', 'chrome']; |
| + static const List<String> BROWSERS_WITH_WINDOW_SUPPORT = const []; |
| + // const ['safari', 'ff', 'firefox', 'chrome']; |
|
ricow1
2013/10/23 11:42:32
why
|
| // TODO(kustermann): add standard support for chrome on android |
| static bool supportedBrowser(String name) { |
| @@ -638,14 +639,21 @@ class BrowserTest { |
| /* Describes the output of running the test in a browser */ |
| class BrowserTestOutput { |
| - final bool didTimeout; |
| final Duration delayUntilTestStarted; |
| final Duration duration; |
| - final BrowserOutput browserOutput; |
| + |
| final String dom; |
| + final String outcome; |
| + final List<String> printCalls; |
| + final List<String> receivedMessages; |
| + final List<String> debugMessages; |
| + |
| + final BrowserOutput browserOutput; |
| + final bool didTimeout; |
| BrowserTestOutput( |
| this.delayUntilTestStarted, this.duration, this.dom, |
| + this.outcome, this.printCalls, this.receivedMessages, this.debugMessages, |
| this.browserOutput, {this.didTimeout: false}); |
| } |
| @@ -754,9 +762,59 @@ class BrowserTestRunner { |
| var timedOut = []; |
| void handleResults(String browserId, String output, int testId) { |
| + void validate(String assertion, bool value) { |
| + if (!value) { |
| + throw "InvalidFormat sent from browser driving page: $assertion:\n\n" |
| + "$output"; |
| + } |
| + } |
| + const ALLOWED_TYPES = |
| + const ['debug', 'print', 'dom', 'test_outcome', 'message_received']; |
|
ricow1
2013/10/23 11:42:32
maybe it is time to decouple test_controller.js fr
|
| + const ALLOWED_OUTCOMES = const ['PASS', 'FAIL', 'NOT_STARTED']; |
| + const REQUIRED_TYPES = const ['test_outcome', 'dom']; |
| + |
| + var messages = convert.JSON.decode(output); |
| + validate("Message must be a List", messages is List); |
| + |
| + var testOutcome, htmlDom; |
| + var debugMessages = [], dartPrints = [], receivedMessages = []; |
| + for (var entry in messages) { |
| + validate("An entry must be a Map", entry is Map); |
| + validate("'type' of an entry must be a String", entry['type'] is String); |
| + validate("'value' of an entry must be a String", entry['value'] is String); |
| + validate("'type' as to be in $ALLOWED_TYPES.", |
| + ALLOWED_TYPES.contains(entry['type'])); |
| + switch(entry['type']) { |
| + case 'debug': |
| + debugMessages.add(entry['value']); |
| + break; |
| + case 'print': |
| + dartPrints.add(entry['value']); |
| + break; |
| + case 'message_received': |
| + receivedMessages.add(entry['value']); |
| + break; |
| + case 'dom': |
| + validate("The message can only contain one 'dom' type.", |
| + htmlDom == null); |
| + htmlDom = entry['value']; |
| + break; |
| + case 'test_outcome': |
| + validate("Test outcome has to be one of $ALLOWED_OUTCOMES.", |
| + ALLOWED_OUTCOMES.contains(entry['value'])); |
| + // We require that we get only one test_outcome |
| + validate("The message can only contain one 'test_outcome'.", |
| + testOutcome == null); |
| + testOutcome = entry['value']; |
| + break; |
| + } |
| + } |
| + validate("The message must have a 'test_outcome' and a 'dom'.", |
| + testOutcome != null && htmlDom != null); |
| + |
| var status = browserStatus[browserId]; |
| if (testCache.containsKey(testId)) { |
| - doubleReportingOutputs[testId] = output; |
| + doubleReportingOutputs[testId] = htmlDom; |
| return; |
| } |
| @@ -783,7 +841,11 @@ class BrowserTestRunner { |
| var browserTestOutput = new BrowserTestOutput( |
| status.currentTest.delayUntilTestStarted, |
| status.currentTest.stopwatch.elapsed, |
| - output, |
| + htmlDom, |
| + testOutcome, |
| + dartPrints, |
| + receivedMessages, |
| + debugMessages, |
| status.browser.testBrowserOutput); |
| status.currentTest.doneCallback(browserTestOutput); |
| @@ -793,7 +855,7 @@ class BrowserTestRunner { |
| } else { |
| print("\nThis is bad, should never happen, handleResult no test"); |
| print("URL: ${status.lastTest.url}"); |
| - print(output); |
| + print(htmlDom); |
| terminate().then((_) { |
| exit(1); |
| }); |
| @@ -828,6 +890,10 @@ class BrowserTestRunner { |
| status.currentTest.delayUntilTestStarted, |
| status.currentTest.stopwatch.elapsed, |
| 'Dom could not be fetched, since the test timed out.', |
| + 'TIMEOUT', |
| + [], |
| + [], |
| + [], |
| status.browser.testBrowserOutput, |
| didTimeout: true); |
| status.currentTest.doneCallback(browserTestOutput); |