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

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

Issue 10909240: Support for pixel layout tests. (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
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;
(...skipping 21 matching lines...) Expand all
32 if (logging) { 32 if (logging) {
33 stdout.add('Copying $htmlSourceName to $htmlDestName'); 33 stdout.add('Copying $htmlSourceName to $htmlDestName');
34 } 34 }
35 copyFile(htmlSourceName, htmlDestName); 35 copyFile(htmlSourceName, htmlDestName);
36 } else { 36 } else {
37 if (logging) { 37 if (logging) {
38 stdout.add('Creating wrapper $htmlDestName'); 38 stdout.add('Creating wrapper $htmlDestName');
39 } 39 }
40 var p = new Path(testname); 40 var p = new Path(testname);
41 var runtime = config.runtime; 41 var runtime = config.runtime;
42 var isLayout = isLayoutRenderTest(testname) || config.generateRenders;
43 StringBuffer sbuf = new StringBuffer(); 42 StringBuffer sbuf = new StringBuffer();
44 sbuf.add(""" 43 sbuf.add("""
45 <!DOCTYPE html> 44 <!DOCTYPE html>
46 45
47 <html> 46 <html>
48 <head> 47 <head>
49 <meta charset="utf-8"> 48 <meta charset="utf-8">
50 <title>$testname</title> 49 <title>$testname</title>
51 <link rel="stylesheet" href="${p.filenameWithoutExtension}.css"> 50 <link rel="stylesheet" href="${p.filenameWithoutExtension}.css">
52 <script type='text/javascript'> 51 <script type='text/javascript'>
53 // We check the search part of the URL for making sure we only do 52 if (window.testRunner) {
54 // this in the parent if in layout tests.
55 if (window.testRunner && window.location.search == '') {
56 function handleMessage(m) { 53 function handleMessage(m) {
57 if (m.data == 'done') { 54 if (m.data == 'done') {
58 window.testRunner.notifyDone(); 55 window.testRunner.notifyDone();
59 } 56 }
60 } 57 }
61 window.testRunner.waitUntilDone(); 58 window.testRunner.waitUntilDone();
62 if (!$isLayout) { 59 ${(config.layoutText || config.layoutPixel)?'':
Siggi Cherem (dart-lang) 2012/09/20 17:37:27 nit: spaces around ? and : also, like in my other
gram 2012/09/20 18:58:03 Done.
63 window.testRunner.dumpAsText(); 60 'window.testRunner.dumpAsText();'}
64 }
65 window.addEventListener("message", handleMessage, false); 61 window.addEventListener("message", handleMessage, false);
66 } 62 }
67 """); 63 """);
68 if (runtime == 'drt-dart') { 64 if (runtime == 'drt-dart') {
69 sbuf.add("if (navigator.webkitStartDart) navigator.webkitStartDart();"); 65 sbuf.add("if (navigator.webkitStartDart) navigator.webkitStartDart();");
70 } 66 }
71 sbuf.add(""" 67 sbuf.add("""
72 </script> 68 </script>
73 </head> 69 </head>
74 <body> 70 <body>
75 """); 71 """);
76 if (!isLayout) { 72 if (!config.layoutText && !config.layoutPixel) {
77 sbuf.add(""" 73 sbuf.add("""
78 <h1>$testname</h1> 74 <h1>$testname</h1>
79 <div id="container"></div> 75 <div id="container"></div>
80 <pre id='console'></pre> 76 <pre id='console'></pre>
81 """); 77 """);
82 } 78 }
83 sbuf.add("<script type='"); 79 sbuf.add("<script type='");
84 var prefix = flattenPath(p.directoryPath.toString()); 80 var prefix = flattenPath(p.directoryPath.toString());
81 var suffix = (config.layoutPixel || config.layoutText) ? '-child': '';
85 if (runtime == 'drt-dart') { 82 if (runtime == 'drt-dart') {
86 sbuf.add("application/dart' src='${prefix}_${p.filename}'>"); 83 sbuf.add("application/dart' "
84 "src='${prefix}_${p.filenameWithoutExtension}$suffix.dart'>");
87 } else { 85 } else {
88 sbuf.add("text/javascript' " 86 sbuf.add("text/javascript' "
89 "src='${prefix}_${p.filenameWithoutExtension}.js'>"); 87 "src='${prefix}_${p.filenameWithoutExtension}$suffix.js'>");
90 } 88 }
91 sbuf.add(""" 89 sbuf.add("""
92 </script> 90 </script>
93 <script 91 <script
94 src="http://dart.googlecode.com/svn/branches/bleeding_edge/dart/client/dart.js"> 92 src="http://dart.googlecode.com/svn/branches/bleeding_edge/dart/client/dart.js">
95 </script> 93 </script>
96 </body> 94 </body>
97 </html> 95 </html>
98 """); 96 """);
99 createFile(htmlDestName, sbuf.toString()); 97 createFile(htmlDestName, sbuf.toString());
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 } 138 }
141 exitHandler(0); 139 exitHandler(0);
142 } 140 }
143 141
144 void cleanup(Path testfile, List stdout, List stderr, 142 void cleanup(Path testfile, List stdout, List stderr,
145 bool logging, bool keepFiles) { 143 bool logging, bool keepFiles) {
146 deleteFiles([_htmlDestFileTemplate, _cssDestFileTemplate], testfile, 144 deleteFiles([_htmlDestFileTemplate, _cssDestFileTemplate], testfile,
147 logging, keepFiles, stdout); 145 logging, keepFiles, stdout);
148 } 146 }
149 } 147 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698