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/gdata_util.h" | 5 #include "chrome/browser/chromeos/gdata/gdata_util.h" |
6 | 6 |
7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
8 #include "testing/gmock/include/gmock/gmock.h" | 8 #include "testing/gmock/include/gmock/gmock.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
44 ExtractGDataPath( | 44 ExtractGDataPath( |
45 FilePath::FromUTF8Unsafe("/special/gdata"))); | 45 FilePath::FromUTF8Unsafe("/special/gdata"))); |
46 EXPECT_EQ(FilePath::FromUTF8Unsafe("gdata/foo.txt"), | 46 EXPECT_EQ(FilePath::FromUTF8Unsafe("gdata/foo.txt"), |
47 ExtractGDataPath( | 47 ExtractGDataPath( |
48 FilePath::FromUTF8Unsafe("/special/gdata/foo.txt"))); | 48 FilePath::FromUTF8Unsafe("/special/gdata/foo.txt"))); |
49 EXPECT_EQ(FilePath::FromUTF8Unsafe("gdata/subdir/foo.txt"), | 49 EXPECT_EQ(FilePath::FromUTF8Unsafe("gdata/subdir/foo.txt"), |
50 ExtractGDataPath( | 50 ExtractGDataPath( |
51 FilePath::FromUTF8Unsafe("/special/gdata/subdir/foo.txt"))); | 51 FilePath::FromUTF8Unsafe("/special/gdata/subdir/foo.txt"))); |
52 } | 52 } |
53 | 53 |
54 TEST(GDataUtilTest, EscapeUnescapeCacheFileName) { | |
55 std::string filename_unescaped("tmp:`~!@#$%^&*()-_=+[{|]}\\\\;\',<.>/?"); | |
satorux1
2012/04/23 21:02:25
const std::string kUnescapedFileName
hshi
2012/04/23 21:47:37
Satoru, it seems that we only declare char[] strin
satorux1
2012/04/23 21:49:07
kSomethingLike this is a naming convention used fo
hshi
2012/04/23 22:01:23
Done.
| |
56 std::string filename_escaped("tmp:`~!@#$%25^&*()-_=+[{|]}\\\\;\',<%2E>%2F?"); | |
satorux1
2012/04/23 21:02:25
ditto
hshi
2012/04/23 22:01:23
Done.
| |
57 EXPECT_EQ(filename_escaped, EscapeCacheFileName(filename_unescaped)); | |
58 EXPECT_EQ(filename_unescaped, UnescapeCacheFileName(filename_escaped)); | |
59 } | |
60 | |
61 TEST(GDataUtilTest, ParseCacheFilePath) { | |
62 std::string resource_id, md5, extra_extension; | |
63 ParseCacheFilePath( | |
64 FilePath::FromUTF8Unsafe( | |
65 "/home/user/GCache/v1/persistent/pdf:a1b2.0123456789abcdef.mounted"), | |
66 &resource_id, | |
67 &md5, | |
68 &extra_extension); | |
69 EXPECT_EQ(resource_id, "pdf:a1b2"); | |
70 EXPECT_EQ(md5, "0123456789abcdef"); | |
71 EXPECT_EQ(extra_extension, "mounted"); | |
72 | |
73 ParseCacheFilePath( | |
74 FilePath::FromUTF8Unsafe( | |
75 "/home/user/GCache/v1/tmp/pdf:a1b2.0123456789abcdef"), | |
76 &resource_id, | |
77 &md5, | |
78 &extra_extension); | |
79 EXPECT_EQ(resource_id, "pdf:a1b2"); | |
80 EXPECT_EQ(md5, "0123456789abcdef"); | |
81 EXPECT_EQ(extra_extension, ""); | |
82 | |
83 ParseCacheFilePath( | |
84 FilePath::FromUTF8Unsafe( | |
85 "/home/user/GCache/v1/pinned/pdf:a1b2"), | |
86 &resource_id, | |
87 &md5, | |
88 &extra_extension); | |
89 EXPECT_EQ(resource_id, "pdf:a1b2"); | |
90 EXPECT_EQ(md5, ""); | |
91 EXPECT_EQ(extra_extension, ""); | |
92 } | |
93 | |
54 } // namespace util | 94 } // namespace util |
55 } // namespace gdata | 95 } // namespace gdata |
OLD | NEW |