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

Side by Side Diff: client/tools/htmlconverter_test.py

Issue 9567032: Bring htmlconverter back up to date: (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 9 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 | « client/tools/htmlconverter.py ('k') | client/tools/update.py » ('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) 2011, the Dart project authors. Please see the AUTHORS file 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 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 #!/usr/bin/env python 5 #!/usr/bin/env python
6 # 6 #
7 7
8 """A test for htmlconverter.py 8 """A test for htmlconverter.py
9 """ 9 """
10 10
11 from os.path import abspath, basename, dirname, exists, join, split 11 from os.path import abspath, basename, dirname, exists, join, split
12 import optparse 12 import optparse
13 import os 13 import os
14 import sys 14 import sys
15 import subprocess 15 import subprocess
16 16
17 # The inputs to our test 17 # The inputs to our test
18 TEST1_HTML = """ 18 TEST1_HTML = """
19 <html> 19 <html>
20 <head></head> 20 <head></head>
21 <body> 21 <body>
22 <script type="application/javascript"> 22 <script type="application/javascript">
23 if (window.layoutTestController) { 23 if (window.layoutTestController) {
24 window.layoutTestController.dumpAsText(); 24 window.layoutTestController.dumpAsText();
25 } 25 }
26 </script> 26 </script>
27 27
28 <!-- embed source code --> 28 <!-- embed source code -->
29 <script type="application/dart"> 29 <script type="application/dart">
30 #import('dart:dom');
30 main() { 31 main() {
31 window.alert('hi'); 32 window.alert('hi');
32 } 33 }
33 </script> 34 </script>
34 </body> 35 </body>
35 </html> 36 </html>
36 """ 37 """
37 38
38 TEST1_OUTPUT = """ 39 TEST1_OUTPUT = """
39 ALERT: hi 40 ALERT: hi
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 } 127 }
127 </script> 128 </script>
128 129
129 <script type="application/dart" src="test_4.dart"></script> 130 <script type="application/dart" src="test_4.dart"></script>
130 </body> 131 </body>
131 </html> 132 </html>
132 """ 133 """
133 134
134 TEST4_DART = """ 135 TEST4_DART = """
135 #import('dart:dom'); 136 #import('dart:dom');
136 #import('observable/observable.dart'); 137 #import('../samples/ui_lib/observable/observable.dart');
137 138
138 main() { 139 main() {
139 // use imported code 140 // use imported code
140 var arr = new ObservableList(); 141 var arr = new ObservableList();
141 arr.addChangeListener((EventSummary events) { 142 arr.addChangeListener((EventSummary events) {
142 var t = ['update', 'add ', 143 var t = ['update', 'add ',
143 'remove', 'global'][events.events[0].type]; 144 'remove', 'global'][events.events[0].type];
144 var o = events.events[0].oldValue; 145 var o = events.events[0].oldValue;
145 o = (o != null ? o : '_'); 146 o = (o != null ? o : '_');
146 var n = events.events[0].newValue; 147 var n = events.events[0].newValue;
(...skipping 29 matching lines...) Expand all
176 <head></head> 177 <head></head>
177 <body> 178 <body>
178 <script type="application/javascript"> 179 <script type="application/javascript">
179 if (window.layoutTestController) { 180 if (window.layoutTestController) {
180 window.layoutTestController.dumpAsText(); 181 window.layoutTestController.dumpAsText();
181 } 182 }
182 </script> 183 </script>
183 184
184 <!-- embed source code --> 185 <!-- embed source code -->
185 <script type="application/dart"> 186 <script type="application/dart">
187 #import('dart:dom');
186 main() { 188 main() {
187 var element = document.getElementById("test5div"); 189 var element = document.getElementById("test5div");
188 if (element == null) { 190 if (element == null) {
189 window.alert("this script shoulnd't be run synchronously"); 191 window.alert("this script shoulnd't be run synchronously");
190 } else { 192 } else {
191 window.alert(element.innerHTML); 193 window.alert(element.innerHTML);
192 } 194 }
193 } 195 }
194 </script> 196 </script>
195 <div id="test5div">this is visible on DOMContentLoaded</div> 197 <div id="test5div">this is visible on DOMContentLoaded</div>
196 </body> 198 </body>
197 </html> 199 </html>
198 """ 200 """
199 201
200 TEST5_OUTPUT = """ 202 TEST5_OUTPUT = """
201 ALERT: this is visible on DOMContentLoaded 203 ALERT: this is visible on DOMContentLoaded
202 Content-Type: text/plain 204 Content-Type: text/plain
203 this is visible on DOMContentLoaded 205 this is visible on DOMContentLoaded
204 #EOF 206 #EOF
205 """ 207 """
206 208
207 # TODO(sigmund): integrate with testing infrastructure and mark negative tests.
208 # removing the prefix on test6 should purposely fail.
209
210 TEST6_HTML = """ 209 TEST6_HTML = """
211 <html> 210 <html>
212 <head></head> 211 <head></head>
213 <body> 212 <body>
214 <script type="application/javascript"> 213 <script type="application/javascript">
215 if (window.layoutTestController) { 214 if (window.layoutTestController) {
216 window.layoutTestController.dumpAsText(); 215 window.layoutTestController.dumpAsText();
217 } 216 }
218 </script> 217 </script>
219 218
220 <!-- embed source code --> 219 <!-- embed source code -->
221 <script type="application/dart"> 220 <script type="application/dart">
222 #import('html/html.dart', prefix: 'html'); 221 #import('dart:html', prefix: 'html');
223 main() { 222 main() {
224 html.window.alert('hi'); 223 html.window.alert('hi');
225 } 224 }
226 </script> 225 </script>
227 </body> 226 </body>
228 </html> 227 </html>
229 """ 228 """
230 229
231 TEST6_OUTPUT = """ 230 TEST6_OUTPUT = """
232 ALERT: hi 231 ALERT: hi
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 if verbose or pipe.returncode != 0: 298 if verbose or pipe.returncode != 0:
300 print output 299 print output
301 print err 300 print err
302 return pipe.returncode, output, err 301 return pipe.returncode, output, err
303 302
304 def browserRun(message, htmlfile, test, verbose): 303 def browserRun(message, htmlfile, test, verbose):
305 # run the generated code 304 # run the generated code
306 printLine(message + ' [%d]' % (test + 1)) 305 printLine(message + ' [%d]' % (test + 1))
307 status, out, err = execute([ 306 status, out, err = execute([
308 'tests/drt/DumpRenderTree', 307 'tests/drt/DumpRenderTree',
309 '--dart-flags=--enable_type_checks --enable_asserts', htmlfile], 308 htmlfile],
310 verbose) 309 verbose)
311 if status != 0: 310 if status != 0:
312 printLine("%sERROR%s test output [%d]" % (RED_COLOR, NO_COLOR, test + 1)) 311 printLine("%sERROR%s test output [%d]" % (RED_COLOR, NO_COLOR, test + 1))
313 return status 312 return status
314 313
315 # check that the output is equivalent and cleanup 314 # check that the output is equivalent and cleanup
316 out = '\n' + out 315 out = '\n' + out
317 if out == OUTPUTS[test]: 316 if out == OUTPUTS[test]:
318 printLine("%sPASS%s [%d]" % (GREEN_COLOR, NO_COLOR, test + 1)) 317 printLine("%sPASS%s [%d]" % (GREEN_COLOR, NO_COLOR, test + 1))
319 else: 318 else:
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 deleteInputFiles() 406 deleteInputFiles()
408 return 1 407 return 1
409 408
410 if not keep_temporary_files: 409 if not keep_temporary_files:
411 deleteInputFiles() 410 deleteInputFiles()
412 return 0 411 return 0
413 412
414 413
415 if __name__ == '__main__': 414 if __name__ == '__main__':
416 sys.exit(main()) 415 sys.exit(main())
OLDNEW
« no previous file with comments | « client/tools/htmlconverter.py ('k') | client/tools/update.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698