Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/drive_file_system_util.h" | 5 #include "chrome/browser/chromeos/drive/drive_file_system_util.h" |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 69 ExtractDrivePath( | 69 ExtractDrivePath( |
| 70 base::FilePath::FromUTF8Unsafe("/special/drive"))); | 70 base::FilePath::FromUTF8Unsafe("/special/drive"))); |
| 71 EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive/foo.txt"), | 71 EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive/foo.txt"), |
| 72 ExtractDrivePath( | 72 ExtractDrivePath( |
| 73 base::FilePath::FromUTF8Unsafe("/special/drive/foo.txt"))); | 73 base::FilePath::FromUTF8Unsafe("/special/drive/foo.txt"))); |
| 74 EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive/subdir/foo.txt"), | 74 EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive/subdir/foo.txt"), |
| 75 ExtractDrivePath(base::FilePath::FromUTF8Unsafe( | 75 ExtractDrivePath(base::FilePath::FromUTF8Unsafe( |
| 76 "/special/drive/subdir/foo.txt"))); | 76 "/special/drive/subdir/foo.txt"))); |
| 77 } | 77 } |
| 78 | 78 |
| 79 TEST(DriveFileSystemUtilTest, ExtractDrivePathFromFileSystemUrl) { | |
| 80 const GURL dummy_origin("chrome-extension://extension-id"); | |
| 81 EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive/foo/bar"), | |
| 82 ExtractDrivePathFromFileSystemUrl( | |
| 83 fileapi::FileSystemURL::CreateForTest( | |
| 84 dummy_origin, | |
| 85 fileapi::kFileSystemTypeDrive, | |
| 86 base::FilePath::FromUTF8Unsafe("/special/drive/foo/bar")))); | |
| 87 EXPECT_EQ(base::FilePath(), | |
| 88 ExtractDrivePathFromFileSystemUrl( | |
| 89 fileapi::FileSystemURL::CreateForTest( | |
| 90 dummy_origin, | |
| 91 fileapi::kFileSystemTypeDrive, | |
| 92 base::FilePath::FromUTF8Unsafe("/special/drivex/foo")))); | |
| 93 EXPECT_EQ(base::FilePath(), | |
|
hashimoto
2013/04/08 03:51:00
How about testing a case where |virtual_path| is d
kinaba
2013/04/08 05:47:50
Done. I hope the things became clearer.
| |
| 94 ExtractDrivePathFromFileSystemUrl( | |
| 95 fileapi::FileSystemURL::CreateForTest( | |
| 96 dummy_origin, | |
| 97 fileapi::kFileSystemTypeNativeLocal, | |
| 98 base::FilePath::FromUTF8Unsafe("/Downloads/foo.txt")))); | |
| 99 } | |
| 100 | |
| 79 TEST(DriveFileSystemUtilTest, EscapeUnescapeCacheFileName) { | 101 TEST(DriveFileSystemUtilTest, EscapeUnescapeCacheFileName) { |
| 80 const std::string kUnescapedFileName( | 102 const std::string kUnescapedFileName( |
| 81 "tmp:`~!@#$%^&*()-_=+[{|]}\\\\;\',<.>/?"); | 103 "tmp:`~!@#$%^&*()-_=+[{|]}\\\\;\',<.>/?"); |
| 82 const std::string kEscapedFileName( | 104 const std::string kEscapedFileName( |
| 83 "tmp:`~!@#$%25^&*()-_=+[{|]}\\\\;\',<%2E>%2F?"); | 105 "tmp:`~!@#$%25^&*()-_=+[{|]}\\\\;\',<%2E>%2F?"); |
| 84 EXPECT_EQ(kEscapedFileName, EscapeCacheFileName(kUnescapedFileName)); | 106 EXPECT_EQ(kEscapedFileName, EscapeCacheFileName(kUnescapedFileName)); |
| 85 EXPECT_EQ(kUnescapedFileName, UnescapeCacheFileName(kEscapedFileName)); | 107 EXPECT_EQ(kUnescapedFileName, UnescapeCacheFileName(kEscapedFileName)); |
| 86 } | 108 } |
| 87 | 109 |
| 88 TEST(DriveFileSystemUtilTest, EscapeUtf8FileName) { | 110 TEST(DriveFileSystemUtilTest, EscapeUtf8FileName) { |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 186 EXPECT_FALSE(util::IsSpecialResourceId("file:123")); | 208 EXPECT_FALSE(util::IsSpecialResourceId("file:123")); |
| 187 EXPECT_FALSE(util::IsSpecialResourceId("folder:root")); | 209 EXPECT_FALSE(util::IsSpecialResourceId("folder:root")); |
| 188 EXPECT_FALSE(util::IsSpecialResourceId("folder:xyz")); | 210 EXPECT_FALSE(util::IsSpecialResourceId("folder:xyz")); |
| 189 | 211 |
| 190 EXPECT_TRUE(util::IsSpecialResourceId("<drive>")); | 212 EXPECT_TRUE(util::IsSpecialResourceId("<drive>")); |
| 191 EXPECT_TRUE(util::IsSpecialResourceId("<other>")); | 213 EXPECT_TRUE(util::IsSpecialResourceId("<other>")); |
| 192 } | 214 } |
| 193 | 215 |
| 194 } // namespace util | 216 } // namespace util |
| 195 } // namespace drive | 217 } // namespace drive |
| OLD | NEW |