| 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/chromeos/fileapi/cros_mount_point_provider.h" | 5 #include "webkit/chromeos/fileapi/cros_mount_point_provider.h" | 
| 6 | 6 | 
| 7 #include <set> | 7 #include <set> | 
| 8 | 8 | 
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" | 
| 10 #include "googleurl/src/url_util.h" | 10 #include "googleurl/src/url_util.h" | 
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" | 
| 12 #include "webkit/fileapi/external_mount_points.h" | 12 #include "webkit/fileapi/external_mount_points.h" | 
| 13 #include "webkit/fileapi/file_system_url.h" | 13 #include "webkit/fileapi/file_system_url.h" | 
| 14 #include "webkit/fileapi/isolated_context.h" | 14 #include "webkit/fileapi/isolated_context.h" | 
| 15 #include "webkit/quota/mock_special_storage_policy.h" | 15 #include "webkit/quota/mock_special_storage_policy.h" | 
| 16 | 16 | 
| 17 #define FPL(x) FILE_PATH_LITERAL(x) | 17 #define FPL(x) FILE_PATH_LITERAL(x) | 
| 18 | 18 | 
| 19 using fileapi::ExternalMountPoints; | 19 using fileapi::ExternalMountPoints; | 
| 20 using fileapi::FileSystemURL; | 20 using fileapi::FileSystemURL; | 
| 21 | 21 | 
| 22 namespace { | 22 namespace { | 
| 23 | 23 | 
| 24 FileSystemURL CreateFileSystemURL(const std::string& extension, | 24 FileSystemURL CreateFileSystemURL(const std::string& extension, | 
| 25                                   const char* path, | 25                                   const char* path, | 
| 26                                   ExternalMountPoints* mount_points) { | 26                                   ExternalMountPoints* mount_points) { | 
| 27   return mount_points->CreateCrackedFileSystemURL( | 27   return mount_points->CreateCrackedFileSystemURL( | 
| 28       GURL("chrome-extension://" + extension + "/"), | 28       GURL("chrome-extension://" + extension + "/"), | 
| 29       fileapi::kFileSystemTypeExternal, | 29       fileapi::kFileSystemTypeExternal, | 
| 30       FilePath::FromUTF8Unsafe(path)); | 30       base::FilePath::FromUTF8Unsafe(path)); | 
| 31 } | 31 } | 
| 32 | 32 | 
| 33 TEST(CrosMountPointProviderTest, DefaultMountPoints) { | 33 TEST(CrosMountPointProviderTest, DefaultMountPoints) { | 
| 34   scoped_refptr<quota::SpecialStoragePolicy> storage_policy = | 34   scoped_refptr<quota::SpecialStoragePolicy> storage_policy = | 
| 35       new quota::MockSpecialStoragePolicy(); | 35       new quota::MockSpecialStoragePolicy(); | 
| 36   scoped_refptr<fileapi::ExternalMountPoints> mount_points( | 36   scoped_refptr<fileapi::ExternalMountPoints> mount_points( | 
| 37       fileapi::ExternalMountPoints::CreateRefCounted()); | 37       fileapi::ExternalMountPoints::CreateRefCounted()); | 
| 38   chromeos::CrosMountPointProvider provider( | 38   chromeos::CrosMountPointProvider provider( | 
| 39       storage_policy, | 39       storage_policy, | 
| 40       mount_points.get(), | 40       mount_points.get(), | 
| 41       fileapi::ExternalMountPoints::GetSystemInstance()); | 41       fileapi::ExternalMountPoints::GetSystemInstance()); | 
| 42   std::vector<FilePath> root_dirs = provider.GetRootDirectories(); | 42   std::vector<base::FilePath> root_dirs = provider.GetRootDirectories(); | 
| 43   std::set<FilePath> root_dirs_set(root_dirs.begin(), root_dirs.end()); | 43   std::set<base::FilePath> root_dirs_set(root_dirs.begin(), root_dirs.end()); | 
| 44 | 44 | 
| 45   // By default there should be 3 mount points (in system mount points): | 45   // By default there should be 3 mount points (in system mount points): | 
| 46   EXPECT_EQ(3u, root_dirs.size()); | 46   EXPECT_EQ(3u, root_dirs.size()); | 
| 47   EXPECT_TRUE(root_dirs_set.count(FilePath(FPL("/media/removable")))); | 47   EXPECT_TRUE(root_dirs_set.count(base::FilePath(FPL("/media/removable")))); | 
| 48   EXPECT_TRUE(root_dirs_set.count(FilePath(FPL("/media/archive")))); | 48   EXPECT_TRUE(root_dirs_set.count(base::FilePath(FPL("/media/archive")))); | 
| 49   EXPECT_TRUE(root_dirs_set.count(FilePath(FPL("/usr/share/oem")))); | 49   EXPECT_TRUE(root_dirs_set.count(base::FilePath(FPL("/usr/share/oem")))); | 
| 50 } | 50 } | 
| 51 | 51 | 
| 52 TEST(CrosMountPointProviderTest, GetRootDirectories) { | 52 TEST(CrosMountPointProviderTest, GetRootDirectories) { | 
| 53   scoped_refptr<quota::SpecialStoragePolicy> storage_policy = | 53   scoped_refptr<quota::SpecialStoragePolicy> storage_policy = | 
| 54       new quota::MockSpecialStoragePolicy(); | 54       new quota::MockSpecialStoragePolicy(); | 
| 55   scoped_refptr<fileapi::ExternalMountPoints> mount_points( | 55   scoped_refptr<fileapi::ExternalMountPoints> mount_points( | 
| 56       fileapi::ExternalMountPoints::CreateRefCounted()); | 56       fileapi::ExternalMountPoints::CreateRefCounted()); | 
| 57 | 57 | 
| 58   scoped_refptr<fileapi::ExternalMountPoints> system_mount_points( | 58   scoped_refptr<fileapi::ExternalMountPoints> system_mount_points( | 
| 59       fileapi::ExternalMountPoints::CreateRefCounted()); | 59       fileapi::ExternalMountPoints::CreateRefCounted()); | 
| 60 | 60 | 
| 61   chromeos::CrosMountPointProvider provider( | 61   chromeos::CrosMountPointProvider provider( | 
| 62       storage_policy, | 62       storage_policy, | 
| 63       mount_points.get(), | 63       mount_points.get(), | 
| 64       system_mount_points.get()); | 64       system_mount_points.get()); | 
| 65 | 65 | 
| 66   // Register 'local' test mount points. | 66   // Register 'local' test mount points. | 
| 67   mount_points->RegisterFileSystem("c", | 67   mount_points->RegisterFileSystem("c", | 
| 68                                    fileapi::kFileSystemTypeNativeLocal, | 68                                    fileapi::kFileSystemTypeNativeLocal, | 
| 69                                    FilePath(FPL("/a/b/c"))); | 69                                    base::FilePath(FPL("/a/b/c"))); | 
| 70   mount_points->RegisterFileSystem("d", | 70   mount_points->RegisterFileSystem("d", | 
| 71                                    fileapi::kFileSystemTypeNativeLocal, | 71                                    fileapi::kFileSystemTypeNativeLocal, | 
| 72                                    FilePath(FPL("/b/c/d"))); | 72                                    base::FilePath(FPL("/b/c/d"))); | 
| 73 | 73 | 
| 74   // Register system test mount points. | 74   // Register system test mount points. | 
| 75   system_mount_points->RegisterFileSystem("d", | 75   system_mount_points->RegisterFileSystem("d", | 
| 76                                           fileapi::kFileSystemTypeNativeLocal, | 76                                           fileapi::kFileSystemTypeNativeLocal, | 
| 77                                           FilePath(FPL("/g/c/d"))); | 77                                           base::FilePath(FPL("/g/c/d"))); | 
| 78   system_mount_points->RegisterFileSystem("e", | 78   system_mount_points->RegisterFileSystem("e", | 
| 79                                           fileapi::kFileSystemTypeNativeLocal, | 79                                           fileapi::kFileSystemTypeNativeLocal, | 
| 80                                           FilePath(FPL("/g/d/e"))); | 80                                           base::FilePath(FPL("/g/d/e"))); | 
| 81 | 81 | 
| 82   std::vector<FilePath> root_dirs = provider.GetRootDirectories(); | 82   std::vector<base::FilePath> root_dirs = provider.GetRootDirectories(); | 
| 83   std::set<FilePath> root_dirs_set(root_dirs.begin(), root_dirs.end()); | 83   std::set<base::FilePath> root_dirs_set(root_dirs.begin(), root_dirs.end()); | 
| 84   EXPECT_EQ(4u, root_dirs.size()); | 84   EXPECT_EQ(4u, root_dirs.size()); | 
| 85   EXPECT_TRUE(root_dirs_set.count(FilePath(FPL("/a/b/c")))); | 85   EXPECT_TRUE(root_dirs_set.count(base::FilePath(FPL("/a/b/c")))); | 
| 86   EXPECT_TRUE(root_dirs_set.count(FilePath(FPL("/b/c/d")))); | 86   EXPECT_TRUE(root_dirs_set.count(base::FilePath(FPL("/b/c/d")))); | 
| 87   EXPECT_TRUE(root_dirs_set.count(FilePath(FPL("/g/c/d")))); | 87   EXPECT_TRUE(root_dirs_set.count(base::FilePath(FPL("/g/c/d")))); | 
| 88   EXPECT_TRUE(root_dirs_set.count(FilePath(FPL("/g/d/e")))); | 88   EXPECT_TRUE(root_dirs_set.count(base::FilePath(FPL("/g/d/e")))); | 
| 89 } | 89 } | 
| 90 | 90 | 
| 91 TEST(CrosMountPointProviderTest, AccessPermissions) { | 91 TEST(CrosMountPointProviderTest, AccessPermissions) { | 
| 92   url_util::AddStandardScheme("chrome-extension"); | 92   url_util::AddStandardScheme("chrome-extension"); | 
| 93 | 93 | 
| 94   scoped_refptr<quota::MockSpecialStoragePolicy> storage_policy = | 94   scoped_refptr<quota::MockSpecialStoragePolicy> storage_policy = | 
| 95       new quota::MockSpecialStoragePolicy(); | 95       new quota::MockSpecialStoragePolicy(); | 
| 96   scoped_refptr<fileapi::ExternalMountPoints> mount_points( | 96   scoped_refptr<fileapi::ExternalMountPoints> mount_points( | 
| 97       fileapi::ExternalMountPoints::CreateRefCounted()); | 97       fileapi::ExternalMountPoints::CreateRefCounted()); | 
| 98   scoped_refptr<fileapi::ExternalMountPoints> system_mount_points( | 98   scoped_refptr<fileapi::ExternalMountPoints> system_mount_points( | 
| 99       fileapi::ExternalMountPoints::CreateRefCounted()); | 99       fileapi::ExternalMountPoints::CreateRefCounted()); | 
| 100   chromeos::CrosMountPointProvider provider( | 100   chromeos::CrosMountPointProvider provider( | 
| 101       storage_policy, | 101       storage_policy, | 
| 102       mount_points.get(), | 102       mount_points.get(), | 
| 103       system_mount_points.get()); | 103       system_mount_points.get()); | 
| 104 | 104 | 
| 105   std::string extension("ddammdhioacbehjngdmkjcjbnfginlla"); | 105   std::string extension("ddammdhioacbehjngdmkjcjbnfginlla"); | 
| 106 | 106 | 
| 107   storage_policy->AddFileHandler(extension); | 107   storage_policy->AddFileHandler(extension); | 
| 108 | 108 | 
| 109   // Initialize mount points. | 109   // Initialize mount points. | 
| 110   ASSERT_TRUE(system_mount_points->RegisterFileSystem( | 110   ASSERT_TRUE(system_mount_points->RegisterFileSystem( | 
| 111       "system", | 111       "system", | 
| 112       fileapi::kFileSystemTypeNativeLocal, | 112       fileapi::kFileSystemTypeNativeLocal, | 
| 113       FilePath(FPL("/g/system")))); | 113       base::FilePath(FPL("/g/system")))); | 
| 114   ASSERT_TRUE(mount_points->RegisterFileSystem( | 114   ASSERT_TRUE(mount_points->RegisterFileSystem( | 
| 115       "removable", | 115       "removable", | 
| 116       fileapi::kFileSystemTypeNativeLocal, | 116       fileapi::kFileSystemTypeNativeLocal, | 
| 117       FilePath(FPL("/media/removable")))); | 117       base::FilePath(FPL("/media/removable")))); | 
| 118   ASSERT_TRUE(mount_points->RegisterFileSystem( | 118   ASSERT_TRUE(mount_points->RegisterFileSystem( | 
| 119       "oem", | 119       "oem", | 
| 120       fileapi::kFileSystemTypeRestrictedNativeLocal, | 120       fileapi::kFileSystemTypeRestrictedNativeLocal, | 
| 121       FilePath(FPL("/usr/share/oem")))); | 121       base::FilePath(FPL("/usr/share/oem")))); | 
| 122 | 122 | 
| 123   // Provider specific mount point access. | 123   // Provider specific mount point access. | 
| 124   EXPECT_FALSE(provider.IsAccessAllowed( | 124   EXPECT_FALSE(provider.IsAccessAllowed( | 
| 125       CreateFileSystemURL(extension, "removable/foo", mount_points.get()))); | 125       CreateFileSystemURL(extension, "removable/foo", mount_points.get()))); | 
| 126 | 126 | 
| 127   provider.GrantFileAccessToExtension(extension, | 127   provider.GrantFileAccessToExtension(extension, | 
| 128                                       FilePath(FPL("removable/foo"))); | 128                                       base::FilePath(FPL("removable/foo"))); | 
| 129   EXPECT_TRUE(provider.IsAccessAllowed( | 129   EXPECT_TRUE(provider.IsAccessAllowed( | 
| 130       CreateFileSystemURL(extension, "removable/foo", mount_points.get()))); | 130       CreateFileSystemURL(extension, "removable/foo", mount_points.get()))); | 
| 131   EXPECT_FALSE(provider.IsAccessAllowed( | 131   EXPECT_FALSE(provider.IsAccessAllowed( | 
| 132       CreateFileSystemURL(extension, "removable/foo1", mount_points.get()))); | 132       CreateFileSystemURL(extension, "removable/foo1", mount_points.get()))); | 
| 133 | 133 | 
| 134   // System mount point access. | 134   // System mount point access. | 
| 135   EXPECT_FALSE(provider.IsAccessAllowed( | 135   EXPECT_FALSE(provider.IsAccessAllowed( | 
| 136       CreateFileSystemURL(extension, "system/foo", system_mount_points.get()))); | 136       CreateFileSystemURL(extension, "system/foo", system_mount_points.get()))); | 
| 137 | 137 | 
| 138   provider.GrantFileAccessToExtension(extension, FilePath(FPL("system/foo"))); | 138   provider.GrantFileAccessToExtension(extension, base::FilePath(FPL("system/foo"
     ))); | 
| 139   EXPECT_TRUE(provider.IsAccessAllowed( | 139   EXPECT_TRUE(provider.IsAccessAllowed( | 
| 140       CreateFileSystemURL(extension, "system/foo", system_mount_points.get()))); | 140       CreateFileSystemURL(extension, "system/foo", system_mount_points.get()))); | 
| 141   EXPECT_FALSE(provider.IsAccessAllowed(CreateFileSystemURL( | 141   EXPECT_FALSE(provider.IsAccessAllowed(CreateFileSystemURL( | 
| 142       extension, "system/foo1", system_mount_points.get()))); | 142       extension, "system/foo1", system_mount_points.get()))); | 
| 143 | 143 | 
| 144   // oem is restricted file system. | 144   // oem is restricted file system. | 
| 145   provider.GrantFileAccessToExtension(extension, FilePath(FPL("oem/foo"))); | 145   provider.GrantFileAccessToExtension(extension, base::FilePath(FPL("oem/foo")))
     ; | 
| 146   // The extension should not be able to access the file even if | 146   // The extension should not be able to access the file even if | 
| 147   // GrantFileAccessToExtension was called. | 147   // GrantFileAccessToExtension was called. | 
| 148   EXPECT_FALSE(provider.IsAccessAllowed( | 148   EXPECT_FALSE(provider.IsAccessAllowed( | 
| 149       CreateFileSystemURL(extension, "oem/foo", mount_points.get()))); | 149       CreateFileSystemURL(extension, "oem/foo", mount_points.get()))); | 
| 150 | 150 | 
| 151   provider.GrantFullAccessToExtension(extension); | 151   provider.GrantFullAccessToExtension(extension); | 
| 152   // The extension should be able to access restricted file system after it was | 152   // The extension should be able to access restricted file system after it was | 
| 153   // granted full access. | 153   // granted full access. | 
| 154   EXPECT_TRUE(provider.IsAccessAllowed( | 154   EXPECT_TRUE(provider.IsAccessAllowed( | 
| 155       CreateFileSystemURL(extension, "oem/foo", mount_points.get()))); | 155       CreateFileSystemURL(extension, "oem/foo", mount_points.get()))); | 
| 156   // The extension which was granted full access  should be able to access any | 156   // The extension which was granted full access  should be able to access any | 
| 157   // path on curent file systems. | 157   // path on curent file systems. | 
| 158   EXPECT_TRUE(provider.IsAccessAllowed( | 158   EXPECT_TRUE(provider.IsAccessAllowed( | 
| 159       CreateFileSystemURL(extension, "removable/foo1", mount_points.get()))); | 159       CreateFileSystemURL(extension, "removable/foo1", mount_points.get()))); | 
| 160   EXPECT_TRUE(provider.IsAccessAllowed(CreateFileSystemURL( | 160   EXPECT_TRUE(provider.IsAccessAllowed(CreateFileSystemURL( | 
| 161       extension, "system/foo1", system_mount_points.get()))); | 161       extension, "system/foo1", system_mount_points.get()))); | 
| 162 | 162 | 
| 163   // The extension cannot access new mount points. | 163   // The extension cannot access new mount points. | 
| 164   // TODO(tbarzic): This should probably be changed. | 164   // TODO(tbarzic): This should probably be changed. | 
| 165   ASSERT_TRUE(mount_points->RegisterFileSystem( | 165   ASSERT_TRUE(mount_points->RegisterFileSystem( | 
| 166       "test", | 166       "test", | 
| 167       fileapi::kFileSystemTypeNativeLocal, | 167       fileapi::kFileSystemTypeNativeLocal, | 
| 168       FilePath(FPL("/foo/test")))); | 168       base::FilePath(FPL("/foo/test")))); | 
| 169   EXPECT_FALSE(provider.IsAccessAllowed( | 169   EXPECT_FALSE(provider.IsAccessAllowed( | 
| 170       CreateFileSystemURL(extension, "test_/foo", mount_points.get()))); | 170       CreateFileSystemURL(extension, "test_/foo", mount_points.get()))); | 
| 171 | 171 | 
| 172   provider.RevokeAccessForExtension(extension); | 172   provider.RevokeAccessForExtension(extension); | 
| 173   EXPECT_FALSE(provider.IsAccessAllowed( | 173   EXPECT_FALSE(provider.IsAccessAllowed( | 
| 174       CreateFileSystemURL(extension, "removable/foo", mount_points.get()))); | 174       CreateFileSystemURL(extension, "removable/foo", mount_points.get()))); | 
| 175 | 175 | 
| 176   fileapi::FileSystemURL internal_url = FileSystemURL::CreateForTest( | 176   fileapi::FileSystemURL internal_url = FileSystemURL::CreateForTest( | 
| 177       GURL("chrome://foo"), | 177       GURL("chrome://foo"), | 
| 178       fileapi::kFileSystemTypeExternal, | 178       fileapi::kFileSystemTypeExternal, | 
| 179       FilePath(FPL("removable/"))); | 179       base::FilePath(FPL("removable/"))); | 
| 180   // Internal WebUI should have full access. | 180   // Internal WebUI should have full access. | 
| 181   EXPECT_TRUE(provider.IsAccessAllowed(internal_url)); | 181   EXPECT_TRUE(provider.IsAccessAllowed(internal_url)); | 
| 182 } | 182 } | 
| 183 | 183 | 
| 184 TEST(CrosMountPointProvider, GetVirtualPathConflictWithSystemPoints) { | 184 TEST(CrosMountPointProvider, GetVirtualPathConflictWithSystemPoints) { | 
| 185   scoped_refptr<quota::MockSpecialStoragePolicy> storage_policy = | 185   scoped_refptr<quota::MockSpecialStoragePolicy> storage_policy = | 
| 186       new quota::MockSpecialStoragePolicy(); | 186       new quota::MockSpecialStoragePolicy(); | 
| 187   scoped_refptr<fileapi::ExternalMountPoints> mount_points( | 187   scoped_refptr<fileapi::ExternalMountPoints> mount_points( | 
| 188       fileapi::ExternalMountPoints::CreateRefCounted()); | 188       fileapi::ExternalMountPoints::CreateRefCounted()); | 
| 189   scoped_refptr<fileapi::ExternalMountPoints> system_mount_points( | 189   scoped_refptr<fileapi::ExternalMountPoints> system_mount_points( | 
| 190       fileapi::ExternalMountPoints::CreateRefCounted()); | 190       fileapi::ExternalMountPoints::CreateRefCounted()); | 
| 191   chromeos::CrosMountPointProvider provider(storage_policy, | 191   chromeos::CrosMountPointProvider provider(storage_policy, | 
| 192       mount_points.get(), | 192       mount_points.get(), | 
| 193       system_mount_points.get()); | 193       system_mount_points.get()); | 
| 194 | 194 | 
| 195   const fileapi::FileSystemType type = fileapi::kFileSystemTypeNativeLocal; | 195   const fileapi::FileSystemType type = fileapi::kFileSystemTypeNativeLocal; | 
| 196 | 196 | 
| 197   // Provider specific mount points. | 197   // Provider specific mount points. | 
| 198   ASSERT_TRUE( | 198   ASSERT_TRUE( | 
| 199       mount_points->RegisterFileSystem("b", type, FilePath(FPL("/a/b")))); | 199       mount_points->RegisterFileSystem("b", type, base::FilePath(FPL("/a/b")))); | 
| 200   ASSERT_TRUE( | 200   ASSERT_TRUE( | 
| 201       mount_points->RegisterFileSystem("y", type, FilePath(FPL("/z/y")))); | 201       mount_points->RegisterFileSystem("y", type, base::FilePath(FPL("/z/y")))); | 
| 202   ASSERT_TRUE( | 202   ASSERT_TRUE( | 
| 203       mount_points->RegisterFileSystem("n", type, FilePath(FPL("/m/n")))); | 203       mount_points->RegisterFileSystem("n", type, base::FilePath(FPL("/m/n")))); | 
| 204 | 204 | 
| 205   // System mount points | 205   // System mount points | 
| 206   ASSERT_TRUE(system_mount_points->RegisterFileSystem( | 206   ASSERT_TRUE(system_mount_points->RegisterFileSystem( | 
| 207       "gb", type, FilePath(FPL("/a/b")))); | 207       "gb", type, base::FilePath(FPL("/a/b")))); | 
| 208   ASSERT_TRUE( | 208   ASSERT_TRUE( | 
| 209       system_mount_points->RegisterFileSystem("gz", type, FilePath(FPL("/z")))); | 209       system_mount_points->RegisterFileSystem("gz", type, base::FilePath(FPL("/z
     ")))); | 
| 210   ASSERT_TRUE(system_mount_points->RegisterFileSystem( | 210   ASSERT_TRUE(system_mount_points->RegisterFileSystem( | 
| 211        "gp", type, FilePath(FPL("/m/n/o/p")))); | 211        "gp", type, base::FilePath(FPL("/m/n/o/p")))); | 
| 212 | 212 | 
| 213   struct TestCase { | 213   struct TestCase { | 
| 214     const FilePath::CharType* const local_path; | 214     const base::FilePath::CharType* const local_path; | 
| 215     bool success; | 215     bool success; | 
| 216     const FilePath::CharType* const virtual_path; | 216     const base::FilePath::CharType* const virtual_path; | 
| 217   }; | 217   }; | 
| 218 | 218 | 
| 219   const TestCase kTestCases[] = { | 219   const TestCase kTestCases[] = { | 
| 220     // Same paths in both mount points. | 220     // Same paths in both mount points. | 
| 221     { FPL("/a/b/c/d"), true, FPL("b/c/d") }, | 221     { FPL("/a/b/c/d"), true, FPL("b/c/d") }, | 
| 222     // System mount points path more specific. | 222     // System mount points path more specific. | 
| 223     { FPL("/m/n/o/p/r/s"), true, FPL("n/o/p/r/s") }, | 223     { FPL("/m/n/o/p/r/s"), true, FPL("n/o/p/r/s") }, | 
| 224     // System mount points path less specific. | 224     // System mount points path less specific. | 
| 225     { FPL("/z/y/x"), true, FPL("y/x") }, | 225     { FPL("/z/y/x"), true, FPL("y/x") }, | 
| 226     // Only system mount points path matches. | 226     // Only system mount points path matches. | 
| 227     { FPL("/z/q/r/s"), true, FPL("gz/q/r/s") }, | 227     { FPL("/z/q/r/s"), true, FPL("gz/q/r/s") }, | 
| 228     // No match. | 228     // No match. | 
| 229     { FPL("/foo/xxx"), false, FPL("") }, | 229     { FPL("/foo/xxx"), false, FPL("") }, | 
| 230   }; | 230   }; | 
| 231 | 231 | 
| 232   for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) { | 232   for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) { | 
| 233     // Initialize virtual path with a value. | 233     // Initialize virtual path with a value. | 
| 234     FilePath virtual_path(FPL("/mount")); | 234     base::FilePath virtual_path(FPL("/mount")); | 
| 235     FilePath local_path(kTestCases[i].local_path); | 235     base::FilePath local_path(kTestCases[i].local_path); | 
| 236     EXPECT_EQ(kTestCases[i].success, | 236     EXPECT_EQ(kTestCases[i].success, | 
| 237               provider.GetVirtualPath(local_path, &virtual_path)) | 237               provider.GetVirtualPath(local_path, &virtual_path)) | 
| 238         << "Resolving " << kTestCases[i].local_path; | 238         << "Resolving " << kTestCases[i].local_path; | 
| 239 | 239 | 
| 240     // There are no guarantees for |virtual_path| value if |GetVirtualPath| | 240     // There are no guarantees for |virtual_path| value if |GetVirtualPath| | 
| 241     // fails. | 241     // fails. | 
| 242     if (!kTestCases[i].success) | 242     if (!kTestCases[i].success) | 
| 243       continue; | 243       continue; | 
| 244 | 244 | 
| 245     FilePath expected_virtual_path(kTestCases[i].virtual_path); | 245     base::FilePath expected_virtual_path(kTestCases[i].virtual_path); | 
| 246     EXPECT_EQ(expected_virtual_path, virtual_path) | 246     EXPECT_EQ(expected_virtual_path, virtual_path) | 
| 247         << "Resolving " << kTestCases[i].local_path; | 247         << "Resolving " << kTestCases[i].local_path; | 
| 248   } | 248   } | 
| 249 } | 249 } | 
| 250 | 250 | 
| 251 }  // namespace | 251 }  // namespace | 
| 252 | 252 | 
| OLD | NEW | 
|---|