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 "base/sys_info.h" | |
8 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" | 9 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" |
9 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" | 10 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" |
10 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 11 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
11 #include "chrome/browser/download/download_prefs.h" | 12 #include "chrome/browser/download/download_prefs.h" |
12 #include "chrome/test/base/testing_browser_process.h" | 13 #include "chrome/test/base/testing_browser_process.h" |
13 #include "chrome/test/base/testing_profile.h" | 14 #include "chrome/test/base/testing_profile.h" |
14 #include "chrome/test/base/testing_profile_manager.h" | 15 #include "chrome/test/base/testing_profile_manager.h" |
15 #include "components/signin/core/account_id/account_id.h" | 16 #include "components/signin/core/account_id/account_id.h" |
16 #include "content/public/test/test_browser_thread_bundle.h" | 17 #include "content/public/test/test_browser_thread_bundle.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
18 | 19 |
19 namespace file_manager { | 20 namespace file_manager { |
20 namespace util { | 21 namespace util { |
21 namespace { | 22 namespace { |
22 | 23 |
24 const char kLsbRelease[] = | |
25 "CHROMEOS_RELEASE_NAME=Chrome OS\n" | |
26 "CHROMEOS_RELEASE_VERSION=1.2.3.4\n"; | |
27 | |
28 // Sets a valid Chrome OS version info so IsRunningOnChromeOS() returns true. | |
stevenjb
2017/05/25 21:20:24
This is a bit subtle, can you explain a little why
Alexander Alekseev
2017/05/26 02:18:01
Done. (See below.)
| |
29 class ScopedSetRunningOnChromeOS { | |
30 public: | |
31 ScopedSetRunningOnChromeOS(const std::string& lsb_release, | |
32 const base::Time& lsb_release_time) { | |
33 base::SysInfo::SetChromeOSVersionInfoForTest(lsb_release, lsb_release_time); | |
34 } | |
35 ~ScopedSetRunningOnChromeOS() { | |
36 base::SysInfo::SetChromeOSVersionInfoForTest("", base::Time()); | |
37 } | |
38 | |
39 private: | |
40 DISALLOW_COPY_AND_ASSIGN(ScopedSetRunningOnChromeOS); | |
41 }; | |
42 | |
23 TEST(FileManagerPathUtilTest, MultiProfileDownloadsFolderMigration) { | 43 TEST(FileManagerPathUtilTest, MultiProfileDownloadsFolderMigration) { |
24 content::TestBrowserThreadBundle thread_bundle; | 44 content::TestBrowserThreadBundle thread_bundle; |
25 TestingProfile profile; | 45 TestingProfile profile; |
46 ScopedSetRunningOnChromeOS fake_release(kLsbRelease, base::Time()); | |
26 | 47 |
27 // This looks like "/home/chronos/u-hash/Downloads" in the production | 48 // This looks like "/home/chronos/u-hash/Downloads" in the production |
28 // environment. | 49 // environment. |
29 const base::FilePath kDownloads = GetDownloadsFolderForProfile(&profile); | 50 const base::FilePath kDownloads = GetDownloadsFolderForProfile(&profile); |
30 const base::FilePath kOldDownloads = | 51 const base::FilePath kOldDownloads = |
31 DownloadPrefs::GetDefaultDownloadDirectory(); | 52 DownloadPrefs::GetDefaultDownloadDirectory(); |
32 | 53 |
33 base::FilePath path; | 54 base::FilePath path; |
34 | 55 |
35 EXPECT_TRUE(MigratePathFromOldFormat(&profile, kOldDownloads, &path)); | 56 EXPECT_TRUE(MigratePathFromOldFormat(&profile, kOldDownloads, &path)); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
98 // Non-primary profile's downloads folder is not supported for ARC yet. | 119 // Non-primary profile's downloads folder is not supported for ARC yet. |
99 const base::FilePath downloads2 = GetDownloadsFolderForProfile( | 120 const base::FilePath downloads2 = GetDownloadsFolderForProfile( |
100 chromeos::ProfileHelper::Get()->GetProfileByUserIdHash( | 121 chromeos::ProfileHelper::Get()->GetProfileByUserIdHash( |
101 "user2@gmail.com-hash")); | 122 "user2@gmail.com-hash")); |
102 EXPECT_FALSE(ConvertPathToArcUrl(downloads2.AppendASCII("a/b/c"), &url)); | 123 EXPECT_FALSE(ConvertPathToArcUrl(downloads2.AppendASCII("a/b/c"), &url)); |
103 } | 124 } |
104 | 125 |
105 } // namespace | 126 } // namespace |
106 } // namespace util | 127 } // namespace util |
107 } // namespace file_manager | 128 } // namespace file_manager |
OLD | NEW |