| OLD | NEW |
| 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 Loading... |
| 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 } |
| OLD | NEW |