Struct TestEngine
pub struct TestEngine { /* private fields */ }Implementations§
§impl TestEngine
impl TestEngine
pub fn new() -> Arc<TestEngine> ⓘ
pub fn commands(&self) -> Vec<WebViewCommand>
pub fn commands(&self) -> Vec<WebViewCommand>
Every command received so far, in order.
pub fn current_uri(&self) -> Option<String>
pub fn set_media_element(&self, media: Option<MediaElementInfo>)
pub fn set_media_element(&self, media: Option<MediaElementInfo>)
Configure the deterministic response to a media-element probe.
pub fn visibility_changes(&self) -> Vec<bool>
pub fn visibility_changes(&self) -> Vec<bool>
Every visibility change the engine was told, oldest first.
pub fn set_paint_snapshot(&self, snapshot: impl Into<String>)
pub fn set_paint_snapshot(&self, snapshot: impl Into<String>)
Answer every later paint capture with this layout snapshot (raw
DOMSnapshot JSON), as a real engine would for its current page.
pub fn set_measures_document(&self, measures: bool)
pub fn set_measures_document(&self, measures: bool)
Say the engine measures its document (answers
WebViewCommand::ReportDocumentSize), as a ready host that can does.
pub fn push_new_tab_request(&self, url: impl Into<String>)
pub fn push_new_tab_request(&self, url: impl Into<String>)
Say the page asked to open url in a new window, as a link the
person followed does.
pub fn push_popup(
&self,
id: u32,
url: impl Into<String>,
width: u32,
height: u32,
)
pub fn push_popup( &self, id: u32, url: impl Into<String>, width: u32, height: u32, )
Say the page opened a popup, as window.open with a size does. An
engine nobody asked for popups ignores it, as Chromium’s opens it
as a tab.
pub fn accepts_popups(&self) -> bool
pub fn accepts_popups(&self) -> bool
Whether it was asked for the page’s popups.
pub fn accepts_page_dialogs(&self) -> bool
pub fn accepts_page_dialogs(&self) -> bool
Whether it was asked for the page’s own questions.
pub fn created_tabs(&self) -> Vec<Arc<TestEngine>>
pub fn created_tabs(&self) -> Vec<Arc<TestEngine>>
The tabs it created, oldest first.
pub fn adopted(&self, id: u32) -> Option<Arc<TestEngine>>
pub fn adopted(&self, id: u32) -> Option<Arc<TestEngine>>
The engine a popup was adopted as.
pub fn set_selection(&self, text: impl Into<String>)
pub fn set_selection(&self, text: impl Into<String>)
Say the page has text selected: a later
WebViewCommand::CopySelection answers with it.
pub fn set_text_field(&self, field: Option<TextField>)
pub fn set_text_field(&self, field: Option<TextField>)
Report the page’s focused field (None: nothing editable has the
focus), as a host that takes compositions does.
pub fn hold_frames(&self, hold: bool)
pub fn hold_frames(&self, hold: bool)
Hold back every frame, as a renderer still laying out a page does, or paint the page at the view’s current size now.
pub fn mark_page_end(&self)
pub fn mark_page_end(&self)
Paint its pages with a document’s end mark: the bottom-right 2×2
pixels one level off the page beneath, as a mail’s document marks
them (mix-blend-mode: difference with rgb(1,1,1)).
pub fn paint_before_page(&self)
pub fn paint_before_page(&self)
Paint the view at its current size in the page’s background colour and nothing of the page, as Chromium paints a resized view before the page has drawn there.
pub fn paint_stale(&self, width: u32, height: u32)
pub fn paint_stale(&self, width: u32, height: u32)
Deliver a frame painted for an earlier width × height, as an
engine does that finishes a paint after the view has moved on.
pub fn fail_address(&self, uri: impl Into<String>, error: impl Into<String>)
pub fn fail_address(&self, uri: impl Into<String>, error: impl Into<String>)
Make every load of uri fail with the network error
(ERR_CONNECTION_REFUSED), as an unreachable site does: the engine
reports the address, the failure and its history, and an owned
navigation’s outcome carries the error.
pub fn push_event(&self, event: WebViewEvent)
pub fn push_event(&self, event: WebViewEvent)
Deliver event on the next drain, as the engine would on its own (a
page reporting its document size).
pub fn set_page_capture(&self, image: impl Into<Vec<u8>>)
pub fn set_page_capture(&self, image: impl Into<Vec<u8>>)
Answer every later page capture with these pixels (a PNG), as a real engine paints the page it shows.
pub fn push_page_reply(&self, reply: Result<PageReply, PageFailure>)
pub fn push_page_reply(&self, reply: Result<PageReply, PageFailure>)
Queue the answer to the next page request. Without one, an outline is a single document line and every other request succeeds.
pub fn page_color(uri: &str) -> [u8; 3]
pub fn page_color(uri: &str) -> [u8; 3]
Stable page colour for a URL — exposed so tests can compute the expected pixels.
Trait Implementations§
§impl WebViewEngine for TestEngine
impl WebViewEngine for TestEngine
§fn measures_document(&self) -> bool
fn measures_document(&self) -> bool
WebViewCommand::ReportDocumentSize is answered: the
engine measures its document. Known once the engine is ready.§fn supports_composition(&self) -> bool
fn supports_composition(&self) -> bool
WebViewCommand::ImeComposition, WebViewCommand::ImeCommit)
and reports the page’s focused field (Self::text_field).§fn text_field(&self) -> Option<TextField>
fn text_field(&self) -> Option<TextField>
None while nothing editable in the page has the focus.§fn take_new_tab_requests(&self) -> Vec<(String, bool)>
fn take_new_tab_requests(&self) -> Vec<(String, bool)>
§fn create_tab(&self) -> Result<Arc<dyn WebViewEngine>, String>
fn create_tab(&self) -> Result<Arc<dyn WebViewEngine>, String>
§fn accept_popups(&self)
fn accept_popups(&self)
window.open with a size: a sign-in,
a payment) opened as popups of this page, which can answer it,
rather than as tabs: Self::take_popups then lists them. An engine
that cannot goes on opening them as tabs.§fn accept_page_dialogs(&self)
fn accept_page_dialogs(&self)
alert, confirm, prompt, “leave
this page?”) sent as WebViewEvent::PageDialog for the embedder to
show and answer. Until then, and in an engine that cannot, each is
declined at once and a page may always be left.§fn take_popups(&self) -> Vec<Popup>
fn take_popups(&self) -> Vec<Popup>
§fn adopt_popup(&self, popup: u32) -> Result<Arc<dyn WebViewEngine>, String>
fn adopt_popup(&self, popup: u32) -> Result<Arc<dyn WebViewEngine>, String>
Self::take_popups listed, to show it.
Dropping it closes the popup. Read more§fn set_visible(&self, visible: bool)
fn set_visible(&self, visible: bool)
§fn send(&self, cmd: WebViewCommand)
fn send(&self, cmd: WebViewCommand)
fn frames(&self) -> Arc<Mutex<Option<Frame>>> ⓘ
§fn drain_events(&self) -> Vec<WebViewEvent>
fn drain_events(&self) -> Vec<WebViewEvent>
fn supports_text_input(&self) -> bool
§fn supports_guarded_edit_history(&self) -> bool
fn supports_guarded_edit_history(&self) -> bool
§fn handle_undo_request(&self, request: UndoRequest) -> bool
fn handle_undo_request(&self, request: UndoRequest) -> bool
§fn text_input(&self, request: Request) -> Option<Receipt>
fn text_input(&self, request: Request) -> Option<Receipt>
§fn set_modifiers(&self, modifiers: KeyModifiers)
fn set_modifiers(&self, modifiers: KeyModifiers)
WebViewEvent::ClipboardWrite,
and its pastes and reads asked of the embedder
(WebViewEvent::ClipboardRead), where the engine cannot reach the
system clipboard itself. Until then, and in an engine that can or
cannot ask, the page’s clipboard is the engine’s own.§fn supports_native_filtering(&self) -> bool
fn supports_native_filtering(&self) -> bool
WebKit JSON.§fn paint_seq(&self) -> u64
fn paint_seq(&self) -> u64
Self::paint_frame’s Frame::seq):
moves on with every change to what the page draws, so a widget
repaints exactly when the page did. 0 for an engine that paints
pixels rather than a display list.§fn request_close(&self) -> bool
fn request_close(&self) -> bool
TabClosed, TabDetached or TabCloseBlocked.§fn drain_download_events(&self) -> Vec<WebViewEvent>
fn drain_download_events(&self) -> Vec<WebViewEvent>
§fn set_waker(&self, _waker: Box<dyn Fn() + Send + Sync>)
fn set_waker(&self, _waker: Box<dyn Fn() + Send + Sync>)
§fn presented(&self)
fn presented(&self)
paint::PaintEngine) resume here.§fn wrapped(&self) -> Option<&Arc<dyn WebViewEngine>>
fn wrapped(&self) -> Option<&Arc<dyn WebViewEngine>>
§fn cursor(&self) -> Option<CursorIcon>
fn cursor(&self) -> Option<CursorIcon>
None for the default arrow, or
an engine that does not say.§fn paint_frame(&self) -> Option<Arc<Frame>>
fn paint_frame(&self) -> Option<Arc<Frame>>
§fn paint_blob(&self, _hash: &[u8; 32]) -> Option<Arc<Vec<u8>>>
fn paint_blob(&self, _hash: &[u8; 32]) -> Option<Arc<Vec<u8>>>
paint_frame references.§fn take_paint_stream(&self, _keyframe: bool) -> Vec<Payload>
fn take_paint_stream(&self, _keyframe: bool) -> Vec<Payload>
keyframe (or when the consumer must start over), else the patches
since the last call, followed by images not sent yet. Empty for an
engine without a display list.Auto Trait Implementations§
impl !Freeze for TestEngine
impl RefUnwindSafe for TestEngine
impl Send for TestEngine
impl Sync for TestEngine
impl Unpin for TestEngine
impl UnsafeUnpin for TestEngine
impl UnwindSafe for TestEngine
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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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