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 "webkit/browser/fileapi/external_mount_points.h" | 5 #include "webkit/browser/fileapi/external_mount_points.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 { FPL("c/d\\e"), | 449 { FPL("c/d\\e"), |
450 true, fileapi::kFileSystemTypeNativeLocal, DRIVE FPL("/a/b/c/d/e"), "c" }, | 450 true, fileapi::kFileSystemTypeNativeLocal, DRIVE FPL("/a/b/c/d/e"), "c" }, |
451 { FPL("mount\\a\\b"), | 451 { FPL("mount\\a\\b"), |
452 true, fileapi::kFileSystemTypeDrive, DRIVE FPL("/root/a/b"), "mount" }, | 452 true, fileapi::kFileSystemTypeDrive, DRIVE FPL("/root/a/b"), "mount" }, |
453 #endif | 453 #endif |
454 }; | 454 }; |
455 | 455 |
456 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) { | 456 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) { |
457 std::string cracked_name; | 457 std::string cracked_name; |
458 fileapi::FileSystemType cracked_type; | 458 fileapi::FileSystemType cracked_type; |
| 459 std::string cracked_id; |
459 base::FilePath cracked_path; | 460 base::FilePath cracked_path; |
460 fileapi::FileSystemMountOption cracked_option; | 461 fileapi::FileSystemMountOption cracked_option; |
461 EXPECT_EQ(kTestCases[i].expect_valid, | 462 EXPECT_EQ(kTestCases[i].expect_valid, |
462 mount_points->CrackVirtualPath(base::FilePath(kTestCases[i].path), | 463 mount_points->CrackVirtualPath(base::FilePath(kTestCases[i].path), |
463 &cracked_name, &cracked_type, &cracked_path, &cracked_option)) | 464 &cracked_name, &cracked_type, &cracked_id, &cracked_path, |
| 465 &cracked_option)) |
464 << "Test case index: " << i; | 466 << "Test case index: " << i; |
465 | 467 |
466 if (!kTestCases[i].expect_valid) | 468 if (!kTestCases[i].expect_valid) |
467 continue; | 469 continue; |
468 | 470 |
469 EXPECT_EQ(kTestCases[i].expect_type, cracked_type) | 471 EXPECT_EQ(kTestCases[i].expect_type, cracked_type) |
470 << "Test case index: " << i; | 472 << "Test case index: " << i; |
471 EXPECT_EQ(base::FilePath( | 473 EXPECT_EQ(base::FilePath( |
472 kTestCases[i].expect_path).NormalizePathSeparators(), cracked_path) | 474 kTestCases[i].expect_path).NormalizePathSeparators(), cracked_path) |
473 << "Test case index: " << i; | 475 << "Test case index: " << i; |
474 EXPECT_EQ(kTestCases[i].expect_name, cracked_name) | 476 EXPECT_EQ(kTestCases[i].expect_name, cracked_name) |
475 << "Test case index: " << i; | 477 << "Test case index: " << i; |
| 478 // As of now we don't mount other filesystems with non-empty filesystem_id |
| 479 // onto external mount points. |
| 480 EXPECT_TRUE(cracked_id.empty()) << "Test case index: " << i; |
476 } | 481 } |
477 } | 482 } |
478 | 483 |
479 TEST(ExternalMountPointsTest, MountOption) { | 484 TEST(ExternalMountPointsTest, MountOption) { |
480 scoped_refptr<fileapi::ExternalMountPoints> mount_points( | 485 scoped_refptr<fileapi::ExternalMountPoints> mount_points( |
481 fileapi::ExternalMountPoints::CreateRefCounted()); | 486 fileapi::ExternalMountPoints::CreateRefCounted()); |
482 | 487 |
483 mount_points->RegisterFileSystem( | 488 mount_points->RegisterFileSystem( |
484 "nosync", | 489 "nosync", |
485 fileapi::kFileSystemTypeNativeLocal, | 490 fileapi::kFileSystemTypeNativeLocal, |
486 fileapi::FileSystemMountOption(fileapi::COPY_SYNC_OPTION_NO_SYNC), | 491 fileapi::FileSystemMountOption(fileapi::COPY_SYNC_OPTION_NO_SYNC), |
487 base::FilePath(DRIVE FPL("/nosync"))); | 492 base::FilePath(DRIVE FPL("/nosync"))); |
488 mount_points->RegisterFileSystem( | 493 mount_points->RegisterFileSystem( |
489 "sync", | 494 "sync", |
490 fileapi::kFileSystemTypeNativeLocal, | 495 fileapi::kFileSystemTypeNativeLocal, |
491 fileapi::FileSystemMountOption(fileapi::COPY_SYNC_OPTION_SYNC), | 496 fileapi::FileSystemMountOption(fileapi::COPY_SYNC_OPTION_SYNC), |
492 base::FilePath(DRIVE FPL("/sync"))); | 497 base::FilePath(DRIVE FPL("/sync"))); |
493 | 498 |
494 std::string name; | 499 std::string name; |
495 fileapi::FileSystemType type; | 500 fileapi::FileSystemType type; |
| 501 std::string cracked_id; |
496 fileapi::FileSystemMountOption option; | 502 fileapi::FileSystemMountOption option; |
497 base::FilePath path; | 503 base::FilePath path; |
498 EXPECT_TRUE(mount_points->CrackVirtualPath( | 504 EXPECT_TRUE(mount_points->CrackVirtualPath( |
499 base::FilePath(FPL("nosync/file")), &name, &type, &path, &option)); | 505 base::FilePath(FPL("nosync/file")), &name, &type, &cracked_id, &path, |
| 506 &option)); |
500 EXPECT_EQ(fileapi::COPY_SYNC_OPTION_NO_SYNC, option.copy_sync_option()); | 507 EXPECT_EQ(fileapi::COPY_SYNC_OPTION_NO_SYNC, option.copy_sync_option()); |
501 EXPECT_TRUE(mount_points->CrackVirtualPath( | 508 EXPECT_TRUE(mount_points->CrackVirtualPath( |
502 base::FilePath(FPL("sync/file")), &name, &type, &path, &option)); | 509 base::FilePath(FPL("sync/file")), &name, &type, &cracked_id, &path, |
| 510 &option)); |
503 EXPECT_EQ(fileapi::COPY_SYNC_OPTION_SYNC, option.copy_sync_option()); | 511 EXPECT_EQ(fileapi::COPY_SYNC_OPTION_SYNC, option.copy_sync_option()); |
504 } | 512 } |
505 | 513 |
506 } // namespace content | 514 } // namespace content |
507 | 515 |
OLD | NEW |