Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4d400935 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add test for regression in Animators" into udc-dev

parents 2b7011a1 d35b9731
Loading
Loading
Loading
Loading
+25 −0
Original line number Diff line number Diff line
@@ -1127,6 +1127,31 @@ public class ValueAnimatorTests {
        mActivityRule.runOnUiThread(() -> {});
    }

    @Test
    public void restartValueAnimator() throws Throwable {
        CountDownLatch latch = new CountDownLatch(1);
        ValueAnimator.AnimatorUpdateListener listener = new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                if (((float) animation.getAnimatedValue()) != A1_START_VALUE) {
                    latch.countDown();
                }
            }
        };
        a1.addUpdateListener(listener);

        mActivityRule.runOnUiThread(() -> {
            a1.start();
        });

        // wait for a change in the value
        assertTrue(latch.await(2, TimeUnit.SECONDS));

        mActivityRule.runOnUiThread(() -> {
            a1.start();
            assertEquals(A1_START_VALUE, a1.getAnimatedValue());
        });
    }
    class MyUpdateListener implements ValueAnimator.AnimatorUpdateListener {
        boolean wasRunning = false;
        long firstRunningFrameTime = -1;