OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // TestVolumeMountWatcherWin implementation. | 5 // TestVolumeMountWatcherWin implementation. |
6 | 6 |
7 #include "components/storage_monitor/test_volume_mount_watcher_win.h" | 7 #include "components/storage_monitor/test_volume_mount_watcher_win.h" |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "base/files/scoped_temp_dir.h" | 11 #include "base/files/scoped_temp_dir.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "components/storage_monitor/storage_info.h" | 13 #include "components/storage_monitor/storage_info.h" |
14 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" |
15 | 16 |
16 namespace storage_monitor { | 17 namespace storage_monitor { |
17 | 18 |
18 namespace { | 19 namespace { |
19 | 20 |
20 base::FilePath GetTempRoot() { | 21 base::FilePath GetTempRoot() { |
21 base::ScopedTempDir temp_dir; | 22 base::ScopedTempDir temp_dir; |
22 temp_dir.CreateUniqueTempDir(); | 23 EXPECT_TRUE(temp_dir.CreateUniqueTempDir()); |
23 base::FilePath temp_root = temp_dir.path(); | 24 base::FilePath temp_root = temp_dir.path(); |
24 while (temp_root.DirName() != temp_root) | 25 while (temp_root.DirName() != temp_root) |
25 temp_root = temp_root.DirName(); | 26 temp_root = temp_root.DirName(); |
26 return temp_root; | 27 return temp_root; |
27 } | 28 } |
28 | 29 |
29 std::vector<base::FilePath> FakeGetSingleAttachedDevice() { | 30 std::vector<base::FilePath> FakeGetSingleAttachedDevice() { |
30 std::vector<base::FilePath> result; | 31 std::vector<base::FilePath> result; |
31 result.push_back(VolumeMountWatcherWin::DriveNumberToFilePath(2)); // C | 32 result.push_back(VolumeMountWatcherWin::DriveNumberToFilePath(2)); // C |
32 | 33 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 } | 146 } |
146 | 147 |
147 VolumeMountWatcherWin::GetAttachedDevicesCallbackType | 148 VolumeMountWatcherWin::GetAttachedDevicesCallbackType |
148 TestVolumeMountWatcherWin::GetAttachedDevicesCallback() const { | 149 TestVolumeMountWatcherWin::GetAttachedDevicesCallback() const { |
149 if (attached_devices_fake_) | 150 if (attached_devices_fake_) |
150 return base::Bind(&FakeGetAttachedDevices); | 151 return base::Bind(&FakeGetAttachedDevices); |
151 return base::Bind(&FakeGetSingleAttachedDevice); | 152 return base::Bind(&FakeGetSingleAttachedDevice); |
152 } | 153 } |
153 | 154 |
154 } // namespace storage_monitor | 155 } // namespace storage_monitor |
OLD | NEW |