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>${_htmlEscape(test_.stackTrac
e)}</pre></td></tr>'; | 83 html = '$html<tr><td></td><td colspan="2"><pre>' + |
| 84 _htmlEscape(test_.stackTrace.toString()) + |
| 85 '</pre></td></tr>'; |
84 } | 86 } |
85 | 87 |
86 return html; | 88 return html; |
87 } | 89 } |
88 | 90 |
89 //TODO(pquitslund): Move to a common lib | 91 //TODO(pquitslund): Move to a common lib |
90 String _htmlEscape(String string) { | 92 String _htmlEscape(String string) { |
91 return string.replaceAll('&', '&') | 93 return string.replaceAll('&', '&') |
92 .replaceAll('<','<') | 94 .replaceAll('<','<') |
93 .replaceAll('>','>'); | 95 .replaceAll('>','>'); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 window.postMessage('unittest-suite-done', '*'); | 164 window.postMessage('unittest-suite-done', '*'); |
163 } | 165 } |
164 } | 166 } |
165 | 167 |
166 void useHtmlConfiguration([bool isLayoutTest = false]) { | 168 void useHtmlConfiguration([bool isLayoutTest = false]) { |
167 unittestConfiguration = isLayoutTest ? _singletonLayout : _singletonNotLayout; | 169 unittestConfiguration = isLayoutTest ? _singletonLayout : _singletonNotLayout; |
168 } | 170 } |
169 | 171 |
170 final _singletonLayout = new HtmlConfiguration(true); | 172 final _singletonLayout = new HtmlConfiguration(true); |
171 final _singletonNotLayout = new HtmlConfiguration(false); | 173 final _singletonNotLayout = new HtmlConfiguration(false); |
OLD | NEW |