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 "webkit/browser/fileapi/file_system_context.h" | 5 #include "storage/browser/fileapi/file_system_context.h" |
6 | 6 |
7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "content/browser/quota/mock_quota_manager.h" | 10 #include "content/browser/quota/mock_quota_manager.h" |
11 #include "content/public/test/mock_special_storage_policy.h" | 11 #include "content/public/test/mock_special_storage_policy.h" |
12 #include "content/public/test/test_file_system_options.h" | 12 #include "content/public/test/test_file_system_options.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 #include "webkit/browser/fileapi/external_mount_points.h" | 14 #include "storage/browser/fileapi/external_mount_points.h" |
15 #include "webkit/browser/fileapi/file_system_backend.h" | 15 #include "storage/browser/fileapi/file_system_backend.h" |
16 #include "webkit/browser/fileapi/isolated_context.h" | 16 #include "storage/browser/fileapi/isolated_context.h" |
17 | 17 |
18 #define FPL(x) FILE_PATH_LITERAL(x) | 18 #define FPL(x) FILE_PATH_LITERAL(x) |
19 | 19 |
20 #if defined(FILE_PATH_USES_DRIVE_LETTERS) | 20 #if defined(FILE_PATH_USES_DRIVE_LETTERS) |
21 #define DRIVE FPL("C:") | 21 #define DRIVE FPL("C:") |
22 #else | 22 #else |
23 #define DRIVE | 23 #define DRIVE |
24 #endif | 24 #endif |
25 | 25 |
26 using fileapi::ExternalMountPoints; | 26 using storage::ExternalMountPoints; |
27 using fileapi::FileSystemBackend; | 27 using storage::FileSystemBackend; |
28 using fileapi::FileSystemContext; | 28 using storage::FileSystemContext; |
29 using fileapi::FileSystemMountOption; | 29 using storage::FileSystemMountOption; |
30 using fileapi::FileSystemURL; | 30 using storage::FileSystemURL; |
31 using fileapi::IsolatedContext; | 31 using storage::IsolatedContext; |
32 | 32 |
33 namespace content { | 33 namespace content { |
34 | 34 |
35 namespace { | 35 namespace { |
36 | 36 |
37 const char kTestOrigin[] = "http://chromium.org/"; | 37 const char kTestOrigin[] = "http://chromium.org/"; |
38 | 38 |
39 GURL CreateRawFileSystemURL(const std::string& type_str, | 39 GURL CreateRawFileSystemURL(const std::string& type_str, |
40 const std::string& fs_id) { | 40 const std::string& fs_id) { |
41 std::string url_str = base::StringPrintf( | 41 std::string url_str = base::StringPrintf( |
(...skipping 15 matching lines...) Expand all Loading... |
57 mock_quota_manager_ = | 57 mock_quota_manager_ = |
58 new MockQuotaManager(false /* is_incognito */, | 58 new MockQuotaManager(false /* is_incognito */, |
59 data_dir_.path(), | 59 data_dir_.path(), |
60 base::MessageLoopProxy::current().get(), | 60 base::MessageLoopProxy::current().get(), |
61 base::MessageLoopProxy::current().get(), | 61 base::MessageLoopProxy::current().get(), |
62 storage_policy_.get()); | 62 storage_policy_.get()); |
63 } | 63 } |
64 | 64 |
65 protected: | 65 protected: |
66 FileSystemContext* CreateFileSystemContextForTest( | 66 FileSystemContext* CreateFileSystemContextForTest( |
67 fileapi::ExternalMountPoints* external_mount_points) { | 67 storage::ExternalMountPoints* external_mount_points) { |
68 return new FileSystemContext( | 68 return new FileSystemContext( |
69 base::MessageLoopProxy::current().get(), | 69 base::MessageLoopProxy::current().get(), |
70 base::MessageLoopProxy::current().get(), | 70 base::MessageLoopProxy::current().get(), |
71 external_mount_points, | 71 external_mount_points, |
72 storage_policy_.get(), | 72 storage_policy_.get(), |
73 mock_quota_manager_->proxy(), | 73 mock_quota_manager_->proxy(), |
74 ScopedVector<FileSystemBackend>(), | 74 ScopedVector<FileSystemBackend>(), |
75 std::vector<fileapi::URLRequestAutoMountHandler>(), | 75 std::vector<storage::URLRequestAutoMountHandler>(), |
76 data_dir_.path(), | 76 data_dir_.path(), |
77 CreateAllowFileAccessOptions()); | 77 CreateAllowFileAccessOptions()); |
78 } | 78 } |
79 | 79 |
80 // Verifies a *valid* filesystem url has expected values. | 80 // Verifies a *valid* filesystem url has expected values. |
81 void ExpectFileSystemURLMatches(const FileSystemURL& url, | 81 void ExpectFileSystemURLMatches(const FileSystemURL& url, |
82 const GURL& expect_origin, | 82 const GURL& expect_origin, |
83 fileapi::FileSystemType expect_mount_type, | 83 storage::FileSystemType expect_mount_type, |
84 fileapi::FileSystemType expect_type, | 84 storage::FileSystemType expect_type, |
85 const base::FilePath& expect_path, | 85 const base::FilePath& expect_path, |
86 const base::FilePath& expect_virtual_path, | 86 const base::FilePath& expect_virtual_path, |
87 const std::string& expect_filesystem_id) { | 87 const std::string& expect_filesystem_id) { |
88 EXPECT_TRUE(url.is_valid()); | 88 EXPECT_TRUE(url.is_valid()); |
89 | 89 |
90 EXPECT_EQ(expect_origin, url.origin()); | 90 EXPECT_EQ(expect_origin, url.origin()); |
91 EXPECT_EQ(expect_mount_type, url.mount_type()); | 91 EXPECT_EQ(expect_mount_type, url.mount_type()); |
92 EXPECT_EQ(expect_type, url.type()); | 92 EXPECT_EQ(expect_type, url.type()); |
93 EXPECT_EQ(expect_path, url.path()); | 93 EXPECT_EQ(expect_path, url.path()); |
94 EXPECT_EQ(expect_virtual_path, url.virtual_path()); | 94 EXPECT_EQ(expect_virtual_path, url.virtual_path()); |
(...skipping 11 matching lines...) Expand all Loading... |
106 // ChromeOS. | 106 // ChromeOS. |
107 #if !defined(OS_CHROMEOS) | 107 #if !defined(OS_CHROMEOS) |
108 TEST_F(FileSystemContextTest, NullExternalMountPoints) { | 108 TEST_F(FileSystemContextTest, NullExternalMountPoints) { |
109 scoped_refptr<FileSystemContext> file_system_context( | 109 scoped_refptr<FileSystemContext> file_system_context( |
110 CreateFileSystemContextForTest(NULL)); | 110 CreateFileSystemContextForTest(NULL)); |
111 | 111 |
112 // Cracking system external mount and isolated mount points should work. | 112 // Cracking system external mount and isolated mount points should work. |
113 std::string isolated_name = "root"; | 113 std::string isolated_name = "root"; |
114 std::string isolated_id = | 114 std::string isolated_id = |
115 IsolatedContext::GetInstance()->RegisterFileSystemForPath( | 115 IsolatedContext::GetInstance()->RegisterFileSystemForPath( |
116 fileapi::kFileSystemTypeNativeLocal, | 116 storage::kFileSystemTypeNativeLocal, |
117 std::string(), | 117 std::string(), |
118 base::FilePath(DRIVE FPL("/test/isolated/root")), | 118 base::FilePath(DRIVE FPL("/test/isolated/root")), |
119 &isolated_name); | 119 &isolated_name); |
120 // Register system external mount point. | 120 // Register system external mount point. |
121 ASSERT_TRUE(ExternalMountPoints::GetSystemInstance()->RegisterFileSystem( | 121 ASSERT_TRUE(ExternalMountPoints::GetSystemInstance()->RegisterFileSystem( |
122 "system", | 122 "system", |
123 fileapi::kFileSystemTypeNativeLocal, | 123 storage::kFileSystemTypeNativeLocal, |
124 FileSystemMountOption(), | 124 FileSystemMountOption(), |
125 base::FilePath(DRIVE FPL("/test/sys/")))); | 125 base::FilePath(DRIVE FPL("/test/sys/")))); |
126 | 126 |
127 FileSystemURL cracked_isolated = file_system_context->CrackURL( | 127 FileSystemURL cracked_isolated = file_system_context->CrackURL( |
128 CreateRawFileSystemURL("isolated", isolated_id)); | 128 CreateRawFileSystemURL("isolated", isolated_id)); |
129 | 129 |
130 ExpectFileSystemURLMatches( | 130 ExpectFileSystemURLMatches( |
131 cracked_isolated, | 131 cracked_isolated, |
132 GURL(kTestOrigin), | 132 GURL(kTestOrigin), |
133 fileapi::kFileSystemTypeIsolated, | 133 storage::kFileSystemTypeIsolated, |
134 fileapi::kFileSystemTypeNativeLocal, | 134 storage::kFileSystemTypeNativeLocal, |
135 base::FilePath( | 135 base::FilePath(DRIVE FPL("/test/isolated/root/file")) |
136 DRIVE FPL("/test/isolated/root/file")).NormalizePathSeparators(), | 136 .NormalizePathSeparators(), |
137 base::FilePath::FromUTF8Unsafe(isolated_id).Append(FPL("root/file")). | 137 base::FilePath::FromUTF8Unsafe(isolated_id) |
138 NormalizePathSeparators(), | 138 .Append(FPL("root/file")) |
| 139 .NormalizePathSeparators(), |
139 isolated_id); | 140 isolated_id); |
140 | 141 |
141 FileSystemURL cracked_external = file_system_context->CrackURL( | 142 FileSystemURL cracked_external = file_system_context->CrackURL( |
142 CreateRawFileSystemURL("external", "system")); | 143 CreateRawFileSystemURL("external", "system")); |
143 | 144 |
144 ExpectFileSystemURLMatches( | 145 ExpectFileSystemURLMatches( |
145 cracked_external, | 146 cracked_external, |
146 GURL(kTestOrigin), | 147 GURL(kTestOrigin), |
147 fileapi::kFileSystemTypeExternal, | 148 storage::kFileSystemTypeExternal, |
148 fileapi::kFileSystemTypeNativeLocal, | 149 storage::kFileSystemTypeNativeLocal, |
149 base::FilePath( | 150 base::FilePath(DRIVE FPL("/test/sys/root/file")) |
150 DRIVE FPL("/test/sys/root/file")).NormalizePathSeparators(), | 151 .NormalizePathSeparators(), |
151 base::FilePath(FPL("system/root/file")).NormalizePathSeparators(), | 152 base::FilePath(FPL("system/root/file")).NormalizePathSeparators(), |
152 "system"); | 153 "system"); |
153 | 154 |
154 | |
155 IsolatedContext::GetInstance()->RevokeFileSystem(isolated_id); | 155 IsolatedContext::GetInstance()->RevokeFileSystem(isolated_id); |
156 ExternalMountPoints::GetSystemInstance()->RevokeFileSystem("system"); | 156 ExternalMountPoints::GetSystemInstance()->RevokeFileSystem("system"); |
157 } | 157 } |
158 #endif // !defiend(OS_CHROMEOS) | 158 #endif // !defiend(OS_CHROMEOS) |
159 | 159 |
160 TEST_F(FileSystemContextTest, FileSystemContextKeepsMountPointsAlive) { | 160 TEST_F(FileSystemContextTest, FileSystemContextKeepsMountPointsAlive) { |
161 scoped_refptr<ExternalMountPoints> mount_points = | 161 scoped_refptr<ExternalMountPoints> mount_points = |
162 ExternalMountPoints::CreateRefCounted(); | 162 ExternalMountPoints::CreateRefCounted(); |
163 | 163 |
164 // Register system external mount point. | 164 // Register system external mount point. |
165 ASSERT_TRUE(mount_points->RegisterFileSystem( | 165 ASSERT_TRUE(mount_points->RegisterFileSystem( |
166 "system", | 166 "system", |
167 fileapi::kFileSystemTypeNativeLocal, | 167 storage::kFileSystemTypeNativeLocal, |
168 FileSystemMountOption(), | 168 FileSystemMountOption(), |
169 base::FilePath(DRIVE FPL("/test/sys/")))); | 169 base::FilePath(DRIVE FPL("/test/sys/")))); |
170 | 170 |
171 scoped_refptr<FileSystemContext> file_system_context( | 171 scoped_refptr<FileSystemContext> file_system_context( |
172 CreateFileSystemContextForTest(mount_points.get())); | 172 CreateFileSystemContextForTest(mount_points.get())); |
173 | 173 |
174 // Release a MountPoints reference created in the test. | 174 // Release a MountPoints reference created in the test. |
175 mount_points = NULL; | 175 mount_points = NULL; |
176 | 176 |
177 // FileSystemContext should keep a reference to the |mount_points|, so it | 177 // FileSystemContext should keep a reference to the |mount_points|, so it |
178 // should be able to resolve the URL. | 178 // should be able to resolve the URL. |
179 FileSystemURL cracked_external = file_system_context->CrackURL( | 179 FileSystemURL cracked_external = file_system_context->CrackURL( |
180 CreateRawFileSystemURL("external", "system")); | 180 CreateRawFileSystemURL("external", "system")); |
181 | 181 |
182 ExpectFileSystemURLMatches( | 182 ExpectFileSystemURLMatches( |
183 cracked_external, | 183 cracked_external, |
184 GURL(kTestOrigin), | 184 GURL(kTestOrigin), |
185 fileapi::kFileSystemTypeExternal, | 185 storage::kFileSystemTypeExternal, |
186 fileapi::kFileSystemTypeNativeLocal, | 186 storage::kFileSystemTypeNativeLocal, |
187 base::FilePath( | 187 base::FilePath(DRIVE FPL("/test/sys/root/file")) |
188 DRIVE FPL("/test/sys/root/file")).NormalizePathSeparators(), | 188 .NormalizePathSeparators(), |
189 base::FilePath(FPL("system/root/file")).NormalizePathSeparators(), | 189 base::FilePath(FPL("system/root/file")).NormalizePathSeparators(), |
190 "system"); | 190 "system"); |
191 | 191 |
192 // No need to revoke the registered filesystem since |mount_points| lifetime | 192 // No need to revoke the registered filesystem since |mount_points| lifetime |
193 // is bound to this test. | 193 // is bound to this test. |
194 } | 194 } |
195 | 195 |
196 TEST_F(FileSystemContextTest, CrackFileSystemURL) { | 196 TEST_F(FileSystemContextTest, CrackFileSystemURL) { |
197 scoped_refptr<ExternalMountPoints> external_mount_points( | 197 scoped_refptr<ExternalMountPoints> external_mount_points( |
198 ExternalMountPoints::CreateRefCounted()); | 198 ExternalMountPoints::CreateRefCounted()); |
199 scoped_refptr<FileSystemContext> file_system_context( | 199 scoped_refptr<FileSystemContext> file_system_context( |
200 CreateFileSystemContextForTest(external_mount_points.get())); | 200 CreateFileSystemContextForTest(external_mount_points.get())); |
201 | 201 |
202 // Register an isolated mount point. | 202 // Register an isolated mount point. |
203 std::string isolated_file_system_name = "root"; | 203 std::string isolated_file_system_name = "root"; |
204 const std::string kIsolatedFileSystemID = | 204 const std::string kIsolatedFileSystemID = |
205 IsolatedContext::GetInstance()->RegisterFileSystemForPath( | 205 IsolatedContext::GetInstance()->RegisterFileSystemForPath( |
206 fileapi::kFileSystemTypeNativeLocal, | 206 storage::kFileSystemTypeNativeLocal, |
207 std::string(), | 207 std::string(), |
208 base::FilePath(DRIVE FPL("/test/isolated/root")), | 208 base::FilePath(DRIVE FPL("/test/isolated/root")), |
209 &isolated_file_system_name); | 209 &isolated_file_system_name); |
210 // Register system external mount point. | 210 // Register system external mount point. |
211 ASSERT_TRUE(ExternalMountPoints::GetSystemInstance()->RegisterFileSystem( | 211 ASSERT_TRUE(ExternalMountPoints::GetSystemInstance()->RegisterFileSystem( |
212 "system", | 212 "system", |
213 fileapi::kFileSystemTypeDrive, | 213 storage::kFileSystemTypeDrive, |
214 FileSystemMountOption(), | 214 FileSystemMountOption(), |
215 base::FilePath(DRIVE FPL("/test/sys/")))); | 215 base::FilePath(DRIVE FPL("/test/sys/")))); |
216 ASSERT_TRUE(ExternalMountPoints::GetSystemInstance()->RegisterFileSystem( | 216 ASSERT_TRUE(ExternalMountPoints::GetSystemInstance()->RegisterFileSystem( |
217 "ext", | 217 "ext", |
218 fileapi::kFileSystemTypeNativeLocal, | 218 storage::kFileSystemTypeNativeLocal, |
219 FileSystemMountOption(), | 219 FileSystemMountOption(), |
220 base::FilePath(DRIVE FPL("/test/ext")))); | 220 base::FilePath(DRIVE FPL("/test/ext")))); |
221 // Register a system external mount point with the same name/id as the | 221 // Register a system external mount point with the same name/id as the |
222 // registered isolated mount point. | 222 // registered isolated mount point. |
223 ASSERT_TRUE(ExternalMountPoints::GetSystemInstance()->RegisterFileSystem( | 223 ASSERT_TRUE(ExternalMountPoints::GetSystemInstance()->RegisterFileSystem( |
224 kIsolatedFileSystemID, | 224 kIsolatedFileSystemID, |
225 fileapi::kFileSystemTypeRestrictedNativeLocal, | 225 storage::kFileSystemTypeRestrictedNativeLocal, |
226 FileSystemMountOption(), | 226 FileSystemMountOption(), |
227 base::FilePath(DRIVE FPL("/test/system/isolated")))); | 227 base::FilePath(DRIVE FPL("/test/system/isolated")))); |
228 // Add a mount points with the same name as a system mount point to | 228 // Add a mount points with the same name as a system mount point to |
229 // FileSystemContext's external mount points. | 229 // FileSystemContext's external mount points. |
230 ASSERT_TRUE(external_mount_points->RegisterFileSystem( | 230 ASSERT_TRUE(external_mount_points->RegisterFileSystem( |
231 "ext", | 231 "ext", |
232 fileapi::kFileSystemTypeNativeLocal, | 232 storage::kFileSystemTypeNativeLocal, |
233 FileSystemMountOption(), | 233 FileSystemMountOption(), |
234 base::FilePath(DRIVE FPL("/test/local/ext/")))); | 234 base::FilePath(DRIVE FPL("/test/local/ext/")))); |
235 | 235 |
236 const GURL kTestOrigin = GURL("http://chromium.org/"); | 236 const GURL kTestOrigin = GURL("http://chromium.org/"); |
237 const base::FilePath kVirtualPathNoRoot = base::FilePath(FPL("root/file")); | 237 const base::FilePath kVirtualPathNoRoot = base::FilePath(FPL("root/file")); |
238 | 238 |
239 struct TestCase { | 239 struct TestCase { |
240 // Test case values. | 240 // Test case values. |
241 std::string root; | 241 std::string root; |
242 std::string type_str; | 242 std::string type_str; |
243 | 243 |
244 // Expected test results. | 244 // Expected test results. |
245 bool expect_is_valid; | 245 bool expect_is_valid; |
246 fileapi::FileSystemType expect_mount_type; | 246 storage::FileSystemType expect_mount_type; |
247 fileapi::FileSystemType expect_type; | 247 storage::FileSystemType expect_type; |
248 const base::FilePath::CharType* expect_path; | 248 const base::FilePath::CharType* expect_path; |
249 std::string expect_filesystem_id; | 249 std::string expect_filesystem_id; |
250 }; | 250 }; |
251 | 251 |
252 const TestCase kTestCases[] = { | 252 const TestCase kTestCases[] = { |
253 // Following should not be handled by the url crackers: | 253 // Following should not be handled by the url crackers: |
254 { | 254 { |
255 "pers_mount", "persistent", true /* is_valid */, | 255 "pers_mount", "persistent", true /* is_valid */, |
256 fileapi::kFileSystemTypePersistent, fileapi::kFileSystemTypePersistent, | 256 storage::kFileSystemTypePersistent, storage::kFileSystemTypePersistent, |
257 FPL("pers_mount/root/file"), | 257 FPL("pers_mount/root/file"), std::string() /* filesystem id */ |
258 std::string() /* filesystem id */ | |
259 }, | 258 }, |
260 { | 259 { |
261 "temp_mount", "temporary", true /* is_valid */, | 260 "temp_mount", "temporary", true /* is_valid */, |
262 fileapi::kFileSystemTypeTemporary, fileapi::kFileSystemTypeTemporary, | 261 storage::kFileSystemTypeTemporary, storage::kFileSystemTypeTemporary, |
263 FPL("temp_mount/root/file"), | 262 FPL("temp_mount/root/file"), std::string() /* filesystem id */ |
264 std::string() /* filesystem id */ | |
265 }, | 263 }, |
266 // Should be cracked by isolated mount points: | 264 // Should be cracked by isolated mount points: |
267 { | 265 {kIsolatedFileSystemID, "isolated", true /* is_valid */, |
268 kIsolatedFileSystemID, "isolated", true /* is_valid */, | 266 storage::kFileSystemTypeIsolated, storage::kFileSystemTypeNativeLocal, |
269 fileapi::kFileSystemTypeIsolated, fileapi::kFileSystemTypeNativeLocal, | 267 DRIVE FPL("/test/isolated/root/file"), kIsolatedFileSystemID}, |
270 DRIVE FPL("/test/isolated/root/file"), | |
271 kIsolatedFileSystemID | |
272 }, | |
273 // Should be cracked by system mount points: | 268 // Should be cracked by system mount points: |
274 { | 269 {"system", "external", true /* is_valid */, |
275 "system", "external", true /* is_valid */, | 270 storage::kFileSystemTypeExternal, storage::kFileSystemTypeDrive, |
276 fileapi::kFileSystemTypeExternal, fileapi::kFileSystemTypeDrive, | 271 DRIVE FPL("/test/sys/root/file"), "system"}, |
277 DRIVE FPL("/test/sys/root/file"), | 272 {kIsolatedFileSystemID, "external", true /* is_valid */, |
278 "system" | 273 storage::kFileSystemTypeExternal, |
279 }, | 274 storage::kFileSystemTypeRestrictedNativeLocal, |
280 { | 275 DRIVE FPL("/test/system/isolated/root/file"), kIsolatedFileSystemID}, |
281 kIsolatedFileSystemID, "external", true /* is_valid */, | |
282 fileapi::kFileSystemTypeExternal, | |
283 fileapi::kFileSystemTypeRestrictedNativeLocal, | |
284 DRIVE FPL("/test/system/isolated/root/file"), | |
285 kIsolatedFileSystemID | |
286 }, | |
287 // Should be cracked by FileSystemContext's ExternalMountPoints. | 276 // Should be cracked by FileSystemContext's ExternalMountPoints. |
288 { | 277 {"ext", "external", true /* is_valid */, storage::kFileSystemTypeExternal, |
289 "ext", "external", true /* is_valid */, | 278 storage::kFileSystemTypeNativeLocal, |
290 fileapi::kFileSystemTypeExternal, fileapi::kFileSystemTypeNativeLocal, | 279 DRIVE FPL("/test/local/ext/root/file"), "ext"}, |
291 DRIVE FPL("/test/local/ext/root/file"), | |
292 "ext" | |
293 }, | |
294 // Test for invalid filesystem url (made invalid by adding invalid | 280 // Test for invalid filesystem url (made invalid by adding invalid |
295 // filesystem type). | 281 // filesystem type). |
296 { | 282 {"sytem", "external", false /* is_valid */, |
297 "sytem", "external", false /* is_valid */, | 283 // The rest of values will be ignored. |
298 // The rest of values will be ignored. | 284 storage::kFileSystemTypeUnknown, storage::kFileSystemTypeUnknown, |
299 fileapi::kFileSystemTypeUnknown, fileapi::kFileSystemTypeUnknown, | 285 FPL(""), std::string()}, |
300 FPL(""), std::string() | |
301 }, | |
302 // Test for URL with non-existing filesystem id. | 286 // Test for URL with non-existing filesystem id. |
303 { | 287 {"invalid", "external", false /* is_valid */, |
304 "invalid", "external", false /* is_valid */, | 288 // The rest of values will be ignored. |
305 // The rest of values will be ignored. | 289 storage::kFileSystemTypeUnknown, storage::kFileSystemTypeUnknown, |
306 fileapi::kFileSystemTypeUnknown, fileapi::kFileSystemTypeUnknown, | 290 FPL(""), std::string()}, |
307 FPL(""), std::string() | |
308 }, | |
309 }; | 291 }; |
310 | 292 |
311 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) { | 293 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) { |
312 const base::FilePath virtual_path = | 294 const base::FilePath virtual_path = |
313 base::FilePath::FromUTF8Unsafe( | 295 base::FilePath::FromUTF8Unsafe( |
314 kTestCases[i].root).Append(kVirtualPathNoRoot); | 296 kTestCases[i].root).Append(kVirtualPathNoRoot); |
315 | 297 |
316 GURL raw_url = | 298 GURL raw_url = |
317 CreateRawFileSystemURL(kTestCases[i].type_str, kTestCases[i].root); | 299 CreateRawFileSystemURL(kTestCases[i].type_str, kTestCases[i].root); |
318 FileSystemURL cracked_url = file_system_context->CrackURL(raw_url); | 300 FileSystemURL cracked_url = file_system_context->CrackURL(raw_url); |
(...skipping 25 matching lines...) Expand all Loading... |
344 | 326 |
345 TEST_F(FileSystemContextTest, CanServeURLRequest) { | 327 TEST_F(FileSystemContextTest, CanServeURLRequest) { |
346 scoped_refptr<ExternalMountPoints> external_mount_points( | 328 scoped_refptr<ExternalMountPoints> external_mount_points( |
347 ExternalMountPoints::CreateRefCounted()); | 329 ExternalMountPoints::CreateRefCounted()); |
348 scoped_refptr<FileSystemContext> context( | 330 scoped_refptr<FileSystemContext> context( |
349 CreateFileSystemContextForTest(external_mount_points.get())); | 331 CreateFileSystemContextForTest(external_mount_points.get())); |
350 | 332 |
351 // A request for a sandbox mount point should be served. | 333 // A request for a sandbox mount point should be served. |
352 FileSystemURL cracked_url = | 334 FileSystemURL cracked_url = |
353 context->CrackURL(CreateRawFileSystemURL("persistent", "pers_mount")); | 335 context->CrackURL(CreateRawFileSystemURL("persistent", "pers_mount")); |
354 EXPECT_EQ(fileapi::kFileSystemTypePersistent, cracked_url.mount_type()); | 336 EXPECT_EQ(storage::kFileSystemTypePersistent, cracked_url.mount_type()); |
355 EXPECT_TRUE(context->CanServeURLRequest(cracked_url)); | 337 EXPECT_TRUE(context->CanServeURLRequest(cracked_url)); |
356 | 338 |
357 // A request for an isolated mount point should NOT be served. | 339 // A request for an isolated mount point should NOT be served. |
358 std::string isolated_fs_name = "root"; | 340 std::string isolated_fs_name = "root"; |
359 std::string isolated_fs_id = | 341 std::string isolated_fs_id = |
360 IsolatedContext::GetInstance()->RegisterFileSystemForPath( | 342 IsolatedContext::GetInstance()->RegisterFileSystemForPath( |
361 fileapi::kFileSystemTypeNativeLocal, | 343 storage::kFileSystemTypeNativeLocal, |
362 std::string(), | 344 std::string(), |
363 base::FilePath(DRIVE FPL("/test/isolated/root")), | 345 base::FilePath(DRIVE FPL("/test/isolated/root")), |
364 &isolated_fs_name); | 346 &isolated_fs_name); |
365 cracked_url = context->CrackURL( | 347 cracked_url = context->CrackURL( |
366 CreateRawFileSystemURL("isolated", isolated_fs_id)); | 348 CreateRawFileSystemURL("isolated", isolated_fs_id)); |
367 EXPECT_EQ(fileapi::kFileSystemTypeIsolated, cracked_url.mount_type()); | 349 EXPECT_EQ(storage::kFileSystemTypeIsolated, cracked_url.mount_type()); |
368 EXPECT_FALSE(context->CanServeURLRequest(cracked_url)); | 350 EXPECT_FALSE(context->CanServeURLRequest(cracked_url)); |
369 | 351 |
370 // A request for an external mount point should be served. | 352 // A request for an external mount point should be served. |
371 const std::string kExternalMountName = "ext_mount"; | 353 const std::string kExternalMountName = "ext_mount"; |
372 ASSERT_TRUE(ExternalMountPoints::GetSystemInstance()->RegisterFileSystem( | 354 ASSERT_TRUE(ExternalMountPoints::GetSystemInstance()->RegisterFileSystem( |
373 kExternalMountName, fileapi::kFileSystemTypeDrive, | 355 kExternalMountName, |
| 356 storage::kFileSystemTypeDrive, |
374 FileSystemMountOption(), | 357 FileSystemMountOption(), |
375 base::FilePath())); | 358 base::FilePath())); |
376 cracked_url = context->CrackURL( | 359 cracked_url = context->CrackURL( |
377 CreateRawFileSystemURL("external", kExternalMountName)); | 360 CreateRawFileSystemURL("external", kExternalMountName)); |
378 EXPECT_EQ(fileapi::kFileSystemTypeExternal, cracked_url.mount_type()); | 361 EXPECT_EQ(storage::kFileSystemTypeExternal, cracked_url.mount_type()); |
379 EXPECT_TRUE(context->CanServeURLRequest(cracked_url)); | 362 EXPECT_TRUE(context->CanServeURLRequest(cracked_url)); |
380 | 363 |
381 ExternalMountPoints::GetSystemInstance()->RevokeFileSystem( | 364 ExternalMountPoints::GetSystemInstance()->RevokeFileSystem( |
382 kExternalMountName); | 365 kExternalMountName); |
383 IsolatedContext::GetInstance()->RevokeFileSystem(isolated_fs_id); | 366 IsolatedContext::GetInstance()->RevokeFileSystem(isolated_fs_id); |
384 } | 367 } |
385 | 368 |
386 } // namespace | 369 } // namespace |
387 | 370 |
388 } // namespace content | 371 } // namespace content |
OLD | NEW |