pub struct MockPlatformWindow {
pub config: WindowConfig,
pub scale_factor: f32,
pub is_focused: bool,
pub cursor: CursorIcon,
pub redraw_requested: bool,
pub event_queue: VecDeque<PlatformEvent>,
pub last_accessibility_update: Option<String>,
pub ime_cursor_location: Option<(i32, i32, i32, i32)>,
pub ime_surrounding: Option<(String, i32)>,
pub monitors: Vec<MonitorInfo>,
pub current_monitor_id: Option<u64>,
}Expand description
Headless mock platform window for deterministic testing, CI automation, and headless rendering.
Fields§
§config: WindowConfig§scale_factor: f32§is_focused: bool§cursor: CursorIcon§redraw_requested: bool§event_queue: VecDeque<PlatformEvent>§last_accessibility_update: Option<String>§ime_cursor_location: Option<(i32, i32, i32, i32)>§ime_surrounding: Option<(String, i32)>§monitors: Vec<MonitorInfo>§current_monitor_id: Option<u64>Implementations§
Source§impl MockPlatformWindow
impl MockPlatformWindow
Sourcepub fn new(config: WindowConfig) -> MockPlatformWindow
pub fn new(config: WindowConfig) -> MockPlatformWindow
Creates a new mock window with the specified configuration.
Sourcepub fn new_mock() -> MockPlatformWindow
pub fn new_mock() -> MockPlatformWindow
Creates a mock window with default configuration.
Sourcepub fn inject_event(&mut self, event: PlatformEvent)
pub fn inject_event(&mut self, event: PlatformEvent)
Injects an event into the window’s event queue.
Sourcepub fn take_redraw_request(&mut self) -> bool
pub fn take_redraw_request(&mut self) -> bool
Consumes and clears the redraw request flag.
Sourcepub fn add_monitor(&mut self, monitor: MonitorInfo)
pub fn add_monitor(&mut self, monitor: MonitorInfo)
Adds a monitor to the mock topology.
Sourcepub fn move_to_monitor(&mut self, monitor_id: u64)
pub fn move_to_monitor(&mut self, monitor_id: u64)
Moves the window to another monitor, automatically updating high-DPI scaling.
Trait Implementations§
Source§impl Clone for MockPlatformWindow
impl Clone for MockPlatformWindow
Source§fn clone(&self) -> MockPlatformWindow
fn clone(&self) -> MockPlatformWindow
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MockPlatformWindow
impl Debug for MockPlatformWindow
Source§impl NativeSurfaceWindow for MockPlatformWindow
impl NativeSurfaceWindow for MockPlatformWindow
Source§fn present_surface(
&mut self,
_pixels: &[u8],
_width: u32,
_height: u32,
) -> Result<(), PresentError>
fn present_surface( &mut self, _pixels: &[u8], _width: u32, _height: u32, ) -> Result<(), PresentError>
Blits a 32-bit BGRA uncompressed buffer to the window client area.
Source§impl PlatformWindow for MockPlatformWindow
impl PlatformWindow for MockPlatformWindow
fn title(&self) -> &str
fn set_title(&mut self, title: &str)
fn size(&self) -> (u32, u32)
fn set_size(&mut self, width: u32, height: u32)
fn scale_factor(&self) -> f32
fn set_scale_factor(&mut self, scale_factor: f32)
fn mode(&self) -> WindowMode
fn set_mode(&mut self, mode: WindowMode)
fn is_focused(&self) -> bool
fn set_focused(&mut self, focused: bool)
fn cursor(&self) -> CursorIcon
fn set_cursor(&mut self, cursor: CursorIcon)
fn request_redraw(&mut self)
fn is_redraw_requested(&self) -> bool
fn poll_events(&mut self) -> Vec<PlatformEvent>
fn push_event(&mut self, event: PlatformEvent)
Source§fn current_monitor(&self) -> Option<MonitorInfo>
fn current_monitor(&self) -> Option<MonitorInfo>
Returns the monitor containing the center of this window, if known.
Source§fn available_monitors(&self) -> Vec<MonitorInfo>
fn available_monitors(&self) -> Vec<MonitorInfo>
Returns the list of currently connected physical display monitors.
Source§fn primary_monitor(&self) -> Option<MonitorInfo>
fn primary_monitor(&self) -> Option<MonitorInfo>
Returns the primary system monitor.
Source§fn on_accessibility_update(&mut self, json_payload: &str)
fn on_accessibility_update(&mut self, json_payload: &str)
Transmits an incremental AccessKit/OS accessibility tree update to native screen readers.
Source§fn set_ime_cursor_location(&mut self, x: i32, y: i32, width: i32, height: i32)
fn set_ime_cursor_location(&mut self, x: i32, y: i32, width: i32, height: i32)
Sets candidate window positioning following active text caret coordinate.
Source§fn set_ime_surrounding_text(&mut self, text: &str, cursor_index: i32)
fn set_ime_surrounding_text(&mut self, text: &str, cursor_index: i32)
Updates surrounding text buffer for context-aware IME prediction.
Source§fn begin_window_drag(&mut self, _x: f32, _y: f32)
fn begin_window_drag(&mut self, _x: f32, _y: f32)
Initiates an interactive window drag operation with the native window manager.
Source§fn begin_window_resize(&mut self, _edge: CsdHitZone, _x: f32, _y: f32)
fn begin_window_resize(&mut self, _edge: CsdHitZone, _x: f32, _y: f32)
Initiates an interactive window resize operation with the native window manager.
Source§fn toggle_maximize(&mut self) -> bool
fn toggle_maximize(&mut self) -> bool
Toggles the window maximized state and returns true if the window is now maximized.
Auto Trait Implementations§
impl Forget for MockPlatformWindow
impl Freeze for MockPlatformWindow
impl Move for MockPlatformWindow
impl RefUnwindSafe for MockPlatformWindow
impl Send for MockPlatformWindow
impl Sync for MockPlatformWindow
impl Unpin for MockPlatformWindow
impl UnsafeUnpin for MockPlatformWindow
impl UnwindSafe for MockPlatformWindow
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more