Replced BluetoothCodecStatus creator by Builder

Bug: 222540543
Test: atest BluetoothCodecsTest
Tag: #feature
Change-Id: I2585b1bac9044add2dd072ed2effc3e61e4b1223
This commit is contained in:
Etienne Ruffieux
2022-03-08 13:35:07 +00:00
parent 2e6f2dcfff
commit 8db7f1a81d
6 changed files with 70 additions and 37 deletions

View File

@@ -121,7 +121,7 @@ public class AbstractBluetoothDialogPreferenceControllerTest {
@Test @Test
public void onIndexUpdated_checkFlow() { public void onIndexUpdated_checkFlow() {
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, null); mCodecStatus = new BluetoothCodecStatus.Builder().setCodecConfig(mCodecConfigAAC).build();
when(mBluetoothA2dp.getCodecStatus( when(mBluetoothA2dp.getCodecStatus(
mActiveDevice)).thenReturn(mCodecStatus); mActiveDevice)).thenReturn(mCodecStatus);
when(mBluetoothA2dpConfigStore.createCodecConfig()).thenReturn(mCodecConfigAAC); when(mBluetoothA2dpConfigStore.createCodecConfig()).thenReturn(mCodecConfigAAC);
@@ -161,7 +161,7 @@ public class AbstractBluetoothDialogPreferenceControllerTest {
@Test @Test
public void getCurrentCodecConfig_verifyConfig() { public void getCurrentCodecConfig_verifyConfig() {
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, null); mCodecStatus = new BluetoothCodecStatus.Builder().setCodecConfig(mCodecConfigAAC).build();
when(mBluetoothA2dp.getCodecStatus( when(mBluetoothA2dp.getCodecStatus(
mActiveDevice)).thenReturn(mCodecStatus); mActiveDevice)).thenReturn(mCodecStatus);
mController.onBluetoothServiceConnected(mBluetoothA2dp); mController.onBluetoothServiceConnected(mBluetoothA2dp);
@@ -171,8 +171,10 @@ public class AbstractBluetoothDialogPreferenceControllerTest {
@Test @Test
public void getSelectableConfigs_verifyConfig() { public void getSelectableConfigs_verifyConfig() {
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecStatus = new BluetoothCodecStatus.Builder()
Arrays.asList(mCodecConfigs)); .setCodecConfig(mCodecConfigAAC)
.setCodecsSelectableCapabilities(Arrays.asList(mCodecConfigs))
.build();
when(mBluetoothA2dp.getCodecStatus( when(mBluetoothA2dp.getCodecStatus(
mActiveDevice)).thenReturn(mCodecStatus); mActiveDevice)).thenReturn(mCodecStatus);
mController.onBluetoothServiceConnected(mBluetoothA2dp); mController.onBluetoothServiceConnected(mBluetoothA2dp);
@@ -182,8 +184,10 @@ public class AbstractBluetoothDialogPreferenceControllerTest {
@Test @Test
public void getSelectableByCodecType_verifyConfig() { public void getSelectableByCodecType_verifyConfig() {
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecStatus = new BluetoothCodecStatus.Builder()
Arrays.asList(mCodecConfigs)); .setCodecConfig(mCodecConfigAAC)
.setCodecsSelectableCapabilities(Arrays.asList(mCodecConfigs))
.build();
when(mBluetoothA2dp.getCodecStatus( when(mBluetoothA2dp.getCodecStatus(
mActiveDevice)).thenReturn(mCodecStatus); mActiveDevice)).thenReturn(mCodecStatus);
mController.onBluetoothServiceConnected(mBluetoothA2dp); mController.onBluetoothServiceConnected(mBluetoothA2dp);
@@ -194,8 +198,10 @@ public class AbstractBluetoothDialogPreferenceControllerTest {
@Test @Test
public void getSelectableByCodecType_unavailable() { public void getSelectableByCodecType_unavailable() {
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecStatus = new BluetoothCodecStatus.Builder()
Arrays.asList(mCodecConfigs)); .setCodecConfig(mCodecConfigAAC)
.setCodecsSelectableCapabilities(Arrays.asList(mCodecConfigs))
.build();
when(mBluetoothA2dp.getCodecStatus( when(mBluetoothA2dp.getCodecStatus(
mActiveDevice)).thenReturn(mCodecStatus); mActiveDevice)).thenReturn(mCodecStatus);
mController.onBluetoothServiceConnected(mBluetoothA2dp); mController.onBluetoothServiceConnected(mBluetoothA2dp);
@@ -206,8 +212,10 @@ public class AbstractBluetoothDialogPreferenceControllerTest {
@Test @Test
public void onBluetoothServiceConnected_verifyBluetoothA2dpConfigStore() { public void onBluetoothServiceConnected_verifyBluetoothA2dpConfigStore() {
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecStatus = new BluetoothCodecStatus.Builder()
Arrays.asList(mCodecConfigs)); .setCodecConfig(mCodecConfigAAC)
.setCodecsSelectableCapabilities(Arrays.asList(mCodecConfigs))
.build();
when(mBluetoothA2dp.getCodecStatus( when(mBluetoothA2dp.getCodecStatus(
mActiveDevice)).thenReturn(mCodecStatus); mActiveDevice)).thenReturn(mCodecStatus);
mController.onBluetoothServiceConnected(mBluetoothA2dp); mController.onBluetoothServiceConnected(mBluetoothA2dp);

View File

@@ -102,8 +102,10 @@ public class BluetoothBitPerSampleDialogPreferenceControllerTest {
@Test @Test
public void writeConfigurationValues_selectDefault_setHighest() { public void writeConfigurationValues_selectDefault_setHighest() {
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC}; BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecStatus = new BluetoothCodecStatus.Builder()
Arrays.asList(mCodecConfigs)); .setCodecConfig(mCodecConfigAAC)
.setCodecsSelectableCapabilities(Arrays.asList(mCodecConfigs))
.build();
when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus); when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus);
mController.onBluetoothServiceConnected(mBluetoothA2dp); mController.onBluetoothServiceConnected(mBluetoothA2dp);
@@ -132,8 +134,10 @@ public class BluetoothBitPerSampleDialogPreferenceControllerTest {
@Test @Test
public void getSelectableIndex_verifyList() { public void getSelectableIndex_verifyList() {
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC}; BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecStatus = new BluetoothCodecStatus.Builder()
Arrays.asList(mCodecConfigs)); .setCodecConfig(mCodecConfigAAC)
.setCodecsSelectableCapabilities(Arrays.asList(mCodecConfigs))
.build();
when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus); when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus);
mController.onBluetoothServiceConnected(mBluetoothA2dp); mController.onBluetoothServiceConnected(mBluetoothA2dp);
List<Integer> indexList = new ArrayList<>(); List<Integer> indexList = new ArrayList<>();

View File

@@ -102,8 +102,10 @@ public class BluetoothChannelModeDialogPreferenceControllerTest {
@Test @Test
public void writeConfigurationValues_selectDefault_setHighest() { public void writeConfigurationValues_selectDefault_setHighest() {
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC}; BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
mCodecStatus = new BluetoothCodecStatus(mCodecConfigSBC, null, mCodecStatus = new BluetoothCodecStatus.Builder()
Arrays.asList(mCodecConfigs)); .setCodecConfig(mCodecConfigSBC)
.setCodecsSelectableCapabilities(Arrays.asList(mCodecConfigs))
.build();
when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus); when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus);
mController.onBluetoothServiceConnected(mBluetoothA2dp); mController.onBluetoothServiceConnected(mBluetoothA2dp);
@@ -129,8 +131,10 @@ public class BluetoothChannelModeDialogPreferenceControllerTest {
@Test @Test
public void getSelectableIndex_verifyList() { public void getSelectableIndex_verifyList() {
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC}; BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
mCodecStatus = new BluetoothCodecStatus(mCodecConfigSBC, null, mCodecStatus = new BluetoothCodecStatus.Builder()
Arrays.asList(mCodecConfigs)); .setCodecConfig(mCodecConfigSBC)
.setCodecsSelectableCapabilities(Arrays.asList(mCodecConfigs))
.build();
when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus); when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus);
mController.onBluetoothServiceConnected(mBluetoothA2dp); mController.onBluetoothServiceConnected(mBluetoothA2dp);
List<Integer> indexList = new ArrayList<>(); List<Integer> indexList = new ArrayList<>();

View File

@@ -126,8 +126,10 @@ public class BluetoothCodecDialogPreferenceControllerTest {
@Test @Test
public void writeConfigurationValues_selectDefault_setHighest() { public void writeConfigurationValues_selectDefault_setHighest() {
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC}; BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
mCodecStatus = new BluetoothCodecStatus(mCodecConfigSBC, null, mCodecStatus = new BluetoothCodecStatus.Builder()
Arrays.asList(mCodecConfigs)); .setCodecConfig(mCodecConfigSBC)
.setCodecsSelectableCapabilities(Arrays.asList(mCodecConfigs))
.build();
when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus); when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus);
when(mBluetoothA2dp.isOptionalCodecsEnabled(mActiveDevice)).thenReturn( when(mBluetoothA2dp.isOptionalCodecsEnabled(mActiveDevice)).thenReturn(
BluetoothA2dp.OPTIONAL_CODECS_PREF_ENABLED); BluetoothA2dp.OPTIONAL_CODECS_PREF_ENABLED);
@@ -141,8 +143,10 @@ public class BluetoothCodecDialogPreferenceControllerTest {
public void writeConfigurationValues_checkCodec() { public void writeConfigurationValues_checkCodec() {
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC, mCodecConfigAPTX, BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC, mCodecConfigAPTX,
mCodecConfigAPTXHD, mCodecConfigLDAC, mCodecConfigAAC, mCodecConfigSBC}; mCodecConfigAPTXHD, mCodecConfigLDAC, mCodecConfigAAC, mCodecConfigSBC};
mCodecStatus = new BluetoothCodecStatus(mCodecConfigSBC, null, mCodecStatus = new BluetoothCodecStatus.Builder()
Arrays.asList(mCodecConfigs)); .setCodecConfig(mCodecConfigSBC)
.setCodecsSelectableCapabilities(Arrays.asList(mCodecConfigs))
.build();
when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus); when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus);
mController.onBluetoothServiceConnected(mBluetoothA2dp); mController.onBluetoothServiceConnected(mBluetoothA2dp);
@@ -169,8 +173,10 @@ public class BluetoothCodecDialogPreferenceControllerTest {
public void writeConfigurationValues_resetHighestConfig() { public void writeConfigurationValues_resetHighestConfig() {
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC, mCodecConfigAPTX, BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC, mCodecConfigAPTX,
mCodecConfigAPTXHD, mCodecConfigLDAC, mCodecConfigAAC, mCodecConfigSBC}; mCodecConfigAPTXHD, mCodecConfigLDAC, mCodecConfigAAC, mCodecConfigSBC};
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecStatus = new BluetoothCodecStatus.Builder()
Arrays.asList(mCodecConfigs)); .setCodecConfig(mCodecConfigAAC)
.setCodecsSelectableCapabilities(Arrays.asList(mCodecConfigs))
.build();
when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus); when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus);
mController.onBluetoothServiceConnected(mBluetoothA2dp); mController.onBluetoothServiceConnected(mBluetoothA2dp);
mController.writeConfigurationValues(2); mController.writeConfigurationValues(2);
@@ -201,9 +207,10 @@ public class BluetoothCodecDialogPreferenceControllerTest {
@Test @Test
public void onHDAudioEnabled_optionalCodecEnabled_setsCodecTypeAsAAC() { public void onHDAudioEnabled_optionalCodecEnabled_setsCodecTypeAsAAC() {
List<BluetoothCodecConfig> mCodecConfigs = Arrays.asList(mCodecConfigAAC, mCodecConfigSBC); List<BluetoothCodecConfig> mCodecConfigs = Arrays.asList(mCodecConfigAAC, mCodecConfigSBC);
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, mCodecStatus = new BluetoothCodecStatus.Builder()
/* codecsLocalCapabilities= */ null, .setCodecConfig(mCodecConfigAAC)
mCodecConfigs); .setCodecsSelectableCapabilities(mCodecConfigs)
.build();
when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus); when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus);
when(mBluetoothA2dp.isOptionalCodecsEnabled(mActiveDevice)).thenReturn( when(mBluetoothA2dp.isOptionalCodecsEnabled(mActiveDevice)).thenReturn(
BluetoothA2dp.OPTIONAL_CODECS_PREF_ENABLED); BluetoothA2dp.OPTIONAL_CODECS_PREF_ENABLED);
@@ -217,9 +224,10 @@ public class BluetoothCodecDialogPreferenceControllerTest {
@Test @Test
public void onHDAudioEnabled_optionalCodecDisabled_setsCodecTypeAsSBC() { public void onHDAudioEnabled_optionalCodecDisabled_setsCodecTypeAsSBC() {
List<BluetoothCodecConfig> mCodecConfigs = Arrays.asList(mCodecConfigAAC, mCodecConfigSBC); List<BluetoothCodecConfig> mCodecConfigs = Arrays.asList(mCodecConfigAAC, mCodecConfigSBC);
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, mCodecStatus = new BluetoothCodecStatus.Builder()
/* codecsLocalCapabilities= */ null, .setCodecConfig(mCodecConfigAAC)
mCodecConfigs); .setCodecsSelectableCapabilities(mCodecConfigs)
.build();
when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus); when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus);
when(mBluetoothA2dp.isOptionalCodecsEnabled(mActiveDevice)).thenReturn( when(mBluetoothA2dp.isOptionalCodecsEnabled(mActiveDevice)).thenReturn(
BluetoothA2dp.OPTIONAL_CODECS_PREF_DISABLED); BluetoothA2dp.OPTIONAL_CODECS_PREF_DISABLED);

View File

@@ -122,8 +122,10 @@ public class BluetoothQualityDialogPreferenceControllerTest {
@Test @Test
public void updateState_codeTypeIsLDAC_enablePreference() { public void updateState_codeTypeIsLDAC_enablePreference() {
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigLDAC}; BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigLDAC};
mCodecStatus = new BluetoothCodecStatus(mCodecConfigLDAC, null, mCodecStatus = new BluetoothCodecStatus.Builder()
Arrays.asList(mCodecConfigs)); .setCodecConfig(mCodecConfigLDAC)
.setCodecsSelectableCapabilities(Arrays.asList(mCodecConfigs))
.build();
when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus); when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus);
mController.onBluetoothServiceConnected(mBluetoothA2dp); mController.onBluetoothServiceConnected(mBluetoothA2dp);
mController.updateState(mPreference); mController.updateState(mPreference);
@@ -134,8 +136,10 @@ public class BluetoothQualityDialogPreferenceControllerTest {
@Test @Test
public void updateState_codeTypeAAC_disablePreference() { public void updateState_codeTypeAAC_disablePreference() {
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigLDAC}; BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigLDAC};
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecStatus = new BluetoothCodecStatus.Builder()
Arrays.asList(mCodecConfigs)); .setCodecConfig(mCodecConfigAAC)
.setCodecsSelectableCapabilities(Arrays.asList(mCodecConfigs))
.build();
when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus); when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus);
mController.onBluetoothServiceConnected(mBluetoothA2dp); mController.onBluetoothServiceConnected(mBluetoothA2dp);
mController.updateState(mPreference); mController.updateState(mPreference);

View File

@@ -106,8 +106,10 @@ public class BluetoothSampleRateDialogPreferenceControllerTest {
.setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC) .setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC)
.build(); .build();
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC}; BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecStatus = new BluetoothCodecStatus.Builder()
Arrays.asList(mCodecConfigs)); .setCodecConfig(mCodecConfigAAC)
.setCodecsSelectableCapabilities(Arrays.asList(mCodecConfigs))
.build();
when(mBluetoothA2dp.getCodecStatus( when(mBluetoothA2dp.getCodecStatus(
mActiveDevice)).thenReturn(mCodecStatus); mActiveDevice)).thenReturn(mCodecStatus);
mController.onBluetoothServiceConnected(mBluetoothA2dp); mController.onBluetoothServiceConnected(mBluetoothA2dp);
@@ -143,7 +145,10 @@ public class BluetoothSampleRateDialogPreferenceControllerTest {
add(mCodecConfigAAC); add(mCodecConfigAAC);
add(mCodecConfigSBC); add(mCodecConfigSBC);
}}; }};
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs); mCodecStatus = new BluetoothCodecStatus.Builder()
.setCodecConfig(mCodecConfigAAC)
.setCodecsSelectableCapabilities(mCodecConfigs)
.build();
when(mBluetoothA2dp.getCodecStatus( when(mBluetoothA2dp.getCodecStatus(
mActiveDevice)).thenReturn(mCodecStatus); mActiveDevice)).thenReturn(mCodecStatus);
mController.onBluetoothServiceConnected(mBluetoothA2dp); mController.onBluetoothServiceConnected(mBluetoothA2dp);