ui-egui tests: clear the texture deltas of the frames they run (#4039)
Nine tests dropped an egui frame's output with its texture delta still unapplied (the expression completion editor's frames, the slot preview's three, the browser's feature rows). epaint asserts against that in debug builds, so they failed under the dev profile and passed only where debug assertions are off. They clear the delta as the other tests do; one more hover test that dropped its output the same way does too.
This commit is contained in:
@@ -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()
|
||||
}
|
||||
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user