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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 class FilePathWatcherTest : public testing::Test { | 141 class FilePathWatcherTest : public testing::Test { |
142 public: | 142 public: |
143 FilePathWatcherTest() | 143 FilePathWatcherTest() |
144 : file_thread_("FilePathWatcherTest") {} | 144 : file_thread_("FilePathWatcherTest") {} |
145 | 145 |
146 virtual ~FilePathWatcherTest() {} | 146 ~FilePathWatcherTest() override {} |
147 | 147 |
148 protected: | 148 protected: |
149 virtual void SetUp() override { | 149 void SetUp() override { |
150 // 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. |
151 base::Thread::Options options(MessageLoop::TYPE_IO, 0); | 151 base::Thread::Options options(MessageLoop::TYPE_IO, 0); |
152 ASSERT_TRUE(file_thread_.StartWithOptions(options)); | 152 ASSERT_TRUE(file_thread_.StartWithOptions(options)); |
153 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 153 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
154 collector_ = new NotificationCollector(); | 154 collector_ = new NotificationCollector(); |
155 } | 155 } |
156 | 156 |
157 virtual void TearDown() override { | 157 void TearDown() override { RunLoop().RunUntilIdle(); } |
158 RunLoop().RunUntilIdle(); | |
159 } | |
160 | 158 |
161 void DeleteDelegateOnFileThread(TestDelegate* delegate) { | 159 void DeleteDelegateOnFileThread(TestDelegate* delegate) { |
162 file_thread_.message_loop_proxy()->DeleteSoon(FROM_HERE, delegate); | 160 file_thread_.message_loop_proxy()->DeleteSoon(FROM_HERE, delegate); |
163 } | 161 } |
164 | 162 |
165 FilePath test_file() { | 163 FilePath test_file() { |
166 return temp_dir_.path().AppendASCII("FilePathWatcherTest"); | 164 return temp_dir_.path().AppendASCII("FilePathWatcherTest"); |
167 } | 165 } |
168 | 166 |
169 FilePath test_link() { | 167 FilePath test_link() { |
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
863 ASSERT_TRUE(ChangeFilePermissions(test_dir1, Execute, false)); | 861 ASSERT_TRUE(ChangeFilePermissions(test_dir1, Execute, false)); |
864 ASSERT_TRUE(WaitForEvents()); | 862 ASSERT_TRUE(WaitForEvents()); |
865 ASSERT_TRUE(ChangeFilePermissions(test_dir1, Execute, true)); | 863 ASSERT_TRUE(ChangeFilePermissions(test_dir1, Execute, true)); |
866 DeleteDelegateOnFileThread(delegate.release()); | 864 DeleteDelegateOnFileThread(delegate.release()); |
867 } | 865 } |
868 | 866 |
869 #endif // OS_MACOSX | 867 #endif // OS_MACOSX |
870 } // namespace | 868 } // namespace |
871 | 869 |
872 } // namespace base | 870 } // namespace base |
OLD | NEW |