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

Side by Side Diff: chrome/browser/ui/window_snapshot/window_snapshot_mac_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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/window_snapshot/window_snapshot.h"
6
7 #import <Cocoa/Cocoa.h>
8
9 #include "base/scoped_nsobject.h"
10 #include "base/scoped_ptr.h"
11 #include "base/test/mock_chrome_application_mac.h"
12 #include "testing/platform_test.h"
13
14 namespace browser {
15 namespace {
16
17 typedef PlatformTest GrabWindowSnapshotTest;
18
19 TEST_F(GrabWindowSnapshotTest, TestGrabWindowSnapshot) {
20 // Launch a test window so we can take a snapshot.
21 [MockCrApp sharedApplication];
22 NSRect frame = NSMakeRect(0, 0, 400, 400);
23 scoped_nsobject<NSWindow> window(
24 [[NSWindow alloc] initWithContentRect:frame
25 styleMask:NSBorderlessWindowMask
26 backing:NSBackingStoreBuffered
27 defer:NO]);
28 [window setBackgroundColor:[NSColor whiteColor]];
29 [window makeKeyAndOrderFront:NSApp];
30
31 scoped_ptr<std::vector<unsigned char> > png_representation(
32 new std::vector<unsigned char>);
33 int width, height;
34 browser::GrabWindowSnapshot(window, png_representation.get(),
35 &width, &height);
36
37 // Copy png back into NSData object so we can make sure we grabbed a png.
38 scoped_nsobject<NSData> image_data(
39 [[NSData alloc] initWithBytes:&(*png_representation)[0]
40 length:png_representation->size()]);
41 NSBitmapImageRep* rep = [NSBitmapImageRep imageRepWithData:image_data.get()];
42 EXPECT_TRUE([rep isKindOfClass:[NSBitmapImageRep class]]);
43 EXPECT_TRUE(CGImageGetWidth([rep CGImage]) == 400);
44 NSColor* color = [rep colorAtX:200 y:200];
45 CGFloat red = 0, green = 0, blue = 0, alpha = 0;
46 [color getRed:&red green:&green blue:&blue alpha:&alpha];
47 EXPECT_GE(red + green + blue, 3.0);
48 }
49
50 } // namespace
51 } // namespace browser
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698