Search in sources :

Example 51 with ShadowActivity

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

the class ChooseLockSettingsHelperTest method testLaunchConfirmationActivityInternal.

@Test
public void testLaunchConfirmationActivityInternal() {
    final Activity activity = Robolectric.setupActivity(Activity.class);
    ChooseLockSettingsHelper.Builder builder = new ChooseLockSettingsHelper.Builder(activity);
    builder.setRequestCode(100).setTitle("title").setHeader("header").setDescription("description").setForceVerifyPath(true).setReturnCredentials(true).setUserId(UserHandle.myUserId());
    ChooseLockSettingsHelper helper = getChooseLockSettingsHelper(builder);
    helper.launch();
    ShadowActivity shadowActivity = Shadows.shadowOf(activity);
    Intent startedIntent = shadowActivity.getNextStartedActivity();
    assertEquals(new ComponentName("com.android.settings", ConfirmLockPattern.InternalActivity.class.getName()), startedIntent.getComponent());
    assertTrue(startedIntent.getBooleanExtra(ChooseLockSettingsHelper.EXTRA_KEY_RETURN_CREDENTIALS, true));
    assertTrue(startedIntent.getBooleanExtra(ChooseLockSettingsHelper.EXTRA_KEY_FORCE_VERIFY, true));
    assertFalse((startedIntent.getFlags() & Intent.FLAG_ACTIVITY_FORWARD_RESULT) != 0);
    assertFalse(startedIntent.getBooleanExtra(ConfirmDeviceCredentialBaseFragment.DARK_THEME, false));
    assertFalse(startedIntent.getBooleanExtra(ConfirmDeviceCredentialBaseFragment.SHOW_CANCEL_BUTTON, false));
    assertFalse(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 52 with ShadowActivity

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

the class SetNewPasswordActivityTest method launchChooseLock_setNewParentProfilePassword_DevicePasswordRequirementExtra.

@Test
@Config(shadows = { ShadowPasswordUtils.class })
public void launchChooseLock_setNewParentProfilePassword_DevicePasswordRequirementExtra() {
    ShadowPasswordUtils.setCallingAppPackageName(PKG_NAME);
    Settings.Global.putInt(RuntimeEnvironment.application.getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 1);
    Intent intent = new Intent(ACTION_SET_NEW_PARENT_PROFILE_PASSWORD).putExtra(DevicePolicyManager.EXTRA_DEVICE_PASSWORD_REQUIREMENT_ONLY, true);
    SetNewPasswordActivity activity = Robolectric.buildActivity(SetNewPasswordActivity.class, intent).create().get();
    ShadowActivity shadowActivity = Shadows.shadowOf(activity);
    Intent actualIntent = getLaunchChooseLockIntent(shadowActivity);
    assertThat(actualIntent.getBooleanExtra(EXTRA_KEY_DEVICE_PASSWORD_REQUIREMENT_ONLY, false)).isTrue();
    verify(mockMetricsProvider).action(SettingsEnums.PAGE_UNKNOWN, SettingsEnums.ACTION_SET_NEW_PARENT_PROFILE_PASSWORD, SettingsEnums.SET_NEW_PASSWORD_ACTIVITY, PKG_NAME, Integer.MIN_VALUE | (1 << 30));
}
Also used : ShadowActivity(org.robolectric.shadows.ShadowActivity) Intent(android.content.Intent) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 53 with ShadowActivity

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

the class SetNewPasswordActivityTest method testLaunchChooseLock_setNewParentProfilePasswordExtraWithPermission.

@Test
@Config(shadows = { ShadowPasswordUtils.class })
public void testLaunchChooseLock_setNewParentProfilePasswordExtraWithPermission() {
    ShadowPasswordUtils.setCallingAppLabel(APP_LABEL);
    ShadowPasswordUtils.setCallingAppPackageName(PKG_NAME);
    ShadowPasswordUtils.addGrantedPermission(REQUEST_PASSWORD_COMPLEXITY);
    Settings.Global.putInt(RuntimeEnvironment.application.getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 1);
    Intent intent = new Intent(ACTION_SET_NEW_PARENT_PROFILE_PASSWORD);
    intent.putExtra(EXTRA_PASSWORD_COMPLEXITY, PASSWORD_COMPLEXITY_HIGH);
    SetNewPasswordActivity activity = Robolectric.buildActivity(SetNewPasswordActivity.class, intent).create().get();
    ShadowActivity shadowActivity = Shadows.shadowOf(activity);
    Intent actualIntent = getLaunchChooseLockIntent(shadowActivity);
    assertThat(actualIntent.getAction()).isEqualTo(ACTION_SET_NEW_PARENT_PROFILE_PASSWORD);
    assertThat(actualIntent.hasExtra(EXTRA_KEY_REQUESTED_MIN_COMPLEXITY)).isFalse();
    assertThat(actualIntent.hasExtra(EXTRA_KEY_CALLER_APP_NAME)).isTrue();
    assertThat(actualIntent.getStringExtra(EXTRA_KEY_CALLER_APP_NAME)).isEqualTo(APP_LABEL);
    verify(mockMetricsProvider).action(SettingsEnums.PAGE_UNKNOWN, SettingsEnums.ACTION_SET_NEW_PARENT_PROFILE_PASSWORD, SettingsEnums.SET_NEW_PASSWORD_ACTIVITY, PKG_NAME, PASSWORD_COMPLEXITY_HIGH);
}
Also used : ShadowActivity(org.robolectric.shadows.ShadowActivity) Intent(android.content.Intent) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 54 with ShadowActivity

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

the class LocalePickerWithRegionActivityTest method onLocaleSelected_resultShouldBeOK.

@Test
public void onLocaleSelected_resultShouldBeOK() {
    final ShadowActivity shadowActivity = Shadows.shadowOf(mActivity);
    mActivity.onLocaleSelected(mock(LocaleStore.LocaleInfo.class));
    assertEquals(Activity.RESULT_OK, shadowActivity.getResultCode());
}
Also used : ShadowActivity(org.robolectric.shadows.ShadowActivity) Test(org.junit.Test)

Example 55 with ShadowActivity

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

the class BackgroundDataConditionControllerTest method onPrimaryClick_shouldReturn2SummaryActivity.

@Test
public void onPrimaryClick_shouldReturn2SummaryActivity() {
    final ComponentName componentName = new ComponentName(mActivity, Settings.DataUsageSummaryActivity.class);
    mController.onPrimaryClick(mActivity);
    final ShadowActivity shadowActivity = Shadow.extract(mActivity);
    assertThat(shadowActivity.getNextStartedActivity().getComponent()).isEqualTo(componentName);
}
Also used : ShadowActivity(org.robolectric.shadows.ShadowActivity) ComponentName(android.content.ComponentName) Settings(com.android.settings.Settings) 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