use of androidx.preference.PreferenceScreen in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class StorageItemPreferenceControllerTest method displayPreference_hideFilePreferenceWhenNoEmulatedInternalStorage.
@Test
public void displayPreference_hideFilePreferenceWhenNoEmulatedInternalStorage() {
final StorageItemPreference audio = new StorageItemPreference(mContext);
final StorageItemPreference image = new StorageItemPreference(mContext);
final StorageItemPreference games = new StorageItemPreference(mContext);
final StorageItemPreference apps = new StorageItemPreference(mContext);
final StorageItemPreference system = new StorageItemPreference(mContext);
final StorageItemPreference files = new StorageItemPreference(mContext);
final PreferenceScreen screen = mock(PreferenceScreen.class);
when(screen.findPreference(eq(StorageItemPreferenceController.GAME_KEY))).thenReturn(games);
when(screen.findPreference(eq(StorageItemPreferenceController.AUDIO_KEY))).thenReturn(audio);
when(screen.findPreference(eq(StorageItemPreferenceController.PHOTO_KEY))).thenReturn(image);
when(screen.findPreference(eq(StorageItemPreferenceController.FILES_KEY))).thenReturn(files);
when(screen.findPreference(eq(StorageItemPreferenceController.SYSTEM_KEY))).thenReturn(system);
when(screen.findPreference(eq(StorageItemPreferenceController.OTHER_APPS_KEY))).thenReturn(apps);
when(mSvp.findEmulatedForPrivate(nullable(VolumeInfo.class))).thenReturn(null);
mController.displayPreference(screen);
verify(screen).removePreference(files);
}
use of androidx.preference.PreferenceScreen in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class StorageItemPreferenceControllerTest method displayPreference_hideFilePreferenceWhenEmulatedStorageUnreadable.
@Test
public void displayPreference_hideFilePreferenceWhenEmulatedStorageUnreadable() {
final StorageItemPreference audio = new StorageItemPreference(mContext);
final StorageItemPreference image = new StorageItemPreference(mContext);
final StorageItemPreference games = new StorageItemPreference(mContext);
final StorageItemPreference apps = new StorageItemPreference(mContext);
final StorageItemPreference system = new StorageItemPreference(mContext);
final StorageItemPreference files = new StorageItemPreference(mContext);
final PreferenceScreen screen = mock(PreferenceScreen.class);
when(screen.findPreference(eq(StorageItemPreferenceController.GAME_KEY))).thenReturn(games);
when(screen.findPreference(eq(StorageItemPreferenceController.AUDIO_KEY))).thenReturn(audio);
when(screen.findPreference(eq(StorageItemPreferenceController.PHOTO_KEY))).thenReturn(image);
when(screen.findPreference(eq(StorageItemPreferenceController.FILES_KEY))).thenReturn(files);
when(screen.findPreference(eq(StorageItemPreferenceController.SYSTEM_KEY))).thenReturn(system);
when(screen.findPreference(eq(StorageItemPreferenceController.OTHER_APPS_KEY))).thenReturn(apps);
when(mSvp.findEmulatedForPrivate(nullable(VolumeInfo.class))).thenReturn(mVolume);
when(mVolume.isMountedReadable()).thenReturn(false);
mController.displayPreference(screen);
verify(screen).removePreference(files);
}
use of androidx.preference.PreferenceScreen in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ColorModePreferenceFragmentTest method addStaticPreferences_shouldAddPreviewImage.
@Test
public void addStaticPreferences_shouldAddPreviewImage() {
PreferenceScreen mockPreferenceScreen = mock(PreferenceScreen.class);
LayoutPreference mockPreview = mock(LayoutPreference.class);
ArgumentCaptor<Preference> preferenceCaptor = ArgumentCaptor.forClass(Preference.class);
mFragment.configureAndInstallPreview(mockPreview, mockPreferenceScreen);
verify(mockPreview, times(1)).setSelectable(false);
verify(mockPreferenceScreen, times(1)).addPreference(preferenceCaptor.capture());
assertThat(preferenceCaptor.getValue()).isEqualTo(mockPreview);
}
use of androidx.preference.PreferenceScreen in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class HighlightablePreferenceGroupAdapter method adjustInitialExpandedChildCount.
/**
* Tries to override initial expanded child count.
* <p/>
* Initial expanded child count will be ignored if:
* 1. fragment contains request to highlight a particular row.
* 2. count value is invalid.
*/
public static void adjustInitialExpandedChildCount(SettingsPreferenceFragment host) {
if (host == null) {
return;
}
final PreferenceScreen screen = host.getPreferenceScreen();
if (screen == null) {
return;
}
final Bundle arguments = host.getArguments();
if (arguments != null) {
final String highlightKey = arguments.getString(EXTRA_FRAGMENT_ARG_KEY);
if (!TextUtils.isEmpty(highlightKey)) {
// Has highlight row - expand everything
screen.setInitialExpandedChildrenCount(Integer.MAX_VALUE);
return;
}
}
final int initialCount = host.getInitialExpandedChildCount();
if (initialCount <= 0) {
return;
}
screen.setInitialExpandedChildrenCount(initialCount);
}
use of androidx.preference.PreferenceScreen in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SettingsPreferenceFragmentTest method removePreference_nested_shouldRemove.
@Test
public void removePreference_nested_shouldRemove() {
final String key = "test_key";
final PreferenceScreen mScreen = spy(new PreferenceScreen(mContext, null));
when(mScreen.getPreferenceManager()).thenReturn(mock(PreferenceManager.class));
final PreferenceCategory nestedCategory = new ProgressCategory(mContext);
final Preference preference = new Preference(mContext);
preference.setKey(key);
preference.setPersistent(false);
mScreen.addPreference(nestedCategory);
nestedCategory.addPreference(preference);
assertThat(mFragment.removePreference(mScreen, key)).isTrue();
assertThat(nestedCategory.getPreferenceCount()).isEqualTo(0);
}
Aggregations