Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1172)

Side by Side Diff: chrome/browser/chromeos/file_manager/path_util_unittest.cc

Issue 2429533004: Revert of ChromeOS: Add unittest for ConvertPathToArcUrl. (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/login/users/fake_chrome_user_manager.h"
9 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h"
10 #include "chrome/browser/chromeos/profiles/profile_helper.h"
11 #include "chrome/browser/download/download_prefs.h" 8 #include "chrome/browser/download/download_prefs.h"
12 #include "chrome/test/base/testing_browser_process.h"
13 #include "chrome/test/base/testing_profile.h" 9 #include "chrome/test/base/testing_profile.h"
14 #include "chrome/test/base/testing_profile_manager.h"
15 #include "components/signin/core/account_id/account_id.h"
16 #include "content/public/test/test_browser_thread_bundle.h" 10 #include "content/public/test/test_browser_thread_bundle.h"
17 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
18 12
19 namespace file_manager { 13 namespace file_manager {
20 namespace util { 14 namespace util {
21 namespace { 15 namespace {
22 16
23 TEST(FileManagerPathUtilTest, MultiProfileDownloadsFolderMigration) { 17 TEST(FileManagerPathUtilTest, MultiProfileDownloadsFolderMigration) {
24 content::TestBrowserThreadBundle thread_bundle; 18 content::TestBrowserThreadBundle thread_bundle;
25 TestingProfile profile; 19 TestingProfile profile;
(...skipping 21 matching lines...) Expand all
47 kDownloads.AppendASCII("a/b"), 41 kDownloads.AppendASCII("a/b"),
48 &path)); 42 &path));
49 43
50 // Only the "Downloads" path is converted. 44 // Only the "Downloads" path is converted.
51 EXPECT_FALSE(MigratePathFromOldFormat( 45 EXPECT_FALSE(MigratePathFromOldFormat(
52 &profile, 46 &profile,
53 base::FilePath::FromUTF8Unsafe("/home/chronos/user/dl"), 47 base::FilePath::FromUTF8Unsafe("/home/chronos/user/dl"),
54 &path)); 48 &path));
55 } 49 }
56 50
57 TEST(FileManagerPathUtilTest, ConvertPathToArcUrl) {
58 // Test SetUp -- add two user-profile pairs and their fake managers.
59 TestingProfileManager testing_profile_manager(
60 TestingBrowserProcess::GetGlobal());
61 ASSERT_TRUE(testing_profile_manager.SetUp());
62
63 chromeos::FakeChromeUserManager* const fake_user_manager =
64 new chromeos::FakeChromeUserManager;
65 chromeos::ScopedUserManagerEnabler user_manager_enabler(fake_user_manager);
66
67 const AccountId account_id(
68 AccountId::FromUserEmailGaiaId("user@gmail.com", "1111111111"));
69 const AccountId account_id_2(
70 AccountId::FromUserEmailGaiaId("user2@gmail.com", "2222222222"));
71 fake_user_manager->AddUser(account_id);
72 fake_user_manager->LoginUser(account_id);
73 fake_user_manager->AddUser(account_id_2);
74 fake_user_manager->LoginUser(account_id_2);
75 ASSERT_TRUE(testing_profile_manager.CreateTestingProfile("user@gmail.com"));
76 ASSERT_TRUE(testing_profile_manager.CreateTestingProfile("user2@gmail.com"));
77
78 GURL url;
79
80 // Conversion of paths for removable storages.
81 EXPECT_TRUE(ConvertPathToArcUrl(
82 base::FilePath::FromUTF8Unsafe("/media/removable/a/b/c"), &url));
83 EXPECT_EQ(GURL("content://org.chromium.arc.removablemediaprovider/a/b/c"),
84 url);
85
86 EXPECT_FALSE(ConvertPathToArcUrl(
87 base::FilePath::FromUTF8Unsafe("/media/removable_foobar"), &url));
88
89 // Conversion of paths under the primary profile's downloads folder.
90 const base::FilePath downloads = GetDownloadsFolderForProfile(
91 chromeos::ProfileHelper::Get()->GetProfileByUserIdHash(
92 "user@gmail.com-hash"));
93 EXPECT_TRUE(ConvertPathToArcUrl(downloads.AppendASCII("a/b/c"), &url));
94 EXPECT_EQ(GURL("file:///sdcard/Download/a/b/c"), url);
95
96 // Non-primary profile's downloads folder is not supported for ARC yet.
97 const base::FilePath downloads2 = GetDownloadsFolderForProfile(
98 chromeos::ProfileHelper::Get()->GetProfileByUserIdHash(
99 "user2@gmail.com-hash"));
100 EXPECT_FALSE(ConvertPathToArcUrl(downloads2.AppendASCII("a/b/c"), &url));
101 }
102
103 } // namespace 51 } // namespace
104 } // namespace util 52 } // namespace util
105 } // namespace file_manager 53 } // namespace file_manager
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698