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>
impl<R> RobotTestRule<R>
Sourcepub fn new(
width: u32,
height: u32,
renderer: R,
content: impl FnMut() + 'static,
) -> Self
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.
Sourcepub fn viewport_size(&self) -> (u32, u32)
pub fn viewport_size(&self) -> (u32, u32)
Get the current viewport size.
Sourcepub fn set_viewport(&mut self, width: u32, height: u32)
pub fn set_viewport(&mut self, width: u32, height: u32)
Resize the viewport (simulates window resize).
Sourcepub fn advance_time(&mut self, _nanos: u64)
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.
Sourcepub fn wait_for_idle(&mut self)
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.
Sourcepub fn click_at(&mut self, x: f32, y: f32) -> bool
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.
Sourcepub fn move_to(&mut self, x: f32, y: f32) -> bool
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.
Sourcepub fn drag(&mut self, from_x: f32, from_y: f32, to_x: f32, to_y: f32)
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.
Sourcepub fn mouse_move(&mut self, x: f32, y: f32)
pub fn mouse_move(&mut self, x: f32, y: f32)
Move the mouse cursor to the given coordinates.
Sourcepub fn mouse_down(&mut self)
pub fn mouse_down(&mut self)
Press the mouse button.
Sourcepub fn find_by_text(&mut self, text: &str) -> ElementFinder<'_, R>
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.
Sourcepub fn find_at_position(&mut self, x: f32, y: f32) -> ElementFinder<'_, R>
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.
Sourcepub fn find_clickable(&mut self) -> ElementFinder<'_, R>
pub fn find_clickable(&mut self) -> ElementFinder<'_, R>
Find all clickable elements.
Returns a finder that matches all elements with clickable semantics.
Sourcepub fn get_all_text(&mut self) -> Vec<String>
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.
Sourcepub fn get_all_rects(&mut self) -> Vec<(Rect, Option<String>)>
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.
Sourcepub fn dump_screen(&mut self)
pub fn dump_screen(&mut self)
Print debug information about the current screen state.
This outputs the layout tree and render scene for debugging.
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.