diff options
author | Tom Sepez <tsepez@chromium.org> | 2016-01-06 09:55:39 -0800 |
---|---|---|
committer | Tom Sepez <tsepez@chromium.org> | 2016-01-06 09:55:39 -0800 |
commit | d368261cc8d604286e29ca6358700e6bb051dcaa (patch) | |
tree | 292709bb93cf818ee823753595cd2c7a6e56c5b4 /testing | |
parent | 61197421793e24add7a250d3f15ab83dc75f80c6 (diff) | |
download | pdfium-d368261cc8d604286e29ca6358700e6bb051dcaa.tar.xz |
Add fpdf_edit basic creation embedder test.
R=thestig@chromium.org
Review URL: https://codereview.chromium.org/1554133003 .
Diffstat (limited to 'testing')
-rw-r--r-- | testing/embedder_test.cpp | 15 | ||||
-rw-r--r-- | testing/embedder_test.h | 6 |
2 files changed, 19 insertions, 2 deletions
diff --git a/testing/embedder_test.cpp b/testing/embedder_test.cpp index 33c72201a1..e99c2e351a 100644 --- a/testing/embedder_test.cpp +++ b/testing/embedder_test.cpp @@ -93,6 +93,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; @@ -152,7 +161,11 @@ bool EmbedderTest::OpenDocument(const std::string& filename, } (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; @@ -169,8 +182,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_; |