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

Side by Side Diff: tests/PDFPrimitivesTest.cpp

Issue 2188623004: SkPDF: SkPDFStream takes a unique_ptr (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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/SkPDFStream.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"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 template <typename T> 76 template <typename T>
77 static void assert_emit_eq(skiatest::Reporter* reporter, 77 static void assert_emit_eq(skiatest::Reporter* reporter,
78 T& object, 78 T& object,
79 const char* string) { 79 const char* string) {
80 SkString result = emit_to_string(object); 80 SkString result = emit_to_string(object);
81 assert_eq(reporter, result, string); 81 assert_eq(reporter, result, string);
82 } 82 }
83 83
84 static void TestPDFStream(skiatest::Reporter* reporter) { 84 static void TestPDFStream(skiatest::Reporter* reporter) {
85 char streamBytes[] = "Test\nFoo\tBar"; 85 char streamBytes[] = "Test\nFoo\tBar";
86 SkAutoTDelete<SkMemoryStream> streamData(new SkMemoryStream( 86 std::unique_ptr<SkStreamAsset> streamData(new SkMemoryStream(
87 streamBytes, strlen(streamBytes), true)); 87 streamBytes, strlen(streamBytes), true));
88 sk_sp<SkPDFStream> stream(new SkPDFStream(streamData.get())); 88 auto stream = sk_make_sp<SkPDFStream>(std::move(streamData));
89 assert_emit_eq(reporter, 89 assert_emit_eq(reporter,
90 *stream, 90 *stream,
91 "<</Length 12>> stream\nTest\nFoo\tBar\nendstream"); 91 "<</Length 12>> stream\nTest\nFoo\tBar\nendstream");
92 stream->insertInt("Attribute", 42); 92 stream->insertInt("Attribute", 42);
93 assert_emit_eq(reporter, 93 assert_emit_eq(reporter,
94 *stream, 94 *stream,
95 "<</Length 12\n/Attribute 42>> stream\n" 95 "<</Length 12\n/Attribute 42>> stream\n"
96 "Test\nFoo\tBar\nendstream"); 96 "Test\nFoo\tBar\nendstream");
97 97
98 { 98 {
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 char buffer[5]; 501 char buffer[5];
502 for (int i = 0; i < 256; ++i) { 502 for (int i = 0; i < 256; ++i) {
503 size_t len = SkPDFUtils::ColorToDecimal(i, buffer); 503 size_t len = SkPDFUtils::ColorToDecimal(i, buffer);
504 REPORTER_ASSERT(reporter, len == strlen(buffer)); 504 REPORTER_ASSERT(reporter, len == strlen(buffer));
505 float f; 505 float f;
506 REPORTER_ASSERT(reporter, 1 == sscanf(buffer, "%f", &f)); 506 REPORTER_ASSERT(reporter, 1 == sscanf(buffer, "%f", &f));
507 int roundTrip = (int)(0.5 + f * 255); 507 int roundTrip = (int)(0.5 + f * 255);
508 REPORTER_ASSERT(reporter, roundTrip == i); 508 REPORTER_ASSERT(reporter, roundTrip == i);
509 } 509 }
510 } 510 }
OLDNEW
« no previous file with comments | « src/pdf/SkPDFStream.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698