@Test
public void selectAudioTracks_withinCapabilities_andSameLanguage_selectsHigherBitrate()
    throws Exception {

  Format lowerBitrateFormat =
      Format.createAudioSampleFormat(
          "audioFormat",
          MimeTypes.AUDIO_AAC,
          /* codecs= */ null,
          /* bitrate= */ 15000,
          /* maxInputSize= */ Format.NO_VALUE,
          /* channelCount= */ 2,
          /* sampleRate= */ 44100,
          /* initializationData= */ null,
          /* drmInitData= */ null,
          /* selectionFlags= */ 0,
          /* language= */ "hi");
  Format higherBitrateFormat =
      Format.createAudioSampleFormat(
          "audioFormat",
          MimeTypes.AUDIO_AAC,
          /* codecs= */ null,
          /* bitrate= */ 30000,
          /* maxInputSize= */ Format.NO_VALUE,
          /* channelCount= */ 2,
          /* sampleRate= */ 44100,
          /* initializationData= */ null,
          /* drmInitData= */ null,
          /* selectionFlags= */ 0,
          /* language= */ "hi");
  TrackGroupArray trackGroups = wrapFormats(lowerBitrateFormat, higherBitrateFormat);
  TrackSelectorResult result =
      trackSelector.selectTracks(
          new RendererCapabilities[] {ALL_AUDIO_FORMAT_SUPPORTED_RENDERER_CAPABILITIES},
          trackGroups,
          periodId,
          TIMELINE);
  assertFixedSelection(result.selections.get(0), trackGroups, higherBitrateFormat);
}