Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ae1dd84b authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

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

parents 3cd17ebd 9acc02e2
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -22,4 +22,5 @@ package android.bluetooth;
public class BluetoothCodecConfig {
    public boolean isMandatoryCodec() { return true; }
    public String getCodecName() { return null; }
    public int getCodecType() { return -1; }
}
+10 −1
Original line number Diff line number Diff line
@@ -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()));
    }