use of androidx.preference.PreferenceCategory in project android_packages_apps_Settings by omnirom.
the class UsbDetailsPowerRoleControllerTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application;
mLifecycle = new Lifecycle(() -> mLifecycle);
mPreferenceManager = new PreferenceManager(mContext);
mScreen = mPreferenceManager.createPreferenceScreen(mContext);
when(mFragment.getActivity()).thenReturn(mActivity);
when(mActivity.getApplicationContext()).thenReturn(mContext);
when(mFragment.getContext()).thenReturn(mContext);
when(mFragment.getPreferenceManager()).thenReturn(mPreferenceManager);
when(mFragment.getPreferenceScreen()).thenReturn(mScreen);
mDetailsPowerRoleController = new UsbDetailsPowerRoleController(mContext, mFragment, mUsbBackend);
mPreference = new PreferenceCategory(mContext);
mPreference.setKey(mDetailsPowerRoleController.getPreferenceKey());
mScreen.addPreference(mPreference);
mDetailsPowerRoleController.mHandler = mHandler;
}
use of androidx.preference.PreferenceCategory in project android_packages_apps_Settings by omnirom.
the class UsbDetailsDataRoleControllerTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application;
mLifecycle = new Lifecycle(() -> mLifecycle);
mPreferenceManager = new PreferenceManager(mContext);
mScreen = mPreferenceManager.createPreferenceScreen(mContext);
when(mFragment.getActivity()).thenReturn(mActivity);
when(mActivity.getApplicationContext()).thenReturn(mContext);
when(mFragment.getContext()).thenReturn(mContext);
when(mFragment.getPreferenceManager()).thenReturn(mPreferenceManager);
when(mFragment.getPreferenceScreen()).thenReturn(mScreen);
mDetailsDataRoleController = new UsbDetailsDataRoleController(mContext, mFragment, mUsbBackend);
mPreference = new PreferenceCategory(mContext);
mPreference.setKey(mDetailsDataRoleController.getPreferenceKey());
mScreen.addPreference(mPreference);
mDetailsDataRoleController.mHandler = mHandler;
}
use of androidx.preference.PreferenceCategory in project android_packages_apps_Settings by omnirom.
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);
}
use of androidx.preference.PreferenceCategory in project android_packages_apps_Settings by omnirom.
the class PlatformCompatDashboardTest method createChangeCategoryPreference_enabledAndDisabled_hasTitleAndEntries.
@Test
public void createChangeCategoryPreference_enabledAndDisabled_hasTitleAndEntries() {
Set<Long> enabledChanges = new HashSet<>();
enabledChanges.add(mChanges[0].getId());
enabledChanges.add(mChanges[1].getId());
enabledChanges.add(mChanges[2].getId());
Set<Long> disabledChanges = new HashSet<>();
disabledChanges.add(mChanges[3].getId());
disabledChanges.add(mChanges[4].getId());
CompatibilityChangeConfig config = new CompatibilityChangeConfig(new ChangeConfig(enabledChanges, disabledChanges));
List<CompatibilityChangeInfo> changesToAdd = new ArrayList<>();
for (int i = 0; i < mChanges.length; ++i) {
changesToAdd.add(new CompatibilityChangeInfo(mChanges[i].getId(), mChanges[i].getName(), -1, mChanges[i].getEnableSinceTargetSdk(), mChanges[i].getDisabled(), mChanges[i].getLoggingOnly(), mChanges[i].getDescription(), mChanges[i].getOverridable()));
}
PreferenceCategory category = mDashboard.createChangeCategoryPreference(changesToAdd, config, "foo");
assertThat(category.getTitle()).isEqualTo("foo");
assertThat(category.getPreferenceCount()).isEqualTo(mChanges.length);
for (int i = 0; i < mChanges.length; ++i) {
Preference childPreference = category.getPreference(i);
assertThat(childPreference instanceof SwitchPreference).isTrue();
}
}
use of androidx.preference.PreferenceCategory in project android_packages_apps_Settings by omnirom.
the class GraphicsDriverAppPreferenceControllerTest method loadConfig.
private void loadConfig(String optIn, String prereleaseOptIn, String optOut) {
Settings.Global.putString(mResolver, Settings.Global.UPDATABLE_DRIVER_PRODUCTION_OPT_IN_APPS, optIn);
Settings.Global.putString(mResolver, Settings.Global.UPDATABLE_DRIVER_PRERELEASE_OPT_IN_APPS, prereleaseOptIn);
Settings.Global.putString(mResolver, Settings.Global.UPDATABLE_DRIVER_PRODUCTION_OPT_OUT_APPS, optOut);
mController = new GraphicsDriverAppPreferenceController(mContext, "testKey");
mController.mEntryList = mContext.getResources().getStringArray(R.array.graphics_driver_app_preference_values);
mGroup = spy(new PreferenceCategory(mContext));
final PreferenceManager preferenceManager = new PreferenceManager(mContext);
when(mGroup.getContext()).thenReturn(mContext);
when(mGroup.getPreferenceManager()).thenReturn(preferenceManager);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mGroup);
mController.displayPreference(mScreen);
}
Aggregations