From 35b5abd5b3c73d47c2fac71277d659d185001a2a Mon Sep 17 00:00:00 2001 From: aiongg Date: Thu, 22 Oct 2026 21:42:02 +0000 Subject: [PATCH] test(engine): show the truncated-page picture exports within a sufficient budget The fixture's image stream held six bytes under /Length 4, and the test only checked that the picture was missing at a zero budget, which a picture that could not be prepared also passes. The stream is four bytes, and the picture is first shown to export at a 1 MiB budget. --- crates/engine/src/tests.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index 3df5279ab5..afe6fd06c2 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -7293,7 +7293,7 @@ fn a_page_truncated_for_forms_and_pictures_is_listed_once() { "<< /Type /Catalog /Pages 2 0 R >>".into(), "<< /Type /Pages /Kids [3 0 R] /Count 1 /MediaBox [0 0 200 200] >>".into(), String::new(), - "<< /Type /XObject /Subtype /Image /Width 2 /Height 2 /ColorSpace /DeviceGray /BitsPerComponent 8 /Length 4 >>\nstream\n\0\x40\u{80}\u{ff}\nendstream".into(), + "<< /Type /XObject /Subtype /Image /Width 2 /Height 2 /ColorSpace /DeviceGray /BitsPerComponent 8 /Length 4 >>\nstream\n\0\x20\x40\x7f\nendstream".into(), "<< /Length 34 >>\nstream\nq 10 0 0 10 0 0 cm /Im Do Q /D1 Do\nendstream".into(), ]; // Forms D1..D{depth}, objects 6 onwards, each drawing the next. @@ -7323,6 +7323,8 @@ fn a_page_truncated_for_forms_and_pictures_is_listed_once() { let id = s.open("both.pdf", None, Arc::new(bytes), None).unwrap(); let doc = s.get(id).unwrap(); assert_eq!(doc.export_pages_checked(false, 0).1, [0], "the forms alone truncate the page"); + let (exported, _) = doc.export_pages_checked(true, 1 << 20); + assert_eq!(exported[0].images.len(), 1, "the picture exports within a sufficient budget"); let (pages, truncated) = doc.export_pages_checked(true, 0); assert!(pages[0].images.is_empty(), "the picture is past the budget"); assert_eq!(truncated, [0]);