test(ui): Shift-click on the Stroke weight stepper steps 10 pt (#991)

The headless panel test of #1015, kept on top of #1013's fix (#1015's
own change to the spinner is superseded by it).
This commit is contained in:
Nigel Ihza Firdausy 2026-10-11 02:06:41 +07:00 committed by bflatastic
parent 057c2ee2c1
commit 6d5fdc8a2a
1 changed files with 43 additions and 0 deletions

View File

@ -139,3 +139,46 @@ fn weight_presets_display_cleanly_in_their_native_unit() {
// Units no stroke is measured in keep the pt ladder, in points.
assert_eq!(stroke::weight_presets(Unit::Meters), stroke::weight_presets(Unit::Points));
}
/// #991: the spinner to the left of Stroke Weight honors Shift on both arrows, while a
/// normal click still steps by one point (the focused numeric field already handles Shift+↑/↓).
#[test]
fn stroke_weight_stepper_uses_ten_point_shift_steps() {
use super::tests_appearance::frame_raw;
let ctx = egui::Context::default();
crate::theme::install_fonts(&ctx);
let mut app = app_with_rect();
run(&mut app, "stroke.set", json!({"weight": 14}));
let t = texts(&ctx, &mut app, stroke::show);
let r = text_rect(&t, "Weight:");
let x = r.right() + ctx.global_style().spacing.item_spacing.x + 8.0;
let click_step = |app: &mut VectorcraftApp, y: f32, modifiers: egui::Modifiers| {
let pos = egui::pos2(x, y);
let button = |pressed| egui::Event::PointerButton {
pos,
button: egui::PointerButton::Primary,
pressed,
modifiers,
};
for event in [egui::Event::PointerMoved(pos), button(true), button(false)] {
frame_raw(
&ctx,
app,
egui::RawInput {
modifiers,
events: vec![event],
..Default::default()
},
stroke::show,
);
}
};
click_step(&mut app, r.center().y - 5.0, egui::Modifiers::SHIFT);
assert_eq!(app.session.shown_stroke().unwrap().width, 24.0);
click_step(&mut app, r.center().y + 5.0, egui::Modifiers::NONE);
assert_eq!(app.session.shown_stroke().unwrap().width, 23.0);
click_step(&mut app, r.center().y + 5.0, egui::Modifiers::SHIFT);
assert_eq!(app.session.shown_stroke().unwrap().width, 13.0);
}