mirror of
https://github.com/storytold/gridcraft.git
synced 2026-11-09 20:09:57 -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
66 lines
2.7 KiB
Rust
66 lines
2.7 KiB
Rust
//! A host that embeds the sheet in its own window can turn off the app's title bar and File tab.
|
|
|
|
use egui_kittest::kittest::Queryable as _;
|
|
use gridcraft_engine::Session;
|
|
use gridcraft_ui_egui::{Chrome, Services, SheetApp, backstage::Page};
|
|
|
|
fn harness(chrome: Chrome) -> egui_kittest::Harness<'static, SheetApp> {
|
|
let mut session = Session::new();
|
|
session.new_workbook();
|
|
let mut app = crate::common::prepare(SheetApp::new(session, Services::default()));
|
|
app.chrome = chrome;
|
|
let mut h = crate::common::builder().with_size(egui::vec2(1200.0, 800.0)).build_ui_state(
|
|
|ui, app: &mut SheetApp| {
|
|
let ctx = ui.ctx().clone();
|
|
app.logic(&ctx);
|
|
app.ui(ui);
|
|
},
|
|
app,
|
|
);
|
|
h.run_steps(4);
|
|
h
|
|
}
|
|
|
|
#[test]
|
|
fn the_title_bar_and_file_tab_are_drawn_by_default() {
|
|
let h = harness(Chrome::default());
|
|
assert!(h.query_by_label("AutoSave").is_some(), "the title bar is drawn");
|
|
assert!(h.query_by_label("File").is_some(), "the File tab is drawn");
|
|
}
|
|
|
|
#[test]
|
|
fn a_host_can_leave_out_the_title_bar_and_the_file_tab() {
|
|
let full = harness(Chrome::default());
|
|
let h = harness(Chrome { title_bar: false, file_tab: false });
|
|
assert!(h.query_by_label("AutoSave").is_none(), "no title bar");
|
|
assert!(h.query_by_label("File").is_none(), "no File tab");
|
|
// The ribbon tabs are painted text, so measure the move with the first ribbon control.
|
|
let (with_bar, without) = (full.get_by_label("Paste").rect(), h.get_by_label("Paste").rect());
|
|
let moved = with_bar.min.y - without.min.y;
|
|
assert!((25.0..=40.0).contains(&moved), "the ribbon moves up by the title bar's height (28 on macOS, 38 elsewhere), moved {moved}");
|
|
assert_eq!(with_bar.min.x, without.min.x, "the ribbon's groups keep their place across");
|
|
}
|
|
|
|
#[test]
|
|
fn without_the_file_tab_the_backstage_view_never_opens() {
|
|
let mut h = harness(Chrome { title_bar: true, file_tab: false });
|
|
h.state_mut().open_backstage(Page::Home);
|
|
h.run_steps(3);
|
|
assert!(h.state().backstage.is_none(), "opening Backstage directly is ignored");
|
|
h.state_mut().open_backstage(Page::Print);
|
|
h.run_steps(3);
|
|
assert!(h.state().backstage.is_none(), "so is every page, Print and Save As included");
|
|
assert!(h.query_by_label("AutoSave").is_some(), "the title bar can stay on its own");
|
|
}
|
|
|
|
#[test]
|
|
fn turning_the_file_tab_off_closes_an_open_backstage() {
|
|
let mut h = harness(Chrome::default());
|
|
h.state_mut().open_backstage(Page::Home);
|
|
h.run_steps(3);
|
|
assert!(h.state().backstage.is_some(), "Backstage opens with the File tab on");
|
|
h.state_mut().chrome.file_tab = false;
|
|
h.run_steps(3);
|
|
assert!(h.state().backstage.is_none(), "and closes when the host turns the File tab off");
|
|
}
|