Search in sources :

Example 1 with TestActivity

use of org.robolectric.shadows.testing.TestActivity in project robolectric by robolectric.

the class ShadowThemeTest method whenNotSetOnActivityInManifest_activityGetsThemeFromApplicationInManifest.

@Test
public void whenNotSetOnActivityInManifest_activityGetsThemeFromApplicationInManifest() {
    TestActivity activity = buildActivity(TestActivity.class).create().get();
    Button theButton = activity.findViewById(R.id.button);
    ColorDrawable background = (ColorDrawable) theButton.getBackground();
    assertThat(background.getColor()).isEqualTo(0xff00ff00);
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) Button(android.widget.Button) TestActivity(org.robolectric.shadows.testing.TestActivity) Test(org.junit.Test)

Example 2 with TestActivity

use of org.robolectric.shadows.testing.TestActivity in project robolectric by robolectric.

the class ShadowThemeTest method whenExplicitlySetOnActivity_afterSetContentView_activityGetsThemeFromActivityInManifest.

@Test
public void whenExplicitlySetOnActivity_afterSetContentView_activityGetsThemeFromActivityInManifest() {
    TestActivity activity = buildActivity(TestActivityWithAnotherTheme.class).create().get();
    activity.setTheme(R.style.Theme_Robolectric);
    Button theButton = activity.findViewById(R.id.button);
    ColorDrawable background = (ColorDrawable) theButton.getBackground();
    assertThat(background.getColor()).isEqualTo(0xffff0000);
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) Button(android.widget.Button) TestActivity(org.robolectric.shadows.testing.TestActivity) Test(org.junit.Test)

Example 3 with TestActivity

use of org.robolectric.shadows.testing.TestActivity in project robolectric by robolectric.

the class ShadowThemeTest method whenExplicitlySetOnActivity_beforeSetContentView_activityUsesNewTheme.

@Test
public void whenExplicitlySetOnActivity_beforeSetContentView_activityUsesNewTheme() {
    ActivityController<TestActivityWithAnotherTheme> activityController = buildActivity(TestActivityWithAnotherTheme.class);
    TestActivity activity = activityController.get();
    activity.setTheme(R.style.Theme_Robolectric);
    activityController.create();
    Button theButton = activity.findViewById(R.id.button);
    ColorDrawable background = (ColorDrawable) theButton.getBackground();
    assertThat(background.getColor()).isEqualTo(0xff00ff00);
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) Button(android.widget.Button) TestActivity(org.robolectric.shadows.testing.TestActivity) Test(org.junit.Test)

Example 4 with TestActivity

use of org.robolectric.shadows.testing.TestActivity in project robolectric by robolectric.

the class ShadowThemeTest method shouldResolveReferencesThatStartWithAQuestionMark.

@Test
public void shouldResolveReferencesThatStartWithAQuestionMark() {
    TestActivity activity = buildActivity(TestActivityWithAnotherTheme.class).create().get();
    Button theButton = activity.findViewById(R.id.button);
    assertThat(theButton.getMinWidth()).isEqualTo(8);
    assertThat(theButton.getMinHeight()).isEqualTo(8);
}
Also used : Button(android.widget.Button) TestActivity(org.robolectric.shadows.testing.TestActivity) Test(org.junit.Test)

Example 5 with TestActivity

use of org.robolectric.shadows.testing.TestActivity in project robolectric by robolectric.

the class ShadowThemeTest method whenSetOnActivityInManifest_activityGetsThemeFromActivityInManifest.

@Test
public void whenSetOnActivityInManifest_activityGetsThemeFromActivityInManifest() {
    TestActivity activity = buildActivity(TestActivityWithAnotherTheme.class).create().get();
    Button theButton = activity.findViewById(R.id.button);
    ColorDrawable background = (ColorDrawable) theButton.getBackground();
    assertThat(background.getColor()).isEqualTo(0xffff0000);
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) Button(android.widget.Button) TestActivity(org.robolectric.shadows.testing.TestActivity) Test(org.junit.Test)

Aggregations

Button (android.widget.Button)5 Test (org.junit.Test)5 TestActivity (org.robolectric.shadows.testing.TestActivity)5 ColorDrawable (android.graphics.drawable.ColorDrawable)4