Skip to main content

Module testing

Module testing 

Source
Expand description

A headless driver for an App (backlog DX11). A headless driver for an App: a Core, a viewport, the app’s extensions, and the inputs a test needs to press its keys, click its nodes and read what it drew — through the real view and on_event, with no window (backlog DX11).

ⓘ
let mut d = Drive::new(Core::new(), 480.0, 320.0);
d.frame(&mut app);
let add = d.key_of("add").ok_or("no add button")?;
d.click_key(&mut app, add);
d.frame(&mut app);
assert_eq!(app.count, 1);
assert!(d.warnings().is_empty());

A gesture sends its inputs and stops; the caller frames when it wants the view to catch up. Drive::framing frames after every gesture instead, and once while a drag is held, for a test written as a list of keystrokes against what is on screen.

It owns its Core or borrows one (Drive::new(&mut core, …)), which is how the examples’ --headless drives run on the core their harness built. Events go to the app the way the runner sends them: an extension’s to the extension (Extensions::route), the rest to on_event, and each is logged.

Structs§

Drive
The headless driver; see the module docs.