pub struct ComposeTestRule { /* private fields */ }Expand description
Headless harness for exercising compositions in tests.
ComposeTestRule mirrors the ergonomics of the Jetpack Compose testing APIs
while remaining lightweight and allocation-friendly for unit tests. It owns
an in-memory applier and exposes helpers for driving recomposition and
draining frame callbacks without requiring a windowing backend.
Implementations§
Source§impl ComposeTestRule
impl ComposeTestRule
Sourcepub fn set_content(
&mut self,
content: impl FnMut() + 'static,
) -> Result<(), NodeError>
pub fn set_content( &mut self, content: impl FnMut() + 'static, ) -> Result<(), NodeError>
Install the provided content into the composition and perform an initial render.
Sourcepub fn recomposition(&mut self) -> Result<(), NodeError>
pub fn recomposition(&mut self) -> Result<(), NodeError>
Force a recomposition using the currently installed content.
Sourcepub fn advance_frame(&mut self, frame_time_nanos: u64) -> Result<(), NodeError>
pub fn advance_frame(&mut self, frame_time_nanos: u64) -> Result<(), NodeError>
Drain scheduled frame callbacks at the supplied timestamp and process any resulting work until the composition becomes idle.
Sourcepub fn pump_until_idle(&mut self) -> Result<(), NodeError>
pub fn pump_until_idle(&mut self) -> Result<(), NodeError>
Drive the composition until there are no pending renders, invalidated scopes, or enqueued node mutations remaining.
Sourcepub fn runtime_handle(&self) -> RuntimeHandle
pub fn runtime_handle(&self) -> RuntimeHandle
Access the runtime driving this rule. Useful for constructing shared state objects within the composition.
Sourcepub fn applier_mut(&mut self) -> ApplierGuard<'_, MemoryApplier>
pub fn applier_mut(&mut self) -> ApplierGuard<'_, MemoryApplier>
Gain mutable access to the underlying in-memory applier for assertions about the produced node tree.
Sourcepub fn has_content(&self) -> bool
pub fn has_content(&self) -> bool
Returns whether user content has been installed in this rule.
Sourcepub fn root_id(&self) -> Option<NodeId>
pub fn root_id(&self) -> Option<NodeId>
Returns the id of the root node produced by the current composition.
Sourcepub fn composition(&mut self) -> &mut Composition<MemoryApplier>
pub fn composition(&mut self) -> &mut Composition<MemoryApplier>
Gain mutable access to the raw composition for advanced scenarios.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ComposeTestRule
impl !RefUnwindSafe for ComposeTestRule
impl !Send for ComposeTestRule
impl !Sync for ComposeTestRule
impl Unpin for ComposeTestRule
impl UnsafeUnpin for ComposeTestRule
impl !UnwindSafe for ComposeTestRule
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§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.Source§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.Source§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.Source§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.