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