| 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_test; | 6 library stream_controller_test; |
| 7 | 7 |
| 8 import "package:expect/expect.dart"; | 8 import "package:expect/expect.dart"; |
| 9 import "package:async_helper/async_helper.dart"; | 9 import "package:async_helper/async_helper.dart"; |
| 10 import 'dart:async'; | 10 import 'dart:async'; |
| (...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 602 StreamController c = new StreamController.broadcast(); | 602 StreamController c = new StreamController.broadcast(); |
| 603 var f = c.close(); | 603 var f = c.close(); |
| 604 f.then((_) { | 604 f.then((_) { |
| 605 // Listening after close is allowed. The listener gets a done event. | 605 // Listening after close is allowed. The listener gets a done event. |
| 606 var sub = c.stream.listen(null, onDone: () { | 606 var sub = c.stream.listen(null, onDone: () { |
| 607 Expect.fail("wrong done"); | 607 Expect.fail("wrong done"); |
| 608 }); | 608 }); |
| 609 sub.pause(); | 609 sub.pause(); |
| 610 sub.pause(); | 610 sub.pause(); |
| 611 new Timer(MS * 100, () { | 611 new Timer(MS * 100, () { |
| 612 sub.asFuture().whenComplete(() { Expect.fail("Bad complete"); }); |
| 612 sub.resume(); | 613 sub.resume(); |
| 613 new Timer(MS * 100, () { | 614 new Timer(MS * 100, () { |
| 614 sub.onDone(asyncEnd); | 615 sub.onDone(asyncEnd); |
| 615 sub.resume(); | 616 sub.resume(); |
| 616 }); | 617 }); |
| 617 }); | 618 }); |
| 618 }); | 619 }); |
| 619 } | 620 } |
| 620 | 621 |
| 621 void testAsBroadcastListenAfterClose() { | 622 void testAsBroadcastListenAfterClose() { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 639 s.listen(null, onDone: asyncEnd); | 640 s.listen(null, onDone: asyncEnd); |
| 640 var f = c.close(); | 641 var f = c.close(); |
| 641 f.then((_) { | 642 f.then((_) { |
| 642 // Listening after close is allowed. The listener gets a done event. | 643 // Listening after close is allowed. The listener gets a done event. |
| 643 var sub = s.listen(null, onDone: () { | 644 var sub = s.listen(null, onDone: () { |
| 644 Expect.fail("wrong done"); | 645 Expect.fail("wrong done"); |
| 645 }); | 646 }); |
| 646 sub.pause(); | 647 sub.pause(); |
| 647 sub.pause(); | 648 sub.pause(); |
| 648 new Timer(MS * 100, () { | 649 new Timer(MS * 100, () { |
| 650 sub.asFuture().whenComplete(() { Expect.fail("Bad complete"); }); |
| 649 sub.resume(); | 651 sub.resume(); |
| 650 new Timer(MS * 100, () { | 652 new Timer(MS * 100, () { |
| 651 sub.onDone(asyncEnd); | 653 sub.onDone(asyncEnd); |
| 652 sub.resume(); | 654 sub.resume(); |
| 653 }); | 655 }); |
| 654 }); | 656 }); |
| 655 }); | 657 }); |
| 656 } | 658 } |
| 657 | 659 |
| 658 main() { | 660 main() { |
| 659 asyncStart(); | 661 asyncStart(); |
| 660 testMultiController(); | 662 testMultiController(); |
| 661 testSingleController(); | 663 testSingleController(); |
| 662 testExtraMethods(); | 664 testExtraMethods(); |
| 663 testClosed(); | 665 testClosed(); |
| 664 testCloseFuture(); | 666 testCloseFuture(); |
| 665 testCloseFuture2(); | 667 testCloseFuture2(); |
| 666 testCloseFuture3(); | 668 testCloseFuture3(); |
| 667 testStreamEquals(); | 669 testStreamEquals(); |
| 668 testCancelThrow(); | 670 testCancelThrow(); |
| 669 testCancelThrow2(); | 671 testCancelThrow2(); |
| 670 testCancelThrow3(); | 672 testCancelThrow3(); |
| 671 testBroadcastListenAfterClose(); | 673 testBroadcastListenAfterClose(); |
| 672 testBroadcastListenAfterClosePaused(); | 674 testBroadcastListenAfterClosePaused(); |
| 673 testAsBroadcastListenAfterClose(); | 675 testAsBroadcastListenAfterClose(); |
| 674 testAsBroadcastListenAfterClosePaused(); | 676 testAsBroadcastListenAfterClosePaused(); |
| 675 asyncEnd(); | 677 asyncEnd(); |
| 676 } | 678 } |
| OLD | NEW |