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/gdata/drive_file_system_util.h" | 5 #include "chrome/browser/chromeos/gdata/drive_file_system_util.h" |
6 | 6 |
7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 namespace gdata { | 10 namespace gdata { |
11 namespace util { | 11 namespace util { |
12 | 12 |
13 TEST(DriveFileSystemUtilTest, IsUnderGDataMountPoint) { | 13 TEST(DriveFileSystemUtilTest, IsUnderDriveMountPoint) { |
14 EXPECT_FALSE(IsUnderGDataMountPoint( | 14 EXPECT_FALSE(IsUnderDriveMountPoint( |
15 FilePath::FromUTF8Unsafe("/wherever/foo.txt"))); | 15 FilePath::FromUTF8Unsafe("/wherever/foo.txt"))); |
16 EXPECT_FALSE(IsUnderGDataMountPoint( | 16 EXPECT_FALSE(IsUnderDriveMountPoint( |
17 FilePath::FromUTF8Unsafe("/special/foo.txt"))); | 17 FilePath::FromUTF8Unsafe("/special/foo.txt"))); |
18 EXPECT_FALSE(IsUnderGDataMountPoint( | 18 EXPECT_FALSE(IsUnderDriveMountPoint( |
19 FilePath::FromUTF8Unsafe("/special/drivex/foo.txt"))); | 19 FilePath::FromUTF8Unsafe("/special/drivex/foo.txt"))); |
20 EXPECT_FALSE(IsUnderGDataMountPoint( | 20 EXPECT_FALSE(IsUnderDriveMountPoint( |
21 FilePath::FromUTF8Unsafe("special/drivex/foo.txt"))); | 21 FilePath::FromUTF8Unsafe("special/drivex/foo.txt"))); |
22 | 22 |
23 EXPECT_TRUE(IsUnderGDataMountPoint( | 23 EXPECT_TRUE(IsUnderDriveMountPoint( |
24 FilePath::FromUTF8Unsafe("/special/drive"))); | 24 FilePath::FromUTF8Unsafe("/special/drive"))); |
25 EXPECT_TRUE(IsUnderGDataMountPoint( | 25 EXPECT_TRUE(IsUnderDriveMountPoint( |
26 FilePath::FromUTF8Unsafe("/special/drive/foo.txt"))); | 26 FilePath::FromUTF8Unsafe("/special/drive/foo.txt"))); |
27 EXPECT_TRUE(IsUnderGDataMountPoint( | 27 EXPECT_TRUE(IsUnderDriveMountPoint( |
28 FilePath::FromUTF8Unsafe("/special/drive/subdir/foo.txt"))); | 28 FilePath::FromUTF8Unsafe("/special/drive/subdir/foo.txt"))); |
29 } | 29 } |
30 | 30 |
31 TEST(DriveFileSystemUtilTest, ExtractGDataPath) { | 31 TEST(DriveFileSystemUtilTest, ExtractDrivePath) { |
32 EXPECT_EQ(FilePath(), | 32 EXPECT_EQ(FilePath(), |
33 ExtractGDataPath( | 33 ExtractDrivePath( |
34 FilePath::FromUTF8Unsafe("/wherever/foo.txt"))); | 34 FilePath::FromUTF8Unsafe("/wherever/foo.txt"))); |
35 EXPECT_EQ(FilePath(), | 35 EXPECT_EQ(FilePath(), |
36 ExtractGDataPath( | 36 ExtractDrivePath( |
37 FilePath::FromUTF8Unsafe("/special/foo.txt"))); | 37 FilePath::FromUTF8Unsafe("/special/foo.txt"))); |
38 EXPECT_EQ(FilePath(), | 38 EXPECT_EQ(FilePath(), |
39 ExtractGDataPath( | 39 ExtractDrivePath( |
40 FilePath::FromUTF8Unsafe("/special/gdatax/foo.txt"))); | 40 FilePath::FromUTF8Unsafe("/special/gdatax/foo.txt"))); |
41 | 41 |
42 EXPECT_EQ(FilePath::FromUTF8Unsafe("drive"), | 42 EXPECT_EQ(FilePath::FromUTF8Unsafe("drive"), |
43 ExtractGDataPath( | 43 ExtractDrivePath( |
44 FilePath::FromUTF8Unsafe("/special/drive"))); | 44 FilePath::FromUTF8Unsafe("/special/drive"))); |
45 EXPECT_EQ(FilePath::FromUTF8Unsafe("drive/foo.txt"), | 45 EXPECT_EQ(FilePath::FromUTF8Unsafe("drive/foo.txt"), |
46 ExtractGDataPath( | 46 ExtractDrivePath( |
47 FilePath::FromUTF8Unsafe("/special/drive/foo.txt"))); | 47 FilePath::FromUTF8Unsafe("/special/drive/foo.txt"))); |
48 EXPECT_EQ(FilePath::FromUTF8Unsafe("drive/subdir/foo.txt"), | 48 EXPECT_EQ(FilePath::FromUTF8Unsafe("drive/subdir/foo.txt"), |
49 ExtractGDataPath( | 49 ExtractDrivePath( |
50 FilePath::FromUTF8Unsafe("/special/drive/subdir/foo.txt"))); | 50 FilePath::FromUTF8Unsafe("/special/drive/subdir/foo.txt"))); |
51 } | 51 } |
52 | 52 |
53 TEST(DriveFileSystemUtilTest, EscapeUnescapeCacheFileName) { | 53 TEST(DriveFileSystemUtilTest, EscapeUnescapeCacheFileName) { |
54 const std::string kUnescapedFileName( | 54 const std::string kUnescapedFileName( |
55 "tmp:`~!@#$%^&*()-_=+[{|]}\\\\;\',<.>/?"); | 55 "tmp:`~!@#$%^&*()-_=+[{|]}\\\\;\',<.>/?"); |
56 const std::string kEscapedFileName( | 56 const std::string kEscapedFileName( |
57 "tmp:`~!@#$%25^&*()-_=+[{|]}\\\\;\',<%2E>%2F?"); | 57 "tmp:`~!@#$%25^&*()-_=+[{|]}\\\\;\',<%2E>%2F?"); |
58 EXPECT_EQ(kEscapedFileName, EscapeCacheFileName(kUnescapedFileName)); | 58 EXPECT_EQ(kEscapedFileName, EscapeCacheFileName(kUnescapedFileName)); |
59 EXPECT_EQ(kUnescapedFileName, UnescapeCacheFileName(kEscapedFileName)); | 59 EXPECT_EQ(kUnescapedFileName, UnescapeCacheFileName(kEscapedFileName)); |
(...skipping 27 matching lines...) Expand all Loading... |
87 &resource_id, | 87 &resource_id, |
88 &md5, | 88 &md5, |
89 &extra_extension); | 89 &extra_extension); |
90 EXPECT_EQ(resource_id, "pdf:a1b2"); | 90 EXPECT_EQ(resource_id, "pdf:a1b2"); |
91 EXPECT_EQ(md5, ""); | 91 EXPECT_EQ(md5, ""); |
92 EXPECT_EQ(extra_extension, ""); | 92 EXPECT_EQ(extra_extension, ""); |
93 } | 93 } |
94 | 94 |
95 } // namespace util | 95 } // namespace util |
96 } // namespace gdata | 96 } // namespace gdata |
OLD | NEW |