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

Side by Side Diff: pkg/unittest/lib/html_enhanced_config.dart

Issue 149573006: pkg/unittest: more lock-down, cleanup (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 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) 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 * Provides enhanced HTML output with collapsible group headers 8 * Provides enhanced HTML output with collapsible group headers
9 * and other at-a-glance information about the test results. 9 * and other at-a-glance information about the test results.
10 */ 10 */
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 if ('unittest-suite-external-error' == e.data) { 60 if ('unittest-suite-external-error' == e.data) {
61 handleExternalError('<unknown>', '(external error detected)'); 61 handleExternalError('<unknown>', '(external error detected)');
62 } 62 }
63 } 63 }
64 64
65 void onInit() { 65 void onInit() {
66 _installHandlers(); 66 _installHandlers();
67 //initialize and load CSS 67 //initialize and load CSS
68 final String _CSSID = '_unittestcss_'; 68 final String _CSSID = '_unittestcss_';
69 69
70 var cssElement = document.head.query('#${_CSSID}'); 70 var cssElement = document.head.querySelector('#${_CSSID}');
71 if (cssElement == null) { 71 if (cssElement == null) {
72 cssElement = new StyleElement(); 72 cssElement = new StyleElement();
73 cssElement.id = _CSSID; 73 cssElement.id = _CSSID;
74 document.head.append(cssElement); 74 document.head.append(cssElement);
75 } 75 }
76 76
77 cssElement.text = _htmlTestCSS; 77 cssElement.text = _htmlTestCSS;
78 window.postMessage('unittest-suite-wait-for-done', '*'); 78 window.postMessage('unittest-suite-wait-for-done', '*');
79 } 79 }
80 80
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 <span class='unittest-error'> 127 <span class='unittest-error'>
128 ${errors + (uncaughtError == null ? 0 : 1)} errors</span> 128 ${errors + (uncaughtError == null ? 0 : 1)} errors</span>
129 </div>""")); 129 </div>"""));
130 } 130 }
131 131
132 te.children.add(new Element.html(""" 132 te.children.add(new Element.html("""
133 <div><button id='btnCollapseAll'>Collapse All</button></div> 133 <div><button id='btnCollapseAll'>Collapse All</button></div>
134 """)); 134 """));
135 135
136 // handle the click event for the collapse all button 136 // handle the click event for the collapse all button
137 te.query('#btnCollapseAll').onClick.listen((_){ 137 te.querySelector('#btnCollapseAll').onClick.listen((_){
138 document 138 document
139 .queryAll('.unittest-row') 139 .querySelectorAll('.unittest-row')
140 .forEach((el) => el.attributes['class'] = el.attributes['class'] 140 .forEach((el) => el.attributes['class'] = el.attributes['class']
141 .replaceAll('unittest-row ', 'unittest-row-hidden ')); 141 .replaceAll('unittest-row ', 'unittest-row-hidden '));
142 }); 142 });
143 143
144 var previousGroup = ''; 144 var previousGroup = '';
145 var groupPassFail = true; 145 var groupPassFail = true;
146 final indentAmount = 50; 146 final indentAmount = 50;
147 147
148 // order by group and sort numerically within each group 148 // order by group and sort numerically within each group
149 var groupedBy = new LinkedHashMap<String, List<TestCase>>(); 149 var groupedBy = new LinkedHashMap<String, List<TestCase>>();
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 </div> 200 </div>
201 <div ${_isIE ? "style='display:inline-block' ": ""}> 201 <div ${_isIE ? "style='display:inline-block' ": ""}>
202 ${test_.currentGroup}</div> 202 ${test_.currentGroup}</div>
203 &nbsp; 203 &nbsp;
204 <div ${_isIE ? "style='display:inline-block' ": ""}> 204 <div ${_isIE ? "style='display:inline-block' ": ""}>
205 (${groupTestPassedCount}/${groupTotalTestCount})</div> 205 (${groupTestPassedCount}/${groupTotalTestCount})</div>
206 </div> 206 </div>
207 </div>""")); 207 </div>"""));
208 208
209 // 'safeGroup' could be empty 209 // 'safeGroup' could be empty
210 var grp = (safeGroup == '') ? null : te.query('#${safeGroup}'); 210 var grp = (safeGroup == '') ? null : te.querySelector('#${safeGroup}') ;
Siggi Cherem (dart-lang) 2014/02/03 18:09:46 80
kevmoo 2014/02/03 18:22:57 Done.
211 if (grp != null) { 211 if (grp != null) {
212 grp.onClick.listen((_) { 212 grp.onClick.listen((_) {
213 var row = document.query('.unittest-row-${safeGroup}'); 213 var row = document.querySelector('.unittest-row-${safeGroup}');
214 if (row.attributes['class'].contains('unittest-row ')){ 214 if (row.attributes['class'].contains('unittest-row ')){
215 document.queryAll('.unittest-row-${safeGroup}').forEach( 215 document.querySelectorAll('.unittest-row-${safeGroup}').forEach(
216 (e) => e.attributes['class'] = e.attributes['class'] 216 (e) => e.attributes['class'] = e.attributes['class']
217 .replaceAll('unittest-row ', 'unittest-row-hidden ')); 217 .replaceAll('unittest-row ', 'unittest-row-hidden '));
218 }else{ 218 }else{
219 document.queryAll('.unittest-row-${safeGroup}').forEach( 219 document.querySelectorAll('.unittest-row-${safeGroup}').forEach(
220 (e) => e.attributes['class'] = e.attributes['class'] 220 (e) => e.attributes['class'] = e.attributes['class']
221 .replaceAll('unittest-row-hidden', 'unittest-row')); 221 .replaceAll('unittest-row-hidden', 'unittest-row'));
222 } 222 }
223 }); 223 });
224 } 224 }
225 } 225 }
226 226
227 _buildRow(test_, te, safeGroup, !groupPassFail); 227 _buildRow(test_, te, safeGroup, !groupPassFail);
228 } 228 }
229 229
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 410
411 '''; 411 ''';
412 } 412 }
413 413
414 void useHtmlEnhancedConfiguration([bool isLayoutTest = false]) { 414 void useHtmlEnhancedConfiguration([bool isLayoutTest = false]) {
415 unittestConfiguration = isLayoutTest ? _singletonLayout : _singletonNotLayout; 415 unittestConfiguration = isLayoutTest ? _singletonLayout : _singletonNotLayout;
416 } 416 }
417 417
418 final _singletonLayout = new HtmlEnhancedConfiguration(true); 418 final _singletonLayout = new HtmlEnhancedConfiguration(true);
419 final _singletonNotLayout = new HtmlEnhancedConfiguration(false); 419 final _singletonNotLayout = new HtmlEnhancedConfiguration(false);
OLDNEW
« no previous file with comments | « no previous file | pkg/unittest/lib/src/group_context.dart » ('j') | pkg/unittest/lib/src/spread_args_helper.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698