Search in sources :

Example 36 with ShadowActivity

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"));
}
Also used : ShadowActivity(org.robolectric.shadows.ShadowActivity) Intent(android.content.Intent) ComponentName(android.content.ComponentName) Test(org.junit.Test)

Example 37 with ShadowActivity

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"));
}
Also used : ShadowActivity(org.robolectric.shadows.ShadowActivity) Intent(android.content.Intent) ComponentName(android.content.ComponentName) Test(org.junit.Test)

Example 38 with ShadowActivity

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)));
}
Also used : ShadowActivity(org.robolectric.shadows.ShadowActivity) Intent(android.content.Intent) ComponentName(android.content.ComponentName) Test(org.junit.Test)

Example 39 with ShadowActivity

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"));
}
Also used : ShadowActivity(org.robolectric.shadows.ShadowActivity) Intent(android.content.Intent) ComponentName(android.content.ComponentName) Uri(android.net.Uri) Test(org.junit.Test)

Example 40 with ShadowActivity

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();
}
Also used : ShadowActivity(org.robolectric.shadows.ShadowActivity) Intent(android.content.Intent) Test(org.junit.Test)

Aggregations

ShadowActivity (org.robolectric.shadows.ShadowActivity)343 Test (org.junit.Test)330 Intent (android.content.Intent)163 ComponentName (android.content.ComponentName)100 Button (android.widget.Button)67 Config (org.robolectric.annotation.Config)53 IntentForResult (org.robolectric.shadows.ShadowActivity.IntentForResult)53 Activity (android.app.Activity)41 EnrollmentCallback (android.hardware.fingerprint.FingerprintManager.EnrollmentCallback)33 Bundle (android.os.Bundle)32 PartnerCustomizationLayout (com.google.android.setupcompat.PartnerCustomizationLayout)30 FooterBarMixin (com.google.android.setupcompat.template.FooterBarMixin)20 FragmentActivity (androidx.fragment.app.FragmentActivity)11 Tile (com.android.settingslib.drawer.Tile)11 Settings (com.android.settings.Settings)10 ContextualCardsFragment (com.android.settings.homepage.contextualcards.ContextualCardsFragment)10 IntentBuilder (com.android.settings.password.ChooseLockPassword.IntentBuilder)7 SetupChooseLockPasswordFragment (com.android.settings.password.SetupChooseLockPassword.SetupChooseLockPasswordFragment)7 ShadowIntent (org.robolectric.shadows.ShadowIntent)7 Preference (android.support.v7.preference.Preference)6