Adjust FPDFEditEmbedderTest new document creation code.
Switch FPDFEditEmbedderTest::CreateNewDocument() from calling
FPDF_CreateNewDocument() directly to calling
EmbedderTest::CreateEmptyDocumentWithoutFormFillEnvironment(). Removing
the need for FPDFEditEmbedderTest to set `EmbedderTest::document_`
directly.
Change-Id: Ifb8eac42122ee57103e7679c3ad4db1da302cd77
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/86891
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
diff --git a/fpdfsdk/fpdf_edit_embeddertest.cpp b/fpdfsdk/fpdf_edit_embeddertest.cpp
index 9b21f85..a563cad 100644
--- a/fpdfsdk/fpdf_edit_embeddertest.cpp
+++ b/fpdfsdk/fpdf_edit_embeddertest.cpp
@@ -94,7 +94,7 @@
class FPDFEditEmbedderTest : public EmbedderTest {
protected:
FPDF_DOCUMENT CreateNewDocument() {
- document_ = FPDF_CreateNewDocument();
+ CreateEmptyDocumentWithoutFormFillEnvironment();
cpdf_doc_ = CPDFDocumentFromFPDFDocument(document_);
return document_;
}
diff --git a/testing/embedder_test.cpp b/testing/embedder_test.cpp
index 4ef9352..e931d6a 100644
--- a/testing/embedder_test.cpp
+++ b/testing/embedder_test.cpp
@@ -79,13 +79,16 @@
}
void EmbedderTest::CreateEmptyDocument() {
- document_ = FPDF_CreateNewDocument();
- DCHECK(document_);
-
+ CreateEmptyDocumentWithoutFormFillEnvironment();
form_handle_.reset(
SetupFormFillEnvironment(document_, JavaScriptOption::kEnableJavaScript));
}
+void EmbedderTest::CreateEmptyDocumentWithoutFormFillEnvironment() {
+ document_ = FPDF_CreateNewDocument();
+ DCHECK(document_);
+}
+
bool EmbedderTest::OpenDocument(const std::string& filename) {
return OpenDocumentWithOptions(filename, nullptr,
LinearizeOption::kDefaultLinearize,
diff --git a/testing/embedder_test.h b/testing/embedder_test.h
index 3e1709c..b1e18ce 100644
--- a/testing/embedder_test.h
+++ b/testing/embedder_test.h
@@ -112,6 +112,9 @@
// Create an empty document, and its form fill environment.
void CreateEmptyDocument();
+ // Create an empty document without a form fill environment.
+ void CreateEmptyDocumentWithoutFormFillEnvironment();
+
// 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 test files. |password| can