Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(589)

Unified Diff: fpdfsdk/src/fpdfdoc_embeddertest.cpp

Issue 1335373002: Implement FPDFAction_GetFilePath(). (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: fpdfsdk/src/fpdfdoc_embeddertest.cpp
diff --git a/fpdfsdk/src/fpdfdoc_embeddertest.cpp b/fpdfsdk/src/fpdfdoc_embeddertest.cpp
index b263fafe16905a3c448e0b9e9b0f4861a2d67059..f3663baf10e965c2e4bd836687a8cd9ba76725d2 100644
--- a/fpdfsdk/src/fpdfdoc_embeddertest.cpp
+++ b/fpdfsdk/src/fpdfdoc_embeddertest.cpp
@@ -35,3 +35,28 @@ TEST_F(FPDFDocEmbeddertest, DestGetPageIndex) {
EXPECT_NE(nullptr, dest);
EXPECT_EQ(0U, FPDFDest_GetPageIndex(document(), dest));
}
+
+TEST_F(FPDFDocEmbeddertest, ActionGetFilePath) {
+ EXPECT_TRUE(OpenDocument("testing/resources/launch_action.pdf"));
+
+ FPDF_PAGE page = FPDF_LoadPage(document(), 0);
+ ASSERT_TRUE(page);
jun_fang 2015/09/14 14:18:58 EXPECT_NE(nullptr, page);
Lei Zhang 2015/09/15 08:24:50 I want this test to be straight forward and only c
jun_fang 2015/09/15 08:35:03 The returned value, page, is handle not boolean va
Lei Zhang 2015/09/15 08:50:57 So handles are really pointers, and the range of v
+
+ // The target action is nearly the size of the whole page.
+ FPDF_LINK link = FPDFLink_GetLinkAtPoint(page, 100, 100);
+ ASSERT_TRUE(link);
jun_fang 2015/09/14 14:18:58 EXPECT_NE(nullptr, link);
+
+ FPDF_ACTION action = FPDFLink_GetAction(link);
+ ASSERT_TRUE(action);
jun_fang 2015/09/14 14:18:58 EXPECT_NE(nullptr, action);
+
+ const char kExpectedResult[] = "test.pdf";
+ const unsigned long kExpectedLength = strlen(kExpectedResult) + 1;
+ unsigned long bufsize = FPDFAction_GetFilePath(action, nullptr, 0);
+ ASSERT_EQ(kExpectedLength, bufsize);
+
+ char buf[kExpectedLength];
+ EXPECT_EQ(bufsize, FPDFAction_GetFilePath(action, buf, bufsize));
+ EXPECT_EQ(std::string(kExpectedResult), std::string(buf));
+
+ FPDF_ClosePage(page);
+}

Powered by Google App Engine
This is Rietveld 408576698