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

Side by Side Diff: tests/lib/async/stream_state_nonzero_timer_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 // Uses a non-zero timer so it fails on d8. 6 // Uses a non-zero timer so it fails on d8.
7 7
8 library stream_state_nonzero_timer_test; 8 library stream_state_nonzero_timer_test;
9 9
10 import "dart:async"; 10 import "dart:async";
11 import "../../../pkg/unittest/lib/unittest.dart"; 11 import "../../../pkg/unittest/lib/unittest.dart";
12 import "stream_state_helper.dart"; 12 import "stream_state_helper.dart";
13 13
14 const ms5 = const Duration(milliseconds: 5); 14 const ms5 = const Duration(milliseconds: 5);
15 15
16 main() { 16 main() {
17 mainTest(false); 17 mainTest(false);
18 // TODO(floitsch): reenable? 18 // TODO(floitsch): reenable?
19 // mainTest(true); 19 // mainTest(true);
20 } 20 }
21 21
22 mainTest(bool broadcast) { 22 mainTest(bool broadcast) {
23 var p = broadcast ? "BC" : "SC"; 23 var p = broadcast ? "BC" : "SC";
24 24
25 test("$p-sub-data/pause/resume/pause/resume-done", () { 25 test("$p-sub-data/pause/resume/pause/resume-done", () {
26 var t = new StreamProtocolTest(broadcast); 26 var t = new StreamProtocolTest(broadcast: broadcast);
27 t..expectSubscription() 27 t..expectListen()
28 ..expectData(42, () { 28 ..expectData(42, () {
29 t.pause(); 29 t.pause();
30 }) 30 })
31 ..expectPause(() { t.resume(); }) 31 ..expectPause(() { t.resume(); })
32 ..expectResume(() { t.pause(); }) 32 ..expectResume(() { t.pause(); })
33 ..expectPause(() { t.resume(); }) 33 ..expectPause(() { t.resume(); })
34 ..expectResume(() { t.close(); }) 34 ..expectResume(() { t.close(); })
35 ..expectDone() 35 ..expectDone()
36 ..expectCancel(); 36 ..expectCancel();
37 t..subscribe()..add(42); 37 t..listen()..add(42);
38 }); 38 });
39 39
40 test("$p-sub-data/pause-done", () { 40 test("$p-sub-data/pause-done", () {
41 var t = new StreamProtocolTest(broadcast); 41 var t = new StreamProtocolTest(broadcast: broadcast);
42 t..expectSubscription() 42 t..expectListen()
43 ..expectData(42, () { 43 ..expectData(42, () {
44 t.pause(new Future.delayed(ms5, () => null)); 44 t.pause(new Future.delayed(ms5, () => null));
45 }) 45 })
46 ..expectPause() 46 ..expectPause()
47 ..expectDone() 47 ..expectDone()
48 ..expectCancel(); 48 ..expectCancel();
49 // We are calling "close" while the controller is actually paused, 49 // We are calling "close" while the controller is actually paused,
50 // and it will stay paused until the pending events are sent. 50 // and it will stay paused until the pending events are sent.
51 t..subscribe()..add(42)..close(); 51 t..listen()..add(42)..close();
52 }); 52 });
53 53
54 test("$p-sub-data/pause-resume/done", () { 54 test("$p-sub-data/pause-resume/done", () {
55 var t = new StreamProtocolTest(broadcast); 55 var t = new StreamProtocolTest(broadcast: broadcast);
56 t..expectSubscription() 56 t..expectListen()
57 ..expectData(42, () { 57 ..expectData(42, () {
58 t.pause(new Future.delayed(ms5, () => null)); 58 t.pause(new Future.delayed(ms5, () => null));
59 }) 59 })
60 ..expectPause() 60 ..expectPause()
61 ..expectResume(t.close) 61 ..expectResume(t.close)
62 ..expectDone() 62 ..expectDone()
63 ..expectCancel(); 63 ..expectCancel();
64 t..subscribe()..add(42); 64 t..listen()..add(42);
65 }); 65 });
66 66
67 test("$p-sub-data/data+pause-data-resume-done", () { 67 test("$p-sub-data/data+pause-data-resume-done", () {
68 var t = new StreamProtocolTest(broadcast); 68 var t = new StreamProtocolTest(broadcast: broadcast);
69 t..expectSubscription() 69 t..expectListen()
70 ..expectData(42, () { 70 ..expectData(42, () {
71 t.add(43); 71 t.add(43);
72 t.pause(new Future.delayed(ms5, () => null)); 72 t.pause(new Future.delayed(ms5, () => null));
73 // Should now be paused until the future finishes. 73 // Should now be paused until the future finishes.
74 // After that, the controller stays paused until the pending queue 74 // After that, the controller stays paused until the pending queue
75 // is empty. 75 // is empty.
76 }) 76 })
77 ..expectPause() 77 ..expectPause()
78 ..expectData(43) 78 ..expectData(43)
79 ..expectResume(t.close) 79 ..expectResume(t.close)
80 ..expectDone() 80 ..expectDone()
81 ..expectCancel(); 81 ..expectCancel();
82 t..subscribe()..add(42); 82 t..listen()..add(42);
83 }); 83 });
84 return; 84
85 test("$p-pause-during-callback", () { 85 test("$p-pause-during-callback", () {
86 var t = new StreamProtocolTest(broadcast); 86 var t = new StreamProtocolTest(broadcast: broadcast);
87 t..expectSubscription() 87 t..expectListen()
88 ..expectData(42, () { 88 ..expectData(42, () {
89 t.pause(); 89 t.pause();
90 }) 90 })
91 ..expectPause(() { 91 ..expectPause(() {
92 t.resume(); 92 t.resume();
93 }) 93 })
94 ..expectResume(() { 94 ..expectResume(() {
95 t.pause(); 95 t.pause();
96 t.resume(); 96 t.resume();
97 t.close(); 97 t.close();
98 }) 98 })
99 ..expectDone() 99 ..expectDone()
100 ..expectCancel(); 100 ..expectCancel();
101 t..subscribe() 101 t..listen()
102 ..add(42); 102 ..add(42);
103 }); 103 });
104 } 104 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698