Search in sources :

Example 31 with ShadowActivity

use of org.robolectric.shadows.ShadowActivity in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class SliceContextualCardControllerTest method onDismissed_feedbackDisabled_shouldNotShowFeedbackDialog.

@Test
public void onDismissed_feedbackDisabled_shouldNotShowFeedbackDialog() {
    mResolver.insert(CardContentProvider.REFRESH_CARD_URI, generateOneRow());
    final ContextualCardsFragment fragment = FragmentController.of(new ContextualCardsFragment()).create().get();
    final ShadowActivity shadowActivity = Shadows.shadowOf(fragment.getActivity());
    doReturn(false).when(mController).isFeedbackEnabled(anyString());
    mController.onDismissed(getTestSliceCard());
    assertThat(shadowActivity.getNextStartedActivity()).isNull();
}
Also used : ContextualCardsFragment(com.android.settings.homepage.contextualcards.ContextualCardsFragment) ShadowActivity(org.robolectric.shadows.ShadowActivity) Test(org.junit.Test)

Example 32 with ShadowActivity

use of org.robolectric.shadows.ShadowActivity in project DeepLinkDispatch by airbnb.

the class MainActivityTest method testIntentViaMethodResult.

@Test
public void testIntentViaMethodResult() {
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("dld://host/methodResult/intent"));
    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, SecondActivity.class)));
    assertThat(launchedIntent.getBooleanExtra(DeepLink.IS_DEEP_LINK, false), equalTo(true));
    assertThat(launchedIntent.getAction(), equalTo(MainActivity.ACTION_DEEP_LINK_INTENT));
}
Also used : ShadowActivity(org.robolectric.shadows.ShadowActivity) Intent(android.content.Intent) ComponentName(android.content.ComponentName) Test(org.junit.Test)

Example 33 with ShadowActivity

use of org.robolectric.shadows.ShadowActivity in project DeepLinkDispatch by airbnb.

the class MainActivityTest method testQueryParams.

@Test
public void testQueryParams() {
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("dld://classDeepLink?foo=bar"));
    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"), equalTo("bar"));
    assertThat(launchedIntent.getAction(), equalTo(Intent.ACTION_VIEW));
    assertThat(launchedIntent.getStringExtra(DeepLink.URI), equalTo("dld://classDeepLink?foo=bar"));
}
Also used : ShadowActivity(org.robolectric.shadows.ShadowActivity) Intent(android.content.Intent) ComponentName(android.content.ComponentName) Test(org.junit.Test)

Example 34 with ShadowActivity

use of org.robolectric.shadows.ShadowActivity in project DeepLinkDispatch by airbnb.

the class MainActivityTest method testNullIntent.

@Test
public void testNullIntent() {
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("dld://host/intent/null"));
    DeepLinkActivity deepLinkActivity = Robolectric.buildActivity(DeepLinkActivity.class, intent).create().get();
    ShadowActivity shadowActivity = shadowOf(deepLinkActivity);
    assertNull(shadowActivity.peekNextStartedActivityForResult());
}
Also used : ShadowActivity(org.robolectric.shadows.ShadowActivity) Intent(android.content.Intent) Test(org.junit.Test)

Example 35 with ShadowActivity

use of org.robolectric.shadows.ShadowActivity in project DeepLinkDispatch by airbnb.

the class MainActivityTest method testNullDeepLinkMethodResult.

@Test
public void testNullDeepLinkMethodResult() {
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("dld://host/methodResult/null"));
    DeepLinkActivity deepLinkActivity = Robolectric.buildActivity(DeepLinkActivity.class, intent).create().get();
    ShadowActivity shadowActivity = shadowOf(deepLinkActivity);
    assertNull(shadowActivity.peekNextStartedActivityForResult());
}
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