| 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 /** | 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 //initialize and load CSS | 58 //initialize and load CSS |
| 59 final String _CSSID = '_unittestcss_'; | 59 final String _CSSID = '_unittestcss_'; |
| 60 | 60 |
| 61 var cssElement = document.head.query('#${_CSSID}'); | 61 var cssElement = document.head.query('#${_CSSID}'); |
| 62 if (cssElement == null){ | 62 if (cssElement == null){ |
| 63 document.head.elements.add(new Element.html( | 63 document.head.elements.add(new Element.html( |
| 64 '<style id="${_CSSID}"></style>')); | 64 '<style id="${_CSSID}"></style>')); |
| 65 cssElement = document.head.query('#${_CSSID}'); | 65 cssElement = document.head.query('#${_CSSID}'); |
| 66 } | 66 } |
| 67 | 67 |
| 68 cssElement.innerHTML = _htmlTestCSS; | 68 cssElement.innerHtml = _htmlTestCSS; |
| 69 } | 69 } |
| 70 | 70 |
| 71 void onStart() { | 71 void onStart() { |
| 72 window.postMessage('unittest-suite-wait-for-done', '*'); | 72 window.postMessage('unittest-suite-wait-for-done', '*'); |
| 73 // Listen for uncaught errors. | 73 // Listen for uncaught errors. |
| 74 window.on.error.add(_onErrorClosure); | 74 window.on.error.add(_onErrorClosure); |
| 75 } | 75 } |
| 76 | 76 |
| 77 void onTestResult(TestCase testCase) {} | 77 void onTestResult(TestCase testCase) {} |
| 78 | 78 |
| 79 void onDone(int passed, int failed, int errors, List<TestCase> results, | 79 void onDone(int passed, int failed, int errors, List<TestCase> results, |
| 80 String uncaughtError) { | 80 String uncaughtError) { |
| 81 _uninstallHandlers(); | 81 _uninstallHandlers(); |
| 82 | 82 |
| 83 _showInteractiveResultsInPage(passed, failed, errors, results, | 83 _showInteractiveResultsInPage(passed, failed, errors, results, |
| 84 _isLayoutTest, uncaughtError); | 84 _isLayoutTest, uncaughtError); |
| 85 | 85 |
| 86 window.postMessage('unittest-suite-done', '*'); | 86 window.postMessage('unittest-suite-done', '*'); |
| 87 } | 87 } |
| 88 | 88 |
| 89 void _showInteractiveResultsInPage(int passed, int failed, int errors, | 89 void _showInteractiveResultsInPage(int passed, int failed, int errors, |
| 90 List<TestCase> results, bool isLayoutTest, String uncaughtError) { | 90 List<TestCase> results, bool isLayoutTest, String uncaughtError) { |
| 91 if (isLayoutTest && passed == results.length) { | 91 if (isLayoutTest && passed == results.length) { |
| 92 document.body.innerHTML = "PASS"; | 92 document.body.innerHtml = "PASS"; |
| 93 } else { | 93 } else { |
| 94 // changed the StringBuffer to an Element fragment | 94 // changed the StringBuffer to an Element fragment |
| 95 Element te = new Element.html('<div class="unittest-table"></div>'); | 95 Element te = new Element.html('<div class="unittest-table"></div>'); |
| 96 | 96 |
| 97 te.elements.add(new Element.html(passed == results.length | 97 te.elements.add(new Element.html(passed == results.length |
| 98 ? "<div class='unittest-overall unittest-pass'>PASS</div>" | 98 ? "<div class='unittest-overall unittest-pass'>PASS</div>" |
| 99 : "<div class='unittest-overall unittest-fail'>FAIL</div>")); | 99 : "<div class='unittest-overall unittest-fail'>FAIL</div>")); |
| 100 | 100 |
| 101 // moved summary to the top since web browsers | 101 // moved summary to the top since web browsers |
| 102 // don't auto-scroll to the bottom like consoles typically do. | 102 // don't auto-scroll to the bottom like consoles typically do. |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 .unittest-row-description | 405 .unittest-row-description |
| 406 { | 406 { |
| 407 } | 407 } |
| 408 | 408 |
| 409 '''; | 409 '''; |
| 410 } | 410 } |
| 411 | 411 |
| 412 void useHtmlEnhancedConfiguration([bool isLayoutTest = false]) { | 412 void useHtmlEnhancedConfiguration([bool isLayoutTest = false]) { |
| 413 configure(new HtmlEnhancedConfiguration(isLayoutTest)); | 413 configure(new HtmlEnhancedConfiguration(isLayoutTest)); |
| 414 } | 414 } |
| OLD | NEW |