Index: ui/gfx/image/image_unittest.cc |
diff --git a/ui/gfx/image/image_unittest.cc b/ui/gfx/image/image_unittest.cc |
index 0cdc237fabb3c356077697b766f71facb7b98cb4..bf46ac1bb2864a860824e02b75d200e8cbbb8a01 100644 |
--- a/ui/gfx/image/image_unittest.cc |
+++ b/ui/gfx/image/image_unittest.cc |
@@ -4,6 +4,7 @@ |
#include "testing/gtest/include/gtest/gtest.h" |
#include "ui/gfx/image/image.h" |
+#include "ui/gfx/image/image_png.h" |
#include "ui/gfx/image/image_skia.h" |
#include "ui/gfx/image/image_unittest_util.h" |
@@ -93,6 +94,33 @@ TEST_F(ImageTest, SkiaToSkiaRef) { |
EXPECT_FALSE(image.HasRepresentation(gt::GetPlatformRepresentationType())); |
} |
+TEST_F(ImageTest, SkiaToPNGEncodeAndDecode) { |
+ gfx::Image image(gt::CreateBitmap(25, 25)); |
+ const gfx::ImagePNG* png = image.ToImagePNG(); |
+ EXPECT_TRUE(png); |
+ EXPECT_FALSE(png->empty()); |
+ EXPECT_TRUE(image.HasRepresentation(gfx::Image::kImageRepPNG)); |
+ |
+ gfx::Image from_png(*png); |
+ EXPECT_TRUE(image.HasRepresentation(gfx::Image::kImageRepPNG)); |
+ EXPECT_TRUE(image.HasRepresentation(gfx::Image::kImageRepSkia)); |
+ EXPECT_TRUE(gt::IsEqual(from_png, image)); |
+} |
+ |
+TEST_F(ImageTest, PlatformToPNGEncodeAndDecode) { |
+ gfx::Image image(gt::CreatePlatformImage()); |
+ const gfx::ImagePNG* png = image.ToImagePNG(); |
+ EXPECT_TRUE(png); |
+ EXPECT_FALSE(png->empty()); |
+ EXPECT_TRUE(image.HasRepresentation(gfx::Image::kImageRepPNG)); |
+ |
+ gfx::Image from_png(*png); |
+ EXPECT_TRUE(image.HasRepresentation(gfx::Image::kImageRepPNG)); |
+ EXPECT_TRUE(image.HasRepresentation(gt::GetPlatformRepresentationType())); |
+ EXPECT_TRUE(gt::IsPlatformImageValid(gt::ToPlatformType(image))); |
+} |
+ |
+ |
TEST_F(ImageTest, SkiaToPlatform) { |
gfx::Image image(gt::CreateBitmap(25, 25)); |
const size_t kRepCount = kUsesSkiaNatively ? 1U : 2U; |