Search in sources :

Example 1 with IntentForResult

use of org.robolectric.shadows.ShadowActivity.IntentForResult in project android_packages_apps_Settings by LineageOS.

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)

Example 2 with IntentForResult

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

the class SetupChooseLockPasswordTest method createActivity_clickDifferentOption_extrasShouldBePropagated.

@Test
public void createActivity_clickDifferentOption_extrasShouldBePropagated() {
    Bundle bundle = new Bundle();
    bundle.putString("foo", "bar");
    Intent intent = new IntentBuilder(application).build();
    intent.putExtra(ChooseLockGenericFragment.EXTRA_CHOOSE_LOCK_GENERIC_EXTRAS, bundle);
    intent = SetupChooseLockPassword.modifyIntentForSetup(application, intent);
    intent.putExtra(ChooseLockGenericFragment.EXTRA_SHOW_OPTIONS_BUTTON, true);
    SetupChooseLockPassword activity = Robolectric.buildActivity(SetupChooseLockPassword.class, intent).setup().get();
    SetupChooseLockPasswordFragment fragment = (SetupChooseLockPasswordFragment) activity.getFragmentManager().findFragmentById(R.id.main_content);
    fragment.onLockTypeSelected(ScreenLockType.PATTERN);
    ShadowActivity shadowActivity = shadowOf(activity);
    IntentForResult chooseLockIntent = shadowActivity.getNextStartedActivityForResult();
    assertThat(chooseLockIntent).isNotNull();
    assertThat(chooseLockIntent.requestCode).isEqualTo(SetupChooseLockPasswordFragment.REQUEST_SCREEN_LOCK_OPTIONS);
    assertThat(chooseLockIntent.intent.getStringExtra("foo")).named("Foo extra").isEqualTo("bar");
}
Also used : Bundle(android.os.Bundle) IntentBuilder(com.android.settings.password.ChooseLockPassword.IntentBuilder) SetupChooseLockPasswordFragment(com.android.settings.password.SetupChooseLockPassword.SetupChooseLockPasswordFragment) ShadowActivity(org.robolectric.shadows.ShadowActivity) Intent(android.content.Intent) IntentForResult(org.robolectric.shadows.ShadowActivity.IntentForResult) Test(org.junit.Test)

Example 3 with IntentForResult

use of org.robolectric.shadows.ShadowActivity.IntentForResult in project android_packages_apps_Settings by crdroidandroid.

the class ChooseLockSettingsHelperTest method testLaunchConfirmationActivity_internal_shouldPropagateTheme.

@Test
public void testLaunchConfirmationActivity_internal_shouldPropagateTheme() {
    Intent intent = new Intent().putExtra(WizardManagerHelper.EXTRA_THEME, WizardManagerHelper.THEME_GLIF_V2);
    Activity activity = Robolectric.buildActivity(Activity.class).withIntent(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(WizardManagerHelper.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 4 with IntentForResult

use of org.robolectric.shadows.ShadowActivity.IntentForResult in project android_packages_apps_Settings by crdroidandroid.

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 5 with IntentForResult

use of org.robolectric.shadows.ShadowActivity.IntentForResult in project android_packages_apps_Settings by crdroidandroid.

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)

Aggregations

IntentForResult (org.robolectric.shadows.ShadowActivity.IntentForResult)44 Test (org.junit.Test)43 ShadowActivity (org.robolectric.shadows.ShadowActivity)41 ComponentName (android.content.ComponentName)21 EnrollmentCallback (android.hardware.fingerprint.FingerprintManager.EnrollmentCallback)21 Intent (android.content.Intent)15 Activity (android.app.Activity)7 Bundle (android.os.Bundle)7 Config (org.robolectric.annotation.Config)7 Button (android.widget.Button)6 TestConfig (com.android.settings.TestConfig)6 IntentBuilder (com.android.settings.password.ChooseLockPassword.IntentBuilder)6 SetupChooseLockPasswordFragment (com.android.settings.password.SetupChooseLockPassword.SetupChooseLockPasswordFragment)6 FilterComparison (android.content.Intent.FilterComparison)1 PartnerCustomizationLayout (com.google.android.setupcompat.PartnerCustomizationLayout)1