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

Unified Diff: packages/async/test/single_subscription_transformer_test.dart

Issue 2989763002: Update charted to 0.4.8 and roll (Closed)
Patch Set: Removed Cutch from list of reviewers Created 3 years, 5 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 | « packages/async/test/result_test.dart ('k') | packages/async/test/stream_completer_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: packages/async/test/single_subscription_transformer_test.dart
diff --git a/packages/async/test/single_subscription_transformer_test.dart b/packages/async/test/single_subscription_transformer_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..74e462b3ee04a6b64c83c36b1bf69c28e86873bf
--- /dev/null
+++ b/packages/async/test/single_subscription_transformer_test.dart
@@ -0,0 +1,50 @@
+// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'dart:async';
+
+import 'package:async/async.dart';
+import 'package:test/test.dart';
+
+import 'utils.dart';
+
+void main() {
+ test("buffers events as soon as it's bound", () async {
+ var controller = new StreamController.broadcast();
+ var stream =
+ controller.stream.transform(const SingleSubscriptionTransformer());
+
+ // Add events before [stream] has a listener to be sure it buffers them.
+ controller.add(1);
+ controller.add(2);
+ await flushMicrotasks();
+
+ expect(stream.toList(), completion(equals([1, 2, 3, 4])));
+ await flushMicrotasks();
+
+ controller.add(3);
+ controller.add(4);
+ controller.close();
+ });
+
+ test("cancels the subscription to the broadcast stream when it's canceled",
+ () async {
+ var canceled = false;
+ var controller = new StreamController.broadcast(onCancel: () {
+ canceled = true;
+ });
+ var stream =
+ controller.stream.transform(const SingleSubscriptionTransformer());
+ await flushMicrotasks();
+ expect(canceled, isFalse);
+
+ var subscription = stream.listen(null);
+ await flushMicrotasks();
+ expect(canceled, isFalse);
+
+ subscription.cancel();
+ await flushMicrotasks();
+ expect(canceled, isTrue);
+ });
+}
« no previous file with comments | « packages/async/test/result_test.dart ('k') | packages/async/test/stream_completer_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698