use of androidx.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DashboardFeatureProviderImplTest method clickPreference_withUnresolvableIntent_shouldNotLaunchAnything.
@Test
public void clickPreference_withUnresolvableIntent_shouldNotLaunchAnything() {
ReflectionHelpers.setField(mImpl, "mPackageManager", RuntimeEnvironment.application.getPackageManager());
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();
final ShadowActivity.IntentForResult launchIntent = Shadows.shadowOf(activity).getNextStartedActivityForResult();
assertThat(launchIntent).isNull();
}
use of androidx.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DashboardFeatureProviderImplTest method bindPreference_withNullKeyNullPriority_shouldGenerateKeyAndPriority.
@Test
public void bindPreference_withNullKeyNullPriority_shouldGenerateKeyAndPriority() {
final Preference preference = new Preference(RuntimeEnvironment.application);
final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
mImpl.bindPreferenceToTile(mActivity, mForceRoundedIcon, MetricsEvent.VIEW_UNKNOWN, preference, tile, null, /*key */
Preference.DEFAULT_ORDER);
assertThat(preference.getKey()).isNotNull();
assertThat(preference.getOrder()).isEqualTo(Preference.DEFAULT_ORDER);
}
use of androidx.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DashboardFeatureProviderImplTest method bindPreference_noFragmentMetadata_shouldBindToProfileSelector.
@Test
public void bindPreference_noFragmentMetadata_shouldBindToProfileSelector() {
final Preference preference = new Preference(RuntimeEnvironment.application);
final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
tile.userHandle = new ArrayList<>();
tile.userHandle.add(mock(UserHandle.class));
tile.userHandle.add(mock(UserHandle.class));
mImpl.bindPreferenceToTile(mActivity, mForceRoundedIcon, MetricsEvent.SETTINGS_GESTURES, preference, tile, "123", Preference.DEFAULT_ORDER);
preference.getOnPreferenceClickListener().onPreferenceClick(null);
verify(mActivity).getSupportFragmentManager();
}
use of androidx.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DashboardFeatureProviderImplTest method bindPreference_noFragmentMetadataSingleUser_shouldBindToDirectLaunchIntent.
@Test
public void bindPreference_noFragmentMetadataSingleUser_shouldBindToDirectLaunchIntent() {
final Preference preference = new Preference(RuntimeEnvironment.application);
final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
tile.userHandle = new ArrayList<>();
tile.userHandle.add(mock(UserHandle.class));
when(mActivity.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
mImpl.bindPreferenceToTile(mActivity, mForceRoundedIcon, MetricsEvent.SETTINGS_GESTURES, preference, tile, "123", Preference.DEFAULT_ORDER);
preference.getOnPreferenceClickListener().onPreferenceClick(null);
verify(mFeatureFactory.metricsFeatureProvider).logDashboardStartIntent(any(Context.class), any(Intent.class), eq(MetricsEvent.SETTINGS_GESTURES));
verify(mActivity).startActivityForResultAsUser(any(Intent.class), anyInt(), any(UserHandle.class));
}
use of androidx.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DashboardFeatureProviderImplTest method bindPreference_noFragmentMetadata_shouldBindIntent.
@Test
public void bindPreference_noFragmentMetadata_shouldBindIntent() {
final Preference preference = new Preference(RuntimeEnvironment.application);
mActivityInfo.metaData.putInt(META_DATA_KEY_ORDER, 10);
final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
mImpl.bindPreferenceToTile(mActivity, mForceRoundedIcon, MetricsEvent.SETTINGS_GESTURES, preference, tile, "123", Preference.DEFAULT_ORDER);
assertThat(preference.getFragment()).isNull();
assertThat(preference.getOnPreferenceClickListener()).isNotNull();
assertThat(preference.getOrder()).isEqualTo(tile.getOrder());
}
Aggregations