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

Side by Side 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: Addressed comments. 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 String GetHtmlContents(String title,
6 String controllerScript,
7 String scriptType,
8 String sourceScript) =>
9 """
10 <html>
11 <head>
12 <title> Test $title </title>
13 <style>
14 .unittest-table { font-family:monospace; border:1px; }
15 .unittest-pass { background: #6b3;}
16 .unittest-fail { background: #d55;}
17 .unittest-error { background: #a11;}
18 </style>
19 </head>
20 <body>
21 <h1> Running $title </h1>
22 <script type="text/javascript" src="../../../$controllerScript"></script>
23 <script type="$scriptType" src="../../../$sourceScript"></script>
24 <script type="text/javascript">
25 // If nobody intercepts the error, finish the test.
26 onerror = function() { window.layoutTestController.notifyDone() };
27
28 document.onreadystatechange = function() {
29 if (document.readyState != "loaded") return;
30 // If 'startedDartTest' is not set, that means that the test did not have
31 // a chance to load. This will happen when a load error occurs in the VM.
32 // Give the machine time to start up.
33 setTimeout(function() {
34 // A window.postMessage might have been enqueued after this timeout.
35 // Just sleep another time to give the browser the time to process the
36 // posted message.
37 setTimeout(function() {
38 if (layoutTestController && !layoutTestController.startedDartTest) {
39 layoutTestController.notifyDone();
40 }
41 }, 0);
42 }, 50);
43 };
44 </script>
45 </body>
46 </html>
47 """;
48
49 String WrapDartTestInLibrary(String test) =>
50 """
51 #library('libraryWrapper');
52 #source('$test');
53 """;
54
55 String DartTestWrapper(String unittest_ignored,
56 String test_ignored,
57 String domLibrary,
58 String testFramework,
59 String library) =>
60 """
61 #library('test');
62
63 #import('${domLibrary}');
64 #import('${testFramework}');
65
66 #import('${library}', prefix: "Test");
67
68 waitForDone() {
69 window.postMessage('unittest-suite-wait-for-done', '*');
70 }
71
72 pass() {
73 document.body.innerHTML = 'PASS';
74 window.postMessage('unittest-suite-done', '*');
75 }
76
77 fail(e, trace) {
78 document.body.innerHTML = 'FAIL: \$e, \$trace';
79 window.postMessage('unittest-suite-done', '*');
80 }
81
82 main() {
83 bool needsToWait = false;
84 bool mainIsFinished = false;
85 TestRunner.waitForDoneCallback = () { needsToWait = true; };
86 TestRunner.doneCallback = () {
87 if (mainIsFinished) {
88 pass();
89 } else {
90 needsToWait = false;
91 }
92 };
93 try {
94 Test.main();
95 if (needsToWait) {
96 waitForDone();
97 } else {
98 pass();
99 }
100 mainIsFinished = true;
101 } catch(var e, var trace) {
102 fail(e, trace);
103 }
104 }
105 """;
OLDNEW
« 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