Skip to main content

TestSequence

Struct TestSequence 

Source
pub struct TestSequence<'a> { /* private fields */ }
Expand description

Builder returned by TestBackend::sequence.

Chain step builders (tick, key, type_string, events) and finalize with run. Steps execute sequentially, advancing FrameState between them so focus and hooks evolve naturally without the caller having to thread state.

Implementations§

Source§

impl<'a> TestSequence<'a>

Source

pub fn tick(self, f: impl FnOnce(&mut Context) + 'a) -> Self

Append a step that renders without injecting any events.

Equivalent to a single frame tick — useful for letting hooks / animations advance between input steps.

Source

pub fn key(self, code: KeyCode, f: impl FnOnce(&mut Context) + 'a) -> Self

Append a step that fires a single key-press event with no modifiers.

Source

pub fn type_string(self, s: &str, f: impl FnOnce(&mut Context) + 'a) -> Self

Append a step that types s as a sequence of KeyCode::Char events before invoking render.

Unlike TestBackend::type_string, this collapses every typed character into a single render step — useful when the per-character frame state is not the assertion target. For per-keystroke rendering, chain individual .key(...) calls.

Source

pub fn events( self, events: Vec<Event>, f: impl FnOnce(&mut Context) + 'a, ) -> Self

Append a step with an arbitrary event batch.

Useful for mouse interactions, paste events, or sequences built with EventBuilder.

Source

pub fn run(self)

Execute every queued step in order. Returns control to the caller (the TestBackend is borrowed mutably for the lifetime of the sequence builder). Use TestBackend::buffer / .frames() / .assert_* after run() returns.

Auto Trait Implementations§

§

impl<'a> Freeze for TestSequence<'a>

§

impl<'a> !RefUnwindSafe for TestSequence<'a>

§

impl<'a> !Send for TestSequence<'a>

§

impl<'a> !Sync for TestSequence<'a>

§

impl<'a> Unpin for TestSequence<'a>

§

impl<'a> UnsafeUnpin for TestSequence<'a>

§

impl<'a> !UnwindSafe for TestSequence<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.