From e906780205d52ce731d5da67888225e704897047 Mon Sep 17 00:00:00 2001 From: Bob Singor Date: Sun, 1 Nov 2026 22:56:00 +0200 Subject: [PATCH] Run the in-memory tests as layers in layer mode The fork's embedder tests that build their documents in memory, with FPDF_LoadMemDocument*, FPDF_CreateNewDocument or CreateEmptyDocument(), never ran on a layer, so layer mode's read-only check and write guards never reached them. They now open through EmbedderTest::OpenDocumentFromMemory(), embedpdf_test::LoadMemDocumentForTest() or the new NewTestDocument() (EmptyPdf() for a test of its own to write into). A test about plain documents, or the plain half of one that compares a plain document with a layer, stays plain and says why. The run found one read path that writes: a stamp's drawing taken from another document's page read that page through the mutable getter and added a temporary form to it, so a layer source gained its page and two object numbers. ImportPageAsDrawing() now only reads the source. Two tests read through a mutable getter or relied on FPDF_CreateNewDocument()'s /Info; they now read as the runtime does and write their /Info. The tests that write on purpose are in the writers list. --- docs/embedpdf/fork-ledger.md | 7 +- fpdfsdk/epdf_action_embeddertest.cpp | 30 +- fpdfsdk/epdf_annot.cpp | 17 +- fpdfsdk/epdf_annot_embeddertest.cpp | 297 ++++++++++-------- fpdfsdk/epdf_annot_identity_embeddertest.cpp | 1 + fpdfsdk/epdf_annot_raw_embeddertest.cpp | 14 +- fpdfsdk/epdf_attachment_embeddertest.cpp | 4 +- fpdfsdk/epdf_capture_embeddertest.cpp | 5 + fpdfsdk/epdf_catalog_embeddertest.cpp | 1 + fpdfsdk/epdf_content_rewrite_embeddertest.cpp | 1 + fpdfsdk/epdf_edit_test_util.cpp | 8 + fpdfsdk/epdf_edit_test_util.h | 5 + fpdfsdk/epdf_flatten_embeddertest.cpp | 24 +- fpdfsdk/epdf_layer_embeddertest.cpp | 5 + fpdfsdk/epdf_measure_embeddertest.cpp | 36 ++- fpdfsdk/epdf_named_pages_embeddertest.cpp | 3 +- fpdfsdk/epdf_object_number_embeddertest.cpp | 11 +- fpdfsdk/epdf_outline_embeddertest.cpp | 52 +-- fpdfsdk/epdf_page_labels_embeddertest.cpp | 19 +- fpdfsdk/epdf_page_residency_embeddertest.cpp | 24 +- fpdfsdk/epdf_pieceinfo_embeddertest.cpp | 12 +- fpdfsdk/epdf_ppo_embeddertest.cpp | 45 +-- fpdfsdk/epdf_redact_embeddertest.cpp | 29 +- fpdfsdk/epdf_richtextlayout_embeddertest.cpp | 6 +- fpdfsdk/epdf_save_embeddertest.cpp | 55 ++-- fpdfsdk/epdf_signature_embeddertest.cpp | 143 +++++---- fpdfsdk/epdf_sliced_load_embeddertest.cpp | 35 ++- fpdfsdk/epdf_text_bounds_embeddertest.cpp | 10 +- fpdfsdk/epdf_transaction_embeddertest.cpp | 1 + fpdfsdk/epdf_view_embeddertest.cpp | 6 +- testing/embedpdf_layer_mode_writers.txt | 199 ++++++++++++ 31 files changed, 733 insertions(+), 372 deletions(-) diff --git a/docs/embedpdf/fork-ledger.md b/docs/embedpdf/fork-ledger.md index 3945f4a416..e50c001d08 100644 --- a/docs/embedpdf/fork-ledger.md +++ b/docs/embedpdf/fork-ledger.md @@ -121,7 +121,8 @@ edits, and the copy happens outside any transaction. On a frozen base it writes `cpdf_annot.cpp`. Writes that read first: the field pruning in `fpdf_flatten.cpp` compares fields read const and takes an array mutable only when an entry goes. **Guarded by.** `cpdf_read_only_graph_guard_unittest.cpp`, -`EPDFAnnotEmbedderTest.DrawingARedactionMarkWithoutAppearanceWritesNone`; layer mode's list of +`EPDFAnnotEmbedderTest.DrawingARedactionMarkWithoutAppearanceWritesNone`, +`EPDFStampResizeEmbedderTest.ADrawingFromALayersPageLeavesTheLayerAlone`; layer mode's list of tests that write (`testing/embedpdf_layer_mode_writers.txt`): a test that only reads must leave nothing in a layer. **When upstream touches this.** A new read path that calls `GetMutable*` or the appearance @@ -498,7 +499,9 @@ layer over a frozen base. Like the engine, it sends the form-fill environment no doesn't draw with it. A document a test builds in memory goes through the layer too when the test opens it with `EmbedderTest::OpenDocumentFromMemory()`, or with `embedpdf_test::LoadMemDocumentForTest()` when it keeps the document itself; a test that writes -into a new document starts from `EmptyPdf()`, since `CreateEmptyDocument()` never makes a layer. +into a new document starts from `EmptyPdf()` (`NewTestDocument()` when it keeps the document), since +`CreateEmptyDocument()` and `FPDF_CreateNewDocument()` never make a layer. A test about plain +documents keeps one in layer mode too, and says why. **Why.** Upstream's embedder tests then run through the layer's read and write paths, so a new upstream feature is tested on a layer without anyone writing a layer test. **Where.** `testing/embedpdf_layer_mode.{h,cpp}`, the `EmbedPDF(layer-mode)` hooks in diff --git a/fpdfsdk/epdf_action_embeddertest.cpp b/fpdfsdk/epdf_action_embeddertest.cpp index 75e1997789..0aefb649f5 100644 --- a/fpdfsdk/epdf_action_embeddertest.cpp +++ b/fpdfsdk/epdf_action_embeddertest.cpp @@ -20,6 +20,7 @@ #include "core/fxcrt/bytestring.h" #include "core/fxcrt/retain_ptr.h" #include "fpdfsdk/cpdfsdk_helpers.h" +#include "fpdfsdk/epdf_edit_test_util.h" #include "public/epdf_doc.h" #include "public/epdf_form.h" #include "public/epdf_layer.h" @@ -29,6 +30,7 @@ #include "public/fpdf_edit.h" #include "public/fpdf_javascript.h" #include "testing/embedder_test.h" +#include "testing/embedpdf_layer_mode.h" #include "testing/fx_string_testhelpers.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/utils/file_util.h" @@ -146,7 +148,7 @@ TEST_F(EPDFActionEmbedderTest, NamedJavaScriptIndexPairing) { } TEST_F(EPDFActionEmbedderTest, NextRenditionCycleAndMalformedEntry) { - ScopedFPDFDocument document(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument document(NewTestDocument()); ASSERT_TRUE(document); CPDF_Document* doc = CPDFDocumentFromFPDFDocument(document.get()); ASSERT_TRUE(doc); @@ -223,7 +225,7 @@ TEST_F(EPDFActionEmbedderTest, DepthLimitMarksModelIncomplete) { } TEST_F(EPDFActionEmbedderTest, DocumentAndPageModelsAreDetached) { - ScopedFPDFDocument document(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument document(NewTestDocument()); ASSERT_TRUE(document); ScopedFPDFPage page(FPDFPage_New(document.get(), 0, 300, 300)); ASSERT_TRUE(page); @@ -483,7 +485,7 @@ TEST_F(EPDFActionEmbedderTest, NodeUriPayloadFromRealDocument) { } TEST_F(EPDFActionEmbedderTest, NodeDestPayloadFromCreatedGoTo) { - ScopedFPDFDocument document(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument document(NewTestDocument()); ASSERT_TRUE(document); ScopedFPDFPage page(FPDFPage_New(document.get(), 0, 612, 792)); ASSERT_TRUE(page); @@ -525,7 +527,7 @@ TEST_F(EPDFActionEmbedderTest, NodeDestPayloadFromCreatedGoTo) { } TEST_F(EPDFActionEmbedderTest, DestinationsByPageObjectNumber) { - ScopedFPDFDocument document(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument document(NewTestDocument()); ASSERT_TRUE(document); ScopedFPDFPage first(FPDFPage_New(document.get(), 0, 612, 792)); ScopedFPDFPage second(FPDFPage_New(document.get(), 1, 612, 792)); @@ -588,7 +590,7 @@ TEST_F(EPDFActionEmbedderTest, DestinationsByPageObjectNumber) { } TEST_F(EPDFActionEmbedderTest, CreateNamedWritesTheName) { - ScopedFPDFDocument document(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument document(NewTestDocument()); ASSERT_TRUE(document); FPDF_ACTION next = EPDFAction_CreateNamed(document.get(), "NextPage"); @@ -604,7 +606,7 @@ TEST_F(EPDFActionEmbedderTest, CreateNamedWritesTheName) { } TEST_F(EPDFActionEmbedderTest, NodeFilePathAndNamePayloadsFromSyntheticDicts) { - ScopedFPDFDocument document(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument document(NewTestDocument()); ASSERT_TRUE(document); CPDF_Document* doc = CPDFDocumentFromFPDFDocument(document.get()); ASSERT_TRUE(doc); @@ -655,7 +657,7 @@ TEST_F(EPDFActionEmbedderTest, NodeFilePathAndNamePayloadsFromSyntheticDicts) { } TEST_F(EPDFActionEmbedderTest, HideTargetPayloadsMixedForms) { - ScopedFPDFDocument document(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument document(NewTestDocument()); ASSERT_TRUE(document); CPDF_Document* doc = CPDFDocumentFromFPDFDocument(document.get()); ASSERT_TRUE(doc); @@ -754,7 +756,7 @@ TEST_F(EPDFActionEmbedderTest, PartialHideTargetListIsWithheld) { } TEST_F(EPDFActionEmbedderTest, ResetFormThreeStates) { - ScopedFPDFDocument document(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument document(NewTestDocument()); ASSERT_TRUE(document); CPDF_Document* doc = CPDFDocumentFromFPDFDocument(document.get()); ASSERT_TRUE(doc); @@ -877,14 +879,14 @@ TEST_F(EPDFActionEmbedderTest, PayloadByteBudgetOverflowDropsNode) { TEST_F(EPDFActionEmbedderTest, OpenActionDestinationForms) { // Absent /OpenAction: both readers answer null. - ScopedFPDFDocument empty(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument empty(NewTestDocument()); ASSERT_TRUE(empty); EXPECT_FALSE(EPDFDoc_GetOpenActionDest(empty.get())); EXPECT_FALSE(EPDFDoc_GetOpenActionModel(empty.get())); EXPECT_FALSE(EPDFDoc_GetOpenActionDest(nullptr)); // Destination form: the dest reads, the action model stays null. - ScopedFPDFDocument document(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument document(NewTestDocument()); ASSERT_TRUE(document); ScopedFPDFPage page(FPDFPage_New(document.get(), 0, 612, 792)); ASSERT_TRUE(page); @@ -934,7 +936,7 @@ TEST_F(EPDFActionEmbedderTest, OpenActionDestinationForms) { } TEST_F(EPDFActionEmbedderTest, DestinationArrayJunkBeyondViewIsIgnored) { - ScopedFPDFDocument document(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument document(NewTestDocument()); ASSERT_TRUE(document); ScopedFPDFPage page(FPDFPage_New(document.get(), 0, 612, 792)); ASSERT_TRUE(page); @@ -1004,7 +1006,7 @@ std::string GetSubmitURL(EPDF_ACTION_MODEL model, EPDF_ACTION_NODE_ID node) { // Each creator's action reads back through the action model as written. TEST_F(EPDFActionEmbedderTest, CreatorsReadBack) { - ScopedFPDFDocument document(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument document(NewTestDocument()); ASSERT_TRUE(document); CPDF_Document* doc = CPDFDocumentFromFPDFDocument(document.get()); RetainPtr field = doc->NewIndirect(); @@ -1099,7 +1101,7 @@ TEST_F(EPDFActionEmbedderTest, CreatorsReadBack) { // /Next: one action is the entry itself; several, an array, read back in // order. An action can't follow itself. TEST_F(EPDFActionEmbedderTest, SetNextChainsActions) { - ScopedFPDFDocument document(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument document(NewTestDocument()); ASSERT_TRUE(document); auto script = [&](const wchar_t* source) { return EPDFAction_CreateJavaScript(document.get(), @@ -1130,7 +1132,7 @@ TEST_F(EPDFActionEmbedderTest, SetNextChainsActions) { EXPECT_FALSE(CPDFDictionaryFromFPDFAction(first)->KeyExist("Next")); // An action of another document is refused. - ScopedFPDFDocument other(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument other(NewTestDocument()); FPDF_ACTION foreign = EPDFAction_CreateJavaScript( other.get(), GetFPDFWideString(L"x();").get()); EXPECT_FALSE(EPDFAction_SetNext(document.get(), first, &foreign, 1)); diff --git a/fpdfsdk/epdf_annot.cpp b/fpdfsdk/epdf_annot.cpp index 5bf2591fc0..d0113926cf 100644 --- a/fpdfsdk/epdf_annot.cpp +++ b/fpdfsdk/epdf_annot.cpp @@ -3521,8 +3521,10 @@ static RetainPtr ImportPageAsDrawing(CPDF_Document* dest_doc, CPDF_Document* src_doc, int page_index, float opacity) { - RetainPtr src_page_dict = - src_doc->GetMutablePageDictionary(page_index); + // The source is only read (rule reads-dont-write): a mutable getter would + // copy a layer's page into the layer. + RetainPtr src_page_dict = + src_doc->GetPageDictionary(page_index); if (!src_page_dict) { return nullptr; } @@ -3586,8 +3588,9 @@ static RetainPtr ImportPageAsDrawing(CPDF_Document* dest_doc, return nullptr; } - // Build a Form XObject stream in the source document so that - // AnnotAppearanceExporter can deep-clone it with all resource dependencies. + // A Form XObject over the page's content and resources, which + // AnnotAppearanceExporter deep-clones with everything they refer to. It is + // no object of the source: adding it would write there. auto xobj_dict = pdfium::MakeRetain(); xobj_dict->SetNewFor(pdfium::annotation::kType, "XObject"); xobj_dict->SetNewFor(pdfium::annotation::kSubtype, "Form"); @@ -3599,16 +3602,12 @@ static RetainPtr ImportPageAsDrawing(CPDF_Document* dest_doc, xobj_dict->SetFor("Resources", src_resources->Clone()); } - auto src_stream = src_doc->NewIndirect(std::move(xobj_dict)); + auto src_stream = pdfium::MakeRetain(std::move(xobj_dict)); src_stream->SetData(content_data); // Clone the stream (and all its resource references) into dest_doc. AnnotAppearanceExporter exporter(dest_doc, src_doc); RetainPtr cloned_stream = exporter.ExportFormXObject(src_stream); - - // Clean up temporary object from source document. - src_doc->DeleteIndirectObject(src_stream->GetObjNum()); - if (!cloned_stream) { return nullptr; } diff --git a/fpdfsdk/epdf_annot_embeddertest.cpp b/fpdfsdk/epdf_annot_embeddertest.cpp index 7580a9db8d..8e8f8a548c 100644 --- a/fpdfsdk/epdf_annot_embeddertest.cpp +++ b/fpdfsdk/epdf_annot_embeddertest.cpp @@ -56,6 +56,7 @@ #include "fpdfsdk/cpdfsdk_helpers.h" #include "fpdfsdk/epdf_edit_test_util.h" #include "public/cpp/fpdf_scopers.h" +#include "public/epdf_doc.h" #include "public/epdf_edit.h" #include "public/epdf_flatten.h" #include "public/epdf_font.h" @@ -626,7 +627,7 @@ int CountInkPixels(FPDF_BITMAP bitmap, class EPDFAnnotEmbedderTest : public EmbedderTest {}; TEST_F(EPDFAnnotEmbedderTest, SetNumberValueStoresTheNumberAsGiven) { - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ASSERT_TRUE(doc); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 612, 792)); ASSERT_TRUE(page); @@ -665,7 +666,7 @@ TEST_F(EPDFAnnotEmbedderTest, SetNumberValueStoresTheNumberAsGiven) { } TEST_F(EPDFAnnotEmbedderTest, SetNumberValueRefusesWithoutWriting) { - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ASSERT_TRUE(doc); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 612, 792)); ASSERT_TRUE(page); @@ -764,7 +765,7 @@ TEST_F(EPDFAnnotEmbedderTest, ReadsResolveThroughTheLayer) { } TEST_F(EPDFAnnotEmbedderTest, OpacityIsStoredAsGiven) { - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ASSERT_TRUE(doc); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 100, 100)); ASSERT_TRUE(page); @@ -799,7 +800,7 @@ TEST_F(EPDFAnnotEmbedderTest, OpacityIsStoredAsGiven) { } TEST_F(EPDFAnnotEmbedderTest, GenerateInkAppearanceSetsRectToWhatItPaints) { - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ASSERT_TRUE(doc); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 200, 200)); ASSERT_TRUE(page); @@ -849,7 +850,7 @@ TEST_F(EPDFAnnotEmbedderTest, GenerateInkAppearanceSetsRectToWhatItPaints) { } TEST_F(EPDFAnnotEmbedderTest, LineRectHoldsItsArrowhead) { - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ASSERT_TRUE(doc); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 600, 600)); ASSERT_TRUE(page); @@ -879,7 +880,7 @@ TEST_F(EPDFAnnotEmbedderTest, LineRectHoldsItsArrowhead) { } TEST_F(EPDFAnnotEmbedderTest, LineRectIsWhatItsStrokePaints) { - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ASSERT_TRUE(doc); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 600, 600)); ASSERT_TRUE(page); @@ -918,7 +919,7 @@ TEST_F(EPDFAnnotEmbedderTest, LineRectIsWhatItsStrokePaints) { } TEST_F(EPDFAnnotEmbedderTest, PolylineKneePastTheMiterLimitIsBeveled) { - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ASSERT_TRUE(doc); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 600, 600)); ASSERT_TRUE(page); @@ -941,7 +942,7 @@ TEST_F(EPDFAnnotEmbedderTest, PolylineKneePastTheMiterLimitIsBeveled) { } TEST_F(EPDFAnnotEmbedderTest, DrawingAnnotationsWithoutAppearancesWritesNone) { - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ASSERT_TRUE(doc); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 300, 300)); ASSERT_TRUE(page); @@ -1025,7 +1026,7 @@ TEST_F(EPDFAnnotEmbedderTest, DrawingARedactionMarkWithoutAppearanceWritesNone) } TEST_F(EPDFAnnotEmbedderTest, DrawingRectIsWhereTheAppearanceIsDrawn) { - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ASSERT_TRUE(doc); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 600, 600)); ASSERT_TRUE(page); @@ -1086,7 +1087,7 @@ TEST_F(EPDFAnnotEmbedderTest, DrawingRectIsWhereTheAppearanceIsDrawn) { } TEST_F(EPDFAnnotEmbedderTest, CloudyPolygonRectHoldsItsBumps) { - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ASSERT_TRUE(doc); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 600, 600)); ASSERT_TRUE(page); @@ -1226,7 +1227,7 @@ TEST_F(EPDFAnnotEmbedderTest, FPDF_FONT_ZAPFDINGBATS, }; - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ASSERT_TRUE(doc); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 400, 400)); ASSERT_TRUE(page); @@ -1256,7 +1257,7 @@ TEST_F(EPDFAnnotEmbedderTest, TEST_F(EPDFAnnotEmbedderTest, DefaultAppearancePrefersAnnotationDrThenFallsBackToAcroFormDr) { - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ASSERT_TRUE(doc); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 400, 400)); ASSERT_TRUE(page); @@ -1316,7 +1317,7 @@ TEST_F(EPDFAnnotEmbedderTest, FreeTextAppearanceUsesRegisteredMemoryFont) { font_data.data(), font_data.size()); ASSERT_NE(0u, font_id); - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ASSERT_TRUE(doc); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 400, 400)); ASSERT_TRUE(page); @@ -1358,7 +1359,7 @@ TEST_F(EPDFAnnotEmbedderTest, FreeTextAppearanceFallsBackToRegisteredFont) { ASSERT_NE(0u, font_id); ASSERT_TRUE(EPDFFont_AddFallbackFont(font_id, /*tier=*/0)); - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ASSERT_TRUE(doc); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 400, 400)); ASSERT_TRUE(page); @@ -1386,7 +1387,7 @@ TEST_F(EPDFAnnotEmbedderTest, FreeTextKoreanUsesRegisteredDroidFallbackFont) { EPDF_FONT_ID font_id = RegisterDroidSansFallbackFullFont(); ASSERT_NE(0u, font_id); - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ASSERT_TRUE(doc); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 400, 400)); ASSERT_TRUE(page); @@ -1418,7 +1419,7 @@ TEST_F(EPDFAnnotEmbedderTest, FreeTextRegisteredFontEmbedsSubsetInSavedPdf) { font_data.data(), font_data.size()); ASSERT_NE(0u, font_id); - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ASSERT_TRUE(doc); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 400, 400)); ASSERT_TRUE(page); @@ -1465,7 +1466,7 @@ TEST_F(EPDFAnnotEmbedderTest, FreeTextRegistersFontFromFileAccess) { /*italic=*/0, &font_access); ASSERT_NE(0u, font_id); - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ASSERT_TRUE(doc); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 400, 400)); ASSERT_TRUE(page); @@ -1663,7 +1664,7 @@ TEST_F(EPDFAnnotEmbedderTest, FreeTextRegisteredFontInstallsRealDrEntry) { font_data.data(), font_data.size()); ASSERT_NE(0u, font_id); - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ASSERT_TRUE(doc); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 400, 400)); ASSERT_TRUE(page); @@ -1727,7 +1728,7 @@ TEST_F(EPDFAnnotEmbedderTest, std::string saved_pdf; { - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ASSERT_TRUE(doc); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 400, 400)); ASSERT_TRUE(page); @@ -1764,8 +1765,8 @@ TEST_F(EPDFAnnotEmbedderTest, ASSERT_NE(roboto_id, roboto_id_2); ASSERT_EQ(roboto_id_2, amiri_id + 2u); // the stale hint must not win by luck - ScopedFPDFDocument doc(FPDF_LoadMemDocument( - saved_pdf.data(), static_cast(saved_pdf.size()), nullptr)); + embedpdf_test::ScopedTestDocument doc(embedpdf_test::LoadMemDocumentForTest( + saved_pdf.data(), saved_pdf.size(), nullptr)); ASSERT_TRUE(doc); ScopedFPDFPage page(FPDF_LoadPage(doc.get(), 0)); ASSERT_TRUE(page); @@ -1809,7 +1810,7 @@ TEST_F(EPDFAnnotEmbedderTest, FreeTextLegacyMarkerDrEntryUpgradesToRealFont) { font_data.data(), font_data.size()); ASSERT_NE(0u, font_id); - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ASSERT_TRUE(doc); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 400, 400)); ASSERT_TRUE(page); @@ -1880,7 +1881,7 @@ TEST_F(EPDFAnnotEmbedderTest, RegisteredFontResolutionPrefersStoredFamily) { ASSERT_NE(0u, roboto_id); ASSERT_NE(0u, amiri_id); - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); CPDF_Document* cpdf_doc = CPDFDocumentFromFPDFDocument(doc.get()); // Requested family present, hint elsewhere: the family wins. @@ -1914,7 +1915,7 @@ TEST_F(EPDFAnnotEmbedderTest, RegisteredFontResolutionRefusesConflictingHint) { "Roboto", /*weight=*/400, /*italic=*/0, roboto.data(), roboto.size()); ASSERT_NE(0u, roboto_id); - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); CPDF_Document* cpdf_doc = CPDFDocumentFromFPDFDocument(doc.get()); // Requested family absent, hint points at a live but different font. @@ -1951,7 +1952,7 @@ TEST_F(EPDFAnnotEmbedderTest, EPDF_FONT_ID droid_id = RegisterDroidSansFallbackFullFont(); ASSERT_NE(0u, droid_id); - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ASSERT_TRUE(doc); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 400, 400)); ASSERT_TRUE(page); @@ -2016,7 +2017,7 @@ TEST_F(EPDFAnnotEmbedderTest, std::string saved_pdf; { - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 400, 400)); ScopedFPDFAnnotation annot( FPDFPage_CreateAnnot(page.get(), FPDF_ANNOT_FREETEXT)); @@ -2058,8 +2059,8 @@ TEST_F(EPDFAnnotEmbedderTest, "Roboto", /*weight=*/400, /*italic=*/0, roboto.data(), roboto.size()); ASSERT_NE(roboto_id, roboto_id_2); - ScopedFPDFDocument doc(FPDF_LoadMemDocument( - saved_pdf.data(), static_cast(saved_pdf.size()), nullptr)); + embedpdf_test::ScopedTestDocument doc(embedpdf_test::LoadMemDocumentForTest( + saved_pdf.data(), saved_pdf.size(), nullptr)); ASSERT_TRUE(doc); ScopedFPDFPage page(FPDF_LoadPage(doc.get(), 0)); ScopedFPDFAnnotation annot(FPDFPage_GetAnnot(page.get(), 0)); @@ -2087,7 +2088,7 @@ TEST_F(EPDFAnnotEmbedderTest, FreeTextAllFallbackTextKeepsRegisteredDaFont) { EPDF_FONT_ID droid_id = RegisterDroidSansFallbackFullFont(); ASSERT_NE(0u, droid_id); - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 400, 400)); ScopedFPDFAnnotation annot( FPDFPage_CreateAnnot(page.get(), FPDF_ANNOT_FREETEXT)); @@ -2124,7 +2125,7 @@ TEST_F(EPDFAnnotEmbedderTest, FreeTextRegeneratingOneAnnotationLeavesTheOther) { ASSERT_NE(0u, roboto_id); const ByteString alias = RegisteredFontAlias(roboto_id); - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 400, 400)); auto make = [&](const wchar_t* text, float top) { ScopedFPDFAnnotation annot( @@ -2173,7 +2174,7 @@ TEST_F(EPDFAnnotEmbedderTest, FreeTextEphemeralAppearanceLeavesDrUntouched) { "Roboto", /*weight=*/400, /*italic=*/0, roboto.data(), roboto.size()); ASSERT_NE(0u, roboto_id); - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 400, 400)); ASSERT_TRUE(page); ScopedFPDFAnnotation annot( @@ -2205,7 +2206,7 @@ TEST_F(EPDFAnnotEmbedderTest, WidgetRegisteredFontInstallsRealDrEntry) { ASSERT_NE(0u, roboto_id); const ByteString alias = RegisteredFontAlias(roboto_id); - CreateEmptyDocument(); + ASSERT_TRUE(OpenDocumentFromMemory(EmptyPdf())); { ScopedFPDFPage page(FPDFPage_New(document(), 0, 400, 400)); ASSERT_TRUE(page); @@ -2250,7 +2251,7 @@ TEST_F(EPDFAnnotEmbedderTest, RedactLabelRegisteredFontInstallsRealDrEntry) { "Roboto", /*weight=*/400, /*italic=*/0, roboto.data(), roboto.size()); ASSERT_NE(0u, roboto_id); - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 200, 200)); { ScopedFPDFAnnotation annot = @@ -2298,7 +2299,7 @@ TEST_F(EPDFAnnotEmbedderTest, WriteA1AcrobatFixtureFromEnv) { font_data.data(), font_data.size()); ASSERT_NE(0u, font_id); - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ASSERT_TRUE(doc); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 612, 792)); ASSERT_TRUE(page); @@ -2373,7 +2374,7 @@ TEST_F(EPDFAnnotEmbedderTest, RegistryHonoursFsTypeEmbeddingPermissions) { EXPECT_EQ(-1, EPDFFont_GetEmbeddingPermission(preview + 1000)); EXPECT_FALSE(EPDFFont_AuthorizeEditing(preview + 1000)); - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 400, 400)); ScopedFPDFAnnotation annot( FPDFPage_CreateAnnot(page.get(), FPDF_ANNOT_FREETEXT)); @@ -2416,7 +2417,7 @@ TEST_F(EPDFAnnotEmbedderTest, ASSERT_NE(0u, droid_id); ASSERT_TRUE(EPDFFont_AddFallbackFont(droid_id, /*tier=*/0)); - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 400, 400)); ScopedFPDFAnnotation annot( FPDFPage_CreateAnnot(page.get(), FPDF_ANNOT_FREETEXT)); @@ -2453,7 +2454,7 @@ TEST_F(EPDFAnnotEmbedderTest, NoSubsettingFontEmbedsWholeProgram) { EXPECT_EQ(EPDF_FONT_EMBEDDING_INSTALLABLE, EPDFFont_GetEmbeddingPermission(font_id)); - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 400, 400)); ScopedFPDFAnnotation annot( FPDFPage_CreateAnnot(page.get(), FPDF_ANNOT_FREETEXT)); @@ -2526,7 +2527,7 @@ TEST_F(EPDFAnnotEmbedderTest, VariableFontIsInstancedAtRegistration) { EXPECT_GT(bold_a, regular_a); // What gets embedded is static too. - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 400, 400)); ScopedFPDFAnnotation annot( FPDFPage_CreateAnnot(page.get(), FPDF_ANNOT_FREETEXT)); @@ -2571,7 +2572,7 @@ std::string GetRichTextJson(FPDF_ANNOTATION annot) { // B: without /RC the rich text model is synthesised from /Contents and /DA, // so callers always get one shape. TEST_F(EPDFAnnotEmbedderTest, RichTextJsonFromContentsOnly) { - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 400, 400)); ScopedFPDFAnnotation annot( FPDFPage_CreateAnnot(page.get(), FPDF_ANNOT_FREETEXT)); @@ -2595,7 +2596,7 @@ TEST_F(EPDFAnnotEmbedderTest, RichTextJsonFromContentsOnly) { } TEST_F(EPDFAnnotEmbedderTest, RichTextJsonFromRCAndDS) { - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 400, 400)); ScopedFPDFAnnotation annot( FPDFPage_CreateAnnot(page.get(), FPDF_ANNOT_FREETEXT)); @@ -2759,7 +2760,7 @@ TEST_F(EPDFAnnotEmbedderTest, RegisteredCffFontEmitsCidFontType0) { "CffLatin", /*weight=*/400, /*italic=*/0, cff.data(), cff.size()); ASSERT_NE(0u, font_id); - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 400, 400)); ScopedFPDFAnnotation annot = AuthorFreeText(page.get(), font_id, L"ABC"); ASSERT_TRUE(annot); @@ -2820,7 +2821,7 @@ TEST_F(EPDFAnnotEmbedderTest, RegisteredCidKeyedCffKeepsCidsInAppearance) { EXPECT_EQ(9831, identity.CidOf(3).value()); } - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 400, 400)); ScopedFPDFAnnotation annot = AuthorFreeText(page.get(), font_id, L"\x4e00"); ASSERT_TRUE(annot); @@ -2880,7 +2881,7 @@ TEST_F(EPDFAnnotEmbedderTest, CffProgramRaisesPdfVersionTo16) { // A 1.4 file: a fresh document saved with that version and reloaded. std::string old_pdf; { - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 400, 400)); ASSERT_TRUE(FPDFPage_GenerateContent(page.get())); ASSERT_TRUE(FPDF_SaveWithVersion(doc.get(), this, 0, 14)); @@ -2889,8 +2890,8 @@ TEST_F(EPDFAnnotEmbedderTest, CffProgramRaisesPdfVersionTo16) { } ASSERT_EQ(0u, old_pdf.find("%PDF-1.4")); - ScopedFPDFDocument doc(FPDF_LoadMemDocument( - old_pdf.data(), static_cast(old_pdf.size()), nullptr)); + embedpdf_test::ScopedTestDocument doc(embedpdf_test::LoadMemDocumentForTest( + old_pdf.data(), old_pdf.size(), nullptr)); ASSERT_TRUE(doc); ScopedFPDFPage page(FPDF_LoadPage(doc.get(), 0)); ASSERT_TRUE(page); @@ -2904,8 +2905,8 @@ TEST_F(EPDFAnnotEmbedderTest, CffProgramRaisesPdfVersionTo16) { std::vector roboto = LoadRobotoFontData(); EPDF_FONT_ID roboto_id = EPDFFont_RegisterMemFont64( "Roboto", /*weight=*/400, /*italic=*/0, roboto.data(), roboto.size()); - ScopedFPDFDocument doc2(FPDF_LoadMemDocument( - old_pdf.data(), static_cast(old_pdf.size()), nullptr)); + embedpdf_test::ScopedTestDocument doc2(embedpdf_test::LoadMemDocumentForTest( + old_pdf.data(), old_pdf.size(), nullptr)); ScopedFPDFPage page2(FPDF_LoadPage(doc2.get(), 0)); ScopedFPDFAnnotation annot2 = AuthorFreeText(page2.get(), roboto_id, L"ABC"); ASSERT_TRUE(annot2); @@ -2974,7 +2975,7 @@ TEST_F(EPDFAnnotEmbedderTest, ASSERT_NE(0u, noto_id); ASSERT_TRUE(EPDFFont_AddFallbackFont(noto_id, /*tier=*/0)); - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ASSERT_TRUE(doc); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 400, 400)); ASSERT_TRUE(page); @@ -3035,7 +3036,7 @@ TEST_F(EPDFAnnotEmbedderTest, RegisteredLayoutFontAllocatesNoDocumentObject) { "Roboto", /*weight=*/400, /*italic=*/0, roboto.data(), roboto.size()); ASSERT_NE(0u, roboto_id); - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); CPDF_Document* cpdf_doc = CPDFDocumentFromFPDFDocument(doc.get()); const uint32_t last_obj_before = cpdf_doc->GetLastObjNum(); { @@ -3068,7 +3069,7 @@ TEST_F(EPDFAnnotEmbedderTest, FontEmbeddingPolicyGovernsRegisteredResources) { EXPECT_EQ(-1, EPDFDoc_GetFontEmbeddingPolicy(nullptr)); EXPECT_FALSE(EPDFDoc_SetFontEmbeddingPolicy(nullptr, 0)); - CreateEmptyDocument(); + ASSERT_TRUE(OpenDocumentFromMemory(EmptyPdf())); { EXPECT_EQ(EPDF_FONT_EMBEDDING_POLICY_DEFAULT, EPDFDoc_GetFontEmbeddingPolicy(document())); @@ -3668,7 +3669,7 @@ TEST_F(RichTextParityTest, SubSuperscriptFixtureMatchesAcrobat) { // the appearance in one go, in Acrobat's shapes, and reads back the same // document. TEST_F(EPDFAnnotEmbedderTest, SetRichTextJSONWritesAllFourForms) { - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 400, 400)); ScopedFPDFAnnotation annot( FPDFPage_CreateAnnot(page.get(), FPDF_ANNOT_FREETEXT)); @@ -3736,7 +3737,7 @@ TEST_F(EPDFAnnotEmbedderTest, SetRichTextJSONWritesAllFourForms) { } TEST_F(EPDFAnnotEmbedderTest, SetRichTextJSONWithoutBodyKeepsCurrentBody) { - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 400, 400)); ScopedFPDFAnnotation annot( FPDFPage_CreateAnnot(page.get(), FPDF_ANNOT_FREETEXT)); @@ -3761,7 +3762,7 @@ TEST_F(EPDFAnnotEmbedderTest, SetRichTextJSONWithoutBodyKeepsCurrentBody) { } TEST_F(EPDFAnnotEmbedderTest, SetRichTextJSONRejectsInvalidInputUnchanged) { - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 400, 400)); ScopedFPDFAnnotation annot( FPDFPage_CreateAnnot(page.get(), FPDF_ANNOT_FREETEXT)); @@ -3802,7 +3803,7 @@ TEST_F(EPDFAnnotEmbedderTest, SetRichTextJSONRejectsInvalidInputUnchanged) { } TEST_F(EPDFAnnotEmbedderTest, SetRichTextXHTMLImportsOverDefaults) { - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 400, 400)); ScopedFPDFAnnotation annot( FPDFPage_CreateAnnot(page.get(), FPDF_ANNOT_FREETEXT)); @@ -3836,7 +3837,7 @@ TEST_F(EPDFAnnotEmbedderTest, SetRichTextJSONWithRegisteredBodyFont) { std::string saved; { - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 400, 400)); ScopedFPDFAnnotation annot( FPDFPage_CreateAnnot(page.get(), FPDF_ANNOT_FREETEXT)); @@ -3876,8 +3877,8 @@ TEST_F(EPDFAnnotEmbedderTest, SetRichTextJSONWithRegisteredBodyFont) { EPDF_FreeBuffer(saved_buffer); } // Reopened: the body family reads back from the descriptor. - ScopedFPDFDocument doc(FPDF_LoadMemDocument( - saved.data(), static_cast(saved.size()), nullptr)); + embedpdf_test::ScopedTestDocument doc(embedpdf_test::LoadMemDocumentForTest( + saved.data(), saved.size(), nullptr)); ASSERT_TRUE(doc); ScopedFPDFPage page(FPDF_LoadPage(doc.get(), 0)); ScopedFPDFAnnotation annot(FPDFPage_GetAnnot(page.get(), 0)); @@ -4029,7 +4030,7 @@ TEST_F(EPDFAnnotEmbedderTest, TextFieldDrawsItsBorderStyle) { } TEST_F(EPDFAnnotEmbedderTest, RichTextAlignmentFollowsTheAnnotation) { - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ASSERT_TRUE(doc); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 400, 400)); ASSERT_TRUE(page); @@ -4106,7 +4107,7 @@ TEST_F(EPDFAnnotEmbedderTest, RichTextAlignmentFollowsTheAnnotation) { // no text is laid out). Plain /Contents and /RC boxes share the one engine. TEST_F(EPDFAnnotEmbedderTest, FreeTextPlateFollowsBorderWidth) { { - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ASSERT_TRUE(doc); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 400, 400)); ASSERT_TRUE(page); @@ -4168,7 +4169,7 @@ TEST_F(EPDFAnnotEmbedderTest, FreeTextPlateFollowsBorderWidth) { // The document-level typographic features switch (kerning/ligatures off by // default for Acrobat parity). TEST_F(EPDFAnnotEmbedderTest, TypographicFeaturesSwitch) { - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); EXPECT_FALSE(EPDFDoc_GetTypographicFeatures(doc.get())); EXPECT_TRUE(EPDFDoc_SetTypographicFeatures(doc.get(), true)); EXPECT_TRUE(EPDFDoc_GetTypographicFeatures(doc.get())); @@ -4189,7 +4190,7 @@ TEST_F(EPDFAnnotEmbedderTest, RichTextWriterFailureLeavesDocumentUntouched) { ASSERT_NE(0u, roboto_id); ASSERT_NE(0u, amiri_id); - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 400, 400)); ScopedFPDFAnnotation annot( FPDFPage_CreateAnnot(page.get(), FPDF_ANNOT_FREETEXT)); @@ -4240,7 +4241,7 @@ TEST_F(EPDFAnnotEmbedderTest, RichTextRtlRunCarriesActualTextAndExtracts) { /*italic=*/0, amiri.data(), amiri.size())); std::string saved; { - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 400, 400)); ScopedFPDFAnnotation annot( FPDFPage_CreateAnnot(page.get(), FPDF_ANNOT_FREETEXT)); @@ -4264,8 +4265,8 @@ TEST_F(EPDFAnnotEmbedderTest, RichTextRtlRunCarriesActualTextAndExtracts) { saved.assign(static_cast(saved_buffer), saved_size); EPDF_FreeBuffer(saved_buffer); } - ScopedFPDFDocument doc(FPDF_LoadMemDocument( - saved.data(), static_cast(saved.size()), nullptr)); + embedpdf_test::ScopedTestDocument doc(embedpdf_test::LoadMemDocumentForTest( + saved.data(), saved.size(), nullptr)); ASSERT_TRUE(doc); ScopedFPDFPage page(FPDF_LoadPage(doc.get(), 0)); ASSERT_TRUE(page); @@ -4405,7 +4406,7 @@ TEST_F(EPDFAnnotEmbedderTest, RichTextResolvesDocumentProgramWhenUnregistered) { "Roboto", /*weight=*/400, /*italic=*/0, roboto.data(), roboto.size()); ASSERT_NE(0u, roboto_id); - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ASSERT_TRUE(EPDFDoc_SetFontEmbeddingPolicy(doc.get(), EPDF_FONT_EMBEDDING_POLICY_FULL)); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 400, 400)); @@ -4536,8 +4537,9 @@ TEST_F(EPDFAnnotEmbedderTest, RichTextSkipsDocumentSubsetWithoutCmap) { EPDF_FreeBuffer(saved_buffer); UnloadPage(page); { - ScopedFPDFDocument reloaded(FPDF_LoadMemDocument( - saved.data(), static_cast(saved.size()), nullptr)); + embedpdf_test::ScopedTestDocument reloaded( + embedpdf_test::LoadMemDocumentForTest(saved.data(), saved.size(), + nullptr)); ASSERT_TRUE(reloaded); ScopedFPDFPage reloaded_page(FPDF_LoadPage(reloaded.get(), 0)); ASSERT_TRUE(reloaded_page); @@ -4552,8 +4554,8 @@ TEST_F(EPDFAnnotEmbedderTest, RichTextSkipsDocumentSubsetWithoutCmap) { saved.assign(static_cast(flat_buffer), flat_size); EPDF_FreeBuffer(flat_buffer); } - ScopedFPDFDocument flat(FPDF_LoadMemDocument( - saved.data(), static_cast(saved.size()), nullptr)); + embedpdf_test::ScopedTestDocument flat(embedpdf_test::LoadMemDocumentForTest( + saved.data(), saved.size(), nullptr)); ASSERT_TRUE(flat); ScopedFPDFPage flat_page(FPDF_LoadPage(flat.get(), 0)); ASSERT_TRUE(flat_page); @@ -4597,7 +4599,7 @@ TEST_F(EPDFAnnotEmbedderTest, RichTextDocumentSubsetDrawsOnlyWhatItCovers) { roboto.size())); std::string saved; { - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 400, 400)); ScopedFPDFAnnotation annot( FPDFPage_CreateAnnot(page.get(), FPDF_ANNOT_FREETEXT)); @@ -4614,8 +4616,8 @@ TEST_F(EPDFAnnotEmbedderTest, RichTextDocumentSubsetDrawsOnlyWhatItCovers) { EPDF_FreeBuffer(saved_buffer); } EPDFFont_ClearRegisteredFonts(); - ScopedFPDFDocument doc(FPDF_LoadMemDocument( - saved.data(), static_cast(saved.size()), nullptr)); + embedpdf_test::ScopedTestDocument doc(embedpdf_test::LoadMemDocumentForTest( + saved.data(), saved.size(), nullptr)); ASSERT_TRUE(doc); ScopedFPDFPage page(FPDF_LoadPage(doc.get(), 0)); ASSERT_TRUE(page); @@ -4691,11 +4693,11 @@ TEST_F(EPDFAnnotEmbedderTest, RichTextPicksTheDocumentSubsetThatCoversTheText) { ASSERT_NE(0u, EPDFFont_RegisterMemFont64("Roboto", /*weight=*/400, /*italic=*/0, roboto.data(), roboto.size())); - ScopedFPDFDocument doc(saved.empty() - ? FPDF_CreateNewDocument() - : FPDF_LoadMemDocument( - saved.data(), - static_cast(saved.size()), nullptr)); + embedpdf_test::ScopedTestDocument doc = + saved.empty() ? NewTestDocument() + : embedpdf_test::ScopedTestDocument( + embedpdf_test::LoadMemDocumentForTest( + saved.data(), saved.size(), nullptr)); ASSERT_TRUE(doc); ScopedFPDFPage page(saved.empty() ? FPDFPage_New(doc.get(), 0, 400, 400) @@ -4717,8 +4719,8 @@ TEST_F(EPDFAnnotEmbedderTest, RichTextPicksTheDocumentSubsetThatCoversTheText) { }; author("Hello", 380.0f); // subset 1: H e l o author("World", 300.0f); // subset 2: W o r l d - ScopedFPDFDocument doc(FPDF_LoadMemDocument( - saved.data(), static_cast(saved.size()), nullptr)); + embedpdf_test::ScopedTestDocument doc(embedpdf_test::LoadMemDocumentForTest( + saved.data(), saved.size(), nullptr)); ASSERT_TRUE(doc); ScopedFPDFPage page(FPDF_LoadPage(doc.get(), 0)); ASSERT_TRUE(page); @@ -4761,7 +4763,7 @@ TEST_F(EPDFAnnotEmbedderTest, AnnotFontMapStagesEveryNamedFont) { EPDF_FONT_ID roboto_id = EPDFFont_RegisterMemFont64( "Roboto", /*weight=*/400, /*italic=*/0, roboto.data(), roboto.size()); ASSERT_NE(0u, roboto_id); - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ASSERT_TRUE(EPDFDoc_SetFontEmbeddingPolicy(doc.get(), EPDF_FONT_EMBEDDING_POLICY_FULL)); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 400, 400)); @@ -4877,7 +4879,7 @@ TEST_F(EPDFAnnotEmbedderTest, FreeTextRegisteredFontMarkerSurvivesAliasSuffix) { font_data.data(), font_data.size()); ASSERT_NE(0u, font_id); - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ASSERT_TRUE(doc); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 400, 400)); ASSERT_TRUE(page); @@ -4931,7 +4933,7 @@ TEST_F(EPDFAnnotEmbedderTest, TextFieldKoreanUsesRegisteredDroidFallbackFont) { EPDF_FONT_ID font_id = RegisterDroidSansFallbackFullFont(); ASSERT_NE(0u, font_id); - CreateEmptyDocument(); + ASSERT_TRUE(OpenDocumentFromMemory(EmptyPdf())); { ScopedFPDFPage page(FPDFPage_New(document(), 0, 400, 400)); ASSERT_TRUE(page); @@ -4971,7 +4973,7 @@ TEST_F(EPDFAnnotEmbedderTest, ComboBoxKoreanUsesRegisteredDroidFallbackFont) { EPDF_FONT_ID font_id = RegisterDroidSansFallbackFullFont(); ASSERT_NE(0u, font_id); - CreateEmptyDocument(); + ASSERT_TRUE(OpenDocumentFromMemory(EmptyPdf())); { ScopedFPDFPage page(FPDFPage_New(document(), 0, 400, 400)); ASSERT_TRUE(page); @@ -5012,7 +5014,7 @@ TEST_F(EPDFAnnotEmbedderTest, ListBoxKoreanUsesRegisteredDroidFallbackFont) { EPDF_FONT_ID font_id = RegisterDroidSansFallbackFullFont(); ASSERT_NE(0u, font_id); - CreateEmptyDocument(); + ASSERT_TRUE(OpenDocumentFromMemory(EmptyPdf())); { ScopedFPDFPage page(FPDFPage_New(document(), 0, 400, 400)); ASSERT_TRUE(page); @@ -5139,7 +5141,7 @@ TEST_F(EPDFAnnotEmbedderTest, FreeTextRegisteredFontSubsetsAreLayerLocal) { TEST_F(EPDFAnnotEmbedderTest, RegisteredFallbackFontRendersPageMissingGlyph) { auto create_broken_pdf = []() { - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); EXPECT_TRUE(doc); { ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 200, 200)); @@ -5888,7 +5890,7 @@ TEST_F(EPDFAnnotEmbedderTest, CloudyBumpsReachPastTheBoxIntoRect) { } TEST_F(EPDFAnnotEmbedderTest, CalloutRectHoldsItsLineAndArrow) { - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ASSERT_TRUE(doc); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 400, 400)); ASSERT_TRUE(page); @@ -6669,7 +6671,7 @@ TEST_F(EPDFAnnotEmbedderTest, ApplyRedactionCascadesPopupRemoval) { } TEST_F(EPDFAnnotEmbedderTest, ApplyRedactionRemovesTheMarksOwnPopup) { - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ASSERT_TRUE(doc); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 200, 200)); ASSERT_TRUE(page); @@ -6723,7 +6725,7 @@ TEST_F(EPDFAnnotEmbedderTest, ApplyPageRedactionsCountsRemovedAnnotations) { // [50,150) with the top half of the region at y [50,100). TEST_F(EPDFAnnotEmbedderTest, ApplyRedactionSynthesizesInteriorColorFill) { - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ASSERT_TRUE(doc); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 200, 200)); ASSERT_TRUE(page); @@ -6747,7 +6749,7 @@ TEST_F(EPDFAnnotEmbedderTest, ApplyRedactionSynthesizesInteriorColorFill) { } TEST_F(EPDFAnnotEmbedderTest, ApplyRedactionSynthesizesOverlayTextLabel) { - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ASSERT_TRUE(doc); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 200, 200)); ASSERT_TRUE(page); @@ -6778,7 +6780,7 @@ TEST_F(EPDFAnnotEmbedderTest, ApplyRedactionSynthesizesOverlayTextLabel) { } TEST_F(EPDFAnnotEmbedderTest, ApplyRedactionRepeatsOverlayTextToFillRegion) { - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ASSERT_TRUE(doc); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 200, 200)); ASSERT_TRUE(page); @@ -6809,7 +6811,7 @@ TEST_F(EPDFAnnotEmbedderTest, ApplyRedactionRepeatsOverlayTextToFillRegion) { } TEST_F(EPDFAnnotEmbedderTest, ApplyRedactionHonorsOverlayTextAlignment) { - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ASSERT_TRUE(doc); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 200, 200)); ASSERT_TRUE(page); @@ -6840,7 +6842,7 @@ TEST_F(EPDFAnnotEmbedderTest, ApplyRedactionHonorsOverlayTextAlignment) { } TEST_F(EPDFAnnotEmbedderTest, ApplyRedactionPrefersBakedOverlayStream) { - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ASSERT_TRUE(doc); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 200, 200)); ASSERT_TRUE(page); @@ -6876,7 +6878,7 @@ TEST_F(EPDFAnnotEmbedderTest, ApplyRedactionPrefersBakedOverlayStream) { } TEST_F(EPDFAnnotEmbedderTest, ApplyRedactionWithoutOverlayLeavesRegionClear) { - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ASSERT_TRUE(doc); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 200, 200)); ASSERT_TRUE(page); @@ -6975,7 +6977,7 @@ TEST_F(EPDFAnnotEmbedderTest, ApplyRedactionOnNeverParsedPageRemovesText) { } TEST_F(EPDFAnnotEmbedderTest, GenerateRedactAppearanceBakesLabelIntoOverlay) { - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ASSERT_TRUE(doc); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 200, 200)); ASSERT_TRUE(page); @@ -7012,7 +7014,7 @@ TEST_F(EPDFAnnotEmbedderTest, GenerateRedactAppearanceBakesLabelIntoOverlay) { // A /DA size of 0 means auto-size, and the font is still named: without it no // viewer can draw the text. TEST_F(EPDFAnnotEmbedderTest, SetDefaultAppearanceKeepsFontAtAutoSize) { - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ASSERT_TRUE(doc); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 200, 200)); ASSERT_TRUE(page); @@ -7041,7 +7043,7 @@ TEST_F(EPDFAnnotEmbedderTest, SetDefaultAppearanceKeepsFontAtAutoSize) { // The engine's path: the label at auto-size, baked into /RO, then applied. TEST_F(EPDFAnnotEmbedderTest, ApplyRedactionBurnsInAutoSizedLabel) { - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ASSERT_TRUE(doc); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 200, 200)); ASSERT_TRUE(page); @@ -7075,7 +7077,7 @@ TEST_F(EPDFAnnotEmbedderTest, ApplyRedactionBurnsInAutoSizedLabel) { // /Repeat at auto-size tiles the label at the fallback size, so the bottom // half of the region carries ink too. TEST_F(EPDFAnnotEmbedderTest, ApplyRedactionRepeatsAutoSizedLabel) { - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ASSERT_TRUE(doc); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 200, 200)); ASSERT_TRUE(page); @@ -7107,7 +7109,7 @@ TEST_F(EPDFAnnotEmbedderTest, ApplyRedactionRepeatsAutoSizedLabel) { // A /DA that names no font (another producer, or a mark written before /DA // kept the font at auto-size) still draws the label, in Helvetica. TEST_F(EPDFAnnotEmbedderTest, ApplyRedactionLabelWithoutDaFontUsesHelvetica) { - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ASSERT_TRUE(doc); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 200, 200)); ASSERT_TRUE(page); @@ -7133,7 +7135,7 @@ TEST_F(EPDFAnnotEmbedderTest, ApplyRedactionLabelWithoutDaFontUsesHelvetica) { } TEST_F(EPDFAnnotEmbedderTest, BorderStyleResolutionUsesISOPrecedence) { - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ASSERT_TRUE(doc); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 100, 100)); ASSERT_TRUE(page); @@ -7221,7 +7223,7 @@ TEST_F(EPDFAnnotEmbedderTest, BorderStyleResolutionUsesISOPrecedence) { } TEST_F(EPDFAnnotEmbedderTest, DashedBorderDrawsItsDashOrTheDefault) { - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ASSERT_TRUE(doc); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 200, 200)); ASSERT_TRUE(page); @@ -7263,7 +7265,7 @@ TEST_F(EPDFAnnotEmbedderTest, DashedBorderDrawsItsDashOrTheDefault) { } TEST_F(EPDFAnnotEmbedderTest, SetNameAcceptsAnyNameAndKeepsAppearance) { - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ASSERT_TRUE(doc); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 400, 400)); ASSERT_TRUE(page); @@ -7348,7 +7350,7 @@ TEST_F(EPDFAnnotEmbedderTest, SetNameAcceptsAnyNameAndKeepsAppearance) { } TEST_F(EPDFAnnotEmbedderTest, GenerateFileAttachmentAppearance) { - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ASSERT_TRUE(doc); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 400, 400)); ASSERT_TRUE(page); @@ -7380,7 +7382,7 @@ TEST_F(EPDFAnnotEmbedderTest, GenerateFileAttachmentAppearance) { } TEST_F(EPDFAnnotEmbedderTest, GenerateTextAppearanceFillsItsRect) { - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ASSERT_TRUE(doc); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 400, 400)); ASSERT_TRUE(page); @@ -7412,7 +7414,7 @@ TEST_F(EPDFAnnotEmbedderTest, GenerateTextAppearanceFillsItsRect) { } TEST_F(EPDFAnnotEmbedderTest, GenerateTextAppearancePerIcon) { - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ASSERT_TRUE(doc); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 400, 400)); ASSERT_TRUE(page); @@ -7448,7 +7450,7 @@ TEST_F(EPDFAnnotEmbedderTest, GenerateTextAppearancePerIcon) { } TEST_F(EPDFAnnotEmbedderTest, GenerateFileAttachmentAppearancePerIcon) { - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ASSERT_TRUE(doc); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 400, 400)); ASSERT_TRUE(page); @@ -8214,7 +8216,7 @@ class EPDFStampResizeEmbedderTest : public EmbedderTest { protected: void SetUp() override { EmbedderTest::SetUp(); - doc_.reset(FPDF_CreateNewDocument()); + doc_ = NewTestDocument(); ASSERT_TRUE(doc_); page_.reset(FPDFPage_New(doc_.get(), 0, 600, 600)); ASSERT_TRUE(page_); @@ -8275,8 +8277,9 @@ class EPDFStampResizeEmbedderTest : public EmbedderTest { ScopedFPDFAnnotation stamp(FPDFPage_CreateAnnot(page, FPDF_ANNOT_STAMP)); EXPECT_TRUE(stamp); EXPECT_TRUE(EPDFAnnot_SetRect(stamp.get(), &rect)); - ScopedFPDFDocument source( - FPDF_LoadMemDocument(bytes.data(), bytes.size(), nullptr)); + embedpdf_test::ScopedTestDocument source( + embedpdf_test::LoadMemDocumentForTest(bytes.data(), bytes.size(), + nullptr)); EXPECT_TRUE(source); EXPECT_TRUE(EPDFAnnot_SetAppearanceFromPage(stamp.get(), source.get(), 0)); EXPECT_TRUE( @@ -8284,7 +8287,7 @@ class EPDFStampResizeEmbedderTest : public EmbedderTest { return stamp; } - ScopedFPDFDocument doc_; + embedpdf_test::ScopedTestDocument doc_; ScopedFPDFPage page_; ScopedFPDFAnnotation annot_; }; @@ -8758,8 +8761,9 @@ TEST_F(EPDFStampResizeEmbedderTest, AnExportIsTheCanonicalDrawingPage) { EXPECT_EQ(std::string::npos, bytes.find("EPDFOrigContentRect")); EXPECT_EQ(std::string::npos, bytes.find("EPDFWRAP")); - ScopedFPDFDocument exported( - FPDF_LoadMemDocument(bytes.data(), bytes.size(), nullptr)); + embedpdf_test::ScopedTestDocument exported( + embedpdf_test::LoadMemDocumentForTest(bytes.data(), bytes.size(), + nullptr)); ScopedFPDFPage page(FPDF_LoadPage(exported.get(), 0)); auto page_dict = CPDFPageFromFPDFPage(page.get())->GetDict(); EXPECT_EQ("/EPDFDRAWING Do", @@ -8812,7 +8816,7 @@ TEST_F(EPDFStampResizeEmbedderTest, ExportAndImportAreAFixedPoint) { StreamBytes(drawing.Get())); // Another document numbers its objects differently: still the same bytes. - ScopedFPDFDocument other(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument other(NewTestDocument()); ScopedFPDFPage other_page(FPDFPage_New(other.get(), 0, 300, 300)); FS_RECTF other_rect{10, 60, 110, 10}; for (int cycle = 0; cycle < 2; ++cycle) { @@ -8830,7 +8834,7 @@ TEST_F(EPDFStampResizeEmbedderTest, ExportAndImportAreAFixedPoint) { // A page exported before the canonical shape (placement in a `cm`) still // imports, wrapped like any page. TEST_F(EPDFStampResizeEmbedderTest, AnOlderExportStillImports) { - ScopedFPDFDocument source(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument source(NewTestDocument()); ScopedFPDFPage source_page(FPDFPage_New(source.get(), 0, 100, 50)); CPDF_Document* source_doc = CPDFDocumentFromFPDFDocument(source.get()); const ByteStringView kArtwork = "1 0 0 rg 0 0 100 50 re f"; @@ -8860,9 +8864,8 @@ TEST_F(EPDFStampResizeEmbedderTest, AnOlderExportStillImports) { // Making a stamp from a page copies the page's drawing and changes nothing // else in the document: not its /Info. TEST_F(EPDFStampResizeEmbedderTest, AStampFromAPageLeavesTheDocumentInfoAlone) { - RetainPtr info = pdf()->GetInfo(); - ASSERT_TRUE(info); - info->SetNewFor("Producer", "Acme Writer"); + ScopedFPDFWideString producer = GetFPDFWideString(L"Acme Writer"); + ASSERT_TRUE(EPDF_SetMetaText(doc_.get(), "Producer", producer.get())); InstallArtwork(); ASSERT_TRUE( EPDFAnnot_UpdateAppearanceToRect(annot_.get(), EPDF_STAMP_FIT_CONTAIN)); @@ -8983,8 +8986,8 @@ std::string StreamSnapshot(const CPDF_Stream* stream) { // How many streams of the saved file `bytes` have exactly `content`, // filters applied. size_t StreamsWithContent(const std::string& bytes, ByteStringView content) { - ScopedFPDFDocument saved( - FPDF_LoadMemDocument(bytes.data(), bytes.size(), nullptr)); + embedpdf_test::ScopedTestDocument saved(embedpdf_test::LoadMemDocumentForTest( + bytes.data(), bytes.size(), nullptr)); CPDF_Document* doc = CPDFDocumentFromFPDFDocument(saved.get()); if (!doc) { ADD_FAILURE() << "the saved file does not open"; @@ -9007,8 +9010,9 @@ size_t StreamsWithContent(const std::string& bytes, ByteStringView content) { // exports, and a canonical page is its own canonical drawing. TEST_F(EPDFStampResizeEmbedderTest, CanonicalDrawingIsWhatAStampExports) { const std::string artwork = OnePagePdf(kBlueArtwork, 200, 100); - ScopedFPDFDocument source( - FPDF_LoadMemDocument(artwork.data(), artwork.size(), nullptr)); + embedpdf_test::ScopedTestDocument source( + embedpdf_test::LoadMemDocumentForTest(artwork.data(), artwork.size(), + nullptr)); ASSERT_TRUE(source); ScopedFPDFDocument canonical(EPDFDoc_CanonicalDrawing(source.get(), 0)); ASSERT_TRUE(canonical); @@ -9018,8 +9022,9 @@ TEST_F(EPDFStampResizeEmbedderTest, CanonicalDrawingIsWhatAStampExports) { StampFrom(page_.get(), artwork, FS_RECTF{300, 400, 500, 300}); EXPECT_EQ(bytes, ExportedBytes(stamp.get())); - ScopedFPDFDocument reloaded( - FPDF_LoadMemDocument(bytes.data(), bytes.size(), nullptr)); + embedpdf_test::ScopedTestDocument reloaded( + embedpdf_test::LoadMemDocumentForTest(bytes.data(), bytes.size(), + nullptr)); ScopedFPDFDocument again(EPDFDoc_CanonicalDrawing(reloaded.get(), 0)); ASSERT_TRUE(again); EXPECT_EQ(bytes, SavedBytes(again.get())); @@ -9032,8 +9037,9 @@ TEST_F(EPDFStampResizeEmbedderTest, CanonicalDrawingIsWhatAStampExports) { // canonical page is a drawing, and only a form exports as one. TEST_F(EPDFStampResizeEmbedderTest, AnImportedDrawingExportsItsCanonicalBytes) { const std::string artwork = OnePagePdf(kBlueArtwork, 200, 100); - ScopedFPDFDocument source( - FPDF_LoadMemDocument(artwork.data(), artwork.size(), nullptr)); + embedpdf_test::ScopedTestDocument source( + embedpdf_test::LoadMemDocumentForTest(artwork.data(), artwork.size(), + nullptr)); ScopedFPDFDocument canonical(EPDFDoc_CanonicalDrawing(source.get(), 0)); ASSERT_TRUE(canonical); const std::string bytes = SavedBytes(canonical.get()); @@ -9052,12 +9058,29 @@ TEST_F(EPDFStampResizeEmbedderTest, AnImportedDrawingExportsItsCanonicalBytes) { doc_.get(), EPDFDoc_GetPageObjectNumberByIndex(doc_.get(), 0))); } +// Taking a drawing from another document's page only reads that document +// (rule reads-dont-write): a layer's page stays in its base, and the layer +// hands out no object number. +TEST_F(EPDFStampResizeEmbedderTest, + ADrawingFromALayersPageLeavesTheLayerAlone) { + const std::string artwork = OnePagePdf(kBlueArtwork, 200, 100); + embedpdf_test::LayerFixture source; + ASSERT_TRUE(source.OpenBytes({artwork.begin(), artwork.end()})); + const unsigned long last = EPDFLayer_GetLastObjectNumber(source.layer); + ScopedFPDFDocument canonical(EPDFDoc_CanonicalDrawing(source.layer, 0)); + ASSERT_TRUE(canonical); + ASSERT_TRUE(EPDFAnnot_SetAppearanceFromPage(annot_.get(), source.layer, 0)); + EXPECT_EQ(0u, EPDFLayer_GetPromotedObjectCount(source.layer)); + EXPECT_EQ(last, EPDFLayer_GetLastObjectNumber(source.layer)); +} + // Stamps placing one drawing share it: a wrapper each, one drawing, and a // full save holds the drawing once. TEST_F(EPDFStampResizeEmbedderTest, StampsPlacingOneDrawingShareIt) { const std::string artwork = OnePagePdf(kBlueArtwork, 200, 100); - ScopedFPDFDocument source( - FPDF_LoadMemDocument(artwork.data(), artwork.size(), nullptr)); + embedpdf_test::ScopedTestDocument source( + embedpdf_test::LoadMemDocumentForTest(artwork.data(), artwork.size(), + nullptr)); ScopedFPDFDocument canonical(EPDFDoc_CanonicalDrawing(source.get(), 0)); const std::string bytes = SavedBytes(canonical.get()); const unsigned int drawing = @@ -9095,12 +9118,14 @@ TEST_F(EPDFStampResizeEmbedderTest, StampsPlacingOneDrawingShareIt) { // nothing has loaded it yet. unsigned int saved_drawing = 0; { - ScopedFPDFDocument saved( - FPDF_LoadMemDocument(saved_bytes.data(), saved_bytes.size(), nullptr)); + embedpdf_test::ScopedTestDocument saved( + embedpdf_test::LoadMemDocumentForTest(saved_bytes.data(), + saved_bytes.size(), nullptr)); ASSERT_EQ(1u, EPDFDoc_GetStampDrawings(saved.get(), &saved_drawing, 1)); } - ScopedFPDFDocument reopened( - FPDF_LoadMemDocument(saved_bytes.data(), saved_bytes.size(), nullptr)); + embedpdf_test::ScopedTestDocument reopened( + embedpdf_test::LoadMemDocumentForTest(saved_bytes.data(), + saved_bytes.size(), nullptr)); ScopedFPDFDocument reexported( EPDFDoc_ExportDrawing(reopened.get(), saved_drawing)); ASSERT_TRUE(reexported); @@ -9157,11 +9182,12 @@ TEST_F(EPDFStampResizeEmbedderTest, {Change::kResize, Change::kFit, Change::kTurn, Change::kOpacity, Change::kNewDrawing, Change::kFlatten, Change::kDelete}) { SCOPED_TRACE(static_cast(change)); - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 600, 600)); auto import = [&](const std::string& bytes) { - ScopedFPDFDocument source( - FPDF_LoadMemDocument(bytes.data(), bytes.size(), nullptr)); + embedpdf_test::ScopedTestDocument source( + embedpdf_test::LoadMemDocumentForTest(bytes.data(), bytes.size(), + nullptr)); ScopedFPDFDocument canonical(EPDFDoc_CanonicalDrawing(source.get(), 0)); return EPDFDoc_ImportDrawing(doc.get(), canonical.get()); }; @@ -9512,8 +9538,9 @@ TEST_P(EPDFStampSaveEmbedderTest, EXPECT_TRUE(std::equal(layer.bytes.begin(), layer.bytes.end(), saved.bytes.begin())); } - ScopedFPDFDocument reopened(FPDF_LoadMemDocument64( - saved.bytes.data(), saved.bytes.size(), nullptr)); + embedpdf_test::ScopedTestDocument reopened( + embedpdf_test::LoadMemDocumentForTest(saved.bytes.data(), + saved.bytes.size(), nullptr)); ASSERT_TRUE(reopened); ScopedFPDFPage reopened_page(FPDF_LoadPage(reopened.get(), 0)); ASSERT_TRUE(reopened_page); diff --git a/fpdfsdk/epdf_annot_identity_embeddertest.cpp b/fpdfsdk/epdf_annot_identity_embeddertest.cpp index 973f6b9813..c54a7b72fd 100644 --- a/fpdfsdk/epdf_annot_identity_embeddertest.cpp +++ b/fpdfsdk/epdf_annot_identity_embeddertest.cpp @@ -363,6 +363,7 @@ TEST_F(EPDFAnnotIdentityEmbedderTest, InlineAnnotationInAnIndirectArray) { TEST_F(EPDFAnnotIdentityEmbedderTest, LinkingToAnInlineAnnotationPromotes) { for (bool layer : {true, false}) { SCOPED_TRACE(layer ? "layer" : "document"); + // Plain in layer mode too: the layer is the other case. ScopedFPDFDocument doc = layer ? OpenLayer() : ScopedFPDFDocument(FPDF_LoadMemDocument( diff --git a/fpdfsdk/epdf_annot_raw_embeddertest.cpp b/fpdfsdk/epdf_annot_raw_embeddertest.cpp index 7f6d74f872..361fb6e255 100644 --- a/fpdfsdk/epdf_annot_raw_embeddertest.cpp +++ b/fpdfsdk/epdf_annot_raw_embeddertest.cpp @@ -10,6 +10,7 @@ #include "core/fpdfapi/parser/cpdf_name.h" #include "core/fpdfapi/parser/cpdf_string.h" #include "fpdfsdk/cpdfsdk_helpers.h" +#include "fpdfsdk/epdf_edit_test_util.h" #include "public/cpp/fpdf_scopers.h" #include "public/epdf_annot.h" #include "public/epdf_view.h" @@ -18,6 +19,7 @@ #include "public/fpdf_ppo.h" #include "public/fpdfview.h" #include "testing/embedder_test.h" +#include "testing/embedpdf_layer_mode.h" #include "testing/fx_string_testhelpers.h" #include "testing/gtest/include/gtest/gtest.h" @@ -52,7 +54,7 @@ uint32_t PageNamedByFirstAnnot(FPDF_DOCUMENT doc, int page_index) { class EPDFAnnotRawEmbedderTest : public EmbedderTest {}; TEST_F(EPDFAnnotRawEmbedderTest, FindsAnAnnotationByNameOnItsPage) { - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ASSERT_TRUE(doc); for (int index : {0, 1}) { ScopedFPDFPage page(FPDFPage_New(doc.get(), index, 612, 792)); @@ -86,7 +88,7 @@ TEST_F(EPDFAnnotRawEmbedderTest, FindsAnAnnotationByNameOnItsPage) { } TEST_F(EPDFAnnotRawEmbedderTest, FindsANameOnAnAnnotationWrittenInPlace) { - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ASSERT_TRUE(doc); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 612, 792)); ASSERT_TRUE(page); @@ -102,7 +104,7 @@ TEST_F(EPDFAnnotRawEmbedderTest, FindsANameOnAnAnnotationWrittenInPlace) { } TEST_F(EPDFAnnotRawEmbedderTest, FindsAnAnnotationByObjectNumber) { - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ASSERT_TRUE(doc); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 612, 792)); ASSERT_TRUE(page); @@ -134,7 +136,7 @@ TEST_F(EPDFAnnotRawEmbedderTest, FindsAnAnnotationByObjectNumber) { } TEST_F(EPDFAnnotRawEmbedderTest, FindsNothingWhereThereIsNothing) { - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ASSERT_TRUE(doc); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 612, 792)); ASSERT_TRUE(page); @@ -149,7 +151,7 @@ TEST_F(EPDFAnnotRawEmbedderTest, FindsNothingWhereThereIsNothing) { // A new annotation names its page (/P), whichever call made it; a copy of the // page names the copy. TEST_F(EPDFAnnotRawEmbedderTest, NewAnnotationsNameTheirPage) { - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ASSERT_TRUE(doc); for (int index : {0, 1}) { ScopedFPDFPage page(FPDFPage_New(doc.get(), index, 612, 792)); @@ -171,7 +173,7 @@ TEST_F(EPDFAnnotRawEmbedderTest, NewAnnotationsNameTheirPage) { EXPECT_EQ(EPDFDoc_GetPageObjectNumberByIndex(doc.get(), 1), PageNamedByFirstAnnot(doc.get(), 1)); - ScopedFPDFDocument copy(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument copy(NewTestDocument()); ASSERT_TRUE(copy); const int second_page[] = {1}; ASSERT_TRUE( diff --git a/fpdfsdk/epdf_attachment_embeddertest.cpp b/fpdfsdk/epdf_attachment_embeddertest.cpp index 7e6cc4e833..d764dca4b8 100644 --- a/fpdfsdk/epdf_attachment_embeddertest.cpp +++ b/fpdfsdk/epdf_attachment_embeddertest.cpp @@ -9,9 +9,11 @@ #include #include +#include "fpdfsdk/epdf_edit_test_util.h" #include "public/epdf_save.h" #include "public/fpdf_save.h" #include "testing/embedder_test.h" +#include "testing/embedpdf_layer_mode.h" #include "testing/fx_string_testhelpers.h" namespace { @@ -74,7 +76,7 @@ class EPDFAttachmentEmbedderTest : public EmbedderTest {}; // reported. (The size check was inverted: a larger buffer came back unfilled, // and a smaller one failed a CHECK.) TEST_F(EPDFAttachmentEmbedderTest, GetFileHonoursTheBufferContract) { - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ScopedFPDFWideString name = GetFPDFWideString(L"a.txt"); FPDF_ATTACHMENT file = FPDFDoc_AddAttachment(doc.get(), name.get()); ASSERT_TRUE(file); diff --git a/fpdfsdk/epdf_capture_embeddertest.cpp b/fpdfsdk/epdf_capture_embeddertest.cpp index 227567e89c..9fcea91a62 100644 --- a/fpdfsdk/epdf_capture_embeddertest.cpp +++ b/fpdfsdk/epdf_capture_embeddertest.cpp @@ -46,6 +46,7 @@ #include "public/fpdf_transformpage.h" #include "public/fpdfview.h" #include "testing/embedder_test.h" +#include "testing/embedpdf_layer_mode.h" #include "testing/fx_string_testhelpers.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" @@ -888,6 +889,7 @@ TEST_F(EPDFCaptureEmbedderTest, NonTerminalFieldHasNoCapture) { // Captures are for layers: a plain document has none. TEST_F(EPDFCaptureEmbedderTest, PlainDocumentHasNoCaptures) { + // Plain in layer mode too: the test is about a plain document. ScopedFPDFDocument doc( FPDF_LoadMemDocument(input_.data(), input_.size(), nullptr)); ASSERT_TRUE(doc); @@ -1364,6 +1366,7 @@ TEST_F(EPDFPageCaptureEmbedderTest, CapturesNeedAPageAndALayer) { EXPECT_FALSE(ImportPage(layer.get(), capture)); // outside a transaction EXPECT_THAT(PageOrder(layer.get()), ElementsAre(kCover, kBody)); + // Plain in layer mode too: a plain document has no captures. ScopedFPDFDocument plain( FPDF_LoadMemDocument(input_.data(), input_.size(), nullptr)); ASSERT_TRUE(plain); @@ -1670,6 +1673,7 @@ TEST_F(EPDFAttachmentCaptureEmbedderTest, CanonicalBytesTellTheSameFile) { EXPECT_NE(made, CanonicalAttachment(reopened.get(), L"c.txt")); EXPECT_TRUE(CanonicalAttachment(reopened.get(), L"none.txt").empty()); + // Plain in layer mode too: a plain document has no captures. ScopedFPDFDocument plain( FPDF_LoadMemDocument(input_.data(), input_.size(), nullptr)); ASSERT_TRUE(plain); @@ -1696,6 +1700,7 @@ TEST_F(EPDFAttachmentCaptureEmbedderTest, CapturesNeedAFileAndALayer) { ASSERT_TRUE(EPDFLayer_CommitTransaction(layer.get())); EXPECT_THAT(AttachmentKeys(layer.get()), ElementsAre(L"b.txt")); + // Plain in layer mode too: a plain document has no captures. ScopedFPDFDocument plain( FPDF_LoadMemDocument(input_.data(), input_.size(), nullptr)); ASSERT_TRUE(plain); diff --git a/fpdfsdk/epdf_catalog_embeddertest.cpp b/fpdfsdk/epdf_catalog_embeddertest.cpp index e74f3e39bc..f2c82bbb2e 100644 --- a/fpdfsdk/epdf_catalog_embeddertest.cpp +++ b/fpdfsdk/epdf_catalog_embeddertest.cpp @@ -90,6 +90,7 @@ OpenedPdf OpenPdf(const std::string& input, bool layer) { EPDFLayer_OpenLayer(opened.base.get(), nullptr, nullptr, nullptr)); } } else { + // Plain in layer mode too: the layer is the other case. opened.doc.reset( FPDF_LoadMemDocument64(input.data(), input.size(), nullptr)); } diff --git a/fpdfsdk/epdf_content_rewrite_embeddertest.cpp b/fpdfsdk/epdf_content_rewrite_embeddertest.cpp index dc3d1f5be3..09b0240b71 100644 --- a/fpdfsdk/epdf_content_rewrite_embeddertest.cpp +++ b/fpdfsdk/epdf_content_rewrite_embeddertest.cpp @@ -311,6 +311,7 @@ class EPDFContentRewriteEmbedderTest } doc_.reset(EPDFLayer_OpenLayer(base_.get(), nullptr, nullptr, nullptr)); } else { + // Plain in layer mode too: the layer is the other case. doc_.reset(FPDF_LoadMemDocument64(bytes_.data(), bytes_.size(), nullptr)); } return doc_.get(); diff --git a/fpdfsdk/epdf_edit_test_util.cpp b/fpdfsdk/epdf_edit_test_util.cpp index f8575a19ac..83f9321e34 100644 --- a/fpdfsdk/epdf_edit_test_util.cpp +++ b/fpdfsdk/epdf_edit_test_util.cpp @@ -109,6 +109,14 @@ std::string EmptyPdf() { }); } +embedpdf_test::ScopedTestDocument NewTestDocument() { + // The bytes outlive every document opened over them. + static const std::string* const empty = new std::string(EmptyPdf()); + return embedpdf_test::ScopedTestDocument( + embedpdf_test::LoadMemDocumentForTest(empty->data(), empty->size(), + nullptr)); +} + std::string Stream(const std::string& data) { return Stream("", data); } diff --git a/fpdfsdk/epdf_edit_test_util.h b/fpdfsdk/epdf_edit_test_util.h index b9e1fc523d..b4e5f0b01c 100644 --- a/fpdfsdk/epdf_edit_test_util.h +++ b/fpdfsdk/epdf_edit_test_util.h @@ -18,6 +18,7 @@ #include "public/cpp/fpdf_scopers.h" #include "public/fpdf_annot.h" #include "public/fpdfview.h" +#include "testing/embedpdf_layer_mode.h" class CPDF_Document; @@ -48,6 +49,10 @@ std::string MakePdf(const std::vector& objects); // every document the engine opens is; CreateEmptyDocument() never is. std::string EmptyPdf(); +// EmptyPdf() opened with embedpdf_test::LoadMemDocumentForTest(): a document +// of a test's own to write into, in place of FPDF_CreateNewDocument(). +embedpdf_test::ScopedTestDocument NewTestDocument(); + // A stream object body holding `data`. std::string Stream(const std::string& data); diff --git a/fpdfsdk/epdf_flatten_embeddertest.cpp b/fpdfsdk/epdf_flatten_embeddertest.cpp index 808c6e3b2e..9584a30c58 100644 --- a/fpdfsdk/epdf_flatten_embeddertest.cpp +++ b/fpdfsdk/epdf_flatten_embeddertest.cpp @@ -22,6 +22,7 @@ #include "core/fpdfapi/parser/cpdf_stream.h" #include "core/fpdfapi/parser/cpdf_string.h" #include "fpdfsdk/cpdfsdk_helpers.h" +#include "fpdfsdk/epdf_edit_test_util.h" #include "fpdfsdk/epdf_object_copier.h" #include "public/epdf_annot.h" #include "public/epdf_form.h" @@ -34,6 +35,7 @@ #include "public/fpdf_save.h" #include "public/fpdfview.h" #include "testing/embedder_test.h" +#include "testing/embedpdf_layer_mode.h" #include "testing/fx_string_testhelpers.h" #include "testing/test_loader.h" #include "testing/utils/file_util.h" @@ -355,7 +357,7 @@ TEST_F(EPDFFlattenEmbedderTest, FlattenReadsAlreadyPromotedAnnotationState) { } TEST_F(EPDFFlattenEmbedderTest, FlattenDirectAnnotationByHandle) { - ScopedFPDFDocument document(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument document(NewTestDocument()); ASSERT_TRUE(document); ScopedFPDFPage page(FPDFPage_New(document.get(), 0, 100, 100)); ASSERT_TRUE(page); @@ -436,7 +438,7 @@ TEST_F(EPDFFlattenEmbedderTest, FlattenAnnotationSetRejectsForeignAnnotation) { ASSERT_TRUE(page); // An annotation from ANOTHER document: the whole call fails, nothing moves. - ScopedFPDFDocument other(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument other(NewTestDocument()); ScopedFPDFPage other_page(FPDFPage_New(other.get(), 0, 100, 100)); ScopedFPDFAnnotation foreign( FPDFPage_CreateAnnot(other_page.get(), FPDF_ANNOT_SQUARE)); @@ -459,7 +461,7 @@ TEST_F(EPDFFlattenEmbedderTest, FlattenAnnotationSetRejectsForeignAnnotation) { TEST_F(EPDFFlattenEmbedderTest, ExportAnnotationsMatchesSourceCrop) { // Blank source page: a render of the exported page must equal a crop of // the source page rendered WITH annotations, pixel for pixel. - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ASSERT_TRUE(doc); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 300, 300)); ASSERT_TRUE(page); @@ -552,7 +554,7 @@ TEST_F(EPDFFlattenEmbedderTest, ExportAnnotationsIsAllOrNothing) { TEST_F(EPDFFlattenEmbedderTest, ExportAnnotationsDeduplicatesSharedResources) { // Two annotations whose appearance streams reference the SAME indirect // font object: the exported document must carry that font once. - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 200, 200)); ASSERT_TRUE(page); CPDF_Document* src = CPDFDocumentFromFPDFDocument(doc.get()); @@ -622,7 +624,7 @@ TEST_F(EPDFFlattenEmbedderTest, ExportAnnotationsDeduplicatesSharedResources) { } TEST_F(EPDFFlattenEmbedderTest, FlattenPaintsTheAppearanceDrawnInMemory) { - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ASSERT_TRUE(doc); CPDF_Document* pdf = CPDFDocumentFromFPDFDocument(doc.get()); { @@ -661,8 +663,8 @@ TEST_F(EPDFFlattenEmbedderTest, ExportPagesFlattenedPrintsAFieldDrawnInMemory) { const std::string path = PathService::GetTestFilePath("text_form.pdf"); ASSERT_FALSE(path.empty()); std::vector bytes = GetFileContents(path.c_str()); - ScopedFPDFDocument doc( - FPDF_LoadMemDocument64(bytes.data(), bytes.size(), nullptr)); + embedpdf_test::ScopedTestDocument doc(embedpdf_test::LoadMemDocumentForTest( + bytes.data(), bytes.size(), nullptr)); ASSERT_TRUE(doc); CPDF_Document* pdf = CPDFDocumentFromFPDFDocument(doc.get()); // The text field has no appearance: the renderer draws its value in @@ -727,7 +729,7 @@ TEST_F(EPDFFlattenEmbedderTest, ExportPagesFlattenedLeavesThePageActionsOut) { } TEST_F(EPDFFlattenEmbedderTest, ExportPagesFlattenedKeepsTheLayersPrintState) { - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ASSERT_TRUE(doc); CPDF_Document* pdf = CPDFDocumentFromFPDFDocument(doc.get()); @@ -877,7 +879,7 @@ TEST_F(EPDFFlattenEmbedderTest, InvisibleLeavesOutOnlyAnUnknownType) { }; for (const Case& test : cases) { SCOPED_TRACE(testing::Message() << test.subtype << " /F " << test.flags); - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ASSERT_TRUE(doc); { ScopedFPDFPage blank(FPDFPage_New(doc.get(), 0, 200, 200)); @@ -916,7 +918,7 @@ TEST_F(EPDFFlattenEmbedderTest, InvisibleLeavesOutOnlyAnUnknownType) { TEST_F(EPDFFlattenEmbedderTest, ExportPagesFlattenedCopiesPagesInTheGivenOrder) { - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ASSERT_TRUE(doc); for (int i = 0; i < 3; ++i) { ScopedFPDFPage page(FPDFPage_New(doc.get(), i, 100.0 + 10 * i, 200)); @@ -966,7 +968,7 @@ TEST_F(EPDFFlattenEmbedderTest, ExportPagesFlattenedFromALayerWritesNothing) { } TEST_F(EPDFFlattenEmbedderTest, CopierFollowsReferencesByWhatTheyResolveTo) { - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ASSERT_TRUE(doc); CPDF_Document* pdf = CPDFDocumentFromFPDFDocument(doc.get()); // An appearance drawn in memory numbers its fonts from 1 in a store of its diff --git a/fpdfsdk/epdf_layer_embeddertest.cpp b/fpdfsdk/epdf_layer_embeddertest.cpp index e11c87e920..23d1ff5b48 100644 --- a/fpdfsdk/epdf_layer_embeddertest.cpp +++ b/fpdfsdk/epdf_layer_embeddertest.cpp @@ -1470,6 +1470,7 @@ TEST_F(EPDFLayerEmbedderTest, SaveLayerDeltaMaterializesWithBaseBytes) { materialized += delta; } + // Plain in layer mode too: any reader opens the materialized file. ScopedFPDFDocument reopened(FPDF_LoadMemDocument64( materialized.data(), materialized.size(), nullptr)); ASSERT_TRUE(reopened); @@ -1540,6 +1541,7 @@ TEST_F(EPDFLayerEmbedderTest, LayerDeltaReplayWithLeadingBytesInBase) { EXPECT_EQ(1, FPDFPage_GetAnnotCount(replayed_page.get())); const std::string materialized = base_bytes + delta; + // Plain in layer mode too: any reader opens the materialized file. ScopedFPDFDocument stock_reopened(FPDF_LoadMemDocument64( materialized.data(), materialized.size(), nullptr)); ASSERT_TRUE(stock_reopened); @@ -1594,6 +1596,7 @@ TEST_F(EPDFLayerEmbedderTest, LayerDeltaReplayWithTrailingBytesInBase) { EXPECT_EQ(1, FPDFPage_GetAnnotCount(replayed_page.get())); const std::string materialized = base_bytes + delta; + // Plain in layer mode too: any reader opens the materialized file. ScopedFPDFDocument stock_reopened(FPDF_LoadMemDocument64( materialized.data(), materialized.size(), nullptr)); ASSERT_TRUE(stock_reopened); @@ -1897,6 +1900,7 @@ TEST_F(EPDFLayerEmbedderTest, LayerReplaySoakSmoke) { materialized += GetString(); } + // Plain in layer mode too: any reader opens the materialized file. ScopedFPDFDocument reopened(FPDF_LoadMemDocument64( materialized.data(), materialized.size(), nullptr)); ASSERT_TRUE(reopened); @@ -1958,6 +1962,7 @@ TEST_F(EPDFLayerEmbedderTest, LayerDeltaReplaysMultipleAnnotRemoval) { std::string materialized(reinterpret_cast(base_bytes.data()), base_bytes.size()); materialized += delta; + // Plain in layer mode too: any reader opens the materialized file. ScopedFPDFDocument stock_reopened(FPDF_LoadMemDocument64( materialized.data(), materialized.size(), nullptr)); ASSERT_TRUE(stock_reopened); diff --git a/fpdfsdk/epdf_measure_embeddertest.cpp b/fpdfsdk/epdf_measure_embeddertest.cpp index 84d792de75..5ceb11cdc7 100644 --- a/fpdfsdk/epdf_measure_embeddertest.cpp +++ b/fpdfsdk/epdf_measure_embeddertest.cpp @@ -22,6 +22,7 @@ #include "core/fpdfdoc/cpdf_annotfontmap.h" #include "core/fpdfdoc/cpdf_appearancegenerator.h" #include "fpdfsdk/cpdfsdk_helpers.h" +#include "fpdfsdk/epdf_edit_test_util.h" #include "public/cpp/fpdf_scopers.h" #include "public/epdf_annot.h" #include "public/epdf_font.h" @@ -32,6 +33,7 @@ #include "testing/embedder_test.h" #include "testing/embedder_test_environment.h" #include "testing/embedpdf_layer_fixture.h" +#include "testing/embedpdf_layer_mode.h" #include "testing/fx_string_testhelpers.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/test_fonts.h" @@ -102,7 +104,7 @@ Delta SaveDelta(FPDF_DOCUMENT doc) { class EPDFMeasureEmbedderTest : public EmbedderTest { protected: std::vector Base(bool indirect = false) { - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 612, 792)); ScopedFPDFAnnotation a(EPDFPage_CreateAnnot(page.get(), FPDF_ANNOT_LINE)); ScopedFPDFAnnotation b(EPDFPage_CreateAnnot(page.get(), FPDF_ANNOT_LINE)); @@ -209,7 +211,7 @@ TEST_F(EPDFMeasureEmbedderTest, BadArgumentsAndRejectedWrites) { } TEST_F(EPDFMeasureEmbedderTest, NumberFormatsRoundTripAndAbsentVersusEmpty) { - CreateEmptyDocument(); + ASSERT_TRUE(OpenDocumentFromMemory(EmptyPdf())); ScopedFPDFPage page(FPDFPage_New(document(), 0, 612, 792)); ScopedFPDFAnnotation annot(EPDFPage_CreateAnnot(page.get(), FPDF_ANNOT_LINE)); auto m = EPDFAnnot_AddMeasure(annot.get()); @@ -284,7 +286,7 @@ TEST_F(EPDFMeasureEmbedderTest, NumberFormatsRoundTripAndAbsentVersusEmpty) { } TEST_F(EPDFMeasureEmbedderTest, HandlesInvalidateAcrossTwoAnnotationHandles) { - CreateEmptyDocument(); + ASSERT_TRUE(OpenDocumentFromMemory(EmptyPdf())); ScopedFPDFPage page(FPDFPage_New(document(), 0, 612, 792)); ScopedFPDFAnnotation a(EPDFPage_CreateAnnot(page.get(), FPDF_ANNOT_LINE)); ScopedFPDFAnnotation b(FPDFPage_GetAnnot(page.get(), 0)); @@ -312,7 +314,7 @@ TEST_F(EPDFMeasureEmbedderTest, HandlesInvalidateAcrossTwoAnnotationHandles) { } TEST_F(EPDFMeasureEmbedderTest, ViewportsFindLastAndInvalidateOnRemoval) { - CreateEmptyDocument(); + ASSERT_TRUE(OpenDocumentFromMemory(EmptyPdf())); ScopedFPDFPage page(FPDFPage_New(document(), 0, 612, 792)); auto a = EPDFPage_AddViewport(page.get(), &kBox); const FS_RECTF box{50, 300, 300, 50}; @@ -348,8 +350,8 @@ TEST_F(EPDFMeasureEmbedderTest, ViewportsFindLastAndInvalidateOnRemoval) { TEST_F(EPDFMeasureEmbedderTest, UnknownMeasureIsPreservedAndGeoSettersRejectBeforePromotion) { auto bytes = Base(); - ScopedFPDFDocument doc( - FPDF_LoadMemDocument64(bytes.data(), bytes.size(), nullptr)); + embedpdf_test::ScopedTestDocument doc(embedpdf_test::LoadMemDocumentForTest( + bytes.data(), bytes.size(), nullptr)); ScopedFPDFPage page(FPDF_LoadPage(doc.get(), 0)); ScopedFPDFAnnotation a(FPDFPage_GetAnnot(page.get(), 0)); auto dict = CPDFAnnotContextFromFPDFAnnotation(a.get()) @@ -445,7 +447,7 @@ TEST_F(EPDFMeasureEmbedderTest, LayerReadsPromoteNothingAndPageWritesOnlyPage) { } TEST_F(EPDFMeasureEmbedderTest, LineAndShapeCaptionEntriesStaySeparate) { - CreateEmptyDocument(); + ASSERT_TRUE(OpenDocumentFromMemory(EmptyPdf())); ScopedFPDFPage page(FPDFPage_New(document(), 0, 612, 792)); ScopedFPDFAnnotation line(EPDFPage_CreateAnnot(page.get(), FPDF_ANNOT_LINE)); ScopedFPDFAnnotation shape( @@ -512,7 +514,7 @@ TEST_F(EPDFMeasureEmbedderTest, LineAndShapeCaptionEntriesStaySeparate) { } TEST_F(EPDFMeasureEmbedderTest, LineAppearanceLeadersInlineGapAndStableBounds) { - CreateEmptyDocument(); + ASSERT_TRUE(OpenDocumentFromMemory(EmptyPdf())); ScopedFPDFPage page(FPDFPage_New(document(), 0, 612, 792)); ScopedFPDFAnnotation a(EPDFPage_CreateAnnot(page.get(), FPDF_ANNOT_LINE)); MakeLine(a.get()); @@ -550,7 +552,7 @@ TEST_F(EPDFMeasureEmbedderTest, LineAppearanceLeadersInlineGapAndStableBounds) { } TEST_F(EPDFMeasureEmbedderTest, ShortDistanceOmitsShaftAndBoundsCanShrink) { - CreateEmptyDocument(); + ASSERT_TRUE(OpenDocumentFromMemory(EmptyPdf())); ScopedFPDFPage page(FPDFPage_New(document(), 0, 612, 792)); ScopedFPDFAnnotation annot(EPDFPage_CreateAnnot(page.get(), FPDF_ANNOT_LINE)); MakeLine(annot.get()); @@ -596,7 +598,7 @@ TEST_F(EPDFMeasureEmbedderTest, ShortDistanceOmitsShaftAndBoundsCanShrink) { TEST_F(EPDFMeasureEmbedderTest, ShapeCaptionCenterRoundTripsAndOnlyChangesVisualBounds) { - CreateEmptyDocument(); + ASSERT_TRUE(OpenDocumentFromMemory(EmptyPdf())); ScopedFPDFPage page(FPDFPage_New(document(), 0, 612, 792)); ScopedFPDFAnnotation a(EPDFPage_CreateAnnot(page.get(), FPDF_ANNOT_POLYGON)); FS_POINTF points[] = {{100, 100}, {200, 100}, {200, 200}, {100, 200}}; @@ -637,7 +639,7 @@ TEST_F(EPDFMeasureEmbedderTest, } TEST_F(EPDFMeasureEmbedderTest, ShapeCaptionBoundsShrinkWhenMovedInward) { - CreateEmptyDocument(); + ASSERT_TRUE(OpenDocumentFromMemory(EmptyPdf())); ScopedFPDFPage page(FPDFPage_New(document(), 0, 612, 792)); ScopedFPDFAnnotation annot( EPDFPage_CreateAnnot(page.get(), FPDF_ANNOT_POLYGON)); @@ -766,8 +768,8 @@ TEST_F(EPDFMeasureEmbedderTest, ReadsAllAcrobatImperialMeasurements) { TEST_F(EPDFMeasureEmbedderTest, DirectMeasureWithSharedNestedFormatDetachesOnlyItsOwner) { auto bytes = Base(); - ScopedFPDFDocument doc( - FPDF_LoadMemDocument64(bytes.data(), bytes.size(), nullptr)); + embedpdf_test::ScopedTestDocument doc(embedpdf_test::LoadMemDocumentForTest( + bytes.data(), bytes.size(), nullptr)); ScopedFPDFPage page(FPDF_LoadPage(doc.get(), 0)); ScopedFPDFAnnotation a(FPDFPage_GetAnnot(page.get(), 0)), b(FPDFPage_GetAnnot(page.get(), 1)); @@ -807,7 +809,7 @@ TEST_F(EPDFMeasureEmbedderTest, TEST_F(EPDFMeasureEmbedderTest, SharedIndirectViewportTreeDetachesAndForeignEntriesSurvive) { - CreateEmptyDocument(); + ASSERT_TRUE(OpenDocumentFromMemory(EmptyPdf())); ScopedFPDFPage page(FPDFPage_New(document(), 0, 612, 792)); ScopedFPDFPage other(FPDFPage_New(document(), 1, 612, 792)); auto first = EPDFPage_AddViewport(page.get(), &kBox); @@ -867,7 +869,7 @@ TEST_F(EPDFMeasureEmbedderTest, } TEST_F(EPDFMeasureEmbedderTest, MissingOrMalformedConversionNeverBecomesOne) { - CreateEmptyDocument(); + ASSERT_TRUE(OpenDocumentFromMemory(EmptyPdf())); ScopedFPDFPage page(FPDFPage_New(document(), 0, 612, 792)); ScopedFPDFAnnotation a(EPDFPage_CreateAnnot(page.get(), FPDF_ANNOT_LINE)); auto m = EPDFAnnot_AddMeasure(a.get()); @@ -907,7 +909,7 @@ TEST_F(EPDFMeasureEmbedderTest, } TEST_F(EPDFMeasureEmbedderTest, CaptionAppearanceGolden) { - CreateEmptyDocument(); + ASSERT_TRUE(OpenDocumentFromMemory(EmptyPdf())); ScopedFPDFPage page(FPDFPage_New(document(), 0, 612, 500)); const FS_POINTF start[] = {{60, 430}, {330, 430}, {60, 300}, {330, 300}, {60, 160}, {330, 160}}; @@ -966,7 +968,7 @@ TEST_F(EPDFMeasureEmbedderTest, auto id = EPDFFont_RegisterMemFont64("Roboto", 400, false, bytes.data(), bytes.size()); ASSERT_NE(0u, id); - CreateEmptyDocument(); + ASSERT_TRUE(OpenDocumentFromMemory(EmptyPdf())); ScopedFPDFPage page(FPDFPage_New(document(), 0, 612, 792)); ScopedFPDFAnnotation a(EPDFPage_CreateAnnot(page.get(), FPDF_ANNOT_LINE)); MakeLine(a.get()); diff --git a/fpdfsdk/epdf_named_pages_embeddertest.cpp b/fpdfsdk/epdf_named_pages_embeddertest.cpp index 1a94f06ab5..896d972726 100644 --- a/fpdfsdk/epdf_named_pages_embeddertest.cpp +++ b/fpdfsdk/epdf_named_pages_embeddertest.cpp @@ -6,6 +6,7 @@ #include #include +#include "fpdfsdk/epdf_edit_test_util.h" #include "public/cpp/fpdf_scopers.h" #include "public/epdf_layer.h" #include "public/epdf_save.h" @@ -233,7 +234,7 @@ TEST_F(EPDFNamedPagesEmbedderTest, DeletingAPageDropsItsRegistrations) { } TEST_F(EPDFNamedPagesEmbedderTest, NewDocumentGrowsATreeOnFirstSet) { - CreateEmptyDocument(); + ASSERT_TRUE(OpenDocumentFromMemory(EmptyPdf())); ScopedFPDFPage first(FPDFPage_New(document(), 0, 200, 100)); ScopedFPDFPage second(FPDFPage_New(document(), 1, 200, 100)); ASSERT_TRUE(first); diff --git a/fpdfsdk/epdf_object_number_embeddertest.cpp b/fpdfsdk/epdf_object_number_embeddertest.cpp index c6d5c03813..c0e68b26bc 100644 --- a/fpdfsdk/epdf_object_number_embeddertest.cpp +++ b/fpdfsdk/epdf_object_number_embeddertest.cpp @@ -38,6 +38,7 @@ #include "public/fpdf_save.h" #include "public/fpdfview.h" #include "testing/embedder_test.h" +#include "testing/embedpdf_layer_mode.h" #include "testing/fx_string_testhelpers.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" @@ -258,6 +259,7 @@ TEST_F(EPDFObjectNumberEmbedderTest, RaiseStopsAtTheParserLimit) { // A document that is not a layer has no last object number to raise and // takes no chosen numbers; creates without one work as before. TEST_F(EPDFObjectNumberEmbedderTest, PlainDocumentTakesNoChosenNumber) { + // Plain in layer mode too: the test is about a plain document. ScopedFPDFDocument doc( FPDF_LoadMemDocument(input_.data(), input_.size(), nullptr)); ASSERT_TRUE(doc); @@ -439,8 +441,9 @@ TEST_F(EPDFObjectNumberEmbedderTest, FullSaveListsUnusedNumbersAsFree) { EXPECT_EQ(row, entry(number)); } - ScopedFPDFDocument reopened( - FPDF_LoadMemDocument64(saved.data(), saved.size(), nullptr)); + embedpdf_test::ScopedTestDocument reopened( + embedpdf_test::LoadMemDocumentForTest(saved.data(), saved.size(), + nullptr)); ASSERT_TRUE(reopened); EXPECT_FALSE(CPDFDocumentFromFPDFDocument(reopened.get()) ->GetParser() @@ -456,8 +459,8 @@ TEST_F(EPDFObjectNumberEmbedderTest, FullSaveListsUnusedNumbersAsFree) { ClearString(); ASSERT_TRUE(FPDF_SaveAsCopy(reopened.get(), this, FPDF_INCREMENTAL)); const std::string updated = GetString(); - ScopedFPDFDocument newer( - FPDF_LoadMemDocument64(updated.data(), updated.size(), nullptr)); + embedpdf_test::ScopedTestDocument newer(embedpdf_test::LoadMemDocumentForTest( + updated.data(), updated.size(), nullptr)); ASSERT_TRUE(newer); ScopedFPDFDocument older(EPDFDoc_OpenRevision(newer.get(), saved.size())); ASSERT_TRUE(older); diff --git a/fpdfsdk/epdf_outline_embeddertest.cpp b/fpdfsdk/epdf_outline_embeddertest.cpp index 9ca4b3cc24..ee87d9e89c 100644 --- a/fpdfsdk/epdf_outline_embeddertest.cpp +++ b/fpdfsdk/epdf_outline_embeddertest.cpp @@ -32,6 +32,7 @@ #include "public/fpdf_doc.h" #include "public/fpdfview.h" #include "testing/embedder_test.h" +#include "testing/embedpdf_layer_mode.h" #include "testing/fx_string_testhelpers.h" #include "testing/gtest/include/gtest/gtest.h" @@ -294,7 +295,16 @@ class EPDFOutlineEmbedderTest : public EmbedderTest { EmbedderTest::TearDown(); } - // A plain document of |bytes|. + // A document of |bytes|, as a test opens one: a layer in layer mode. + embedpdf_test::ScopedTestDocument Open(std::string bytes = MakeDocument()) { + plain_ = std::move(bytes); + return embedpdf_test::ScopedTestDocument( + embedpdf_test::LoadMemDocumentForTest(plain_.data(), plain_.size(), + nullptr)); + } + + // A plain document of |bytes|, in layer mode too: for a test about plain + // documents. ScopedFPDFDocument OpenPlain(std::string bytes = MakeDocument()) { plain_ = std::move(bytes); return ScopedFPDFDocument( @@ -344,7 +354,7 @@ class EPDFOutlineEmbedderTest : public EmbedderTest { }; TEST_F(EPDFOutlineEmbedderTest, ItemsAreNamedByNumber) { - ScopedFPDFDocument doc = OpenPlain(); + embedpdf_test::ScopedTestDocument doc = Open(); ASSERT_TRUE(doc); EXPECT_EQ("4:A+1[A1] B C-1[C1]", Tree(doc.get())); EXPECT_EQ("", Problems(doc.get())); @@ -362,7 +372,7 @@ TEST_F(EPDFOutlineEmbedderTest, ItemsAreNamedByNumber) { } TEST_F(EPDFOutlineEmbedderTest, CreatePlacesTheItemAndCounts) { - ScopedFPDFDocument doc = OpenPlain(); + embedpdf_test::ScopedTestDocument doc = Open(); ASSERT_TRUE(doc); const uint32_t top = Create(doc.get(), 0, 0, L"Top"); ASSERT_TRUE(top); @@ -390,7 +400,7 @@ TEST_F(EPDFOutlineEmbedderTest, CreatePlacesTheItemAndCounts) { } TEST_F(EPDFOutlineEmbedderTest, CreateRefusesAndChangesNothing) { - ScopedFPDFDocument doc = OpenPlain(); + embedpdf_test::ScopedTestDocument doc = Open(); ASSERT_TRUE(doc); CPDF_Document* pdf = CPDFDocumentFromFPDFDocument(doc.get()); const std::map before = ObjectGraph(pdf); @@ -417,7 +427,7 @@ TEST_F(EPDFOutlineEmbedderTest, CreateAtANumberOnALayer) { } TEST_F(EPDFOutlineEmbedderTest, CreateMakesTheOutline) { - ScopedFPDFDocument doc = OpenPlain(MakePdf({ + embedpdf_test::ScopedTestDocument doc = Open(MakePdf({ "<< /Type /Catalog /Pages 2 0 R >>", "<< /Type /Pages /Kids [3 0 R] /Count 1 >>", "<< /Type /Page /Parent 2 0 R /MediaBox [0 0 300 300] >>", @@ -435,7 +445,7 @@ TEST_F(EPDFOutlineEmbedderTest, CreateMakesTheOutline) { } TEST_F(EPDFOutlineEmbedderTest, MoveKeepsNumbersKeysAndState) { - ScopedFPDFDocument doc = OpenPlain(); + embedpdf_test::ScopedTestDocument doc = Open(); ASSERT_TRUE(doc); // C goes under A, closed, with its child and its keys. ASSERT_TRUE(EPDFOutline_MoveItem(doc.get(), kC, kA, kA1)); @@ -459,7 +469,7 @@ TEST_F(EPDFOutlineEmbedderTest, MoveKeepsNumbersKeysAndState) { } TEST_F(EPDFOutlineEmbedderTest, MoveRefusesAndChangesNothing) { - ScopedFPDFDocument doc = OpenPlain(); + embedpdf_test::ScopedTestDocument doc = Open(); ASSERT_TRUE(doc); CPDF_Document* pdf = CPDFDocumentFromFPDFDocument(doc.get()); const std::map before = ObjectGraph(pdf); @@ -474,7 +484,7 @@ TEST_F(EPDFOutlineEmbedderTest, MoveRefusesAndChangesNothing) { } TEST_F(EPDFOutlineEmbedderTest, DeleteTakesTheItemsUnderIt) { - ScopedFPDFDocument doc = OpenPlain(); + embedpdf_test::ScopedTestDocument doc = Open(); ASSERT_TRUE(doc); ASSERT_TRUE(EPDFOutline_DeleteItem(doc.get(), kA)); EXPECT_EQ("2:B C-1[C1]", Tree(doc.get())); @@ -499,7 +509,7 @@ TEST_F(EPDFOutlineEmbedderTest, DeleteTakesTheItemsUnderIt) { } TEST_F(EPDFOutlineEmbedderTest, SetOpenFlipsTheSignAndCountsAgain) { - ScopedFPDFDocument doc = OpenPlain(); + embedpdf_test::ScopedTestDocument doc = Open(); ASSERT_TRUE(doc); ASSERT_TRUE(EPDFOutline_SetOpen(doc.get(), kC, true)); EXPECT_EQ("5:A+1[A1] B C+1[C1]", Tree(doc.get())); @@ -513,7 +523,7 @@ TEST_F(EPDFOutlineEmbedderTest, SetOpenFlipsTheSignAndCountsAgain) { } TEST_F(EPDFOutlineEmbedderTest, TitleColorAndStyle) { - ScopedFPDFDocument doc = OpenPlain(); + embedpdf_test::ScopedTestDocument doc = Open(); ASSERT_TRUE(doc); ScopedFPDFWideString renamed = GetFPDFWideString(L"Ölçü"); ASSERT_TRUE(EPDFOutline_SetTitle(doc.get(), kA1, renamed.get())); @@ -544,7 +554,7 @@ TEST_F(EPDFOutlineEmbedderTest, TitleColorAndStyle) { } TEST_F(EPDFOutlineEmbedderTest, SetActionReplacesTheDestination) { - ScopedFPDFDocument doc = OpenPlain(); + embedpdf_test::ScopedTestDocument doc = Open(); ASSERT_TRUE(doc); ASSERT_TRUE(DictOf(doc.get(), kA)->KeyExist("Dest")); FPDF_ACTION action = GoTo(doc.get(), kFirstPage); @@ -557,8 +567,8 @@ TEST_F(EPDFOutlineEmbedderTest, SetActionReplacesTheDestination) { // Another document's action is refused, also when its number names an // object here (the action set above); none removes the target. - ScopedFPDFDocument other( - FPDF_LoadMemDocument(plain_.data(), plain_.size(), nullptr)); + embedpdf_test::ScopedTestDocument other(embedpdf_test::LoadMemDocumentForTest( + plain_.data(), plain_.size(), nullptr)); ASSERT_TRUE(other); FPDF_ACTION foreign = GoTo(other.get(), kFirstPage); ASSERT_TRUE(foreign); @@ -609,7 +619,7 @@ TEST_F(EPDFOutlineEmbedderTest, SetActionLeavesASharedActionAlone) { // A /Next that comes back ends the list; the next write of that list // straightens it. TEST_F(EPDFOutlineEmbedderTest, ALoopEndsTheList) { - ScopedFPDFDocument doc = OpenPlain(MakeDocumentWith({ + embedpdf_test::ScopedTestDocument doc = Open(MakeDocumentWith({ "<< /Type /Outlines /First 5 0 R /Last 6 0 R /Count 2 >>", "<< /Type /Page /Parent 2 0 R /MediaBox [0 0 300 300] >>", "<< /Title (One) /Parent 3 0 R /Next 6 0 R >>", @@ -625,7 +635,7 @@ TEST_F(EPDFOutlineEmbedderTest, ALoopEndsTheList) { // A wrong /Last, /Prev or /Count never misleads a write. A write puts right // the lists it changes and the counts above them, and leaves the rest. TEST_F(EPDFOutlineEmbedderTest, WrongLinksAndCountsAreWrittenRight) { - ScopedFPDFDocument doc = OpenPlain(MakeDocumentWith({ + embedpdf_test::ScopedTestDocument doc = Open(MakeDocumentWith({ "<< /Type /Outlines /First 5 0 R /Last 5 0 R /Count 9 >>", "<< /Type /Page /Parent 2 0 R /MediaBox [0 0 300 300] >>", "<< /Title (One) /Parent 3 0 R /Next 6 0 R /Prev 6 0 R >>", @@ -647,7 +657,7 @@ TEST_F(EPDFOutlineEmbedderTest, WrongLinksAndCountsAreWrittenRight) { // A list holding an item that isn't an indirect object is never written; // what doesn't change the list still works. TEST_F(EPDFOutlineEmbedderTest, ADirectItemKeepsItsListAsItIs) { - ScopedFPDFDocument doc = OpenPlain(MakeDocumentWith({ + embedpdf_test::ScopedTestDocument doc = Open(MakeDocumentWith({ "<< /Type /Outlines /First 5 0 R /Count 2 >>", "<< /Type /Page /Parent 2 0 R /MediaBox [0 0 300 300] >>", "<< /Title (One) /Parent 3 0 R /Next << /Title (Direct) >> >>", @@ -665,7 +675,7 @@ TEST_F(EPDFOutlineEmbedderTest, ADirectItemKeepsItsListAsItIs) { } TEST_F(EPDFOutlineEmbedderTest, ADirectOutlineDictionaryIsNeverWritten) { - ScopedFPDFDocument doc = OpenPlain(MakePdf({ + embedpdf_test::ScopedTestDocument doc = Open(MakePdf({ "<< /Type /Catalog /Pages 2 0 R /Outlines << /Type /Outlines >> >>", "<< /Type /Pages /Kids [3 0 R] /Count 1 >>", "<< /Type /Page /Parent 2 0 R /MediaBox [0 0 300 300] >>", @@ -687,7 +697,7 @@ TEST_F(EPDFOutlineEmbedderTest, ADictionaryThatIsntAnItemEndsTheList) { "<< /Type /Pages /Kids [4 0 R] /Count 1 >>", }) { SCOPED_TRACE(other); - ScopedFPDFDocument doc = OpenPlain(MakeDocumentWith({ + embedpdf_test::ScopedTestDocument doc = Open(MakeDocumentWith({ "<< /Type /Outlines /First 5 0 R /Last 5 0 R /Count 1 >>", "<< /Type /Page /Parent 2 0 R /MediaBox [0 0 300 300] >>", "<< /Title (One) /Parent 3 0 R /Next 6 0 R >>", @@ -713,7 +723,7 @@ TEST_F(EPDFOutlineEmbedderTest, ADictionaryThatIsntAnItemEndsTheList) { // no outline: the readers show none, and a create makes a new outline in // its place without touching what was linked there. TEST_F(EPDFOutlineEmbedderTest, AnOutlinesThatIsntAnOutlineIsNone) { - ScopedFPDFDocument doc = OpenPlain(MakePdf({ + embedpdf_test::ScopedTestDocument doc = Open(MakePdf({ "<< /Type /Catalog /Pages 2 0 R /Outlines 2 0 R >>", "<< /Type /Pages /Kids [3 0 R] /Count 1 >>", "<< /Type /Page /Parent 2 0 R /MediaBox [0 0 300 300] >>", @@ -747,7 +757,7 @@ TEST_F(EPDFOutlineEmbedderTest, SharedListsAreCountedOnce) { } outline.push_back(item + " >>"); } - ScopedFPDFDocument doc = OpenPlain(MakeDocumentWith(outline)); + embedpdf_test::ScopedTestDocument doc = Open(MakeDocumentWith(outline)); ASSERT_TRUE(doc); ASSERT_TRUE(Create(doc.get(), 0, last, L"After")); EXPECT_EQ(static_cast(kItems) + 1, @@ -773,7 +783,7 @@ TEST_F(EPDFOutlineEmbedderTest, ItemsDeeperThanReadsGoAreLeftAlone) { } outline.push_back(item + " >>"); } - ScopedFPDFDocument doc = OpenPlain(MakeDocumentWith(outline)); + embedpdf_test::ScopedTestDocument doc = Open(MakeDocumentWith(outline)); ASSERT_TRUE(doc); ScopedFPDFWideString title = GetFPDFWideString(L"y"); EXPECT_TRUE(EPDFOutline_GetItem(doc.get(), 5 + 127)); diff --git a/fpdfsdk/epdf_page_labels_embeddertest.cpp b/fpdfsdk/epdf_page_labels_embeddertest.cpp index 3722a302ef..7f90db2b69 100644 --- a/fpdfsdk/epdf_page_labels_embeddertest.cpp +++ b/fpdfsdk/epdf_page_labels_embeddertest.cpp @@ -14,6 +14,7 @@ #include "core/fpdfapi/parser/cpdf_reference.h" #include "core/fpdfapi/parser/cpdf_string.h" #include "fpdfsdk/cpdfsdk_helpers.h" +#include "fpdfsdk/epdf_edit_test_util.h" #include "public/cpp/fpdf_scopers.h" #include "public/epdf_doc.h" #include "public/epdf_layer.h" @@ -22,6 +23,7 @@ #include "public/fpdf_edit.h" #include "public/fpdf_save.h" #include "testing/embedder_test.h" +#include "testing/embedpdf_layer_mode.h" #include "testing/fx_string_testhelpers.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/utils/file_util.h" @@ -111,8 +113,8 @@ uint32_t PageLabelsObject(FPDF_DOCUMENT document) { return reference ? reference->GetRefObjNum() : 0; } -ScopedFPDFDocument NewDocument(int page_count) { - ScopedFPDFDocument document(FPDF_CreateNewDocument()); +embedpdf_test::ScopedTestDocument NewDocument(int page_count) { + embedpdf_test::ScopedTestDocument document(NewTestDocument()); for (int i = 0; i < page_count; ++i) { FPDF_ClosePage(FPDFPage_New(document.get(), i, 612, 792)); } @@ -134,13 +136,14 @@ const std::vector kFileLabels = {L"i", L"ii", L"1", L"2", class EPDFPageLabelsEmbedderTest : public EmbedderTest { protected: - ScopedFPDFDocument SaveAndReopen(FPDF_DOCUMENT document) { + embedpdf_test::ScopedTestDocument SaveAndReopen(FPDF_DOCUMENT document) { ClearString(); EXPECT_TRUE(FPDF_SaveAsCopy(document, this, 0)); saved_.push_back(GetString()); const std::string& bytes = saved_.back(); - return ScopedFPDFDocument(FPDF_LoadMemDocument( - bytes.data(), static_cast(bytes.size()), nullptr)); + return embedpdf_test::ScopedTestDocument( + embedpdf_test::LoadMemDocumentForTest(bytes.data(), bytes.size(), + nullptr)); } // page_labels.pdf as a layer over a frozen base. @@ -205,7 +208,7 @@ TEST_F(EPDFPageLabelsEmbedderTest, AFileWithoutPageLabelsHasNoSections) { // the first entry and the entry that isn't a dictionary number by their // place, and an entry past the last page is left out. TEST_F(EPDFPageLabelsEmbedderTest, ReadsATreeAsPageLabelsDo) { - ScopedFPDFDocument document = NewDocument(7); + embedpdf_test::ScopedTestDocument document = NewDocument(7); CPDF_Document* doc = CPDFDocumentFromFPDFDocument(document.get()); auto labels = doc->GetMutableRoot()->SetNewFor("PageLabels"); auto kids = labels->SetNewFor("Kids"); @@ -253,7 +256,7 @@ TEST_F(EPDFPageLabelsEmbedderTest, ReadsATreeAsPageLabelsDo) { } TEST_F(EPDFPageLabelsEmbedderTest, WritesSectionsThatLabelThePages) { - ScopedFPDFDocument document = NewDocument(6); + embedpdf_test::ScopedTestDocument document = NewDocument(6); const std::vector
sections = { {0, EPDF_PAGE_LABEL_STYLE_LOWER_ROMAN, 1, L""}, {2, EPDF_PAGE_LABEL_STYLE_DECIMAL, 1, L""}, @@ -274,7 +277,7 @@ TEST_F(EPDFPageLabelsEmbedderTest, WritesSectionsThatLabelThePages) { EXPECT_FALSE(nums->GetDictAt(1)->KeyExist("P")); EXPECT_EQ(7, nums->GetDictAt(5)->GetIntegerFor("St")); - ScopedFPDFDocument reopened = SaveAndReopen(document.get()); + embedpdf_test::ScopedTestDocument reopened = SaveAndReopen(document.get()); ASSERT_TRUE(reopened); EXPECT_EQ(sections, SectionsOf(reopened.get())); EXPECT_EQ(labels, LabelsOf(reopened.get())); diff --git a/fpdfsdk/epdf_page_residency_embeddertest.cpp b/fpdfsdk/epdf_page_residency_embeddertest.cpp index 6d1342988a..39c40c3a3f 100644 --- a/fpdfsdk/epdf_page_residency_embeddertest.cpp +++ b/fpdfsdk/epdf_page_residency_embeddertest.cpp @@ -26,6 +26,7 @@ #include "public/fpdf_transformpage.h" #include "public/fpdfview.h" #include "testing/embedder_test.h" +#include "testing/embedpdf_layer_mode.h" #include "testing/gtest/include/gtest/gtest.h" namespace { @@ -103,10 +104,12 @@ class EPDFPageResidencyEmbedderTest : public EmbedderTest { return layer; } - ScopedFPDFDocument OpenPlain(std::string pdf) { + // A document of |pdf|, as a test opens one: a layer in layer mode. + embedpdf_test::ScopedTestDocument Open(std::string pdf) { inputs_.push_back(std::move(pdf)); - return ScopedFPDFDocument(FPDF_LoadMemDocument( - inputs_.back().data(), inputs_.back().size(), nullptr)); + return embedpdf_test::ScopedTestDocument( + embedpdf_test::LoadMemDocumentForTest(inputs_.back().data(), + inputs_.back().size(), nullptr)); } // Removes the page's first object and writes the page's content. @@ -124,7 +127,7 @@ class EPDFPageResidencyEmbedderTest : public EmbedderTest { } // namespace TEST_F(EPDFPageResidencyEmbedderTest, CountsEveryObjectNestedFormsIncluded) { - ScopedFPDFDocument doc = OpenPlain(MakeDocument()); + embedpdf_test::ScopedTestDocument doc = Open(MakeDocument()); ScopedFPDFPage page(FPDF_LoadPage(doc.get(), 0)); ASSERT_TRUE(page); @@ -144,7 +147,7 @@ TEST_F(EPDFPageResidencyEmbedderTest, CountsEveryObjectNestedFormsIncluded) { // agree: after an edit the page counts again, and putting back what was taken // gives the parse's count exactly. TEST_F(EPDFPageResidencyEmbedderTest, CountsAgainAfterTheObjectsChange) { - ScopedFPDFDocument doc = OpenPlain(MakeDocument()); + embedpdf_test::ScopedTestDocument doc = Open(MakeDocument()); ScopedFPDFPage page(FPDF_LoadPage(doc.get(), 0)); ASSERT_TRUE(page); const EPDF_PAGE_PARSED_SIZE parsed = SizeOf(page.get()); @@ -170,10 +173,13 @@ TEST_F(EPDFPageResidencyEmbedderTest, CountsAgainAfterTheObjectsChange) { // While a page parses, its size is what the parse has added so far. TEST_F(EPDFPageResidencyEmbedderTest, CountsWhileParsing) { constexpr int kSquares = 250; - ScopedFPDFDocument doc = OpenPlain(MakeManySquares(kSquares)); + embedpdf_test::ScopedTestDocument doc = Open(MakeManySquares(kSquares)); CPDF_Document* document = CPDFDocumentFromFPDFDocument(doc.get()); + // As FPDF_LoadPage() makes a page: the mutable getter would copy the page + // dictionary into a layer, and the page copies it up on its first write. + RetainPtr dict = document->GetPageDictionary(0); auto page = pdfium::MakeRetain( - document, document->GetMutablePageDictionary(0)); + document, pdfium::WrapRetain(const_cast(dict.Get()))); FPDF_PAGE handle = FPDFPageFromIPDFPage(page.Get()); EXPECT_FALSE(SizeOf(handle).complete); @@ -245,7 +251,9 @@ TEST_F(EPDFPageResidencyEmbedderTest, // A page that writes its own content outside a transaction matches what it // wrote; a page loaded before is not told. TEST_F(EPDFPageResidencyEmbedderTest, WritesInPlaceAreNotSeen) { - ScopedFPDFDocument doc = OpenPlain(MakeDocument()); + // Plain in layer mode too: a layer tells the page loaded before. + const std::string pdf = MakeDocument(); + ScopedFPDFDocument doc(FPDF_LoadMemDocument(pdf.data(), pdf.size(), nullptr)); ScopedFPDFPage kept(FPDF_LoadPage(doc.get(), 0)); ScopedFPDFPage writer(FPDF_LoadPage(doc.get(), 0)); RemoveFirstObjectAndGenerate(writer.get()); diff --git a/fpdfsdk/epdf_pieceinfo_embeddertest.cpp b/fpdfsdk/epdf_pieceinfo_embeddertest.cpp index e37f455536..c6c28428c6 100644 --- a/fpdfsdk/epdf_pieceinfo_embeddertest.cpp +++ b/fpdfsdk/epdf_pieceinfo_embeddertest.cpp @@ -7,6 +7,7 @@ #include #include +#include "fpdfsdk/epdf_edit_test_util.h" #include "public/cpp/fpdf_scopers.h" #include "public/epdf_layer.h" #include "public/epdf_save.h" @@ -16,6 +17,7 @@ #include "public/fpdf_save.h" #include "public/fpdfview.h" #include "testing/embedder_test.h" +#include "testing/embedpdf_layer_mode.h" #include "testing/fx_string_testhelpers.h" #include "testing/gtest/include/gtest/gtest.h" @@ -197,7 +199,7 @@ std::string GetPieceInfoEntryAt(FPDF_DOCUMENT document, class EPDFPieceInfoEmbedderTest : public EmbedderTest {}; TEST_F(EPDFPieceInfoEmbedderTest, CatalogTypedValuesSaveReloadAndLayerRead) { - CreateEmptyDocument(); + ASSERT_TRUE(OpenDocumentFromMemory(EmptyPdf())); ScopedFPDFPage page(FPDFPage_New(document(), 0, 240, 100)); ASSERT_TRUE(page); @@ -341,7 +343,7 @@ TEST_F(EPDFPieceInfoEmbedderTest, CatalogTypedValuesSaveReloadAndLayerRead) { } TEST_F(EPDFPieceInfoEmbedderTest, CatalogGranularClearPreservesOtherData) { - CreateEmptyDocument(); + ASSERT_TRUE(OpenDocumentFromMemory(EmptyPdf())); ScopedFPDFPage page(FPDFPage_New(document(), 0, 240, 100)); ASSERT_TRUE(page); @@ -375,7 +377,7 @@ TEST_F(EPDFPieceInfoEmbedderTest, CatalogGranularClearPreservesOtherData) { } TEST_F(EPDFPieceInfoEmbedderTest, TypedValuesSaveReloadAndImport) { - CreateEmptyDocument(); + ASSERT_TRUE(OpenDocumentFromMemory(EmptyPdf())); ScopedFPDFPage page(FPDFPage_New(document(), 0, 240, 100)); ASSERT_TRUE(page); const unsigned int page_object_number = EPDFPage_GetObjectNumber(page.get()); @@ -459,7 +461,7 @@ TEST_F(EPDFPieceInfoEmbedderTest, TypedValuesSaveReloadAndImport) { L"D:20260713093703+03'00'", GetPieceInfoLastModified(document(), page_object_number, "EMBD_Stamp")); - ScopedFPDFDocument imported(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument imported(NewTestDocument()); ASSERT_TRUE(imported); static constexpr int kPageIndices[] = {0}; ASSERT_TRUE(FPDF_ImportPagesByIndex(imported.get(), document(), kPageIndices, @@ -511,7 +513,7 @@ TEST_F(EPDFPieceInfoEmbedderTest, TypedValuesSaveReloadAndImport) { } TEST_F(EPDFPieceInfoEmbedderTest, GranularClearPreservesOtherData) { - CreateEmptyDocument(); + ASSERT_TRUE(OpenDocumentFromMemory(EmptyPdf())); ScopedFPDFPage page(FPDFPage_New(document(), 0, 240, 100)); ASSERT_TRUE(page); const unsigned int page_object_number = EPDFPage_GetObjectNumber(page.get()); diff --git a/fpdfsdk/epdf_ppo_embeddertest.cpp b/fpdfsdk/epdf_ppo_embeddertest.cpp index a5cafe06f3..8d7c594a5c 100644 --- a/fpdfsdk/epdf_ppo_embeddertest.cpp +++ b/fpdfsdk/epdf_ppo_embeddertest.cpp @@ -16,6 +16,7 @@ #include "core/fpdfapi/parser/cpdf_reference.h" #include "core/fpdfapi/parser/cpdf_string.h" #include "fpdfsdk/cpdfsdk_helpers.h" +#include "fpdfsdk/epdf_edit_test_util.h" #include "public/cpp/fpdf_scopers.h" #include "public/epdf_form.h" #include "public/epdf_layer.h" @@ -25,6 +26,7 @@ #include "public/fpdf_save.h" #include "public/fpdfview.h" #include "testing/embedder_test.h" +#include "testing/embedpdf_layer_mode.h" #include "testing/fx_string_testhelpers.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/utils/file_util.h" @@ -146,8 +148,9 @@ void SetSpaceWidth(CPDF_Dictionary* font, int width) { // A new one-page document with a form: a "person" field, |font| as /F1 and a // /DA of its own. -ScopedFPDFDocument NewTargetForm(const ByteString& base_font, int width = 0) { - ScopedFPDFDocument dest(FPDF_CreateNewDocument()); +embedpdf_test::ScopedTestDocument NewTargetForm(const ByteString& base_font, + int width = 0) { + embedpdf_test::ScopedTestDocument dest(NewTestDocument()); FPDF_ClosePage(FPDFPage_New(dest.get(), 0, 300, 300)); CPDF_Document* doc = CPDFDocumentFromFPDFDocument(dest.get()); RetainPtr font = NewFont(doc, base_font); @@ -182,7 +185,7 @@ ByteString CopiedEmailAppearance(FPDF_DOCUMENT document) { class EPDFPpoEmbedderTest : public EmbedderTest { protected: // |document| saved in full and opened again. - ScopedFPDFDocument SaveAndReopen(FPDF_DOCUMENT document) { + embedpdf_test::ScopedTestDocument SaveAndReopen(FPDF_DOCUMENT document) { unsigned long size = 0; void* buffer = EPDF_SaveDocumentToOwnedBuffer(document, FPDF_NO_INCREMENTAL, &size); @@ -191,8 +194,9 @@ class EPDFPpoEmbedderTest : public EmbedderTest { static_cast(buffer) + size); EPDF_FreeBuffer(buffer); const std::string& bytes = saved_.back(); - return ScopedFPDFDocument(FPDF_LoadMemDocument( - bytes.data(), static_cast(bytes.size()), nullptr)); + return embedpdf_test::ScopedTestDocument( + embedpdf_test::LoadMemDocumentForTest(bytes.data(), bytes.size(), + nullptr)); } struct LayerDoc { @@ -251,7 +255,7 @@ TEST_F(EPDFPpoEmbedderTest, NamesTheTopLevelFieldsThePagesBring) { TEST_F(EPDFPpoEmbedderTest, BringsTheFieldsOfEveryPage) { ASSERT_TRUE(OpenDocument("form_page_import.pdf")); - ScopedFPDFDocument dest(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument dest(NewTestDocument()); ASSERT_TRUE( EPDFDoc_ImportPages(dest.get(), document(), nullptr, 0, 0, nullptr)); EXPECT_EQ(2, FPDF_GetPageCount(dest.get())); @@ -279,14 +283,14 @@ TEST_F(EPDFPpoEmbedderTest, BringsTheFieldsOfEveryPage) { EXPECT_FALSE(person->KeyExist("DA")); EXPECT_FALSE(person->KeyExist("Q")); - ScopedFPDFDocument reopened = SaveAndReopen(dest.get()); + embedpdf_test::ScopedTestDocument reopened = SaveAndReopen(dest.get()); ASSERT_TRUE(reopened); EXPECT_EQ(AllPagesFields(), ReadFields(reopened.get())); } TEST_F(EPDFPpoEmbedderTest, BringsOnlyWhatIsAboveThePagesWidgets) { ASSERT_TRUE(OpenDocument("form_page_import.pdf")); - ScopedFPDFDocument dest(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument dest(NewTestDocument()); const int second_page = 1; ASSERT_TRUE( EPDFDoc_ImportPages(dest.get(), document(), &second_page, 1, 0, nullptr)); @@ -304,14 +308,14 @@ TEST_F(EPDFPpoEmbedderTest, BringsOnlyWhatIsAboveThePagesWidgets) { EXPECT_EQ(L"person", person->GetUnicodeTextFor("T")); ASSERT_EQ(1u, person->GetArrayFor("Kids")->size()); - ScopedFPDFDocument reopened = SaveAndReopen(dest.get()); + embedpdf_test::ScopedTestDocument reopened = SaveAndReopen(dest.get()); ASSERT_TRUE(reopened); EXPECT_EQ(expected, ReadFields(reopened.get())); } TEST_F(EPDFPpoEmbedderTest, PointsCopiedParentsAtTheCopies) { ASSERT_TRUE(OpenDocument("form_page_import.pdf")); - ScopedFPDFDocument dest(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument dest(NewTestDocument()); // A page first, so the copies' numbers differ from the source's. FPDF_ClosePage(FPDFPage_New(dest.get(), 0, 300, 300)); const int first_page = 0; @@ -339,7 +343,7 @@ TEST_F(EPDFPpoEmbedderTest, PointsCopiedParentsAtTheCopies) { TEST_F(EPDFPpoEmbedderTest, AddsToAFormAndRenamesAFontItUses) { ASSERT_TRUE(OpenDocument("form_page_import.pdf")); - ScopedFPDFDocument dest = NewTargetForm("Courier"); + embedpdf_test::ScopedTestDocument dest = NewTargetForm("Courier"); // The caller renames the source's "person" first. EXPECT_FALSE(EPDFForm_SetFieldName(document(), kPerson, @@ -378,7 +382,7 @@ TEST_F(EPDFPpoEmbedderTest, AddsToAFormAndRenamesAFontItUses) { EXPECT_EQ(L"email", email->GetUnicodeTextFor("T")); EXPECT_EQ("/F1_1 10 Tf 0 g", email->GetByteStringFor("DA")); - ScopedFPDFDocument reopened = SaveAndReopen(dest.get()); + embedpdf_test::ScopedTestDocument reopened = SaveAndReopen(dest.get()); ASSERT_TRUE(reopened); EXPECT_EQ(expected, ReadFields(reopened.get())); } @@ -394,7 +398,7 @@ TEST_F(EPDFPpoEmbedderTest, CopiesIntoALayerInATransaction) { EXPECT_EQ(3, FPDF_GetPageCount(dest.layer)); EXPECT_EQ(AllPagesFields(), ReadFields(dest.layer)); - ScopedFPDFDocument reopened = SaveAndReopen(dest.layer); + embedpdf_test::ScopedTestDocument reopened = SaveAndReopen(dest.layer); ASSERT_TRUE(reopened); EXPECT_EQ(AllPagesFields(), ReadFields(reopened.get())); } @@ -407,7 +411,7 @@ TEST_F(EPDFPpoEmbedderTest, CopiesOutOfALayerAsTheLayerReadsIt) { GetFPDFWideString(L"applicant").get())); ASSERT_TRUE(EPDFLayer_CommitTransaction(src.layer)); - ScopedFPDFDocument dest(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument dest(NewTestDocument()); const int first_page = 0; ASSERT_TRUE( EPDFDoc_ImportPages(dest.get(), src.layer, &first_page, 1, 0, nullptr)); @@ -416,7 +420,7 @@ TEST_F(EPDFPpoEmbedderTest, CopiesOutOfALayerAsTheLayerReadsIt) { {L"plan", {L"yearly", 1, true}}, }; EXPECT_EQ(expected, ReadFields(dest.get())); - ScopedFPDFDocument reopened = SaveAndReopen(dest.get()); + embedpdf_test::ScopedTestDocument reopened = SaveAndReopen(dest.get()); ASSERT_TRUE(reopened); EXPECT_EQ(expected, ReadFields(reopened.get())); } @@ -441,7 +445,7 @@ TEST_F(EPDFPpoEmbedderTest, CopiesTakeTheChosenNumbers) { EXPECT_EQ(last + 2, PageOfFirstAnnot(dest.layer, 0)); EXPECT_EQ(AllPagesFields(), ReadFields(dest.layer)); - ScopedFPDFDocument reopened = SaveAndReopen(dest.layer); + embedpdf_test::ScopedTestDocument reopened = SaveAndReopen(dest.layer); ASSERT_TRUE(reopened); EXPECT_EQ(last + 2, EPDFDoc_GetPageObjectNumberByIndex(reopened.get(), 0)); EXPECT_EQ(last + 2, PageOfFirstAnnot(reopened.get(), 0)); @@ -479,6 +483,7 @@ TEST_F(EPDFPpoEmbedderTest, RefusesNumbersItCannotTake) { ASSERT_TRUE(EPDFLayer_CommitTransaction(dest.layer)); EXPECT_EQ(last + 1, EPDFDoc_GetPageObjectNumberByIndex(dest.layer, 1)); + // Plain in layer mode too: a plain document takes no chosen numbers. ScopedFPDFDocument plain(FPDF_CreateNewDocument()); const uint32_t chosen[] = {5, 0}; EXPECT_FALSE( @@ -488,7 +493,7 @@ TEST_F(EPDFPpoEmbedderTest, RefusesNumbersItCannotTake) { TEST_F(EPDFPpoEmbedderTest, RefusesBadArguments) { ASSERT_TRUE(OpenDocument("form_page_import.pdf")); - ScopedFPDFDocument dest(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument dest(NewTestDocument()); const int out_of_range[] = {0, 2}; EXPECT_FALSE( EPDFDoc_ImportPages(dest.get(), document(), out_of_range, 2, 0, nullptr)); @@ -511,7 +516,7 @@ TEST_F(EPDFPpoEmbedderTest, RefusesBadArguments) { TEST_F(EPDFPpoEmbedderTest, SharesAFontDefinedTheSameWay) { ASSERT_TRUE(OpenDocument("form_page_import.pdf")); // /F1 is Times-Roman in both, with the same keys. - ScopedFPDFDocument dest = NewTargetForm("Times-Roman"); + embedpdf_test::ScopedTestDocument dest = NewTargetForm("Times-Roman"); ASSERT_TRUE(EPDFForm_SetFieldName(document(), kPerson, GetFPDFWideString(L"person_2").get())); ASSERT_TRUE( @@ -528,7 +533,7 @@ TEST_F(EPDFPpoEmbedderTest, RenamesAFontWithOtherWidths) { // The same Times-Roman, but its widths differ: 900 here, 200 there. CPDF_Document* src = CPDFDocumentFromFPDFDocument(document()); SetSpaceWidth(ToDictionary(src->GetMutableIndirectObject(21)).Get(), 900); - ScopedFPDFDocument dest = NewTargetForm("Times-Roman", 200); + embedpdf_test::ScopedTestDocument dest = NewTargetForm("Times-Roman", 200); ASSERT_TRUE(EPDFForm_SetFieldName(document(), kPerson, GetFPDFWideString(L"person_2").get())); ASSERT_TRUE( @@ -549,7 +554,7 @@ TEST_F(EPDFPpoEmbedderTest, RenamesTheFontOfAnAppearanceWithAComment) { CPDF_Document* src = CPDFDocumentFromFPDFDocument(document()); ToDictionary(src->GetMutableIndirectObject(kEmail)) ->SetNewFor("DA", "/F1 % the field's font\n10 Tf 0 g"); - ScopedFPDFDocument dest = NewTargetForm("Courier"); + embedpdf_test::ScopedTestDocument dest = NewTargetForm("Courier"); ASSERT_TRUE(EPDFForm_SetFieldName(document(), kPerson, GetFPDFWideString(L"person_2").get())); ASSERT_TRUE( diff --git a/fpdfsdk/epdf_redact_embeddertest.cpp b/fpdfsdk/epdf_redact_embeddertest.cpp index 7785c024f1..c01f50ae18 100644 --- a/fpdfsdk/epdf_redact_embeddertest.cpp +++ b/fpdfsdk/epdf_redact_embeddertest.cpp @@ -25,6 +25,7 @@ #include "core/fpdfapi/parser/cpdf_stream_acc.h" #include "core/fxcodec/flate/flatemodule.h" #include "fpdfsdk/cpdfsdk_helpers.h" +#include "fpdfsdk/epdf_edit_test_util.h" #include "public/cpp/fpdf_scopers.h" #include "public/epdf_annot.h" #include "public/epdf_edit.h" @@ -37,6 +38,7 @@ #include "public/fpdf_text.h" #include "testing/document_sentinels.h" #include "testing/embedder_test.h" +#include "testing/embedpdf_layer_mode.h" #include "testing/fx_string_testhelpers.h" #include "testing/gtest/include/gtest/gtest.h" @@ -203,6 +205,7 @@ OpenedPdf OpenPdf(const std::string& input, bool layer) { EPDFLayer_OpenLayer(opened.base.get(), nullptr, nullptr, nullptr)); } } else { + // Plain in layer mode too: the layer is the other case. opened.doc.reset( FPDF_LoadMemDocument64(input.data(), input.size(), nullptr)); } @@ -521,8 +524,9 @@ class EPDFRedactEmbedderTest : public EmbedderTest { return -1; } const std::string bytes = GetString(); - ScopedFPDFDocument saved( - FPDF_LoadMemDocument(bytes.data(), bytes.size(), nullptr)); + embedpdf_test::ScopedTestDocument saved( + embedpdf_test::LoadMemDocumentForTest(bytes.data(), bytes.size(), + nullptr)); if (!saved) { ADD_FAILURE() << "the rewrite does not open"; return -1; @@ -747,6 +751,7 @@ class EPDFRedactPageTreeTest EPDFLayer_OpenLayer(base_.get(), nullptr, nullptr, &status)); EXPECT_EQ(EPDFLayerOpenStatus_kSuccess, status); } else { + // Plain in layer mode too: the layer is the other case. working_.reset( FPDF_LoadMemDocument64(input_.data(), input_.size(), nullptr)); } @@ -851,10 +856,11 @@ INSTANTIATE_TEST_SUITE_P(All, TEST_F(EPDFRedactEmbedderTest, RedactingAFlattenedStampLeavesAStampSharingItsDrawingAlone) { const std::string drawing_pdf = MakeTextDrawing({"SENTINELSHARED", "KEEP"}); - ScopedFPDFDocument source( - FPDF_LoadMemDocument(drawing_pdf.data(), drawing_pdf.size(), nullptr)); + embedpdf_test::ScopedTestDocument source( + embedpdf_test::LoadMemDocumentForTest(drawing_pdf.data(), + drawing_pdf.size(), nullptr)); ASSERT_TRUE(source); - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 600, 600)); ScopedFPDFAnnotation redacted = AddStamp(page.get(), source.get(), FS_RECTF{50, 590, 350, 500}); @@ -912,10 +918,11 @@ TEST_F(EPDFRedactEmbedderTest, RedactingTheOnlyStampLeavesNothingOfItsDrawing) { for (bool flatten : {false, true}) { SCOPED_TRACE(flatten ? "flattened" : "live"); const std::string drawing_pdf = MakeTextDrawing({"SENTINELONLY"}); - ScopedFPDFDocument source( - FPDF_LoadMemDocument(drawing_pdf.data(), drawing_pdf.size(), nullptr)); + embedpdf_test::ScopedTestDocument source( + embedpdf_test::LoadMemDocumentForTest(drawing_pdf.data(), + drawing_pdf.size(), nullptr)); ASSERT_TRUE(source); - ScopedFPDFDocument doc(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument doc(NewTestDocument()); ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 600, 600)); ScopedFPDFAnnotation stamp = AddStamp(page.get(), source.get(), FS_RECTF{50, 550, 350, 500}); @@ -968,6 +975,7 @@ TEST_F(EPDFRedactEmbedderTest, AppliesOnAPageWithoutContentsOrResources) { ASSERT_TRUE(base); doc.reset(EPDFLayer_OpenLayer(base.get(), nullptr, nullptr, nullptr)); } else { + // Plain in layer mode too: the layer is the other case. doc.reset(FPDF_LoadMemDocument64(input.data(), input.size(), nullptr)); } ASSERT_TRUE(doc); @@ -1454,8 +1462,9 @@ TEST_F(EPDFRedactEmbedderTest, ARedactedImageKeepsItsSamplesAndFormat) { image.entries, image.data), "1 0 0 rg"); - ScopedFPDFDocument source_doc( - FPDF_LoadMemDocument64(input.data(), input.size(), nullptr)); + embedpdf_test::ScopedTestDocument source_doc( + embedpdf_test::LoadMemDocumentForTest(input.data(), input.size(), + nullptr)); ASSERT_TRUE(source_doc); RetainPtr source_image = OnlyImage(source_doc.get()); ASSERT_TRUE(source_image); diff --git a/fpdfsdk/epdf_richtextlayout_embeddertest.cpp b/fpdfsdk/epdf_richtextlayout_embeddertest.cpp index 47e6b98463..5ca239e12f 100644 --- a/fpdfsdk/epdf_richtextlayout_embeddertest.cpp +++ b/fpdfsdk/epdf_richtextlayout_embeddertest.cpp @@ -20,10 +20,12 @@ #include "core/fxcrt/fx_coordinates.h" #include "core/fxcrt/widestring.h" #include "fpdfsdk/cpdfsdk_helpers.h" +#include "fpdfsdk/epdf_edit_test_util.h" #include "public/cpp/fpdf_scopers.h" #include "public/epdf_font.h" #include "public/fpdf_edit.h" #include "testing/embedder_test.h" +#include "testing/embedpdf_layer_mode.h" #include "testing/fx_string_testhelpers.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/utils/file_util.h" @@ -61,7 +63,7 @@ class EPDFRichTextLayoutEmbedderTest : public EmbedderTest { EPDFFont_ClearRegisteredFonts(); arimo_ = Register("Arimo", TestFont("Arimo-Regular.ttf")); ASSERT_NE(0u, arimo_); - doc_.reset(FPDF_CreateNewDocument()); + doc_ = NewTestDocument(); ASSERT_TRUE(doc_); } @@ -128,7 +130,7 @@ class EPDFRichTextLayoutEmbedderTest : public EmbedderTest { } EPDF_FONT_ID arimo_ = 0; - ScopedFPDFDocument doc_; + embedpdf_test::ScopedTestDocument doc_; // The fonts of the last Arrange(). std::unique_ptr fonts_; }; diff --git a/fpdfsdk/epdf_save_embeddertest.cpp b/fpdfsdk/epdf_save_embeddertest.cpp index 224563eeb0..aba5a4ba14 100644 --- a/fpdfsdk/epdf_save_embeddertest.cpp +++ b/fpdfsdk/epdf_save_embeddertest.cpp @@ -52,6 +52,7 @@ #include "public/fpdf_save.h" #include "public/fpdfview.h" #include "testing/embedder_test.h" +#include "testing/embedpdf_layer_mode.h" #include "testing/fx_string_testhelpers.h" #include "testing/gmock/include/gmock/gmock-matchers.h" #include "testing/utils/file_util.h" @@ -302,8 +303,8 @@ SavedPdfModel AnalyzeSavedPdf(const std::string& bytes, const char* password = nullptr, size_t original_size = 0) { SavedPdfModel model; - ScopedFPDFDocument saved( - FPDF_LoadMemDocument(bytes.data(), bytes.size(), password)); + embedpdf_test::ScopedTestDocument saved(embedpdf_test::LoadMemDocumentForTest( + bytes.data(), bytes.size(), password)); EXPECT_TRUE(saved); if (!saved) { return model; @@ -382,6 +383,7 @@ TEST_F(EPDFSaveEmbedderTest, FullRewriteWritesOnlyReachableObjects) { source.reset(EPDFLayer_OpenLayer(base, nullptr, nullptr, nullptr)); EPDF_ReleaseBaseDocument(base); } else { + // Plain in layer mode too: the layer is the other case. source.reset(FPDF_LoadMemDocument(input.data(), input.size(), nullptr)); } ASSERT_TRUE(source); @@ -590,8 +592,9 @@ TEST_F(EPDFSaveEmbedderTest, DetachedObjectDoesNotInflateWarmSaveReads) { TEST_F(EPDFSaveEmbedderTest, IncrementalRevisionWritesExactlyChangedObjects) { for (bool xref_stream : {false, true}) { const std::string input = MakeGenerationDocument(256, xref_stream); - ScopedFPDFDocument source( - FPDF_LoadMemDocument(input.data(), input.size(), nullptr)); + embedpdf_test::ScopedTestDocument source( + embedpdf_test::LoadMemDocumentForTest(input.data(), input.size(), + nullptr)); ASSERT_TRUE(source); auto* doc = CPDFDocumentFromFPDFDocument(source.get()); auto page = doc->GetMutablePageDictionary(0); @@ -678,8 +681,9 @@ TEST_F(EPDFSaveEmbedderTest, SavePreservesConsistentObjectGenerations) { << generation << ":" << xref_stream << ":" << flags); const std::string input = MakeGenerationDocument(generation, xref_stream); - ScopedFPDFDocument source( - FPDF_LoadMemDocument(input.data(), input.size(), nullptr)); + embedpdf_test::ScopedTestDocument source( + embedpdf_test::LoadMemDocumentForTest(input.data(), input.size(), + nullptr)); ASSERT_TRUE(source); auto* doc = CPDFDocumentFromFPDFDocument(source.get()); ASSERT_FALSE(doc->GetParser()->xref_table_rebuilt()); @@ -709,8 +713,9 @@ TEST_F(EPDFSaveEmbedderTest, SavePreservesConsistentObjectGenerations) { revision, HasSubstr("3 " + std::to_string(saved_generation) + " obj")); - ScopedFPDFDocument saved(FPDF_LoadMemDocument( - GetString().data(), GetString().size(), nullptr)); + embedpdf_test::ScopedTestDocument saved( + embedpdf_test::LoadMemDocumentForTest(GetString().data(), + GetString().size(), nullptr)); ASSERT_TRUE(saved); auto* saved_doc = CPDFDocumentFromFPDFDocument(saved.get()); auto* parser = saved_doc->GetParser(); @@ -774,8 +779,9 @@ TEST_F(EPDFSaveEmbedderTest, IncrementalSavePreservesDeclaredXrefSize) { const auto size_position = input.find("/Size 6"); ASSERT_NE(std::string::npos, size_position); input.replace(size_position, 7, "/Size 20"); - ScopedFPDFDocument source( - FPDF_LoadMemDocument(input.data(), input.size(), nullptr)); + embedpdf_test::ScopedTestDocument source( + embedpdf_test::LoadMemDocumentForTest(input.data(), input.size(), + nullptr)); ASSERT_TRUE(source); auto* doc = CPDFDocumentFromFPDFDocument(source.get()); ASSERT_FALSE(doc->GetParser()->xref_table_rebuilt()); @@ -802,8 +808,9 @@ TEST_F(EPDFSaveEmbedderTest, for (unsigned long flags : {FPDF_INCREMENTAL, FPDF_NO_INCREMENTAL}) { SCOPED_TRACE(testing::Message() << filename << ":" << xref_stream << ":" << flags); - ScopedFPDFDocument source( - FPDF_LoadMemDocument(input.data(), input.size(), password)); + embedpdf_test::ScopedTestDocument source( + embedpdf_test::LoadMemDocumentForTest(input.data(), input.size(), + password)); ASSERT_TRUE(source); auto* doc = CPDFDocumentFromFPDFDocument(source.get()); ASSERT_EQ("original", doc->GetInfo()->GetByteStringFor("Title")); @@ -822,8 +829,9 @@ TEST_F(EPDFSaveEmbedderTest, EXPECT_EQ(model.reachable, model.in_use); EXPECT_EQ(1u, model.encryption_dictionaries); } - ScopedFPDFDocument saved(FPDF_LoadMemDocument( - GetString().data(), GetString().size(), password)); + embedpdf_test::ScopedTestDocument saved( + embedpdf_test::LoadMemDocumentForTest( + GetString().data(), GetString().size(), password)); ASSERT_TRUE(saved); auto* saved_doc = CPDFDocumentFromFPDFDocument(saved.get()); EXPECT_FALSE(saved_doc->GetParser()->xref_table_rebuilt()); @@ -874,8 +882,9 @@ TEST_F(EPDFSaveEmbedderTest, IncrementalSavePreservesSharedBaseAndSibling) { EXPECT_THAT(GetString(), HasSubstr("3 256 obj")); EXPECT_THAT(GetString(), HasSubstr("/Root 1 256 R")); const std::string combined = input + GetString(); - ScopedFPDFDocument saved( - FPDF_LoadMemDocument(combined.data(), combined.size(), nullptr)); + embedpdf_test::ScopedTestDocument saved( + embedpdf_test::LoadMemDocumentForTest(combined.data(), combined.size(), + nullptr)); ASSERT_TRUE(saved); auto* saved_doc = CPDFDocumentFromFPDFDocument(saved.get()); EXPECT_FALSE(saved_doc->GetParser()->xref_table_rebuilt()); @@ -918,8 +927,8 @@ TEST_F(EPDFSaveEmbedderTest, LayerSavePreservesReferenceGenerationChanges) { EXPECT_THAT(GetString(), HasSubstr("3 257 obj")); EXPECT_THAT(GetString(), HasSubstr(" 3 257 R ")); const std::string combined = input + GetString(); - ScopedFPDFDocument saved( - FPDF_LoadMemDocument(combined.data(), combined.size(), nullptr)); + embedpdf_test::ScopedTestDocument saved(embedpdf_test::LoadMemDocumentForTest( + combined.data(), combined.size(), nullptr)); ASSERT_TRUE(saved); auto* saved_doc = CPDFDocumentFromFPDFDocument(saved.get()); EXPECT_FALSE(saved_doc->GetParser()->xref_table_rebuilt()); @@ -1246,14 +1255,16 @@ TEST_F(EPDFSaveEmbedderTest, EncryptedSavesShareNoKeyOrSalts) { save = GetString(); } - ScopedFPDFDocument saved[2]; + embedpdf_test::ScopedTestDocument saved[2]; for (size_t i = 0; i < 2; ++i) { SCOPED_TRACE(i); const std::string& save = saves[i]; // The owner password opens the file too. - EXPECT_TRUE(ScopedFPDFDocument( - FPDF_LoadMemDocument(save.data(), save.size(), "owner"))); - saved[i].reset(FPDF_LoadMemDocument(save.data(), save.size(), "user")); + EXPECT_TRUE( + embedpdf_test::ScopedTestDocument(embedpdf_test::LoadMemDocumentForTest( + save.data(), save.size(), "owner"))); + saved[i].reset(embedpdf_test::LoadMemDocumentForTest(save.data(), + save.size(), "user")); ASSERT_TRUE(saved[i]); // Streams decrypt with the file's key and its IVs: the page's content // reads back. diff --git a/fpdfsdk/epdf_signature_embeddertest.cpp b/fpdfsdk/epdf_signature_embeddertest.cpp index b9fa9f0b42..34f9e412f9 100644 --- a/fpdfsdk/epdf_signature_embeddertest.cpp +++ b/fpdfsdk/epdf_signature_embeddertest.cpp @@ -30,6 +30,7 @@ #include "public/fpdfview.h" #include "testing/embedder_test.h" #include "testing/embedpdf_form_writes.h" +#include "testing/embedpdf_layer_mode.h" #include "testing/fx_string_testhelpers.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/utils/file_util.h" @@ -792,7 +793,9 @@ TEST_F(EPDFSignatureEmbedderTest, SignRoundTrip) { EXPECT_EQ(0u, EPDFSig_Prepare(document(), field, &opts)); // The sealed bytes are a complete, signed, two-revision document. - ScopedFPDFDocument signed_doc(FPDF_LoadMemDocument64(sealed.bytes.data(), sealed.bytes.size(), nullptr)); + embedpdf_test::ScopedTestDocument signed_doc( + embedpdf_test::LoadMemDocumentForTest(sealed.bytes.data(), + sealed.bytes.size(), nullptr)); ASSERT_TRUE(signed_doc); EXPECT_EQ(2, EPDFDoc_GetRevisionCount(signed_doc.get())); EPDF_SIGNATURE_MODEL model = EPDFSig_LoadModel(signed_doc.get()); @@ -880,7 +883,9 @@ TEST_F(EPDFSignatureEmbedderTest, CertifyThenRefuseSecondCertification) { Sealed sealed; ASSERT_TRUE(SignField(document(), first, opts, &sealed)); - ScopedFPDFDocument signed_doc(FPDF_LoadMemDocument64(sealed.bytes.data(), sealed.bytes.size(), nullptr)); + embedpdf_test::ScopedTestDocument signed_doc( + embedpdf_test::LoadMemDocumentForTest(sealed.bytes.data(), + sealed.bytes.size(), nullptr)); ASSERT_TRUE(signed_doc); EPDF_SIGNATURE_MODEL model = EPDFSig_LoadModel(signed_doc.get()); ASSERT_TRUE(model); @@ -918,7 +923,9 @@ TEST_F(EPDFSignatureEmbedderTest, PermissionOneAllowsOnlyTimestamps) { opts.docmdp_permission = 1; Sealed sealed; ASSERT_TRUE(SignField(document(), first, opts, &sealed)); - ScopedFPDFDocument signed_doc(FPDF_LoadMemDocument64(sealed.bytes.data(), sealed.bytes.size(), nullptr)); + embedpdf_test::ScopedTestDocument signed_doc( + embedpdf_test::LoadMemDocumentForTest(sealed.bytes.data(), + sealed.bytes.size(), nullptr)); ASSERT_TRUE(signed_doc); EPDF_SIG_PREPARE approval = opts; @@ -942,7 +949,9 @@ TEST_F(EPDFSignatureEmbedderTest, PermissionOneAllowsOnlyTimestamps) { stamped.range, &stamped.contents_offset, &stamped.contents_hex_len, digest, &len)); ASSERT_TRUE(EPDFSig_WriteContents(stamped.bytes.data(), size, stamped.contents_offset, stamped.contents_hex_len, kFakeCms, sizeof(kFakeCms))); - ScopedFPDFDocument stamped_doc(FPDF_LoadMemDocument64(stamped.bytes.data(), stamped.bytes.size(), nullptr)); + embedpdf_test::ScopedTestDocument stamped_doc( + embedpdf_test::LoadMemDocumentForTest(stamped.bytes.data(), + stamped.bytes.size(), nullptr)); ASSERT_TRUE(stamped_doc); EXPECT_EQ(3, EPDFDoc_GetRevisionCount(stamped_doc.get())); EPDF_SIGNATURE_MODEL model = EPDFSig_LoadModel(stamped_doc.get()); @@ -1002,7 +1011,9 @@ TEST_F(EPDFSignatureEmbedderTest, SealRejectsDecoysAndBadDer) { huge[3] = 0x28; // 296 content bytes: 300 total, 600 hex > 512 EXPECT_FALSE(EPDFSig_WriteContents(bytes.data(), size, contents_offset, hex_len, huge.data(), huge.size())); ASSERT_TRUE(EPDFSig_WriteContents(bytes.data(), size, contents_offset, hex_len, kFakeCms, sizeof(kFakeCms))); - ScopedFPDFDocument signed_doc(FPDF_LoadMemDocument64(bytes.data(), bytes.size(), nullptr)); + embedpdf_test::ScopedTestDocument signed_doc( + embedpdf_test::LoadMemDocumentForTest(bytes.data(), bytes.size(), + nullptr)); ASSERT_TRUE(signed_doc); EPDF_SIGNATURE_MODEL model = EPDFSig_LoadModel(signed_doc.get()); EXPECT_EQ(EPDF_SIG_COVERAGE_WHOLE_REVISION, EPDFSig_GetCoverage(model, 0)); @@ -1028,7 +1039,9 @@ TEST_F(EPDFSignatureEmbedderTest, SignEncryptedDocument) { ASSERT_TRUE(SignField(document(), field, opts, &sealed)); // Encrypted with the empty user password: reopens without one, /Contents // was written in the clear, and the digest covers the encrypted bytes. - ScopedFPDFDocument signed_doc(FPDF_LoadMemDocument64(sealed.bytes.data(), sealed.bytes.size(), nullptr)); + embedpdf_test::ScopedTestDocument signed_doc( + embedpdf_test::LoadMemDocumentForTest(sealed.bytes.data(), + sealed.bytes.size(), nullptr)); ASSERT_TRUE(signed_doc); EXPECT_EQ(5, EPDFDoc_GetRevisionCount(signed_doc.get())); EPDF_SIGNATURE_MODEL model = EPDFSig_LoadModel(signed_doc.get()); @@ -1101,8 +1114,11 @@ std::vector BasicObjects(const std::string& catalog_extra = "") { "<>"}; } -ScopedFPDFDocument OpenRaw(const RawPdf& p) { - return ScopedFPDFDocument(FPDF_LoadMemDocument64(p.bytes.data(), p.bytes.size(), nullptr)); +// |p| as a test opens it: a layer in layer mode. +embedpdf_test::ScopedTestDocument OpenRaw(const RawPdf& p) { + return embedpdf_test::ScopedTestDocument( + embedpdf_test::LoadMemDocumentForTest(p.bytes.data(), p.bytes.size(), + nullptr)); } // A form with a group field carrying an inherited Multiline flag, a text @@ -1197,7 +1213,7 @@ TEST_F(EPDFSignatureEmbedderTest, DiffReadStatusSeparatesFailureFromNull) { snprintf(fixed, sizeof(fixed), "%010zu", offset + 2); broken.bytes.replace(row, 10, fixed); } - ScopedFPDFDocument dnew = OpenRaw(broken); + embedpdf_test::ScopedTestDocument dnew = OpenRaw(broken); ASSERT_TRUE(dnew); ScopedFPDFDocument dold(EPDFDoc_OpenRevision(dnew.get(), old.bytes.size())); ASSERT_TRUE(dold); @@ -1211,7 +1227,7 @@ TEST_F(EPDFSignatureEmbedderTest, DiffReadStatusSeparatesFailureFromNull) { // An added object: absent on the old side, readable on the new. RawPdf added = AppendRawUpdate(old, 5, "<>", 6); - ScopedFPDFDocument dadded = OpenRaw(added); + embedpdf_test::ScopedTestDocument dadded = OpenRaw(added); ASSERT_TRUE(dadded); ScopedFPDFDocument dbase(EPDFDoc_OpenRevision(dadded.get(), old.bytes.size())); ASSERT_TRUE(dbase); @@ -1237,7 +1253,7 @@ TEST_F(EPDFSignatureEmbedderTest, DiffStreamSignatureIsChunkedAndShared) { std::string changed = data; changed.back() = 'b'; RawPdf touched = AppendRawUpdate(old, 4, stream_body(changed), 5); - ScopedFPDFDocument dnew = OpenRaw(touched); + embedpdf_test::ScopedTestDocument dnew = OpenRaw(touched); ASSERT_TRUE(dnew); ScopedFPDFDocument dold(EPDFDoc_OpenRevision(dnew.get(), old.bytes.size())); ASSERT_TRUE(dold); @@ -1255,7 +1271,7 @@ TEST_F(EPDFSignatureEmbedderTest, DiffStreamSignatureIsChunkedAndShared) { EPDFObjectDiff_Close(diff); RawPdf same = AppendRawUpdate(old, 4, stream_body(data), 5); - ScopedFPDFDocument dsame = OpenRaw(same); + embedpdf_test::ScopedTestDocument dsame = OpenRaw(same); ASSERT_TRUE(dsame); ScopedFPDFDocument dbase(EPDFDoc_OpenRevision(dsame.get(), old.bytes.size())); ASSERT_TRUE(dbase); @@ -1274,7 +1290,7 @@ TEST_F(EPDFSignatureEmbedderTest, DiffRevisionHealthSparseTableAndBareReference) { RawPdf old = MakeRawPdf(BasicObjects()); RawPdf newer = AppendRawUpdate(old, 4, "<>", 5); - ScopedFPDFDocument dnew = OpenRaw(newer); + embedpdf_test::ScopedTestDocument dnew = OpenRaw(newer); ASSERT_TRUE(dnew); ScopedFPDFDocument dold(EPDFDoc_OpenRevision(dnew.get(), old.bytes.size())); ASSERT_TRUE(dold); @@ -1295,7 +1311,7 @@ TEST_F(EPDFSignatureEmbedderTest, DiffRevisionHealthSparseTableAndBareReference) { RawPdf old = MakeRawPdf(BasicObjects()); RawPdf newer = AppendRawUpdate(old, 6, "<>", 7); - ScopedFPDFDocument dnew = OpenRaw(newer); + embedpdf_test::ScopedTestDocument dnew = OpenRaw(newer); ASSERT_TRUE(dnew); ScopedFPDFDocument dold(EPDFDoc_OpenRevision(dnew.get(), old.bytes.size())); ASSERT_TRUE(dold); @@ -1309,7 +1325,7 @@ TEST_F(EPDFSignatureEmbedderTest, DiffRevisionHealthSparseTableAndBareReference) { RawPdf old = MakeRawPdf(BasicObjects()); RawPdf newer = AppendRawUpdate(old, 4, "<>", 9); - ScopedFPDFDocument dnew = OpenRaw(newer); + embedpdf_test::ScopedTestDocument dnew = OpenRaw(newer); ASSERT_TRUE(dnew); ScopedFPDFDocument dold(EPDFDoc_OpenRevision(dnew.get(), old.bytes.size())); ASSERT_TRUE(dold); @@ -1329,7 +1345,7 @@ TEST_F(EPDFSignatureEmbedderTest, DiffRevisionHealthSparseTableAndBareReference) objects.push_back("<>"); RawPdf old = MakeSparseRawPdf(numbers, objects, 8); RawPdf newer = AppendRawUpdate(old, 8, "<>", 9); - ScopedFPDFDocument dnew = OpenRaw(newer); + embedpdf_test::ScopedTestDocument dnew = OpenRaw(newer); ASSERT_TRUE(dnew); ScopedFPDFDocument dold(EPDFDoc_OpenRevision(dnew.get(), old.bytes.size())); ASSERT_TRUE(dold); @@ -1350,7 +1366,7 @@ TEST_F(EPDFSignatureEmbedderTest, DiffRevisionHealthSparseTableAndBareReference) objects.push_back("<>"); RawPdf old = MakeSparseRawPdf(numbers, objects, 6); RawPdf newer = AppendRawUpdate(old, 6, "<>", 7); - ScopedFPDFDocument dnew = OpenRaw(newer); + embedpdf_test::ScopedTestDocument dnew = OpenRaw(newer); ASSERT_TRUE(dnew); ScopedFPDFDocument dold(EPDFDoc_OpenRevision(dnew.get(), old.bytes.size())); ASSERT_TRUE(dold); @@ -1372,10 +1388,10 @@ TEST_F(EPDFSignatureEmbedderTest, BareEofAtEndOfFileClosesTheRevision) { p->bytes.pop_back(); ASSERT_EQ("%%EOF", p->bytes.substr(p->bytes.size() - 5)); } - ScopedFPDFDocument d1 = OpenRaw(one); + embedpdf_test::ScopedTestDocument d1 = OpenRaw(one); ASSERT_TRUE(d1); EXPECT_EQ(1, EPDFDoc_GetRevisionCount(d1.get())); - ScopedFPDFDocument d2 = OpenRaw(two); + embedpdf_test::ScopedTestDocument d2 = OpenRaw(two); ASSERT_TRUE(d2); EXPECT_EQ(2, EPDFDoc_GetRevisionCount(d2.get())); unsigned long long end = 0; @@ -1390,8 +1406,8 @@ TEST_F(EPDFSignatureEmbedderTest, ProbeUnrelatedFilesDoNotShareHistory) { // Same layout, same offsets, different bytes: not a revision pair. RawPdf a = MakeRawPdf(BasicObjects("/Tag(A)")); RawPdf b = MakeRawPdf(BasicObjects("/Tag(B)")); - ScopedFPDFDocument da = OpenRaw(a); - ScopedFPDFDocument db = OpenRaw(b); + embedpdf_test::ScopedTestDocument da = OpenRaw(a); + embedpdf_test::ScopedTestDocument db = OpenRaw(b); ASSERT_TRUE(da); ASSERT_TRUE(db); EXPECT_FALSE(EPDFDoc_CompareRevisions(da.get(), db.get())); @@ -1402,7 +1418,7 @@ TEST_F(EPDFSignatureEmbedderTest, ProbeDictionaryEvidenceDoesNotCollide) { b.push_back("<>"); RawPdf old = MakeRawPdf(b); RawPdf newer = AppendRawUpdate(old, 4, "<>", 5); - ScopedFPDFDocument dnew = OpenRaw(newer); + embedpdf_test::ScopedTestDocument dnew = OpenRaw(newer); ASSERT_TRUE(dnew); ScopedFPDFDocument dold(EPDFDoc_OpenRevision(dnew.get(), old.bytes.size())); ASSERT_TRUE(dold); @@ -1425,7 +1441,7 @@ TEST_F(EPDFSignatureEmbedderTest, ProbeReferrerLabelsEscapeKeys) { b.push_back("<>"); RawPdf old = MakeRawPdf(b); RawPdf newer = AppendRawUpdate(old, 4, "<>", 6); - ScopedFPDFDocument dnew = OpenRaw(newer); + embedpdf_test::ScopedTestDocument dnew = OpenRaw(newer); ASSERT_TRUE(dnew); ScopedFPDFDocument dold(EPDFDoc_OpenRevision(dnew.get(), old.bytes.size())); ASSERT_TRUE(dold); @@ -1450,7 +1466,7 @@ TEST_F(EPDFSignatureEmbedderTest, ProbeCoverageRequiresPhysicalContents) { snprintf(range, sizeof(range), "%010u %010zu %010zu %010zu", 0u, decoy, decoy + 18, p.bytes.size() - decoy - 18); p.bytes.replace(p.bytes.find(placeholder), placeholder.size(), range); - ScopedFPDFDocument doc = OpenRaw(p); + embedpdf_test::ScopedTestDocument doc = OpenRaw(p); ASSERT_TRUE(doc); EPDF_SIGNATURE_MODEL m = EPDFSig_LoadModel(doc.get()); ASSERT_TRUE(m); @@ -1466,7 +1482,7 @@ TEST_F(EPDFSignatureEmbedderTest, ProbeCoverageRequiresPhysicalContents) { snprintf(range, sizeof(range), "%010u %010zu %010zu %010zu", 0u, real, real + 18, q.bytes.size() - real - 18); q.bytes.replace(q.bytes.find(placeholder), placeholder.size(), range); - ScopedFPDFDocument doc2 = OpenRaw(q); + embedpdf_test::ScopedTestDocument doc2 = OpenRaw(q); ASSERT_TRUE(doc2); m = EPDFSig_LoadModel(doc2.get()); EXPECT_EQ(EPDF_SIG_COVERAGE_WHOLE_REVISION, EPDFSig_GetCoverage(m, 0)); @@ -1476,7 +1492,7 @@ TEST_F(EPDFSignatureEmbedderTest, ProbeCoverageRequiresPhysicalContents) { TEST_F(EPDFSignatureEmbedderTest, ProbeContactInfoCannotBecomePlaceholder) { RawPdf p = FormObjects(); - ScopedFPDFDocument doc = OpenRaw(p); + embedpdf_test::ScopedTestDocument doc = OpenRaw(p); ASSERT_TRUE(doc); EPDF_SIG_PREPARE o = DefaultPrepare(); // Sorts before /Contents and reads exactly like the placeholder. @@ -1502,7 +1518,7 @@ TEST_F(EPDFSignatureEmbedderTest, ProbeContactInfoCannotBecomePlaceholder) { TEST_F(EPDFSignatureEmbedderTest, ProbeLockPreservesInheritedFlags) { RawPdf p = FormObjects(); - ScopedFPDFDocument doc = OpenRaw(p); + embedpdf_test::ScopedTestDocument doc = OpenRaw(p); ASSERT_TRUE(doc); EPDF_SIG_PREPARE o = DefaultPrepare(); ScopedFPDFWideString name = GetFPDFWideString(L"group.total"); @@ -1516,7 +1532,7 @@ TEST_F(EPDFSignatureEmbedderTest, ProbeLockPreservesInheritedFlags) { TEST_F(EPDFSignatureEmbedderTest, ProbeLockParentCoversChildren) { RawPdf p = FormObjects(); - ScopedFPDFDocument doc = OpenRaw(p); + embedpdf_test::ScopedTestDocument doc = OpenRaw(p); ASSERT_TRUE(doc); EPDF_SIG_PREPARE o = DefaultPrepare(); ScopedFPDFWideString name = GetFPDFWideString(L"group"); @@ -1529,7 +1545,7 @@ TEST_F(EPDFSignatureEmbedderTest, ProbeLockParentCoversChildren) { EXPECT_FALSE(EPDFSig_Prepare(doc.get(), 6, &o)); // already prepared // Bad counts are refused, not converted. RawPdf p2 = FormObjects(); - ScopedFPDFDocument doc2 = OpenRaw(p2); + embedpdf_test::ScopedTestDocument doc2 = OpenRaw(p2); o.fieldmdp_field_count = -1; EXPECT_EQ(0u, EPDFSig_Prepare(doc2.get(), 6, &o)); EXPECT_FALSE(EPDFSig_SetFieldLock(doc2.get(), 6, EPDF_SIG_FIELD_ACTION_INCLUDE, names, -1, 0)); @@ -1537,7 +1553,7 @@ TEST_F(EPDFSignatureEmbedderTest, ProbeLockParentCoversChildren) { TEST_F(EPDFSignatureEmbedderTest, ProbeExistingLockBecomesFieldMdp) { RawPdf p = FormObjects("/Lock<>"); - ScopedFPDFDocument doc = OpenRaw(p); + embedpdf_test::ScopedTestDocument doc = OpenRaw(p); ASSERT_TRUE(doc); // A request that contradicts the field's lock is refused ... EPDF_SIG_PREPARE conflicting = DefaultPrepare(); @@ -1568,7 +1584,7 @@ TEST_F(EPDFSignatureEmbedderTest, ProbeNestedBerContentsLength) { // 30 80 { 30 80 { 02 01 01 } 00 00 } 00 00, then zero padding. b.push_back("<>>"); RawPdf p = MakeRawPdf(b); - ScopedFPDFDocument doc = OpenRaw(p); + embedpdf_test::ScopedTestDocument doc = OpenRaw(p); ASSERT_TRUE(doc); EPDF_SIGNATURE_MODEL m = EPDFSig_LoadModel(doc.get()); ASSERT_TRUE(m); @@ -1577,7 +1593,7 @@ TEST_F(EPDFSignatureEmbedderTest, ProbeNestedBerContentsLength) { // A BER object that never closes is malformed. b.back() = "<>>"; RawPdf q = MakeRawPdf(b); - ScopedFPDFDocument doc2 = OpenRaw(q); + embedpdf_test::ScopedTestDocument doc2 = OpenRaw(q); ASSERT_TRUE(doc2); m = EPDFSig_LoadModel(doc2.get()); EXPECT_EQ(0u, EPDFSig_GetContents(m, 0, nullptr, 0)); @@ -1587,7 +1603,7 @@ TEST_F(EPDFSignatureEmbedderTest, ProbeNestedBerContentsLength) { TEST_F(EPDFSignatureEmbedderTest, ProbeMdpStructuresAreDirect) { RawPdf p = FormObjects(); - ScopedFPDFDocument doc = OpenRaw(p); + embedpdf_test::ScopedTestDocument doc = OpenRaw(p); ASSERT_TRUE(doc); EPDF_SIG_PREPARE o = DefaultPrepare(); o.docmdp_permission = 2; @@ -1634,7 +1650,7 @@ TEST_F(EPDFSignatureEmbedderTest, ProbeDuplicateContentsKeyIsNotWhole) { snprintf(range, sizeof(range), "%010u %010zu %010zu %010zu", 0u, first, first + 18, p.bytes.size() - first - 18); p.bytes.replace(p.bytes.find(placeholder), placeholder.size(), range); - ScopedFPDFDocument doc = OpenRaw(p); + embedpdf_test::ScopedTestDocument doc = OpenRaw(p); ASSERT_TRUE(doc); EPDF_SIGNATURE_MODEL m = EPDFSig_LoadModel(doc.get()); ASSERT_TRUE(m); @@ -1645,7 +1661,7 @@ TEST_F(EPDFSignatureEmbedderTest, ProbeDuplicateContentsKeyIsNotWhole) { TEST_F(EPDFSignatureEmbedderTest, ProbeSeedValueVersionAndApprovalOnly) { // A required parser capability newer than the PDF 1.7 entry set: refused. RawPdf p = FormObjects("/SV<>"); - ScopedFPDFDocument doc = OpenRaw(p); + embedpdf_test::ScopedTestDocument doc = OpenRaw(p); ASSERT_TRUE(doc); EPDF_SIG_PREPARE o = DefaultPrepare(); EXPECT_EQ(0u, EPDFSig_Prepare(doc.get(), 6, &o)); @@ -1655,13 +1671,13 @@ TEST_F(EPDFSignatureEmbedderTest, ProbeSeedValueVersionAndApprovalOnly) { EPDFSig_CloseModel(m); // The same requirement at version 2 is fine. RawPdf p2 = FormObjects("/SV<>"); - ScopedFPDFDocument doc2 = OpenRaw(p2); + embedpdf_test::ScopedTestDocument doc2 = OpenRaw(p2); ASSERT_TRUE(doc2); EXPECT_NE(0u, EPDFSig_Prepare(doc2.get(), 6, &o)); // /MDP /P 0: approval only. A certification is refused, an approval is not. RawPdf p3 = FormObjects("/SV<>>>"); - ScopedFPDFDocument doc3 = OpenRaw(p3); + embedpdf_test::ScopedTestDocument doc3 = OpenRaw(p3); ASSERT_TRUE(doc3); m = EPDFSig_LoadModel(doc3.get()); EXPECT_TRUE(EPDFSig_GetSeedValuePresentFlags(m, 0) & EPDF_SIG_SV_MDP); @@ -1674,7 +1690,7 @@ TEST_F(EPDFSignatureEmbedderTest, ProbeSeedValueVersionAndApprovalOnly) { // /MDP without /P imposes no constraint: a certification is fine. RawPdf p5 = FormObjects("/SV<>>>"); - ScopedFPDFDocument doc5 = OpenRaw(p5); + embedpdf_test::ScopedTestDocument doc5 = OpenRaw(p5); ASSERT_TRUE(doc5); m = EPDFSig_LoadModel(doc5.get()); EXPECT_FALSE(EPDFSig_GetSeedValuePresentFlags(m, 0) & EPDF_SIG_SV_MDP); @@ -1683,7 +1699,7 @@ TEST_F(EPDFSignatureEmbedderTest, ProbeSeedValueVersionAndApprovalOnly) { // /MDP /P 2: a certification at that level is forced; other levels refused. RawPdf p4 = FormObjects("/SV<>>>"); - ScopedFPDFDocument doc4 = OpenRaw(p4); + embedpdf_test::ScopedTestDocument doc4 = OpenRaw(p4); ASSERT_TRUE(doc4); certify.docmdp_permission = 1; EXPECT_EQ(0u, EPDFSig_Prepare(doc4.get(), 6, &certify)); @@ -1761,8 +1777,19 @@ std::string SaveDelta(FPDF_DOCUMENT layer) { return delta; } -ScopedFPDFDocument OpenBytes(const std::string& bytes) { - return ScopedFPDFDocument(FPDF_LoadMemDocument64(bytes.data(), bytes.size(), nullptr)); +// |bytes| as a test opens them: a layer in layer mode. +embedpdf_test::ScopedTestDocument OpenBytes(const std::string& bytes) { + return embedpdf_test::ScopedTestDocument( + embedpdf_test::LoadMemDocumentForTest(bytes.data(), bytes.size(), + nullptr)); +} + +// |bytes| as a plain document, in layer mode too: for a test about a plain +// document, one that compares a plain document with a layer, or one that makes +// the bytes a layer opens. +ScopedFPDFDocument OpenPlainBytes(const std::string& bytes) { + return ScopedFPDFDocument( + FPDF_LoadMemDocument64(bytes.data(), bytes.size(), nullptr)); } std::string BytesOf(const Sealed& sealed) { @@ -1858,7 +1885,7 @@ TEST_F(EPDFSignatureEmbedderTest, LayerPrepareAndSaveStayInCandidate) { const std::string signed_bytes = BytesOf(sealed); // Saving a layer appends to the base bytes verbatim. EXPECT_EQ(p.bytes, signed_bytes.substr(0, p.bytes.size())); - ScopedFPDFDocument signed_doc = OpenBytes(signed_bytes); + embedpdf_test::ScopedTestDocument signed_doc = OpenBytes(signed_bytes); ASSERT_TRUE(signed_doc); EXPECT_EQ(EPDF_SIG_COVERAGE_WHOLE_REVISION, CoverageOf(signed_doc.get(), 0)); EXPECT_EQ(0ul, EPDFLayer_GetPromotedObjectCount(sibling.get())); @@ -1905,12 +1932,12 @@ TEST_F(EPDFSignatureEmbedderTest, LayerReopenedSignedDeltaReportsItsLoadedBytes) // delta. The layer was loaded from base + delta, so it must report what // the plain document reports: two revisions, WHOLE coverage, one digest. RawPdf p = FormObjects(); - ScopedFPDFDocument plain = OpenRaw(p); + ScopedFPDFDocument plain = OpenPlainBytes(p.bytes); ASSERT_TRUE(plain); Sealed sealed; ASSERT_TRUE(SignField(plain.get(), 6, DefaultPrepare(), &sealed)); const std::string signed_bytes = BytesOf(sealed); - ScopedFPDFDocument standalone = OpenBytes(signed_bytes); + ScopedFPDFDocument standalone = OpenPlainBytes(signed_bytes); ASSERT_TRUE(standalone); ASSERT_EQ(2, EPDFDoc_GetRevisionCount(standalone.get())); ASSERT_EQ(EPDF_SIG_COVERAGE_WHOLE_REVISION, CoverageOf(standalone.get(), 0)); @@ -1972,8 +1999,8 @@ TEST_F(EPDFSignatureEmbedderTest, LayerCompareLoadedDeltaReportsChanges) { EXPECT_NE(std::string::npos, ReadDiffValue(diff, 0, EPDF_DIFF_NEW).find("(changed)")); EPDFObjectDiff_Close(diff); // The layered comparison equals the plain one over the same bytes. - ScopedFPDFDocument older = OpenRaw(p); - ScopedFPDFDocument newer = OpenRaw(n); + ScopedFPDFDocument older = OpenPlainBytes(p.bytes); + ScopedFPDFDocument newer = OpenPlainBytes(n.bytes); EPDF_OBJECT_DIFF plain = EPDFDoc_CompareRevisions(older.get(), newer.get()); ASSERT_TRUE(plain); const std::vector plain_rows = ReadDiffRows(plain); @@ -1998,8 +2025,8 @@ TEST_F(EPDFSignatureEmbedderTest, LayerFreshBaseDiffKeepsUnreachableObjectValues ScopedBase base(n.bytes); ASSERT_TRUE(base.get()); ScopedFPDFDocument layer = OpenLayer(base.get()); - ScopedFPDFDocument older = OpenRaw(p); - ScopedFPDFDocument newer = OpenRaw(n); + ScopedFPDFDocument older = OpenPlainBytes(p.bytes); + ScopedFPDFDocument newer = OpenPlainBytes(n.bytes); ASSERT_TRUE(layer); ASSERT_TRUE(older); ASSERT_TRUE(newer); @@ -2028,7 +2055,7 @@ TEST_F(EPDFSignatureEmbedderTest, PlainDiffValuesComeFromBytesNotCache) { b.push_back("<>"); RawPdf p = MakeRawPdf(b); RawPdf n = AppendRawUpdate(p, 4, "<>", 5); - ScopedFPDFDocument newer = OpenRaw(n); + ScopedFPDFDocument newer = OpenPlainBytes(n.bytes); ASSERT_TRUE(newer); ScopedFPDFDocument older(EPDFDoc_OpenRevision(newer.get(), p.bytes.size())); ASSERT_TRUE(older); @@ -2072,7 +2099,7 @@ TEST_F(EPDFSignatureEmbedderTest, LayerFinalizedBytesAsNewBasePreserveConsecutiv const std::string second_bytes = BytesOf(second); EXPECT_EQ(first_bytes, second_bytes.substr(0, first_bytes.size())); - ScopedFPDFDocument reopened = OpenBytes(second_bytes); + embedpdf_test::ScopedTestDocument reopened = OpenBytes(second_bytes); ASSERT_TRUE(reopened); EXPECT_EQ(3, EPDFDoc_GetRevisionCount(reopened.get())); EXPECT_EQ(EPDF_SIG_COVERAGE_WHOLE_REVISION, CoverageOf(reopened.get(), 0)); @@ -2095,7 +2122,7 @@ TEST_F(EPDFSignatureEmbedderTest, LayerPrepareRefusesSignedBytesInLoadedDelta) { // dropping what the first signature sealed. The same bytes as a base, or // a delta holding only unsigned edits over a signed base, are fine. RawPdf p = TwoSignatureFields(); - ScopedFPDFDocument plain = OpenRaw(p); + ScopedFPDFDocument plain = OpenPlainBytes(p.bytes); ASSERT_TRUE(plain); Sealed first; ASSERT_TRUE(SignField(plain.get(), 4, DefaultPrepare(), &first)); @@ -2132,7 +2159,7 @@ TEST_F(EPDFSignatureEmbedderTest, LayerPrepareRefusesSignedBytesInLoadedDelta) { ASSERT_TRUE(SignField(unsigned_delta_layer.get(), 5, opts, &second)); const std::string second_bytes = BytesOf(second); EXPECT_EQ(signed_bytes, second_bytes.substr(0, signed_bytes.size())); - ScopedFPDFDocument reopened = OpenBytes(second_bytes); + embedpdf_test::ScopedTestDocument reopened = OpenBytes(second_bytes); ASSERT_TRUE(reopened); EXPECT_EQ(EPDF_SIG_COVERAGE_WHOLE_REVISION, CoverageOf(reopened.get(), 0)); EXPECT_EQ(EPDF_SIG_COVERAGE_WHOLE_REVISION, CoverageOf(reopened.get(), 1)); @@ -2176,7 +2203,7 @@ TEST_F(EPDFSignatureEmbedderTest, LayerEncryptedBaseModelMatchesOrdinaryDocument ScopedBase base(bytes); ASSERT_TRUE(base.get()); ScopedFPDFDocument layer = OpenLayer(base.get()); - ScopedFPDFDocument plain = OpenBytes(bytes); + ScopedFPDFDocument plain = OpenPlainBytes(bytes); ASSERT_TRUE(layer); ASSERT_TRUE(plain); EPDF_SIGNATURE_MODEL from_layer = EPDFSig_LoadModel(layer.get()); @@ -2221,7 +2248,7 @@ TEST_F(EPDFSignatureEmbedderTest, LayerEncryptedSigningPreservesExistingSignatur ASSERT_TRUE(SignField(candidate.get(), field, opts, &sealed)); const std::string signed_bytes = BytesOf(sealed); EXPECT_EQ(bytes, signed_bytes.substr(0, bytes.size())); - ScopedFPDFDocument signed_doc = OpenBytes(signed_bytes); + embedpdf_test::ScopedTestDocument signed_doc = OpenBytes(signed_bytes); ASSERT_TRUE(signed_doc); EPDF_SIGNATURE_MODEL model = EPDFSig_LoadModel(signed_doc.get()); ASSERT_TRUE(model); @@ -2238,7 +2265,7 @@ TEST_F(EPDFSignatureEmbedderTest, LayerEncryptedSigningPreservesExistingSignatur TEST_F(EPDFSignatureEmbedderTest, LoadedBytesPlainDocument) { RawPdf p = FormObjects(); RawPdf n = AppendRawUpdate(p, 5, "<>", 7); - ScopedFPDFDocument doc = OpenRaw(n); + ScopedFPDFDocument doc = OpenPlainBytes(n.bytes); ASSERT_TRUE(doc); EXPECT_EQ(n.bytes.size(), EPDFDoc_GetLoadedBytesSize(doc.get())); EXPECT_EQ(n.bytes.size(), EPDFDoc_GetBaseBytesSize(doc.get())); @@ -2302,7 +2329,7 @@ TEST_F(EPDFSignatureEmbedderTest, BaseSha256IsLazyAndCanBeSupplied) { ASSERT_EQ(32u, expected.size()); EXPECT_EQ(0, memcmp(reported, expected.data(), 32)); EXPECT_FALSE(EPDFLayer_GetBaseSha256(layer.get(), nullptr)); - ScopedFPDFDocument plain = OpenRaw(p); + ScopedFPDFDocument plain = OpenPlainBytes(p.bytes); EXPECT_FALSE(EPDFLayer_GetBaseSha256(plain.get(), reported)); // Supplied: a host that already hashed the bytes hands the value over and @@ -2350,7 +2377,7 @@ TEST_F(EPDFSignatureEmbedderTest, BaseSha256IsLazyAndCanBeSupplied) { TEST_F(EPDFSignatureEmbedderTest, StructureObjectNumbers) { RawPdf p = FormObjects(); - ScopedFPDFDocument doc = OpenRaw(p); + embedpdf_test::ScopedTestDocument doc = OpenRaw(p); ASSERT_TRUE(doc); unsigned int root = 0; unsigned int acroform = 0; @@ -2442,7 +2469,7 @@ TEST_F(EPDFSignatureEmbedderTest, LayerBaseOverlayReplacesTheLoadedDelta) { static_cast(EPDFDoc_GetLoadedBytesSize(reopened.get()))); // Refused for a plain document and for an empty delta. - ScopedFPDFDocument plain = OpenBytes(p.bytes); + ScopedFPDFDocument plain = OpenPlainBytes(p.bytes); ASSERT_TRUE(plain); EXPECT_FALSE(EPDFDoc_OpenBaseOverlay(plain.get(), delta2.data(), delta2.size())); EXPECT_FALSE(EPDFDoc_OpenBaseOverlay(reopened.get(), delta2.data(), 0)); diff --git a/fpdfsdk/epdf_sliced_load_embeddertest.cpp b/fpdfsdk/epdf_sliced_load_embeddertest.cpp index 9256879bc5..f4fc63c447 100644 --- a/fpdfsdk/epdf_sliced_load_embeddertest.cpp +++ b/fpdfsdk/epdf_sliced_load_embeddertest.cpp @@ -48,6 +48,7 @@ #include "public/fpdf_edit.h" #include "public/fpdfview.h" #include "testing/embedder_test.h" +#include "testing/embedpdf_layer_mode.h" #include "testing/gtest/include/gtest/gtest.h" namespace { @@ -244,13 +245,14 @@ class EPDFSlicedLoadEmbedderTest : public EmbedderTest { void ExpectSameEitherWay(const std::string& pdf) { Parsed expected; { - ScopedFPDFDocument doc( - FPDF_LoadMemDocument(pdf.data(), pdf.size(), nullptr)); + embedpdf_test::ScopedTestDocument doc( + embedpdf_test::LoadMemDocumentForTest(pdf.data(), pdf.size(), + nullptr)); ASSERT_TRUE(doc); expected = LoadInOneGo(doc.get(), 0); } - ScopedFPDFDocument doc( - FPDF_LoadMemDocument(pdf.data(), pdf.size(), nullptr)); + embedpdf_test::ScopedTestDocument doc( + embedpdf_test::LoadMemDocumentForTest(pdf.data(), pdf.size(), nullptr)); ASSERT_TRUE(doc); int slices = 0; ExpectSame(expected, LoadInSlices(doc.get(), 0, &slices)); @@ -354,7 +356,8 @@ TEST_F(EPDFSlicedLoadEmbedderTest, FormsWaitForTheContentThatPlacesThem) { const std::string pdf = OnePage("<< /XObject << /F 5 0 R >> >>", "/F Do 0 0 1 rg 0 0 10 10 re f", {Form("/BBox [0 0 100 100]", "1 0 0 rg 20 20 30 30 re f")}); - ScopedFPDFDocument doc(FPDF_LoadMemDocument(pdf.data(), pdf.size(), nullptr)); + embedpdf_test::ScopedTestDocument doc( + embedpdf_test::LoadMemDocumentForTest(pdf.data(), pdf.size(), nullptr)); ASSERT_TRUE(doc); ScopedFPDFPage page(EPDFDoc_StartLoadPageByObjectNumber( doc.get(), ObjectNumberOf(doc.get(), 0), /*normalized=*/false)); @@ -378,7 +381,8 @@ TEST_F(EPDFSlicedLoadEmbedderTest, FormsWaitForTheContentThatPlacesThem) { TEST_F(EPDFSlicedLoadEmbedderTest, AHugeFormLoadsInSlices) { constexpr int kPaths = 20000; const std::string pdf = OneHugeForm(kPaths); - ScopedFPDFDocument doc(FPDF_LoadMemDocument(pdf.data(), pdf.size(), nullptr)); + embedpdf_test::ScopedTestDocument doc( + embedpdf_test::LoadMemDocumentForTest(pdf.data(), pdf.size(), nullptr)); ASSERT_TRUE(doc); ScopedFPDFPage page(EPDFDoc_StartLoadPageByObjectNumber( doc.get(), ObjectNumberOf(doc.get(), 0), /*normalized=*/false)); @@ -423,7 +427,8 @@ TEST_F(EPDFSlicedLoadEmbedderTest, BigContentDecodesInSlices) { " /Filter /FlateDecode >>\nstream\n" + std::string(compressed.begin(), compressed.end()) + "\nendstream", }); - ScopedFPDFDocument doc(FPDF_LoadMemDocument(pdf.data(), pdf.size(), nullptr)); + embedpdf_test::ScopedTestDocument doc( + embedpdf_test::LoadMemDocumentForTest(pdf.data(), pdf.size(), nullptr)); ASSERT_TRUE(doc); ScopedFPDFPage page(EPDFDoc_StartLoadPageByObjectNumber( doc.get(), ObjectNumberOf(doc.get(), 0), /*normalized=*/false)); @@ -443,7 +448,8 @@ TEST_F(EPDFSlicedLoadEmbedderTest, BigContentDecodesInSlices) { TEST_F(EPDFSlicedLoadEmbedderTest, SlicesKeepToTheirBudget) { constexpr int kBudgetMs = 4; const std::string pdf = OneHugeForm(100000); - ScopedFPDFDocument doc(FPDF_LoadMemDocument(pdf.data(), pdf.size(), nullptr)); + embedpdf_test::ScopedTestDocument doc( + embedpdf_test::LoadMemDocumentForTest(pdf.data(), pdf.size(), nullptr)); ASSERT_TRUE(doc); ScopedFPDFPage page(EPDFDoc_StartLoadPageByObjectNumber( doc.get(), ObjectNumberOf(doc.get(), 0), /*normalized=*/false)); @@ -474,11 +480,12 @@ TEST_F(EPDFSlicedLoadEmbedderTest, ClosingMidLoadAbandonsIt) { const std::string pdf = OneHugeForm(5000); Parsed expected; { - ScopedFPDFDocument doc( - FPDF_LoadMemDocument(pdf.data(), pdf.size(), nullptr)); + embedpdf_test::ScopedTestDocument doc( + embedpdf_test::LoadMemDocumentForTest(pdf.data(), pdf.size(), nullptr)); expected = LoadInOneGo(doc.get(), 0); } - ScopedFPDFDocument doc(FPDF_LoadMemDocument(pdf.data(), pdf.size(), nullptr)); + embedpdf_test::ScopedTestDocument doc( + embedpdf_test::LoadMemDocumentForTest(pdf.data(), pdf.size(), nullptr)); ASSERT_TRUE(doc); const uint32_t objnum = ObjectNumberOf(doc.get(), 0); for (int steps : {0, 1, 3, 20}) { @@ -495,7 +502,8 @@ TEST_F(EPDFSlicedLoadEmbedderTest, ClosingMidLoadAbandonsIt) { // A call that reads a page still loading finishes the load first. TEST_F(EPDFSlicedLoadEmbedderTest, CallsThatReadThePageFinishItsLoad) { const std::string pdf = OneHugeForm(3000); - ScopedFPDFDocument doc(FPDF_LoadMemDocument(pdf.data(), pdf.size(), nullptr)); + embedpdf_test::ScopedTestDocument doc( + embedpdf_test::LoadMemDocumentForTest(pdf.data(), pdf.size(), nullptr)); ASSERT_TRUE(doc); ScopedFPDFPage page(EPDFDoc_StartLoadPageByObjectNumber( doc.get(), ObjectNumberOf(doc.get(), 0), /*normalized=*/false)); @@ -529,7 +537,8 @@ TEST_F(EPDFSlicedLoadEmbedderTest, StartAndContinueRefuseWhatIsNoPage) { "/Contents 4 0 R /Resources << >> >>", Stream("0 0 1 rg 10 10 50 50 re f"), }); - ScopedFPDFDocument doc(FPDF_LoadMemDocument(pdf.data(), pdf.size(), nullptr)); + embedpdf_test::ScopedTestDocument doc( + embedpdf_test::LoadMemDocumentForTest(pdf.data(), pdf.size(), nullptr)); ASSERT_TRUE(doc); EXPECT_FALSE(EPDFDoc_StartLoadPageByObjectNumber(nullptr, 3, false)); EXPECT_FALSE(EPDFDoc_StartLoadPageByObjectNumber(doc.get(), 0, false)); diff --git a/fpdfsdk/epdf_text_bounds_embeddertest.cpp b/fpdfsdk/epdf_text_bounds_embeddertest.cpp index c63cd9f7ab..c943ffa762 100644 --- a/fpdfsdk/epdf_text_bounds_embeddertest.cpp +++ b/fpdfsdk/epdf_text_bounds_embeddertest.cpp @@ -22,6 +22,7 @@ #include "public/fpdf_edit.h" #include "public/fpdfview.h" #include "testing/embedder_test.h" +#include "testing/embedpdf_layer_mode.h" #include "testing/gtest/include/gtest/gtest.h" namespace { @@ -61,7 +62,8 @@ struct Line { }; Line BoundsOf(const std::string& pdf) { - ScopedFPDFDocument doc(FPDF_LoadMemDocument(pdf.data(), pdf.size(), nullptr)); + embedpdf_test::ScopedTestDocument doc( + embedpdf_test::LoadMemDocumentForTest(pdf.data(), pdf.size(), nullptr)); ScopedFPDFPage page(FPDF_LoadPage(doc.get(), 0)); const CPDF_TextObject* text = CPDFPageFromFPDFPage(page.get())->GetPageObjectByIndex(0)->AsText(); @@ -74,7 +76,8 @@ Line BoundsOf(const std::string& pdf) { // Draws `pdf`'s page, which sets the generic font's design for its glyphs. void Draw(const std::string& pdf) { - ScopedFPDFDocument doc(FPDF_LoadMemDocument(pdf.data(), pdf.size(), nullptr)); + embedpdf_test::ScopedTestDocument doc( + embedpdf_test::LoadMemDocumentForTest(pdf.data(), pdf.size(), nullptr)); ScopedFPDFPage page(FPDF_LoadPage(doc.get(), 0)); ScopedFPDFBitmap bitmap = EmbedderTest::RenderPage(page.get()); } @@ -82,7 +85,8 @@ void Draw(const std::string& pdf) { // The extent of the dark pixels of `pdf`'s page drawn at `scale` pixels per // point, in page space. CFX_FloatRect Ink(const std::string& pdf, int scale) { - ScopedFPDFDocument doc(FPDF_LoadMemDocument(pdf.data(), pdf.size(), nullptr)); + embedpdf_test::ScopedTestDocument doc( + embedpdf_test::LoadMemDocumentForTest(pdf.data(), pdf.size(), nullptr)); ScopedFPDFPage page(FPDF_LoadPage(doc.get(), 0)); const int width = kPageWidth * scale; const int height = kPageHeight * scale; diff --git a/fpdfsdk/epdf_transaction_embeddertest.cpp b/fpdfsdk/epdf_transaction_embeddertest.cpp index 94b64be439..16b6b7d124 100644 --- a/fpdfsdk/epdf_transaction_embeddertest.cpp +++ b/fpdfsdk/epdf_transaction_embeddertest.cpp @@ -286,6 +286,7 @@ TEST_F(EPDFTransactionEmbedderTest, OnlyOnALayerAndOneAtATime) { EXPECT_FALSE(EPDFLayer_BeginTransaction(nullptr)); EXPECT_FALSE(EPDFLayer_IsInTransaction(nullptr)); const std::string plain_bytes = MakeDocument(); + // Plain in layer mode too: a plain document takes no transaction. ScopedFPDFDocument plain( FPDF_LoadMemDocument(plain_bytes.data(), plain_bytes.size(), nullptr)); ASSERT_TRUE(plain); diff --git a/fpdfsdk/epdf_view_embeddertest.cpp b/fpdfsdk/epdf_view_embeddertest.cpp index aa1e8fc3af..e9e69e13ce 100644 --- a/fpdfsdk/epdf_view_embeddertest.cpp +++ b/fpdfsdk/epdf_view_embeddertest.cpp @@ -26,6 +26,7 @@ #include "core/fxge/dib/cstretchengine.h" #include "fpdfsdk/cpdfsdk_helpers.h" #include "fpdfsdk/epdf_c_api_test.h" +#include "fpdfsdk/epdf_edit_test_util.h" #include "public/cpp/fpdf_scopers.h" #include "public/epdf_progressive.h" #include "public/fpdf_edit.h" @@ -33,6 +34,7 @@ #include "public/fpdf_save.h" #include "public/fpdfview.h" #include "testing/embedder_test.h" +#include "testing/embedpdf_layer_mode.h" // Our public headers compile and link as C (fpdfsdk/epdf_c_api_test.c). TEST(epdf, CApiTest) { @@ -978,8 +980,8 @@ TEST_F(EPDFViewEmbedderTest, ImageOfAnotherDocumentDraws) { return HashBitmap(bitmap.get()); }; - ScopedFPDFDocument document(FPDF_CreateNewDocument()); - ScopedFPDFDocument other(FPDF_CreateNewDocument()); + embedpdf_test::ScopedTestDocument document(NewTestDocument()); + embedpdf_test::ScopedTestDocument other(NewTestDocument()); ASSERT_TRUE(document); ASSERT_TRUE(other); EXPECT_EQ(render(document.get(), document.get()), diff --git a/testing/embedpdf_layer_mode_writers.txt b/testing/embedpdf_layer_mode_writers.txt index 9c6d7623fb..097e782cef 100644 --- a/testing/embedpdf_layer_mode_writers.txt +++ b/testing/embedpdf_layer_mode_writers.txt @@ -16,6 +16,10 @@ All/EPDFRedactPageTreeTest.RemovesUnusedPropertiesFromEveryAncestor/0 7 All/EPDFRedactPageTreeTest.RemovesUnusedPropertiesFromEveryAncestor/1 7 All/EPDFRedactPageTreeTest.RemovesUnusedPropertiesFromEveryAncestor/2 7 All/EPDFRedactPageTreeTest.RemovesUnusedPropertiesFromEveryAncestor/3 7 +AppearanceSharing/EPDFStampSaveEmbedderTest.LayerRotationSurvivesIncrementalSaveAndRewrite/SharedDictionary 5 +AppearanceSharing/EPDFStampSaveEmbedderTest.LayerRotationSurvivesIncrementalSaveAndRewrite/SharedStates 6 +AppearanceSharing/EPDFStampSaveEmbedderTest.LayerRotationSurvivesIncrementalSaveAndRewrite/SharedStream 4 +AppearanceSharing/EPDFStampSaveEmbedderTest.LayerRotationSurvivesIncrementalSaveAndRewrite/Unshared 4 CPDFSecurityHandlerEmbedderTest.OwnerPasswordVersion2Latin1 3 CPDFSecurityHandlerEmbedderTest.OwnerPasswordVersion2UTF8 3 CPDFSecurityHandlerEmbedderTest.OwnerPasswordVersion3Latin1 3 @@ -32,53 +36,159 @@ CPDFSecurityHandlerEmbedderTest.UserPasswordVersion5Latin1 3 CPDFSecurityHandlerEmbedderTest.UserPasswordVersion5UTF8 3 CPDFSecurityHandlerEmbedderTest.UserPasswordVersion6Latin1 3 CPDFSecurityHandlerEmbedderTest.UserPasswordVersion6UTF8 3 +EPDFActionEmbedderTest.CreateNamedWritesTheName 1 +EPDFActionEmbedderTest.CreatorsReadBack 8 +EPDFActionEmbedderTest.DestinationArrayJunkBeyondViewIsIgnored 4 +EPDFActionEmbedderTest.DestinationsByPageObjectNumber 7 +EPDFActionEmbedderTest.DocumentAndPageModelsAreDetached 3 +EPDFActionEmbedderTest.HideTargetPayloadsMixedForms 2 EPDFActionEmbedderTest.MergedFieldAndWidgetAdditionalActionsStaySeparate 2 +EPDFActionEmbedderTest.NextRenditionCycleAndMalformedEntry 4 +EPDFActionEmbedderTest.NodeDestPayloadFromCreatedGoTo 5 +EPDFActionEmbedderTest.NodeFilePathAndNamePayloadsFromSyntheticDicts 2 +EPDFActionEmbedderTest.OpenActionDestinationForms 3 +EPDFActionEmbedderTest.ResetFormThreeStates 1 +EPDFActionEmbedderTest.SetNextChainsActions 3 +EPDFAnnotEmbedderTest.AnnotFontMapStagesEveryNamedFont 16 EPDFAnnotEmbedderTest.ApplyPageRedactionsCountsRemovedAnnotations 6 EPDFAnnotEmbedderTest.ApplyPageRedactionsTwoMarksOnOneTextObject 3 +EPDFAnnotEmbedderTest.ApplyRedactionBurnsInAutoSizedLabel 9 EPDFAnnotEmbedderTest.ApplyRedactionCascadesPopupRemoval 5 EPDFAnnotEmbedderTest.ApplyRedactionClonesSharedFormBeforeVectorEdit 15 EPDFAnnotEmbedderTest.ApplyRedactionCountsIntersectingAnnotation 5 EPDFAnnotEmbedderTest.ApplyRedactionDoesNotRemoveTouchOnlyAnnotation 5 +EPDFAnnotEmbedderTest.ApplyRedactionHonorsOverlayTextAlignment 8 +EPDFAnnotEmbedderTest.ApplyRedactionLabelWithoutDaFontUsesHelvetica 8 EPDFAnnotEmbedderTest.ApplyRedactionOnNeverParsedPageRemovesText 9 +EPDFAnnotEmbedderTest.ApplyRedactionPrefersBakedOverlayStream 7 EPDFAnnotEmbedderTest.ApplyRedactionPreservesEnclosedVectorHoleAcrossSave 5 EPDFAnnotEmbedderTest.ApplyRedactionPreservesInheritedColorspaceResources 7 EPDFAnnotEmbedderTest.ApplyRedactionPreservesSiblingRedactions 5 EPDFAnnotEmbedderTest.ApplyRedactionRemovesTextInMiddleOfSentence 9 +EPDFAnnotEmbedderTest.ApplyRedactionRemovesTheMarksOwnPopup 3 +EPDFAnnotEmbedderTest.ApplyRedactionRepeatsAutoSizedLabel 9 +EPDFAnnotEmbedderTest.ApplyRedactionRepeatsOverlayTextToFillRegion 8 EPDFAnnotEmbedderTest.ApplyRedactionRotatedQuadSparesNeighbours 3 EPDFAnnotEmbedderTest.ApplyRedactionSplitsFillAndStrokePathAcrossSave 5 +EPDFAnnotEmbedderTest.ApplyRedactionSynthesizesInteriorColorFill 6 +EPDFAnnotEmbedderTest.ApplyRedactionSynthesizesOverlayTextLabel 8 +EPDFAnnotEmbedderTest.ApplyRedactionWithoutOverlayLeavesRegionClear 3 +EPDFAnnotEmbedderTest.BorderStyleResolutionUsesISOPrecedence 4 +EPDFAnnotEmbedderTest.CalloutRectHoldsItsLineAndArrow 6 +EPDFAnnotEmbedderTest.CffProgramRaisesPdfVersionTo16 11 EPDFAnnotEmbedderTest.CloudyBumpsReachPastTheBoxIntoRect 9 +EPDFAnnotEmbedderTest.CloudyPolygonRectHoldsItsBumps 4 +EPDFAnnotEmbedderTest.ComboBoxKoreanUsesRegisteredDroidFallbackFont 20 +EPDFAnnotEmbedderTest.DashedBorderDrawsItsDashOrTheDefault 7 EPDFAnnotEmbedderTest.DefaultAppearanceFontFace 1 +EPDFAnnotEmbedderTest.DefaultAppearancePrefersAnnotationDrThenFallsBackToAcroFormDr 3 EPDFAnnotEmbedderTest.DirectAnnotationObjectNumberStaysZeroAfterRender 1 +EPDFAnnotEmbedderTest.DrawingAnnotationsWithoutAppearancesWritesNone 3 +EPDFAnnotEmbedderTest.DrawingRectIsWhereTheAppearanceIsDrawn 4 EPDFAnnotEmbedderTest.EmbedMetadata 1 EPDFAnnotEmbedderTest.EmbedSetRectPreservesRotatedAppearance 2 EPDFAnnotEmbedderTest.ExplicitGenerateAppearanceAllowed 2 +EPDFAnnotEmbedderTest.FontEmbeddingPolicyGovernsRegisteredResources 51 +EPDFAnnotEmbedderTest.FreeTextAllFallbackTextKeepsRegisteredDaFont 17 +EPDFAnnotEmbedderTest.FreeTextAppearanceFallsBackToRegisteredFont 12 +EPDFAnnotEmbedderTest.FreeTextAppearanceUsesRegisteredMemoryFont 12 +EPDFAnnotEmbedderTest.FreeTextEmptyContentsKeepsRegisteredDaFontAcrossSave 11 +EPDFAnnotEmbedderTest.FreeTextEphemeralAppearanceLeavesDrUntouched 11 +EPDFAnnotEmbedderTest.FreeTextFallbackAliasNeverCollidesWithStaleDaAlias 25 +EPDFAnnotEmbedderTest.FreeTextKoreanUsesRegisteredDroidFallbackFont 12 +EPDFAnnotEmbedderTest.FreeTextLegacyMarkerDrEntryUpgradesToRealFont 11 +EPDFAnnotEmbedderTest.FreeTextPlateFollowsBorderWidth 10 +EPDFAnnotEmbedderTest.FreeTextRegeneratingOneAnnotationLeavesTheOther 26 +EPDFAnnotEmbedderTest.FreeTextRegisteredFontEmbedsSubsetInSavedPdf 12 +EPDFAnnotEmbedderTest.FreeTextRegisteredFontInstallsRealDrEntry 12 +EPDFAnnotEmbedderTest.FreeTextRegisteredFontMarkerSurvivesAliasSuffix 11 +EPDFAnnotEmbedderTest.FreeTextRegisteredFontResolvesByFamilyAfterReregistration 12 +EPDFAnnotEmbedderTest.FreeTextRegistersFontFromFileAccess 12 +EPDFAnnotEmbedderTest.FreeTextStagedFontFailureLeavesDocumentUntouched 18 +EPDFAnnotEmbedderTest.GenerateFileAttachmentAppearance 4 +EPDFAnnotEmbedderTest.GenerateFileAttachmentAppearancePerIcon 8 +EPDFAnnotEmbedderTest.GenerateInkAppearanceSetsRectToWhatItPaints 8 +EPDFAnnotEmbedderTest.GenerateRedactAppearanceBakesLabelIntoOverlay 7 +EPDFAnnotEmbedderTest.GenerateTextAppearanceFillsItsRect 5 +EPDFAnnotEmbedderTest.GenerateTextAppearancePerIcon 12 +EPDFAnnotEmbedderTest.LineRectHoldsItsArrowhead 4 +EPDFAnnotEmbedderTest.LineRectIsWhatItsStrokePaints 5 +EPDFAnnotEmbedderTest.ListBoxKoreanUsesRegisteredDroidFallbackFont 20 +EPDFAnnotEmbedderTest.NoSubsettingFontEmbedsWholeProgram 12 +EPDFAnnotEmbedderTest.OpacityIsStoredAsGiven 3 +EPDFAnnotEmbedderTest.PolylineKneePastTheMiterLimitIsBeveled 4 +EPDFAnnotEmbedderTest.PreviewAndPrintFallbackDoesNotAuthorUntilAuthorized 25 EPDFAnnotEmbedderTest.ReadPurityRenderMarkupAnnotWithContents 1 EPDFAnnotEmbedderTest.RedactInQuadsMultipleRegionsOnOneTextObject 3 EPDFAnnotEmbedderTest.RedactInQuadsRemovesTextInsideFormXObject 5 +EPDFAnnotEmbedderTest.RedactLabelRegisteredFontInstallsRealDrEntry 12 EPDFAnnotEmbedderTest.RedactRemovesInvisibleOcrLayerText 4 EPDFAnnotEmbedderTest.RedactRemovesTextWithEmptyGlyphBoxes 3 EPDFAnnotEmbedderTest.RedactVerticalTextLeadingGlyphKeepsRestInPlace 3 EPDFAnnotEmbedderTest.RedactVerticalTextMiddleGlyphsKeepsTailInPlace 3 +EPDFAnnotEmbedderTest.RegisteredCffFontEmitsCidFontType0 12 +EPDFAnnotEmbedderTest.RegisteredCidKeyedCffKeepsCidsInAppearance 12 +EPDFAnnotEmbedderTest.RegisteredFallbackFontRendersPageMissingGlyph 5 +EPDFAnnotEmbedderTest.RegisteredFontResolutionPrefersStoredFamily 9 +EPDFAnnotEmbedderTest.RegisteredFontResolutionRefusesConflictingHint 6 +EPDFAnnotEmbedderTest.RegistryHonoursFsTypeEmbeddingPermissions 12 EPDFAnnotEmbedderTest.RemoveKey 1 +EPDFAnnotEmbedderTest.RichTextAlignmentFollowsTheAnnotation 11 EPDFAnnotEmbedderTest.RichTextCoversSupplementaryCharactersByScalar 10 +EPDFAnnotEmbedderTest.RichTextDocumentSubsetDrawsOnlyWhatItCovers 21 EPDFAnnotEmbedderTest.RichTextEmptyBoxNeverNamesACmaplessSubset 5 +EPDFAnnotEmbedderTest.RichTextJsonFromContentsOnly 5 +EPDFAnnotEmbedderTest.RichTextJsonFromRCAndDS 5 EPDFAnnotEmbedderTest.RichTextLastResortDrawsWhatNoFontHas 20 +EPDFAnnotEmbedderTest.RichTextPicksTheDocumentSubsetThatCoversTheText 16 EPDFAnnotEmbedderTest.RichTextPreviewAndPrintLastResortWaits 25 +EPDFAnnotEmbedderTest.RichTextResolvesDocumentProgramWhenUnregistered 24 +EPDFAnnotEmbedderTest.RichTextRtlRunCarriesActualTextAndExtracts 14 EPDFAnnotEmbedderTest.RichTextSkipsDocumentSubsetWithoutCmap 6 +EPDFAnnotEmbedderTest.RichTextWriterFailureLeavesDocumentUntouched 18 EPDFAnnotEmbedderTest.RotatedCaretAppearanceCarriesTransform 3 +EPDFAnnotEmbedderTest.SetDefaultAppearanceKeepsFontAtAutoSize 5 +EPDFAnnotEmbedderTest.SetNameAcceptsAnyNameAndKeepsAppearance 4 +EPDFAnnotEmbedderTest.SetNumberValueRefusesWithoutWriting 3 +EPDFAnnotEmbedderTest.SetNumberValueStoresTheNumberAsGiven 3 +EPDFAnnotEmbedderTest.SetRichTextJSONRejectsInvalidInputUnchanged 5 +EPDFAnnotEmbedderTest.SetRichTextJSONWithRegisteredBodyFont 12 +EPDFAnnotEmbedderTest.SetRichTextJSONWithoutBodyKeepsCurrentBody 7 +EPDFAnnotEmbedderTest.SetRichTextJSONWritesAllFourForms 6 +EPDFAnnotEmbedderTest.SetRichTextXHTMLImportsOverDefaults 6 +EPDFAnnotEmbedderTest.StandardFontDefaultAppearanceRoundTripsThroughDr 18 EPDFAnnotEmbedderTest.TextFieldDrawsItsBorderStyle 2 EPDFAnnotEmbedderTest.TextFieldGenerateAppearanceStreamIsStable 2 +EPDFAnnotEmbedderTest.TextFieldKoreanUsesRegisteredDroidFallbackFont 20 EPDFAnnotEmbedderTest.TurnedBoxRectIsTheUprightBoxAroundIt 2 +EPDFAnnotEmbedderTest.VariableFontIsInstancedAtRegistration 12 +EPDFAnnotEmbedderTest.WidgetRegisteredFontInstallsRealDrEntry 25 EPDFAnnotEmbedderTest.WidgetTextAlignment 2 +EPDFAnnotRawEmbedderTest.FindsANameOnAnAnnotationWrittenInPlace 3 +EPDFAnnotRawEmbedderTest.FindsAnAnnotationByNameOnItsPage 5 +EPDFAnnotRawEmbedderTest.FindsAnAnnotationByObjectNumber 5 +EPDFAnnotRawEmbedderTest.FindsNothingWhereThereIsNothing 3 +EPDFAnnotRawEmbedderTest.NewAnnotationsNameTheirPage 6 EPDFAttachmentEmbedderTest.ExtractFileEmptyAttachment 5 EPDFAttachmentEmbedderTest.ExtractFileLargeAttachment 5 EPDFAttachmentEmbedderTest.GetAttachmentIndexByKey 6 +EPDFAttachmentEmbedderTest.GetFileHonoursTheBufferContract 5 +EPDFFlattenEmbedderTest.CopierFollowsReferencesByWhatTheyResolveTo 3 +EPDFFlattenEmbedderTest.ExportAnnotationsDeduplicatesSharedResources 6 +EPDFFlattenEmbedderTest.ExportAnnotationsMatchesSourceCrop 6 +EPDFFlattenEmbedderTest.ExportPagesFlattenedCopiesPagesInTheGivenOrder 5 +EPDFFlattenEmbedderTest.ExportPagesFlattenedKeepsTheLayersPrintState 6 +EPDFFlattenEmbedderTest.ExportPagesFlattenedPrintsAFieldDrawnInMemory 1 +EPDFFlattenEmbedderTest.FlattenAnnotationSetRejectsForeignAnnotation 3 EPDFFlattenEmbedderTest.FlattenAnnotationSetReportsPerEntry 7 +EPDFFlattenEmbedderTest.FlattenDirectAnnotationByHandle 8 EPDFFlattenEmbedderTest.FlattenForDisplayLeavesANoViewAnnotation 1 EPDFFlattenEmbedderTest.FlattenMergedWidgetRemovesFieldTreeEntry 11 EPDFFlattenEmbedderTest.FlattenPageHonorsPrintUsage 10 EPDFFlattenEmbedderTest.FlattenPagePreservesUnpaintedAnnotationsAndDetachesWidget 12 +EPDFFlattenEmbedderTest.FlattenPaintsTheAppearanceDrawnInMemory 7 EPDFFlattenEmbedderTest.FlattenSpecificAnnotationByHandle 7 +EPDFFlattenEmbedderTest.InvisibleLeavesOutOnlyAnUnknownType 7 EPDFFontEmbedderTest.FreeTextReportsCharactersNoFontHas 6 EPDFFontEmbedderTest.ListsADocumentProgramAndHandsOutItsBytes 25 EPDFFontEmbedderTest.PasswordFieldWritesOnlyStars 8 @@ -127,32 +237,120 @@ EPDFFormEmbedderTest.ToggleWidgetsTurnOnTheirOwnState 3 EPDFFormEmbedderTest.TwoPlaneTwinWidgetsFillTogether 9 EPDFFormEmbedderTest.TypedValueSnapshotPreservesPdfShapes 3 EPDFFormEmbedderTest.WidgetRotationTurnsItsAppearance 2 +EPDFMeasureEmbedderTest.BadArgumentsAndRejectedWrites 5 +EPDFMeasureEmbedderTest.CaptionAppearanceGolden 19 +EPDFMeasureEmbedderTest.DirectMeasureWithSharedNestedFormatDetachesOnlyItsOwner 5 +EPDFMeasureEmbedderTest.HandlesInvalidateAcrossTwoAnnotationHandles 4 +EPDFMeasureEmbedderTest.LayerAddThenRemoveCaptionedMeasurementWritesNothing 5 +EPDFMeasureEmbedderTest.LayerAppearanceAndEphemeralRead 5 +EPDFMeasureEmbedderTest.LayerReadsPromoteNothingAndPageWritesOnlyPage 5 +EPDFMeasureEmbedderTest.LineAndShapeCaptionEntriesStaySeparate 5 +EPDFMeasureEmbedderTest.LineAppearanceLeadersInlineGapAndStableBounds 7 +EPDFMeasureEmbedderTest.MissingOrMalformedConversionNeverBecomesOne 4 EPDFMeasureEmbedderTest.NumberFormatsRoundTripAndAbsentVersusEmpty 1 +EPDFMeasureEmbedderTest.RegisteredCaptionFontsStayOutOfCatalogAndEphemeralWrites 11 +EPDFMeasureEmbedderTest.ShapeCaptionBoundsShrinkWhenMovedInward 6 +EPDFMeasureEmbedderTest.ShapeCaptionCenterRoundTripsAndOnlyChangesVisualBounds 7 +EPDFMeasureEmbedderTest.SharedIndirectMeasureAndNestedFormatsDetach 8 +EPDFMeasureEmbedderTest.SharedIndirectViewportTreeDetachesAndForeignEntriesSurvive 7 +EPDFMeasureEmbedderTest.ShortDistanceOmitsShaftAndBoundsCanShrink 7 +EPDFMeasureEmbedderTest.UnknownMeasureIsPreservedAndGeoSettersRejectBeforePromotion 5 +EPDFMeasureEmbedderTest.ViewportsFindLastAndInvalidateOnRemoval 3 EPDFNamedPagesEmbedderTest.DeletingAPageDropsItsRegistrations 9 +EPDFNamedPagesEmbedderTest.NewDocumentGrowsATreeOnFirstSet 6 EPDFNamedPagesEmbedderTest.RemoveByKeyKeepsThePage 8 EPDFNamedPagesEmbedderTest.SetReplacesRejectsAndRoundTrips 8 +EPDFObjectNumberEmbedderTest.FullSaveListsUnusedNumbersAsFree 1 +EPDFOutlineEmbedderTest.ADictionaryThatIsntAnItemEndsTheList 3 +EPDFOutlineEmbedderTest.ADirectItemKeepsItsListAsItIs 1 +EPDFOutlineEmbedderTest.ALoopEndsTheList 3 +EPDFOutlineEmbedderTest.AnOutlinesThatIsntAnOutlineIsNone 3 +EPDFOutlineEmbedderTest.CreateMakesTheOutline 3 +EPDFOutlineEmbedderTest.CreatePlacesTheItemAndCounts 13 +EPDFOutlineEmbedderTest.DeleteTakesTheItemsUnderIt 2 +EPDFOutlineEmbedderTest.ItemsDeeperThanReadsGoAreLeftAlone 1 +EPDFOutlineEmbedderTest.MoveKeepsNumbersKeysAndState 6 +EPDFOutlineEmbedderTest.SetActionReplacesTheDestination 3 +EPDFOutlineEmbedderTest.SetOpenFlipsTheSignAndCountsAgain 3 +EPDFOutlineEmbedderTest.SharedListsAreCountedOnce 3001 +EPDFOutlineEmbedderTest.TitleColorAndStyle 3 +EPDFOutlineEmbedderTest.WrongLinksAndCountsAreWrittenRight 6 +EPDFPageLabelsEmbedderTest.ReadsATreeAsPageLabelsDo 11 +EPDFPageLabelsEmbedderTest.WritesSectionsThatLabelThePages 8 +EPDFPieceInfoEmbedderTest.CatalogGranularClearPreservesOtherData 4 +EPDFPieceInfoEmbedderTest.CatalogTypedValuesSaveReloadAndLayerRead 4 +EPDFPieceInfoEmbedderTest.GranularClearPreservesOtherData 3 +EPDFPieceInfoEmbedderTest.TypedValuesSaveReloadAndImport 3 EPDFPpoEmbedderTest.AddsToAFormAndRenamesAFontItUses 1 +EPDFPpoEmbedderTest.BringsOnlyWhatIsAboveThePagesWidgets 12 +EPDFPpoEmbedderTest.BringsTheFieldsOfEveryPage 18 +EPDFPpoEmbedderTest.CopiesOutOfALayerAsTheLayerReadsIt 14 +EPDFPpoEmbedderTest.PointsCopiedParentsAtTheCopies 15 EPDFPpoEmbedderTest.RenamesAFontWithOtherWidths 2 EPDFPpoEmbedderTest.RenamesTheFontOfAnAppearanceWithAComment 2 EPDFPpoEmbedderTest.SharesAFontDefinedTheSameWay 1 EPDFRedactEmbedderTest.DirectReplacementTextIsRemovedFromSiblingObjects 3 EPDFRedactEmbedderTest.InheritedPropertiesLeaveNoUnusedOriginalOnPage 5 EPDFRedactEmbedderTest.NestedFormsUseTheRenderersTransformOrder 7 +EPDFRedactEmbedderTest.RedactingAFlattenedStampLeavesAStampSharingItsDrawingAlone 20 +EPDFRedactEmbedderTest.RedactingTheOnlyStampLeavesNothingOfItsDrawing 18 EPDFRedactEmbedderTest.RemovesReplacementTextFromWholeAffectedSpan 8 EPDFRedactEmbedderTest.SharedFormPreservesUnmarkedReplacementText 5 EPDFRedactEmbedderTest.SharedImageAndMaskPreserveOtherPlacements 6 EPDFRedactEmbedderTest.SharedImagePlacementsReceiveIndependentRegions 8 +EPDFSaveEmbedderTest.EncryptedSaveUsesObjectGenerationForStringsAndStreams 2 EPDFSaveEmbedderTest.FullRewritePreservesLiveAnnotationAcrossSaves 2 EPDFSaveEmbedderTest.FullSaveSubsetsNewFonts 19 +EPDFSaveEmbedderTest.IncrementalRevisionWritesExactlyChangedObjects 3 EPDFSaveEmbedderTest.IncrementalSaveDoesNotPopulateDocumentCaches 2 +EPDFSaveEmbedderTest.IncrementalSavePreservesDeclaredXrefSize 1 EPDFSaveEmbedderTest.IncrementalSavePrunesUnlinkedNewAnnotation 2 EPDFSaveEmbedderTest.SaveAsCopyKeepsLinkedNewAnnotation 2 EPDFSaveEmbedderTest.SaveAsCopyPrunesUnlinkedNewAnnotation 2 +EPDFSaveEmbedderTest.SavePreservesConsistentObjectGenerations 1 EPDFSignatureEmbedderTest.CertifyThenRefuseSecondCertification 7 EPDFSignatureEmbedderTest.CreateSignatureFieldAndLock 5 EPDFSignatureEmbedderTest.PermissionOneAllowsOnlyTimestamps 7 +EPDFSignatureEmbedderTest.ProbeContactInfoCannotBecomePlaceholder 3 +EPDFSignatureEmbedderTest.ProbeExistingLockBecomesFieldMdp 4 +EPDFSignatureEmbedderTest.ProbeLockParentCoversChildren 5 +EPDFSignatureEmbedderTest.ProbeLockPreservesInheritedFlags 5 +EPDFSignatureEmbedderTest.ProbeMdpStructuresAreDirect 5 +EPDFSignatureEmbedderTest.ProbeSeedValueVersionAndApprovalOnly 3 EPDFSignatureEmbedderTest.SealRejectsDecoysAndBadDer 5 EPDFSignatureEmbedderTest.SignRoundTrip 7 +EPDFStampResizeEmbedderTest.ADrawingFromALayersPageLeavesTheLayerAlone 5 +EPDFStampResizeEmbedderTest.AFormThatChangesItsDrawingIsNotLookedThrough 18 +EPDFStampResizeEmbedderTest.AFormThatOnlyMovesItsDrawingIsLookedThrough 8 +EPDFStampResizeEmbedderTest.ALayerThatDoesNotPaintCAOverOurWrapperIsPartOfTheDrawing 9 +EPDFStampResizeEmbedderTest.ALayerThatDoesNotRepeatCAIsPartOfTheDrawing 7 +EPDFStampResizeEmbedderTest.AStampFromAPageLeavesTheDocumentInfoAlone 10 +EPDFStampResizeEmbedderTest.AnExportIsTheCanonicalDrawingPage 7 +EPDFStampResizeEmbedderTest.AnImportedDrawingExportsItsCanonicalBytes 4 +EPDFStampResizeEmbedderTest.AnOlderExportStillImports 7 +EPDFStampResizeEmbedderTest.AnOpacityLayerRepeatingCAIsReplacedNotNested 8 +EPDFStampResizeEmbedderTest.AnotherToolsArtworkIsOneDrawingAtAnySize 5 +EPDFStampResizeEmbedderTest.BooleanValues 3 +EPDFStampResizeEmbedderTest.CanonicalDrawingIsWhatAStampExports 6 +EPDFStampResizeEmbedderTest.ChangingAStampLeavesAStampSharingItsDrawingAlone 9 +EPDFStampResizeEmbedderTest.CoverCentersBothAxes 9 +EPDFStampResizeEmbedderTest.DetachesSharedDictionariesAndSelectedState 8 +EPDFStampResizeEmbedderTest.EditingOneStampsDrawingLeavesAStampSharingItAlone 10 +EPDFStampResizeEmbedderTest.ExportAndImportAreAFixedPoint 16 +EPDFStampResizeEmbedderTest.ExportAppearanceLeavesAnOpacityLayerOut 5 +EPDFStampResizeEmbedderTest.ExportAppearanceOfOurWrapperIsTheDrawing 7 +EPDFStampResizeEmbedderTest.FailedWrappingLeavesOriginalAppearanceUnchanged 4 +EPDFStampResizeEmbedderTest.OpacityIsAcrobatsLayerOverOurWrapper 10 +EPDFStampResizeEmbedderTest.OurWrapperIsFoundUnderFormsThatOnlyDrawIt 14 +EPDFStampResizeEmbedderTest.RefreshesAlreadyParsedAnnotationObjects 6 +EPDFStampResizeEmbedderTest.RepeatedResizesReuseChildDespiteMissingOrStaleMarker 26 +EPDFStampResizeEmbedderTest.RotatedWrapperStartsAtTheOrigin 7 +EPDFStampResizeEmbedderTest.SetStampOpacityReplacesAcrobatsLayer 7 +EPDFStampResizeEmbedderTest.StaleMarkerDoesNotReplaceArtworkWithMissingDo 6 +EPDFStampResizeEmbedderTest.StampsPlacingOneDrawingShareIt 9 +EPDFStampResizeEmbedderTest.StateSelectionWithoutASMatchesRendering 15 +EPDFStampResizeEmbedderTest.TheSameDrawingExportsToTheSameBytes 6 +EPDFStampResizeEmbedderTest.WrappingMovesTheDrawingsEntriesWithIt 6 EPDFViewEmbedderTest.EPDFDocDeletePageByObjectNumber 3 EPDFViewEmbedderTest.EPDFDocDeletePageByObjectNumberDeletesDuplicatePageObjectOccurrence 2 EPDFViewEmbedderTest.EPDFDocSetPageRotationByObjectNumber 1 @@ -160,6 +358,7 @@ EPDFViewEmbedderTest.EPDFGetPageBoxByIndex 2 EPDFViewEmbedderTest.EPDFGetPageRotateByIndex 2 EPDFViewEmbedderTest.EPDFGetPageTabOrderByIndex 2 EPDFViewEmbedderTest.EPDFGetPageUserUnitByIndex 1 +EPDFViewEmbedderTest.ImageOfAnotherDocumentDraws 4 FPDFAnnotEmbedderTest.AddAndModifyImage 7 FPDFAnnotEmbedderTest.AddAndModifyPath 9 FPDFAnnotEmbedderTest.AddAndModifyText 5