| 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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 | 126 |
| 127 std::set<std::string> image_filenames_; | 127 std::set<std::string> image_filenames_; |
| 128 | 128 |
| 129 base::ScopedTempDir folder_dir_; | 129 base::ScopedTempDir folder_dir_; |
| 130 AlbumInfo folder_info_; | 130 AlbumInfo folder_info_; |
| 131 }; | 131 }; |
| 132 | 132 |
| 133 void ReadDirectoryTestHelperCallback( | 133 void ReadDirectoryTestHelperCallback( |
| 134 base::RunLoop* run_loop, | 134 base::RunLoop* run_loop, |
| 135 FileSystemOperation::FileEntryList* contents, | 135 FileSystemOperation::FileEntryList* contents, |
| 136 bool* completed, base::PlatformFileError error, | 136 bool* completed, base::File::Error error, |
| 137 const FileSystemOperation::FileEntryList& file_list, | 137 const FileSystemOperation::FileEntryList& file_list, |
| 138 bool has_more) { | 138 bool has_more) { |
| 139 DCHECK(!*completed); | 139 DCHECK(!*completed); |
| 140 *completed = !has_more && error == base::PLATFORM_FILE_OK; | 140 *completed = !has_more && error == base::File::FILE_OK; |
| 141 *contents = file_list; | 141 *contents = file_list; |
| 142 run_loop->Quit(); | 142 run_loop->Quit(); |
| 143 } | 143 } |
| 144 | 144 |
| 145 void ReadDirectoryTestHelper(fileapi::FileSystemOperationRunner* runner, | 145 void ReadDirectoryTestHelper(fileapi::FileSystemOperationRunner* runner, |
| 146 const FileSystemURL& url, | 146 const FileSystemURL& url, |
| 147 FileSystemOperation::FileEntryList* contents, | 147 FileSystemOperation::FileEntryList* contents, |
| 148 bool* completed) { | 148 bool* completed) { |
| 149 DCHECK(contents); | 149 DCHECK(contents); |
| 150 DCHECK(completed); | 150 DCHECK(completed); |
| 151 base::RunLoop run_loop; | 151 base::RunLoop run_loop; |
| 152 runner->ReadDirectory( | 152 runner->ReadDirectory( |
| 153 url, base::Bind(&ReadDirectoryTestHelperCallback, &run_loop, contents, | 153 url, base::Bind(&ReadDirectoryTestHelperCallback, &run_loop, contents, |
| 154 completed)); | 154 completed)); |
| 155 run_loop.Run(); | 155 run_loop.Run(); |
| 156 } | 156 } |
| 157 | 157 |
| 158 void SynchronouslyRunOnMediaTaskRunner(const base::Closure& closure) { | 158 void SynchronouslyRunOnMediaTaskRunner(const base::Closure& closure) { |
| 159 base::RunLoop loop; | 159 base::RunLoop loop; |
| 160 MediaFileSystemBackend::MediaTaskRunner()->PostTaskAndReply( | 160 MediaFileSystemBackend::MediaTaskRunner()->PostTaskAndReply( |
| 161 FROM_HERE, | 161 FROM_HERE, |
| 162 closure, | 162 closure, |
| 163 loop.QuitClosure()); | 163 loop.QuitClosure()); |
| 164 loop.Run(); | 164 loop.Run(); |
| 165 } | 165 } |
| 166 | 166 |
| 167 void CreateSnapshotFileTestHelperCallback( | 167 void CreateSnapshotFileTestHelperCallback( |
| 168 base::RunLoop* run_loop, | 168 base::RunLoop* run_loop, |
| 169 base::PlatformFileError* error, | 169 base::File::Error* error, |
| 170 base::FilePath* platform_path_result, | 170 base::FilePath* platform_path_result, |
| 171 base::PlatformFileError result, | 171 base::File::Error result, |
| 172 const base::PlatformFileInfo& file_info, | 172 const base::File::Info& file_info, |
| 173 const base::FilePath& platform_path, | 173 const base::FilePath& platform_path, |
| 174 const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref) { | 174 const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref) { |
| 175 DCHECK(run_loop); | 175 DCHECK(run_loop); |
| 176 DCHECK(error); | 176 DCHECK(error); |
| 177 DCHECK(platform_path_result); | 177 DCHECK(platform_path_result); |
| 178 | 178 |
| 179 *error = result; | 179 *error = result; |
| 180 *platform_path_result = platform_path; | 180 *platform_path_result = platform_path; |
| 181 run_loop->Quit(); | 181 run_loop->Quit(); |
| 182 } | 182 } |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 ReadDirectoryTestHelper(operation_runner(), url, &contents, &completed); | 570 ReadDirectoryTestHelper(operation_runner(), url, &contents, &completed); |
| 571 | 571 |
| 572 ASSERT_TRUE(completed); | 572 ASSERT_TRUE(completed); |
| 573 EXPECT_EQ(1u, contents.size()); | 573 EXPECT_EQ(1u, contents.size()); |
| 574 EXPECT_EQ("mapped_name.jpg", | 574 EXPECT_EQ("mapped_name.jpg", |
| 575 base::FilePath(contents.begin()->name).AsUTF8Unsafe()); | 575 base::FilePath(contents.begin()->name).AsUTF8Unsafe()); |
| 576 EXPECT_FALSE(contents.begin()->is_directory); | 576 EXPECT_FALSE(contents.begin()->is_directory); |
| 577 | 577 |
| 578 // Create a snapshot file to verify the file path. | 578 // Create a snapshot file to verify the file path. |
| 579 base::RunLoop loop; | 579 base::RunLoop loop; |
| 580 base::PlatformFileError error; | 580 base::File::Error error; |
| 581 base::FilePath platform_path_result; | 581 base::FilePath platform_path_result; |
| 582 fileapi::FileSystemOperationRunner::SnapshotFileCallback snapshot_callback = | 582 fileapi::FileSystemOperationRunner::SnapshotFileCallback snapshot_callback = |
| 583 base::Bind(&CreateSnapshotFileTestHelperCallback, | 583 base::Bind(&CreateSnapshotFileTestHelperCallback, |
| 584 &loop, | 584 &loop, |
| 585 &error, | 585 &error, |
| 586 &platform_path_result); | 586 &platform_path_result); |
| 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::PLATFORM_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 |