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

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

Issue 6386009: Remove app/win/win_util.h,cc etc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Code cleanup 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/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"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 EXPECT_TRUE(GetUserDirectory(NSLibraryDirectory, &library_dir)); 46 EXPECT_TRUE(GetUserDirectory(NSLibraryDirectory, &library_dir));
47 EXPECT_FALSE(library_dir.empty()); 47 EXPECT_FALSE(library_dir.empty());
48 } 48 }
49 49
50 TEST_F(MacUtilTest, TestLibraryPath) { 50 TEST_F(MacUtilTest, TestLibraryPath) {
51 FilePath library_dir = GetUserLibraryPath(); 51 FilePath library_dir = GetUserLibraryPath();
52 // Make sure the string isn't empty. 52 // Make sure the string isn't empty.
53 EXPECT_FALSE(library_dir.value().empty()); 53 EXPECT_FALSE(library_dir.value().empty());
54 } 54 }
55 55
56 TEST_F(MacUtilTest, TestGrabWindowSnapshot) {
57 // Launch a test window so we can take a snapshot.
58 [MockCrApp sharedApplication];
59 NSRect frame = NSMakeRect(0, 0, 400, 400);
60 scoped_nsobject<NSWindow> window(
61 [[NSWindow alloc] initWithContentRect:frame
62 styleMask:NSBorderlessWindowMask
63 backing:NSBackingStoreBuffered
64 defer:NO]);
65 [window setBackgroundColor:[NSColor whiteColor]];
66 [window makeKeyAndOrderFront:NSApp];
67
68 scoped_ptr<std::vector<unsigned char> > png_representation(
69 new std::vector<unsigned char>);
70 int width, height;
71 GrabWindowSnapshot(window, png_representation.get(),
72 &width, &height);
73
74 // Copy png back into NSData object so we can make sure we grabbed a png.
75 scoped_nsobject<NSData> image_data(
76 [[NSData alloc] initWithBytes:&(*png_representation)[0]
77 length:png_representation->size()]);
78 NSBitmapImageRep* rep = [NSBitmapImageRep imageRepWithData:image_data.get()];
79 EXPECT_TRUE([rep isKindOfClass:[NSBitmapImageRep class]]);
80 EXPECT_TRUE(CGImageGetWidth([rep CGImage]) == 400);
81 NSColor* color = [rep colorAtX:200 y:200];
82 CGFloat red = 0, green = 0, blue = 0, alpha = 0;
83 [color getRed:&red green:&green blue:&blue alpha:&alpha];
84 EXPECT_GE(red + green + blue, 3.0);
85 }
86
87 TEST_F(MacUtilTest, TestGetAppBundlePath) { 56 TEST_F(MacUtilTest, TestGetAppBundlePath) {
88 FilePath out; 57 FilePath out;
89 58
90 // Make sure it doesn't crash. 59 // Make sure it doesn't crash.
91 out = GetAppBundlePath(FilePath()); 60 out = GetAppBundlePath(FilePath());
92 EXPECT_TRUE(out.empty()); 61 EXPECT_TRUE(out.empty());
93 62
94 // Some more invalid inputs. 63 // Some more invalid inputs.
95 const char* invalid_inputs[] = { 64 const char* invalid_inputs[] = {
96 "/", "/foo", "foo", "/foo/bar.", "foo/bar.", "/foo/bar./bazquux", 65 "/", "/foo", "foo", "/foo/bar.", "foo/bar.", "/foo/bar./bazquux",
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 EXPECT_EQ(2U, [array retainCount]); 157 EXPECT_EQ(2U, [array retainCount]);
189 158
190 NSObjectRelease(array); 159 NSObjectRelease(array);
191 EXPECT_EQ(1U, [array retainCount]); 160 EXPECT_EQ(1U, [array retainCount]);
192 } 161 }
193 162
194 } // namespace 163 } // namespace
195 164
196 } // namespace mac 165 } // namespace mac
197 } // namespace base 166 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698