Skip to main content

HeadlessHandle

Struct HeadlessHandle 

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

Shared access to a HeadlessBackend after it was moved into a Ui.

Implementations§

Source§

impl HeadlessHandle

Source

pub fn record_commands(&self, on: bool)

Records the commands applied from now on, for command_log and take_command_log, or stops and drops them.

Source

pub fn command_log(&self) -> Vec<Command>

Every command applied since recording started (record_commands), in order.

Source

pub fn take_command_log(&self) -> Vec<Command>

Source

pub fn app_locale(&self) -> Option<(String, bool)>

The app’s language as the core last gave it (Backend::set_locale), and whether it’s right to left.

Source

pub fn resize_window(&self, window: NodeId, size: Size)

Simulates the user resizing a window, which goes no smaller than its minimum size, and keeps its height if its content sets it. A window that isn’t resizable keeps its size.

Source

pub fn screen(&self) -> Size

The size of the screen a window in full screen fills.

Source

pub fn set_window_active(&self, window: NodeId, active: bool)

Simulates a window becoming the active one, or another taking over.

Source

pub fn set_full_screen(&self, window: NodeId, on: bool)

Simulates the user putting a window in full screen, or taking it out (the title bar’s button, the window manager’s key).

Source

pub fn work_area(&self) -> Size

The size of a maximized window’s content.

Source

pub fn set_maximized(&self, window: NodeId, on: bool)

Simulates the user maximizing a window, or restoring it (the title bar’s button, a double-click on it, the window manager’s key).

Source

pub fn set_sidebar_shown(&self, sidebar: NodeId, shown: bool)

Simulates the user showing or hiding a window’s sidebar (the platform’s toggle, its divider dragged away).

Source

pub fn set_viewport_insets(&self, scroll_view: NodeId, insets: Insets)

Simulates a platform whose scroll bars take room from a scroll view’s content, as classic scroll bars do (the viewport is inside these insets).

Source

pub fn set_metrics(&self, metrics: PlatformMetrics)

Simulates a change of system settings (text size, dark mode, …).

Source

pub fn focused(&self) -> Option<NodeId>

Source

pub fn deactivate(&self, window: NodeId)

Simulates the user switching to another app: the window’s GPU surfaces lose their pointer lock and keyboard grab, as every platform ends them.

Source

pub fn move_locked_pointer(&self, surface: NodeId, dx: f32, dy: f32)

Simulates the mouse moving while a surface holds the pointer: its move with the host’s acceleration, and before it. Headless has no acceleration, and one count to a point.

Source

pub fn a11y(&self, id: NodeId) -> Option<A11yProps>

Source

pub fn node_count(&self) -> usize

Number of live native nodes: a leak detector for tests.

Trait Implementations§

Source§

impl Clone for HeadlessHandle

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 TestHooks for HeadlessHandle

Source§

fn hit(&self, window: NodeId, at: Point) -> Result<Option<NodeId>, ActionError>

The topmost node with a frame there (later children are over earlier ones), past containers clicks pass through.

Source§

fn dragged_files(&self, node: NodeId) -> Option<Vec<PathBuf>>

The selected rows’ files if the row is selected, else its own, as platforms’ lists drag.

Source§

fn app_info(&self, _window: NodeId) -> NativeAppInfo

All of it, as every platform has a place for some of it; the icon’s size from its PNG header.

Source§

fn name(&self) -> &'static str

Short name used in snapshot and visual baseline paths: "appkit", "gtk", "winui", "kirigami".
Source§

fn resize_window(&self, window: NodeId, size: Size)

Resizes a window’s content area the way the user would, so the platform reports it back as WindowResized.
Source§

fn close_window(&self, window: NodeId)

Clicks the window’s close button, the way the user would, so the platform reports WindowCloseRequested. Whether it closes is the app’s call.
Source§

fn take_command_log(&self) -> Vec<Command>

Commands applied since the last call (record them when asked to).
Source§

fn node_count(&self) -> usize

Live native nodes, as a leak detector.
Source§

fn settle(&self)

Called after every settle: lets the platform catch up on work it does asynchronously (showing windows, allocating, delivering queued notifications) without waiting. Every backend has some: AppKit lays out tables and toolbars, which make their views in a layout pass.

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