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

Unified Diff: packages/watcher/test/no_subscription/shared.dart

Issue 1400473008: Roll Observatory packages and add a roll script (Closed) Base URL: git@github.com:dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years, 2 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/watcher/test/no_subscription/polling_test.dart ('k') | packages/watcher/test/path_set_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: packages/watcher/test/no_subscription/shared.dart
diff --git a/packages/watcher/test/no_subscription/shared.dart b/packages/watcher/test/no_subscription/shared.dart
new file mode 100644
index 0000000000000000000000000000000000000000..52649f1a72d292b1acf1a474cfbd0902d310a7ce
--- /dev/null
+++ b/packages/watcher/test/no_subscription/shared.dart
@@ -0,0 +1,63 @@
+// Copyright (c) 2012, 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:scheduled_test/scheduled_test.dart';
+import 'package:watcher/watcher.dart';
+
+import '../utils.dart';
+
+void sharedTests() {
+ test('does not notify for changes when there are no subscribers', () {
+ // Note that this test doesn't rely as heavily on the test functions in
+ // utils.dart because it needs to be very explicit about when the event
+ // stream is and is not subscribed.
+ var watcher = createWatcher();
+
+ // Subscribe to the events.
+ var completer = new Completer();
+ var subscription = watcher.events.listen(expectAsync((event) {
+ expect(event, isWatchEvent(ChangeType.ADD, "file.txt"));
+ completer.complete();
+ }));
+
+ writeFile("file.txt");
+
+ // Then wait until we get an event for it.
+ schedule(() => completer.future);
+
+ // Unsubscribe.
+ schedule(() {
+ subscription.cancel();
+ });
+
+ // Now write a file while we aren't listening.
+ writeFile("unwatched.txt");
+
+ // Then start listening again.
+ schedule(() {
+ completer = new Completer();
+ subscription = watcher.events.listen(expectAsync((event) {
+ // We should get an event for the third file, not the one added while
+ // we weren't subscribed.
+ expect(event, isWatchEvent(ChangeType.ADD, "added.txt"));
+ completer.complete();
+ }));
+
+ // Wait until the watcher is ready to dispatch events again.
+ return watcher.ready;
+ });
+
+ // And add a third file.
+ writeFile("added.txt");
+
+ // Wait until we get an event for the third file.
+ schedule(() => completer.future);
+
+ schedule(() {
+ subscription.cancel();
+ });
+ });
+}
« no previous file with comments | « packages/watcher/test/no_subscription/polling_test.dart ('k') | packages/watcher/test/path_set_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698