Merge "Make BluetoothCodecConfig and BluetoothCodecStatus public" am: 0e1a4d3bdf
Original change: https://android-review.googlesource.com/c/platform/packages/apps/Settings/+/1849631 Change-Id: I248efd0968d1a4c3207d78c9d015142ba9e02030
This commit is contained in:
@@ -47,6 +47,7 @@ import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@@ -85,8 +86,12 @@ public class AbstractBluetoothDialogPreferenceControllerTest {
|
||||
mBluetoothA2dpConfigStore));
|
||||
mPreference = spy(new BaseBluetoothDialogPreferenceImpl(mContext));
|
||||
|
||||
mCodecConfigAAC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC);
|
||||
mCodecConfigSBC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC);
|
||||
mCodecConfigAAC = new BluetoothCodecConfig.Builder()
|
||||
.setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC)
|
||||
.build();
|
||||
mCodecConfigSBC = new BluetoothCodecConfig.Builder()
|
||||
.setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC)
|
||||
.build();
|
||||
mCodecConfigs[0] = mCodecConfigAAC;
|
||||
mCodecConfigs[1] = mCodecConfigSBC;
|
||||
|
||||
@@ -160,17 +165,19 @@ public class AbstractBluetoothDialogPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void getSelectableConfigs_verifyConfig() {
|
||||
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
|
||||
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null,
|
||||
Arrays.asList(mCodecConfigs));
|
||||
when(mBluetoothA2dp.getCodecStatus(
|
||||
mActiveDevice)).thenReturn(mCodecStatus);
|
||||
mController.onBluetoothServiceConnected(mBluetoothA2dp);
|
||||
|
||||
assertThat(mController.getSelectableConfigs(null)).isEqualTo(mCodecConfigs);
|
||||
assertThat(mController.getSelectableConfigs(null)).isEqualTo(Arrays.asList(mCodecConfigs));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSelectableByCodecType_verifyConfig() {
|
||||
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
|
||||
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null,
|
||||
Arrays.asList(mCodecConfigs));
|
||||
when(mBluetoothA2dp.getCodecStatus(
|
||||
mActiveDevice)).thenReturn(mCodecStatus);
|
||||
mController.onBluetoothServiceConnected(mBluetoothA2dp);
|
||||
@@ -181,7 +188,8 @@ public class AbstractBluetoothDialogPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void getSelectableByCodecType_unavailable() {
|
||||
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
|
||||
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null,
|
||||
Arrays.asList(mCodecConfigs));
|
||||
when(mBluetoothA2dp.getCodecStatus(
|
||||
mActiveDevice)).thenReturn(mCodecStatus);
|
||||
mController.onBluetoothServiceConnected(mBluetoothA2dp);
|
||||
@@ -192,7 +200,8 @@ public class AbstractBluetoothDialogPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void onBluetoothServiceConnected_verifyBluetoothA2dpConfigStore() {
|
||||
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
|
||||
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null,
|
||||
Arrays.asList(mCodecConfigs));
|
||||
when(mBluetoothA2dp.getCodecStatus(
|
||||
mActiveDevice)).thenReturn(mCodecStatus);
|
||||
mController.onBluetoothServiceConnected(mBluetoothA2dp);
|
||||
|
@@ -44,6 +44,7 @@ import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@@ -80,25 +81,23 @@ public class BluetoothBitPerSampleDialogPreferenceControllerTest {
|
||||
mPreference = new BluetoothBitPerSampleDialogPreference(mContext);
|
||||
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
||||
mController.displayPreference(mScreen);
|
||||
mCodecConfigAAC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC,
|
||||
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
|
||||
BluetoothCodecConfig.SAMPLE_RATE_NONE,
|
||||
BluetoothCodecConfig.BITS_PER_SAMPLE_16 | BluetoothCodecConfig.BITS_PER_SAMPLE_24,
|
||||
BluetoothCodecConfig.CHANNEL_MODE_NONE,
|
||||
0, 0, 0, 0);
|
||||
mCodecConfigSBC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
|
||||
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
|
||||
BluetoothCodecConfig.SAMPLE_RATE_NONE,
|
||||
BluetoothCodecConfig.BITS_PER_SAMPLE_24,
|
||||
BluetoothCodecConfig.CHANNEL_MODE_NONE,
|
||||
0, 0, 0, 0);
|
||||
mCodecConfigAAC = new BluetoothCodecConfig.Builder()
|
||||
.setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC)
|
||||
.setBitsPerSample(BluetoothCodecConfig.BITS_PER_SAMPLE_16
|
||||
| BluetoothCodecConfig.BITS_PER_SAMPLE_24)
|
||||
.build();
|
||||
mCodecConfigSBC = new BluetoothCodecConfig.Builder()
|
||||
.setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC)
|
||||
.setBitsPerSample(BluetoothCodecConfig.BITS_PER_SAMPLE_24)
|
||||
.build();
|
||||
when(mBluetoothA2dp.getActiveDevice()).thenReturn(mActiveDevice);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void writeConfigurationValues_selectDefault_setHighest() {
|
||||
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
|
||||
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
|
||||
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null,
|
||||
Arrays.asList(mCodecConfigs));
|
||||
when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus);
|
||||
mController.onBluetoothServiceConnected(mBluetoothA2dp);
|
||||
|
||||
@@ -127,7 +126,8 @@ public class BluetoothBitPerSampleDialogPreferenceControllerTest {
|
||||
@Test
|
||||
public void getSelectableIndex_verifyList() {
|
||||
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
|
||||
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
|
||||
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null,
|
||||
Arrays.asList(mCodecConfigs));
|
||||
when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus);
|
||||
mController.onBluetoothServiceConnected(mBluetoothA2dp);
|
||||
List<Integer> indexList = new ArrayList<>();
|
||||
|
@@ -44,6 +44,7 @@ import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@@ -80,25 +81,23 @@ public class BluetoothChannelModeDialogPreferenceControllerTest {
|
||||
mPreference = new BluetoothChannelModeDialogPreference(mContext);
|
||||
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
||||
mController.displayPreference(mScreen);
|
||||
mCodecConfigAAC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC,
|
||||
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
|
||||
BluetoothCodecConfig.SAMPLE_RATE_NONE,
|
||||
BluetoothCodecConfig.BITS_PER_SAMPLE_NONE,
|
||||
BluetoothCodecConfig.CHANNEL_MODE_STEREO,
|
||||
0, 0, 0, 0);
|
||||
mCodecConfigSBC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
|
||||
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
|
||||
BluetoothCodecConfig.SAMPLE_RATE_NONE,
|
||||
BluetoothCodecConfig.BITS_PER_SAMPLE_NONE,
|
||||
BluetoothCodecConfig.CHANNEL_MODE_MONO | BluetoothCodecConfig.CHANNEL_MODE_STEREO,
|
||||
0, 0, 0, 0);
|
||||
mCodecConfigAAC = new BluetoothCodecConfig.Builder()
|
||||
.setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC)
|
||||
.setChannelMode(BluetoothCodecConfig.CHANNEL_MODE_STEREO)
|
||||
.build();
|
||||
mCodecConfigSBC = new BluetoothCodecConfig.Builder()
|
||||
.setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC)
|
||||
.setChannelMode(BluetoothCodecConfig.CHANNEL_MODE_MONO
|
||||
| BluetoothCodecConfig.CHANNEL_MODE_STEREO)
|
||||
.build();
|
||||
when(mBluetoothA2dp.getActiveDevice()).thenReturn(mActiveDevice);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void writeConfigurationValues_selectDefault_setHighest() {
|
||||
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
|
||||
mCodecStatus = new BluetoothCodecStatus(mCodecConfigSBC, null, mCodecConfigs);
|
||||
mCodecStatus = new BluetoothCodecStatus(mCodecConfigSBC, null,
|
||||
Arrays.asList(mCodecConfigs));
|
||||
when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus);
|
||||
mController.onBluetoothServiceConnected(mBluetoothA2dp);
|
||||
|
||||
@@ -124,7 +123,8 @@ public class BluetoothChannelModeDialogPreferenceControllerTest {
|
||||
@Test
|
||||
public void getSelectableIndex_verifyList() {
|
||||
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
|
||||
mCodecStatus = new BluetoothCodecStatus(mCodecConfigSBC, null, mCodecConfigs);
|
||||
mCodecStatus = new BluetoothCodecStatus(mCodecConfigSBC, null,
|
||||
Arrays.asList(mCodecConfigs));
|
||||
when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus);
|
||||
mController.onBluetoothServiceConnected(mBluetoothA2dp);
|
||||
List<Integer> indexList = new ArrayList<>();
|
||||
|
@@ -45,6 +45,9 @@ import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class BluetoothCodecDialogPreferenceControllerTest {
|
||||
|
||||
@@ -85,29 +88,41 @@ public class BluetoothCodecDialogPreferenceControllerTest {
|
||||
mPreference = new BluetoothCodecDialogPreference(mContext);
|
||||
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
||||
mController.displayPreference(mScreen);
|
||||
mCodecConfigSBC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
|
||||
BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST,
|
||||
BluetoothCodecConfig.SAMPLE_RATE_96000 | BluetoothCodecConfig.SAMPLE_RATE_176400,
|
||||
BluetoothCodecConfig.BITS_PER_SAMPLE_32,
|
||||
BluetoothCodecConfig.CHANNEL_MODE_MONO | BluetoothCodecConfig.CHANNEL_MODE_STEREO,
|
||||
0, 0, 0, 0);
|
||||
mCodecConfigAAC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC,
|
||||
BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST,
|
||||
BluetoothCodecConfig.SAMPLE_RATE_48000 | BluetoothCodecConfig.SAMPLE_RATE_88200,
|
||||
BluetoothCodecConfig.BITS_PER_SAMPLE_16 | BluetoothCodecConfig.BITS_PER_SAMPLE_24,
|
||||
BluetoothCodecConfig.CHANNEL_MODE_STEREO,
|
||||
0, 0, 0, 0);
|
||||
mCodecConfigAPTX = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX);
|
||||
mCodecConfigAPTXHD = new BluetoothCodecConfig(
|
||||
BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX_HD);
|
||||
mCodecConfigLDAC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC);
|
||||
mCodecConfigSBC = new BluetoothCodecConfig.Builder()
|
||||
.setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC)
|
||||
.setCodecPriority(BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST)
|
||||
.setSampleRate(BluetoothCodecConfig.SAMPLE_RATE_96000
|
||||
| BluetoothCodecConfig.SAMPLE_RATE_176400)
|
||||
.setBitsPerSample(BluetoothCodecConfig.BITS_PER_SAMPLE_32)
|
||||
.setChannelMode(BluetoothCodecConfig.CHANNEL_MODE_MONO
|
||||
| BluetoothCodecConfig.CHANNEL_MODE_STEREO)
|
||||
.build();
|
||||
mCodecConfigAAC = new BluetoothCodecConfig.Builder()
|
||||
.setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC)
|
||||
.setCodecPriority(BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST)
|
||||
.setSampleRate(BluetoothCodecConfig.SAMPLE_RATE_48000
|
||||
| BluetoothCodecConfig.SAMPLE_RATE_88200)
|
||||
.setBitsPerSample(BluetoothCodecConfig.BITS_PER_SAMPLE_16
|
||||
| BluetoothCodecConfig.BITS_PER_SAMPLE_24)
|
||||
.setChannelMode(BluetoothCodecConfig.CHANNEL_MODE_STEREO)
|
||||
.build();
|
||||
mCodecConfigAPTX = new BluetoothCodecConfig.Builder()
|
||||
.setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX)
|
||||
.build();
|
||||
mCodecConfigAPTXHD = new BluetoothCodecConfig.Builder()
|
||||
.setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX_HD)
|
||||
.build();
|
||||
mCodecConfigLDAC = new BluetoothCodecConfig.Builder()
|
||||
.setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC)
|
||||
.build();
|
||||
when(mBluetoothA2dp.getActiveDevice()).thenReturn(mActiveDevice);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void writeConfigurationValues_selectDefault_setHighest() {
|
||||
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
|
||||
mCodecStatus = new BluetoothCodecStatus(mCodecConfigSBC, null, mCodecConfigs);
|
||||
mCodecStatus = new BluetoothCodecStatus(mCodecConfigSBC, null,
|
||||
Arrays.asList(mCodecConfigs));
|
||||
when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus);
|
||||
when(mBluetoothA2dp.isOptionalCodecsEnabled(mActiveDevice)).thenReturn(
|
||||
BluetoothA2dp.OPTIONAL_CODECS_PREF_ENABLED);
|
||||
@@ -121,7 +136,8 @@ public class BluetoothCodecDialogPreferenceControllerTest {
|
||||
public void writeConfigurationValues_checkCodec() {
|
||||
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC, mCodecConfigAPTX,
|
||||
mCodecConfigAPTXHD, mCodecConfigLDAC, mCodecConfigAAC, mCodecConfigSBC};
|
||||
mCodecStatus = new BluetoothCodecStatus(mCodecConfigSBC, null, mCodecConfigs);
|
||||
mCodecStatus = new BluetoothCodecStatus(mCodecConfigSBC, null,
|
||||
Arrays.asList(mCodecConfigs));
|
||||
when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus);
|
||||
mController.onBluetoothServiceConnected(mBluetoothA2dp);
|
||||
|
||||
@@ -148,7 +164,8 @@ public class BluetoothCodecDialogPreferenceControllerTest {
|
||||
public void writeConfigurationValues_resetHighestConfig() {
|
||||
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC, mCodecConfigAPTX,
|
||||
mCodecConfigAPTXHD, mCodecConfigLDAC, mCodecConfigAAC, mCodecConfigSBC};
|
||||
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
|
||||
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null,
|
||||
Arrays.asList(mCodecConfigs));
|
||||
when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus);
|
||||
mController.onBluetoothServiceConnected(mBluetoothA2dp);
|
||||
mController.writeConfigurationValues(2);
|
||||
@@ -178,7 +195,7 @@ public class BluetoothCodecDialogPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void onHDAudioEnabled_optionalCodecEnabled_setsCodecTypeAsAAC() {
|
||||
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
|
||||
List<BluetoothCodecConfig> mCodecConfigs = Arrays.asList(mCodecConfigAAC, mCodecConfigSBC);
|
||||
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC,
|
||||
/* codecsLocalCapabilities= */ null,
|
||||
mCodecConfigs);
|
||||
@@ -194,7 +211,7 @@ public class BluetoothCodecDialogPreferenceControllerTest {
|
||||
}
|
||||
@Test
|
||||
public void onHDAudioEnabled_optionalCodecDisabled_setsCodecTypeAsSBC() {
|
||||
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
|
||||
List<BluetoothCodecConfig> mCodecConfigs = Arrays.asList(mCodecConfigAAC, mCodecConfigSBC);
|
||||
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC,
|
||||
/* codecsLocalCapabilities= */ null,
|
||||
mCodecConfigs);
|
||||
|
@@ -43,6 +43,8 @@ import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class BluetoothQualityDialogPreferenceControllerTest {
|
||||
|
||||
@@ -77,18 +79,16 @@ public class BluetoothQualityDialogPreferenceControllerTest {
|
||||
mPreference = new BluetoothQualityDialogPreference(mContext);
|
||||
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
||||
mController.displayPreference(mScreen);
|
||||
mCodecConfigAAC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC,
|
||||
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
|
||||
BluetoothCodecConfig.SAMPLE_RATE_48000 | BluetoothCodecConfig.SAMPLE_RATE_88200,
|
||||
BluetoothCodecConfig.BITS_PER_SAMPLE_NONE,
|
||||
BluetoothCodecConfig.CHANNEL_MODE_NONE,
|
||||
0, 0, 0, 0);
|
||||
mCodecConfigLDAC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC,
|
||||
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
|
||||
BluetoothCodecConfig.SAMPLE_RATE_96000,
|
||||
BluetoothCodecConfig.BITS_PER_SAMPLE_NONE,
|
||||
BluetoothCodecConfig.CHANNEL_MODE_NONE,
|
||||
1001, 0, 0, 0);
|
||||
mCodecConfigAAC = new BluetoothCodecConfig.Builder()
|
||||
.setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC)
|
||||
.setSampleRate(BluetoothCodecConfig.SAMPLE_RATE_48000
|
||||
| BluetoothCodecConfig.SAMPLE_RATE_88200)
|
||||
.build();
|
||||
mCodecConfigLDAC = new BluetoothCodecConfig.Builder()
|
||||
.setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC)
|
||||
.setSampleRate(BluetoothCodecConfig.SAMPLE_RATE_96000)
|
||||
.setCodecSpecific1(1001)
|
||||
.build();
|
||||
when(mBluetoothA2dp.getActiveDevice()).thenReturn(mActiveDevice);
|
||||
}
|
||||
|
||||
@@ -116,7 +116,8 @@ public class BluetoothQualityDialogPreferenceControllerTest {
|
||||
@Test
|
||||
public void updateState_codeTypeIsLDAC_enablePreference() {
|
||||
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigLDAC};
|
||||
mCodecStatus = new BluetoothCodecStatus(mCodecConfigLDAC, null, mCodecConfigs);
|
||||
mCodecStatus = new BluetoothCodecStatus(mCodecConfigLDAC, null,
|
||||
Arrays.asList(mCodecConfigs));
|
||||
when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus);
|
||||
mController.onBluetoothServiceConnected(mBluetoothA2dp);
|
||||
mController.updateState(mPreference);
|
||||
@@ -127,7 +128,8 @@ public class BluetoothQualityDialogPreferenceControllerTest {
|
||||
@Test
|
||||
public void updateState_codeTypeAAC_disablePreference() {
|
||||
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigLDAC};
|
||||
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
|
||||
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null,
|
||||
Arrays.asList(mCodecConfigs));
|
||||
when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus);
|
||||
mController.onBluetoothServiceConnected(mBluetoothA2dp);
|
||||
mController.updateState(mPreference);
|
||||
|
@@ -44,6 +44,7 @@ import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@@ -81,26 +82,26 @@ public class BluetoothSampleRateDialogPreferenceControllerTest {
|
||||
mPreference = new BluetoothSampleRateDialogPreference(mContext);
|
||||
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
||||
mController.displayPreference(mScreen);
|
||||
mCodecConfigAAC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC,
|
||||
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
|
||||
BluetoothCodecConfig.SAMPLE_RATE_48000 | BluetoothCodecConfig.SAMPLE_RATE_88200,
|
||||
BluetoothCodecConfig.BITS_PER_SAMPLE_NONE,
|
||||
BluetoothCodecConfig.CHANNEL_MODE_NONE,
|
||||
0, 0, 0, 0);
|
||||
mCodecConfigSBC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
|
||||
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
|
||||
BluetoothCodecConfig.SAMPLE_RATE_96000,
|
||||
BluetoothCodecConfig.BITS_PER_SAMPLE_NONE,
|
||||
BluetoothCodecConfig.CHANNEL_MODE_NONE,
|
||||
0, 0, 0, 0);
|
||||
mCodecConfigAAC = new BluetoothCodecConfig.Builder()
|
||||
.setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC)
|
||||
.setSampleRate(BluetoothCodecConfig.SAMPLE_RATE_48000
|
||||
| BluetoothCodecConfig.SAMPLE_RATE_88200)
|
||||
.build();
|
||||
mCodecConfigSBC = new BluetoothCodecConfig.Builder()
|
||||
.setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC)
|
||||
.setSampleRate(BluetoothCodecConfig.SAMPLE_RATE_96000)
|
||||
.build();
|
||||
when(mBluetoothA2dp.getActiveDevice()).thenReturn(mActiveDevice);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void writeConfigurationValues_selectDefault_setHighest() {
|
||||
mCodecConfigSBC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC);
|
||||
BluetoothCodecConfig mCodecConfigSBC = new BluetoothCodecConfig.Builder()
|
||||
.setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC)
|
||||
.build();
|
||||
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
|
||||
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
|
||||
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null,
|
||||
Arrays.asList(mCodecConfigs));
|
||||
when(mBluetoothA2dp.getCodecStatus(
|
||||
mActiveDevice)).thenReturn(mCodecStatus);
|
||||
mController.onBluetoothServiceConnected(mBluetoothA2dp);
|
||||
@@ -132,7 +133,10 @@ public class BluetoothSampleRateDialogPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void getSelectableIndex_verifyList() {
|
||||
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
|
||||
List<BluetoothCodecConfig> mCodecConfigs = new ArrayList() {{
|
||||
add(mCodecConfigAAC);
|
||||
add(mCodecConfigSBC);
|
||||
}};
|
||||
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
|
||||
when(mBluetoothA2dp.getCodecStatus(
|
||||
mActiveDevice)).thenReturn(mCodecStatus);
|
||||
|
Reference in New Issue
Block a user