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

Unified Diff: base/directory_watcher_unittest.cc

Issue 52005: Implement recursive DirectoryWatcher watches on Linux (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 7 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 | « base/directory_watcher_inotify.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/directory_watcher_unittest.cc
===================================================================
--- base/directory_watcher_unittest.cc (revision 16266)
+++ base/directory_watcher_unittest.cc (working copy)
@@ -329,9 +329,6 @@
}
}
-#if defined(OS_WIN) || defined(OS_MACOSX)
-// TODO(phajdan.jr): Enable when support for Linux recursive watches is added.
-
TEST_F(DirectoryWatcherTest, WatchCreatedDirectory) {
TestDelegate delegate(this);
DirectoryWatcher watcher;
@@ -397,8 +394,52 @@
ASSERT_TRUE(WriteTestFile(subdir2.AppendASCII("file"), "other content"));
VerifyExpectedNumberOfNotifiedDelegates();
}
-#endif // defined(OS_WIN) || defined(OS_MACOSX)
+TEST_F(DirectoryWatcherTest, MoveFileOutofWatcher) {
+ FilePath subdir(CreateTestDirDirectoryASCII("SubDir", true));
+ FilePath subdir2(subdir.AppendASCII("SubDir2"));
+ EXPECT_TRUE(file_util::CreateDirectory(subdir2));
+
+ TestDelegate delegate(this);
+ DirectoryWatcher watcher;
+ ASSERT_TRUE(watcher.Watch(subdir2, &delegate, NULL, true));
+
+ // Write a file to the subdir.
+ SetExpectedNumberOfNotifiedDelegates(1);
+ ASSERT_TRUE(WriteTestFile(subdir2.AppendASCII("test_file"), "some content"));
+ VerifyExpectedNumberOfNotifiedDelegates();
+
+ delegate.reset();
+
+ SetExpectedNumberOfNotifiedDelegates(1);
+ ASSERT_TRUE(file_util::Move(subdir, test_dir_));
+ VerifyExpectedNumberOfNotifiedDelegates();
+
+ SetExpectedNumberOfNotifiedDelegates(0);
+ FilePath test_file(test_dir_.AppendASCII("SubDir2"));
+ ASSERT_TRUE(WriteTestFile(test_file.AppendASCII("test_file"),
+ "some content2"));
+ VerifyExpectedNumberOfNotifiedDelegates();
+}
+
+TEST_F(DirectoryWatcherTest, ParentDeleted) {
+ FilePath subdir(CreateTestDirDirectoryASCII("SubDir", true));
+ FilePath subdir2(subdir.AppendASCII("SubDir2"));
+ EXPECT_TRUE(file_util::CreateDirectory(subdir2));
+
+ TestDelegate delegate(this);
+ DirectoryWatcher watcher;
+ ASSERT_TRUE(watcher.Watch(subdir, &delegate, NULL, true));
+
+#if defined(OS_LINUX)
+ SetExpectedNumberOfNotifiedDelegates(1);
+#else
+ SetExpectedNumberOfNotifiedDelegates(2);
+#endif
+ ASSERT_TRUE(file_util::Delete(subdir, true));
+ VerifyExpectedNumberOfNotifiedDelegates();
+}
+
// Verify that watching a directory that doesn't exist fails, but doesn't
// asssert.
// Basic test: add a file and verify we notice it.
« no previous file with comments | « base/directory_watcher_inotify.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698