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 "chrome/browser/chromeos/drive/file_system_util.h" | 5 #include "chrome/browser/chromeos/drive/file_system_util.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 scoped_refptr<storage::ExternalMountPoints> mount_points = | 124 scoped_refptr<storage::ExternalMountPoints> mount_points = |
125 storage::ExternalMountPoints::CreateRefCounted(); | 125 storage::ExternalMountPoints::CreateRefCounted(); |
126 scoped_refptr<storage::FileSystemContext> context( | 126 scoped_refptr<storage::FileSystemContext> context( |
127 new storage::FileSystemContext( | 127 new storage::FileSystemContext( |
128 base::ThreadTaskRunnerHandle::Get().get(), | 128 base::ThreadTaskRunnerHandle::Get().get(), |
129 base::ThreadTaskRunnerHandle::Get().get(), mount_points.get(), | 129 base::ThreadTaskRunnerHandle::Get().get(), mount_points.get(), |
130 NULL, // special_storage_policy | 130 NULL, // special_storage_policy |
131 NULL, // quota_manager_proxy, | 131 NULL, // quota_manager_proxy, |
132 ScopedVector<storage::FileSystemBackend>(), | 132 ScopedVector<storage::FileSystemBackend>(), |
133 std::vector<storage::URLRequestAutoMountHandler>(), | 133 std::vector<storage::URLRequestAutoMountHandler>(), |
134 temp_dir_.path(), // partition_path | 134 temp_dir_.GetPath(), // partition_path |
135 content::CreateAllowFileAccessOptions())); | 135 content::CreateAllowFileAccessOptions())); |
136 | 136 |
137 // Type:"external" + virtual_path:"drive/foo/bar" resolves to "drive/foo/bar". | 137 // Type:"external" + virtual_path:"drive/foo/bar" resolves to "drive/foo/bar". |
138 const std::string& drive_mount_name = | 138 const std::string& drive_mount_name = |
139 GetDriveMountPointPath(&profile).BaseName().AsUTF8Unsafe(); | 139 GetDriveMountPointPath(&profile).BaseName().AsUTF8Unsafe(); |
140 mount_points->RegisterFileSystem( | 140 mount_points->RegisterFileSystem( |
141 drive_mount_name, storage::kFileSystemTypeDrive, | 141 drive_mount_name, storage::kFileSystemTypeDrive, |
142 storage::FileSystemMountOption(), GetDriveMountPointPath(&profile)); | 142 storage::FileSystemMountOption(), GetDriveMountPointPath(&profile)); |
143 EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive/foo/bar"), | 143 EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive/foo/bar"), |
144 ExtractDrivePathFromFileSystemUrl(context->CrackURL( | 144 ExtractDrivePathFromFileSystemUrl(context->CrackURL( |
145 GURL("filesystem:chrome-extension://dummy-id/external/" + | 145 GURL("filesystem:chrome-extension://dummy-id/external/" + |
146 drive_mount_name + "/foo/bar")))); | 146 drive_mount_name + "/foo/bar")))); |
147 | 147 |
148 // Virtual mount name should not affect the extracted path. | 148 // Virtual mount name should not affect the extracted path. |
149 mount_points->RevokeFileSystem(drive_mount_name); | 149 mount_points->RevokeFileSystem(drive_mount_name); |
150 mount_points->RegisterFileSystem("drive2", storage::kFileSystemTypeDrive, | 150 mount_points->RegisterFileSystem("drive2", storage::kFileSystemTypeDrive, |
151 storage::FileSystemMountOption(), | 151 storage::FileSystemMountOption(), |
152 GetDriveMountPointPath(&profile)); | 152 GetDriveMountPointPath(&profile)); |
153 EXPECT_EQ( | 153 EXPECT_EQ( |
154 base::FilePath::FromUTF8Unsafe("drive/foo/bar"), | 154 base::FilePath::FromUTF8Unsafe("drive/foo/bar"), |
155 ExtractDrivePathFromFileSystemUrl(context->CrackURL(GURL( | 155 ExtractDrivePathFromFileSystemUrl(context->CrackURL(GURL( |
156 "filesystem:chrome-extension://dummy-id/external/drive2/foo/bar")))); | 156 "filesystem:chrome-extension://dummy-id/external/drive2/foo/bar")))); |
157 | 157 |
158 // Type:"external" + virtual_path:"Downloads/foo" is not a Drive path. | 158 // Type:"external" + virtual_path:"Downloads/foo" is not a Drive path. |
159 mount_points->RegisterFileSystem( | 159 mount_points->RegisterFileSystem( |
160 "Downloads", storage::kFileSystemTypeNativeLocal, | 160 "Downloads", storage::kFileSystemTypeNativeLocal, |
161 storage::FileSystemMountOption(), temp_dir_.path()); | 161 storage::FileSystemMountOption(), temp_dir_.GetPath()); |
162 EXPECT_EQ( | 162 EXPECT_EQ( |
163 base::FilePath(), | 163 base::FilePath(), |
164 ExtractDrivePathFromFileSystemUrl(context->CrackURL(GURL( | 164 ExtractDrivePathFromFileSystemUrl(context->CrackURL(GURL( |
165 "filesystem:chrome-extension://dummy-id/external/Downloads/foo")))); | 165 "filesystem:chrome-extension://dummy-id/external/Downloads/foo")))); |
166 | 166 |
167 // Type:"isolated" + virtual_path:"isolated_id/name" mapped on a Drive path. | 167 // Type:"isolated" + virtual_path:"isolated_id/name" mapped on a Drive path. |
168 std::string isolated_name; | 168 std::string isolated_name; |
169 std::string isolated_id = | 169 std::string isolated_id = |
170 storage::IsolatedContext::GetInstance()->RegisterFileSystemForPath( | 170 storage::IsolatedContext::GetInstance()->RegisterFileSystemForPath( |
171 storage::kFileSystemTypeNativeForPlatformApp, std::string(), | 171 storage::kFileSystemTypeNativeForPlatformApp, std::string(), |
172 GetDriveMountPointPath(&profile).AppendASCII("bar/buz"), | 172 GetDriveMountPointPath(&profile).AppendASCII("bar/buz"), |
173 &isolated_name); | 173 &isolated_name); |
174 EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive/bar/buz"), | 174 EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive/bar/buz"), |
175 ExtractDrivePathFromFileSystemUrl(context->CrackURL( | 175 ExtractDrivePathFromFileSystemUrl(context->CrackURL( |
176 GURL("filesystem:chrome-extension://dummy-id/isolated/" + | 176 GURL("filesystem:chrome-extension://dummy-id/isolated/" + |
177 isolated_id + "/" + isolated_name)))); | 177 isolated_id + "/" + isolated_name)))); |
178 } | 178 } |
179 | 179 |
180 TEST_F(ProfileRelatedFileSystemUtilTest, GetCacheRootPath) { | 180 TEST_F(ProfileRelatedFileSystemUtilTest, GetCacheRootPath) { |
181 TestingProfile profile; | 181 TestingProfile profile; |
182 base::FilePath profile_path = profile.GetPath(); | 182 base::FilePath profile_path = profile.GetPath(); |
183 EXPECT_EQ(profile_path.AppendASCII("GCache/v1"), | 183 EXPECT_EQ(profile_path.AppendASCII("GCache/v1"), |
184 util::GetCacheRootPath(&profile)); | 184 util::GetCacheRootPath(&profile)); |
185 } | 185 } |
186 | 186 |
187 } // namespace util | 187 } // namespace util |
188 } // namespace drive | 188 } // namespace drive |
OLD | NEW |