| 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 83f535e6ae3e4d7a0180b516ca5cbda7516d34b1..c7b5b80995dc8cd1e8d0714172546e1c72b4cdba 100644
|
| --- a/ui/gfx/codec/png_codec_unittest.cc
|
| +++ b/ui/gfx/codec/png_codec_unittest.cc
|
| @@ -909,7 +909,7 @@ TEST(PNGCodec, DecodeCorrupted) {
|
| std::vector<unsigned char> original;
|
| MakeRGBImage(w, h, &original);
|
|
|
| - // It should fail when given non-JPEG compressed data.
|
| + // It should fail when given non-PNG compressed data.
|
| std::vector<unsigned char> output;
|
| int outw, outh;
|
| EXPECT_FALSE(PNGCodec::Decode(&original[0], original.size(),
|
| @@ -1129,5 +1129,32 @@ TEST(PNGCodec, EncodeDecodeWithVaryingCompressionLevels) {
|
| ASSERT_TRUE(original == decoded);
|
| }
|
|
|
| +TEST(PNGCodec, CustomScaleChunkDetection) {
|
| + const int w = 20, h = 20;
|
| + static const unsigned char png_scale_chunk[12] =
|
| + { 0, 0, 0, 0, 'c', 's', 'C', 'l', 0xc1, 0x30, 0x60, 0x4d };
|
| +
|
| + // Compress some random data.
|
| + SkBitmap original;
|
| + std::vector<unsigned char> compressed;
|
| + MakeTestSkBitmap(w, h, &original);
|
| + PNGCodec::EncodeBGRASkBitmap(original, false, &compressed);
|
| +
|
| + // Without the custom chunk, scale_fallback should be false.
|
| + SkBitmap decompressed;
|
| + bool scale_fallback = true;
|
| + EXPECT_TRUE(PNGCodec::Decode(&compressed[0], compressed.size(),
|
| + &decompressed, &scale_fallback));
|
| + EXPECT_FALSE(scale_fallback);
|
| +
|
| + // With the custom chunk, scale_fallback should be true.
|
| + compressed.insert(compressed.end() - 12,
|
| + png_scale_chunk, png_scale_chunk + sizeof(png_scale_chunk));
|
| + scale_fallback = false;
|
| + EXPECT_TRUE(PNGCodec::Decode(&compressed[0], compressed.size(),
|
| + &decompressed, &scale_fallback));
|
| + EXPECT_TRUE(scale_fallback);
|
| +}
|
| +
|
|
|
| } // namespace gfx
|
|
|