//! Whether measuring a widget and then giving it the length it reported is a //! fixed point, which is what a span that sizes to its children needs. use iris::harness::Harness; use iris::prelude::*; #[test] fn a_wrapping_text_in_a_span_settles_on_one_width() { let mut h = Harness::new((900, 600)); let words = "the quick brown fox jumps over the lazy dog and keeps on running \ until it reaches the end of a rather long line of text"; let t = wtext(words).size(16).wrap(true).add(&mut h.rsc); let filler = rect(Color::BLUE).add(&mut h.rsc); h.set_root((t, filler).span(Dir::RIGHT)); let mut widths = Vec::new(); for _ in 0..6 { let r = h.region(&t.id()).unwrap(); widths.push(r.bot_right.x - r.top_left.x); // Redrawing it changes nothing about the state, so nothing may move. h.rsc.widgets_mut().get_dyn_mut(t.id()); h.frame(); } println!("widths over six frames: {widths:?}"); assert!( widths.windows(2).all(|w| w[0] == w[1]), "a repaint that changed nothing moved it: {widths:?}" ); }