summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-10-09 21:42:39 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-10-09 21:42:39 +0000
commit69c3285d3a4d6bb60c8d3b88b289873371ca91f9 (patch)
treec0c21ebe89844367cb2294f73d4a298ac42d4d20 /fpdfsdk
parent99f5bbb53316543f4f20ea937b5abc98efe91bf9 (diff)
downloadpdfium-69c3285d3a4d6bb60c8d3b88b289873371ca91f9.tar.xz
Add two NULL argument FPDFDest_* test cases
Change-Id: I4b811bb28f9af5fd4a907a9a9eb29b05a8dc4b6a Reviewed-on: https://pdfium-review.googlesource.com/c/43731 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/fpdf_doc.cpp6
-rw-r--r--fpdfsdk/fpdf_doc_embeddertest.cpp24
2 files changed, 17 insertions, 13 deletions
diff --git a/fpdfsdk/fpdf_doc.cpp b/fpdfsdk/fpdf_doc.cpp
index b8f50c7ccb..614462fa47 100644
--- a/fpdfsdk/fpdf_doc.cpp
+++ b/fpdfsdk/fpdf_doc.cpp
@@ -207,13 +207,13 @@ FPDFAction_GetURIPath(FPDF_DOCUMENT document,
FPDF_EXPORT int FPDF_CALLCONV FPDFDest_GetDestPageIndex(FPDF_DOCUMENT document,
FPDF_DEST dest) {
- if (!dest)
- return -1;
-
CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document);
if (!pDoc)
return -1;
+ if (!dest)
+ return -1;
+
CPDF_Dest destination(CPDFArrayFromFPDFDest(dest));
return destination.GetDestPageIndex(pDoc);
}
diff --git a/fpdfsdk/fpdf_doc_embeddertest.cpp b/fpdfsdk/fpdf_doc_embeddertest.cpp
index d90cc370e3..3d582bcca0 100644
--- a/fpdfsdk/fpdf_doc_embeddertest.cpp
+++ b/fpdfsdk/fpdf_doc_embeddertest.cpp
@@ -42,7 +42,8 @@ TEST_F(FPDFDocEmbeddertest, MultipleSamePage) {
TEST_F(FPDFDocEmbeddertest, DestGetPageIndex) {
EXPECT_TRUE(OpenDocument("named_dests.pdf"));
- // NULL FPDF_DEST case.
+ // NULL argument cases.
+ EXPECT_EQ(-1, FPDFDest_GetDestPageIndex(nullptr, nullptr));
EXPECT_EQ(-1, FPDFDest_GetDestPageIndex(document(), nullptr));
// Page number directly in item from Dests NameTree.
@@ -128,18 +129,21 @@ TEST_F(FPDFDocEmbeddertest, DestGetView) {
TEST_F(FPDFDocEmbeddertest, DestGetLocationInPage) {
EXPECT_TRUE(OpenDocument("named_dests.pdf"));
- // NULL FPDF_DEST case.
- EXPECT_EQ(-1, FPDFDest_GetDestPageIndex(document(), nullptr));
-
FPDF_DEST dest = FPDF_GetNamedDestByName(document(), "First");
EXPECT_TRUE(dest);
- FPDF_BOOL hasX;
- FPDF_BOOL hasY;
- FPDF_BOOL hasZoom;
- FS_FLOAT x;
- FS_FLOAT y;
- FS_FLOAT zoom;
+ FPDF_BOOL hasX = 0;
+ FPDF_BOOL hasY = 0;
+ FPDF_BOOL hasZoom = 0;
+ FS_FLOAT x = -1.0f;
+ FS_FLOAT y = -1.0f;
+ FS_FLOAT zoom = -1.0f;
+
+ // NULL argument case
+ EXPECT_FALSE(FPDFDest_GetLocationInPage(nullptr, &hasX, &hasY, &hasZoom, &x,
+ &y, &zoom));
+
+ // Actual argument case.
EXPECT_TRUE(
FPDFDest_GetLocationInPage(dest, &hasX, &hasY, &hasZoom, &x, &y, &zoom));
EXPECT_TRUE(hasX);