Search in sources :

Example 46 with ShadowActivity

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

the class FingerprintEnrollFindSensorTest method clickSkip_shouldReturnResultSkip.

@Test
public void clickSkip_shouldReturnResultSkip() {
    PartnerCustomizationLayout layout = mActivity.findViewById(R.id.setup_wizard_layout);
    layout.getMixin(FooterBarMixin.class).getSecondaryButtonView().performClick();
    ShadowActivity shadowActivity = Shadows.shadowOf(mActivity);
    assertWithMessage("result code").that(shadowActivity.getResultCode()).isEqualTo(BiometricEnrollBase.RESULT_SKIP);
}
Also used : PartnerCustomizationLayout(com.google.android.setupcompat.PartnerCustomizationLayout) ShadowActivity(org.robolectric.shadows.ShadowActivity) Test(org.junit.Test)

Example 47 with ShadowActivity

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

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();
    assertWithMessage("Next activity 1").that(startedActivity).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 48 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();
    PartnerCustomizationLayout layout = mActivity.findViewById(R.id.setup_wizard_layout);
    final Button cancelButton = layout.getMixin(FooterBarMixin.class).getSecondaryButtonView();
    assertThat(cancelButton.getText().toString()).isEqualTo("Cancel");
    assertWithMessage("Cancel visible").that(cancelButton.getVisibility()).isEqualTo(View.VISIBLE);
    cancelButton.performClick();
    ShadowActivity shadowActivity = Shadows.shadowOf(mActivity);
    assertWithMessage("Is finishing").that(mActivity.isFinishing()).isTrue();
    assertWithMessage("Result code").that(shadowActivity.getResultCode()).isEqualTo(Activity.RESULT_CANCELED);
}
Also used : PartnerCustomizationLayout(com.google.android.setupcompat.PartnerCustomizationLayout) Button(android.widget.Button) FooterBarMixin(com.google.android.setupcompat.template.FooterBarMixin) ShadowActivity(org.robolectric.shadows.ShadowActivity) Test(org.junit.Test)

Example 49 with ShadowActivity

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

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)

Example 50 with ShadowActivity

use of org.robolectric.shadows.ShadowActivity 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 = ActivityController.of(new SetupChooseLockPassword(), intent).setup().get();
    SetupChooseLockPasswordFragment fragment = (SetupChooseLockPasswordFragment) activity.getSupportFragmentManager().findFragmentById(R.id.main_content);
    fragment.onLockTypeSelected(ScreenLockType.PATTERN);
    ShadowActivity shadowActivity = Shadows.shadowOf(activity);
    final Intent nextStartedActivity = shadowActivity.getNextStartedActivity();
    assertThat(nextStartedActivity).isNotNull();
    assertThat(nextStartedActivity.getBooleanExtra(ChooseLockGenericFragment.EXTRA_SHOW_OPTIONS_BUTTON, false)).isTrue();
    assertWithMessage("Foo extra").that(nextStartedActivity.getStringExtra("foo")).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) 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