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

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

Issue 12049013: Change singleSubscription/multiSubscription to normal/broadcast. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed comments, renamed .multiSubscription to .broadcast. Created 7 years, 11 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 basic StreamController and StreamController.singleSubscription. 5 // Test the basic StreamController and StreamController.singleSubscription.
6 library stream_single_test; 6 library stream_single_test;
7 7
8 import 'dart:async'; 8 import 'dart:async';
9 import 'dart:isolate'; 9 import 'dart:isolate';
10 import '../../../pkg/unittest/lib/unittest.dart'; 10 import '../../../pkg/unittest/lib/unittest.dart';
11 import 'event_helper.dart'; 11 import 'event_helper.dart';
12 12
13 main() { 13 main() {
14 test("tomulti 1", () { 14 test("tomulti 1", () {
15 StreamController c = new StreamController<int>(); 15 StreamController c = new StreamController<int>();
16 Stream<int> multi = c.stream.asMultiSubscriberStream(); 16 Stream<int> multi = c.stream.asBroadcastStream();
17 // Listen twice. 17 // Listen twice.
18 multi.listen(expectAsync1((v) => Expect.equals(42, v))); 18 multi.listen(expectAsync1((v) => Expect.equals(42, v)));
19 multi.listen(expectAsync1((v) => Expect.equals(42, v))); 19 multi.listen(expectAsync1((v) => Expect.equals(42, v)));
20 c.add(42); 20 c.add(42);
21 }); 21 });
22 22
23 test("tomulti 2", () { 23 test("tomulti 2", () {
24 StreamController c = new StreamController<int>(); 24 StreamController c = new StreamController<int>();
25 Stream<int> multi = c.stream.asMultiSubscriberStream(); 25 Stream<int> multi = c.stream.asBroadcastStream();
26 Events expected = new Events.fromIterable([1, 2, 3, 4, 5]); 26 Events expected = new Events.fromIterable([1, 2, 3, 4, 5]);
27 Events actual1 = new Events.capture(multi); 27 Events actual1 = new Events.capture(multi);
28 Events actual2 = new Events.capture(multi); 28 Events actual2 = new Events.capture(multi);
29 actual1.onDone(expectAsync0(() { 29 actual1.onDone(expectAsync0(() {
30 Expect.listEquals(expected.events, actual1.events); 30 Expect.listEquals(expected.events, actual1.events);
31 })); 31 }));
32 actual2.onDone(expectAsync0(() { 32 actual2.onDone(expectAsync0(() {
33 Expect.listEquals(expected.events, actual2.events); 33 Expect.listEquals(expected.events, actual2.events);
34 })); 34 }));
35 expected.replay(c); 35 expected.replay(c);
36 }); 36 });
37 37
38 test("tomulti no-op", () { 38 test("tomulti no-op", () {
39 StreamController c = new StreamController<int>.multiSubscription(); 39 StreamController c = new StreamController<int>.broadcast();
40 Stream<int> multi = c.stream.asMultiSubscriberStream(); 40 Stream<int> multi = c.stream.asBroadcastStream();
41 Events expected = new Events.fromIterable([1, 2, 3, 4, 5]); 41 Events expected = new Events.fromIterable([1, 2, 3, 4, 5]);
42 Events actual1 = new Events.capture(multi); 42 Events actual1 = new Events.capture(multi);
43 Events actual2 = new Events.capture(multi); 43 Events actual2 = new Events.capture(multi);
44 actual1.onDone(expectAsync0(() { 44 actual1.onDone(expectAsync0(() {
45 Expect.listEquals(expected.events, actual1.events); 45 Expect.listEquals(expected.events, actual1.events);
46 })); 46 }));
47 actual2.onDone(expectAsync0(() { 47 actual2.onDone(expectAsync0(() {
48 Expect.listEquals(expected.events, actual2.events); 48 Expect.listEquals(expected.events, actual2.events);
49 })); 49 }));
50 expected.replay(c); 50 expected.replay(c);
51 }); 51 });
52 } 52 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698