Home | History | Annotate | Download | only in fileapi
      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
      3 // found in the LICENSE file.
      4 
      5 #include "webkit/browser/fileapi/external_mount_points.h"
      6 
      7 #include <string>
      8 
      9 #include "base/files/file_path.h"
     10 #include "testing/gtest/include/gtest/gtest.h"
     11 #include "webkit/browser/fileapi/file_system_url.h"
     12 
     13 #define FPL FILE_PATH_LITERAL
     14 
     15 #if defined(FILE_PATH_USES_DRIVE_LETTERS)
     16 #define DRIVE FPL("C:")
     17 #else
     18 #define DRIVE
     19 #endif
     20 
     21 using fileapi::FileSystemURL;
     22 
     23 namespace content {
     24 
     25 TEST(ExternalMountPointsTest, AddMountPoint) {
     26   scoped_refptr<fileapi::ExternalMountPoints> mount_points(
     27       fileapi::ExternalMountPoints::CreateRefCounted());
     28 
     29   struct TestCase {
     30     // The mount point's name.
     31     const char* const name;
     32     // The mount point's path.
     33     const base::FilePath::CharType* const path;
     34     // Whether the mount point registration should succeed.
     35     bool success;
     36     // Path returned by GetRegisteredPath. NULL if the method is expected to
     37     // fail.
     38     const base::FilePath::CharType* const registered_path;
     39   };
     40 
     41   const TestCase kTestCases[] = {
     42     // Valid mount point.
     43     { "test", DRIVE FPL("/foo/test"), true, DRIVE FPL("/foo/test") },
     44     // Valid mount point with only one path component.
     45     { "bbb", DRIVE FPL("/bbb"), true, DRIVE FPL("/bbb") },
     46     // Existing mount point path is substring of the mount points path.
     47     { "test11", DRIVE FPL("/foo/test11"), true, DRIVE FPL("/foo/test11") },
     48     // Path substring of an existing path.
     49     { "test1", DRIVE FPL("/foo/test1"), true, DRIVE FPL("/foo/test1") },
     50     // Empty mount point name and path.
     51     { "", DRIVE FPL(""), false, NULL },
     52     // Empty mount point name.
     53     { "", DRIVE FPL("/ddd"), false, NULL },
     54     // Empty mount point path.
     55     { "empty_path", FPL(""), true, FPL("") },
     56     // Name different from path's base name.
     57     { "not_base_name", DRIVE FPL("/x/y/z"), true, DRIVE FPL("/x/y/z") },
     58     // References parent.
     59     { "invalid", DRIVE FPL("../foo/invalid"), false, NULL },
     60     // Relative path.
     61     { "relative", DRIVE FPL("foo/relative"), false, NULL },
     62     // Existing mount point path.
     63     { "path_exists", DRIVE FPL("/foo/test"), false, NULL },
     64     // Mount point with the same name exists.
     65     { "test", DRIVE FPL("/foo/a/test_name_exists"), false,
     66       DRIVE FPL("/foo/test") },
     67     // Child of an existing mount point.
     68     { "a1", DRIVE FPL("/foo/test/a"), false, NULL },
     69     // Parent of an existing mount point.
     70     { "foo1", DRIVE FPL("/foo"), false, NULL },
     71     // Bit bigger depth.
     72     { "g", DRIVE FPL("/foo/a/b/c/d/e/f/g"), true,
     73       DRIVE FPL("/foo/a/b/c/d/e/f/g") },
     74     // Sibling mount point (with similar name) exists.
     75     { "ff", DRIVE FPL("/foo/a/b/c/d/e/ff"), true,
     76        DRIVE FPL("/foo/a/b/c/d/e/ff") },
     77     // Lexicographically last among existing mount points.
     78     { "yyy", DRIVE FPL("/zzz/yyy"), true, DRIVE FPL("/zzz/yyy") },
     79     // Parent of the lexicographically last mount point.
     80     { "zzz1", DRIVE FPL("/zzz"), false, NULL },
     81     // Child of the lexicographically last mount point.
     82     { "xxx1", DRIVE FPL("/zzz/yyy/xxx"), false, NULL },
     83     // Lexicographically first among existing mount points.
     84     { "b", DRIVE FPL("/a/b"), true, DRIVE FPL("/a/b") },
     85     // Parent of lexicographically first mount point.
     86     { "a2", DRIVE FPL("/a"), false, NULL },
     87     // Child of lexicographically last mount point.
     88     { "c1", DRIVE FPL("/a/b/c"), false, NULL },
     89     // Parent to all of the mount points.
     90     { "root", DRIVE FPL("/"), false, NULL },
     91     // Path contains .. component.
     92     { "funky", DRIVE FPL("/tt/fun/../funky"), false, NULL },
     93     // Windows separators.
     94 #if defined(FILE_PATH_USES_WIN_SEPARATORS)
     95     { "win", DRIVE FPL("\\try\\separators\\win"), true,
     96       DRIVE FPL("\\try\\separators\\win") },
     97     { "win1", DRIVE FPL("\\try/separators\\win1"), true,
     98       DRIVE FPL("\\try/separators\\win1") },
     99     { "win2", DRIVE FPL("\\try/separators\\win"), false, NULL },
    100 #else
    101     { "win", DRIVE FPL("\\separators\\win"), false, NULL },
    102     { "win1", DRIVE FPL("\\try/separators\\win1"), false, NULL },
    103 #endif
    104     // Win separators, but relative path.
    105     { "win2", DRIVE FPL("try\\separators\\win2"), false, NULL },
    106   };
    107 
    108   // Test adding mount points.
    109   for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) {
    110     EXPECT_EQ(kTestCases[i].success,
    111               mount_points->RegisterFileSystem(
    112                   kTestCases[i].name,
    113                   fileapi::kFileSystemTypeNativeLocal,
    114                   fileapi::FileSystemMountOption(),
    115                   base::FilePath(kTestCases[i].path)))
    116         << "Adding mount point: " << kTestCases[i].name << " with path "
    117         << kTestCases[i].path;
    118   }
    119 
    120   // Test that final mount point presence state is as expected.
    121   for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) {
    122     base::FilePath found_path;
    123     EXPECT_EQ(kTestCases[i].registered_path != NULL,
    124               mount_points->GetRegisteredPath(kTestCases[i].name, &found_path))
    125         << "Test case: " << i;
    126 
    127     if (kTestCases[i].registered_path) {
    128       base::FilePath expected_path(kTestCases[i].registered_path);
    129       EXPECT_EQ(expected_path.NormalizePathSeparators(), found_path);
    130     }
    131   }
    132 }
    133 
    134 TEST(ExternalMountPointsTest, GetVirtualPath) {
    135   scoped_refptr<fileapi::ExternalMountPoints> mount_points(
    136       fileapi::ExternalMountPoints::CreateRefCounted());
    137 
    138   mount_points->RegisterFileSystem("c",
    139                                    fileapi::kFileSystemTypeNativeLocal,
    140                                    fileapi::FileSystemMountOption(),
    141                                    base::FilePath(DRIVE FPL("/a/b/c")));
    142   // Note that "/a/b/c" < "/a/b/c(1)" < "/a/b/c/".
    143   mount_points->RegisterFileSystem("c(1)",
    144                                    fileapi::kFileSystemTypeNativeLocal,
    145                                    fileapi::FileSystemMountOption(),
    146                                    base::FilePath(DRIVE FPL("/a/b/c(1)")));
    147   mount_points->RegisterFileSystem("x",
    148                                    fileapi::kFileSystemTypeNativeLocal,
    149                                    fileapi::FileSystemMountOption(),
    150                                    base::FilePath(DRIVE FPL("/z/y/x")));
    151   mount_points->RegisterFileSystem("o",
    152                                    fileapi::kFileSystemTypeNativeLocal,
    153                                    fileapi::FileSystemMountOption(),
    154                                    base::FilePath(DRIVE FPL("/m/n/o")));
    155   // A mount point whose name does not match its path base name.
    156   mount_points->RegisterFileSystem("mount",
    157                                    fileapi::kFileSystemTypeNativeLocal,
    158                                    fileapi::FileSystemMountOption(),
    159                                    base::FilePath(DRIVE FPL("/root/foo")));
    160   // A mount point with an empty path.
    161   mount_points->RegisterFileSystem("empty_path",
    162                                    fileapi::kFileSystemTypeNativeLocal,
    163                                    fileapi::FileSystemMountOption(),
    164                                    base::FilePath());
    165 
    166   struct TestCase {
    167     const base::FilePath::CharType* const local_path;
    168     bool success;
    169     const base::FilePath::CharType* const virtual_path;
    170   };
    171 
    172   const TestCase kTestCases[] = {
    173     // Empty path.
    174     { FPL(""), false, FPL("") },
    175     // No registered mount point (but is parent to a mount point).
    176     { DRIVE FPL("/a/b"), false, FPL("") },
    177     // No registered mount point (but is parent to a mount point).
    178     { DRIVE FPL("/z/y"), false, FPL("") },
    179     // No registered mount point (but is parent to a mount point).
    180     { DRIVE FPL("/m/n"), false, FPL("") },
    181     // No registered mount point.
    182     { DRIVE FPL("/foo/mount"), false, FPL("") },
    183     // An existing mount point path is substring.
    184     { DRIVE FPL("/a/b/c1"), false, FPL("") },
    185     // No leading /.
    186     { DRIVE FPL("a/b/c"), false, FPL("") },
    187     // Sibling to a root path.
    188     { DRIVE FPL("/a/b/d/e"), false, FPL("") },
    189     // Sibling to a root path.
    190     { DRIVE FPL("/z/y/v/u"), false, FPL("") },
    191     // Sibling to a root path.
    192     { DRIVE FPL("/m/n/p/q"), false, FPL("") },
    193     // Mount point root path.
    194     { DRIVE FPL("/a/b/c"), true, FPL("c") },
    195     // Mount point root path.
    196     { DRIVE FPL("/z/y/x"), true, FPL("x") },
    197     // Mount point root path.
    198     { DRIVE FPL("/m/n/o"), true, FPL("o") },
    199     // Mount point child path.
    200     { DRIVE FPL("/a/b/c/d/e"), true, FPL("c/d/e") },
    201     // Mount point child path.
    202     { DRIVE FPL("/z/y/x/v/u"), true, FPL("x/v/u") },
    203     // Mount point child path.
    204     { DRIVE FPL("/m/n/o/p/q"), true, FPL("o/p/q") },
    205     // Name doesn't match mount point path base name.
    206     { DRIVE FPL("/root/foo/a/b/c"), true, FPL("mount/a/b/c") },
    207     { DRIVE FPL("/root/foo"), true, FPL("mount") },
    208     // Mount point contains character whose ASCII code is smaller than file path
    209     // separator's.
    210     { DRIVE FPL("/a/b/c(1)/d/e"), true, FPL("c(1)/d/e") },
    211 #if defined(FILE_PATH_USES_WIN_SEPARATORS)
    212     // Path with win separators mixed in.
    213     { DRIVE FPL("/a\\b\\c/d"), true, FPL("c/d") },
    214 #endif
    215   };
    216 
    217   for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) {
    218     // Initialize virtual path with a value.
    219     base::FilePath virtual_path(DRIVE FPL("/mount"));
    220     base::FilePath local_path(kTestCases[i].local_path);
    221     EXPECT_EQ(kTestCases[i].success,
    222               mount_points->GetVirtualPath(local_path, &virtual_path))
    223         << "Resolving " << kTestCases[i].local_path;
    224 
    225     // There are no guarantees for |virtual_path| value if |GetVirtualPath|
    226     // fails.
    227     if (!kTestCases[i].success)
    228       continue;
    229 
    230     base::FilePath expected_virtual_path(kTestCases[i].virtual_path);
    231     EXPECT_EQ(expected_virtual_path.NormalizePathSeparators(), virtual_path)
    232         << "Resolving " << kTestCases[i].local_path;
    233   }
    234 }
    235 
    236 TEST(ExternalMountPointsTest, HandlesFileSystemMountType) {
    237   scoped_refptr<fileapi::ExternalMountPoints> mount_points(
    238       fileapi::ExternalMountPoints::CreateRefCounted());
    239 
    240   const GURL test_origin("http://chromium.org");
    241   const base::FilePath test_path(FPL("/mount"));
    242 
    243   // Should handle External File System.
    244   EXPECT_TRUE(mount_points->HandlesFileSystemMountType(
    245       fileapi::kFileSystemTypeExternal));
    246 
    247   // Shouldn't handle the rest.
    248   EXPECT_FALSE(mount_points->HandlesFileSystemMountType(
    249       fileapi::kFileSystemTypeIsolated));
    250   EXPECT_FALSE(mount_points->HandlesFileSystemMountType(
    251       fileapi::kFileSystemTypeTemporary));
    252   EXPECT_FALSE(mount_points->HandlesFileSystemMountType(
    253       fileapi::kFileSystemTypePersistent));
    254   EXPECT_FALSE(mount_points->HandlesFileSystemMountType(
    255       fileapi::kFileSystemTypeTest));
    256   // Not even if it's external subtype.
    257   EXPECT_FALSE(mount_points->HandlesFileSystemMountType(
    258       fileapi::kFileSystemTypeNativeLocal));
    259   EXPECT_FALSE(mount_points->HandlesFileSystemMountType(
    260       fileapi::kFileSystemTypeRestrictedNativeLocal));
    261   EXPECT_FALSE(mount_points->HandlesFileSystemMountType(
    262       fileapi::kFileSystemTypeDrive));
    263   EXPECT_FALSE(mount_points->HandlesFileSystemMountType(
    264       fileapi::kFileSystemTypeSyncable));
    265 }
    266 
    267 TEST(ExternalMountPointsTest, CreateCrackedFileSystemURL) {
    268   scoped_refptr<fileapi::ExternalMountPoints> mount_points(
    269       fileapi::ExternalMountPoints::CreateRefCounted());
    270 
    271   const GURL kTestOrigin("http://chromium.org");
    272 
    273   mount_points->RegisterFileSystem("c",
    274                                    fileapi::kFileSystemTypeNativeLocal,
    275                                    fileapi::FileSystemMountOption(),
    276                                    base::FilePath(DRIVE FPL("/a/b/c")));
    277   mount_points->RegisterFileSystem("c(1)",
    278                                    fileapi::kFileSystemTypeDrive,
    279                                    fileapi::FileSystemMountOption(),
    280                                    base::FilePath(DRIVE FPL("/a/b/c(1)")));
    281   mount_points->RegisterFileSystem("empty_path",
    282                                    fileapi::kFileSystemTypeSyncable,
    283                                    fileapi::FileSystemMountOption(),
    284                                    base::FilePath());
    285   mount_points->RegisterFileSystem("mount",
    286                                    fileapi::kFileSystemTypeDrive,
    287                                    fileapi::FileSystemMountOption(),
    288                                    base::FilePath(DRIVE FPL("/root")));
    289 
    290   // Try cracking invalid GURL.
    291   FileSystemURL invalid = mount_points->CrackURL(GURL("http://chromium.og"));
    292   EXPECT_FALSE(invalid.is_valid());
    293 
    294   // Try cracking isolated path.
    295   FileSystemURL isolated = mount_points->CreateCrackedFileSystemURL(
    296       kTestOrigin, fileapi::kFileSystemTypeIsolated, base::FilePath(FPL("c")));
    297   EXPECT_FALSE(isolated.is_valid());
    298 
    299   // Try native local which is not cracked.
    300   FileSystemURL native_local = mount_points->CreateCrackedFileSystemURL(
    301       kTestOrigin,
    302       fileapi::kFileSystemTypeNativeLocal,
    303       base::FilePath(FPL("c")));
    304   EXPECT_FALSE(native_local.is_valid());
    305 
    306   struct TestCase {
    307     const base::FilePath::CharType* const path;
    308     bool expect_valid;
    309     fileapi::FileSystemType expect_type;
    310     const base::FilePath::CharType* const expect_path;
    311     const char* const expect_fs_id;
    312   };
    313 
    314   const TestCase kTestCases[] = {
    315     { FPL("c/d/e"),
    316       true, fileapi::kFileSystemTypeNativeLocal, DRIVE FPL("/a/b/c/d/e"), "c" },
    317     { FPL("c(1)/d/e"),
    318       true, fileapi::kFileSystemTypeDrive, DRIVE FPL("/a/b/c(1)/d/e"), "c(1)" },
    319     { FPL("c(1)"),
    320       true, fileapi::kFileSystemTypeDrive, DRIVE FPL("/a/b/c(1)"), "c(1)" },
    321     { FPL("empty_path/a"),
    322       true, fileapi::kFileSystemTypeSyncable, FPL("a"), "empty_path" },
    323     { FPL("empty_path"),
    324       true, fileapi::kFileSystemTypeSyncable, FPL(""), "empty_path" },
    325     { FPL("mount/a/b"),
    326       true, fileapi::kFileSystemTypeDrive, DRIVE FPL("/root/a/b"), "mount" },
    327     { FPL("mount"),
    328       true, fileapi::kFileSystemTypeDrive, DRIVE FPL("/root"), "mount" },
    329     { FPL("cc"),
    330       false, fileapi::kFileSystemTypeUnknown, FPL(""), "" },
    331     { FPL(""),
    332       false, fileapi::kFileSystemTypeUnknown, FPL(""), "" },
    333     { FPL(".."),
    334       false, fileapi::kFileSystemTypeUnknown, FPL(""), "" },
    335     // Absolte paths.
    336     { FPL("/c/d/e"),
    337       false, fileapi::kFileSystemTypeUnknown, FPL(""), "" },
    338     { FPL("/c(1)/d/e"),
    339       false, fileapi::kFileSystemTypeUnknown, FPL(""), "" },
    340     { FPL("/empty_path"),
    341       false, fileapi::kFileSystemTypeUnknown, FPL(""), "" },
    342     // PAth references parent.
    343     { FPL("c/d/../e"),
    344       false, fileapi::kFileSystemTypeUnknown, FPL(""), "" },
    345     { FPL("/empty_path/a/../b"),
    346       false, fileapi::kFileSystemTypeUnknown, FPL(""), "" },
    347 #if defined(FILE_PATH_USES_WIN_SEPARATORS)
    348     { FPL("c/d\\e"),
    349       true, fileapi::kFileSystemTypeNativeLocal, DRIVE FPL("/a/b/c/d/e"), "c" },
    350     { FPL("mount\\a\\b"),
    351       true, fileapi::kFileSystemTypeDrive, DRIVE FPL("/root/a/b"), "mount" },
    352 #endif
    353   };
    354 
    355   for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) {
    356     FileSystemURL cracked = mount_points->CreateCrackedFileSystemURL(
    357         kTestOrigin,
    358         fileapi::kFileSystemTypeExternal,
    359         base::FilePath(kTestCases[i].path));
    360 
    361     EXPECT_EQ(kTestCases[i].expect_valid, cracked.is_valid())
    362         << "Test case index: " << i;
    363 
    364     if (!kTestCases[i].expect_valid)
    365       continue;
    366 
    367     EXPECT_EQ(kTestOrigin, cracked.origin())
    368         << "Test case index: " << i;
    369     EXPECT_EQ(kTestCases[i].expect_type, cracked.type())
    370         << "Test case index: " << i;
    371     EXPECT_EQ(base::FilePath(
    372         kTestCases[i].expect_path).NormalizePathSeparators(), cracked.path())
    373         << "Test case index: " << i;
    374     EXPECT_EQ(base::FilePath(kTestCases[i].path).NormalizePathSeparators(),
    375                        cracked.virtual_path())
    376         << "Test case index: " << i;
    377     EXPECT_EQ(kTestCases[i].expect_fs_id, cracked.filesystem_id())
    378         << "Test case index: " << i;
    379     EXPECT_EQ(fileapi::kFileSystemTypeExternal, cracked.mount_type())
    380         << "Test case index: " << i;
    381   }
    382 }
    383 
    384 TEST(ExternalMountPointsTest, CrackVirtualPath) {
    385   scoped_refptr<fileapi::ExternalMountPoints> mount_points(
    386       fileapi::ExternalMountPoints::CreateRefCounted());
    387 
    388   const GURL kTestOrigin("http://chromium.org");
    389 
    390   mount_points->RegisterFileSystem("c",
    391                                    fileapi::kFileSystemTypeNativeLocal,
    392                                    fileapi::FileSystemMountOption(),
    393                                    base::FilePath(DRIVE FPL("/a/b/c")));
    394   mount_points->RegisterFileSystem("c(1)",
    395                                    fileapi::kFileSystemTypeDrive,
    396                                    fileapi::FileSystemMountOption(),
    397                                    base::FilePath(DRIVE FPL("/a/b/c(1)")));
    398   mount_points->RegisterFileSystem("empty_path",
    399                                    fileapi::kFileSystemTypeSyncable,
    400                                    fileapi::FileSystemMountOption(),
    401                                    base::FilePath());
    402   mount_points->RegisterFileSystem("mount",
    403                                    fileapi::kFileSystemTypeDrive,
    404                                    fileapi::FileSystemMountOption(),
    405                                    base::FilePath(DRIVE FPL("/root")));
    406 
    407   struct TestCase {
    408     const base::FilePath::CharType* const path;
    409     bool expect_valid;
    410     fileapi::FileSystemType expect_type;
    411     const base::FilePath::CharType* const expect_path;
    412     const char* const expect_name;
    413   };
    414 
    415   const TestCase kTestCases[] = {
    416     { FPL("c/d/e"),
    417       true, fileapi::kFileSystemTypeNativeLocal, DRIVE FPL("/a/b/c/d/e"), "c" },
    418     { FPL("c(1)/d/e"),
    419       true, fileapi::kFileSystemTypeDrive, DRIVE FPL("/a/b/c(1)/d/e"), "c(1)" },
    420     { FPL("c(1)"),
    421       true, fileapi::kFileSystemTypeDrive, DRIVE FPL("/a/b/c(1)"), "c(1)" },
    422     { FPL("empty_path/a"),
    423       true, fileapi::kFileSystemTypeSyncable, FPL("a"), "empty_path" },
    424     { FPL("empty_path"),
    425       true, fileapi::kFileSystemTypeSyncable, FPL(""), "empty_path" },
    426     { FPL("mount/a/b"),
    427       true, fileapi::kFileSystemTypeDrive, DRIVE FPL("/root/a/b"), "mount" },
    428     { FPL("mount"),
    429       true, fileapi::kFileSystemTypeDrive, DRIVE FPL("/root"), "mount" },
    430     { FPL("cc"),
    431       false, fileapi::kFileSystemTypeUnknown, FPL(""), "" },
    432     { FPL(""),
    433       false, fileapi::kFileSystemTypeUnknown, FPL(""), "" },
    434     { FPL(".."),
    435       false, fileapi::kFileSystemTypeUnknown, FPL(""), "" },
    436     // Absolte paths.
    437     { FPL("/c/d/e"),
    438       false, fileapi::kFileSystemTypeUnknown, FPL(""), "" },
    439     { FPL("/c(1)/d/e"),
    440       false, fileapi::kFileSystemTypeUnknown, FPL(""), "" },
    441     { FPL("/empty_path"),
    442       false, fileapi::kFileSystemTypeUnknown, FPL(""), "" },
    443     // PAth references parent.
    444     { FPL("c/d/../e"),
    445       false, fileapi::kFileSystemTypeUnknown, FPL(""), "" },
    446     { FPL("/empty_path/a/../b"),
    447       false, fileapi::kFileSystemTypeUnknown, FPL(""), "" },
    448 #if defined(FILE_PATH_USES_WIN_SEPARATORS)
    449     { FPL("c/d\\e"),
    450       true, fileapi::kFileSystemTypeNativeLocal, DRIVE FPL("/a/b/c/d/e"), "c" },
    451     { FPL("mount\\a\\b"),
    452       true, fileapi::kFileSystemTypeDrive, DRIVE FPL("/root/a/b"), "mount" },
    453 #endif
    454   };
    455 
    456   for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) {
    457     std::string cracked_name;
    458     fileapi::FileSystemType cracked_type;
    459     std::string cracked_id;
    460     base::FilePath cracked_path;
    461     fileapi::FileSystemMountOption cracked_option;
    462     EXPECT_EQ(kTestCases[i].expect_valid,
    463               mount_points->CrackVirtualPath(base::FilePath(kTestCases[i].path),
    464                   &cracked_name, &cracked_type, &cracked_id, &cracked_path,
    465                   &cracked_option))
    466         << "Test case index: " << i;
    467 
    468     if (!kTestCases[i].expect_valid)
    469       continue;
    470 
    471     EXPECT_EQ(kTestCases[i].expect_type, cracked_type)
    472         << "Test case index: " << i;
    473     EXPECT_EQ(base::FilePath(
    474         kTestCases[i].expect_path).NormalizePathSeparators(), cracked_path)
    475         << "Test case index: " << i;
    476     EXPECT_EQ(kTestCases[i].expect_name, cracked_name)
    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;
    481   }
    482 }
    483 
    484 TEST(ExternalMountPointsTest, MountOption) {
    485   scoped_refptr<fileapi::ExternalMountPoints> mount_points(
    486       fileapi::ExternalMountPoints::CreateRefCounted());
    487 
    488   mount_points->RegisterFileSystem(
    489       "nosync",
    490       fileapi::kFileSystemTypeNativeLocal,
    491       fileapi::FileSystemMountOption(fileapi::COPY_SYNC_OPTION_NO_SYNC),
    492       base::FilePath(DRIVE FPL("/nosync")));
    493   mount_points->RegisterFileSystem(
    494       "sync",
    495       fileapi::kFileSystemTypeNativeLocal,
    496       fileapi::FileSystemMountOption(fileapi::COPY_SYNC_OPTION_SYNC),
    497       base::FilePath(DRIVE FPL("/sync")));
    498 
    499   std::string name;
    500   fileapi::FileSystemType type;
    501   std::string cracked_id;
    502   fileapi::FileSystemMountOption option;
    503   base::FilePath path;
    504   EXPECT_TRUE(mount_points->CrackVirtualPath(
    505       base::FilePath(FPL("nosync/file")), &name, &type, &cracked_id, &path,
    506       &option));
    507   EXPECT_EQ(fileapi::COPY_SYNC_OPTION_NO_SYNC, option.copy_sync_option());
    508   EXPECT_TRUE(mount_points->CrackVirtualPath(
    509       base::FilePath(FPL("sync/file")), &name, &type, &cracked_id, &path,
    510       &option));
    511   EXPECT_EQ(fileapi::COPY_SYNC_OPTION_SYNC, option.copy_sync_option());
    512 }
    513 
    514 }  // namespace content
    515 
    516