Search in sources :

Example 81 with SwitchPreference

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

the class ZenModeRemindersPreferenceControllerTest method updateState_TotalSilence.

@Test
public void updateState_TotalSilence() {
    Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_NO_INTERRUPTIONS);
    final SwitchPreference mockPref = mock(SwitchPreference.class);
    mController.updateState(mockPref);
    verify(mockPref).setEnabled(false);
    verify(mockPref).setChecked(false);
}
Also used : SwitchPreference(androidx.preference.SwitchPreference) Test(org.junit.Test)

Example 82 with SwitchPreference

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

the class ContactDiscoveryPreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mLifecycleOwner = () -> mLifecycle;
    mLifecycle = new Lifecycle(mLifecycleOwner);
    mContext = spy(RuntimeEnvironment.application);
    doReturn(mImsManager).when(mContext).getSystemService(ImsManager.class);
    doReturn(mImsRcsManager).when(mImsManager).getImsRcsManager(anyInt());
    doReturn(mRcsUceAdapter).when(mImsRcsManager).getUceAdapter();
    doReturn(mCarrierConfigManager).when(mContext).getSystemService(CarrierConfigManager.class);
    doReturn(mCarrierConfig).when(mCarrierConfigManager).getConfigForSubId(eq(TEST_SUB_ID));
    // Start all tests with presence being disabled.
    setRcsPresenceConfig(false);
    doReturn(mContentResolver).when(mContext).getContentResolver();
    doReturn(mFragmentTransaction).when(mFragmentManager).beginTransaction();
    mPreferenceControllerUT = new ContactDiscoveryPreferenceController(mContext, "ContactDiscovery");
    // Ensure subscriptionInfo check doesn't fail.
    SubscriptionUtil.setAvailableSubscriptionsForTesting(Collections.emptyList());
    mPreferenceControllerUT.init(mFragmentManager, TEST_SUB_ID, mLifecycle);
    mSwitchPreferenceUT = spy(new SwitchPreference(mContext));
    mSwitchPreferenceUT.setKey(mPreferenceControllerUT.getPreferenceKey());
    mPreferenceControllerUT.preference = mSwitchPreferenceUT;
}
Also used : SwitchPreference(androidx.preference.SwitchPreference) Lifecycle(com.android.settingslib.core.lifecycle.Lifecycle) Before(org.junit.Before)

Example 83 with SwitchPreference

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

the class DialPadTonePreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    when(mContext.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(mTelephonyManager);
    when(mTelephonyManager.isVoiceCapable()).thenReturn(true);
    when(mSetting.getActivity()).thenReturn(mActivity);
    when(mActivity.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(mTelephonyManager);
    when(mActivity.getContentResolver()).thenReturn(mContentResolver);
    mPreference = new SwitchPreference(RuntimeEnvironment.application);
    mController = new DialPadTonePreferenceController(mContext, mSetting, null);
    when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
    doReturn(mScreen).when(mSetting).getPreferenceScreen();
}
Also used : SwitchPreference(androidx.preference.SwitchPreference) Before(org.junit.Before)

Example 84 with SwitchPreference

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

the class DockingSoundPreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    when(mSetting.getActivity()).thenReturn(mActivity);
    when(mActivity.getContentResolver()).thenReturn(mContentResolver);
    mPreference = new SwitchPreference(RuntimeEnvironment.application);
    when(mActivity.getResources().getBoolean(com.android.settings.R.bool.has_dock_settings)).thenReturn(true);
    mController = new DockingSoundPreferenceController(mContext, mSetting, null);
    when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
    doReturn(mScreen).when(mSetting).getPreferenceScreen();
}
Also used : SwitchPreference(androidx.preference.SwitchPreference) Before(org.junit.Before)

Example 85 with SwitchPreference

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

the class DataUsagePreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = spy(RuntimeEnvironment.application);
    final TelephonyManager telephonyManager = mContext.getSystemService(TelephonyManager.class);
    final ShadowTelephonyManager shadowTelephonyManager = Shadows.shadowOf(telephonyManager);
    shadowTelephonyManager.setTelephonyManagerForSubscriptionId(SUB_ID, telephonyManager);
    shadowTelephonyManager.setTelephonyManagerForSubscriptionId(SubscriptionManager.INVALID_SUBSCRIPTION_ID, telephonyManager);
    doReturn(mNetworkStatsManager).when(mContext).getSystemService(NetworkStatsManager.class);
    mPreference = new SwitchPreference(mContext);
    mController = spy(new DataUsagePreferenceController(mContext, "data_usage"));
    mController.init(SUB_ID);
    mPreference.setKey(mController.getPreferenceKey());
}
Also used : ShadowTelephonyManager(org.robolectric.shadows.ShadowTelephonyManager) TelephonyManager(android.telephony.TelephonyManager) ShadowTelephonyManager(org.robolectric.shadows.ShadowTelephonyManager) SwitchPreference(androidx.preference.SwitchPreference) Before(org.junit.Before)

Aggregations

SwitchPreference (androidx.preference.SwitchPreference)299 Test (org.junit.Test)125 Before (org.junit.Before)68 Intent (android.content.Intent)17 Preference (androidx.preference.Preference)17 ComponentName (android.content.ComponentName)10 A2dpProfile (com.android.settingslib.bluetooth.A2dpProfile)10 RestrictedSwitchPreference (com.android.settingslib.RestrictedSwitchPreference)8 PbapServerProfile (com.android.settingslib.bluetooth.PbapServerProfile)8 ListPreference (androidx.preference.ListPreference)7 PreferenceScreen (androidx.preference.PreferenceScreen)7 RemoteException (android.os.RemoteException)6 PreferenceCategory (androidx.preference.PreferenceCategory)6 HashSet (java.util.HashSet)6 Context (android.content.Context)5 Parcel (android.os.Parcel)5 VisibleForTesting (androidx.annotation.VisibleForTesting)5 BluetoothDevice (android.bluetooth.BluetoothDevice)4 ChangeConfig (android.compat.Compatibility.ChangeConfig)4 ServiceInfo (android.content.pm.ServiceInfo)4