Skip to main content

TestApp

Struct TestApp 

Source
pub struct TestApp { /* private fields */ }

Implementations§

Source§

impl TestApp

Source

pub fn new<F, A>(build: F) -> Result<Self>
where F: FnOnce() -> A + Send + 'static, A: IntoTestRuntime,

Examples found in repository?
examples/basic.rs (lines 15-22)
14fn main() -> Result<()> {
15    let app = TestApp::new(|| {
16        let state = Rc::new(RefCell::new(AppState::default()));
17        Application::new().window(
18            WindowBuilder::new()
19                .title("SUI Testing Example")
20                .root(ExampleRoot::new(state)),
21        )
22    })?;
23
24    let window = app.main_window()?;
25
26    window
27        .get_by_role(SemanticsRole::TextInput)
28        .with_name("Name")
29        .fill("Ada")?;
30    window
31        .get_by_role(SemanticsRole::Button)
32        .with_name("Save")
33        .click()?;
34    window.get_by_text("Saved").expect().to_be_visible()?;
35
36    println!("Example passed: filled the name field and observed the Saved status.");
37    Ok(())
38}
Source

pub fn new_with_vsync<F, A>(build: F, vsync_enabled: bool) -> Result<Self>
where F: FnOnce() -> A + Send + 'static, A: IntoTestRuntime,

Source

pub fn new_with_options<F, A>( build: F, vsync_enabled: bool, visible: bool, ) -> Result<Self>
where F: FnOnce() -> A + Send + 'static, A: IntoTestRuntime,

Source

pub fn builder<F, A>(build: F) -> TestAppBuilder<F>
where F: FnOnce() -> A + Send + 'static, A: IntoTestRuntime,

Start configuring a test app built by build.

Source

pub fn new_no_vsync<F, A>(build: F) -> Result<Self>
where F: FnOnce() -> A + Send + 'static, A: IntoTestRuntime,

Source

pub fn new_visible_no_vsync<F, A>(build: F) -> Result<Self>
where F: FnOnce() -> A + Send + 'static, A: IntoTestRuntime,

Source

pub fn from_runtime(runtime: Runtime) -> Result<Self>

Source

pub fn from_runtime_with_external_texture_registry( runtime: Runtime, registry: WgpuExternalTextureRegistry, ) -> Result<Self>

Build a headless test harness that can resolve app-owned WGPU textures.

Source

pub fn from_runtime_with_frame_budget( runtime: Runtime, initial_frames: usize, ) -> Result<Self>

Source

pub fn set_default_timeout(&self, timeout: f64) -> Result<()>

How many seconds waits such as Self::run_until_idle allow before failing. Infinity waits without a deadline.

Source

pub fn default_timeout(&self) -> f64

Source

pub fn run_until_idle(&self) -> Result<()>

Source

pub fn pump_frames(&self, frames: usize) -> Result<()>

Source

pub fn advance_time(&self, delta: f64) -> Result<()>

Source

pub fn set_motion_preference( &self, preference: Option<MotionPreference>, ) -> Result<()>

Override the motion preference of the app under test, or pass None to follow the system preference, which tests treat as full motion.

Source

pub fn set_motion_time_scale(&self, time_scale: f32) -> Result<()>

Play the app’s transitions at time_scale speed.

Source

pub fn has_running_animations(&self) -> Result<bool>

Whether any window still has a transition running.

Source

pub fn settle_animations(&self) -> Result<f64>

Advance time frame by frame until every transition has finished, and return how many seconds that took. Fails after ten seconds, which usually means an animation repeats forever.

Source

pub fn settle_animations_within(&self, limit: f64) -> Result<f64>

Like TestApp::settle_animations, failing after limit seconds.

Source

pub fn record_motion<T>( &self, duration: f64, step: f64, probe: impl FnMut() -> Result<T>, ) -> Result<Vec<(f64, T)>>

Sample probe now and then every step seconds for duration seconds, returning (elapsed, value) pairs, to assert on the shape of a transition rather than only its end state.

Source

pub fn windows(&self) -> Result<Vec<TestWindow>>

Source

pub fn main_window(&self) -> Result<TestWindow>

Examples found in repository?
examples/basic.rs (line 24)
14fn main() -> Result<()> {
15    let app = TestApp::new(|| {
16        let state = Rc::new(RefCell::new(AppState::default()));
17        Application::new().window(
18            WindowBuilder::new()
19                .title("SUI Testing Example")
20                .root(ExampleRoot::new(state)),
21        )
22    })?;
23
24    let window = app.main_window()?;
25
26    window
27        .get_by_role(SemanticsRole::TextInput)
28        .with_name("Name")
29        .fill("Ada")?;
30    window
31        .get_by_role(SemanticsRole::Button)
32        .with_name("Save")
33        .click()?;
34    window.get_by_text("Saved").expect().to_be_visible()?;
35
36    println!("Example passed: filled the name field and observed the Saved status.");
37    Ok(())
38}
Source

pub fn window_by_title(&self, title: &str) -> Result<TestWindow>

Trait Implementations§

Source§

impl Clone for TestApp

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> Downcast<T> for T

Source§

fn downcast(&self) -> &T

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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<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