| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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_html_config; | 8 library unittest_html_config; |
| 9 | 9 |
| 10 import 'dart:async'; | 10 import 'dart:async'; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 } | 73 } |
| 74 | 74 |
| 75 var html = ''' | 75 var html = ''' |
| 76 <tr> | 76 <tr> |
| 77 <td>${test_.id}</td> | 77 <td>${test_.id}</td> |
| 78 <td class="unittest-${test_.result}">${test_.result.toUpperCase()}</td> | 78 <td class="unittest-${test_.result}">${test_.result.toUpperCase()}</td> |
| 79 <td>Expectation: <a href="#testFilter=${test_.description}">${test_.desc
ription}</a>. ${_htmlEscape(test_.message)}</td> | 79 <td>Expectation: <a href="#testFilter=${test_.description}">${test_.desc
ription}</a>. ${_htmlEscape(test_.message)}</td> |
| 80 </tr>'''; | 80 </tr>'''; |
| 81 | 81 |
| 82 if (test_.stackTrace != null) { | 82 if (test_.stackTrace != null) { |
| 83 html = '$html<tr><td></td><td colspan="2"><pre>' + | 83 html = '$html<tr><td></td><td colspan="2"><pre>${_htmlEscape(test_.stackTrac
e)}</pre></td></tr>'; |
| 84 _htmlEscape(test_.stackTrace.toString()) + | |
| 85 '</pre></td></tr>'; | |
| 86 } | 84 } |
| 87 | 85 |
| 88 return html; | 86 return html; |
| 89 } | 87 } |
| 90 | 88 |
| 91 //TODO(pquitslund): Move to a common lib | 89 //TODO(pquitslund): Move to a common lib |
| 92 String _htmlEscape(String string) { | 90 String _htmlEscape(String string) { |
| 93 return string.replaceAll('&', '&') | 91 return string.replaceAll('&', '&') |
| 94 .replaceAll('<','<') | 92 .replaceAll('<','<') |
| 95 .replaceAll('>','>'); | 93 .replaceAll('>','>'); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 window.postMessage('unittest-suite-done', '*'); | 162 window.postMessage('unittest-suite-done', '*'); |
| 165 } | 163 } |
| 166 } | 164 } |
| 167 | 165 |
| 168 void useHtmlConfiguration([bool isLayoutTest = false]) { | 166 void useHtmlConfiguration([bool isLayoutTest = false]) { |
| 169 unittestConfiguration = isLayoutTest ? _singletonLayout : _singletonNotLayout; | 167 unittestConfiguration = isLayoutTest ? _singletonLayout : _singletonNotLayout; |
| 170 } | 168 } |
| 171 | 169 |
| 172 final _singletonLayout = new HtmlConfiguration(true); | 170 final _singletonLayout = new HtmlConfiguration(true); |
| 173 final _singletonNotLayout = new HtmlConfiguration(false); | 171 final _singletonNotLayout = new HtmlConfiguration(false); |
| OLD | NEW |