use of org.robolectric.shadows.ShadowAudioManager in project ExoPlayer by google.
the class ExoPlayerTest method audioFocusDenied.
@Test
public void audioFocusDenied() throws Exception {
ShadowAudioManager shadowAudioManager = shadowOf(context.getSystemService(AudioManager.class));
shadowAudioManager.setNextFocusRequestResponse(AudioManager.AUDIOFOCUS_REQUEST_FAILED);
PlayerStateGrabber playerStateGrabber = new PlayerStateGrabber();
ActionSchedule actionSchedule = new ActionSchedule.Builder(TAG).setAudioAttributes(AudioAttributes.DEFAULT, /* handleAudioFocus= */
true).play().waitForPlaybackState(Player.STATE_READY).executeRunnable(playerStateGrabber).build();
AtomicBoolean seenPlaybackSuppression = new AtomicBoolean();
Player.Listener listener = new Player.Listener() {
@Override
public void onPlaybackSuppressionReasonChanged(@Player.PlaybackSuppressionReason int playbackSuppressionReason) {
seenPlaybackSuppression.set(true);
}
};
new ExoPlayerTestRunner.Builder(context).setActionSchedule(actionSchedule).setPlayerListener(listener).build().start().blockUntilActionScheduleFinished(TIMEOUT_MS);
assertThat(playerStateGrabber.playWhenReady).isFalse();
assertThat(seenPlaybackSuppression.get()).isFalse();
}
Aggregations