diff --git a/crates/menu/tests/it/ribbon.rs b/crates/menu/tests/it/ribbon.rs index 8945ec2cf..9129ca36c 100644 --- a/crates/menu/tests/it/ribbon.rs +++ b/crates/menu/tests/it/ribbon.rs @@ -135,10 +135,9 @@ fn a_collapsed_groups_popover_stays_open_while_a_child_popup_is_used() { let tabs = [RibbonTab::new(0_usize, "Home")]; let entries = [Entry::new(1_usize, "Keep text only"), Entry::new(2, "Paste values")]; let _ = Ribbon::new("Ribbon", &tabs, Bind::given(0_usize)).show(ui, |row, _| { - // The clipboard group is too wide to show whole beside the wide group's least, so the fit leaves it - // collapsed; its content alone still fits the room, so its popover shows whole. + // Every control is stacked, so the clipboard group is as wide at the compact level as at the full one. row.group(RibbonGroup::new("clip", "Clipboard", IconId::new("list").into()), |ui| { - if let Some(entry) = SplitButton::new("Paste", &entries).show(ui).chosen { + if let Some(entry) = SplitButton::new("Paste", &entries).arrangement(Arrangement::Stacked).show(ui).chosen { seen.borrow_mut().push(entry); } for label in &WIDE[..4] { @@ -148,7 +147,13 @@ fn a_collapsed_groups_popover_stays_open_while_a_child_popup_is_used() { group(row, "wide", "Wide", &WIDE); }); }); - fixture.room(vec2(400.0, 300.0)); + // The room is the clipboard group's own width and a little more, measured where both groups show whole: its content + // alone fits, so its popover shows whole, but not beside the wide group's least, so the fit collapses it. Measured, + // not a fixed room, so the trial does not hang on the buttons' padding. + fixture.room(vec2(2000.0, 300.0)); + fixture.settle(); + let whole = fixture.by_label("Clipboard").expect("the clipboard group shows whole in a wide room").rect.width(); + fixture.room(vec2(whole + 8.0, 300.0)); fixture.settle(); assert!(fixture.by_label("Paste").is_none(), "the group is collapsed"); let button = fixture.by_label("Clipboard").expect("the collapsed group's button"); @@ -158,7 +163,7 @@ fn a_collapsed_groups_popover_stays_open_while_a_child_popup_is_used() { fixture.key(Key::Enter, Modifiers::NONE).idle(3); assert_eq!(picked.borrow().clone(), vec![1], "the split button's menu picked its first row"); assert!(fixture.by_label("Paste").is_some(), "the group's popover is still open after a pick from a menu opened inside it"); - fixture.click_at(Pos2::new(395.0, 295.0)).idle(3); + fixture.click_at(Pos2::new(whole + 3.0, 295.0)).idle(3); assert!(fixture.by_label("Paste").is_none(), "a press outside closes the popover"); } diff --git a/crates/menu/tests/it/ribbon_gallery.rs b/crates/menu/tests/it/ribbon_gallery.rs index 3e316f8a7..547d59946 100644 --- a/crates/menu/tests/it/ribbon_gallery.rs +++ b/crates/menu/tests/it/ribbon_gallery.rs @@ -71,9 +71,9 @@ fn the_tile_count_follows_the_group_level_and_stepping_stays_in_range_when_the_i assert_eq!(*picks.borrow(), vec![1], "a click on a tile picks its key"); } -/// The tiles' rects and the painted texts of a gallery of three, square and uncaptioned or two to one and named under -/// each picture. -fn tiles(wide: bool) -> (Vec, Vec) { +/// The tiles' rects and the painted texts (with their rects) of a gallery of three, square and uncaptioned or two to +/// one and named under each picture. +fn tiles(wide: bool) -> (Vec, Vec<(String, Rect)>) { let mut fixture = Fixture::new(move |ui| { let paint = |_: &ContentPainterCx, _: Rect| {}; let items: Vec> = @@ -84,11 +84,13 @@ fn tiles(wide: bool) -> (Vec, Vec) { }); fixture.settle(); let rects = (0..3).filter_map(|at| fixture.by_label(&format!("Tile {at}")).map(|tile| tile.rect)).collect(); - (rects, fixture.texts().iter().map(|run| run.text.clone()).collect()) + (rects, fixture.texts().iter().map(|run| (run.text.clone(), run.rect)).collect()) } -/// A style gallery's tiles are twice as wide as a square one's and name their items under the pictures; a plain -/// gallery's tiles are square and show no names. +/// A style gallery's tiles are twice as wide as a square one's and name their items under the pictures, inside the +/// tile; a plain gallery's tiles are square and show no names. Every tile is as high as the strip (its column of +/// buttons), as the ribbon's gallery tiles always were, so a caption takes its line inside the tile rather than +/// making it taller. #[trial] fn a_wide_captioned_gallery_names_its_tiles_under_wide_pictures() { let (square, plain) = tiles(false); @@ -96,7 +98,10 @@ fn a_wide_captioned_gallery_names_its_tiles_under_wide_pictures() { assert_eq!((square.len(), wide.len()), (3, 3), "every tile shows"); let (square, wide) = (square[0], wide[0]); assert!(wide.width() > 1.5 * square.width(), "a two to one tile is wider: {wide:?} against {square:?}"); - assert!(wide.height() > square.height() + 0.5, "a captioned tile keeps a line for its name: {wide:?} against {square:?}"); - assert!(named.iter().any(|text| text == "Tile 0"), "a captioned tile paints its name: {named:?}"); - assert!(!plain.iter().any(|text| text == "Tile 0"), "a plain tile paints no name: {plain:?}"); + let name = named.iter().find(|(text, _)| text == "Tile 0").map(|(_, rect)| *rect); + let Some(name) = name else { panic!("a captioned tile paints its name: {named:?}") }; + assert!(wide.expand(0.5).contains_rect(name), "the name {name:?} keeps its line inside its tile {wide:?}"); + // The picture is at the tile's top, at least half as high as the square tile is wide: the name is under it. + assert!(name.min.y >= wide.min.y + square.width() / 2.0, "the name {name:?} is under the picture in {wide:?}"); + assert!(!plain.iter().any(|(text, _)| text == "Tile 0"), "a plain tile paints no name: {plain:?}"); }