use of androidx.preference.PreferenceScreen in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SettingsPreferenceFragmentTest method removePreference_flat_shouldRemove.
@Test
public void removePreference_flat_shouldRemove() {
final String key = "test_key";
final PreferenceScreen mScreen = spy(new PreferenceScreen(mContext, null));
when(mScreen.getPreferenceManager()).thenReturn(mock(PreferenceManager.class));
final Preference preference = mock(Preference.class);
when(preference.getKey()).thenReturn(key);
mScreen.addPreference(preference);
assertThat(mFragment.removePreference(mScreen, key)).isTrue();
assertThat(mScreen.getPreferenceCount()).isEqualTo(0);
}
use of androidx.preference.PreferenceScreen in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class BasePreferenceControllerTest method disabledDependentSetting_disabledOnDisplayPreference_preferenceDisabled.
@Test
public void disabledDependentSetting_disabledOnDisplayPreference_preferenceDisabled() {
final PreferenceScreen screen = mock(PreferenceScreen.class);
final Preference preference = new Preference(mContext);
preference.setEnabled(true);
when(screen.findPreference(anyString())).thenReturn(preference);
mPreferenceController.setAvailability(DISABLED_DEPENDENT_SETTING);
mPreferenceController.displayPreference(screen);
assertThat(preference.isEnabled()).isFalse();
}
use of androidx.preference.PreferenceScreen in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class BasePreferenceControllerTest method settingAvailable_disabledOnDisplayPreference_preferenceEnabled.
@Test
public void settingAvailable_disabledOnDisplayPreference_preferenceEnabled() {
final PreferenceScreen screen = mock(PreferenceScreen.class);
final Preference preference = new Preference(mContext);
preference.setEnabled(true);
when(screen.findPreference(anyString())).thenReturn(preference);
mPreferenceController.displayPreference(screen);
assertThat(preference.isEnabled()).isTrue();
}
use of androidx.preference.PreferenceScreen in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class InputMethodAndSubtypePreferenceControllerTest method displayPreference_hasInputMethodSubType_shouldAddPreference.
@Test
public void displayPreference_hasInputMethodSubType_shouldAddPreference() {
final PreferenceManager preferenceManager = new PreferenceManager(mContext);
final PreferenceScreen screen = preferenceManager.createPreferenceScreen(mContext);
mController.displayPreference(screen);
assertThat(screen.getPreferenceCount()).isEqualTo(0);
final List<InputMethodInfo> imis = new ArrayList<>();
imis.add(createInputMethodInfo("test", mContext));
ShadowInputMethodManagerWithMethodList.getShadow().setInputMethodList(imis);
mController.initialize(mFragment, "");
mController.displayPreference(screen);
assertThat(screen.getPreferenceCount()).isEqualTo(2);
}
use of androidx.preference.PreferenceScreen in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class KeyboardLayoutPickerControllerTest method test_createPreferenceHierarchy_shouldAddTwoPreference.
@Test
public void test_createPreferenceHierarchy_shouldAddTwoPreference() {
initializeTwoLayouts();
final PreferenceManager preferenceManager = new PreferenceManager(mContext);
final PreferenceScreen screen = preferenceManager.createPreferenceScreen(mContext);
mController.displayPreference(screen);
// We create two keyboard layouts in initializeOneLayout()
assertThat(screen.getPreferenceCount()).isEqualTo(2);
}
Aggregations