| 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.
|
|
|