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

Side by Side Diff: pkg/unittest/config.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 | « pkg/pkg.status ('k') | pkg/unittest/html_layout_config.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) 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 /** This file is sourced by unitest.dart. */ 5 /** This file is sourced by unitest.dart. */
6 6
7 /** 7 /**
8 * Hooks to configure the unittest library for different platforms. This class 8 * Hooks to configure the unittest library for different platforms. This class
9 * implements the API in a platform-independent way. Tests that want to take 9 * implements the API in a platform-independent way. Tests that want to take
10 * advantage of the platform can create a subclass and override methods from 10 * advantage of the platform can create a subclass and override methods from
11 * this class. 11 * this class.
12 */ 12 */
13 class Configuration { 13 class Configuration {
14 TestCase currentTestCase = null; 14 TestCase currentTestCase = null;
15 15
16 /** 16 /**
17 * Subclasses can override this with something useful for diagnostics.
18 * Particularly useful in cases where we have parent/child configurations
19 * such as layout tests.
20 */
21 get name => 'Configuration';
22 /**
17 * If true, then tests are started automatically (otherwise [runTests] 23 * If true, then tests are started automatically (otherwise [runTests]
18 * must be called explicitly after the tests are set up. 24 * must be called explicitly after the tests are set up.
19 */ 25 */
20 get autoStart => true; 26 get autoStart => true;
21 27
22 /** 28 /**
23 * Called as soon as the unittest framework becomes initialized. This is done 29 * Called as soon as the unittest framework becomes initialized. This is done
24 * even before tests are added to the test framework. It might be used to 30 * even before tests are added to the test framework. It might be used to
25 * determine/debug errors that occur before the test harness starts executing. 31 * determine/debug errors that occur before the test harness starts executing.
26 */ 32 */
(...skipping 20 matching lines...) Expand all
47 */ 53 */
48 void onTestResult(TestCase testCase) { 54 void onTestResult(TestCase testCase) {
49 currentTestCase = null; 55 currentTestCase = null;
50 } 56 }
51 57
52 /** 58 /**
53 * Can be called by tests to log status. Tests should use this 59 * Can be called by tests to log status. Tests should use this
54 * instead of print. Subclasses should not override this; they 60 * instead of print. Subclasses should not override this; they
55 * should instead override logMessage which is passed the test case. 61 * should instead override logMessage which is passed the test case.
56 */ 62 */
57 void log(String message) { 63 void logMessage(String message) {
58 if (currentTestCase == null || _currentTest >= _tests.length || 64 if (currentTestCase == null || _currentTest >= _tests.length ||
59 currentTestCase.id != _tests[_currentTest].id) { 65 currentTestCase.id != _tests[_currentTest].id) {
60 // Before or after tests run, or with a mismatch between what the 66 // Before or after tests run, or with a mismatch between what the
61 // config and the test harness think is the current test. In this 67 // config and the test harness think is the current test. In this
62 // case we pass null for the test case reference and let the config 68 // case we pass null for the test case reference and let the config
63 // decide what to do with this. 69 // decide what to do with this.
64 logMessage(null, message); 70 logTestCaseMessage(null, message);
65 } else { 71 } else {
66 logMessage(currentTestCase, message); 72 logTestCaseMessage(currentTestCase, message);
67 } 73 }
68 } 74 }
69 75
70 /** 76 /**
71 * Handles the logging of messages by a test case. The default in 77 * Handles the logging of messages by a test case. The default in
72 * this base configuration is to call print(); 78 * this base configuration is to call print();
73 */ 79 */
74 void logMessage(TestCase testCase, String message) { 80 void logTestCaseMessage(TestCase testCase, String message) {
75 print(message); 81 print(message);
76 } 82 }
77 83
78 /** 84 /**
79 * Called with the result of all test cases. The default implementation prints 85 * Called with the result of all test cases. The default implementation prints
80 * the result summary using the built-in [print] command. Browser tests 86 * the result summary using the built-in [print] command. Browser tests
81 * commonly override this to reformat the output. 87 * commonly override this to reformat the output.
82 * 88 *
83 * When [uncaughtError] is not null, it contains an error that occured outside 89 * When [uncaughtError] is not null, it contains an error that occured outside
84 * of tests (e.g. setting up the test). 90 * of tests (e.g. setting up the test).
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 131
126 return Strings.join(str.split("\n").map((line) => " $line"), "\n"); 132 return Strings.join(str.split("\n").map((line) => " $line"), "\n");
127 } 133 }
128 134
129 /** Handle errors that happen outside the tests. */ 135 /** Handle errors that happen outside the tests. */
130 // TODO(vsm): figure out how to expose the stack trace here 136 // TODO(vsm): figure out how to expose the stack trace here
131 // Currently e.message works in dartium, but not in dartc. 137 // Currently e.message works in dartium, but not in dartc.
132 handleExternalError(e, String message) => 138 handleExternalError(e, String message) =>
133 _reportTestError('$message\nCaught $e', ''); 139 _reportTestError('$message\nCaught $e', '');
134 } 140 }
OLDNEW
« no previous file with comments | « pkg/pkg.status ('k') | pkg/unittest/html_layout_config.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698