OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 // This file contains a subclass of VolumeMountWatcherWin to expose some | 5 // This file contains a subclass of VolumeMountWatcherWin to expose some |
6 // functionality for testing. | 6 // functionality for testing. |
7 | 7 |
8 #ifndef CHROME_BROWSER_STORAGE_MONITOR_TEST_VOLUME_MOUNT_WATCHER_WIN_H_ | 8 #ifndef CHROME_BROWSER_STORAGE_MONITOR_TEST_VOLUME_MOUNT_WATCHER_WIN_H_ |
9 #define CHROME_BROWSER_STORAGE_MONITOR_TEST_VOLUME_MOUNT_WATCHER_WIN_H_ | 9 #define CHROME_BROWSER_STORAGE_MONITOR_TEST_VOLUME_MOUNT_WATCHER_WIN_H_ |
10 | 10 |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/string16.h" | 14 #include "base/string16.h" |
15 #include "base/synchronization/waitable_event.h" | 15 #include "base/synchronization/waitable_event.h" |
16 #include "chrome/browser/storage_monitor/volume_mount_watcher_win.h" | 16 #include "chrome/browser/storage_monitor/volume_mount_watcher_win.h" |
17 | 17 |
18 namespace base { | 18 namespace base { |
19 class FilePath; | 19 class FilePath; |
20 } | 20 } |
21 | 21 |
22 namespace chrome { | 22 namespace chrome { |
23 namespace test { | 23 namespace test { |
24 | 24 |
25 class TestVolumeMountWatcherWin : public VolumeMountWatcherWin { | 25 class TestVolumeMountWatcherWin : public VolumeMountWatcherWin { |
26 public: | 26 public: |
27 TestVolumeMountWatcherWin(); | 27 TestVolumeMountWatcherWin(); |
28 virtual ~TestVolumeMountWatcherWin(); | 28 virtual ~TestVolumeMountWatcherWin(); |
29 | 29 |
| 30 static bool GetDeviceRemovable(const base::FilePath& device_path, |
| 31 bool* removable); |
| 32 |
30 void AddDeviceForTesting(const base::FilePath& device_path, | 33 void AddDeviceForTesting(const base::FilePath& device_path, |
31 const std::string& device_id, | 34 const std::string& device_id, |
32 const string16& device_name, | 35 const base::string16& device_name, |
33 uint64 total_size_in_bytes); | 36 uint64 total_size_in_bytes); |
34 | 37 |
35 void SetAttachedDevicesFake(); | 38 void SetAttachedDevicesFake(); |
36 | 39 |
37 void FlushWorkerPoolForTesting(); | 40 void FlushWorkerPoolForTesting(); |
38 | 41 |
39 virtual void DeviceCheckComplete(const base::FilePath& device_path); | 42 virtual void DeviceCheckComplete(const base::FilePath& device_path); |
40 | 43 |
41 std::vector<base::FilePath> devices_checked() const { | 44 const std::vector<base::FilePath>& devices_checked() const { |
42 return devices_checked_; | 45 return devices_checked_; |
43 } | 46 } |
44 | 47 |
45 void BlockDeviceCheckForTesting(); | 48 void BlockDeviceCheckForTesting(); |
46 | 49 |
47 void ReleaseDeviceCheck(); | 50 void ReleaseDeviceCheck(); |
48 | 51 |
49 bool GetDeviceRemovable(const base::FilePath& device_path, | |
50 bool* removable) const; | |
51 | |
52 // VolumeMountWatcherWin: | 52 // VolumeMountWatcherWin: |
53 | |
54 virtual GetAttachedDevicesCallbackType | 53 virtual GetAttachedDevicesCallbackType |
55 GetAttachedDevicesCallback() const OVERRIDE; | 54 GetAttachedDevicesCallback() const OVERRIDE; |
56 virtual GetDeviceDetailsCallbackType | 55 virtual GetDeviceDetailsCallbackType |
57 GetDeviceDetailsCallback() const OVERRIDE; | 56 GetDeviceDetailsCallback() const OVERRIDE; |
58 | 57 |
59 // Should be used by unit tests to make sure the worker pool doesn't survive | 58 // Should be used by unit tests to make sure the worker pool doesn't survive |
60 // into other test runs. | 59 // into other test runs. |
61 void ShutdownWorkerPool(); | 60 void ShutdownWorkerPool(); |
62 | 61 |
63 private: | 62 private: |
64 std::vector<base::FilePath> devices_checked_; | 63 std::vector<base::FilePath> devices_checked_; |
65 scoped_ptr<base::WaitableEvent> device_check_complete_event_; | 64 scoped_ptr<base::WaitableEvent> device_check_complete_event_; |
66 bool attached_devices_fake_; | 65 bool attached_devices_fake_; |
67 | 66 |
68 DISALLOW_COPY_AND_ASSIGN(TestVolumeMountWatcherWin); | 67 DISALLOW_COPY_AND_ASSIGN(TestVolumeMountWatcherWin); |
69 }; | 68 }; |
70 | 69 |
71 } // namespace test | 70 } // namespace test |
72 } // namespace chrome | 71 } // namespace chrome |
73 | 72 |
74 #endif // CHROME_BROWSER_STORAGE_MONITOR_TEST_VOLUME_MOUNT_WATCHER_WIN_H_ | 73 #endif // CHROME_BROWSER_STORAGE_MONITOR_TEST_VOLUME_MOUNT_WATCHER_WIN_H_ |
OLD | NEW |