| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 import 'dart:async'; | 5 import 'dart:async'; |
| 6 import 'dart:io'; | 6 import 'dart:io'; |
| 7 | 7 |
| 8 import 'package:scheduled_test/scheduled_test.dart'; | 8 import 'package:scheduled_test/scheduled_test.dart'; |
| 9 import 'package:watcher/watcher.dart'; | 9 import 'package:watcher/watcher.dart'; |
| 10 | 10 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 subscription.cancel(); | 34 subscription.cancel(); |
| 35 }); | 35 }); |
| 36 | 36 |
| 37 // Now write a file while we aren't listening. | 37 // Now write a file while we aren't listening. |
| 38 writeFile("unwatched.txt"); | 38 writeFile("unwatched.txt"); |
| 39 | 39 |
| 40 // Then start listening again. | 40 // Then start listening again. |
| 41 schedule(() { | 41 schedule(() { |
| 42 completer = new Completer(); | 42 completer = new Completer(); |
| 43 subscription = watcher.events.listen(wrapAsync((event) { | 43 subscription = watcher.events.listen(wrapAsync((event) { |
| 44 // TODO(nweiz): Remove this when either issue 14373 or 14793 is fixed. | |
| 45 // Issue 14373 means that the new [Directory.watch] will emit an event | |
| 46 // for "unwatched.txt" being created, and issue 14793 means we have to | |
| 47 // check the filesystem, which leads us to assume that the file has been | |
| 48 // modified. | |
| 49 if (Platform.isMacOS && event.path.endsWith("unwatched.txt")) { | |
| 50 expect(event, isWatchEvent(ChangeType.MODIFY, "unwatched.txt")); | |
| 51 return; | |
| 52 } | |
| 53 | |
| 54 // We should get an event for the third file, not the one added while | 44 // We should get an event for the third file, not the one added while |
| 55 // we weren't subscribed. | 45 // we weren't subscribed. |
| 56 expect(event, isWatchEvent(ChangeType.ADD, "added.txt")); | 46 expect(event, isWatchEvent(ChangeType.ADD, "added.txt")); |
| 57 completer.complete(); | 47 completer.complete(); |
| 58 })); | 48 })); |
| 59 | 49 |
| 60 // Wait until the watcher is ready to dispatch events again. | 50 // Wait until the watcher is ready to dispatch events again. |
| 61 return watcher.ready; | 51 return watcher.ready; |
| 62 }); | 52 }); |
| 63 | 53 |
| 64 // And add a third file. | 54 // And add a third file. |
| 65 writeFile("added.txt"); | 55 writeFile("added.txt"); |
| 66 | 56 |
| 67 // Wait until we get an event for the third file. | 57 // Wait until we get an event for the third file. |
| 68 schedule(() => completer.future); | 58 schedule(() => completer.future); |
| 69 | 59 |
| 70 schedule(() { | 60 schedule(() { |
| 71 subscription.cancel(); | 61 subscription.cancel(); |
| 72 }); | 62 }); |
| 73 }); | 63 }); |
| 74 } | 64 } |
| OLD | NEW |