diff options
Diffstat (limited to 'core/fpdfapi')
3 files changed, 26 insertions, 25 deletions
diff --git a/core/fpdfapi/parser/fpdf_parser_decode_embeddertest.cpp b/core/fpdfapi/parser/fpdf_parser_decode_embeddertest.cpp index 20e8cf775c..0a7dde9b05 100644 --- a/core/fpdfapi/parser/fpdf_parser_decode_embeddertest.cpp +++ b/core/fpdfapi/parser/fpdf_parser_decode_embeddertest.cpp @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "core/fpdfapi/parser/fpdf_parser_decode.h" - #include <cstring> +#include <memory> #include <string> +#include "core/fpdfapi/parser/fpdf_parser_decode.h" #include "testing/embedder_test.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/test_support.h" @@ -93,9 +93,9 @@ TEST_F(FPDFParserDecodeEmbeddertest, Bug_552046) { // crash when rendered. EXPECT_TRUE(OpenDocument("bug_552046.pdf")); FPDF_PAGE page = LoadPage(0); - FPDF_BITMAP bitmap = RenderPageDeprecated(page); - CompareBitmap(bitmap, 612, 792, "1940568c9ba33bac5d0b1ee9558c76b3"); - FPDFBitmap_Destroy(bitmap); + ASSERT_TRUE(page); + std::unique_ptr<void, FPDFBitmapDeleter> bitmap = RenderLoadedPage(page); + CompareBitmap(bitmap.get(), 612, 792, "1940568c9ba33bac5d0b1ee9558c76b3"); UnloadPage(page); } @@ -104,9 +104,9 @@ TEST_F(FPDFParserDecodeEmbeddertest, Bug_555784) { // Should not cause a crash when rendered. EXPECT_TRUE(OpenDocument("bug_555784.pdf")); FPDF_PAGE page = LoadPage(0); - FPDF_BITMAP bitmap = RenderPageDeprecated(page); - CompareBitmap(bitmap, 612, 792, "1940568c9ba33bac5d0b1ee9558c76b3"); - FPDFBitmap_Destroy(bitmap); + ASSERT_TRUE(page); + std::unique_ptr<void, FPDFBitmapDeleter> bitmap = RenderLoadedPage(page); + CompareBitmap(bitmap.get(), 612, 792, "1940568c9ba33bac5d0b1ee9558c76b3"); UnloadPage(page); } @@ -115,7 +115,8 @@ TEST_F(FPDFParserDecodeEmbeddertest, Bug_455199) { // Should open successfully. EXPECT_TRUE(OpenDocument("bug_455199.pdf")); FPDF_PAGE page = LoadPage(0); - FPDF_BITMAP bitmap = RenderPageDeprecated(page); + ASSERT_TRUE(page); + std::unique_ptr<void, FPDFBitmapDeleter> bitmap = RenderLoadedPage(page); #if _FX_PLATFORM_ == _FX_PLATFORM_APPLE_ const char kExpectedMd5sum[] = "b90475ca64d1348c3bf5e2b77ad9187a"; #elif _FX_PLATFORM_ == _FX_PLATFORM_WINDOWS_ @@ -123,7 +124,6 @@ TEST_F(FPDFParserDecodeEmbeddertest, Bug_455199) { #else const char kExpectedMd5sum[] = "2baa4c0e1758deba1b9c908e1fbd04ed"; #endif - CompareBitmap(bitmap, 200, 200, kExpectedMd5sum); - FPDFBitmap_Destroy(bitmap); + CompareBitmap(bitmap.get(), 200, 200, kExpectedMd5sum); UnloadPage(page); } diff --git a/core/fpdfapi/render/fpdf_render_loadimage_embeddertest.cpp b/core/fpdfapi/render/fpdf_render_loadimage_embeddertest.cpp index caf4673b85..588b974e29 100644 --- a/core/fpdfapi/render/fpdf_render_loadimage_embeddertest.cpp +++ b/core/fpdfapi/render/fpdf_render_loadimage_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,10 +14,9 @@ TEST_F(FPDFRenderLoadImageEmbeddertest, Bug_554151) { // Should not crash. EXPECT_TRUE(OpenDocument("bug_554151.pdf")); FPDF_PAGE page = LoadPage(0); - EXPECT_NE(nullptr, page); - FPDF_BITMAP bitmap = RenderPageDeprecated(page); - CompareBitmap(bitmap, 612, 792, "a14d7ee573c1b2456d7bf6b7762823cf"); - FPDFBitmap_Destroy(bitmap); + ASSERT_TRUE(page); + std::unique_ptr<void, FPDFBitmapDeleter> bitmap = RenderLoadedPage(page); + CompareBitmap(bitmap.get(), 612, 792, "a14d7ee573c1b2456d7bf6b7762823cf"); UnloadPage(page); } @@ -23,10 +24,9 @@ TEST_F(FPDFRenderLoadImageEmbeddertest, Bug_557223) { // Should not crash EXPECT_TRUE(OpenDocument("bug_557223.pdf")); FPDF_PAGE page = LoadPage(0); - EXPECT_NE(nullptr, page); - FPDF_BITMAP bitmap = RenderPageDeprecated(page); - CompareBitmap(bitmap, 24, 24, "dc0ea1b743c2edb22c597cadc8537f7b"); - FPDFBitmap_Destroy(bitmap); + ASSERT_TRUE(page); + std::unique_ptr<void, FPDFBitmapDeleter> bitmap = RenderLoadedPage(page); + CompareBitmap(bitmap.get(), 24, 24, "dc0ea1b743c2edb22c597cadc8537f7b"); UnloadPage(page); } @@ -35,8 +35,7 @@ TEST_F(FPDFRenderLoadImageEmbeddertest, Bug_603518) { EXPECT_TRUE(OpenDocument("bug_603518.pdf")); FPDF_PAGE page = LoadPage(0); EXPECT_NE(nullptr, page); - FPDF_BITMAP bitmap = RenderPageDeprecated(page); - CompareBitmap(bitmap, 749, 749, "b9e75190cdc5edf0069a408744ca07dc"); - FPDFBitmap_Destroy(bitmap); + std::unique_ptr<void, FPDFBitmapDeleter> bitmap = RenderLoadedPage(page); + CompareBitmap(bitmap.get(), 749, 749, "b9e75190cdc5edf0069a408744ca07dc"); UnloadPage(page); } diff --git a/core/fpdfapi/render/fpdf_render_pattern_embeddertest.cpp b/core/fpdfapi/render/fpdf_render_pattern_embeddertest.cpp index f141590f46..00b0933b71 100644 --- a/core/fpdfapi/render/fpdf_render_pattern_embeddertest.cpp +++ b/core/fpdfapi/render/fpdf_render_pattern_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,8 @@ TEST_F(FPDFRenderPatternEmbeddertest, LoadError_547706) { // Test shading where object is a dictionary instead of a stream. EXPECT_TRUE(OpenDocument("bug_547706.pdf")); FPDF_PAGE page = LoadPage(0); - FPDF_BITMAP bitmap = RenderPageDeprecated(page); - CompareBitmap(bitmap, 612, 792, "1940568c9ba33bac5d0b1ee9558c76b3"); - FPDFBitmap_Destroy(bitmap); + ASSERT_TRUE(page); + std::unique_ptr<void, FPDFBitmapDeleter> bitmap = RenderLoadedPage(page); + CompareBitmap(bitmap.get(), 612, 792, "1940568c9ba33bac5d0b1ee9558c76b3"); UnloadPage(page); } |