| 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/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 "webkit/browser/fileapi/external_mount_points.h" |
| 15 #include "webkit/browser/fileapi/file_system_backend.h" | 15 #include "webkit/browser/fileapi/file_system_backend.h" |
| 16 #include "webkit/browser/fileapi/isolated_context.h" | 16 #include "webkit/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 fileapi::ExternalMountPoints; |
| 27 using fileapi::FileSystemBackend; | 27 using fileapi::FileSystemBackend; |
| 28 using fileapi::FileSystemContext; | 28 using fileapi::FileSystemContext; |
| 29 using fileapi::FileSystemMountOption; | 29 using fileapi::FileSystemMountOption; |
| 30 using fileapi::FileSystemType; | |
| 31 using fileapi::FileSystemURL; | 30 using fileapi::FileSystemURL; |
| 32 using fileapi::IsolatedContext; | 31 using fileapi::IsolatedContext; |
| 33 | 32 |
| 34 namespace content { | 33 namespace content { |
| 35 | 34 |
| 36 namespace { | 35 namespace { |
| 37 | 36 |
| 38 const char kTestOrigin[] = "http://chromium.org/"; | 37 const char kTestOrigin[] = "http://chromium.org/"; |
| 39 | 38 |
| 40 GURL CreateRawFileSystemURL(const std::string& type_str, | 39 GURL CreateRawFileSystemURL(const std::string& type_str, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 mock_quota_manager_->proxy(), | 73 mock_quota_manager_->proxy(), |
| 75 ScopedVector<FileSystemBackend>(), | 74 ScopedVector<FileSystemBackend>(), |
| 76 std::vector<fileapi::URLRequestAutoMountHandler>(), | 75 std::vector<fileapi::URLRequestAutoMountHandler>(), |
| 77 data_dir_.path(), | 76 data_dir_.path(), |
| 78 CreateAllowFileAccessOptions()); | 77 CreateAllowFileAccessOptions()); |
| 79 } | 78 } |
| 80 | 79 |
| 81 // Verifies a *valid* filesystem url has expected values. | 80 // Verifies a *valid* filesystem url has expected values. |
| 82 void ExpectFileSystemURLMatches(const FileSystemURL& url, | 81 void ExpectFileSystemURLMatches(const FileSystemURL& url, |
| 83 const GURL& expect_origin, | 82 const GURL& expect_origin, |
| 84 FileSystemType expect_mount_type, | 83 fileapi::FileSystemType expect_mount_type, |
| 85 FileSystemType expect_type, | 84 fileapi::FileSystemType expect_type, |
| 86 const base::FilePath& expect_path, | 85 const base::FilePath& expect_path, |
| 87 const base::FilePath& expect_virtual_path, | 86 const base::FilePath& expect_virtual_path, |
| 88 const std::string& expect_filesystem_id) { | 87 const std::string& expect_filesystem_id) { |
| 89 EXPECT_TRUE(url.is_valid()); | 88 EXPECT_TRUE(url.is_valid()); |
| 90 | 89 |
| 91 EXPECT_EQ(expect_origin, url.origin()); | 90 EXPECT_EQ(expect_origin, url.origin()); |
| 92 EXPECT_EQ(expect_mount_type, url.mount_type()); | 91 EXPECT_EQ(expect_mount_type, url.mount_type()); |
| 93 EXPECT_EQ(expect_type, url.type()); | 92 EXPECT_EQ(expect_type, url.type()); |
| 94 EXPECT_EQ(expect_path, url.path()); | 93 EXPECT_EQ(expect_path, url.path()); |
| 95 EXPECT_EQ(expect_virtual_path, url.virtual_path()); | 94 EXPECT_EQ(expect_virtual_path, url.virtual_path()); |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 const GURL kTestOrigin = GURL("http://chromium.org/"); | 234 const GURL kTestOrigin = GURL("http://chromium.org/"); |
| 236 const base::FilePath kVirtualPathNoRoot = base::FilePath(FPL("root/file")); | 235 const base::FilePath kVirtualPathNoRoot = base::FilePath(FPL("root/file")); |
| 237 | 236 |
| 238 struct TestCase { | 237 struct TestCase { |
| 239 // Test case values. | 238 // Test case values. |
| 240 std::string root; | 239 std::string root; |
| 241 std::string type_str; | 240 std::string type_str; |
| 242 | 241 |
| 243 // Expected test results. | 242 // Expected test results. |
| 244 bool expect_is_valid; | 243 bool expect_is_valid; |
| 245 FileSystemType expect_mount_type; | 244 fileapi::FileSystemType expect_mount_type; |
| 246 FileSystemType expect_type; | 245 fileapi::FileSystemType expect_type; |
| 247 const base::FilePath::CharType* expect_path; | 246 const base::FilePath::CharType* expect_path; |
| 248 std::string expect_filesystem_id; | 247 std::string expect_filesystem_id; |
| 249 }; | 248 }; |
| 250 | 249 |
| 251 const TestCase kTestCases[] = { | 250 const TestCase kTestCases[] = { |
| 252 // Following should not be handled by the url crackers: | 251 // Following should not be handled by the url crackers: |
| 253 { | 252 { |
| 254 "pers_mount", "persistent", true /* is_valid */, | 253 "pers_mount", "persistent", true /* is_valid */, |
| 255 fileapi::kFileSystemTypePersistent, fileapi::kFileSystemTypePersistent, | 254 fileapi::kFileSystemTypePersistent, fileapi::kFileSystemTypePersistent, |
| 256 FPL("pers_mount/root/file"), | 255 FPL("pers_mount/root/file"), |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 EXPECT_TRUE(context->CanServeURLRequest(cracked_url)); | 376 EXPECT_TRUE(context->CanServeURLRequest(cracked_url)); |
| 378 | 377 |
| 379 ExternalMountPoints::GetSystemInstance()->RevokeFileSystem( | 378 ExternalMountPoints::GetSystemInstance()->RevokeFileSystem( |
| 380 kExternalMountName); | 379 kExternalMountName); |
| 381 IsolatedContext::GetInstance()->RevokeFileSystem(isolated_fs_id); | 380 IsolatedContext::GetInstance()->RevokeFileSystem(isolated_fs_id); |
| 382 } | 381 } |
| 383 | 382 |
| 384 } // namespace | 383 } // namespace |
| 385 | 384 |
| 386 } // namespace content | 385 } // namespace content |
| OLD | NEW |