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

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

Issue 6533013: Move ui::gfx::Image out of the ui namespace to be just gfx::Image. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 10 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
« no previous file with comments | « chrome/browser/ui/tests/ui_gfx_image_unittest.cc ('k') | ui/gfx/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/scoped_nsobject.h" 7 #include "base/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.h" 11 #include "ui/gfx/image.h"
12 #include "ui/gfx/image_unittest.h" 12 #include "ui/gfx/image_unittest.h"
13 13
14 namespace { 14 namespace {
15 15
16 using namespace ui::gfx::test; 16 using namespace gfx::test;
17 17
18 class UiGfxImageTest : public CocoaTest { 18 class UiGfxImageTest : public CocoaTest {
19 }; 19 };
20 20
21 TEST_F(UiGfxImageTest, CheckColor) { 21 TEST_F(UiGfxImageTest, CheckColor) {
22 ui::gfx::Image image(CreateBitmap()); 22 gfx::Image image(CreateBitmap());
23 [image lockFocus]; 23 [image lockFocus];
24 NSColor* color = NSReadPixel(NSMakePoint(10, 10)); 24 NSColor* color = NSReadPixel(NSMakePoint(10, 10));
25 [image unlockFocus]; 25 [image unlockFocus];
26 26
27 // SkBitmapToNSImage returns a bitmap in the calibrated color space (sRGB), 27 // SkBitmapToNSImage returns a bitmap in the calibrated color space (sRGB),
28 // while NSReadPixel returns a color in the device color space. Convert back 28 // while NSReadPixel returns a color in the device color space. Convert back
29 // to the calibrated color space before testing. 29 // to the calibrated color space before testing.
30 color = [color colorUsingColorSpaceName:NSCalibratedRGBColorSpace]; 30 color = [color colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
31 31
32 CGFloat components[4] = { 0 }; 32 CGFloat components[4] = { 0 };
33 [color getComponents:components]; 33 [color getComponents:components];
34 34
35 EXPECT_GT(components[0], 0.95); 35 EXPECT_GT(components[0], 0.95);
36 EXPECT_LT(components[1], 0.05); 36 EXPECT_LT(components[1], 0.05);
37 EXPECT_LT(components[2], 0.05); 37 EXPECT_LT(components[2], 0.05);
38 EXPECT_GT(components[3], 0.95); 38 EXPECT_GT(components[3], 0.95);
39 } 39 }
40 40
41 TEST_F(UiGfxImageTest, ImageView) { 41 TEST_F(UiGfxImageTest, ImageView) {
42 scoped_nsobject<NSImageView> image_view( 42 scoped_nsobject<NSImageView> image_view(
43 [[NSImageView alloc] initWithFrame:NSMakeRect(10, 10, 25, 25)]); 43 [[NSImageView alloc] initWithFrame:NSMakeRect(10, 10, 25, 25)]);
44 [[test_window() contentView] addSubview:image_view]; 44 [[test_window() contentView] addSubview:image_view];
45 [test_window() orderFront:nil]; 45 [test_window() orderFront:nil];
46 46
47 ui::gfx::Image image(CreateBitmap()); 47 gfx::Image image(CreateBitmap());
48 [image_view setImage:image]; 48 [image_view setImage:image];
49 } 49 }
50 50
51 } // namespace 51 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/ui/tests/ui_gfx_image_unittest.cc ('k') | ui/gfx/image.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698