MockWindow

Struct MockWindow 

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

A mock window implementation for headless testing.

This struct implements the winit::window::Window trait with stub implementations that are suitable for testing without a real window system.

Implementations§

Source§

impl MockWindow

Source

pub fn new() -> Self

Create a new mock window with default settings.

Source

pub fn with_size(width: u32, height: u32) -> Self

Create a new mock window with the given size.

Source

pub fn set_scale_factor(&mut self, scale: f64)

Set the scale factor for this mock window.

Trait Implementations§

Source§

impl Debug for MockWindow

Source§

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

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

impl Default for MockWindow

Source§

fn default() -> Self

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

impl Window for MockWindow

Source§

fn id(&self) -> WindowId

Returns an identifier unique to the window.
Source§

fn scale_factor(&self) -> f64

Returns the scale factor that can be used to map logical pixels to physical pixels, and vice versa. Read more
Source§

fn request_redraw(&self)

Queues a WindowEvent::RedrawRequested event to be emitted that aligns with the windowing system drawing loop. Read more
Source§

fn pre_present_notify(&self)

Notify the windowing system before presenting to the window. Read more
Source§

fn reset_dead_keys(&self)

Reset the dead key state of the keyboard. Read more
Source§

fn surface_position(&self) -> PhysicalPosition<i32>

The position of the top-left hand corner of the surface relative to the top-left hand corner of the window. Read more
Source§

fn outer_position(&self) -> Result<PhysicalPosition<i32>, RequestError>

The position of the top-left hand corner of the window relative to the top-left hand corner of the desktop. Read more
Source§

fn set_outer_position(&self, _position: Position)

Sets the position of the window on the desktop. Read more
Source§

fn surface_size(&self) -> PhysicalSize<u32>

Returns the size of the window’s render-able surface. Read more
Source§

fn request_surface_size(&self, _size: Size) -> Option<PhysicalSize<u32>>

Request the new size for the surface. Read more
Source§

fn outer_size(&self) -> PhysicalSize<u32>

Returns the size of the entire window. Read more
Source§

fn safe_area(&self) -> PhysicalInsets<u32>

The inset area of the surface that is unobstructed. Read more
Source§

fn set_min_surface_size(&self, _min_size: Option<Size>)

Sets a minimum dimensions of the window’s surface. Read more
Source§

fn set_max_surface_size(&self, _max_size: Option<Size>)

Sets a maximum dimensions of the window’s surface. Read more
Source§

fn surface_resize_increments(&self) -> Option<PhysicalSize<u32>>

Returns surface resize increments if any were set. Read more
Source§

fn set_surface_resize_increments(&self, _increments: Option<Size>)

Sets resize increments of the surface. Read more
Source§

fn set_title(&self, _title: &str)

Modifies the title of the window. Read more
Source§

fn set_transparent(&self, _transparent: bool)

Change the window transparency state. Read more
Source§

fn set_blur(&self, _blur: bool)

Change the window blur state. Read more
Source§

fn set_visible(&self, _visible: bool)

Modifies the window’s visibility. Read more
Source§

fn is_visible(&self) -> Option<bool>

Gets the window’s current visibility state. Read more
Source§

fn set_resizable(&self, _resizable: bool)

Sets whether the window is resizable or not. Read more
Source§

fn is_resizable(&self) -> bool

Gets the window’s current resizable state. Read more
Source§

fn set_enabled_buttons(&self, _buttons: WindowButtons)

Sets the enabled window buttons. Read more
Source§

fn enabled_buttons(&self) -> WindowButtons

Gets the enabled window buttons. Read more
Source§

fn set_minimized(&self, _minimized: bool)

Minimize the window, or put it back from the minimized state. Read more
Source§

fn is_minimized(&self) -> Option<bool>

Gets the window’s current minimized state. Read more
Source§

fn set_maximized(&self, _maximized: bool)

Sets the window to maximized or back. Read more
Source§

fn is_maximized(&self) -> bool

Gets the window’s current maximized state. Read more
Source§

fn set_fullscreen(&self, _fullscreen: Option<Fullscreen>)

Set the window’s fullscreen state. Read more
Source§

fn fullscreen(&self) -> Option<Fullscreen>

Gets the window’s current fullscreen state. Read more
Source§

fn set_decorations(&self, _decorations: bool)

Turn window decorations on or off. Read more
Source§

fn is_decorated(&self) -> bool

Gets the window’s current decorations state. Read more
Source§

fn set_window_level(&self, _level: WindowLevel)

Change the window level. Read more
Source§

fn set_window_icon(&self, _window_icon: Option<Icon>)

Sets the window icon. Read more
Source§

fn request_ime_update( &self, _request: ImeRequest, ) -> Result<(), ImeRequestError>

Atomically apply request to IME. Read more
Source§

fn ime_capabilities(&self) -> Option<ImeCapabilities>

Return enabled by the client ImeCapabilities for this window. Read more
Source§

fn focus_window(&self)

Brings the window to the front and sets input focus. Has no effect if the window is already in focus, minimized, or not visible. Read more
Source§

fn has_focus(&self) -> bool

Gets whether the window has keyboard focus. Read more
Source§

fn request_user_attention(&self, _request_type: Option<UserAttentionType>)

Requests user attention to the window, this has no effect if the application is already focused. How requesting for user attention manifests is platform dependent, see UserAttentionType for details. Read more
Source§

fn set_theme(&self, _theme: Option<Theme>)

Set or override the window theme. Read more
Source§

fn theme(&self) -> Option<Theme>

Returns the current window theme. Read more
Source§

fn set_content_protected(&self, _protected: bool)

Prevents the window contents from being captured by other apps. Read more
Source§

fn title(&self) -> String

Gets the current title of the window. Read more
Source§

fn set_cursor(&self, _cursor: Cursor)

Modifies the cursor icon of the window. Read more
Source§

fn set_cursor_position(&self, _position: Position) -> Result<(), RequestError>

Changes the position of the cursor in window coordinates. Read more
Source§

fn set_cursor_grab(&self, _mode: CursorGrabMode) -> Result<(), RequestError>

Set grabbing mode on the cursor preventing it from leaving the window. Read more
Source§

fn set_cursor_visible(&self, _visible: bool)

Modifies the cursor’s visibility. Read more
Source§

fn drag_window(&self) -> Result<(), RequestError>

Moves the window with the left mouse button until the button is released. Read more
Source§

fn drag_resize_window( &self, _direction: ResizeDirection, ) -> Result<(), RequestError>

Resizes the window with the left mouse button until the button is released. Read more
Source§

fn show_window_menu(&self, _position: Position)

Show window menu at a specified position in surface coordinates. Read more
Source§

fn set_cursor_hittest(&self, _hittest: bool) -> Result<(), RequestError>

Modifies whether the window catches cursor events. Read more
Source§

fn current_monitor(&self) -> Option<MonitorHandle>

Returns the monitor on which the window currently resides. Read more
Source§

fn available_monitors(&self) -> Box<dyn Iterator<Item = MonitorHandle>>

Returns the list of all the monitors available on the system. Read more
Source§

fn primary_monitor(&self) -> Option<MonitorHandle>

Returns the primary monitor of the system. Read more
Source§

fn rwh_06_display_handle(&self) -> &dyn HasDisplayHandle

Get the raw-window-handle v0.6 display handle.
Source§

fn rwh_06_window_handle(&self) -> &dyn HasWindowHandle

Get the raw-window-handle v0.6 window handle.
Source§

fn set_ime_cursor_area(&self, position: Position, size: Size)

👎Deprecated: use Window::request_ime_update instead
Set the IME cursor editing area, where the position is the top left corner of that area in surface coordinates and size is the size of this area starting from the position. An example of such area could be a input field in the UI or line in the editor. Read more
Source§

fn set_ime_allowed(&self, allowed: bool)

👎Deprecated: use Window::request_ime_update instead
Sets whether the window should get IME events Read more
Source§

fn set_ime_purpose(&self, purpose: ImePurpose)

👎Deprecated: use Window::request_ime_update instead
Sets the IME purpose for the window using ImePurpose. 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> 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> Same for T

Source§

type Output = T

Should always be Self
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.
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
Source§

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

Source§

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

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,