@Test
public void setAudioAttributes_withUsageMedia_usesAudioFocusGain() {

  // Ensure setting media type audio attributes requests AUDIOFOCUS_GAIN.
  AudioAttributes media = new AudioAttributes.Builder().setUsage(C.USAGE_MEDIA).build();
  Shadows.shadowOf(audioManager)
      .setNextFocusRequestResponse(AudioManager.AUDIOFOCUS_REQUEST_GRANTED);
  assertThat(
          audioFocusManager.setAudioAttributes(
              media, /* playWhenReady= */ true, Player.STATE_READY))
      .isEqualTo(PLAYER_COMMAND_PLAY_WHEN_READY);
  ShadowAudioManager.AudioFocusRequest request =
      Shadows.shadowOf(audioManager).getLastAudioFocusRequest();
  assertThat(getAudioFocusGainFromRequest(request)).isEqualTo(AudioManager.AUDIOFOCUS_GAIN);
}