Skip to content

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

ui-egui tests: clear the texture deltas of the frames they run (#4039)

raykholo6fb72c7401cd
diff --git a/crates/ui-egui/src/browser/features.rs b/crates/ui-egui/src/browser/features.rs
index 8177fd11fa..0e66b85fcd 100644
--- a/crates/ui-egui/src/browser/features.rs
+++ b/crates/ui-egui/src/browser/features.rs
@@ -109,7 +109,7 @@ mod tests {
h.app.tree.expanded.insert("c0/features".into());
DRAWN.with(|d| d.borrow_mut().clear());
let raw = egui::RawInput { screen_rect: Some(Rect::from_min_size(Pos2::ZERO, vec2(800.0, 600.0))), ..Default::default() };
- let _ = h.ctx.run_ui(raw, |ui| rows(&mut h.app, ui, 0, &[], 0, &mut Actions::default()));
+ h.ctx.run_ui(raw, |ui| rows(&mut h.app, ui, 0, &[], 0, &mut Actions::default())).textures_delta.clear();
drawn_rows().into_iter().map(|(label, ..)| label).collect()
}
diff --git a/crates/ui-egui/src/sketch_display_preview_tests.rs b/crates/ui-egui/src/sketch_display_preview_tests.rs
index 06e54483b4..d133e2c5c6 100644
--- a/crates/ui-egui/src/sketch_display_preview_tests.rs
+++ b/crates/ui-egui/src/sketch_display_preview_tests.rs
@@ -205,9 +205,10 @@ fn slot_preview_matches_every_committed_side_and_cap() {
.unwrap_or_else(|| panic!("{command}: no slot outline before the width click"));
let ctx = egui::Context::default();
let proj = projection(2.0);
- let output = ctx.run_ui(egui::RawInput { screen_rect: Some(proj.rect), ..Default::default() }, |ui| {
+ let mut output = ctx.run_ui(egui::RawInput { screen_rect: Some(proj.rect), ..Default::default() }, |ui| {
super::paint_preview_curve(preview.clone(), &Plane::XY, ui.painter(), &proj, egui::Stroke::new(1.5, egui::Color32::WHITE), 0);
});
+ output.textures_delta.clear();
assert_eq!(
output.shapes.iter().filter(|shape| matches!(shape.shape, egui::Shape::Path(_))).count(),
4,
@@ -248,7 +249,8 @@ fn typed_small_slot_width_preview_matches_the_final_click() {
let ctx = egui::Context::default();
let proj = projection(2_000_000.0);
let input = || egui::RawInput { screen_rect: Some(proj.rect), ..Default::default() };
- let output = ctx.run_ui(input(), |ui| super::preview(&h.app, &t, ui.painter(), &proj));
+ let mut output = ctx.run_ui(input(), |ui| super::preview(&h.app, &t, ui.painter(), &proj));
+ output.textures_delta.clear();
let paths = |output: egui::FullOutput| {
output
.shapes
@@ -270,9 +272,10 @@ fn typed_small_slot_width_preview_matches_the_final_click() {
assert_eq!(committed.curves.len(), 4, "{command}: final click commits the typed width");
let solidcraft_engine::geom::Seg2::Arc { radius, .. } = committed.segs(1)[0] else { panic!("missing slot cap") };
assert!((radius - 0.00005).abs() < 1e-10, "{command}: the typed width determines the cap radius");
- let output = ctx.run_ui(input(), |ui| {
+ let mut output = ctx.run_ui(input(), |ui| {
super::paint_preview_curve(committed.clone(), &Plane::XY, ui.painter(), &proj, egui::Stroke::new(1.5, egui::Color32::WHITE), 0);
});
+ output.textures_delta.clear();
let expected = paths(output);
assert!(!expected.is_empty(), "{command}: the zoomed cap must be visible");
assert_eq!(preview.len(), expected.len(), "{command}: preview and committed paths");
diff --git a/crates/ui-egui/src/viewport.rs b/crates/ui-egui/src/viewport.rs
index c7341bd2f2..1dbdede0bb 100644
--- a/crates/ui-egui/src/viewport.rs
+++ b/crates/ui-egui/src/viewport.rs
@@ -5911,10 +5911,12 @@ mod tests {
let modifiers = egui::Modifiers { shift, ..Default::default() };
let frame = |app: &mut SolveApp, mut events: Vec<egui::Event>| {
events.insert(0, egui::Event::ModifiersChanged(modifiers));
- let _ = ctx.run_ui(
+ ctx.run_ui(
egui::RawInput { screen_rect: Some(Rect::from_min_size(Pos2::ZERO, vec2(800.0, 600.0))), events, ..Default::default() },
|ui| show(app, ui),
- );
+ )
+ .textures_delta
+ .clear();
};
frame(&mut app, vec![egui::Event::PointerMoved(p), egui::Event::PointerButton { pos: p, button, pressed: true, modifiers }]);
let end = p + vec2(30.0, 20.0);