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

Side by Side Diff: chrome/browser/ui/tests/ui_gfx_image_unittest.mm

Issue 10933083: Remove deprecated gfx::Image::operator NSImage*(). (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Comments and merge Created 8 years, 3 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <AppKit/AppKit.h> 5 #import <AppKit/AppKit.h>
6 6
7 #include "base/memory/scoped_nsobject.h" 7 #include "base/memory/scoped_nsobject.h"
8 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" 8 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "third_party/skia/include/core/SkBitmap.h" 10 #include "third_party/skia/include/core/SkBitmap.h"
11 #include "ui/gfx/image/image.h" 11 #include "ui/gfx/image/image.h"
12 #include "ui/gfx/image/image_unittest_util.h" 12 #include "ui/gfx/image/image_unittest_util.h"
13 13
14 namespace { 14 namespace {
15 15
16 class UiGfxImageTest : public CocoaTest { 16 class UiGfxImageTest : public CocoaTest {
17 }; 17 };
18 18
19 TEST_F(UiGfxImageTest, CheckColor) { 19 TEST_F(UiGfxImageTest, CheckColor) {
20 gfx::Image image(gfx::test::CreateBitmap(25, 25)); 20 gfx::Image image(gfx::test::CreateBitmap(25, 25));
21 [image lockFocus]; 21 NSImage* ns_image = image.ToNSImage();
22 [ns_image lockFocus];
22 NSColor* color = NSReadPixel(NSMakePoint(10, 10)); 23 NSColor* color = NSReadPixel(NSMakePoint(10, 10));
23 [image unlockFocus]; 24 [ns_image unlockFocus];
24 25
25 // SkBitmapToNSImage returns a bitmap in the calibrated color space (sRGB), 26 // SkBitmapToNSImage returns a bitmap in the calibrated color space (sRGB),
26 // while NSReadPixel returns a color in the device color space. Convert back 27 // while NSReadPixel returns a color in the device color space. Convert back
27 // to the calibrated color space before testing. 28 // to the calibrated color space before testing.
28 color = [color colorUsingColorSpaceName:NSCalibratedRGBColorSpace]; 29 color = [color colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
29 30
30 CGFloat components[4] = { 0 }; 31 CGFloat components[4] = { 0 };
31 [color getComponents:components]; 32 [color getComponents:components];
32 33
33 EXPECT_LT(components[0], 0.05); 34 EXPECT_LT(components[0], 0.05);
34 EXPECT_GT(components[1], 0.95); 35 EXPECT_GT(components[1], 0.95);
35 EXPECT_LT(components[2], 0.05); 36 EXPECT_LT(components[2], 0.05);
36 EXPECT_GT(components[3], 0.95); 37 EXPECT_GT(components[3], 0.95);
37 } 38 }
38 39
39 TEST_F(UiGfxImageTest, ImageView) { 40 TEST_F(UiGfxImageTest, ImageView) {
40 scoped_nsobject<NSImageView> image_view( 41 scoped_nsobject<NSImageView> image_view(
41 [[NSImageView alloc] initWithFrame:NSMakeRect(10, 10, 25, 25)]); 42 [[NSImageView alloc] initWithFrame:NSMakeRect(10, 10, 25, 25)]);
42 [[test_window() contentView] addSubview:image_view]; 43 [[test_window() contentView] addSubview:image_view];
43 [test_window() orderFront:nil]; 44 [test_window() orderFront:nil];
44 45
45 gfx::Image image(gfx::test::CreateBitmap(25, 25)); 46 gfx::Image image(gfx::test::CreateBitmap(25, 25));
46 [image_view setImage:image.ToNSImage()]; 47 [image_view setImage:image.ToNSImage()];
47 } 48 }
48 49
49 } // namespace 50 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/ui/panels/panel_window_controller_cocoa.mm ('k') | content/browser/web_contents/web_drag_source_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698