Improve embedder test coverage of FPDFBookmark_GetDest()/GetAction().
Pass an actual object instead of nullptr.
- Remove uncalled method.
- Remove duplicate nullptr test case.
- Move buffer decls to first line of test since it looks better.
Change-Id: Icb006f26040efb575d1ab84e05c55c43f0f0b26d
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/62690
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfdoc/cpdf_bookmark.cpp b/core/fpdfdoc/cpdf_bookmark.cpp
index 96752af..b08fba5 100644
--- a/core/fpdfdoc/cpdf_bookmark.cpp
+++ b/core/fpdfdoc/cpdf_bookmark.cpp
@@ -24,10 +24,6 @@
CPDF_Bookmark::~CPDF_Bookmark() = default;
-uint32_t CPDF_Bookmark::GetFontStyle() const {
- return m_pDict ? m_pDict->GetIntegerFor("F") : 0;
-}
-
WideString CPDF_Bookmark::GetTitle() const {
if (!m_pDict)
return WideString();
diff --git a/core/fpdfdoc/cpdf_bookmark.h b/core/fpdfdoc/cpdf_bookmark.h
index 400b869..b185c03 100644
--- a/core/fpdfdoc/cpdf_bookmark.h
+++ b/core/fpdfdoc/cpdf_bookmark.h
@@ -24,7 +24,6 @@
const CPDF_Dictionary* GetDict() const { return m_pDict.Get(); }
- uint32_t GetFontStyle() const;
WideString GetTitle() const;
CPDF_Dest GetDest(CPDF_Document* pDocument) const;
CPDF_Action GetAction() const;
diff --git a/fpdfsdk/fpdf_doc_embeddertest.cpp b/fpdfsdk/fpdf_doc_embeddertest.cpp
index a421fd0..84712ed 100644
--- a/fpdfsdk/fpdf_doc_embeddertest.cpp
+++ b/fpdfsdk/fpdf_doc_embeddertest.cpp
@@ -349,14 +349,13 @@
}
TEST_F(FPDFDocEmbedderTest, NoBookmarks) {
+ unsigned short buf[128];
+
// Open a file with no bookmarks.
EXPECT_TRUE(OpenDocument("named_dests.pdf"));
- // The non-existent top-level bookmark has no title.
- unsigned short buf[128];
- EXPECT_EQ(0u, FPDFBookmark_GetTitle(nullptr, buf, sizeof(buf)));
-
// NULL argument cases.
+ EXPECT_EQ(0u, FPDFBookmark_GetTitle(nullptr, buf, sizeof(buf)));
EXPECT_EQ(nullptr, FPDFBookmark_GetFirstChild(nullptr, nullptr));
EXPECT_EQ(nullptr, FPDFBookmark_GetFirstChild(document(), nullptr));
EXPECT_EQ(nullptr, FPDFBookmark_GetNextSibling(nullptr, nullptr));
@@ -369,19 +368,24 @@
}
TEST_F(FPDFDocEmbedderTest, Bookmarks) {
+ unsigned short buf[128];
+
// Open a file with two bookmarks.
EXPECT_TRUE(OpenDocument("bookmarks.pdf"));
- // The existent top-level bookmark has no title.
- unsigned short buf[128];
- EXPECT_EQ(0u, FPDFBookmark_GetTitle(nullptr, buf, sizeof(buf)));
-
FPDF_BOOKMARK child = FPDFBookmark_GetFirstChild(document(), nullptr);
EXPECT_TRUE(child);
EXPECT_EQ(34u, FPDFBookmark_GetTitle(child, buf, sizeof(buf)));
EXPECT_EQ(WideString(L"A Good Beginning"), WideString::FromUTF16LE(buf, 16));
- EXPECT_EQ(nullptr, FPDFBookmark_GetFirstChild(document(), child));
+ FPDF_DEST dest = FPDFBookmark_GetDest(document(), child);
+ EXPECT_FALSE(dest); // TODO(tsepez): put real dest into bookmarks.pdf
+
+ FPDF_ACTION action = FPDFBookmark_GetAction(child);
+ EXPECT_FALSE(action); // TODO(tsepez): put real action into bookmarks.pdf
+
+ FPDF_BOOKMARK grand_child = FPDFBookmark_GetFirstChild(document(), child);
+ EXPECT_FALSE(grand_child);
FPDF_BOOKMARK sibling = FPDFBookmark_GetNextSibling(document(), child);
EXPECT_TRUE(sibling);
@@ -392,6 +396,8 @@
}
TEST_F(FPDFDocEmbedderTest, FindBookmarks) {
+ unsigned short buf[128];
+
// Open a file with two bookmarks.
EXPECT_TRUE(OpenDocument("bookmarks.pdf"));
@@ -401,7 +407,6 @@
EXPECT_TRUE(child);
// Check that the string matches.
- unsigned short buf[128];
EXPECT_EQ(34u, FPDFBookmark_GetTitle(child, buf, sizeof(buf)));
EXPECT_EQ(WideString(L"A Good Beginning"), WideString::FromUTF16LE(buf, 16));