diff options
author | Tom Sepez <tsepez@chromium.org> | 2018-05-07 20:25:46 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-05-07 20:25:46 +0000 |
commit | 8dcab3c246751763e044a5ba5378e55e2274cde6 (patch) | |
tree | da833b1401cae0bab02cf7252e5dbc5d0f0192e6 /fpdfsdk | |
parent | cb391259aefd52f09352d35a1bb5b56c0db6db11 (diff) | |
download | pdfium-8dcab3c246751763e044a5ba5378e55e2274cde6.tar.xz |
Add test for mutltiple copies of same PDF page.
Shows that under non-XFA, we hand out a new FPDF_PAGE on each call,
but under XFA we hand out the same FPDF_PAGE and ref-count it
under the covers.
Change-Id: I47cd28c65faed90cf425bbc920e1b56b1e4676a8
Reviewed-on: https://pdfium-review.googlesource.com/32057
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fpdfsdk')
-rw-r--r-- | fpdfsdk/fpdf_doc_embeddertest.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/fpdfsdk/fpdf_doc_embeddertest.cpp b/fpdfsdk/fpdf_doc_embeddertest.cpp index 07b83263be..43af5f26c7 100644 --- a/fpdfsdk/fpdf_doc_embeddertest.cpp +++ b/fpdfsdk/fpdf_doc_embeddertest.cpp @@ -3,9 +3,12 @@ // found in the LICENSE file. #include <memory> +#include <set> #include <string> +#include <vector> #include "core/fxcrt/fx_string.h" +#include "public/cpp/fpdf_scopers.h" #include "public/fpdf_doc.h" #include "public/fpdf_edit.h" #include "public/fpdfview.h" @@ -15,6 +18,22 @@ class FPDFDocEmbeddertest : public EmbedderTest {}; +TEST_F(FPDFDocEmbeddertest, MultipleSamePage) { + EXPECT_TRUE(OpenDocument("hello_world.pdf")); + + std::set<FPDF_PAGE> unique_pages; + std::vector<ScopedFPDFPage> owned_pages(4); + for (auto& ref : owned_pages) { + ref.reset(FPDF_LoadPage(document(), 0)); + unique_pages.insert(ref.get()); + } +#ifdef PDF_ENABLE_XFA + EXPECT_EQ(1u, unique_pages.size()); +#else // PDF_ENABLE_XFA + EXPECT_EQ(4u, unique_pages.size()); +#endif // PDF_ENABLE_XFA +} + TEST_F(FPDFDocEmbeddertest, DestGetPageIndex) { EXPECT_TRUE(OpenDocument("named_dests.pdf")); |