Search in sources :

Example 6 with SwitchPreference

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

the class AutoTimeFormatPreferenceControllerTest method updatePreference_autoSet_shouldSendIntent_24HourLocale.

@Test
public void updatePreference_autoSet_shouldSendIntent_24HourLocale() {
    mController = new TestAutoTimeFormatPreferenceController(mContext, mCallback);
    mPreference = new SwitchPreference(mContext);
    mPreference.setKey(mController.getPreferenceKey());
    mPreference.setChecked(false);
    mController.setIs24HourLocale(true);
    boolean result = mController.handlePreferenceTreeClick(mPreference);
    assertThat(result).isTrue();
    List<Intent> intentsFired = mApplication.getBroadcastIntents();
    assertThat(intentsFired.size()).isEqualTo(1);
    Intent intentFired = intentsFired.get(0);
    assertThat(intentFired.getAction()).isEqualTo(Intent.ACTION_TIME_CHANGED);
    assertThat(intentFired.getIntExtra(Intent.EXTRA_TIME_PREF_24_HOUR_FORMAT, -1)).isEqualTo(Intent.EXTRA_TIME_PREF_VALUE_USE_24_HOUR);
}
Also used : SwitchPreference(androidx.preference.SwitchPreference) Intent(android.content.Intent) Test(org.junit.Test)

Example 7 with SwitchPreference

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

the class SmartBatteryPreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mFeatureFactory = FakeFeatureFactory.setupForTest();
    mContentResolver = RuntimeEnvironment.application.getContentResolver();
    mController = new SmartBatteryPreferenceController(RuntimeEnvironment.application);
    mPreference = new SwitchPreference(RuntimeEnvironment.application);
}
Also used : SwitchPreference(androidx.preference.SwitchPreference) Before(org.junit.Before)

Example 8 with SwitchPreference

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

the class ApnEditorTest method setMockPreference.

private void setMockPreference(Context context) {
    mApnEditorUT.mName = new EditTextPreference(context);
    mApnEditorUT.mApn = new EditTextPreference(context);
    mApnEditorUT.mProxy = new EditTextPreference(context);
    mApnEditorUT.mPort = new EditTextPreference(context);
    mApnEditorUT.mUser = new EditTextPreference(context);
    mApnEditorUT.mServer = new EditTextPreference(context);
    mApnEditorUT.mPassword = new EditTextPreference(context);
    mApnEditorUT.mMmsc = new EditTextPreference(context);
    mApnEditorUT.mMcc = new EditTextPreference(context);
    mApnEditorUT.mMnc = new EditTextPreference(context);
    mApnEditorUT.mMmsProxy = new EditTextPreference(context);
    mApnEditorUT.mMmsPort = new EditTextPreference(context);
    mApnEditorUT.mAuthType = new ListPreference(context);
    mApnEditorUT.mApnType = new EditTextPreference(context);
    mApnEditorUT.mProtocol = new ListPreference(context);
    mApnEditorUT.mRoamingProtocol = new ListPreference(context);
    mApnEditorUT.mCarrierEnabled = new SwitchPreference(context);
    mApnEditorUT.mBearerMulti = new MultiSelectListPreference(context);
    mApnEditorUT.mMvnoType = new ListPreference(context);
    mApnEditorUT.mMvnoMatchData = new EditTextPreference(context);
}
Also used : SwitchPreference(androidx.preference.SwitchPreference) MultiSelectListPreference(androidx.preference.MultiSelectListPreference) EditTextPreference(androidx.preference.EditTextPreference) MultiSelectListPreference(androidx.preference.MultiSelectListPreference) ListPreference(androidx.preference.ListPreference)

Example 9 with SwitchPreference

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

the class DataDuringCallsPreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = spy(RuntimeEnvironment.application);
    doReturn(mTelephonyManager).when(mContext).getSystemService(eq(TelephonyManager.class));
    when(mTelephonyManager.createForSubscriptionId(anyInt())).thenReturn(mTelephonyManager);
    mSwitchPreference = new SwitchPreference(mContext);
    when(mPreferenceScreen.findPreference(PREF_KEY)).thenReturn(mSwitchPreference);
    mController = new DataDuringCallsPreferenceController(mContext, PREF_KEY);
    mController.init(mLifecycle, SUB_ID_1);
}
Also used : TelephonyManager(android.telephony.TelephonyManager) SwitchPreference(androidx.preference.SwitchPreference) DataDuringCallsPreferenceController(com.android.settings.network.telephony.DataDuringCallsPreferenceController) Before(org.junit.Before)

Example 10 with SwitchPreference

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

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)

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