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

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

Issue 10799014: Add support for PNG representation in gfx::Image (Closed) Base URL: http://git.chromium.org/chromium/src.git@bookmark-sync
Patch Set: Created 8 years, 5 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
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..d4811bd9e924fe431bd69aed464f7ad390e29025 100644
--- a/ui/gfx/image/image_unittest.cc
+++ b/ui/gfx/image/image_unittest.cc
@@ -93,6 +93,33 @@ TEST_F(ImageTest, SkiaToSkiaRef) {
EXPECT_FALSE(image.HasRepresentation(gt::GetPlatformRepresentationType()));
}
+TEST_F(ImageTest, SkiaToPNGEncodeAndDecode) {
+ gfx::Image image(gt::CreateBitmap(25, 25));
+ const std::vector<unsigned char>* 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 std::vector<unsigned char>* 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;
« ui/gfx/image/image.cc ('K') | « ui/gfx/image/image.cc ('k') | ui/gfx/image/image_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698