diff options
author | Nicolas Pena <npm@chromium.org> | 2017-07-05 11:55:35 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-07-05 17:08:57 +0000 |
commit | 3ff54008a163eea3158a7c107595daf79ccc7d44 (patch) | |
tree | f460b4f50863e65922799970208bf93bd845a7d8 /testing/embedder_test.h | |
parent | fb00ec2af390ccfe8f5e81f49b9113e044f5e5ad (diff) | |
download | pdfium-3ff54008a163eea3158a7c107595daf79ccc7d44.tar.xz |
Allow EmbedderTest to test saving
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 <dsinclair@chromium.org>
Commit-Queue: Nicolás Peña <npm@chromium.org>
Diffstat (limited to 'testing/embedder_test.h')
-rw-r--r-- | testing/embedder_test.h | 26 |
1 files changed, 24 insertions, 2 deletions
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<Delegate> default_delegate_; FPDF_DOCUMENT document_; @@ -142,6 +156,9 @@ class EmbedderTest : public ::testing::Test, std::unique_ptr<char, pdfium::FreeDeleter> file_contents_; std::map<int, FPDF_PAGE> page_map_; std::map<FPDF_PAGE, int> 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_ |