dynamic-animation/src/androidTest/java/androidx/dynamicanimation/tests/SpringTests.java
@Test
    public void testCustomProperties() {
        final Object animObj = new Object();
        FloatPropertyCompat property = new FloatPropertyCompat("") {
            private float mValue = 0f;
            @Override
            public float getValue(Object object) {
                assertEquals(animObj, object);
                return mValue;
            }

            @Override
            public void setValue(Object object, float value) {
                assertEquals(animObj, object);
                assertTrue(value >= mValue);
                mValue = value;
            }
        };
        final SpringAnimation anim = new SpringAnimation(animObj, property, 1f);
        DynamicAnimation.OnAnimationEndListener listener = mock(
                DynamicAnimation.OnAnimationEndListener.class);
        anim.addEndListener(listener);
        InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() {
            @Override
            public void run() {
                anim.start();
            }
        });
        verify(listener, timeout(1000)).onAnimationEnd(anim, false, 1f, 0f);
        assertEquals(1f, property.getValue(animObj), 0f);
    }
/**
     * Test that custom properties are supported.
     */
Test that custom properties are supported.
Test that custom properties are supported .
@Test
    public void testCustomProperties() {
        final Object animObj = new Object();
        FloatPropertyCompat property = new FloatPropertyCompat("") {
            private float mValue = 0f;
            @Override
            public float getValue(Object object) {
                assertEquals(animObj, object);
                return mValue;
            }
            @Override
            public void setValue(Object object, float value) {
                assertEquals(animObj, object);
                assertTrue(value >= mValue);
                mValue = value;
            }
        };
        final SpringAnimation anim = new SpringAnimation(animObj, property, 1f);
        DynamicAnimation.OnAnimationEndListener listener = mock(
                DynamicAnimation.OnAnimationEndListener.class);
        anim.addEndListener(listener);
        InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() {
            @Override
            public void run() {
                anim.start();
            }
        });
        verify(listener, timeout(1000)).onAnimationEnd(anim, false, 1f, 0f);
        assertEquals(1f, property.getValue(animObj), 0f);
    }
@ Test public void testCustomProperties ( ) { final Object animObj = new Object ( ) ; FloatPropertyCompat property = new FloatPropertyCompat ( "" ) { private float mValue = 0f ; @ Override public float getValue ( Object object ) { assertEquals ( animObj , object ) ; return mValue ; } @ Override public void setValue ( Object object , float value ) { assertEquals ( animObj , object ) ; assertTrue ( value >= mValue ) ; mValue = value ; } } ; final SpringAnimation anim = new SpringAnimation ( animObj , property , 1f ) ; DynamicAnimation . OnAnimationEndListener listener = mock ( DynamicAnimation . OnAnimationEndListener . class ) ; anim . addEndListener ( listener ) ; InstrumentationRegistry . getInstrumentation ( ) . runOnMainSync ( new Runnable ( ) { @ Override public void run ( ) { anim . start ( ) ; } } ) ; verify ( listener , timeout ( 1000 ) ) . onAnimationEnd ( anim , false , 1f , 0f ) ; assertEquals ( 1f , property . getValue ( animObj ) , 0f ) ; }
Test that custom properties are supported.
Test that custom properties are supported .