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

Side by Side Diff: utils/testrunner/testrunner.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 //#!/usr/bin/env dart 1 //#!/usr/bin/env dart
2 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 2 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
3 // for details. All rights reserved. Use of this source code is governed by a 3 // for details. All rights reserved. Use of this source code is governed by a
4 // BSD-style license that can be found in the LICENSE file. 4 // BSD-style license that can be found in the LICENSE file.
5 5
6 /** 6 /**
7 * testrunner is a program to run Dart unit tests. Unlike $DART/tools/test.dart, 7 * testrunner is a program to run Dart unit tests. Unlike $DART/tools/test.dart,
8 * this program is intended for 3rd parties to be able to run unit tests in 8 * this program is intended for 3rd parties to be able to run unit tests in
9 * a batched fashion. As such, it adds some features and removes others. Some 9 * a batched fashion. As such, it adds some features and removes others. Some
10 * of the removed features are: 10 * of the removed features are:
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 * 42 *
43 * vm - run native Dart in the VM; i.e. using $DARTSDK/dart-sdk/bin/dart. 43 * vm - run native Dart in the VM; i.e. using $DARTSDK/dart-sdk/bin/dart.
44 * drt-dart - run native Dart in DumpRenderTree, the headless version of 44 * drt-dart - run native Dart in DumpRenderTree, the headless version of
45 * Dartium, which is located in $DARTSDK/chromium/DumpRenderTree, if 45 * Dartium, which is located in $DARTSDK/chromium/DumpRenderTree, if
46 * you intsalled the SDK that is bundled with the editor, or available 46 * you intsalled the SDK that is bundled with the editor, or available
47 * from http://gsdview.appspot.com/dartium-archive/continuous/ 47 * from http://gsdview.appspot.com/dartium-archive/continuous/
48 * otherwise. 48 * otherwise.
49 * 49 *
50 * drt-js - run Dart compiled to Javascript in DumpRenderTree. 50 * drt-js - run Dart compiled to Javascript in DumpRenderTree.
51 * 51 *
52 * testrunner supports simple DOM render tests. These use expected values 52 * testrunner supports simple DOM render tests. These can use expected values
53 * for the text render output from DumpRenderTree. When running a test in DRT 53 * for the render output from DumpRenderTree, either are textual DOM
54 * testrunner will see if there is a file with a .render extension in the 54 * descriptions (`--layout-tests`) or pixel renderings (`--pixel-tests`).
55 * same directory as the test file and with the same base file name. If so 55 * When running layout tests, testrunner will see if there is a file with
56 * it will do additional checks of the rendered layout. 56 * a .png or a .txt extension in a directory with the same name as the
57 * test file (withouty extension) and with the test name as the file name.
Siggi Cherem (dart-lang) 2012/09/20 17:37:27 withouty => without
gram 2012/09/20 18:58:03 Done.
58 * For example, if there is a test file foo_test.dart with tests 'test1'
59 * and 'test2', it will look for foo_test/test1.txt and foo_test/test2.txt
60 * for text render layout files. If these exist it will do additional checks
61 * of the rendered layout; if not, the test will fail.
57 * 62 *
58 * Here is a simple example test: 63 * Layout file (re)generation can be done using `--regenerate`. This will
59 * 64 * create or update the layout files (and implicitly pass the tests).
60 * #library('sample');
61 * #import('dart:html');
62 * #import('pkg:unittest/unittest.dart');
63 *
64 * main() {
65 * group('foo', () {
66 * test('test 1', () {
67 * document.body.nodes.add(new Element.html("<p>Test 1</p>"));
68 * });
69 * test('test 2', () {
70 * document.body.nodes.add(new Element.html("<p>Test 2</p>"));
71 * });
72 * });
73 * }
74 *
75 * And a sample matching .render file:
76 *
77 * [foo test 1]
78 * RenderBlock {P} at (0,0) size 284x20
79 * RenderText {#text} at (0,0) size 38x19
80 * text run at (0,0) width 38: "Test 1"
81 * [foo test 2]
82 * RenderBlock {P} at (0,0) size 284x20
83 * RenderText {#text} at (0,0) size 38x19
84 * text run at (0,0) width 38: "Test 2"
85 *
86 * Note that the render content is only the content inside the <body> element,
87 * not including the body element itself.
88 *
89 * Running testrunner with a `--generate-renders` flag will make it create
90 * .render files for you.
91 */ 65 */
92 66
93 // TODO - layout tests that use PNGs rather than DRT text render dumps. 67 // TODO - layout tests that use PNGs rather than DRT text render dumps.
94 #library('testrunner'); 68 #library('testrunner');
95 #import('dart:io'); 69 #import('dart:io');
96 #import('dart:isolate'); 70 #import('dart:isolate');
97 #import('dart:math'); 71 #import('dart:math');
98 #import('../../pkg/args/lib/args.dart'); 72 #import('../../pkg/args/lib/args.dart');
99 73
100 #source('configuration.dart'); 74 #source('configuration.dart');
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 // by these two templates. 167 // by these two templates.
194 var HTMLFile = 168 var HTMLFile =
195 '${Macros.directory}$pathSep${Macros.filenameNoExtension}.html'; 169 '${Macros.directory}$pathSep${Macros.filenameNoExtension}.html';
196 var CSSFile = 170 var CSSFile =
197 '${Macros.directory}$pathSep${Macros.filenameNoExtension}.css'; 171 '${Macros.directory}$pathSep${Macros.filenameNoExtension}.css';
198 pipeline.add(new HtmlWrapTask(Macros.fullFilePath, 172 pipeline.add(new HtmlWrapTask(Macros.fullFilePath,
199 HTMLFile, tempHTMLFile, CSSFile, tempCSSFile)); 173 HTMLFile, tempHTMLFile, CSSFile, tempCSSFile));
200 } 174 }
201 175
202 // Add the execution step. 176 // Add the execution step.
203 if (runtime == 'vm') { 177 if (runtime == 'vm' || config.layoutPixel || config.layoutText) {
204 if (checkedMode) { 178 if (checkedMode) {
205 pipeline.add(new DartTask.checked(tempDartFile)); 179 pipeline.add(new DartTask.checked(tempDartFile));
206 } else { 180 } else {
207 pipeline.add(new DartTask(tempDartFile)); 181 pipeline.add(new DartTask(tempDartFile));
208 } 182 }
209 } else { 183 } else {
210 pipeline.add(new DrtTask(Macros.fullFilePath, tempHTMLFile)); 184 pipeline.add(new DrtTask(Macros.fullFilePath, tempHTMLFile));
211 } 185 }
212 return pipeline; 186 return pipeline;
213 } 187 }
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 } 291 }
318 buildFileList(dirs, 292 buildFileList(dirs,
319 new RegExp(options['test-file-pattern']), options['recurse'], 293 new RegExp(options['test-file-pattern']), options['recurse'],
320 (f) => processTests(pipelineTemplate, f)); 294 (f) => processTests(pipelineTemplate, f));
321 } 295 }
322 } 296 }
323 } 297 }
324 } 298 }
325 299
326 300
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698