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