Avoid rendering demo photos in Settings keyboard trials

This commit is contained in:
skylartaylor committed 2026-11-30 20:09:51 +01:00
1 parent d6b2dae93d
commit 0128f2fa04
3 files changed
+21 -18

No files matched your search

@@ -18,8 +18,9 @@ fn steps(h: &mut Headless) {
}
}
fn demo() -> Headless {
let mut h = Headless::new(LightcraftApp::new(lightcraft_engine::Session::with_demo(), Services::default()), [1400.0, 1100.0], 1.0);
fn fixture() -> Headless {
// Use a real in-memory session without rendering demo photos.
let mut h = Headless::new(LightcraftApp::new(lightcraft_engine::Session::new(), Services::default()), [1400.0, 1100.0], 1.0);
assert!(h.settle(T));
h
}
@@ -77,7 +78,7 @@ fn clear_focus(h: &mut Headless) {
#[test]
fn escape_with_no_focus_closes_real_settings() {
let mut h = demo();
let mut h = fixture();
show(&mut h, "import");
clear_focus(&mut h);
key(&mut h, "Escape");
@@ -86,7 +87,7 @@ fn escape_with_no_focus_closes_real_settings() {
#[test]
fn escape_cancels_a_focused_library_text_draft_before_closing_settings() {
let mut h = demo();
let mut h = fixture();
show(&mut h, "import");
let before = copyright(&mut h);
replace(&mut h, "field:settings.copyright", "Uncommitted Settings Contract");
@@ -103,7 +104,7 @@ fn escape_cancels_a_focused_library_text_draft_before_closing_settings() {
#[test]
fn return_applies_text_and_close_is_not_a_transaction_cancel() {
let mut h = demo();
let mut h = fixture();
show(&mut h, "import");
assert!(!h.app.widgets.iter().any(|(w, _)| w == "button:dialogCancel"), "Settings has Close, not Cancel");
replace(&mut h, "field:settings.copyright", "Committed Settings Contract");
@@ -126,7 +127,7 @@ fn return_applies_text_and_close_is_not_a_transaction_cancel() {
#[test]
fn tab_and_shift_tab_reach_real_import_controls_and_the_close_footer() {
let mut h = demo();
let mut h = fixture();
show(&mut h, "import");
clear_focus(&mut h);
let mut order = Vec::new();
@@ -174,7 +175,7 @@ fn tab_and_shift_tab_reach_real_import_controls_and_the_close_footer() {
#[test]
fn escape_after_a_keyboard_reached_checkbox_closes_settings() {
let mut h = demo();
let mut h = fixture();
show(&mut h, "import");
clear_focus(&mut h);
for _ in 0..64 {
@@ -17,8 +17,9 @@ fn ask(h: &mut Headless, method: &str, params: Value) {
assert_eq!(r["ok"], true, "{method}: {r}");
steps(h);
}
fn demo() -> Headless {
let mut h = Headless::new(LightcraftApp::new(lightcraft_engine::Session::with_demo(), Services::default()), [1400.0, 1100.0], 1.0);
fn fixture() -> Headless {
// Use a real in-memory session without rendering demo photos.
let mut h = Headless::new(LightcraftApp::new(lightcraft_engine::Session::new(), Services::default()), [1400.0, 1100.0], 1.0);
assert!(h.settle(T));
ask(&mut h, "engine.execute", json!({"command":"app.settings","params":{"tab":"import"}}));
h
@@ -47,7 +48,7 @@ fn raw_tab(shift: bool, pressed: bool) -> egui::Event {
#[test]
fn a_raw_batch_of_tab_presses_and_releases_moves_once_per_press_in_its_own_direction() {
let mut h = demo();
let mut h = fixture();
ask(&mut h, "ui.clickWidget", json!({"id":"field:settings.copyright"}));
assert_eq!(focused(&h).as_deref(), Some("field:settings.copyright"));
// The framework moves the focus once for each Tab press of a batch: two forward presses walk two stops.
@@ -71,7 +72,7 @@ fn a_raw_batch_of_tab_presses_and_releases_moves_once_per_press_in_its_own_direc
#[test]
fn modified_tab_leaves_a_real_text_draft_with_its_owner() {
let mut h = demo();
let mut h = fixture();
let before = h.app.session.import_defaults.copyright.clone();
ask(&mut h, "ui.clickWidget", json!({"id":"field:settings.copyright"}));
ask(&mut h, "ui.text", json!({"text":"Modified Tab Draft"}));
@@ -87,7 +88,7 @@ fn modified_tab_leaves_a_real_text_draft_with_its_owner() {
#[test]
fn an_open_preset_combo_closes_on_tab_and_escape_stays_out_of_the_settings_page() {
let mut h = demo();
let mut h = fixture();
let before = h.app.session.import_defaults.clone();
ask(&mut h, "ui.clickWidget", json!({"id":"combo:settingsRawPreset"}));
assert!(popup_open(&h));
@@ -108,7 +109,7 @@ fn an_open_preset_combo_closes_on_tab_and_escape_stays_out_of_the_settings_page(
#[test]
fn changing_the_settings_tab_drops_the_old_field_and_disabled_chooser_is_not_a_stop() {
let mut h = demo();
let mut h = fixture();
ask(&mut h, "ui.clickWidget", json!({"id":"field:settings.copyright"}));
ask(&mut h, "ui.text", json!({"text":"Tab Switch Draft"}));
ask(&mut h, "ui.clickWidget", json!({"id":"button:settingsTab-general"}));
@@ -129,7 +130,7 @@ fn changing_the_settings_tab_drops_the_old_field_and_disabled_chooser_is_not_a_s
#[test]
fn a_tab_consumed_before_a_replacement_dialog_does_not_leak_to_its_fields() {
let mut h = demo();
let mut h = fixture();
ask(&mut h, "ui.clickWidget", json!({"id": "field:settings.copyright"}));
let mut replaced = false;
h.set_after_raw_input_hook(move |app| {
@@ -169,7 +170,7 @@ fn reach(h: &mut Headless, name: &str) {
#[test]
fn coalesced_tab_then_enter_activates_the_new_real_sidecar_choice() {
let mut h = demo();
let mut h = fixture();
ask(&mut h, "ui.clickWidget", json!({"id":"button:settingsXmpNaming-0"}));
reach(&mut h, "button:settingsXmpNaming-0");
let enter = |pressed| egui::Event::Key {
@@ -190,7 +191,7 @@ fn coalesced_tab_then_enter_activates_the_new_real_sidecar_choice() {
#[test]
fn coalesced_tab_then_text_goes_to_the_field_the_tab_moved_to() {
let mut h = demo();
let mut h = fixture();
let copyright = h.app.session.import_defaults.copyright.clone();
ask(&mut h, "ui.clickWidget", json!({"id":"field:settings.copyright"}));
h.events.extend([raw_tab(false, true), raw_tab(false, false), egui::Event::Text("Coalesced Creator Draft".into())]);
@@ -212,7 +213,7 @@ fn coalesced_tab_then_text_goes_to_the_field_the_tab_moved_to() {
#[test]
fn held_tab_repeat_moves_once_per_real_render_without_release_activation() {
let mut h = demo();
let mut h = fixture();
ask(&mut h, "ui.clickWidget", json!({"id":"field:settings.copyright"}));
h.events.push(raw_tab(false, true));
h.step();
@@ -36,7 +36,8 @@ fn snapshot(h: &Headless) -> Value {
json!({"focusId":id.map(|id|format!("{id:?}")),"focusNames":names,"response":response.map(|r|json!({"id":format!("{:?}",r.id),"layer":format!("{:?}",r.layer_id),"sense":format!("{:?}",r.sense),"enabled":r.enabled(),"rect":[r.rect.min.x,r.rect.min.y,r.rect.max.x,r.rect.max.y]})),"popupOpen":popup_open(h),"dialog":format!("{:?}",h.app.ui.dialog),"rawPreset":h.app.session.import_defaults.raw_preset,"otherPreset":h.app.session.import_defaults.other_preset,"perCamera":h.app.session.import_defaults.per_camera})
}
fn probe(key: &str, tab_first: bool) {
let mut h = Headless::new(LightcraftApp::new(lightcraft_engine::Session::with_demo(), Services::default()), [1400.0, 1100.0], 1.0);
// Use a real in-memory session without rendering demo photos.
let mut h = Headless::new(LightcraftApp::new(lightcraft_engine::Session::new(), Services::default()), [1400.0, 1100.0], 1.0);
assert!(h.settle(T));
ask(&mut h, "engine.execute", json!({"command":"app.settings","params":{"tab":"import"}}));
let before = snapshot(&h);