| 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 * This configuration can be used to rerun selected tests, as well | 6 * This configuration can be used to rerun selected tests, as well |
| 7 * as see diagnostic output from tests. It runs each test in its own | 7 * as see diagnostic output from tests. It runs each test in its own |
| 8 * IFrame, so the configuration consists of two parts - a 'parent' | 8 * IFrame, so the configuration consists of two parts - a 'parent' |
| 9 * config that manages all the tests, and a 'child' config for the | 9 * config that manages all the tests, and a 'child' config for the |
| 10 * IFrame that runs the individual tests. | 10 * IFrame that runs the individual tests. |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 void onTestStart(TestCase testCase) { | 124 void onTestStart(TestCase testCase) { |
| 125 super.onTestStart(testCase); | 125 super.onTestStart(testCase); |
| 126 _testStarts[testCase.id]= new DateTime.now(); | 126 _testStarts[testCase.id]= new DateTime.now(); |
| 127 } | 127 } |
| 128 | 128 |
| 129 /** | 129 /** |
| 130 * Tests can call [logMessage] for diagnostic output. These log | 130 * Tests can call [logMessage] for diagnostic output. These log |
| 131 * messages in turn get passed to this method, which adds | 131 * messages in turn get passed to this method, which adds |
| 132 * a timestamp and posts them back to the parent window. | 132 * a timestamp and posts them back to the parent window. |
| 133 */ | 133 */ |
| 134 void logTestCaseMessage(TestCase testCase, String message) { | 134 void onLogMessage(TestCase testCase, String message) { |
| 135 int elapsed; | 135 int elapsed; |
| 136 if (testCase == null) { | 136 if (testCase == null) { |
| 137 elapsed = -1; | 137 elapsed = -1; |
| 138 } else { | 138 } else { |
| 139 DateTime end = new DateTime.now(); | 139 DateTime end = new DateTime.now(); |
| 140 elapsed = end.difference(_testStarts[testCase.id]).inMilliseconds; | 140 elapsed = end.difference(_testStarts[testCase.id]).inMilliseconds; |
| 141 } | 141 } |
| 142 parentWindow.postMessage( | 142 parentWindow.postMessage( |
| 143 _Message.text(_Message.LOG, elapsed, message).toString(), '*'); | 143 _Message.text(_Message.LOG, elapsed, message).toString(), '*'); |
| 144 } | 144 } |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 testItem.classes.clear(); | 352 testItem.classes.clear(); |
| 353 testItem.classes.add('test-it'); | 353 testItem.classes.add('test-it'); |
| 354 testItem.classes.add('status-pending'); | 354 testItem.classes.add('status-pending'); |
| 355 testItem.query('#$_actionIdPrefix$id').innerHtml = ''; | 355 testItem.query('#$_actionIdPrefix$id').innerHtml = ''; |
| 356 } | 356 } |
| 357 } | 357 } |
| 358 | 358 |
| 359 // Actually test logging is handled by the child, then posted | 359 // Actually test logging is handled by the child, then posted |
| 360 // back to the parent. So here we know that the [message] argument | 360 // back to the parent. So here we know that the [message] argument |
| 361 // is in the format used by [_Message]. | 361 // is in the format used by [_Message]. |
| 362 void logTestCaseMessage(TestCase testCase, String message) { | 362 void onLogMessage(TestCase testCase, String message) { |
| 363 var msg = new _Message.fromString(message); | 363 var msg = new _Message.fromString(message); |
| 364 if (msg.elapsed < 0) { // No associated test case. | 364 if (msg.elapsed < 0) { // No associated test case. |
| 365 document.query('#otherlogs').nodes.add( | 365 document.query('#otherlogs').nodes.add( |
| 366 new Element.html('<p>${msg.body}</p>')); | 366 new Element.html('<p>${msg.body}</p>')); |
| 367 } else { | 367 } else { |
| 368 var actions = document.query('#$_testIdPrefix${testCase.id}'). | 368 var actions = document.query('#$_testIdPrefix${testCase.id}'). |
| 369 query('.test-actions'); | 369 query('.test-actions'); |
| 370 String elapsedText = msg.elapsed >= 0 ? "${msg.elapsed}ms" : ""; | 370 String elapsedText = msg.elapsed >= 0 ? "${msg.elapsed}ms" : ""; |
| 371 actions.nodes.add(new Element.html( | 371 actions.nodes.add(new Element.html( |
| 372 "<li style='list-style-stype:none>" | 372 "<li style='list-style-stype:none>" |
| 373 "<div class='timer-result'>${elapsedText}</div>" | 373 "<div class='timer-result'>${elapsedText}</div>" |
| 374 "<div class='test-title'>${msg.body}</div>" | 374 "<div class='test-title'>${msg.body}</div>" |
| 375 "</li>")); | 375 "</li>")); |
| 376 } | 376 } |
| 377 } | 377 } |
| 378 | 378 |
| 379 void onTestResult(TestCase testCase) { | 379 void onTestResult(TestCase testCase) { |
| 380 if (!testCase.enabled) return; | 380 if (!testCase.enabled) return; |
| 381 super.onTestResult(testCase); | 381 super.onTestResult(testCase); |
| 382 if (testCase.message != '') { | 382 if (testCase.message != '') { |
| 383 logTestCaseMessage(testCase, | 383 onLogMessage(testCase, |
| 384 _Message.text(_Message.LOG, -1, testCase.message)); | 384 _Message.text(_Message.LOG, -1, testCase.message)); |
| 385 } | 385 } |
| 386 int id = testCase.id; | 386 int id = testCase.id; |
| 387 var testItem = document.query('#$_testIdPrefix$id'); | 387 var testItem = document.query('#$_testIdPrefix$id'); |
| 388 var timeSpan = testItem.query('.test-timer-result'); | 388 var timeSpan = testItem.query('.test-timer-result'); |
| 389 timeSpan.text = '${_testTime}ms'; | 389 timeSpan.text = '${_testTime}ms'; |
| 390 // Convert status into what we need for our CSS. | 390 // Convert status into what we need for our CSS. |
| 391 String result = 'status-error'; | 391 String result = 'status-error'; |
| 392 if (testCase.result == 'pass') { | 392 if (testCase.result == 'pass') { |
| 393 result = 'status-success'; | 393 result = 'status-success'; |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 display: block; | 669 display: block; |
| 670 list-style-type: disc; | 670 list-style-type: disc; |
| 671 -webkit-margin-before: 1em; | 671 -webkit-margin-before: 1em; |
| 672 -webkit-margin-after: 1em; | 672 -webkit-margin-after: 1em; |
| 673 -webkit-margin-start: 0px; | 673 -webkit-margin-start: 0px; |
| 674 -webkit-margin-end: 0px; | 674 -webkit-margin-end: 0px; |
| 675 -webkit-padding-start: 40px; | 675 -webkit-padding-start: 40px; |
| 676 } | 676 } |
| 677 | 677 |
| 678 """; | 678 """; |
| OLD | NEW |