summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/fpdfview_embeddertest.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-01-22 11:11:45 -0800
committerTom Sepez <tsepez@chromium.org>2015-01-22 11:11:45 -0800
commit83f96a01a2cfd64d0a370e74c3f4353eb9a102d2 (patch)
tree44467cae28bf66afe91a435532411234a8551217 /fpdfsdk/src/fpdfview_embeddertest.cpp
parent9dcd7b841a6ec11b3cfff39f8d2d1f033dea9705 (diff)
downloadpdfium-83f96a01a2cfd64d0a370e74c3f4353eb9a102d2.tar.xz
Add API tests: NamedDestsByName, DestGetPageIndex.
This also adds a fpdfdoc_embeddertest.cpp to keep the test file name matching with the API call under test. R=bo_xu@foxitsoftware.com Review URL: https://codereview.chromium.org/812933004
Diffstat (limited to 'fpdfsdk/src/fpdfview_embeddertest.cpp')
-rw-r--r--fpdfsdk/src/fpdfview_embeddertest.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/fpdfsdk/src/fpdfview_embeddertest.cpp b/fpdfsdk/src/fpdfview_embeddertest.cpp
index 55c159a42c..ee32727ace 100644
--- a/fpdfsdk/src/fpdfview_embeddertest.cpp
+++ b/fpdfsdk/src/fpdfview_embeddertest.cpp
@@ -140,3 +140,40 @@ TEST_F(FPDFViewEmbeddertest, NamedDests) {
EXPECT_EQ(nullptr, dest);
EXPECT_EQ(sizeof(fixed_buffer), buffer_size); // unmodified.
}
+
+TEST_F(FPDFViewEmbeddertest, NamedDestsByName) {
+ EXPECT_TRUE(OpenDocument("testing/resources/named_dests.pdf"));
+
+ // Null pointer returns NULL.
+ FPDF_DEST dest = FPDF_GetNamedDestByName(document(), nullptr);
+ EXPECT_EQ(nullptr, dest);
+
+ // Empty string returns NULL.
+ dest = FPDF_GetNamedDestByName(document(), "");
+ EXPECT_EQ(nullptr, dest);
+
+ // Item from Dests NameTree.
+ dest = FPDF_GetNamedDestByName(document(), "First");
+ EXPECT_NE(nullptr, dest);
+
+ long ignore_len = 0;
+ FPDF_DEST dest_by_index =
+ FPDF_GetNamedDest(document(), 0, nullptr, ignore_len);
+ EXPECT_EQ(dest_by_index, dest);
+
+ // Item from Dests dictionary.
+ dest = FPDF_GetNamedDestByName(document(), "FirstAlternate");
+ EXPECT_NE(nullptr, dest);
+
+ ignore_len = 0;
+ dest_by_index = FPDF_GetNamedDest(document(), 4, nullptr, ignore_len);
+ EXPECT_EQ(dest_by_index, dest);
+
+ // Bad value type for item from Dests NameTree array.
+ dest = FPDF_GetNamedDestByName(document(), "WrongType");
+ EXPECT_EQ(nullptr, dest);
+
+ // No such destination in either Dest NameTree or dictionary.
+ dest = FPDF_GetNamedDestByName(document(), "Bogus");
+ EXPECT_EQ(nullptr, dest);
+}