Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #include <Cocoa/Cocoa.h> | 5 #include <Cocoa/Cocoa.h> |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/scoped_nsobject.h" | 8 #include "base/memory/scoped_nsobject.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_skia.h" | 12 #include "ui/gfx/image/image_skia.h" |
| 13 #include "ui/gfx/image/image_unittest_util.h" | 13 #include "ui/gfx/image/image_unittest_util.h" |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| 16 | 16 |
| 17 class ImageMacTest : public testing::Test { | 17 class ImageMacTest : public testing::Test { |
| 18 public: | 18 public: |
| 19 void CreateBitmapImageRep(int width, int height, | 19 void CreateBitmapImageRep(int width, int height, |
|
Nico
2012/06/12 15:31:50
nit: "Create" suggests that the caller is responsi
| |
| 20 NSBitmapImageRep** image_rep) { | 20 NSBitmapImageRep** image_rep) { |
| 21 *image_rep = [[NSBitmapImageRep alloc] | 21 *image_rep = [[[NSBitmapImageRep alloc] |
| 22 initWithBitmapDataPlanes:NULL | 22 initWithBitmapDataPlanes:NULL |
| 23 pixelsWide:width | 23 pixelsWide:width |
| 24 pixelsHigh:height | 24 pixelsHigh:height |
| 25 bitsPerSample:8 | 25 bitsPerSample:8 |
| 26 samplesPerPixel:3 | 26 samplesPerPixel:3 |
| 27 hasAlpha:NO | 27 hasAlpha:NO |
| 28 isPlanar:NO | 28 isPlanar:NO |
| 29 colorSpaceName:NSDeviceRGBColorSpace | 29 colorSpaceName:NSDeviceRGBColorSpace |
| 30 bitmapFormat:0 | 30 bitmapFormat:0 |
| 31 bytesPerRow:0 | 31 bytesPerRow:0 |
| 32 bitsPerPixel:0]; | 32 bitsPerPixel:0] |
| 33 autorelease]; | |
| 33 } | 34 } |
| 34 }; | 35 }; |
| 35 | 36 |
| 36 namespace gt = gfx::test; | 37 namespace gt = gfx::test; |
| 37 | 38 |
| 38 TEST_F(ImageMacTest, NSImageWithResizedNSImageRepToImageSkia) { | 39 TEST_F(ImageMacTest, NSImageWithResizedNSImageRepToImageSkia) { |
| 39 const int kWidth1x = 10; | 40 const int kWidth1x = 10; |
| 40 const int kHeight1x = 12; | 41 const int kHeight1x = 12; |
| 41 const int kWidth2x = 20; | 42 const int kWidth2x = 20; |
| 42 const int kHeight2x = 24; | 43 const int kHeight2x = 24; |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 138 EXPECT_EQ([image_rep_1 size].height, kHeight2x); | 139 EXPECT_EQ([image_rep_1 size].height, kHeight2x); |
| 139 EXPECT_EQ([image_rep_2 size].width, kWidth1x); | 140 EXPECT_EQ([image_rep_2 size].width, kWidth1x); |
| 140 EXPECT_EQ([image_rep_2 size].height, kHeight1x); | 141 EXPECT_EQ([image_rep_2 size].height, kHeight1x); |
| 141 } | 142 } |
| 142 | 143 |
| 143 // Cast to NSImage* should create a second representation. | 144 // Cast to NSImage* should create a second representation. |
| 144 EXPECT_EQ(2u, image.RepresentationCount()); | 145 EXPECT_EQ(2u, image.RepresentationCount()); |
| 145 } | 146 } |
| 146 | 147 |
| 147 } // namespace | 148 } // namespace |
| OLD | NEW |