OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 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. |
| 4 |
| 5 import 'dart:async'; |
| 6 import 'dart:io'; |
| 7 |
| 8 import 'package:scheduled_test/scheduled_test.dart'; |
| 9 |
| 10 import '../metatest.dart'; |
| 11 import '../utils.dart'; |
| 12 |
| 13 void main() { |
| 14 setUpTimeout(); |
| 15 |
| 16 expectTestsPass("aborting the schedule before it's started running should " |
| 17 "cause no tasks to be run", () { |
| 18 test('test', () { |
| 19 schedule(() { |
| 20 throw 'error'; |
| 21 }); |
| 22 |
| 23 currentSchedule.abort(); |
| 24 }); |
| 25 }); |
| 26 |
| 27 expectTestsPass("aborting the schedule while it's running should stop future " |
| 28 "tasks from running", () { |
| 29 test('test', () { |
| 30 schedule(currentSchedule.abort); |
| 31 |
| 32 schedule(() { |
| 33 throw 'error'; |
| 34 }); |
| 35 }); |
| 36 }); |
| 37 |
| 38 expectTestsPass("aborting the schedule while it's running shouldn't stop " |
| 39 "tasks in other queues from running", () { |
| 40 var onCompleteRun = false; |
| 41 test('test 1', () { |
| 42 schedule(currentSchedule.abort); |
| 43 |
| 44 currentSchedule.onComplete.schedule(() { |
| 45 onCompleteRun = true; |
| 46 }); |
| 47 }); |
| 48 |
| 49 test('test 2', () { |
| 50 expect(onCompleteRun, isTrue); |
| 51 }); |
| 52 }); |
| 53 |
| 54 expectTestsPass("aborting the schedule while it's running shouldn't stop " |
| 55 "out-of-band callbacks", () { |
| 56 test('test', () { |
| 57 var outOfBandFinished = false; |
| 58 schedule(() { |
| 59 wrapFuture(pumpEventQueue().then((_) { |
| 60 outOfBandFinished = true; |
| 61 })); |
| 62 |
| 63 currentSchedule.abort(); |
| 64 }); |
| 65 |
| 66 currentSchedule.onComplete.schedule(() { |
| 67 expect(outOfBandFinished, isTrue); |
| 68 }); |
| 69 }); |
| 70 }); |
| 71 |
| 72 expectTestsPass("aborting the schedule in a non-tasks queue should stop " |
| 73 "future tasks from running", () { |
| 74 test('test', () { |
| 75 currentSchedule.onComplete.schedule(() { |
| 76 currentSchedule.abort(); |
| 77 }); |
| 78 |
| 79 currentSchedule.onComplete.schedule(() { |
| 80 throw 'error'; |
| 81 }); |
| 82 }); |
| 83 }); |
| 84 |
| 85 expectTestsFail("aborting the schedule after an out-of-band error should " |
| 86 "still surface the error", () { |
| 87 test('test', () { |
| 88 schedule(() { |
| 89 currentSchedule.signalError('error'); |
| 90 currentSchedule.abort(); |
| 91 }); |
| 92 }); |
| 93 }); |
| 94 } |
OLD | NEW |