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 #library('dartest'); | 5 #library('dartest'); |
6 | 6 |
7 #import('dart:dom'); | 7 #import('dart:dom'); |
8 #import('../unittest/unittest_dartest.dart'); | 8 #import('../unittest/unittest_dartest.dart'); |
9 | 9 |
10 #source('css.dart'); | 10 #source('css.dart'); |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 } | 159 } |
160 | 160 |
161 HTMLSpanElement durationSpan = domWin.document.createElement('span'); | 161 HTMLSpanElement durationSpan = domWin.document.createElement('span'); |
162 durationSpan.textContent = 'took ${_printDuration(t.runningTime)}'; | 162 durationSpan.textContent = 'took ${_printDuration(t.runningTime)}'; |
163 tableCell.appendChild(durationSpan); | 163 tableCell.appendChild(durationSpan); |
164 | 164 |
165 return tableCell; | 165 return tableCell; |
166 } | 166 } |
167 | 167 |
168 /** Update the UI after running test. */ | 168 /** Update the UI after running test. */ |
169 void _updateDARTestUI(TestCase test) { | 169 void _updateDARTestUI(TestCase test_) { |
170 _updateResultsTable(test, window); | 170 _updateResultsTable(test_, window); |
171 if(_runnerWindow != window) { | 171 if(_runnerWindow != window) { |
172 _updateResultsTable(test, _runnerWindow); | 172 _updateResultsTable(test_, _runnerWindow); |
173 } | 173 } |
174 | 174 |
175 if(test.result != null) { | 175 if(test_.result != null) { |
176 _log(' Result: ${test.result.toUpperCase()} ${test.message}'); | 176 _log(' Result: ${test_.result.toUpperCase()} ${test_.message}'); |
177 } | 177 } |
178 if(test.runningTime != null) { | 178 if(test_.runningTime != null) { |
179 _log(' took ${_printDuration(test.runningTime)}'); | 179 _log(' took ${_printDuration(test_.runningTime)}'); |
180 } | 180 } |
181 _updateStatusProgress(_appElements); | 181 _updateStatusProgress(_appElements); |
182 if(_runnerWindow != window) { | 182 if(_runnerWindow != window) { |
183 _updateStatusProgress(_inAppElements); | 183 _updateStatusProgress(_inAppElements); |
184 } | 184 } |
185 } | 185 } |
186 | 186 |
187 void _updateStatusProgress(AppElements elements) { | 187 void _updateStatusProgress(AppElements elements) { |
188 // Update progressbar | 188 // Update progressbar |
189 var pPass = | 189 var pPass = |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 | 233 |
234 _showTestControls(); | 234 _showTestControls(); |
235 | 235 |
236 // Create header to hold window controls | 236 // Create header to hold window controls |
237 if(_runnerWindow == window) { | 237 if(_runnerWindow == window) { |
238 HTMLDivElement headDiv = _runnerWindow.document.createElement('div'); | 238 HTMLDivElement headDiv = _runnerWindow.document.createElement('div'); |
239 headDiv.className = 'dt-header'; | 239 headDiv.className = 'dt-header'; |
240 headDiv.innerHTML = 'DARTest: In-App View'; | 240 headDiv.innerHTML = 'DARTest: In-App View'; |
241 HTMLImageElement close = _runnerWindow.document.createElement('img'); | 241 HTMLImageElement close = _runnerWindow.document.createElement('img'); |
242 close.className = 'dt-header-close'; | 242 close.className = 'dt-header-close'; |
243 close.addEventListener('click', (Event) { | 243 close.addEventListener('click', (event) { |
244 containerDiv.className = 'dt-hide'; | 244 containerDiv.className = 'dt-hide'; |
245 }, true); | 245 }, true); |
246 HTMLImageElement pop = _runnerWindow.document.createElement('img'); | 246 HTMLImageElement pop = _runnerWindow.document.createElement('img'); |
247 pop.className = 'dt-header-pop'; | 247 pop.className = 'dt-header-pop'; |
248 pop.addEventListener('click', (Event) => _dartestMaximize(), true); | 248 pop.addEventListener('click', (event) => _dartestMaximize(), true); |
249 HTMLImageElement minMax = _runnerWindow.document.createElement('img'); | 249 HTMLImageElement minMax = _runnerWindow.document.createElement('img'); |
250 minMax.className = 'dt-header-min'; | 250 minMax.className = 'dt-header-min'; |
251 minMax.addEventListener('click', (Event) { | 251 minMax.addEventListener('click', (event) { |
252 if (mainElem.classList.contains('dt-hide')) { | 252 if (mainElem.classList.contains('dt-hide')) { |
253 mainElem.classList.remove('dt-hide'); | 253 mainElem.classList.remove('dt-hide'); |
254 mainElem.classList.add('dt-show'); | 254 mainElem.classList.add('dt-show'); |
255 minMax.className = 'dt-header-min'; | 255 minMax.className = 'dt-header-min'; |
256 } else { | 256 } else { |
257 if (mainElem.classList.contains('dt-show')) { | 257 if (mainElem.classList.contains('dt-show')) { |
258 mainElem.classList.remove('dt-show'); | 258 mainElem.classList.remove('dt-show'); |
259 } | 259 } |
260 mainElem.classList.add('dt-hide'); | 260 mainElem.classList.add('dt-hide'); |
261 minMax.className = 'dt-header-max'; | 261 minMax.className = 'dt-header-max'; |
262 } | 262 } |
263 }, true); | 263 }, true); |
264 headDiv.appendChild(close); | 264 headDiv.appendChild(close); |
265 headDiv.appendChild(pop); | 265 headDiv.appendChild(pop); |
266 headDiv.appendChild(minMax); | 266 headDiv.appendChild(minMax); |
267 | 267 |
268 containerDiv.appendChild(headDiv); | 268 containerDiv.appendChild(headDiv); |
269 } | 269 } |
270 | 270 |
271 HTMLDivElement tabDiv = _runnerWindow.document.createElement('div'); | 271 HTMLDivElement tabDiv = _runnerWindow.document.createElement('div'); |
272 tabDiv.className = 'dt-tab'; | 272 tabDiv.className = 'dt-tab'; |
273 HTMLUListElement tabList = _runnerWindow.document.createElement('ul'); | 273 HTMLUListElement tabList = _runnerWindow.document.createElement('ul'); |
274 HTMLLIElement testingTab = _runnerWindow.document.createElement('li'); | 274 HTMLLIElement testingTab = _runnerWindow.document.createElement('li'); |
275 HTMLLIElement coverageTab = _runnerWindow.document.createElement('li'); | 275 HTMLLIElement coverageTab = _runnerWindow.document.createElement('li'); |
276 testingTab.className = 'dt-tab-selected'; | 276 testingTab.className = 'dt-tab-selected'; |
277 testingTab.textContent = 'Testing'; | 277 testingTab.textContent = 'Testing'; |
278 testingTab.addEventListener('click', (Event) { | 278 testingTab.addEventListener('click', (event) { |
279 _showTestControls(); | 279 _showTestControls(); |
280 _changeTabs(testingTab, coverageTab); | 280 _changeTabs(testingTab, coverageTab); |
281 }, true); | 281 }, true); |
282 tabList.appendChild(testingTab); | 282 tabList.appendChild(testingTab); |
283 coverageTab.textContent = 'Coverage'; | 283 coverageTab.textContent = 'Coverage'; |
284 coverageTab.addEventListener('click', (Event) { | 284 coverageTab.addEventListener('click', (event) { |
285 _showCoverageControls(); | 285 _showCoverageControls(); |
286 _changeTabs(coverageTab, testingTab); | 286 _changeTabs(coverageTab, testingTab); |
287 }, true); | 287 }, true); |
288 tabList.appendChild(coverageTab); | 288 tabList.appendChild(coverageTab); |
289 tabDiv.appendChild(tabList); | 289 tabDiv.appendChild(tabList); |
290 containerDiv.appendChild(tabDiv); | 290 containerDiv.appendChild(tabDiv); |
291 | 291 |
292 if(_runnerWindow != window) { | 292 if(_runnerWindow != window) { |
293 HTMLDivElement popIn = _runnerWindow.document.createElement('div'); | 293 HTMLDivElement popIn = _runnerWindow.document.createElement('div'); |
294 popIn.className = 'dt-minimize'; | 294 popIn.className = 'dt-minimize'; |
295 popIn.innerHTML = 'Pop In ⇲'; | 295 popIn.innerHTML = 'Pop In ⇲'; |
296 popIn.addEventListener('click', (Event) => _dartestMinimize(), true); | 296 popIn.addEventListener('click', (event) => _dartestMinimize(), true); |
297 containerDiv.appendChild(popIn); | 297 containerDiv.appendChild(popIn); |
298 } | 298 } |
299 | 299 |
300 containerDiv.appendChild(mainElem); | 300 containerDiv.appendChild(mainElem); |
301 _runnerWindow.document.body.appendChild(containerDiv); | 301 _runnerWindow.document.body.appendChild(containerDiv); |
302 } | 302 } |
303 | 303 |
304 void _changeTabs(HTMLLIElement clickedTab, HTMLLIElement oldTab) { | 304 void _changeTabs(HTMLLIElement clickedTab, HTMLLIElement oldTab) { |
305 oldTab.className = ''; | 305 oldTab.className = ''; |
306 clickedTab.className = 'dt-tab-selected'; | 306 clickedTab.className = 'dt-tab-selected'; |
307 } | 307 } |
308 | 308 |
309 void _showTestControls() { | 309 void _showTestControls() { |
310 HTMLDivElement testBody = _appElements.testBody; | 310 HTMLDivElement testBody = _appElements.testBody; |
311 if(testBody == null) { | 311 if(testBody == null) { |
312 testBody = _runnerWindow.document.createElement('div'); | 312 testBody = _runnerWindow.document.createElement('div'); |
313 _appElements.testBody = testBody; | 313 _appElements.testBody = testBody; |
314 | 314 |
315 // Create a toolbar to hold action buttons | 315 // Create a toolbar to hold action buttons |
316 HTMLDivElement toolDiv = _runnerWindow.document.createElement('div'); | 316 HTMLDivElement toolDiv = _runnerWindow.document.createElement('div'); |
317 toolDiv.className = 'dt-toolbar'; | 317 toolDiv.className = 'dt-toolbar'; |
318 HTMLButtonElement runBtn = _runnerWindow.document.createElement('button'); | 318 HTMLButtonElement runBtn = _runnerWindow.document.createElement('button'); |
319 runBtn.innerHTML = '►'; | 319 runBtn.innerHTML = '►'; |
320 runBtn.title = 'Run Tests'; | 320 runBtn.title = 'Run Tests'; |
321 runBtn.className = 'dt-button dt-run'; | 321 runBtn.className = 'dt-button dt-run'; |
322 runBtn.addEventListener('click', (Event) { | 322 runBtn.addEventListener('click', (event) { |
323 _log('Running tests'); | 323 _log('Running tests'); |
324 updateUI = _updateDARTestUI; | 324 updateUI = _updateDARTestUI; |
325 runDartests(); | 325 runDartests(); |
326 }, true); | 326 }, true); |
327 toolDiv.appendChild(runBtn); | 327 toolDiv.appendChild(runBtn); |
328 HTMLButtonElement exportBtn = | 328 HTMLButtonElement exportBtn = |
329 _runnerWindow.document.createElement('button'); | 329 _runnerWindow.document.createElement('button'); |
330 exportBtn.innerHTML = '↷'; | 330 exportBtn.innerHTML = '↷'; |
331 exportBtn.title = 'Export Results'; | 331 exportBtn.title = 'Export Results'; |
332 exportBtn.className = 'dt-button dt-run'; | 332 exportBtn.className = 'dt-button dt-run'; |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 | 518 |
519 static String _lpad(String s, int n) { | 519 static String _lpad(String s, int n) { |
520 if(s.length < n) { | 520 if(s.length < n) { |
521 for(int i = 0; i < n - s.length; i++) { | 521 for(int i = 0; i < n - s.length; i++) { |
522 s = '0'+s; | 522 s = '0'+s; |
523 } | 523 } |
524 } | 524 } |
525 return s; | 525 return s; |
526 } | 526 } |
527 } | 527 } |
OLD | NEW |