Index: ui/snapshot/snapshot_mac_unittest.mm |
diff --git a/ui/snapshot/snapshot_mac_unittest.mm b/ui/snapshot/snapshot_mac_unittest.mm |
index eea1067072823cc50b650a1b1bbcea9c972b646d..d1d9250464012794bb20f25093d7326d35136a89 100644 |
--- a/ui/snapshot/snapshot_mac_unittest.mm |
+++ b/ui/snapshot/snapshot_mac_unittest.mm |
@@ -12,32 +12,34 @@ |
#include "base/mac/sdk_forward_declarations.h" |
#include "testing/platform_test.h" |
#include "ui/gfx/geometry/rect.h" |
-#include "ui/gfx/image/image.h" |
-#import "ui/gfx/test/ui_cocoa_test_helper.h" |
namespace ui { |
namespace { |
-typedef CocoaTest GrabWindowSnapshotTest; |
+typedef PlatformTest GrabWindowSnapshotTest; |
TEST_F(GrabWindowSnapshotTest, TestGrabWindowSnapshot) { |
// Launch a test window so we can take a snapshot. |
NSRect frame = NSMakeRect(0, 0, 400, 400); |
- NSWindow* window = test_window(); |
- [window setFrame:frame display:false]; |
+ base::scoped_nsobject<NSWindow> window( |
+ [[NSWindow alloc] initWithContentRect:frame |
+ styleMask:NSBorderlessWindowMask |
+ backing:NSBackingStoreBuffered |
+ defer:NO]); |
[window setBackgroundColor:[NSColor whiteColor]]; |
[window makeKeyAndOrderFront:NSApp]; |
- [window display]; |
- gfx::Image image; |
+ std::unique_ptr<std::vector<unsigned char>> png_representation( |
+ new std::vector<unsigned char>); |
gfx::Rect bounds = gfx::Rect(0, 0, frame.size.width, frame.size.height); |
- EXPECT_TRUE(ui::GrabWindowSnapshot(window, bounds, &image)); |
+ EXPECT_TRUE(ui::GrabWindowSnapshot(window, png_representation.get(), |
+ bounds)); |
- NSImage* nsImage = image.ToNSImage(); |
- CGImageRef cgImage = |
- [nsImage CGImageForProposedRect:nil context:nil hints:nil]; |
- base::scoped_nsobject<NSBitmapImageRep> rep( |
- [[NSBitmapImageRep alloc] initWithCGImage:cgImage]); |
+ // Copy png back into NSData object so we can make sure we grabbed a png. |
+ base::scoped_nsobject<NSData> image_data( |
+ [[NSData alloc] initWithBytes:&(*png_representation)[0] |
+ length:png_representation->size()]); |
+ NSBitmapImageRep* rep = [NSBitmapImageRep imageRepWithData:image_data.get()]; |
EXPECT_TRUE([rep isKindOfClass:[NSBitmapImageRep class]]); |
CGFloat scaleFactor = 1.0f; |
if ([window respondsToSelector:@selector(backingScaleFactor)]) |