OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/files/file_path_watcher.h" | 5 #include "base/files/file_path_watcher.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <aclapi.h> | 9 #include <aclapi.h> |
10 #elif defined(OS_POSIX) | 10 #elif defined(OS_POSIX) |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 TestDelegateBase* delegate, | 131 TestDelegateBase* delegate, |
132 bool recursive_watch, | 132 bool recursive_watch, |
133 bool* result, | 133 bool* result, |
134 base::WaitableEvent* completion) { | 134 base::WaitableEvent* completion) { |
135 *result = watcher->Watch(target, recursive_watch, | 135 *result = watcher->Watch(target, recursive_watch, |
136 base::Bind(&TestDelegateBase::OnFileChanged, | 136 base::Bind(&TestDelegateBase::OnFileChanged, |
137 delegate->AsWeakPtr())); | 137 delegate->AsWeakPtr())); |
138 completion->Signal(); | 138 completion->Signal(); |
139 } | 139 } |
140 | 140 |
141 void QuitLoopWatchCallback(MessageLoop* loop, | |
142 const FilePath& expected_path, | |
143 bool expected_error, | |
144 bool* flag, | |
145 const FilePath& path, | |
146 bool error) { | |
147 ASSERT_TRUE(flag); | |
148 *flag = true; | |
149 EXPECT_EQ(expected_path, path); | |
150 EXPECT_EQ(expected_error, error); | |
151 loop->PostTask(FROM_HERE, loop->QuitWhenIdleClosure()); | |
152 } | |
153 | |
154 class FilePathWatcherTest : public testing::Test { | 141 class FilePathWatcherTest : public testing::Test { |
155 public: | 142 public: |
156 FilePathWatcherTest() | 143 FilePathWatcherTest() |
157 : file_thread_("FilePathWatcherTest") {} | 144 : file_thread_("FilePathWatcherTest") {} |
158 | 145 |
159 virtual ~FilePathWatcherTest() {} | 146 virtual ~FilePathWatcherTest() {} |
160 | 147 |
161 protected: | 148 protected: |
162 virtual void SetUp() OVERRIDE { | 149 virtual void SetUp() OVERRIDE { |
163 // Create a separate file thread in order to test proper thread usage. | 150 // Create a separate file thread in order to test proper thread usage. |
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
900 ASSERT_TRUE(ChangeFilePermissions(test_dir1, Execute, false)); | 887 ASSERT_TRUE(ChangeFilePermissions(test_dir1, Execute, false)); |
901 ASSERT_TRUE(WaitForEvents()); | 888 ASSERT_TRUE(WaitForEvents()); |
902 ASSERT_TRUE(ChangeFilePermissions(test_dir1, Execute, true)); | 889 ASSERT_TRUE(ChangeFilePermissions(test_dir1, Execute, true)); |
903 DeleteDelegateOnFileThread(delegate.release()); | 890 DeleteDelegateOnFileThread(delegate.release()); |
904 } | 891 } |
905 | 892 |
906 #endif // OS_MACOSX | 893 #endif // OS_MACOSX |
907 } // namespace | 894 } // namespace |
908 | 895 |
909 } // namespace base | 896 } // namespace base |
OLD | NEW |