| 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" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 EXPECT_EQ(2u, image.RepresentationCount()); | 72 EXPECT_EQ(2u, image.RepresentationCount()); |
| 73 } | 73 } |
| 74 | 74 |
| 75 TEST_F(ImageMacTest, MultiResolutionSkBitmapToNSImage) { | 75 TEST_F(ImageMacTest, MultiResolutionSkBitmapToNSImage) { |
| 76 const int width1 = 10; | 76 const int width1 = 10; |
| 77 const int height1 = 12; | 77 const int height1 = 12; |
| 78 const int width2 = 20; | 78 const int width2 = 20; |
| 79 const int height2 = 24; | 79 const int height2 = 24; |
| 80 | 80 |
| 81 std::vector<const SkBitmap*> bitmaps; | 81 std::vector<const SkBitmap*> bitmaps; |
| 82 bitmaps.push_back(gt::CreateBitmap(width1, height1)); | 82 bitmaps.push_back(new SkBitmap(gt::CreateBitmap(width1, height1))); |
| 83 bitmaps.push_back(gt::CreateBitmap(width2, height2)); | 83 bitmaps.push_back(new SkBitmap(gt::CreateBitmap(width2, height2))); |
| 84 gfx::Image image(bitmaps); | 84 gfx::Image image(bitmaps); |
| 85 | 85 |
| 86 EXPECT_EQ(1u, image.RepresentationCount()); | 86 EXPECT_EQ(1u, image.RepresentationCount()); |
| 87 EXPECT_EQ(2u, image.ToImageSkia()->bitmaps().size()); | 87 EXPECT_EQ(2u, image.ToImageSkia()->bitmaps().size()); |
| 88 | 88 |
| 89 NSImage* ns_image = image; | 89 NSImage* ns_image = image; |
| 90 EXPECT_TRUE(ns_image); | 90 EXPECT_TRUE(ns_image); |
| 91 | 91 |
| 92 EXPECT_EQ(2u, [[image representations] count]); | 92 EXPECT_EQ(2u, [[image representations] count]); |
| 93 NSImageRep* image_rep_1 = [[image representations] objectAtIndex:0]; | 93 NSImageRep* image_rep_1 = [[image representations] objectAtIndex:0]; |
| 94 NSImageRep* image_rep_2 = [[image representations] objectAtIndex:1]; | 94 NSImageRep* image_rep_2 = [[image representations] objectAtIndex:1]; |
| 95 | 95 |
| 96 if ([image_rep_1 size].width == width1) { | 96 if ([image_rep_1 size].width == width1) { |
| 97 EXPECT_EQ([image_rep_1 size].height, height1); | 97 EXPECT_EQ([image_rep_1 size].height, height1); |
| 98 EXPECT_EQ([image_rep_2 size].width, width2); | 98 EXPECT_EQ([image_rep_2 size].width, width2); |
| 99 EXPECT_EQ([image_rep_2 size].height, height2); | 99 EXPECT_EQ([image_rep_2 size].height, height2); |
| 100 } else { | 100 } else { |
| 101 EXPECT_EQ([image_rep_1 size].width, width2); | 101 EXPECT_EQ([image_rep_1 size].width, width2); |
| 102 EXPECT_EQ([image_rep_1 size].height, height2); | 102 EXPECT_EQ([image_rep_1 size].height, height2); |
| 103 EXPECT_EQ([image_rep_2 size].width, width1); | 103 EXPECT_EQ([image_rep_2 size].width, width1); |
| 104 EXPECT_EQ([image_rep_2 size].height, height1); | 104 EXPECT_EQ([image_rep_2 size].height, height1); |
| 105 } | 105 } |
| 106 | 106 |
| 107 // Cast to NSImage* should create a second representation. | 107 // Cast to NSImage* should create a second representation. |
| 108 EXPECT_EQ(2u, image.RepresentationCount()); | 108 EXPECT_EQ(2u, image.RepresentationCount()); |
| 109 } | 109 } |
| 110 | 110 |
| 111 } // namespace | 111 } // namespace |
| OLD | NEW |