Skip to main content

Case

Struct Case 

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

One test: what it proves, what it needs, the page it shows and the body that drives it. Built by a #[day::test] function each time the test runs, so the signals a page and its drive share are fresh per run; the registry names it after that function.

Implementations§

Source§

impl Case

Source

pub fn new() -> Self

A GUI case: a page the app’s test host shows while the case runs, and a drive against it.

Source

pub fn headless() -> Self

A test with no page: app logic run inside the app’s own environment.

Source

pub fn timeout(self, secs: f64) -> Self

How long the case may take, page and drive together, before it fails as timed out. Unset, the run’s default applies (30 s, or what day test --case-timeout says).

Source

pub fn proves(self, kind: &str) -> Self

The piece kind this case is the proof of (kinds::BUTTON); a pass marks the kind on this toolkit in the coverage tables.

Source

pub fn proves_cap(self, cap: Cap) -> Self

The capability this case proves.

Source

pub fn proves_modifier(self, modifier: &str) -> Self

The Decorate modifier this case proves ("padding").

Source

pub fn proves_duty(self, duty: &str) -> Self

The toolkit duty this case proves ("set_input_traits").

Source

pub fn requires(self, cap: Cap) -> Self

A capability the case needs; where the toolkit answers Unsupported the case is skipped with that reason rather than failed. The one way a case adapts to a toolkit.

Source

pub fn requires_support(self, what: &str, support: fn() -> Support) -> Self

A piece’s own support the case needs (day_piece_map::support), named for the skip reason: where it answers Unsupported the case is skipped, as for Case::requires. For a piece realized only where its platform ships the widget.

Source

pub fn missing_support(&self) -> Option<String>

The first support this case needs that the running toolkit lacks, named.

Source

pub fn page<P: Piece>(self, page: impl Fn() -> P + 'static) -> Self

The page the app shows for this case; any piece.

Source

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

A capture taken before the drive runs, once the page is shown.

Source

pub fn drive<F>(self, body: impl Fn(Drive) -> F + 'static) -> Self
where F: Future<Output = TestResult> + 'static,

The drive: an async body over a Drive, awaiting each step so the app’s main loop runs between them (a transition settles, a capture paints) as it does between a script’s steps.

Source

pub fn run<F>(self, body: impl Fn(Drive) -> F + 'static) -> Self
where F: Future<Output = TestResult> + 'static,

Case::drive under the name a headless test reads better with.

Source

pub fn name(&self) -> &str

The name the registry gave the case: its function’s, hyphenated. Empty for a case built outside the registry.

Source

pub fn timeout_secs(&self) -> Option<f64>

The case’s own time limit, if it set one.

Source

pub fn kind(&self) -> TestKind

Source

pub fn proves_keys(&self) -> &[String]

The kind:, cap: and duty: keys this case proves, in the matrices’ own spelling.

Source

pub fn requirements(&self) -> &[Cap]

Source

pub fn shots(&self) -> &[String]

The captures to take before the drive.

Source

pub fn build_page(&self) -> Option<AnyPiece>

Build the case’s page, if it has one.

Source

pub fn run_body( &self, drive: Drive, ) -> Pin<Box<dyn Future<Output = TestResult>>>

Run the body over drive; a case with no body passes once its page showed.

Trait Implementations§

Source§

impl Clone for Case

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

impl Default for Case

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Case

§

impl !Send for Case

§

impl !Sync for Case

§

impl !UnwindSafe for Case

§

impl Freeze for Case

§

impl Unpin for Case

§

impl UnsafeUnpin for Case

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.