Chromium Code Reviews| 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, |
|
Bob Nystrom
2012/04/20 22:31:36
These methods are named strangely. Any reason why?
Siggi Cherem (dart-lang)
2012/04/21 00:03:43
I agree, I don't like the capitalization. I'll kee
| |
| 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> |
| 11 <html> | 11 <html> |
| 12 <head> | 12 <head> |
| 13 <title> Test $title </title> | 13 <title> Test $title </title> |
| 14 <style> | 14 <style> |
| 15 .unittest-table { font-family:monospace; border:1px; } | 15 .unittest-table { font-family:monospace; border:1px; } |
| (...skipping 34 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 domLibrary, | 60 String DartTestWrapper(String dartHome, String library) => |
| 61 String testFramework, | |
| 62 String library) => | |
| 63 """ | 61 """ |
| 64 #library('test'); | 62 #library('test'); |
| 65 | 63 |
| 66 #import('${domLibrary}'); | 64 #import('${dartHome}/lib/unittest/unittest.dart', prefix: 'unittest'); |
| 67 #import('${testFramework}'); | 65 #import('${dartHome}/lib/unittest/html_config.dart', prefix: 'config'); |
| 68 | 66 |
| 69 #import('${library}', prefix: "Test"); | 67 #import('${library}', prefix: "Test"); |
| 70 | 68 |
| 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 | |
| 85 main() { | 69 main() { |
| 86 bool needsToWait = false; | 70 config.useHtmlConfiguration(); |
| 87 bool mainIsFinished = false; | |
| 88 TestRunner.waitForDoneCallback = () { needsToWait = true; }; | |
| 89 TestRunner.doneCallback = () { | |
| 90 if (mainIsFinished) { | |
| 91 pass(); | |
| 92 } else { | |
| 93 needsToWait = false; | |
| 94 } | |
| 95 }; | |
| 96 try { | 71 try { |
| 72 unittest.ensureInitialized(); | |
| 97 Test.main(); | 73 Test.main(); |
| 98 if (needsToWait) { | |
| 99 waitForDone(); | |
| 100 } else { | |
| 101 pass(); | |
| 102 } | |
| 103 mainIsFinished = true; | |
| 104 } catch(var e, var trace) { | 74 } catch(var e, var trace) { |
| 105 fail(e, trace); | 75 unittest.notifyError(e.message, trace); |
| 106 } | 76 } |
| 107 } | 77 } |
| 108 """; | 78 """; |
| OLD | NEW |