Search in sources :

Example 21 with PreferenceCategory

use of androidx.preference.PreferenceCategory in project android_packages_apps_Settings by omnirom.

the class RecentConversationsPreferenceControllerTest method testPopulateList_validConversations.

@Test
public void testPopulateList_validConversations() {
    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, false);
    ArrayList<ConversationChannel> list = new ArrayList<>();
    list.add(ccw);
    mController.populateList(list, outerContainer);
    // one for the preference, one for the button ro clear all
    verify(outerContainer, times(2)).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 22 with PreferenceCategory

use of androidx.preference.PreferenceCategory in project android_packages_apps_Settings by omnirom.

the class RecentConversationsPreferenceControllerTest method testPopulateList_hideIfNoConversations.

@Test
public void testPopulateList_hideIfNoConversations() {
    PreferenceCategory outerContainer = mock(PreferenceCategory.class);
    mController.populateList(new ArrayList<>(), outerContainer);
    verify(outerContainer).setVisible(false);
    verify(outerContainer, never()).addPreference(any());
}
Also used : PreferenceCategory(androidx.preference.PreferenceCategory) Test(org.junit.Test)

Example 23 with PreferenceCategory

use of androidx.preference.PreferenceCategory in project android_packages_apps_Settings by omnirom.

the class SubscriptionsPreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = spy(ApplicationProvider.getApplicationContext());
    if (Looper.myLooper() == null) {
        Looper.prepare();
    }
    mLifecycleRegistry = new LifecycleRegistry(mLifecycleOwner);
    when(mContext.getSystemService(SubscriptionManager.class)).thenReturn(mSubscriptionManager);
    when(mContext.getSystemService(ConnectivityManager.class)).thenReturn(mConnectivityManager);
    when(mContext.getSystemService(TelephonyManager.class)).thenReturn(mTelephonyManager);
    when(mContext.getSystemService(UserManager.class)).thenReturn(mUserManager);
    when(mTelephonyManager.createForSubscriptionId(anyInt())).thenReturn(mTelephonyManager);
    when(mConnectivityManager.getActiveNetwork()).thenReturn(mActiveNetwork);
    when(mConnectivityManager.getNetworkCapabilities(mActiveNetwork)).thenReturn(mNetworkCapabilities);
    when(mUserManager.isAdminUser()).thenReturn(true);
    when(mLifecycleOwner.getLifecycle()).thenReturn(mLifecycleRegistry);
    mPreferenceManager = new PreferenceManager(mContext);
    mPreferenceScreen = mPreferenceManager.createPreferenceScreen(mContext);
    mPreferenceScreen.setInitialExpandedChildrenCount(3);
    mPreferenceCategory = new PreferenceCategory(mContext);
    mPreferenceCategory.setKey(KEY);
    mPreferenceCategory.setOrderingAsAdded(true);
    mPreferenceScreen.addPreference(mPreferenceCategory);
    mOnChildUpdatedCount = 0;
    mUpdateListener = () -> mOnChildUpdatedCount++;
    sInjector = spy(new SubsPrefCtrlInjector());
    initializeMethod(true, 1, 1, 1, false, false);
    mController = new FakeSubscriptionsPreferenceController(mContext, mLifecycle, mUpdateListener, KEY, 5);
    Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, 0);
}
Also used : LifecycleRegistry(androidx.lifecycle.LifecycleRegistry) PreferenceCategory(androidx.preference.PreferenceCategory) SubsPrefCtrlInjector(com.android.settings.network.SubscriptionsPreferenceController.SubsPrefCtrlInjector) PreferenceManager(androidx.preference.PreferenceManager) Before(org.junit.Before)

Example 24 with PreferenceCategory

use of androidx.preference.PreferenceCategory in project android_packages_apps_Settings by omnirom.

the class InternetResetHelperTest method setUp.

@Before
public void setUp() {
    mContext = spy(ApplicationProvider.getApplicationContext());
    when(mContext.getSystemService(WifiManager.class)).thenReturn(mWifiManager);
    if (Looper.myLooper() == null) {
        Looper.prepare();
    }
    mResettingPreference = new Preference(mContext);
    mWifiTogglePreferences = new Preference(mContext);
    mConnectedWifiEntryPreferences = spy(new PreferenceCategory(mContext));
    mWifiEntryPreferences = spy(new PreferenceCategory(mContext));
    final Lifecycle lifecycle = mock(Lifecycle.class);
    mInternetResetHelper = new InternetResetHelper(mContext, lifecycle);
    mInternetResetHelper.mWorkerThread = mWorkerThread;
    mFakeHandlerInjector = new FakeHandlerInjector(mContext);
    mInternetResetHelper.mHandlerInjector = mFakeHandlerInjector;
    mInternetResetHelper.mConnectivitySubsystemsRecoveryManager = mConnectivitySubsystemsRecoveryManager;
    mInternetResetHelper.setResettingPreference(mResettingPreference);
    mInternetResetHelper.setMobileNetworkController(mMobileNetworkController);
    mInternetResetHelper.setWifiTogglePreference(mWifiTogglePreferences);
    mInternetResetHelper.addWifiNetworkPreference(mConnectedWifiEntryPreferences);
    mInternetResetHelper.addWifiNetworkPreference(mWifiEntryPreferences);
}
Also used : Preference(androidx.preference.Preference) PreferenceCategory(androidx.preference.PreferenceCategory) Lifecycle(androidx.lifecycle.Lifecycle) Before(org.junit.Before)

Example 25 with PreferenceCategory

use of androidx.preference.PreferenceCategory in project android_packages_apps_Settings by omnirom.

the class NetworkProviderSimsCategoryControllerTest method setUp.

@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    mContext = spy(ApplicationProvider.getApplicationContext());
    if (Looper.myLooper() == null) {
        Looper.prepare();
    }
    mPreferenceManager = new PreferenceManager(mContext);
    mPreferenceScreen = mPreferenceManager.createPreferenceScreen(mContext);
    mPreferenceCategory = new PreferenceCategory(mContext);
    mPreferenceCategory.setKey(KEY_PREFERENCE_CATEGORY_SIM);
    mPreferenceScreen.addPreference(mPreferenceCategory);
    mCategoryController = new NetworkProviderSimsCategoryController(mContext, KEY_PREFERENCE_CATEGORY_SIM, mLifecycle);
}
Also used : PreferenceCategory(androidx.preference.PreferenceCategory) PreferenceManager(androidx.preference.PreferenceManager) Before(org.junit.Before)

Aggregations

PreferenceCategory (androidx.preference.PreferenceCategory)111 Preference (androidx.preference.Preference)38 PreferenceManager (androidx.preference.PreferenceManager)24 Before (org.junit.Before)24 PreferenceScreen (androidx.preference.PreferenceScreen)22 Test (org.junit.Test)19 SwitchPreference (androidx.preference.SwitchPreference)13 NotificationChannel (android.app.NotificationChannel)11 ArrayList (java.util.ArrayList)11 NotificationChannelGroup (android.app.NotificationChannelGroup)9 ShortcutInfo (android.content.pm.ShortcutInfo)9 Context (android.content.Context)8 ConversationChannel (android.app.people.ConversationChannel)7 View (android.view.View)7 PreferenceViewHolder (androidx.preference.PreferenceViewHolder)7 Lifecycle (com.android.settingslib.core.lifecycle.Lifecycle)7 ListPreference (androidx.preference.ListPreference)6 ComponentName (android.content.ComponentName)5 ContentResolver (android.content.ContentResolver)5 Bundle (android.os.Bundle)5