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/cros_mount_point_provider.h" | 5 #include "chrome/browser/chromeos/fileapi/cros_mount_point_provider.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 21 matching lines...) Expand all Loading... |
32 fileapi::kFileSystemTypeExternal, | 32 fileapi::kFileSystemTypeExternal, |
33 base::FilePath::FromUTF8Unsafe(path)); | 33 base::FilePath::FromUTF8Unsafe(path)); |
34 } | 34 } |
35 | 35 |
36 TEST(CrosMountPointProviderTest, DefaultMountPoints) { | 36 TEST(CrosMountPointProviderTest, DefaultMountPoints) { |
37 scoped_refptr<quota::SpecialStoragePolicy> storage_policy = | 37 scoped_refptr<quota::SpecialStoragePolicy> storage_policy = |
38 new quota::MockSpecialStoragePolicy(); | 38 new quota::MockSpecialStoragePolicy(); |
39 scoped_refptr<fileapi::ExternalMountPoints> mount_points( | 39 scoped_refptr<fileapi::ExternalMountPoints> mount_points( |
40 fileapi::ExternalMountPoints::CreateRefCounted()); | 40 fileapi::ExternalMountPoints::CreateRefCounted()); |
41 chromeos::CrosMountPointProvider provider( | 41 chromeos::CrosMountPointProvider provider( |
| 42 NULL, // drive_delegate |
42 storage_policy, | 43 storage_policy, |
43 mount_points.get(), | 44 mount_points.get(), |
44 fileapi::ExternalMountPoints::GetSystemInstance()); | 45 fileapi::ExternalMountPoints::GetSystemInstance()); |
45 provider.AddSystemMountPoints(); | 46 provider.AddSystemMountPoints(); |
46 std::vector<base::FilePath> root_dirs = provider.GetRootDirectories(); | 47 std::vector<base::FilePath> root_dirs = provider.GetRootDirectories(); |
47 std::set<base::FilePath> root_dirs_set(root_dirs.begin(), root_dirs.end()); | 48 std::set<base::FilePath> root_dirs_set(root_dirs.begin(), root_dirs.end()); |
48 | 49 |
49 // By default there should be 4 mount points (in system mount points): | 50 // By default there should be 4 mount points (in system mount points): |
50 EXPECT_EQ(4u, root_dirs.size()); | 51 EXPECT_EQ(4u, root_dirs.size()); |
51 base::FilePath home_path; | 52 base::FilePath home_path; |
(...skipping 10 matching lines...) Expand all Loading... |
62 TEST(CrosMountPointProviderTest, GetRootDirectories) { | 63 TEST(CrosMountPointProviderTest, 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::CrosMountPointProvider provider( | 72 chromeos::CrosMountPointProvider provider( |
| 73 NULL, // drive_delegate |
72 storage_policy, | 74 storage_policy, |
73 mount_points.get(), | 75 mount_points.get(), |
74 system_mount_points.get()); | 76 system_mount_points.get()); |
75 | 77 |
76 const size_t initial_root_dirs_size = provider.GetRootDirectories().size(); | 78 const size_t initial_root_dirs_size = provider.GetRootDirectories().size(); |
77 | 79 |
78 // Register 'local' test mount points. | 80 // Register 'local' test mount points. |
79 mount_points->RegisterFileSystem("c", | 81 mount_points->RegisterFileSystem("c", |
80 fileapi::kFileSystemTypeNativeLocal, | 82 fileapi::kFileSystemTypeNativeLocal, |
81 base::FilePath(FPL("/a/b/c"))); | 83 base::FilePath(FPL("/a/b/c"))); |
(...skipping 21 matching lines...) Expand all Loading... |
103 TEST(CrosMountPointProviderTest, AccessPermissions) { | 105 TEST(CrosMountPointProviderTest, AccessPermissions) { |
104 url_util::AddStandardScheme("chrome-extension"); | 106 url_util::AddStandardScheme("chrome-extension"); |
105 | 107 |
106 scoped_refptr<quota::MockSpecialStoragePolicy> storage_policy = | 108 scoped_refptr<quota::MockSpecialStoragePolicy> storage_policy = |
107 new quota::MockSpecialStoragePolicy(); | 109 new quota::MockSpecialStoragePolicy(); |
108 scoped_refptr<fileapi::ExternalMountPoints> mount_points( | 110 scoped_refptr<fileapi::ExternalMountPoints> mount_points( |
109 fileapi::ExternalMountPoints::CreateRefCounted()); | 111 fileapi::ExternalMountPoints::CreateRefCounted()); |
110 scoped_refptr<fileapi::ExternalMountPoints> system_mount_points( | 112 scoped_refptr<fileapi::ExternalMountPoints> system_mount_points( |
111 fileapi::ExternalMountPoints::CreateRefCounted()); | 113 fileapi::ExternalMountPoints::CreateRefCounted()); |
112 chromeos::CrosMountPointProvider provider( | 114 chromeos::CrosMountPointProvider provider( |
| 115 NULL, // drive_delegate |
113 storage_policy, | 116 storage_policy, |
114 mount_points.get(), | 117 mount_points.get(), |
115 system_mount_points.get()); | 118 system_mount_points.get()); |
116 | 119 |
117 std::string extension("ddammdhioacbehjngdmkjcjbnfginlla"); | 120 std::string extension("ddammdhioacbehjngdmkjcjbnfginlla"); |
118 | 121 |
119 storage_policy->AddFileHandler(extension); | 122 storage_policy->AddFileHandler(extension); |
120 | 123 |
121 // Initialize mount points. | 124 // Initialize mount points. |
122 ASSERT_TRUE(system_mount_points->RegisterFileSystem( | 125 ASSERT_TRUE(system_mount_points->RegisterFileSystem( |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 EXPECT_TRUE(provider.IsAccessAllowed(internal_url)); | 200 EXPECT_TRUE(provider.IsAccessAllowed(internal_url)); |
198 } | 201 } |
199 | 202 |
200 TEST(CrosMountPointProvider, GetVirtualPathConflictWithSystemPoints) { | 203 TEST(CrosMountPointProvider, GetVirtualPathConflictWithSystemPoints) { |
201 scoped_refptr<quota::MockSpecialStoragePolicy> storage_policy = | 204 scoped_refptr<quota::MockSpecialStoragePolicy> storage_policy = |
202 new quota::MockSpecialStoragePolicy(); | 205 new quota::MockSpecialStoragePolicy(); |
203 scoped_refptr<fileapi::ExternalMountPoints> mount_points( | 206 scoped_refptr<fileapi::ExternalMountPoints> mount_points( |
204 fileapi::ExternalMountPoints::CreateRefCounted()); | 207 fileapi::ExternalMountPoints::CreateRefCounted()); |
205 scoped_refptr<fileapi::ExternalMountPoints> system_mount_points( | 208 scoped_refptr<fileapi::ExternalMountPoints> system_mount_points( |
206 fileapi::ExternalMountPoints::CreateRefCounted()); | 209 fileapi::ExternalMountPoints::CreateRefCounted()); |
207 chromeos::CrosMountPointProvider provider(storage_policy, | 210 chromeos::CrosMountPointProvider provider( |
| 211 NULL, // drive_delegate |
| 212 storage_policy, |
208 mount_points.get(), | 213 mount_points.get(), |
209 system_mount_points.get()); | 214 system_mount_points.get()); |
210 | 215 |
211 const fileapi::FileSystemType type = fileapi::kFileSystemTypeNativeLocal; | 216 const fileapi::FileSystemType type = fileapi::kFileSystemTypeNativeLocal; |
212 | 217 |
213 // Provider specific mount points. | 218 // Provider specific mount points. |
214 ASSERT_TRUE( | 219 ASSERT_TRUE( |
215 mount_points->RegisterFileSystem("b", type, base::FilePath(FPL("/a/b")))); | 220 mount_points->RegisterFileSystem("b", type, base::FilePath(FPL("/a/b")))); |
216 ASSERT_TRUE( | 221 ASSERT_TRUE( |
217 mount_points->RegisterFileSystem("y", type, base::FilePath(FPL("/z/y")))); | 222 mount_points->RegisterFileSystem("y", type, base::FilePath(FPL("/z/y")))); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 if (!kTestCases[i].success) | 264 if (!kTestCases[i].success) |
260 continue; | 265 continue; |
261 | 266 |
262 base::FilePath expected_virtual_path(kTestCases[i].virtual_path); | 267 base::FilePath expected_virtual_path(kTestCases[i].virtual_path); |
263 EXPECT_EQ(expected_virtual_path, virtual_path) | 268 EXPECT_EQ(expected_virtual_path, virtual_path) |
264 << "Resolving " << kTestCases[i].local_path; | 269 << "Resolving " << kTestCases[i].local_path; |
265 } | 270 } |
266 } | 271 } |
267 | 272 |
268 } // namespace | 273 } // namespace |
OLD | NEW |