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

Unified Diff: tests/CodexTest.cpp

Issue 1385703002: SkScaledCodec should implement onRewind() (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 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/SkScaledCodec.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/CodexTest.cpp
diff --git a/tests/CodexTest.cpp b/tests/CodexTest.cpp
index f1c5bbaa128e1c989bf06af39f27f7a22e211864..7fb95bc1afb9ce3850a47e7b1d1c0fb447bc2f46 100644
--- a/tests/CodexTest.cpp
+++ b/tests/CodexTest.cpp
@@ -220,6 +220,40 @@ static void check(skiatest::Reporter* r,
REPORTER_ASSERT(r, result == SkCodec::kUnimplemented);
}
}
+
+ // SkScaledCodec tests
+ {
+ SkAutoTDelete<SkStream> stream(resource(path));
+ if (!stream) {
+ SkDebugf("Missing resource '%s'\n", path);
+ return;
+ }
+ SkAutoTDelete<SkCodec> codec(SkScaledCodec::NewFromStream(stream.detach()));
+ if (!codec) {
+ ERRORF(r, "Unable to decode '%s'", path);
+ return;
+ }
+
+ SkImageInfo info = codec->getInfo().makeColorType(kN32_SkColorType);
+ REPORTER_ASSERT(r, info.dimensions() == size);
+
+ // FIXME: We will be able to run this test on ICOs as well, after we have implemented
+ // scanline decoding for ICO.
+ if (SkEncodedFormat::kICO_SkEncodedFormat != codec->getEncodedFormat()) {
scroggo 2015/10/02 20:56:06 Another way you could do this - not sure if it's b
msarett 2015/10/05 14:26:51 Done.
+ SkBitmap bm;
+ bm.allocPixels(info);
+ SkAutoLockPixels autoLockPixels(bm);
+ SkCodec::Result result =
+ codec->getPixels(info, bm.getPixels(), bm.rowBytes(), nullptr, nullptr, nullptr);
scroggo 2015/10/02 20:56:06 nit: This is copied and pasted, so I know it's the
msarett 2015/10/05 14:26:51 I will refactor into a different method and check
+ REPORTER_ASSERT(r, result == SkCodec::kSuccess);
+
+ SkMD5::Digest digest;
+ md5(bm, &digest);
+
+ // Verify that re-decoding gives the same result.
+ test_info(r, codec, info, SkCodec::kSuccess, &digest);
+ }
+ }
}
DEF_TEST(Codec, r) {
« no previous file with comments | « src/codec/SkScaledCodec.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698