use of androidx.preference.PreferenceManager 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.PreferenceManager 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.PreferenceManager in project android_packages_apps_Settings by omnirom.
the class PlatformCompatDashboardTest method setUp.
@Before
public void setUp() throws RemoteException, NameNotFoundException {
MockitoAnnotations.initMocks(this);
mChanges = new CompatibilityChangeInfo[5];
mChanges[0] = new CompatibilityChangeInfo(1L, "Default_Enabled", 0, 0, false, false, "", false);
mChanges[1] = new CompatibilityChangeInfo(2L, "Default_Disabled", 0, 0, true, false, "", false);
mChanges[2] = new CompatibilityChangeInfo(3L, "Enabled_Since_SDK_1_1", -1, 1, false, false, "", false);
mChanges[3] = new CompatibilityChangeInfo(4L, "Enabled_Since_SDK_1_2", -1, 1, false, false, "", false);
mChanges[4] = new CompatibilityChangeInfo(5L, "Enabled_Since_SDK_2", -1, 2, false, false, "", false);
when(mPlatformCompat.listUIChanges()).thenReturn(mChanges);
when(mPlatformCompat.getOverrideValidator()).thenReturn(mOverrideValidator);
// By default, allow any change
when(mOverrideValidator.getOverrideAllowedState(anyLong(), anyString())).thenReturn(new OverrideAllowedState(ALLOWED, -1, -1));
mContext = spy(RuntimeEnvironment.application);
mPreferenceManager = new PreferenceManager(mContext);
mPreferenceScreen = mPreferenceManager.createPreferenceScreen(mContext);
mApplicationInfo.packageName = APP_NAME;
mDashboard = spy(new PlatformCompatDashboard());
mDashboard.mSelectedApp = APP_NAME;
doReturn(mApplicationInfo).when(mDashboard).getApplicationInfo();
doReturn(mContext).when(mDashboard).getContext();
doReturn(mPlatformCompat).when(mDashboard).getPlatformCompat();
doReturn(mPreferenceScreen).when(mDashboard).getPreferenceScreen();
doReturn(mPreferenceManager).when(mDashboard).getPreferenceManager();
doReturn(mPackageManager).when(mContext).getPackageManager();
}
use of androidx.preference.PreferenceManager 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);
}
use of androidx.preference.PreferenceManager in project android_packages_apps_Settings by omnirom.
the class RecentConversationsPreferenceControllerTest method testRemoveConversations.
@Test
public void testRemoveConversations() throws Exception {
ShortcutInfo si = mock(ShortcutInfo.class);
when(si.getId()).thenReturn("person");
when(si.getPackage()).thenReturn("pkg");
ConversationChannel ccw = new ConversationChannel(si, 6, new NotificationChannel("hi", "hi", 4), new NotificationChannelGroup("hi", "group"), 7, false);
ConversationChannel ccw2 = new ConversationChannel(si, 6, new NotificationChannel("bye", "bye", 4), new NotificationChannelGroup("hi", "group"), 7, true);
PreferenceCategory group = new PreferenceCategory(mContext);
PreferenceScreen screen = new PreferenceManager(mContext).createPreferenceScreen(mContext);
screen.addPreference(group);
RecentConversationPreference pref = mController.createConversationPref(new PreferenceCategory(mContext), ccw, 100);
final View view = View.inflate(mContext, pref.getLayoutResource(), null);
PreferenceViewHolder holder = spy(PreferenceViewHolder.createInstanceForTests(view));
View delete = View.inflate(mContext, pref.getSecondTargetResId(), null);
when(holder.findViewById(pref.getClearId())).thenReturn(delete);
group.addPreference(pref);
RecentConversationPreference pref2 = mController.createConversationPref(new PreferenceCategory(mContext), ccw2, 100);
final View view2 = View.inflate(mContext, pref2.getLayoutResource(), null);
PreferenceViewHolder holder2 = spy(PreferenceViewHolder.createInstanceForTests(view2));
View delete2 = View.inflate(mContext, pref2.getSecondTargetResId(), null);
when(holder2.findViewById(pref.getClearId())).thenReturn(delete2);
group.addPreference(pref2);
LayoutPreference clearAll = mController.getClearAll(group);
group.addPreference(clearAll);
clearAll.findViewById(R.id.conversation_settings_clear_recents).performClick();
verify(mPs).removeAllRecentConversations();
assertThat((Preference) group.findPreference("hi:person")).isNull();
assertThat((Preference) group.findPreference("bye:person")).isNotNull();
}
Aggregations