Test Cases for android.animation
ValueAnimator, ObjectAnimator, TypeEvaluator, TimeInterpolator

Change-Id: Ibce490022298d310ded511834aff28556d223adf
diff --git a/tests/tests/animation/src/android/animation/cts/AnimationActivity.java b/tests/tests/animation/src/android/animation/cts/AnimationActivity.java
index ee3202e..43679c8 100644
--- a/tests/tests/animation/src/android/animation/cts/AnimationActivity.java
+++ b/tests/tests/animation/src/android/animation/cts/AnimationActivity.java
@@ -58,7 +58,6 @@
     float mDeltaY = 200f;
     long mDuration = 1000;
     public AnimationView view = null;
-    private boolean isAnimationRunning = false;
 
     @Override
     public void onCreate(Bundle bundle){
@@ -92,12 +91,12 @@
     }
 
     public ValueAnimator createAnimatorWithRepeatMode(int repeatMode) {
-        return createAnimator(view.newBall, "y", 1000,ValueAnimator.INFINITE, repeatMode,
+        return createAnimator(view.newBall, "y", 1000, ValueAnimator.INFINITE, repeatMode,
                 new AccelerateInterpolator(), mStartY, mStartY + mDeltaY);
     }
 
     public ValueAnimator createAnimatorWithRepeatCount(int repeatCount) {
-        return createAnimator(view.newBall, "y", 1000,repeatCount, ValueAnimator.REVERSE,
+        return createAnimator(view.newBall, "y", 1000, repeatCount, ValueAnimator.REVERSE,
                 new AccelerateInterpolator(), mStartY, mStartY + mDeltaY);
     }
 
@@ -106,46 +105,98 @@
                 ValueAnimator.REVERSE,new AccelerateInterpolator(), mStartY, mStartY + mDeltaY);
     }
 
+    public ValueAnimator createAnimatorWithInterpolator(TimeInterpolator interpolator){
+        return createAnimator(view.newBall, "y", 1000, ValueAnimator.INFINITE, ValueAnimator.REVERSE,
+                interpolator, mStartY, mStartY + mDeltaY);
+    }
+
+    public ValueAnimator createObjectAnimatorForInt(Object object,String propertyName,
+            long duration, int repeatCount, int repeatMode, TimeInterpolator timeInterpolator,
+            int start, int end) {
+        ObjectAnimator objAnimator = ObjectAnimator.ofInt(object, propertyName, start,end);
+        objAnimator.setDuration(duration);
+
+        objAnimator.setRepeatCount(repeatCount);
+        objAnimator.setInterpolator(timeInterpolator);
+        objAnimator.setRepeatMode(repeatMode);
+        return objAnimator;
+    }
+
+    public ValueAnimator createObjectAnimatorForInt() {
+        ObjectAnimator objAnimator = ObjectAnimator.ofInt(view.newBall, "y", (int)mStartY,
+            (int)(mStartY + mDeltaY));
+        objAnimator.setDuration(mDuration);
+
+        objAnimator.setRepeatCount(ValueAnimator.INFINITE);
+        objAnimator.setInterpolator(new AccelerateInterpolator());
+        objAnimator.setRepeatMode(ValueAnimator.REVERSE);
+        return objAnimator;
+    }
+
     public void startAnimation(long duration){
         ValueAnimator bounceAnimator = ObjectAnimator.ofFloat(view.newBall, "y", mStartY,
-                mStartY + mDeltaY);
+            mStartY + mDeltaY);
         bounceAnimator.setDuration(duration);
         bounceAnimator.setRepeatCount(ValueAnimator.INFINITE);
         bounceAnimator.setInterpolator(new AccelerateInterpolator());
         bounceAnimator.setRepeatMode(ValueAnimator.REVERSE);
         view.bounceAnimator = bounceAnimator;
+        view.startColorAnimator();
         view.animateBall();
     }
 
     public void startAnimation(ValueAnimator valueAnimator){
         view.bounceAnimator = valueAnimator;
+        view.startColorAnimator();
         view.animateBall();
-        isAnimationRunning = true;
+    }
+
+    public void startAnimation(ObjectAnimator bounceAnimator) {
+        view.bounceAnimator = bounceAnimator;
+        view.startColorAnimator();
+        view.animateBall();
+    }
+
+    public void startAnimation(ObjectAnimator bounceAnimator, ObjectAnimator colorAnimator) {
+        view.bounceAnimator = bounceAnimator;
+        view.startColorAnimator(colorAnimator);
+        view.animateBall();
+    }
+
+    public void startColorAnimation(ValueAnimator colorAnimator){
+        view.startColorAnimator(colorAnimator);
     }
 
     public class AnimationView extends View {
-        private static final int RED = 0xffFF8080;
-        private static final int BLUE = 0xff8080FF;
+        public static final int RED = 0xffFF8080;
+        public static final int BLUE = 0xff8080FF;
         public ShapeHolder newBall = null;
         public final ArrayList<ShapeHolder> balls = new ArrayList<ShapeHolder>();
         AnimatorSet animation = null;
         public ValueAnimator bounceAnimator;
+        public ValueAnimator colorAnimator;
 
         public AnimationView(Context context) {
             super(context);
-            ValueAnimator colorAnim = ObjectAnimator.ofInt(this, "backgroundColor", RED, BLUE);
-            colorAnim.setDuration(1000);
-            colorAnim.setEvaluator(new ArgbEvaluator());
-            colorAnim.setRepeatCount(1);
-            colorAnim.setRepeatMode(ValueAnimator.REVERSE);
-            colorAnim.start();
             newBall = addBall(mBallHeight, mBallWidth);
         }
 
+        public void startColorAnimator() {
+            colorAnimator = ObjectAnimator.ofInt(this, "backgroundColor", RED, BLUE);
+            colorAnimator.setDuration(1000);
+            colorAnimator.setEvaluator(new ArgbEvaluator());
+            colorAnimator.setRepeatCount(ValueAnimator.INFINITE);
+            colorAnimator.setRepeatMode(ValueAnimator.REVERSE);
+            colorAnimator.start();
+        }
+
+        public void startColorAnimator(ValueAnimator animator) {
+            this.colorAnimator = animator;
+            colorAnimator.start();
+        }
+
         @Override
         public boolean onTouchEvent(MotionEvent event) {
-
-
             return true;
         }
 
@@ -203,4 +254,3 @@
         }
     }
 }
-
diff --git a/tests/tests/animation/src/android/animation/cts/ArgbEvaluatorTest.java b/tests/tests/animation/src/android/animation/cts/ArgbEvaluatorTest.java
new file mode 100644
index 0000000..33c3716
--- /dev/null
+++ b/tests/tests/animation/src/android/animation/cts/ArgbEvaluatorTest.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.animation.cts;
+
+import android.animation.ArgbEvaluator;
+import android.graphics.Color;
+import android.test.InstrumentationTestCase;
+
+public class ArgbEvaluatorTest extends InstrumentationTestCase {
+    public void testEvaluate() throws Throwable {
+        final int RED =  0xffFF8080;
+        final int BLUE = 0xff8080FF;
+        int aRED = Color.alpha(RED);
+        int rRED = Color.red(RED);
+        int gRED = Color.green(RED);
+        int bRED = Color.blue(RED);
+        int aBLUE = Color.alpha(BLUE);
+        int rBLUE = Color.red(BLUE);
+        int gBLUE = Color.green(BLUE);
+        int bBLUE = Color.blue(BLUE);
+
+        final ArgbEvaluator evaluator = new ArgbEvaluator();
+        class AnimationRunnable implements Runnable{
+            int result;
+            public void run() {
+                result = (Integer) evaluator.evaluate(0.5f, RED, BLUE);
+            }
+        }
+        AnimationRunnable aRunnable = new AnimationRunnable();
+        this.runTestOnUiThread(aRunnable);
+        Thread.sleep(100);
+        int result = aRunnable.result;
+
+        int aResult = Color.alpha(result);
+        int rResult = Color.red(result);
+        int gResult = Color.green(result);
+        int bResult = Color.blue(result);
+        assertTrue(aResult >= aRED);
+        assertTrue(aResult <= aBLUE);
+        assertTrue(rResult <= rRED);
+        assertTrue(rResult >= rBLUE);
+        assertTrue(gResult >= gRED);
+        assertTrue(gResult <= gBLUE);
+        assertTrue(bResult >= bRED);
+        assertTrue(bResult <= bBLUE);
+    }
+}
+
diff --git a/tests/tests/animation/src/android/animation/cts/FloatEvaluatorTest.java b/tests/tests/animation/src/android/animation/cts/FloatEvaluatorTest.java
new file mode 100644
index 0000000..8cc1ffe
--- /dev/null
+++ b/tests/tests/animation/src/android/animation/cts/FloatEvaluatorTest.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.animation.cts;
+
+import android.animation.FloatEvaluator;
+import android.test.InstrumentationTestCase;
+
+public class FloatEvaluatorTest extends InstrumentationTestCase {
+    public void testEvaluate() {
+        float start = 0.0f;
+        float end = 1.0f;
+        float fraction = 0.5f;
+        FloatEvaluator floatEvaluator = new FloatEvaluator();
+        float result = floatEvaluator.evaluate(fraction, start, end);
+        assertTrue(result >= (fraction*start));
+        assertTrue(result <= (fraction*end));
+    }
+}
+
diff --git a/tests/tests/animation/src/android/animation/cts/IntEvaluatorTest.java b/tests/tests/animation/src/android/animation/cts/IntEvaluatorTest.java
new file mode 100644
index 0000000..11df20c
--- /dev/null
+++ b/tests/tests/animation/src/android/animation/cts/IntEvaluatorTest.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.animation.cts;
+
+import android.animation.IntEvaluator;
+import android.test.InstrumentationTestCase;
+
+public class IntEvaluatorTest extends InstrumentationTestCase {
+    public void testEvaluate() throws Throwable {
+        final int start = 0;
+        final int end = 100;
+        final float fraction = 0.5f;
+        final IntEvaluator intEvaluator = new IntEvaluator();
+        class AnimationRunnable implements Runnable{
+            int result;
+            public void run() {
+                result = intEvaluator.evaluate(fraction, start, end);
+            }
+        }
+        AnimationRunnable aRunnable = new AnimationRunnable();
+        this.runTestOnUiThread(aRunnable);
+        Thread.sleep(1);
+        int result = aRunnable.result;
+        assertTrue(result >= (fraction*start));
+        assertTrue(result <= (fraction*end));
+    }
+}
+
diff --git a/tests/tests/animation/src/android/animation/cts/ObjectAnimatorTest.java b/tests/tests/animation/src/android/animation/cts/ObjectAnimatorTest.java
new file mode 100644
index 0000000..be5c1d4
--- /dev/null
+++ b/tests/tests/animation/src/android/animation/cts/ObjectAnimatorTest.java
@@ -0,0 +1,269 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.animation.cts;
+
+import android.animation.ArgbEvaluator;
+import android.animation.ObjectAnimator;
+import android.animation.PropertyValuesHolder;
+import android.animation.ValueAnimator;
+import android.test.ActivityInstrumentationTestCase2;
+import android.util.Property;
+import android.view.animation.AccelerateInterpolator;
+import android.view.animation.Interpolator;
+
+public class ObjectAnimatorTest extends
+        ActivityInstrumentationTestCase2<AnimationActivity> {
+    private AnimationActivity mActivity;
+    private ObjectAnimator mObjectAnimator;
+    private long mDuration = 1000;
+
+    public ObjectAnimatorTest() {
+        super(AnimationActivity.class);
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        setActivityInitialTouchMode(false);
+        mActivity = getActivity();
+        mObjectAnimator = (ObjectAnimator) mActivity.createAnimatorWithDuration(mDuration);
+    }
+
+    public void testDuration() throws Throwable {
+        final long duration = 2000;
+        ObjectAnimator objectAnimatorLocal = (ObjectAnimator)mActivity.createAnimatorWithDuration(
+            duration);
+        startAnimation(objectAnimatorLocal);
+        assertEquals(duration, objectAnimatorLocal.getDuration());
+    }
+    public void testOfFloat() throws Throwable {
+        Object object = mActivity.view.newBall;
+        String property = "y";
+        float startY = mActivity.mStartY;
+        float endY = mActivity.mStartY + mActivity.mDeltaY;
+        ObjectAnimator objAnimator = ObjectAnimator.ofFloat(object, property, startY, endY);
+        assertTrue(objAnimator != null);
+        objAnimator.setDuration(mDuration);
+        objAnimator.setRepeatCount(ValueAnimator.INFINITE);
+        objAnimator.setInterpolator(new AccelerateInterpolator());
+        objAnimator.setRepeatMode(ValueAnimator.REVERSE);
+        startAnimation(objAnimator);
+        assertTrue(objAnimator != null);
+        Thread.sleep(100);
+        float x = mActivity.view.newBall.getX();
+        float y = mActivity.view.newBall.getY();
+        assertTrue( y >= startY);
+        assertTrue( y <= endY);
+    }
+
+    public void testOfFloatBase() throws Throwable {
+        Object object = mActivity.view.newBall;
+        String property = "y";
+        float startY = mActivity.mStartY;
+        float endY = mActivity.mStartY + mActivity.mDeltaY;
+        ObjectAnimator animator = ObjectAnimator.ofFloat(object, property, startY, endY);
+        ObjectAnimator objAnimator = new ObjectAnimator();
+        objAnimator.setTarget(object);
+        objAnimator.setPropertyName(property);
+        assertEquals(animator.getTarget(), objAnimator.getTarget());
+        assertEquals(animator.getPropertyName(), objAnimator.getPropertyName());
+    }
+
+    public void testOfInt() throws Throwable {
+        Object object = mActivity.view.newBall;
+        String property = "backgroundColor";
+        int startColor = mActivity.view.RED;
+        int endColor = mActivity.view.BLUE;
+
+        ObjectAnimator colorAnimator = ObjectAnimator.ofInt(object, property,
+                startColor, endColor);
+        colorAnimator.setDuration(1000);
+        colorAnimator.setEvaluator(new ArgbEvaluator());
+        colorAnimator.setRepeatCount(1);
+        colorAnimator.setRepeatMode(ValueAnimator.REVERSE);
+        colorAnimator.start();
+        startAnimation(mObjectAnimator, colorAnimator);
+        Thread.sleep(100);
+        Integer i = (Integer) colorAnimator.getAnimatedValue();
+        //We are going from less negative value to a more negative value
+        assertTrue(i.intValue() <= startColor);
+        assertTrue(endColor <= i.intValue());
+    }
+
+    public void testOfObject() throws Throwable {
+        Object object = mActivity.view.newBall;
+        String property = "backgroundColor";
+        int startColor = mActivity.view.RED;
+        int endColor = mActivity.view.BLUE;
+        Object[] values = {new Integer(startColor), new Integer(endColor)};
+        ArgbEvaluator evaluator = new ArgbEvaluator();
+        ObjectAnimator colorAnimator = ObjectAnimator.ofObject(object, property,
+                evaluator, values);
+        colorAnimator.setDuration(1000);
+        colorAnimator.setRepeatCount(1);
+        colorAnimator.setRepeatMode(ValueAnimator.REVERSE);
+        colorAnimator.start();
+        startAnimation(mObjectAnimator, colorAnimator);
+        Thread.sleep(100);
+        Integer i = (Integer) colorAnimator.getAnimatedValue();
+        //We are going from less negative value to a more negative value
+        assertTrue(i.intValue() <= startColor);
+        assertTrue(endColor <= i.intValue());
+    }
+
+    public void testOfPropertyValuesHolder() throws Throwable {
+        Object object = mActivity.view.newBall;
+        String propertyName = "backgroundColor";
+        int startColor = mActivity.view.RED;
+        int endColor = mActivity.view.BLUE;
+        int values[] = {startColor, endColor};
+        ArgbEvaluator evaluator = new ArgbEvaluator();
+        PropertyValuesHolder propertyValuesHolder = PropertyValuesHolder.ofInt(propertyName, values);
+        ObjectAnimator colorAnimator = ObjectAnimator.ofPropertyValuesHolder(object, 
+            propertyValuesHolder);
+        colorAnimator.setDuration(1000);
+        colorAnimator.setRepeatCount(1);
+        colorAnimator.setRepeatMode(ValueAnimator.REVERSE);
+        colorAnimator.start();
+        startAnimation(mObjectAnimator, colorAnimator);
+        Thread.sleep(100);
+        Integer i = (Integer) colorAnimator.getAnimatedValue();
+        //We are going from less negative value to a more negative value
+        assertTrue(i.intValue() <= startColor);
+        assertTrue(endColor <= i.intValue());
+    }
+
+    public void testGetPropertyName() throws Throwable {
+        Object object = mActivity.view.newBall;
+        String propertyName = "backgroundColor";
+        int startColor = mActivity.view.RED;
+        int endColor = mActivity.view.BLUE;
+        Object[] values = {new Integer(startColor), new Integer(endColor)};
+        ArgbEvaluator evaluator = new ArgbEvaluator();
+        ObjectAnimator colorAnimator = ObjectAnimator.ofObject(object, propertyName,
+                evaluator, values);
+        String actualPropertyName = colorAnimator.getPropertyName();
+        assertEquals(propertyName, actualPropertyName);
+    }
+
+    public void testSetCurrentPlayTime() throws Throwable {
+        Object object = mActivity.view.newBall;
+        String propertyName = "backgroundColor";
+        int startColor = mActivity.view.RED;
+        int endColor = mActivity.view.BLUE;
+        long playTime = 10000l;
+        Object[] values = {new Integer(startColor), new Integer(endColor)};
+        ArgbEvaluator evaluator = new ArgbEvaluator();
+        ObjectAnimator colorAnimator = ObjectAnimator.ofObject(object, propertyName,
+                evaluator, values);
+        colorAnimator.setCurrentPlayTime(playTime);
+        long actualPlayTime = colorAnimator.getCurrentPlayTime();
+        assertEquals(playTime, actualPlayTime);
+    }
+
+    public void testSetFloatValues() throws Throwable {
+        Object object = mActivity.view.newBall;
+        String property = "y";
+        float startY = mActivity.mStartY;
+        float endY = mActivity.mStartY + mActivity.mDeltaY;
+        float[] values = {startY, endY};
+        ObjectAnimator objAnimator = new ObjectAnimator();
+        objAnimator.setTarget(object);
+        objAnimator.setPropertyName(property);
+        objAnimator.setFloatValues(values);
+        objAnimator.setDuration(mDuration);
+        objAnimator.setRepeatCount(ValueAnimator.INFINITE);
+        objAnimator.setInterpolator(new AccelerateInterpolator());
+        objAnimator.setRepeatMode(ValueAnimator.REVERSE);
+        startAnimation(objAnimator);
+        Thread.sleep(100);
+        float y = mActivity.view.newBall.getY();
+        assertTrue( y >= startY);
+        assertTrue( y <= endY);
+    }
+
+    public void testGetTarget() throws Throwable {
+        Object object = mActivity.view.newBall;
+        String propertyName = "backgroundColor";
+        int startColor = mActivity.view.RED;
+        int endColor = mActivity.view.BLUE;
+        Object[] values = {new Integer(startColor), new Integer(endColor)};
+        ArgbEvaluator evaluator = new ArgbEvaluator();
+        ObjectAnimator colorAnimator = ObjectAnimator.ofObject(object, propertyName,
+                evaluator, values);
+        Object target = colorAnimator.getTarget();
+        assertEquals(object, target);
+    }
+
+    public void testClone() throws Throwable {
+        Object object = mActivity.view.newBall;
+        String property = "y";
+        float startY = mActivity.mStartY;
+        float endY = mActivity.mStartY + mActivity.mDeltaY;
+        Interpolator interpolator = new AccelerateInterpolator();
+        ObjectAnimator objAnimator = ObjectAnimator.ofFloat(object, property, startY, endY);
+        objAnimator.setDuration(mDuration);
+        objAnimator.setRepeatCount(ValueAnimator.INFINITE);
+        objAnimator.setInterpolator(interpolator);
+        objAnimator.setRepeatMode(ValueAnimator.REVERSE);
+        ObjectAnimator cloneAnimator = objAnimator.clone();
+
+        assertEquals(mDuration, cloneAnimator.getDuration());
+        assertEquals(ValueAnimator.INFINITE, cloneAnimator.getRepeatCount());
+        assertEquals(ValueAnimator.REVERSE, cloneAnimator.getRepeatMode());
+        assertEquals(object, cloneAnimator.getTarget());
+        assertEquals(property, cloneAnimator.getPropertyName());
+        assertEquals(interpolator, cloneAnimator.getInterpolator());
+    }
+
+    public void testIsStarted() throws Throwable {
+        Object object = mActivity.view.newBall;
+        String property = "y";
+        float startY = mActivity.mStartY;
+        float endY = mActivity.mStartY + mActivity.mDeltaY;
+        Interpolator interpolator = new AccelerateInterpolator();
+        ObjectAnimator objAnimator = ObjectAnimator.ofFloat(object, property, startY, endY);
+        objAnimator.setDuration(mDuration);
+        objAnimator.setRepeatCount(ValueAnimator.INFINITE);
+        objAnimator.setInterpolator(interpolator);
+        objAnimator.setRepeatMode(ValueAnimator.REVERSE);
+        startAnimation(objAnimator);
+        Thread.sleep(100);
+        assertTrue(objAnimator.isStarted());
+        Thread.sleep(100);
+    }
+
+    private void startAnimation(final ObjectAnimator mObjectAnimator) throws Throwable {
+        Thread mAnimationRunnable = new Thread() {
+            public void run() {
+                mActivity.startAnimation(mObjectAnimator);
+            }
+        };
+        this.runTestOnUiThread(mAnimationRunnable);
+    }
+    private void startAnimation(final ObjectAnimator mObjectAnimator, final
+            ObjectAnimator colorAnimator) throws Throwable {
+        Thread mAnimationRunnable = new Thread() {
+            public void run() {
+                mActivity.startAnimation(mObjectAnimator, colorAnimator);
+            }
+        };
+        this.runTestOnUiThread(mAnimationRunnable);
+    }
+}
+
+
diff --git a/tests/tests/animation/src/android/animation/cts/ValueAnimatorTest.java b/tests/tests/animation/src/android/animation/cts/ValueAnimatorTest.java
index 314c06d..a7626bc 100644
--- a/tests/tests/animation/src/android/animation/cts/ValueAnimatorTest.java
+++ b/tests/tests/animation/src/android/animation/cts/ValueAnimatorTest.java
@@ -15,24 +15,22 @@
  */
 package android.animation.cts;
 
+import android.animation.ArgbEvaluator;
+import android.animation.FloatEvaluator;
+import android.animation.IntEvaluator;
+import android.animation.ObjectAnimator;
 import android.animation.ValueAnimator;
-import android.app.Instrumentation;
-import android.content.Intent;
 import android.test.ActivityInstrumentationTestCase2;
+import android.view.animation.AccelerateInterpolator;
 
 public class ValueAnimatorTest extends
         ActivityInstrumentationTestCase2<AnimationActivity> {
     private AnimationActivity mActivity;
-    private Instrumentation mInstrumentation;
     private ValueAnimator mValueAnimator;
-    private long mDuration;
+    private long mDuration = 1000;
 
     public ValueAnimatorTest() {
-        super("com.android.cts.animation",AnimationActivity.class);
-    }
-
-    public ValueAnimatorTest(Class<AnimationActivity> activityClass) {
-        super("com.android.cts.animation",AnimationActivity.class);
+        super(AnimationActivity.class);
     }
 
     @Override
@@ -57,6 +55,16 @@
         assertTrue(valueAnimatorReturned.isRunning());
     }
 
+    public void testIsStarted() throws Throwable {
+        assertFalse(mValueAnimator.isRunning());
+        assertFalse(mValueAnimator.isStarted());
+        long startDelay = 10000;
+        mValueAnimator.setStartDelay(startDelay);
+        startAnimation(mValueAnimator);
+        assertFalse(mValueAnimator.isRunning());
+        assertTrue(mValueAnimator.isStarted());
+    }
+
     public void testRepeatMode() throws Throwable {
         ValueAnimator mValueAnimator = mActivity.createAnimatorWithRepeatMode(ValueAnimator.RESTART);
         startAnimation(mValueAnimator);
@@ -92,12 +100,164 @@
         assertEquals(frameDelay, actualFrameDelay);
     }
 
-    private void startAnimation(final ValueAnimator mValueAnimator) throws Throwable {
+    public void testSetInterpolator() throws Throwable {
+        AccelerateInterpolator interpolator = new AccelerateInterpolator();
+        ValueAnimator mValueAnimator = mActivity.createAnimatorWithInterpolator(interpolator);
+        startAnimation(mValueAnimator);
+        assertTrue(interpolator.equals(mValueAnimator.getInterpolator()));
+    }
+
+    public void testCancel() throws Throwable {
+        startAnimation(mValueAnimator);
+        Thread.sleep(100);
+        mValueAnimator.cancel();
+        assertFalse(mValueAnimator.isRunning());
+    }
+
+    public void testEnd() throws Throwable {
+        Object object = mActivity.view.newBall;
+        String property = "y";
+        float startY = mActivity.mStartY;
+        float endY = mActivity.mStartY + mActivity.mDeltaY;
+        ObjectAnimator objAnimator = ObjectAnimator.ofFloat(object, property, startY, endY);
+        objAnimator.setDuration(mDuration);
+        objAnimator.setRepeatCount(ValueAnimator.INFINITE);
+        objAnimator.setInterpolator(new AccelerateInterpolator());
+        objAnimator.setRepeatMode(ValueAnimator.REVERSE);
+        startAnimation(objAnimator);
+        Thread.sleep(100);
+        endAnimation(objAnimator);
+        float y = mActivity.view.newBall.getY();
+        assertEquals(y, endY);
+    }
+
+    public void testGetAnimatedFraction() throws Throwable {
+        ValueAnimator objAnimator = getAnimator();
+        startAnimation(objAnimator);
+        assertNotNull(objAnimator);
+        float[] fractions = getValue(objAnimator, 10, "getAnimatedFraction()", 100l, null);
+        for(int j = 0; j < 9; j++){
+            assertTrue(fractions[j] >= 0.0);
+            assertTrue(fractions[j] <= 1.0);
+            assertTrue(fractions[j + 1] != fractions[j]);
+        }
+    }
+
+    public void testGetAnimatedValue() throws Throwable {
+        ValueAnimator objAnimator = getAnimator();
+        startAnimation(objAnimator);
+        assertNotNull(objAnimator);
+        float[] animatedValues = getValue(objAnimator, 10, "getAnimatedValue()", 100l, null);
+
+        for(int j = 0; j < 9; j++){
+            assertTrue(animatedValues[j + 1] != animatedValues[j]);
+        }
+    }
+    public void testGetAnimatedValue_PropertyName() throws Throwable {
+        String property = "y";
+
+        ValueAnimator objAnimator = getAnimator();
+        startAnimation(objAnimator);
+        assertNotNull(objAnimator);
+        float[] animatedValues = getValue(objAnimator, 10, "getAnimatedValue(property)", 100l,
+            property);
+        for(int j = 0; j < 9; j++){
+            assertTrue(animatedValues[j + 1] != animatedValues[j]);
+        }
+    }
+
+    public void testOfFloat() throws Throwable {
+        float start = 0.0f;
+        float end = 1.0f;
+        float[] values = {start, end};
+        final ValueAnimator valueAnimatorLocal = ValueAnimator.ofFloat(values);
+        valueAnimatorLocal.setDuration(mDuration);
+        valueAnimatorLocal.setRepeatCount(ValueAnimator.INFINITE);
+        valueAnimatorLocal.setInterpolator(new AccelerateInterpolator());
+        valueAnimatorLocal.setRepeatMode(ValueAnimator.RESTART);
+
         this.runTestOnUiThread(new Runnable(){
-            public void run(){
-                mActivity.startAnimation(mValueAnimator);
+            public void run() {
+                valueAnimatorLocal.start();
             }
         });
+        Thread.sleep(100);
+        boolean isRunning = valueAnimatorLocal.isRunning();
+        assertTrue(isRunning);
+
+        Float animatedValue = (Float) valueAnimatorLocal.getAnimatedValue();
+        assertTrue(animatedValue >= start);
+        assertTrue(animatedValue <= end);
+    }
+
+    public void testOfInt() throws Throwable {
+        int start = 0;
+        int end = 10;
+        int[] values = {start, end};
+        final ValueAnimator valueAnimatorLocal = ValueAnimator.ofInt(values);
+        valueAnimatorLocal.setDuration(mDuration);
+        valueAnimatorLocal.setRepeatCount(ValueAnimator.INFINITE);
+        valueAnimatorLocal.setInterpolator(new AccelerateInterpolator());
+        valueAnimatorLocal.setRepeatMode(ValueAnimator.RESTART);
+
+        this.runTestOnUiThread(new Runnable(){
+            public void run() {
+                valueAnimatorLocal.start();
+            }
+        });
+        Thread.sleep(100);
+        boolean isRunning = valueAnimatorLocal.isRunning();
+        assertTrue(isRunning);
+
+        Integer animatedValue = (Integer) valueAnimatorLocal.getAnimatedValue();
+        assertTrue(animatedValue >= start);
+        assertTrue(animatedValue <= end);
+    }
+
+    private ValueAnimator getAnimator() {
+        Object object = mActivity.view.newBall;
+        String property = "y";
+        float startY = mActivity.mStartY;
+        float endY = mActivity.mStartY + mActivity.mDeltaY;
+        ValueAnimator objAnimator = ObjectAnimator.ofFloat(object, property, startY, endY);
+        objAnimator.setDuration(mDuration);
+        objAnimator.setRepeatCount(ValueAnimator.INFINITE);
+        objAnimator.setInterpolator(new AccelerateInterpolator());
+        objAnimator.setRepeatMode(ValueAnimator.REVERSE);
+        return objAnimator;
+    }
+
+    private float[] getValue(ValueAnimator animator, int n, String methodName, 
+            long sleepTime, String property) throws InterruptedException {
+        float[] values = new float[n];
+        for(int i = 0; i < (n-1); i++){
+            Thread.sleep(sleepTime);
+            float value = 0.0f;
+            if(methodName.equals("getAnimatedFraction()")) {
+                value = animator.getAnimatedFraction();
+            }else if(methodName.equals("getAnimatedValue()")) {
+              value = ((Float)animator.getAnimatedValue()).floatValue();
+            }else if(methodName.equals("getAnimatedValue(property)")) {
+              value = ((Float)animator.getAnimatedValue(property)).floatValue();
+            }
+            values[i] = value;
+        }
+        return values;
+    }
+    private void startAnimation(final ValueAnimator mValueAnimator) throws Throwable {
+        this.runTestOnUiThread(new Runnable(){
+            public void run() {
+                  mActivity.startAnimation(mValueAnimator);
+            }
+        });
+    }
+    private void endAnimation(final ValueAnimator mValueAnimator) throws Throwable {
+        Thread animationRunnable = new Thread() {
+            public void run() {
+                mValueAnimator.end();
+            }
+        };
+        this.runTestOnUiThread(animationRunnable);
     }
 }