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

Unified Diff: ui/gfx/codec/png_codec_unittest.cc

Issue 2944633002: Use SkPngEncoder in gfx jpeg_codec (Closed)
Patch Set: Created 3 years, 6 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
« ui/gfx/codec/png_codec.cc ('K') | « ui/gfx/codec/png_codec.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/codec/png_codec_unittest.cc
diff --git a/ui/gfx/codec/png_codec_unittest.cc b/ui/gfx/codec/png_codec_unittest.cc
index faf665d670847e0536356aa51e075322ad6462f0..986d187d193b88ffe409c176a67dc94ecf6a0e59 100644
--- a/ui/gfx/codec/png_codec_unittest.cc
+++ b/ui/gfx/codec/png_codec_unittest.cc
@@ -286,10 +286,11 @@ TEST(PNGCodec, EncodeDecodeRGBA) {
// encode
std::vector<unsigned char> encoded;
- ASSERT_TRUE(PNGCodec::Encode(&original[0], PNGCodec::FORMAT_RGBA,
- Size(w, h), w * 4, false,
- std::vector<PNGCodec::Comment>(),
- &encoded));
+ SkImageInfo info =
+ SkImageInfo::Make(w, h, kRGBA_8888_SkColorType, kUnpremul_SkAlphaType);
+ SkPixmap src(info, &original[0], w * 4);
+ ASSERT_TRUE(
+ PNGCodec::Encode(src, std::vector<PNGCodec::Comment>(), &encoded));
// decode, it should have the same size as the original
std::vector<unsigned char> decoded;
@@ -315,10 +316,11 @@ TEST(PNGCodec, EncodeDecodeBGRA) {
// Encode.
std::vector<unsigned char> encoded;
- ASSERT_TRUE(PNGCodec::Encode(&original[0], PNGCodec::FORMAT_BGRA,
- Size(w, h), w * 4, false,
- std::vector<PNGCodec::Comment>(),
- &encoded));
+ SkImageInfo info =
+ SkImageInfo::Make(w, h, kBGRA_8888_SkColorType, kUnpremul_SkAlphaType);
+ SkPixmap src(info, &original[0], w * 4);
+ ASSERT_TRUE(
+ PNGCodec::Encode(src, std::vector<PNGCodec::Comment>(), &encoded));
// Decode, it should have the same size as the original.
std::vector<unsigned char> decoded;
@@ -749,9 +751,11 @@ TEST(PNGCodec, DecodeCorrupted) {
// Make some compressed data.
std::vector<unsigned char> compressed;
- ASSERT_TRUE(PNGCodec::Encode(&original[0], PNGCodec::FORMAT_RGBA, Size(w, h),
- w * 4, false, std::vector<PNGCodec::Comment>(),
- &compressed));
+ SkImageInfo info =
+ SkImageInfo::Make(w, h, kRGBA_8888_SkColorType, kUnpremul_SkAlphaType);
+ SkPixmap src(info, &original[0], w * 4);
+ ASSERT_TRUE(
+ PNGCodec::Encode(src, std::vector<PNGCodec::Comment>(), &compressed));
// Try decompressing a truncated version.
EXPECT_FALSE(PNGCodec::Decode(&compressed[0], compressed.size() / 2,
@@ -908,8 +912,10 @@ TEST(PNGCodec, EncodeWithComment) {
comments.push_back(PNGCodec::Comment("key", "text"));
comments.push_back(PNGCodec::Comment("test", "something"));
comments.push_back(PNGCodec::Comment("have some", "spaces in both"));
- EXPECT_TRUE(PNGCodec::Encode(&original[0], PNGCodec::FORMAT_RGBA, Size(w, h),
- w * 4, false, comments, &encoded));
+ SkImageInfo info =
+ SkImageInfo::Make(w, h, kRGBA_8888_SkColorType, kUnpremul_SkAlphaType);
+ SkPixmap src(info, &original[0], w * 4);
+ EXPECT_TRUE(PNGCodec::Encode(src, comments, &encoded));
// Each chunk is of the form length (4 bytes), chunk type (tEXt), data,
// checksum (4 bytes). Make sure we find all of them in the encoded
« ui/gfx/codec/png_codec.cc ('K') | « ui/gfx/codec/png_codec.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698