diff options
author | Tom Sepez <tsepez@chromium.org> | 2016-01-04 16:35:52 -0800 |
---|---|---|
committer | Tom Sepez <tsepez@chromium.org> | 2016-01-04 16:35:52 -0800 |
commit | 0861c161376074bce453de31fdf96e120c482696 (patch) | |
tree | ee6b2e0f8c127a0cd5bbfe1cee9598b59aa6993a /fpdfsdk/src/fpdfdoc_embeddertest.cpp | |
parent | fad30ca54e059602b5b4b56cb2dcb8be53d703e2 (diff) | |
download | pdfium-0861c161376074bce453de31fdf96e120c482696.tar.xz |
Merge to XFA: Cover FPDFBookmark_Find() with embedder tests.
Original Review URL: https://codereview.chromium.org/1559043006 .
(cherry picked from commit 5dac8047f02c937a5a3546a8cc5b352db2188d97)
TBR=thestig@chromium.org
Review URL: https://codereview.chromium.org/1553313002 .
Diffstat (limited to 'fpdfsdk/src/fpdfdoc_embeddertest.cpp')
-rw-r--r-- | fpdfsdk/src/fpdfdoc_embeddertest.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/fpdfsdk/src/fpdfdoc_embeddertest.cpp b/fpdfsdk/src/fpdfdoc_embeddertest.cpp index 6435704cb2..38a366268c 100644 --- a/fpdfsdk/src/fpdfdoc_embeddertest.cpp +++ b/fpdfsdk/src/fpdfdoc_embeddertest.cpp @@ -99,3 +99,22 @@ TEST_F(FPDFDocEmbeddertest, Bookmarks) { EXPECT_EQ(nullptr, FPDFBookmark_GetNextSibling(document(), sibling)); } + +TEST_F(FPDFDocEmbeddertest, FindBookmarks) { + // Open a file with two bookmarks, and extract the first. + EXPECT_TRUE(OpenDocument("bookmarks.pdf")); + + unsigned short buf[128]; + FPDF_BOOKMARK child = FPDFBookmark_GetFirstChild(document(), nullptr); + EXPECT_NE(nullptr, child); + EXPECT_EQ(34, FPDFBookmark_GetTitle(child, buf, sizeof(buf))); + EXPECT_EQ(CFX_WideString(L"A Good Beginning"), + CFX_WideString::FromUTF16LE(buf, 16)); + + // Find the same one again using the title. + EXPECT_EQ(child, FPDFBookmark_Find(document(), buf)); + + // Try to find one using a non-existent title. + buf[0] = 'X'; + EXPECT_EQ(nullptr, FPDFBookmark_Find(document(), buf)); +} |