Skip to main content

Harness

Struct Harness 

Source
pub struct Harness { /* private fields */ }
Expand description

Test harness for interacting with Presentar widgets.

Implementations§

Source§

impl Harness

Source

pub fn new(root: impl Widget + 'static) -> Self

Create a new harness with a root widget.

Source

pub const fn viewport(self, width: f32, height: f32) -> Self

Set the viewport size.

Source

pub fn click(&mut self, selector: &str) -> &mut Self

Simulate a click on a widget matching the selector.

Source

pub fn type_text(&mut self, selector: &str, text: &str) -> &mut Self

Simulate typing text into a widget.

Source

pub fn press_key(&mut self, key: Key) -> &mut Self

Simulate a key press.

Source

pub fn scroll(&mut self, selector: &str, delta: f32) -> &mut Self

Simulate scrolling.

Source

pub fn query(&self, selector: &str) -> Option<&dyn Widget>

Query for a widget matching the selector.

Source

pub fn query_all(&self, selector: &str) -> Vec<&dyn Widget>

Query for all widgets matching the selector.

Source

pub fn text(&self, selector: &str) -> String

Get text content from a widget.

Source

pub fn exists(&self, selector: &str) -> bool

Check if a widget exists.

Source

pub fn assert_exists(&self, selector: &str) -> &Self

Assert that a widget exists.

§Panics

Panics if the widget does not exist.

Source

pub fn assert_not_exists(&self, selector: &str) -> &Self

Assert that a widget does not exist.

§Panics

Panics if the widget exists.

Source

pub fn assert_text(&self, selector: &str, expected: &str) -> &Self

Assert that text matches exactly.

§Panics

Panics if the text does not match.

Source

pub fn assert_text_contains(&self, selector: &str, substring: &str) -> &Self

Assert that text contains a substring.

§Panics

Panics if the text does not contain the substring.

Source

pub fn assert_count(&self, selector: &str, expected: usize) -> &Self

Assert the count of matching widgets.

§Panics

Panics if the count does not match.

Source

pub fn tick(&mut self, _ms: u64)

Advance simulated time.

Auto Trait Implementations§

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.