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

Unified Diff: tests/CodexTest.cpp

Issue 1473673005: Support wbmp that are supported by SkImageDecoder (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 1 month 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/SkCodec_wbmp.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 b53cbe1a4d7dd6c468af08f678f4b27087e91be6..697ba749f70861d9678a19894622dff8ec1ed8bf 100644
--- a/tests/CodexTest.cpp
+++ b/tests/CodexTest.cpp
@@ -10,9 +10,11 @@
#include "SkBitmap.h"
#include "SkCodec.h"
#include "SkData.h"
+#include "SkImageDecoder.h"
#include "SkMD5.h"
#include "SkRandom.h"
#include "SkStream.h"
+#include "SkStreamPriv.h"
#include "SkPngChunkReader.h"
#include "Test.h"
@@ -845,3 +847,33 @@ DEF_TEST(Codec_pngChunkReader, r) {
REPORTER_ASSERT(r, chunkReader.allHaveBeenSeen());
}
#endif // PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
+
+// SkCodec's wbmp decoder was initially more restrictive than SkImageDecoder.
+// It required the second byte to be zero. But SkImageDecoder allowed a couple
+// of bits to be 1 (so long as they do not overlap with 0x9F). Test that
+// SkCodec now supports an image with these bits set.
+DEF_TEST(Codec_wbmp, r) {
+ const char* path = "mandrill.wbmp";
msarett 2015/11/30 13:24:55 Did we fail on this image before you made this cha
scroggo 2015/11/30 13:48:13 No. See below - I had to modify the image to make
msarett 2015/11/30 14:00:44 My mistake, it's perfectly clear.
+ SkAutoTDelete<SkStream> stream(resource(path));
+ if (!stream) {
+ SkDebugf("Missing resource '%s'\n", path);
+ return;
+ }
+
+ // Modify the stream to contain a second byte with some bits set.
+ SkAutoTUnref<SkData> data(SkCopyStreamToData(stream));
+ uint8_t* writeableData = static_cast<uint8_t*>(data->writable_data());
+ writeableData[1] = static_cast<uint8_t>(~0x9F);
+
+ // SkImageDecoder supports this.
+ SkBitmap bitmap;
+ REPORTER_ASSERT(r, SkImageDecoder::DecodeMemory(data->data(), data->size(), &bitmap));
+
+ // So SkCodec should, too.
+ SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(data));
+ REPORTER_ASSERT(r, codec);
+ if (!codec) {
+ return;
+ }
+ test_info(r, codec, codec->getInfo(), SkCodec::kSuccess, nullptr);
+}
« no previous file with comments | « src/codec/SkCodec_wbmp.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698