pub struct HttpRunnerClient { /* private fields */ }Expand description
HTTP client to the swift-side SmixRunnerCore. Async (tokio-based).
Constructed once per Cell; ensure_reachable memoizes a successful
/health probe so subsequent calls don’t re-probe.
Implementations§
Source§impl HttpRunnerClient
impl HttpRunnerClient
Sourcepub fn with_base<S: Into<String>>(base: S) -> Self
pub fn with_base<S: Into<String>>(base: S) -> Self
Construct with an explicit base URL (test / non-localhost cases).
Sourcepub fn with_target_bundle_id<S: Into<String>>(self, bundle: S) -> Self
pub fn with_target_bundle_id<S: Into<String>>(self, bundle: S) -> Self
v0.2.1 — set the target bundle id sent as App-Bundle-Id
header on every subsequent request. Runner rebinds
XCUIApplication(bundleIdentifier:) per request if this differs
from its boot-time default. gol-611-v0.2.1 §Phase B.
Sourcepub fn set_target_bundle_id<S: Into<String>>(&mut self, bundle: S)
pub fn set_target_bundle_id<S: Into<String>>(&mut self, bundle: S)
v0.2.1 — mutable variant of Self::with_target_bundle_id. Used from
the driver-trait pass-through where the driver holds the client
by value and can’t easily use the builder shape.
Sourcepub fn with_auto_activate(self, activate: bool) -> Self
pub fn with_auto_activate(self, activate: bool) -> Self
v0.2.1 — when set, every subsequent request sends
App-Activate: true, causing the runner to .activate() the
resolved target before operating. gol-611-v0.2.1 §Phase B.
Sourcepub fn set_auto_activate(&mut self, activate: bool)
pub fn set_auto_activate(&mut self, activate: bool)
v0.2.1 — mutable variant of Self::with_auto_activate.
Sourcepub fn target_bundle_id(&self) -> Option<&str>
pub fn target_bundle_id(&self) -> Option<&str>
v0.2.1 — accessor for the current target bundle. Used by callers that want to log or diagnose.
Sourcepub fn auto_activate(&self) -> bool
pub fn auto_activate(&self) -> bool
v0.2.1 — accessor for the current auto-activate flag.
Sourcepub async fn health(&self) -> bool
pub async fn health(&self) -> bool
GET /health — bare alive probe (no memoization). Returns true on 2xx.
Sourcepub async fn ensure_reachable(&self) -> Result<(), RunnerTransportError>
pub async fn ensure_reachable(&self) -> Result<(), RunnerTransportError>
GET /health memoized — first call probes; subsequent are no-ops
after one success. Failure raises RunnerTransportError::Unreachable.
Mirrors TS ensureReachable.
Sourcepub async fn get_tree(
&self,
include: Option<IncludeScope>,
) -> Result<A11yNode, RunnerTransportError>
pub async fn get_tree( &self, include: Option<IncludeScope>, ) -> Result<A11yNode, RunnerTransportError>
GET /tree?include= — full a11y tree dump.
v3.5 c3: post-deser pass derive_roles_recursive fills
A11yNode.role from raw_type because the Swift /tree route
only emits rawType on the wire. Without this, Selector::Role
would never match real-sim payloads.
Sourcepub async fn system_popups(
&self,
include: Option<IncludeScope>,
) -> Result<Vec<SystemPopup>, RunnerTransportError>
pub async fn system_popups( &self, include: Option<IncludeScope>, ) -> Result<Vec<SystemPopup>, RunnerTransportError>
GET /system-popups?include= — list system popups.
Sourcepub async fn system_popup_action(
&self,
popup_id: &str,
button_id: &str,
) -> Result<bool, RunnerTransportError>
pub async fn system_popup_action( &self, popup_id: &str, button_id: &str, ) -> Result<bool, RunnerTransportError>
POST /system-popup-action (v4.2 c2 — G9 act side). Tap a button
on a previously enumerated popup. popup_id and button_id are
the Popup.id / PopupButton.id strings returned by
Self::system_popups; the runner walks the same scan order so
the round-trip does not need a host-side id map.
Returns Ok(true) when the runner matched both ids and dispatched
the tap, Ok(false) when the runner returned a 404 not_found
(popup id, button id, or synthesize dispatch missed). Transport
errors and non-2xx-non-404 statuses surface as
RunnerTransportError.
Sourcepub async fn tap(
&self,
selector: &Selector,
mode: TapMode,
include: Option<IncludeScope>,
) -> Result<TapResult, RunnerTransportError>
pub async fn tap( &self, selector: &Selector, mode: TapMode, include: Option<IncludeScope>, ) -> Result<TapResult, RunnerTransportError>
POST /tap — selector → element tap. Errors:
- 404 →
TapNotFoundErrorreturned viaErr(.. Other ..). (TS throws subtype; here we surface via the dedicated variant of a future TapError type — for c8 MVP we keep the simpleRunnerTransportError + body inspectionpattern. Driver layer wraps with ExpectationFailure.)
Sourcepub async fn tap_at_norm_coord(
&self,
nx: f64,
ny: f64,
) -> Result<(), RunnerTransportError>
pub async fn tap_at_norm_coord( &self, nx: f64, ny: f64, ) -> Result<(), RunnerTransportError>
POST /tap-at-norm-coord (v1.6 c5) — Apple native UI event coord tap.
Sourcepub async fn double_tap_at_norm_coord(
&self,
nx: f64,
ny: f64,
) -> Result<(), RunnerTransportError>
pub async fn double_tap_at_norm_coord( &self, nx: f64, ny: f64, ) -> Result<(), RunnerTransportError>
POST /double-tap-at-norm-coord (v6.0 c3c-v) — double-tap at
viewport-normalized coord. Android-specific endpoint backing
AndroidDriver::double_tap after host-resolve. iOS path uses
selector-based /double-tap; this exists for Android where the
runner does its own host-resolve via tree dump.
Sourcepub async fn long_press_at_norm_coord(
&self,
nx: f64,
ny: f64,
duration_ms: u64,
) -> Result<(), RunnerTransportError>
pub async fn long_press_at_norm_coord( &self, nx: f64, ny: f64, duration_ms: u64, ) -> Result<(), RunnerTransportError>
POST /long-press-at-norm-coord (v6.0 c3c-v) — long-press at coord
with explicit duration. Android-specific.
Sourcepub async fn input_text(&self, text: &str) -> Result<(), RunnerTransportError>
pub async fn input_text(&self, text: &str) -> Result<(), RunnerTransportError>
POST /input-text (v6.0 c3c-v) — type text into currently-focused
input. Caller must tap to focus the field first (AndroidDriver
orchestrates). Android-specific.
Sourcepub async fn tap_by_id(&self, id: &str) -> Result<bool, RunnerTransportError>
pub async fn tap_by_id(&self, id: &str) -> Result<bool, RunnerTransportError>
POST /tap-by-id (v5.3 c4) — XCUIElement.tap() via the XCTest
gesture-recognizer chain. Drives SwiftUI .sheet / .alert /
.confirmationDialog / .fullScreenCover dismiss bindings that the
default host-HID-at-coord path can’t trigger. Returns
Ok(true) when the element was found and tapped, Ok(false) when
the runner reported ok=false (element not found / NSException
surfaced through smixGuarded). Parallel to
tap_at_norm_coord; the existing /tap envelope stays untouched.
Sourcepub async fn find_text_by_ocr(
&self,
text: &str,
locales: &[String],
recognition_level: &str,
) -> Result<Option<OcrFrame>, RunnerTransportError>
pub async fn find_text_by_ocr( &self, text: &str, locales: &[String], recognition_level: &str, ) -> Result<Option<OcrFrame>, RunnerTransportError>
POST /find-text-by-ocr (v5.19 c1) — Apple Vision OCR over the
current XCUIScreen screenshot. Returns the matching text
observation’s bounding box normalized to [0, 1] in UIKit coord
space (top-left origin, y-down). Ok(None) when no observation
matches the keyword. L5 sense layer for the a11y-less + i18n
initiative; covers ~40-50% of “lib without testID but with
visible text” scenarios per master plan §1.
locales are BCP-47 language subtags (e.g. ["en"] / ["ja"]);
empty defaults to ["en"] on the swift side. recognition_level
is "accurate" (default, slower + higher accuracy) or "fast".
Sourcepub async fn webview_eval(
&self,
js: &str,
) -> Result<Value, RunnerTransportError>
pub async fn webview_eval( &self, js: &str, ) -> Result<Value, RunnerTransportError>
v5.21 c1b — Eval JS against fixture-side WKWebView bridge (Option
A per a11y-i18n master plan §1 L5+). Does NOT use the XCUITest
runner — POSTs directly to the app-side debug bridge on
127.0.0.1:28080/eval (iOS sim shares host loopback). Returns
the JS eval result as JSON Value or runtime error from the bridge.
Scope: works for any app that exposes the
SmixWebViewBridge (selftest-fixture has it by default; user apps
must opt in). Bridge port is fixed at 28080 today.
Sourcepub async fn double_tap(
&self,
selector: &Selector,
include: Option<IncludeScope>,
) -> Result<TapResult, RunnerTransportError>
pub async fn double_tap( &self, selector: &Selector, include: Option<IncludeScope>, ) -> Result<TapResult, RunnerTransportError>
POST /double-tap (v5.2 c3) — XCUIElement.doubleTap() public API.
Mirrors /tap envelope but issues two-tap gesture on the resolved
element. Maestro doubleTapOn 同源.
Sourcepub async fn long_press(
&self,
selector: &Selector,
duration_ms: u64,
include: Option<IncludeScope>,
) -> Result<TapResult, RunnerTransportError>
pub async fn long_press( &self, selector: &Selector, duration_ms: u64, include: Option<IncludeScope>, ) -> Result<TapResult, RunnerTransportError>
POST /long-press (v5.2 c3) — XCUIElement.press(forDuration:) public
API. duration_ms 来自 maestro yaml duration:, default 500.
Maestro longPressOn 同源.
Sourcepub async fn set_orientation(
&self,
orientation: &str,
) -> Result<(), RunnerTransportError>
pub async fn set_orientation( &self, orientation: &str, ) -> Result<(), RunnerTransportError>
POST /set-orientation (v5.2 c5) — rotate sim via swift
XCUIDevice.shared.orientation setter. orientation literal:
“portrait” | “portraitUpsideDown” | “landscapeLeft” | “landscapeRight”.
Sourcepub async fn swipe_at_norm_coord(
&self,
from: (f64, f64),
to: (f64, f64),
) -> Result<(), RunnerTransportError>
pub async fn swipe_at_norm_coord( &self, from: (f64, f64), to: (f64, f64), ) -> Result<(), RunnerTransportError>
POST /swipe-at-norm-coord (v5.2 c1) — Apple native UI event from-to
swipe. Sibling of Self::tap_at_norm_coord under §9 #3 escape hatch.
Sourcepub async fn find(
&self,
selector: &Selector,
include: Option<IncludeScope>,
) -> Result<bool, RunnerTransportError>
pub async fn find( &self, selector: &Selector, include: Option<IncludeScope>, ) -> Result<bool, RunnerTransportError>
POST /find (v1.2 C4) — boolean existence quick-probe.
Sourcepub async fn fill(
&self,
selector: &Selector,
text: &str,
include: Option<IncludeScope>,
) -> Result<RunnerKeyboardResult, RunnerTransportError>
pub async fn fill( &self, selector: &Selector, text: &str, include: Option<IncludeScope>, ) -> Result<RunnerKeyboardResult, RunnerTransportError>
POST /fill — fill text into focused / matched input.
Sourcepub async fn clear(
&self,
selector: &Selector,
include: Option<IncludeScope>,
) -> Result<RunnerKeyboardResult, RunnerTransportError>
pub async fn clear( &self, selector: &Selector, include: Option<IncludeScope>, ) -> Result<RunnerKeyboardResult, RunnerTransportError>
POST /clear — clear focused / matched input.
Sourcepub async fn press_key(
&self,
key: KeyName,
) -> Result<RunnerKeyboardResult, RunnerTransportError>
pub async fn press_key( &self, key: KeyName, ) -> Result<RunnerKeyboardResult, RunnerTransportError>
POST /press-key — press named key (Return/Tab/Delete/etc.).
Sourcepub async fn scroll(
&self,
selector: &RunnerScrollSelector,
direction: SwipeDirection,
include: Option<IncludeScope>,
) -> Result<u32, RunnerTransportError>
pub async fn scroll( &self, selector: &RunnerScrollSelector, direction: SwipeDirection, include: Option<IncludeScope>, ) -> Result<u32, RunnerTransportError>
POST /scroll {selector, direction, include?} — scroll-until-visible.
Sourcepub async fn swipe_once(
&self,
direction: SwipeDirection,
) -> Result<(), RunnerTransportError>
pub async fn swipe_once( &self, direction: SwipeDirection, ) -> Result<(), RunnerTransportError>
POST /swipe-once {direction} (v1.5 c5i-d) — single swipe, no probe.
Sourcepub async fn foreground(
&self,
bundle_id: &str,
) -> Result<(), RunnerTransportError>
pub async fn foreground( &self, bundle_id: &str, ) -> Result<(), RunnerTransportError>
POST /foreground {bundleId} — bring app to foreground.
Sourcepub async fn hide_keyboard(&self) -> Result<(), RunnerTransportError>
pub async fn hide_keyboard(&self) -> Result<(), RunnerTransportError>
POST /hide-keyboard (v1.5 c5g’’).
Sourcepub async fn back(&self) -> Result<(), RunnerTransportError>
pub async fn back(&self) -> Result<(), RunnerTransportError>
POST /back — back gesture.
Sourcepub async fn start_record(&self) -> Result<(), RunnerTransportError>
pub async fn start_record(&self) -> Result<(), RunnerTransportError>
POST /record/start — begin recording.
Sourcepub async fn poll_record(
&self,
) -> Result<Vec<RecordedEvent>, RunnerTransportError>
pub async fn poll_record( &self, ) -> Result<Vec<RecordedEvent>, RunnerTransportError>
GET /record/poll — drain recorded events.
Sourcepub async fn stop_record(
&self,
) -> Result<Vec<RecordedEvent>, RunnerTransportError>
pub async fn stop_record( &self, ) -> Result<Vec<RecordedEvent>, RunnerTransportError>
POST /record/stop — stop recording, drain final events.