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

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; 42 var startDart = '';
43 StringBuffer sbuf = new StringBuffer(); 43 if (runtime == 'drt-dart') {
44 sbuf.add(""" 44 startDart =
45 "if (navigator.webkitStartDart) navigator.webkitStartDart();";
46 }
47
48 var prefix = flattenPath(p.directoryPath.toString());
49 var suffix = (config.layoutPixel || config.layoutText) ? '-child': '';
50 var scriptElement;
51 if (runtime == 'drt-dart') {
52 scriptElement = "<script type='application/dart' "
53 "src='${prefix}_${p.filenameWithoutExtension}$suffix.dart'>";
54 } else {
55 scriptElement = "<script type='text/javascript' "
56 "src='${prefix}_${p.filenameWithoutExtension}$suffix.js'>";
57 }
58
59 var bodyElements = "";
60 var runAsText = "";
61
62 if (!config.layoutText && !config.layoutPixel) {
63 runAsText = "window.testRunner.dumpAsText();";
64 bodyElements = """
65 <h1>$testname</h1>
66 <div id="container"></div>
67 <pre id='console'></pre>
68 """;
69 }
70
71 var htmlContent = """
45 <!DOCTYPE html> 72 <!DOCTYPE html>
46 73
47 <html> 74 <html>
48 <head> 75 <head>
49 <meta charset="utf-8"> 76 <meta charset="utf-8">
50 <title>$testname</title> 77 <title>$testname</title>
51 <link rel="stylesheet" href="${p.filenameWithoutExtension}.css"> 78 <link rel="stylesheet" href="${p.filenameWithoutExtension}.css">
52 <script type='text/javascript'> 79 <script type='text/javascript'>
53 // We check the search part of the URL for making sure we only do 80 if (window.testRunner) {
54 // this in the parent if in layout tests.
55 if (window.testRunner && window.location.search == '') {
56 function handleMessage(m) { 81 function handleMessage(m) {
57 if (m.data == 'done') { 82 if (m.data == 'done') {
58 window.testRunner.notifyDone(); 83 window.testRunner.notifyDone();
59 } 84 }
60 } 85 }
61 window.testRunner.waitUntilDone(); 86 window.testRunner.waitUntilDone();
62 if (!$isLayout) { 87 $runAsText
63 window.testRunner.dumpAsText();
64 }
65 window.addEventListener("message", handleMessage, false); 88 window.addEventListener("message", handleMessage, false);
66 } 89 }
67 """); 90 $startDart
68 if (runtime == 'drt-dart') {
69 sbuf.add("if (navigator.webkitStartDart) navigator.webkitStartDart();");
70 }
71 sbuf.add("""
72 </script> 91 </script>
73 </head> 92 </head>
74 <body> 93 <body>
75 """); 94 $bodyElements
76 if (!isLayout) { 95 $scriptElement
77 sbuf.add("""
78 <h1>$testname</h1>
79 <div id="container"></div>
80 <pre id='console'></pre>
81 """);
82 }
83 sbuf.add("<script type='");
84 var prefix = flattenPath(p.directoryPath.toString());
85 if (runtime == 'drt-dart') {
86 sbuf.add("application/dart' src='${prefix}_${p.filename}'>");
87 } else {
88 sbuf.add("text/javascript' "
89 "src='${prefix}_${p.filenameWithoutExtension}.js'>");
90 }
91 sbuf.add("""
92 </script> 96 </script>
93 <script 97 <script
94 src="http://dart.googlecode.com/svn/branches/bleeding_edge/dart/client/dart.js"> 98 src="http://dart.googlecode.com/svn/branches/bleeding_edge/dart/client/dart.js">
95 </script> 99 </script>
96 </body> 100 </body>
97 </html> 101 </html>
98 """); 102 """;
99 createFile(htmlDestName, sbuf.toString()); 103 createFile(htmlDestName, htmlContent);
100 } 104 }
101 var cssMaster = new File(cssSourceName); 105 var cssMaster = new File(cssSourceName);
102 if (cssMaster.existsSync()) { 106 if (cssMaster.existsSync()) {
103 if (logging) { 107 if (logging) {
104 stdout.add('Copying $cssSourceName to $cssDestName'); 108 stdout.add('Copying $cssSourceName to $cssDestName');
105 } 109 }
106 copyFile(cssSourceName, cssDestName); 110 copyFile(cssSourceName, cssDestName);
107 } else { 111 } else {
108 if (logging) { 112 if (logging) {
109 stdout.add('Creating $cssDestName'); 113 stdout.add('Creating $cssDestName');
(...skipping 30 matching lines...) Expand all
140 } 144 }
141 exitHandler(0); 145 exitHandler(0);
142 } 146 }
143 147
144 void cleanup(Path testfile, List stdout, List stderr, 148 void cleanup(Path testfile, List stdout, List stderr,
145 bool logging, bool keepFiles) { 149 bool logging, bool keepFiles) {
146 deleteFiles([_htmlDestFileTemplate, _cssDestFileTemplate], testfile, 150 deleteFiles([_htmlDestFileTemplate, _cssDestFileTemplate], testfile,
147 logging, keepFiles, stdout); 151 logging, keepFiles, stdout);
148 } 152 }
149 } 153 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698