Skip to main content

Module testing

Module testing 

Source
Expand description

Helpers for unattended tests: synthetic input posted into the app’s own event queue, and probes of AppKit state. Not for production use.

Functions§

click_reaches
Would a click at the centre of the view’s visible part reach the view? (AppKit’s own hit test, so it reflects what a real click would do.)
drag_rows
Starts a drag of table’s view rows rows the way AppKit does (asking the data source for each row’s pasteboard writer) and puts them on a private pasteboard. None if the table doesn’t let rows be dragged.
drop_on_table
Drops whatever is on pasteboard onto table above view row row, as AppKit does at the end of a drag: the data source validates the drop, then accepts it. from_table makes the table itself the drag’s source. Returns whether the drop was accepted.
drop_on_view
Drops whatever is on pasteboard onto view (a drag destination) as AppKit does: draggingEntered:, then performDragOperation: if it offered an operation. Whether the drop was taken.
files_pasteboard
A private pasteboard holding file URLs, as a Finder drag carries them.
first_responder
Class name of the window’s first responder (“host” for the host’s view).
is_visible
Whether the mounted view’s clip container is currently shown.
live_objects
(models alive, library Objective-C objects alive), for leak checks.
make_first_responder_raw
Makes a mounted view first responder directly through AppKit, bypassing crate::focus (as when AppKit moves focus itself, e.g. on a click).
off_grid
Shown views whose clip frame isn’t on the device-pixel grid.
pasteboard_text
The plain text on pasteboard.
post_click
Posts a left click at a point in host coordinates (top-left origin, points).
post_key
Posts a key-down (optionally with ⌘ / ⇧).
post_key_with
Posts a key-down with explicit modifier flags (e.g. Control for Ctrl-Tab).
post_mouse_move
Posts a mouse move to a point in host coordinates (hover).
post_tab
Posts Tab (or Shift-Tab) to the window.
private_pasteboard
A fresh private pasteboard (never the general one); release it with release_pasteboard.
release_pasteboard
Releases a pasteboard made by private_pasteboard.
set_app_appearance
Forces this app’s appearance (None: follow the system). The system setting is untouched; windows’ effectiveAppearance changes exactly as on a system switch.
set_pasteboard_text
Puts text on pasteboard.
subview_count
Number of subviews of the host’s content view (mounted clip containers).
view_is_dark
Whether a mounted view resolves to a dark appearance.
visible_rect
The visible part of a view as last placed (host coordinates).
window_state
(window is key, app is active), for diagnosing posted clicks.