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 24 matching lines...) Expand all Loading... |
35 // Make sure no system-level mount points are registered before testing | 35 // Make sure no system-level mount points are registered before testing |
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 storage_policy, | 46 storage_policy, |
46 mount_points.get(), | 47 mount_points.get(), |
47 fileapi::ExternalMountPoints::GetSystemInstance()); | 48 fileapi::ExternalMountPoints::GetSystemInstance()); |
48 backend.AddSystemMountPoints(); | 49 backend.AddSystemMountPoints(); |
49 std::vector<base::FilePath> root_dirs = backend.GetRootDirectories(); | 50 std::vector<base::FilePath> root_dirs = backend.GetRootDirectories(); |
50 std::set<base::FilePath> root_dirs_set(root_dirs.begin(), root_dirs.end()); | 51 std::set<base::FilePath> root_dirs_set(root_dirs.begin(), root_dirs.end()); |
51 | 52 |
52 // By default there should be 3 mount points (in system mount points): | 53 // By default there should be 3 mount points (in system mount points): |
53 EXPECT_EQ(3u, root_dirs.size()); | 54 EXPECT_EQ(3u, root_dirs.size()); |
54 | 55 |
55 EXPECT_TRUE(root_dirs_set.count( | 56 EXPECT_TRUE(root_dirs_set.count( |
56 chromeos::CrosDisksClient::GetRemovableDiskMountPoint())); | 57 chromeos::CrosDisksClient::GetRemovableDiskMountPoint())); |
57 EXPECT_TRUE(root_dirs_set.count( | 58 EXPECT_TRUE(root_dirs_set.count( |
58 chromeos::CrosDisksClient::GetArchiveMountPoint())); | 59 chromeos::CrosDisksClient::GetArchiveMountPoint())); |
59 EXPECT_TRUE(root_dirs_set.count(base::FilePath(FPL("/usr/share/oem")))); | 60 EXPECT_TRUE(root_dirs_set.count(base::FilePath(FPL("/usr/share/oem")))); |
60 } | 61 } |
61 | 62 |
62 TEST(ChromeOSFileSystemBackendTest, GetRootDirectories) { | 63 TEST(ChromeOSFileSystemBackendTest, GetRootDirectories) { |
63 scoped_refptr<quota::SpecialStoragePolicy> storage_policy = | 64 scoped_refptr<quota::SpecialStoragePolicy> storage_policy = |
64 new quota::MockSpecialStoragePolicy(); | 65 new quota::MockSpecialStoragePolicy(); |
65 scoped_refptr<fileapi::ExternalMountPoints> mount_points( | 66 scoped_refptr<fileapi::ExternalMountPoints> mount_points( |
66 fileapi::ExternalMountPoints::CreateRefCounted()); | 67 fileapi::ExternalMountPoints::CreateRefCounted()); |
67 | 68 |
68 scoped_refptr<fileapi::ExternalMountPoints> system_mount_points( | 69 scoped_refptr<fileapi::ExternalMountPoints> system_mount_points( |
69 fileapi::ExternalMountPoints::CreateRefCounted()); | 70 fileapi::ExternalMountPoints::CreateRefCounted()); |
70 | 71 |
71 chromeos::FileSystemBackend backend( | 72 chromeos::FileSystemBackend backend(NULL, // drive_delegate |
72 NULL, // drive_delegate | 73 NULL, // file_system_provider_delegate |
73 storage_policy, | 74 storage_policy, |
74 mount_points.get(), | 75 mount_points.get(), |
75 system_mount_points.get()); | 76 system_mount_points.get()); |
76 | 77 |
77 const size_t initial_root_dirs_size = backend.GetRootDirectories().size(); | 78 const size_t initial_root_dirs_size = backend.GetRootDirectories().size(); |
78 | 79 |
79 // Register 'local' test mount points. | 80 // Register 'local' test mount points. |
80 mount_points->RegisterFileSystem("c", | 81 mount_points->RegisterFileSystem("c", |
81 fileapi::kFileSystemTypeNativeLocal, | 82 fileapi::kFileSystemTypeNativeLocal, |
82 fileapi::FileSystemMountOption(), | 83 fileapi::FileSystemMountOption(), |
83 base::FilePath(FPL("/a/b/c"))); | 84 base::FilePath(FPL("/a/b/c"))); |
84 mount_points->RegisterFileSystem("d", | 85 mount_points->RegisterFileSystem("d", |
85 fileapi::kFileSystemTypeNativeLocal, | 86 fileapi::kFileSystemTypeNativeLocal, |
(...skipping 21 matching lines...) Expand all Loading... |
107 | 108 |
108 TEST(ChromeOSFileSystemBackendTest, AccessPermissions) { | 109 TEST(ChromeOSFileSystemBackendTest, AccessPermissions) { |
109 url_util::AddStandardScheme("chrome-extension"); | 110 url_util::AddStandardScheme("chrome-extension"); |
110 | 111 |
111 scoped_refptr<quota::MockSpecialStoragePolicy> storage_policy = | 112 scoped_refptr<quota::MockSpecialStoragePolicy> storage_policy = |
112 new quota::MockSpecialStoragePolicy(); | 113 new quota::MockSpecialStoragePolicy(); |
113 scoped_refptr<fileapi::ExternalMountPoints> mount_points( | 114 scoped_refptr<fileapi::ExternalMountPoints> mount_points( |
114 fileapi::ExternalMountPoints::CreateRefCounted()); | 115 fileapi::ExternalMountPoints::CreateRefCounted()); |
115 scoped_refptr<fileapi::ExternalMountPoints> system_mount_points( | 116 scoped_refptr<fileapi::ExternalMountPoints> system_mount_points( |
116 fileapi::ExternalMountPoints::CreateRefCounted()); | 117 fileapi::ExternalMountPoints::CreateRefCounted()); |
117 chromeos::FileSystemBackend backend( | 118 chromeos::FileSystemBackend backend(NULL, // drive_delegate |
118 NULL, // drive_delegate | 119 NULL, // file_system_provider_delegate |
119 storage_policy, | 120 storage_policy, |
120 mount_points.get(), | 121 mount_points.get(), |
121 system_mount_points.get()); | 122 system_mount_points.get()); |
122 | 123 |
123 std::string extension("ddammdhioacbehjngdmkjcjbnfginlla"); | 124 std::string extension("ddammdhioacbehjngdmkjcjbnfginlla"); |
124 | 125 |
125 storage_policy->AddFileHandler(extension); | 126 storage_policy->AddFileHandler(extension); |
126 | 127 |
127 // Initialize mount points. | 128 // Initialize mount points. |
128 ASSERT_TRUE(system_mount_points->RegisterFileSystem( | 129 ASSERT_TRUE(system_mount_points->RegisterFileSystem( |
129 "system", | 130 "system", |
130 fileapi::kFileSystemTypeNativeLocal, | 131 fileapi::kFileSystemTypeNativeLocal, |
131 fileapi::FileSystemMountOption(), | 132 fileapi::FileSystemMountOption(), |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 EXPECT_TRUE(backend.IsAccessAllowed(internal_url)); | 208 EXPECT_TRUE(backend.IsAccessAllowed(internal_url)); |
208 } | 209 } |
209 | 210 |
210 TEST(ChromeOSFileSystemBackendTest, GetVirtualPathConflictWithSystemPoints) { | 211 TEST(ChromeOSFileSystemBackendTest, GetVirtualPathConflictWithSystemPoints) { |
211 scoped_refptr<quota::MockSpecialStoragePolicy> storage_policy = | 212 scoped_refptr<quota::MockSpecialStoragePolicy> storage_policy = |
212 new quota::MockSpecialStoragePolicy(); | 213 new quota::MockSpecialStoragePolicy(); |
213 scoped_refptr<fileapi::ExternalMountPoints> mount_points( | 214 scoped_refptr<fileapi::ExternalMountPoints> mount_points( |
214 fileapi::ExternalMountPoints::CreateRefCounted()); | 215 fileapi::ExternalMountPoints::CreateRefCounted()); |
215 scoped_refptr<fileapi::ExternalMountPoints> system_mount_points( | 216 scoped_refptr<fileapi::ExternalMountPoints> system_mount_points( |
216 fileapi::ExternalMountPoints::CreateRefCounted()); | 217 fileapi::ExternalMountPoints::CreateRefCounted()); |
217 chromeos::FileSystemBackend backend( | 218 chromeos::FileSystemBackend backend(NULL, // drive_delegate |
218 NULL, // drive_delegate | 219 NULL, // file_system_provider_delegate |
219 storage_policy, | 220 storage_policy, |
220 mount_points.get(), | 221 mount_points.get(), |
221 system_mount_points.get()); | 222 system_mount_points.get()); |
222 | 223 |
223 const fileapi::FileSystemType type = fileapi::kFileSystemTypeNativeLocal; | 224 const fileapi::FileSystemType type = fileapi::kFileSystemTypeNativeLocal; |
224 const fileapi::FileSystemMountOption option = | 225 const fileapi::FileSystemMountOption option = |
225 fileapi::FileSystemMountOption(); | 226 fileapi::FileSystemMountOption(); |
226 | 227 |
227 // Backend specific mount points. | 228 // Backend specific mount points. |
228 ASSERT_TRUE(mount_points->RegisterFileSystem( | 229 ASSERT_TRUE(mount_points->RegisterFileSystem( |
229 "b", type, option, base::FilePath(FPL("/a/b")))); | 230 "b", type, option, base::FilePath(FPL("/a/b")))); |
230 ASSERT_TRUE(mount_points->RegisterFileSystem( | 231 ASSERT_TRUE(mount_points->RegisterFileSystem( |
231 "y", type, option, base::FilePath(FPL("/z/y")))); | 232 "y", type, option, base::FilePath(FPL("/z/y")))); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 if (!kTestCases[i].success) | 274 if (!kTestCases[i].success) |
274 continue; | 275 continue; |
275 | 276 |
276 base::FilePath expected_virtual_path(kTestCases[i].virtual_path); | 277 base::FilePath expected_virtual_path(kTestCases[i].virtual_path); |
277 EXPECT_EQ(expected_virtual_path, virtual_path) | 278 EXPECT_EQ(expected_virtual_path, virtual_path) |
278 << "Resolving " << kTestCases[i].local_path; | 279 << "Resolving " << kTestCases[i].local_path; |
279 } | 280 } |
280 } | 281 } |
281 | 282 |
282 } // namespace | 283 } // namespace |
OLD | NEW |