pub struct Session {
pub id: String,
pub app_name: String,
pub app_bus_name: String,
pub app_path: String,
pub a11y_connection: Option<AccessibilityConnection>,
/* private fields */
}Expand description
A running UI test session: a compositor, input + capture backends, the target application process, and an AT-SPI connection to drive it.
Construct via Session::start. Callers are responsible for pre-starting
the compositor (so they can wire mutually-dependent backends like
waydriver-input-mutter / waydriver-capture-mutter, which share state
with the compositor via Arc<MutterState>).
Fields§
§id: String§app_name: String§app_bus_name: String§app_path: String§a11y_connection: Option<AccessibilityConnection>Implementations§
Source§impl Session
impl Session
Sourcepub async fn start(
compositor: Box<dyn CompositorRuntime>,
input: Box<dyn InputBackend>,
capture: Box<dyn CaptureBackend>,
cfg: SessionConfig,
) -> Result<Self>
pub async fn start( compositor: Box<dyn CompositorRuntime>, input: Box<dyn InputBackend>, capture: Box<dyn CaptureBackend>, cfg: SessionConfig, ) -> Result<Self>
Build a session from a pre-started compositor plus matching input and
capture backends. The caller is responsible for calling
CompositorRuntime::start before passing the compositor in; this is
what lets the caller construct backend-specific input/capture types
from whatever state the compositor exposes after startup (for mutter,
that’s waydriver_compositor_mutter::MutterCompositor::state()).
Sourcepub async fn kill(self) -> Result<()>
pub async fn kill(self) -> Result<()>
Shut down the session in the required order.
Ordering is load-bearing:
- Kill the app first. Its Wayland connection holds a reference into the compositor; killing the compositor first can make the app block on its Wayland socket during shutdown.
- Drop the input and capture trait objects. For backends that share
state with the compositor via
Arc(e.g. mutter’sArc<MutterState>holding the private D-Bus connection), the strong count has to reach zero before the compositor tears the underlying resource down. - Stop the compositor.
Sourcepub async fn press_keysym(&self, keysym: u32) -> Result<()>
pub async fn press_keysym(&self, keysym: u32) -> Result<()>
Send a key press + release for the given X11 keysym.
Sourcepub async fn pointer_motion_relative(&self, dx: f64, dy: f64) -> Result<()>
pub async fn pointer_motion_relative(&self, dx: f64, dy: f64) -> Result<()>
Move the pointer by a relative offset in logical pixels.
Press and release a pointer button (Linux evdev code, e.g. BTN_LEFT = 0x110).
Sourcepub fn wayland_display(&self) -> &str
pub fn wayland_display(&self) -> &str
Wayland display socket name this session is running against.
Sourcepub async fn take_screenshot(&self) -> Result<Vec<u8>>
pub async fn take_screenshot(&self) -> Result<Vec<u8>>
Capture a PNG screenshot from the keepalive stream.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Session
impl !RefUnwindSafe for Session
impl Send for Session
impl Sync for Session
impl Unpin for Session
impl UnsafeUnpin for Session
impl !UnwindSafe for Session
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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