| 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 "ui/gfx/image/image_skia.h" | 5 #include "ui/gfx/image/image_skia.h" |
| 6 | 6 |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include "third_party/skia/include/core/SkBitmap.h" | 8 #include "third_party/skia/include/core/SkBitmap.h" |
| 9 #include "ui/base/layout.h" | 9 #include "ui/base/layout.h" |
| 10 #include "ui/gfx/image/image_skia_rep.h" | 10 #include "ui/gfx/image/image_skia_rep.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 EXPECT_EQ(1U, image_skia.image_reps().size()); | 80 EXPECT_EQ(1U, image_skia.image_reps().size()); |
| 81 | 81 |
| 82 const ImageSkiaRep& result_200p = | 82 const ImageSkiaRep& result_200p = |
| 83 image_skia.GetRepresentation(ui::SCALE_FACTOR_200P); | 83 image_skia.GetRepresentation(ui::SCALE_FACTOR_200P); |
| 84 | 84 |
| 85 EXPECT_EQ(100, result_200p.GetWidth()); | 85 EXPECT_EQ(100, result_200p.GetWidth()); |
| 86 EXPECT_EQ(200, result_200p.GetHeight()); | 86 EXPECT_EQ(200, result_200p.GetHeight()); |
| 87 EXPECT_EQ(100, result_200p.pixel_width()); | 87 EXPECT_EQ(100, result_200p.pixel_width()); |
| 88 EXPECT_EQ(200, result_200p.pixel_height()); | 88 EXPECT_EQ(200, result_200p.pixel_height()); |
| 89 EXPECT_EQ(ui::SCALE_FACTOR_100P, result_200p.scale_factor()); | 89 EXPECT_EQ(ui::SCALE_FACTOR_100P, result_200p.scale_factor()); |
| 90 EXPECT_EQ(2U, image_skia.image_reps().size()); | 90 EXPECT_EQ(1U, image_skia.image_reps().size()); |
| 91 | 91 |
| 92 // Get the representation again and make sure it doesn't | 92 // Get the representation again and make sure it doesn't |
| 93 // generate new image skia rep. | 93 // generate new image skia rep. |
| 94 image_skia.GetRepresentation(ui::SCALE_FACTOR_100P); | 94 image_skia.GetRepresentation(ui::SCALE_FACTOR_100P); |
| 95 EXPECT_EQ(2U, image_skia.image_reps().size()); | |
| 96 image_skia.GetRepresentation(ui::SCALE_FACTOR_200P); | 95 image_skia.GetRepresentation(ui::SCALE_FACTOR_200P); |
| 97 EXPECT_EQ(2U, image_skia.image_reps().size()); | 96 EXPECT_EQ(1U, image_skia.image_reps().size()); |
| 98 } | 97 } |
| 99 | 98 |
| 100 TEST(ImageSkiaTest, DynamicSource) { | 99 TEST(ImageSkiaTest, DynamicSource) { |
| 101 ImageSkia image_skia(new DynamicSource(Size(100, 200)), Size(100, 200)); | 100 ImageSkia image_skia(new DynamicSource(Size(100, 200)), Size(100, 200)); |
| 102 EXPECT_EQ(0U, image_skia.image_reps().size()); | 101 EXPECT_EQ(0U, image_skia.image_reps().size()); |
| 103 const ImageSkiaRep& result_100p = | 102 const ImageSkiaRep& result_100p = |
| 104 image_skia.GetRepresentation(ui::SCALE_FACTOR_100P); | 103 image_skia.GetRepresentation(ui::SCALE_FACTOR_100P); |
| 105 EXPECT_EQ(100, result_100p.GetWidth()); | 104 EXPECT_EQ(100, result_100p.GetWidth()); |
| 106 EXPECT_EQ(200, result_100p.GetHeight()); | 105 EXPECT_EQ(200, result_100p.GetHeight()); |
| 107 EXPECT_EQ(ui::SCALE_FACTOR_100P, result_100p.scale_factor()); | 106 EXPECT_EQ(ui::SCALE_FACTOR_100P, result_100p.scale_factor()); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 #endif // OS_MACOSX | 167 #endif // OS_MACOSX |
| 169 | 168 |
| 170 TEST(ImageSkiaTest, GetBitmap) { | 169 TEST(ImageSkiaTest, GetBitmap) { |
| 171 ImageSkia image_skia(new DynamicSource(Size(100, 200)), Size(100, 200)); | 170 ImageSkia image_skia(new DynamicSource(Size(100, 200)), Size(100, 200)); |
| 172 const SkBitmap* bitmap = image_skia.bitmap(); | 171 const SkBitmap* bitmap = image_skia.bitmap(); |
| 173 EXPECT_NE(static_cast<SkBitmap*>(NULL), bitmap); | 172 EXPECT_NE(static_cast<SkBitmap*>(NULL), bitmap); |
| 174 EXPECT_FALSE(bitmap->isNull()); | 173 EXPECT_FALSE(bitmap->isNull()); |
| 175 } | 174 } |
| 176 | 175 |
| 177 } // namespace gfx | 176 } // namespace gfx |
| OLD | NEW |