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" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 | 68 |
69 class TestIPhotoDataProvider : public IPhotoDataProvider { | 69 class TestIPhotoDataProvider : public IPhotoDataProvider { |
70 public: | 70 public: |
71 explicit TestIPhotoDataProvider(const base::FilePath& fake_library_path) | 71 explicit TestIPhotoDataProvider(const base::FilePath& fake_library_path) |
72 : IPhotoDataProvider(fake_library_path) { | 72 : IPhotoDataProvider(fake_library_path) { |
73 EXPECT_TRUE(fake_auto_add_dir_.CreateUniqueTempDir()); | 73 EXPECT_TRUE(fake_auto_add_dir_.CreateUniqueTempDir()); |
74 } | 74 } |
75 | 75 |
76 virtual ~TestIPhotoDataProvider() {} | 76 virtual ~TestIPhotoDataProvider() {} |
77 | 77 |
78 virtual void RefreshData(const ReadyCallback& ready_callback) OVERRIDE { | 78 virtual void RefreshData(const ReadyCallback& ready_callback) override { |
79 ready_callback.Run(true /* success */); | 79 ready_callback.Run(true /* success */); |
80 } | 80 } |
81 | 81 |
82 virtual std::vector<std::string> GetAlbumNames() const OVERRIDE { | 82 virtual std::vector<std::string> GetAlbumNames() const override { |
83 std::vector<std::string> names; | 83 std::vector<std::string> names; |
84 names.push_back("Album1"); | 84 names.push_back("Album1"); |
85 names.push_back("has_originals"); | 85 names.push_back("has_originals"); |
86 return names; | 86 return names; |
87 } | 87 } |
88 | 88 |
89 virtual std::map<std::string, base::FilePath> GetAlbumContents( | 89 virtual std::map<std::string, base::FilePath> GetAlbumContents( |
90 const std::string& album) const OVERRIDE { | 90 const std::string& album) const override { |
91 std::map<std::string, base::FilePath> contents; | 91 std::map<std::string, base::FilePath> contents; |
92 contents["a.jpg"] = library_path().AppendASCII("a.jpg"); | 92 contents["a.jpg"] = library_path().AppendASCII("a.jpg"); |
93 return contents; | 93 return contents; |
94 } | 94 } |
95 | 95 |
96 virtual base::FilePath GetPhotoLocationInAlbum( | 96 virtual base::FilePath GetPhotoLocationInAlbum( |
97 const std::string& album, | 97 const std::string& album, |
98 const std::string& filename) const OVERRIDE { | 98 const std::string& filename) const override { |
99 return library_path().AppendASCII("a.jpg"); | 99 return library_path().AppendASCII("a.jpg"); |
100 } | 100 } |
101 | 101 |
102 virtual bool HasOriginals(const std::string& album) const OVERRIDE { | 102 virtual bool HasOriginals(const std::string& album) const override { |
103 return (album == "has_originals"); | 103 return (album == "has_originals"); |
104 } | 104 } |
105 | 105 |
106 virtual std::map<std::string, base::FilePath> GetOriginals( | 106 virtual std::map<std::string, base::FilePath> GetOriginals( |
107 const std::string& album) const OVERRIDE { | 107 const std::string& album) const override { |
108 std::map<std::string, base::FilePath> contents; | 108 std::map<std::string, base::FilePath> contents; |
109 contents["a.jpg"] = library_path().AppendASCII("orig.jpg"); | 109 contents["a.jpg"] = library_path().AppendASCII("orig.jpg"); |
110 return contents; | 110 return contents; |
111 } | 111 } |
112 | 112 |
113 virtual base::FilePath GetOriginalPhotoLocation( | 113 virtual base::FilePath GetOriginalPhotoLocation( |
114 const std::string& album, | 114 const std::string& album, |
115 const std::string& filename) const OVERRIDE { | 115 const std::string& filename) const override { |
116 return library_path().AppendASCII("orig.jpg"); | 116 return library_path().AppendASCII("orig.jpg"); |
117 } | 117 } |
118 | 118 |
119 private: | 119 private: |
120 base::ScopedTempDir fake_auto_add_dir_; | 120 base::ScopedTempDir fake_auto_add_dir_; |
121 }; | 121 }; |
122 | 122 |
123 class TestIPhotoFileUtil : public IPhotoFileUtil { | 123 class TestIPhotoFileUtil : public IPhotoFileUtil { |
124 public: | 124 public: |
125 explicit TestIPhotoFileUtil(MediaPathFilter* media_path_filter, | 125 explicit TestIPhotoFileUtil(MediaPathFilter* media_path_filter, |
126 IPhotoDataProvider* data_provider) | 126 IPhotoDataProvider* data_provider) |
127 : IPhotoFileUtil(media_path_filter), | 127 : IPhotoFileUtil(media_path_filter), |
128 data_provider_(data_provider) { | 128 data_provider_(data_provider) { |
129 } | 129 } |
130 virtual ~TestIPhotoFileUtil() {} | 130 virtual ~TestIPhotoFileUtil() {} |
131 | 131 |
132 private: | 132 private: |
133 virtual IPhotoDataProvider* GetDataProvider() OVERRIDE { | 133 virtual IPhotoDataProvider* GetDataProvider() override { |
134 return data_provider_; | 134 return data_provider_; |
135 } | 135 } |
136 | 136 |
137 IPhotoDataProvider* data_provider_; | 137 IPhotoDataProvider* data_provider_; |
138 }; | 138 }; |
139 | 139 |
140 class TestMediaFileSystemBackend : public MediaFileSystemBackend { | 140 class TestMediaFileSystemBackend : public MediaFileSystemBackend { |
141 public: | 141 public: |
142 TestMediaFileSystemBackend(const base::FilePath& profile_path, | 142 TestMediaFileSystemBackend(const base::FilePath& profile_path, |
143 IPhotoFileUtil* iphoto_file_util) | 143 IPhotoFileUtil* iphoto_file_util) |
144 : MediaFileSystemBackend( | 144 : MediaFileSystemBackend( |
145 profile_path, | 145 profile_path, |
146 MediaFileSystemBackend::MediaTaskRunner().get()), | 146 MediaFileSystemBackend::MediaTaskRunner().get()), |
147 test_file_util_(iphoto_file_util) {} | 147 test_file_util_(iphoto_file_util) {} |
148 | 148 |
149 virtual storage::AsyncFileUtil* GetAsyncFileUtil( | 149 virtual storage::AsyncFileUtil* GetAsyncFileUtil( |
150 storage::FileSystemType type) OVERRIDE { | 150 storage::FileSystemType type) override { |
151 if (type != storage::kFileSystemTypeIphoto) | 151 if (type != storage::kFileSystemTypeIphoto) |
152 return NULL; | 152 return NULL; |
153 | 153 |
154 return test_file_util_.get(); | 154 return test_file_util_.get(); |
155 } | 155 } |
156 | 156 |
157 private: | 157 private: |
158 scoped_ptr<storage::AsyncFileUtil> test_file_util_; | 158 scoped_ptr<storage::AsyncFileUtil> test_file_util_; |
159 }; | 159 }; |
160 | 160 |
(...skipping 16 matching lines...) Expand all Loading... |
177 0, | 177 0, |
178 base::WriteFile( | 178 base::WriteFile( |
179 fake_library_dir_.path().AppendASCII("orig.jpg"), | 179 fake_library_dir_.path().AppendASCII("orig.jpg"), |
180 NULL, | 180 NULL, |
181 0)); | 181 0)); |
182 | 182 |
183 iphoto_data_provider_.reset( | 183 iphoto_data_provider_.reset( |
184 new TestIPhotoDataProvider(fake_library_dir_.path())); | 184 new TestIPhotoDataProvider(fake_library_dir_.path())); |
185 } | 185 } |
186 | 186 |
187 virtual void SetUp() OVERRIDE { | 187 virtual void SetUp() override { |
188 ASSERT_TRUE(profile_dir_.CreateUniqueTempDir()); | 188 ASSERT_TRUE(profile_dir_.CreateUniqueTempDir()); |
189 ImportedMediaGalleryRegistry::GetInstance()->Initialize(); | 189 ImportedMediaGalleryRegistry::GetInstance()->Initialize(); |
190 | 190 |
191 scoped_refptr<storage::SpecialStoragePolicy> storage_policy = | 191 scoped_refptr<storage::SpecialStoragePolicy> storage_policy = |
192 new content::MockSpecialStoragePolicy(); | 192 new content::MockSpecialStoragePolicy(); |
193 | 193 |
194 // Initialize fake IPhotoDataProvider on media task runner thread. | 194 // Initialize fake IPhotoDataProvider on media task runner thread. |
195 MediaFileSystemBackend::MediaTaskRunner()->PostTask( | 195 MediaFileSystemBackend::MediaTaskRunner()->PostTask( |
196 FROM_HERE, | 196 FROM_HERE, |
197 base::Bind(&IPhotoFileUtilTest::SetUpDataProvider, | 197 base::Bind(&IPhotoFileUtilTest::SetUpDataProvider, |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 completed = false; | 345 completed = false; |
346 ReadDirectoryTestHelper(operation_runner(), url, &contents, &completed); | 346 ReadDirectoryTestHelper(operation_runner(), url, &contents, &completed); |
347 ASSERT_TRUE(completed); | 347 ASSERT_TRUE(completed); |
348 ASSERT_EQ(1u, contents.size()); | 348 ASSERT_EQ(1u, contents.size()); |
349 | 349 |
350 EXPECT_FALSE(contents.front().is_directory); | 350 EXPECT_FALSE(contents.front().is_directory); |
351 EXPECT_EQ("a.jpg", contents.front().name); | 351 EXPECT_EQ("a.jpg", contents.front().name); |
352 } | 352 } |
353 | 353 |
354 } // namespace iphoto | 354 } // namespace iphoto |
OLD | NEW |