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..43cddb695b4521b3832bce3db13e230feda97049 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, fell_back_to_1x should be false. |
+ SkBitmap decompressed; |
+ bool fell_back_to_1x = true; |
+ EXPECT_TRUE(PNGCodec::Decode(&compressed[0], compressed.size(), |
+ &decompressed, &fell_back_to_1x)); |
+ EXPECT_FALSE(fell_back_to_1x); |
+ |
+ // With the custom chunk, fell_back_to_1x should be true. |
+ compressed.insert(compressed.end() - 12, |
+ png_scale_chunk, png_scale_chunk + sizeof(png_scale_chunk)); |
+ fell_back_to_1x = false; |
+ EXPECT_TRUE(PNGCodec::Decode(&compressed[0], compressed.size(), |
+ &decompressed, &fell_back_to_1x)); |
+ EXPECT_TRUE(fell_back_to_1x); |
+} |
+ |
} // namespace gfx |