OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 test.test.utils; | 5 library test.test.utils; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:collection'; | 8 import 'dart:collection'; |
9 | 9 |
10 import 'package:test/src/backend/declarer.dart'; | 10 import 'package:test/src/backend/declarer.dart'; |
| 11 import 'package:test/src/backend/group.dart'; |
| 12 import 'package:test/src/backend/group_entry.dart'; |
11 import 'package:test/src/backend/invoker.dart'; | 13 import 'package:test/src/backend/invoker.dart'; |
12 import 'package:test/src/backend/live_test.dart'; | 14 import 'package:test/src/backend/live_test.dart'; |
13 import 'package:test/src/backend/metadata.dart'; | 15 import 'package:test/src/backend/metadata.dart'; |
14 import 'package:test/src/backend/state.dart'; | 16 import 'package:test/src/backend/state.dart'; |
15 import 'package:test/src/backend/suite.dart'; | 17 import 'package:test/src/backend/suite.dart'; |
16 import 'package:test/src/runner/application_exception.dart'; | 18 import 'package:test/src/runner/application_exception.dart'; |
17 import 'package:test/src/runner/load_exception.dart'; | 19 import 'package:test/src/runner/load_exception.dart'; |
18 import 'package:test/src/util/remote_exception.dart'; | 20 import 'package:test/src/util/remote_exception.dart'; |
19 import 'package:test/test.dart'; | 21 import 'package:test/test.dart'; |
20 | 22 |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 // Use [new Future] future to allow microtask events to finish. The [new | 216 // Use [new Future] future to allow microtask events to finish. The [new |
215 // Future.value] constructor uses scheduleMicrotask itself and would therefore | 217 // Future.value] constructor uses scheduleMicrotask itself and would therefore |
216 // not wait for microtask callbacks that are scheduled after invoking this | 218 // not wait for microtask callbacks that are scheduled after invoking this |
217 // method. | 219 // method. |
218 return new Future(() => pumpEventQueue(times - 1)); | 220 return new Future(() => pumpEventQueue(times - 1)); |
219 } | 221 } |
220 | 222 |
221 /// Returns a local [LiveTest] that runs [body]. | 223 /// Returns a local [LiveTest] that runs [body]. |
222 LiveTest createTest(body()) { | 224 LiveTest createTest(body()) { |
223 var test = new LocalTest("test", new Metadata(), body); | 225 var test = new LocalTest("test", new Metadata(), body); |
224 var suite = new Suite([test]); | 226 var suite = new Suite(new Group.root([test])); |
225 return test.load(suite); | 227 return test.load(suite); |
226 } | 228 } |
227 | 229 |
228 /// Runs [body] as a test. | 230 /// Runs [body] as a test. |
229 /// | 231 /// |
230 /// Once it completes, returns the [LiveTest] used to run it. | 232 /// Once it completes, returns the [LiveTest] used to run it. |
231 Future<LiveTest> runTestBody(body()) async { | 233 Future<LiveTest> runTestBody(body()) async { |
232 var liveTest = createTest(body); | 234 var liveTest = createTest(body); |
233 await liveTest.run(); | 235 await liveTest.run(); |
234 return liveTest; | 236 return liveTest; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 }); | 278 }); |
277 | 279 |
278 await liveTest.run(); | 280 await liveTest.run(); |
279 expectTestPassed(liveTest); | 281 expectTestPassed(liveTest); |
280 // Ensure that the outer test doesn't complete until the inner future | 282 // Ensure that the outer test doesn't complete until the inner future |
281 // completes. | 283 // completes. |
282 return future; | 284 return future; |
283 } | 285 } |
284 | 286 |
285 /// Runs [body] with a declarer and returns the declared entries. | 287 /// Runs [body] with a declarer and returns the declared entries. |
286 List<SuiteEntry> declare(void body()) { | 288 List<GroupEntry> declare(void body()) { |
287 var declarer = new Declarer()..declare(body); | 289 var declarer = new Declarer()..declare(body); |
288 return declarer.build(); | 290 return declarer.build().entries; |
289 } | 291 } |
OLD | NEW |