| 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 <set> | 5 #include <set> |
| 6 #include <string> | 6 #include <string> |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
| 11 #include "base/memory/scoped_vector.h" | 11 #include "base/memory/scoped_vector.h" |
| 12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 13 #include "base/message_loop/message_loop_proxy.h" | 13 #include "base/message_loop/message_loop_proxy.h" |
| 14 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
| 15 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
| 16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
| 17 #include "chrome/browser/media_galleries/fileapi/media_file_system_mount_point_p
rovider.h" | 17 #include "chrome/browser/media_galleries/fileapi/media_file_system_backend.h" |
| 18 #include "chrome/browser/media_galleries/fileapi/media_path_filter.h" | 18 #include "chrome/browser/media_galleries/fileapi/media_path_filter.h" |
| 19 #include "chrome/browser/media_galleries/fileapi/picasa/picasa_data_provider.h" | 19 #include "chrome/browser/media_galleries/fileapi/picasa/picasa_data_provider.h" |
| 20 #include "chrome/browser/media_galleries/fileapi/picasa/picasa_file_util.h" | 20 #include "chrome/browser/media_galleries/fileapi/picasa/picasa_file_util.h" |
| 21 #include "chrome/common/media_galleries/picasa_types.h" | 21 #include "chrome/common/media_galleries/picasa_types.h" |
| 22 #include "chrome/common/media_galleries/pmp_constants.h" | 22 #include "chrome/common/media_galleries/pmp_constants.h" |
| 23 #include "content/public/test/test_browser_thread.h" | 23 #include "content/public/test/test_browser_thread.h" |
| 24 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
| 25 #include "webkit/browser/fileapi/async_file_util_adapter.h" | 25 #include "webkit/browser/fileapi/async_file_util_adapter.h" |
| 26 #include "webkit/browser/fileapi/external_mount_points.h" | 26 #include "webkit/browser/fileapi/external_mount_points.h" |
| 27 #include "webkit/browser/fileapi/file_system_context.h" | 27 #include "webkit/browser/fileapi/file_system_context.h" |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 } | 150 } |
| 151 virtual ~TestPicasaFileUtil() {} | 151 virtual ~TestPicasaFileUtil() {} |
| 152 private: | 152 private: |
| 153 virtual PicasaDataProvider* GetDataProvider() OVERRIDE { | 153 virtual PicasaDataProvider* GetDataProvider() OVERRIDE { |
| 154 return data_provider_; | 154 return data_provider_; |
| 155 } | 155 } |
| 156 | 156 |
| 157 PicasaDataProvider* data_provider_; | 157 PicasaDataProvider* data_provider_; |
| 158 }; | 158 }; |
| 159 | 159 |
| 160 class TestMediaFileSystemMountPointProvider | 160 class TestMediaFileSystemBackend |
| 161 : public chrome::MediaFileSystemMountPointProvider { | 161 : public chrome::MediaFileSystemBackend { |
| 162 public: | 162 public: |
| 163 TestMediaFileSystemMountPointProvider(const base::FilePath& profile_path, | 163 TestMediaFileSystemBackend(const base::FilePath& profile_path, |
| 164 PicasaFileUtil* picasa_file_util) | 164 PicasaFileUtil* picasa_file_util) |
| 165 : chrome::MediaFileSystemMountPointProvider( | 165 : chrome::MediaFileSystemBackend( |
| 166 profile_path, | 166 profile_path, |
| 167 base::MessageLoopProxy::current().get()), | 167 base::MessageLoopProxy::current().get()), |
| 168 test_file_util_(picasa_file_util) {} | 168 test_file_util_(picasa_file_util) {} |
| 169 | 169 |
| 170 virtual fileapi::AsyncFileUtil* | 170 virtual fileapi::AsyncFileUtil* |
| 171 GetAsyncFileUtil(fileapi::FileSystemType type) OVERRIDE { | 171 GetAsyncFileUtil(fileapi::FileSystemType type) OVERRIDE { |
| 172 if (type != fileapi::kFileSystemTypePicasa) | 172 if (type != fileapi::kFileSystemTypePicasa) |
| 173 return NULL; | 173 return NULL; |
| 174 | 174 |
| 175 return test_file_util_.get(); | 175 return test_file_util_.get(); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 virtual ~PicasaFileUtilTest() {} | 227 virtual ~PicasaFileUtilTest() {} |
| 228 | 228 |
| 229 virtual void SetUp() OVERRIDE { | 229 virtual void SetUp() OVERRIDE { |
| 230 ASSERT_TRUE(profile_dir_.CreateUniqueTempDir()); | 230 ASSERT_TRUE(profile_dir_.CreateUniqueTempDir()); |
| 231 | 231 |
| 232 scoped_refptr<quota::SpecialStoragePolicy> storage_policy = | 232 scoped_refptr<quota::SpecialStoragePolicy> storage_policy = |
| 233 new quota::MockSpecialStoragePolicy(); | 233 new quota::MockSpecialStoragePolicy(); |
| 234 | 234 |
| 235 picasa_data_provider_.reset(new TestPicasaDataProvider()); | 235 picasa_data_provider_.reset(new TestPicasaDataProvider()); |
| 236 | 236 |
| 237 ScopedVector<fileapi::FileSystemMountPointProvider> additional_providers; | 237 ScopedVector<fileapi::FileSystemBackend> additional_providers; |
| 238 additional_providers.push_back(new TestMediaFileSystemMountPointProvider( | 238 additional_providers.push_back(new TestMediaFileSystemBackend( |
| 239 profile_dir_.path(), | 239 profile_dir_.path(), |
| 240 new TestPicasaFileUtil(picasa_data_provider_.get()))); | 240 new TestPicasaFileUtil(picasa_data_provider_.get()))); |
| 241 | 241 |
| 242 file_system_context_ = new fileapi::FileSystemContext( | 242 file_system_context_ = new fileapi::FileSystemContext( |
| 243 fileapi::FileSystemTaskRunners::CreateMockTaskRunners(), | 243 fileapi::FileSystemTaskRunners::CreateMockTaskRunners(), |
| 244 fileapi::ExternalMountPoints::CreateRefCounted().get(), | 244 fileapi::ExternalMountPoints::CreateRefCounted().get(), |
| 245 storage_policy.get(), | 245 storage_policy.get(), |
| 246 NULL, | 246 NULL, |
| 247 additional_providers.Pass(), | 247 additional_providers.Pass(), |
| 248 profile_dir_.path(), | 248 profile_dir_.path(), |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 AlbumInfo("unique_name", test_date, "uuid1", base::FilePath())); | 392 AlbumInfo("unique_name", test_date, "uuid1", base::FilePath())); |
| 393 expected_names.push_back("unique_name " + test_date_string); | 393 expected_names.push_back("unique_name " + test_date_string); |
| 394 | 394 |
| 395 scoped_ptr<FileSystemOperationContext> operation_context( | 395 scoped_ptr<FileSystemOperationContext> operation_context( |
| 396 new FileSystemOperationContext(file_system_context().get())); | 396 new FileSystemOperationContext(file_system_context().get())); |
| 397 | 397 |
| 398 scoped_ptr<chrome::MediaPathFilter> media_path_filter( | 398 scoped_ptr<chrome::MediaPathFilter> media_path_filter( |
| 399 new chrome::MediaPathFilter()); | 399 new chrome::MediaPathFilter()); |
| 400 | 400 |
| 401 operation_context->SetUserValue( | 401 operation_context->SetUserValue( |
| 402 chrome::MediaFileSystemMountPointProvider::kMediaPathFilterKey, | 402 chrome::MediaFileSystemBackend::kMediaPathFilterKey, |
| 403 media_path_filter.get()); | 403 media_path_filter.get()); |
| 404 | 404 |
| 405 scoped_ptr<TestPicasaDataProvider> test_picasa_data_provider( | 405 scoped_ptr<TestPicasaDataProvider> test_picasa_data_provider( |
| 406 new TestPicasaDataProvider()); | 406 new TestPicasaDataProvider()); |
| 407 test_picasa_data_provider->Init(std::vector<AlbumInfo>(), folders); | 407 test_picasa_data_provider->Init(std::vector<AlbumInfo>(), folders); |
| 408 TestPicasaFileUtil test_file_util(test_picasa_data_provider.get()); | 408 TestPicasaFileUtil test_file_util(test_picasa_data_provider.get()); |
| 409 | 409 |
| 410 fileapi::AsyncFileUtil::EntryList file_list; | 410 fileapi::AsyncFileUtil::EntryList file_list; |
| 411 ASSERT_EQ(base::PLATFORM_FILE_OK, | 411 ASSERT_EQ(base::PLATFORM_FILE_OK, |
| 412 ReadDirectoryTestHelper(&test_file_util, operation_context.Pass(), | 412 ReadDirectoryTestHelper(&test_file_util, operation_context.Pass(), |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 new TestFolder(base::StringPrintf("folder-%05d", i), | 496 new TestFolder(base::StringPrintf("folder-%05d", i), |
| 497 date, | 497 date, |
| 498 base::StringPrintf("uid%05d", i), i % 5, i % 3)); | 498 base::StringPrintf("uid%05d", i), i % 5, i % 3)); |
| 499 } | 499 } |
| 500 | 500 |
| 501 SetupFolders(&test_folders); | 501 SetupFolders(&test_folders); |
| 502 VerifyFolderDirectoryList(test_folders); | 502 VerifyFolderDirectoryList(test_folders); |
| 503 } | 503 } |
| 504 | 504 |
| 505 } // namespace picasa | 505 } // namespace picasa |
| OLD | NEW |