Search in sources :

Example 61 with PreferenceScreen

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);
}
Also used : PreferenceScreen(androidx.preference.PreferenceScreen) Preference(androidx.preference.Preference) PreferenceManager(androidx.preference.PreferenceManager) Test(org.junit.Test)

Example 62 with PreferenceScreen

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();
}
Also used : PreferenceScreen(androidx.preference.PreferenceScreen) Preference(androidx.preference.Preference) Test(org.junit.Test)

Example 63 with PreferenceScreen

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();
}
Also used : PreferenceScreen(androidx.preference.PreferenceScreen) Preference(androidx.preference.Preference) Test(org.junit.Test)

Example 64 with PreferenceScreen

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);
}
Also used : PreferenceScreen(androidx.preference.PreferenceScreen) ArrayList(java.util.ArrayList) PreferenceManager(androidx.preference.PreferenceManager) InputMethodInfo(android.view.inputmethod.InputMethodInfo) Test(org.junit.Test)

Example 65 with PreferenceScreen

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);
}
Also used : PreferenceScreen(androidx.preference.PreferenceScreen) PreferenceManager(androidx.preference.PreferenceManager) Test(org.junit.Test)

Aggregations

PreferenceScreen (androidx.preference.PreferenceScreen)244 Preference (androidx.preference.Preference)81 Test (org.junit.Test)60 Context (android.content.Context)36 PreferenceManager (androidx.preference.PreferenceManager)36 ContentResolver (android.content.ContentResolver)25 PreferenceCategory (androidx.preference.PreferenceCategory)24 Bundle (android.os.Bundle)20 ArrayList (java.util.ArrayList)20 SwitchPreference (androidx.preference.SwitchPreference)19 Resources (android.content.res.Resources)18 Before (org.junit.Before)17 ListPreference (androidx.preference.ListPreference)14 PackageManager (android.content.pm.PackageManager)13 PreferenceGroup (androidx.preference.PreferenceGroup)13 ApplicationInfo (android.content.pm.ApplicationInfo)9 VisibleForTesting (androidx.annotation.VisibleForTesting)9 List (java.util.List)9 UserManager (android.os.UserManager)8 StorageItemPreference (com.android.settings.deviceinfo.StorageItemPreference)8