summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdfppo_embeddertest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk/fpdfppo_embeddertest.cpp')
-rw-r--r--fpdfsdk/fpdfppo_embeddertest.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/fpdfsdk/fpdfppo_embeddertest.cpp b/fpdfsdk/fpdfppo_embeddertest.cpp
index c642b71ac0..deb87b533a 100644
--- a/fpdfsdk/fpdfppo_embeddertest.cpp
+++ b/fpdfsdk/fpdfppo_embeddertest.cpp
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include <string>
+#include "public/cpp/fpdf_deleters.h"
#include "public/fpdf_edit.h"
#include "public/fpdf_ppo.h"
#include "public/fpdf_save.h"
@@ -57,6 +58,47 @@ TEST_F(FPDFPPOEmbeddertest, ImportPages) {
UnloadPage(page);
}
+TEST_F(FPDFPPOEmbeddertest, ImportNPages) {
+ ASSERT_TRUE(OpenDocument("hello_world_multi_pages.pdf"));
+
+ std::unique_ptr<void, FPDFDocumentDeleter> output_doc_2up(
+ FPDF_ImportNPagesToOne(document(), 612, 792, 2, 1));
+ ASSERT_TRUE(output_doc_2up);
+ EXPECT_EQ(3, FPDF_GetPageCount(output_doc_2up.get()));
+ std::unique_ptr<void, FPDFDocumentDeleter> output_doc_5up(
+ FPDF_ImportNPagesToOne(document(), 612, 792, 5, 1));
+ ASSERT_TRUE(output_doc_5up);
+ EXPECT_EQ(1, FPDF_GetPageCount(output_doc_5up.get()));
+ std::unique_ptr<void, FPDFDocumentDeleter> output_doc_8up(
+ FPDF_ImportNPagesToOne(document(), 792, 612, 8, 1));
+ ASSERT_TRUE(output_doc_8up);
+ EXPECT_EQ(1, FPDF_GetPageCount(output_doc_8up.get()));
+ std::unique_ptr<void, FPDFDocumentDeleter> output_doc_128up(
+ FPDF_ImportNPagesToOne(document(), 792, 612, 128, 1));
+ ASSERT_TRUE(output_doc_128up);
+ EXPECT_EQ(1, FPDF_GetPageCount(output_doc_128up.get()));
+}
+
+TEST_F(FPDFPPOEmbeddertest, BadNupParams) {
+ ASSERT_TRUE(OpenDocument("hello_world_multi_pages.pdf"));
+
+ FPDF_DOCUMENT output_doc_zero_row =
+ FPDF_ImportNPagesToOne(document(), 612, 792, 0, 3);
+ ASSERT_FALSE(output_doc_zero_row);
+ FPDF_DOCUMENT output_doc_zero_col =
+ FPDF_ImportNPagesToOne(document(), 612, 792, 2, 0);
+ ASSERT_FALSE(output_doc_zero_col);
+ FPDF_DOCUMENT output_doc_zero_width =
+ FPDF_ImportNPagesToOne(document(), 0, 792, 2, 1);
+ ASSERT_FALSE(output_doc_zero_width);
+ FPDF_DOCUMENT output_doc_zero_height =
+ FPDF_ImportNPagesToOne(document(), 612, 0, 7, 1);
+ ASSERT_FALSE(output_doc_zero_height);
+}
+
+// TODO(Xlou): Add more tests to check output doc content of
+// FPDF_ImportNPagesToOne()
+
TEST_F(FPDFPPOEmbeddertest, BadRepeatViewerPref) {
ASSERT_TRUE(OpenDocument("repeat_viewer_ref.pdf"));