Chromium Code Reviews| Index: lib/unittest/html_print.dart |
| diff --git a/lib/unittest/unittest_html.dart b/lib/unittest/html_print.dart |
| similarity index 58% |
| copy from lib/unittest/unittest_html.dart |
| copy to lib/unittest/html_print.dart |
| index a307c4a2a54cab01b0087b51497e1a39cb9ab104..6b78be197fae7896381afd4b18863b439f9b690e 100644 |
| --- a/lib/unittest/unittest_html.dart |
| +++ b/lib/unittest/html_print.dart |
| @@ -2,65 +2,24 @@ |
| // for details. All rights reserved. Use of this source code is governed by a |
| // BSD-style license that can be found in the LICENSE file. |
| -/** |
| - * A simple unit test library for running tests in a browser. |
| - */ |
| -#library("unittest"); |
| -#import("dart:html"); |
| - |
| -#source("shared.dart"); |
| - |
| -// TODO(rnystrom): Get rid of this if we get canonical closures for methods. |
| -EventListener _onErrorClosure; |
| - |
| -_platformInitialize() { |
| - _onErrorClosure = (e) { _onError(e); }; |
| -} |
| - |
| -_platformDefer(void callback()) { |
| - window.setTimeout(callback, 0); |
| -} |
| - |
| -void _onError(e) { |
| - if (_currentTest < _tests.length) { |
| - final testCase = _tests[_currentTest]; |
| - // TODO(vsm): figure out how to expose the stack trace here |
| - // Currently e.message works in dartium, but not in dartc. |
| - testCase.error('(DOM callback has errors) Caught ${e}', ''); |
| - _state = _UNCAUGHT_ERROR; |
| - if (testCase.callbacks > 0) { |
| - _currentTest++; |
| - _testRunner(); |
| - } |
| - } |
| -} |
| - |
| -/** Runs all queued tests, one at a time. */ |
| -_platformStartTests() { |
| - window.postMessage('unittest-suite-wait-for-done', '*'); |
| - |
| - // Listen for uncaught errors. |
| - window.on.error.add(_onErrorClosure); |
| -} |
| - |
| -_platformCompleteTests(int testsPassed, int testsFailed, int testsErrors) { |
| - window.on.error.remove(_onErrorClosure); |
| - |
| - if (_isLayoutTest && testsPassed == _tests.length) { |
| +/** Creates a table showing tests results in HTML. */ |
| +void _showResultsInPage(int testsPassed, int testsFailed, int testsErrors, |
| + List<TestCase> results, isLayoutTest) { |
| + if (isLayoutTest && testsPassed == results.length) { |
|
Bob Nystrom
2012/04/10 00:30:31
I would parenthesize the == expression.
Siggi Cherem (dart-lang)
2012/04/10 01:05:28
Done.
|
| document.body.innerHTML = "PASS"; |
| } else { |
| var newBody = new StringBuffer(); |
| newBody.add("<table class='unittest-table'><tbody>"); |
| - newBody.add(testsPassed == _tests.length |
| + newBody.add(testsPassed == results.length |
| ? "<tr><td colspan='3' class='unittest-pass'>PASS</td></tr>" |
| : "<tr><td colspan='3' class='unittest-fail'>FAIL</td></tr>"); |
| - for (final test_ in _tests) { |
| + for (final test_ in results) { |
| newBody.add(_toHtml(test_)); |
| } |
| - if (testsPassed == _tests.length) { |
| + if (testsPassed == results.length) { |
| newBody.add(""" |
| <tr><td colspan='3' class='unittest-pass'> |
| All ${testsPassed} tests passed |
| @@ -76,8 +35,6 @@ _platformCompleteTests(int testsPassed, int testsFailed, int testsErrors) { |
| newBody.add("</tbody></table>"); |
| document.body.innerHTML = newBody.toString(); |
| } |
| - |
| - window.postMessage('unittest-suite-done', '*'); |
| } |
| String _toHtml(TestCase test_) { |
| @@ -110,4 +67,4 @@ String _htmlEscape(String string) { |
| return string.replaceAll('&', '&') |
| .replaceAll('<','<') |
| .replaceAll('>','>'); |
| -} |
| +} |