diff options
author | 2016-10-10 07:17:32 -0700 | |
---|---|---|
committer | 2016-10-10 07:17:32 -0700 | |
commit | e61b3b4018a3e139e9ae19d2c47dc59deeaedd16 (patch) | |
tree | 7cf305fbccbf5c04f9a9af333692664f53ae4c2a /tests/CodecTest.cpp | |
parent | c46cdd48eb0d04f54ecad8ecfa7b3158090c3a0a (diff) |
Report 0 rowsDecoded for no rows (SkPngCodec interlaced)
incrementalDecode is supposed to report the number of rows decoded. It
failed to if none were decoded (for an interlaced png). Fix the bug and
add a test.
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2402063002
Review-Url: https://codereview.chromium.org/2402063002
Diffstat (limited to 'tests/CodecTest.cpp')
-rw-r--r-- | tests/CodecTest.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/CodecTest.cpp b/tests/CodecTest.cpp index a8f8781ef9..bae8344bad 100644 --- a/tests/CodecTest.cpp +++ b/tests/CodecTest.cpp @@ -1332,3 +1332,32 @@ DEF_TEST(Codec_reusePng, r) { result = codec->getAndroidPixels(info, bm.getPixels(), bm.rowBytes(), &opts); REPORTER_ASSERT(r, result == SkCodec::kSuccess); } + +DEF_TEST(Codec_rowsDecoded, r) { + auto file = "plane_interlaced.png"; + std::unique_ptr<SkStream> stream(GetResourceAsStream(file)); + if (!stream) { + return; + } + + // This is enough to read the header etc, but no rows. + auto data = SkData::MakeFromStream(stream.get(), 99); + std::unique_ptr<SkCodec> codec(SkCodec::NewFromData(data)); + if (!codec) { + ERRORF(r, "Failed to create codec\n"); + return; + } + + auto info = codec->getInfo().makeColorType(kN32_SkColorType); + SkBitmap bm; + bm.allocPixels(info); + auto result = codec->startIncrementalDecode(info, bm.getPixels(), bm.rowBytes()); + REPORTER_ASSERT(r, result == SkCodec::kSuccess); + + // This is an arbitrary value. The important fact is that it is not zero, and rowsDecoded + // should get set to zero by incrementalDecode. + int rowsDecoded = 77; + result = codec->incrementalDecode(&rowsDecoded); + REPORTER_ASSERT(r, result == SkCodec::kIncompleteInput); + REPORTER_ASSERT(r, rowsDecoded == 0); +} |