pub struct MockHost {Show 40 fields
pub config: String,
pub values: BTreeMap<String, String>,
pub secrets: BTreeMap<String, String>,
pub account: AccountState,
pub driving: bool,
pub theme: Theme,
pub capabilities: Capabilities,
pub focused_pane: Option<String>,
pub claimed_elsewhere: BTreeSet<String>,
pub claims: BTreeSet<String>,
pub emitted: Vec<(String, String, Target)>,
pub published: Vec<(String, String)>,
pub live_deleted: Vec<String>,
pub listening: BTreeSet<String>,
pub call_answers: BTreeMap<String, String>,
pub calls: Vec<MockCall>,
pub denials: Vec<String>,
pub panes: Vec<Pane>,
pub frame_request: Option<u64>,
pub opened: Vec<String>,
pub opened_urls: Vec<String>,
pub focused_panes: Vec<String>,
pub now_ms: u64,
pub url_gesture_ms: Option<u64>,
pub closed: Vec<String>,
pub gesture: bool,
pub machine_id: Option<String>,
pub account_id: Option<String>,
pub lease_epoch: Option<u64>,
pub release: Option<Release>,
pub instance_id: String,
pub environment: Vec<(String, String)>,
pub wall_ms: u64,
pub utc_offset_minutes: i32,
pub time_zone: Option<String>,
pub health: Option<(Health, String)>,
pub tints: BTreeMap<String, u32>,
pub requested: BTreeMap<String, (u32, u32)>,
pub labels: BTreeMap<String, String>,
pub carets: BTreeMap<String, (u32, u32)>,
/* private fields */
}Expand description
Fields§
§config: String§values: BTreeMap<String, String>§secrets: BTreeMap<String, String>§account: AccountState§driving: bool§theme: Theme§capabilities: Capabilities§focused_pane: Option<String>§claimed_elsewhere: BTreeSet<String>Claims another viewer holds: claiming these fails.
claims: BTreeSet<String>Claims this instance holds.
emitted: Vec<(String, String, Target)>events.emit calls: name, payload, target.
published: Vec<(String, String)>live.publish calls: key, payload.
live_deleted: Vec<String>live.delete calls: the keys withdrawn, in order.
listening: BTreeSet<String>Patterns events.on registered.
call_answers: BTreeMap<String, String>calls.call and call-async answers by method (the companion’s
side); a method without one answers invalid.
calls: Vec<MockCall>Every calls.call, send and call-async, in order.
denials: Vec<String>Grants the plugin was denied, in order.
panes: Vec<Pane>§frame_request: Option<u64>A frame the plugin asked for outside frame()
(crate::Context::request_frame or wake_at): the earliest
viewer instant, 0 for “the next frame”.
opened: Vec<String>Surfaces open opened, in order.
opened_urls: Vec<String>URLs url::open opened, in order.
focused_panes: Vec<String>Panes focus_pane asked the viewer to focus, in order.
now_ms: u64The viewer clock of the last Harness::frame, for the url.open
input window.
url_gesture_ms: Option<u64>When the last user input was delivered (now_ms then), until a URL
opened for it.
closed: Vec<String>Surfaces close closed, in order.
gesture: boolWhether the plugin is handling a user gesture now (the harness sets it around key, paste, pointer-press and command events).
machine_id: Option<String>The machine the plugin runs on: a daemon’s Context::machine_id, a
viewer’s view::machine_id.
account_id: Option<String>A daemon’s Context::account_id.
lease_epoch: Option<u64>daemon-context.lease-epoch: a singleton’s epoch, None for fleet
(MockHost::singleton).
release: Option<Release>The build daemon::Context::release reports.
instance_id: StringA viewer’s view::instance_id.
environment: Vec<(String, String)>A daemon plugin’s environment (daemon::env).
wall_ms: u64view::wall_ms: milliseconds since the Unix epoch.
utc_offset_minutes: i32view::utc_offset_minutes.
time_zone: Option<String>view::time_zone.
health: Option<(Health, String)>The plugin’s last health::set: its state and message.
tints: BTreeMap<String, u32>Identity tints by machine or project id (view::surface_tint,
view::identity_tint).
requested: BTreeMap<String, (u32, u32)>Sizes the plugin asked for, by surface (request_size), bounded as
the host bounds them.
labels: BTreeMap<String, String>Labels the plugin set, by surface (set_label).
carets: BTreeMap<String, (u32, u32)>Carets the plugin set, by surface (set_caret): column and row.
Implementations§
Source§impl MockHost
impl MockHost
Sourcepub fn http(self, method: &str, url_prefix: &str, response: Response) -> Self
pub fn http(self, method: &str, url_prefix: &str, response: Response) -> Self
Queues response for the next request of method (GET, POST,
…; * for any) whose URL starts with url_prefix. Each queued
answer is used once, in the order queued; a request nothing matches
fails with Error::Unavailable.
Sourcepub fn queue_http(
&mut self,
method: &str,
url_prefix: &str,
answer: Result<Response>,
)
pub fn queue_http( &mut self, method: &str, url_prefix: &str, answer: Result<Response>, )
Queues an answer, a failure included (Error::Unavailable("timeout")
is what a request past its timeout gets), on a running host:
harness.host(|host| host.queue_http(...)).
Sourcepub fn http_requests(&self) -> &[Request]
pub fn http_requests(&self) -> &[Request]
Every request the grants let through, in order, as the plugin built it (method, URL, headers, body, timeout, body cap).
Sourcepub fn http_pending(&self) -> usize
pub fn http_pending(&self) -> usize
Answers queued and not used yet.
Source§impl MockHost
impl MockHost
Sourcepub fn websockets(&self) -> &[MockWebSocket]
pub fn websockets(&self) -> &[MockWebSocket]
The WebSockets the plugin opened, in order.
Sourcepub fn websocket_event(&mut self, socket: u32, kind: &str, text: &str)
pub fn websocket_event(&mut self, socket: u32, kind: &str, text: &str)
Delivers a socket’s news to the plugin as the host would
(system.net.websocket): kind open, message (with text) or
closed (with text as the reason).
Sourcepub fn script(self, program: &str, script: ProcessScript) -> Self
pub fn script(self, program: &str, script: ProcessScript) -> Self
Answers every spawn of program (as spawned, any arguments) with
script. A later script for the same program wins.
Sourcepub fn script_args(
self,
program: &str,
args: &[&str],
script: ProcessScript,
) -> Self
pub fn script_args( self, program: &str, args: &[&str], script: ProcessScript, ) -> Self
Answers spawns of program whose arguments start with args.
Sourcepub fn processes(&self) -> &[MockProcess]
pub fn processes(&self) -> &[MockProcess]
Every child the plugin spawned, in order.
Sourcepub fn pane_launches(&self) -> &[MockPaneLaunch]
pub fn pane_launches(&self) -> &[MockPaneLaunch]
The watches the plugin holds. The panes the plugin opened, in order.
pub fn watches(&self) -> &[MockWatch]
Source§impl MockHost
impl MockHost
Sourcepub fn clock(
self,
wall_ms: u64,
utc_offset_minutes: i32,
time_zone: Option<&str>,
) -> Self
pub fn clock( self, wall_ms: u64, utc_offset_minutes: i32, time_zone: Option<&str>, ) -> Self
The viewer’s wall clock and time zone.
Sourcepub fn singleton(self, epoch: u64) -> Self
pub fn singleton(self, epoch: u64) -> Self
Runs a daemon plugin as a singleton under lease epoch.
Sourcepub fn env(self, name: &str, value: &str) -> Self
pub fn env(self, name: &str, value: &str) -> Self
Sets one variable of a daemon plugin’s environment.
Sourcepub fn surface(self, id: &str, model: Model) -> Self
pub fn surface(self, id: &str, model: Model) -> Self
Declares a surface the way a manifest does, with no size yet.
Sourcepub fn machine_surface(self, id: &str, model: Model) -> Self
pub fn machine_surface(self, id: &str, model: Model) -> Self
Declares a machine.after surface: its instances are
<surface>@<machine>.
Sourcepub fn project_surface(self, id: &str, model: Model) -> Self
pub fn project_surface(self, id: &str, model: Model) -> Self
Declares a project.after surface: its instances are
<surface>@<project>.
pub fn driving(self, driving: bool) -> Self
Sourcepub fn set_geometry(&mut self, id: &str, geometry: Geometry) -> Option<Event>
pub fn set_geometry(&mut self, id: &str, geometry: Geometry) -> Option<Event>
Sets a surface’s size, as the viewer’s layout does. Returns the
resize event to deliver (the Harness delivers it).
Sourcepub fn set_model(&mut self, id: &str, model: Model) -> Option<Event>
pub fn set_model(&mut self, id: &str, model: Model) -> Option<Event>
Switches the model the viewer uses for a surface that lists several: the plugin sees it as a resize.
Sourcepub fn commits(&self, id: &str) -> Vec<MockCommit>
pub fn commits(&self, id: &str) -> Vec<MockCommit>
Every commit of a surface, oldest first.