Search in sources :

Example 86 with ShadowActivity

use of org.robolectric.shadows.ShadowActivity in project platform_packages_apps_Settings by BlissRoms.

the class SetupFingerprintEnrollIntroductionTest method testCancelClicked_shouldSetIntentDataIfLockScreenAdded.

@Test
public void testCancelClicked_shouldSetIntentDataIfLockScreenAdded() {
    getShadowKeyguardManager().setIsKeyguardSecure(false);
    SetupFingerprintEnrollIntroduction activity = mController.create().resume().get();
    final Button skipButton = activity.findViewById(R.id.fingerprint_cancel_button);
    getShadowKeyguardManager().setIsKeyguardSecure(true);
    skipButton.performClick();
    ShadowActivity shadowActivity = Shadows.shadowOf(activity);
    assertThat(shadowActivity.getResultIntent()).isNotNull();
    assertThat(shadowActivity.getResultIntent().hasExtra(SetupChooseLockGenericFragment.EXTRA_PASSWORD_QUALITY)).isTrue();
}
Also used : Button(android.widget.Button) ShadowActivity(org.robolectric.shadows.ShadowActivity) Test(org.junit.Test)

Example 87 with ShadowActivity

use of org.robolectric.shadows.ShadowActivity in project platform_packages_apps_Settings by BlissRoms.

the class WallpaperSuggestionActivityTest method launch_primarySuggestionActivityDoesNotExist_shouldFallback.

@Test
public void launch_primarySuggestionActivityDoesNotExist_shouldFallback() {
    ShadowActivity activity = shadowOf(mController.setup().get());
    final Intent intent = activity.getNextStartedActivity();
    assertThat(intent.getComponent().getClassName()).isEqualTo(SubSettings.class.getName());
}
Also used : SubSettings(com.android.settings.SubSettings) ShadowActivity(org.robolectric.shadows.ShadowActivity) Intent(android.content.Intent) Test(org.junit.Test)

Example 88 with ShadowActivity

use of org.robolectric.shadows.ShadowActivity in project platform_packages_apps_Settings by BlissRoms.

the class ChooseLockSettingsHelperTest method testLaunchConfirmationActivityWithExternalAndChallenge.

@Test
public void testLaunchConfirmationActivityWithExternalAndChallenge() {
    final int userId = UserHandle.myUserId();
    final int request = 100;
    final long challenge = 10000L;
    final Activity activity = Robolectric.setupActivity(Activity.class);
    ChooseLockSettingsHelper helper = getChooseLockSettingsHelper(activity);
    helper.launchConfirmationActivityWithExternalAndChallenge(// request
    request, "title", "header", "description", // external
    true, challenge, userId);
    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(challenge, startedIntent.getLongExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE, 0L));
    assertEquals(true, (startedIntent.getFlags() & Intent.FLAG_ACTIVITY_FORWARD_RESULT) != 0);
    assertEquals(true, startedIntent.getBooleanExtra(ConfirmDeviceCredentialBaseFragment.ALLOW_FP_AUTHENTICATION, false));
    assertEquals(true, startedIntent.getBooleanExtra(ConfirmDeviceCredentialBaseFragment.DARK_THEME, false));
    assertEquals(true, startedIntent.getBooleanExtra(ConfirmDeviceCredentialBaseFragment.SHOW_CANCEL_BUTTON, false));
    assertEquals(true, 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 89 with ShadowActivity

use of org.robolectric.shadows.ShadowActivity in project platform_packages_apps_Settings by BlissRoms.

the class SetNewPasswordActivityTest method testChooseLockGeneric.

@Test
public void testChooseLockGeneric() {
    Settings.Global.putInt(RuntimeEnvironment.application.getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 1);
    SetNewPasswordActivity activity = Robolectric.buildActivity(SetNewPasswordActivity.class).get();
    activity.launchChooseLock(new Bundle());
    ShadowActivity shadowActivity = shadowOf(activity);
    Intent intent = shadowActivity.getNextStartedActivityForResult().intent;
    assertThat(intent.getComponent()).isEqualTo(new ComponentName(activity, ChooseLockGeneric.class));
}
Also used : Bundle(android.os.Bundle) ShadowActivity(org.robolectric.shadows.ShadowActivity) Intent(android.content.Intent) ComponentName(android.content.ComponentName) Test(org.junit.Test)

Example 90 with ShadowActivity

use of org.robolectric.shadows.ShadowActivity in project platform_packages_apps_Settings by BlissRoms.

the class SetNewPasswordActivityTest method testSetupChooseLockGeneric.

@Test
public void testSetupChooseLockGeneric() {
    Settings.Global.putInt(RuntimeEnvironment.application.getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 0);
    SetNewPasswordActivity activity = Robolectric.buildActivity(SetNewPasswordActivity.class).get();
    activity.launchChooseLock(new Bundle());
    ShadowActivity shadowActivity = shadowOf(activity);
    Intent intent = shadowActivity.getNextStartedActivityForResult().intent;
    assertThat(intent.getComponent()).isEqualTo(new ComponentName(activity, SetupChooseLockGeneric.class));
}
Also used : Bundle(android.os.Bundle) ShadowActivity(org.robolectric.shadows.ShadowActivity) Intent(android.content.Intent) ComponentName(android.content.ComponentName) 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