dynamic-animation/src/androidTest/java/androidx/dynamicanimation/tests/SpringTests.java
public void testScaleMinChange() {
        FloatValueHolder valueHolder = new FloatValueHolder(0.5f);
        final SpringAnimation anim = new SpringAnimation(valueHolder);
        DynamicAnimation.OnAnimationUpdateListener mockListener =
                mock(DynamicAnimation.OnAnimationUpdateListener.class);
        anim.addUpdateListener(mockListener);

        final DynamicAnimation.OnAnimationEndListener endListener =
                mock(DynamicAnimation.OnAnimationEndListener.class);
        anim.addEndListener(endListener);

        InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() {
            @Override
            public void run() {
                anim.animateToFinalPosition(1f);
            }
        });

        verify(endListener, timeout(500)).onAnimationEnd(anim, false, 0, 0);
        verify(mockListener, atMost(5)).onAnimationUpdate(eq(anim), anyFloat(), anyFloat());

        assertEquals(DynamicAnimation.MIN_VISIBLE_CHANGE_PIXELS, anim.getMinimumVisibleChange(),
                0.01f);

        // Set the right threshold and start again.
        anim.setMinimumVisibleChange(DynamicAnimation.MIN_VISIBLE_CHANGE_SCALE);
        anim.setStartValue(0.5f);

        InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() {
            @Override
            public void run() {
                anim.animateToFinalPosition(1f);
            }
        });

        verify(endListener, timeout(2000)).onAnimationEnd(anim, false, 0, 0);
        verify(mockListener, atLeast(10)).onAnimationUpdate(eq(anim), anyFloat(), anyFloat());
    }
/**
     * Check that the min visible change does affect how soon spring animations end.
     */
Check that the min visible change does affect how soon spring animations end.
Check that the min visible change does affect how soon spring animations end .
public void testScaleMinChange() {
        FloatValueHolder valueHolder = new FloatValueHolder(0.5f);
        final SpringAnimation anim = new SpringAnimation(valueHolder);
        DynamicAnimation.OnAnimationUpdateListener mockListener =
                mock(DynamicAnimation.OnAnimationUpdateListener.class);
        anim.addUpdateListener(mockListener);
        final DynamicAnimation.OnAnimationEndListener endListener =
                mock(DynamicAnimation.OnAnimationEndListener.class);
        anim.addEndListener(endListener);
        InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() {
            @Override
            public void run() {
                anim.animateToFinalPosition(1f);
            }
        });
        verify(endListener, timeout(500)).onAnimationEnd(anim, false, 0, 0);
        verify(mockListener, atMost(5)).onAnimationUpdate(eq(anim), anyFloat(), anyFloat());
        assertEquals(DynamicAnimation.MIN_VISIBLE_CHANGE_PIXELS, anim.getMinimumVisibleChange(),
                0.01f);
        anim.setMinimumVisibleChange(DynamicAnimation.MIN_VISIBLE_CHANGE_SCALE);
        anim.setStartValue(0.5f);
        InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() {
            @Override
            public void run() {
                anim.animateToFinalPosition(1f);
            }
        });
        verify(endListener, timeout(2000)).onAnimationEnd(anim, false, 0, 0);
        verify(mockListener, atLeast(10)).onAnimationUpdate(eq(anim), anyFloat(), anyFloat());
    }
public void testScaleMinChange ( ) { FloatValueHolder valueHolder = new FloatValueHolder ( 0.5f ) ; final SpringAnimation anim = new SpringAnimation ( valueHolder ) ; DynamicAnimation . OnAnimationUpdateListener mockListener = mock ( DynamicAnimation . OnAnimationUpdateListener . class ) ; anim . addUpdateListener ( mockListener ) ; final DynamicAnimation . OnAnimationEndListener endListener = mock ( DynamicAnimation . OnAnimationEndListener . class ) ; anim . addEndListener ( endListener ) ; InstrumentationRegistry . getInstrumentation ( ) . runOnMainSync ( new Runnable ( ) { @ Override public void run ( ) { anim . animateToFinalPosition ( 1f ) ; } } ) ; verify ( endListener , timeout ( 500 ) ) . onAnimationEnd ( anim , false , 0 , 0 ) ; verify ( mockListener , atMost ( 5 ) ) . onAnimationUpdate ( eq ( anim ) , anyFloat ( ) , anyFloat ( ) ) ; assertEquals ( DynamicAnimation . MIN_VISIBLE_CHANGE_PIXELS , anim . getMinimumVisibleChange ( ) , 0.01f ) ; anim . setMinimumVisibleChange ( DynamicAnimation . MIN_VISIBLE_CHANGE_SCALE ) ; anim . setStartValue ( 0.5f ) ; InstrumentationRegistry . getInstrumentation ( ) . runOnMainSync ( new Runnable ( ) { @ Override public void run ( ) { anim . animateToFinalPosition ( 1f ) ; } } ) ; verify ( endListener , timeout ( 2000 ) ) . onAnimationEnd ( anim , false , 0 , 0 ) ; verify ( mockListener , atLeast ( 10 ) ) . onAnimationUpdate ( eq ( anim ) , anyFloat ( ) , anyFloat ( ) ) ; }
Check that the min visible change does affect how soon spring animations end.
Check that the min visible change does affect how soon spring animations end .
// Set the right threshold and start again.