Skip to main content

Drive

Struct Drive 

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

The handle a test drives the app with. Every method awaits the op and fails the test with the step’s own message when the op fails after its retry window.

Implementations§

Source§

impl Drive

Source

pub fn new(backend: Rc<dyn DriveBackend>) -> Self

A drive over backend; the engine and the mock harness build one per test.

Source

pub fn tap(&self, id: &str) -> OpFuture

Source

pub fn input(&self, id: &str, text: &str) -> OpFuture

Type text into the field, replacing what it holds.

Source

pub fn toggle(&self, id: &str, on: bool) -> OpFuture

Source

pub fn set_value(&self, id: &str, value: f64) -> OpFuture

Source

pub fn select(&self, id: &str, index: usize) -> OpFuture

Source

pub fn focus(&self, id: &str) -> OpFuture

Source

pub fn submit(&self, id: &str) -> OpFuture

Source

pub fn navigate(&self, route: &str) -> OpFuture

Source

pub fn wait_idle(&self) -> OpFuture

Let native transitions settle.

Source

pub fn pause(&self, secs: f64) -> OpFuture

Source

pub fn shot(&self, name: &str) -> OpFuture

Capture the window as name; the capture rides the test’s record to the runner.

Source

pub fn assert_text(&self, id: &str, text: &str) -> OpFuture

Source

pub fn assert_visible(&self, id: &str) -> OpFuture

Source

pub fn assert_missing(&self, id: &str) -> OpFuture

Source

pub fn hover(&self, id: &str, at: Option<(f64, f64)>) -> OpFuture

The pointer entering id at (x, y) in its coordinates (its center for None).

Source

pub fn hover_leave(&self, id: &str) -> OpFuture

The pointer leaving id.

Source

pub fn pan(&self, id: &str, dx: f64, dy: f64) -> OpFuture

A two-finger pan over id by (dx, dy) in total.

Source

pub fn pinch(&self, id: &str, scale: f64) -> OpFuture

A pinch over id to scale (cumulative; 1 = unchanged).

Source

pub fn drag(&self, id: &str, from: (f64, f64), to: (f64, f64)) -> OpFuture

A pointer drag over id from from to to, in its coordinates.

Source

pub fn tap_at(&self, id: &str, x: f64, y: f64) -> OpFuture

A tap at (x, y) in id’s coordinates.

Source

pub fn key(&self, id: Option<&str>, key: &str) -> OpFuture

A key press (web KeyboardEvent.key names: "Enter", "ArrowRight", "a") to id, or to whatever holds focus for None.

Source

pub fn assert_announced(&self, text: &str) -> OpFuture

That the app announced text to the screen reader during the run.

Source

pub fn assert_hidden(&self, id: &str) -> OpFuture

That an element is not on screen: missing, with an empty frame, or hidden natively (a collapsed pane a toolkit keeps built).

Source

pub fn assert_value(&self, id: &str, value: f64) -> OpFuture

Source

pub fn assert_on(&self, id: &str, on: bool) -> OpFuture

A toggle’s on/off state.

Source

pub fn assert_focused(&self, id: &str, focused: bool) -> OpFuture

Source

pub fn assert_route(&self, route: &str) -> OpFuture

Source

pub fn a11y_audit(&self, id: Option<&str>) -> OpFuture

Diff the native accessibility tree against Day’s expectation for id (all id’d nodes when None), where the toolkit can read its tree back.

Source

pub fn assert_native(&self, id: &str, expect: NativeExpect) -> OpFuture

The native widget’s own state, as the platform reports it (docs/testing.md). A field the toolkit cannot read is recorded in the report as unread rather than failed. In a conformance run assert_text, assert_value and assert_on check the native widget too; this is for what they do not cover.

Source

pub fn assert_frame(&self, id: &str, expect: FrameExpect) -> OpFuture

The element’s frame in Day’s layout and, where the toolkit reads it back, natively.

Source

pub fn assert_size(&self, id: &str, width: f64, height: f64) -> OpFuture

The element’s size, the common case of Drive::assert_frame.

Source

pub fn sample_pixel(&self, id: &str, x: f64, y: f64, color: &str) -> OpFuture

The color drawn at (x, y), fractions of the element’s frame, as #rrggbb. Passes as unread where the toolkit has no capture.

Source

pub fn assert_opened_url(&self, url: &str) -> OpFuture

That the app asked to open url (a link, day::open_url) during the run; in a run nothing actually opens.

Source

pub fn assert_enabled(&self, id: &str, enabled: bool) -> OpFuture

Whether the element takes input, in Day’s tree and in the native widget.

Source

pub fn activate(&self, id: &str, index: usize) -> OpFuture

Activate a list’s row by position: what a double click, Return or a phone’s tap commits.

Source

pub fn reorder(&self, id: &str, from: usize, to: usize) -> OpFuture

Move a list’s row from from to to, as a native drag-to-reorder commits it.

Source

pub fn delete_row(&self, id: &str, row: usize) -> OpFuture

Delete a list’s row, as the platform’s delete gesture commits it.

Source

pub fn swipe_row( &self, id: &str, row: usize, leading: bool, action: usize, ) -> OpFuture

Press the actionth swipe action on a list row’s leading or trailing edge.

Source

pub fn scroll_to(&self, id: &str, edge: &str) -> OpFuture

Scroll a scroll view or list to an edge: "top", "bottom", "leading", "trailing".

Source

pub fn expand(&self, id: &str, row: &str, expanded: bool) -> OpFuture

Expand or collapse a tree’s row, named by its row id.

Source

pub fn nav_back(&self) -> OpFuture

Go back one page in the innermost navigation stack.

Source

pub fn tree_move( &self, id: &str, row: &str, parent: Option<&str>, index: Option<usize>, ) -> OpFuture

Move a tree’s row (by row id) under parent (None = the root level), at index among its new siblings (None = last), as a native drag commits it.

Source

pub fn context_menu(&self, id: &str, item: &str) -> OpFuture

Choose the item labeled item from id’s context menu, as a right click (or long press) and a choice would.

Source

pub fn menu(&self, item_id: &str) -> OpFuture

Choose an app-menu item by the id the app gave it (MenuEntry::id).

Source

pub fn toolbar_press(&self, item: &str) -> OpFuture

Press the toolbar button item.

Source

pub fn toolbar_toggle(&self, item: &str, on: bool) -> OpFuture

Turn the toolbar toggle item on or off.

Source

pub fn dialogs_scripted(&self, scripted: bool) -> OpFuture

Show presentations natively (false, the default) or hold them for Drive::respond without any native dialog (true). In native mode respond still answers, and the toolkit dismisses the dialog it showed.

Source

pub fn assert_presented(&self, title: Option<&str>) -> OpFuture

That a dialog or picker is pending, titled title where one is given.

Source

pub fn respond(&self, button: Option<usize>) -> OpFuture

Answer the pending dialog with the button at button (presentation order), or dismiss it for None.

Source

pub fn respond_text(&self, text: &str) -> OpFuture

Confirm a pending text prompt.

Source

pub fn check(&self, ok: bool, what: &str) -> TestResult

A plain assertion for a headless test: fails with what when ok is false.

Source

pub fn check_eq<T: PartialEq + Debug>(&self, got: T, want: T) -> TestResult

Equality for a headless test, naming both sides on a mismatch.

Trait Implementations§

Source§

impl Clone for Drive

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§

§

impl !RefUnwindSafe for Drive

§

impl !Send for Drive

§

impl !Sync for Drive

§

impl !UnwindSafe for Drive

§

impl Freeze for Drive

§

impl Unpin for Drive

§

impl UnsafeUnpin for Drive

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> 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> ErasedDestructor for T
where T: 'static,

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