Skip to main content

FakeOs

Struct FakeOs 

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

A fake system: the answers its dialogs give, and what the handlers did.

Implementations§

Source§

impl FakeOs

Source

pub fn new() -> Self

A fake system with no answers, no clipboard text, and no windows.

Source

pub fn os(&self) -> Os

The Os to give the application’s handlers.

Source

pub fn answer_dialog(&self, paths: impl IntoIterator<Item = PathBuf>)

Makes the next dialog answer as if the person chose paths.

Dialogs take the answers in the order they were given. A dialog other than DialogKind::OpenFiles panics unless paths holds exactly one path, since the person chooses one there.

Source

pub fn choose(&self, choice: Choice)

Makes the next message box that waits for a choice answer as if the person chose choice. Os::tell takes none.

A box panics when its choice is not one of its buttons.

Source

pub fn messages(&self) -> Vec<ShownMessage>

The message boxes the handlers showed, in order.

Source

pub fn cancel_dialog(&self)

Makes the next dialog answer as if the person cancelled it.

Source

pub fn dialogs(&self) -> Vec<ShownDialog>

The dialogs the handlers have shown and the test answered, in order.

Source

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

The text on the fake clipboard.

Source

pub fn set_clipboard_text(&self, text: impl Into<String>)

Puts text on the fake clipboard, as another program would.

Source

pub fn open_windows(&self) -> Vec<Url>

The pages of the windows the handlers opened and have not closed.

Source

pub fn window(&self, window: &Window) -> Option<Arranged>

How the handlers arranged window, or None once it is closed.

Source

pub fn focused_window(&self) -> Option<Url>

The page of the window opened or focused last, while it is open.

Source

pub fn updater(&self) -> Updater

An Updater that finds no newer version and makes no request, for the handlers’ state in place of the one App::run gives.

Source

pub fn launch( &self, dir: impl Into<PathBuf>, args: impl IntoIterator<Item = OsString>, )

Hands args, started in dir, to the Launches taken from this fake’s Os, as a second start of the application would.

Source

pub fn badge(&self) -> u32

The count the handlers last put on the application’s icon, 0 when none is shown.

Source

pub fn notifications(&self) -> Vec<Notification>

The notifications the handlers showed, in order.

Source

pub fn click_notification(&self, index: usize)

Clicks the notification shown indexth from 0, so its Notified::clicked returns true. A notification the test does not click returns false once the FakeOs and every Os from it are dropped.

§Panics

Panics when no notification was shown at index, or it was clicked already.

Source

pub fn has_shortcut(&self, shortcut: Shortcut) -> bool

Whether the handlers registered shortcut.

Source

pub fn press_shortcut(&self, shortcut: Shortcut, press: Press)

Sends press of shortcut, as the person would, to every Presses of it.

§Panics

Panics when the handlers did not register shortcut.

Source

pub fn tray(&self) -> Option<Tray>

The tray the handlers showed last, if any.

Source

pub fn click_tray_item(&self, item: &TrayItem)

Clicks item in the tray’s menu, as the person would.

§Panics

Panics when the tray shown, if any, has no such item.

Source

pub fn menus(&self) -> Vec<Menu>

The menus the handlers put in the menu bar last.

Source

pub fn click_menu_item(&self, item: &MenuItem)

Clicks item in the menu bar, as the person would.

§Panics

Panics when no menu of the menu bar holds item.

Source

pub fn opened_externally(&self) -> Vec<SafeUrl>

The URLs the handlers opened in another program.

Trait Implementations§

Source§

impl Clone for FakeOs

Source§

fn clone(&self) -> FakeOs

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 Debug for FakeOs

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for FakeOs

Source§

fn default() -> FakeOs

Returns the “default value” for a type. 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<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
§

impl<T> Downcast for T
where T: Any,

§

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

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

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

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

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

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.

§

impl<T> NoneValue for T
where T: Default,

§

type NoneType = T

§

fn null_value() -> T

The none-equivalent value.
§

impl<T> NoneValue for T
where T: Default,

§

type NoneType = T

The type of the none-equivalent value that [NoneValue::null_value] produces.
§

fn null_value() -> T

The none-equivalent value.
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. 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 = 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.
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more