Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(796)

Side by Side Diff: chrome/browser/chromeos/gdata/gdata_util_unittest.cc

Issue 10116044: gdata: Support mounting archive files in GData cache. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: gdata: Support mounting archive files in GData cache. Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 const std::string kUnescapedFileName(
56 "tmp:`~!@#$%^&*()-_=+[{|]}\\\\;\',<.>/?");
57 const std::string kEscapedFileName(
58 "tmp:`~!@#$%25^&*()-_=+[{|]}\\\\;\',<%2E>%2F?");
59 EXPECT_EQ(kEscapedFileName, EscapeCacheFileName(kUnescapedFileName));
60 EXPECT_EQ(kUnescapedFileName, UnescapeCacheFileName(kEscapedFileName));
61 }
62
63 TEST(GDataUtilTest, ParseCacheFilePath) {
64 std::string resource_id, md5, extra_extension;
65 ParseCacheFilePath(
66 FilePath::FromUTF8Unsafe(
67 "/home/user/GCache/v1/persistent/pdf:a1b2.0123456789abcdef.mounted"),
68 &resource_id,
69 &md5,
70 &extra_extension);
71 EXPECT_EQ(resource_id, "pdf:a1b2");
72 EXPECT_EQ(md5, "0123456789abcdef");
73 EXPECT_EQ(extra_extension, "mounted");
74
75 ParseCacheFilePath(
76 FilePath::FromUTF8Unsafe(
77 "/home/user/GCache/v1/tmp/pdf:a1b2.0123456789abcdef"),
78 &resource_id,
79 &md5,
80 &extra_extension);
81 EXPECT_EQ(resource_id, "pdf:a1b2");
82 EXPECT_EQ(md5, "0123456789abcdef");
83 EXPECT_EQ(extra_extension, "");
84
85 ParseCacheFilePath(
86 FilePath::FromUTF8Unsafe(
87 "/home/user/GCache/v1/pinned/pdf:a1b2"),
88 &resource_id,
89 &md5,
90 &extra_extension);
91 EXPECT_EQ(resource_id, "pdf:a1b2");
92 EXPECT_EQ(md5, "");
93 EXPECT_EQ(extra_extension, "");
94 }
95
54 } // namespace util 96 } // namespace util
55 } // namespace gdata 97 } // namespace gdata
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_util.cc ('k') | chrome/browser/chromeos/gdata/mock_gdata_file_system.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698