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

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

Issue 2318033002: c/browser, c/common, components M-N: Change ScopedTempDir::path() to GetPath() (Closed)
Patch Set: Fix ItunesFileUtilTest Created 4 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
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 "chrome/browser/media_galleries/fileapi/picasa_file_util.h" 5 #include "chrome/browser/media_galleries/fileapi/picasa_file_util.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <set> 10 #include <set>
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 uid_(uid), 69 uid_(uid),
70 image_files_(image_files), 70 image_files_(image_files),
71 non_image_files_(non_image_files), 71 non_image_files_(non_image_files),
72 folder_info_("", base::Time(), "", base::FilePath()) { 72 folder_info_("", base::Time(), "", base::FilePath()) {
73 } 73 }
74 74
75 bool Init() { 75 bool Init() {
76 if (!folder_dir_.CreateUniqueTempDir()) 76 if (!folder_dir_.CreateUniqueTempDir())
77 return false; 77 return false;
78 78
79 folder_info_ = AlbumInfo(name_, timestamp_, uid_, folder_dir_.path()); 79 folder_info_ = AlbumInfo(name_, timestamp_, uid_, folder_dir_.GetPath());
80 80
81 for (unsigned int i = 0; i < image_files_; ++i) { 81 for (unsigned int i = 0; i < image_files_; ++i) {
82 std::string image_filename = base::StringPrintf("img%05d.jpg", i); 82 std::string image_filename = base::StringPrintf("img%05d.jpg", i);
83 image_filenames_.insert(image_filename); 83 image_filenames_.insert(image_filename);
84 84
85 base::FilePath path = folder_dir_.path().AppendASCII(image_filename); 85 base::FilePath path = folder_dir_.GetPath().AppendASCII(image_filename);
86 86
87 if (!WriteJPEGHeader(path)) 87 if (!WriteJPEGHeader(path))
88 return false; 88 return false;
89 } 89 }
90 90
91 for (unsigned int i = 0; i < non_image_files_; ++i) { 91 for (unsigned int i = 0; i < non_image_files_; ++i) {
92 base::FilePath path = folder_dir_.path().AppendASCII( 92 base::FilePath path = folder_dir_.GetPath().AppendASCII(
93 base::StringPrintf("hello%05d.txt", i)); 93 base::StringPrintf("hello%05d.txt", i));
94 if (base::WriteFile(path, NULL, 0) == -1) 94 if (base::WriteFile(path, NULL, 0) == -1)
95 return false; 95 return false;
96 } 96 }
97 97
98 return true; 98 return true;
99 } 99 }
100 100
101 double GetVariantTimestamp() const { 101 double GetVariantTimestamp() const {
102 DCHECK(!folder_dir_.path().empty()); 102 DCHECK(!folder_dir_.GetPath().empty());
103 base::Time variant_epoch; 103 base::Time variant_epoch;
104 EXPECT_TRUE(base::Time::FromLocalExploded(picasa::kPmpVariantTimeEpoch, 104 EXPECT_TRUE(base::Time::FromLocalExploded(picasa::kPmpVariantTimeEpoch,
105 &variant_epoch)); 105 &variant_epoch));
106 106
107 int64_t microseconds_since_epoch = 107 int64_t microseconds_since_epoch =
108 (folder_info_.timestamp - variant_epoch).InMicroseconds(); 108 (folder_info_.timestamp - variant_epoch).InMicroseconds();
109 109
110 return static_cast<double>(microseconds_since_epoch) / 110 return static_cast<double>(microseconds_since_epoch) /
111 base::Time::kMicrosecondsPerDay; 111 base::Time::kMicrosecondsPerDay;
112 } 112 }
113 113
114 const std::set<std::string>& image_filenames() const { 114 const std::set<std::string>& image_filenames() const {
115 DCHECK(!folder_dir_.path().empty()); 115 DCHECK(!folder_dir_.GetPath().empty());
116 return image_filenames_; 116 return image_filenames_;
117 } 117 }
118 118
119 const AlbumInfo& folder_info() const { 119 const AlbumInfo& folder_info() const {
120 DCHECK(!folder_dir_.path().empty()); 120 DCHECK(!folder_dir_.GetPath().empty());
121 return folder_info_; 121 return folder_info_;
122 } 122 }
123 123
124 const base::Time& timestamp() const { 124 const base::Time& timestamp() const {
125 return timestamp_; 125 return timestamp_;
126 } 126 }
127 127
128 private: 128 private:
129 const std::string name_; 129 const std::string name_;
130 const base::Time timestamp_; 130 const base::Time timestamp_;
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 scoped_refptr<storage::SpecialStoragePolicy> storage_policy = 239 scoped_refptr<storage::SpecialStoragePolicy> storage_policy =
240 new content::MockSpecialStoragePolicy(); 240 new content::MockSpecialStoragePolicy();
241 241
242 SynchronouslyRunOnMediaTaskRunner(base::Bind( 242 SynchronouslyRunOnMediaTaskRunner(base::Bind(
243 &PicasaFileUtilTest::SetUpOnMediaTaskRunner, base::Unretained(this))); 243 &PicasaFileUtilTest::SetUpOnMediaTaskRunner, base::Unretained(this)));
244 244
245 media_path_filter_.reset(new MediaPathFilter()); 245 media_path_filter_.reset(new MediaPathFilter());
246 246
247 ScopedVector<storage::FileSystemBackend> additional_providers; 247 ScopedVector<storage::FileSystemBackend> additional_providers;
248 additional_providers.push_back(new TestMediaFileSystemBackend( 248 additional_providers.push_back(new TestMediaFileSystemBackend(
249 profile_dir_.path(), 249 profile_dir_.GetPath(),
250 new TestPicasaFileUtil(media_path_filter_.get(), 250 new TestPicasaFileUtil(media_path_filter_.get(),
251 picasa_data_provider_.get()))); 251 picasa_data_provider_.get())));
252 252
253 file_system_context_ = new storage::FileSystemContext( 253 file_system_context_ = new storage::FileSystemContext(
254 base::ThreadTaskRunnerHandle::Get().get(), 254 base::ThreadTaskRunnerHandle::Get().get(),
255 base::ThreadTaskRunnerHandle::Get().get(), 255 base::ThreadTaskRunnerHandle::Get().get(),
256 storage::ExternalMountPoints::CreateRefCounted().get(), 256 storage::ExternalMountPoints::CreateRefCounted().get(),
257 storage_policy.get(), NULL, std::move(additional_providers), 257 storage_policy.get(), NULL, std::move(additional_providers),
258 std::vector<storage::URLRequestAutoMountHandler>(), profile_dir_.path(), 258 std::vector<storage::URLRequestAutoMountHandler>(),
259 content::CreateAllowFileAccessOptions()); 259 profile_dir_.GetPath(), content::CreateAllowFileAccessOptions());
260 } 260 }
261 261
262 void TearDown() override { 262 void TearDown() override {
263 SynchronouslyRunOnMediaTaskRunner( 263 SynchronouslyRunOnMediaTaskRunner(
264 base::Bind(&PicasaFileUtilTest::TearDownOnMediaTaskRunner, 264 base::Bind(&PicasaFileUtilTest::TearDownOnMediaTaskRunner,
265 base::Unretained(this))); 265 base::Unretained(this)));
266 } 266 }
267 267
268 protected: 268 protected:
269 void SetUpOnMediaTaskRunner() { 269 void SetUpOnMediaTaskRunner() {
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 std::vector<AlbumInfo> albums; 553 std::vector<AlbumInfo> albums;
554 AlbumInfo info; 554 AlbumInfo info;
555 info.name = "albumname"; 555 info.name = "albumname";
556 info.uid = "albumuid"; 556 info.uid = "albumuid";
557 info.timestamp = test_date; 557 info.timestamp = test_date;
558 albums.push_back(info); 558 albums.push_back(info);
559 559
560 base::ScopedTempDir temp_dir; 560 base::ScopedTempDir temp_dir;
561 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); 561 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
562 562
563 base::FilePath image_path = temp_dir.path().AppendASCII("img.jpg"); 563 base::FilePath image_path = temp_dir.GetPath().AppendASCII("img.jpg");
564 ASSERT_TRUE(WriteJPEGHeader(image_path)); 564 ASSERT_TRUE(WriteJPEGHeader(image_path));
565 565
566 AlbumImagesMap albums_images; 566 AlbumImagesMap albums_images;
567 albums_images[info.uid] = AlbumImages(); 567 albums_images[info.uid] = AlbumImages();
568 albums_images[info.uid]["mapped_name.jpg"] = image_path; 568 albums_images[info.uid]["mapped_name.jpg"] = image_path;
569 569
570 SetupFolders(&test_folders, albums, albums_images); 570 SetupFolders(&test_folders, albums, albums_images);
571 571
572 FileSystemOperation::FileEntryList contents; 572 FileSystemOperation::FileEntryList contents;
573 FileSystemURL url = 573 FileSystemURL url =
(...skipping 19 matching lines...) Expand all
593 operation_runner()->CreateSnapshotFile( 593 operation_runner()->CreateSnapshotFile(
594 CreateURL(std::string(kPicasaDirAlbums) + 594 CreateURL(std::string(kPicasaDirAlbums) +
595 "/albumname 2013-04-16/mapped_name.jpg"), 595 "/albumname 2013-04-16/mapped_name.jpg"),
596 snapshot_callback); 596 snapshot_callback);
597 loop.Run(); 597 loop.Run();
598 EXPECT_EQ(base::File::FILE_OK, error); 598 EXPECT_EQ(base::File::FILE_OK, error);
599 EXPECT_EQ(image_path, platform_path_result); 599 EXPECT_EQ(image_path, platform_path_result);
600 } 600 }
601 601
602 } // namespace picasa 602 } // namespace picasa
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698