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/service.h" | 5 #include "chrome/browser/chromeos/file_system_provider/service.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/files/file.h" | 10 #include "base/files/file.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
14 #include "chrome/browser/chromeos/file_system_provider/fake_provided_file_system
.h" | 14 #include "chrome/browser/chromeos/file_system_provider/fake_provided_file_system
.h" |
15 #include "chrome/browser/chromeos/file_system_provider/mount_path_util.h" | 15 #include "chrome/browser/chromeos/file_system_provider/mount_path_util.h" |
16 #include "chrome/browser/chromeos/file_system_provider/observer.h" | 16 #include "chrome/browser/chromeos/file_system_provider/observer.h" |
17 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_info
.h" | 17 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_info
.h" |
18 #include "chrome/browser/chromeos/file_system_provider/registry_interface.h" | 18 #include "chrome/browser/chromeos/file_system_provider/registry_interface.h" |
19 #include "chrome/browser/chromeos/login/users/fake_user_manager.h" | 19 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" |
20 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" | 20 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" |
21 #include "chrome/test/base/testing_browser_process.h" | 21 #include "chrome/test/base/testing_browser_process.h" |
22 #include "chrome/test/base/testing_pref_service_syncable.h" | 22 #include "chrome/test/base/testing_pref_service_syncable.h" |
23 #include "chrome/test/base/testing_profile.h" | 23 #include "chrome/test/base/testing_profile.h" |
24 #include "chrome/test/base/testing_profile_manager.h" | 24 #include "chrome/test/base/testing_profile_manager.h" |
25 #include "components/user_prefs/user_prefs.h" | 25 #include "components/user_prefs/user_prefs.h" |
26 #include "content/public/test/test_browser_thread_bundle.h" | 26 #include "content/public/test/test_browser_thread_bundle.h" |
27 #include "extensions/browser/extension_registry.h" | 27 #include "extensions/browser/extension_registry.h" |
28 #include "extensions/common/extension.h" | 28 #include "extensions/common/extension.h" |
29 #include "extensions/common/manifest_constants.h" | 29 #include "extensions/common/manifest_constants.h" |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 protected: | 172 protected: |
173 FileSystemProviderServiceTest() : profile_(NULL) {} | 173 FileSystemProviderServiceTest() : profile_(NULL) {} |
174 | 174 |
175 ~FileSystemProviderServiceTest() override {} | 175 ~FileSystemProviderServiceTest() override {} |
176 | 176 |
177 void SetUp() override { | 177 void SetUp() override { |
178 profile_manager_.reset( | 178 profile_manager_.reset( |
179 new TestingProfileManager(TestingBrowserProcess::GetGlobal())); | 179 new TestingProfileManager(TestingBrowserProcess::GetGlobal())); |
180 ASSERT_TRUE(profile_manager_->SetUp()); | 180 ASSERT_TRUE(profile_manager_->SetUp()); |
181 profile_ = profile_manager_->CreateTestingProfile("test-user@example.com"); | 181 profile_ = profile_manager_->CreateTestingProfile("test-user@example.com"); |
182 user_manager_ = new FakeUserManager(); | 182 user_manager_ = new FakeChromeUserManager(); |
183 user_manager_->AddUser(profile_->GetProfileName()); | 183 user_manager_->AddUser(profile_->GetProfileName()); |
184 user_manager_enabler_.reset(new ScopedUserManagerEnabler(user_manager_)); | 184 user_manager_enabler_.reset(new ScopedUserManagerEnabler(user_manager_)); |
185 extension_registry_.reset(new extensions::ExtensionRegistry(profile_)); | 185 extension_registry_.reset(new extensions::ExtensionRegistry(profile_)); |
186 | 186 |
187 service_.reset(new Service(profile_, extension_registry_.get())); | 187 service_.reset(new Service(profile_, extension_registry_.get())); |
188 service_->SetFileSystemFactoryForTesting( | 188 service_->SetFileSystemFactoryForTesting( |
189 base::Bind(&FakeProvidedFileSystem::Create)); | 189 base::Bind(&FakeProvidedFileSystem::Create)); |
190 extension_ = CreateFakeExtension(kExtensionId); | 190 extension_ = CreateFakeExtension(kExtensionId); |
191 | 191 |
192 registry_ = new FakeRegistry; | 192 registry_ = new FakeRegistry; |
193 // Passes ownership to the service instance. | 193 // Passes ownership to the service instance. |
194 service_->SetRegistryForTesting(make_scoped_ptr(registry_)); | 194 service_->SetRegistryForTesting(make_scoped_ptr(registry_)); |
195 | 195 |
196 fake_watcher_.entry_path = base::FilePath(FILE_PATH_LITERAL("/a/b/c")); | 196 fake_watcher_.entry_path = base::FilePath(FILE_PATH_LITERAL("/a/b/c")); |
197 fake_watcher_.recursive = true; | 197 fake_watcher_.recursive = true; |
198 fake_watcher_.last_tag = "hello-world"; | 198 fake_watcher_.last_tag = "hello-world"; |
199 } | 199 } |
200 | 200 |
201 content::TestBrowserThreadBundle thread_bundle_; | 201 content::TestBrowserThreadBundle thread_bundle_; |
202 scoped_ptr<TestingProfileManager> profile_manager_; | 202 scoped_ptr<TestingProfileManager> profile_manager_; |
203 TestingProfile* profile_; | 203 TestingProfile* profile_; |
204 FakeUserManager* user_manager_; | 204 FakeChromeUserManager* user_manager_; |
205 scoped_ptr<ScopedUserManagerEnabler> user_manager_enabler_; | 205 scoped_ptr<ScopedUserManagerEnabler> user_manager_enabler_; |
206 scoped_ptr<extensions::ExtensionRegistry> extension_registry_; | 206 scoped_ptr<extensions::ExtensionRegistry> extension_registry_; |
207 scoped_ptr<Service> service_; | 207 scoped_ptr<Service> service_; |
208 scoped_refptr<extensions::Extension> extension_; | 208 scoped_refptr<extensions::Extension> extension_; |
209 FakeRegistry* registry_; // Owned by Service. | 209 FakeRegistry* registry_; // Owned by Service. |
210 Watcher fake_watcher_; | 210 Watcher fake_watcher_; |
211 }; | 211 }; |
212 | 212 |
213 TEST_F(FileSystemProviderServiceTest, MountFileSystem) { | 213 TEST_F(FileSystemProviderServiceTest, MountFileSystem) { |
214 LoggingObserver observer; | 214 LoggingObserver observer; |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 EXPECT_EQ(1u, observer.unmounts.size()); | 526 EXPECT_EQ(1u, observer.unmounts.size()); |
527 EXPECT_FALSE(registry_->file_system_info()); | 527 EXPECT_FALSE(registry_->file_system_info()); |
528 EXPECT_FALSE(registry_->watchers()); | 528 EXPECT_FALSE(registry_->watchers()); |
529 } | 529 } |
530 | 530 |
531 service_->RemoveObserver(&observer); | 531 service_->RemoveObserver(&observer); |
532 } | 532 } |
533 | 533 |
534 } // namespace file_system_provider | 534 } // namespace file_system_provider |
535 } // namespace chromeos | 535 } // namespace chromeos |
OLD | NEW |