summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdf_ppo_embeddertest.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-04-25 18:49:32 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-04-25 18:49:32 +0000
commite08d2b1fee0db40bac9538ca8b7be0a951675bd6 (patch)
tree81ded468a54adb247f46d7824632f6c4a537619c /fpdfsdk/fpdf_ppo_embeddertest.cpp
parenteb3ec8f29846a5df67269a53ca94d1d740c84513 (diff)
downloadpdfium-e08d2b1fee0db40bac9538ca8b7be0a951675bd6.tar.xz
Introduce ScopedFPDF types in public/cpp/fpdf_scopers.h
Applies std::remove_ptr to the public API types so that we can deduce a correct unique ptr type no matter how that API might change away from void* usage. Creates shorter names for std::unique_ptr<std::remove_pointer<>, ...> Change-Id: I04a0ff43cb7d5a4d3867939a53a54c9cef00db86 Reviewed-on: https://pdfium-review.googlesource.com/31292 Reviewed-by: Lei Zhang <thestig@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdf_ppo_embeddertest.cpp')
-rw-r--r--fpdfsdk/fpdf_ppo_embeddertest.cpp28
1 files changed, 12 insertions, 16 deletions
diff --git a/fpdfsdk/fpdf_ppo_embeddertest.cpp b/fpdfsdk/fpdf_ppo_embeddertest.cpp
index 614573b24f..8412771aaf 100644
--- a/fpdfsdk/fpdf_ppo_embeddertest.cpp
+++ b/fpdfsdk/fpdf_ppo_embeddertest.cpp
@@ -6,7 +6,7 @@
#include <string>
#include "fpdfsdk/cpdfsdk_helpers.h"
-#include "public/cpp/fpdf_deleters.h"
+#include "public/cpp/fpdf_scopers.h"
#include "public/fpdf_edit.h"
#include "public/fpdf_ppo.h"
#include "public/fpdf_save.h"
@@ -64,19 +64,19 @@ TEST_F(FPDFPPOEmbeddertest, ImportPages) {
TEST_F(FPDFPPOEmbeddertest, ImportNPages) {
ASSERT_TRUE(OpenDocument("rectangles_multi_pages.pdf"));
- std::unique_ptr<void, FPDFDocumentDeleter> output_doc_2up(
+ ScopedFPDFDocument output_doc_2up(
FPDF_ImportNPagesToOne(document(), 612, 792, 2, 1));
ASSERT_TRUE(output_doc_2up);
EXPECT_EQ(3, FPDF_GetPageCount(output_doc_2up.get()));
- std::unique_ptr<void, FPDFDocumentDeleter> output_doc_5up(
+ ScopedFPDFDocument output_doc_5up(
FPDF_ImportNPagesToOne(document(), 612, 792, 5, 1));
ASSERT_TRUE(output_doc_5up);
EXPECT_EQ(1, FPDF_GetPageCount(output_doc_5up.get()));
- std::unique_ptr<void, FPDFDocumentDeleter> output_doc_8up(
+ ScopedFPDFDocument output_doc_8up(
FPDF_ImportNPagesToOne(document(), 792, 612, 8, 1));
ASSERT_TRUE(output_doc_8up);
EXPECT_EQ(1, FPDF_GetPageCount(output_doc_8up.get()));
- std::unique_ptr<void, FPDFDocumentDeleter> output_doc_128up(
+ ScopedFPDFDocument output_doc_128up(
FPDF_ImportNPagesToOne(document(), 792, 612, 128, 1));
ASSERT_TRUE(output_doc_128up);
EXPECT_EQ(1, FPDF_GetPageCount(output_doc_128up.get()));
@@ -106,16 +106,14 @@ TEST_F(FPDFPPOEmbeddertest, NupRenderImage) {
const int kPageCount = 2;
constexpr const char* kExpectedMD5s[kPageCount] = {
"4d225b961da0f1bced7c83273e64c9b6", "fb18142190d770cfbc329d2b071aee4d"};
- std::unique_ptr<void, FPDFDocumentDeleter> output_doc_3up(
+ ScopedFPDFDocument output_doc_3up(
FPDF_ImportNPagesToOne(document(), 792, 612, 3, 1));
ASSERT_TRUE(output_doc_3up);
ASSERT_EQ(kPageCount, FPDF_GetPageCount(output_doc_3up.get()));
for (int i = 0; i < kPageCount; ++i) {
- std::unique_ptr<void, FPDFPageDeleter> page(
- FPDF_LoadPage(output_doc_3up.get(), i));
+ ScopedFPDFPage page(FPDF_LoadPage(output_doc_3up.get(), i));
ASSERT_TRUE(page);
- std::unique_ptr<void, FPDFBitmapDeleter> bitmap(
- RenderPageWithFlags(page.get(), nullptr, 0));
+ ScopedFPDFBitmap bitmap(RenderPageWithFlags(page.get(), nullptr, 0));
EXPECT_EQ(792, FPDFBitmap_GetWidth(bitmap.get()));
EXPECT_EQ(612, FPDFBitmap_GetHeight(bitmap.get()));
EXPECT_EQ(kExpectedMD5s[i], HashBitmap(bitmap.get()));
@@ -218,7 +216,7 @@ TEST_F(FPDFPPOEmbeddertest, BUG_750568) {
FPDF_PAGE page = LoadPage(i);
ASSERT_TRUE(page);
- std::unique_ptr<void, FPDFBitmapDeleter> bitmap = RenderLoadedPage(page);
+ ScopedFPDFBitmap bitmap = RenderLoadedPage(page);
ASSERT_EQ(200, FPDFBitmap_GetWidth(bitmap.get()));
ASSERT_EQ(200, FPDFBitmap_GetHeight(bitmap.get()));
ASSERT_EQ(800, FPDFBitmap_GetStride(bitmap.get()));
@@ -235,8 +233,7 @@ TEST_F(FPDFPPOEmbeddertest, BUG_750568) {
FPDF_PAGE page = FPDF_LoadPage(output_doc, i);
ASSERT_TRUE(page);
- std::unique_ptr<void, FPDFBitmapDeleter> bitmap =
- RenderPageWithFlags(page, nullptr, 0);
+ ScopedFPDFBitmap 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()));
@@ -252,7 +249,7 @@ TEST_F(FPDFPPOEmbeddertest, ImportWithZeroLengthStream) {
FPDF_PAGE page = LoadPage(0);
ASSERT_TRUE(page);
- std::unique_ptr<void, FPDFBitmapDeleter> bitmap = RenderLoadedPage(page);
+ ScopedFPDFBitmap bitmap = RenderLoadedPage(page);
ASSERT_EQ(200, FPDFBitmap_GetWidth(bitmap.get()));
ASSERT_EQ(200, FPDFBitmap_GetHeight(bitmap.get()));
ASSERT_EQ(800, FPDFBitmap_GetStride(bitmap.get()));
@@ -267,8 +264,7 @@ 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);
- std::unique_ptr<void, FPDFBitmapDeleter> new_bitmap =
- RenderPageWithFlags(new_page, nullptr, 0);
+ ScopedFPDFBitmap 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()));