diff options
author | Tom Sepez <tsepez@chromium.org> | 2016-01-07 12:22:44 -0800 |
---|---|---|
committer | Tom Sepez <tsepez@chromium.org> | 2016-01-07 12:22:44 -0800 |
commit | 0aec19b09e48097df6096802f70daeb53d348c79 (patch) | |
tree | fd469542edef770d61c6e3614c6d441cbf202abf /testing | |
parent | 6a5f9662d1f36d1e67eb3431c0e628096e51aa15 (diff) | |
download | pdfium-0aec19b09e48097df6096802f70daeb53d348c79.tar.xz |
Merge to XFA: Disentangle fpdfsave_embeddertest's FPDF_FILEWRITE.
Original Review URL: https://codereview.chromium.org/1561303002 .
(cherry picked from commit 5dc13d7858f9caf58b0e12f38823300a739302e2)
TBR=thestig@chromium.org
Review URL: https://codereview.chromium.org/1569973002 .
Diffstat (limited to 'testing')
-rw-r--r-- | testing/test_support.cpp | 18 | ||||
-rw-r--r-- | testing/test_support.h | 16 |
2 files changed, 34 insertions, 0 deletions
diff --git a/testing/test_support.cpp b/testing/test_support.cpp index 96e01c5b01..da5ea7e9ee 100644 --- a/testing/test_support.cpp +++ b/testing/test_support.cpp @@ -172,3 +172,21 @@ int TestLoader::GetBlock(void* param, memcpy(pBuf, pLoader->m_pBuf + pos, size); return 1; } + +TestSaver::TestSaver() { + FPDF_FILEWRITE::version = 1; + FPDF_FILEWRITE::WriteBlock = WriteBlockCallback; +} + +void TestSaver::ClearString() { + m_String.clear(); +} + +// static +int TestSaver::WriteBlockCallback(FPDF_FILEWRITE* pFileWrite, + const void* data, + unsigned long size) { + TestSaver* pThis = static_cast<TestSaver*>(pFileWrite); + pThis->m_String.append(static_cast<const char*>(data), size); + return 1; +} diff --git a/testing/test_support.h b/testing/test_support.h index 945704194d..f59d5440e7 100644 --- a/testing/test_support.h +++ b/testing/test_support.h @@ -10,6 +10,7 @@ #include <string> #include "public/fpdfview.h" +#include "public/fpdf_save.h" #ifdef PDF_ENABLE_V8 #include "v8/include/v8.h" @@ -62,4 +63,19 @@ class TestLoader { const size_t m_Len; }; +class TestSaver : public FPDF_FILEWRITE { + public: + TestSaver(); + + void ClearString(); + const std::string& GetString() const { return m_String; } + + private: + static int WriteBlockCallback(FPDF_FILEWRITE* pFileWrite, + const void* data, + unsigned long size); + + std::string m_String; +}; + #endif // TESTING_EMBEDDER_TEST_SUPPORT_H_ |