diff --git a/crates/ui-egui/tests/it/viewer.rs b/crates/ui-egui/tests/it/viewer.rs index eebff9882b..20fef9629b 100644 --- a/crates/ui-egui/tests/it/viewer.rs +++ b/crates/ui-egui/tests/it/viewer.rs @@ -417,16 +417,9 @@ fn a_search_flash_preserves_following_while_an_unrelated_drag_is_held() { /// #9001: the document thumb is visibly wide at rest and can be dragged from that width. #[test] fn document_scrollbar_is_wide_at_rest_and_draggable() { - let mut h = harness(); - h.state_mut().active = Some(0); - h.run_steps(5); - let bar = h.get_by_role_and_label(egui::accesskit::Role::ScrollBar, "Vertical scroll bar").rect(); - assert!(bar.width() >= 14.0, "the document target is comfortably wide: {bar:?}"); - let thumb = h - .output() - .shapes - .iter() - .filter_map(|shape| match &shape.shape { + fn painted_thumb(shape: &egui::Shape, bar: egui::Rect) -> Option { + match shape { + egui::Shape::Vec(children) => children.iter().find_map(|child| painted_thumb(child, bar)), egui::Shape::Rect(paint) if paint.fill.a() > 0 && bar.expand(1.0).contains_rect(paint.rect) @@ -437,9 +430,15 @@ fn document_scrollbar_is_wide_at_rest_and_draggable() { Some(paint.rect) } _ => None, - }) - .next() - .expect("a full-width thumb is painted before hovering"); + } + } + + let mut h = harness(); + h.state_mut().active = Some(0); + h.run_steps(5); + let bar = h.get_by_role_and_label(egui::accesskit::Role::ScrollBar, "Vertical scroll bar").rect(); + assert!(bar.width() >= 14.0, "the document target is comfortably wide: {bar:?}"); + let thumb = h.output().shapes.iter().find_map(|shape| painted_thumb(&shape.shape, bar)).expect("a full-width thumb is painted before hovering"); let start = egui::pos2(thumb.left() + 2.0, thumb.center().y); let before = h.state().views[0].page_screen_rect(0).expect("first page visible").top(); h.hover_at(start);