Search in sources :

Example 31 with SwitchPreference

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

the class MmsMessagePreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = spy(RuntimeEnvironment.application);
    when(mContext.getSystemService(TelephonyManager.class)).thenReturn(mTelephonyManager);
    when(mContext.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(mTelephonyManager);
    when(mContext.getSystemService(SubscriptionManager.class)).thenReturn(mSubscriptionManager);
    when(mTelephonyManager.createForSubscriptionId(SUB_ID)).thenReturn(mTelephonyManager);
    mPreference = new SwitchPreference(mContext);
    mController = new MmsMessagePreferenceController(mContext, "mms_message");
    ShadowSubscriptionManager.setDefaultDataSubscriptionId(SUB_ID);
    mController.init(SUB_ID);
    mPreference.setKey(mController.getPreferenceKey());
}
Also used : SwitchPreference(androidx.preference.SwitchPreference) Before(org.junit.Before)

Example 32 with SwitchPreference

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

the class DataUsagePreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = spy(Robolectric.setupActivity(Activity.class));
    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 = 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)

Example 33 with SwitchPreference

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

the class VideoCallingPreferenceControllerTest method setUp.

@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    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);
    mCarrierConfig = new PersistableBundle();
    mCarrierConfig.putBoolean(CarrierConfigManager.KEY_IGNORE_DATA_ENABLED_CHANGED_FOR_VIDEO_CALLS, true);
    doReturn(mCarrierConfig).when(mCarrierConfigManager).getConfigForSubId(SUB_ID);
    mPreference = new SwitchPreference(mContext);
    mController = new VideoCallingPreferenceController(mContext, "wifi_calling");
    mController.init(SUB_ID);
    mController.mImsManager = mImsManager;
    mPreference.setKey(mController.getPreferenceKey());
    doReturn(true).when(mImsManager).isVtEnabledByPlatform();
    doReturn(true).when(mImsManager).isVtProvisionedOnDevice();
    doReturn(ImsFeature.STATE_READY).when(mImsManager).getImsServiceState();
    doReturn(true).when(mTelephonyManager).isDataEnabled();
}
Also used : PersistableBundle(android.os.PersistableBundle) SwitchPreference(androidx.preference.SwitchPreference) Before(org.junit.Before)

Example 34 with SwitchPreference

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

the class ZenModeSystemPreferenceControllerTest 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 35 with SwitchPreference

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

the class ZenModeAlarmsPreferenceControllerTest 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)

Aggregations

SwitchPreference (androidx.preference.SwitchPreference)139 Test (org.junit.Test)61 Before (org.junit.Before)29 Intent (android.content.Intent)9 Preference (androidx.preference.Preference)6 ComponentName (android.content.ComponentName)5 A2dpProfile (com.android.settingslib.bluetooth.A2dpProfile)5 ListPreference (androidx.preference.ListPreference)4 PreferenceScreen (androidx.preference.PreferenceScreen)4 PbapServerProfile (com.android.settingslib.bluetooth.PbapServerProfile)4 BluetoothDevice (android.bluetooth.BluetoothDevice)2 Context (android.content.Context)2 ServiceInfo (android.content.pm.ServiceInfo)2 KeyboardLayout (android.hardware.input.KeyboardLayout)2 Parcel (android.os.Parcel)2 PersistableBundle (android.os.PersistableBundle)2 RemoteException (android.os.RemoteException)2 TelephonyManager (android.telephony.TelephonyManager)2 VisibleForTesting (androidx.annotation.VisibleForTesting)2 MultiSelectListPreference (androidx.preference.MultiSelectListPreference)2