Created
April 29, 2012 16:45
-
-
Save sourcerebels/2551810 to your computer and use it in GitHub Desktop.
Android > Testing > Robolectric > Assert some button starts activity
This file contains hidden or 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
@Test | |
public void shouldStartSomeActivityWhenSomeButtonPressed() { | |
someButton.performClick(); | |
assertActivityStarted(SomeActivity.class) | |
} | |
private void assertActivityStarted(Class<? extends Activity> clazz) { | |
ShadowActivity shadowActivity = shadowOf(activity); | |
Intent startedIntent = shadowActivity.getNextStartedActivity(); | |
ShadowIntent shadowIntent = shadowOf(startedIntent); | |
assertThat(shadowIntent.getComponent().getClassName(), | |
equalTo(clazz.getName())); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment