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));
}
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));
}
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);
}
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());
}
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);
}
Aggregations