Search in sources :

Example 96 with ShadowActivity

use of org.robolectric.shadows.ShadowActivity in project android_packages_apps_Settings by omnirom.

the class FingerprintSuggestionActivityTest method testKeyguardSecure_shouldFinishWithFingerprintResultSkip.

@Test
public void testKeyguardSecure_shouldFinishWithFingerprintResultSkip() {
    getShadowKeyguardManager().setIsKeyguardSecure(true);
    mController.create().resume();
    final Button cancelButton = mController.get().findViewById(R.id.fingerprint_cancel_button);
    assertThat(cancelButton.getText().toString()).isEqualTo("Cancel");
    assertThat(cancelButton.getVisibility()).named("Cancel visible").isEqualTo(View.VISIBLE);
    cancelButton.performClick();
    ShadowActivity shadowActivity = Shadows.shadowOf(mController.get());
    assertThat(mController.get().isFinishing()).named("Is finishing").isTrue();
    assertThat(shadowActivity.getResultCode()).named("Result code").isEqualTo(Activity.RESULT_CANCELED);
}
Also used : Button(android.widget.Button) ShadowActivity(org.robolectric.shadows.ShadowActivity) Test(org.junit.Test)

Example 97 with ShadowActivity

use of org.robolectric.shadows.ShadowActivity in project android_packages_apps_Settings by omnirom.

the class SetupFingerprintEnrollIntroductionTest method testKeyguardNotSecure_shouldFinishWithSetupSkipDialogResultSkip.

@Test
public void testKeyguardNotSecure_shouldFinishWithSetupSkipDialogResultSkip() {
    getShadowKeyguardManager().setIsKeyguardSecure(false);
    mController.create().resume();
    final Button skipButton = mController.get().findViewById(R.id.fingerprint_cancel_button);
    assertThat(skipButton.getVisibility()).named("Skip visible").isEqualTo(View.VISIBLE);
    skipButton.performClick();
    ShadowActivity shadowActivity = Shadows.shadowOf(mController.get());
    assertThat(mController.get().isFinishing()).named("Is finishing").isTrue();
    assertThat(shadowActivity.getResultCode()).named("Result code").isEqualTo(SetupSkipDialog.RESULT_SKIP);
}
Also used : Button(android.widget.Button) ShadowActivity(org.robolectric.shadows.ShadowActivity) Test(org.junit.Test)

Example 98 with ShadowActivity

use of org.robolectric.shadows.ShadowActivity in project android_packages_apps_Settings by omnirom.

the class SetupFingerprintEnrollIntroductionTest method testCancelClicked_shouldNotSetIntentDataIfLockScreenPresentBeforeLaunch.

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

Example 99 with ShadowActivity

use of org.robolectric.shadows.ShadowActivity in project android_packages_apps_Settings by omnirom.

the class SetupFingerprintEnrollIntroductionTest method testBackKeyPress_shouldNotSetIntentDataIfLockScreenPresentBeforeLaunch.

@Test
public void testBackKeyPress_shouldNotSetIntentDataIfLockScreenPresentBeforeLaunch() {
    getShadowKeyguardManager().setIsKeyguardSecure(true);
    mController.create().resume();
    SetupFingerprintEnrollIntroduction activity = mController.get();
    activity.onBackPressed();
    ShadowActivity shadowActivity = Shadows.shadowOf(activity);
    assertThat(shadowActivity.getResultIntent()).isNull();
}
Also used : ShadowActivity(org.robolectric.shadows.ShadowActivity) Test(org.junit.Test)

Example 100 with ShadowActivity

use of org.robolectric.shadows.ShadowActivity in project android_packages_apps_Settings by omnirom.

the class SetupFingerprintEnrollIntroductionTest method testLockPattern.

@Test
public void testLockPattern() {
    ShadowStorageManagerWrapper.sIsFileEncrypted = false;
    mController.create().postCreate(null).resume();
    SetupFingerprintEnrollIntroduction activity = mController.get();
    final Button nextButton = activity.findViewById(R.id.fingerprint_next_button);
    nextButton.performClick();
    ShadowActivity shadowActivity = Shadows.shadowOf(activity);
    IntentForResult startedActivity = shadowActivity.getNextStartedActivityForResult();
    assertThat(startedActivity).isNotNull();
    assertThat(startedActivity.intent.hasExtra(SetupChooseLockGenericFragment.EXTRA_PASSWORD_QUALITY)).isFalse();
}
Also used : Button(android.widget.Button) ShadowActivity(org.robolectric.shadows.ShadowActivity) IntentForResult(org.robolectric.shadows.ShadowActivity.IntentForResult) 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