summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdfppo_embeddertest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk/fpdfppo_embeddertest.cpp')
-rw-r--r--fpdfsdk/fpdfppo_embeddertest.cpp56
1 files changed, 25 insertions, 31 deletions
diff --git a/fpdfsdk/fpdfppo_embeddertest.cpp b/fpdfsdk/fpdfppo_embeddertest.cpp
index 4e7b2ae82e..f62ca52048 100644
--- a/fpdfsdk/fpdfppo_embeddertest.cpp
+++ b/fpdfsdk/fpdfppo_embeddertest.cpp
@@ -215,17 +215,15 @@ TEST_F(FPDFPPOEmbeddertest, BUG_750568) {
for (size_t i = 0; i < 4; ++i) {
FPDF_PAGE page = LoadPage(i);
- ASSERT_NE(nullptr, page);
+ ASSERT_TRUE(page);
- FPDF_BITMAP bitmap = RenderPageDeprecated(page);
- ASSERT_EQ(200, FPDFBitmap_GetWidth(bitmap));
- ASSERT_EQ(200, FPDFBitmap_GetHeight(bitmap));
- ASSERT_EQ(800, FPDFBitmap_GetStride(bitmap));
+ std::unique_ptr<void, FPDFBitmapDeleter> bitmap = RenderLoadedPage(page);
+ ASSERT_EQ(200, FPDFBitmap_GetWidth(bitmap.get()));
+ ASSERT_EQ(200, FPDFBitmap_GetHeight(bitmap.get()));
+ ASSERT_EQ(800, FPDFBitmap_GetStride(bitmap.get()));
- std::string digest = HashBitmap(bitmap);
- FPDFBitmap_Destroy(bitmap);
+ EXPECT_EQ(kHashes[i], HashBitmap(bitmap.get()));
UnloadPage(page);
- EXPECT_EQ(kHashes[i], digest);
}
FPDF_DOCUMENT output_doc = FPDF_CreateNewDocument();
@@ -234,17 +232,16 @@ TEST_F(FPDFPPOEmbeddertest, BUG_750568) {
ASSERT_EQ(4, FPDF_GetPageCount(output_doc));
for (size_t i = 0; i < 4; ++i) {
FPDF_PAGE page = FPDF_LoadPage(output_doc, i);
- ASSERT_NE(nullptr, page);
+ ASSERT_TRUE(page);
- FPDF_BITMAP bitmap = RenderPageDeprecated(page);
- ASSERT_EQ(200, FPDFBitmap_GetWidth(bitmap));
- ASSERT_EQ(200, FPDFBitmap_GetHeight(bitmap));
- ASSERT_EQ(800, FPDFBitmap_GetStride(bitmap));
+ std::unique_ptr<void, FPDFBitmapDeleter> bitmap =
+ RenderPageWithFlags(page, nullptr, 0);
+ ASSERT_EQ(200, FPDFBitmap_GetWidth(bitmap.get()));
+ ASSERT_EQ(200, FPDFBitmap_GetHeight(bitmap.get()));
+ ASSERT_EQ(800, FPDFBitmap_GetStride(bitmap.get()));
- std::string digest = HashBitmap(bitmap);
- FPDFBitmap_Destroy(bitmap);
+ EXPECT_EQ(kHashes[i], HashBitmap(bitmap.get()));
FPDF_ClosePage(page);
- EXPECT_EQ(kHashes[i], digest);
}
FPDF_CloseDocument(output_doc);
}
@@ -252,15 +249,14 @@ TEST_F(FPDFPPOEmbeddertest, BUG_750568) {
TEST_F(FPDFPPOEmbeddertest, ImportWithZeroLengthStream) {
EXPECT_TRUE(OpenDocument("zero_length_stream.pdf"));
FPDF_PAGE page = LoadPage(0);
- ASSERT_NE(nullptr, page);
+ ASSERT_TRUE(page);
- FPDF_BITMAP bitmap = RenderPageDeprecated(page);
- ASSERT_EQ(200, FPDFBitmap_GetWidth(bitmap));
- ASSERT_EQ(200, FPDFBitmap_GetHeight(bitmap));
- ASSERT_EQ(800, FPDFBitmap_GetStride(bitmap));
+ std::unique_ptr<void, FPDFBitmapDeleter> bitmap = RenderLoadedPage(page);
+ ASSERT_EQ(200, FPDFBitmap_GetWidth(bitmap.get()));
+ ASSERT_EQ(200, FPDFBitmap_GetHeight(bitmap.get()));
+ ASSERT_EQ(800, FPDFBitmap_GetStride(bitmap.get()));
- std::string digest = HashBitmap(bitmap);
- FPDFBitmap_Destroy(bitmap);
+ std::string digest = HashBitmap(bitmap.get());
UnloadPage(page);
FPDF_DOCUMENT new_doc = FPDF_CreateNewDocument();
@@ -270,15 +266,13 @@ TEST_F(FPDFPPOEmbeddertest, ImportWithZeroLengthStream) {
EXPECT_EQ(1, FPDF_GetPageCount(new_doc));
FPDF_PAGE new_page = FPDF_LoadPage(new_doc, 0);
ASSERT_NE(nullptr, new_page);
- FPDF_BITMAP new_bitmap = RenderPageDeprecated(new_page);
- ASSERT_EQ(200, FPDFBitmap_GetWidth(new_bitmap));
- ASSERT_EQ(200, FPDFBitmap_GetHeight(new_bitmap));
- ASSERT_EQ(800, FPDFBitmap_GetStride(new_bitmap));
+ std::unique_ptr<void, FPDFBitmapDeleter> new_bitmap =
+ RenderPageWithFlags(new_page, nullptr, 0);
+ ASSERT_EQ(200, FPDFBitmap_GetWidth(new_bitmap.get()));
+ ASSERT_EQ(200, FPDFBitmap_GetHeight(new_bitmap.get()));
+ ASSERT_EQ(800, FPDFBitmap_GetStride(new_bitmap.get()));
- std::string new_digest = HashBitmap(new_bitmap);
- FPDFBitmap_Destroy(new_bitmap);
+ EXPECT_EQ(digest, HashBitmap(new_bitmap.get()));
FPDF_ClosePage(new_page);
FPDF_CloseDocument(new_doc);
-
- EXPECT_EQ(digest, new_digest);
}