Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(632)

Side by Side Diff: lib/unittest/html_config.dart

Issue 10037027: unittest step2: bye bye to multiple entrypoints for unittest (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « lib/unittest/expectation.dart ('k') | lib/unittest/html_print.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 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 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 4
5 /** 5 /**
6 * A simple unit test library for running tests in a browser. 6 * A simple unit test library for running tests in a browser.
7 */ 7 */
8 #library('unittest'); 8 #library('unittest');
9 9
10 #import('dart:html'); 10 #import('dart:html');
11 #import('dart:isolate'); 11 #import('unittest.dart');
12 12
13 #source('config.dart');
14 #source('shared.dart');
15 #source('html_print.dart'); 13 #source('html_print.dart');
16 14
17 /** Whether this is run within dartium layout tests. */ 15 class HtmlConfiguration extends Configuration {
18 bool _isLayoutTest = false; 16 /** Whether this is run within dartium layout tests. */
17 final bool _isLayoutTest;
18 HtmlConfiguration(this._isLayoutTest);
19 19
20 void forLayoutTests() {
21 _isLayoutTest = true;
22 }
23
24 class PlatformConfiguration extends Configuration {
25 // TODO(rnystrom): Get rid of this if we get canonical closures for methods. 20 // TODO(rnystrom): Get rid of this if we get canonical closures for methods.
26 EventListener _onErrorClosure; 21 EventListener _onErrorClosure;
27 22
28 void onInit() { 23 void onInit() {
29 _onErrorClosure = (e) { _onError(e); }; 24 _onErrorClosure = (e) {
30 }
31
32 void _onError(e) {
33 if (_currentTest < _tests.length) {
34 final testCase = _tests[_currentTest];
35 // TODO(vsm): figure out how to expose the stack trace here 25 // TODO(vsm): figure out how to expose the stack trace here
36 // Currently e.message works in dartium, but not in dartc. 26 // Currently e.message works in dartium, but not in dartc.
37 testCase.error('(DOM callback has errors) Caught ${e}', ''); 27 notifyError('(DOM callback has errors) Caught ${e}', '');
38 _state = _UNCAUGHT_ERROR; 28 };
39 if (testCase.callbacks > 0) {
40 _currentTest++;
41 _testRunner();
42 }
43 }
44 } 29 }
45 30
46 void onStart() { 31 void onStart() {
47 window.postMessage('unittest-suite-wait-for-done', '*'); 32 window.postMessage('unittest-suite-wait-for-done', '*');
48 // Listen for uncaught errors. 33 // Listen for uncaught errors.
49 window.on.error.add(_onErrorClosure); 34 window.on.error.add(_onErrorClosure);
50 } 35 }
51 36
52 void onTestResult(TestCase testCase) {} 37 void onTestResult(TestCase testCase) {}
53 38
54 void onDone(int passed, int failed, int errors, List<TestCase> results) { 39 void onDone(int passed, int failed, int errors, List<TestCase> results) {
55 window.on.error.remove(_onErrorClosure); 40 window.on.error.remove(_onErrorClosure);
56 _showResultsInPage(passed, failed, errors, results, _isLayoutTest); 41 _showResultsInPage(passed, failed, errors, results, _isLayoutTest);
57 window.postMessage('unittest-suite-done', '*'); 42 window.postMessage('unittest-suite-done', '*');
58 } 43 }
59 } 44 }
45
46 void useHtmlConfiguration([bool isLayoutTest = false]) {
47 configure(new HtmlConfiguration(isLayoutTest));
48 }
OLDNEW
« no previous file with comments | « lib/unittest/expectation.dart ('k') | lib/unittest/html_print.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698