| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | |
| 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. | |
| 4 | |
| 5 /** | |
| 6 * A simple unit test library for running tests in a browser. | |
| 7 */ | |
| 8 #library('unittest'); | |
| 9 | |
| 10 #import('dart:html'); | |
| 11 #import('unittest.dart'); | |
| 12 | |
| 13 #source('src/html_print.dart'); | |
| 14 | |
| 15 class HtmlConfiguration extends Configuration { | |
| 16 /** Whether this is run within dartium layout tests. */ | |
| 17 final bool _isLayoutTest; | |
| 18 HtmlConfiguration(this._isLayoutTest); | |
| 19 | |
| 20 // TODO(rnystrom): Get rid of this if we get canonical closures for methods. | |
| 21 EventListener _onErrorClosure; | |
| 22 | |
| 23 void onInit() { | |
| 24 _onErrorClosure = | |
| 25 (e) => handleExternalError(e, '(DOM callback has errors)'); | |
| 26 } | |
| 27 | |
| 28 void onStart() { | |
| 29 window.postMessage('unittest-suite-wait-for-done', '*'); | |
| 30 // Listen for uncaught errors. | |
| 31 window.on.error.add(_onErrorClosure); | |
| 32 } | |
| 33 | |
| 34 void onTestResult(TestCase testCase) {} | |
| 35 | |
| 36 void onDone(int passed, int failed, int errors, List<TestCase> results, | |
| 37 String uncaughtError) { | |
| 38 window.on.error.remove(_onErrorClosure); | |
| 39 _showResultsInPage(passed, failed, errors, results, _isLayoutTest, | |
| 40 uncaughtError); | |
| 41 window.postMessage('unittest-suite-done', '*'); | |
| 42 } | |
| 43 } | |
| 44 | |
| 45 void useHtmlConfiguration([bool isLayoutTest = false]) { | |
| 46 configure(new HtmlConfiguration(isLayoutTest)); | |
| 47 } | |
| OLD | NEW |