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" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 using fileapi::FileSystemURL; | 42 using fileapi::FileSystemURL; |
43 | 43 |
44 namespace picasa { | 44 namespace picasa { |
45 | 45 |
46 namespace { | 46 namespace { |
47 | 47 |
48 base::Time::Exploded test_date_exploded = { 2013, 4, 0, 16, 0, 0, 0, 0 }; | 48 base::Time::Exploded test_date_exploded = { 2013, 4, 0, 16, 0, 0, 0, 0 }; |
49 | 49 |
50 bool WriteJPEGHeader(const base::FilePath& path) { | 50 bool WriteJPEGHeader(const base::FilePath& path) { |
51 const char kJpegHeader[] = "\xFF\xD8\xFF"; // Per HTML5 specification. | 51 const char kJpegHeader[] = "\xFF\xD8\xFF"; // Per HTML5 specification. |
52 return file_util::WriteFile(path, kJpegHeader, arraysize(kJpegHeader)) != -1; | 52 return base::WriteFile(path, kJpegHeader, arraysize(kJpegHeader)) != -1; |
53 } | 53 } |
54 | 54 |
55 class TestFolder { | 55 class TestFolder { |
56 public: | 56 public: |
57 TestFolder(const std::string& name, const base::Time& timestamp, | 57 TestFolder(const std::string& name, const base::Time& timestamp, |
58 const std::string& uid, unsigned int image_files, | 58 const std::string& uid, unsigned int image_files, |
59 unsigned int non_image_files) | 59 unsigned int non_image_files) |
60 : name_(name), | 60 : name_(name), |
61 timestamp_(timestamp), | 61 timestamp_(timestamp), |
62 uid_(uid), | 62 uid_(uid), |
(...skipping 14 matching lines...) Expand all Loading... |
77 | 77 |
78 base::FilePath path = folder_dir_.path().AppendASCII(image_filename); | 78 base::FilePath path = folder_dir_.path().AppendASCII(image_filename); |
79 | 79 |
80 if (!WriteJPEGHeader(path)) | 80 if (!WriteJPEGHeader(path)) |
81 return false; | 81 return false; |
82 } | 82 } |
83 | 83 |
84 for (unsigned int i = 0; i < non_image_files_; ++i) { | 84 for (unsigned int i = 0; i < non_image_files_; ++i) { |
85 base::FilePath path = folder_dir_.path().AppendASCII( | 85 base::FilePath path = folder_dir_.path().AppendASCII( |
86 base::StringPrintf("hello%05d.txt", i)); | 86 base::StringPrintf("hello%05d.txt", i)); |
87 if (file_util::WriteFile(path, NULL, 0) == -1) | 87 if (base::WriteFile(path, NULL, 0) == -1) |
88 return false; | 88 return false; |
89 } | 89 } |
90 | 90 |
91 return true; | 91 return true; |
92 } | 92 } |
93 | 93 |
94 double GetVariantTimestamp() const { | 94 double GetVariantTimestamp() const { |
95 DCHECK(!folder_dir_.path().empty()); | 95 DCHECK(!folder_dir_.path().empty()); |
96 base::Time variant_epoch = base::Time::FromLocalExploded( | 96 base::Time variant_epoch = base::Time::FromLocalExploded( |
97 picasa::kPmpVariantTimeEpoch); | 97 picasa::kPmpVariantTimeEpoch); |
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 operation_runner()->CreateSnapshotFile( | 587 operation_runner()->CreateSnapshotFile( |
588 CreateURL(std::string(kPicasaDirAlbums) + | 588 CreateURL(std::string(kPicasaDirAlbums) + |
589 "/albumname 2013-04-16/mapped_name.jpg"), | 589 "/albumname 2013-04-16/mapped_name.jpg"), |
590 snapshot_callback); | 590 snapshot_callback); |
591 loop.Run(); | 591 loop.Run(); |
592 EXPECT_EQ(base::File::FILE_OK, error); | 592 EXPECT_EQ(base::File::FILE_OK, error); |
593 EXPECT_EQ(image_path, platform_path_result); | 593 EXPECT_EQ(image_path, platform_path_result); |
594 } | 594 } |
595 | 595 |
596 } // namespace picasa | 596 } // namespace picasa |
OLD | NEW |