Last active
December 21, 2015 13:59
-
-
Save roman-mazur/6316618 to your computer and use it in GitHub Desktop.
Robolectric PhoneWindow test error example.
Pull request: https://github.com/robolectric/robolectric/pull/659
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.chuze.ui.activity.test; | |
import android.support.v7.app.ActionBar; | |
import android.support.v7.app.ActionBarActivity; | |
import org.junit.Before; | |
import org.junit.Test; | |
import org.junit.runner.RunWith; | |
import org.robolectric.Robolectric; | |
import org.robolectric.RobolectricTestRunner; | |
import static org.fest.assertions.api.Assertions.*; | |
@RunWith(RobolectricTestRunner.class) | |
public class AppCompatTest { | |
/** Activity under the test. */ | |
private ActionBarActivity activity; | |
@Before | |
public void create() { | |
activity = Robolectric.buildActivity(ActionBarActivity.class).attach().create().get(); | |
} | |
@Test | |
public void activityShouldBeCreated() { | |
assertThat(activity).isNotNull(); | |
} | |
@Test | |
public void shouldChangeDisplayOptions() { | |
activity.getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_USE_LOGO); | |
assertThat(activity.getSupportActionBar().getDisplayOptions()).isEqualTo(ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_USE_LOGO); | |
} | |
@Test | |
public void shouldChangeTitle() { | |
activity.getSupportActionBar().setTitle("custom title"); | |
assertThat(activity.getTitle()).isEqualTo("custom title"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment