Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(755)

Unified Diff: ui/gfx/image/image_skia_unittest.cc

Issue 10828296: Avoid crashing when an ImageSkia has no representations and is converted to SkBitmap. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix pkotwicz's comments. Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/gfx/image/image_skia_rep.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..1780254bc493531ca898440ff47f370c83d43a7b 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 and remove it so the ImageSkiaStorage
+ // is left with no representations.
+ ImageSkia empty_image(ImageSkiaRep(Size(100, 200), ui::SCALE_FACTOR_100P));
+ ImageSkia empty_image_copy(empty_image);
+ empty_image.RemoveRepresentation(ui::SCALE_FACTOR_100P);
+
+ // Check that ImageSkia::bitmap() still returns a valid SkBitmap pointer for
+ // the image and all its copies.
+ 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
« no previous file with comments | « ui/gfx/image/image_skia_rep.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698