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