OLD | NEW |
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 <map> | 5 #include <map> |
6 #include <set> | 6 #include <set> |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
13 #include "base/files/scoped_temp_dir.h" | 13 #include "base/files/scoped_temp_dir.h" |
14 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
15 #include "base/synchronization/waitable_event.h" | 15 #include "base/synchronization/waitable_event.h" |
16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
17 #include "chrome/browser/media_galleries/fileapi/iphoto_data_provider.h" | 17 #include "chrome/browser/media_galleries/fileapi/iphoto_data_provider.h" |
18 #include "chrome/browser/media_galleries/fileapi/iphoto_file_util.h" | 18 #include "chrome/browser/media_galleries/fileapi/iphoto_file_util.h" |
19 #include "chrome/browser/media_galleries/fileapi/media_file_system_backend.h" | 19 #include "chrome/browser/media_galleries/fileapi/media_file_system_backend.h" |
20 #include "chrome/browser/media_galleries/fileapi/media_path_filter.h" | 20 #include "chrome/browser/media_galleries/fileapi/media_path_filter.h" |
| 21 #include "chrome/browser/media_galleries/imported_media_gallery_registry.h" |
21 #include "content/public/browser/browser_thread.h" | 22 #include "content/public/browser/browser_thread.h" |
22 #include "content/public/test/test_browser_thread.h" | 23 #include "content/public/test/test_browser_thread.h" |
23 #include "content/public/test/test_file_system_options.h" | 24 #include "content/public/test/test_file_system_options.h" |
24 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
25 #include "webkit/browser/fileapi/async_file_util.h" | 26 #include "webkit/browser/fileapi/async_file_util.h" |
26 #include "webkit/browser/fileapi/external_mount_points.h" | 27 #include "webkit/browser/fileapi/external_mount_points.h" |
27 #include "webkit/browser/fileapi/file_system_context.h" | 28 #include "webkit/browser/fileapi/file_system_context.h" |
28 #include "webkit/browser/fileapi/file_system_operation_context.h" | 29 #include "webkit/browser/fileapi/file_system_operation_context.h" |
29 #include "webkit/browser/fileapi/file_system_operation_runner.h" | 30 #include "webkit/browser/fileapi/file_system_operation_runner.h" |
30 #include "webkit/browser/quota/mock_special_storage_policy.h" | 31 #include "webkit/browser/quota/mock_special_storage_policy.h" |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 fake_library_dir_.path().AppendASCII("orig.jpg"), | 179 fake_library_dir_.path().AppendASCII("orig.jpg"), |
179 NULL, | 180 NULL, |
180 0)); | 181 0)); |
181 | 182 |
182 iphoto_data_provider_.reset( | 183 iphoto_data_provider_.reset( |
183 new TestIPhotoDataProvider(fake_library_dir_.path())); | 184 new TestIPhotoDataProvider(fake_library_dir_.path())); |
184 } | 185 } |
185 | 186 |
186 virtual void SetUp() OVERRIDE { | 187 virtual void SetUp() OVERRIDE { |
187 ASSERT_TRUE(profile_dir_.CreateUniqueTempDir()); | 188 ASSERT_TRUE(profile_dir_.CreateUniqueTempDir()); |
| 189 ImportedMediaGalleryRegistry::GetInstance()->Initialize(); |
188 | 190 |
189 scoped_refptr<quota::SpecialStoragePolicy> storage_policy = | 191 scoped_refptr<quota::SpecialStoragePolicy> storage_policy = |
190 new quota::MockSpecialStoragePolicy(); | 192 new quota::MockSpecialStoragePolicy(); |
191 | 193 |
192 // Initialize fake IPhotoDataProvider on media task runner thread. | 194 // Initialize fake IPhotoDataProvider on media task runner thread. |
193 MediaFileSystemBackend::MediaTaskRunner()->PostTask( | 195 MediaFileSystemBackend::MediaTaskRunner()->PostTask( |
194 FROM_HERE, | 196 FROM_HERE, |
195 base::Bind(&IPhotoFileUtilTest::SetUpDataProvider, | 197 base::Bind(&IPhotoFileUtilTest::SetUpDataProvider, |
196 base::Unretained(this))); | 198 base::Unretained(this))); |
197 base::WaitableEvent event(true, false /* initially_signalled */); | 199 base::WaitableEvent event(true, false /* initially_signalled */); |
(...skipping 24 matching lines...) Expand all Loading... |
222 protected: | 224 protected: |
223 void TestNonexistentFolder(const std::string& path_append) { | 225 void TestNonexistentFolder(const std::string& path_append) { |
224 FileSystemOperation::FileEntryList contents; | 226 FileSystemOperation::FileEntryList contents; |
225 FileSystemURL url = CreateURL(path_append); | 227 FileSystemURL url = CreateURL(path_append); |
226 bool completed = false; | 228 bool completed = false; |
227 ReadDirectoryTestHelper(operation_runner(), url, &contents, &completed); | 229 ReadDirectoryTestHelper(operation_runner(), url, &contents, &completed); |
228 | 230 |
229 ASSERT_FALSE(completed); | 231 ASSERT_FALSE(completed); |
230 } | 232 } |
231 | 233 |
232 FileSystemURL CreateURL(const std::string& virtual_path) const { | 234 FileSystemURL CreateURL(const std::string& path) const { |
| 235 base::FilePath virtual_path = |
| 236 ImportedMediaGalleryRegistry::GetInstance()->ImportedRoot(); |
| 237 virtual_path = virtual_path.AppendASCII("iphoto"); |
| 238 virtual_path = virtual_path.AppendASCII(path); |
233 return file_system_context_->CreateCrackedFileSystemURL( | 239 return file_system_context_->CreateCrackedFileSystemURL( |
234 GURL("http://www.example.com"), fileapi::kFileSystemTypeIphoto, | 240 GURL("http://www.example.com"), fileapi::kFileSystemTypeIphoto, |
235 base::FilePath::FromUTF8Unsafe(virtual_path)); | 241 virtual_path); |
236 } | 242 } |
237 | 243 |
238 fileapi::FileSystemOperationRunner* operation_runner() const { | 244 fileapi::FileSystemOperationRunner* operation_runner() const { |
239 return file_system_context_->operation_runner(); | 245 return file_system_context_->operation_runner(); |
240 } | 246 } |
241 | 247 |
242 scoped_refptr<fileapi::FileSystemContext> file_system_context() const { | 248 scoped_refptr<fileapi::FileSystemContext> file_system_context() const { |
243 return file_system_context_; | 249 return file_system_context_; |
244 } | 250 } |
245 | 251 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 completed = false; | 344 completed = false; |
339 ReadDirectoryTestHelper(operation_runner(), url, &contents, &completed); | 345 ReadDirectoryTestHelper(operation_runner(), url, &contents, &completed); |
340 ASSERT_TRUE(completed); | 346 ASSERT_TRUE(completed); |
341 ASSERT_EQ(1u, contents.size()); | 347 ASSERT_EQ(1u, contents.size()); |
342 | 348 |
343 EXPECT_FALSE(contents.front().is_directory); | 349 EXPECT_FALSE(contents.front().is_directory); |
344 EXPECT_EQ("a.jpg", contents.front().name); | 350 EXPECT_EQ("a.jpg", contents.front().name); |
345 } | 351 } |
346 | 352 |
347 } // namespace iphoto | 353 } // namespace iphoto |
OLD | NEW |