Allow ExoPlayerTestRunner to end when Player.stop() is called.

In this case the playback state transitions to IDLE, which isn't
caught so far. (This code is equivalent to the one in ExoHostedTest.java)

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=167980981
This commit is contained in:
tonihei 2017-09-08 04:05:38 -07:00 committed by Oliver Woodman
parent 7c3fe19d3f
commit b2627d63fd

View File

@ -212,6 +212,7 @@ public final class ExoPlayerTestRunner implements Player.EventListener {
private Exception exception;
private TrackGroupArray trackGroups;
private int positionDiscontinuityCount;
private boolean playerWasPrepared;
private ExoPlayerTestRunner(PlayerFactory playerFactory, MediaSource mediaSource,
RenderersFactory renderersFactory, MappingTrackSelector trackSelector,
@ -350,7 +351,9 @@ public final class ExoPlayerTestRunner implements Player.EventListener {
if (periodIndices.isEmpty() && playbackState == Player.STATE_READY) {
periodIndices.add(player.getCurrentPeriodIndex());
}
if (playbackState == Player.STATE_ENDED) {
playerWasPrepared |= playbackState != Player.STATE_IDLE;
if (playbackState == Player.STATE_ENDED
|| (playbackState == Player.STATE_IDLE && playerWasPrepared)) {
endedCountDownLatch.countDown();
}
}