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

Unified Diff: ui/snapshot/snapshot_mac_unittest.mm

Issue 2650903003: Revert of [devtools] Support different encodings for Page.CaptureScreenshot. (Closed)
Patch Set: Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/snapshot/snapshot_mac.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)])
« no previous file with comments | « ui/snapshot/snapshot_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698