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

Side by Side Diff: tests/PDFPrimitivesTest.cpp

Issue 1298243002: SkPDF/Deflate: clean up old SkFlate code (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-18 (Tuesday) 16:19:01 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2010 The Android Open Source Project 2 * Copyright 2010 The Android Open Source Project
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 "SkBitmap.h" 8 #include "SkBitmap.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkData.h" 10 #include "SkData.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 { 92 {
93 char streamBytes2[] = "This is a longer string, so that compression " 93 char streamBytes2[] = "This is a longer string, so that compression "
94 "can do something with it. With shorter strings, " 94 "can do something with it. With shorter strings, "
95 "the short circuit logic cuts in and we end up " 95 "the short circuit logic cuts in and we end up "
96 "with an uncompressed string."; 96 "with an uncompressed string.";
97 SkAutoDataUnref streamData2(SkData::NewWithCopy(streamBytes2, 97 SkAutoDataUnref streamData2(SkData::NewWithCopy(streamBytes2,
98 strlen(streamBytes2))); 98 strlen(streamBytes2)));
99 SkAutoTUnref<SkPDFStream> stream(new SkPDFStream(streamData2.get())); 99 SkAutoTUnref<SkPDFStream> stream(new SkPDFStream(streamData2.get()));
100 100
101 SkDynamicMemoryWStream compressedByteStream; 101 SkDynamicMemoryWStream compressedByteStream;
102 SkFlate::Deflate(streamData2.get(), &compressedByteStream); 102 SkDeflateWStream deflateWStream(&compressedByteStream);
103 SkAutoDataUnref compressedData(compressedByteStream.copyToData()); 103 deflateWStream.write(streamBytes2, strlen(streamBytes2));
104 deflateWStream.finalize();
104 105
105 SkDynamicMemoryWStream expected; 106 SkDynamicMemoryWStream expected;
106 expected.writeText("<</Filter /FlateDecode\n/Length 116>> stream\n"); 107 expected.writeText("<</Filter /FlateDecode\n/Length 116>> stream\n");
107 expected.write(compressedData->data(), compressedData->size()); 108 compressedByteStream.writeToStream(&expected);
109 compressedByteStream.reset();
108 expected.writeText("\nendstream"); 110 expected.writeText("\nendstream");
109 SkAutoDataUnref expectedResultData2(expected.copyToData()); 111 SkAutoDataUnref expectedResultData2(expected.copyToData());
110 SkString result = emit_to_string(*stream); 112 SkString result = emit_to_string(*stream);
111 ASSERT_EQL(reporter, 113 ASSERT_EQL(reporter,
112 result, 114 result,
113 (const char*)expectedResultData2->data(), 115 (const char*)expectedResultData2->data(),
114 expectedResultData2->size()); 116 expectedResultData2->size());
115 } 117 }
116 } 118 }
117 119
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 // Filter just created; should be unvisited. 408 // Filter just created; should be unvisited.
407 REPORTER_ASSERT(reporter, !filter->visited()); 409 REPORTER_ASSERT(reporter, !filter->visited());
408 SkPaint paint; 410 SkPaint paint;
409 paint.setImageFilter(filter.get()); 411 paint.setImageFilter(filter.get());
410 canvas->drawRect(SkRect::MakeWH(100, 100), paint); 412 canvas->drawRect(SkRect::MakeWH(100, 100), paint);
411 doc->close(); 413 doc->close();
412 414
413 // Filter was used in rendering; should be visited. 415 // Filter was used in rendering; should be visited.
414 REPORTER_ASSERT(reporter, filter->visited()); 416 REPORTER_ASSERT(reporter, filter->visited());
415 } 417 }
OLDNEW
« no previous file with comments | « tests/PDFFlateTest.cpp ('k') | tests/StreamTest.cpp » ('j') | tests/StreamTest.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698