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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/testing/dart/browser_test.dart
diff --git a/tools/testing/dart/browser_test.dart b/tools/testing/dart/browser_test.dart
index 1236b55dac062ec6cb3e1b921a3664657f003835..862375d87227a878bfbe1774b83823cd1a9b6ab5 100644
--- a/tools/testing/dart/browser_test.dart
+++ b/tools/testing/dart/browser_test.dart
@@ -2,11 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-library browser_test;
-
-import 'path.dart';
-
-String getHtmlContents(String title, String scriptType, Path sourceScript) {
+String getHtmlContents(String title, String scriptType, String scriptPath) {
return """
<!DOCTYPE html>
<html>
@@ -26,7 +22,7 @@ String getHtmlContents(String title, String scriptType, Path sourceScript) {
<script type="text/javascript"
src="/root_dart/tools/testing/dart/test_controller.js">
</script>
- <script type="$scriptType" src="$sourceScript"
+ <script type="$scriptType" src="$scriptPath"
onerror="scriptTagOnErrorCallback(null)"
defer>
</script>
@@ -36,6 +32,59 @@ String getHtmlContents(String title, String scriptType, Path sourceScript) {
</html>""";
}
+/// Generates the HTML template file needed to load and run a dartdevc test in
+/// the browser.
+///
+/// The [testName] is the short name of the test without any subdirectory path
+/// or extension, like "math_test". The [testJSDir] is the relative path to the
+/// build directory where the dartdevc-generated JS file is stored.
+String dartdevcHtml(String testName, String testJSDir) => """
+<!DOCTYPE html>
+<html>
+<head>
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="dart.unittest" content="full-stack-traces">
+ <title>Test $testName</title>
+ <style>
+ .unittest-table { font-family:monospace; border:1px; }
+ .unittest-pass { background: #6b3;}
+ .unittest-fail { background: #d55;}
+ .unittest-error { background: #a11;}
+ </style>
+</head>
+<body>
+<h1>Running $testName</h1>
+<script type="text/javascript"
+ src="/root_dart/tools/testing/dart/test_controller.js">
+</script>
+<script>
+var require = {
+ baseUrl: "/root_dart/$testJSDir",
+ // TODO(29923): Add paths to the packages that are used in tests once they
+ // are being built. Right now, they are compiled into the test module itself.
+ paths: {
+ "dart_sdk": "/root_dart/pkg/dev_compiler/lib/js/amd/dart_sdk",
+ }
+};
+
+// Don't try to bring up the debugger on a runtime error.
+window.ddcSettings = {
+ trapRuntimeErrors: false
+};
+</script>
+<script type="text/javascript"
+ src="/root_dart/third_party/requirejs/require.js"></script>
+<script type="text/javascript">
+requirejs(["$testName", "dart_sdk"],
+ function($testName, dart_sdk) {
+ dart_sdk._isolate_helper.startRootIsolate(function() {}, []);
+ dartMainRunner($testName.$testName.main);
+});
+</script>
+</body>
+</html>
+""";
+
String dartTestWrapper(String libraryPathComponent) {
return """
import '$libraryPathComponent' as test;
« 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