Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(853)

Side by Side Diff: tools/testing/dart/browser_test.dart

Issue 12223074: Create generated tests inside the build directory (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 part of test_suite; 5 part of test_suite;
6 6
7 String getHtmlContents(String title, 7 String getHtmlContents(String title,
8 Path controllerScript,
9 Path dartJsScript,
10 String scriptType, 8 String scriptType,
11 Path sourceScript) => 9 Path sourceScript) =>
12 """ 10 """
13 <!DOCTYPE html> 11 <!DOCTYPE html>
14 <html> 12 <html>
15 <head> 13 <head>
16 <meta http-equiv="X-UA-Compatible" content="IE=edge"> 14 <meta http-equiv="X-UA-Compatible" content="IE=edge">
17 <title> Test $title </title> 15 <title> Test $title </title>
18 <style> 16 <style>
19 .unittest-table { font-family:monospace; border:1px; } 17 .unittest-table { font-family:monospace; border:1px; }
20 .unittest-pass { background: #6b3;} 18 .unittest-pass { background: #6b3;}
21 .unittest-fail { background: #d55;} 19 .unittest-fail { background: #d55;}
22 .unittest-error { background: #a11;} 20 .unittest-error { background: #a11;}
23 </style> 21 </style>
24 </head> 22 </head>
25 <body> 23 <body>
26 <h1> Running $title </h1> 24 <h1> Running $title </h1>
27 <script type="text/javascript" src="$controllerScript"></script> 25 <script type="text/javascript" src="/root_dart/pkg/unittest/lib/test_controlle r.js">
Emily Fortuna 2013/02/12 18:04:09 long line
kustermann 2013/02/15 08:00:30 Done.
26 </script>
28 <script type="$scriptType" src="$sourceScript" onerror="externalError(null)"> 27 <script type="$scriptType" src="$sourceScript" onerror="externalError(null)">
29 </script> 28 </script>
30 <script type="text/javascript" src="$dartJsScript"></script> 29 <script type="text/javascript" src="/root_dart/pkg/browser/lib/dart.js"></scri pt>
31 </body> 30 </body>
32 </html> 31 </html>
33 """; 32 """;
34 33
35 String getHtmlLayoutContents(String scriptType, String sourceScript) => 34 String getHtmlLayoutContents(String scriptType, String sourceScript) =>
36 """ 35 """
37 <!DOCTYPE html> 36 <!DOCTYPE html>
38 <html> 37 <html>
39 <head> 38 <head>
40 <meta http-equiv="X-UA-Compatible" content="IE=edge"> 39 <meta http-equiv="X-UA-Compatible" content="IE=edge">
41 </head> 40 </head>
42 <body> 41 <body>
43 <script type="text/javascript"> 42 <script type="text/javascript">
44 if (navigator.webkitStartDart) navigator.webkitStartDart(); 43 if (navigator.webkitStartDart) navigator.webkitStartDart();
45 </script> 44 </script>
46 <script type="$scriptType" src="$sourceScript"></script> 45 <script type="$scriptType" src="$sourceScript"></script>
47 </body> 46 </body>
48 </html> 47 </html>
49 """; 48 """;
50 49
51 String wrapDartTestInLibrary(Path test, String testPath) => 50 String wrapDartTestInLibrary(Path testRelativeToDart) =>
52 """ 51 """
53 library libraryWrapper; 52 library libraryWrapper;
54 part '${pathLib.relative(test.toNativePath(), 53 part '/$testRelativeToDart';
55 from: pathLib.dirname(testPath)).replaceAll('\\', '\\\\')}';
56 """; 54 """;
57 55
58 String dartTestWrapper(Path dartHome, String testPath, Path library) { 56 String dartTestWrapper(bool usePackageImport, String libraryPathComponent) {
59 var testPathDir = pathLib.dirname(testPath);
60 var dartHomePath = dartHome.toNativePath();
61 // TODO(efortuna): Unify path libraries used in test.dart.
62 var unitTest = pathLib.relative(pathLib.join(dartHomePath,
63 'pkg/unittest/lib'), from: testPathDir).replaceAll('\\', '\\\\');
64
65 var libString = library.toNativePath();
66 if (!pathLib.isAbsolute(libString)) {
67 libString = pathLib.join(dartHome.toNativePath(), libString);
68 }
69 // Tests inside "pkg" import unittest using "package:". All others use a 57 // Tests inside "pkg" import unittest using "package:". All others use a
70 // relative path. The imports need to agree, so use a matching form here. 58 // relative path. The imports need to agree, so use a matching form here.
71 if (pathLib.split(pathLib.relative(libString, 59 var unitTest;
72 from: dartHome.toNativePath())).contains("pkg")) { 60 if (usePackageImport) {
73 unitTest = 'package:unittest'; 61 unitTest = 'package:unittest';
62 } else {
63 unitTest = '/root_dart/pkg/unittest/lib';
74 } 64 }
75 return """ 65 return """
76 library test; 66 library test;
77 67
78 import '$unitTest/unittest.dart' as unittest; 68 import '$unitTest/unittest.dart' as unittest;
79 import '$unitTest/html_config.dart' as config; 69 import '$unitTest/html_config.dart' as config;
80 import '${pathLib.relative(libString, from: testPathDir).replaceAll( 70 import '$libraryPathComponent' as Test;
81 '\\', '\\\\')}' as Test;
82 71
83 main() { 72 main() {
84 config.useHtmlConfiguration(); 73 config.useHtmlConfiguration();
85 unittest.group('', Test.main); 74 unittest.group('', Test.main);
86 } 75 }
87 """; 76 """;
88 } 77 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698