use super::fixture::world;
use super::screen::{Screen, press};
const STOPS: usize = 40;
fn tab() -> egui::Event {
press(egui::Key::Tab, egui::Modifiers::NONE)
}
#[test]
fn tab_walks_the_frame_control_by_control() {
let mut world = world();
let screen = Screen::new();
screen.idle(&mut world);
screen.release(&mut world);
assert_eq!(screen.focused(), None, "the released plane holds nothing");
screen.frame(&mut world, vec![tab()]);
let first = screen.focused();
assert!(first.is_some(), "Tab put the focus on a control");
screen.frame(&mut world, vec![tab()]);
assert_ne!(
screen.focused(),
first,
"a second Tab stepped on to the next control"
);
}
#[test]
fn space_presses_the_control_the_walk_reached() {
let pressed = (1..=STOPS).any(|stop| {
let mut world = world();
let screen = Screen::new();
screen.idle(&mut world);
screen.release(&mut world);
let before = world.model.is_collapsed("balls");
for _ in 0..stop {
screen.frame(&mut world, vec![tab()]);
}
screen.frame(
&mut world,
vec![press(egui::Key::Space, egui::Modifiers::NONE)],
);
world.model.is_collapsed("balls") != before
});
assert!(
pressed,
"the keyboard alone never pressed the balls fold within {STOPS} stops — \
the floor under §11's table is what makes every control operable"
);
}