summaryrefslogtreecommitdiff
path: root/fpdfsdk/src
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk/src')
-rw-r--r--fpdfsdk/src/fpdfdoc_embeddertest.cpp19
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));
+}