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

Unified Diff: tests/lib/async/stream_controller_async_test.dart

Issue 16003002: Add StreamController.multiplex constructor. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove unused code Created 7 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/utf/utf_stream.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/lib/async/stream_controller_async_test.dart
diff --git a/tests/lib/async/stream_controller_async_test.dart b/tests/lib/async/stream_controller_async_test.dart
index 2408b6d8206a625b48d20cdf47df435b7181ca94..53be91005be249e8497bcff6447cc80b59971768 100644
--- a/tests/lib/async/stream_controller_async_test.dart
+++ b/tests/lib/async/stream_controller_async_test.dart
@@ -429,10 +429,66 @@ testRethrow() {
testFuture("drain", (s, act) => s.drain().then(act));
}
+void testMultiplex() {
+ test("multiplex-basic", () {
+ StreamController<int> c = new StreamController.multiplex(
+ onListen: expectAsync0(() {}),
+ onCancel: expectAsync0(() {})
+ );
+ Stream<int> s = c.stream;
+ s.listen(expectAsync1((x) { expect(x, equals(42)); }));
+ c.add(42);
+ c.close();
+ });
+
+ test("multiplex-listen-twice", () {
+ StreamController<int> c = new StreamController.multiplex(
+ onListen: expectAsync0(() {}),
+ onCancel: expectAsync0(() {})
+ );
+ c.stream.listen(expectAsync1((x) { expect(x, equals(42)); }, count: 2));
+ c.add(42);
+ c.stream.listen(expectAsync1((x) { expect(x, equals(42)); }));
+ c.add(42);
+ c.close();
+ });
+
+ test("multiplex-listen-twice-non-overlap", () {
+ StreamController<int> c = new StreamController.multiplex(
+ onListen: expectAsync0(() {}, count: 2),
+ onCancel: expectAsync0(() {}, count: 2)
+ );
+ var sub = c.stream.listen(expectAsync1((x) { expect(x, equals(42)); }));
+ c.add(42);
+ sub.cancel();
+ c.stream.listen(expectAsync1((x) { expect(x, equals(42)); }));
+ c.add(42);
+ c.close();
+ });
+
+ test("multiplex-individual-pause", () {
+ StreamController<int> c = new StreamController.multiplex(
+ onListen: expectAsync0(() {}),
+ onCancel: expectAsync0(() {})
+ );
+ var sub1 = c.stream.listen(expectAsync1((x) { expect(x, equals(42)); }));
+ var sub2 = c.stream.listen(expectAsync1((x) { expect(x, equals(42)); },
+ count: 3));
+ c.add(42);
+ sub1.pause();
+ c.add(42);
+ sub1.cancel();
+ var sub3 = c.stream.listen(expectAsync1((x) { expect(x, equals(42)); }));
+ c.add(42);
+ c.close();
+ });
+}
+
main() {
testController();
testSingleController();
testExtraMethods();
testPause();
testRethrow();
+ testMultiplex();
}
« no previous file with comments | « sdk/lib/utf/utf_stream.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698