summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdf_doc_embeddertest.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-10-10 17:27:33 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-10-10 17:27:33 +0000
commit7bf816420aa79b23c37ad433183f01dc5af653fa (patch)
tree04aa335d90f659322d1e97ad2fc852e93121dd26 /fpdfsdk/fpdf_doc_embeddertest.cpp
parent73ae71f2f63ab8a3084cb0e691e661b071dc1a92 (diff)
downloadpdfium-7bf816420aa79b23c37ad433183f01dc5af653fa.tar.xz
Better test FPDFAction_* public functions.
Update public documentation. Make implementation match documentation for bad argument types. Change-Id: I70aa3ccaf2580f81d6eb14c6fb4198374010a695 Reviewed-on: https://pdfium-review.googlesource.com/c/43690 Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdf_doc_embeddertest.cpp')
-rw-r--r--fpdfsdk/fpdf_doc_embeddertest.cpp24
1 files changed, 21 insertions, 3 deletions
diff --git a/fpdfsdk/fpdf_doc_embeddertest.cpp b/fpdfsdk/fpdf_doc_embeddertest.cpp
index 3d582bcca0..91a2333241 100644
--- a/fpdfsdk/fpdf_doc_embeddertest.cpp
+++ b/fpdfsdk/fpdf_doc_embeddertest.cpp
@@ -225,7 +225,19 @@ TEST_F(FPDFDocEmbeddertest, BUG_821454) {
UnloadPage(page);
}
-TEST_F(FPDFDocEmbeddertest, ActionGetFilePath) {
+TEST_F(FPDFDocEmbeddertest, ActionBadArguments) {
+ EXPECT_TRUE(OpenDocument("launch_action.pdf"));
+ EXPECT_EQ(static_cast<unsigned long>(PDFACTION_UNSUPPORTED),
+ FPDFAction_GetType(nullptr));
+
+ EXPECT_EQ(nullptr, FPDFAction_GetDest(nullptr, nullptr));
+ EXPECT_EQ(nullptr, FPDFAction_GetDest(document(), nullptr));
+ EXPECT_EQ(0u, FPDFAction_GetFilePath(nullptr, nullptr, 0));
+ EXPECT_EQ(0u, FPDFAction_GetURIPath(nullptr, nullptr, nullptr, 0));
+ EXPECT_EQ(0u, FPDFAction_GetURIPath(document(), nullptr, nullptr, 0));
+}
+
+TEST_F(FPDFDocEmbeddertest, ActionLaunch) {
EXPECT_TRUE(OpenDocument("launch_action.pdf"));
FPDF_PAGE page = LoadPage(0);
@@ -237,15 +249,21 @@ TEST_F(FPDFDocEmbeddertest, ActionGetFilePath) {
FPDF_ACTION action = FPDFLink_GetAction(link);
ASSERT_TRUE(action);
+ EXPECT_EQ(static_cast<unsigned long>(PDFACTION_LAUNCH),
+ FPDFAction_GetType(action));
const char kExpectedResult[] = "test.pdf";
const unsigned long kExpectedLength = sizeof(kExpectedResult);
unsigned long bufsize = FPDFAction_GetFilePath(action, nullptr, 0);
- ASSERT_EQ(kExpectedLength, bufsize);
+ EXPECT_EQ(kExpectedLength, bufsize);
char buf[kExpectedLength];
EXPECT_EQ(bufsize, FPDFAction_GetFilePath(action, buf, bufsize));
- EXPECT_EQ(std::string(kExpectedResult), std::string(buf));
+ EXPECT_STREQ(kExpectedResult, buf);
+
+ // Other public methods are not appropriate for this action type.
+ EXPECT_EQ(nullptr, FPDFAction_GetDest(document(), action));
+ EXPECT_EQ(0u, FPDFAction_GetURIPath(document(), action, buf, bufsize));
UnloadPage(page);
}