Skip to content

Instantly share code, notes, and snippets.

@kmdupr33
Created May 29, 2015 10:40
Show Gist options
  • Save kmdupr33/fda1634fab637941d338 to your computer and use it in GitHub Desktop.
Save kmdupr33/fda1634fab637941d338 to your computer and use it in GitHub Desktop.
public class LaunchActivityTest
extends ActivityUnitTestCase<LaunchActivity> {
...
@Override
protected void setUp() throws Exception {
super.setUp();
mLaunchIntent = new Intent(getInstrumentation()
.getTargetContext(), LaunchActivity.class);
startActivity(mLaunchIntent, null, null);
final Button launchNextButton =
(Button) getActivity()
.findViewById(R.id.launch_next_activity_button);
}
@MediumTest
public void testNextActivityWasLaunchedWithIntent() {
startActivity(mLaunchIntent, null, null);
final Button launchNextButton =
(Button) getActivity()
.findViewById(R.id.launch_next_activity_button);
launchNextButton.performClick();
final Intent launchIntent = getStartedActivityIntent();
assertNotNull("Intent was null", launchIntent);
assertTrue(isFinishCalled());
final String payload =
launchIntent.getStringExtra(NextActivity.EXTRAS_PAYLOAD_KEY);
assertEquals("Payload is empty", LaunchActivity.STRING_PAYLOAD, payload);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment