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

Side by Side Diff: base/mac/mac_util_unittest.mm

Issue 17593006: mac: Update clients of scoped_nsobject.h. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: iwyu, scoped_nsprotocol Created 7 years, 6 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 <Cocoa/Cocoa.h> 5 #import <Cocoa/Cocoa.h>
6 6
7 #include "base/mac/mac_util.h" 7 #include "base/mac/mac_util.h"
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/files/scoped_temp_dir.h" 11 #include "base/files/scoped_temp_dir.h"
12 #include "base/mac/foundation_util.h" 12 #include "base/mac/foundation_util.h"
13 #include "base/mac/scoped_cftyperef.h" 13 #include "base/mac/scoped_cftyperef.h"
14 #include "base/memory/scoped_nsobject.h" 14 #include "base/mac/scoped_nsobject.h"
15 #include "base/sys_info.h" 15 #include "base/sys_info.h"
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 #include "testing/platform_test.h" 17 #include "testing/platform_test.h"
18 18
19 #include <errno.h> 19 #include <errno.h>
20 #include <sys/xattr.h> 20 #include <sys/xattr.h>
21 21
22 namespace base { 22 namespace base {
23 namespace mac { 23 namespace mac {
24 24
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 EXPECT_TRUE(SetFileBackupExclusion(dummy_file_path)); 118 EXPECT_TRUE(SetFileBackupExclusion(dummy_file_path));
119 // SetFileBackupExclusion never excludes by path. 119 // SetFileBackupExclusion never excludes by path.
120 Boolean excluded_by_path = FALSE; 120 Boolean excluded_by_path = FALSE;
121 Boolean excluded = 121 Boolean excluded =
122 CSBackupIsItemExcluded(base::mac::NSToCFCast(fileURL), &excluded_by_path); 122 CSBackupIsItemExcluded(base::mac::NSToCFCast(fileURL), &excluded_by_path);
123 EXPECT_TRUE(excluded); 123 EXPECT_TRUE(excluded);
124 EXPECT_FALSE(excluded_by_path); 124 EXPECT_FALSE(excluded_by_path);
125 } 125 }
126 126
127 TEST_F(MacUtilTest, CopyNSImageToCGImage) { 127 TEST_F(MacUtilTest, CopyNSImageToCGImage) {
128 scoped_nsobject<NSImage> nsImage( 128 base::scoped_nsobject<NSImage> nsImage(
129 [[NSImage alloc] initWithSize:NSMakeSize(20, 20)]); 129 [[NSImage alloc] initWithSize:NSMakeSize(20, 20)]);
130 [nsImage lockFocus]; 130 [nsImage lockFocus];
131 [[NSColor redColor] set]; 131 [[NSColor redColor] set];
132 NSRect rect = NSZeroRect; 132 NSRect rect = NSZeroRect;
133 rect.size = [nsImage size]; 133 rect.size = [nsImage size];
134 NSRectFill(rect); 134 NSRectFill(rect);
135 [nsImage unlockFocus]; 135 [nsImage unlockFocus];
136 136
137 ScopedCFTypeRef<CGImageRef> cgImage(CopyNSImageToCGImage(nsImage.get())); 137 ScopedCFTypeRef<CGImageRef> cgImage(CopyNSImageToCGImage(nsImage.get()));
138 EXPECT_TRUE(cgImage.get()); 138 EXPECT_TRUE(cgImage.get());
139 } 139 }
140 140
141 TEST_F(MacUtilTest, NSObjectRetainRelease) { 141 TEST_F(MacUtilTest, NSObjectRetainRelease) {
142 scoped_nsobject<NSArray> array([[NSArray alloc] initWithObjects:@"foo", nil]); 142 base::scoped_nsobject<NSArray> array(
143 [[NSArray alloc] initWithObjects:@"foo", nil]);
143 EXPECT_EQ(1U, [array retainCount]); 144 EXPECT_EQ(1U, [array retainCount]);
144 145
145 NSObjectRetain(array); 146 NSObjectRetain(array);
146 EXPECT_EQ(2U, [array retainCount]); 147 EXPECT_EQ(2U, [array retainCount]);
147 148
148 NSObjectRelease(array); 149 NSObjectRelease(array);
149 EXPECT_EQ(1U, [array retainCount]); 150 EXPECT_EQ(1U, [array retainCount]);
150 } 151 }
151 152
152 TEST_F(MacUtilTest, IsOSEllipsis) { 153 TEST_F(MacUtilTest, IsOSEllipsis) {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 247 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
247 FilePath non_existent_path = temp_dir_.path().Append("DummyPath"); 248 FilePath non_existent_path = temp_dir_.path().Append("DummyPath");
248 ASSERT_FALSE(file_util::PathExists(non_existent_path)); 249 ASSERT_FALSE(file_util::PathExists(non_existent_path));
249 EXPECT_FALSE(RemoveQuarantineAttribute(non_existent_path)); 250 EXPECT_FALSE(RemoveQuarantineAttribute(non_existent_path));
250 } 251 }
251 252
252 } // namespace 253 } // namespace
253 254
254 } // namespace mac 255 } // namespace mac
255 } // namespace base 256 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698