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

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

Issue 15673006: Implement asBroadcast using a _MultiplexStreamController. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Don't keep pending events when calling onCancel. 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
« no previous file with comments | « sdk/lib/async/stream_impl.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_controller_async_test; 6 library stream_controller_async_test;
7 7
8 import "package:expect/expect.dart"; 8 import "package:expect/expect.dart";
9 import 'dart:async'; 9 import 'dart:async';
10 import 'dart:isolate'; 10 import 'dart:isolate';
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 var sub2 = c.stream.listen(expectAsync1((x) { expect(x, equals(42)); }, 475 var sub2 = c.stream.listen(expectAsync1((x) { expect(x, equals(42)); },
476 count: 3)); 476 count: 3));
477 c.add(42); 477 c.add(42);
478 sub1.pause(); 478 sub1.pause();
479 c.add(42); 479 c.add(42);
480 sub1.cancel(); 480 sub1.cancel();
481 var sub3 = c.stream.listen(expectAsync1((x) { expect(x, equals(42)); })); 481 var sub3 = c.stream.listen(expectAsync1((x) { expect(x, equals(42)); }));
482 c.add(42); 482 c.add(42);
483 c.close(); 483 c.close();
484 }); 484 });
485
486 test("broadcast-controller-add-in-callback", () {
487 StreamController<int> c;
488 c = new StreamController(
489 onListen: expectAsync0(() {}),
490 onCancel: expectAsync0(() {
491 c.add(42);
492 })
493 );
494 var sub;
495 sub = c.stream.asBroadcastStream().listen(expectAsync1((v) {
496 Expect.equals(37, v);
497 c.add(21);
498 sub.cancel();
499 }));
500 c.add(37); // Triggers listener, which adds 21 and removes itself.
501 // Removing listener triggers onCancel which adds another 42.
502 // Both 21 and 42 are lost because there are no listeners.
503 });
485 } 504 }
486 505
487 main() { 506 main() {
488 testController(); 507 testController();
489 testSingleController(); 508 testSingleController();
490 testExtraMethods(); 509 testExtraMethods();
491 testPause(); 510 testPause();
492 testRethrow(); 511 testRethrow();
493 testBroadcastController(); 512 testBroadcastController();
494 } 513 }
OLDNEW
« no previous file with comments | « sdk/lib/async/stream_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698