image_viewer: Cover pinch zoom in the PDF interaction test

Assert that a pinch gesture scales the PDF zoom by the gesture delta,
pinning the on_pinch wiring across real event dispatch.
This commit is contained in:
yenru0 committed 2026-10-03 21:14:03 +09:00
1 parent 157c4646bb
commit 67b9fe8b73
1 file changed
+16
+16
View File
@@ -5840,6 +5840,22 @@ mod tests {
offset_h.x >= -cx.read(|cx| image_view.read(cx).pdf_scroll_handle.max_offset().x),
"horizontal pan should stay within the scrollable range"
);
// Trackpad pinch zooms around the touch point by the gesture delta.
let zoom_before_pinch = cx.read(|cx| image_view.read(cx).zoom_level);
cx.simulate_event(PinchEvent {
position: anchor,
delta: 0.5,
modifiers: Modifiers::default(),
phase: TouchPhase::Moved,
});
cx.run_until_parked();
let zoom_after_pinch = cx.read(|cx| image_view.read(cx).zoom_level);
assert!(
(zoom_after_pinch - zoom_before_pinch * 1.5).abs() < 1e-3,
"pinch delta 0.5 should scale zoom by 1.5x, got {zoom_before_pinch} -> {zoom_after_pinch}"
);
}
#[gpui::test]