Skip to main content

RobotTestRule

Struct RobotTestRule 

Source
pub struct RobotTestRule<R>
where R: Renderer,
{ /* private fields */ }
Expand description

Main robot testing rule that provides programmatic control over a real app.

This is similar to Jetpack Compose’s ComposeTestRule but for full app testing with real rendering and input simulation.

Implementations§

Source§

impl<R> RobotTestRule<R>
where R: Renderer, R::Error: Debug,

Source

pub fn new( width: u32, height: u32, renderer: R, content: impl FnMut() + 'static, ) -> Self

Create a new robot test rule with the given viewport size and app content.

The app will be launched immediately with the provided dimensions.

Source

pub fn viewport_size(&self) -> (u32, u32)

Get the current viewport size.

Source

pub fn set_viewport(&mut self, width: u32, height: u32)

Resize the viewport (simulates window resize).

Source

pub fn advance_time(&mut self, _nanos: u64)

Advance frame time by the given duration in nanoseconds.

This is useful for testing animations and time-based behaviors.

Source

pub fn wait_for_idle(&mut self)

Pump the app until it’s idle (no pending updates).

This ensures all compositions, layouts, and renders have completed.

Source

pub fn click_at(&mut self, x: f32, y: f32) -> bool

Perform a click at the given coordinates.

Returns true if the click hit a UI element, false otherwise.

Source

pub fn move_to(&mut self, x: f32, y: f32) -> bool

Move the cursor to the given coordinates.

Returns true if the move hit a UI element, false otherwise.

Source

pub fn drag(&mut self, from_x: f32, from_y: f32, to_x: f32, to_y: f32)

Perform a drag from one point to another.

This simulates a pointer down, move, and up sequence.

Source

pub fn mouse_move(&mut self, x: f32, y: f32)

Move the mouse cursor to the given coordinates.

Source

pub fn mouse_down(&mut self)

Press the mouse button.

Source

pub fn mouse_up(&mut self)

Release the mouse button.

Source

pub fn find_by_text(&mut self, text: &str) -> ElementFinder<'_, R>

Find an element by text content.

Returns a finder that can be used to interact with or assert on the element.

Source

pub fn find_at_position(&mut self, x: f32, y: f32) -> ElementFinder<'_, R>

Find an element at the given position.

Returns a finder for the topmost element at that position.

Source

pub fn find_clickable(&mut self) -> ElementFinder<'_, R>

Find all clickable elements.

Returns a finder that matches all elements with clickable semantics.

Source

pub fn get_all_text(&mut self) -> Vec<String>

Get all text content currently visible on screen.

This is useful for debugging or asserting on overall screen state.

Source

pub fn get_all_rects(&mut self) -> Vec<(Rect, Option<String>)>

Get all rectangles (bounds) of UI elements on screen.

Returns a list of (bounds, optional_text) tuples.

Source

pub fn dump_screen(&mut self)

Print debug information about the current screen state.

This outputs the layout tree and render scene for debugging.

Source

pub fn shell_mut(&mut self) -> &mut AppShell<R>

Get access to the underlying app shell for advanced scenarios.

Auto Trait Implementations§

§

impl<R> Freeze for RobotTestRule<R>
where R: Freeze,

§

impl<R> !RefUnwindSafe for RobotTestRule<R>

§

impl<R> !Send for RobotTestRule<R>

§

impl<R> !Sync for RobotTestRule<R>

§

impl<R> Unpin for RobotTestRule<R>
where R: Unpin,

§

impl<R> UnsafeUnpin for RobotTestRule<R>
where R: UnsafeUnpin,

§

impl<R> !UnwindSafe for RobotTestRule<R>

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> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more