Skip to main content

Session

Struct Session 

Source
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

Source

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

Source

pub async fn kill(self) -> Result<()>

Shut down the session in the required order.

Ordering is load-bearing:

  1. 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.
  2. Drop the input and capture trait objects. For backends that share state with the compositor via Arc (e.g. mutter’s Arc<MutterState> holding the private D-Bus connection), the strong count has to reach zero before the compositor tears the underlying resource down.
  3. Stop the compositor.
Source

pub async fn press_keysym(&self, keysym: u32) -> Result<()>

Send a key press + release for the given X11 keysym.

Source

pub async fn pointer_motion_relative(&self, dx: f64, dy: f64) -> Result<()>

Move the pointer by a relative offset in logical pixels.

Source

pub async fn pointer_button(&self, button: u32) -> Result<()>

Press and release a pointer button (Linux evdev code, e.g. BTN_LEFT = 0x110).

Source

pub fn wayland_display(&self) -> &str

Wayland display socket name this session is running against.

Source

pub async fn take_screenshot(&self) -> Result<Vec<u8>>

Capture a PNG screenshot from the keepalive stream.

Trait Implementations§

Source§

impl Drop for Session

Source§

fn drop(&mut self)

Executes the destructor for this type. 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, 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