https://kotlinlang.org logo
#compose
Title
# compose
m

mattinger

03/12/2024, 1:46 PM
Good morning everyone, I’m having some issues with compose navigation and espresso tests. I have an enter transition defined as follows:
Copy code
fun AnimatedContentTransitionScope<NavBackStackEntry>.slideInEnterTransition() =
    slideIntoContainer(
        AnimatedContentTransitionScope.SlideDirection.Left,
        animationSpec = tween(1000)
    )
However, even with the
android.testOptions.animationsDisabled
flag set to true in the build.gradle.kts, i get intermittent failures trying to assert things like:
assertIsDisplayed
after clicking to apply a transition. There’s also times where doing things like clicking gets ignored because it’s off screen. I have noticed that after the click, the component tree says that the particular item in question has a left coordinate that is outside of the screen bounds. I would have expected that with animations disabled, it would not do that and instead just render it on screen immediately. However, if i instead check deliberately in code and replace the animation, the problem goes away:
Copy code
if  (Build.VERSION.SDK_INT >= 26 &&  ValueAnimator.areAnimatorsEnabled().not())
    EnterTransition.None
else
    ...