Merge "Fix A2dpProfileTest#getLabelDeviceConnectedWithHighQualityCodec" into oc-mr1-dev

am: ae1dd84bf0

Change-Id: Ifa7eea6473cc68ee71b8a6b7d3884012868407d0
This commit is contained in:
Justin Klaassen
2017-09-05 19:42:19 +00:00
committed by android-build-merger
2 changed files with 12 additions and 2 deletions

View File

@@ -21,5 +21,6 @@ package android.bluetooth;
*/
public class BluetoothCodecConfig {
public boolean isMandatoryCodec() { return true; }
public String getCodecName() { return null;}
public String getCodecName() { return null; }
public int getCodecType() { return -1; }
}

View File

@@ -21,6 +21,7 @@ import android.bluetooth.BluetoothCodecStatus;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothProfile;
import android.content.Context;
import android.content.res.Resources;
import com.android.settingslib.R;
import com.android.settingslib.TestConfig;
@@ -133,6 +134,8 @@ public class A2dpProfileTest {
// Strings to use in fake resource lookups.
private static String KNOWN_CODEC_LABEL = "Use high quality audio: %1$s";
private static String UNKNOWN_CODEC_LABEL = "Use high quality audio";
private static String[] CODEC_NAMES =
new String[] { "Default", "SBC", "AAC", "aptX", "aptX HD", "LDAC" };
/**
* Helper for setting up several tests of getHighQualityAudioOptionLabel
@@ -147,6 +150,11 @@ public class A2dpProfileTest {
when(mContext.getString(eq(R.string.bluetooth_profile_a2dp_high_quality_unknown_codec)))
.thenReturn(UNKNOWN_CODEC_LABEL);
final Resources res = mock(Resources.class);
when(mContext.getResources()).thenReturn(res);
when(res.getStringArray(eq(R.array.bluetooth_a2dp_codec_titles)))
.thenReturn(CODEC_NAMES);
// Most tests want to simulate optional codecs being supported by the device, so do that
// by default here.
when(mBluetoothA2dpWrapper.supportsOptionalCodecs(any())).thenReturn(
@@ -196,7 +204,8 @@ public class A2dpProfileTest {
when(status.getCodecsSelectableCapabilities()).thenReturn(configs);
when(config.isMandatoryCodec()).thenReturn(false);
when(config.getCodecName()).thenReturn("PiedPiper");
when(config.getCodecType()).thenReturn(4);
when(config.getCodecName()).thenReturn("LDAC");
assertThat(mProfile.getHighQualityAudioOptionLabel(mDevice)).isEqualTo(
String.format(KNOWN_CODEC_LABEL, config.getCodecName()));
}