Search in sources :

Example 66 with PreferenceManager

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());
}
Also used : NotificationChannel(android.app.NotificationChannel) NotificationChannelGroup(android.app.NotificationChannelGroup) PreferenceScreen(androidx.preference.PreferenceScreen) ConversationChannel(android.app.people.ConversationChannel) ShortcutInfo(android.content.pm.ShortcutInfo) PreferenceCategory(androidx.preference.PreferenceCategory) ArrayList(java.util.ArrayList) PreferenceManager(androidx.preference.PreferenceManager) Test(org.junit.Test)

Example 67 with PreferenceManager

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);
}
Also used : PreferenceScreen(androidx.preference.PreferenceScreen) ArrayList(java.util.ArrayList) PreferenceManager(androidx.preference.PreferenceManager) InputMethodInfo(android.view.inputmethod.InputMethodInfo) Test(org.junit.Test)

Example 68 with PreferenceManager

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);
}
Also used : ApplicationsState(com.android.settingslib.applications.ApplicationsState) ApplicationInfo(android.content.pm.ApplicationInfo) Drawable(android.graphics.drawable.Drawable) PreferenceManager(androidx.preference.PreferenceManager) Before(org.junit.Before)

Example 69 with PreferenceManager

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);
}
Also used : PreferenceCategory(androidx.preference.PreferenceCategory) PreferenceManager(androidx.preference.PreferenceManager) Before(org.junit.Before)

Example 70 with PreferenceManager

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));
}
Also used : PersistableBundle(android.os.PersistableBundle) MockWfcQueryImsState(com.android.settings.network.ims.MockWfcQueryImsState) PreferenceManager(androidx.preference.PreferenceManager) Before(org.junit.Before)

Aggregations

PreferenceManager (androidx.preference.PreferenceManager)87 Before (org.junit.Before)67 Preference (androidx.preference.Preference)23 PreferenceCategory (androidx.preference.PreferenceCategory)22 PreferenceScreen (androidx.preference.PreferenceScreen)19 Test (org.junit.Test)18 Lifecycle (com.android.settingslib.core.lifecycle.Lifecycle)15 Context (android.content.Context)5 LifecycleRegistry (androidx.lifecycle.LifecycleRegistry)5 ArrayList (java.util.ArrayList)5 NotificationChannel (android.app.NotificationChannel)4 ShortcutInfo (android.content.pm.ShortcutInfo)4 View (android.view.View)4 NotificationChannelGroup (android.app.NotificationChannelGroup)3 ConversationChannel (android.app.people.ConversationChannel)3 PackageInfo (android.content.pm.PackageInfo)3 PersistableBundle (android.os.PersistableBundle)3 BluetoothManager (android.bluetooth.BluetoothManager)2 SoftApConfiguration (android.net.wifi.SoftApConfiguration)2 WifiManager (android.net.wifi.WifiManager)2