Chromium Code Reviews| Index: chrome/browser/chromeos/drive/drive_file_system_util_unittest.cc |
| diff --git a/chrome/browser/chromeos/drive/drive_file_system_util_unittest.cc b/chrome/browser/chromeos/drive/drive_file_system_util_unittest.cc |
| index 70ba8e5fd874f8d2fcd55a908de0ac2d5e0b3911..935579d0ae278502741a6de74b8cba01698813e8 100644 |
| --- a/chrome/browser/chromeos/drive/drive_file_system_util_unittest.cc |
| +++ b/chrome/browser/chromeos/drive/drive_file_system_util_unittest.cc |
| @@ -5,8 +5,15 @@ |
| #include "chrome/browser/chromeos/drive/drive_file_system_util.h" |
| #include "base/files/file_path.h" |
| +#include "base/message_loop.h" |
| #include "base/utf_string_conversions.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| +#include "webkit/fileapi/external_mount_points.h" |
| +#include "webkit/fileapi/file_system_context.h" |
| +#include "webkit/fileapi/file_system_task_runners.h" |
| +#include "webkit/fileapi/file_system_url.h" |
| +#include "webkit/fileapi/isolated_context.h" |
| +#include "webkit/fileapi/mock_file_system_options.h" |
| namespace drive { |
| namespace util { |
| @@ -76,6 +83,55 @@ TEST(DriveFileSystemUtilTest, ExtractDrivePath) { |
| "/special/drive/subdir/foo.txt"))); |
| } |
| +TEST(DriveFileSystemUtilTest, ExtractDrivePathFromFileSystemUrl) { |
| + // Set up file system context for testing. |
| + MessageLoop message_loop; |
| + scoped_refptr<fileapi::ExternalMountPoints> mount_points = |
| + fileapi::ExternalMountPoints::CreateRefCounted(); |
| + scoped_refptr<fileapi::FileSystemContext> context( |
| + new fileapi::FileSystemContext( |
| + fileapi::FileSystemTaskRunners::CreateMockTaskRunners(), |
| + mount_points, |
| + NULL, // special_storage_policy |
| + NULL, // quota_manager_proxy, |
| + base::FilePath::FromUTF8Unsafe("/tmp"), // partition_path |
|
hashimoto
2013/04/08 06:03:49
Using "/tmp" seems not multi platform friendly.
Ho
kinaba
2013/04/08 06:43:41
Done.
|
| + fileapi::CreateAllowFileAccessOptions())); |
| + |
| + // Type:"external" + virtual_path:"drive/foo/bar" resolves to "drive/foo/bar". |
| + mount_points->RegisterRemoteFileSystem( |
| + "drive", |
| + fileapi::kFileSystemTypeDrive, |
| + NULL, // RemoteFileSystemProxyInterface |
| + base::FilePath::FromUTF8Unsafe("/special/drive")); |
|
hashimoto
2013/04/08 06:03:49
How about using drive::util::GetDriveMountPointPat
kinaba
2013/04/08 06:43:41
Done (and added a test for the case "drive" is not
|
| + EXPECT_EQ( |
| + base::FilePath::FromUTF8Unsafe("drive/foo/bar"), |
| + ExtractDrivePathFromFileSystemUrl(context->CrackURL(GURL( |
| + "filesystem:chrome-extension://dummy-id/external/drive/foo/bar")))); |
| + |
| + // Type:"external" + virtual_path:"Downloads/foo" is not a Drive path. |
| + mount_points->RegisterFileSystem( |
| + "Downloads", |
| + fileapi::kFileSystemTypeNativeLocal, |
| + base::FilePath::FromUTF8Unsafe("/tmp")); |
| + EXPECT_EQ( |
| + base::FilePath(), |
| + ExtractDrivePathFromFileSystemUrl(context->CrackURL(GURL( |
| + "filesystem:chrome-extension://dummy-id/external/Downloads/foo")))); |
| + |
| + // Type:"isolated" + virtual_path:"isolated_id/name" mapped on a Drive path. |
| + std::string isolated_name; |
| + std::string isolated_id = |
| + fileapi::IsolatedContext::GetInstance()->RegisterFileSystemForPath( |
| + fileapi::kFileSystemTypeNativeForPlatformApp, |
| + base::FilePath::FromUTF8Unsafe("/special/drive/bar/buz"), |
|
hashimoto
2013/04/08 06:03:49
How about using GetDriveMountPointPath()?
kinaba
2013/04/08 06:43:41
Done.
|
| + &isolated_name); |
| + EXPECT_EQ( |
| + base::FilePath::FromUTF8Unsafe("drive/bar/buz"), |
| + ExtractDrivePathFromFileSystemUrl(context->CrackURL(GURL( |
| + "filesystem:chrome-extension://dummy-id/isolated/" + |
| + isolated_id + "/" + isolated_name)))); |
| +} |
| + |
| TEST(DriveFileSystemUtilTest, EscapeUnescapeCacheFileName) { |
| const std::string kUnescapedFileName( |
| "tmp:`~!@#$%^&*()-_=+[{|]}\\\\;\',<.>/?"); |