Skip to content

SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.

Shell: test the interface scale raised in a narrow window, the crash #9271 fixed (#9315)

semmelrinde37dc878f3111
diff --git a/crates/ui-egui/src/shell_tests.rs b/crates/ui-egui/src/shell_tests.rs
index d93d17bd0b..6a5b5064ce 100644
--- a/crates/ui-egui/src/shell_tests.rs
+++ b/crates/ui-egui/src/shell_tests.rs
@@ -1211,3 +1211,21 @@ fn content_outside_a_shrunk_viewport_gives_way_to_the_viewport() {
assert!(free.min.x.is_finite() && free.min.y.is_finite(), "{free:?}");
}
}
+
+/// The interface scale raised after a click at the top of a narrow window (found by a UI fuzzer
+/// and shrunk to these three steps): the content kept from the frame before lay outside the new
+/// viewport, and the next frame's layout panicked clamping into it (`min = 264.0, max =
+/// 165.28125`).
+#[test]
+fn a_larger_interface_scale_in_a_narrow_window_keeps_drawing() {
+ let mut h = Harness::new();
+ for step in [
+ json!({"call": "ui.resize", "params": {"width": 330.5693343218654, "height": 1445.8773151935186}}),
+ json!({"click": [206.1875, 17.0]}),
+ json!({"call": "ui.prefs", "params": {"ui_scale": 2.0}}),
+ ] {
+ h.step(&step).unwrap();
+ }
+ h.frames(3);
+ assert!(h.app.viewport.rect.unwrap().is_positive());
+}