OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_system_provider/mount_path_util.h" | 5 #include "chrome/browser/chromeos/file_system_provider/mount_path_util.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/files/file.h" | 9 #include "base/files/file.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "chrome/browser/chromeos/file_system_provider/fake_provided_file_system
.h" | 11 #include "chrome/browser/chromeos/file_system_provider/fake_provided_file_system
.h" |
12 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_inte
rface.h" | 12 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_inte
rface.h" |
13 #include "chrome/browser/chromeos/file_system_provider/service.h" | 13 #include "chrome/browser/chromeos/file_system_provider/service.h" |
14 #include "chrome/browser/chromeos/file_system_provider/service_factory.h" | 14 #include "chrome/browser/chromeos/file_system_provider/service_factory.h" |
15 #include "chrome/browser/chromeos/login/users/fake_user_manager.h" | 15 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" |
16 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" | 16 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" |
17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
18 #include "chrome/test/base/testing_browser_process.h" | 18 #include "chrome/test/base/testing_browser_process.h" |
19 #include "chrome/test/base/testing_profile.h" | 19 #include "chrome/test/base/testing_profile.h" |
20 #include "chrome/test/base/testing_profile_manager.h" | 20 #include "chrome/test/base/testing_profile_manager.h" |
21 #include "components/keyed_service/core/keyed_service.h" | 21 #include "components/keyed_service/core/keyed_service.h" |
22 #include "content/public/browser/browser_context.h" | 22 #include "content/public/browser/browser_context.h" |
23 #include "content/public/test/test_browser_thread_bundle.h" | 23 #include "content/public/test/test_browser_thread_bundle.h" |
24 #include "extensions/browser/extension_registry.h" | 24 #include "extensions/browser/extension_registry.h" |
25 #include "storage/browser/fileapi/external_mount_points.h" | 25 #include "storage/browser/fileapi/external_mount_points.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 class FileSystemProviderMountPathUtilTest : public testing::Test { | 67 class FileSystemProviderMountPathUtilTest : public testing::Test { |
68 protected: | 68 protected: |
69 FileSystemProviderMountPathUtilTest() {} | 69 FileSystemProviderMountPathUtilTest() {} |
70 ~FileSystemProviderMountPathUtilTest() override {} | 70 ~FileSystemProviderMountPathUtilTest() override {} |
71 | 71 |
72 void SetUp() override { | 72 void SetUp() override { |
73 profile_manager_.reset( | 73 profile_manager_.reset( |
74 new TestingProfileManager(TestingBrowserProcess::GetGlobal())); | 74 new TestingProfileManager(TestingBrowserProcess::GetGlobal())); |
75 ASSERT_TRUE(profile_manager_->SetUp()); | 75 ASSERT_TRUE(profile_manager_->SetUp()); |
76 profile_ = profile_manager_->CreateTestingProfile("testing-profile"); | 76 profile_ = profile_manager_->CreateTestingProfile("testing-profile"); |
77 user_manager_ = new FakeUserManager(); | 77 user_manager_ = new FakeChromeUserManager(); |
78 user_manager_enabler_.reset(new ScopedUserManagerEnabler(user_manager_)); | 78 user_manager_enabler_.reset(new ScopedUserManagerEnabler(user_manager_)); |
79 user_manager_->AddUser(profile_->GetProfileName()); | 79 user_manager_->AddUser(profile_->GetProfileName()); |
80 ServiceFactory::GetInstance()->SetTestingFactory(profile_, &CreateService); | 80 ServiceFactory::GetInstance()->SetTestingFactory(profile_, &CreateService); |
81 file_system_provider_service_ = Service::Get(profile_); | 81 file_system_provider_service_ = Service::Get(profile_); |
82 file_system_provider_service_->SetFileSystemFactoryForTesting( | 82 file_system_provider_service_->SetFileSystemFactoryForTesting( |
83 base::Bind(&FakeProvidedFileSystem::Create)); | 83 base::Bind(&FakeProvidedFileSystem::Create)); |
84 } | 84 } |
85 | 85 |
86 void TearDown() override { | 86 void TearDown() override { |
87 // Setting the testing factory to NULL will destroy the created service | 87 // Setting the testing factory to NULL will destroy the created service |
88 // associated with the testing profile. | 88 // associated with the testing profile. |
89 ServiceFactory::GetInstance()->SetTestingFactory(profile_, NULL); | 89 ServiceFactory::GetInstance()->SetTestingFactory(profile_, NULL); |
90 } | 90 } |
91 | 91 |
92 content::TestBrowserThreadBundle thread_bundle_; | 92 content::TestBrowserThreadBundle thread_bundle_; |
93 scoped_ptr<TestingProfileManager> profile_manager_; | 93 scoped_ptr<TestingProfileManager> profile_manager_; |
94 TestingProfile* profile_; // Owned by TestingProfileManager. | 94 TestingProfile* profile_; // Owned by TestingProfileManager. |
95 scoped_ptr<ScopedUserManagerEnabler> user_manager_enabler_; | 95 scoped_ptr<ScopedUserManagerEnabler> user_manager_enabler_; |
96 FakeUserManager* user_manager_; | 96 FakeChromeUserManager* user_manager_; |
97 Service* file_system_provider_service_; // Owned by its factory. | 97 Service* file_system_provider_service_; // Owned by its factory. |
98 }; | 98 }; |
99 | 99 |
100 TEST_F(FileSystemProviderMountPathUtilTest, GetMountPath) { | 100 TEST_F(FileSystemProviderMountPathUtilTest, GetMountPath) { |
101 const base::FilePath result = | 101 const base::FilePath result = |
102 GetMountPath(profile_, kExtensionId, kFileSystemId); | 102 GetMountPath(profile_, kExtensionId, kFileSystemId); |
103 const std::string expected = | 103 const std::string expected = |
104 "/provided/mbflcebpggnecokmikipoihdbecnjfoj:" | 104 "/provided/mbflcebpggnecokmikipoihdbecnjfoj:" |
105 "File%2FSystem%2FId:testing-profile-hash"; | 105 "File%2FSystem%2FId:testing-profile-hash"; |
106 EXPECT_EQ(expected, result.AsUTF8Unsafe()); | 106 EXPECT_EQ(expected, result.AsUTF8Unsafe()); |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 const base::FilePath kFilePath = | 305 const base::FilePath kFilePath = |
306 base::FilePath(FILE_PATH_LITERAL("provided/hello/world")); | 306 base::FilePath(FILE_PATH_LITERAL("provided/hello/world")); |
307 LocalPathParser parser(profile_, kFilePath); | 307 LocalPathParser parser(profile_, kFilePath); |
308 EXPECT_FALSE(parser.Parse()); | 308 EXPECT_FALSE(parser.Parse()); |
309 } | 309 } |
310 } | 310 } |
311 | 311 |
312 } // namespace util | 312 } // namespace util |
313 } // namespace file_system_provider | 313 } // namespace file_system_provider |
314 } // namespace chromeos | 314 } // namespace chromeos |
OLD | NEW |