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

Side by Side Diff: tests/lib_strong/async/stream_state_nonzero_timer_test.dart

Issue 2802973005: Migrate async tests to strong (Closed)
Patch Set: Created 3 years, 8 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
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 // Test the event/callback protocol of the stream implementations.
6 // Uses a non-zero timer so it fails on d8.
7
8 library stream_state_nonzero_timer_test;
9
10 import "dart:async";
11 import "package:unittest/unittest.dart";
12 import "stream_state_helper.dart";
13
14 const ms5 = const Duration(milliseconds: 5);
15
16 // Testing pause/resume, some with non-zero duration. This only makes sense for
17 // non-broadcast streams, since broadcast stream subscriptions handle their
18 // own pauses.
19
20 main() {
21 var p = "StreamController";
22
23 test("$p-sub-data/pause/resume/pause/resume-done", () {
24 var t = new StreamProtocolTest();
25 t..expectListen()
26 ..expectData(42, () {
27 t.pause();
28 })
29 ..expectPause(() { t.resume(); })
30 ..expectResume(() { t.pause(); })
31 ..expectPause(() { t.resume(); })
32 ..expectResume(() { t.close(); })
33 ..expectCancel()
34 ..expectDone(t.terminate);
35 t..listen()..add(42);
36 });
37
38 test("$p-sub-data/pause-done", () {
39 var t = new StreamProtocolTest();
40 t..expectListen()
41 ..expectData(42, () {
42 t.pause(new Future.delayed(ms5, () => null));
43 })
44 ..expectPause()
45 ..expectCancel()
46 ..expectDone(t.terminate);
47 // We are calling "close" while the controller is actually paused,
48 // and it will stay paused until the pending events are sent.
49 t..listen()..add(42)..close();
50 });
51
52 test("$p-sub-data/pause-resume/done", () {
53 var t = new StreamProtocolTest();
54 t..expectListen()
55 ..expectData(42, () {
56 t.pause(new Future.delayed(ms5, () => null));
57 })
58 ..expectPause()
59 ..expectResume(t.close)
60 ..expectCancel()
61 ..expectDone(t.terminate);
62 t..listen()..add(42);
63 });
64
65 test("$p-sub-data/data+pause-data-resume-done", () {
66 var t = new StreamProtocolTest();
67 t..expectListen()
68 ..expectData(42, () {
69 t.add(43);
70 t.pause(new Future.delayed(ms5, () => null));
71 // Should now be paused until the future finishes.
72 // After that, the controller stays paused until the pending queue
73 // is empty.
74 })
75 ..expectPause()
76 ..expectData(43)
77 ..expectResume(t.close)
78 ..expectCancel()
79 ..expectDone(t.terminate);
80 t..listen()..add(42);
81 });
82
83 test("$p-pause-during-callback", () {
84 var t = new StreamProtocolTest();
85 t..expectListen()
86 ..expectData(42, () {
87 t.pause();
88 })
89 ..expectPause(() {
90 t.resume();
91 })
92 ..expectResume(() {
93 t.pause();
94 t.resume();
95 t.close();
96 })
97 ..expectCancel()
98 ..expectDone(t.terminate);
99 t..listen()
100 ..add(42);
101 });
102 }
OLDNEW
« no previous file with comments | « tests/lib_strong/async/stream_state_helper.dart ('k') | tests/lib_strong/async/stream_state_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698