use of androidx.preference.PreferenceManager in project android_packages_apps_Settings by omnirom.
the class RecentConversationsPreferenceControllerTest method testPopulateList_onlyNonremoveableConversations.
@Test
public void testPopulateList_onlyNonremoveableConversations() {
final PreferenceManager preferenceManager = new PreferenceManager(mContext);
PreferenceScreen ps = preferenceManager.createPreferenceScreen(mContext);
PreferenceCategory outerContainer = spy(new PreferenceCategory(mContext));
ps.addPreference(outerContainer);
ConversationChannel ccw = new ConversationChannel(mock(ShortcutInfo.class), 6, new NotificationChannel("hi", "hi", 4), new NotificationChannelGroup("hi", "hi"), 7, true);
ArrayList<ConversationChannel> list = new ArrayList<>();
list.add(ccw);
mController.populateList(list, outerContainer);
// one for the preference, none for 'clear all'
verify(outerContainer, times(1)).addPreference(any());
}
use of androidx.preference.PreferenceManager in project android_packages_apps_Settings by omnirom.
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);
}
use of androidx.preference.PreferenceManager in project android_packages_apps_Settings by omnirom.
the class BridgedAppsPreferenceControllerTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = ApplicationProvider.getApplicationContext();
if (Looper.myLooper() == null) {
Looper.prepare();
}
PreferenceManager preferenceManager = new PreferenceManager(mContext);
mScreen = preferenceManager.createPreferenceScreen(mContext);
ApplicationInfo ai = new ApplicationInfo();
ai.packageName = "pkg";
ai.uid = 12300;
ai.sourceDir = "";
ApplicationInfo ai2 = new ApplicationInfo();
ai2.packageName = "another";
ai2.uid = 18800;
ai2.sourceDir = "";
mAppEntry = new ApplicationsState.AppEntry(mContext, ai, 0);
mAppEntry2 = new ApplicationsState.AppEntry(mContext, ai2, 1);
mAppEntry.info = ai;
mAppEntry.label = "hi";
Drawable icon = mock(Drawable.class);
mAppEntry.icon = icon;
mController = new BridgedAppsPreferenceController(mContext, "key");
mController.setCn(mCn);
mController.setNm(mNm);
mController.setUserId(0);
mController.setAppState(mAppState);
mController.displayPreference(mScreen);
}
use of androidx.preference.PreferenceManager in project android_packages_apps_Settings by omnirom.
the class PasswordsPreferenceControllerTest method setUp.
@Before
public void setUp() {
mContext = spy(ApplicationProvider.getApplicationContext());
if (Looper.myLooper() == null) {
// needed to create the preference screen
Looper.prepare();
}
mScreen = new PreferenceManager(mContext).createPreferenceScreen(mContext);
mPasswordsPreferenceCategory = new PreferenceCategory(mContext);
mPasswordsPreferenceCategory.setKey("passwords");
mScreen.addPreference(mPasswordsPreferenceCategory);
}
use of androidx.preference.PreferenceManager in project android_packages_apps_Settings by omnirom.
the class NetworkProviderWifiCallingGroupTest method setUp.
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
mContext = spy(ApplicationProvider.getApplicationContext());
when(mContext.getSystemService(CarrierConfigManager.class)).thenReturn(mCarrierConfigManager);
when(mContext.getSystemService(SubscriptionManager.class)).thenReturn(mSubscriptionManager);
when(mContext.getSystemService(TelecomManager.class)).thenReturn(mTelecomManager);
when(mContext.getSystemService(TelephonyManager.class)).thenReturn(mTelephonyManager);
when(mTelephonyManager.createForSubscriptionId(SUB_ID)).thenReturn(mTelephonyManager);
when(mContext.getPackageManager()).thenReturn(mPackageManager);
when(mSubscriptionInfo.getSubscriptionId()).thenReturn(SUB_ID);
when(mSubscriptionManager.getActiveSubscriptionInfoList()).thenReturn(Arrays.asList(mSubscriptionInfo));
mCarrierConfig = new PersistableBundle();
doReturn(mCarrierConfig).when(mCarrierConfigManager).getConfigForSubId(SUB_ID);
mCarrierConfig.putBoolean(CarrierConfigManager.KEY_CARRIER_WFC_IMS_AVAILABLE_BOOL, true);
when(mTelecomManager.getSimCallManagerForSubscription(SUB_ID)).thenReturn(mPhoneAccountHandle);
mMockQueryWfcState = new MockWfcQueryImsState(mContext, SUB_ID);
if (Looper.myLooper() == null) {
Looper.prepare();
}
mPreferenceManager = new PreferenceManager(mContext);
mPreferenceScreen = mPreferenceManager.createPreferenceScreen(mContext);
when(mPreferenceCategory.getKey()).thenReturn(KEY_PREFERENCE_WFC_CATEGORY);
when(mPreferenceCategory.getPreferenceCount()).thenReturn(1);
mPreferenceScreen.addPreference(mPreferenceCategory);
mNetworkProviderWifiCallingGroup = spy(new NetworkProviderWifiCallingGroup(mContext, mLifecycle, KEY_PREFERENCE_WFC_CATEGORY));
}
Aggregations