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

Side by Side Diff: tests/PDFPrimitivesTest.cpp

Issue 2190883003: SkPDF: PDFStream has-a not is-a PDFDict (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2016-07-29 (Friday) 12:30:20 EDT Created 4 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
« no previous file with comments | « src/pdf/SkPDFTypes.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "Resources.h" 8 #include "Resources.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
11 #include "SkData.h" 11 #include "SkData.h"
12 #include "SkDocument.h" 12 #include "SkDocument.h"
13 #include "SkDeflate.h" 13 #include "SkDeflate.h"
14 #include "SkImageEncoder.h" 14 #include "SkImageEncoder.h"
15 #include "SkMatrix.h" 15 #include "SkMatrix.h"
16 #include "SkPDFCanon.h" 16 #include "SkPDFCanon.h"
17 #include "SkPDFDevice.h" 17 #include "SkPDFDevice.h"
18 #include "SkPDFFont.h" 18 #include "SkPDFFont.h"
19 #include "SkPDFStream.h"
20 #include "SkPDFTypes.h" 19 #include "SkPDFTypes.h"
21 #include "SkPDFUtils.h" 20 #include "SkPDFUtils.h"
22 #include "SkReadBuffer.h" 21 #include "SkReadBuffer.h"
23 #include "SkScalar.h" 22 #include "SkScalar.h"
24 #include "SkSpecialImage.h" 23 #include "SkSpecialImage.h"
25 #include "SkStream.h" 24 #include "SkStream.h"
26 #include "SkTypes.h" 25 #include "SkTypes.h"
27 #include "Test.h" 26 #include "Test.h"
28 #include "sk_tool_utils.h" 27 #include "sk_tool_utils.h"
29 28
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 } 81 }
83 82
84 static void TestPDFStream(skiatest::Reporter* reporter) { 83 static void TestPDFStream(skiatest::Reporter* reporter) {
85 char streamBytes[] = "Test\nFoo\tBar"; 84 char streamBytes[] = "Test\nFoo\tBar";
86 std::unique_ptr<SkStreamAsset> streamData(new SkMemoryStream( 85 std::unique_ptr<SkStreamAsset> streamData(new SkMemoryStream(
87 streamBytes, strlen(streamBytes), true)); 86 streamBytes, strlen(streamBytes), true));
88 auto stream = sk_make_sp<SkPDFStream>(std::move(streamData)); 87 auto stream = sk_make_sp<SkPDFStream>(std::move(streamData));
89 assert_emit_eq(reporter, 88 assert_emit_eq(reporter,
90 *stream, 89 *stream,
91 "<</Length 12>> stream\nTest\nFoo\tBar\nendstream"); 90 "<</Length 12>> stream\nTest\nFoo\tBar\nendstream");
92 stream->insertInt("Attribute", 42); 91 stream->dict()->insertInt("Attribute", 42);
93 assert_emit_eq(reporter, 92 assert_emit_eq(reporter,
94 *stream, 93 *stream,
95 "<</Length 12\n/Attribute 42>> stream\n" 94 "<</Length 12\n/Attribute 42>> stream\n"
96 "Test\nFoo\tBar\nendstream"); 95 "Test\nFoo\tBar\nendstream");
97 96
98 { 97 {
99 char streamBytes2[] = "This is a longer string, so that compression " 98 char streamBytes2[] = "This is a longer string, so that compression "
100 "can do something with it. With shorter strings, " 99 "can do something with it. With shorter strings, "
101 "the short circuit logic cuts in and we end up " 100 "the short circuit logic cuts in and we end up "
102 "with an uncompressed string."; 101 "with an uncompressed string.";
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 char buffer[5]; 499 char buffer[5];
501 for (int i = 0; i < 256; ++i) { 500 for (int i = 0; i < 256; ++i) {
502 size_t len = SkPDFUtils::ColorToDecimal(i, buffer); 501 size_t len = SkPDFUtils::ColorToDecimal(i, buffer);
503 REPORTER_ASSERT(reporter, len == strlen(buffer)); 502 REPORTER_ASSERT(reporter, len == strlen(buffer));
504 float f; 503 float f;
505 REPORTER_ASSERT(reporter, 1 == sscanf(buffer, "%f", &f)); 504 REPORTER_ASSERT(reporter, 1 == sscanf(buffer, "%f", &f));
506 int roundTrip = (int)(0.5 + f * 255); 505 int roundTrip = (int)(0.5 + f * 255);
507 REPORTER_ASSERT(reporter, roundTrip == i); 506 REPORTER_ASSERT(reporter, roundTrip == i);
508 } 507 }
509 } 508 }
OLDNEW
« no previous file with comments | « src/pdf/SkPDFTypes.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698