diff options
author | Henrique Nakashima <hnakashima@chromium.org> | 2018-06-06 19:17:34 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-06-06 19:17:34 +0000 |
commit | 7c2e8a32c34e0a258963daf6483d5af1695a3dba (patch) | |
tree | 7f916521fb3e2f9d7e7b8d3c5b1989d82ff3c453 /testing/embedder_test.cpp | |
parent | b8a2978cbff28424cb6364092236072dba8073d7 (diff) | |
download | pdfium-7c2e8a32c34e0a258963daf6483d5af1695a3dba.tar.xz |
Embedder tests can write saved PDFs to a file for debugging.
Before calling a method that use EmbedderTest as FPDF_FILEWRITE
(usually calling FPDF_SaveAsCopy()), call:
OpenPDFFileForWrite("Filename.pdf");
After the write, close the stream with:
ClosePDFFileForWrite();
Change-Id: Id1e7f778a9ff2b2b5bf976d49b485d5cb15f94bd
Reviewed-on: https://pdfium-review.googlesource.com/34150
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
Diffstat (limited to 'testing/embedder_test.cpp')
-rw-r--r-- | testing/embedder_test.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/testing/embedder_test.cpp b/testing/embedder_test.cpp index 03eebe3abc..e4ac4ad2c7 100644 --- a/testing/embedder_test.cpp +++ b/testing/embedder_test.cpp @@ -546,7 +546,12 @@ int EmbedderTest::WriteBlockCallback(FPDF_FILEWRITE* pFileWrite, const void* data, unsigned long size) { EmbedderTest* pThis = static_cast<EmbedderTest*>(pFileWrite); + pThis->data_string_.append(static_cast<const char*>(data), size); + + if (pThis->filestream_.is_open()) + pThis->filestream_.write(static_cast<const char*>(data), size); + return 1; } @@ -587,3 +592,11 @@ int EmbedderTest::GetPageNumberForLoadedPage(FPDF_PAGE page) const { int EmbedderTest::GetPageNumberForSavedPage(FPDF_PAGE page) const { return GetPageNumberForPage(saved_page_map_, page); } + +void EmbedderTest::OpenPDFFileForWrite(const char* filename) { + filestream_.open(filename, std::ios_base::binary); +} + +void EmbedderTest::ClosePDFFileForWrite() { + filestream_.close(); +} |