Revert "Revert "Merge to master: contention over isolate data slots""
[pdfium.git] / fpdfsdk / src / fpdfdoc_embeddertest.cpp
index 1f11bef..8b1c4fb 100644 (file)
@@ -7,32 +7,56 @@
 #include "../../testing/embedder_test.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
-class FPDFDocEmbeddertest : public EmbedderTest {
-};
+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));
+  EXPECT_EQ(0U, 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));
+  EXPECT_EQ(1U, 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));
+  EXPECT_EQ(1U, 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));
+  EXPECT_EQ(11U, 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));
+  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);
+
+  // The target action is nearly the size of the whole page.
+  FPDF_LINK link = FPDFLink_GetLinkAtPoint(page, 100, 100);
+  ASSERT_TRUE(link);
+
+  FPDF_ACTION action = FPDFLink_GetAction(link);
+  ASSERT_TRUE(action);
+
+  const char kExpectedResult[] = "test.pdf";
+  const unsigned long kExpectedLength = sizeof(kExpectedResult);
+  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);
 }