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

Unified Diff: tests/PDFDeflateWStreamTest.cpp

Issue 1727153005: SkPDF/Test: detailed error messages in PDFDeflateWStreamTest (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 10 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/PDFDeflateWStreamTest.cpp
diff --git a/tests/PDFDeflateWStreamTest.cpp b/tests/PDFDeflateWStreamTest.cpp
index f4d8dd3730e40955bb86e03a344ac7323987bd28..91c8c3fffe3b0142c1e3ca5ac9f0dca9ae345715 100644
--- a/tests/PDFDeflateWStreamTest.cpp
+++ b/tests/PDFDeflateWStreamTest.cpp
@@ -29,7 +29,7 @@ void skia_free_func(void*, void* address) { sk_free(address); }
* Use the un-deflate compression algorithm to decompress the data in src,
* returning the result. Returns nullptr if an error occurs.
*/
-SkStreamAsset* stream_inflate(SkStream* src) {
+SkStreamAsset* stream_inflate(skiatest::Reporter* reporter, SkStream* src) {
SkDynamicMemoryWStream decompressedDynamicMemoryWStream;
SkWStream* dst = &decompressedDynamicMemoryWStream;
@@ -46,9 +46,10 @@ SkStreamAsset* stream_inflate(SkStream* src) {
flateData.avail_out = kBufferSize;
int rc;
rc = inflateInit(&flateData);
- if (rc != Z_OK)
+ if (rc != Z_OK) {
+ ERRORF(reporter, "Zlib: inflateInit failed");
return nullptr;
-
+ }
uint8_t* input = (uint8_t*)src->getMemoryBase();
size_t inputLength = src->getLength();
if (input == nullptr || inputLength == 0) {
@@ -86,8 +87,10 @@ SkStreamAsset* stream_inflate(SkStream* src) {
while (rc == Z_OK) {
rc = inflate(&flateData, Z_FINISH);
if (flateData.avail_out < kBufferSize) {
- if (!dst->write(outputBuffer, kBufferSize - flateData.avail_out))
+ if (!dst->write(outputBuffer, kBufferSize - flateData.avail_out)) {
+ ERRORF(reporter, "write failed");
return nullptr;
+ }
flateData.next_out = outputBuffer;
flateData.avail_out = kBufferSize;
}
@@ -95,6 +98,7 @@ SkStreamAsset* stream_inflate(SkStream* src) {
inflateEnd(&flateData);
if (rc != Z_STREAM_END) {
+ ERRORF(reporter, "Zlib: inflateEnd failed");
return nullptr;
}
return decompressedDynamicMemoryWStream.detachAsStream();
@@ -126,8 +130,12 @@ DEF_TEST(SkDeflateWStream, r) {
}
SkAutoTDelete<SkStreamAsset> compressed(
dynamicMemoryWStream.detachAsStream());
- SkAutoTDelete<SkStreamAsset> decompressed(stream_inflate(compressed));
+ SkAutoTDelete<SkStreamAsset> decompressed(stream_inflate(r, compressed));
+ if (!decompressed) {
+ ERRORF(r, "Decompression failed.");
+ return;
+ }
if (decompressed->getLength() != size) {
ERRORF(r, "Decompression failed to get right size [%d]."
" %u != %u", i, (unsigned)(decompressed->getLength()),
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698