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

Side by Side Diff: tests/PDFDocumentTest.cpp

Issue 2333713002: change SkStreams to work with sk_sp<SkData> instead of SkData* (Closed)
Patch Set: fix xpsdevice Created 4 years, 3 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 | « tests/CodecTest.cpp ('k') | tests/PDFGlyphsToUnicodeTest.cpp » ('j') | 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 2013 Google Inc. 2 * Copyright 2013 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 #include "Test.h" 7 #include "Test.h"
8 8
9 #include "Resources.h" 9 #include "Resources.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 SkDocument::PDFMetadata pdfMetadata; 186 SkDocument::PDFMetadata pdfMetadata;
187 pdfMetadata.fTitle = "test document"; 187 pdfMetadata.fTitle = "test document";
188 pdfMetadata.fCreation.fEnabled = true; 188 pdfMetadata.fCreation.fEnabled = true;
189 pdfMetadata.fCreation.fDateTime = {0, 1999, 12, 5, 31, 23, 59, 59}; 189 pdfMetadata.fCreation.fDateTime = {0, 1999, 12, 5, 31, 23, 59, 59};
190 190
191 SkDynamicMemoryWStream buffer; 191 SkDynamicMemoryWStream buffer;
192 auto doc = SkDocument::MakePDF(&buffer, SK_ScalarDefaultRasterDPI, 192 auto doc = SkDocument::MakePDF(&buffer, SK_ScalarDefaultRasterDPI,
193 pdfMetadata, nullptr, /* pdfa = */ true); 193 pdfMetadata, nullptr, /* pdfa = */ true);
194 doc->beginPage(64, 64)->drawColor(SK_ColorRED); 194 doc->beginPage(64, 64)->drawColor(SK_ColorRED);
195 doc->close(); 195 doc->close();
196 sk_sp<SkData> data(buffer.copyToData()); 196 sk_sp<SkData> data(buffer.detachAsData());
197 buffer.reset(); 197
198 static const char* expectations[] = { 198 static const char* expectations[] = {
199 "sRGB IEC61966-2.1", 199 "sRGB IEC61966-2.1",
200 "<dc:title><rdf:Alt><rdf:li xml:lang=\"x-default\">test document", 200 "<dc:title><rdf:Alt><rdf:li xml:lang=\"x-default\">test document",
201 "<xmp:CreateDate>1999-12-31T23:59:59+00:00</xmp:CreateDate>", 201 "<xmp:CreateDate>1999-12-31T23:59:59+00:00</xmp:CreateDate>",
202 "/Subtype /XML", 202 "/Subtype /XML",
203 "/CreationDate (D:19991231235959+00'00')>>", 203 "/CreationDate (D:19991231235959+00'00')>>",
204 }; 204 };
205 for (const char* expectation : expectations) { 205 for (const char* expectation : expectations) {
206 if (!contains(data->bytes(), data->size(), expectation)) { 206 if (!contains(data->bytes(), data->size(), expectation)) {
207 ERRORF(r, "PDFA expectation missing: '%s'.", expectation); 207 ERRORF(r, "PDFA expectation missing: '%s'.", expectation);
208 } 208 }
209 } 209 }
210 pdfMetadata.fProducer = "phoney library"; 210 pdfMetadata.fProducer = "phoney library";
211 doc = SkDocument::MakePDF(&buffer, SK_ScalarDefaultRasterDPI, 211 doc = SkDocument::MakePDF(&buffer, SK_ScalarDefaultRasterDPI,
212 pdfMetadata, nullptr, /* pdfa = */ true); 212 pdfMetadata, nullptr, /* pdfa = */ true);
213 doc->beginPage(64, 64)->drawColor(SK_ColorRED); 213 doc->beginPage(64, 64)->drawColor(SK_ColorRED);
214 doc->close(); 214 doc->close();
215 data.reset(buffer.copyToData()); 215 data = buffer.detachAsData();
216 buffer.reset();
217 216
218 static const char* moreExpectations[] = { 217 static const char* moreExpectations[] = {
219 "/Producer (phoney library)", 218 "/Producer (phoney library)",
220 "/ProductionLibrary (Skia/PDF m", 219 "/ProductionLibrary (Skia/PDF m",
221 "<!-- <skia:ProductionLibrary>Skia/PDF m", 220 "<!-- <skia:ProductionLibrary>Skia/PDF m",
222 "<pdf:Producer>phoney library</pdf:Producer>", 221 "<pdf:Producer>phoney library</pdf:Producer>",
223 }; 222 };
224 for (const char* expectation : moreExpectations) { 223 for (const char* expectation : moreExpectations) {
225 if (!contains(data->bytes(), data->size(), expectation)) { 224 if (!contains(data->bytes(), data->size(), expectation)) {
226 ERRORF(r, "PDFA expectation missing: '%s'.", expectation); 225 ERRORF(r, "PDFA expectation missing: '%s'.", expectation);
227 } 226 }
228 } 227 }
229 } 228 }
OLDNEW
« no previous file with comments | « tests/CodecTest.cpp ('k') | tests/PDFGlyphsToUnicodeTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698