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

Side by Side Diff: utils/testrunner/html_wrap_task.dart

Issue 10897016: Testrunner for 3rd parties. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 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
(Empty)
1 // Copyright (c) 2012, 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 // Create HTML wrapper for a test so it can run in DRT.
6 class HtmlWrapTask extends PipelineTask {
7 String testFileTemplate;
8 String htmlSourceFileTemplate;
9 String htmlDestFileTemplate;
10 String cssSourceFileTemplate;
11 String cssDestFileTemplate;
12
13 HtmlWrapTask(this.testFileTemplate, this.htmlSourceFileTemplate,
14 this.htmlDestFileTemplate, this.cssSourceFileTemplate,
15 this.cssDestFileTemplate);
16
17 void execute(Path testfile, List stdout, List stderr, bool verboseLogging,
18 Function exitHandler) {
19 // If the test already has a corresponding HTML file we copy that,
20 // else we create a new wrapper.
21 var testname = concretize(testFileTemplate, testfile);
22 var htmlSourceName = concretize(htmlSourceFileTemplate, testfile);
23 var htmlDestName = concretize(htmlDestFileTemplate, testfile);
24 var cssSourceName = concretize(cssSourceFileTemplate, testfile);
25 var cssDestName = concretize(cssDestFileTemplate, testfile);
26
27 var htmlMaster = new File(htmlSourceName);
28 if (htmlMaster.existsSync()) {
29 if (verboseLogging) {
30 stdout.add('Copying $htmlSourceName to $htmlDestName');
31 }
32 copyFile(htmlSourceName, htmlDestName);
33 } else {
34 if (verboseLogging) {
35 stdout.add('Creating wrapper $htmlDestName');
36 }
37 var p = new Path(testname);
38 var runtime = configuration['runtime'];
39 StringBuffer sbuf = new StringBuffer();
40 sbuf.add("""
41 <!DOCTYPE html>
42
43 <html>
44 <head>
45 <meta charset="utf-8">
46 <title>$testname</title>
47 <link rel="stylesheet" href="${p.filenameWithoutExtension}.css">
48 <script type='text/javascript'>
49 function handleMessage(m) {
50 if (m.data == 'done') {
51 window.testRunner.notifyDone();
52 }
53 }
54
55 if (window.testRunner) {
56 window.testRunner.waitUntilDone();
57 window.testRunner.dumpAsText();
58 window.addEventListener("message", handleMessage, false);
59 }
60 """);
61 if (runtime == 'drt-dart') {
62 sbuf.add("if (navigator.webkitStartDart) navigator.webkitStartDart();");
63 }
64 sbuf.add("""
65 </script>
66 </head>
67 <body>
68 <h1>$testname</h1>
69 <div id="container"></div>
70 <pre id="console"></pre>
71 <script type='""");
72 if (runtime == 'drt-dart') {
73 sbuf.add("application/dart' src='${p.filename}'>");
74 } else {
75 sbuf.add("text/javascript' src='${p.filenameWithoutExtension}.js'>");
76 }
77 sbuf.add("""
78 </script>
79 <script
80 src="http://dart.googlecode.com/svn/branches/bleeding_edge/dart/client/dart.js">
81 </script>
82 </body>
83 </html>
84 """);
85 createFile(htmlDestName, sbuf.toString());
86 }
87 var cssMaster = new File(cssSourceName);
88 if (cssMaster.existsSync()) {
89 if (verboseLogging) {
90 stdout.add('Copying $cssSourceName to $cssDestName');
91 }
92 copyFile(cssSourceName, cssDestName);
93 } else {
94 if (verboseLogging) {
95 stdout.add('Creating $cssDestName');
96 }
97 createFile(cssDestName, """
98 body {
99 background-color: #F8F8F8;
100 font-family: 'Open Sans', sans-serif;
101 font-size: 14px;
102 font-weight: normal;
103 line-height: 1.2em;
104 margin: 15px;
105 }
106
107 p {
108 color: #333;
109 }
110
111 #container {
112 width: 100%;
113 height: 400px;
114 position: relative;
115 border: 1px solid #ccc;
116 background-color: #fff;
117 }
118
119 #text {
120 font-size: 24pt;
121 text-align: center;
122 margin-top: 140px;
123 }
124
125 """);
126 }
127 exitHandler(0);
128 }
129 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698