Search in sources :

Example 66 with ShadowActivity

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

the class SetupFingerprintEnrollIntroductionTest method testKeyguardSecure_shouldFinishWithFingerprintResultSkip.

@Test
public void testKeyguardSecure_shouldFinishWithFingerprintResultSkip() {
    getShadowKeyguardManager().setIsKeyguardSecure(true);
    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(FingerprintEnrollBase.RESULT_SKIP);
}
Also used : Button(android.widget.Button) ShadowActivity(org.robolectric.shadows.ShadowActivity) Test(org.junit.Test)

Example 67 with ShadowActivity

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

the class FingerprintEnrollFindSensorTest method enrollFingerprintTwice_shouldStartOneEnrolling.

@Test
public void enrollFingerprintTwice_shouldStartOneEnrolling() {
    EnrollmentCallback enrollmentCallback = verifyAndCaptureEnrollmentCallback();
    enrollmentCallback.onEnrollmentProgress(123);
    // A second enroll should be a no-op
    enrollmentCallback.onEnrollmentProgress(123);
    ShadowActivity shadowActivity = Shadows.shadowOf(mActivity);
    IntentForResult startedActivity = shadowActivity.getNextStartedActivityForResult();
    assertThat(startedActivity).named("Next activity 1").isNotNull();
    assertThat(startedActivity.intent.getComponent()).isEqualTo(new ComponentName(application, FingerprintEnrollEnrolling.class));
    // Should only start one next activity
    assertThat(shadowActivity.getNextStartedActivityForResult()).named("Next activity 2").isNull();
}
Also used : ShadowActivity(org.robolectric.shadows.ShadowActivity) ComponentName(android.content.ComponentName) IntentForResult(org.robolectric.shadows.ShadowActivity.IntentForResult) EnrollmentCallback(android.hardware.fingerprint.FingerprintManager.EnrollmentCallback) Test(org.junit.Test)

Example 68 with ShadowActivity

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

the class FingerprintEnrollFindSensorTest method clickSkip_shouldReturnResultSkip.

@Test
public void clickSkip_shouldReturnResultSkip() {
    Button skipButton = mActivity.findViewById(R.id.skip_button);
    skipButton.performClick();
    ShadowActivity shadowActivity = Shadows.shadowOf(mActivity);
    assertThat(shadowActivity.getResultCode()).named("result code").isEqualTo(FingerprintEnrollBase.RESULT_SKIP);
}
Also used : Button(android.widget.Button) ShadowActivity(org.robolectric.shadows.ShadowActivity) Test(org.junit.Test)

Example 69 with ShadowActivity

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

the class FingerprintEnrollFindSensorTest method enrollFingerprint_shouldProceed.

@Test
public void enrollFingerprint_shouldProceed() {
    EnrollmentCallback enrollmentCallback = verifyAndCaptureEnrollmentCallback();
    enrollmentCallback.onEnrollmentProgress(123);
    enrollmentCallback.onEnrollmentError(FingerprintManager.FINGERPRINT_ERROR_CANCELED, "test");
    ShadowActivity shadowActivity = Shadows.shadowOf(mActivity);
    IntentForResult startedActivity = shadowActivity.getNextStartedActivityForResult();
    assertThat(startedActivity).named("Next activity 1").isNotNull();
    assertThat(startedActivity.intent.getComponent()).isEqualTo(new ComponentName(application, FingerprintEnrollEnrolling.class));
}
Also used : ShadowActivity(org.robolectric.shadows.ShadowActivity) ComponentName(android.content.ComponentName) IntentForResult(org.robolectric.shadows.ShadowActivity.IntentForResult) EnrollmentCallback(android.hardware.fingerprint.FingerprintManager.EnrollmentCallback) Test(org.junit.Test)

Example 70 with ShadowActivity

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

the class FingerprintEnrollFindSensorTest method layoutWithoutAnimation_shouldNotCrash.

// Use a non-default resource qualifier to load the test layout in
// robotests/res/layout-mcc999/fingerprint_enroll_find_sensor. This layout is a copy of the
// regular find sensor layout, with the animation removed.
@Config(qualifiers = "mcc999")
@Test
public void layoutWithoutAnimation_shouldNotCrash() {
    EnrollmentCallback enrollmentCallback = verifyAndCaptureEnrollmentCallback();
    enrollmentCallback.onEnrollmentProgress(123);
    enrollmentCallback.onEnrollmentError(FingerprintManager.FINGERPRINT_ERROR_CANCELED, "test");
    ShadowActivity shadowActivity = Shadows.shadowOf(mActivity);
    IntentForResult startedActivity = shadowActivity.getNextStartedActivityForResult();
    assertThat(startedActivity).named("Next activity").isNotNull();
    assertThat(startedActivity.intent.getComponent()).isEqualTo(new ComponentName(application, FingerprintEnrollEnrolling.class));
}
Also used : ShadowActivity(org.robolectric.shadows.ShadowActivity) ComponentName(android.content.ComponentName) IntentForResult(org.robolectric.shadows.ShadowActivity.IntentForResult) EnrollmentCallback(android.hardware.fingerprint.FingerprintManager.EnrollmentCallback) Test(org.junit.Test) Config(org.robolectric.annotation.Config) TestConfig(com.android.settings.TestConfig)

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