use of com.google.android.exoplayer2.Player.STATE_ENDED in project ExoPlayer by google.
the class ExoPlayerTest method onPlayerErrorChanged_isNotifiedForNullError.
@Test
public void onPlayerErrorChanged_isNotifiedForNullError() throws Exception {
ExoPlayer player = new TestExoPlayerBuilder(context).build();
player.addMediaSource(new FakeMediaSource(/* timeline= */
null) {
@Override
public void maybeThrowSourceInfoRefreshError() throws IOException {
throw new IOException();
}
});
Player.Listener mockListener = mock(Player.Listener.class);
player.addListener(mockListener);
player.prepare();
player.play();
ExoPlaybackException error = TestPlayerRunHelper.runUntilError(player);
// The media source fails preparation, so we expect both methods to be called.
verify(mockListener).onPlayerErrorChanged(error);
verify(mockListener).onPlayerError(error);
reset(mockListener);
player.setMediaSource(new FakeMediaSource());
player.prepare();
player.play();
TestPlayerRunHelper.runUntilPlaybackState(player, STATE_ENDED);
// Now the player, which had a playback error, was re-prepared causing the error to be cleared.
// We expect the change to null to be notified, but not onPlayerError.
verify(mockListener).onPlayerErrorChanged(ArgumentMatchers.isNull());
verify(mockListener, never()).onPlayerError(any());
}
Aggregations