use of androidx.preference.PreferenceScreen in project android_packages_apps_Settings by omnirom.
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 android_packages_apps_Settings by omnirom.
the class ConnectedDeviceGroupControllerTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application;
mPreference = new Preference(mContext);
mPreference.setKey(PREFERENCE_KEY_1);
mPackageManager = (ShadowApplicationPackageManager) Shadows.shadowOf(mContext.getPackageManager());
mPreferenceGroup = spy(new PreferenceScreen(mContext, null));
when(mPreferenceGroup.getPreferenceManager()).thenReturn(mPreferenceManager);
doReturn(mContext).when(mDashboardFragment).getContext();
mPackageManager.setSystemFeature(PackageManager.FEATURE_BLUETOOTH, true);
mConnectedDeviceGroupController = new ConnectedDeviceGroupController(mContext);
mConnectedDeviceGroupController.init(mConnectedBluetoothDeviceUpdater, mConnectedUsbDeviceUpdater, mConnectedDockUpdater);
mConnectedDeviceGroupController.mPreferenceGroup = mPreferenceGroup;
}
use of androidx.preference.PreferenceScreen in project android_packages_apps_Settings by omnirom.
the class RestrictAppPreferenceControllerTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
final List<AppOpsManager.OpEntry> allowOps = new ArrayList<>();
allowOps.add(new AppOpsManager.OpEntry(AppOpsManager.OP_RUN_ANY_IN_BACKGROUND, AppOpsManager.MODE_ALLOWED, Collections.emptyMap()));
final List<AppOpsManager.OpEntry> restrictedOps = new ArrayList<>();
restrictedOps.add(new AppOpsManager.OpEntry(AppOpsManager.OP_RUN_ANY_IN_BACKGROUND, AppOpsManager.MODE_IGNORED, Collections.emptyMap()));
mAllowedPackageOps = new AppOpsManager.PackageOps(ALLOWED_PACKAGE_NAME, ALLOWED_UID, allowOps);
mRestrictedPackageOps = new AppOpsManager.PackageOps(RESTRICTED_PACKAGE_NAME, RESTRICTED_UID, restrictedOps);
mOtherUserPackageOps = new AppOpsManager.PackageOps(RESTRICTED_PACKAGE_NAME, OTHER_USER_UID, restrictedOps);
mContext = spy(Robolectric.setupActivity(Activity.class));
doReturn(mAppOpsManager).when(mContext).getSystemService(Context.APP_OPS_SERVICE);
doReturn(mUserManager).when(mContext).getSystemService(UserManager.class);
doReturn(mContext).when(mFragment).getContext();
mPackageOpsList = new ArrayList<>();
mPreference = new Preference(mContext);
mPreference.setKey(RestrictAppPreferenceController.KEY_RESTRICT_APP);
mPreferenceScreen = spy(new PreferenceScreen(mContext, null));
when(mPreferenceScreen.getPreferenceManager()).thenReturn(mock(PreferenceManager.class));
when(mPreferenceScreen.getContext()).thenReturn(mContext);
when(mPreferenceScreen.findPreference(RestrictAppPreferenceController.KEY_RESTRICT_APP)).thenReturn(mPreference);
final List<UserHandle> userHandles = new ArrayList<>();
userHandles.add(new UserHandle(0));
doReturn(userHandles).when(mUserManager).getUserProfiles();
}
use of androidx.preference.PreferenceScreen in project android_packages_apps_Settings by omnirom.
the class HighlightablePreferenceGroupAdapterTest method adjustInitialExpandedChildCount_hasCountOverride_shouldDoNothing.
@Test
public void adjustInitialExpandedChildCount_hasCountOverride_shouldDoNothing() {
when(mFragment.getInitialExpandedChildCount()).thenReturn(10);
final PreferenceScreen screen = mock(PreferenceScreen.class);
when(mFragment.getPreferenceScreen()).thenReturn(screen);
HighlightablePreferenceGroupAdapter.adjustInitialExpandedChildCount(mFragment);
verify(mFragment).getInitialExpandedChildCount();
verify(screen).setInitialExpandedChildrenCount(10);
}
use of androidx.preference.PreferenceScreen in project android_packages_apps_Settings by omnirom.
the class HighlightablePreferenceGroupAdapterTest method adjustInitialExpandedChildCount_noKeyOrChildCountOverride_shouldDoNothing.
@Test
public void adjustInitialExpandedChildCount_noKeyOrChildCountOverride_shouldDoNothing() {
final Bundle args = new Bundle();
when(mFragment.getArguments()).thenReturn(args);
when(mFragment.getInitialExpandedChildCount()).thenReturn(-1);
final PreferenceScreen screen = mock(PreferenceScreen.class);
when(mFragment.getPreferenceScreen()).thenReturn(screen);
HighlightablePreferenceGroupAdapter.adjustInitialExpandedChildCount(mFragment);
verify(mFragment).getInitialExpandedChildCount();
verifyZeroInteractions(screen);
}
Aggregations