From 3ff54008a163eea3158a7c107595daf79ccc7d44 Mon Sep 17 00:00:00 2001 From: Nicolas Pena Date: Wed, 5 Jul 2017 11:55:35 -0400 Subject: Allow EmbedderTest to test saving MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This CL adds helper methods for EmbedderTest to save. This means that TestSaver is no longer needed and all the methods it uses are moved to the EmbedderTest. Change-Id: I740f29699bfd8c6b570cb1fd85e7aab9bc1d3f6f Reviewed-on: https://pdfium-review.googlesource.com/7171 Reviewed-by: dsinclair Commit-Queue: Nicolás Peña --- testing/embedder_test.h | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'testing/embedder_test.h') diff --git a/testing/embedder_test.h b/testing/embedder_test.h index ba44673004..d2fd984a10 100644 --- a/testing/embedder_test.h +++ b/testing/embedder_test.h @@ -12,6 +12,7 @@ #include "public/fpdf_dataavail.h" #include "public/fpdf_ext.h" #include "public/fpdf_formfill.h" +#include "public/fpdf_save.h" #include "public/fpdfview.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/test_support.h" @@ -27,7 +28,8 @@ class TestLoader; class EmbedderTest : public ::testing::Test, public UNSUPPORT_INFO, public IPDF_JSPLATFORM, - public FPDF_FORMFILLINFO { + public FPDF_FORMFILLINFO, + public FPDF_FILEWRITE { public: class Delegate { public: @@ -112,7 +114,7 @@ class EmbedderTest : public ::testing::Test, virtual void UnloadPage(FPDF_PAGE page); protected: - void SetupFormFillEnvironment(); + FPDF_FORMHANDLE SetupFormFillEnvironment(FPDF_DOCUMENT doc); // Return the hash of |bitmap|. static std::string HashBitmap(FPDF_BITMAP bitmap, @@ -125,6 +127,18 @@ class EmbedderTest : public ::testing::Test, int expected_height, const char* expected_md5sum); + void ClearString() { m_String.clear(); } + const std::string& GetString() const { return m_String; } + + static int GetBlockFromString(void* param, + unsigned long pos, + unsigned char* buf, + unsigned long size); + + void TestSaved(int width, int height, const char* md5); + void CloseSaved(); + void TestAndCloseSaved(int width, int height, const char* md5); + Delegate* delegate_; std::unique_ptr default_delegate_; FPDF_DOCUMENT document_; @@ -142,6 +156,9 @@ class EmbedderTest : public ::testing::Test, std::unique_ptr file_contents_; std::map page_map_; std::map page_reverse_map_; + FPDF_DOCUMENT m_SavedDocument; + FPDF_PAGE m_SavedPage; + FPDF_FORMHANDLE m_SavedForm; private: static void UnsupportedHandlerTrampoline(UNSUPPORT_INFO*, int type); @@ -157,6 +174,11 @@ class EmbedderTest : public ::testing::Test, static FPDF_PAGE GetPageTrampoline(FPDF_FORMFILLINFO* info, FPDF_DOCUMENT document, int page_index); + static int WriteBlockCallback(FPDF_FILEWRITE* pFileWrite, + const void* data, + unsigned long size); + + std::string m_String; }; #endif // TESTING_EMBEDDER_TEST_H_ -- cgit v1.2.3