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