Struct re_viewer::external::egui_kittest::HarnessBuilder
pub struct HarnessBuilder<State = ()> {
pub(crate) screen_rect: Rect,
pub(crate) pixels_per_point: f32,
pub(crate) max_steps: u64,
pub(crate) step_dt: f32,
pub(crate) state: PhantomData<State>,
pub(crate) renderer: Box<dyn TestRenderer>,
}
Expand description
Builder for Harness
.
Fields§
§screen_rect: Rect
§pixels_per_point: f32
§max_steps: u64
§step_dt: f32
§state: PhantomData<State>
§renderer: Box<dyn TestRenderer>
Implementations§
§impl<State> HarnessBuilder<State>
impl<State> HarnessBuilder<State>
pub fn with_size(self, size: impl Into<Vec2>) -> HarnessBuilder<State>
pub fn with_size(self, size: impl Into<Vec2>) -> HarnessBuilder<State>
Set the size of the window.
pub fn with_pixels_per_point(
self,
pixels_per_point: f32,
) -> HarnessBuilder<State>
pub fn with_pixels_per_point( self, pixels_per_point: f32, ) -> HarnessBuilder<State>
Set the pixels_per_point
of the window.
pub fn with_max_steps(self, max_steps: u64) -> HarnessBuilder<State>
pub fn with_max_steps(self, max_steps: u64) -> HarnessBuilder<State>
Set the maximum number of steps to run when calling Harness::run
.
Default is 4.
With the default step_dt
, this means 1 second of simulation.
pub fn with_step_dt(self, step_dt: f32) -> HarnessBuilder<State>
pub fn with_step_dt(self, step_dt: f32) -> HarnessBuilder<State>
Set the time delta for a single Harness::step
.
Default is 1.0 / 4.0 (4fps). The default is low so we don’t waste cpu waiting for animations.
pub fn renderer(
self,
renderer: impl TestRenderer + 'static,
) -> HarnessBuilder<State>
pub fn renderer( self, renderer: impl TestRenderer + 'static, ) -> HarnessBuilder<State>
Set the TestRenderer
to use for rendering.
By default, a LazyRenderer
is used.
pub fn wgpu(self) -> HarnessBuilder<State>
pub fn wgpu(self) -> HarnessBuilder<State>
Enable wgpu rendering with a default setup suitable for testing.
This sets up a crate::wgpu::WgpuTestRenderer
with the default setup.
pub fn wgpu_setup(self, setup: WgpuSetup) -> HarnessBuilder<State>
pub fn wgpu_setup(self, setup: WgpuSetup) -> HarnessBuilder<State>
Enable wgpu rendering with the given setup.
pub fn build_state<'a>(
self,
app: impl FnMut(&Context, &mut State) + 'a,
state: State,
) -> Harness<'a, State>
pub fn build_state<'a>( self, app: impl FnMut(&Context, &mut State) + 'a, state: State, ) -> Harness<'a, State>
Create a new Harness with the given app closure and a state.
The app closure will immediately be called once to create the initial ui.
If you don’t need to create Windows / Panels, you can use HarnessBuilder::build_ui
instead.
§Example
let checked = false;
let mut harness = Harness::builder()
.with_size(egui::Vec2::new(300.0, 200.0))
.build_state(|ctx, checked| {
CentralPanel::default().show(ctx, |ui| {
ui.checkbox(checked, "Check me!");
});
}, checked);
harness.get_by_label("Check me!").click();
harness.run();
assert_eq!(*harness.state(), true);
pub fn build_ui_state<'a>(
self,
app: impl FnMut(&mut Ui, &mut State) + 'a,
state: State,
) -> Harness<'a, State>
pub fn build_ui_state<'a>( self, app: impl FnMut(&mut Ui, &mut State) + 'a, state: State, ) -> Harness<'a, State>
Create a new Harness with the given ui closure and a state.
The ui closure will immediately be called once to create the initial ui.
If you need to create Windows / Panels, you can use HarnessBuilder::build
instead.
§Example
let mut checked = false;
let mut harness = Harness::builder()
.with_size(egui::Vec2::new(300.0, 200.0))
.build_ui_state(|ui, checked| {
ui.checkbox(checked, "Check me!");
}, checked);
harness.get_by_label("Check me!").click();
harness.run();
assert_eq!(*harness.state(), true);
pub fn build_eframe<'a>(
self,
build: impl FnOnce(&mut CreationContext<'a>) -> State,
) -> Harness<'a, State>where
State: App,
pub fn build_eframe<'a>(
self,
build: impl FnOnce(&mut CreationContext<'a>) -> State,
) -> Harness<'a, State>where
State: App,
Create a new Harness from the given eframe creation closure.
The app can be accessed via the Harness::state
/ Harness::state_mut
methods.
§impl HarnessBuilder
impl HarnessBuilder
pub fn build<'a>(self, app: impl FnMut(&Context) + 'a) -> Harness<'a>
pub fn build<'a>(self, app: impl FnMut(&Context) + 'a) -> Harness<'a>
Create a new Harness with the given app closure.
The app closure will immediately be called once to create the initial ui.
If you don’t need to create Windows / Panels, you can use HarnessBuilder::build_ui
instead.
§Example
let mut harness = Harness::builder()
.with_size(egui::Vec2::new(300.0, 200.0))
.build(|ctx| {
CentralPanel::default().show(ctx, |ui| {
ui.label("Hello, world!");
});
});
pub fn build_ui<'a>(self, app: impl FnMut(&mut Ui) + 'a) -> Harness<'a>
pub fn build_ui<'a>(self, app: impl FnMut(&mut Ui) + 'a) -> Harness<'a>
Create a new Harness with the given ui closure.
The ui closure will immediately be called once to create the initial ui.
If you need to create Windows / Panels, you can use HarnessBuilder::build
instead.
§Example
let mut harness = Harness::builder()
.with_size(egui::Vec2::new(300.0, 200.0))
.build_ui(|ui| {
ui.label("Hello, world!");
});
Trait Implementations§
§impl<State> Default for HarnessBuilder<State>
impl<State> Default for HarnessBuilder<State>
§fn default() -> HarnessBuilder<State>
fn default() -> HarnessBuilder<State>
Auto Trait Implementations§
impl<State> Freeze for HarnessBuilder<State>
impl<State = ()> !RefUnwindSafe for HarnessBuilder<State>
impl<State = ()> !Send for HarnessBuilder<State>
impl<State = ()> !Sync for HarnessBuilder<State>
impl<State> Unpin for HarnessBuilder<State>where
State: Unpin,
impl<State = ()> !UnwindSafe for HarnessBuilder<State>
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
source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
§impl<T> Conv for T
impl<T> Conv for 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> 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 moresource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request
source§impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
source§fn lossless_try_into(self) -> Option<Dst>
fn lossless_try_into(self) -> Option<Dst>
source§impl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
impl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
source§fn lossy_into(self) -> Dst
fn lossy_into(self) -> Dst
§impl<T> NoneValue for Twhere
T: Default,
impl<T> NoneValue for Twhere
T: Default,
type NoneType = T
§fn null_value() -> T
fn null_value() -> T
source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.