summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdfppo_embeddertest.cpp
diff options
context:
space:
mode:
authorxlou <xlou@chromium.org>2018-02-06 00:11:23 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-02-06 00:11:23 +0000
commit29561e53b60c680e4f6fca9d91047952b2de7906 (patch)
tree7abfecbdf9207d35a90e762b3a7f1b457c81e126 /fpdfsdk/fpdfppo_embeddertest.cpp
parent6ec142da3f9cccb60a4d983ee7132c41a0798e24 (diff)
downloadpdfium-29561e53b60c680e4f6fca9d91047952b2de7906.tar.xz
Add rendering embeddertests for FPDF_ImportNPagesToOne.
One test is added to render the output pdf of FPDF_ImportNPagesToOne, and check the width, height and hash value of the rendered image. Change-Id: Idd3f953d62ecd4e85ad52a9323eb13243dc49597 Reviewed-on: https://pdfium-review.googlesource.com/25330 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdfppo_embeddertest.cpp')
-rw-r--r--fpdfsdk/fpdfppo_embeddertest.cpp26
1 files changed, 24 insertions, 2 deletions
diff --git a/fpdfsdk/fpdfppo_embeddertest.cpp b/fpdfsdk/fpdfppo_embeddertest.cpp
index deb87b533a..2a4c774bae 100644
--- a/fpdfsdk/fpdfppo_embeddertest.cpp
+++ b/fpdfsdk/fpdfppo_embeddertest.cpp
@@ -1,6 +1,8 @@
// Copyright 2016 PDFium Authors. All rights reserved.
// 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 "public/cpp/fpdf_deleters.h"
@@ -59,7 +61,7 @@ TEST_F(FPDFPPOEmbeddertest, ImportPages) {
}
TEST_F(FPDFPPOEmbeddertest, ImportNPages) {
- ASSERT_TRUE(OpenDocument("hello_world_multi_pages.pdf"));
+ ASSERT_TRUE(OpenDocument("rectangles_multi_pages.pdf"));
std::unique_ptr<void, FPDFDocumentDeleter> output_doc_2up(
FPDF_ImportNPagesToOne(document(), 612, 792, 2, 1));
@@ -80,7 +82,7 @@ TEST_F(FPDFPPOEmbeddertest, ImportNPages) {
}
TEST_F(FPDFPPOEmbeddertest, BadNupParams) {
- ASSERT_TRUE(OpenDocument("hello_world_multi_pages.pdf"));
+ ASSERT_TRUE(OpenDocument("rectangles_multi_pages.pdf"));
FPDF_DOCUMENT output_doc_zero_row =
FPDF_ImportNPagesToOne(document(), 612, 792, 0, 3);
@@ -98,6 +100,26 @@ TEST_F(FPDFPPOEmbeddertest, BadNupParams) {
// TODO(Xlou): Add more tests to check output doc content of
// FPDF_ImportNPagesToOne()
+TEST_F(FPDFPPOEmbeddertest, NupRenderImage) {
+ ASSERT_TRUE(OpenDocument("rectangles_multi_pages.pdf"));
+ const int kPageCount = 2;
+ constexpr const char* kExpectedMD5s[kPageCount] = {
+ "4d225b961da0f1bced7c83273e64c9b6", "fb18142190d770cfbc329d2b071aee4d"};
+ std::unique_ptr<void, FPDFDocumentDeleter> 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));
+ ASSERT_TRUE(page);
+ std::unique_ptr<void, FPDFBitmapDeleter> 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()));
+ }
+}
TEST_F(FPDFPPOEmbeddertest, BadRepeatViewerPref) {
ASSERT_TRUE(OpenDocument("repeat_viewer_ref.pdf"));