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" |
11 #include "base/mac/foundation_util.h" | 11 #include "base/mac/foundation_util.h" |
12 #include "base/memory/scoped_nsobject.h" | 12 #include "base/mac/scoped_nsobject.h" |
13 #include "base/message_loop.h" | 13 #include "base/message_loop.h" |
14 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
15 #include "base/strings/sys_string_conversions.h" | 15 #include "base/strings/sys_string_conversions.h" |
16 #include "base/synchronization/waitable_event.h" | 16 #include "base/synchronization/waitable_event.h" |
17 #include "base/test/sequenced_worker_pool_owner.h" | 17 #include "base/test/sequenced_worker_pool_owner.h" |
18 #include "base/threading/sequenced_worker_pool.h" | 18 #include "base/threading/sequenced_worker_pool.h" |
19 #include "chrome/browser/media_galleries/mac/mtp_device_delegate_impl_mac.h" | 19 #include "chrome/browser/media_galleries/mac/mtp_device_delegate_impl_mac.h" |
20 #include "chrome/browser/storage_monitor/image_capture_device_manager.h" | 20 #include "chrome/browser/storage_monitor/image_capture_device_manager.h" |
21 #include "chrome/browser/storage_monitor/test_storage_monitor.h" | 21 #include "chrome/browser/storage_monitor/test_storage_monitor.h" |
22 #include "content/public/browser/browser_thread.h" | 22 #include "content/public/browser/browser_thread.h" |
(...skipping 17 matching lines...) Expand all Loading... |
40 namespace { | 40 namespace { |
41 | 41 |
42 const char kDeviceId[] = "id"; | 42 const char kDeviceId[] = "id"; |
43 const char kDevicePath[] = "/ic:id"; | 43 const char kDevicePath[] = "/ic:id"; |
44 const char kTestFileContents[] = "test"; | 44 const char kTestFileContents[] = "test"; |
45 | 45 |
46 } // namespace | 46 } // namespace |
47 | 47 |
48 @interface MockMTPICCameraDevice : ICCameraDevice { | 48 @interface MockMTPICCameraDevice : ICCameraDevice { |
49 @private | 49 @private |
50 scoped_nsobject<NSMutableArray> allMediaFiles_; | 50 base::scoped_nsobject<NSMutableArray> allMediaFiles_; |
51 } | 51 } |
52 | 52 |
53 - (void)addMediaFile:(ICCameraFile*)file; | 53 - (void)addMediaFile:(ICCameraFile*)file; |
54 | 54 |
55 @end | 55 @end |
56 | 56 |
57 @implementation MockMTPICCameraDevice | 57 @implementation MockMTPICCameraDevice |
58 | 58 |
59 - (NSString*)mountPoint { | 59 - (NSString*)mountPoint { |
60 return @"mountPoint"; | 60 return @"mountPoint"; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 didDownloadFile:file | 114 didDownloadFile:file |
115 error:nil | 115 error:nil |
116 options:returnOptions | 116 options:returnOptions |
117 contextInfo:contextInfo]; | 117 contextInfo:contextInfo]; |
118 } | 118 } |
119 | 119 |
120 @end | 120 @end |
121 | 121 |
122 @interface MockMTPICCameraFile : ICCameraFile { | 122 @interface MockMTPICCameraFile : ICCameraFile { |
123 @private | 123 @private |
124 scoped_nsobject<NSString> name_; | 124 base::scoped_nsobject<NSString> name_; |
125 scoped_nsobject<NSDate> date_; | 125 base::scoped_nsobject<NSDate> date_; |
126 } | 126 } |
127 | 127 |
128 - (id)init:(NSString*)name; | 128 - (id)init:(NSString*)name; |
129 | 129 |
130 @end | 130 @end |
131 | 131 |
132 @implementation MockMTPICCameraFile | 132 @implementation MockMTPICCameraFile |
133 | 133 |
134 - (id)init:(NSString*)name { | 134 - (id)init:(NSString*)name { |
135 if ((self = [super init])) { | 135 if ((self = [super init])) { |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 539 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
540 base::Time t1 = base::Time::Now(); | 540 base::Time t1 = base::Time::Now(); |
541 base::PlatformFileInfo info; | 541 base::PlatformFileInfo info; |
542 info.size = 4; | 542 info.size = 4; |
543 info.is_directory = false; | 543 info.is_directory = false; |
544 info.is_symbolic_link = false; | 544 info.is_symbolic_link = false; |
545 info.last_modified = t1; | 545 info.last_modified = t1; |
546 info.last_accessed = t1; | 546 info.last_accessed = t1; |
547 info.creation_time = t1; | 547 info.creation_time = t1; |
548 std::string kTestFileName("filename"); | 548 std::string kTestFileName("filename"); |
549 scoped_nsobject<MockMTPICCameraFile> picture1( | 549 base::scoped_nsobject<MockMTPICCameraFile> picture1( |
550 [[MockMTPICCameraFile alloc] | 550 [[MockMTPICCameraFile alloc] |
551 init:base::SysUTF8ToNSString(kTestFileName)]); | 551 init:base::SysUTF8ToNSString(kTestFileName)]); |
552 [camera_ addMediaFile:picture1]; | 552 [camera_ addMediaFile:picture1]; |
553 delegate_->ItemAdded(kTestFileName, info); | 553 delegate_->ItemAdded(kTestFileName, info); |
554 delegate_->NoMoreItems(); | 554 delegate_->NoMoreItems(); |
555 | 555 |
556 EXPECT_EQ(base::PLATFORM_FILE_OK, ReadDir(base::FilePath(kDevicePath))); | 556 EXPECT_EQ(base::PLATFORM_FILE_OK, ReadDir(base::FilePath(kDevicePath))); |
557 ASSERT_EQ(1U, file_list_.size()); | 557 ASSERT_EQ(1U, file_list_.size()); |
558 ASSERT_EQ("filename", file_list_[0].name); | 558 ASSERT_EQ("filename", file_list_[0].name); |
559 | 559 |
560 EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, | 560 EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, |
561 DownloadFile(base::FilePath("/ic:id/nonexist"), | 561 DownloadFile(base::FilePath("/ic:id/nonexist"), |
562 temp_dir_.path().Append("target"))); | 562 temp_dir_.path().Append("target"))); |
563 | 563 |
564 EXPECT_EQ(base::PLATFORM_FILE_OK, | 564 EXPECT_EQ(base::PLATFORM_FILE_OK, |
565 DownloadFile(base::FilePath("/ic:id/filename"), | 565 DownloadFile(base::FilePath("/ic:id/filename"), |
566 temp_dir_.path().Append("target"))); | 566 temp_dir_.path().Append("target"))); |
567 std::string contents; | 567 std::string contents; |
568 EXPECT_TRUE(file_util::ReadFileToString(temp_dir_.path().Append("target"), | 568 EXPECT_TRUE(file_util::ReadFileToString(temp_dir_.path().Append("target"), |
569 &contents)); | 569 &contents)); |
570 EXPECT_EQ(kTestFileContents, contents); | 570 EXPECT_EQ(kTestFileContents, contents); |
571 } | 571 } |
OLD | NEW |