Search in sources :

Example 16 with ListPreference

use of androidx.preference.ListPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class GameDriverAppPreferenceControllerTest method createPreference_configDefault_shouldSetDefaultAttributes.

@Test
public void createPreference_configDefault_shouldSetDefaultAttributes() {
    loadDefaultConfig();
    final ListPreference preference = mController.createListPreference(mContext, TEST_PKG_NAME, TEST_APP_NAME);
    assertThat(preference.getKey()).isEqualTo(TEST_PKG_NAME);
    assertThat(preference.getTitle()).isEqualTo(TEST_APP_NAME);
    assertThat(preference.getDialogTitle()).isEqualTo(mDialogTitle);
    assertThat(preference.getEntries()).isEqualTo(mValueList);
    assertThat(preference.getEntryValues()).isEqualTo(mValueList);
    assertThat(preference.getEntry()).isEqualTo(mValueList[DEFAULT]);
    assertThat(preference.getValue()).isEqualTo(mValueList[DEFAULT]);
    assertThat(preference.getSummary()).isEqualTo(mValueList[DEFAULT]);
}
Also used : ListPreference(androidx.preference.ListPreference) Test(org.junit.Test)

Example 17 with ListPreference

use of androidx.preference.ListPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class CdmaSubscriptionPreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = spy(RuntimeEnvironment.application);
    doReturn(mTelephonyManager).when(mContext).getSystemService(Context.TELEPHONY_SERVICE);
    doReturn(mSubscriptionManager).when(mContext).getSystemService(SubscriptionManager.class);
    doReturn(mTelephonyManager).when(mTelephonyManager).createForSubscriptionId(SUB_ID);
    doReturn(mInvalidTelephonyManager).when(mTelephonyManager).createForSubscriptionId(SubscriptionManager.INVALID_SUBSCRIPTION_ID);
    doReturn(mCarrierConfigManager).when(mContext).getSystemService(CarrierConfigManager.class);
    mCarrierConfig = new PersistableBundle();
    when(mCarrierConfigManager.getConfigForSubId(SUB_ID)).thenReturn(mCarrierConfig);
    mPreference = new ListPreference(mContext);
    mController = new CdmaSubscriptionPreferenceController(mContext, "mobile_data");
    mController.init(mPreferenceManager, SUB_ID);
    mController.mPreference = mPreference;
    mPreference.setKey(mController.getPreferenceKey());
}
Also used : PersistableBundle(android.os.PersistableBundle) ListPreference(androidx.preference.ListPreference) Before(org.junit.Before)

Example 18 with ListPreference

use of androidx.preference.ListPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class EnabledNetworkModePreferenceControllerTest method setUp.

@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    mLifecycleOwner = () -> mLifecycle;
    mLifecycle = new Lifecycle(mLifecycleOwner);
    mContext = spy(RuntimeEnvironment.application);
    doReturn(mTelephonyManager).when(mContext).getSystemService(Context.TELEPHONY_SERVICE);
    doReturn(mTelephonyManager).when(mContext).getSystemService(TelephonyManager.class);
    doReturn(mCarrierConfigManager).when(mContext).getSystemService(CarrierConfigManager.class);
    doReturn(mTelephonyManager).when(mTelephonyManager).createForSubscriptionId(SUB_ID);
    doReturn(mInvalidTelephonyManager).when(mTelephonyManager).createForSubscriptionId(SubscriptionManager.INVALID_SUBSCRIPTION_ID);
    doReturn(mContext).when(mContext).createPackageContext(anyString(), anyInt());
    doReturn(mServiceState).when(mTelephonyManager).getServiceState();
    mPersistableBundle = new PersistableBundle();
    doReturn(mPersistableBundle).when(mCarrierConfigManager).getConfigForSubId(SUB_ID);
    mPreference = new ListPreference(mContext);
    mPreference.setEntries(R.array.enabled_networks_choices);
    mPreference.setEntryValues(R.array.enabled_networks_values);
    mController = new EnabledNetworkModePreferenceController(mContext, KEY);
    mController.init(mLifecycle, SUB_ID);
    mPreference.setKey(mController.getPreferenceKey());
}
Also used : PersistableBundle(android.os.PersistableBundle) Lifecycle(com.android.settingslib.core.lifecycle.Lifecycle) ListPreference(androidx.preference.ListPreference) Before(org.junit.Before)

Example 19 with ListPreference

use of androidx.preference.ListPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ZenModePriorityCallsPreferenceControllerTest method updateState_TotalSilence.

@Test
public void updateState_TotalSilence() {
    Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_NO_INTERRUPTIONS);
    when(mBackend.isPriorityCategoryEnabled(NotificationManager.Policy.PRIORITY_CATEGORY_CALLS)).thenReturn(false);
    final ListPreference mockPref = mock(ListPreference.class);
    mController.updateState(mockPref);
    verify(mockPref).setEnabled(false);
    verify(mockPref).setSummary(R.string.zen_mode_from_none_calls);
}
Also used : ListPreference(androidx.preference.ListPreference) Test(org.junit.Test)

Example 20 with ListPreference

use of androidx.preference.ListPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ZenModePriorityCallsPreferenceControllerTest method updateState_AlarmsOnly.

@Test
public void updateState_AlarmsOnly() {
    Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_ALARMS);
    final ListPreference mockPref = mock(ListPreference.class);
    mController.updateState(mockPref);
    verify(mockPref).setEnabled(false);
    verify(mockPref).setSummary(R.string.zen_mode_from_none_calls);
}
Also used : ListPreference(androidx.preference.ListPreference) Test(org.junit.Test)

Aggregations

ListPreference (androidx.preference.ListPreference)170 Test (org.junit.Test)24 Before (org.junit.Before)23 Preference (androidx.preference.Preference)20 EditTextPreference (androidx.preference.EditTextPreference)10 PreferenceScreen (androidx.preference.PreferenceScreen)10 SwitchPreference (androidx.preference.SwitchPreference)9 Context (android.content.Context)8 ContentResolver (android.content.ContentResolver)7 Intent (android.content.Intent)7 PersistableBundle (android.os.PersistableBundle)6 MultiSelectListPreference (androidx.preference.MultiSelectListPreference)6 Resources (android.content.res.Resources)5 Bundle (android.os.Bundle)5 RemoteException (android.os.RemoteException)5 RestrictionEntry (android.content.RestrictionEntry)4 OverlayInfo (android.content.om.OverlayInfo)4 ApplicationInfo (android.content.pm.ApplicationInfo)4 PackageInfo (android.content.pm.PackageInfo)4 WifiConfiguration (android.net.wifi.WifiConfiguration)4