summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2016-01-04 16:29:51 -0800
committerTom Sepez <tsepez@chromium.org>2016-01-04 16:29:51 -0800
commit5dac8047f02c937a5a3546a8cc5b352db2188d97 (patch)
tree5fb950cab5f04dee11964efcd1967f20a507a8c9 /fpdfsdk
parent14fdb1d40741912e430db4318a9033764429659f (diff)
downloadpdfium-5dac8047f02c937a5a3546a8cc5b352db2188d97.tar.xz
Cover FPDFBookmark_Find() with embedder tests.
R=thestig@chromium.org Review URL: https://codereview.chromium.org/1559043006 .
Diffstat (limited to 'fpdfsdk')
-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));
+}