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/fileapi/external_mount_points.h" | 5 #include "webkit/fileapi/external_mount_points.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 namespace { | 23 namespace { |
24 | 24 |
25 TEST(ExternalMountPointsTest, AddMountPoint) { | 25 TEST(ExternalMountPointsTest, AddMountPoint) { |
26 scoped_refptr<fileapi::ExternalMountPoints> mount_points( | 26 scoped_refptr<fileapi::ExternalMountPoints> mount_points( |
27 fileapi::ExternalMountPoints::CreateRefCounted()); | 27 fileapi::ExternalMountPoints::CreateRefCounted()); |
28 | 28 |
29 struct TestCase { | 29 struct TestCase { |
30 // The mount point's name. | 30 // The mount point's name. |
31 const char* const name; | 31 const char* const name; |
32 // The mount point's path. | 32 // The mount point's path. |
33 const FilePath::CharType* const path; | 33 const base::FilePath::CharType* const path; |
34 // Whether the mount point registration should succeed. | 34 // Whether the mount point registration should succeed. |
35 bool success; | 35 bool success; |
36 // Path returned by GetRegisteredPath. NULL if the method is expected to | 36 // Path returned by GetRegisteredPath. NULL if the method is expected to |
37 // fail. | 37 // fail. |
38 const FilePath::CharType* const registered_path; | 38 const base::FilePath::CharType* const registered_path; |
39 }; | 39 }; |
40 | 40 |
41 const TestCase kTestCases[] = { | 41 const TestCase kTestCases[] = { |
42 // Valid mount point. | 42 // Valid mount point. |
43 { "test", DRIVE FPL("/foo/test"), true, DRIVE FPL("/foo/test") }, | 43 { "test", DRIVE FPL("/foo/test"), true, DRIVE FPL("/foo/test") }, |
44 // Valid mount point with only one path component. | 44 // Valid mount point with only one path component. |
45 { "bbb", DRIVE FPL("/bbb"), true, DRIVE FPL("/bbb") }, | 45 { "bbb", DRIVE FPL("/bbb"), true, DRIVE FPL("/bbb") }, |
46 // Existing mount point path is substring of the mount points path. | 46 // Existing mount point path is substring of the mount points path. |
47 { "test11", DRIVE FPL("/foo/test11"), true, DRIVE FPL("/foo/test11") }, | 47 { "test11", DRIVE FPL("/foo/test11"), true, DRIVE FPL("/foo/test11") }, |
48 // Path substring of an existing path. | 48 // Path substring of an existing path. |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 // Win separators, but relative path. | 104 // Win separators, but relative path. |
105 { "win2", DRIVE FPL("try\\separators\\win2"), false, NULL }, | 105 { "win2", DRIVE FPL("try\\separators\\win2"), false, NULL }, |
106 }; | 106 }; |
107 | 107 |
108 // Test adding mount points. | 108 // Test adding mount points. |
109 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) { | 109 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) { |
110 EXPECT_EQ(kTestCases[i].success, | 110 EXPECT_EQ(kTestCases[i].success, |
111 mount_points->RegisterFileSystem( | 111 mount_points->RegisterFileSystem( |
112 kTestCases[i].name, | 112 kTestCases[i].name, |
113 fileapi::kFileSystemTypeNativeLocal, | 113 fileapi::kFileSystemTypeNativeLocal, |
114 FilePath(kTestCases[i].path))) | 114 base::FilePath(kTestCases[i].path))) |
115 << "Adding mount point: " << kTestCases[i].name << " with path " | 115 << "Adding mount point: " << kTestCases[i].name << " with path " |
116 << kTestCases[i].path; | 116 << kTestCases[i].path; |
117 } | 117 } |
118 | 118 |
119 // Test that final mount point presence state is as expected. | 119 // Test that final mount point presence state is as expected. |
120 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) { | 120 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) { |
121 FilePath found_path; | 121 base::FilePath found_path; |
122 EXPECT_EQ(kTestCases[i].registered_path != NULL, | 122 EXPECT_EQ(kTestCases[i].registered_path != NULL, |
123 mount_points->GetRegisteredPath(kTestCases[i].name, &found_path)) | 123 mount_points->GetRegisteredPath(kTestCases[i].name, &found_path)) |
124 << "Test case: " << i; | 124 << "Test case: " << i; |
125 | 125 |
126 if (kTestCases[i].registered_path) { | 126 if (kTestCases[i].registered_path) { |
127 FilePath expected_path(kTestCases[i].registered_path); | 127 base::FilePath expected_path(kTestCases[i].registered_path); |
128 EXPECT_EQ(expected_path.NormalizePathSeparators(), found_path); | 128 EXPECT_EQ(expected_path.NormalizePathSeparators(), found_path); |
129 } | 129 } |
130 } | 130 } |
131 } | 131 } |
132 | 132 |
133 TEST(ExternalMountPointsTest, GetVirtualPath) { | 133 TEST(ExternalMountPointsTest, GetVirtualPath) { |
134 scoped_refptr<fileapi::ExternalMountPoints> mount_points( | 134 scoped_refptr<fileapi::ExternalMountPoints> mount_points( |
135 fileapi::ExternalMountPoints::CreateRefCounted()); | 135 fileapi::ExternalMountPoints::CreateRefCounted()); |
136 | 136 |
137 mount_points->RegisterFileSystem("c", | 137 mount_points->RegisterFileSystem("c", |
138 fileapi::kFileSystemTypeNativeLocal, | 138 fileapi::kFileSystemTypeNativeLocal, |
139 FilePath(DRIVE FPL("/a/b/c"))); | 139 base::FilePath(DRIVE FPL("/a/b/c"))); |
140 // Note that "/a/b/c" < "/a/b/c(1)" < "/a/b/c/". | 140 // Note that "/a/b/c" < "/a/b/c(1)" < "/a/b/c/". |
141 mount_points->RegisterFileSystem("c(1)", | 141 mount_points->RegisterFileSystem("c(1)", |
142 fileapi::kFileSystemTypeNativeLocal, | 142 fileapi::kFileSystemTypeNativeLocal, |
143 FilePath(DRIVE FPL("/a/b/c(1)"))); | 143 base::FilePath(DRIVE FPL("/a/b/c(1)"))); |
144 mount_points->RegisterFileSystem("x", | 144 mount_points->RegisterFileSystem("x", |
145 fileapi::kFileSystemTypeNativeLocal, | 145 fileapi::kFileSystemTypeNativeLocal, |
146 FilePath(DRIVE FPL("/z/y/x"))); | 146 base::FilePath(DRIVE FPL("/z/y/x"))); |
147 mount_points->RegisterFileSystem("o", | 147 mount_points->RegisterFileSystem("o", |
148 fileapi::kFileSystemTypeNativeLocal, | 148 fileapi::kFileSystemTypeNativeLocal, |
149 FilePath(DRIVE FPL("/m/n/o"))); | 149 base::FilePath(DRIVE FPL("/m/n/o"))); |
150 // A mount point whose name does not match its path base name. | 150 // A mount point whose name does not match its path base name. |
151 mount_points->RegisterFileSystem("mount", | 151 mount_points->RegisterFileSystem("mount", |
152 fileapi::kFileSystemTypeNativeLocal, | 152 fileapi::kFileSystemTypeNativeLocal, |
153 FilePath(DRIVE FPL("/root/foo"))); | 153 base::FilePath(DRIVE FPL("/root/foo"))); |
154 // A mount point with an empty path. | 154 // A mount point with an empty path. |
155 mount_points->RegisterFileSystem("empty_path", | 155 mount_points->RegisterFileSystem("empty_path", |
156 fileapi::kFileSystemTypeNativeLocal, | 156 fileapi::kFileSystemTypeNativeLocal, |
157 FilePath(FPL(""))); | 157 base::FilePath(FPL(""))); |
158 | 158 |
159 struct TestCase { | 159 struct TestCase { |
160 const FilePath::CharType* const local_path; | 160 const base::FilePath::CharType* const local_path; |
161 bool success; | 161 bool success; |
162 const FilePath::CharType* const virtual_path; | 162 const base::FilePath::CharType* const virtual_path; |
163 }; | 163 }; |
164 | 164 |
165 const TestCase kTestCases[] = { | 165 const TestCase kTestCases[] = { |
166 // Empty path. | 166 // Empty path. |
167 { FPL(""), false, FPL("") }, | 167 { FPL(""), false, FPL("") }, |
168 // No registered mount point (but is parent to a mount point). | 168 // No registered mount point (but is parent to a mount point). |
169 { DRIVE FPL("/a/b"), false, FPL("") }, | 169 { DRIVE FPL("/a/b"), false, FPL("") }, |
170 // No registered mount point (but is parent to a mount point). | 170 // No registered mount point (but is parent to a mount point). |
171 { DRIVE FPL("/z/y"), false, FPL("") }, | 171 { DRIVE FPL("/z/y"), false, FPL("") }, |
172 // No registered mount point (but is parent to a mount point). | 172 // No registered mount point (but is parent to a mount point). |
(...skipping 29 matching lines...) Expand all Loading... |
202 // separator's. | 202 // separator's. |
203 { DRIVE FPL("/a/b/c(1)/d/e"), true, FPL("c(1)/d/e") }, | 203 { DRIVE FPL("/a/b/c(1)/d/e"), true, FPL("c(1)/d/e") }, |
204 #if defined(FILE_PATH_USES_WIN_SEPARATORS) | 204 #if defined(FILE_PATH_USES_WIN_SEPARATORS) |
205 // Path with win separators mixed in. | 205 // Path with win separators mixed in. |
206 { DRIVE FPL("/a\\b\\c/d"), true, FPL("c/d") }, | 206 { DRIVE FPL("/a\\b\\c/d"), true, FPL("c/d") }, |
207 #endif | 207 #endif |
208 }; | 208 }; |
209 | 209 |
210 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) { | 210 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) { |
211 // Initialize virtual path with a value. | 211 // Initialize virtual path with a value. |
212 FilePath virtual_path(DRIVE FPL("/mount")); | 212 base::FilePath virtual_path(DRIVE FPL("/mount")); |
213 FilePath local_path(kTestCases[i].local_path); | 213 base::FilePath local_path(kTestCases[i].local_path); |
214 EXPECT_EQ(kTestCases[i].success, | 214 EXPECT_EQ(kTestCases[i].success, |
215 mount_points->GetVirtualPath(local_path, &virtual_path)) | 215 mount_points->GetVirtualPath(local_path, &virtual_path)) |
216 << "Resolving " << kTestCases[i].local_path; | 216 << "Resolving " << kTestCases[i].local_path; |
217 | 217 |
218 // There are no guarantees for |virtual_path| value if |GetVirtualPath| | 218 // There are no guarantees for |virtual_path| value if |GetVirtualPath| |
219 // fails. | 219 // fails. |
220 if (!kTestCases[i].success) | 220 if (!kTestCases[i].success) |
221 continue; | 221 continue; |
222 | 222 |
223 FilePath expected_virtual_path(kTestCases[i].virtual_path); | 223 base::FilePath expected_virtual_path(kTestCases[i].virtual_path); |
224 EXPECT_EQ(expected_virtual_path.NormalizePathSeparators(), virtual_path) | 224 EXPECT_EQ(expected_virtual_path.NormalizePathSeparators(), virtual_path) |
225 << "Resolving " << kTestCases[i].local_path; | 225 << "Resolving " << kTestCases[i].local_path; |
226 } | 226 } |
227 } | 227 } |
228 | 228 |
229 TEST(ExternalMountPointsTest, HandlesFileSystemMountType) { | 229 TEST(ExternalMountPointsTest, HandlesFileSystemMountType) { |
230 scoped_refptr<fileapi::ExternalMountPoints> mount_points( | 230 scoped_refptr<fileapi::ExternalMountPoints> mount_points( |
231 fileapi::ExternalMountPoints::CreateRefCounted()); | 231 fileapi::ExternalMountPoints::CreateRefCounted()); |
232 | 232 |
233 const GURL test_origin("http://chromium.org"); | 233 const GURL test_origin("http://chromium.org"); |
234 const FilePath test_path(FPL("/mount")); | 234 const base::FilePath test_path(FPL("/mount")); |
235 | 235 |
236 // Should handle External File System. | 236 // Should handle External File System. |
237 EXPECT_TRUE(mount_points->HandlesFileSystemMountType( | 237 EXPECT_TRUE(mount_points->HandlesFileSystemMountType( |
238 fileapi::kFileSystemTypeExternal)); | 238 fileapi::kFileSystemTypeExternal)); |
239 | 239 |
240 // Shouldn't handle the rest. | 240 // Shouldn't handle the rest. |
241 EXPECT_FALSE(mount_points->HandlesFileSystemMountType( | 241 EXPECT_FALSE(mount_points->HandlesFileSystemMountType( |
242 fileapi::kFileSystemTypeIsolated)); | 242 fileapi::kFileSystemTypeIsolated)); |
243 EXPECT_FALSE(mount_points->HandlesFileSystemMountType( | 243 EXPECT_FALSE(mount_points->HandlesFileSystemMountType( |
244 fileapi::kFileSystemTypeTemporary)); | 244 fileapi::kFileSystemTypeTemporary)); |
(...skipping 13 matching lines...) Expand all Loading... |
258 } | 258 } |
259 | 259 |
260 TEST(ExternalMountPointsTest, CreateCrackedFileSystemURL) { | 260 TEST(ExternalMountPointsTest, CreateCrackedFileSystemURL) { |
261 scoped_refptr<fileapi::ExternalMountPoints> mount_points( | 261 scoped_refptr<fileapi::ExternalMountPoints> mount_points( |
262 fileapi::ExternalMountPoints::CreateRefCounted()); | 262 fileapi::ExternalMountPoints::CreateRefCounted()); |
263 | 263 |
264 const GURL kTestOrigin("http://chromium.org"); | 264 const GURL kTestOrigin("http://chromium.org"); |
265 | 265 |
266 mount_points->RegisterFileSystem("c", | 266 mount_points->RegisterFileSystem("c", |
267 fileapi::kFileSystemTypeNativeLocal, | 267 fileapi::kFileSystemTypeNativeLocal, |
268 FilePath(DRIVE FPL("/a/b/c"))); | 268 base::FilePath(DRIVE FPL("/a/b/c"))); |
269 mount_points->RegisterFileSystem("c(1)", | 269 mount_points->RegisterFileSystem("c(1)", |
270 fileapi::kFileSystemTypeDrive, | 270 fileapi::kFileSystemTypeDrive, |
271 FilePath(DRIVE FPL("/a/b/c(1)"))); | 271 base::FilePath(DRIVE FPL("/a/b/c(1)"))); |
272 mount_points->RegisterFileSystem("empty_path", | 272 mount_points->RegisterFileSystem("empty_path", |
273 fileapi::kFileSystemTypeSyncable, | 273 fileapi::kFileSystemTypeSyncable, |
274 FilePath(FPL(""))); | 274 base::FilePath(FPL(""))); |
275 mount_points->RegisterFileSystem("mount", | 275 mount_points->RegisterFileSystem("mount", |
276 fileapi::kFileSystemTypeDrive, | 276 fileapi::kFileSystemTypeDrive, |
277 FilePath(DRIVE FPL("/root"))); | 277 base::FilePath(DRIVE FPL("/root"))); |
278 | 278 |
279 // Try cracking invalid GURL. | 279 // Try cracking invalid GURL. |
280 FileSystemURL invalid = mount_points->CrackURL(GURL("http://chromium.og")); | 280 FileSystemURL invalid = mount_points->CrackURL(GURL("http://chromium.og")); |
281 EXPECT_FALSE(invalid.is_valid()); | 281 EXPECT_FALSE(invalid.is_valid()); |
282 | 282 |
283 // Try cracking isolated path. | 283 // Try cracking isolated path. |
284 FileSystemURL isolated = mount_points->CreateCrackedFileSystemURL( | 284 FileSystemURL isolated = mount_points->CreateCrackedFileSystemURL( |
285 kTestOrigin, fileapi::kFileSystemTypeIsolated, FilePath(FPL("c"))); | 285 kTestOrigin, fileapi::kFileSystemTypeIsolated, base::FilePath(FPL("c"))); |
286 EXPECT_FALSE(isolated.is_valid()); | 286 EXPECT_FALSE(isolated.is_valid()); |
287 | 287 |
288 // Try native local which is not cracked. | 288 // Try native local which is not cracked. |
289 FileSystemURL native_local = mount_points->CreateCrackedFileSystemURL( | 289 FileSystemURL native_local = mount_points->CreateCrackedFileSystemURL( |
290 kTestOrigin, fileapi::kFileSystemTypeNativeLocal, FilePath(FPL("c"))); | 290 kTestOrigin, fileapi::kFileSystemTypeNativeLocal, base::FilePath(FPL("c"))
); |
291 EXPECT_FALSE(native_local.is_valid()); | 291 EXPECT_FALSE(native_local.is_valid()); |
292 | 292 |
293 struct TestCase { | 293 struct TestCase { |
294 const FilePath::CharType* const path; | 294 const base::FilePath::CharType* const path; |
295 bool expect_valid; | 295 bool expect_valid; |
296 fileapi::FileSystemType expect_type; | 296 fileapi::FileSystemType expect_type; |
297 const FilePath::CharType* const expect_path; | 297 const base::FilePath::CharType* const expect_path; |
298 const char* const expect_fs_id; | 298 const char* const expect_fs_id; |
299 }; | 299 }; |
300 | 300 |
301 const TestCase kTestCases[] = { | 301 const TestCase kTestCases[] = { |
302 { FPL("c/d/e"), | 302 { FPL("c/d/e"), |
303 true, fileapi::kFileSystemTypeNativeLocal, DRIVE FPL("/a/b/c/d/e"), "c" }, | 303 true, fileapi::kFileSystemTypeNativeLocal, DRIVE FPL("/a/b/c/d/e"), "c" }, |
304 { FPL("c(1)/d/e"), | 304 { FPL("c(1)/d/e"), |
305 true, fileapi::kFileSystemTypeDrive, DRIVE FPL("/a/b/c(1)/d/e"), "c(1)" }, | 305 true, fileapi::kFileSystemTypeDrive, DRIVE FPL("/a/b/c(1)/d/e"), "c(1)" }, |
306 { FPL("c(1)"), | 306 { FPL("c(1)"), |
307 true, fileapi::kFileSystemTypeDrive, DRIVE FPL("/a/b/c(1)"), "c(1)" }, | 307 true, fileapi::kFileSystemTypeDrive, DRIVE FPL("/a/b/c(1)"), "c(1)" }, |
(...skipping 28 matching lines...) Expand all Loading... |
336 true, fileapi::kFileSystemTypeNativeLocal, DRIVE FPL("/a/b/c/d/e"), "c" }, | 336 true, fileapi::kFileSystemTypeNativeLocal, DRIVE FPL("/a/b/c/d/e"), "c" }, |
337 { FPL("mount\\a\\b"), | 337 { FPL("mount\\a\\b"), |
338 true, fileapi::kFileSystemTypeDrive, DRIVE FPL("/root/a/b"), "mount" }, | 338 true, fileapi::kFileSystemTypeDrive, DRIVE FPL("/root/a/b"), "mount" }, |
339 #endif | 339 #endif |
340 }; | 340 }; |
341 | 341 |
342 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) { | 342 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) { |
343 FileSystemURL cracked = mount_points->CreateCrackedFileSystemURL( | 343 FileSystemURL cracked = mount_points->CreateCrackedFileSystemURL( |
344 kTestOrigin, | 344 kTestOrigin, |
345 fileapi::kFileSystemTypeExternal, | 345 fileapi::kFileSystemTypeExternal, |
346 FilePath(kTestCases[i].path)); | 346 base::FilePath(kTestCases[i].path)); |
347 | 347 |
348 EXPECT_EQ(kTestCases[i].expect_valid, cracked.is_valid()) | 348 EXPECT_EQ(kTestCases[i].expect_valid, cracked.is_valid()) |
349 << "Test case index: " << i; | 349 << "Test case index: " << i; |
350 | 350 |
351 if (!kTestCases[i].expect_valid) | 351 if (!kTestCases[i].expect_valid) |
352 continue; | 352 continue; |
353 | 353 |
354 EXPECT_EQ(kTestOrigin, cracked.origin()) | 354 EXPECT_EQ(kTestOrigin, cracked.origin()) |
355 << "Test case index: " << i; | 355 << "Test case index: " << i; |
356 EXPECT_EQ(kTestCases[i].expect_type, cracked.type()) | 356 EXPECT_EQ(kTestCases[i].expect_type, cracked.type()) |
357 << "Test case index: " << i; | 357 << "Test case index: " << i; |
358 EXPECT_EQ(FilePath(kTestCases[i].expect_path).NormalizePathSeparators(), | 358 EXPECT_EQ(base::FilePath(kTestCases[i].expect_path).NormalizePathSeparators(
), |
359 cracked.path()) | 359 cracked.path()) |
360 << "Test case index: " << i; | 360 << "Test case index: " << i; |
361 EXPECT_EQ(FilePath(kTestCases[i].path).NormalizePathSeparators(), | 361 EXPECT_EQ(base::FilePath(kTestCases[i].path).NormalizePathSeparators(), |
362 cracked.virtual_path()) | 362 cracked.virtual_path()) |
363 << "Test case index: " << i; | 363 << "Test case index: " << i; |
364 EXPECT_EQ(kTestCases[i].expect_fs_id, cracked.filesystem_id()) | 364 EXPECT_EQ(kTestCases[i].expect_fs_id, cracked.filesystem_id()) |
365 << "Test case index: " << i; | 365 << "Test case index: " << i; |
366 EXPECT_EQ(fileapi::kFileSystemTypeExternal, cracked.mount_type()) | 366 EXPECT_EQ(fileapi::kFileSystemTypeExternal, cracked.mount_type()) |
367 << "Test case index: " << i; | 367 << "Test case index: " << i; |
368 } | 368 } |
369 } | 369 } |
370 | 370 |
371 TEST(ExternalMountPointsTest, CrackVirtualPath) { | 371 TEST(ExternalMountPointsTest, CrackVirtualPath) { |
372 scoped_refptr<fileapi::ExternalMountPoints> mount_points( | 372 scoped_refptr<fileapi::ExternalMountPoints> mount_points( |
373 fileapi::ExternalMountPoints::CreateRefCounted()); | 373 fileapi::ExternalMountPoints::CreateRefCounted()); |
374 | 374 |
375 const GURL kTestOrigin("http://chromium.org"); | 375 const GURL kTestOrigin("http://chromium.org"); |
376 | 376 |
377 mount_points->RegisterFileSystem("c", | 377 mount_points->RegisterFileSystem("c", |
378 fileapi::kFileSystemTypeNativeLocal, | 378 fileapi::kFileSystemTypeNativeLocal, |
379 FilePath(DRIVE FPL("/a/b/c"))); | 379 base::FilePath(DRIVE FPL("/a/b/c"))); |
380 mount_points->RegisterFileSystem("c(1)", | 380 mount_points->RegisterFileSystem("c(1)", |
381 fileapi::kFileSystemTypeDrive, | 381 fileapi::kFileSystemTypeDrive, |
382 FilePath(DRIVE FPL("/a/b/c(1)"))); | 382 base::FilePath(DRIVE FPL("/a/b/c(1)"))); |
383 mount_points->RegisterFileSystem("empty_path", | 383 mount_points->RegisterFileSystem("empty_path", |
384 fileapi::kFileSystemTypeSyncable, | 384 fileapi::kFileSystemTypeSyncable, |
385 FilePath(FPL(""))); | 385 base::FilePath(FPL(""))); |
386 mount_points->RegisterFileSystem("mount", | 386 mount_points->RegisterFileSystem("mount", |
387 fileapi::kFileSystemTypeDrive, | 387 fileapi::kFileSystemTypeDrive, |
388 FilePath(DRIVE FPL("/root"))); | 388 base::FilePath(DRIVE FPL("/root"))); |
389 | 389 |
390 struct TestCase { | 390 struct TestCase { |
391 const FilePath::CharType* const path; | 391 const base::FilePath::CharType* const path; |
392 bool expect_valid; | 392 bool expect_valid; |
393 fileapi::FileSystemType expect_type; | 393 fileapi::FileSystemType expect_type; |
394 const FilePath::CharType* const expect_path; | 394 const base::FilePath::CharType* const expect_path; |
395 const char* const expect_name; | 395 const char* const expect_name; |
396 }; | 396 }; |
397 | 397 |
398 const TestCase kTestCases[] = { | 398 const TestCase kTestCases[] = { |
399 { FPL("c/d/e"), | 399 { FPL("c/d/e"), |
400 true, fileapi::kFileSystemTypeNativeLocal, DRIVE FPL("/a/b/c/d/e"), "c" }, | 400 true, fileapi::kFileSystemTypeNativeLocal, DRIVE FPL("/a/b/c/d/e"), "c" }, |
401 { FPL("c(1)/d/e"), | 401 { FPL("c(1)/d/e"), |
402 true, fileapi::kFileSystemTypeDrive, DRIVE FPL("/a/b/c(1)/d/e"), "c(1)" }, | 402 true, fileapi::kFileSystemTypeDrive, DRIVE FPL("/a/b/c(1)/d/e"), "c(1)" }, |
403 { FPL("c(1)"), | 403 { FPL("c(1)"), |
404 true, fileapi::kFileSystemTypeDrive, DRIVE FPL("/a/b/c(1)"), "c(1)" }, | 404 true, fileapi::kFileSystemTypeDrive, DRIVE FPL("/a/b/c(1)"), "c(1)" }, |
(...skipping 27 matching lines...) Expand all Loading... |
432 { FPL("c/d\\e"), | 432 { FPL("c/d\\e"), |
433 true, fileapi::kFileSystemTypeNativeLocal, DRIVE FPL("/a/b/c/d/e"), "c" }, | 433 true, fileapi::kFileSystemTypeNativeLocal, DRIVE FPL("/a/b/c/d/e"), "c" }, |
434 { FPL("mount\\a\\b"), | 434 { FPL("mount\\a\\b"), |
435 true, fileapi::kFileSystemTypeDrive, DRIVE FPL("/root/a/b"), "mount" }, | 435 true, fileapi::kFileSystemTypeDrive, DRIVE FPL("/root/a/b"), "mount" }, |
436 #endif | 436 #endif |
437 }; | 437 }; |
438 | 438 |
439 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) { | 439 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) { |
440 std::string cracked_name; | 440 std::string cracked_name; |
441 fileapi::FileSystemType cracked_type; | 441 fileapi::FileSystemType cracked_type; |
442 FilePath cracked_path; | 442 base::FilePath cracked_path; |
443 EXPECT_EQ(kTestCases[i].expect_valid, | 443 EXPECT_EQ(kTestCases[i].expect_valid, |
444 mount_points->CrackVirtualPath(FilePath(kTestCases[i].path), | 444 mount_points->CrackVirtualPath(base::FilePath(kTestCases[i].path), |
445 &cracked_name, &cracked_type, &cracked_path)) | 445 &cracked_name, &cracked_type, &cracked_path)) |
446 << "Test case index: " << i; | 446 << "Test case index: " << i; |
447 | 447 |
448 if (!kTestCases[i].expect_valid) | 448 if (!kTestCases[i].expect_valid) |
449 continue; | 449 continue; |
450 | 450 |
451 EXPECT_EQ(kTestCases[i].expect_type, cracked_type) | 451 EXPECT_EQ(kTestCases[i].expect_type, cracked_type) |
452 << "Test case index: " << i; | 452 << "Test case index: " << i; |
453 EXPECT_EQ(FilePath(kTestCases[i].expect_path).NormalizePathSeparators(), | 453 EXPECT_EQ(base::FilePath(kTestCases[i].expect_path).NormalizePathSeparators(
), |
454 cracked_path) | 454 cracked_path) |
455 << "Test case index: " << i; | 455 << "Test case index: " << i; |
456 EXPECT_EQ(kTestCases[i].expect_name, cracked_name) | 456 EXPECT_EQ(kTestCases[i].expect_name, cracked_name) |
457 << "Test case index: " << i; | 457 << "Test case index: " << i; |
458 } | 458 } |
459 } | 459 } |
460 | 460 |
461 } // namespace | 461 } // namespace |
462 | 462 |
OLD | NEW |