OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 contextInfo:(void*)contextInfo { | 103 contextInfo:(void*)contextInfo { |
104 base::FilePath saveDir(base::SysNSStringToUTF8( | 104 base::FilePath saveDir(base::SysNSStringToUTF8( |
105 [[options objectForKey:ICDownloadsDirectoryURL] path])); | 105 [[options objectForKey:ICDownloadsDirectoryURL] path])); |
106 std::string saveAsFilename = | 106 std::string saveAsFilename = |
107 base::SysNSStringToUTF8([options objectForKey:ICSaveAsFilename]); | 107 base::SysNSStringToUTF8([options objectForKey:ICSaveAsFilename]); |
108 // It appears that the ImageCapture library adds an extension to the requested | 108 // It appears that the ImageCapture library adds an extension to the requested |
109 // filename. Do that here to require a rename. | 109 // filename. Do that here to require a rename. |
110 saveAsFilename += ".jpg"; | 110 saveAsFilename += ".jpg"; |
111 base::FilePath toBeSaved = saveDir.Append(saveAsFilename); | 111 base::FilePath toBeSaved = saveDir.Append(saveAsFilename); |
112 ASSERT_EQ(static_cast<int>(strlen(kTestFileContents)), | 112 ASSERT_EQ(static_cast<int>(strlen(kTestFileContents)), |
113 file_util::WriteFile(toBeSaved, kTestFileContents, | 113 base::WriteFile(toBeSaved, kTestFileContents, |
114 strlen(kTestFileContents))); | 114 strlen(kTestFileContents))); |
115 | 115 |
116 NSMutableDictionary* returnOptions = | 116 NSMutableDictionary* returnOptions = |
117 [NSMutableDictionary dictionaryWithDictionary:options]; | 117 [NSMutableDictionary dictionaryWithDictionary:options]; |
118 [returnOptions setObject:base::SysUTF8ToNSString(saveAsFilename) | 118 [returnOptions setObject:base::SysUTF8ToNSString(saveAsFilename) |
119 forKey:ICSavedFilename]; | 119 forKey:ICSavedFilename]; |
120 | 120 |
121 [static_cast<NSObject<ICCameraDeviceDownloadDelegate>*>(downloadDelegate) | 121 [static_cast<NSObject<ICCameraDeviceDownloadDelegate>*>(downloadDelegate) |
122 didDownloadFile:file | 122 didDownloadFile:file |
123 error:nil | 123 error:nil |
124 options:returnOptions | 124 options:returnOptions |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 char file_contents[5]; | 429 char file_contents[5]; |
430 ASSERT_EQ(4, base::ReadFile(temp_file, file_contents, | 430 ASSERT_EQ(4, base::ReadFile(temp_file, file_contents, |
431 strlen(kTestFileContents))); | 431 strlen(kTestFileContents))); |
432 EXPECT_EQ(kTestFileContents, | 432 EXPECT_EQ(kTestFileContents, |
433 std::string(file_contents, strlen(kTestFileContents))); | 433 std::string(file_contents, strlen(kTestFileContents))); |
434 | 434 |
435 [camera didRemoveDevice:device]; | 435 [camera didRemoveDevice:device]; |
436 } | 436 } |
437 | 437 |
438 } // namespace storage_monitor | 438 } // namespace storage_monitor |
OLD | NEW |