From 7350981ef95279c0d6b94c6045e68cd8b42e2cc1 Mon Sep 17 00:00:00 2001 From: tonihei Date: Fri, 17 Apr 2020 15:23:49 +0100 Subject: [PATCH] Use higher level interface for method parameters where possible. This makes it easier to use the helper methods because the player doesn't have to be assigned to a SimpleExoPlayer in all cases. PiperOrigin-RevId: 307039126 --- .../android/exoplayer2/ExoPlayerTest.java | 2 +- .../exoplayer2/testutil/TestExoPlayer.java | 20 +++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/library/core/src/test/java/com/google/android/exoplayer2/ExoPlayerTest.java b/library/core/src/test/java/com/google/android/exoplayer2/ExoPlayerTest.java index eb75c42ef0..b170a71f9b 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/ExoPlayerTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/ExoPlayerTest.java @@ -3595,7 +3595,7 @@ public final class ExoPlayerTest { } }; - SimpleExoPlayer player = + ExoPlayer player = new TestExoPlayer.Builder(context) .setRenderers(rendererWaitingForData) .setLoadControl(loadControlWithMaxBufferUs) diff --git a/testutils/src/main/java/com/google/android/exoplayer2/testutil/TestExoPlayer.java b/testutils/src/main/java/com/google/android/exoplayer2/testutil/TestExoPlayer.java index 4b4d8892ba..9d431b7f67 100644 --- a/testutils/src/main/java/com/google/android/exoplayer2/testutil/TestExoPlayer.java +++ b/testutils/src/main/java/com/google/android/exoplayer2/testutil/TestExoPlayer.java @@ -23,6 +23,7 @@ import android.os.Looper; import androidx.annotation.Nullable; import com.google.android.exoplayer2.DefaultLoadControl; import com.google.android.exoplayer2.ExoPlaybackException; +import com.google.android.exoplayer2.ExoPlayer; import com.google.android.exoplayer2.LoadControl; import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.Renderer; @@ -307,8 +308,7 @@ public class TestExoPlayer { * Run tasks of the main {@link Looper} until the {@code player}'s state reaches the {@code * expectedState}. */ - public static void runUntilPlaybackState( - SimpleExoPlayer player, @Player.State int expectedState) { + public static void runUntilPlaybackState(Player player, @Player.State int expectedState) { verifyMainTestThread(player); if (player.getPlaybackState() == expectedState) { return; @@ -334,7 +334,7 @@ public class TestExoPlayer { * Player.EventListener#onPlaybackSpeedChanged} callback with that matches {@code * expectedPlayWhenReady}. */ - public static void runUntilPlayWhenReady(SimpleExoPlayer player, boolean expectedPlayWhenReady) { + public static void runUntilPlayWhenReady(Player player, boolean expectedPlayWhenReady) { verifyMainTestThread(player); if (player.getPlayWhenReady() == expectedPlayWhenReady) { return; @@ -359,13 +359,13 @@ public class TestExoPlayer { * Run tasks of the main {@link Looper} until the {@code player} calls the {@link * Player.EventListener#onTimelineChanged} callback. * - * @param player The {@link SimpleExoPlayer}. + * @param player The {@link Player}. * @param expectedTimeline A specific {@link Timeline} to wait for, or null if any timeline is * accepted. * @return The received {@link Timeline}. */ public static Timeline runUntilTimelineChanged( - SimpleExoPlayer player, @Nullable Timeline expectedTimeline) { + Player player, @Nullable Timeline expectedTimeline) { verifyMainTestThread(player); if (expectedTimeline != null && expectedTimeline.equals(player.getCurrentTimeline())) { @@ -394,7 +394,7 @@ public class TestExoPlayer { * Player.DiscontinuityReason}. */ public static void runUntilPositionDiscontinuity( - SimpleExoPlayer player, @Player.DiscontinuityReason int expectedReason) { + Player player, @Player.DiscontinuityReason int expectedReason) { AtomicBoolean receivedCallback = new AtomicBoolean(false); Player.EventListener listener = new Player.EventListener() { @@ -414,10 +414,10 @@ public class TestExoPlayer { * Run tasks of the main {@link Looper} until the {@code player} calls the {@link * Player.EventListener#onPlayerError} callback. * - * @param player The {@link SimpleExoPlayer}. + * @param player The {@link Player}. * @return The raised error. */ - public static ExoPlaybackException runUntilError(SimpleExoPlayer player) { + public static ExoPlaybackException runUntilError(Player player) { verifyMainTestThread(player); AtomicReference receivedError = new AtomicReference<>(); Player.EventListener listener = @@ -456,7 +456,7 @@ public class TestExoPlayer { * Runs tasks of the main {@link Looper} until the {@code player} handled all previously issued * commands completely on the internal playback thread. */ - public static void runUntilPendingCommandsAreFullyHandled(SimpleExoPlayer player) { + public static void runUntilPendingCommandsAreFullyHandled(ExoPlayer player) { verifyMainTestThread(player); // Send message to player that will arrive after all other pending commands. Thus, the message // execution on the app thread will also happen after all other pending command @@ -484,7 +484,7 @@ public class TestExoPlayer { } } - private static void verifyMainTestThread(SimpleExoPlayer player) { + private static void verifyMainTestThread(Player player) { if (Looper.myLooper() != Looper.getMainLooper() || player.getApplicationLooper() != Looper.getMainLooper()) { throw new IllegalStateException();