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

Side by Side Diff: ui/base/snapshot/snapshot_mac_unittest.mm

Issue 11399002: Implemented GetWindowSnapshot on RenderViewImpl (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Moved snapshot files to ui/base Created 8 years, 1 month 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
jam 2012/11/15 01:05:59 you'll need to move this from chrome's test gypi t
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 #include "chrome/browser/ui/window_snapshot/window_snapshot.h" 5 #include "ui/base/snapshot/snapshot.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include "base/memory/scoped_nsobject.h" 9 #include "base/memory/scoped_nsobject.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "testing/platform_test.h" 11 #include "testing/platform_test.h"
12 #include "ui/gfx/rect.h" 12 #include "ui/gfx/rect.h"
13 13
14 #if !defined(MAC_OS_X_VERSION_10_7) || \ 14 #if !defined(MAC_OS_X_VERSION_10_7) || \
15 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7 15 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
16 16
17 @interface NSWindow (LionAPI) 17 @interface NSWindow (LionAPI)
18 - (CGFloat)backingScaleFactor; 18 - (CGFloat)backingScaleFactor;
19 @end 19 @end
20 20
21 #endif // 10.7 21 #endif // 10.7
22 22
23 namespace chrome { 23 namespace ui {
24 namespace { 24 namespace {
25 25
26 typedef PlatformTest GrabWindowSnapshotTest; 26 typedef PlatformTest GrabWindowSnapshotTest;
27 27
28 TEST_F(GrabWindowSnapshotTest, TestGrabWindowSnapshot) { 28 TEST_F(GrabWindowSnapshotTest, TestGrabWindowSnapshot) {
29 // Launch a test window so we can take a snapshot. 29 // Launch a test window so we can take a snapshot.
30 NSRect frame = NSMakeRect(0, 0, 400, 400); 30 NSRect frame = NSMakeRect(0, 0, 400, 400);
31 scoped_nsobject<NSWindow> window( 31 scoped_nsobject<NSWindow> window(
32 [[NSWindow alloc] initWithContentRect:frame 32 [[NSWindow alloc] initWithContentRect:frame
33 styleMask:NSBorderlessWindowMask 33 styleMask:NSBorderlessWindowMask
(...skipping 18 matching lines...) Expand all
52 if ([window respondsToSelector:@selector(backingScaleFactor)]) 52 if ([window respondsToSelector:@selector(backingScaleFactor)])
53 scaleFactor = [window backingScaleFactor]; 53 scaleFactor = [window backingScaleFactor];
54 EXPECT_EQ(400 * scaleFactor, CGImageGetWidth([rep CGImage])); 54 EXPECT_EQ(400 * scaleFactor, CGImageGetWidth([rep CGImage]));
55 NSColor* color = [rep colorAtX:200 * scaleFactor y:200 * scaleFactor]; 55 NSColor* color = [rep colorAtX:200 * scaleFactor y:200 * scaleFactor];
56 CGFloat red = 0, green = 0, blue = 0, alpha = 0; 56 CGFloat red = 0, green = 0, blue = 0, alpha = 0;
57 [color getRed:&red green:&green blue:&blue alpha:&alpha]; 57 [color getRed:&red green:&green blue:&blue alpha:&alpha];
58 EXPECT_GE(red + green + blue, 3.0); 58 EXPECT_GE(red + green + blue, 3.0);
59 } 59 }
60 60
61 } // namespace 61 } // namespace
62 } // namespace chrome 62 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698