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

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

Issue 16125005: Make new StreamController be async by default. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments Created 7 years, 6 months 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) 2013, the Dart project authors. Please see the AUTHORS file 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 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 event/callback protocol of the stream implementations. 5 // Test the event/callback protocol of the stream implementations.
6 library stream_state_test; 6 library stream_state_test;
7 7
8 import "../../../pkg/unittest/lib/unittest.dart"; 8 import "../../../pkg/unittest/lib/unittest.dart";
9 import "stream_state_helper.dart"; 9 import "stream_state_helper.dart";
10 10
11 const ms5 = const Duration(milliseconds: 5); 11 const ms5 = const Duration(milliseconds: 5);
12 12
13 main() { 13 main() {
14 mainTest(false); 14 mainTest(sync: true, broadcast: false);
15 // TODO(floitsch): reenable? 15 mainTest(sync: true, broadcast: true);
16 // mainTest(true); 16 mainTest(sync: false, broadcast: false);
17 mainTest(sync: false, broadcast: true);
17 } 18 }
18 19
19 mainTest(bool broadcast) { 20 mainTest({bool sync, bool broadcast}) {
20 var p = broadcast ? "BC" : "SC"; 21 var p = (sync ? "S" : "AS") + (broadcast ? "BC" : "SC");
21 test("$p-sub-data-done", () { 22 test("$p-sub-data-done", () {
22 var t = new StreamProtocolTest(broadcast); 23 var t = new StreamProtocolTest(sync: sync, broadcast: broadcast);
23 t..expectSubscription() 24 t..expectListen()
24 ..expectData(42) 25 ..expectData(42)
25 ..expectDone() 26 ..expectDone()
26 ..expectCancel(); 27 ..expectCancel();
27 t..subscribe()..add(42)..close(); 28 t..listen()..add(42)..close();
28 }); 29 });
29 30
30 test("$p-data-done-sub", () { 31 test("$p-data-done-sub-sync", () {
31 var t = new StreamProtocolTest(broadcast); 32 var t = new StreamProtocolTest(sync: sync, broadcast: broadcast);
32 if (broadcast) { 33 t..expectListen()
33 t..expectDone(); 34 ..expectData(42)
34 } else { 35 ..expectDone()
35 t..expectSubscription() 36 ..expectCancel();
36 ..expectData(42) 37 t..add(42)..close()..listen();
37 ..expectDone() 38 });
38 ..expectCancel(); 39
39 } 40 test("$p-data-done-sub-async", () {
40 t..add(42)..close()..subscribe(); 41 var t = new StreamProtocolTest(sync: sync, broadcast: broadcast);
42 t..expectListen()
43 ..expectData(42)
44 ..expectDone()
45 ..expectCancel();
46 t..add(42)..close()..listen();
41 }); 47 });
42 48
43 test("$p-sub-data/pause+resume-done", () { 49 test("$p-sub-data/pause+resume-done", () {
44 var t = new StreamProtocolTest(broadcast); 50 var t = new StreamProtocolTest(sync: sync, broadcast: broadcast);
45 t..expectSubscription() 51 t..expectListen()
46 ..expectData(42, () { 52 ..expectData(42, () {
47 t.pause(); 53 t.pause();
48 t.resume(); 54 t.resume();
49 t.close(); 55 t.close();
50 }) 56 })
51 ..expectDone() 57 ..expectDone()
52 ..expectCancel(); 58 ..expectCancel();
53 t..subscribe()..add(42); 59 t..listen()..add(42);
54 }); 60 });
55 61
56 test("$p-sub-data-unsubonerror", () { 62 test("$p-sub-data-unsubonerror", () {
57 var t = new StreamProtocolTest(broadcast); 63 var t = new StreamProtocolTest(sync: sync, broadcast: broadcast);
58 t..expectSubscription() 64 t..expectListen()
59 ..expectData(42) 65 ..expectData(42)
60 ..expectError("bad") 66 ..expectError("bad")
61 ..expectCancel(); 67 ..expectCancel();
62 t..subscribe(cancelOnError: true) 68 t..listen(cancelOnError: true)
63 ..add(42) 69 ..add(42)
64 ..error("bad") 70 ..error("bad")
65 ..add(43) 71 ..add(43)
66 ..close(); 72 ..close();
67 }); 73 });
68 74
69 test("$p-sub-data-no-unsubonerror", () { 75 test("$p-sub-data-no-unsubonerror", () {
70 var t = new StreamProtocolTest(broadcast); 76 var t = new StreamProtocolTest(sync: sync, broadcast: broadcast);
71 t..expectSubscription() 77 t..expectListen()
72 ..expectData(42) 78 ..expectData(42)
73 ..expectError("bad") 79 ..expectError("bad")
74 ..expectData(43) 80 ..expectData(43)
75 ..expectDone() 81 ..expectDone()
76 ..expectCancel(); 82 ..expectCancel();
77 t..subscribe(cancelOnError: false) 83 t..listen(cancelOnError: false)
78 ..add(42) 84 ..add(42)
79 ..error("bad") 85 ..error("bad")
80 ..add(43) 86 ..add(43)
81 ..close(); 87 ..close();
82 }); 88 });
83 89
84 test("$p-pause-resume-during-event", () { 90 test("$p-pause-resume-during-event", () {
85 var t = new StreamProtocolTest(broadcast); 91 var t = new StreamProtocolTest(sync: sync, broadcast: broadcast);
86 t..expectSubscription() 92 t..expectListen()
87 ..expectData(42, () { 93 ..expectData(42, () {
88 t.pause(); 94 t.pause();
89 t.resume(); 95 t.resume();
90 }) 96 });
91 ..expectDone() 97 if (!broadcast && !sync) {
98 t..expectPause();
99 }
100 t..expectDone()
92 ..expectCancel(); 101 ..expectCancel();
93 t..subscribe() 102 t..listen()
94 ..add(42) 103 ..add(42)
95 ..close(); 104 ..close();
96 }); 105 });
97 } 106 }
OLDNEW
« no previous file with comments | « tests/lib/async/stream_state_nonzero_timer_test.dart ('k') | tests/lib/async/stream_subscription_as_future_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698