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

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

Issue 442043002: ProfileManager doesn't depend on "--login-profile" switch. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments addressed and rebased. Created 6 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 | Annotate | Revision Log
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/drive/file_system_util.h" 5 #include "chrome/browser/chromeos/drive/file_system_util.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/files/scoped_temp_dir.h" 9 #include "base/files/scoped_temp_dir.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "chrome/browser/chromeos/profiles/profile_helper.h"
12 #include "chrome/common/chrome_constants.h" 13 #include "chrome/common/chrome_constants.h"
mtomasz 2014/08/22 05:43:40 The chrome_constants.h include is not used anymore
dzhioev (left Google) 2014/08/25 17:39:11 Done.
13 #include "chrome/test/base/testing_browser_process.h" 14 #include "chrome/test/base/testing_browser_process.h"
14 #include "chrome/test/base/testing_profile.h" 15 #include "chrome/test/base/testing_profile.h"
15 #include "chrome/test/base/testing_profile_manager.h" 16 #include "chrome/test/base/testing_profile_manager.h"
16 #include "content/public/test/test_browser_thread_bundle.h" 17 #include "content/public/test/test_browser_thread_bundle.h"
17 #include "content/public/test/test_file_system_options.h" 18 #include "content/public/test/test_file_system_options.h"
18 #include "google_apis/drive/test_util.h" 19 #include "google_apis/drive/test_util.h"
19 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
20 #include "webkit/browser/fileapi/external_mount_points.h" 21 #include "webkit/browser/fileapi/external_mount_points.h"
21 #include "webkit/browser/fileapi/file_system_backend.h" 22 #include "webkit/browser/fileapi/file_system_backend.h"
22 #include "webkit/browser/fileapi/file_system_context.h" 23 #include "webkit/browser/fileapi/file_system_context.h"
(...skipping 11 matching lines...) Expand all
34 class ProfileRelatedFileSystemUtilTest : public testing::Test { 35 class ProfileRelatedFileSystemUtilTest : public testing::Test {
35 protected: 36 protected:
36 ProfileRelatedFileSystemUtilTest() 37 ProfileRelatedFileSystemUtilTest()
37 : testing_profile_manager_(TestingBrowserProcess::GetGlobal()) { 38 : testing_profile_manager_(TestingBrowserProcess::GetGlobal()) {
38 } 39 }
39 40
40 virtual void SetUp() OVERRIDE { 41 virtual void SetUp() OVERRIDE {
41 ASSERT_TRUE(testing_profile_manager_.SetUp()); 42 ASSERT_TRUE(testing_profile_manager_.SetUp());
42 } 43 }
43 44
44 Profile* CreateProfileWithName(const std::string& name) { 45 Profile* CreateProfileWithName(const std::string& name) {
mtomasz 2014/08/22 05:43:40 nit: This utility method became trivial, so we sho
dzhioev (left Google) 2014/08/25 17:39:11 Done.
45 return testing_profile_manager_.CreateTestingProfile( 46 return testing_profile_manager_.CreateTestingProfile(name);
46 chrome::kProfileDirPrefix + name);
47 } 47 }
48 48
49 private: 49 private:
50 content::TestBrowserThreadBundle thread_bundle_; 50 content::TestBrowserThreadBundle thread_bundle_;
51 TestingProfileManager testing_profile_manager_; 51 TestingProfileManager testing_profile_manager_;
52 }; 52 };
53 53
54 } // namespace 54 } // namespace
55 55
56 TEST(FileSystemUtilTest, FilePathToDriveURL) { 56 TEST(FileSystemUtilTest, FilePathToDriveURL) {
(...skipping 15 matching lines...) Expand all
72 // Path with multi byte characters. 72 // Path with multi byte characters.
73 base::string16 utf16_string; 73 base::string16 utf16_string;
74 utf16_string.push_back(0x307b); // HIRAGANA_LETTER_HO 74 utf16_string.push_back(0x307b); // HIRAGANA_LETTER_HO
75 utf16_string.push_back(0x3052); // HIRAGANA_LETTER_GE 75 utf16_string.push_back(0x3052); // HIRAGANA_LETTER_GE
76 path = GetDriveMyDriveRootPath().Append( 76 path = GetDriveMyDriveRootPath().Append(
77 base::FilePath::FromUTF8Unsafe(base::UTF16ToUTF8(utf16_string) + ".txt")); 77 base::FilePath::FromUTF8Unsafe(base::UTF16ToUTF8(utf16_string) + ".txt"));
78 EXPECT_EQ(path, DriveURLToFilePath(FilePathToDriveURL(path))); 78 EXPECT_EQ(path, DriveURLToFilePath(FilePathToDriveURL(path)));
79 } 79 }
80 80
81 TEST_F(ProfileRelatedFileSystemUtilTest, GetDriveMountPointPath) { 81 TEST_F(ProfileRelatedFileSystemUtilTest, GetDriveMountPointPath) {
82 Profile* profile = CreateProfileWithName("hash1"); 82 Profile* profile = CreateProfileWithName("user1");
83 EXPECT_EQ(base::FilePath::FromUTF8Unsafe("/special/drive-hash1"), 83 std::string user_id_hash =
84 chromeos::ProfileHelper::GetUserIdHashByUserIdForTesting("user1");
85 EXPECT_EQ(base::FilePath::FromUTF8Unsafe("/special/drive-" + user_id_hash),
84 GetDriveMountPointPath(profile)); 86 GetDriveMountPointPath(profile));
85 } 87 }
86 88
87 TEST_F(ProfileRelatedFileSystemUtilTest, ExtractProfileFromPath) { 89 TEST_F(ProfileRelatedFileSystemUtilTest, ExtractProfileFromPath) {
88 Profile* profile1 = CreateProfileWithName("hash1"); 90 Profile* profile1 = CreateProfileWithName("user1");
89 Profile* profile2 = CreateProfileWithName("hash2"); 91 Profile* profile2 = CreateProfileWithName("user2");
90 EXPECT_EQ(profile1, ExtractProfileFromPath( 92 std::string user1_id_hash =
mtomasz 2014/08/22 05:43:40 optional: const would be nice, but it seems that i
dzhioev (left Google) 2014/08/25 17:39:11 Done.
91 base::FilePath::FromUTF8Unsafe("/special/drive-hash1"))); 93 chromeos::ProfileHelper::GetUserIdHashByUserIdForTesting("user1");
92 EXPECT_EQ(profile2, ExtractProfileFromPath( 94 std::string user2_id_hash =
93 base::FilePath::FromUTF8Unsafe("/special/drive-hash2/root/xxx"))); 95 chromeos::ProfileHelper::GetUserIdHashByUserIdForTesting("user2");
96 EXPECT_EQ(profile1,
97 ExtractProfileFromPath(base::FilePath::FromUTF8Unsafe(
98 "/special/drive-" + user1_id_hash)));
99 EXPECT_EQ(profile2,
100 ExtractProfileFromPath(base::FilePath::FromUTF8Unsafe(
101 "/special/drive-" + user2_id_hash + "/root/xxx")));
94 EXPECT_EQ(NULL, ExtractProfileFromPath( 102 EXPECT_EQ(NULL, ExtractProfileFromPath(
95 base::FilePath::FromUTF8Unsafe("/special/non-drive-path"))); 103 base::FilePath::FromUTF8Unsafe("/special/non-drive-path")));
96 } 104 }
97 105
98 TEST(FileSystemUtilTest, IsUnderDriveMountPoint) { 106 TEST(FileSystemUtilTest, IsUnderDriveMountPoint) {
99 EXPECT_FALSE(IsUnderDriveMountPoint( 107 EXPECT_FALSE(IsUnderDriveMountPoint(
100 base::FilePath::FromUTF8Unsafe("/wherever/foo.txt"))); 108 base::FilePath::FromUTF8Unsafe("/wherever/foo.txt")));
101 EXPECT_FALSE(IsUnderDriveMountPoint( 109 EXPECT_FALSE(IsUnderDriveMountPoint(
102 base::FilePath::FromUTF8Unsafe("/special/foo.txt"))); 110 base::FilePath::FromUTF8Unsafe("/special/foo.txt")));
103 EXPECT_FALSE(IsUnderDriveMountPoint( 111 EXPECT_FALSE(IsUnderDriveMountPoint(
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 // Non GDoc file. 290 // Non GDoc file.
283 file = temp_dir.path().AppendASCII("test.txt"); 291 file = temp_dir.path().AppendASCII("test.txt");
284 std::string data = "Hello world!"; 292 std::string data = "Hello world!";
285 EXPECT_TRUE(google_apis::test_util::WriteStringToFile(file, data)); 293 EXPECT_TRUE(google_apis::test_util::WriteStringToFile(file, data));
286 EXPECT_TRUE(ReadUrlFromGDocFile(file).is_empty()); 294 EXPECT_TRUE(ReadUrlFromGDocFile(file).is_empty());
287 EXPECT_TRUE(ReadResourceIdFromGDocFile(file).empty()); 295 EXPECT_TRUE(ReadResourceIdFromGDocFile(file).empty());
288 } 296 }
289 297
290 } // namespace util 298 } // namespace util
291 } // namespace drive 299 } // namespace drive
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698