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

Side by Side Diff: lib/unittest/html_print.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_enhanced_config.dart ('k') | lib/unittest/unittest.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 /** This file is sourced by both dom_config.dart and html_config.dart. */ 5 /** This file is sourced by both dom_config.dart and html_config.dart. */
6 6
7 /** Creates a table showing tests results in HTML. */ 7 /** Creates a table showing tests results in HTML. */
8 void _showResultsInPage(int passed, int failed, int errors, 8 void _showResultsInPage(int testsPassed, int testsFailed, int testsErrors,
9 List<TestCase> results, bool isLayoutTest, String uncaughtError) { 9 List<TestCase> results, isLayoutTest) {
10 if (isLayoutTest && (passed == results.length) && uncaughtError == null) { 10 if (isLayoutTest && (testsPassed == results.length)) {
11 document.body.innerHTML = "PASS"; 11 document.body.innerHTML = "PASS";
12 } else { 12 } else {
13 var newBody = new StringBuffer(); 13 var newBody = new StringBuffer();
14 newBody.add("<table class='unittest-table'><tbody>"); 14 newBody.add("<table class='unittest-table'><tbody>");
15 newBody.add(passed == results.length && uncaughtError == null 15 newBody.add(testsPassed == results.length
16 ? "<tr><td colspan='3' class='unittest-pass'>PASS</td></tr>" 16 ? "<tr><td colspan='3' class='unittest-pass'>PASS</td></tr>"
17 : "<tr><td colspan='3' class='unittest-fail'>FAIL</td></tr>"); 17 : "<tr><td colspan='3' class='unittest-fail'>FAIL</td></tr>");
18 18
19 for (final test_ in results) { 19 for (final test_ in results) {
20 newBody.add(_toHtml(test_)); 20 newBody.add(_toHtml(test_));
21 } 21 }
22 22
23 if (uncaughtError != null) { 23 if (testsPassed == results.length) {
24 newBody.add('''<tr>
25 <td>--</td>
26 <td class="unittest-error">ERROR</td>
27 <td>Uncaught error: $uncaughtError</td>
28 </tr>''');
29 }
30
31 if (passed == results.length && uncaughtError == null) {
32 newBody.add(""" 24 newBody.add("""
33 <tr><td colspan='3' class='unittest-pass'> 25 <tr><td colspan='3' class='unittest-pass'>
34 All ${passed} tests passed 26 All ${testsPassed} tests passed
35 </td></tr>"""); 27 </td></tr>""");
36 } else { 28 } else {
37 newBody.add(""" 29 newBody.add("""
38 <tr><td colspan='3'>Total 30 <tr><td colspan='3'>Total
39 <span class='unittest-pass'>${passed} passed</span>, 31 <span class='unittest-pass'>${testsPassed} passed</span>,
40 <span class='unittest-fail'>${failed} failed</span> 32 <span class='unittest-fail'>${testsFailed} failed</span>
41 <span class='unittest-error'> 33 <span class='unittest-error'>${testsErrors} errors</span>
42 ${errors + (uncaughtError == null ? 0 : 1)} errors</span>
43 </td></tr>"""); 34 </td></tr>""");
44 } 35 }
45 newBody.add("</tbody></table>"); 36 newBody.add("</tbody></table>");
46 document.body.innerHTML = newBody.toString(); 37 document.body.innerHTML = newBody.toString();
47 } 38 }
48 } 39 }
49 40
50 String _toHtml(TestCase test_) { 41 String _toHtml(TestCase test_) {
51 if (!test_.isComplete) { 42 if (!test_.isComplete) {
52 return ''' 43 return '''
(...skipping 18 matching lines...) Expand all
71 62
72 return html; 63 return html;
73 } 64 }
74 65
75 //TODO(pquitslund): Move to a common lib 66 //TODO(pquitslund): Move to a common lib
76 String _htmlEscape(String string) { 67 String _htmlEscape(String string) {
77 return string.replaceAll('&', '&amp;') 68 return string.replaceAll('&', '&amp;')
78 .replaceAll('<','&lt;') 69 .replaceAll('<','&lt;')
79 .replaceAll('>','&gt;'); 70 .replaceAll('>','&gt;');
80 } 71 }
OLDNEW
« no previous file with comments | « lib/unittest/html_enhanced_config.dart ('k') | lib/unittest/unittest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698