| 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/common/media_galleries/picasa_test_util.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 "testing/gtest/include/gtest/gtest.h" | 30 #include "testing/gtest/include/gtest/gtest.h" |
| 30 #include "webkit/browser/fileapi/async_file_util_adapter.h" | 31 #include "webkit/browser/fileapi/async_file_util_adapter.h" |
| 31 #include "webkit/browser/fileapi/external_mount_points.h" | 32 #include "webkit/browser/fileapi/external_mount_points.h" |
| 32 #include "webkit/browser/fileapi/file_system_context.h" | 33 #include "webkit/browser/fileapi/file_system_context.h" |
| 33 #include "webkit/browser/fileapi/file_system_file_util.h" | 34 #include "webkit/browser/fileapi/file_system_file_util.h" |
| 34 #include "webkit/browser/fileapi/file_system_operation_context.h" | 35 #include "webkit/browser/fileapi/file_system_operation_context.h" |
| 35 #include "webkit/browser/fileapi/file_system_operation_runner.h" | 36 #include "webkit/browser/fileapi/file_system_operation_runner.h" |
| 36 #include "webkit/browser/fileapi/isolated_context.h" | 37 #include "webkit/browser/fileapi/isolated_context.h" |
| 37 #include "webkit/browser/fileapi/mock_file_system_options.h" | 38 #include "webkit/browser/fileapi/mock_file_system_options.h" |
| 38 #include "webkit/browser/quota/mock_special_storage_policy.h" | 39 #include "webkit/browser/quota/mock_special_storage_policy.h" |
| 39 #include "webkit/common/blob/shareable_file_reference.h" | 40 #include "webkit/common/blob/shareable_file_reference.h" |
| 40 | 41 |
| 41 using fileapi::FileSystemFileUtil; | 42 using fileapi::FileSystemFileUtil; |
| 42 using fileapi::FileSystemOperationContext; | 43 using fileapi::FileSystemOperationContext; |
| 43 using fileapi::FileSystemOperation; | 44 using fileapi::FileSystemOperation; |
| 44 using fileapi::FileSystemURL; | 45 using fileapi::FileSystemURL; |
| 45 | 46 |
| 46 namespace picasa { | 47 namespace picasa { |
| 47 | 48 |
| 48 namespace { | 49 namespace { |
| 49 | 50 |
| 50 base::Time::Exploded test_date_exploded = { 2013, 4, 0, 16, 0, 0, 0, 0 }; | 51 base::Time::Exploded test_date_exploded = { 2013, 4, 0, 16, 0, 0, 0, 0 }; |
| 51 | 52 |
| 52 bool WriteJPEGHeader(const base::FilePath& path) { | |
| 53 const char kJpegHeader[] = "\xFF\xD8\xFF"; // Per HTML5 specification. | |
| 54 return file_util::WriteFile(path, kJpegHeader, arraysize(kJpegHeader)) != -1; | |
| 55 } | |
| 56 | |
| 57 class TestFolder { | 53 class TestFolder { |
| 58 public: | 54 public: |
| 59 TestFolder(const std::string& name, const base::Time& timestamp, | 55 TestFolder(const std::string& name, const base::Time& timestamp, |
| 60 const std::string& uid, unsigned int image_files, | 56 const std::string& uid, unsigned int image_files, |
| 61 unsigned int non_image_files) | 57 unsigned int non_image_files) |
| 62 : name_(name), | 58 : name_(name), |
| 63 timestamp_(timestamp), | 59 timestamp_(timestamp), |
| 64 uid_(uid), | 60 uid_(uid), |
| 65 image_files_(image_files), | 61 image_files_(image_files), |
| 66 non_image_files_(non_image_files), | 62 non_image_files_(non_image_files), |
| (...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 operation_runner()->CreateSnapshotFile( | 585 operation_runner()->CreateSnapshotFile( |
| 590 CreateURL(std::string(kPicasaDirAlbums) + | 586 CreateURL(std::string(kPicasaDirAlbums) + |
| 591 "/albumname 2013-04-16/mapped_name.jpg"), | 587 "/albumname 2013-04-16/mapped_name.jpg"), |
| 592 snapshot_callback); | 588 snapshot_callback); |
| 593 loop.Run(); | 589 loop.Run(); |
| 594 EXPECT_EQ(base::PLATFORM_FILE_OK, error); | 590 EXPECT_EQ(base::PLATFORM_FILE_OK, error); |
| 595 EXPECT_EQ(image_path, platform_path_result); | 591 EXPECT_EQ(image_path, platform_path_result); |
| 596 } | 592 } |
| 597 | 593 |
| 598 } // namespace picasa | 594 } // namespace picasa |
| OLD | NEW |