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

Side by Side Diff: tests/PDFDeflateWStreamTest.cpp

Issue 1298243002: SkPDF/Deflate: clean up old SkFlate code (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 4 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkDeflate.h" 8 #include "SkDeflate.h"
9 #include "SkRandom.h" 9 #include "SkRandom.h"
10 #include "Test.h" 10 #include "Test.h"
(...skipping 16 matching lines...) Expand all
27 SkTMin(size - j, random.nextRangeU(1, 400)); 27 SkTMin(size - j, random.nextRangeU(1, 400));
28 if (!deflateWStream.write(&buffer[j], writeSize)) { 28 if (!deflateWStream.write(&buffer[j], writeSize)) {
29 ERRORF(r, "something went wrong."); 29 ERRORF(r, "something went wrong.");
30 return; 30 return;
31 } 31 }
32 j += writeSize; 32 j += writeSize;
33 } 33 }
34 } 34 }
35 SkAutoTDelete<SkStreamAsset> compressed( 35 SkAutoTDelete<SkStreamAsset> compressed(
36 dynamicMemoryWStream.detachAsStream()); 36 dynamicMemoryWStream.detachAsStream());
37 37 SkAutoTDelete<SkStreamAsset> decompressed(SkInflate(compressed));
38 SkDynamicMemoryWStream decompressedDynamicMemoryWStream;
39 SkAssertResult(SkFlate::Inflate(compressed,
40 &decompressedDynamicMemoryWStream));
41
42 SkAutoTDelete<SkStreamAsset> decompressed(
43 decompressedDynamicMemoryWStream.detachAsStream());
44 38
45 if (decompressed->getLength() != size) { 39 if (decompressed->getLength() != size) {
46 ERRORF(r, "Decompression failed to get right size [%d]." 40 ERRORF(r, "Decompression failed to get right size [%d]."
47 " %u != %u", i, (unsigned)(decompressed->getLength()), 41 " %u != %u", i, (unsigned)(decompressed->getLength()),
48 (unsigned)size); 42 (unsigned)size);
49 SkString s = SkStringPrintf("/tmp/deftst_compressed_%d", i); 43 SkString s = SkStringPrintf("/tmp/deftst_compressed_%d", i);
50 SkFILEWStream o(s.c_str()); 44 SkFILEWStream o(s.c_str());
51 o.writeStream(compressed.get(), compressed->getLength()); 45 o.writeStream(compressed.get(), compressed->getLength());
52 compressed->rewind(); 46 compressed->rewind();
53 47
54 s = SkStringPrintf("/tmp/deftst_input_%d", i); 48 s = SkStringPrintf("/tmp/deftst_input_%d", i);
55 SkFILEWStream o2(s.c_str()); 49 SkFILEWStream o2(s.c_str());
56 o2.write(&buffer[0], size); 50 o2.write(&buffer[0], size);
57 51
58 continue; 52 continue;
59 } 53 }
60 uint32_t minLength = SkTMin(size, 54 uint32_t minLength = SkTMin(size,
61 (uint32_t)(decompressed->getLength())); 55 (uint32_t)(decompressed->getLength()));
62 for (uint32_t i = 0; i < minLength; ++i) { 56 for (uint32_t i = 0; i < minLength; ++i) {
63 uint8_t c; 57 uint8_t c;
64 SkDEBUGCODE(size_t rb =)decompressed->read(&c, sizeof(uint8_t)); 58 SkDEBUGCODE(size_t rb =)decompressed->read(&c, sizeof(uint8_t));
65 SkASSERT(sizeof(uint8_t) == rb); 59 SkASSERT(sizeof(uint8_t) == rb);
66 if (buffer[i] != c) { 60 if (buffer[i] != c) {
67 ERRORF(r, "Decompression failed at byte %u.", (unsigned)i); 61 ERRORF(r, "Decompression failed at byte %u.", (unsigned)i);
68 break; 62 break;
69 } 63 }
70 } 64 }
71 } 65 }
72 } 66 }
OLDNEW
« src/pdf/SkDeflate.cpp ('K') | « src/pdf/SkPDFStream.cpp ('k') | tests/PDFFlateTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698