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

Commit c2076853 authored by Paul Sowden's avatar Paul Sowden Committed by Gerrit Code Review
Browse files

Merge "Only set `mEnded` to true if `pulseAnimationFrame` returns true" into main

parents 322a4767 a172b3f1
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -1311,8 +1311,9 @@ public final class AnimatorSet extends Animator implements AnimationHandler.Anim
        if (!node.mEnded) {
            float durationScale = ValueAnimator.getDurationScale();
            durationScale = durationScale == 0  ? 1 : durationScale;
            node.mEnded = node.mAnimation.pulseAnimationFrame(
                    (long) (animPlayTime * durationScale));
            if (node.mAnimation.pulseAnimationFrame((long) (animPlayTime * durationScale))) {
                node.mEnded = true;
            }
        }
    }

+15 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package android.animation;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import android.util.PollingCheck;
@@ -342,6 +343,20 @@ public class AnimatorSetCallsTest {
        });
    }

    @Test
    public void childAnimatorCancelsDuringUpdate_animatorSetIsEnded() throws Throwable {
        mAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                animation.cancel();
            }
        });
        mActivity.runOnUiThread(() -> {
            mSet1.start();
            assertFalse(mSet1.isRunning());
        });
    }

    @Test
    public void reentrantStart() throws Throwable {
        CountDownLatch latch = new CountDownLatch(3);