Files
gridcraft/crates/ui-egui/tests/it/status_bar_menu.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

61 lines
2.2 KiB
Rust

//! Right-clicking the status bar opens a menu that turns its selection statistics on and off.
use egui::{Event, Modifiers, PointerButton, Pos2, pos2, vec2};
use egui_kittest::kittest::Queryable;
use gridcraft_engine::Session;
use gridcraft_ui_egui::SheetApp;
use serde_json::json;
type Harness = egui_kittest::Harness<'static, SheetApp>;
fn harness() -> Harness {
let mut session = Session::new();
session.new_workbook();
for (cell, input) in [("A1", "4"), ("A2", "-1"), ("A3", "9")] {
session.execute("cell.set", json!({"cell": cell, "input": input})).unwrap();
}
session.execute("selection.set", json!({"range": "A1:A3"})).unwrap();
let mut h = crate::common::builder().with_size(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(4);
h
}
fn right_click(h: &mut Harness, pos: Pos2) {
h.input_mut().events.push(Event::PointerMoved(pos));
h.run_steps(1);
for pressed in [true, false] {
h.input_mut().events.push(Event::PointerButton { pos, button: PointerButton::Secondary, pressed, modifiers: Modifiers::NONE });
h.run_steps(1);
}
h.run_steps(3);
}
#[test]
fn right_clicking_the_status_bar_turns_on_minimum() {
let mut h = harness();
assert!(h.query_by_label("Sum: 12").is_some(), "Sum is on by default");
assert!(h.query_by_label("Minimum: -1").is_none(), "Minimum is off by default");
// An empty stretch of the 26-point status bar, between the mode text and the statistics.
right_click(&mut h, pos2(300.0, 787.0));
h.get_by_label("Minimum").click();
h.run_steps(4);
assert!(h.state().session.prefs.status_bar.minimum);
assert!(h.query_by_label("Minimum: -1").is_some(), "the status bar shows the minimum of the selection");
}
#[test]
fn right_clicking_the_status_bar_text_opens_the_menu() {
for text in ["Sum: 12", "Ready"] {
let mut h = harness();
let pos = h.get_by_label(text).rect().center();
right_click(&mut h, pos);
assert!(h.query_by_label("Numerical Count").is_some(), "a right-click on {text:?} opens the statistics menu");
}
}