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

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

Issue 10226008: Revert "unittest step 3 and 4: remove TestFramework.dart, make test.dart use" (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/html_config.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 * Provides enhanced HTML output with collapsible group headers 8 * Provides enhanced HTML output with collapsible group headers
9 * and other at-a-glance information about the test results. 9 * and other at-a-glance information about the test results.
10 */ 10 */
(...skipping 20 matching lines...) Expand all
31 document.head.elements.add(new Element.html( 31 document.head.elements.add(new Element.html(
32 '<style id="${_CSSID}"></style>')); 32 '<style id="${_CSSID}"></style>'));
33 cssElement = document.head.query('#${_CSSID}'); 33 cssElement = document.head.query('#${_CSSID}');
34 } 34 }
35 35
36 cssElement.innerHTML = _htmlTestCSS; 36 cssElement.innerHTML = _htmlTestCSS;
37 37
38 _onErrorClosure = (e) { 38 _onErrorClosure = (e) {
39 // TODO(vsm): figure out how to expose the stack trace here 39 // TODO(vsm): figure out how to expose the stack trace here
40 // Currently e.message works in dartium, but not in dartc. 40 // Currently e.message works in dartium, but not in dartc.
41 reportTestError('(DOM callback has errors) Caught ${e}', ''); 41 notifyError('(DOM callback has errors) Caught ${e}', '');
42 }; 42 };
43 } 43 }
44 44
45 void onStart() { 45 void onStart() {
46 window.postMessage('unittest-suite-wait-for-done', '*'); 46 window.postMessage('unittest-suite-wait-for-done', '*');
47 // Listen for uncaught errors. 47 // Listen for uncaught errors.
48 window.on.error.add(_onErrorClosure); 48 window.on.error.add(_onErrorClosure);
49 } 49 }
50 50
51 void onTestResult(TestCase testCase) {} 51 void onTestResult(TestCase testCase) {}
52 52
53 void onDone(int passed, int failed, int errors, List<TestCase> results, 53 void onDone(int passed, int failed, int errors, List<TestCase> results) {
54 String uncaughtError) {
55 window.on.error.remove(_onErrorClosure); 54 window.on.error.remove(_onErrorClosure);
56 55
57 _showInteractiveResultsInPage(passed, failed, errors, results, 56 _showInteractiveResultsInPage(passed, failed, errors, results,
58 _isLayoutTest, uncaughtError); 57 _isLayoutTest);
59 58
60 window.postMessage('unittest-suite-done', '*'); 59 window.postMessage('unittest-suite-done', '*');
61 } 60 }
62 61
63 void _showInteractiveResultsInPage(int passed, int failed, int errors, 62 void _showInteractiveResultsInPage(int passed, int failed, int errors,
64 List<TestCase> results, bool isLayoutTest, String uncaughtError) { 63 List<TestCase> results, bool isLayoutTest){
65 if (isLayoutTest && passed == results.length) { 64 if (isLayoutTest && passed == results.length) {
66 document.body.innerHTML = "PASS"; 65 document.body.innerHTML = "PASS";
67 } else { 66 } else {
68 // changed the StringBuffer to an Element fragment 67 // changed the StringBuffer to an Element fragment
69 Element te = new Element.html('<div class="unittest-table"></div>'); 68 Element te = new Element.html('<div class="unittest-table"></div>');
70 69
71 te.elements.add(new Element.html(passed == results.length 70 te.elements.add(new Element.html(passed == results.length
72 ? "<div class='unittest-overall unittest-pass'>PASS</div>" 71 ? "<div class='unittest-overall unittest-pass'>PASS</div>"
73 : "<div class='unittest-overall unittest-fail'>FAIL</div>")); 72 : "<div class='unittest-overall unittest-fail'>FAIL</div>"));
74 73
75 // moved summary to the top since web browsers 74 // moved summary to the top since web browsers
76 // don't auto-scroll to the bottom like consoles typically do. 75 // don't auto-scroll to the bottom like consoles typically do.
77 if (passed == results.length && uncaughtError == null) { 76 if (passed == results.length) {
78 te.elements.add(new Element.html(""" 77 te.elements.add(new Element.html("""
79 <div class='unittest-pass'>All ${passed} tests passed</div>""")); 78 <div class='unittest-pass'>All ${passed} tests passed</div>"""));
80 } else { 79 } else {
81 80
82 if (uncaughtError != null) {
83 te.elements.add(new Element.html("""
84 <div class='unittest-summary'>
85 <span class='unittest-error'>Uncaught error: $uncaughtError</span>
86 </div>"""));
87 }
88
89 te.elements.add(new Element.html(""" 81 te.elements.add(new Element.html("""
90 <div class='unittest-summary'> 82 <div class='unittest-summary'>
91 <span class='unittest-pass'>Total ${passed} passed</span>, 83 <span class='unittest-pass'>Total ${passed} passed</span>,
92 <span class='unittest-fail'>${failed} failed</span>, 84 <span class='unittest-fail'>${failed} failed</span>,
93 <span class='unittest-error'> 85 <span class='unittest-error'>${errors} errors</span>
94 ${errors + (uncaughtError == null ? 0 : 1)} errors</span> 86 </div>"""));
95 </div>"""));
96 } 87 }
97 88
98 te.elements.add(new Element.html(""" 89 te.elements.add(new Element.html("""
99 <div><button id='btnCollapseAll'>Collapse All</button></div> 90 <div><button id='btnCollapseAll'>Collapse All</button></div>
100 """)); 91 """));
101 92
102 // handle the click event for the collapse all button 93 // handle the click event for the collapse all button
103 te.query('#btnCollapseAll').on.click.add((_){ 94 te.query('#btnCollapseAll').on.click.add((_){
104 document 95 document
105 .queryAll('.unittest-row') 96 .queryAll('.unittest-row')
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 .unittest-row-description 354 .unittest-row-description
364 { 355 {
365 } 356 }
366 357
367 '''; 358 ''';
368 } 359 }
369 360
370 void useHtmlEnhancedConfiguration([bool isLayoutTest = false]) { 361 void useHtmlEnhancedConfiguration([bool isLayoutTest = false]) {
371 configure(new HtmlEnhancedConfiguration(isLayoutTest)); 362 configure(new HtmlEnhancedConfiguration(isLayoutTest));
372 } 363 }
OLDNEW
« no previous file with comments | « lib/unittest/html_config.dart ('k') | lib/unittest/html_print.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698