Search in sources :

Example 21 with BluetoothCodecStatus

use of android.bluetooth.BluetoothCodecStatus in project android_packages_apps_Settings by omnirom.

the class BluetoothChannelModeDialogPreferenceControllerTest method getSelectableIndex_verifyList.

@Test
public void getSelectableIndex_verifyList() {
    BluetoothCodecConfig[] mCodecConfigs = { mCodecConfigAAC, mCodecConfigSBC };
    mCodecStatus = new BluetoothCodecStatus(mCodecConfigSBC, null, mCodecConfigs);
    when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus);
    mController.onBluetoothServiceConnected(mBluetoothA2dp);
    List<Integer> indexList = new ArrayList<>();
    indexList.add(mPreference.getDefaultIndex());
    indexList.add(mController.convertCfgToBtnIndex(BluetoothCodecConfig.CHANNEL_MODE_MONO));
    indexList.add(mController.convertCfgToBtnIndex(BluetoothCodecConfig.CHANNEL_MODE_STEREO));
    assertThat(mController.getSelectableIndex().containsAll(indexList)).isTrue();
    assertThat(indexList.containsAll(mController.getSelectableIndex())).isTrue();
}
Also used : BluetoothCodecStatus(android.bluetooth.BluetoothCodecStatus) BluetoothCodecConfig(android.bluetooth.BluetoothCodecConfig) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 22 with BluetoothCodecStatus

use of android.bluetooth.BluetoothCodecStatus in project android_packages_apps_Settings by omnirom.

the class BluetoothCodecDialogPreferenceControllerTest method writeConfigurationValues_checkCodec.

@Test
public void writeConfigurationValues_checkCodec() {
    BluetoothCodecConfig[] mCodecConfigs = { mCodecConfigAAC, mCodecConfigSBC, mCodecConfigAPTX, mCodecConfigAPTXHD, mCodecConfigLDAC, mCodecConfigAAC, mCodecConfigSBC };
    mCodecStatus = new BluetoothCodecStatus(mCodecConfigSBC, null, mCodecConfigs);
    when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus);
    mController.onBluetoothServiceConnected(mBluetoothA2dp);
    mController.writeConfigurationValues(1);
    verify(mBluetoothA2dpConfigStore, atLeastOnce()).setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC);
    mController.writeConfigurationValues(2);
    verify(mBluetoothA2dpConfigStore).setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC);
    mController.writeConfigurationValues(3);
    verify(mBluetoothA2dpConfigStore).setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX);
    mController.writeConfigurationValues(4);
    verify(mBluetoothA2dpConfigStore).setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX_HD);
    mController.writeConfigurationValues(5);
    verify(mBluetoothA2dpConfigStore).setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC);
}
Also used : BluetoothCodecStatus(android.bluetooth.BluetoothCodecStatus) BluetoothCodecConfig(android.bluetooth.BluetoothCodecConfig) Test(org.junit.Test)

Example 23 with BluetoothCodecStatus

use of android.bluetooth.BluetoothCodecStatus in project android_packages_apps_Settings by omnirom.

the class BluetoothCodecDialogPreferenceControllerTest method writeConfigurationValues_selectDefault_setHighest.

@Test
public void writeConfigurationValues_selectDefault_setHighest() {
    BluetoothCodecConfig[] mCodecConfigs = { mCodecConfigAAC, mCodecConfigSBC };
    mCodecStatus = new BluetoothCodecStatus(mCodecConfigSBC, null, mCodecConfigs);
    when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus);
    mController.onBluetoothServiceConnected(mBluetoothA2dp);
    mController.writeConfigurationValues(0);
    verify(mBluetoothA2dpConfigStore).setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC);
}
Also used : BluetoothCodecStatus(android.bluetooth.BluetoothCodecStatus) BluetoothCodecConfig(android.bluetooth.BluetoothCodecConfig) Test(org.junit.Test)

Example 24 with BluetoothCodecStatus

use of android.bluetooth.BluetoothCodecStatus in project android_packages_apps_Settings by omnirom.

the class AbstractBluetoothDialogPreferenceControllerTest method onBluetoothServiceConnected_verifyBluetoothA2dpConfigStore.

@Test
public void onBluetoothServiceConnected_verifyBluetoothA2dpConfigStore() {
    mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
    when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus);
    mController.onBluetoothServiceConnected(mBluetoothA2dp);
    verify(mBluetoothA2dpConfigStore).setCodecType(mCodecConfigAAC.getCodecType());
    verify(mBluetoothA2dpConfigStore).setSampleRate(mCodecConfigAAC.getSampleRate());
    verify(mBluetoothA2dpConfigStore).setBitsPerSample(mCodecConfigAAC.getBitsPerSample());
    verify(mBluetoothA2dpConfigStore).setChannelMode(mCodecConfigAAC.getChannelMode());
    verify(mBluetoothA2dpConfigStore).setCodecPriority(CODEC_PRIORITY_HIGHEST);
    verify(mBluetoothA2dpConfigStore).setCodecSpecific1Value(mCodecConfigAAC.getCodecSpecific1());
}
Also used : BluetoothCodecStatus(android.bluetooth.BluetoothCodecStatus) Test(org.junit.Test)

Example 25 with BluetoothCodecStatus

use of android.bluetooth.BluetoothCodecStatus in project android_packages_apps_Settings by omnirom.

the class AbstractBluetoothDialogPreferenceControllerTest method getSelectableByCodecType_verifyConfig.

@Test
public void getSelectableByCodecType_verifyConfig() {
    mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
    when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus);
    mController.onBluetoothServiceConnected(mBluetoothA2dp);
    assertThat(mController.getSelectableByCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC)).isEqualTo(mCodecConfigAAC);
}
Also used : BluetoothCodecStatus(android.bluetooth.BluetoothCodecStatus) Test(org.junit.Test)

Aggregations

BluetoothCodecStatus (android.bluetooth.BluetoothCodecStatus)26 BluetoothCodecConfig (android.bluetooth.BluetoothCodecConfig)17 Test (org.junit.Test)17 Resources (android.content.res.Resources)6 BluetoothDevice (android.bluetooth.BluetoothDevice)3 ArrayList (java.util.ArrayList)3 BluetoothA2dp (android.bluetooth.BluetoothA2dp)2 VisibleForTesting (androidx.annotation.VisibleForTesting)1