use of org.robolectric.Robolectric.setupActivity in project robolectric by robolectric.
the class ShadowActivityTest method getCallingActivity_returnsSetValue.
@Test
public void getCallingActivity_returnsSetValue() {
Activity activity = Robolectric.setupActivity(Activity.class);
ComponentName componentName = new ComponentName("com.example.package", "SomeActivity");
ShadowActivity shadowActivity = shadowOf(activity);
shadowActivity.setCallingActivity(componentName);
assertEquals(componentName, activity.getCallingActivity());
}
use of org.robolectric.Robolectric.setupActivity in project robolectric by robolectric.
the class ShadowActivityTest method getCallingActivity_defaultsToNull.
@Test
public void getCallingActivity_defaultsToNull() {
Activity activity = Robolectric.setupActivity(Activity.class);
assertNull(activity.getCallingActivity());
}
use of org.robolectric.Robolectric.setupActivity in project robolectric by robolectric.
the class ShadowActivityTest method getPendingTransitionExitAnimationResourceId_should.
@Test
public void getPendingTransitionExitAnimationResourceId_should() throws Exception {
Activity activity = Robolectric.setupActivity(Activity.class);
activity.overridePendingTransition(15, 2);
assertThat(shadowOf(activity).getPendingTransitionExitAnimationResourceId()).isEqualTo(2);
}
use of org.robolectric.Robolectric.setupActivity in project robolectric by robolectric.
the class ShadowActivityTest method shouldGiveSharedPreferences.
@Test
public void shouldGiveSharedPreferences() throws Exception {
Activity activity = Robolectric.setupActivity(Activity.class);
SharedPreferences preferences = activity.getPreferences(Context.MODE_PRIVATE);
assertNotNull(preferences);
preferences.edit().putString("foo", "bar").commit();
assertThat(activity.getPreferences(Context.MODE_PRIVATE).getString("foo", null)).isEqualTo("bar");
}
use of org.robolectric.Robolectric.setupActivity in project robolectric by robolectric.
the class ShadowActivityTest method getPendingTransitionEnterAnimationResourceId_should.
@Test
public void getPendingTransitionEnterAnimationResourceId_should() throws Exception {
Activity activity = Robolectric.setupActivity(Activity.class);
activity.overridePendingTransition(15, 2);
assertThat(shadowOf(activity).getPendingTransitionEnterAnimationResourceId()).isEqualTo(15);
}
Aggregations