| Index: pkg/watcher/test/directory_watcher_test.dart
|
| diff --git a/pkg/watcher/test/directory_watcher_test.dart b/pkg/watcher/test/directory_watcher_test.dart
|
| index 635f7ee6704e9ab680b01392d7c5e2f353ff8884..800d54d63b819670155304a1d0d34597eaaa8e69 100644
|
| --- a/pkg/watcher/test/directory_watcher_test.dart
|
| +++ b/pkg/watcher/test/directory_watcher_test.dart
|
| @@ -90,150 +90,4 @@ main() {
|
| writeFile("a/b/c/d/file.txt");
|
| expectAddEvent("a/b/c/d/file.txt");
|
| });
|
| -
|
| - test('does not notify for changes when there were 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((event) {
|
| - expect(event.type, equals(ChangeType.ADD));
|
| - expect(event.path, endsWith("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((event) {
|
| - // We should get an event for the third file, not the one added while
|
| - // we weren't subscribed.
|
| - expect(event.type, equals(ChangeType.ADD));
|
| - expect(event.path, endsWith("added.txt"));
|
| - completer.complete();
|
| - });
|
| - });
|
| -
|
| - // The watcher will have been cancelled and then resumed in the middle of
|
| - // its pause between polling loops. That means the second scan to skip
|
| - // what changed while we were unsubscribed won't happen until after that
|
| - // delay is done. Wait long enough for that to happen.
|
| - schedule(() => new Future.delayed(new Duration(seconds: 1)));
|
| -
|
| - // And add a third file.
|
| - writeFile("added.txt");
|
| -
|
| - // Wait until we get an event for the third file.
|
| - schedule(() => completer.future);
|
| -
|
| - schedule(() {
|
| - subscription.cancel();
|
| - });
|
| - });
|
| -
|
| -
|
| - test('ready does not complete until after subscription', () {
|
| - var watcher = createWatcher(waitForReady: false);
|
| -
|
| - var ready = false;
|
| - watcher.ready.then((_) {
|
| - ready = true;
|
| - });
|
| -
|
| - // Should not be ready yet.
|
| - schedule(() {
|
| - expect(ready, isFalse);
|
| - });
|
| -
|
| - // Subscribe to the events.
|
| - schedule(() {
|
| - var subscription = watcher.events.listen((event) {});
|
| -
|
| - currentSchedule.onComplete.schedule(() {
|
| - subscription.cancel();
|
| - });
|
| - });
|
| -
|
| - // Should eventually be ready.
|
| - schedule(() => watcher.ready);
|
| -
|
| - schedule(() {
|
| - expect(ready, isTrue);
|
| - });
|
| - });
|
| -
|
| - test('ready completes immediately when already ready', () {
|
| - var watcher = createWatcher(waitForReady: false);
|
| -
|
| - // Subscribe to the events.
|
| - schedule(() {
|
| - var subscription = watcher.events.listen((event) {});
|
| -
|
| - currentSchedule.onComplete.schedule(() {
|
| - subscription.cancel();
|
| - });
|
| - });
|
| -
|
| - // Should eventually be ready.
|
| - schedule(() => watcher.ready);
|
| -
|
| - // Now ready should be a future that immediately completes.
|
| - var ready = false;
|
| - schedule(() {
|
| - watcher.ready.then((_) {
|
| - ready = true;
|
| - });
|
| - });
|
| -
|
| - schedule(() {
|
| - expect(ready, isTrue);
|
| - });
|
| - });
|
| -
|
| - test('ready returns a future that does not complete after unsubscribing', () {
|
| - var watcher = createWatcher(waitForReady: false);
|
| -
|
| - // Subscribe to the events.
|
| - var subscription;
|
| - schedule(() {
|
| - subscription = watcher.events.listen((event) {});
|
| - });
|
| -
|
| - var ready = false;
|
| -
|
| - // Wait until ready.
|
| - schedule(() => watcher.ready);
|
| -
|
| - // Now unsubscribe.
|
| - schedule(() {
|
| - subscription.cancel();
|
| -
|
| - // Track when it's ready again.
|
| - ready = false;
|
| - watcher.ready.then((_) {
|
| - ready = true;
|
| - });
|
| - });
|
| -
|
| - // Should be back to not ready.
|
| - schedule(() {
|
| - expect(ready, isFalse);
|
| - });
|
| - });
|
| }
|
|
|