| 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 String GetHtmlContents(String title, | 5 String GetHtmlContents(String title, |
| 6 String controllerScript, | 6 String controllerScript, |
| 7 String scriptType, | 7 String scriptType, |
| 8 String sourceScript) => | 8 String sourceScript) => |
| 9 """ | 9 """ |
| 10 <!DOCTYPE html> | 10 <!DOCTYPE html> |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 </body> | 50 </body> |
| 51 </html> | 51 </html> |
| 52 """; | 52 """; |
| 53 | 53 |
| 54 String WrapDartTestInLibrary(String test) => | 54 String WrapDartTestInLibrary(String test) => |
| 55 """ | 55 """ |
| 56 #library('libraryWrapper'); | 56 #library('libraryWrapper'); |
| 57 #source('$test'); | 57 #source('$test'); |
| 58 """; | 58 """; |
| 59 | 59 |
| 60 String DartTestWrapper(String dartHome, String library) => | 60 String DartTestWrapper(String domLibrary, |
| 61 String testFramework, |
| 62 String library) => |
| 61 """ | 63 """ |
| 62 #library('test'); | 64 #library('test'); |
| 63 | 65 |
| 64 #import('${dartHome}/lib/unittest/unittest.dart', prefix: 'unittest'); | 66 #import('${domLibrary}'); |
| 65 #import('${dartHome}/lib/unittest/html_config.dart', prefix: 'config'); | 67 #import('${testFramework}'); |
| 66 | 68 |
| 67 #import('${library}', prefix: "Test"); | 69 #import('${library}', prefix: "Test"); |
| 68 | 70 |
| 71 waitForDone() { |
| 72 window.postMessage('unittest-suite-wait-for-done', '*'); |
| 73 } |
| 74 |
| 75 pass() { |
| 76 document.body.innerHTML = 'PASS'; |
| 77 window.postMessage('unittest-suite-done', '*'); |
| 78 } |
| 79 |
| 80 fail(e, trace) { |
| 81 document.body.innerHTML = 'FAIL: \$e, \$trace'; |
| 82 window.postMessage('unittest-suite-done', '*'); |
| 83 } |
| 84 |
| 69 main() { | 85 main() { |
| 70 config.useHtmlConfiguration(); | 86 bool needsToWait = false; |
| 87 bool mainIsFinished = false; |
| 88 TestRunner.waitForDoneCallback = () { needsToWait = true; }; |
| 89 TestRunner.doneCallback = () { |
| 90 if (mainIsFinished) { |
| 91 pass(); |
| 92 } else { |
| 93 needsToWait = false; |
| 94 } |
| 95 }; |
| 71 try { | 96 try { |
| 72 unittest.ensureInitialized(); | |
| 73 Test.main(); | 97 Test.main(); |
| 98 if (needsToWait) { |
| 99 waitForDone(); |
| 100 } else { |
| 101 pass(); |
| 102 } |
| 103 mainIsFinished = true; |
| 74 } catch(var e, var trace) { | 104 } catch(var e, var trace) { |
| 75 unittest.reportTestError(e.message, trace); | 105 fail(e, trace); |
| 76 } | 106 } |
| 77 } | 107 } |
| 78 """; | 108 """; |
| OLD | NEW |