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

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

Issue 6046009: Move base/mac_util.h to base/mac and use the base::mac namespace.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 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
« no previous file with comments | « base/mac/mac_util.mm ('k') | base/mac_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #include <vector> 6 #include <vector>
7 7
8 #include "base/mac_util.h" 8 #include "base/mac/mac_util.h"
9 9
10 #include "base/file_path.h" 10 #include "base/file_path.h"
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/mac/scoped_cftyperef.h" 12 #include "base/mac/scoped_cftyperef.h"
13 #include "base/test/mock_chrome_application_mac.h" 13 #include "base/test/mock_chrome_application_mac.h"
14 #include "base/scoped_nsobject.h" 14 #include "base/scoped_nsobject.h"
15 #include "base/scoped_ptr.h" 15 #include "base/scoped_ptr.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 namespace mac_util { 19 namespace base {
20 namespace mac {
20 21
21 namespace { 22 namespace {
22 23
23 typedef PlatformTest MacUtilTest; 24 typedef PlatformTest MacUtilTest;
24 25
25 TEST_F(MacUtilTest, TestFSRef) { 26 TEST_F(MacUtilTest, TestFSRef) {
26 FSRef ref; 27 FSRef ref;
27 std::string path("/System/Library"); 28 std::string path("/System/Library");
28 29
29 ASSERT_TRUE(FSRefFromPath(path, &ref)); 30 ASSERT_TRUE(FSRefFromPath(path, &ref));
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 EXPECT_FALSE(CSBackupIsItemExcluded((CFURLRef)fileURL, &excludeByPath)); 145 EXPECT_FALSE(CSBackupIsItemExcluded((CFURLRef)fileURL, &excludeByPath));
145 // Exclude the file. 146 // Exclude the file.
146 EXPECT_TRUE(SetFileBackupExclusion(file_path, true)); 147 EXPECT_TRUE(SetFileBackupExclusion(file_path, true));
147 EXPECT_TRUE(CSBackupIsItemExcluded((CFURLRef)fileURL, &excludeByPath)); 148 EXPECT_TRUE(CSBackupIsItemExcluded((CFURLRef)fileURL, &excludeByPath));
148 // Un-exclude the file. 149 // Un-exclude the file.
149 EXPECT_TRUE(SetFileBackupExclusion(file_path, false)); 150 EXPECT_TRUE(SetFileBackupExclusion(file_path, false));
150 EXPECT_FALSE(CSBackupIsItemExcluded((CFURLRef)fileURL, &excludeByPath)); 151 EXPECT_FALSE(CSBackupIsItemExcluded((CFURLRef)fileURL, &excludeByPath));
151 } 152 }
152 153
153 TEST_F(MacUtilTest, TestGetValueFromDictionary) { 154 TEST_F(MacUtilTest, TestGetValueFromDictionary) {
154 base::mac::ScopedCFTypeRef<CFMutableDictionaryRef> dict( 155 ScopedCFTypeRef<CFMutableDictionaryRef> dict(
155 CFDictionaryCreateMutable(0, 0, 156 CFDictionaryCreateMutable(0, 0,
156 &kCFTypeDictionaryKeyCallBacks, 157 &kCFTypeDictionaryKeyCallBacks,
157 &kCFTypeDictionaryValueCallBacks)); 158 &kCFTypeDictionaryValueCallBacks));
158 CFDictionarySetValue(dict.get(), CFSTR("key"), CFSTR("value")); 159 CFDictionarySetValue(dict.get(), CFSTR("key"), CFSTR("value"));
159 160
160 EXPECT_TRUE(CFEqual(CFSTR("value"), 161 EXPECT_TRUE(CFEqual(CFSTR("value"),
161 GetValueFromDictionary( 162 GetValueFromDictionary(
162 dict, CFSTR("key"), CFStringGetTypeID()))); 163 dict, CFSTR("key"), CFStringGetTypeID())));
163 EXPECT_FALSE(GetValueFromDictionary(dict, CFSTR("key"), CFNumberGetTypeID())); 164 EXPECT_FALSE(GetValueFromDictionary(dict, CFSTR("key"), CFNumberGetTypeID()));
164 EXPECT_FALSE(GetValueFromDictionary( 165 EXPECT_FALSE(GetValueFromDictionary(
165 dict, CFSTR("no-exist"), CFStringGetTypeID())); 166 dict, CFSTR("no-exist"), CFStringGetTypeID()));
166 } 167 }
167 168
168 TEST_F(MacUtilTest, CopyNSImageToCGImage) { 169 TEST_F(MacUtilTest, CopyNSImageToCGImage) {
169 scoped_nsobject<NSImage> nsImage( 170 scoped_nsobject<NSImage> nsImage(
170 [[NSImage alloc] initWithSize:NSMakeSize(20, 20)]); 171 [[NSImage alloc] initWithSize:NSMakeSize(20, 20)]);
171 [nsImage lockFocus]; 172 [nsImage lockFocus];
172 [[NSColor redColor] set]; 173 [[NSColor redColor] set];
173 NSRect rect = NSZeroRect; 174 NSRect rect = NSZeroRect;
174 rect.size = [nsImage size]; 175 rect.size = [nsImage size];
175 NSRectFill(rect); 176 NSRectFill(rect);
176 [nsImage unlockFocus]; 177 [nsImage unlockFocus];
177 178
178 base::mac::ScopedCFTypeRef<CGImageRef> cgImage( 179 ScopedCFTypeRef<CGImageRef> cgImage(CopyNSImageToCGImage(nsImage.get()));
179 mac_util::CopyNSImageToCGImage(nsImage.get()));
180 EXPECT_TRUE(cgImage.get()); 180 EXPECT_TRUE(cgImage.get());
181 } 181 }
182 182
183 TEST_F(MacUtilTest, NSObjectRetainRelease) { 183 TEST_F(MacUtilTest, NSObjectRetainRelease) {
184 scoped_nsobject<NSArray> array([[NSArray alloc] initWithObjects:@"foo", nil]); 184 scoped_nsobject<NSArray> array([[NSArray alloc] initWithObjects:@"foo", nil]);
185 EXPECT_EQ(1U, [array retainCount]); 185 EXPECT_EQ(1U, [array retainCount]);
186 186
187 mac_util::NSObjectRetain(array); 187 NSObjectRetain(array);
188 EXPECT_EQ(2U, [array retainCount]); 188 EXPECT_EQ(2U, [array retainCount]);
189 189
190 mac_util::NSObjectRelease(array); 190 NSObjectRelease(array);
191 EXPECT_EQ(1U, [array retainCount]); 191 EXPECT_EQ(1U, [array retainCount]);
192 } 192 }
193 193
194 } // namespace 194 } // namespace
195 195
196 } // namespace mac_util 196 } // namespace mac
197 } // namespace base
OLDNEW
« no previous file with comments | « base/mac/mac_util.mm ('k') | base/mac_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698