| 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/file_util.h" | 10 #include "base/file_util.h" |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/files/scoped_temp_dir.h" | 12 #include "base/files/scoped_temp_dir.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
| 15 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
| 16 #include "base/message_loop/message_loop_proxy.h" | 16 #include "base/message_loop/message_loop_proxy.h" |
| 17 #include "base/platform_file.h" | 17 #include "base/platform_file.h" |
| 18 #include "base/run_loop.h" | 18 #include "base/run_loop.h" |
| 19 #include "base/strings/stringprintf.h" | 19 #include "base/strings/stringprintf.h" |
| 20 #include "base/time/time.h" | 20 #include "base/time/time.h" |
| 21 #include "chrome/browser/media_galleries/fileapi/media_file_system_backend.h" | 21 #include "chrome/browser/media_galleries/fileapi/media_file_system_backend.h" |
| 22 #include "chrome/browser/media_galleries/fileapi/media_path_filter.h" | 22 #include "chrome/browser/media_galleries/fileapi/media_path_filter.h" |
| 23 #include "chrome/browser/media_galleries/fileapi/picasa_data_provider.h" | 23 #include "chrome/browser/media_galleries/fileapi/picasa_data_provider.h" |
| 24 #include "chrome/browser/media_galleries/fileapi/picasa_file_util.h" | 24 #include "chrome/browser/media_galleries/fileapi/picasa_file_util.h" |
| 25 #include "chrome/browser/media_galleries/imported_media_gallery_registry.h" |
| 25 #include "chrome/common/media_galleries/picasa_types.h" | 26 #include "chrome/common/media_galleries/picasa_types.h" |
| 26 #include "chrome/common/media_galleries/pmp_constants.h" | 27 #include "chrome/common/media_galleries/pmp_constants.h" |
| 27 #include "content/public/browser/browser_thread.h" | 28 #include "content/public/browser/browser_thread.h" |
| 28 #include "content/public/test/test_browser_thread.h" | 29 #include "content/public/test/test_browser_thread.h" |
| 29 #include "content/public/test/test_file_system_options.h" | 30 #include "content/public/test/test_file_system_options.h" |
| 30 #include "testing/gtest/include/gtest/gtest.h" | 31 #include "testing/gtest/include/gtest/gtest.h" |
| 31 #include "webkit/browser/fileapi/async_file_util.h" | 32 #include "webkit/browser/fileapi/async_file_util.h" |
| 32 #include "webkit/browser/fileapi/external_mount_points.h" | 33 #include "webkit/browser/fileapi/external_mount_points.h" |
| 33 #include "webkit/browser/fileapi/file_system_context.h" | 34 #include "webkit/browser/fileapi/file_system_context.h" |
| 34 #include "webkit/browser/fileapi/file_system_operation_context.h" | 35 #include "webkit/browser/fileapi/file_system_operation_context.h" |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 | 222 |
| 222 class PicasaFileUtilTest : public testing::Test { | 223 class PicasaFileUtilTest : public testing::Test { |
| 223 public: | 224 public: |
| 224 PicasaFileUtilTest() | 225 PicasaFileUtilTest() |
| 225 : io_thread_(content::BrowserThread::IO, &message_loop_) { | 226 : io_thread_(content::BrowserThread::IO, &message_loop_) { |
| 226 } | 227 } |
| 227 virtual ~PicasaFileUtilTest() {} | 228 virtual ~PicasaFileUtilTest() {} |
| 228 | 229 |
| 229 virtual void SetUp() OVERRIDE { | 230 virtual void SetUp() OVERRIDE { |
| 230 ASSERT_TRUE(profile_dir_.CreateUniqueTempDir()); | 231 ASSERT_TRUE(profile_dir_.CreateUniqueTempDir()); |
| 232 ImportedMediaGalleryRegistry::GetInstance()->Initialize(); |
| 231 | 233 |
| 232 scoped_refptr<quota::SpecialStoragePolicy> storage_policy = | 234 scoped_refptr<quota::SpecialStoragePolicy> storage_policy = |
| 233 new quota::MockSpecialStoragePolicy(); | 235 new quota::MockSpecialStoragePolicy(); |
| 234 | 236 |
| 235 SynchronouslyRunOnMediaTaskRunner(base::Bind( | 237 SynchronouslyRunOnMediaTaskRunner(base::Bind( |
| 236 &PicasaFileUtilTest::SetUpOnMediaTaskRunner, base::Unretained(this))); | 238 &PicasaFileUtilTest::SetUpOnMediaTaskRunner, base::Unretained(this))); |
| 237 | 239 |
| 238 media_path_filter_.reset(new MediaPathFilter()); | 240 media_path_filter_.reset(new MediaPathFilter()); |
| 239 | 241 |
| 240 ScopedVector<fileapi::FileSystemBackend> additional_providers; | 242 ScopedVector<fileapi::FileSystemBackend> additional_providers; |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 void TestEmptyDirectory(const std::string& path) { | 351 void TestEmptyDirectory(const std::string& path) { |
| 350 FileSystemOperation::FileEntryList contents; | 352 FileSystemOperation::FileEntryList contents; |
| 351 FileSystemURL url = CreateURL(path); | 353 FileSystemURL url = CreateURL(path); |
| 352 bool completed = false; | 354 bool completed = false; |
| 353 ReadDirectoryTestHelper(operation_runner(), url, &contents, &completed); | 355 ReadDirectoryTestHelper(operation_runner(), url, &contents, &completed); |
| 354 | 356 |
| 355 ASSERT_TRUE(completed); | 357 ASSERT_TRUE(completed); |
| 356 EXPECT_EQ(0u, contents.size()); | 358 EXPECT_EQ(0u, contents.size()); |
| 357 } | 359 } |
| 358 | 360 |
| 359 FileSystemURL CreateURL(const std::string& virtual_path) const { | 361 FileSystemURL CreateURL(const std::string& path) const { |
| 362 base::FilePath virtual_path = |
| 363 ImportedMediaGalleryRegistry::GetInstance()->ImportedRoot(); |
| 364 virtual_path = virtual_path.AppendASCII("picasa"); |
| 365 virtual_path = virtual_path.AppendASCII(path); |
| 360 return file_system_context_->CreateCrackedFileSystemURL( | 366 return file_system_context_->CreateCrackedFileSystemURL( |
| 361 GURL("http://www.example.com"), fileapi::kFileSystemTypePicasa, | 367 GURL("http://www.example.com"), fileapi::kFileSystemTypePicasa, |
| 362 base::FilePath::FromUTF8Unsafe(virtual_path)); | 368 virtual_path); |
| 363 } | 369 } |
| 364 | 370 |
| 365 fileapi::FileSystemOperationRunner* operation_runner() const { | 371 fileapi::FileSystemOperationRunner* operation_runner() const { |
| 366 return file_system_context_->operation_runner(); | 372 return file_system_context_->operation_runner(); |
| 367 } | 373 } |
| 368 | 374 |
| 369 scoped_refptr<fileapi::FileSystemContext> file_system_context() const { | 375 scoped_refptr<fileapi::FileSystemContext> file_system_context() const { |
| 370 return file_system_context_; | 376 return file_system_context_; |
| 371 } | 377 } |
| 372 | 378 |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 operation_runner()->CreateSnapshotFile( | 594 operation_runner()->CreateSnapshotFile( |
| 589 CreateURL(std::string(kPicasaDirAlbums) + | 595 CreateURL(std::string(kPicasaDirAlbums) + |
| 590 "/albumname 2013-04-16/mapped_name.jpg"), | 596 "/albumname 2013-04-16/mapped_name.jpg"), |
| 591 snapshot_callback); | 597 snapshot_callback); |
| 592 loop.Run(); | 598 loop.Run(); |
| 593 EXPECT_EQ(base::File::FILE_OK, error); | 599 EXPECT_EQ(base::File::FILE_OK, error); |
| 594 EXPECT_EQ(image_path, platform_path_result); | 600 EXPECT_EQ(image_path, platform_path_result); |
| 595 } | 601 } |
| 596 | 602 |
| 597 } // namespace picasa | 603 } // namespace picasa |
| OLD | NEW |