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

Unified Diff: tests/standalone/io/file_system_watcher_test.dart

Issue 52123002: Fire event and close the stream when the watched directory is moved. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Always listen for move self. Created 7 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 | « runtime/bin/file_system_watcher_linux.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/file_system_watcher_test.dart
diff --git a/tests/standalone/io/file_system_watcher_test.dart b/tests/standalone/io/file_system_watcher_test.dart
index e76f7199f0fbecdd0fe1bf54541a61ea1c6ea623..2cc97b7aadb9b317115d2781736275618134e831 100644
--- a/tests/standalone/io/file_system_watcher_test.dart
+++ b/tests/standalone/io/file_system_watcher_test.dart
@@ -300,6 +300,33 @@ void testWatchNonExisting() {
}
+void testWatchMoveSelf() {
+ // Windows keeps the directory handle open, even though it's deleted. It'll
+ // be flushed completely, once the watcher is closed as well.
+ if (Platform.isWindows) return;
+ var dir = Directory.systemTemp.createTempSync('dart_file_system_watcher');
+ var dir2 = new Directory(join(dir.path, 'dir'))..createSync();
+
+ var watcher = dir2.watch();
+
+ asyncStart();
+ var sub;
+ bool gotDelete = false;
+ sub = watcher.listen((event) {
+ if (event is FileSystemDeleteEvent) {
+ Expect.isTrue(event.path.endsWith('dir'));
+ gotDelete = true;
+ }
+ }, onDone: () {
+ Expect.isTrue(gotDelete);
+ dir.deleteSync(recursive: true);
+ asyncEnd();
+ });
+
+ dir2.renameSync(join(dir.path, 'new_dir'));
+}
+
+
void main() {
if (!FileSystemEntity.isWatchSupported) return;
testWatchCreateFile();
@@ -312,4 +339,5 @@ void main() {
testMultipleEvents();
testWatchNonRecursive();
testWatchNonExisting();
+ testWatchMoveSelf();
}
« no previous file with comments | « runtime/bin/file_system_watcher_linux.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698