Chromium Code Reviews| Index: ui/gfx/image/image_skia_unittest.cc |
| diff --git a/ui/gfx/image/image_skia_unittest.cc b/ui/gfx/image/image_skia_unittest.cc |
| index 118c858bfad011fab820d72cd485bd01ec74cb19..7b4a5ae96ecbeadb6e781f0b3256e13d085041fb 100644 |
| --- a/ui/gfx/image/image_skia_unittest.cc |
| +++ b/ui/gfx/image/image_skia_unittest.cc |
| @@ -173,4 +173,27 @@ TEST(ImageSkiaTest, GetBitmap) { |
| EXPECT_FALSE(bitmap->isNull()); |
| } |
| +TEST(ImageSkiaTest, GetBitmapFromEmpty) { |
| + // Create an image with 1 representation, remove it, and make sure that |
| + // doesn't crash a later bitmap retrieval. We retrieve from a copy, since |
| + // RemoveRepresentation could null out the ImageSkia it's called on, but not |
| + // the copy. |
| + ImageSkia empty_image(ImageSkiaRep(Size(100, 200), ui::SCALE_FACTOR_100P)); |
| + ImageSkia empty_image_copy(empty_image); |
|
pkotwicz
2012/08/14 14:44:24
I don't think it should make a difference as to wh
Jeffrey Yasskin
2012/08/14 17:08:28
Imagine that RemoveRepresentation checked if it ha
pkotwicz
2012/08/14 17:41:15
I follow your reasoning. My personal opinion is th
Jeffrey Yasskin
2012/08/14 19:14:15
Done, thanks.
I think I still need rsesek to LGTM
|
| + empty_image.RemoveRepresentation(ui::SCALE_FACTOR_100P); |
| + |
| + const SkBitmap* bitmap = empty_image_copy.bitmap(); |
| + ASSERT_NE(static_cast<SkBitmap*>(NULL), bitmap); |
| + EXPECT_TRUE(bitmap->isNull()); |
| + EXPECT_TRUE(bitmap->empty()); |
| +} |
| + |
| +TEST(ImageSkiaTest, OperatorBitmapFromSource) { |
| + ImageSkia image_skia(new DynamicSource(Size(100, 200)), Size(100, 200)); |
| + // ImageSkia should use the source to create the bitmap. |
| + const SkBitmap& bitmap = image_skia; |
| + ASSERT_NE(static_cast<SkBitmap*>(NULL), &bitmap); |
| + EXPECT_FALSE(bitmap.isNull()); |
| +} |
| + |
| } // namespace gfx |