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

Unified Diff: tests/PDFMetadataAttributeTest.cpp

Issue 1916093002: SkDocument/PDF: new API (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2016-04-26 (Tuesday) 15:55:33 EDT Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/PDFJpegEmbedTest.cpp ('k') | tests/PDFOpaqueSrcModeToSrcOverTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/PDFMetadataAttributeTest.cpp
diff --git a/tests/PDFMetadataAttributeTest.cpp b/tests/PDFMetadataAttributeTest.cpp
index 6a5aca76f73b5301cbcd8d2ff037f25b7b407e7e..2d43d30d7ca19ad6e18b800e43734cce010cee2b 100644
--- a/tests/PDFMetadataAttributeTest.cpp
+++ b/tests/PDFMetadataAttributeTest.cpp
@@ -9,22 +9,24 @@
#include "SkData.h"
#include "Test.h"
-DEF_TEST(SkPDF_MetadataAttribute, r) {
- REQUIRE_PDF_DOCUMENT(SkPDF_MetadataAttribute, r);
- SkDynamicMemoryWStream pdf;
- SkAutoTUnref<SkDocument> doc(SkDocument::CreatePDF(&pdf));
- typedef SkDocument::Attribute Attr;
- Attr info[] = {
- Attr(SkString("Title"), SkString("A1")),
- Attr(SkString("Author"), SkString("A2")),
- Attr(SkString("Subject"), SkString("A3")),
- Attr(SkString("Keywords"), SkString("A4")),
- Attr(SkString("Creator"), SkString("A5")),
- };
- int infoCount = sizeof(info) / sizeof(info[0]);
+DEF_TEST(SkPDF_Metadata, r) {
+ REQUIRE_PDF_DOCUMENT(SkPDF_Metadata, r);
SkTime::DateTime now;
SkTime::GetDateTime(&now);
- doc->setMetadata(&info[0], infoCount, &now, &now);
+ SkDocument::PDFMetadata metadata;
+ metadata.fTitle = "A1";
+ metadata.fAuthor = "A2";
+ metadata.fSubject = "A3";
+ metadata.fKeywords = "A4";
+ metadata.fCreator = "A5";
+ metadata.fCreation.fEnabled = true;
+ metadata.fCreation.fDateTime = now;
+ metadata.fModified.fEnabled = true;
+ metadata.fModified.fDateTime = now;
+
+ SkDynamicMemoryWStream pdf;
+ sk_sp<SkDocument> doc = SkDocument::MakePDF(&pdf, SK_ScalarDefaultRasterDPI,
+ metadata, nullptr, false);
doc->beginPage(612.0f, 792.0f);
doc->close();
SkAutoTUnref<SkData> data(pdf.copyToData());
@@ -38,12 +40,13 @@ DEF_TEST(SkPDF_MetadataAttribute, r) {
"/CreationDate (D:",
"/ModDate (D:"
};
+ const uint8_t* bytes = data->bytes();
for (const char* expectation : expectations) {
+ size_t len = strlen(expectation);
bool found = false;
- size_t N = 1 + data->size() - strlen(expectation);
+ size_t N = 1 + data->size() - len;
for (size_t i = 0; i < N; ++i) {
- if (0 == memcmp(data->bytes() + i,
- expectation, strlen(expectation))) {
+ if (0 == memcmp(bytes + i, expectation, len)) {
found = true;
break;
}
« no previous file with comments | « tests/PDFJpegEmbedTest.cpp ('k') | tests/PDFOpaqueSrcModeToSrcOverTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698