test(edit): pin when revealed OCR text moves on top

A table test for `revealed_under_paint`: only invisible text with an
XObject, inline image or shading after its place moves; a filled path,
visible text or nothing after it does not. Seen to fail with the check
reduced to `invisible`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SqmHYx8FiWM5PcsoiErgp9
This commit is contained in:
KenM76andClaude Opus 5.5 committed 2026-10-30 00:46:27 -04:00
1 parent 270a11e699
commit 5a2f9273a3
1 file changed
+16
+16
View File
@@ -4550,6 +4550,22 @@ fn group_selection_refuses_incomplete_content_and_resource_budget_overruns() {
assert!(editable_objects(&doc, 0).is_err(), "an undecodable stream is refused");
}
/// Only invisible text with an XObject, inline image or shading painted after its place moves on top.
#[test]
fn revealed_text_moves_on_top_only_when_painted_over() {
let ops = pdfcraft_content::parse(b"BT (a) Tj ET q /Im Do Q BT (b) Tj ET BI /W 1 ID x EI /Sh sh").ops;
let at = |name: &str, n: usize| ops.iter().enumerate().filter(|(_, o)| o.is(name)).nth(n).map(|(i, _)| i).unwrap();
let after_bi = at("BI", 0) + 1;
assert!(revealed_under_paint(true, &ops, at("BT", 0)));
assert!(revealed_under_paint(true, &ops, at("BT", 1)), "inline image and shading after it");
assert!(revealed_under_paint(true, &ops, after_bi), "a shading after it");
assert!(!revealed_under_paint(true, &ops, ops.len()), "nothing after it");
assert!(!revealed_under_paint(true, &ops, ops.len() + 5), "past the end");
assert!(!revealed_under_paint(false, &ops, 0), "visible text stays where it is");
let text_only = pdfcraft_content::parse(b"BT (a) Tj ET 0 0 10 10 re f").ops;
assert!(!revealed_under_paint(true, &text_only, 0), "a filled path does not move it");
}
/// Revealed OCR text may have to go on top of the page; a page whose marked content nests too deep
/// for that is refused before either rewrite path changes anything.
#[test]