Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(384)

Side by Side Diff: tests/lib/async/stream_controller_async_test.dart

Issue 48733002: Fix bugs in StreamController.addStream. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove StreamControllerSink. The optional cancelOnError on addStream is only in controller. Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 657 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 actual.onDone(() { 668 actual.onDone(() {
669 Expect.listEquals(expected.events, actual.events); 669 Expect.listEquals(expected.events, actual.events);
670 done(); 670 done();
671 }); 671 });
672 } else { 672 } else {
673 Expect.listEquals(expected.events, actual.events); 673 Expect.listEquals(expected.events, actual.events);
674 done(); 674 done();
675 } 675 }
676 }); 676 });
677 }); 677 });
678
679 test("$type-conroller-addstream-error-stop", () {
680 // Check that addStream defaults to ending after the first error.
681 var done = expectAsync0((){});
682 var c = broadcast ? new StreamController.broadcast(sync: sync)
683 : new StreamController(sync: sync);
684 var stream = asBroadcast ? c.stream.asBroadcastStream() : c.stream;
685 var actual = new Events.capture(stream);
686
687 var source = new Events();
688 source..add(1)..add(2)..error("BAD")..add(3)..error("FAIL")..close();
689
690 var expected = new Events()..add(1)..add(2)..error("BAD")..close();
691 StreamController sourceController = new StreamController();
692 c.addStream(sourceController.stream).then((_) {
693 print("stop-stream-end");
694 c.close().then((_) {
695 print("stop-all-end");
696 Expect.listEquals(expected.events, actual.events);
697 done();
698 });
699 });
700
701 source.replay(sourceController);
702 });
703
704 test("$type-conroller-addstream-error-forward", () {
705 // Check that addStream with cancelOnError:false passes all data and errors
706 // to the controller.
707 var done = expectAsync0((){});
708 var c = broadcast ? new StreamController.broadcast(sync: sync)
709 : new StreamController(sync: sync);
710 var stream = asBroadcast ? c.stream.asBroadcastStream() : c.stream;
711 var actual = new Events.capture(stream);
712
713 var source = new Events();
714 source..add(1)..add(2)..addError("BAD")..add(3)..addError("FAIL")..close();
715
716 StreamController sourceController = new StreamController();
717 c.addStream(sourceController.stream, cancelOnError: false).then((_) {
718 print("forward-stream-end");
719 c.close().then((_) {
720 print("forward-all-end");
721 Expect.listEquals(source.events, actual.events);
722 done();
723 });
724 });
725
726 source.replay(sourceController);
727 });
678 } 728 }
679 729
680 main() { 730 main() {
681 testController(); 731 testController();
682 testSingleController(); 732 testSingleController();
683 testExtraMethods(); 733 testExtraMethods();
684 testPause(); 734 testPause();
685 testRethrow(); 735 testRethrow();
686 testBroadcastController(); 736 testBroadcastController();
687 testAsBroadcast(); 737 testAsBroadcast();
688 testSink(sync: true, broadcast: false, asBroadcast: false); 738 testSink(sync: true, broadcast: false, asBroadcast: false);
689 testSink(sync: true, broadcast: false, asBroadcast: true); 739 testSink(sync: true, broadcast: false, asBroadcast: true);
690 testSink(sync: true, broadcast: true, asBroadcast: false); 740 testSink(sync: true, broadcast: true, asBroadcast: false);
691 testSink(sync: false, broadcast: false, asBroadcast: false); 741 testSink(sync: false, broadcast: false, asBroadcast: false);
692 testSink(sync: false, broadcast: false, asBroadcast: true); 742 testSink(sync: false, broadcast: false, asBroadcast: true);
693 testSink(sync: false, broadcast: true, asBroadcast: false); 743 testSink(sync: false, broadcast: true, asBroadcast: false);
694 } 744 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698