Search in sources :

Example 1 with Robolectric.setupActivity

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());
}
Also used : Robolectric.setupActivity(org.robolectric.Robolectric.setupActivity) Robolectric.buildActivity(org.robolectric.Robolectric.buildActivity) Activity(android.app.Activity) ComponentName(android.content.ComponentName) Test(org.junit.Test)

Example 2 with Robolectric.setupActivity

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());
}
Also used : Robolectric.setupActivity(org.robolectric.Robolectric.setupActivity) Robolectric.buildActivity(org.robolectric.Robolectric.buildActivity) Activity(android.app.Activity) Test(org.junit.Test)

Example 3 with Robolectric.setupActivity

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);
}
Also used : Robolectric.setupActivity(org.robolectric.Robolectric.setupActivity) Robolectric.buildActivity(org.robolectric.Robolectric.buildActivity) Activity(android.app.Activity) Test(org.junit.Test)

Example 4 with Robolectric.setupActivity

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");
}
Also used : SharedPreferences(android.content.SharedPreferences) Robolectric.setupActivity(org.robolectric.Robolectric.setupActivity) Robolectric.buildActivity(org.robolectric.Robolectric.buildActivity) Activity(android.app.Activity) Test(org.junit.Test)

Example 5 with Robolectric.setupActivity

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);
}
Also used : Robolectric.setupActivity(org.robolectric.Robolectric.setupActivity) Robolectric.buildActivity(org.robolectric.Robolectric.buildActivity) Activity(android.app.Activity) Test(org.junit.Test)

Aggregations

Activity (android.app.Activity)6 Test (org.junit.Test)6 Robolectric.buildActivity (org.robolectric.Robolectric.buildActivity)6 Robolectric.setupActivity (org.robolectric.Robolectric.setupActivity)6 ComponentName (android.content.ComponentName)1 SharedPreferences (android.content.SharedPreferences)1