>()
);
}
#[test]
fn long_text_run_wraps_across_multiple_lines() {
// A long single text node with no inline elements breaking it up must
// wrap within a narrow container instead of overflowing on one line. The
// container's height is the mode-independent proof: several wrapped lines
// make it much taller than one line, whether text is shaped by cosmic-text
// (paint) or split into word boxes (layout-only).
let html = r##"This sentence has plenty of words to wrap across several lines
"##;
let tree = parse_html(html);
let layout = layout_dom(&tree, (1000.0, 1000.0));
// Tightest element enclosing the text: the 100px div itself.
let mut div_rect: Option = None;
for (id, rect) in &layout.rects {
if tree.text_content(*id).contains("several lines") {
if div_rect.as_ref().map(|d| rect.width * rect.height < d.width * d.height).unwrap_or(true) {
div_rect = Some(*rect);
}
}
}
let div_rect = div_rect.expect("text container laid out");
assert!(div_rect.width <= 101.0, "container should hold its 100px width, got {}", div_rect.width);
assert!(
div_rect.height > 60.0,
"text should wrap onto several lines in a 100px-wide box (tall container), got height {}",
div_rect.height
);
}