| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/file_manager/path_util.h" | 5 #include "chrome/browser/chromeos/file_manager/path_util.h" |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "chrome/browser/chromeos/drive/file_system_util.h" | 8 #include "chrome/browser/chromeos/drive/file_system_util.h" |
| 9 #include "chrome/common/chrome_constants.h" | 9 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 10 #include "chrome/test/base/testing_browser_process.h" | 10 #include "chrome/test/base/testing_browser_process.h" |
| 11 #include "chrome/test/base/testing_profile.h" | 11 #include "chrome/test/base/testing_profile.h" |
| 12 #include "chrome/test/base/testing_profile_manager.h" | 12 #include "chrome/test/base/testing_profile_manager.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 14 |
| 15 namespace file_manager { | 15 namespace file_manager { |
| 16 namespace util { | 16 namespace util { |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 class ProfileRelatedTest : public testing::Test { | 19 class ProfileRelatedTest : public testing::Test { |
| 20 protected: | 20 protected: |
| 21 ProfileRelatedTest() | 21 ProfileRelatedTest() |
| 22 : testing_profile_manager_(TestingBrowserProcess::GetGlobal()) { | 22 : testing_profile_manager_(TestingBrowserProcess::GetGlobal()) { |
| 23 } | 23 } |
| 24 | 24 |
| 25 virtual void SetUp() OVERRIDE { | 25 virtual void SetUp() OVERRIDE { |
| 26 ASSERT_TRUE(testing_profile_manager_.SetUp()); | 26 ASSERT_TRUE(testing_profile_manager_.SetUp()); |
| 27 } | 27 } |
| 28 | 28 |
| 29 Profile* CreateProfileWithName(const std::string& name) { | 29 Profile* CreateProfileWithName(const std::string& name) { |
| 30 return testing_profile_manager_.CreateTestingProfile( | 30 return testing_profile_manager_.CreateTestingProfile(name); |
| 31 chrome::kProfileDirPrefix + name); | |
| 32 } | 31 } |
| 33 | 32 |
| 34 private: | 33 private: |
| 35 TestingProfileManager testing_profile_manager_; | 34 TestingProfileManager testing_profile_manager_; |
| 36 }; | 35 }; |
| 37 | 36 |
| 38 TEST(FileManagerPathUtilTest, MultiProfileDownloadsFolderMigration) { | 37 TEST(FileManagerPathUtilTest, MultiProfileDownloadsFolderMigration) { |
| 39 TestingProfile profile; | 38 TestingProfile profile; |
| 40 | 39 |
| 41 // This looks like "/home/chronos/u-hash/Downloads" in the production | 40 // This looks like "/home/chronos/u-hash/Downloads" in the production |
| (...skipping 21 matching lines...) Expand all Loading... |
| 63 &path)); | 62 &path)); |
| 64 | 63 |
| 65 // Only the "Downloads" path is converted. | 64 // Only the "Downloads" path is converted. |
| 66 EXPECT_FALSE(MigratePathFromOldFormat( | 65 EXPECT_FALSE(MigratePathFromOldFormat( |
| 67 &profile, | 66 &profile, |
| 68 base::FilePath::FromUTF8Unsafe("/home/chronos/user/dl"), | 67 base::FilePath::FromUTF8Unsafe("/home/chronos/user/dl"), |
| 69 &path)); | 68 &path)); |
| 70 } | 69 } |
| 71 | 70 |
| 72 TEST_F(ProfileRelatedTest, MultiProfileDriveFolderMigration) { | 71 TEST_F(ProfileRelatedTest, MultiProfileDriveFolderMigration) { |
| 73 Profile* profile = CreateProfileWithName("hash"); | 72 Profile* profile = CreateProfileWithName("user1"); |
| 74 | 73 |
| 75 const base::FilePath kDrive = drive::util::GetDriveMountPointPath(profile); | 74 const base::FilePath kDrive = drive::util::GetDriveMountPointPath(profile); |
| 76 ASSERT_EQ(base::FilePath::FromUTF8Unsafe("/special/drive-hash"), kDrive); | 75 const std::string user_id_hash = |
| 76 chromeos::ProfileHelper::GetUserIdHashByUserIdForTesting("user1"); |
| 77 ASSERT_EQ(base::FilePath::FromUTF8Unsafe("/special/drive-" + user_id_hash), |
| 78 kDrive); |
| 77 | 79 |
| 78 base::FilePath path; | 80 base::FilePath path; |
| 79 | 81 |
| 80 EXPECT_TRUE(MigratePathFromOldFormat( | 82 EXPECT_TRUE(MigratePathFromOldFormat( |
| 81 profile, | 83 profile, |
| 82 base::FilePath::FromUTF8Unsafe("/special/drive"), | 84 base::FilePath::FromUTF8Unsafe("/special/drive"), |
| 83 &path)); | 85 &path)); |
| 84 EXPECT_EQ(kDrive, path); | 86 EXPECT_EQ(kDrive, path); |
| 85 | 87 |
| 86 EXPECT_TRUE(MigratePathFromOldFormat( | 88 EXPECT_TRUE(MigratePathFromOldFormat( |
| (...skipping 11 matching lines...) Expand all Loading... |
| 98 // Only the "/special/drive" path is converted. | 100 // Only the "/special/drive" path is converted. |
| 99 EXPECT_FALSE(MigratePathFromOldFormat( | 101 EXPECT_FALSE(MigratePathFromOldFormat( |
| 100 profile, | 102 profile, |
| 101 base::FilePath::FromUTF8Unsafe("/special/notdrive"), | 103 base::FilePath::FromUTF8Unsafe("/special/notdrive"), |
| 102 &path)); | 104 &path)); |
| 103 } | 105 } |
| 104 | 106 |
| 105 } // namespace | 107 } // namespace |
| 106 } // namespace util | 108 } // namespace util |
| 107 } // namespace file_manager | 109 } // namespace file_manager |
| OLD | NEW |