summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdfdoc_embeddertest.cpp
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2017-09-14 13:41:52 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-09-14 20:42:31 +0000
commit753818af9dbb15a048703dffc11da0b87a2e243a (patch)
tree939098bb54f8f19c88d656f655848c43dcaea598 /fpdfsdk/fpdfdoc_embeddertest.cpp
parent188cf0cfc6b9dabc4454eba17685410e714b3f9d (diff)
downloadpdfium-753818af9dbb15a048703dffc11da0b87a2e243a.tar.xz
Add more FPDF_GetMetaText() tests.
Change-Id: I27d26691a3b7bd8593581483d4a21729040fbe95 Reviewed-on: https://pdfium-review.googlesource.com/13910 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdfdoc_embeddertest.cpp')
-rw-r--r--fpdfsdk/fpdfdoc_embeddertest.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/fpdfsdk/fpdfdoc_embeddertest.cpp b/fpdfsdk/fpdfdoc_embeddertest.cpp
index 781af1e67e..b44a8ecc80 100644
--- a/fpdfsdk/fpdfdoc_embeddertest.cpp
+++ b/fpdfsdk/fpdfdoc_embeddertest.cpp
@@ -216,6 +216,30 @@ TEST_F(FPDFDocEmbeddertest, GetMetaText) {
CFX_WideString::FromUTF16LE(buf, FXSYS_len(kExpectedModDate)));
}
+TEST_F(FPDFDocEmbeddertest, GetMetaTextSameObjectNumber) {
+ ASSERT_TRUE(OpenDocument("annotation_highlight_square_with_ap.pdf"));
+
+ // The PDF has been edited. It has two %%EOF markers, and 2 objects numbered
+ // (1 0). Both objects are /Info dictionaries, but contain different data.
+ // Make sure ModDate is the date of the last modification.
+ unsigned short buf[128];
+ constexpr wchar_t kExpectedModDate[] = L"D:20170612232940-04'00'";
+ ASSERT_EQ(48u, FPDF_GetMetaText(document(), "ModDate", buf, sizeof(buf)));
+ EXPECT_EQ(CFX_WideString(kExpectedModDate),
+ CFX_WideString::FromUTF16LE(buf, FXSYS_len(kExpectedModDate)));
+}
+
+TEST_F(FPDFDocEmbeddertest, GetMetaTextInAttachmentFile) {
+ ASSERT_TRUE(OpenDocument("embedded_attachments.pdf"));
+
+ // Make sure this is the date from the PDF itself and not the attached PDF.
+ unsigned short buf[128];
+ constexpr wchar_t kExpectedModDate[] = L"D:20170712214448-07'00'";
+ ASSERT_EQ(48u, FPDF_GetMetaText(document(), "ModDate", buf, sizeof(buf)));
+ EXPECT_EQ(CFX_WideString(kExpectedModDate),
+ CFX_WideString::FromUTF16LE(buf, FXSYS_len(kExpectedModDate)));
+}
+
TEST_F(FPDFDocEmbeddertest, NoPageLabels) {
EXPECT_TRUE(OpenDocument("about_blank.pdf"));
EXPECT_EQ(1, FPDF_GetPageCount(document()));