mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-12-04 13:03:19 -05:00
Find the painted document thumb in its viewport paint slot
This commit is contained in:
1 parent
361654b708
commit
d24593f708
1 file changed
+12
-13
@@ -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<egui::Rect> {
|
||||
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);
|
||||
|
||||
Reference in new issue
Block a user