Mark more methods in EmbedderTest as debug-only.
Like WriteBitmapToPng(), OpenPDFFileForWrite() and
ClosePDFFileForWrite() are only used for developers for debugging. So
guard them with #ifndef NDEBUG, better document them, and pass a
consistent string type for the |filename| parameter.
Change-Id: I40c80a790895bb0eb0eaa3a4f1fa3a3303084e1a
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/63872
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/testing/embedder_test.cpp b/testing/embedder_test.cpp
index 265b33f..372d059 100644
--- a/testing/embedder_test.cpp
+++ b/testing/embedder_test.cpp
@@ -695,10 +695,12 @@
return GetPageNumberForPage(saved_page_map_, page);
}
-void EmbedderTest::OpenPDFFileForWrite(const char* filename) {
+#ifndef NDEBUG
+void EmbedderTest::OpenPDFFileForWrite(const std::string& filename) {
filestream_.open(filename, std::ios_base::binary);
}
void EmbedderTest::ClosePDFFileForWrite() {
filestream_.close();
}
+#endif
diff --git a/testing/embedder_test.h b/testing/embedder_test.h
index 0711bfa..5896d8a 100644
--- a/testing/embedder_test.h
+++ b/testing/embedder_test.h
@@ -196,7 +196,7 @@
#ifndef NDEBUG
// For debugging purposes.
- // Write |bitmap| to a png file.
+ // Write |bitmap| as a PNG to |filename|.
static void WriteBitmapToPng(FPDF_BITMAP bitmap, const std::string& filename);
#endif
@@ -229,8 +229,14 @@
void SetWholeFileAvailable();
- void OpenPDFFileForWrite(const char* filename);
+#ifndef NDEBUG
+ // For debugging purposes.
+ // While open, write any data that gets passed to WriteBlockCallback() to
+ // |filename|. This is typically used to capture data from FPDF_SaveAsCopy()
+ // calls.
+ void OpenPDFFileForWrite(const std::string& filename);
void ClosePDFFileForWrite();
+#endif
std::unique_ptr<Delegate> default_delegate_;
Delegate* delegate_;