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

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

Issue 10153005: 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
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 testsPassed, int testsFailed, int testsErrors, 8 void _showResultsInPage(int passed, int failed, int errors,
Bob Nystrom 2012/04/20 22:31:36 If we keep adding arguments here, eventually we ma
Siggi Cherem (dart-lang) 2012/04/21 00:03:43 agreed - I was thinking of getting rid of the firs
Bob Nystrom 2012/04/23 17:34:07 I do like that this code doesn't have to loop and
9 List<TestCase> results, isLayoutTest) { 9 List<TestCase> results, bool isLayoutTest, String uncaughtError) {
10 if (isLayoutTest && (testsPassed == results.length)) { 10 if (isLayoutTest && (passed == results.length) && uncaughtError == null) {
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(testsPassed == results.length 15 newBody.add(passed == results.length && uncaughtError == null
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 (testsPassed == results.length) { 23 if (uncaughtError != null) {
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) {
24 newBody.add(""" 32 newBody.add("""
25 <tr><td colspan='3' class='unittest-pass'> 33 <tr><td colspan='3' class='unittest-pass'>
26 All ${testsPassed} tests passed 34 All ${passed} tests passed
27 </td></tr>"""); 35 </td></tr>""");
28 } else { 36 } else {
29 newBody.add(""" 37 newBody.add("""
30 <tr><td colspan='3'>Total 38 <tr><td colspan='3'>Total
31 <span class='unittest-pass'>${testsPassed} passed</span>, 39 <span class='unittest-pass'>${passed} passed</span>,
32 <span class='unittest-fail'>${testsFailed} failed</span> 40 <span class='unittest-fail'>${failed} failed</span>
33 <span class='unittest-error'>${testsErrors} errors</span> 41 <span class='unittest-error'>
42 ${errors + (uncaughtError == null ? 0 : 1)} errors</span>
34 </td></tr>"""); 43 </td></tr>""");
35 } 44 }
36 newBody.add("</tbody></table>"); 45 newBody.add("</tbody></table>");
37 document.body.innerHTML = newBody.toString(); 46 document.body.innerHTML = newBody.toString();
38 } 47 }
39 } 48 }
40 49
41 String _toHtml(TestCase test_) { 50 String _toHtml(TestCase test_) {
42 if (!test_.isComplete) { 51 if (!test_.isComplete) {
43 return ''' 52 return '''
(...skipping 18 matching lines...) Expand all
62 71
63 return html; 72 return html;
64 } 73 }
65 74
66 //TODO(pquitslund): Move to a common lib 75 //TODO(pquitslund): Move to a common lib
67 String _htmlEscape(String string) { 76 String _htmlEscape(String string) {
68 return string.replaceAll('&', '&amp;') 77 return string.replaceAll('&', '&amp;')
69 .replaceAll('<','&lt;') 78 .replaceAll('<','&lt;')
70 .replaceAll('>','&gt;'); 79 .replaceAll('>','&gt;');
71 } 80 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698