LithoAnimationTestRule

class LithoAnimationTestRule(afterFrame: () -> Unit = {}) : TestRule

JUnit rule that installs a deterministic animation frame driver for the duration of a test.

This rule keeps AnimationController global while giving animation tests explicit control over frame delivery and frame timestamps. advanceBy and advanceTo advance animation elapsed time: if an animation is scheduled but has not received its first frame yet, the rule first dispatches a frame at the current test time, then advances to the requested time. Tests that need Litho or Robolectric work flushed after each frame can provide afterFrame, for example shadowOf(getMainLooper()).idle().

Constructors

Link copied to clipboard
constructor(afterFrame: () -> Unit = {})

Properties

Link copied to clipboard

Functions

Link copied to clipboard
fun advanceBy(duration: Duration)

Advances animation elapsed time by duration, bootstrapping newly scheduled animations.

Link copied to clipboard
fun advanceTo(frameTimeNanos: Long)

Advances animation elapsed time until frameTimeNanos, bootstrapping scheduled animations.

fun advanceTo(frameTime: Duration)

Advances animation elapsed time until frameTime, bootstrapping newly scheduled animations.

Link copied to clipboard
open override fun apply(base: Statement, description: Description): Statement
Link copied to clipboard
Link copied to clipboard
fun runNextFrame(frameDelay: Duration = 16.ms)

Runs one raw frame after frameDelay. New duration-based animations start on this frame.