| 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 unittest.test.utils; | 5 library unittest.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:unittest/src/backend/invoker.dart'; | 10 import 'package:unittest/src/backend/invoker.dart'; |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 // Use [new Future] future to allow microtask events to finish. The [new | 172 // Use [new Future] future to allow microtask events to finish. The [new |
| 173 // Future.value] constructor uses scheduleMicrotask itself and would therefore | 173 // Future.value] constructor uses scheduleMicrotask itself and would therefore |
| 174 // not wait for microtask callbacks that are scheduled after invoking this | 174 // not wait for microtask callbacks that are scheduled after invoking this |
| 175 // method. | 175 // method. |
| 176 return new Future(() => pumpEventQueue(times - 1)); | 176 return new Future(() => pumpEventQueue(times - 1)); |
| 177 } | 177 } |
| 178 | 178 |
| 179 /// Returns a local [LiveTest] that runs [body]. | 179 /// Returns a local [LiveTest] that runs [body]. |
| 180 LiveTest createTest(body()) { | 180 LiveTest createTest(body()) { |
| 181 var test = new LocalTest("test", body); | 181 var test = new LocalTest("test", body); |
| 182 var suite = new Suite("suite", [test]); | 182 var suite = new Suite([test]); |
| 183 return test.load(suite); | 183 return test.load(suite); |
| 184 } | 184 } |
| 185 | 185 |
| 186 /// Runs [body] as a test. | 186 /// Runs [body] as a test. |
| 187 /// | 187 /// |
| 188 /// Once it completes, returns the [LiveTest] used to run it. | 188 /// Once it completes, returns the [LiveTest] used to run it. |
| 189 Future<LiveTest> runTest(body()) { | 189 Future<LiveTest> runTest(body()) { |
| 190 var liveTest = createTest(body); | 190 var liveTest = createTest(body); |
| 191 return liveTest.run().then((_) => liveTest); | 191 return liveTest.run().then((_) => liveTest); |
| 192 } | 192 } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 }); | 232 }); |
| 233 }); | 233 }); |
| 234 | 234 |
| 235 return liveTest.run().then((_) { | 235 return liveTest.run().then((_) { |
| 236 expectTestPassed(liveTest); | 236 expectTestPassed(liveTest); |
| 237 // Ensure that the outer test doesn't complete until the inner future | 237 // Ensure that the outer test doesn't complete until the inner future |
| 238 // completes. | 238 // completes. |
| 239 return future; | 239 return future; |
| 240 }); | 240 }); |
| 241 } | 241 } |
| OLD | NEW |