OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "testing/gtest/include/gtest/gtest.h" | 5 #include "testing/gtest/include/gtest/gtest.h" |
6 #include "ui/gfx/image/image.h" | 6 #include "ui/gfx/image/image.h" |
7 #include "ui/gfx/image/image_family.h" | 7 #include "ui/gfx/image/image_family.h" |
8 #include "ui/gfx/image/image_skia.h" | 8 #include "ui/gfx/image/image_skia.h" |
9 #include "ui/gfx/image/image_unittest_util.h" | 9 #include "ui/gfx/image/image_unittest_util.h" |
10 | 10 |
11 namespace { | 11 namespace { |
12 | 12 |
13 namespace gt = gfx::test; | 13 namespace gt = gfx::test; |
14 | 14 |
15 // Tests that |image| != NULL, and has the given width and height. | 15 // Tests that |image| != NULL, and has the given width and height. |
16 // This is a macro instead of a function, so that the correct line numbers are | 16 // This is a macro instead of a function, so that the correct line numbers are |
17 // reported when a test fails. | 17 // reported when a test fails. |
18 #define EXPECT_IMAGE_NON_NULL_AND_SIZE(image, expected_width, expected_height) \ | 18 #define EXPECT_IMAGE_NON_NULL_AND_SIZE(image, expected_width, expected_height) \ |
19 do { \ | 19 do { \ |
20 const gfx::Image* image_ = image; \ | 20 const gfx::Image* image_ = image; \ |
21 EXPECT_TRUE(image_); \ | 21 EXPECT_TRUE(image_); \ |
22 EXPECT_EQ(expected_width, image_->Width()); \ | 22 EXPECT_EQ(expected_width, image_->Width()); \ |
23 EXPECT_EQ(expected_height, image_->Height()); \ | 23 EXPECT_EQ(expected_height, image_->Height()); \ |
24 } while(0) | 24 } while(0) |
25 | 25 |
26 class ImageFamilyTest : public testing::Test { | 26 class ImageFamilyTest : public testing::Test { |
27 public: | 27 public: |
28 // Construct an ImageFamily. Implicitly tests Add and Empty. | 28 // Construct an ImageFamily. Implicitly tests Add and Empty. |
29 virtual void SetUp() OVERRIDE { | 29 virtual void SetUp() override { |
30 EXPECT_TRUE(image_family_.empty()); | 30 EXPECT_TRUE(image_family_.empty()); |
31 | 31 |
32 // Aspect ratio 1:1. | 32 // Aspect ratio 1:1. |
33 image_family_.Add(gt::CreateImageSkia(32, 32)); | 33 image_family_.Add(gt::CreateImageSkia(32, 32)); |
34 EXPECT_FALSE(image_family_.empty()); | 34 EXPECT_FALSE(image_family_.empty()); |
35 image_family_.Add(gt::CreateImageSkia(16, 16)); | 35 image_family_.Add(gt::CreateImageSkia(16, 16)); |
36 image_family_.Add(gt::CreateImageSkia(64, 64)); | 36 image_family_.Add(gt::CreateImageSkia(64, 64)); |
37 // Duplicate (should override previous one). | 37 // Duplicate (should override previous one). |
38 // Insert an Image directly, instead of an ImageSkia. | 38 // Insert an Image directly, instead of an ImageSkia. |
39 gfx::Image image(gt::CreateImageSkia(32, 32)); | 39 gfx::Image image(gt::CreateImageSkia(32, 32)); |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 EXPECT_IMAGE_NON_NULL_AND_SIZE(image_family_.GetBest(0, 1), 0, 0); | 168 EXPECT_IMAGE_NON_NULL_AND_SIZE(image_family_.GetBest(0, 1), 0, 0); |
169 EXPECT_IMAGE_NON_NULL_AND_SIZE(image_family_.GetBest(0, 32), 0, 0); | 169 EXPECT_IMAGE_NON_NULL_AND_SIZE(image_family_.GetBest(0, 32), 0, 0); |
170 EXPECT_IMAGE_NON_NULL_AND_SIZE(image_family_.GetBest(1, 0), 0, 0); | 170 EXPECT_IMAGE_NON_NULL_AND_SIZE(image_family_.GetBest(1, 0), 0, 0); |
171 EXPECT_IMAGE_NON_NULL_AND_SIZE(image_family_.GetBest(32, 0), 0, 0); | 171 EXPECT_IMAGE_NON_NULL_AND_SIZE(image_family_.GetBest(32, 0), 0, 0); |
172 | 172 |
173 EXPECT_IMAGE_NON_NULL_AND_SIZE(image_family_.GetBest(1, 32), 12, 48); | 173 EXPECT_IMAGE_NON_NULL_AND_SIZE(image_family_.GetBest(1, 32), 12, 48); |
174 EXPECT_IMAGE_NON_NULL_AND_SIZE(image_family_.GetBest(32, 1), 256, 64); | 174 EXPECT_IMAGE_NON_NULL_AND_SIZE(image_family_.GetBest(32, 1), 256, 64); |
175 } | 175 } |
176 | 176 |
177 } // namespace | 177 } // namespace |
OLD | NEW |