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 "third_party/skia/include/core/SkBitmap.h" | 8 #include "third_party/skia/include/core/SkBitmap.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "ui/base/layout.h" |
9 #include "ui/gfx/image/image_skia_rep.h" | 10 #include "ui/gfx/image/image_skia_rep.h" |
10 #include "ui/gfx/image/image_skia_source.h" | 11 #include "ui/gfx/image/image_skia_source.h" |
11 #include "ui/gfx/size.h" | 12 #include "ui/gfx/size.h" |
12 #include "ui/base/layout.h" | |
13 | 13 |
14 namespace gfx { | 14 namespace gfx { |
15 | 15 |
16 namespace { | 16 namespace { |
17 | 17 |
18 class FixedSource : public ImageSkiaSource { | 18 class FixedSource : public ImageSkiaSource { |
19 public: | 19 public: |
20 FixedSource(const ImageSkiaRep& image) : image_(image) {} | 20 FixedSource(const ImageSkiaRep& image) : image_(image) {} |
21 | 21 |
22 virtual ~FixedSource() { | 22 virtual ~FixedSource() { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 } | 58 } |
59 | 59 |
60 virtual ImageSkiaRep GetImageForScale(ui::ScaleFactor scale_factor) OVERRIDE { | 60 virtual ImageSkiaRep GetImageForScale(ui::ScaleFactor scale_factor) OVERRIDE { |
61 return gfx::ImageSkiaRep(); | 61 return gfx::ImageSkiaRep(); |
62 } | 62 } |
63 | 63 |
64 private: | 64 private: |
65 DISALLOW_COPY_AND_ASSIGN(NullSource); | 65 DISALLOW_COPY_AND_ASSIGN(NullSource); |
66 }; | 66 }; |
67 | 67 |
68 } // namespace; | 68 } // namespace |
69 | |
70 typedef testing::Test ImageSkiaTest; | |
71 | 69 |
72 TEST(ImageSkiaTest, FixedSource) { | 70 TEST(ImageSkiaTest, FixedSource) { |
73 ImageSkiaRep image(Size(100, 200), ui::SCALE_FACTOR_100P); | 71 ImageSkiaRep image(Size(100, 200), ui::SCALE_FACTOR_100P); |
74 ImageSkia image_skia(new FixedSource(image), Size(100, 200)); | 72 ImageSkia image_skia(new FixedSource(image), Size(100, 200)); |
75 EXPECT_EQ(0U, image_skia.image_reps().size()); | 73 EXPECT_EQ(0U, image_skia.image_reps().size()); |
76 | 74 |
77 const ImageSkiaRep& result_100p = | 75 const ImageSkiaRep& result_100p = |
78 image_skia.GetRepresentation(ui::SCALE_FACTOR_100P); | 76 image_skia.GetRepresentation(ui::SCALE_FACTOR_100P); |
79 EXPECT_EQ(100, result_100p.GetWidth()); | 77 EXPECT_EQ(100, result_100p.GetWidth()); |
80 EXPECT_EQ(200, result_100p.GetHeight()); | 78 EXPECT_EQ(200, result_100p.GetHeight()); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 #endif // OS_MACOSX | 168 #endif // OS_MACOSX |
171 | 169 |
172 TEST(ImageSkiaTest, GetBitmap) { | 170 TEST(ImageSkiaTest, GetBitmap) { |
173 ImageSkia image_skia(new DynamicSource(Size(100, 200)), Size(100, 200)); | 171 ImageSkia image_skia(new DynamicSource(Size(100, 200)), Size(100, 200)); |
174 const SkBitmap* bitmap = image_skia.bitmap(); | 172 const SkBitmap* bitmap = image_skia.bitmap(); |
175 EXPECT_NE(static_cast<SkBitmap*>(NULL), bitmap); | 173 EXPECT_NE(static_cast<SkBitmap*>(NULL), bitmap); |
176 EXPECT_FALSE(bitmap->isNull()); | 174 EXPECT_FALSE(bitmap->isNull()); |
177 } | 175 } |
178 | 176 |
179 } // namespace gfx | 177 } // namespace gfx |
OLD | NEW |