1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-31 05:40:03 -04:00

Make sure egui can handle zero-sized screen rect

This would previously hit a debug assert

Fixes https://github.com/emilk/egui/issues/395
This commit is contained in:
Emil Ernerfeldt
2021-05-17 22:53:52 +02:00
parent 6e5b52e3bc
commit dd4ac43b13
2 changed files with 25 additions and 1 deletions

View File

@@ -139,3 +139,22 @@ fn test_egui_e2e() {
assert!(!clipped_meshes.is_empty());
}
}
#[test]
fn test_egui_zero_window_size() {
let mut demo_windows = crate::DemoWindows::default();
let mut ctx = egui::CtxRef::default();
let raw_input = egui::RawInput {
screen_rect: Some(egui::Rect::from_min_max(egui::Pos2::ZERO, egui::Pos2::ZERO)),
..Default::default()
};
const NUM_FRAMES: usize = 5;
for _ in 0..NUM_FRAMES {
ctx.begin_frame(raw_input.clone());
demo_windows.ui(&ctx);
let (_output, shapes) = ctx.end_frame();
let clipped_meshes = ctx.tessellate(shapes);
assert!(clipped_meshes.is_empty(), "There should be nothing to show");
}
}