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

Side by Side Diff: chrome/browser/chromeos/drive/file_system_util_unittest.cc

Issue 1296483003: Move chrome/browser/chromeos/drive/resource* (+deps) into components/drive. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebasing... Created 5 years, 4 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/file_system_util.h" 5 #include "chrome/browser/chromeos/drive/file_system_util.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 } // namespace 53 } // namespace
54 54
55 TEST_F(ProfileRelatedFileSystemUtilTest, GetDriveMountPointPath) { 55 TEST_F(ProfileRelatedFileSystemUtilTest, GetDriveMountPointPath) {
56 Profile* profile = testing_profile_manager().CreateTestingProfile("user1"); 56 Profile* profile = testing_profile_manager().CreateTestingProfile("user1");
57 const std::string user_id_hash = 57 const std::string user_id_hash =
58 chromeos::ProfileHelper::GetUserIdHashByUserIdForTesting("user1"); 58 chromeos::ProfileHelper::GetUserIdHashByUserIdForTesting("user1");
59 EXPECT_EQ(base::FilePath::FromUTF8Unsafe("/special/drive-" + user_id_hash), 59 EXPECT_EQ(base::FilePath::FromUTF8Unsafe("/special/drive-" + user_id_hash),
60 GetDriveMountPointPath(profile)); 60 GetDriveMountPointPath(profile));
61 } 61 }
62 62
63 TEST_F(ProfileRelatedFileSystemUtilTest, IsUnderDriveMountPoint) {
64 EXPECT_FALSE(IsUnderDriveMountPoint(
65 base::FilePath::FromUTF8Unsafe("/wherever/foo.txt")));
66 EXPECT_FALSE(IsUnderDriveMountPoint(
67 base::FilePath::FromUTF8Unsafe("/special/foo.txt")));
68 EXPECT_FALSE(IsUnderDriveMountPoint(
69 base::FilePath::FromUTF8Unsafe("special/drive/foo.txt")));
70
71 EXPECT_TRUE(
72 IsUnderDriveMountPoint(base::FilePath::FromUTF8Unsafe("/special/drive")));
73 EXPECT_TRUE(IsUnderDriveMountPoint(
74 base::FilePath::FromUTF8Unsafe("/special/drive/foo.txt")));
75 EXPECT_TRUE(IsUnderDriveMountPoint(
76 base::FilePath::FromUTF8Unsafe("/special/drive/subdir/foo.txt")));
77 EXPECT_TRUE(IsUnderDriveMountPoint(
78 base::FilePath::FromUTF8Unsafe("/special/drive-xxx/foo.txt")));
79 }
80
81 TEST_F(ProfileRelatedFileSystemUtilTest, ExtractDrivePath) {
82 EXPECT_EQ(
83 base::FilePath(),
84 ExtractDrivePath(base::FilePath::FromUTF8Unsafe("/wherever/foo.txt")));
85 EXPECT_EQ(
86 base::FilePath(),
87 ExtractDrivePath(base::FilePath::FromUTF8Unsafe("/special/foo.txt")));
88
89 EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive"),
90 ExtractDrivePath(base::FilePath::FromUTF8Unsafe("/special/drive")));
91 EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive/foo.txt"),
92 ExtractDrivePath(
93 base::FilePath::FromUTF8Unsafe("/special/drive/foo.txt")));
94 EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive/subdir/foo.txt"),
95 ExtractDrivePath(base::FilePath::FromUTF8Unsafe(
96 "/special/drive/subdir/foo.txt")));
97 EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive/foo.txt"),
98 ExtractDrivePath(
99 base::FilePath::FromUTF8Unsafe("/special/drive-xxx/foo.txt")));
100 }
101
63 TEST_F(ProfileRelatedFileSystemUtilTest, ExtractProfileFromPath) { 102 TEST_F(ProfileRelatedFileSystemUtilTest, ExtractProfileFromPath) {
64 Profile* profile1 = testing_profile_manager().CreateTestingProfile("user1"); 103 Profile* profile1 = testing_profile_manager().CreateTestingProfile("user1");
65 Profile* profile2 = testing_profile_manager().CreateTestingProfile("user2"); 104 Profile* profile2 = testing_profile_manager().CreateTestingProfile("user2");
66 const std::string user1_id_hash = 105 const std::string user1_id_hash =
67 chromeos::ProfileHelper::GetUserIdHashByUserIdForTesting("user1"); 106 chromeos::ProfileHelper::GetUserIdHashByUserIdForTesting("user1");
68 const std::string user2_id_hash = 107 const std::string user2_id_hash =
69 chromeos::ProfileHelper::GetUserIdHashByUserIdForTesting("user2"); 108 chromeos::ProfileHelper::GetUserIdHashByUserIdForTesting("user2");
70 EXPECT_EQ(profile1, ExtractProfileFromPath(base::FilePath::FromUTF8Unsafe( 109 EXPECT_EQ(profile1, ExtractProfileFromPath(base::FilePath::FromUTF8Unsafe(
71 "/special/drive-" + user1_id_hash))); 110 "/special/drive-" + user1_id_hash)));
72 EXPECT_EQ(profile2, ExtractProfileFromPath(base::FilePath::FromUTF8Unsafe( 111 EXPECT_EQ(profile2, ExtractProfileFromPath(base::FilePath::FromUTF8Unsafe(
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 179
141 TEST_F(ProfileRelatedFileSystemUtilTest, GetCacheRootPath) { 180 TEST_F(ProfileRelatedFileSystemUtilTest, GetCacheRootPath) {
142 TestingProfile profile; 181 TestingProfile profile;
143 base::FilePath profile_path = profile.GetPath(); 182 base::FilePath profile_path = profile.GetPath();
144 EXPECT_EQ(profile_path.AppendASCII("GCache/v1"), 183 EXPECT_EQ(profile_path.AppendASCII("GCache/v1"),
145 util::GetCacheRootPath(&profile)); 184 util::GetCacheRootPath(&profile));
146 } 185 }
147 186
148 } // namespace util 187 } // namespace util
149 } // namespace drive 188 } // namespace drive
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/file_system_util.cc ('k') | chrome/browser/chromeos/drive/file_write_watcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698