Issue
I have a simple Espresso test that's failing to assert visibility due to what I'd assume to be an animation issue. I have disabled all animation settings on the device.
bannerLayout.animate()
.y(0)
.setInterpolator(new DecelerateInterpolator(1));
and my assertion in Espresso is
onView(withId(R.id.banner_layout)).check(matches(not(isDisplayed())));
Adding a sleep before the assertion makes the test pass.
Solution
I found that explicitly forcing the animation to start instead of relying on the framework to start it fixed the issue.
bannerLayout.animate()
.y(0)
.setInterpolator(new DecelerateInterpolator(1))
.start();
The Android docs state:
void start ()
Starts the currently pending property animations immediately. Calling start() is optional because all animations start automatically at the next opportunity. However, if the animations are needed to start immediately and synchronously (not at the time when the next event is processed by the hierarchy, which is when the animations would begin otherwise), then this method can be used.
For simple animations, this should be fine. If you've got some complex scenario with performance concerns, this may not be the way to go.
Answered By - loeschg
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.