summaryrefslogtreecommitdiff
path: root/testing
diff options
context:
space:
mode:
Diffstat (limited to 'testing')
-rw-r--r--testing/embedder_test.cpp23
-rw-r--r--testing/embedder_test.h5
-rw-r--r--testing/resources/linearized.pdfbin0 -> 11384 bytes
3 files changed, 16 insertions, 12 deletions
diff --git a/testing/embedder_test.cpp b/testing/embedder_test.cpp
index 36ee08f85d..bb202bff1c 100644
--- a/testing/embedder_test.cpp
+++ b/testing/embedder_test.cpp
@@ -106,6 +106,8 @@ void EmbedderTest::SetUp() {
info->version = 1;
info->FSDK_UnSupport_Handler = UnsupportedHandlerTrampoline;
FSDK_SetUnSpObjProcessHandler(info);
+
+ m_SavedDocument = nullptr;
}
void EmbedderTest::TearDown() {
@@ -347,6 +349,10 @@ FPDF_PAGE EmbedderTest::LoadSavedPage(int page_number) {
return page;
}
+FPDF_BITMAP EmbedderTest::RenderSavedPage(FPDF_PAGE page) {
+ return RenderPageWithFlags(page, m_SavedForm, 0);
+}
+
void EmbedderTest::CloseSavedPage(FPDF_PAGE page) {
ASSERT(page);
FPDF_ClosePage(page);
@@ -424,14 +430,14 @@ FPDF_PAGE EmbedderTest::GetPageTrampoline(FPDF_FORMFILLINFO* info,
page_index);
}
-std::string EmbedderTest::HashBitmap(FPDF_BITMAP bitmap,
- int expected_width,
- int expected_height) {
+// static
+std::string EmbedderTest::HashBitmap(FPDF_BITMAP bitmap) {
uint8_t digest[16];
- CRYPT_MD5Generate(
- static_cast<uint8_t*>(FPDFBitmap_GetBuffer(bitmap)),
- expected_width * GetBitmapBytesPerPixel(bitmap) * expected_height,
- digest);
+ CRYPT_MD5Generate(static_cast<uint8_t*>(FPDFBitmap_GetBuffer(bitmap)),
+ FPDFBitmap_GetWidth(bitmap) *
+ GetBitmapBytesPerPixel(bitmap) *
+ FPDFBitmap_GetHeight(bitmap),
+ digest);
return CryptToBase16(digest);
}
@@ -452,8 +458,7 @@ void EmbedderTest::CompareBitmap(FPDF_BITMAP bitmap,
if (!expected_md5sum)
return;
- EXPECT_EQ(expected_md5sum,
- HashBitmap(bitmap, expected_width, expected_height));
+ EXPECT_EQ(expected_md5sum, HashBitmap(bitmap));
}
// static
diff --git a/testing/embedder_test.h b/testing/embedder_test.h
index df9e837f0f..7b6b40a818 100644
--- a/testing/embedder_test.h
+++ b/testing/embedder_test.h
@@ -125,9 +125,7 @@ class EmbedderTest : public ::testing::Test,
FPDF_FORMHANDLE SetupFormFillEnvironment(FPDF_DOCUMENT doc);
// Return the hash of |bitmap|.
- static std::string HashBitmap(FPDF_BITMAP bitmap,
- int expected_width,
- int expected_height);
+ static std::string HashBitmap(FPDF_BITMAP bitmap);
// Check |bitmap| to make sure it has the right dimensions and content.
static void CompareBitmap(FPDF_BITMAP bitmap,
@@ -146,6 +144,7 @@ class EmbedderTest : public ::testing::Test,
FPDF_DOCUMENT OpenSavedDocument(const char* password = nullptr);
void CloseSavedDocument();
FPDF_PAGE LoadSavedPage(int page_number);
+ FPDF_BITMAP RenderSavedPage(FPDF_PAGE page);
void CloseSavedPage(FPDF_PAGE page);
void VerifySavedRendering(FPDF_PAGE page,
int width,
diff --git a/testing/resources/linearized.pdf b/testing/resources/linearized.pdf
new file mode 100644
index 0000000000..3c2d3a25a2
--- /dev/null
+++ b/testing/resources/linearized.pdf
Binary files differ