summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdfdoc_embeddertest.cpp
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-03-21 17:19:46 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-03-21 17:19:46 +0000
commitbf85feeafdd8791f9dab7bfcd14ff850e015be26 (patch)
tree83d03d643bf8807fc55d16b114d6173587fa974f /fpdfsdk/fpdfdoc_embeddertest.cpp
parenta17ac192c043a6bce51e16cf7cd076087c78d9a9 (diff)
downloadpdfium-bf85feeafdd8791f9dab7bfcd14ff850e015be26.tar.xz
Add a regression test for bug 821454.
WideString::Compare() went bad but no embedder test failed. Improve coverage by hand crafting a PDF similar to the sample PDF in the bug report. BUG=chromium:823369 Change-Id: I267f53ba3ef7612bf54771a85f8305b2cbc3cfcb Reviewed-on: https://pdfium-review.googlesource.com/28910 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdfdoc_embeddertest.cpp')
-rw-r--r--fpdfsdk/fpdfdoc_embeddertest.cpp55
1 files changed, 55 insertions, 0 deletions
diff --git a/fpdfsdk/fpdfdoc_embeddertest.cpp b/fpdfsdk/fpdfdoc_embeddertest.cpp
index 7cd27751e7..07b83263be 100644
--- a/fpdfsdk/fpdfdoc_embeddertest.cpp
+++ b/fpdfsdk/fpdfdoc_embeddertest.cpp
@@ -143,6 +143,61 @@ TEST_F(FPDFDocEmbeddertest, BUG_680376) {
EXPECT_EQ(-1, FPDFDest_GetDestPageIndex(document(), dest));
}
+TEST_F(FPDFDocEmbeddertest, BUG_821454) {
+ EXPECT_TRUE(OpenDocument("bug_821454.pdf"));
+
+ FPDF_PAGE page = LoadPage(0);
+ ASSERT_TRUE(page);
+
+ FPDF_LINK link1 = FPDFLink_GetLinkAtPoint(page, 150, 360);
+ ASSERT_TRUE(link1);
+ FPDF_LINK link2 = FPDFLink_GetLinkAtPoint(page, 150, 420);
+ ASSERT_TRUE(link2);
+
+ FPDF_DEST dest1 = FPDFLink_GetDest(document(), link1);
+ ASSERT_TRUE(dest1);
+ FPDF_DEST dest2 = FPDFLink_GetDest(document(), link2);
+ ASSERT_TRUE(dest2);
+
+ EXPECT_EQ(0, FPDFDest_GetDestPageIndex(document(), dest1));
+ EXPECT_EQ(0, FPDFDest_GetDestPageIndex(document(), dest2));
+
+ {
+ FPDF_BOOL has_x_coord;
+ FPDF_BOOL has_y_coord;
+ FPDF_BOOL has_zoom;
+ FS_FLOAT x;
+ FS_FLOAT y;
+ FS_FLOAT zoom;
+ FPDF_BOOL success = FPDFDest_GetLocationInPage(
+ dest1, &has_x_coord, &has_y_coord, &has_zoom, &x, &y, &zoom);
+ ASSERT_TRUE(success);
+ EXPECT_TRUE(has_x_coord);
+ EXPECT_TRUE(has_y_coord);
+ EXPECT_FALSE(has_zoom);
+ EXPECT_FLOAT_EQ(100.0f, x);
+ EXPECT_FLOAT_EQ(200.0f, y);
+ }
+ {
+ FPDF_BOOL has_x_coord;
+ FPDF_BOOL has_y_coord;
+ FPDF_BOOL has_zoom;
+ FS_FLOAT x;
+ FS_FLOAT y;
+ FS_FLOAT zoom;
+ FPDF_BOOL success = FPDFDest_GetLocationInPage(
+ dest2, &has_x_coord, &has_y_coord, &has_zoom, &x, &y, &zoom);
+ ASSERT_TRUE(success);
+ EXPECT_TRUE(has_x_coord);
+ EXPECT_TRUE(has_y_coord);
+ EXPECT_FALSE(has_zoom);
+ EXPECT_FLOAT_EQ(150.0f, x);
+ EXPECT_FLOAT_EQ(250.0f, y);
+ }
+
+ UnloadPage(page);
+}
+
TEST_F(FPDFDocEmbeddertest, ActionGetFilePath) {
EXPECT_TRUE(OpenDocument("launch_action.pdf"));