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.cpp40
1 files changed, 38 insertions, 2 deletions
diff --git a/fpdfsdk/fpdfppo_embeddertest.cpp b/fpdfsdk/fpdfppo_embeddertest.cpp
index 0972316534..db39700ca1 100644
--- a/fpdfsdk/fpdfppo_embeddertest.cpp
+++ b/fpdfsdk/fpdfppo_embeddertest.cpp
@@ -15,6 +15,12 @@ namespace {
class FPDFPPOEmbeddertest : public EmbedderTest {};
+int FakeBlockWriter(FPDF_FILEWRITE* pThis,
+ const void* pData,
+ unsigned long size) {
+ return size;
+}
+
} // namespace
TEST_F(FPDFPPOEmbeddertest, NoViewerPreferences) {
@@ -36,13 +42,13 @@ TEST_F(FPDFPPOEmbeddertest, ViewerPreferences) {
}
TEST_F(FPDFPPOEmbeddertest, ImportPages) {
- EXPECT_TRUE(OpenDocument("viewer_ref.pdf"));
+ ASSERT_TRUE(OpenDocument("viewer_ref.pdf"));
FPDF_PAGE page = LoadPage(0);
EXPECT_TRUE(page);
FPDF_DOCUMENT output_doc = FPDF_CreateNewDocument();
- EXPECT_TRUE(output_doc);
+ ASSERT_TRUE(output_doc);
EXPECT_TRUE(FPDF_CopyViewerPreferences(output_doc, document()));
EXPECT_TRUE(FPDF_ImportPages(output_doc, document(), "1", 0));
EXPECT_EQ(1, FPDF_GetPageCount(output_doc));
@@ -51,6 +57,36 @@ TEST_F(FPDFPPOEmbeddertest, ImportPages) {
UnloadPage(page);
}
+TEST_F(FPDFPPOEmbeddertest, BadRepeatViewerPref) {
+ ASSERT_TRUE(OpenDocument("repeat_viewer_ref.pdf"));
+
+ FPDF_DOCUMENT output_doc = FPDF_CreateNewDocument();
+ EXPECT_TRUE(output_doc);
+ EXPECT_TRUE(FPDF_CopyViewerPreferences(output_doc, document()));
+
+ FPDF_FILEWRITE writer;
+ writer.version = 1;
+ writer.WriteBlock = FakeBlockWriter;
+
+ EXPECT_TRUE(FPDF_SaveAsCopy(output_doc, &writer, 0));
+ FPDF_CloseDocument(output_doc);
+}
+
+TEST_F(FPDFPPOEmbeddertest, BadCircularViewerPref) {
+ ASSERT_TRUE(OpenDocument("circular_viewer_ref.pdf"));
+
+ FPDF_DOCUMENT output_doc = FPDF_CreateNewDocument();
+ EXPECT_TRUE(output_doc);
+ EXPECT_TRUE(FPDF_CopyViewerPreferences(output_doc, document()));
+
+ FPDF_FILEWRITE writer;
+ writer.version = 1;
+ writer.WriteBlock = FakeBlockWriter;
+
+ EXPECT_TRUE(FPDF_SaveAsCopy(output_doc, &writer, 0));
+ FPDF_CloseDocument(output_doc);
+}
+
TEST_F(FPDFPPOEmbeddertest, BadRanges) {
EXPECT_TRUE(OpenDocument("viewer_ref.pdf"));