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 <string> | 5 #include <string> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/files/file.h" | 8 #include "base/files/file.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 user_manager_enabler_.reset(new ScopedUserManagerEnabler(user_manager_)); | 98 user_manager_enabler_.reset(new ScopedUserManagerEnabler(user_manager_)); |
99 extension_registry_.reset( | 99 extension_registry_.reset( |
100 new extensions::ExtensionRegistry(profile_.get())); | 100 new extensions::ExtensionRegistry(profile_.get())); |
101 file_system_provider_service_.reset( | 101 file_system_provider_service_.reset( |
102 new Service(profile_.get(), extension_registry_.get())); | 102 new Service(profile_.get(), extension_registry_.get())); |
103 file_system_provider_service_->SetFileSystemFactoryForTests( | 103 file_system_provider_service_->SetFileSystemFactoryForTests( |
104 base::Bind(&FakeProvidedFileSystem::Create)); | 104 base::Bind(&FakeProvidedFileSystem::Create)); |
105 extension_ = createFakeExtension(kExtensionId); | 105 extension_ = createFakeExtension(kExtensionId); |
106 } | 106 } |
107 | 107 |
108 virtual void TearDown() { | |
109 fileapi::ExternalMountPoints::GetSystemInstance()->RevokeAllFileSystems(); | |
110 } | |
111 | |
112 content::TestBrowserThreadBundle thread_bundle_; | 108 content::TestBrowserThreadBundle thread_bundle_; |
113 scoped_ptr<TestingProfile> profile_; | 109 scoped_ptr<TestingProfile> profile_; |
114 FakeUserManager* user_manager_; | 110 FakeUserManager* user_manager_; |
115 scoped_ptr<ScopedUserManagerEnabler> user_manager_enabler_; | 111 scoped_ptr<ScopedUserManagerEnabler> user_manager_enabler_; |
116 scoped_ptr<extensions::ExtensionRegistry> extension_registry_; | 112 scoped_ptr<extensions::ExtensionRegistry> extension_registry_; |
117 scoped_ptr<Service> file_system_provider_service_; | 113 scoped_ptr<Service> file_system_provider_service_; |
118 scoped_refptr<extensions::Extension> extension_; | 114 scoped_refptr<extensions::Extension> extension_; |
119 }; | 115 }; |
120 | 116 |
121 TEST_F(FileSystemProviderServiceTest, MountFileSystem) { | 117 TEST_F(FileSystemProviderServiceTest, MountFileSystem) { |
122 LoggingObserver observer; | 118 LoggingObserver observer; |
123 file_system_provider_service_->AddObserver(&observer); | 119 file_system_provider_service_->AddObserver(&observer); |
124 | 120 |
125 int file_system_id = file_system_provider_service_->MountFileSystem( | 121 int file_system_id = file_system_provider_service_->MountFileSystem( |
126 kExtensionId, kFileSystemName); | 122 kExtensionId, kFileSystemName); |
127 | 123 |
128 EXPECT_LT(0, file_system_id); | 124 EXPECT_LT(0, file_system_id); |
129 ASSERT_EQ(1u, observer.mounts.size()); | 125 ASSERT_EQ(1u, observer.mounts.size()); |
130 EXPECT_EQ(kExtensionId, observer.mounts[0].file_system_info().extension_id()); | 126 EXPECT_EQ(kExtensionId, observer.mounts[0].file_system_info().extension_id()); |
131 EXPECT_EQ(1, observer.mounts[0].file_system_info().file_system_id()); | 127 EXPECT_EQ(1, observer.mounts[0].file_system_info().file_system_id()); |
132 base::FilePath expected_mount_path = | 128 base::FilePath expected_mount_path = |
133 util::GetMountPointPath(profile_.get(), kExtensionId, file_system_id); | 129 util::GetMountPath(profile_.get(), kExtensionId, file_system_id); |
134 EXPECT_EQ(expected_mount_path.AsUTF8Unsafe(), | 130 EXPECT_EQ(expected_mount_path.AsUTF8Unsafe(), |
135 observer.mounts[0].file_system_info().mount_path().AsUTF8Unsafe()); | 131 observer.mounts[0].file_system_info().mount_path().AsUTF8Unsafe()); |
136 EXPECT_EQ(kFileSystemName, | 132 EXPECT_EQ(kFileSystemName, |
137 observer.mounts[0].file_system_info().file_system_name()); | 133 observer.mounts[0].file_system_info().file_system_name()); |
138 EXPECT_EQ(base::File::FILE_OK, observer.mounts[0].error()); | 134 EXPECT_EQ(base::File::FILE_OK, observer.mounts[0].error()); |
139 ASSERT_EQ(0u, observer.unmounts.size()); | 135 ASSERT_EQ(0u, observer.unmounts.size()); |
140 | 136 |
141 std::vector<ProvidedFileSystemInfo> file_system_info_list = | 137 std::vector<ProvidedFileSystemInfo> file_system_info_list = |
142 file_system_provider_service_->GetProvidedFileSystemInfoList(); | 138 file_system_provider_service_->GetProvidedFileSystemInfoList(); |
143 ASSERT_EQ(1u, file_system_info_list.size()); | 139 ASSERT_EQ(1u, file_system_info_list.size()); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 const bool result = file_system_provider_service_->UnmountFileSystem( | 205 const bool result = file_system_provider_service_->UnmountFileSystem( |
210 kExtensionId, file_system_id); | 206 kExtensionId, file_system_id); |
211 EXPECT_TRUE(result); | 207 EXPECT_TRUE(result); |
212 ASSERT_EQ(1u, observer.unmounts.size()); | 208 ASSERT_EQ(1u, observer.unmounts.size()); |
213 EXPECT_EQ(base::File::FILE_OK, observer.unmounts[0].error()); | 209 EXPECT_EQ(base::File::FILE_OK, observer.unmounts[0].error()); |
214 | 210 |
215 EXPECT_EQ(kExtensionId, | 211 EXPECT_EQ(kExtensionId, |
216 observer.unmounts[0].file_system_info().extension_id()); | 212 observer.unmounts[0].file_system_info().extension_id()); |
217 EXPECT_EQ(1, observer.unmounts[0].file_system_info().file_system_id()); | 213 EXPECT_EQ(1, observer.unmounts[0].file_system_info().file_system_id()); |
218 base::FilePath expected_mount_path = | 214 base::FilePath expected_mount_path = |
219 util::GetMountPointPath(profile_.get(), kExtensionId, file_system_id); | 215 util::GetMountPath(profile_.get(), kExtensionId, file_system_id); |
220 EXPECT_EQ( | 216 EXPECT_EQ( |
221 expected_mount_path.AsUTF8Unsafe(), | 217 expected_mount_path.AsUTF8Unsafe(), |
222 observer.unmounts[0].file_system_info().mount_path().AsUTF8Unsafe()); | 218 observer.unmounts[0].file_system_info().mount_path().AsUTF8Unsafe()); |
223 EXPECT_EQ(kFileSystemName, | 219 EXPECT_EQ(kFileSystemName, |
224 observer.unmounts[0].file_system_info().file_system_name()); | 220 observer.unmounts[0].file_system_info().file_system_name()); |
225 | 221 |
226 std::vector<ProvidedFileSystemInfo> file_system_info_list = | 222 std::vector<ProvidedFileSystemInfo> file_system_info_list = |
227 file_system_provider_service_->GetProvidedFileSystemInfoList(); | 223 file_system_provider_service_->GetProvidedFileSystemInfoList(); |
228 ASSERT_EQ(0u, file_system_info_list.size()); | 224 ASSERT_EQ(0u, file_system_info_list.size()); |
229 | 225 |
(...skipping 15 matching lines...) Expand all Loading... |
245 extension_.get(), | 241 extension_.get(), |
246 extensions::UnloadedExtensionInfo::REASON_DISABLE); | 242 extensions::UnloadedExtensionInfo::REASON_DISABLE); |
247 | 243 |
248 ASSERT_EQ(1u, observer.unmounts.size()); | 244 ASSERT_EQ(1u, observer.unmounts.size()); |
249 EXPECT_EQ(base::File::FILE_OK, observer.unmounts[0].error()); | 245 EXPECT_EQ(base::File::FILE_OK, observer.unmounts[0].error()); |
250 | 246 |
251 EXPECT_EQ(kExtensionId, | 247 EXPECT_EQ(kExtensionId, |
252 observer.unmounts[0].file_system_info().extension_id()); | 248 observer.unmounts[0].file_system_info().extension_id()); |
253 EXPECT_EQ(1, observer.unmounts[0].file_system_info().file_system_id()); | 249 EXPECT_EQ(1, observer.unmounts[0].file_system_info().file_system_id()); |
254 base::FilePath expected_mount_path = | 250 base::FilePath expected_mount_path = |
255 util::GetMountPointPath(profile_.get(), kExtensionId, file_system_id); | 251 util::GetMountPath(profile_.get(), kExtensionId, file_system_id); |
256 EXPECT_EQ( | 252 EXPECT_EQ( |
257 expected_mount_path.AsUTF8Unsafe(), | 253 expected_mount_path.AsUTF8Unsafe(), |
258 observer.unmounts[0].file_system_info().mount_path().AsUTF8Unsafe()); | 254 observer.unmounts[0].file_system_info().mount_path().AsUTF8Unsafe()); |
259 EXPECT_EQ(kFileSystemName, | 255 EXPECT_EQ(kFileSystemName, |
260 observer.unmounts[0].file_system_info().file_system_name()); | 256 observer.unmounts[0].file_system_info().file_system_name()); |
261 | 257 |
262 std::vector<ProvidedFileSystemInfo> file_system_info_list = | 258 std::vector<ProvidedFileSystemInfo> file_system_info_list = |
263 file_system_provider_service_->GetProvidedFileSystemInfoList(); | 259 file_system_provider_service_->GetProvidedFileSystemInfoList(); |
264 ASSERT_EQ(0u, file_system_info_list.size()); | 260 ASSERT_EQ(0u, file_system_info_list.size()); |
265 | 261 |
(...skipping 25 matching lines...) Expand all Loading... |
291 | 287 |
292 std::vector<ProvidedFileSystemInfo> file_system_info_list = | 288 std::vector<ProvidedFileSystemInfo> file_system_info_list = |
293 file_system_provider_service_->GetProvidedFileSystemInfoList(); | 289 file_system_provider_service_->GetProvidedFileSystemInfoList(); |
294 ASSERT_EQ(1u, file_system_info_list.size()); | 290 ASSERT_EQ(1u, file_system_info_list.size()); |
295 | 291 |
296 file_system_provider_service_->RemoveObserver(&observer); | 292 file_system_provider_service_->RemoveObserver(&observer); |
297 } | 293 } |
298 | 294 |
299 } // namespace file_system_provider | 295 } // namespace file_system_provider |
300 } // namespace chromeos | 296 } // namespace chromeos |
OLD | NEW |