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