Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(556)

Side by Side Diff: chrome/browser/media_galleries/fileapi/picasa_file_util_unittest.cc

Issue 23727009: Cleanup: Remove chrome namespace for storage monitor and media galleries. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix nit Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 DCHECK(completed); 152 DCHECK(completed);
153 base::RunLoop run_loop; 153 base::RunLoop run_loop;
154 runner->ReadDirectory( 154 runner->ReadDirectory(
155 url, base::Bind(&ReadDirectoryTestHelperCallback, &run_loop, contents, 155 url, base::Bind(&ReadDirectoryTestHelperCallback, &run_loop, contents,
156 completed)); 156 completed));
157 run_loop.Run(); 157 run_loop.Run();
158 } 158 }
159 159
160 void SynchronouslyRunOnMediaTaskRunner(const base::Closure& closure) { 160 void SynchronouslyRunOnMediaTaskRunner(const base::Closure& closure) {
161 base::RunLoop loop; 161 base::RunLoop loop;
162 chrome::MediaFileSystemBackend::MediaTaskRunner()->PostTaskAndReply( 162 MediaFileSystemBackend::MediaTaskRunner()->PostTaskAndReply(
163 FROM_HERE, 163 FROM_HERE,
164 closure, 164 closure,
165 loop.QuitClosure()); 165 loop.QuitClosure());
166 loop.Run(); 166 loop.Run();
167 } 167 }
168 168
169 void CreateSnapshotFileTestHelperCallback( 169 void CreateSnapshotFileTestHelperCallback(
170 base::RunLoop* run_loop, 170 base::RunLoop* run_loop,
171 base::PlatformFileError* error, 171 base::PlatformFileError* error,
172 base::FilePath* platform_path_result, 172 base::FilePath* platform_path_result,
173 base::PlatformFileError result, 173 base::PlatformFileError result,
174 const base::PlatformFileInfo& file_info, 174 const base::PlatformFileInfo& file_info,
175 const base::FilePath& platform_path, 175 const base::FilePath& platform_path,
176 const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref) { 176 const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref) {
177 DCHECK(run_loop); 177 DCHECK(run_loop);
178 DCHECK(error); 178 DCHECK(error);
179 DCHECK(platform_path_result); 179 DCHECK(platform_path_result);
180 180
181 *error = result; 181 *error = result;
182 *platform_path_result = platform_path; 182 *platform_path_result = platform_path;
183 run_loop->Quit(); 183 run_loop->Quit();
184 } 184 }
185 185
186 } // namespace 186 } // namespace
187 187
188 class TestPicasaFileUtil : public PicasaFileUtil { 188 class TestPicasaFileUtil : public PicasaFileUtil {
189 public: 189 public:
190 TestPicasaFileUtil(chrome::MediaPathFilter* media_path_filter, 190 TestPicasaFileUtil(MediaPathFilter* media_path_filter,
191 PicasaDataProvider* data_provider) 191 PicasaDataProvider* data_provider)
192 : PicasaFileUtil(media_path_filter), 192 : PicasaFileUtil(media_path_filter),
193 data_provider_(data_provider) { 193 data_provider_(data_provider) {
194 } 194 }
195 virtual ~TestPicasaFileUtil() {} 195 virtual ~TestPicasaFileUtil() {}
196 private: 196 private:
197 virtual PicasaDataProvider* GetDataProvider() OVERRIDE { 197 virtual PicasaDataProvider* GetDataProvider() OVERRIDE {
198 return data_provider_; 198 return data_provider_;
199 } 199 }
200 200
201 PicasaDataProvider* data_provider_; 201 PicasaDataProvider* data_provider_;
202 }; 202 };
203 203
204 class TestMediaFileSystemBackend 204 class TestMediaFileSystemBackend : public MediaFileSystemBackend {
205 : public chrome::MediaFileSystemBackend {
206 public: 205 public:
207 TestMediaFileSystemBackend(const base::FilePath& profile_path, 206 TestMediaFileSystemBackend(const base::FilePath& profile_path,
208 PicasaFileUtil* picasa_file_util) 207 PicasaFileUtil* picasa_file_util)
209 : chrome::MediaFileSystemBackend( 208 : MediaFileSystemBackend(profile_path,
210 profile_path, 209 MediaFileSystemBackend::MediaTaskRunner().get()),
211 chrome::MediaFileSystemBackend::MediaTaskRunner().get()),
212 test_file_util_(picasa_file_util) {} 210 test_file_util_(picasa_file_util) {}
213 211
214 virtual fileapi::AsyncFileUtil* 212 virtual fileapi::AsyncFileUtil*
215 GetAsyncFileUtil(fileapi::FileSystemType type) OVERRIDE { 213 GetAsyncFileUtil(fileapi::FileSystemType type) OVERRIDE {
216 if (type != fileapi::kFileSystemTypePicasa) 214 if (type != fileapi::kFileSystemTypePicasa)
217 return NULL; 215 return NULL;
218 216
219 return test_file_util_.get(); 217 return test_file_util_.get();
220 } 218 }
221 219
(...skipping 10 matching lines...) Expand all
232 230
233 virtual void SetUp() OVERRIDE { 231 virtual void SetUp() OVERRIDE {
234 ASSERT_TRUE(profile_dir_.CreateUniqueTempDir()); 232 ASSERT_TRUE(profile_dir_.CreateUniqueTempDir());
235 233
236 scoped_refptr<quota::SpecialStoragePolicy> storage_policy = 234 scoped_refptr<quota::SpecialStoragePolicy> storage_policy =
237 new quota::MockSpecialStoragePolicy(); 235 new quota::MockSpecialStoragePolicy();
238 236
239 SynchronouslyRunOnMediaTaskRunner(base::Bind( 237 SynchronouslyRunOnMediaTaskRunner(base::Bind(
240 &PicasaFileUtilTest::SetUpOnMediaTaskRunner, base::Unretained(this))); 238 &PicasaFileUtilTest::SetUpOnMediaTaskRunner, base::Unretained(this)));
241 239
242 media_path_filter_.reset(new chrome::MediaPathFilter()); 240 media_path_filter_.reset(new MediaPathFilter());
243 241
244 ScopedVector<fileapi::FileSystemBackend> additional_providers; 242 ScopedVector<fileapi::FileSystemBackend> additional_providers;
245 additional_providers.push_back(new TestMediaFileSystemBackend( 243 additional_providers.push_back(new TestMediaFileSystemBackend(
246 profile_dir_.path(), 244 profile_dir_.path(),
247 new TestPicasaFileUtil(media_path_filter_.get(), 245 new TestPicasaFileUtil(media_path_filter_.get(),
248 picasa_data_provider_.get()))); 246 picasa_data_provider_.get())));
249 247
250 file_system_context_ = new fileapi::FileSystemContext( 248 file_system_context_ = new fileapi::FileSystemContext(
251 base::MessageLoopProxy::current().get(), 249 base::MessageLoopProxy::current().get(),
252 base::MessageLoopProxy::current().get(), 250 base::MessageLoopProxy::current().get(),
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 } 372 }
375 373
376 private: 374 private:
377 base::MessageLoop message_loop_; 375 base::MessageLoop message_loop_;
378 content::TestBrowserThread io_thread_; 376 content::TestBrowserThread io_thread_;
379 377
380 base::ScopedTempDir profile_dir_; 378 base::ScopedTempDir profile_dir_;
381 379
382 scoped_refptr<fileapi::FileSystemContext> file_system_context_; 380 scoped_refptr<fileapi::FileSystemContext> file_system_context_;
383 scoped_ptr<PicasaDataProvider> picasa_data_provider_; 381 scoped_ptr<PicasaDataProvider> picasa_data_provider_;
384 scoped_ptr<chrome::MediaPathFilter> media_path_filter_; 382 scoped_ptr<MediaPathFilter> media_path_filter_;
385 383
386 DISALLOW_COPY_AND_ASSIGN(PicasaFileUtilTest); 384 DISALLOW_COPY_AND_ASSIGN(PicasaFileUtilTest);
387 }; 385 };
388 386
389 TEST_F(PicasaFileUtilTest, DateFormat) { 387 TEST_F(PicasaFileUtilTest, DateFormat) {
390 base::Time::Exploded exploded_shortmonth = { 2013, 4, 0, 16, 0, 0, 0, 0 }; 388 base::Time::Exploded exploded_shortmonth = { 2013, 4, 0, 16, 0, 0, 0, 0 };
391 base::Time shortmonth = base::Time::FromLocalExploded(exploded_shortmonth); 389 base::Time shortmonth = base::Time::FromLocalExploded(exploded_shortmonth);
392 390
393 base::Time::Exploded exploded_shortday = { 2013, 11, 0, 3, 0, 0, 0, 0 }; 391 base::Time::Exploded exploded_shortday = { 2013, 11, 0, 3, 0, 0, 0, 0 };
394 base::Time shortday = base::Time::FromLocalExploded(exploded_shortday); 392 base::Time shortday = base::Time::FromLocalExploded(exploded_shortday);
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 operation_runner()->CreateSnapshotFile( 589 operation_runner()->CreateSnapshotFile(
592 CreateURL(std::string(kPicasaDirAlbums) + 590 CreateURL(std::string(kPicasaDirAlbums) +
593 "/albumname 2013-04-16/mapped_name.jpg"), 591 "/albumname 2013-04-16/mapped_name.jpg"),
594 snapshot_callback); 592 snapshot_callback);
595 loop.Run(); 593 loop.Run();
596 EXPECT_EQ(base::PLATFORM_FILE_OK, error); 594 EXPECT_EQ(base::PLATFORM_FILE_OK, error);
597 EXPECT_EQ(image_path, platform_path_result); 595 EXPECT_EQ(image_path, platform_path_result);
598 } 596 }
599 597
600 } // namespace picasa 598 } // namespace picasa
OLDNEW
« no previous file with comments | « chrome/browser/media_galleries/fileapi/picasa_file_util.cc ('k') | chrome/browser/media_galleries/fileapi/picasa_finder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698