Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: chrome/browser/media_galleries/mac/mtp_device_delegate_impl_mac_unittest.mm

Issue 184563006: Move WriteFile and WriteFileDescriptor from file_util to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698