summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdfannot_embeddertest.cpp
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-02-07 20:28:35 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-02-07 20:28:35 +0000
commita98e36657d0e5a78e216f828b3e712e85250c1a7 (patch)
tree4621be8a3be00efafe28eea4639b87675db80d2b /fpdfsdk/fpdfannot_embeddertest.cpp
parent2496f8e3f3cb1cbfffd664c9b5d7983dc192887b (diff)
downloadpdfium-a98e36657d0e5a78e216f828b3e712e85250c1a7.tar.xz
Clean up RenderPage methods in EmbedderTest.
Add replacement methods that make themselves clear as to what they are rendering, and return unique_ptrs to help prevent leakage. Mark existing methods deprecated. Change-Id: I9055407e614dfbe765428fb32a7da64df3418d1d Reviewed-on: https://pdfium-review.googlesource.com/25470 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdfannot_embeddertest.cpp')
-rw-r--r--fpdfsdk/fpdfannot_embeddertest.cpp45
1 files changed, 25 insertions, 20 deletions
diff --git a/fpdfsdk/fpdfannot_embeddertest.cpp b/fpdfsdk/fpdfannot_embeddertest.cpp
index ba9bbe0ea9..5b5c29717b 100644
--- a/fpdfsdk/fpdfannot_embeddertest.cpp
+++ b/fpdfsdk/fpdfannot_embeddertest.cpp
@@ -38,9 +38,9 @@ TEST_F(FPDFAnnotEmbeddertest, RenderAnnotWithOnlyRolloverAP) {
// normal appearance defined, only its rollover appearance. In this case, its
// normal appearance should be generated, allowing the highlight annotation to
// still display.
- FPDF_BITMAP bitmap = RenderPageWithFlags(page, form_handle(), FPDF_ANNOT);
- CompareBitmap(bitmap, 612, 792, "dc98f06da047bd8aabfa99562d2cbd1e");
- FPDFBitmap_Destroy(bitmap);
+ std::unique_ptr<void, FPDFBitmapDeleter> bitmap =
+ RenderLoadedPageWithFlags(page, FPDF_ANNOT);
+ CompareBitmap(bitmap.get(), 612, 792, "dc98f06da047bd8aabfa99562d2cbd1e");
UnloadPage(page);
}
@@ -356,7 +356,8 @@ TEST_F(FPDFAnnotEmbeddertest, ModifyRectQuadpointsWithAP) {
EXPECT_EQ(4, FPDFPage_GetAnnotCount(page));
// Check that the original file renders correctly.
- FPDF_BITMAP bitmap = RenderPageWithFlags(page, form_handle_, FPDF_ANNOT);
+ FPDF_BITMAP bitmap =
+ RenderPageWithFlagsDeprecated(page, form_handle_, FPDF_ANNOT);
CompareBitmap(bitmap, 612, 792, md5_original);
FPDFBitmap_Destroy(bitmap);
@@ -396,7 +397,7 @@ TEST_F(FPDFAnnotEmbeddertest, ModifyRectQuadpointsWithAP) {
EXPECT_EQ(quadpoints.y4, new_quadpoints.y4);
// Check that updating quadpoints does not change the annotation's position.
- bitmap = RenderPageWithFlags(page, form_handle_, FPDF_ANNOT);
+ bitmap = RenderPageWithFlagsDeprecated(page, form_handle_, FPDF_ANNOT);
CompareBitmap(bitmap, 612, 792, md5_original);
FPDFBitmap_Destroy(bitmap);
@@ -416,7 +417,7 @@ TEST_F(FPDFAnnotEmbeddertest, ModifyRectQuadpointsWithAP) {
}
// Check that updating the rectangle changes the annotation's position.
- bitmap = RenderPageWithFlags(page, form_handle_, FPDF_ANNOT);
+ bitmap = RenderPageWithFlagsDeprecated(page, form_handle_, FPDF_ANNOT);
CompareBitmap(bitmap, 612, 792, md5_modified_highlight);
FPDFBitmap_Destroy(bitmap);
@@ -437,7 +438,7 @@ TEST_F(FPDFAnnotEmbeddertest, ModifyRectQuadpointsWithAP) {
// Check that updating the rectangle changes the square annotation's
// position.
- bitmap = RenderPageWithFlags(page, form_handle_, FPDF_ANNOT);
+ bitmap = RenderPageWithFlagsDeprecated(page, form_handle_, FPDF_ANNOT);
CompareBitmap(bitmap, 612, 792, md5_modified_square);
FPDFBitmap_Destroy(bitmap);
}
@@ -546,7 +547,8 @@ TEST_F(FPDFAnnotEmbeddertest, AddAndModifyPath) {
EXPECT_EQ(2, FPDFPage_GetAnnotCount(page));
// Check that the page renders correctly.
- FPDF_BITMAP bitmap = RenderPageWithFlags(page, form_handle_, FPDF_ANNOT);
+ FPDF_BITMAP bitmap =
+ RenderPageWithFlagsDeprecated(page, form_handle_, FPDF_ANNOT);
CompareBitmap(bitmap, 595, 842, md5_original);
FPDFBitmap_Destroy(bitmap);
@@ -569,7 +571,7 @@ TEST_F(FPDFAnnotEmbeddertest, AddAndModifyPath) {
EXPECT_TRUE(FPDFAnnot_UpdateObject(annot.get(), path));
// Check that the page with the modified annotation renders correctly.
- bitmap = RenderPageWithFlags(page, form_handle_, FPDF_ANNOT);
+ bitmap = RenderPageWithFlagsDeprecated(page, form_handle_, FPDF_ANNOT);
CompareBitmap(bitmap, 595, 842, md5_modified_path);
FPDFBitmap_Destroy(bitmap);
@@ -583,7 +585,7 @@ TEST_F(FPDFAnnotEmbeddertest, AddAndModifyPath) {
EXPECT_EQ(2, FPDFAnnot_GetObjectCount(annot.get()));
// Check that the page with an annotation with two paths renders correctly.
- bitmap = RenderPageWithFlags(page, form_handle_, FPDF_ANNOT);
+ bitmap = RenderPageWithFlagsDeprecated(page, form_handle_, FPDF_ANNOT);
CompareBitmap(bitmap, 595, 842, md5_two_paths);
FPDFBitmap_Destroy(bitmap);
@@ -593,7 +595,7 @@ TEST_F(FPDFAnnotEmbeddertest, AddAndModifyPath) {
}
// Check that the page renders the same as before.
- bitmap = RenderPageWithFlags(page, form_handle_, FPDF_ANNOT);
+ bitmap = RenderPageWithFlagsDeprecated(page, form_handle_, FPDF_ANNOT);
CompareBitmap(bitmap, 595, 842, md5_modified_path);
FPDFBitmap_Destroy(bitmap);
@@ -669,7 +671,8 @@ TEST_F(FPDFAnnotEmbeddertest, ModifyAnnotationFlags) {
ASSERT_TRUE(page);
// Check that the page renders correctly.
- FPDF_BITMAP bitmap = RenderPageWithFlags(page, form_handle_, FPDF_ANNOT);
+ FPDF_BITMAP bitmap =
+ RenderPageWithFlagsDeprecated(page, form_handle_, FPDF_ANNOT);
CompareBitmap(bitmap, 612, 792, "dc98f06da047bd8aabfa99562d2cbd1e");
FPDFBitmap_Destroy(bitmap);
@@ -692,7 +695,7 @@ TEST_F(FPDFAnnotEmbeddertest, ModifyAnnotationFlags) {
EXPECT_TRUE(flags & FPDF_ANNOT_FLAG_PRINT);
// Check that the page renders correctly without rendering the annotation.
- bitmap = RenderPageWithFlags(page, form_handle_, FPDF_ANNOT);
+ bitmap = RenderPageWithFlagsDeprecated(page, form_handle_, FPDF_ANNOT);
CompareBitmap(bitmap, 612, 792, "1940568c9ba33bac5d0b1ee9558c76b3");
FPDFBitmap_Destroy(bitmap);
@@ -706,7 +709,7 @@ TEST_F(FPDFAnnotEmbeddertest, ModifyAnnotationFlags) {
EXPECT_TRUE(flags & FPDF_ANNOT_FLAG_PRINT);
// Check that the page renders correctly as before.
- bitmap = RenderPageWithFlags(page, form_handle_, FPDF_ANNOT);
+ bitmap = RenderPageWithFlagsDeprecated(page, form_handle_, FPDF_ANNOT);
CompareBitmap(bitmap, 612, 792, "dc98f06da047bd8aabfa99562d2cbd1e");
FPDFBitmap_Destroy(bitmap);
}
@@ -732,7 +735,8 @@ TEST_F(FPDFAnnotEmbeddertest, AddAndModifyImage) {
EXPECT_EQ(2, FPDFPage_GetAnnotCount(page));
// Check that the page renders correctly.
- FPDF_BITMAP bitmap = RenderPageWithFlags(page, form_handle_, FPDF_ANNOT);
+ FPDF_BITMAP bitmap =
+ RenderPageWithFlagsDeprecated(page, form_handle_, FPDF_ANNOT);
CompareBitmap(bitmap, 595, 842, md5_original);
FPDFBitmap_Destroy(bitmap);
@@ -766,7 +770,7 @@ TEST_F(FPDFAnnotEmbeddertest, AddAndModifyImage) {
}
// Check that the page renders correctly with the new image object.
- bitmap = RenderPageWithFlags(page, form_handle_, FPDF_ANNOT);
+ bitmap = RenderPageWithFlagsDeprecated(page, form_handle_, FPDF_ANNOT);
CompareBitmap(bitmap, 595, 842, md5_new_image);
FPDFBitmap_Destroy(bitmap);
@@ -813,7 +817,8 @@ TEST_F(FPDFAnnotEmbeddertest, AddAndModifyText) {
EXPECT_EQ(2, FPDFPage_GetAnnotCount(page));
// Check that the page renders correctly.
- FPDF_BITMAP bitmap = RenderPageWithFlags(page, form_handle_, FPDF_ANNOT);
+ FPDF_BITMAP bitmap =
+ RenderPageWithFlagsDeprecated(page, form_handle_, FPDF_ANNOT);
CompareBitmap(bitmap, 595, 842, md5_original);
FPDFBitmap_Destroy(bitmap);
@@ -842,7 +847,7 @@ TEST_F(FPDFAnnotEmbeddertest, AddAndModifyText) {
}
// Check that the page renders correctly with the new text object.
- bitmap = RenderPageWithFlags(page, form_handle_, FPDF_ANNOT);
+ bitmap = RenderPageWithFlagsDeprecated(page, form_handle_, FPDF_ANNOT);
CompareBitmap(bitmap, 595, 842, md5_new_text);
FPDFBitmap_Destroy(bitmap);
@@ -863,13 +868,13 @@ TEST_F(FPDFAnnotEmbeddertest, AddAndModifyText) {
}
// Check that the page renders correctly with the modified text object.
- bitmap = RenderPageWithFlags(page, form_handle_, FPDF_ANNOT);
+ bitmap = RenderPageWithFlagsDeprecated(page, form_handle_, FPDF_ANNOT);
CompareBitmap(bitmap, 595, 842, md5_modified_text);
FPDFBitmap_Destroy(bitmap);
// Remove the new annotation, and check that the page renders as before.
EXPECT_TRUE(FPDFPage_RemoveAnnot(page, 2));
- bitmap = RenderPageWithFlags(page, form_handle_, FPDF_ANNOT);
+ bitmap = RenderPageWithFlagsDeprecated(page, form_handle_, FPDF_ANNOT);
CompareBitmap(bitmap, 595, 842, md5_original);
FPDFBitmap_Destroy(bitmap);