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

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

Issue 10914049: Added support for layout render tests. These use expected values for the text render output from Du… (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
« no previous file with comments | « utils/testrunner/drt_task.dart ('k') | utils/testrunner/options.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) 2012, the Dart project authors. Please see the AUTHORS file 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 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 /** 5 /**
6 * A pipeline task to create a HTML/CSS wrapper for a test so it can run in DRT. 6 * A pipeline task to create a HTML/CSS wrapper for a test so it can run in DRT.
7 */ 7 */
8 class HtmlWrapTask extends PipelineTask { 8 class HtmlWrapTask extends PipelineTask {
9 final String _testFileTemplate; 9 final String _testFileTemplate;
10 final String _htmlSourceFileTemplate; 10 final String _htmlSourceFileTemplate;
11 final String _htmlDestFileTemplate; 11 final String _htmlDestFileTemplate;
12 final String _cssSourceFileTemplate; 12 final String _cssSourceFileTemplate;
13 final String _cssDestFileTemplate; 13 final String _cssDestFileTemplate;
14 14
15 HtmlWrapTask(this._testFileTemplate, this._htmlSourceFileTemplate, 15 HtmlWrapTask(this._testFileTemplate, this._htmlSourceFileTemplate,
16 this._htmlDestFileTemplate, this._cssSourceFileTemplate, 16 this._htmlDestFileTemplate, this._cssSourceFileTemplate,
17 this._cssDestFileTemplate); 17 this._cssDestFileTemplate);
18 18
19 void execute(Path testfile, List stdout, List stderr, bool logging, 19 void execute(Path testfile, List stdout, List stderr, bool logging,
20 Function exitHandler) { 20 Function exitHandler) {
21 var testname = expandMacros(_testFileTemplate, testfile);
22
21 // If the test already has a corresponding HTML file we copy that, 23 // If the test already has a corresponding HTML file we copy that,
22 // else we create a new wrapper. 24 // else we create a new wrapper.
23 var testname = expandMacros(_testFileTemplate, testfile);
24 var htmlSourceName = expandMacros(_htmlSourceFileTemplate, testfile); 25 var htmlSourceName = expandMacros(_htmlSourceFileTemplate, testfile);
25 var htmlDestName = expandMacros(_htmlDestFileTemplate, testfile); 26 var htmlDestName = expandMacros(_htmlDestFileTemplate, testfile);
26 var cssSourceName = expandMacros(_cssSourceFileTemplate, testfile); 27 var cssSourceName = expandMacros(_cssSourceFileTemplate, testfile);
27 var cssDestName = expandMacros(_cssDestFileTemplate, testfile); 28 var cssDestName = expandMacros(_cssDestFileTemplate, testfile);
28 29
29 var htmlMaster = new File(htmlSourceName); 30 var htmlMaster = new File(htmlSourceName);
30 if (htmlMaster.existsSync()) { 31 if (htmlMaster.existsSync()) {
31 if (logging) { 32 if (logging) {
32 stdout.add('Copying $htmlSourceName to $htmlDestName'); 33 stdout.add('Copying $htmlSourceName to $htmlDestName');
33 } 34 }
34 copyFile(htmlSourceName, htmlDestName); 35 copyFile(htmlSourceName, htmlDestName);
35 } else { 36 } else {
36 if (logging) { 37 if (logging) {
37 stdout.add('Creating wrapper $htmlDestName'); 38 stdout.add('Creating wrapper $htmlDestName');
38 } 39 }
39 var p = new Path(testname); 40 var p = new Path(testname);
40 var runtime = config.runtime; 41 var runtime = config.runtime;
42 var isLayout = isLayoutRenderTest(testname) || config.generateRenders;
41 StringBuffer sbuf = new StringBuffer(); 43 StringBuffer sbuf = new StringBuffer();
42 sbuf.add(""" 44 sbuf.add("""
43 <!DOCTYPE html> 45 <!DOCTYPE html>
44 46
45 <html> 47 <html>
46 <head> 48 <head>
47 <meta charset="utf-8"> 49 <meta charset="utf-8">
48 <title>$testname</title> 50 <title>$testname</title>
49 <link rel="stylesheet" href="${p.filenameWithoutExtension}.css"> 51 <link rel="stylesheet" href="${p.filenameWithoutExtension}.css">
50 <script type='text/javascript'> 52 <script type='text/javascript'>
51 function handleMessage(m) { 53 // We check the search part of the URL for making sure we only do
52 if (m.data == 'done') { 54 // this in the parent if in layout tests.
53 window.testRunner.notifyDone(); 55 if (window.testRunner && window.location.search == '') {
56 function handleMessage(m) {
57 if (m.data == 'done') {
58 window.testRunner.notifyDone();
59 }
54 } 60 }
61 window.testRunner.waitUntilDone();
62 if (!$isLayout) {
63 window.testRunner.dumpAsText();
64 }
65 window.addEventListener("message", handleMessage, false);
55 } 66 }
56
57 if (window.testRunner) {
58 window.testRunner.waitUntilDone();
59 window.testRunner.dumpAsText();
60 window.addEventListener("message", handleMessage, false);
61 }
62 """); 67 """);
63 if (runtime == 'drt-dart') { 68 if (runtime == 'drt-dart') {
64 sbuf.add("if (navigator.webkitStartDart) navigator.webkitStartDart();"); 69 sbuf.add("if (navigator.webkitStartDart) navigator.webkitStartDart();");
65 } 70 }
66 sbuf.add(""" 71 sbuf.add("""
67 </script> 72 </script>
68 </head> 73 </head>
69 <body> 74 <body>
75 """);
76 if (!isLayout) {
77 sbuf.add("""
70 <h1>$testname</h1> 78 <h1>$testname</h1>
71 <div id="container"></div> 79 <div id="container"></div>
72 <pre id="console"></pre> 80 <pre id='console'></pre>
73 <script type='"""); 81 """);
82 }
83 sbuf.add("<script type='");
74 var prefix = flattenPath(p.directoryPath.toString()); 84 var prefix = flattenPath(p.directoryPath.toString());
75 if (runtime == 'drt-dart') { 85 if (runtime == 'drt-dart') {
76 sbuf.add("application/dart' src='${prefix}_${p.filename}'>"); 86 sbuf.add("application/dart' src='${prefix}_${p.filename}'>");
77 } else { 87 } else {
78 sbuf.add("text/javascript' " 88 sbuf.add("text/javascript' "
79 "src='${prefix}_${p.filenameWithoutExtension}.js'>"); 89 "src='${prefix}_${p.filenameWithoutExtension}.js'>");
80 } 90 }
81 sbuf.add(""" 91 sbuf.add("""
82 </script> 92 </script>
83 <script 93 <script
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 } 140 }
131 exitHandler(0); 141 exitHandler(0);
132 } 142 }
133 143
134 void cleanup(Path testfile, List stdout, List stderr, 144 void cleanup(Path testfile, List stdout, List stderr,
135 bool logging, bool keepFiles) { 145 bool logging, bool keepFiles) {
136 deleteFiles([_htmlDestFileTemplate, _cssDestFileTemplate], testfile, 146 deleteFiles([_htmlDestFileTemplate, _cssDestFileTemplate], testfile,
137 logging, keepFiles, stdout); 147 logging, keepFiles, stdout);
138 } 148 }
139 } 149 }
OLDNEW
« no previous file with comments | « utils/testrunner/drt_task.dart ('k') | utils/testrunner/options.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698