| OLD | NEW |
| 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, |
| 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 Loading... |
| 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('&', '&') | 77 return string.replaceAll('&', '&') |
| 69 .replaceAll('<','<') | 78 .replaceAll('<','<') |
| 70 .replaceAll('>','>'); | 79 .replaceAll('>','>'); |
| 71 } | 80 } |
| OLD | NEW |