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.