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

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: 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(false);
15 // TODO(floitsch): reenable? 15 // TODO(floitsch): reenable?
16 // mainTest(true); 16 // mainTest(true);
17 } 17 }
18 18
19 mainTest(bool broadcast) { 19 mainTest(bool broadcast) {
20 var p = broadcast ? "BC" : "SC"; 20 var p = broadcast ? "BC" : "SC";
21 test("$p-sub-data-done", () { 21 test("$p-sub-data-done", () {
22 var t = new StreamProtocolTest(broadcast); 22 var t = new StreamProtocolTest(broadcast: broadcast);
23 t..expectSubscription() 23 t..expectListen()
24 ..expectData(42) 24 ..expectData(42)
25 ..expectDone() 25 ..expectDone()
26 ..expectCancel(); 26 ..expectCancel();
27 t..subscribe()..add(42)..close(); 27 t..listen()..add(42)..close();
28 }); 28 });
29 29
30 test("$p-data-done-sub", () { 30 test("$p-data-done-sub", () {
31 var t = new StreamProtocolTest(broadcast); 31 var t = new StreamProtocolTest(broadcast: broadcast);
32 if (broadcast) { 32 if (broadcast) {
33 t..expectDone(); 33 t..expectDone();
34 } else { 34 } else {
35 t..expectSubscription() 35 t..expectListen()
36 ..expectData(42) 36 ..expectData(42)
37 ..expectDone() 37 ..expectDone()
38 ..expectCancel(); 38 ..expectCancel();
39 } 39 }
40 t..add(42)..close()..subscribe(); 40 t..add(42)..close()..listen();
41 }); 41 });
42 42
43 test("$p-sub-data/pause+resume-done", () { 43 test("$p-sub-data/pause+resume-done", () {
44 var t = new StreamProtocolTest(broadcast); 44 var t = new StreamProtocolTest(broadcast: broadcast);
45 t..expectSubscription() 45 t..expectListen()
46 ..expectData(42, () { 46 ..expectData(42, () {
47 t.pause(); 47 t.pause();
48 t.resume(); 48 t.resume();
49 t.close(); 49 t.close();
50 }) 50 })
51 ..expectDone() 51 ..expectDone()
52 ..expectCancel(); 52 ..expectCancel();
53 t..subscribe()..add(42); 53 t..listen()..add(42);
54 }); 54 });
55 55
56 test("$p-sub-data-unsubonerror", () { 56 test("$p-sub-data-unsubonerror", () {
57 var t = new StreamProtocolTest(broadcast); 57 var t = new StreamProtocolTest(broadcast: broadcast);
58 t..expectSubscription() 58 t..expectListen()
59 ..expectData(42) 59 ..expectData(42)
60 ..expectError("bad") 60 ..expectError("bad")
61 ..expectCancel(); 61 ..expectCancel();
62 t..subscribe(cancelOnError: true) 62 t..listen(cancelOnError: true)
63 ..add(42) 63 ..add(42)
64 ..error("bad") 64 ..error("bad")
65 ..add(43) 65 ..add(43)
66 ..close(); 66 ..close();
67 }); 67 });
68 68
69 test("$p-sub-data-no-unsubonerror", () { 69 test("$p-sub-data-no-unsubonerror", () {
70 var t = new StreamProtocolTest(broadcast); 70 var t = new StreamProtocolTest(broadcast: broadcast);
71 t..expectSubscription() 71 t..expectListen()
72 ..expectData(42) 72 ..expectData(42)
73 ..expectError("bad") 73 ..expectError("bad")
74 ..expectData(43) 74 ..expectData(43)
75 ..expectDone() 75 ..expectDone()
76 ..expectCancel(); 76 ..expectCancel();
77 t..subscribe(cancelOnError: false) 77 t..listen(cancelOnError: false)
78 ..add(42) 78 ..add(42)
79 ..error("bad") 79 ..error("bad")
80 ..add(43) 80 ..add(43)
81 ..close(); 81 ..close();
82 }); 82 });
83 83
84 test("$p-pause-resume-during-event", () { 84 test("$p-pause-resume-during-event", () {
85 var t = new StreamProtocolTest(broadcast); 85 var t = new StreamProtocolTest(broadcast: broadcast);
86 t..expectSubscription() 86 t..expectListen()
87 ..expectData(42, () { 87 ..expectData(42, () {
88 t.pause(); 88 t.pause();
89 t.resume(); 89 t.resume();
90 }) 90 })
91 ..expectDone() 91 ..expectDone()
92 ..expectCancel(); 92 ..expectCancel();
93 t..subscribe() 93 t..listen()
94 ..add(42) 94 ..add(42)
95 ..close(); 95 ..close();
96 }); 96 });
97 } 97 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698