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 "chrome/browser/chromeos/fileapi/file_system_backend.h" | 5 #include "chrome/browser/chromeos/fileapi/file_system_backend.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 // to avoid flakiness. | 36 // to avoid flakiness. |
37 fileapi::ExternalMountPoints::GetSystemInstance()->RevokeAllFileSystems(); | 37 fileapi::ExternalMountPoints::GetSystemInstance()->RevokeAllFileSystems(); |
38 | 38 |
39 scoped_refptr<quota::SpecialStoragePolicy> storage_policy = | 39 scoped_refptr<quota::SpecialStoragePolicy> storage_policy = |
40 new quota::MockSpecialStoragePolicy(); | 40 new quota::MockSpecialStoragePolicy(); |
41 scoped_refptr<fileapi::ExternalMountPoints> mount_points( | 41 scoped_refptr<fileapi::ExternalMountPoints> mount_points( |
42 fileapi::ExternalMountPoints::CreateRefCounted()); | 42 fileapi::ExternalMountPoints::CreateRefCounted()); |
43 chromeos::FileSystemBackend backend( | 43 chromeos::FileSystemBackend backend( |
44 NULL, // drive_delegate | 44 NULL, // drive_delegate |
45 NULL, // file_system_provider_delegate | 45 NULL, // file_system_provider_delegate |
| 46 NULL, // mtp_delegate |
46 storage_policy, | 47 storage_policy, |
47 mount_points.get(), | 48 mount_points.get(), |
48 fileapi::ExternalMountPoints::GetSystemInstance()); | 49 fileapi::ExternalMountPoints::GetSystemInstance()); |
49 backend.AddSystemMountPoints(); | 50 backend.AddSystemMountPoints(); |
50 std::vector<base::FilePath> root_dirs = backend.GetRootDirectories(); | 51 std::vector<base::FilePath> root_dirs = backend.GetRootDirectories(); |
51 std::set<base::FilePath> root_dirs_set(root_dirs.begin(), root_dirs.end()); | 52 std::set<base::FilePath> root_dirs_set(root_dirs.begin(), root_dirs.end()); |
52 | 53 |
53 // By default there should be 3 mount points (in system mount points): | 54 // By default there should be 3 mount points (in system mount points): |
54 EXPECT_EQ(3u, root_dirs.size()); | 55 EXPECT_EQ(3u, root_dirs.size()); |
55 | 56 |
56 EXPECT_TRUE(root_dirs_set.count( | 57 EXPECT_TRUE(root_dirs_set.count( |
57 chromeos::CrosDisksClient::GetRemovableDiskMountPoint())); | 58 chromeos::CrosDisksClient::GetRemovableDiskMountPoint())); |
58 EXPECT_TRUE(root_dirs_set.count( | 59 EXPECT_TRUE(root_dirs_set.count( |
59 chromeos::CrosDisksClient::GetArchiveMountPoint())); | 60 chromeos::CrosDisksClient::GetArchiveMountPoint())); |
60 EXPECT_TRUE(root_dirs_set.count(base::FilePath(FPL("/usr/share/oem")))); | 61 EXPECT_TRUE(root_dirs_set.count(base::FilePath(FPL("/usr/share/oem")))); |
61 } | 62 } |
62 | 63 |
63 TEST(ChromeOSFileSystemBackendTest, GetRootDirectories) { | 64 TEST(ChromeOSFileSystemBackendTest, GetRootDirectories) { |
64 scoped_refptr<quota::SpecialStoragePolicy> storage_policy = | 65 scoped_refptr<quota::SpecialStoragePolicy> storage_policy = |
65 new quota::MockSpecialStoragePolicy(); | 66 new quota::MockSpecialStoragePolicy(); |
66 scoped_refptr<fileapi::ExternalMountPoints> mount_points( | 67 scoped_refptr<fileapi::ExternalMountPoints> mount_points( |
67 fileapi::ExternalMountPoints::CreateRefCounted()); | 68 fileapi::ExternalMountPoints::CreateRefCounted()); |
68 | 69 |
69 scoped_refptr<fileapi::ExternalMountPoints> system_mount_points( | 70 scoped_refptr<fileapi::ExternalMountPoints> system_mount_points( |
70 fileapi::ExternalMountPoints::CreateRefCounted()); | 71 fileapi::ExternalMountPoints::CreateRefCounted()); |
71 | 72 |
72 chromeos::FileSystemBackend backend(NULL, // drive_delegate | 73 chromeos::FileSystemBackend backend(NULL, // drive_delegate |
73 NULL, // file_system_provider_delegate | 74 NULL, // file_system_provider_delegate |
| 75 NULL, // mtp_delegate |
74 storage_policy, | 76 storage_policy, |
75 mount_points.get(), | 77 mount_points.get(), |
76 system_mount_points.get()); | 78 system_mount_points.get()); |
77 | 79 |
78 const size_t initial_root_dirs_size = backend.GetRootDirectories().size(); | 80 const size_t initial_root_dirs_size = backend.GetRootDirectories().size(); |
79 | 81 |
80 // Register 'local' test mount points. | 82 // Register 'local' test mount points. |
81 mount_points->RegisterFileSystem("c", | 83 mount_points->RegisterFileSystem("c", |
82 fileapi::kFileSystemTypeNativeLocal, | 84 fileapi::kFileSystemTypeNativeLocal, |
83 fileapi::FileSystemMountOption(), | 85 fileapi::FileSystemMountOption(), |
(...skipping 26 matching lines...) Expand all Loading... |
110 url_util::AddStandardScheme("chrome-extension"); | 112 url_util::AddStandardScheme("chrome-extension"); |
111 | 113 |
112 scoped_refptr<quota::MockSpecialStoragePolicy> storage_policy = | 114 scoped_refptr<quota::MockSpecialStoragePolicy> storage_policy = |
113 new quota::MockSpecialStoragePolicy(); | 115 new quota::MockSpecialStoragePolicy(); |
114 scoped_refptr<fileapi::ExternalMountPoints> mount_points( | 116 scoped_refptr<fileapi::ExternalMountPoints> mount_points( |
115 fileapi::ExternalMountPoints::CreateRefCounted()); | 117 fileapi::ExternalMountPoints::CreateRefCounted()); |
116 scoped_refptr<fileapi::ExternalMountPoints> system_mount_points( | 118 scoped_refptr<fileapi::ExternalMountPoints> system_mount_points( |
117 fileapi::ExternalMountPoints::CreateRefCounted()); | 119 fileapi::ExternalMountPoints::CreateRefCounted()); |
118 chromeos::FileSystemBackend backend(NULL, // drive_delegate | 120 chromeos::FileSystemBackend backend(NULL, // drive_delegate |
119 NULL, // file_system_provider_delegate | 121 NULL, // file_system_provider_delegate |
| 122 NULL, // mtp_delegate |
120 storage_policy, | 123 storage_policy, |
121 mount_points.get(), | 124 mount_points.get(), |
122 system_mount_points.get()); | 125 system_mount_points.get()); |
123 | 126 |
124 std::string extension("ddammdhioacbehjngdmkjcjbnfginlla"); | 127 std::string extension("ddammdhioacbehjngdmkjcjbnfginlla"); |
125 | 128 |
126 storage_policy->AddFileHandler(extension); | 129 storage_policy->AddFileHandler(extension); |
127 | 130 |
128 // Initialize mount points. | 131 // Initialize mount points. |
129 ASSERT_TRUE(system_mount_points->RegisterFileSystem( | 132 ASSERT_TRUE(system_mount_points->RegisterFileSystem( |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 | 206 |
204 TEST(ChromeOSFileSystemBackendTest, GetVirtualPathConflictWithSystemPoints) { | 207 TEST(ChromeOSFileSystemBackendTest, GetVirtualPathConflictWithSystemPoints) { |
205 scoped_refptr<quota::MockSpecialStoragePolicy> storage_policy = | 208 scoped_refptr<quota::MockSpecialStoragePolicy> storage_policy = |
206 new quota::MockSpecialStoragePolicy(); | 209 new quota::MockSpecialStoragePolicy(); |
207 scoped_refptr<fileapi::ExternalMountPoints> mount_points( | 210 scoped_refptr<fileapi::ExternalMountPoints> mount_points( |
208 fileapi::ExternalMountPoints::CreateRefCounted()); | 211 fileapi::ExternalMountPoints::CreateRefCounted()); |
209 scoped_refptr<fileapi::ExternalMountPoints> system_mount_points( | 212 scoped_refptr<fileapi::ExternalMountPoints> system_mount_points( |
210 fileapi::ExternalMountPoints::CreateRefCounted()); | 213 fileapi::ExternalMountPoints::CreateRefCounted()); |
211 chromeos::FileSystemBackend backend(NULL, // drive_delegate | 214 chromeos::FileSystemBackend backend(NULL, // drive_delegate |
212 NULL, // file_system_provider_delegate | 215 NULL, // file_system_provider_delegate |
| 216 NULL, // mtp_delegate |
213 storage_policy, | 217 storage_policy, |
214 mount_points.get(), | 218 mount_points.get(), |
215 system_mount_points.get()); | 219 system_mount_points.get()); |
216 | 220 |
217 const fileapi::FileSystemType type = fileapi::kFileSystemTypeNativeLocal; | 221 const fileapi::FileSystemType type = fileapi::kFileSystemTypeNativeLocal; |
218 const fileapi::FileSystemMountOption option = | 222 const fileapi::FileSystemMountOption option = |
219 fileapi::FileSystemMountOption(); | 223 fileapi::FileSystemMountOption(); |
220 | 224 |
221 // Backend specific mount points. | 225 // Backend specific mount points. |
222 ASSERT_TRUE(mount_points->RegisterFileSystem( | 226 ASSERT_TRUE(mount_points->RegisterFileSystem( |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 if (!kTestCases[i].success) | 271 if (!kTestCases[i].success) |
268 continue; | 272 continue; |
269 | 273 |
270 base::FilePath expected_virtual_path(kTestCases[i].virtual_path); | 274 base::FilePath expected_virtual_path(kTestCases[i].virtual_path); |
271 EXPECT_EQ(expected_virtual_path, virtual_path) | 275 EXPECT_EQ(expected_virtual_path, virtual_path) |
272 << "Resolving " << kTestCases[i].local_path; | 276 << "Resolving " << kTestCases[i].local_path; |
273 } | 277 } |
274 } | 278 } |
275 | 279 |
276 } // namespace | 280 } // namespace |
OLD | NEW |