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

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

Issue 10799014: Add support for PNG representation in gfx::Image (Closed) Base URL: http://git.chromium.org/chromium/src.git@bookmark-sync
Patch Set: Created 8 years, 4 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
« no previous file with comments | « no previous file | ui/gfx/image/image.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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"
(...skipping 12 matching lines...) Expand all
23 [image unlockFocus]; 23 [image unlockFocus];
24 24
25 // SkBitmapToNSImage returns a bitmap in the calibrated color space (sRGB), 25 // SkBitmapToNSImage returns a bitmap in the calibrated color space (sRGB),
26 // while NSReadPixel returns a color in the device color space. Convert back 26 // while NSReadPixel returns a color in the device color space. Convert back
27 // to the calibrated color space before testing. 27 // to the calibrated color space before testing.
28 color = [color colorUsingColorSpaceName:NSCalibratedRGBColorSpace]; 28 color = [color colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
29 29
30 CGFloat components[4] = { 0 }; 30 CGFloat components[4] = { 0 };
31 [color getComponents:components]; 31 [color getComponents:components];
32 32
33 EXPECT_GT(components[0], 0.95); 33 EXPECT_LT(components[0], 0.05);
34 EXPECT_LT(components[1], 0.05); 34 EXPECT_GT(components[1], 0.95);
35 EXPECT_LT(components[2], 0.05); 35 EXPECT_LT(components[2], 0.05);
36 EXPECT_GT(components[3], 0.95); 36 EXPECT_GT(components[3], 0.95);
37 } 37 }
38 38
39 TEST_F(UiGfxImageTest, ImageView) { 39 TEST_F(UiGfxImageTest, ImageView) {
40 scoped_nsobject<NSImageView> image_view( 40 scoped_nsobject<NSImageView> image_view(
41 [[NSImageView alloc] initWithFrame:NSMakeRect(10, 10, 25, 25)]); 41 [[NSImageView alloc] initWithFrame:NSMakeRect(10, 10, 25, 25)]);
42 [[test_window() contentView] addSubview:image_view]; 42 [[test_window() contentView] addSubview:image_view];
43 [test_window() orderFront:nil]; 43 [test_window() orderFront:nil];
44 44
45 gfx::Image image(gfx::test::CreateBitmap(25, 25)); 45 gfx::Image image(gfx::test::CreateBitmap(25, 25));
46 [image_view setImage:image.ToNSImage()]; 46 [image_view setImage:image.ToNSImage()];
47 } 47 }
48 48
49 } // namespace 49 } // namespace
OLDNEW
« no previous file with comments | « no previous file | ui/gfx/image/image.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698