Expand description
A headless test driver for any game on the engine (game ADR-0007 layer 4):
scripted key and controller-button presses and waits in, in frames of
1/60 s or by a tick stage’s fixed steps (Harness::steps), screen
names, snapshots and the audio asked for out. No window,
no clock, no sound card: it runs the game in an App on the
HeadlessPlatform, through the same frame the devices run, and the
headless backend’s Speaker says what music
sounds, so a screen that keeps time with the music is tested too.
A game wraps it with its own start-up and lookups (its flow, its
battle); the scripts are the same for every game. With the harness
feature.
use shuyi_platform::harness::Harness;
use shuyi_ui::toy;
let mut h = Harness::new(toy::game());
h.keys("f");
assert_eq!(h.screens(), ["home", "menu"]);
h.keys("f");
assert_eq!(h.sounds(), ["click"]);Harness::new takes a game already running. Harness::start runs it
from its real Start, card and load first, as a device does;
Harness::start_recording records that run (session),
and Harness::from_session plays such a record to any frame
(play_to).
Re-exports§
pub use crate::script::FRAME_DT;
Structs§
- Harness
- Drives a
Gamewith simulated key presses and time, as the platform would: in anApp, on theHeadlessPlatform.
Constants§
- MAX_
FRAMES - Most frames one
Harness::holdorHarness::waitmay run (about half a simulated minute), so a runaway script fails instead of hanging. - MAX_
WAIT - The longest wait of one step of a
Scriptthe Harness plays, in seconds:MAX_FRAMESframes.
Functions§
- assert_
session - A test that the session record at
pathplays fromstartwith no difference (check_session). With the environment variableSHUYI_BLESS=1it writes the file again instead (bless_session). - bless_
session - The session record in
textmade again fromstart: every frame played, differences and all, and recorded. The same inputs, this build’s stamp and hashes. The error says why it can’t be played, or that this build reads the platform differently, so its inputs are no longer the record’s. - check_
session - Plays the session record in
textfromstart, stamps checked, to its end (Harness::from_session). The error says why it can’t be played, or names the first frame that played differently.