Search in sources :

Example 21 with ShadowActivity

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

the class LocalePickerWithRegionActivityTest method onLocaleSelected_resultShouldBeOK.

@Test
public void onLocaleSelected_resultShouldBeOK() {
    final ShadowActivity shadowActivity = Shadows.shadowOf(mActivity);
    mActivity.onLocaleSelected(mock(LocaleStore.LocaleInfo.class));
    assertEquals(Activity.RESULT_OK, shadowActivity.getResultCode());
}
Also used : ShadowActivity(org.robolectric.shadows.ShadowActivity) Test(org.junit.Test)

Example 22 with ShadowActivity

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

the class ChooseLockSettingsHelperTest method testLaunchConfirmationActivity_internal_shouldPropagateTheme.

@Test
public void testLaunchConfirmationActivity_internal_shouldPropagateTheme() {
    Intent intent = new Intent().putExtra(WizardManagerHelper.EXTRA_THEME, ThemeHelper.THEME_GLIF_V2);
    Activity activity = Robolectric.buildActivity(Activity.class, intent).get();
    ChooseLockSettingsHelper helper = getChooseLockSettingsHelper(activity);
    helper.launchConfirmationActivity(123, "test title", true, 0);
    ShadowActivity shadowActivity = Shadows.shadowOf(activity);
    IntentForResult startedActivity = shadowActivity.getNextStartedActivityForResult();
    assertThat(startedActivity.requestCode).isEqualTo(123);
    assertThat(startedActivity.intent.getStringExtra(WizardManagerHelper.EXTRA_THEME)).isEqualTo(ThemeHelper.THEME_GLIF_V2);
}
Also used : ShadowActivity(org.robolectric.shadows.ShadowActivity) Activity(android.app.Activity) ShadowActivity(org.robolectric.shadows.ShadowActivity) Intent(android.content.Intent) IntentForResult(org.robolectric.shadows.ShadowActivity.IntentForResult) Test(org.junit.Test)

Example 23 with ShadowActivity

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

the class ChooseLockSettingsHelperTest method testLaunchConfirmationActivityWithExternalAndChallenge.

@Test
public void testLaunchConfirmationActivityWithExternalAndChallenge() {
    final Activity activity = Robolectric.setupActivity(Activity.class);
    ChooseLockSettingsHelper helper = getChooseLockSettingsHelper(activity);
    helper.launchConfirmationActivityWithExternalAndChallenge(// request
    100, "title", "header", "description", // external
    true, 10000L, UserHandle.myUserId());
    ShadowActivity shadowActivity = Shadows.shadowOf(activity);
    Intent startedIntent = shadowActivity.getNextStartedActivity();
    assertEquals(new ComponentName("com.android.settings", ConfirmLockPattern.InternalActivity.class.getName()), startedIntent.getComponent());
    assertFalse(startedIntent.getBooleanExtra(ChooseLockSettingsHelper.EXTRA_KEY_RETURN_CREDENTIALS, false));
    assertTrue(startedIntent.getBooleanExtra(ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, false));
    assertEquals(10000L, startedIntent.getLongExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE, 0L));
    assertTrue((startedIntent.getFlags() & Intent.FLAG_ACTIVITY_FORWARD_RESULT) != 0);
    assertFalse(startedIntent.getBooleanExtra(ConfirmDeviceCredentialBaseFragment.DARK_THEME, false));
    assertFalse(startedIntent.getBooleanExtra(ConfirmDeviceCredentialBaseFragment.SHOW_CANCEL_BUTTON, false));
    assertTrue(startedIntent.getBooleanExtra(ConfirmDeviceCredentialBaseFragment.SHOW_WHEN_LOCKED, false));
}
Also used : ShadowActivity(org.robolectric.shadows.ShadowActivity) Activity(android.app.Activity) ShadowActivity(org.robolectric.shadows.ShadowActivity) Intent(android.content.Intent) ComponentName(android.content.ComponentName) Test(org.junit.Test)

Example 24 with ShadowActivity

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

the class ChooseLockSettingsHelperTest method testLaunchConfirmationActivityInternalAndChallenge.

@Test
public void testLaunchConfirmationActivityInternalAndChallenge() {
    final Activity activity = Robolectric.setupActivity(Activity.class);
    ChooseLockSettingsHelper helper = getChooseLockSettingsHelper(activity);
    helper.launchConfirmationActivityWithExternalAndChallenge(100, "title", "header", "description", // external
    false, 10000L, UserHandle.myUserId());
    ShadowActivity shadowActivity = Shadows.shadowOf(activity);
    Intent startedIntent = shadowActivity.getNextStartedActivity();
    assertEquals(new ComponentName("com.android.settings", ConfirmLockPattern.InternalActivity.class.getName()), startedIntent.getComponent());
    assertFalse(startedIntent.getBooleanExtra(ChooseLockSettingsHelper.EXTRA_KEY_RETURN_CREDENTIALS, false));
    assertTrue(startedIntent.getBooleanExtra(ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, false));
    assertEquals(10000L, startedIntent.getLongExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE, 0L));
    assertFalse((startedIntent.getFlags() & Intent.FLAG_ACTIVITY_FORWARD_RESULT) != 0);
    assertFalse(startedIntent.getBooleanExtra(ConfirmDeviceCredentialBaseFragment.DARK_THEME, false));
    assertFalse(startedIntent.getBooleanExtra(ConfirmDeviceCredentialBaseFragment.SHOW_CANCEL_BUTTON, false));
    assertFalse(startedIntent.getBooleanExtra(ConfirmDeviceCredentialBaseFragment.SHOW_WHEN_LOCKED, false));
}
Also used : ShadowActivity(org.robolectric.shadows.ShadowActivity) Activity(android.app.Activity) ShadowActivity(org.robolectric.shadows.ShadowActivity) Intent(android.content.Intent) ComponentName(android.content.ComponentName) Test(org.junit.Test)

Example 25 with ShadowActivity

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

the class SetupChooseLockGenericTest method setupChooseLockGenericPasswordComplexityExtraWithoutPermission.

@Test
public void setupChooseLockGenericPasswordComplexityExtraWithoutPermission() {
    Intent intent = new Intent("com.android.settings.SETUP_LOCK_SCREEN");
    intent.putExtra(EXTRA_KEY_REQUESTED_MIN_COMPLEXITY, PASSWORD_COMPLEXITY_HIGH);
    SetupChooseLockGeneric activity = Robolectric.buildActivity(SetupChooseLockGeneric.class, intent).create().get();
    ShadowActivity shadowActivity = Shadows.shadowOf(activity);
    assertThat(shadowActivity.isFinishing()).isTrue();
}
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