summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2016-01-06 10:03:59 -0800
committerTom Sepez <tsepez@chromium.org>2016-01-06 10:03:59 -0800
commitd483eb46d8920547d1b47351e65fa0299eaba191 (patch)
tree9b86db31f9f858c767cc58fee110839afdcdeef1
parentec32127b105fc1ff74842dc939cb6fa7d23430b0 (diff)
downloadpdfium-d483eb46d8920547d1b47351e65fa0299eaba191.tar.xz
Merge to XFA: Add fpdf_edit basic creation embedder test.
Original Review URL: https://codereview.chromium.org/1554133003 . (cherry picked from commit d368261cc8d604286e29ca6358700e6bb051dcaa) TBR=thestig@chromium.org Review URL: https://codereview.chromium.org/1567643002 .
-rw-r--r--BUILD.gn1
-rw-r--r--fpdfsdk/src/fpdfedit_embeddertest.cpp18
-rw-r--r--pdfium.gyp1
-rw-r--r--testing/embedder_test.cpp15
-rw-r--r--testing/embedder_test.h6
5 files changed, 39 insertions, 2 deletions
diff --git a/BUILD.gn b/BUILD.gn
index 47dc81e469..d881d00c49 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -1492,6 +1492,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/fpdfedit_embeddertest.cpp",
"fpdfsdk/src/fpdfext_embeddertest.cpp",
"fpdfsdk/src/fpdfformfill_embeddertest.cpp",
"fpdfsdk/src/fpdfsave_embeddertest.cpp",
diff --git a/fpdfsdk/src/fpdfedit_embeddertest.cpp b/fpdfsdk/src/fpdfedit_embeddertest.cpp
new file mode 100644
index 0000000000..9db948cd1f
--- /dev/null
+++ b/fpdfsdk/src/fpdfedit_embeddertest.cpp
@@ -0,0 +1,18 @@
+// 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_edit.h"
+#include "public/fpdfview.h"
+#include "testing/embedder_test.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+class FPDFEditEmbeddertest : public EmbedderTest {};
+
+TEST_F(FPDFEditEmbeddertest, EmptyCreation) {
+ EXPECT_TRUE(CreateEmptyDocument());
+ FPDF_PAGE page = FPDFPage_New(document(), 1, 640.0, 480.0);
+ EXPECT_NE(nullptr, page);
+ EXPECT_TRUE(FPDFPage_GenerateContent(page));
+ FPDFPage_Delete(document(), 1);
+}
diff --git a/pdfium.gyp b/pdfium.gyp
index ef1c175c92..b2cbb30a37 100644
--- a/pdfium.gyp
+++ b/pdfium.gyp
@@ -793,6 +793,7 @@
'core/src/fpdfapi/fpdf_render/fpdf_render_pattern_embeddertest.cpp',
'fpdfsdk/src/fpdf_dataavail_embeddertest.cpp',
'fpdfsdk/src/fpdfdoc_embeddertest.cpp',
+ 'fpdfsdk/src/fpdfedit_embeddertest.cpp',
'fpdfsdk/src/fpdfext_embeddertest.cpp',
'fpdfsdk/src/fpdfformfill_embeddertest.cpp',
'fpdfsdk/src/fpdfsave_embeddertest.cpp',
diff --git a/testing/embedder_test.cpp b/testing/embedder_test.cpp
index 8d4682eacf..7224e227c6 100644
--- a/testing/embedder_test.cpp
+++ b/testing/embedder_test.cpp
@@ -102,6 +102,15 @@ void EmbedderTest::TearDown() {
free(file_contents_);
}
+bool EmbedderTest::CreateEmptyDocument() {
+ document_ = FPDF_CreateNewDocument();
+ if (!document_)
+ return false;
+
+ SetupFormFillEnvironment();
+ return true;
+}
+
bool EmbedderTest::OpenDocument(const std::string& filename,
bool must_linearize) {
std::string file_path;
@@ -169,7 +178,11 @@ bool EmbedderTest::OpenDocument(const std::string& filename,
#endif // PDF_ENABLE_XFA
(void)FPDF_GetDocPermissions(document_);
+ SetupFormFillEnvironment();
+ return true;
+}
+void EmbedderTest::SetupFormFillEnvironment() {
IPDF_JSPLATFORM* platform = static_cast<IPDF_JSPLATFORM*>(this);
memset(platform, 0, sizeof(IPDF_JSPLATFORM));
platform->version = 2;
@@ -190,8 +203,6 @@ bool EmbedderTest::OpenDocument(const std::string& filename,
form_handle_ = FPDFDOC_InitFormFillEnvironment(document_, formfillinfo);
FPDF_SetFormFieldHighlightColor(form_handle_, 0, 0xFFE4DD);
FPDF_SetFormFieldHighlightAlpha(form_handle_, 100);
-
- return true;
}
void EmbedderTest::DoOpenActions() {
diff --git a/testing/embedder_test.h b/testing/embedder_test.h
index a544f26543..c780cca74b 100644
--- a/testing/embedder_test.h
+++ b/testing/embedder_test.h
@@ -78,6 +78,10 @@ class EmbedderTest : public ::testing::Test,
FPDF_DOCUMENT document() { return document_; }
FPDF_FORMHANDLE form_handle() { return form_handle_; }
+ // Create an empty document, and its form fill environment. Returns true
+ // on success or false on failure.
+ virtual bool CreateEmptyDocument();
+
// Open the document specified by |filename|, and create its form fill
// environment, or return false on failure.
// The filename is relative to the test data directory where we store all the
@@ -107,6 +111,8 @@ class EmbedderTest : public ::testing::Test,
virtual void UnloadPage(FPDF_PAGE page);
protected:
+ void SetupFormFillEnvironment();
+
Delegate* delegate_;
std::unique_ptr<Delegate> default_delegate_;
FPDF_DOCUMENT document_;