use of org.robolectric.shadows.ShadowActivity in project Resurrection_packages_apps_Settings by ResurrectionRemix.
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 Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SetNewPasswordActivityTest method testLaunchChooseLock_setNewPasswordExtraInvalidValue.
@Test
@Config(shadows = { ShadowPasswordUtils.class })
public void testLaunchChooseLock_setNewPasswordExtraInvalidValue() {
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_PASSWORD);
intent.putExtra(EXTRA_PASSWORD_COMPLEXITY, -1);
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_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_PASSWORD, SettingsEnums.SET_NEW_PASSWORD_ACTIVITY, PKG_NAME, -1);
}
use of org.robolectric.shadows.ShadowActivity in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DefaultAppShortcutPreferenceControllerBaseTest method handlePreferenceTreeClick_shouldStartManageDefaultAppIntent.
@Test
public void handlePreferenceTreeClick_shouldStartManageDefaultAppIntent() {
final ShadowActivity shadowActivity = shadowOf(mActivity);
mController.handlePreferenceTreeClick(mPreference);
final Intent intent = shadowActivity.getNextStartedActivity();
assertThat(intent).isNotNull();
assertThat(intent.getAction()).isEqualTo(Intent.ACTION_MANAGE_DEFAULT_APP);
assertThat(intent.getStringExtra(Intent.EXTRA_ROLE_NAME)).isEqualTo(TEST_ROLE_NAME);
}
use of org.robolectric.shadows.ShadowActivity in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DashboardFeatureProviderImplTest method bindPreference_withIntentActionMetadata_shouldSetLaunchAction.
@Test
public void bindPreference_withIntentActionMetadata_shouldSetLaunchAction() {
FragmentActivity activity = Robolectric.buildActivity(FragmentActivity.class).get();
final Preference preference = new Preference(RuntimeEnvironment.application);
final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
mActivityInfo.metaData.putString(META_DATA_PREFERENCE_KEYHINT, "key");
mActivityInfo.metaData.putString("com.android.settings.intent.action", "TestAction");
tile.userHandle = null;
mImpl.bindPreferenceToTile(activity, mForceRoundedIcon, MetricsEvent.SETTINGS_GESTURES, preference, tile, "123", Preference.DEFAULT_ORDER);
preference.performClick();
ShadowActivity shadowActivity = Shadows.shadowOf(activity);
final Intent launchIntent = shadowActivity.getNextStartedActivityForResult().intent;
assertThat(launchIntent.getAction()).isEqualTo("TestAction");
assertThat(launchIntent.getIntExtra(MetricsFeatureProvider.EXTRA_SOURCE_METRICS_CATEGORY, 0)).isEqualTo(MetricsEvent.SETTINGS_GESTURES);
}
use of org.robolectric.shadows.ShadowActivity in project Resurrection_packages_apps_Settings by ResurrectionRemix.
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