dynamic-animation/src/androidTest/java/androidx/dynamicanimation/tests/SpringTests.java
@Test
    public void testSetMinMax() {
        final SpringAnimation anim = new SpringAnimation(mView1, DynamicAnimation.SCALE_X, 0.0f);
        anim.setMinValue(0.0f);
        anim.setMaxValue(1.0f);
        anim.getSpring().setStiffness(SpringForce.STIFFNESS_HIGH).setDampingRatio(
                SpringForce.DAMPING_RATIO_HIGH_BOUNCY);

        final DynamicAnimation.OnAnimationUpdateListener mockUpdateListener = mock(
                DynamicAnimation.OnAnimationUpdateListener.class);
        final DynamicAnimation.OnAnimationEndListener mockEndListener = mock(
                DynamicAnimation.OnAnimationEndListener.class);
        final DynamicAnimation.OnAnimationUpdateListener updateListener =
                new DynamicAnimation.OnAnimationUpdateListener() {

            @Override
            public void onAnimationUpdate(DynamicAnimation animation, float value, float velocity) {
                assertTrue(value >= 0.0f);
                assertTrue(value <= 1.0f);
            }
        };

        InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() {
            @Override
            public void run() {
                anim.setStartValue(1.0f).setStartVelocity(8000f)
                        .addEndListener(mockEndListener).addUpdateListener(mockUpdateListener)
                        .addUpdateListener(updateListener).start();
            }});

        verify(mockEndListener, timeout(2000)).onAnimationEnd(anim, false, 0f, 0f);
        verify(mockUpdateListener, atLeast(2)).onAnimationUpdate(eq(anim), any(float.class),
                any(float.class));
    }
/**
     * Verifies that once min and max value threshold does apply to the values in animation.
     */
Verifies that once min and max value threshold does apply to the values in animation.
Verifies that once min and max value threshold does apply to the values in animation .
@Test
    public void testSetMinMax() {
        final SpringAnimation anim = new SpringAnimation(mView1, DynamicAnimation.SCALE_X, 0.0f);
        anim.setMinValue(0.0f);
        anim.setMaxValue(1.0f);
        anim.getSpring().setStiffness(SpringForce.STIFFNESS_HIGH).setDampingRatio(
                SpringForce.DAMPING_RATIO_HIGH_BOUNCY);
        final DynamicAnimation.OnAnimationUpdateListener mockUpdateListener = mock(
                DynamicAnimation.OnAnimationUpdateListener.class);
        final DynamicAnimation.OnAnimationEndListener mockEndListener = mock(
                DynamicAnimation.OnAnimationEndListener.class);
        final DynamicAnimation.OnAnimationUpdateListener updateListener =
                new DynamicAnimation.OnAnimationUpdateListener() {
            @Override
            public void onAnimationUpdate(DynamicAnimation animation, float value, float velocity) {
                assertTrue(value >= 0.0f);
                assertTrue(value <= 1.0f);
            }
        };
        InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() {
            @Override
            public void run() {
                anim.setStartValue(1.0f).setStartVelocity(8000f)
                        .addEndListener(mockEndListener).addUpdateListener(mockUpdateListener)
                        .addUpdateListener(updateListener).start();
            }});
        verify(mockEndListener, timeout(2000)).onAnimationEnd(anim, false, 0f, 0f);
        verify(mockUpdateListener, atLeast(2)).onAnimationUpdate(eq(anim), any(float.class),
                any(float.class));
    }
@ Test public void testSetMinMax ( ) { final SpringAnimation anim = new SpringAnimation ( mView1 , DynamicAnimation . SCALE_X , 0.0f ) ; anim . setMinValue ( 0.0f ) ; anim . setMaxValue ( 1.0f ) ; anim . getSpring ( ) . setStiffness ( SpringForce . STIFFNESS_HIGH ) . setDampingRatio ( SpringForce . DAMPING_RATIO_HIGH_BOUNCY ) ; final DynamicAnimation . OnAnimationUpdateListener mockUpdateListener = mock ( DynamicAnimation . OnAnimationUpdateListener . class ) ; final DynamicAnimation . OnAnimationEndListener mockEndListener = mock ( DynamicAnimation . OnAnimationEndListener . class ) ; final DynamicAnimation . OnAnimationUpdateListener updateListener = new DynamicAnimation . OnAnimationUpdateListener ( ) { @ Override public void onAnimationUpdate ( DynamicAnimation animation , float value , float velocity ) { assertTrue ( value >= 0.0f ) ; assertTrue ( value <= 1.0f ) ; } } ; InstrumentationRegistry . getInstrumentation ( ) . runOnMainSync ( new Runnable ( ) { @ Override public void run ( ) { anim . setStartValue ( 1.0f ) . setStartVelocity ( 8000f ) . addEndListener ( mockEndListener ) . addUpdateListener ( mockUpdateListener ) . addUpdateListener ( updateListener ) . start ( ) ; } } ) ; verify ( mockEndListener , timeout ( 2000 ) ) . onAnimationEnd ( anim , false , 0f , 0f ) ; verify ( mockUpdateListener , atLeast ( 2 ) ) . onAnimationUpdate ( eq ( anim ) , any ( float . class ) , any ( float . class ) ) ; }
Verifies that once min and max value threshold does apply to the values in animation.
Verifies that once min and max value threshold does apply to the values in animation .