From b2627d63fdb0215f65096ef2fe0c8e47c341e4a2 Mon Sep 17 00:00:00 2001 From: tonihei Date: Fri, 8 Sep 2017 04:05:38 -0700 Subject: [PATCH] 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 --- .../android/exoplayer2/testutil/ExoPlayerTestRunner.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/testutils/src/main/java/com/google/android/exoplayer2/testutil/ExoPlayerTestRunner.java b/testutils/src/main/java/com/google/android/exoplayer2/testutil/ExoPlayerTestRunner.java index 2b5ea11d94..f65cb39bfc 100644 --- a/testutils/src/main/java/com/google/android/exoplayer2/testutil/ExoPlayerTestRunner.java +++ b/testutils/src/main/java/com/google/android/exoplayer2/testutil/ExoPlayerTestRunner.java @@ -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(); } }