summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-02-12 14:58:44 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-02-12 14:58:44 +0000
commitc113c7aa67aac8ce597a1c15da065389bba36b9b (patch)
treee0dc1e16034ab5d2d7a532b20721e3ad2d073ceb
parent9e705dfe91b1cc36a3333c963500a656a0e635a8 (diff)
downloadpdfium-c113c7aa67aac8ce597a1c15da065389bba36b9b.tar.xz
Get rid of EmbedderTest::RenderPageWithFlagsDeprecated().
Change-Id: I653619faa61181137795bb3675418fd8d0945d25 Reviewed-on: https://pdfium-review.googlesource.com/25590 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
-rw-r--r--fpdfsdk/fpdfannot_embeddertest.cpp139
-rw-r--r--fpdfsdk/fpdfedit_embeddertest.cpp13
-rw-r--r--testing/embedder_test.cpp7
-rw-r--r--testing/embedder_test.h8
4 files changed, 90 insertions, 77 deletions
diff --git a/fpdfsdk/fpdfannot_embeddertest.cpp b/fpdfsdk/fpdfannot_embeddertest.cpp
index 5406397375..310d042885 100644
--- a/fpdfsdk/fpdfannot_embeddertest.cpp
+++ b/fpdfsdk/fpdfannot_embeddertest.cpp
@@ -362,10 +362,11 @@ TEST_F(FPDFAnnotEmbeddertest, ModifyRectQuadpointsWithAP) {
EXPECT_EQ(4, FPDFPage_GetAnnotCount(page));
// Check that the original file renders correctly.
- FPDF_BITMAP bitmap =
- RenderPageWithFlagsDeprecated(page, form_handle_, FPDF_ANNOT);
- CompareBitmap(bitmap, 612, 792, md5_original);
- FPDFBitmap_Destroy(bitmap);
+ {
+ std::unique_ptr<void, FPDFBitmapDeleter> bitmap =
+ RenderLoadedPageWithFlags(page, FPDF_ANNOT);
+ CompareBitmap(bitmap.get(), 612, 792, md5_original);
+ }
FS_RECTF rect;
FS_RECTF new_rect;
@@ -403,9 +404,11 @@ TEST_F(FPDFAnnotEmbeddertest, ModifyRectQuadpointsWithAP) {
EXPECT_EQ(quadpoints.y4, new_quadpoints.y4);
// Check that updating quadpoints does not change the annotation's position.
- bitmap = RenderPageWithFlagsDeprecated(page, form_handle_, FPDF_ANNOT);
- CompareBitmap(bitmap, 612, 792, md5_original);
- FPDFBitmap_Destroy(bitmap);
+ {
+ std::unique_ptr<void, FPDFBitmapDeleter> bitmap =
+ RenderLoadedPageWithFlags(page, FPDF_ANNOT);
+ CompareBitmap(bitmap.get(), 612, 792, md5_original);
+ }
// Verify its annotation rectangle.
ASSERT_TRUE(FPDFAnnot_GetRect(annot.get(), &rect));
@@ -423,9 +426,11 @@ TEST_F(FPDFAnnotEmbeddertest, ModifyRectQuadpointsWithAP) {
}
// Check that updating the rectangle changes the annotation's position.
- bitmap = RenderPageWithFlagsDeprecated(page, form_handle_, FPDF_ANNOT);
- CompareBitmap(bitmap, 612, 792, md5_modified_highlight);
- FPDFBitmap_Destroy(bitmap);
+ {
+ std::unique_ptr<void, FPDFBitmapDeleter> bitmap =
+ RenderLoadedPageWithFlags(page, FPDF_ANNOT);
+ CompareBitmap(bitmap.get(), 612, 792, md5_modified_highlight);
+ }
{
// Retrieve the square annotation which has its AP stream already defined.
@@ -444,9 +449,9 @@ TEST_F(FPDFAnnotEmbeddertest, ModifyRectQuadpointsWithAP) {
// Check that updating the rectangle changes the square annotation's
// position.
- bitmap = RenderPageWithFlagsDeprecated(page, form_handle_, FPDF_ANNOT);
- CompareBitmap(bitmap, 612, 792, md5_modified_square);
- FPDFBitmap_Destroy(bitmap);
+ std::unique_ptr<void, FPDFBitmapDeleter> bitmap =
+ RenderLoadedPageWithFlags(page, FPDF_ANNOT);
+ CompareBitmap(bitmap.get(), 612, 792, md5_modified_square);
}
UnloadPage(page);
@@ -556,10 +561,11 @@ TEST_F(FPDFAnnotEmbeddertest, AddAndModifyPath) {
EXPECT_EQ(2, FPDFPage_GetAnnotCount(page));
// Check that the page renders correctly.
- FPDF_BITMAP bitmap =
- RenderPageWithFlagsDeprecated(page, form_handle_, FPDF_ANNOT);
- CompareBitmap(bitmap, 595, 842, md5_original);
- FPDFBitmap_Destroy(bitmap);
+ {
+ std::unique_ptr<void, FPDFBitmapDeleter> bitmap =
+ RenderLoadedPageWithFlags(page, FPDF_ANNOT);
+ CompareBitmap(bitmap.get(), 595, 842, md5_original);
+ }
{
// Retrieve the stamp annotation which has its AP stream already defined.
@@ -580,9 +586,11 @@ TEST_F(FPDFAnnotEmbeddertest, AddAndModifyPath) {
EXPECT_TRUE(FPDFAnnot_UpdateObject(annot.get(), path));
// Check that the page with the modified annotation renders correctly.
- bitmap = RenderPageWithFlagsDeprecated(page, form_handle_, FPDF_ANNOT);
- CompareBitmap(bitmap, 595, 842, md5_modified_path);
- FPDFBitmap_Destroy(bitmap);
+ {
+ std::unique_ptr<void, FPDFBitmapDeleter> bitmap =
+ RenderLoadedPageWithFlags(page, FPDF_ANNOT);
+ CompareBitmap(bitmap.get(), 595, 842, md5_modified_path);
+ }
// Add a second path object to the same annotation.
FPDF_PAGEOBJECT dot = FPDFPageObj_CreateNewPath(7, 84);
@@ -594,9 +602,11 @@ TEST_F(FPDFAnnotEmbeddertest, AddAndModifyPath) {
EXPECT_EQ(2, FPDFAnnot_GetObjectCount(annot.get()));
// Check that the page with an annotation with two paths renders correctly.
- bitmap = RenderPageWithFlagsDeprecated(page, form_handle_, FPDF_ANNOT);
- CompareBitmap(bitmap, 595, 842, md5_two_paths);
- FPDFBitmap_Destroy(bitmap);
+ {
+ std::unique_ptr<void, FPDFBitmapDeleter> bitmap =
+ RenderLoadedPageWithFlags(page, FPDF_ANNOT);
+ CompareBitmap(bitmap.get(), 595, 842, md5_two_paths);
+ }
// Delete the newly added path object.
EXPECT_TRUE(FPDFAnnot_RemoveObject(annot.get(), 1));
@@ -604,9 +614,11 @@ TEST_F(FPDFAnnotEmbeddertest, AddAndModifyPath) {
}
// Check that the page renders the same as before.
- bitmap = RenderPageWithFlagsDeprecated(page, form_handle_, FPDF_ANNOT);
- CompareBitmap(bitmap, 595, 842, md5_modified_path);
- FPDFBitmap_Destroy(bitmap);
+ {
+ std::unique_ptr<void, FPDFBitmapDeleter> bitmap =
+ RenderLoadedPageWithFlags(page, FPDF_ANNOT);
+ CompareBitmap(bitmap.get(), 595, 842, md5_modified_path);
+ }
FS_RECTF rect;
@@ -680,10 +692,11 @@ TEST_F(FPDFAnnotEmbeddertest, ModifyAnnotationFlags) {
ASSERT_TRUE(page);
// Check that the page renders correctly.
- FPDF_BITMAP bitmap =
- RenderPageWithFlagsDeprecated(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");
+ }
{
// Retrieve the annotation.
@@ -704,9 +717,11 @@ TEST_F(FPDFAnnotEmbeddertest, ModifyAnnotationFlags) {
EXPECT_TRUE(flags & FPDF_ANNOT_FLAG_PRINT);
// Check that the page renders correctly without rendering the annotation.
- bitmap = RenderPageWithFlagsDeprecated(page, form_handle_, FPDF_ANNOT);
- CompareBitmap(bitmap, 612, 792, "1940568c9ba33bac5d0b1ee9558c76b3");
- FPDFBitmap_Destroy(bitmap);
+ {
+ std::unique_ptr<void, FPDFBitmapDeleter> bitmap =
+ RenderLoadedPageWithFlags(page, FPDF_ANNOT);
+ CompareBitmap(bitmap.get(), 612, 792, "1940568c9ba33bac5d0b1ee9558c76b3");
+ }
// Unset the HIDDEN flag.
EXPECT_TRUE(FPDFAnnot_SetFlags(annot.get(), FPDF_ANNOT_FLAG_NONE));
@@ -718,9 +733,11 @@ TEST_F(FPDFAnnotEmbeddertest, ModifyAnnotationFlags) {
EXPECT_TRUE(flags & FPDF_ANNOT_FLAG_PRINT);
// Check that the page renders correctly as before.
- bitmap = RenderPageWithFlagsDeprecated(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);
@@ -744,10 +761,11 @@ TEST_F(FPDFAnnotEmbeddertest, AddAndModifyImage) {
EXPECT_EQ(2, FPDFPage_GetAnnotCount(page));
// Check that the page renders correctly.
- FPDF_BITMAP bitmap =
- RenderPageWithFlagsDeprecated(page, form_handle_, FPDF_ANNOT);
- CompareBitmap(bitmap, 595, 842, md5_original);
- FPDFBitmap_Destroy(bitmap);
+ {
+ std::unique_ptr<void, FPDFBitmapDeleter> bitmap =
+ RenderLoadedPageWithFlags(page, FPDF_ANNOT);
+ CompareBitmap(bitmap.get(), 595, 842, md5_original);
+ }
constexpr int kBitmapSize = 200;
FPDF_BITMAP image_bitmap;
@@ -779,9 +797,11 @@ TEST_F(FPDFAnnotEmbeddertest, AddAndModifyImage) {
}
// Check that the page renders correctly with the new image object.
- bitmap = RenderPageWithFlagsDeprecated(page, form_handle_, FPDF_ANNOT);
- CompareBitmap(bitmap, 595, 842, md5_new_image);
- FPDFBitmap_Destroy(bitmap);
+ {
+ std::unique_ptr<void, FPDFBitmapDeleter> bitmap =
+ RenderLoadedPageWithFlags(page, FPDF_ANNOT);
+ CompareBitmap(bitmap.get(), 595, 842, md5_new_image);
+ }
{
// Retrieve the newly added stamp annotation and its image object.
@@ -826,10 +846,11 @@ TEST_F(FPDFAnnotEmbeddertest, AddAndModifyText) {
EXPECT_EQ(2, FPDFPage_GetAnnotCount(page));
// Check that the page renders correctly.
- FPDF_BITMAP bitmap =
- RenderPageWithFlagsDeprecated(page, form_handle_, FPDF_ANNOT);
- CompareBitmap(bitmap, 595, 842, md5_original);
- FPDFBitmap_Destroy(bitmap);
+ {
+ std::unique_ptr<void, FPDFBitmapDeleter> bitmap =
+ RenderLoadedPageWithFlags(page, FPDF_ANNOT);
+ CompareBitmap(bitmap.get(), 595, 842, md5_original);
+ }
{
// Create a stamp annotation and set its annotation rectangle.
@@ -856,9 +877,11 @@ TEST_F(FPDFAnnotEmbeddertest, AddAndModifyText) {
}
// Check that the page renders correctly with the new text object.
- bitmap = RenderPageWithFlagsDeprecated(page, form_handle_, FPDF_ANNOT);
- CompareBitmap(bitmap, 595, 842, md5_new_text);
- FPDFBitmap_Destroy(bitmap);
+ {
+ std::unique_ptr<void, FPDFBitmapDeleter> bitmap =
+ RenderLoadedPageWithFlags(page, FPDF_ANNOT);
+ CompareBitmap(bitmap.get(), 595, 842, md5_new_text);
+ }
{
// Retrieve the newly added stamp annotation and its text object.
@@ -877,15 +900,19 @@ TEST_F(FPDFAnnotEmbeddertest, AddAndModifyText) {
}
// Check that the page renders correctly with the modified text object.
- bitmap = RenderPageWithFlagsDeprecated(page, form_handle_, FPDF_ANNOT);
- CompareBitmap(bitmap, 595, 842, md5_modified_text);
- FPDFBitmap_Destroy(bitmap);
+ {
+ std::unique_ptr<void, FPDFBitmapDeleter> bitmap =
+ RenderLoadedPageWithFlags(page, FPDF_ANNOT);
+ CompareBitmap(bitmap.get(), 595, 842, md5_modified_text);
+ }
// Remove the new annotation, and check that the page renders as before.
EXPECT_TRUE(FPDFPage_RemoveAnnot(page, 2));
- bitmap = RenderPageWithFlagsDeprecated(page, form_handle_, FPDF_ANNOT);
- CompareBitmap(bitmap, 595, 842, md5_original);
- FPDFBitmap_Destroy(bitmap);
+ {
+ std::unique_ptr<void, FPDFBitmapDeleter> bitmap =
+ RenderLoadedPageWithFlags(page, FPDF_ANNOT);
+ CompareBitmap(bitmap.get(), 595, 842, md5_original);
+ }
UnloadPage(page);
}
diff --git a/fpdfsdk/fpdfedit_embeddertest.cpp b/fpdfsdk/fpdfedit_embeddertest.cpp
index 3787318418..8c97d42365 100644
--- a/fpdfsdk/fpdfedit_embeddertest.cpp
+++ b/fpdfsdk/fpdfedit_embeddertest.cpp
@@ -483,11 +483,12 @@ TEST_F(FPDFEditEmbeddertest, EditOverExistingContent) {
EXPECT_TRUE(FPDFPath_SetFillColor(green_rect2, 0, 255, 0, 100));
EXPECT_TRUE(FPDFPath_SetDrawMode(green_rect2, FPDF_FILLMODE_ALTERNATE, 0));
FPDFPage_InsertObject(saved_page, green_rect2);
- FPDF_BITMAP new_bitmap =
- RenderPageWithFlagsDeprecated(saved_page, saved_form_handle_, 0);
- const char last_md5[] = "4b5b00f824620f8c9b8801ebb98e1cdd";
- CompareBitmap(new_bitmap, 612, 792, last_md5);
- FPDFBitmap_Destroy(new_bitmap);
+ const char kLastMD5[] = "4b5b00f824620f8c9b8801ebb98e1cdd";
+ {
+ std::unique_ptr<void, FPDFBitmapDeleter> new_bitmap =
+ RenderSavedPage(saved_page);
+ CompareBitmap(new_bitmap.get(), 612, 792, kLastMD5);
+ }
EXPECT_TRUE(FPDFPage_GenerateContent(saved_page));
// Now save the result, closing the page and document
@@ -497,7 +498,7 @@ TEST_F(FPDFEditEmbeddertest, EditOverExistingContent) {
CloseSavedDocument();
// Render the saved result
- VerifySavedDocument(612, 792, last_md5);
+ VerifySavedDocument(612, 792, kLastMD5);
}
TEST_F(FPDFEditEmbeddertest, AddStrokedPaths) {
diff --git a/testing/embedder_test.cpp b/testing/embedder_test.cpp
index 549ebe1f80..b4f3851e3e 100644
--- a/testing/embedder_test.cpp
+++ b/testing/embedder_test.cpp
@@ -312,13 +312,6 @@ std::unique_ptr<void, FPDFBitmapDeleter> EmbedderTest::RenderSavedPageWithFlags(
}
// static
-FPDF_BITMAP EmbedderTest::RenderPageWithFlagsDeprecated(FPDF_PAGE page,
- FPDF_FORMHANDLE handle,
- int flags) {
- return RenderPageWithFlags(page, handle, flags).release();
-}
-
-// static
std::unique_ptr<void, FPDFBitmapDeleter> EmbedderTest::RenderPageWithFlags(
FPDF_PAGE page,
FPDF_FORMHANDLE handle,
diff --git a/testing/embedder_test.h b/testing/embedder_test.h
index dc91df8bf3..c1f1844eba 100644
--- a/testing/embedder_test.h
+++ b/testing/embedder_test.h
@@ -141,14 +141,6 @@ class EmbedderTest : public ::testing::Test,
FPDF_PAGE page,
int flags);
- // DEPRECATED. Use RenderPageWithFlags() instead.
- // Caller takes ownership of the returned bitmap.
- //
- // See public/fpdfview.h for a list of page rendering flags.
- static FPDF_BITMAP RenderPageWithFlagsDeprecated(FPDF_PAGE page,
- FPDF_FORMHANDLE handle,
- int flags);
-
// Convert |page| into a bitmap with the specified page rendering |flags|.
// The form handle associated with |page| should be passed in via |handle|.
// If |handle| is nullptr, then forms on the page will not be rendered.