use of org.robolectric.shadows.ShadowActivity in project DeepLinkDispatch by airbnb.
the class MainActivityTest method testQueryParamsWithBracket.
@Test
public void testQueryParamsWithBracket() {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("dld://classDeepLink?foo[max]=123"));
DeepLinkActivity deepLinkActivity = Robolectric.buildActivity(DeepLinkActivity.class, intent).create().get();
ShadowActivity shadowActivity = shadowOf(deepLinkActivity);
Intent launchedIntent = shadowActivity.peekNextStartedActivityForResult().intent;
assertThat(launchedIntent.getComponent(), equalTo(new ComponentName(deepLinkActivity, MainActivity.class)));
assertThat(launchedIntent.getBooleanExtra(DeepLink.IS_DEEP_LINK, false), equalTo(true));
assertThat(launchedIntent.getStringExtra("foo[max]"), equalTo("123"));
assertThat(launchedIntent.getStringExtra(DeepLink.URI), equalTo("dld://classDeepLink?foo[max]=123"));
}
use of org.robolectric.shadows.ShadowActivity in project DeepLinkDispatch by airbnb.
the class MainActivityTest method testHttpScheme.
@Test
public void testHttpScheme() {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://example.com/fooball?baz=something"));
DeepLinkActivity deepLinkActivity = Robolectric.buildActivity(DeepLinkActivity.class, intent).create().get();
ShadowActivity shadowActivity = shadowOf(deepLinkActivity);
Intent launchedIntent = shadowActivity.peekNextStartedActivityForResult().intent;
assertThat(launchedIntent.getComponent(), equalTo(new ComponentName(deepLinkActivity, MainActivity.class)));
assertThat(launchedIntent.getBooleanExtra(DeepLink.IS_DEEP_LINK, false), equalTo(true));
assertThat(launchedIntent.getStringExtra("baz"), equalTo("something"));
assertThat(launchedIntent.getStringExtra("arg_end"), equalTo("ball"));
assertThat(launchedIntent.getStringExtra(DeepLink.URI), equalTo("http://example.com/fooball?baz=something"));
}
use of org.robolectric.shadows.ShadowActivity in project DeepLinkDispatch by airbnb.
the class MainActivityTest method testMoreConcreteMach.
@Test
public void testMoreConcreteMach() {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("placeholder://host/somePathOne/somePathTwo/somePathThree"));
DeepLinkActivity deepLinkActivity = Robolectric.buildActivity(DeepLinkActivity.class, intent).create().get();
ShadowActivity shadowActivity = shadowOf(deepLinkActivity);
Intent launchedIntent = shadowActivity.peekNextStartedActivityForResult().intent;
assertThat(launchedIntent.getComponent(), equalTo(new ComponentName(deepLinkActivity, LibraryActivity.class)));
}
use of org.robolectric.shadows.ShadowActivity in project DeepLinkDispatch by airbnb.
the class MainActivityTest method testIntent.
@Test
public void testIntent() {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("dld://host/somePath/1234321")).putExtra("TEST_EXTRA", "FOO");
DeepLinkActivity deepLinkActivity = Robolectric.buildActivity(DeepLinkActivity.class, intent).create().get();
ShadowActivity shadowActivity = shadowOf(deepLinkActivity);
Intent launchedIntent = shadowActivity.peekNextStartedActivityForResult().intent;
assertThat(launchedIntent.getComponent(), equalTo(new ComponentName(deepLinkActivity, MainActivity.class)));
assertThat(launchedIntent.getBooleanExtra(DeepLink.IS_DEEP_LINK, false), equalTo(true));
assertThat(launchedIntent.getStringExtra("arbitraryNumber"), equalTo("1234321"));
assertThat(launchedIntent.getStringExtra("TEST_EXTRA"), equalTo("FOO"));
assertThat(launchedIntent.getAction(), equalTo("deep_link_complex"));
assertThat(launchedIntent.<Uri>getParcelableExtra(DeepLink.REFERRER_URI).toString(), equalTo("dld://host/somePath/1234321"));
assertThat(launchedIntent.getData(), equalTo(Uri.parse("dld://host/somePath/1234321")));
assertThat(launchedIntent.getStringExtra(DeepLink.URI), equalTo("dld://host/somePath/1234321"));
}
use of org.robolectric.shadows.ShadowActivity in project android_packages_apps_Settings by omnirom.
the class HelpTrampolineTest method launchHelp_hasExtra_shouldLaunchHelp.
@Test
public void launchHelp_hasExtra_shouldLaunchHelp() {
final Intent intent = new Intent().setClassName(RuntimeEnvironment.application.getPackageName(), HelpTrampoline.class.getName()).putExtra(Intent.EXTRA_TEXT, "help_url_upgrading");
final ShadowActivity shadow = Shadows.shadowOf(Robolectric.buildActivity(HelpTrampoline.class, intent).create().get());
final Intent launchedIntent = shadow.getNextStartedActivity();
assertThat(ShadowHelpUtils.isGetHelpIntentCalled()).isTrue();
assertThat(launchedIntent).isNotNull();
}
Aggregations