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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 | 166 |
167 #endif // OS_MACOSX | 167 #endif // OS_MACOSX |
168 | 168 |
169 TEST(ImageSkiaTest, GetBitmap) { | 169 TEST(ImageSkiaTest, GetBitmap) { |
170 ImageSkia image_skia(new DynamicSource(Size(100, 200)), Size(100, 200)); | 170 ImageSkia image_skia(new DynamicSource(Size(100, 200)), Size(100, 200)); |
171 const SkBitmap* bitmap = image_skia.bitmap(); | 171 const SkBitmap* bitmap = image_skia.bitmap(); |
172 EXPECT_NE(static_cast<SkBitmap*>(NULL), bitmap); | 172 EXPECT_NE(static_cast<SkBitmap*>(NULL), bitmap); |
173 EXPECT_FALSE(bitmap->isNull()); | 173 EXPECT_FALSE(bitmap->isNull()); |
174 } | 174 } |
175 | 175 |
| 176 TEST(ImageSkiaTest, Equals) { |
| 177 // Null images should all be equal. |
| 178 ImageSkia image; |
| 179 ImageSkia unrelated; |
| 180 EXPECT_TRUE(image.Equals(unrelated)); |
| 181 |
| 182 image.AddRepresentation(gfx::ImageSkiaRep(gfx::Size(10, 10), |
| 183 ui::SCALE_FACTOR_100P)); |
| 184 ImageSkia copy = image; |
| 185 copy.AddRepresentation(gfx::ImageSkiaRep(gfx::Size(10, 10), |
| 186 ui::SCALE_FACTOR_200P)); |
| 187 unrelated.AddRepresentation(gfx::ImageSkiaRep(gfx::Size(10, 10), |
| 188 ui::SCALE_FACTOR_100P)); |
| 189 EXPECT_TRUE(image.Equals(copy)); |
| 190 EXPECT_FALSE(image.Equals(unrelated)); |
| 191 EXPECT_FALSE(copy.Equals(unrelated)); |
| 192 } |
| 193 |
176 } // namespace gfx | 194 } // namespace gfx |
OLD | NEW |