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, |
Siggi Cherem (dart-lang)
2012/06/27 01:50:42
I noticed that these should start with lower-case
| |
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 <meta http-equiv="X-UA-Compatible" content="IE=edge"> | 13 <meta http-equiv="X-UA-Compatible" content="IE=edge"> |
14 <title> Test $title </title> | 14 <title> Test $title </title> |
15 <style> | 15 <style> |
16 .unittest-table { font-family:monospace; border:1px; } | 16 .unittest-table { font-family:monospace; border:1px; } |
17 .unittest-pass { background: #6b3;} | 17 .unittest-pass { background: #6b3;} |
18 .unittest-fail { background: #d55;} | 18 .unittest-fail { background: #d55;} |
19 .unittest-error { background: #a11;} | 19 .unittest-error { background: #a11;} |
20 </style> | 20 </style> |
21 </head> | 21 </head> |
22 <body> | 22 <body> |
23 <h1> Running $title </h1> | 23 <h1> Running $title </h1> |
24 <script type="text/javascript" src="$controllerScript"></script> | 24 <script type="text/javascript" src="$controllerScript"></script> |
25 <script type="$scriptType" src="$sourceScript"></script> | 25 <script type="$scriptType" src="$sourceScript"></script> |
26 </body> | 26 </body> |
27 </html> | 27 </html> |
28 """; | 28 """; |
29 | 29 |
30 String getHtmlLayoutContents(String scriptType, String sourceScript) => | |
31 """ | |
32 <!DOCTYPE html> | |
33 <html> | |
34 <head> | |
35 <meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
36 </head> | |
37 <body> | |
38 <script type="text/javascript"> | |
39 if (navigator.webkitStartDart) navigator.webkitStartDart(); | |
40 </script> | |
41 <script type="$scriptType" src="$sourceScript"></script> | |
42 </body> | |
43 </html> | |
44 """; | |
45 | |
30 /** | 46 /** |
31 * Returns the native [path] converted for use in a URI. | 47 * Returns the native [path] converted for use in a URI. |
32 */ | 48 */ |
33 nativePathToUri(String path) { | 49 nativePathToUri(String path) { |
34 // This regexp matches Windows-like file names. Strictly speaking, | 50 // This regexp matches Windows-like file names. Strictly speaking, |
35 // this prevents us from having a file named a:something on Linux, | 51 // this prevents us from having a file named a:something on Linux, |
36 // but since this wrapping is a hack in the first place, it seems | 52 // but since this wrapping is a hack in the first place, it seems |
37 // better to exercise this path on all architectures. | 53 // better to exercise this path on all architectures. |
38 final re = const RegExp('^[a-z]:', ignoreCase: true); | 54 final re = const RegExp('^[a-z]:', ignoreCase: true); |
39 if (re.hasMatch(path)) { | 55 if (re.hasMatch(path)) { |
40 path = '/$path'; | 56 path = '/$path'; |
41 } | 57 } |
42 return path.replaceAll('\\', '/'); | 58 return path.replaceAll('\\', '/'); |
43 } | 59 } |
44 | 60 |
45 String WrapDartTestInLibrary(String test) => | 61 String wrapDartTestInLibrary(String test) => |
46 """ | 62 """ |
47 #library('libraryWrapper'); | 63 #library('libraryWrapper'); |
48 #source('${nativePathToUri(test)}'); | 64 #source('${nativePathToUri(test)}'); |
49 """; | 65 """; |
50 | 66 |
51 String DartTestWrapper(String dartHome, String library) { | 67 String dartTestWrapper(String dartHome, String library) { |
52 dartHome = nativePathToUri(dartHome); | 68 dartHome = nativePathToUri(dartHome); |
53 library = nativePathToUri(library); | 69 library = nativePathToUri(library); |
54 return """ | 70 return """ |
55 #library('test'); | 71 #library('test'); |
56 | 72 |
57 #import('${dartHome}/lib/unittest/unittest.dart', prefix: 'unittest'); | 73 #import('${dartHome}/lib/unittest/unittest.dart', prefix: 'unittest'); |
58 #import('${dartHome}/lib/unittest/html_config.dart', prefix: 'config'); | 74 #import('${dartHome}/lib/unittest/html_config.dart', prefix: 'config'); |
59 | 75 |
60 #import('${library}', prefix: "Test"); | 76 #import('${library}', prefix: "Test"); |
61 | 77 |
62 main() { | 78 main() { |
63 config.useHtmlConfiguration(); | 79 config.useHtmlConfiguration(); |
64 try { | 80 try { |
65 unittest.ensureInitialized(); | 81 unittest.ensureInitialized(); |
66 Test.main(); | 82 Test.main(); |
67 } catch(var e, var trace) { | 83 } catch(var e, var trace) { |
68 unittest.reportTestError( | 84 unittest.reportTestError( |
69 e.toString(), trace == null ? '' : trace.toString()); | 85 e.toString(), trace == null ? '' : trace.toString()); |
70 } | 86 } |
71 } | 87 } |
72 """; | 88 """; |
73 } | 89 } |
OLD | NEW |