Search in sources :

Example 21 with ListPreference

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

the class ZenModePriorityMessagesPreferenceControllerTest 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_messages);
}
Also used : ListPreference(androidx.preference.ListPreference) Test(org.junit.Test)

Example 22 with ListPreference

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

the class ZenModePriorityMessagesPreferenceControllerTest 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_MESSAGES)).thenReturn(false);
    final ListPreference mockPref = mock(ListPreference.class);
    mController.updateState(mockPref);
    verify(mockPref).setEnabled(false);
    verify(mockPref).setSummary(R.string.zen_mode_from_none_messages);
}
Also used : ListPreference(androidx.preference.ListPreference) Test(org.junit.Test)

Example 23 with ListPreference

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

the class AudioOutputSwitchPreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = spy(RuntimeEnvironment.application);
    mAudioManager = mContext.getSystemService(AudioManager.class);
    mShadowAudioManager = ShadowAudioManager.getShadow();
    ShadowBluetoothUtils.sLocalBluetoothManager = mLocalManager;
    mLocalBluetoothManager = Utils.getLocalBtManager(mContext);
    when(mLocalBluetoothManager.getEventManager()).thenReturn(mBluetoothEventManager);
    when(mLocalBluetoothManager.getProfileManager()).thenReturn(mLocalBluetoothProfileManager);
    when(mLocalBluetoothProfileManager.getA2dpProfile()).thenReturn(mA2dpProfile);
    when(mLocalBluetoothProfileManager.getHearingAidProfile()).thenReturn(mHearingAidProfile);
    when(mLocalBluetoothProfileManager.getHeadsetProfile()).thenReturn(mHeadsetProfile);
    mPackageManager = Shadow.extract(mContext.getPackageManager());
    mPackageManager.setSystemFeature(PackageManager.FEATURE_BLUETOOTH, true);
    mBluetoothManager = new BluetoothManager(mContext);
    mBluetoothAdapter = mBluetoothManager.getAdapter();
    mBluetoothDevice = spy(mBluetoothAdapter.getRemoteDevice(TEST_DEVICE_ADDRESS_1));
    when(mBluetoothDevice.getName()).thenReturn(TEST_DEVICE_NAME_1);
    when(mBluetoothDevice.isConnected()).thenReturn(true);
    mLeftBluetoothHapDevice = spy(mBluetoothAdapter.getRemoteDevice(TEST_DEVICE_ADDRESS_2));
    when(mLeftBluetoothHapDevice.isConnected()).thenReturn(true);
    mRightBluetoothHapDevice = spy(mBluetoothAdapter.getRemoteDevice(TEST_DEVICE_ADDRESS_3));
    when(mRightBluetoothHapDevice.isConnected()).thenReturn(true);
    mController = new AudioSwitchPreferenceControllerTestable(mContext, TEST_KEY);
    mScreen = spy(new PreferenceScreen(mContext, null));
    mPreference = new ListPreference(mContext);
    mProfileConnectedDevices = new ArrayList<>();
    mHearingAidActiveDevices = new ArrayList<>(2);
    mEmptyDevices = new ArrayList<>(2);
    when(mScreen.getPreferenceManager()).thenReturn(mock(PreferenceManager.class));
    when(mScreen.getContext()).thenReturn(mContext);
    when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
    mScreen.addPreference(mPreference);
    mController.displayPreference(mScreen);
}
Also used : AudioManager(android.media.AudioManager) ShadowAudioManager(com.android.settings.testutils.shadow.ShadowAudioManager) PreferenceScreen(androidx.preference.PreferenceScreen) BluetoothManager(android.bluetooth.BluetoothManager) LocalBluetoothManager(com.android.settingslib.bluetooth.LocalBluetoothManager) ListPreference(androidx.preference.ListPreference) PreferenceManager(androidx.preference.PreferenceManager) Before(org.junit.Before)

Example 24 with ListPreference

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

the class HandsFreeProfileOutputPreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = spy(RuntimeEnvironment.application);
    mAudioManager = mContext.getSystemService(AudioManager.class);
    mShadowAudioManager = ShadowAudioManager.getShadow();
    ShadowBluetoothUtils.sLocalBluetoothManager = mLocalManager;
    mLocalBluetoothManager = Utils.getLocalBtManager(mContext);
    when(mLocalBluetoothManager.getEventManager()).thenReturn(mBluetoothEventManager);
    when(mLocalBluetoothManager.getProfileManager()).thenReturn(mLocalBluetoothProfileManager);
    when(mLocalBluetoothProfileManager.getHeadsetProfile()).thenReturn(mHeadsetProfile);
    when(mLocalBluetoothProfileManager.getHearingAidProfile()).thenReturn(mHearingAidProfile);
    mBluetoothManager = new BluetoothManager(mContext);
    mBluetoothAdapter = mBluetoothManager.getAdapter();
    mBluetoothDevice = spy(mBluetoothAdapter.getRemoteDevice(TEST_DEVICE_ADDRESS_1));
    when(mBluetoothDevice.getName()).thenReturn(TEST_DEVICE_NAME_1);
    when(mBluetoothDevice.isConnected()).thenReturn(true);
    mSecondBluetoothDevice = spy(mBluetoothAdapter.getRemoteDevice(TEST_DEVICE_ADDRESS_2));
    when(mSecondBluetoothDevice.getName()).thenReturn(TEST_DEVICE_NAME_2);
    when(mSecondBluetoothDevice.isConnected()).thenReturn(true);
    mLeftBluetoothHapDevice = spy(mBluetoothAdapter.getRemoteDevice(TEST_DEVICE_ADDRESS_3));
    when(mLeftBluetoothHapDevice.getName()).thenReturn(TEST_HAP_DEVICE_NAME_1);
    when(mLeftBluetoothHapDevice.isConnected()).thenReturn(true);
    mRightBluetoothHapDevice = spy(mBluetoothAdapter.getRemoteDevice(TEST_DEVICE_ADDRESS_4));
    when(mRightBluetoothHapDevice.getName()).thenReturn(TEST_HAP_DEVICE_NAME_2);
    when(mRightBluetoothHapDevice.isConnected()).thenReturn(true);
    mController = new HandsFreeProfileOutputPreferenceController(mContext, TEST_KEY);
    mScreen = spy(new PreferenceScreen(mContext, null));
    mPreference = new ListPreference(mContext);
    mProfileConnectedDevices = new ArrayList<>();
    mHearingAidActiveDevices = new ArrayList<>(2);
    when(mScreen.getPreferenceManager()).thenReturn(mock(PreferenceManager.class));
    when(mScreen.getContext()).thenReturn(mContext);
    when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
    mScreen.addPreference(mPreference);
    mController.displayPreference(mScreen);
    mController.setCallback(mAudioSwitchPreferenceCallback);
}
Also used : AudioManager(android.media.AudioManager) ShadowAudioManager(com.android.settings.testutils.shadow.ShadowAudioManager) PreferenceScreen(androidx.preference.PreferenceScreen) LocalBluetoothManager(com.android.settingslib.bluetooth.LocalBluetoothManager) BluetoothManager(android.bluetooth.BluetoothManager) ListPreference(androidx.preference.ListPreference) PreferenceManager(androidx.preference.PreferenceManager) Before(org.junit.Before)

Example 25 with ListPreference

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

the class WifiTetherApBandPreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = spy(RuntimeEnvironment.application);
    mPreference = new ListPreference(RuntimeEnvironment.application);
    when(mContext.getSystemService(Context.WIFI_SERVICE)).thenReturn(mWifiManager);
    when(mContext.getSystemService(Context.CONNECTIVITY_SERVICE)).thenReturn(mConnectivityManager);
    when(mConnectivityManager.getTetherableWifiRegexs()).thenReturn(new String[] { "1", "2" });
    when(mContext.getResources()).thenReturn(RuntimeEnvironment.application.getResources());
    when(mScreen.findPreference(anyString())).thenReturn(mPreference);
    WifiConfiguration config = new WifiConfiguration();
    config.apBand = WifiConfiguration.AP_BAND_ANY;
    when(mWifiManager.getWifiApConfiguration()).thenReturn(new WifiConfiguration());
    when(mWifiManager.isDualModeSupported()).thenReturn(false);
    mController = new WifiTetherApBandPreferenceController(mContext, mListener);
}
Also used : WifiConfiguration(android.net.wifi.WifiConfiguration) ListPreference(androidx.preference.ListPreference) Before(org.junit.Before)

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