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

Unified Diff: tests/CodecTest.cpp

Issue 2402063002: Report 0 rowsDecoded for no rows (SkPngCodec interlaced) (Closed)
Patch Set: rebase Created 4 years, 2 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
« no previous file with comments | « src/codec/SkPngCodec.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/CodecTest.cpp
diff --git a/tests/CodecTest.cpp b/tests/CodecTest.cpp
index a8f8781ef91f99442d700fb8fe4e0a33b00dbb88..bae8344bad631d5e6e4102ad561f2d911b455b03 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);
+}
« no previous file with comments | « src/codec/SkPngCodec.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698