diff options
author | Lei Zhang <thestig@chromium.org> | 2018-02-07 23:00:07 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-02-07 23:00:07 +0000 |
commit | 6183a6e7693b7aeb9763eaa130b43269b13a02d7 (patch) | |
tree | 713cb705473751210b1ec89d6a6f365f888f0d5e /core | |
parent | 9ad9a5fc81a36ab406ff49408dd0814d350bbc7e (diff) | |
download | pdfium-6183a6e7693b7aeb9763eaa130b43269b13a02d7.tar.xz |
Remove some deprecated RenderPage method usage.
Do some additional checks in test cases where pages were rendered but
the resulting bitmap was immediately destroyed.
Change-Id: I2f4678140cdc672ab4ced70f748135464447ff59
Reviewed-on: https://pdfium-review.googlesource.com/25510
Reviewed-by: dsinclair <dsinclair@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'core')
-rw-r--r-- | core/fpdfapi/edit/cpdf_creator_embeddertest.cpp | 9 | ||||
-rw-r--r-- | core/fpdfapi/parser/cpdf_security_handler_embeddertest.cpp | 6 | ||||
-rw-r--r-- | core/fxcodec/codec/fx_codec_embeddertest.cpp | 9 | ||||
-rw-r--r-- | core/fxge/fx_ge_text_embeddertest.cpp | 9 |
4 files changed, 19 insertions, 14 deletions
diff --git a/core/fpdfapi/edit/cpdf_creator_embeddertest.cpp b/core/fpdfapi/edit/cpdf_creator_embeddertest.cpp index 7d1fb30595..86cd67b121 100644 --- a/core/fpdfapi/edit/cpdf_creator_embeddertest.cpp +++ b/core/fpdfapi/edit/cpdf_creator_embeddertest.cpp @@ -25,11 +25,12 @@ TEST_F(CPDF_CreatorEmbedderTest, SavedDocsAreEqualAfterParse) { { // Do some read only operations. ASSERT_GE(1, FPDF_GetPageCount(document())); - FPDF_PAGE page = FPDF_LoadPage(document(), 0); + FPDF_PAGE page = LoadPage(0); ASSERT_TRUE(page); - FPDF_BITMAP new_bitmap = - RenderPageWithFlagsDeprecated(page, form_handle(), FPDF_ANNOT); - FPDFBitmap_Destroy(new_bitmap); + std::unique_ptr<void, FPDFBitmapDeleter> bitmap = + RenderLoadedPageWithFlags(page, FPDF_ANNOT); + EXPECT_EQ(595, FPDFBitmap_GetWidth(bitmap.get())); + EXPECT_EQ(842, FPDFBitmap_GetHeight(bitmap.get())); UnloadPage(page); } diff --git a/core/fpdfapi/parser/cpdf_security_handler_embeddertest.cpp b/core/fpdfapi/parser/cpdf_security_handler_embeddertest.cpp index 6c1a0e9ae5..df7b5b6873 100644 --- a/core/fpdfapi/parser/cpdf_security_handler_embeddertest.cpp +++ b/core/fpdfapi/parser/cpdf_security_handler_embeddertest.cpp @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include <memory> #include <string> #include "core/fxcrt/fx_system.h" @@ -58,9 +59,8 @@ TEST_F(CPDFSecurityHandlerEmbeddertest, PasswordAfterGenerateSave) { EXPECT_TRUE(FPDFPath_SetFillColor(red_rect, 255, 0, 0, 255)); EXPECT_TRUE(FPDFPath_SetDrawMode(red_rect, FPDF_FILLMODE_ALTERNATE, 0)); FPDFPage_InsertObject(page, red_rect); - FPDF_BITMAP page_bitmap = RenderPageDeprecated(page); - CompareBitmap(page_bitmap, 612, 792, md5); - FPDFBitmap_Destroy(page_bitmap); + std::unique_ptr<void, FPDFBitmapDeleter> bitmap = RenderLoadedPage(page); + CompareBitmap(bitmap.get(), 612, 792, md5); EXPECT_TRUE(FPDFPage_GenerateContent(page)); SetWholeFileAvailable(); EXPECT_TRUE(FPDF_SaveAsCopy(document(), this, 0)); diff --git a/core/fxcodec/codec/fx_codec_embeddertest.cpp b/core/fxcodec/codec/fx_codec_embeddertest.cpp index 50a15c3dc2..40a1662839 100644 --- a/core/fxcodec/codec/fx_codec_embeddertest.cpp +++ b/core/fxcodec/codec/fx_codec_embeddertest.cpp @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include <memory> + #include "testing/embedder_test.h" #include "testing/gtest/include/gtest/gtest.h" @@ -12,9 +14,8 @@ TEST_F(FXCodecEmbeddertest, Bug_631912) { // Should not crash. EXPECT_TRUE(OpenDocument("bug_631912.pdf")); FPDF_PAGE page = LoadPage(0); - EXPECT_NE(nullptr, page); - FPDF_BITMAP bitmap = RenderPageDeprecated(page); - CompareBitmap(bitmap, 691, 432, "24d75af646f8772c5ee7ced260452ae4"); - FPDFBitmap_Destroy(bitmap); + ASSERT_TRUE(page); + std::unique_ptr<void, FPDFBitmapDeleter> bitmap = RenderLoadedPage(page); + CompareBitmap(bitmap.get(), 691, 432, "24d75af646f8772c5ee7ced260452ae4"); UnloadPage(page); } diff --git a/core/fxge/fx_ge_text_embeddertest.cpp b/core/fxge/fx_ge_text_embeddertest.cpp index 7aeb3f3e07..362ccf5dc1 100644 --- a/core/fxge/fx_ge_text_embeddertest.cpp +++ b/core/fxge/fx_ge_text_embeddertest.cpp @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include <memory> + #include "testing/embedder_test.h" #include "testing/gtest/include/gtest/gtest.h" @@ -11,8 +13,9 @@ TEST_F(FXGETextEmbedderTest, BadItalic) { // Shouldn't crash. EXPECT_TRUE(OpenDocument("bug_601362.pdf")); FPDF_PAGE page = LoadPage(0); - EXPECT_NE(nullptr, page); - FPDF_BITMAP bitmap = RenderPageDeprecated(page); - FPDFBitmap_Destroy(bitmap); + ASSERT_TRUE(page); + std::unique_ptr<void, FPDFBitmapDeleter> bitmap = RenderLoadedPage(page); + EXPECT_EQ(612, FPDFBitmap_GetWidth(bitmap.get())); + EXPECT_EQ(792, FPDFBitmap_GetHeight(bitmap.get())); UnloadPage(page); } |