6월 3일의 ⁠#Android11: 베타 버전 출시 행사에 참여하세요.

AnimationClockTestRule

class AnimationClockTestRule : TestRule
kotlin.Any
   ↳ androidx.ui.test.AnimationClockTestRule

A TestRule to monitor and take over the animation clock in the composition. It substitutes the ambient animation clock provided at the root of the composition tree with a TestAnimationClock and registers it with registerTestClock.

Usually you don't need to create this rule by yourself, it is done for you in ComposeTestRule. If you don't use ComposeTestRule, use this rule in your test and make sure it is run before your activity is created.

If your app provides a custom animation clock somewhere in your composition, make sure to have it implement TestAnimationClock and register it with registerTestClock. Alternatively, if you use Espresso you can create your own IdlingResource to let Espresso await your animations. Otherwise, built in steps that make sure the UI is stable when performing actions or assertions will fail to work.

Summary

Public constructors

A TestRule to monitor and take over the animation clock in the composition.

Public methods

Unit
advanceClock(milliseconds: Long)

Convenience method for calling clock.advanceClock()

Statement
apply(base: Statement, description: Description?)

Unit

Convenience method for calling clock.pauseClock()

Unit

Convenience method for calling clock.resumeClock()

Properties

TestAnimationClock

The ambient animation clock that is provided at the root of the composition tree.

Boolean

Convenience property for calling clock.isPaused

Public constructors

<init>

AnimationClockTestRule()

A TestRule to monitor and take over the animation clock in the composition. It substitutes the ambient animation clock provided at the root of the composition tree with a TestAnimationClock and registers it with registerTestClock.

Usually you don't need to create this rule by yourself, it is done for you in ComposeTestRule. If you don't use ComposeTestRule, use this rule in your test and make sure it is run before your activity is created.

If your app provides a custom animation clock somewhere in your composition, make sure to have it implement TestAnimationClock and register it with registerTestClock. Alternatively, if you use Espresso you can create your own IdlingResource to let Espresso await your animations. Otherwise, built in steps that make sure the UI is stable when performing actions or assertions will fail to work.

Public methods

advanceClock

fun advanceClock(milliseconds: Long): Unit

Convenience method for calling clock.advanceClock()

apply

fun apply(
    base: Statement,
    description: Description?
): Statement

pauseClock

fun pauseClock(): Unit

Convenience method for calling clock.pauseClock()

resumeClock

fun resumeClock(): Unit

Convenience method for calling clock.resumeClock()

Properties

clock

val clock: TestAnimationClock

The ambient animation clock that is provided at the root of the composition tree. Typically, apps will only use this clock. If your app provides another clock in the tree, make sure to let it implement TestAnimationClock and register it with registerTestClock.

isPaused

val isPaused: Boolean

Convenience property for calling clock.isPaused