| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #import <Foundation/Foundation.h> | 5 #import <Foundation/Foundation.h> |
| 6 #import <ImageCaptureCore/ImageCaptureCore.h> | 6 #import <ImageCaptureCore/ImageCaptureCore.h> |
| 7 | 7 |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/files/file.h" | 9 #include "base/files/file.h" |
| 10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 } | 196 } |
| 197 | 197 |
| 198 void OnFileInfo(base::WaitableEvent* event, | 198 void OnFileInfo(base::WaitableEvent* event, |
| 199 const base::File::Info& info) { | 199 const base::File::Info& info) { |
| 200 error_ = base::File::FILE_OK; | 200 error_ = base::File::FILE_OK; |
| 201 info_ = info; | 201 info_ = info; |
| 202 event->Signal(); | 202 event->Signal(); |
| 203 } | 203 } |
| 204 | 204 |
| 205 void OnReadDir(base::WaitableEvent* event, | 205 void OnReadDir(base::WaitableEvent* event, |
| 206 const fileapi::AsyncFileUtil::EntryList& files, | 206 const storage::AsyncFileUtil::EntryList& files, |
| 207 bool has_more) { | 207 bool has_more) { |
| 208 error_ = base::File::FILE_OK; | 208 error_ = base::File::FILE_OK; |
| 209 ASSERT_FALSE(has_more); | 209 ASSERT_FALSE(has_more); |
| 210 file_list_ = files; | 210 file_list_ = files; |
| 211 event->Signal(); | 211 event->Signal(); |
| 212 } | 212 } |
| 213 | 213 |
| 214 void OverlappedOnReadDir(base::WaitableEvent* event, | 214 void OverlappedOnReadDir(base::WaitableEvent* event, |
| 215 const fileapi::AsyncFileUtil::EntryList& files, | 215 const storage::AsyncFileUtil::EntryList& files, |
| 216 bool has_more) { | 216 bool has_more) { |
| 217 overlapped_error_ = base::File::FILE_OK; | 217 overlapped_error_ = base::File::FILE_OK; |
| 218 ASSERT_FALSE(has_more); | 218 ASSERT_FALSE(has_more); |
| 219 overlapped_file_list_ = files; | 219 overlapped_file_list_ = files; |
| 220 event->Signal(); | 220 event->Signal(); |
| 221 } | 221 } |
| 222 | 222 |
| 223 void OnDownload(base::WaitableEvent* event, | 223 void OnDownload(base::WaitableEvent* event, |
| 224 const base::File::Info& file_info, | 224 const base::File::Info& file_info, |
| 225 const base::FilePath& local_path) { | 225 const base::FilePath& local_path) { |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 scoped_ptr<content::TestBrowserThread> io_thread_; | 287 scoped_ptr<content::TestBrowserThread> io_thread_; |
| 288 base::ScopedTempDir temp_dir_; | 288 base::ScopedTempDir temp_dir_; |
| 289 storage_monitor::ImageCaptureDeviceManager manager_; | 289 storage_monitor::ImageCaptureDeviceManager manager_; |
| 290 MockMTPICCameraDevice* camera_; | 290 MockMTPICCameraDevice* camera_; |
| 291 | 291 |
| 292 // This object needs special deletion inside the above |task_runner_|. | 292 // This object needs special deletion inside the above |task_runner_|. |
| 293 MTPDeviceDelegateImplMac* delegate_; | 293 MTPDeviceDelegateImplMac* delegate_; |
| 294 | 294 |
| 295 base::File::Error error_; | 295 base::File::Error error_; |
| 296 base::File::Info info_; | 296 base::File::Info info_; |
| 297 fileapi::AsyncFileUtil::EntryList file_list_; | 297 storage::AsyncFileUtil::EntryList file_list_; |
| 298 | 298 |
| 299 base::File::Error overlapped_error_; | 299 base::File::Error overlapped_error_; |
| 300 fileapi::AsyncFileUtil::EntryList overlapped_file_list_; | 300 storage::AsyncFileUtil::EntryList overlapped_file_list_; |
| 301 | 301 |
| 302 private: | 302 private: |
| 303 DISALLOW_COPY_AND_ASSIGN(MTPDeviceDelegateImplMacTest); | 303 DISALLOW_COPY_AND_ASSIGN(MTPDeviceDelegateImplMacTest); |
| 304 }; | 304 }; |
| 305 | 305 |
| 306 TEST_F(MTPDeviceDelegateImplMacTest, TestGetRootFileInfo) { | 306 TEST_F(MTPDeviceDelegateImplMacTest, TestGetRootFileInfo) { |
| 307 base::File::Info info; | 307 base::File::Info info; |
| 308 // Making a fresh delegate should have a single file entry for the synthetic | 308 // Making a fresh delegate should have a single file entry for the synthetic |
| 309 // root directory, with the name equal to the device id string. | 309 // root directory, with the name equal to the device id string. |
| 310 EXPECT_EQ(base::File::FILE_OK, | 310 EXPECT_EQ(base::File::FILE_OK, |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 temp_dir_.path().Append("target"))); | 543 temp_dir_.path().Append("target"))); |
| 544 | 544 |
| 545 EXPECT_EQ(base::File::FILE_OK, | 545 EXPECT_EQ(base::File::FILE_OK, |
| 546 DownloadFile(base::FilePath("/ic:id/filename"), | 546 DownloadFile(base::FilePath("/ic:id/filename"), |
| 547 temp_dir_.path().Append("target"))); | 547 temp_dir_.path().Append("target"))); |
| 548 std::string contents; | 548 std::string contents; |
| 549 EXPECT_TRUE(base::ReadFileToString(temp_dir_.path().Append("target"), | 549 EXPECT_TRUE(base::ReadFileToString(temp_dir_.path().Append("target"), |
| 550 &contents)); | 550 &contents)); |
| 551 EXPECT_EQ(kTestFileContents, contents); | 551 EXPECT_EQ(kTestFileContents, contents); |
| 552 } | 552 } |
| OLD | NEW |