| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "components/drive/file_write_watcher.h" | 5 #include "components/drive/file_write_watcher.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 std::set<std::string> expected; | 82 std::set<std::string> expected; |
| 83 expected.insert("1"); | 83 expected.insert("1"); |
| 84 expected.insert("2"); | 84 expected.insert("2"); |
| 85 expected.insert("3"); | 85 expected.insert("3"); |
| 86 | 86 |
| 87 base::RunLoop loop; | 87 base::RunLoop loop; |
| 88 TestObserver observer(expected, loop.QuitClosure()); | 88 TestObserver observer(expected, loop.QuitClosure()); |
| 89 | 89 |
| 90 // Set up the watcher. | 90 // Set up the watcher. |
| 91 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner = | 91 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner = |
| 92 content::BrowserThread::GetMessageLoopProxyForThread( | 92 content::BrowserThread::GetTaskRunnerForThread( |
| 93 content::BrowserThread::FILE); | 93 content::BrowserThread::FILE); |
| 94 FileWriteWatcher watcher(file_task_runner.get()); | 94 FileWriteWatcher watcher(file_task_runner.get()); |
| 95 watcher.DisableDelayForTesting(); | 95 watcher.DisableDelayForTesting(); |
| 96 | 96 |
| 97 // Start watching and running. | 97 // Start watching and running. |
| 98 base::FilePath path1 = GetTempPath("foo.txt"); | 98 base::FilePath path1 = GetTempPath("foo.txt"); |
| 99 base::FilePath path2 = GetTempPath("bar.png"); | 99 base::FilePath path2 = GetTempPath("bar.png"); |
| 100 base::FilePath path3 = GetTempPath("buz.doc"); | 100 base::FilePath path3 = GetTempPath("buz.doc"); |
| 101 base::FilePath path4 = GetTempPath("mya.mp3"); | 101 base::FilePath path4 = GetTempPath("mya.mp3"); |
| 102 watcher.StartWatch( | 102 watcher.StartWatch( |
| (...skipping 11 matching lines...) Expand all Loading... |
| 114 | 114 |
| 115 // Unwatched write. It shouldn't be notified. | 115 // Unwatched write. It shouldn't be notified. |
| 116 WriteSomethingAfterStartWatch(path4, true); | 116 WriteSomethingAfterStartWatch(path4, true); |
| 117 | 117 |
| 118 // The loop should quit if all the three paths are notified to be written. | 118 // The loop should quit if all the three paths are notified to be written. |
| 119 loop.Run(); | 119 loop.Run(); |
| 120 } | 120 } |
| 121 | 121 |
| 122 } // namespace internal | 122 } // namespace internal |
| 123 } // namespace drive | 123 } // namespace drive |
| OLD | NEW |