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

Unified Diff: tests/DeflateWStream.cpp

Issue 1278403006: SkPDF: clean up overuse of SK_SUPPORT_PDF (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-11 (Tuesday) 16:25:36 EDT 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/CanvasTest.cpp ('k') | tests/DocumentTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/DeflateWStream.cpp
diff --git a/tests/DeflateWStream.cpp b/tests/DeflateWStream.cpp
deleted file mode 100644
index 930ecb41441d55a3358845e7e7d22d3226dc72ee..0000000000000000000000000000000000000000
--- a/tests/DeflateWStream.cpp
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright 2015 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "SkFlate.h"
-#include "SkRandom.h"
-#include "Test.h"
-
-#if SK_SUPPORT_PDF
-
-DEF_TEST(SkDeflateWStream, r) {
- SkRandom random(123456);
- for (int i = 0; i < 50; ++i) {
- uint32_t size = random.nextULessThan(10000);
- SkAutoTMalloc<uint8_t> buffer(size);
- for (uint32_t j = 0; j < size; ++j) {
- buffer[j] = random.nextU() & 0xff;
- }
-
- SkDynamicMemoryWStream dynamicMemoryWStream;
- {
- SkDeflateWStream deflateWStream(&dynamicMemoryWStream);
- uint32_t j = 0;
- while (j < size) {
- uint32_t writeSize =
- SkTMin(size - j, random.nextRangeU(1, 400));
- if (!deflateWStream.write(&buffer[j], writeSize)) {
- ERRORF(r, "something went wrong.");
- return;
- }
- j += writeSize;
- }
- }
- SkAutoTDelete<SkStreamAsset> compressed(
- dynamicMemoryWStream.detachAsStream());
-
- SkDynamicMemoryWStream decompressedDynamicMemoryWStream;
- SkAssertResult(SkFlate::Inflate(compressed,
- &decompressedDynamicMemoryWStream));
-
- SkAutoTDelete<SkStreamAsset> decompressed(
- decompressedDynamicMemoryWStream.detachAsStream());
-
- if (decompressed->getLength() != size) {
- ERRORF(r, "Decompression failed to get right size [%d]."
- " %u != %u", i, (unsigned)(decompressed->getLength()),
- (unsigned)size);
- SkString s = SkStringPrintf("/tmp/deftst_compressed_%d", i);
- SkFILEWStream o(s.c_str());
- o.writeStream(compressed.get(), compressed->getLength());
- compressed->rewind();
-
- s = SkStringPrintf("/tmp/deftst_input_%d", i);
- SkFILEWStream o2(s.c_str());
- o2.write(&buffer[0], size);
-
- continue;
- }
- uint32_t minLength = SkTMin(size,
- (uint32_t)(decompressed->getLength()));
- for (uint32_t i = 0; i < minLength; ++i) {
- uint8_t c;
- SkDEBUGCODE(size_t rb =)decompressed->read(&c, sizeof(uint8_t));
- SkASSERT(sizeof(uint8_t) == rb);
- if (buffer[i] != c) {
- ERRORF(r, "Decompression failed at byte %u.", (unsigned)i);
- break;
- }
- }
- }
-}
-#endif // SK_SUPPORT_PDF
« no previous file with comments | « tests/CanvasTest.cpp ('k') | tests/DocumentTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698