pub struct TestHarness<P: Plugin> { /* private fields */ }Expand description
Drives a plugin through the same FFI adapter the host uses.
Implementations§
Source§impl<P: Plugin> TestHarness<P>
impl<P: Plugin> TestHarness<P>
Sourcepub fn new() -> Result<Self, String>
pub fn new() -> Result<Self, String>
Creates the plugin with test_init. Like eov, this sets the
language tr! translates with, here English, for the whole plugin
library (see the module documentation).
Sourcepub fn with_init(init: PluginInit) -> Result<Self, String>
pub fn with_init(init: PluginInit) -> Result<Self, String>
Creates the plugin with init, switching tr! to init.language
(English when None) for the whole plugin library, or for this
thread with the thread-local-language feature, and loading the
catalog that plugin.toml in init.plugin_root declares for it.
Sourcepub fn with_host(host: MockHost, init: PluginInit) -> Result<Self, String>
pub fn with_host(host: MockHost, init: PluginInit) -> Result<Self, String>
Uses a prepared mock (e.g. with a snapshot or region reader set).
Sets the language as Self::with_init does.
pub fn host(&self) -> &MockHost
pub fn state(&self) -> MutexGuard<'_, MockState>
Sourcepub fn calls_to(&self, method: &str) -> Vec<Value>
pub fn calls_to(&self, method: &str) -> Vec<Value>
The arguments of every call to method so far.
Sourcepub fn send(&self, event: HostEvent) -> Result<Value, FfiError>
pub fn send(&self, event: HostEvent) -> Result<Value, FfiError>
Delivers an event; returns the plugin’s JSON response.
Requests context-menu items.
Sourcepub fn open_slide(
&self,
request: &SlideOpenRequest,
) -> Result<TestSlide, FfiError>
pub fn open_slide( &self, request: &SlideOpenRequest, ) -> Result<TestSlide, FfiError>
Invokes a surface callback.
Opens a slide through the plugin’s slide source as eov does, through
the FFI: what TestSlide returns is what eov would get.
pub fn ui_callback( &self, surface_id: &str, name: &str, args: Vec<Value>, ) -> Result<Value, FfiError>
Sourcepub fn last_model_fetch(&self) -> Option<(String, ModelFetchArgs)>
pub fn last_model_fetch(&self) -> Option<(String, ModelFetchArgs)>
The last model.fetch request: the request id it was answered with
and its arguments.
Sourcepub fn finish_model_fetch(
&self,
request_id: &str,
outcome: Result<ModelRecord, String>,
) -> Result<Value, FfiError>
pub fn finish_model_fetch( &self, request_id: &str, outcome: Result<ModelRecord, String>, ) -> Result<Value, FfiError>
Answers the model.fetch request request_id as eov does: with the
stored model (which then also goes into the mock’s model store, so
model.resolve finds it) or with the error eov reported.
Sourcepub fn cancel_model_fetch(&self, request_id: &str) -> Result<Value, FfiError>
pub fn cancel_model_fetch(&self, request_id: &str) -> Result<Value, FfiError>
Answers request_id as eov does when the user declines or cancels
the download.
Sourcepub fn apply_filter(
&self,
filter_id: &str,
pixels: &mut [u8],
width: u32,
height: u32,
view: FilterView,
) -> Result<(), FfiError>
pub fn apply_filter( &self, filter_id: &str, pixels: &mut [u8], width: u32, height: u32, view: FilterView, ) -> Result<(), FfiError>
Runs a filter over a tightly packed RGBA buffer.
Trait Implementations§
Source§impl<P: Plugin> Drop for TestHarness<P>
impl<P: Plugin> Drop for TestHarness<P>
Auto Trait Implementations§
impl<P> !Unpin for TestHarness<P>
impl<P> Forget for TestHarness<P>
impl<P> Freeze for TestHarness<P>
impl<P> Move for TestHarness<P>
impl<P> RefUnwindSafe for TestHarness<P>
impl<P> Send for TestHarness<P>
impl<P> Sync for TestHarness<P>
impl<P> UnsafeUnpin for TestHarness<P>
impl<P> UnwindSafe for TestHarness<P>
Blanket Implementations§
Source§impl<T> AlignerFor<1> for T
impl<T> AlignerFor<1> for T
Source§impl<T> AlignerFor<2> for T
impl<T> AlignerFor<2> for T
Source§impl<T> AlignerFor<4> for T
impl<T> AlignerFor<4> for T
Source§impl<T> AlignerFor<8> for T
impl<T> AlignerFor<8> for T
Source§impl<T> AlignerFor<16> for T
impl<T> AlignerFor<16> for T
Source§impl<T> AlignerFor<32> for T
impl<T> AlignerFor<32> for T
Source§impl<T> AlignerFor<64> for T
impl<T> AlignerFor<64> for T
Source§impl<T> AlignerFor<128> for T
impl<T> AlignerFor<128> for T
Source§type Aligner = AlignTo128<T>
type Aligner = AlignTo128<T>
AlignTo* type which aligns Self to ALIGNMENT.Source§impl<T> AlignerFor<256> for T
impl<T> AlignerFor<256> for T
Source§type Aligner = AlignTo256<T>
type Aligner = AlignTo256<T>
AlignTo* type which aligns Self to ALIGNMENT.Source§impl<T> AlignerFor<512> for T
impl<T> AlignerFor<512> for T
Source§type Aligner = AlignTo512<T>
type Aligner = AlignTo512<T>
AlignTo* type which aligns Self to ALIGNMENT.Source§impl<T> AlignerFor<1024> for T
impl<T> AlignerFor<1024> for T
Source§type Aligner = AlignTo1024<T>
type Aligner = AlignTo1024<T>
AlignTo* type which aligns Self to ALIGNMENT.Source§impl<T> AlignerFor<2048> for T
impl<T> AlignerFor<2048> for T
Source§type Aligner = AlignTo2048<T>
type Aligner = AlignTo2048<T>
AlignTo* type which aligns Self to ALIGNMENT.Source§impl<T> AlignerFor<4096> for T
impl<T> AlignerFor<4096> for T
Source§type Aligner = AlignTo4096<T>
type Aligner = AlignTo4096<T>
AlignTo* type which aligns Self to ALIGNMENT.Source§impl<T> AlignerFor<8192> for T
impl<T> AlignerFor<8192> for T
Source§type Aligner = AlignTo8192<T>
type Aligner = AlignTo8192<T>
AlignTo* type which aligns Self to ALIGNMENT.Source§impl<T> AlignerFor<16384> for T
impl<T> AlignerFor<16384> for T
Source§type Aligner = AlignTo16384<T>
type Aligner = AlignTo16384<T>
AlignTo* type which aligns Self to ALIGNMENT.Source§impl<T> AlignerFor<32768> for T
impl<T> AlignerFor<32768> for T
Source§type Aligner = AlignTo32768<T>
type Aligner = AlignTo32768<T>
AlignTo* type which aligns Self to ALIGNMENT.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, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<S> ROExtAcc for S
impl<S> ROExtAcc for S
Source§fn f_get<F>(&self, offset: FieldOffset<S, F, Aligned>) -> &F
fn f_get<F>(&self, offset: FieldOffset<S, F, Aligned>) -> &F
offset. Read moreSource§fn f_get_mut<F>(&mut self, offset: FieldOffset<S, F, Aligned>) -> &mut F
fn f_get_mut<F>(&mut self, offset: FieldOffset<S, F, Aligned>) -> &mut F
offset. Read moreSource§fn f_get_ptr<F, A>(&self, offset: FieldOffset<S, F, A>) -> *const F
fn f_get_ptr<F, A>(&self, offset: FieldOffset<S, F, A>) -> *const F
offset. Read moreSource§fn f_get_mut_ptr<F, A>(&mut self, offset: FieldOffset<S, F, A>) -> *mut F
fn f_get_mut_ptr<F, A>(&mut self, offset: FieldOffset<S, F, A>) -> *mut F
offset. Read moreSource§impl<S> ROExtOps<Aligned> for S
impl<S> ROExtOps<Aligned> for S
Source§fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Aligned>, value: F) -> F
fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Aligned>, value: F) -> F
offset) with value,
returning the previous value of the field. Read moreSource§fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Aligned>) -> Fwhere
F: Copy,
fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Aligned>) -> Fwhere
F: Copy,
Source§impl<S> ROExtOps<Unaligned> for S
impl<S> ROExtOps<Unaligned> for S
Source§fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Unaligned>, value: F) -> F
fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Unaligned>, value: F) -> F
offset) with value,
returning the previous value of the field. Read moreSource§fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Unaligned>) -> Fwhere
F: Copy,
fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Unaligned>) -> Fwhere
F: Copy,
Source§impl<T> SelfOps for Twhere
T: ?Sized,
impl<T> SelfOps for Twhere
T: ?Sized,
Source§fn piped<F, U>(self, f: F) -> U
fn piped<F, U>(self, f: F) -> U
Source§fn piped_ref<'a, F, U>(&'a self, f: F) -> Uwhere
F: FnOnce(&'a Self) -> U,
fn piped_ref<'a, F, U>(&'a self, f: F) -> Uwhere
F: FnOnce(&'a Self) -> U,
piped except that the function takes &Self
Useful for functions that take &Self instead of Self. Read moreSource§fn piped_mut<'a, F, U>(&'a mut self, f: F) -> Uwhere
F: FnOnce(&'a mut Self) -> U,
fn piped_mut<'a, F, U>(&'a mut self, f: F) -> Uwhere
F: FnOnce(&'a mut Self) -> U,
piped, except that the function takes &mut Self.
Useful for functions that take &mut Self instead of Self.Source§fn mutated<F>(self, f: F) -> Self
fn mutated<F>(self, f: F) -> Self
Source§fn observe<F>(self, f: F) -> Self
fn observe<F>(self, f: F) -> Self
Source§fn as_ref_<T>(&self) -> &T
fn as_ref_<T>(&self) -> &T
AsRef,
using the turbofish .as_ref_::<_>() syntax. Read more