use of org.robolectric.shadows.ShadowActivity in project DeepLinkDispatch by airbnb.
the class SecondActivityTest method testIntent.
@Test
public void testIntent() {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://example.com/deepLink/123/myname"));
DeepLinkActivity deepLinkActivity = Robolectric.buildActivity(DeepLinkActivity.class).withIntent(intent).create().get();
ShadowActivity shadowActivity = shadowOf(deepLinkActivity);
Intent launchedIntent = shadowActivity.peekNextStartedActivityForResult().intent;
assertThat(launchedIntent.getComponent(), equalTo(new ComponentName(deepLinkActivity, SecondActivity.class)));
assertThat(launchedIntent.getBooleanExtra(DeepLink.IS_DEEP_LINK, false), equalTo(true));
assertThat(launchedIntent.getStringExtra(DeepLink.URI), equalTo("http://example.com/deepLink/123/myname"));
}
use of org.robolectric.shadows.ShadowActivity in project scdl by passy.
the class DownloadActivityTest method purchaseFlow.
@Test
public void purchaseFlow() {
final TrackEntity track = new TrackEntity();
final UserEntity user = new UserEntity();
final String downloadUrl = "http://3lau.to/downloadstuff";
user.setUsername("awesomesauce");
track.setDownloadable(false);
track.setUser(user);
track.setPurchaseUrl(downloadUrl);
final Bundle bundle = new Bundle();
bundle.putParcelable(DownloadActivity.MEDIA_STATE_TAG, MediaState.fromEntity(track));
final DownloadActivity activity = Robolectric.buildActivity(DownloadActivity.class).attach().create(bundle).start().resume().get();
final View button = activity.findViewById(R.id.btn_download);
assertTrue(button.isEnabled());
button.performClick();
final ShadowActivity shadowActivity = Robolectric.shadowOf(activity);
final Intent nextIntent = shadowActivity.getNextStartedActivity();
assertThat(nextIntent.getAction(), equalTo("android.intent.action.VIEW"));
assertThat(nextIntent.toUri(0), startsWith(downloadUrl));
}
use of org.robolectric.shadows.ShadowActivity in project scdl by passy.
the class PreferencesMenuTest method shouldStartPreferencesInActivity.
private void shouldStartPreferencesInActivity(Fragment fragment) {
final ActivityController<FragmentActivity> controller = Robolectric.buildActivity(FragmentActivity.class);
controller.create().start().resume();
final FragmentActivity activity = controller.get();
activity.getSupportFragmentManager().beginTransaction().add(fragment, null).commit();
final MenuItem item = new TestMenuItem(R.id.preferences);
fragment.onOptionsItemSelected(item);
final ShadowActivity shadowActivity = Robolectric.shadowOf(activity);
final Intent startedActivity = shadowActivity.getNextStartedActivity();
// Intent was actually started
assertThat(startedActivity, notNullValue());
final ShadowIntent intent = Robolectric.shadowOf(startedActivity);
assertThat(intent.getComponent().getClassName(), equalTo(ApplicationPreferencesActivity.class.getName()));
}
use of org.robolectric.shadows.ShadowActivity in project androidannotations by androidannotations.
the class AwaitingResultFragmentTest method testOnResultCalledInFragment.
@Test
public void testOnResultCalledInFragment() {
FragmentStartedActivity_.intent(fragment).startForResult(AwaitingResultFragment.FIRST_REQUEST);
ShadowActivity a = (ShadowActivity) extract(fragment.getActivity());
a.receiveResult(FragmentStartedActivity_.intent(fragment).get(), Activity.RESULT_OK, new Intent());
assertThat(fragment.onResultCalled).isTrue();
}
Aggregations