| 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/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
| 10 #include "base/mac/cocoa_protocols.h" | 10 #include "base/mac/cocoa_protocols.h" |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 | 177 |
| 178 virtual void SetUp() OVERRIDE { | 178 virtual void SetUp() OVERRIDE { |
| 179 ui_thread_.reset(new content::TestBrowserThread( | 179 ui_thread_.reset(new content::TestBrowserThread( |
| 180 content::BrowserThread::UI, &message_loop_)); | 180 content::BrowserThread::UI, &message_loop_)); |
| 181 file_thread_.reset(new content::TestBrowserThread( | 181 file_thread_.reset(new content::TestBrowserThread( |
| 182 content::BrowserThread::FILE, &message_loop_)); | 182 content::BrowserThread::FILE, &message_loop_)); |
| 183 io_thread_.reset(new content::TestBrowserThread( | 183 io_thread_.reset(new content::TestBrowserThread( |
| 184 content::BrowserThread::IO)); | 184 content::BrowserThread::IO)); |
| 185 ASSERT_TRUE(io_thread_->Start()); | 185 ASSERT_TRUE(io_thread_->Start()); |
| 186 | 186 |
| 187 chrome::test::TestStorageMonitor* monitor = | 187 TestStorageMonitor* monitor = TestStorageMonitor::CreateAndInstall(); |
| 188 chrome::test::TestStorageMonitor::CreateAndInstall(); | |
| 189 manager_.SetNotifications(monitor->receiver()); | 188 manager_.SetNotifications(monitor->receiver()); |
| 190 | 189 |
| 191 camera_ = [MockMTPICCameraDevice alloc]; | 190 camera_ = [MockMTPICCameraDevice alloc]; |
| 192 id<ICDeviceBrowserDelegate> delegate = manager_.device_browser(); | 191 id<ICDeviceBrowserDelegate> delegate = manager_.device_browser(); |
| 193 [delegate deviceBrowser:nil didAddDevice:camera_ moreComing:NO]; | 192 [delegate deviceBrowser:nil didAddDevice:camera_ moreComing:NO]; |
| 194 | 193 |
| 195 delegate_ = new chrome::MTPDeviceDelegateImplMac(kDeviceId, kDevicePath); | 194 delegate_ = new MTPDeviceDelegateImplMac(kDeviceId, kDevicePath); |
| 196 } | 195 } |
| 197 | 196 |
| 198 virtual void TearDown() OVERRIDE { | 197 virtual void TearDown() OVERRIDE { |
| 199 id<ICDeviceBrowserDelegate> delegate = manager_.device_browser(); | 198 id<ICDeviceBrowserDelegate> delegate = manager_.device_browser(); |
| 200 [delegate deviceBrowser:nil didRemoveDevice:camera_ moreGoing:NO]; | 199 [delegate deviceBrowser:nil didRemoveDevice:camera_ moreGoing:NO]; |
| 201 | 200 |
| 202 delegate_->CancelPendingTasksAndDeleteDelegate(); | 201 delegate_->CancelPendingTasksAndDeleteDelegate(); |
| 203 | 202 |
| 204 chrome::test::TestStorageMonitor::RemoveSingleton(); | 203 TestStorageMonitor::RemoveSingleton(); |
| 205 | 204 |
| 206 io_thread_->Stop(); | 205 io_thread_->Stop(); |
| 207 } | 206 } |
| 208 | 207 |
| 209 void OnError(base::WaitableEvent* event, base::PlatformFileError error) { | 208 void OnError(base::WaitableEvent* event, base::PlatformFileError error) { |
| 210 error_ = error; | 209 error_ = error; |
| 211 event->Signal(); | 210 event->Signal(); |
| 212 } | 211 } |
| 213 | 212 |
| 214 void OverlappedOnError(base::WaitableEvent* event, | 213 void OverlappedOnError(base::WaitableEvent* event, |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 return error_; | 300 return error_; |
| 302 } | 301 } |
| 303 | 302 |
| 304 protected: | 303 protected: |
| 305 base::MessageLoopForUI message_loop_; | 304 base::MessageLoopForUI message_loop_; |
| 306 // Note: threads must be made in this order: UI > FILE > IO | 305 // Note: threads must be made in this order: UI > FILE > IO |
| 307 scoped_ptr<content::TestBrowserThread> ui_thread_; | 306 scoped_ptr<content::TestBrowserThread> ui_thread_; |
| 308 scoped_ptr<content::TestBrowserThread> file_thread_; | 307 scoped_ptr<content::TestBrowserThread> file_thread_; |
| 309 scoped_ptr<content::TestBrowserThread> io_thread_; | 308 scoped_ptr<content::TestBrowserThread> io_thread_; |
| 310 base::ScopedTempDir temp_dir_; | 309 base::ScopedTempDir temp_dir_; |
| 311 chrome::ImageCaptureDeviceManager manager_; | 310 ImageCaptureDeviceManager manager_; |
| 312 MockMTPICCameraDevice* camera_; | 311 MockMTPICCameraDevice* camera_; |
| 313 | 312 |
| 314 // This object needs special deletion inside the above |task_runner_|. | 313 // This object needs special deletion inside the above |task_runner_|. |
| 315 chrome::MTPDeviceDelegateImplMac* delegate_; | 314 MTPDeviceDelegateImplMac* delegate_; |
| 316 | 315 |
| 317 base::PlatformFileError error_; | 316 base::PlatformFileError error_; |
| 318 base::PlatformFileInfo info_; | 317 base::PlatformFileInfo info_; |
| 319 fileapi::AsyncFileUtil::EntryList file_list_; | 318 fileapi::AsyncFileUtil::EntryList file_list_; |
| 320 | 319 |
| 321 base::PlatformFileError overlapped_error_; | 320 base::PlatformFileError overlapped_error_; |
| 322 fileapi::AsyncFileUtil::EntryList overlapped_file_list_; | 321 fileapi::AsyncFileUtil::EntryList overlapped_file_list_; |
| 323 | 322 |
| 324 private: | 323 private: |
| 325 DISALLOW_COPY_AND_ASSIGN(MTPDeviceDelegateImplMacTest); | 324 DISALLOW_COPY_AND_ASSIGN(MTPDeviceDelegateImplMacTest); |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 temp_dir_.path().Append("target"))); | 564 temp_dir_.path().Append("target"))); |
| 566 | 565 |
| 567 EXPECT_EQ(base::PLATFORM_FILE_OK, | 566 EXPECT_EQ(base::PLATFORM_FILE_OK, |
| 568 DownloadFile(base::FilePath("/ic:id/filename"), | 567 DownloadFile(base::FilePath("/ic:id/filename"), |
| 569 temp_dir_.path().Append("target"))); | 568 temp_dir_.path().Append("target"))); |
| 570 std::string contents; | 569 std::string contents; |
| 571 EXPECT_TRUE(base::ReadFileToString(temp_dir_.path().Append("target"), | 570 EXPECT_TRUE(base::ReadFileToString(temp_dir_.path().Append("target"), |
| 572 &contents)); | 571 &contents)); |
| 573 EXPECT_EQ(kTestFileContents, contents); | 572 EXPECT_EQ(kTestFileContents, contents); |
| 574 } | 573 } |
| OLD | NEW |