Search in sources :

Example 26 with SwitchPreference

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

the class UsbDetailsPowerRoleControllerTest method displayRefresh_sink_shouldUncheck.

@Test
public void displayRefresh_sink_shouldUncheck() {
    mDetailsPowerRoleController.displayPreference(mScreen);
    when(mUsbBackend.areAllRolesSupported()).thenReturn(true);
    mDetailsPowerRoleController.refresh(true, UsbManager.FUNCTION_NONE, POWER_ROLE_SINK, DATA_ROLE_DEVICE);
    SwitchPreference pref = getPreference();
    assertThat(pref.isChecked()).isFalse();
}
Also used : SwitchPreference(androidx.preference.SwitchPreference) Test(org.junit.Test)

Example 27 with SwitchPreference

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

the class UsbDetailsPowerRoleControllerTest method onClickTwice_sink_shouldSetSourceOnce.

@Test
public void onClickTwice_sink_shouldSetSourceOnce() {
    mDetailsPowerRoleController.displayPreference(mScreen);
    when(mUsbBackend.getPowerRole()).thenReturn(POWER_ROLE_SINK);
    SwitchPreference pref = getPreference();
    pref.performClick();
    assertThat(pref.getSummary()).isEqualTo(mContext.getString(R.string.usb_switching));
    pref.performClick();
    verify(mUsbBackend, times(1)).setPowerRole(POWER_ROLE_SOURCE);
}
Also used : SwitchPreference(androidx.preference.SwitchPreference) Test(org.junit.Test)

Example 28 with SwitchPreference

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

the class UsbDetailsPowerRoleControllerTest method displayRefresh_source_shouldCheck.

@Test
public void displayRefresh_source_shouldCheck() {
    mDetailsPowerRoleController.displayPreference(mScreen);
    when(mUsbBackend.areAllRolesSupported()).thenReturn(true);
    mDetailsPowerRoleController.refresh(true, UsbManager.FUNCTION_NONE, POWER_ROLE_SOURCE, DATA_ROLE_HOST);
    SwitchPreference pref = getPreference();
    assertThat(pref.isChecked()).isTrue();
}
Also used : SwitchPreference(androidx.preference.SwitchPreference) Test(org.junit.Test)

Example 29 with SwitchPreference

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

the class DevelopmentTilePreferenceControllerTest method preferenceChecked_shouldAddTile.

@Test
public void preferenceChecked_shouldAddTile() throws RemoteException {
    SwitchPreference preference = createPreference(/* defaultCheckedState = */
    false);
    preference.performClick();
    ArgumentCaptor<ComponentName> argument = ArgumentCaptor.forClass(ComponentName.class);
    verify(mStatusBarService).addTile(argument.capture());
    assertThat(argument.getValue().getClassName()).isEqualTo(SERVICE_INFO_NAME);
    assertThat(argument.getValue().getPackageName()).isEqualTo(mContext.getPackageName());
}
Also used : SwitchPreference(androidx.preference.SwitchPreference) ComponentName(android.content.ComponentName) Test(org.junit.Test)

Example 30 with SwitchPreference

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

the class DevelopmentTilePreferenceControllerTest method preferenceUnchecked_shouldRemoveTile.

@Test
public void preferenceUnchecked_shouldRemoveTile() throws RemoteException {
    SwitchPreference preference = createPreference(/* defaultCheckedState = */
    true);
    preference.performClick();
    ArgumentCaptor<ComponentName> argument = ArgumentCaptor.forClass(ComponentName.class);
    verify(mStatusBarService).remTile(argument.capture());
    assertThat(argument.getValue().getClassName()).isEqualTo(SERVICE_INFO_NAME);
    assertThat(argument.getValue().getPackageName()).isEqualTo(mContext.getPackageName());
}
Also used : SwitchPreference(androidx.preference.SwitchPreference) ComponentName(android.content.ComponentName) 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