OSDN Git Service

Testing initial value for 0-duration animations
authorDoris Liu <tianliu@google.com>
Fri, 26 Feb 2016 02:37:06 +0000 (18:37 -0800)
committerDoris Liu <tianliu@google.com>
Fri, 26 Feb 2016 03:24:41 +0000 (03:24 +0000)
To ensure consistency with the pre-N animation behavior, we are testing
the following:

- For animations that have a duration of 0, we set the animator's value
  to the end value when start() is called.
- For animations with a duration > 0 but with the duration scale of 0
  applied, we set the animator's value to its start value when start()
  gets called.

Change-Id: I666105e0677c6cfdeddb11b483d71dab978adc11

core/tests/coretests/src/android/animation/ValueAnimatorTests.java

index 998c72a..aa21b1d 100644 (file)
@@ -900,6 +900,10 @@ public class ValueAnimatorTests extends ActivityInstrumentationTestCase2<BasicAn
                 a1.start();
                 a2.reverse();
                 a3.start();
+                // Check that the animators' values are immediately set to end value in the case of
+                // 0-duration.
+                assertEquals(A1_END_VALUE, a1.getAnimatedValue());
+                assertEquals(A2_START_VALUE, a2.getAnimatedValue());
             }
         });
         Thread.sleep(POLL_INTERVAL);
@@ -946,6 +950,10 @@ public class ValueAnimatorTests extends ActivityInstrumentationTestCase2<BasicAn
 
                 a1.start();
                 a2.start();
+
+                // In the case of 0 duration scale applied to a non-0 duration, check that the
+                // value is immediately set to the start value.
+                assertEquals(A2_START_VALUE, a2.getAnimatedValue());
             }
         });
         Thread.sleep(POLL_INTERVAL);
@@ -957,6 +965,8 @@ public class ValueAnimatorTests extends ActivityInstrumentationTestCase2<BasicAn
                 assertTrue(l2.startCalled);
                 assertTrue(l1.endCalled);
                 assertTrue(l2.endCalled);
+                assertEquals(A1_END_VALUE, a1.getAnimatedValue());
+                assertEquals(A2_END_VALUE, a2.getAnimatedValue());
             }
         });