mirror of
https://github.com/storytold/gridcraft.git
synced 2026-10-28 04:36:51 -06:00
* 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
44 lines
2.0 KiB
Rust
44 lines
2.0 KiB
Rust
//! Interface size preference (#230): a persistent zoom for the whole window, clamped.
|
|
|
|
use gridcraft_engine::Session;
|
|
use gridcraft_ui_egui::{SheetApp, UiState};
|
|
use serde_json::json;
|
|
|
|
#[test]
|
|
/// Interface size applies and persists, clamps to 75-200, accepts `auto`, and rejects missing or non-numeric values.
|
|
fn interface_size_applies_persists_and_clamps() {
|
|
let mut session = Session::new();
|
|
session.new_workbook();
|
|
let mut h = crate::common::builder().with_size(egui::vec2(1200.0, 800.0)).build_ui_state(
|
|
|ui, app: &mut SheetApp| {
|
|
app.logic(ui.ctx());
|
|
app.ui(ui);
|
|
},
|
|
crate::common::app(session),
|
|
);
|
|
h.run_steps(2);
|
|
assert_eq!(h.ctx.zoom_factor(), 1.0);
|
|
|
|
h.state_mut().run("view.interfaceScale", json!({"percent": 125})).unwrap();
|
|
h.run_steps(2);
|
|
assert_eq!(h.ctx.zoom_factor(), 1.25);
|
|
let saved: UiState = serde_json::from_str(&serde_json::to_string(&h.state().ui).unwrap()).unwrap();
|
|
assert_eq!(saved.interface_scale, 125);
|
|
|
|
// Hostile and missing values: clamped or refused, never applied raw.
|
|
assert_eq!(h.state_mut().run("view.interfaceScale", json!({"percent": 1e12})).unwrap()["percent"], 200);
|
|
assert_eq!(h.state_mut().run("view.interfaceScale", json!({"percent": -5})).unwrap()["percent"], 75);
|
|
assert!(h.state_mut().run("view.interfaceScale", json!({})).is_err(), "no value is an error, not a dialog");
|
|
assert!(h.state_mut().run("view.interfaceScale", json!({"percent": "huge"})).is_err());
|
|
h.state_mut().run("view.interfaceScale", json!({"percent": "auto"})).unwrap();
|
|
h.run_steps(2);
|
|
assert_eq!(h.ctx.zoom_factor(), 1.0);
|
|
|
|
// A malformed or out-of-range ui.json keeps the other preferences.
|
|
let ui: UiState = serde_json::from_str(r#"{"dark": true, "interfaceScale": "big"}"#).unwrap();
|
|
assert!(ui.dark);
|
|
assert_eq!(ui.interface_scale, 100);
|
|
let ui: UiState = serde_json::from_str(r#"{"interfaceScale": 900}"#).unwrap();
|
|
assert_eq!(ui.interface_scale, 200);
|
|
}
|