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

Side by Side Diff: samples/tests/samples/lib/layout/layout_test.dart

Issue 10917275: Update unittest to new package layout. (Closed) Base URL: https://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) 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 #library('layout_tests'); 5 #library('layout_tests');
6 6
7 #import('dart:html'); 7 #import('dart:html');
8 #import('../../../../ui_lib/base/base.dart'); 8 #import('../../../../ui_lib/base/base.dart');
9 #import('../../../../ui_lib/layout/layout.dart'); 9 #import('../../../../ui_lib/layout/layout.dart');
10 #import('../../../../ui_lib/view/view.dart'); 10 #import('../../../../ui_lib/view/view.dart');
11 #import('../../../../ui_lib/util/utilslib.dart'); 11 #import('../../../../ui_lib/util/utilslib.dart');
12 #import('../../../../../pkg/unittest/unittest.dart'); 12 #import('../../../../../pkg/unittest/lib/unittest.dart');
13 #import('../../../../../pkg/unittest/html_config.dart'); 13 #import('../../../../../pkg/unittest/lib/html_config.dart');
14 14
15 #source('grid_layout_demo.dart'); 15 #source('grid_layout_demo.dart');
16 #source('grid_examples.dart'); 16 #source('grid_examples.dart');
17 #source('css.dart'); 17 #source('css.dart');
18 18
19 // TODO(jmesserly): these tests would be easier to work with if they were WebKit 19 // TODO(jmesserly): these tests would be easier to work with if they were WebKit
20 // layout tests. The way DumpRenderTree works is exactly what we want for 20 // layout tests. The way DumpRenderTree works is exactly what we want for
21 // testing layout: run the example and then print the element tree with metrics. 21 // testing layout: run the example and then print the element tree with metrics.
22 // The UnitTestSuite wrapper gets in our way here, because you can't "see" the 22 // The UnitTestSuite wrapper gets in our way here, because you can't "see" the
23 // test layout visually when you're debugging. 23 // test layout visually when you're debugging.
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 152
153 // Note: to debug failures, best bet is to use GridLayoutDemo to run an 153 // Note: to debug failures, best bet is to use GridLayoutDemo to run an
154 // individual asyncTest and see the resulting layout. 154 // individual asyncTest and see the resulting layout.
155 155
156 usingGrid(String example, void test_(View grid)) { 156 usingGrid(String example, void test_(View grid)) {
157 final grid = createGrid(GridExamples.styles[example]); 157 final grid = createGrid(GridExamples.styles[example]);
158 grid.addToDocument(document.body); 158 grid.addToDocument(document.body);
159 window.setTimeout(() { 159 window.setTimeout(() {
160 test_(grid); 160 test_(grid);
161 window.setTimeout(expectAsync0(() { grid.removeFromDocument(); }), 0); 161 window.setTimeout(expectAsync0(() { grid.removeFromDocument(); }), 0);
162 }, 0); 162 }, 0);
163 } 163 }
164 164
165 verifyGrid(String example, [Map expected = null]) { 165 verifyGrid(String example, [Map expected = null]) {
166 printMetrics(example); 166 printMetrics(example);
167 if (expected == null) { 167 if (expected == null) {
168 return; 168 return;
169 } 169 }
170 170
171 for (String name in expected.getKeys()) { 171 for (String name in expected.getKeys()) {
172 final values = expected[name]; 172 final values = expected[name];
173 final node = document.body.query('#$name'); 173 final node = document.body.query('#$name');
174 Expect.isNotNull(node); 174 Expect.isNotNull(node);
175 node.rect.then(expectAsync0((rect) { 175 node.rect.then(expectAsync0((rect) {
176 final offset = rect.offset; 176 final offset = rect.offset;
177 Expect.equals(values[0], offset.left); 177 Expect.equals(values[0], offset.left);
178 Expect.equals(values[1], offset.top); 178 Expect.equals(values[1], offset.top);
179 Expect.equals(values[2], offset.width); 179 Expect.equals(values[2], offset.width);
180 Expect.equals(values[3], offset.height); 180 Expect.equals(values[3], offset.height);
181 })); 181 }));
182 } 182 }
183 } 183 }
184 184
185 verifyExample(String example, [Map expected = null]) { 185 verifyExample(String example, [Map expected = null]) {
186 usingGrid(example, (grid) => verifyGrid(example, expected)); 186 usingGrid(example, (grid) => verifyGrid(example, expected));
187 } 187 }
OLDNEW
« no previous file with comments | « samples/tests/samples/dartcombat/dartcombat_test.dart ('k') | samples/tests/samples/lib/observable/observable_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698