Repository navigation
Run the in-memory tests as layers in layer mode - #99
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #95. That PR took the font tests through layer mode. This one does the same for every other fork test that builds its document in memory with
FPDF_LoadMemDocument*,FPDF_CreateNewDocumentorCreateEmptyDocument(). Until now, those tests never ran on a layer with the read-only check and the layer DCHECKs on.What changes
fpdfsdk/epdf_*embeddertest.cppfiles:OpenDocumentFromMemory(EmptyPdf())replacesCreateEmptyDocument()(22 sites);NewTestDocument()(inepdf_edit_test_util) replacesFPDF_CreateNewDocument()(124 sites). It isEmptyPdf()throughLoadMemDocumentForTest();LoadMemDocumentForTest()withScopedTestDocumentcovers reopened saves and in-memory PDFs, directly or through the files' helpers:SaveAndReopenin ppo and page labels;OpenRaw/OpenBytesin signatures;Openin outline and page residency;epdf_layer;WritesInPlaceAreNotSeen;OpenPlainBytes).reads-dont-write: taking a stamp's drawing from another document's page (EPDFDoc_CanonicalDrawing,EPDFAnnot_SetAppearanceFromPage) wrote to that source document. It took the page throughGetMutablePageDictionary()and added a temporary form object, then deleted it. On a layer source, the page was copied into the layer and two object numbers were used up.ImportPageAsDrawing()now reads the page const and builds the temporary form as a stream no document holds.EPDFStampResizeEmbedderTest.ADrawingFromALayersPageLeavesTheLayerAlone. Before the fix it fails with 1 promoted object, and the last number goes from 4 to 6.EPDFPageResidencyEmbedderTest.CountsWhileParsingbuilt its page throughGetMutablePageDictionary(). It now builds it asFPDF_LoadPage()does.AStampFromAPageLeavesTheDocumentInfoAlonerelied on the/InfothatFPDF_CreateNewDocument()makes. It now writes/InfowithEPDF_SetMetaText().testing/embedpdf_layer_mode_writers.txtby hand. They are new documents, fixtures that write, and reopened saves the tests write into. For every test that closes more than one document, I checked each document's count: the documents a test only reads leave 0.layer-moderule namesNewTestDocument()and says when a test stays plain.reads-dont-writelists the new guard test.Testing (macOS arm64, debug)
run_layer_mode.pyover all 1760 tests: no new errors.testing/embedpdf_layer_mode_expectations.txt. Almost all of these are the form-fill suites.EPDFSignatureEmbedderTest.SignEncryptedDocument, which is local-only: its fixture is untracked, so the test skips on CI. It is left out of the writers list.pdfium_embeddertests: 1742 pass, 13 fail.FPDFProgressiveRenderEmbedderTest×8,FPDFViewEmbedderTest.Render*×2,FPDFEditEmbedderTest.SetTextRenderModeandEPDFMeasureEmbedderTest.CaptionAppearanceGolden.EPDFSlicedLoadEmbedderTest.SlicesKeepToTheirBudget, a timing bound that missed while the machine's load average was about 200. In a plain run its document opens as before.pdfium_unittests: 1312 pass.check-fork-tags.py --strictandcheck-c-api.pypass.The Linux Docker suites and layer mode run in CI.