| OLD | NEW |
| 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 Loading... |
| 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 |
| OLD | NEW |