OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
11 #include "webkit/browser/fileapi/external_mount_points.h" | 12 #include "webkit/browser/fileapi/external_mount_points.h" |
12 #include "webkit/browser/fileapi/file_system_backend.h" | 13 #include "webkit/browser/fileapi/file_system_backend.h" |
13 #include "webkit/browser/fileapi/isolated_context.h" | 14 #include "webkit/browser/fileapi/isolated_context.h" |
14 #include "webkit/browser/fileapi/mock_file_system_options.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 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 base::FilePath(DRIVE FPL("/test/sys/")))); | 114 base::FilePath(DRIVE FPL("/test/sys/")))); |
115 | 115 |
116 FileSystemURL cracked_isolated = file_system_context->CrackURL( | 116 FileSystemURL cracked_isolated = file_system_context->CrackURL( |
117 CreateRawFileSystemURL("isolated", isolated_id)); | 117 CreateRawFileSystemURL("isolated", isolated_id)); |
118 | 118 |
119 ExpectFileSystemURLMatches( | 119 ExpectFileSystemURLMatches( |
120 cracked_isolated, | 120 cracked_isolated, |
121 GURL(kTestOrigin), | 121 GURL(kTestOrigin), |
122 kFileSystemTypeIsolated, | 122 kFileSystemTypeIsolated, |
123 kFileSystemTypeNativeLocal, | 123 kFileSystemTypeNativeLocal, |
124 base::FilePath(DRIVE FPL("/test/isolated/root/file")).NormalizePathSeparat
ors(), | 124 base::FilePath( |
| 125 DRIVE FPL("/test/isolated/root/file")).NormalizePathSeparators(), |
125 base::FilePath::FromUTF8Unsafe(isolated_id).Append(FPL("root/file")). | 126 base::FilePath::FromUTF8Unsafe(isolated_id).Append(FPL("root/file")). |
126 NormalizePathSeparators(), | 127 NormalizePathSeparators(), |
127 isolated_id); | 128 isolated_id); |
128 | 129 |
129 FileSystemURL cracked_external = file_system_context->CrackURL( | 130 FileSystemURL cracked_external = file_system_context->CrackURL( |
130 CreateRawFileSystemURL("external", "system")); | 131 CreateRawFileSystemURL("external", "system")); |
131 | 132 |
132 ExpectFileSystemURLMatches( | 133 ExpectFileSystemURLMatches( |
133 cracked_external, | 134 cracked_external, |
134 GURL(kTestOrigin), | 135 GURL(kTestOrigin), |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 { | 285 { |
285 "invalid", "external", false /* is_valid */, | 286 "invalid", "external", false /* is_valid */, |
286 // The rest of values will be ignored. | 287 // The rest of values will be ignored. |
287 kFileSystemTypeUnknown, kFileSystemTypeUnknown, FPL(""), | 288 kFileSystemTypeUnknown, kFileSystemTypeUnknown, FPL(""), |
288 std::string() | 289 std::string() |
289 }, | 290 }, |
290 }; | 291 }; |
291 | 292 |
292 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) { | 293 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) { |
293 const base::FilePath virtual_path = | 294 const base::FilePath virtual_path = |
294 base::FilePath::FromUTF8Unsafe(kTestCases[i].root).Append(kVirtualPathNo
Root); | 295 base::FilePath::FromUTF8Unsafe( |
| 296 kTestCases[i].root).Append(kVirtualPathNoRoot); |
295 | 297 |
296 GURL raw_url = | 298 GURL raw_url = |
297 CreateRawFileSystemURL(kTestCases[i].type_str, kTestCases[i].root); | 299 CreateRawFileSystemURL(kTestCases[i].type_str, kTestCases[i].root); |
298 FileSystemURL cracked_url = file_system_context->CrackURL(raw_url); | 300 FileSystemURL cracked_url = file_system_context->CrackURL(raw_url); |
299 | 301 |
300 SCOPED_TRACE(testing::Message() << "Test case " << i << ": " | 302 SCOPED_TRACE(testing::Message() << "Test case " << i << ": " |
301 << "Cracking URL: " << raw_url); | 303 << "Cracking URL: " << raw_url); |
302 | 304 |
303 EXPECT_EQ(kTestCases[i].expect_is_valid, cracked_url.is_valid()); | 305 EXPECT_EQ(kTestCases[i].expect_is_valid, cracked_url.is_valid()); |
304 if (!kTestCases[i].expect_is_valid) | 306 if (!kTestCases[i].expect_is_valid) |
(...skipping 13 matching lines...) Expand all Loading... |
318 base::FilePath(DRIVE FPL("/test/isolated/root"))); | 320 base::FilePath(DRIVE FPL("/test/isolated/root"))); |
319 ExternalMountPoints::GetSystemInstance()->RevokeFileSystem("system"); | 321 ExternalMountPoints::GetSystemInstance()->RevokeFileSystem("system"); |
320 ExternalMountPoints::GetSystemInstance()->RevokeFileSystem("ext"); | 322 ExternalMountPoints::GetSystemInstance()->RevokeFileSystem("ext"); |
321 ExternalMountPoints::GetSystemInstance()->RevokeFileSystem( | 323 ExternalMountPoints::GetSystemInstance()->RevokeFileSystem( |
322 kIsolatedFileSystemID); | 324 kIsolatedFileSystemID); |
323 } | 325 } |
324 | 326 |
325 } // namespace | 327 } // namespace |
326 | 328 |
327 } // namespace fileapi | 329 } // namespace fileapi |
OLD | NEW |