| 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 contextInfo:(void*)contextInfo { | 95 contextInfo:(void*)contextInfo { |
| 96 base::FilePath saveDir(base::SysNSStringToUTF8( | 96 base::FilePath saveDir(base::SysNSStringToUTF8( |
| 97 [[options objectForKey:ICDownloadsDirectoryURL] path])); | 97 [[options objectForKey:ICDownloadsDirectoryURL] path])); |
| 98 std::string saveAsFilename = | 98 std::string saveAsFilename = |
| 99 base::SysNSStringToUTF8([options objectForKey:ICSaveAsFilename]); | 99 base::SysNSStringToUTF8([options objectForKey:ICSaveAsFilename]); |
| 100 // It appears that the ImageCapture library adds an extension to the requested | 100 // It appears that the ImageCapture library adds an extension to the requested |
| 101 // filename. Do that here to require a rename. | 101 // filename. Do that here to require a rename. |
| 102 saveAsFilename += ".jpg"; | 102 saveAsFilename += ".jpg"; |
| 103 base::FilePath toBeSaved = saveDir.Append(saveAsFilename); | 103 base::FilePath toBeSaved = saveDir.Append(saveAsFilename); |
| 104 ASSERT_EQ(static_cast<int>(strlen(kTestFileContents)), | 104 ASSERT_EQ(static_cast<int>(strlen(kTestFileContents)), |
| 105 file_util::WriteFile(toBeSaved, kTestFileContents, | 105 base::WriteFile(toBeSaved, kTestFileContents, |
| 106 strlen(kTestFileContents))); | 106 strlen(kTestFileContents))); |
| 107 | 107 |
| 108 NSMutableDictionary* returnOptions = | 108 NSMutableDictionary* returnOptions = |
| 109 [NSMutableDictionary dictionaryWithDictionary:options]; | 109 [NSMutableDictionary dictionaryWithDictionary:options]; |
| 110 [returnOptions setObject:base::SysUTF8ToNSString(saveAsFilename) | 110 [returnOptions setObject:base::SysUTF8ToNSString(saveAsFilename) |
| 111 forKey:ICSavedFilename]; | 111 forKey:ICSavedFilename]; |
| 112 | 112 |
| 113 [static_cast<NSObject<ICCameraDeviceDownloadDelegate>*>(downloadDelegate) | 113 [static_cast<NSObject<ICCameraDeviceDownloadDelegate>*>(downloadDelegate) |
| 114 didDownloadFile:file | 114 didDownloadFile:file |
| 115 error:nil | 115 error:nil |
| 116 options:returnOptions | 116 options:returnOptions |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 temp_dir_.path().Append("target"))); | 555 temp_dir_.path().Append("target"))); |
| 556 | 556 |
| 557 EXPECT_EQ(base::File::FILE_OK, | 557 EXPECT_EQ(base::File::FILE_OK, |
| 558 DownloadFile(base::FilePath("/ic:id/filename"), | 558 DownloadFile(base::FilePath("/ic:id/filename"), |
| 559 temp_dir_.path().Append("target"))); | 559 temp_dir_.path().Append("target"))); |
| 560 std::string contents; | 560 std::string contents; |
| 561 EXPECT_TRUE(base::ReadFileToString(temp_dir_.path().Append("target"), | 561 EXPECT_TRUE(base::ReadFileToString(temp_dir_.path().Append("target"), |
| 562 &contents)); | 562 &contents)); |
| 563 EXPECT_EQ(kTestFileContents, contents); | 563 EXPECT_EQ(kTestFileContents, contents); |
| 564 } | 564 } |
| OLD | NEW |