1 package com.xtremelabs.robolectric.shadows;
2 
3 import android.view.animation.Animation;
4 import android.view.animation.TranslateAnimation;
5 import com.xtremelabs.robolectric.WithTestDefaultsRunner;
6 import org.junit.Before;
7 import org.junit.Test;
8 import org.junit.runner.RunWith;
9 
10 import static com.xtremelabs.robolectric.Robolectric.shadowOf;
11 import static org.hamcrest.CoreMatchers.equalTo;
12 import static org.junit.Assert.assertThat;
13 
14 @RunWith(WithTestDefaultsRunner.class)
15 public class TranslateAnimationTest {
16 
17     private TranslateAnimation animation;
18     private ShadowTranslateAnimation shadow;
19 
20     @Before
setUp()21     public void setUp() throws Exception {
22         animation = new TranslateAnimation(1, 2, 3, 4, 5, 6, 7, 8);
23         shadow = shadowOf(animation);
24     }
25 
26     @Test
animationParametersFromConstructor()27     public void animationParametersFromConstructor() throws Exception {
28         assertThat(shadow.getFromXType(), equalTo(1));
29         assertThat(shadow.getFromXValue(), equalTo(2f));
30         assertThat(shadow.getToXType(), equalTo(3));
31         assertThat(shadow.getToXValue(), equalTo(4f));
32         assertThat(shadow.getFromYType(), equalTo(5));
33         assertThat(shadow.getFromYValue(), equalTo(6f));
34         assertThat(shadow.getToYType(), equalTo(7));
35         assertThat(shadow.getToYValue(), equalTo(8f));
36     }
37 
38     @Test
animationParametersFromConstructor2()39     public void animationParametersFromConstructor2() throws Exception {
40     	TranslateAnimation animation2 = new TranslateAnimation(1, 2, 3, 4);
41     	ShadowTranslateAnimation shadow2 = shadowOf(animation2);
42     	int defType = Animation.ABSOLUTE;
43         assertThat(shadow2.getFromXType(), equalTo(defType));
44         assertThat(shadow2.getFromXValue(), equalTo(1f));
45         assertThat(shadow2.getToXType(), equalTo(defType));
46         assertThat(shadow2.getToXValue(), equalTo(2f));
47         assertThat(shadow2.getFromYType(), equalTo(defType));
48         assertThat(shadow2.getFromYValue(), equalTo(3f));
49         assertThat(shadow2.getToYType(), equalTo(defType));
50         assertThat(shadow2.getToYValue(), equalTo(4f));
51     }
52 }
53