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" |
| 12 #include "chrome/browser/chromeos/scoped_sys_info_chromeos_version_for_testing.h
" |
11 #include "chrome/browser/download/download_prefs.h" | 13 #include "chrome/browser/download/download_prefs.h" |
12 #include "chrome/test/base/testing_browser_process.h" | 14 #include "chrome/test/base/testing_browser_process.h" |
13 #include "chrome/test/base/testing_profile.h" | 15 #include "chrome/test/base/testing_profile.h" |
14 #include "chrome/test/base/testing_profile_manager.h" | 16 #include "chrome/test/base/testing_profile_manager.h" |
15 #include "components/signin/core/account_id/account_id.h" | 17 #include "components/signin/core/account_id/account_id.h" |
16 #include "content/public/test/test_browser_thread_bundle.h" | 18 #include "content/public/test/test_browser_thread_bundle.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
18 | 20 |
19 namespace file_manager { | 21 namespace file_manager { |
20 namespace util { | 22 namespace util { |
21 namespace { | 23 namespace { |
22 | 24 |
| 25 const char kLsbRelease[] = |
| 26 "CHROMEOS_RELEASE_NAME=Chrome OS\n" |
| 27 "CHROMEOS_RELEASE_VERSION=1.2.3.4\n"; |
| 28 |
23 TEST(FileManagerPathUtilTest, MultiProfileDownloadsFolderMigration) { | 29 TEST(FileManagerPathUtilTest, MultiProfileDownloadsFolderMigration) { |
24 content::TestBrowserThreadBundle thread_bundle; | 30 content::TestBrowserThreadBundle thread_bundle; |
25 TestingProfile profile; | 31 TestingProfile profile; |
| 32 // MigratePathFromOldFormat is explicitly disabled on Linux build. |
| 33 // So we need to fake that this is real ChromeOS system. |
| 34 chromeos::ScopedSetRunningOnChromeOSForTesting fake_release(kLsbRelease, |
| 35 base::Time()); |
26 | 36 |
27 // This looks like "/home/chronos/u-hash/Downloads" in the production | 37 // This looks like "/home/chronos/u-hash/Downloads" in the production |
28 // environment. | 38 // environment. |
29 const base::FilePath kDownloads = GetDownloadsFolderForProfile(&profile); | 39 const base::FilePath kDownloads = GetDownloadsFolderForProfile(&profile); |
30 const base::FilePath kOldDownloads = | 40 const base::FilePath kOldDownloads = |
31 DownloadPrefs::GetDefaultDownloadDirectory(); | 41 DownloadPrefs::GetDefaultDownloadDirectory(); |
32 | 42 |
33 base::FilePath path; | 43 base::FilePath path; |
34 | 44 |
35 EXPECT_TRUE(MigratePathFromOldFormat(&profile, kOldDownloads, &path)); | 45 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. | 108 // Non-primary profile's downloads folder is not supported for ARC yet. |
99 const base::FilePath downloads2 = GetDownloadsFolderForProfile( | 109 const base::FilePath downloads2 = GetDownloadsFolderForProfile( |
100 chromeos::ProfileHelper::Get()->GetProfileByUserIdHash( | 110 chromeos::ProfileHelper::Get()->GetProfileByUserIdHash( |
101 "user2@gmail.com-hash")); | 111 "user2@gmail.com-hash")); |
102 EXPECT_FALSE(ConvertPathToArcUrl(downloads2.AppendASCII("a/b/c"), &url)); | 112 EXPECT_FALSE(ConvertPathToArcUrl(downloads2.AppendASCII("a/b/c"), &url)); |
103 } | 113 } |
104 | 114 |
105 } // namespace | 115 } // namespace |
106 } // namespace util | 116 } // namespace util |
107 } // namespace file_manager | 117 } // namespace file_manager |
OLD | NEW |