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

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

Issue 2947473002: Basic support for dev_compiler in test.dart. (Closed)
Patch Set: Revise. Created 3 years, 6 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
« no previous file with comments | « tools/testing/dart/browser_controller.dart ('k') | tools/testing/dart/command.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 library browser_test; 5 String getHtmlContents(String title, String scriptType, String scriptPath) {
6
7 import 'path.dart';
8
9 String getHtmlContents(String title, String scriptType, Path sourceScript) {
10 return """ 6 return """
11 <!DOCTYPE html> 7 <!DOCTYPE html>
12 <html> 8 <html>
13 <head> 9 <head>
14 <meta http-equiv="X-UA-Compatible" content="IE=edge"> 10 <meta http-equiv="X-UA-Compatible" content="IE=edge">
15 <meta name="dart.unittest" content="full-stack-traces"> 11 <meta name="dart.unittest" content="full-stack-traces">
16 <title> Test $title </title> 12 <title> Test $title </title>
17 <style> 13 <style>
18 .unittest-table { font-family:monospace; border:1px; } 14 .unittest-table { font-family:monospace; border:1px; }
19 .unittest-pass { background: #6b3;} 15 .unittest-pass { background: #6b3;}
20 .unittest-fail { background: #d55;} 16 .unittest-fail { background: #d55;}
21 .unittest-error { background: #a11;} 17 .unittest-error { background: #a11;}
22 </style> 18 </style>
23 </head> 19 </head>
24 <body> 20 <body>
25 <h1> Running $title </h1> 21 <h1> Running $title </h1>
26 <script type="text/javascript" 22 <script type="text/javascript"
27 src="/root_dart/tools/testing/dart/test_controller.js"> 23 src="/root_dart/tools/testing/dart/test_controller.js">
28 </script> 24 </script>
29 <script type="$scriptType" src="$sourceScript" 25 <script type="$scriptType" src="$scriptPath"
30 onerror="scriptTagOnErrorCallback(null)" 26 onerror="scriptTagOnErrorCallback(null)"
31 defer> 27 defer>
32 </script> 28 </script>
33 <script type="text/javascript" 29 <script type="text/javascript"
34 src="/root_dart/pkg/browser/lib/dart.js"></script> 30 src="/root_dart/pkg/browser/lib/dart.js"></script>
35 </body> 31 </body>
36 </html>"""; 32 </html>""";
37 } 33 }
38 34
35 /// Generates the HTML template file needed to load and run a dartdevc test in
36 /// the browser.
37 ///
38 /// The [testName] is the short name of the test without any subdirectory path
39 /// or extension, like "math_test". The [testJSDir] is the relative path to the
40 /// build directory where the dartdevc-generated JS file is stored.
41 String dartdevcHtml(String testName, String testJSDir) => """
42 <!DOCTYPE html>
43 <html>
44 <head>
45 <meta http-equiv="X-UA-Compatible" content="IE=edge">
46 <meta name="dart.unittest" content="full-stack-traces">
47 <title>Test $testName</title>
48 <style>
49 .unittest-table { font-family:monospace; border:1px; }
50 .unittest-pass { background: #6b3;}
51 .unittest-fail { background: #d55;}
52 .unittest-error { background: #a11;}
53 </style>
54 </head>
55 <body>
56 <h1>Running $testName</h1>
57 <script type="text/javascript"
58 src="/root_dart/tools/testing/dart/test_controller.js">
59 </script>
60 <script>
61 var require = {
62 baseUrl: "/root_dart/$testJSDir",
63 // TODO(29923): Add paths to the packages that are used in tests once they
64 // are being built. Right now, they are compiled into the test module itself.
65 paths: {
66 "dart_sdk": "/root_dart/pkg/dev_compiler/lib/js/amd/dart_sdk",
67 }
68 };
69
70 // Don't try to bring up the debugger on a runtime error.
71 window.ddcSettings = {
72 trapRuntimeErrors: false
73 };
74 </script>
75 <script type="text/javascript"
76 src="/root_dart/third_party/requirejs/require.js"></script>
77 <script type="text/javascript">
78 requirejs(["$testName", "dart_sdk"],
79 function($testName, dart_sdk) {
80 dart_sdk._isolate_helper.startRootIsolate(function() {}, []);
81 dartMainRunner($testName.$testName.main);
82 });
83 </script>
84 </body>
85 </html>
86 """;
87
39 String dartTestWrapper(String libraryPathComponent) { 88 String dartTestWrapper(String libraryPathComponent) {
40 return """ 89 return """
41 import '$libraryPathComponent' as test; 90 import '$libraryPathComponent' as test;
42 91
43 main() { 92 main() {
44 print("dart-calling-main"); 93 print("dart-calling-main");
45 test.main(); 94 test.main();
46 print("dart-main-done"); 95 print("dart-main-done");
47 } 96 }
48 """; 97 """;
49 } 98 }
OLDNEW
« no previous file with comments | « tools/testing/dart/browser_controller.dart ('k') | tools/testing/dart/command.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698