Files
gridcraft/crates/ui-egui/tests/common/mod.rs
T
skylar taylor-barrick 41769f1d16 Migrate GridCraft to egui 0.37 (#2543)
* E37: migrate GridCraft to egui 0.37

Pin the reviewed fork and shared dependencies, adapt input and rendering to the
new frame lifecycle, and preserve bounded capture handling and font notices.
Add representative accessibility checks and meaningful control labels.

Validation: full repository CI passed all ten stages, with 2,249 tests passed,
zero failed and one existing timing test ignored. Native workflows and paired
performance qualification remain documented separately.

* egui037: record final published pins and local qualification

* M0.37: fix RTL clipping and preserve screenshot budgets

* test: share migrated GridCraft UI harness setup

* egui037: document migrated UI and regression contracts

* egui-037: align popup test fonts and avoid redundant tooltip probes
2026-10-25 14:55:00 -04:00

58 lines
2.3 KiB
Rust
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
//! The shared strict test harness: bundled faces plus the pinned craft-fonts input, never the
//! host's installed fonts.
//!
//! `egui_kittest` keeps `MissingGlyphPolicy::Panic` and accessibility checks on. The production
//! font set probes system fonts for scripts a workstation may lack; the suite must not, or a
//! minimal CI image would fail for a reason unrelated to the change under test. `CRAFT_FONTS_DIR`
//! is the pinned input (never a font copy in this repository); without it only egui's bundled
//! faces are installed and the non-Latin language cases are skipped explicitly in the one test
//! that renders every catalog.
use egui_kittest::HarnessBuilder;
use gridcraft_engine::Session;
use gridcraft_ui_egui::{Services, SheetApp};
pub type Harness = egui_kittest::Harness<'static, SheetApp>;
/// A kittest builder with the deterministic font set and GridCraft's visuals installed.
pub fn builder<State>() -> HarnessBuilder<State> {
egui_kittest::Harness::builder().with_context_setup(|ctx| {
ctx.set_fonts(gridcraft_ui_egui::theme::pinned_font_definitions());
gridcraft_ui_egui::theme::apply(ctx, false);
})
}
/// A test app whose first `logic` pass keeps the harness's pinned font set.
pub fn app(session: Session) -> SheetApp {
prepare(SheetApp::new(session, Services::default()))
}
/// Mark `app` as already using the harness's pinned font set.
pub fn prepare(mut app: SheetApp) -> SheetApp {
app.use_prepared_fonts();
app
}
/// Drive `app`'s `logic` then `ui` each frame in a harness built with `builder`.
///
/// Tests that need a non-standard size, step timing, OS or pixel ratio configure the builder
/// here so those details stay explicit; the shared font and lifecycle setup lives in `builder`
/// and `app`.
pub fn harness_with(builder: HarnessBuilder<SheetApp>, app: SheetApp, steps: usize) -> Harness {
let mut h = builder.build_ui_state(
|ui, app: &mut SheetApp| {
let ctx = ui.ctx().clone();
app.logic(&ctx);
app.ui(ui);
},
app,
);
h.run_steps(steps);
h
}
/// A 1200×800 harness that reports `os` to egui, for platform-specific input.
pub fn os_harness(session: Session, os: egui::os::OperatingSystem) -> Harness {
harness_with(builder().with_os(os).with_size(egui::vec2(1200.0, 800.0)), app(session), 4)
}