OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "webkit/browser/fileapi/file_system_url.h" | 10 #include "webkit/browser/fileapi/file_system_url.h" |
11 #include "webkit/browser/fileapi/isolated_context.h" | 11 #include "webkit/browser/fileapi/isolated_context.h" |
12 | 12 |
13 #define FPL(x) FILE_PATH_LITERAL(x) | 13 #define FPL(x) FILE_PATH_LITERAL(x) |
14 | 14 |
15 #if defined(FILE_PATH_USES_DRIVE_LETTERS) | 15 #if defined(FILE_PATH_USES_DRIVE_LETTERS) |
16 #define DRIVE FPL("C:") | 16 #define DRIVE FPL("C:") |
17 #else | 17 #else |
18 #define DRIVE | 18 #define DRIVE |
19 #endif | 19 #endif |
20 | 20 |
21 using fileapi::FileSystemMountOption; | 21 using fileapi::FileSystemMountOption; |
22 using fileapi::FileSystemType; | |
23 using fileapi::FileSystemURL; | 22 using fileapi::FileSystemURL; |
24 using fileapi::IsolatedContext; | 23 using fileapi::IsolatedContext; |
25 using fileapi::kFileSystemTypeDragged; | 24 using fileapi::kFileSystemTypeDragged; |
26 using fileapi::kFileSystemTypeIsolated; | 25 using fileapi::kFileSystemTypeIsolated; |
27 using fileapi::kFileSystemTypeNativeLocal; | 26 using fileapi::kFileSystemTypeNativeLocal; |
28 | 27 |
29 namespace content { | 28 namespace content { |
30 | 29 |
31 typedef IsolatedContext::MountPointInfo FileInfo; | 30 typedef IsolatedContext::MountPointInfo FileInfo; |
32 | 31 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 } | 95 } |
97 | 96 |
98 // See if the name of each registered kTestPaths (that is what we | 97 // See if the name of each registered kTestPaths (that is what we |
99 // register in SetUp() by RegisterDraggedFileSystem) is properly cracked as | 98 // register in SetUp() by RegisterDraggedFileSystem) is properly cracked as |
100 // a valid virtual path in the isolated filesystem. | 99 // a valid virtual path in the isolated filesystem. |
101 for (size_t i = 0; i < arraysize(kTestPaths); ++i) { | 100 for (size_t i = 0; i < arraysize(kTestPaths); ++i) { |
102 base::FilePath virtual_path = isolated_context()->CreateVirtualRootPath(id_) | 101 base::FilePath virtual_path = isolated_context()->CreateVirtualRootPath(id_) |
103 .AppendASCII(names_[i]); | 102 .AppendASCII(names_[i]); |
104 std::string cracked_id; | 103 std::string cracked_id; |
105 base::FilePath cracked_path; | 104 base::FilePath cracked_path; |
106 FileSystemType cracked_type; | 105 fileapi::FileSystemType cracked_type; |
107 FileSystemMountOption cracked_option; | 106 FileSystemMountOption cracked_option; |
108 ASSERT_TRUE(isolated_context()->CrackVirtualPath( | 107 ASSERT_TRUE(isolated_context()->CrackVirtualPath( |
109 virtual_path, &cracked_id, &cracked_type, &cracked_path, | 108 virtual_path, &cracked_id, &cracked_type, &cracked_path, |
110 &cracked_option)); | 109 &cracked_option)); |
111 ASSERT_EQ(kTestPaths[i].NormalizePathSeparators().value(), | 110 ASSERT_EQ(kTestPaths[i].NormalizePathSeparators().value(), |
112 cracked_path.value()); | 111 cracked_path.value()); |
113 ASSERT_EQ(id_, cracked_id); | 112 ASSERT_EQ(id_, cracked_id); |
114 ASSERT_EQ(kFileSystemTypeDragged, cracked_type); | 113 ASSERT_EQ(kFileSystemTypeDragged, cracked_type); |
115 } | 114 } |
116 | 115 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 | 193 |
195 for (size_t i = 0; i < arraysize(kTestPaths); ++i) { | 194 for (size_t i = 0; i < arraysize(kTestPaths); ++i) { |
196 for (size_t j = 0; j < ARRAYSIZE_UNSAFE(relatives); ++j) { | 195 for (size_t j = 0; j < ARRAYSIZE_UNSAFE(relatives); ++j) { |
197 SCOPED_TRACE(testing::Message() << "Testing " | 196 SCOPED_TRACE(testing::Message() << "Testing " |
198 << kTestPaths[i].value() << " " << relatives[j].path); | 197 << kTestPaths[i].value() << " " << relatives[j].path); |
199 base::FilePath virtual_path = | 198 base::FilePath virtual_path = |
200 isolated_context()->CreateVirtualRootPath(id_).AppendASCII( | 199 isolated_context()->CreateVirtualRootPath(id_).AppendASCII( |
201 names_[i]).Append(relatives[j].path); | 200 names_[i]).Append(relatives[j].path); |
202 std::string cracked_id; | 201 std::string cracked_id; |
203 base::FilePath cracked_path; | 202 base::FilePath cracked_path; |
204 FileSystemType cracked_type; | 203 fileapi::FileSystemType cracked_type; |
205 FileSystemMountOption cracked_option; | 204 FileSystemMountOption cracked_option; |
206 if (!relatives[j].valid) { | 205 if (!relatives[j].valid) { |
207 ASSERT_FALSE(isolated_context()->CrackVirtualPath( | 206 ASSERT_FALSE(isolated_context()->CrackVirtualPath( |
208 virtual_path, &cracked_id, &cracked_type, &cracked_path, | 207 virtual_path, &cracked_id, &cracked_type, &cracked_path, |
209 &cracked_option)); | 208 &cracked_option)); |
210 continue; | 209 continue; |
211 } | 210 } |
212 ASSERT_TRUE(isolated_context()->CrackVirtualPath( | 211 ASSERT_TRUE(isolated_context()->CrackVirtualPath( |
213 virtual_path, &cracked_id, &cracked_type, &cracked_path, | 212 virtual_path, &cracked_id, &cracked_type, &cracked_path, |
214 &cracked_option)); | 213 &cracked_option)); |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 std::string cracked_id; | 343 std::string cracked_id; |
345 base::FilePath cracked_path; | 344 base::FilePath cracked_path; |
346 FileSystemMountOption cracked_option; | 345 FileSystemMountOption cracked_option; |
347 ASSERT_TRUE(isolated_context()->CrackVirtualPath( | 346 ASSERT_TRUE(isolated_context()->CrackVirtualPath( |
348 whole_virtual_path, &cracked_id, NULL, &cracked_path, &cracked_option)); | 347 whole_virtual_path, &cracked_id, NULL, &cracked_path, &cracked_option)); |
349 ASSERT_EQ(database_fsid, cracked_id); | 348 ASSERT_EQ(database_fsid, cracked_id); |
350 ASSERT_EQ(test_virtual_path, cracked_path); | 349 ASSERT_EQ(test_virtual_path, cracked_path); |
351 } | 350 } |
352 | 351 |
353 } // namespace content | 352 } // namespace content |
OLD | NEW |