From 0861c161376074bce453de31fdf96e120c482696 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Mon, 4 Jan 2016 16:35:52 -0800 Subject: 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 . --- fpdfsdk/src/fpdfdoc_embeddertest.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'fpdfsdk/src') 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)); +} -- cgit v1.2.3