| OLD | NEW |
| 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 // Test the basic StreamController and StreamController.singleSubscription. | 5 // Test the basic StreamController and StreamController.singleSubscription. |
| 6 library stream_controller_async_test; | 6 library stream_controller_async_test; |
| 7 | 7 |
| 8 import 'dart:async'; | 8 import 'dart:async'; |
| 9 import 'dart:isolate'; | 9 import 'dart:isolate'; |
| 10 import "package:expect/expect.dart"; | 10 import "package:expect/expect.dart"; |
| (...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 652 onDone: actual.close); | 652 onDone: actual.close); |
| 653 var sink = c.sink; | 653 var sink = c.sink; |
| 654 sink.add(42); | 654 sink.add(42); |
| 655 sink.addError("error"); | 655 sink.addError("error"); |
| 656 sink.addStream(new Stream.fromIterable([1, 2, 3, 4, 5])) | 656 sink.addStream(new Stream.fromIterable([1, 2, 3, 4, 5])) |
| 657 .then((_) { | 657 .then((_) { |
| 658 sink.add(43); | 658 sink.add(43); |
| 659 return sink.close(); | 659 return sink.close(); |
| 660 }) | 660 }) |
| 661 .then((_) { | 661 .then((_) { |
| 662 if (asBroadcast) { | 662 if (asBroadcast || broadcast) { |
| 663 // The done-future of the sink completes when it passes | 663 // The done-future of the sink completes when it passes |
| 664 // the done event to the asBroadcastStream controller, which is | 664 // the done event to the asBroadcastStream controller, which is |
| 665 // before the final listener gets the event. | 665 // before the final listener gets the event. |
| 666 // Wait for the pause to end before testing the events. | 666 // Wait for the pause to end before testing the events. |
| 667 dynamic executeWhenPauseIsDone(Function f) { | 667 dynamic executeWhenPauseIsDone(Function f) { |
| 668 if (!pauseIsDone) { | 668 if (!pauseIsDone) { |
| 669 return new Future.delayed(const Duration(milliseconds: 50), () { | 669 return new Future.delayed(const Duration(milliseconds: 50), () { |
| 670 return executeWhenPauseIsDone(f); | 670 return executeWhenPauseIsDone(f); |
| 671 }); | 671 }); |
| 672 } | 672 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 692 testRethrow(); | 692 testRethrow(); |
| 693 testBroadcastController(); | 693 testBroadcastController(); |
| 694 testAsBroadcast(); | 694 testAsBroadcast(); |
| 695 testSink(sync: true, broadcast: false, asBroadcast: false); | 695 testSink(sync: true, broadcast: false, asBroadcast: false); |
| 696 testSink(sync: true, broadcast: false, asBroadcast: true); | 696 testSink(sync: true, broadcast: false, asBroadcast: true); |
| 697 testSink(sync: true, broadcast: true, asBroadcast: false); | 697 testSink(sync: true, broadcast: true, asBroadcast: false); |
| 698 testSink(sync: false, broadcast: false, asBroadcast: false); | 698 testSink(sync: false, broadcast: false, asBroadcast: false); |
| 699 testSink(sync: false, broadcast: false, asBroadcast: true); | 699 testSink(sync: false, broadcast: false, asBroadcast: true); |
| 700 testSink(sync: false, broadcast: true, asBroadcast: false); | 700 testSink(sync: false, broadcast: true, asBroadcast: false); |
| 701 } | 701 } |
| OLD | NEW |