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

Commit a0942e21 authored by Doris Liu's avatar Doris Liu
Browse files

Test ValueAnimator when duration scale is set to 0

Change-Id: I33a90bc39d3b451696752eae02edfacb4ddfd80e
parent 2c35eb81
Loading
Loading
Loading
Loading
+41 −0
Original line number Original line Diff line number Diff line
@@ -864,6 +864,47 @@ public class ValueAnimatorTests extends ActivityInstrumentationTestCase2<BasicAn
        });
        });
    }
    }


    @SmallTest
    public void testZeroScale() throws Throwable {
        // Test whether animations would end properly when the scale is forced to be zero
        float scale = ValueAnimator.getDurationScale();
        ValueAnimator.setDurationScale(0f);

        // Run two animators, one of which has a start delay, after setting the duration scale to 0
        a1.setStartDelay(200);
        final MyListener l1 =  new MyListener();
        final MyListener l2 = new MyListener();
        a1.addListener(l1);
        a2.addListener(l2);

        runTestOnUiThread(new Runnable() {
            @Override
            public void run() {
                assertFalse(l1.startCalled);
                assertFalse(l2.startCalled);
                assertFalse(l1.endCalled);
                assertFalse(l2.endCalled);

                a1.start();
                a2.start();
            }
        });
        Thread.sleep(POLL_INTERVAL);

        runTestOnUiThread(new Runnable() {
            @Override
            public void run() {
                assertTrue(l1.startCalled);
                assertTrue(l2.startCalled);
                assertTrue(l1.endCalled);
                assertTrue(l2.endCalled);
            }
        });

        // Restore duration scale
        ValueAnimator.setDurationScale(scale);
    }

    @SmallTest
    @SmallTest
    public void testReverse() throws Throwable {
    public void testReverse() throws Throwable {
        // Prolong animators duration so that we can do multiple checks during their run
        // Prolong animators duration so that we can do multiple checks during their run