summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/fpdfdoc_embeddertest.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-01-22 11:20:06 -0800
committerTom Sepez <tsepez@chromium.org>2015-01-22 11:20:06 -0800
commitc8f6ab628c4bdf90dcee3d5ac153beb043a42f92 (patch)
treefa9d7cfadb37a382ce08bffcecad897d33ff04a8 /fpdfsdk/src/fpdfdoc_embeddertest.cpp
parent70ad112e874cd076144cc1254db254ee651b5c81 (diff)
downloadpdfium-c8f6ab628c4bdf90dcee3d5ac153beb043a42f92.tar.xz
Merge to XFA: Add embeddertests.
This brings in: 83f96a0 Add API tests: NamedDestsByName, DestGetPageIndex. 9dcd7b8 Add tests for GetNamedDests() API. TBR=bo_xu@foxitsoftware.com Review URL: https://codereview.chromium.org/849693007
Diffstat (limited to 'fpdfsdk/src/fpdfdoc_embeddertest.cpp')
-rw-r--r--fpdfsdk/src/fpdfdoc_embeddertest.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/fpdfsdk/src/fpdfdoc_embeddertest.cpp b/fpdfsdk/src/fpdfdoc_embeddertest.cpp
new file mode 100644
index 0000000000..dadaf1d809
--- /dev/null
+++ b/fpdfsdk/src/fpdfdoc_embeddertest.cpp
@@ -0,0 +1,38 @@
+// Copyright 2015 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "../../testing/embedder_test.h"
+#include "../../fpdfsdk/include/fpdfview.h"
+#include "../../fpdfsdk/include/fpdfdoc.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+class FPDFDocEmbeddertest : public EmbedderTest {
+};
+
+TEST_F(FPDFDocEmbeddertest, DestGetPageIndex) {
+ EXPECT_TRUE(OpenDocument("testing/resources/named_dests.pdf"));
+
+ // NULL FPDF_DEST case.
+ EXPECT_EQ(0, FPDFDest_GetPageIndex(document(), nullptr));
+
+ // Page number directly in item from Dests NameTree.
+ FPDF_DEST dest = FPDF_GetNamedDestByName(document(), "First");
+ EXPECT_NE(nullptr, dest);
+ EXPECT_EQ(1, FPDFDest_GetPageIndex(document(), dest));
+
+ // Page number via object reference in item from Dests NameTree.
+ dest = FPDF_GetNamedDestByName(document(), "Next");
+ EXPECT_NE(nullptr, dest);
+ EXPECT_EQ(1, FPDFDest_GetPageIndex(document(), dest));
+
+ // Page number directly in item from Dests dictionary.
+ dest = FPDF_GetNamedDestByName(document(), "FirstAlternate");
+ EXPECT_NE(nullptr, dest);
+ EXPECT_EQ(11, FPDFDest_GetPageIndex(document(), dest));
+
+ // Invalid object reference in item from Dests NameTree.
+ dest = FPDF_GetNamedDestByName(document(), "LastAlternate");
+ EXPECT_NE(nullptr, dest);
+ EXPECT_EQ(0, FPDFDest_GetPageIndex(document(), dest));
+}