summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2016-01-04 15:03:48 -0800
committerTom Sepez <tsepez@chromium.org>2016-01-04 15:03:48 -0800
commit14fdb1d40741912e430db4318a9033764429659f (patch)
tree6ee91255818647338516f63e1e6f166dedbd4d68
parent03f5040cbe03cc93e133cb98ecce6725e2679170 (diff)
downloadpdfium-14fdb1d40741912e430db4318a9033764429659f.tar.xz
Add FPDFDoc_GetPageMode() embeddertest
R=thestig@chromium.org Review URL: https://codereview.chromium.org/1557173002 .
-rw-r--r--BUILD.gn1
-rw-r--r--fpdfsdk/src/fpdfext_embeddertest.cpp24
-rw-r--r--pdfium.gyp1
-rw-r--r--testing/resources/use_outlines.in57
-rw-r--r--testing/resources/use_outlines.pdf67
5 files changed, 150 insertions, 0 deletions
diff --git a/BUILD.gn b/BUILD.gn
index 1377b68af5..6ce83350c3 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -756,6 +756,7 @@ test("pdfium_embeddertests") {
"core/src/fpdfapi/fpdf_render/fpdf_render_pattern_embeddertest.cpp",
"fpdfsdk/src/fpdf_dataavail_embeddertest.cpp",
"fpdfsdk/src/fpdfdoc_embeddertest.cpp",
+ "fpdfsdk/src/fpdfext_embeddertest.cpp",
"fpdfsdk/src/fpdfformfill_embeddertest.cpp",
"fpdfsdk/src/fpdftext_embeddertest.cpp",
"fpdfsdk/src/fpdfview_c_api_test.c",
diff --git a/fpdfsdk/src/fpdfext_embeddertest.cpp b/fpdfsdk/src/fpdfext_embeddertest.cpp
new file mode 100644
index 0000000000..7c28c29a8e
--- /dev/null
+++ b/fpdfsdk/src/fpdfext_embeddertest.cpp
@@ -0,0 +1,24 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "public/fpdf_ext.h"
+#include "public/fpdfview.h"
+#include "testing/embedder_test.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+class FPDFExtEmbeddertest : public EmbedderTest {};
+
+TEST_F(FPDFExtEmbeddertest, PageModeUnknown) {
+ EXPECT_EQ(PAGEMODE_UNKNOWN, FPDFDoc_GetPageMode(nullptr));
+}
+
+TEST_F(FPDFExtEmbeddertest, PageModeUseNone) {
+ EXPECT_TRUE(OpenDocument("hello_world.pdf"));
+ EXPECT_EQ(PAGEMODE_USENONE, FPDFDoc_GetPageMode(document()));
+}
+
+TEST_F(FPDFExtEmbeddertest, PageModeUseOutlines) {
+ EXPECT_TRUE(OpenDocument("use_outlines.pdf"));
+ EXPECT_EQ(PAGEMODE_USEOUTLINES, FPDFDoc_GetPageMode(document()));
+}
diff --git a/pdfium.gyp b/pdfium.gyp
index 8401dcc5b9..d598a6e403 100644
--- a/pdfium.gyp
+++ b/pdfium.gyp
@@ -751,6 +751,7 @@
'core/src/fpdfapi/fpdf_render/fpdf_render_pattern_embeddertest.cpp',
'fpdfsdk/src/fpdf_dataavail_embeddertest.cpp',
'fpdfsdk/src/fpdfdoc_embeddertest.cpp',
+ 'fpdfsdk/src/fpdfext_embeddertest.cpp',
'fpdfsdk/src/fpdfformfill_embeddertest.cpp',
'fpdfsdk/src/fpdftext_embeddertest.cpp',
'fpdfsdk/src/fpdfview_c_api_test.c',
diff --git a/testing/resources/use_outlines.in b/testing/resources/use_outlines.in
new file mode 100644
index 0000000000..b344143f64
--- /dev/null
+++ b/testing/resources/use_outlines.in
@@ -0,0 +1,57 @@
+{{header}}
+{{object 1 0}} <<
+ /Type /Catalog
+ /Pages 2 0 R
+ /PageMode /UseOutlines
+>>
+{{object 2 0}} <<
+ /Type /Pages
+ /MediaBox [ 0 0 200 200 ]
+ /Count 1
+ /Kids [ 3 0 R ]
+>>
+endobj
+{{object 3 0}} <<
+ /Type /Page
+ /Parent 2 0 R
+ /Resources <<
+ /Font <<
+ /F1 4 0 R
+ /F2 5 0 R
+ >>
+ >>
+ /Contents 6 0 R
+>>
+endobj
+{{object 4 0}} <<
+ /Type /Font
+ /Subtype /Type1
+ /BaseFont /Times-Roman
+>>
+endobj
+{{object 5 0}} <<
+ /Type /Font
+ /Subtype /Type1
+ /BaseFont /Helvetica
+>>
+endobj
+{{object 6 0}} <<
+>>
+stream
+BT
+20 50 Td
+/F1 12 Tf
+(Hello, world!) Tj
+0 50 Td
+/F2 16 Tf
+(Goodbye, world!) Tj
+ET
+endstream
+endobj
+{{xref}}
+trailer <<
+ /Size 6
+ /Root 1 0 R
+>>
+{{startxref}}
+%%EOF
diff --git a/testing/resources/use_outlines.pdf b/testing/resources/use_outlines.pdf
new file mode 100644
index 0000000000..371ff4083c
--- /dev/null
+++ b/testing/resources/use_outlines.pdf
@@ -0,0 +1,67 @@
+%PDF-1.7
+% ò¤ô
+1 0 obj <<
+ /Type /Catalog
+ /Pages 2 0 R
+ /PageMode /UseOutlines
+>>
+2 0 obj <<
+ /Type /Pages
+ /MediaBox [ 0 0 200 200 ]
+ /Count 1
+ /Kids [ 3 0 R ]
+>>
+endobj
+3 0 obj <<
+ /Type /Page
+ /Parent 2 0 R
+ /Resources <<
+ /Font <<
+ /F1 4 0 R
+ /F2 5 0 R
+ >>
+ >>
+ /Contents 6 0 R
+>>
+endobj
+4 0 obj <<
+ /Type /Font
+ /Subtype /Type1
+ /BaseFont /Times-Roman
+>>
+endobj
+5 0 obj <<
+ /Type /Font
+ /Subtype /Type1
+ /BaseFont /Helvetica
+>>
+endobj
+6 0 obj <<
+>>
+stream
+BT
+20 50 Td
+/F1 12 Tf
+(Hello, world!) Tj
+0 50 Td
+/F2 16 Tf
+(Goodbye, world!) Tj
+ET
+endstream
+endobj
+xref
+0 7
+0000000000 65535 f
+0000000015 00000 n
+0000000086 00000 n
+0000000179 00000 n
+0000000321 00000 n
+0000000399 00000 n
+0000000475 00000 n
+trailer <<
+ /Size 6
+ /Root 1 0 R
+>>
+startxref
+596
+%%EOF