Search in sources :

Example 6 with PreferenceScreen

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

the class OverlayCategoryPreferenceControllerTest method onDeveloperOptionsSwitchDisabled.

@Test
public void onDeveloperOptionsSwitchDisabled() throws Exception {
    mockCurrentOverlays(ONE_ENABLED, TWO_DISABLED);
    final PreferenceScreen screen = mock(PreferenceScreen.class);
    when(screen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
    mController.displayPreference(screen);
    mController.onDeveloperOptionsSwitchDisabled();
    verify(mPreference).setEnabled(false);
    verify(mOverlayManager).setEnabled(eq(ONE_ENABLED.packageName), eq(false), anyInt());
}
Also used : PreferenceScreen(androidx.preference.PreferenceScreen) Test(org.junit.Test)

Example 7 with PreferenceScreen

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

the class ConversationListPreferenceControllerTest 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);
    ConversationChannelWrapper ccw = new ConversationChannelWrapper();
    ccw.setNotificationChannel(mock(NotificationChannel.class));
    ccw.setPkg("pkg");
    ccw.setUid(1);
    ccw.setShortcutInfo(mock(ShortcutInfo.class));
    ArrayList<ConversationChannelWrapper> list = new ArrayList<>();
    list.add(ccw);
    mController.populateList(list, outerContainer);
    verify(outerContainer, times(1)).addPreference(any());
}
Also used : NotificationChannel(android.app.NotificationChannel) PreferenceScreen(androidx.preference.PreferenceScreen) ShortcutInfo(android.content.pm.ShortcutInfo) PreferenceCategory(androidx.preference.PreferenceCategory) ConversationChannelWrapper(android.service.notification.ConversationChannelWrapper) ArrayList(java.util.ArrayList) PreferenceManager(androidx.preference.PreferenceManager) Test(org.junit.Test)

Example 8 with PreferenceScreen

use of androidx.preference.PreferenceScreen 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 9 with PreferenceScreen

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

the class EnabledNetworkModePreferenceControllerTest method preferredNetworkModeNotification_preferenceUpdates.

@UiThreadTest
@Test
public void preferredNetworkModeNotification_preferenceUpdates() {
    final PreferenceManager preferenceManager = new PreferenceManager(mContext);
    PreferenceScreen screen = preferenceManager.createPreferenceScreen(mContext);
    mPreference.setKey(KEY);
    screen.addPreference(mPreference);
    mockEnabledNetworkMode(TelephonyManagerConstants.NETWORK_MODE_TDSCDMA_GSM_WCDMA);
    // NETWORK_MODE_TDSCDMA_GSM_WCDMA = RAF_TD_SCDMA | GSM | WCDMA
    when(mTelephonyManager.getAllowedNetworkTypesForReason(TelephonyManager.ALLOWED_NETWORK_TYPES_REASON_USER)).thenReturn((long) (RAF_TD_SCDMA | GSM | WCDMA));
    mController.displayPreference(screen);
    mController.updateState(mPreference);
    mLifecycle.handleLifecycleEvent(ON_START);
    assertThat(Integer.parseInt(mPreference.getValue())).isEqualTo(TelephonyManagerConstants.NETWORK_MODE_TDSCDMA_GSM_WCDMA);
    assertThat(mPreference.getSummary()).isEqualTo("3G");
}
Also used : PreferenceScreen(androidx.preference.PreferenceScreen) PreferenceManager(androidx.preference.PreferenceManager) Test(org.junit.Test) UiThreadTest(androidx.test.annotation.UiThreadTest) UiThreadTest(androidx.test.annotation.UiThreadTest)

Example 10 with PreferenceScreen

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

the class PaymentSettingsTest method isShowEmptyImage_hasVisiblePreference_returnFalse.

@Test
public void isShowEmptyImage_hasVisiblePreference_returnFalse() {
    final PaymentSettings paymentSettings = new PaymentSettings();
    final PreferenceManager preferenceManager = new PreferenceManager(mContext);
    final PreferenceScreen screen = preferenceManager.createPreferenceScreen(mContext);
    final Preference preference1 = new Preference(mContext);
    screen.addPreference(preference1);
    final Preference preference2 = new Preference(mContext);
    screen.addPreference(preference2);
    assertThat(paymentSettings.isShowEmptyImage(screen)).isFalse();
}
Also used : PreferenceScreen(androidx.preference.PreferenceScreen) Preference(androidx.preference.Preference) PreferenceManager(androidx.preference.PreferenceManager) Test(org.junit.Test)

Aggregations

PreferenceScreen (androidx.preference.PreferenceScreen)244 Preference (androidx.preference.Preference)81 Test (org.junit.Test)60 Context (android.content.Context)36 PreferenceManager (androidx.preference.PreferenceManager)36 ContentResolver (android.content.ContentResolver)25 PreferenceCategory (androidx.preference.PreferenceCategory)24 Bundle (android.os.Bundle)20 ArrayList (java.util.ArrayList)20 SwitchPreference (androidx.preference.SwitchPreference)19 Resources (android.content.res.Resources)18 Before (org.junit.Before)17 ListPreference (androidx.preference.ListPreference)14 PackageManager (android.content.pm.PackageManager)13 PreferenceGroup (androidx.preference.PreferenceGroup)13 ApplicationInfo (android.content.pm.ApplicationInfo)9 VisibleForTesting (androidx.annotation.VisibleForTesting)9 List (java.util.List)9 UserManager (android.os.UserManager)8 StorageItemPreference (com.android.settings.deviceinfo.StorageItemPreference)8