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

Side by Side Diff: test/util/stream_queue_test.dart

Issue 2515303002: Add expectAsyncX and expectAsyncUntilX methods, and deprecate the old methods. (Closed)
Patch Set: Mark parameter types as Object. Created 4 years 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
« no previous file with comments | « test/util/path_handler_test.dart ('k') | test/utils.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 filevents. 3 // BSD-style license that can be found in the LICENSE filevents.
4 4
5 // TODO(nweiz): Get rid of this when https://codereview.chromium.org/1241723003/ 5 // TODO(nweiz): Get rid of this when https://codereview.chromium.org/1241723003/
6 // lands. 6 // lands.
7 7
8 import "dart:async"; 8 import "dart:async";
9 9
10 import "package:test/src/util/stream_queue.dart"; 10 import "package:test/src/util/stream_queue.dart";
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 var queue4 = queue1.fork(); 736 var queue4 = queue1.fork();
737 var queue5 = queue1.fork(); 737 var queue5 = queue1.fork();
738 738
739 for (var i = 0; i < 4; i++) { 739 for (var i = 0; i < 4; i++) {
740 var queue1Fired = false; 740 var queue1Fired = false;
741 var queue2Fired = false; 741 var queue2Fired = false;
742 var queue3Fired = false; 742 var queue3Fired = false;
743 var queue4Fired = false; 743 var queue4Fired = false;
744 var queue5Fired = false; 744 var queue5Fired = false;
745 745
746 queue5.next.then(expectAsync((_) { 746 queue5.next.then(expectAsync1((_) {
747 queue5Fired = true; 747 queue5Fired = true;
748 expect(queue1Fired, isTrue); 748 expect(queue1Fired, isTrue);
749 expect(queue2Fired, isTrue); 749 expect(queue2Fired, isTrue);
750 expect(queue3Fired, isTrue); 750 expect(queue3Fired, isTrue);
751 expect(queue4Fired, isTrue); 751 expect(queue4Fired, isTrue);
752 })); 752 }));
753 753
754 queue1.next.then(expectAsync((_) { 754 queue1.next.then(expectAsync1((_) {
755 queue1Fired = true; 755 queue1Fired = true;
756 expect(queue2Fired, isFalse); 756 expect(queue2Fired, isFalse);
757 expect(queue3Fired, isFalse); 757 expect(queue3Fired, isFalse);
758 expect(queue4Fired, isFalse); 758 expect(queue4Fired, isFalse);
759 expect(queue5Fired, isFalse); 759 expect(queue5Fired, isFalse);
760 })); 760 }));
761 761
762 queue4.next.then(expectAsync((_) { 762 queue4.next.then(expectAsync1((_) {
763 queue4Fired = true; 763 queue4Fired = true;
764 expect(queue1Fired, isTrue); 764 expect(queue1Fired, isTrue);
765 expect(queue2Fired, isTrue); 765 expect(queue2Fired, isTrue);
766 expect(queue3Fired, isTrue); 766 expect(queue3Fired, isTrue);
767 expect(queue5Fired, isFalse); 767 expect(queue5Fired, isFalse);
768 })); 768 }));
769 769
770 queue2.next.then(expectAsync((_) { 770 queue2.next.then(expectAsync1((_) {
771 queue2Fired = true; 771 queue2Fired = true;
772 expect(queue1Fired, isTrue); 772 expect(queue1Fired, isTrue);
773 expect(queue3Fired, isFalse); 773 expect(queue3Fired, isFalse);
774 expect(queue4Fired, isFalse); 774 expect(queue4Fired, isFalse);
775 expect(queue5Fired, isFalse); 775 expect(queue5Fired, isFalse);
776 })); 776 }));
777 777
778 queue3.next.then(expectAsync((_) { 778 queue3.next.then(expectAsync1((_) {
779 queue3Fired = true; 779 queue3Fired = true;
780 expect(queue1Fired, isTrue); 780 expect(queue1Fired, isTrue);
781 expect(queue2Fired, isTrue); 781 expect(queue2Fired, isTrue);
782 expect(queue4Fired, isFalse); 782 expect(queue4Fired, isFalse);
783 expect(queue5Fired, isFalse); 783 expect(queue5Fired, isFalse);
784 })); 784 }));
785 } 785 }
786 }); 786 });
787 787
788 test("forks can be created from forks", () async { 788 test("forks can be created from forks", () async {
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
988 988
989 controller.add(3); 989 controller.add(3);
990 await flushMicrotasks(); 990 await flushMicrotasks();
991 expect(controller.isPaused, isTrue); 991 expect(controller.isPaused, isTrue);
992 }); 992 });
993 993
994 test("pausing a fork doesn't pause its source", () async { 994 test("pausing a fork doesn't pause its source", () async {
995 var queue1 = new StreamQueue<int>(createStream()); 995 var queue1 = new StreamQueue<int>(createStream());
996 var queue2 = queue1.fork(); 996 var queue2 = queue1.fork();
997 997
998 queue2.rest.listen(expectAsync((_) {}, count: 0)).pause(); 998 queue2.rest.listen(expectAsync1((_) {}, count: 0)).pause();
999 999
1000 expect(await queue1.next, 1); 1000 expect(await queue1.next, 1);
1001 expect(await queue1.next, 2); 1001 expect(await queue1.next, 2);
1002 expect(await queue1.next, 3); 1002 expect(await queue1.next, 3);
1003 expect(await queue1.next, 4); 1003 expect(await queue1.next, 4);
1004 expect(await queue1.hasNext, isFalse); 1004 expect(await queue1.hasNext, isFalse);
1005 }); 1005 });
1006 1006
1007 test("pausing a source doesn't pause its fork", () async { 1007 test("pausing a source doesn't pause its fork", () async {
1008 var queue1 = new StreamQueue<int>(createStream()); 1008 var queue1 = new StreamQueue<int>(createStream());
1009 var queue2 = queue1.fork(); 1009 var queue2 = queue1.fork();
1010 1010
1011 queue1.rest.listen(expectAsync((_) {}, count: 0)).pause(); 1011 queue1.rest.listen(expectAsync1((_) {}, count: 0)).pause();
1012 1012
1013 expect(await queue2.next, 1); 1013 expect(await queue2.next, 1);
1014 expect(await queue2.next, 2); 1014 expect(await queue2.next, 2);
1015 expect(await queue2.next, 3); 1015 expect(await queue2.next, 3);
1016 expect(await queue2.next, 4); 1016 expect(await queue2.next, 4);
1017 expect(await queue2.hasNext, isFalse); 1017 expect(await queue2.hasNext, isFalse);
1018 }); 1018 });
1019 1019
1020 test("the underlying stream is only paused when all forks are paused", 1020 test("the underlying stream is only paused when all forks are paused",
1021 () async { 1021 () async {
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1125 controller.close(); 1125 controller.close();
1126 }(); 1126 }();
1127 return controller.stream; 1127 return controller.stream;
1128 } 1128 }
1129 1129
1130 Stream<int> createLongStream(int eventCount) async* { 1130 Stream<int> createLongStream(int eventCount) async* {
1131 for (int i = 0; i < eventCount; i++) yield i; 1131 for (int i = 0; i < eventCount; i++) yield i;
1132 } 1132 }
1133 1133
1134 Future flushMicrotasks() => new Future.delayed(Duration.ZERO); 1134 Future flushMicrotasks() => new Future.delayed(Duration.ZERO);
OLDNEW
« no previous file with comments | « test/util/path_handler_test.dart ('k') | test/utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698