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

Unified Diff: tools/testing/dart/browser_test.dart

Issue 8889016: Enable Dartium tests in tools/test.dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years 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 | « no previous file | tools/testing/dart/test_options.dart » ('j') | tools/testing/dart/test_runner.dart » ('J')
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
new file mode 100644
index 0000000000000000000000000000000000000000..b386033c78bb3ed3fdc11b98bbf045b3ade0d0bd
--- /dev/null
+++ b/tools/testing/dart/browser_test.dart
@@ -0,0 +1,102 @@
+// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+// 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.
+
+String GetHtmlContents(String title,
+ String controllerScript,
+ String scriptType,
+ String sourceScript) => """
Mads Ager (google) 2011/12/09 09:21:12 Nit: I think I would put the """ on a new line by
+<html>
+<head>
+ <title> Test $title </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 $title </h1>
+ <script type="text/javascript" src="../../../$controllerScript"></script>
+ <script type="$scriptType" src="../../../$sourceScript"></script>
+ <script type="text/javascript">
+ // If nobody intercepts the error, finish the test.
+ onerror = function() { window.layoutTestController.notifyDone() };
+
+ document.onreadystatechange = function() {
+ if (document.readyState != "loaded") return;
+ // If 'startedDartTest' is not set, that means that the test did not have
+ // a chance to load. This will happen when a load error occurs in the VM.
+ // Give the machine time to start up.
+ setTimeout(function() {
+ // A window.postMessage might have been enqueued after this timeout.
+ // Just sleep another time to give the browser the time to process the
+ // posted message.
+ setTimeout(function() {
+ if (layoutTestController && !layoutTestController.startedDartTest) {
+ layoutTestController.notifyDone();
+ }
+ }, 0);
+ }, 50);
+ };
+ </script>
+</body>
+</html>
+""";
+
+String WrapDartTestInLibrary(String test) => """
Mads Ager (google) 2011/12/09 09:21:12 Ditto.
+#library('libraryWrapper');
+#source('$test');
+""";
+
+String DartTestWrapper(String unittest_ignored,
+ String test_ignored,
+ String domLibrary,
+ String testFramework,
+ String library) => """
Mads Ager (google) 2011/12/09 09:21:12 And here. I'll shut up now. ;-)
Bill Hesse 2011/12/09 12:33:29 Done.
+#library('test');
+
+#import('${domLibrary}');
+#import('${testFramework}');
+
+#import('${library}', prefix: "Test");
+
+waitForDone() {
+ window.postMessage('unittest-suite-wait-for-done', '*');
+}
+
+pass() {
+ document.body.innerHTML = 'PASS';
+ window.postMessage('unittest-suite-done', '*');
+}
+
+fail(e, trace) {
+ document.body.innerHTML = 'FAIL: \$e, \$trace';
+ window.postMessage('unittest-suite-done', '*');
+}
+
+main() {
+ bool needsToWait = false;
+ bool mainIsFinished = false;
+ TestRunner.waitForDoneCallback = () { needsToWait = true; };
+ TestRunner.doneCallback = () {
+ if (mainIsFinished) {
+ pass();
+ } else {
+ needsToWait = false;
+ }
+ };
+ try {
+ Test.main();
+ if (needsToWait) {
+ waitForDone();
+ } else {
+ pass();
+ }
+ mainIsFinished = true;
+ } catch(var e, var trace) {
+ fail(e, trace);
+ }
+}
+""";
« no previous file with comments | « no previous file | tools/testing/dart/test_options.dart » ('j') | tools/testing/dart/test_runner.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698