| 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/registry.h" | 5 #include "chrome/browser/chromeos/file_system_provider/registry.h" |
| 6 | 6 |
| 7 #include <memory> |
| 7 #include <string> | 8 #include <string> |
| 8 #include <vector> | 9 #include <vector> |
| 9 | 10 |
| 10 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_info
.h" | 12 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_info
.h" |
| 13 #include "chrome/common/extensions/api/file_system_provider_capabilities/file_sy
stem_provider_capabilities_handler.h" | 13 #include "chrome/common/extensions/api/file_system_provider_capabilities/file_sy
stem_provider_capabilities_handler.h" |
| 14 #include "chrome/common/pref_names.h" | 14 #include "chrome/common/pref_names.h" |
| 15 #include "chrome/test/base/testing_browser_process.h" | 15 #include "chrome/test/base/testing_browser_process.h" |
| 16 #include "chrome/test/base/testing_profile.h" | 16 #include "chrome/test/base/testing_profile.h" |
| 17 #include "chrome/test/base/testing_profile_manager.h" | 17 #include "chrome/test/base/testing_profile_manager.h" |
| 18 #include "components/syncable_prefs/testing_pref_service_syncable.h" | 18 #include "components/syncable_prefs/testing_pref_service_syncable.h" |
| 19 #include "components/user_prefs/user_prefs.h" | 19 #include "components/user_prefs/user_prefs.h" |
| 20 #include "content/public/test/test_browser_thread_bundle.h" | 20 #include "content/public/test/test_browser_thread_bundle.h" |
| 21 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 fake_watcher_.subscribers[GURL(kTemporaryOrigin)].origin = | 109 fake_watcher_.subscribers[GURL(kTemporaryOrigin)].origin = |
| 110 GURL(kTemporaryOrigin); | 110 GURL(kTemporaryOrigin); |
| 111 fake_watcher_.subscribers[GURL(kTemporaryOrigin)].persistent = false; | 111 fake_watcher_.subscribers[GURL(kTemporaryOrigin)].persistent = false; |
| 112 fake_watcher_.subscribers[GURL(kPersistentOrigin)].origin = | 112 fake_watcher_.subscribers[GURL(kPersistentOrigin)].origin = |
| 113 GURL(kPersistentOrigin); | 113 GURL(kPersistentOrigin); |
| 114 fake_watcher_.subscribers[GURL(kPersistentOrigin)].persistent = true; | 114 fake_watcher_.subscribers[GURL(kPersistentOrigin)].persistent = true; |
| 115 fake_watcher_.last_tag = "hello-world"; | 115 fake_watcher_.last_tag = "hello-world"; |
| 116 } | 116 } |
| 117 | 117 |
| 118 content::TestBrowserThreadBundle thread_bundle_; | 118 content::TestBrowserThreadBundle thread_bundle_; |
| 119 scoped_ptr<TestingProfileManager> profile_manager_; | 119 std::unique_ptr<TestingProfileManager> profile_manager_; |
| 120 TestingProfile* profile_; | 120 TestingProfile* profile_; |
| 121 scoped_ptr<RegistryInterface> registry_; | 121 std::unique_ptr<RegistryInterface> registry_; |
| 122 Watcher fake_watcher_; | 122 Watcher fake_watcher_; |
| 123 }; | 123 }; |
| 124 | 124 |
| 125 TEST_F(FileSystemProviderRegistryTest, RestoreFileSystems) { | 125 TEST_F(FileSystemProviderRegistryTest, RestoreFileSystems) { |
| 126 // Create a fake entry in the preferences. | 126 // Create a fake entry in the preferences. |
| 127 RememberFakeFileSystem(profile_, kExtensionId, kFileSystemId, kDisplayName, | 127 RememberFakeFileSystem(profile_, kExtensionId, kFileSystemId, kDisplayName, |
| 128 true /* writable */, true /* supports_notify_tag */, | 128 true /* writable */, true /* supports_notify_tag */, |
| 129 kOpenedFilesLimit, fake_watcher_); | 129 kOpenedFilesLimit, fake_watcher_); |
| 130 | 130 |
| 131 scoped_ptr<RegistryInterface::RestoredFileSystems> restored_file_systems = | 131 std::unique_ptr<RegistryInterface::RestoredFileSystems> |
| 132 registry_->RestoreFileSystems(kExtensionId); | 132 restored_file_systems = registry_->RestoreFileSystems(kExtensionId); |
| 133 | 133 |
| 134 ASSERT_EQ(1u, restored_file_systems->size()); | 134 ASSERT_EQ(1u, restored_file_systems->size()); |
| 135 const RegistryInterface::RestoredFileSystem& restored_file_system = | 135 const RegistryInterface::RestoredFileSystem& restored_file_system = |
| 136 restored_file_systems->at(0); | 136 restored_file_systems->at(0); |
| 137 EXPECT_EQ(kExtensionId, restored_file_system.extension_id); | 137 EXPECT_EQ(kExtensionId, restored_file_system.extension_id); |
| 138 EXPECT_EQ(kFileSystemId, restored_file_system.options.file_system_id); | 138 EXPECT_EQ(kFileSystemId, restored_file_system.options.file_system_id); |
| 139 EXPECT_EQ(kDisplayName, restored_file_system.options.display_name); | 139 EXPECT_EQ(kDisplayName, restored_file_system.options.display_name); |
| 140 EXPECT_TRUE(restored_file_system.options.writable); | 140 EXPECT_TRUE(restored_file_system.options.writable); |
| 141 EXPECT_TRUE(restored_file_system.options.supports_notify_tag); | 141 EXPECT_TRUE(restored_file_system.options.supports_notify_tag); |
| 142 EXPECT_EQ(kOpenedFilesLimit, restored_file_system.options.opened_files_limit); | 142 EXPECT_EQ(kOpenedFilesLimit, restored_file_system.options.opened_files_limit); |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 fake_watcher_.entry_path.value(), &watcher)); | 314 fake_watcher_.entry_path.value(), &watcher)); |
| 315 | 315 |
| 316 std::string last_tag; | 316 std::string last_tag; |
| 317 EXPECT_TRUE(watcher->GetStringWithoutPathExpansion(kPrefKeyWatcherLastTag, | 317 EXPECT_TRUE(watcher->GetStringWithoutPathExpansion(kPrefKeyWatcherLastTag, |
| 318 &last_tag)); | 318 &last_tag)); |
| 319 EXPECT_EQ(fake_watcher_.last_tag, last_tag); | 319 EXPECT_EQ(fake_watcher_.last_tag, last_tag); |
| 320 } | 320 } |
| 321 | 321 |
| 322 } // namespace file_system_provider | 322 } // namespace file_system_provider |
| 323 } // namespace chromeos | 323 } // namespace chromeos |
| OLD | NEW |