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

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..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;

Powered by Google App Engine
This is Rietveld 408576698