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

Unified Diff: base/files/file_path_watcher_browsertest.cc

Issue 283423003: Use FSEvents for recursive file watch on Mac (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix win compile Created 6 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
Index: base/files/file_path_watcher_browsertest.cc
diff --git a/base/files/file_path_watcher_browsertest.cc b/base/files/file_path_watcher_browsertest.cc
index 2bdcf13827c88216eb1db428780d0227a61cb5a8..4ec8ababe30c3b561b0d886032a8b02e91579d06 100644
--- a/base/files/file_path_watcher_browsertest.cc
+++ b/base/files/file_path_watcher_browsertest.cc
@@ -205,9 +205,8 @@ bool FilePathWatcherTest::SetupWatch(const FilePath& target,
bool result;
file_thread_.message_loop_proxy()->PostTask(
FROM_HERE,
- base::Bind(SetupWatchCallback,
- target, watcher, delegate, recursive_watch, &result,
- &completion));
+ base::Bind(SetupWatchCallback, target, watcher, delegate, recursive_watch,
+ &result, &completion));
completion.Wait();
return result;
}
@@ -483,7 +482,7 @@ TEST_F(FilePathWatcherTest, MoveParent) {
DeleteDelegateOnFileThread(subdir_delegate.release());
}
-#if defined(OS_WIN) || defined(OS_LINUX)
+#if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_MACOSX)
TEST_F(FilePathWatcherTest, RecursiveWatch) {
FilePathWatcher watcher;
FilePath dir(temp_dir_.path().AppendASCII("dir"));
@@ -548,6 +547,45 @@ TEST_F(FilePathWatcherTest, RecursiveWatch) {
}
#endif
+#if defined(OS_LINUX) || defined(OS_MACOSX)
+TEST_F(FilePathWatcherTest, RecursiveWithSymLink) {
+ FilePathWatcher watcher;
+ FilePath test_dir(temp_dir_.path().AppendASCII("test_dir"));
+ ASSERT_TRUE(base::CreateDirectory(test_dir));
+ FilePath symlink(test_dir.AppendASCII("symlink"));
+ scoped_ptr<TestDelegate> delegate(new TestDelegate(collector()));
+ ASSERT_TRUE(SetupWatch(symlink, &watcher, delegate.get(), true));
+
+ // Link creation.
+ FilePath target1(temp_dir_.path().AppendASCII("target1"));
+ ASSERT_TRUE(base::CreateSymbolicLink(target1, symlink));
+ ASSERT_TRUE(WaitForEvents());
+
+ // Target1 creation.
+ ASSERT_TRUE(base::CreateDirectory(target1));
+ ASSERT_TRUE(WaitForEvents());
+
+ // Create a file in target1.
+ FilePath target1_file(target1.AppendASCII("file"));
+ ASSERT_TRUE(WriteFile(target1_file, "content"));
+ ASSERT_TRUE(WaitForEvents());
+
+ // Link change.
+ FilePath target2(temp_dir_.path().AppendASCII("target2"));
+ ASSERT_TRUE(base::CreateDirectory(target2));
+ ASSERT_TRUE(base::DeleteFile(symlink, false));
+ ASSERT_TRUE(base::CreateSymbolicLink(target2, symlink));
+ ASSERT_TRUE(WaitForEvents());
+
+ // Create a file in target2.
+ FilePath target2_file(target2.AppendASCII("file"));
+ ASSERT_TRUE(WriteFile(target2_file, "content"));
+ ASSERT_TRUE(WaitForEvents());
+
+ DeleteDelegateOnFileThread(delegate.release());
+}
+#endif
+
TEST_F(FilePathWatcherTest, MoveChild) {
FilePathWatcher file_watcher;
FilePathWatcher subdir_watcher;

Powered by Google App Engine
This is Rietveld 408576698