| 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/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 | 185 |
| 186 class TestPicasaFileUtil : public PicasaFileUtil { | 186 class TestPicasaFileUtil : public PicasaFileUtil { |
| 187 public: | 187 public: |
| 188 TestPicasaFileUtil(MediaPathFilter* media_path_filter, | 188 TestPicasaFileUtil(MediaPathFilter* media_path_filter, |
| 189 PicasaDataProvider* data_provider) | 189 PicasaDataProvider* data_provider) |
| 190 : PicasaFileUtil(media_path_filter), | 190 : PicasaFileUtil(media_path_filter), |
| 191 data_provider_(data_provider) { | 191 data_provider_(data_provider) { |
| 192 } | 192 } |
| 193 virtual ~TestPicasaFileUtil() {} | 193 virtual ~TestPicasaFileUtil() {} |
| 194 private: | 194 private: |
| 195 virtual PicasaDataProvider* GetDataProvider() OVERRIDE { | 195 virtual PicasaDataProvider* GetDataProvider() override { |
| 196 return data_provider_; | 196 return data_provider_; |
| 197 } | 197 } |
| 198 | 198 |
| 199 PicasaDataProvider* data_provider_; | 199 PicasaDataProvider* data_provider_; |
| 200 }; | 200 }; |
| 201 | 201 |
| 202 class TestMediaFileSystemBackend : public MediaFileSystemBackend { | 202 class TestMediaFileSystemBackend : public MediaFileSystemBackend { |
| 203 public: | 203 public: |
| 204 TestMediaFileSystemBackend(const base::FilePath& profile_path, | 204 TestMediaFileSystemBackend(const base::FilePath& profile_path, |
| 205 PicasaFileUtil* picasa_file_util) | 205 PicasaFileUtil* picasa_file_util) |
| 206 : MediaFileSystemBackend(profile_path, | 206 : MediaFileSystemBackend(profile_path, |
| 207 MediaFileSystemBackend::MediaTaskRunner().get()), | 207 MediaFileSystemBackend::MediaTaskRunner().get()), |
| 208 test_file_util_(picasa_file_util) {} | 208 test_file_util_(picasa_file_util) {} |
| 209 | 209 |
| 210 virtual storage::AsyncFileUtil* GetAsyncFileUtil( | 210 virtual storage::AsyncFileUtil* GetAsyncFileUtil( |
| 211 storage::FileSystemType type) OVERRIDE { | 211 storage::FileSystemType type) override { |
| 212 if (type != storage::kFileSystemTypePicasa) | 212 if (type != storage::kFileSystemTypePicasa) |
| 213 return NULL; | 213 return NULL; |
| 214 | 214 |
| 215 return test_file_util_.get(); | 215 return test_file_util_.get(); |
| 216 } | 216 } |
| 217 | 217 |
| 218 private: | 218 private: |
| 219 scoped_ptr<storage::AsyncFileUtil> test_file_util_; | 219 scoped_ptr<storage::AsyncFileUtil> test_file_util_; |
| 220 }; | 220 }; |
| 221 | 221 |
| 222 class PicasaFileUtilTest : public testing::Test { | 222 class PicasaFileUtilTest : public testing::Test { |
| 223 public: | 223 public: |
| 224 PicasaFileUtilTest() | 224 PicasaFileUtilTest() |
| 225 : io_thread_(content::BrowserThread::IO, &message_loop_) { | 225 : io_thread_(content::BrowserThread::IO, &message_loop_) { |
| 226 } | 226 } |
| 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 ImportedMediaGalleryRegistry::GetInstance()->Initialize(); | 231 ImportedMediaGalleryRegistry::GetInstance()->Initialize(); |
| 232 | 232 |
| 233 scoped_refptr<storage::SpecialStoragePolicy> storage_policy = | 233 scoped_refptr<storage::SpecialStoragePolicy> storage_policy = |
| 234 new content::MockSpecialStoragePolicy(); | 234 new content::MockSpecialStoragePolicy(); |
| 235 | 235 |
| 236 SynchronouslyRunOnMediaTaskRunner(base::Bind( | 236 SynchronouslyRunOnMediaTaskRunner(base::Bind( |
| 237 &PicasaFileUtilTest::SetUpOnMediaTaskRunner, base::Unretained(this))); | 237 &PicasaFileUtilTest::SetUpOnMediaTaskRunner, base::Unretained(this))); |
| 238 | 238 |
| 239 media_path_filter_.reset(new MediaPathFilter()); | 239 media_path_filter_.reset(new MediaPathFilter()); |
| 240 | 240 |
| 241 ScopedVector<storage::FileSystemBackend> additional_providers; | 241 ScopedVector<storage::FileSystemBackend> additional_providers; |
| 242 additional_providers.push_back(new TestMediaFileSystemBackend( | 242 additional_providers.push_back(new TestMediaFileSystemBackend( |
| 243 profile_dir_.path(), | 243 profile_dir_.path(), |
| 244 new TestPicasaFileUtil(media_path_filter_.get(), | 244 new TestPicasaFileUtil(media_path_filter_.get(), |
| 245 picasa_data_provider_.get()))); | 245 picasa_data_provider_.get()))); |
| 246 | 246 |
| 247 file_system_context_ = new storage::FileSystemContext( | 247 file_system_context_ = new storage::FileSystemContext( |
| 248 base::MessageLoopProxy::current().get(), | 248 base::MessageLoopProxy::current().get(), |
| 249 base::MessageLoopProxy::current().get(), | 249 base::MessageLoopProxy::current().get(), |
| 250 storage::ExternalMountPoints::CreateRefCounted().get(), | 250 storage::ExternalMountPoints::CreateRefCounted().get(), |
| 251 storage_policy.get(), | 251 storage_policy.get(), |
| 252 NULL, | 252 NULL, |
| 253 additional_providers.Pass(), | 253 additional_providers.Pass(), |
| 254 std::vector<storage::URLRequestAutoMountHandler>(), | 254 std::vector<storage::URLRequestAutoMountHandler>(), |
| 255 profile_dir_.path(), | 255 profile_dir_.path(), |
| 256 content::CreateAllowFileAccessOptions()); | 256 content::CreateAllowFileAccessOptions()); |
| 257 } | 257 } |
| 258 | 258 |
| 259 virtual void TearDown() OVERRIDE { | 259 virtual void TearDown() override { |
| 260 SynchronouslyRunOnMediaTaskRunner( | 260 SynchronouslyRunOnMediaTaskRunner( |
| 261 base::Bind(&PicasaFileUtilTest::TearDownOnMediaTaskRunner, | 261 base::Bind(&PicasaFileUtilTest::TearDownOnMediaTaskRunner, |
| 262 base::Unretained(this))); | 262 base::Unretained(this))); |
| 263 } | 263 } |
| 264 | 264 |
| 265 protected: | 265 protected: |
| 266 void SetUpOnMediaTaskRunner() { | 266 void SetUpOnMediaTaskRunner() { |
| 267 picasa_data_provider_.reset(new PicasaDataProvider(base::FilePath())); | 267 picasa_data_provider_.reset(new PicasaDataProvider(base::FilePath())); |
| 268 } | 268 } |
| 269 | 269 |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 operation_runner()->CreateSnapshotFile( | 592 operation_runner()->CreateSnapshotFile( |
| 593 CreateURL(std::string(kPicasaDirAlbums) + | 593 CreateURL(std::string(kPicasaDirAlbums) + |
| 594 "/albumname 2013-04-16/mapped_name.jpg"), | 594 "/albumname 2013-04-16/mapped_name.jpg"), |
| 595 snapshot_callback); | 595 snapshot_callback); |
| 596 loop.Run(); | 596 loop.Run(); |
| 597 EXPECT_EQ(base::File::FILE_OK, error); | 597 EXPECT_EQ(base::File::FILE_OK, error); |
| 598 EXPECT_EQ(image_path, platform_path_result); | 598 EXPECT_EQ(image_path, platform_path_result); |
| 599 } | 599 } |
| 600 | 600 |
| 601 } // namespace picasa | 601 } // namespace picasa |
| OLD | NEW |