pub struct TestApp { /* private fields */ }Implementations§
Source§impl TestApp
impl TestApp
Sourcepub fn new<F, A>(build: F) -> Result<Self>
pub fn new<F, A>(build: F) -> Result<Self>
Examples found in repository?
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}pub fn new_with_vsync<F, A>(build: F, vsync_enabled: bool) -> Result<Self>
pub fn new_with_options<F, A>( build: F, vsync_enabled: bool, visible: bool, ) -> Result<Self>
Sourcepub fn builder<F, A>(build: F) -> TestAppBuilder<F>
pub fn builder<F, A>(build: F) -> TestAppBuilder<F>
Start configuring a test app built by build.
pub fn new_no_vsync<F, A>(build: F) -> Result<Self>
pub fn new_visible_no_vsync<F, A>(build: F) -> Result<Self>
pub fn from_runtime(runtime: Runtime) -> Result<Self>
Sourcepub fn from_runtime_with_external_texture_registry(
runtime: Runtime,
registry: WgpuExternalTextureRegistry,
) -> Result<Self>
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.
pub fn from_runtime_with_frame_budget( runtime: Runtime, initial_frames: usize, ) -> Result<Self>
Sourcepub fn set_default_timeout(&self, timeout: f64) -> Result<()>
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.
pub fn default_timeout(&self) -> f64
pub fn run_until_idle(&self) -> Result<()>
pub fn pump_frames(&self, frames: usize) -> Result<()>
pub fn advance_time(&self, delta: f64) -> Result<()>
Sourcepub fn set_motion_preference(
&self,
preference: Option<MotionPreference>,
) -> Result<()>
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.
Sourcepub fn set_motion_time_scale(&self, time_scale: f32) -> Result<()>
pub fn set_motion_time_scale(&self, time_scale: f32) -> Result<()>
Play the app’s transitions at time_scale speed.
Sourcepub fn has_running_animations(&self) -> Result<bool>
pub fn has_running_animations(&self) -> Result<bool>
Whether any window still has a transition running.
Sourcepub fn settle_animations(&self) -> Result<f64>
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.
Sourcepub fn settle_animations_within(&self, limit: f64) -> Result<f64>
pub fn settle_animations_within(&self, limit: f64) -> Result<f64>
Like TestApp::settle_animations, failing after limit seconds.
Sourcepub fn record_motion<T>(
&self,
duration: f64,
step: f64,
probe: impl FnMut() -> Result<T>,
) -> Result<Vec<(f64, T)>>
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.
pub fn windows(&self) -> Result<Vec<TestWindow>>
Sourcepub fn main_window(&self) -> Result<TestWindow>
pub fn main_window(&self) -> Result<TestWindow>
Examples found in repository?
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}pub fn window_by_title(&self, title: &str) -> Result<TestWindow>
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for TestApp
impl !Send for TestApp
impl !Sync for TestApp
impl !UnwindSafe for TestApp
impl Freeze for TestApp
impl Unpin for TestApp
impl UnsafeUnpin for TestApp
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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