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 8c02bb507e..e3caafb66d 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 @@ -94,7 +94,6 @@ import com.google.android.exoplayer2.testutil.Action; import com.google.android.exoplayer2.testutil.ActionSchedule; import com.google.android.exoplayer2.testutil.ActionSchedule.PlayerRunnable; import com.google.android.exoplayer2.testutil.ActionSchedule.PlayerTarget; -import com.google.android.exoplayer2.testutil.AutoAdvancingFakeClock; import com.google.android.exoplayer2.testutil.ExoPlayerTestRunner; import com.google.android.exoplayer2.testutil.FakeAdaptiveDataSet; import com.google.android.exoplayer2.testutil.FakeAdaptiveMediaSource; @@ -3030,7 +3029,7 @@ public final class ExoPlayerTest { MediaSource mediaSource = new ClippingMediaSource( new FakeMediaSource(), startPositionUs, startPositionUs + expectedDurationUs); - Clock clock = new AutoAdvancingFakeClock(); + Clock clock = new FakeClock(/* isAutoAdvancing= */ true); AtomicReference playerReference = new AtomicReference<>(); AtomicLong positionAtDiscontinuityMs = new AtomicLong(C.TIME_UNSET); AtomicLong clockAtStartMs = new AtomicLong(C.TIME_UNSET); @@ -8782,7 +8781,8 @@ public final class ExoPlayerTest { long nowUnixTimeMs = windowStartUnixTimeMs + 20_000; ExoPlayer player = new TestExoPlayerBuilder(context) - .setClock(new AutoAdvancingFakeClock(/* initialTimeMs= */ nowUnixTimeMs)) + .setClock( + new FakeClock(/* initialTimeMs= */ nowUnixTimeMs, /* isAutoAdvancing= */ true)) .build(); Timeline timeline = new FakeTimeline( @@ -8826,7 +8826,8 @@ public final class ExoPlayerTest { long nowUnixTimeMs = windowStartUnixTimeMs + 20_000; ExoPlayer player = new TestExoPlayerBuilder(context) - .setClock(new AutoAdvancingFakeClock(/* initialTimeMs= */ nowUnixTimeMs)) + .setClock( + new FakeClock(/* initialTimeMs= */ nowUnixTimeMs, /* isAutoAdvancing= */ true)) .build(); Timeline timeline = new FakeTimeline( @@ -8866,7 +8867,8 @@ public final class ExoPlayerTest { long nowUnixTimeMs = windowStartUnixTimeMs + 20_000; ExoPlayer player = new TestExoPlayerBuilder(context) - .setClock(new AutoAdvancingFakeClock(/* initialTimeMs= */ nowUnixTimeMs)) + .setClock( + new FakeClock(/* initialTimeMs= */ nowUnixTimeMs, /* isAutoAdvancing= */ true)) .build(); Timeline timeline = new FakeTimeline( @@ -8908,7 +8910,8 @@ public final class ExoPlayerTest { long nowUnixTimeMs = windowStartUnixTimeMs + 20_000; ExoPlayer player = new TestExoPlayerBuilder(context) - .setClock(new AutoAdvancingFakeClock(/* initialTimeMs= */ nowUnixTimeMs)) + .setClock( + new FakeClock(/* initialTimeMs= */ nowUnixTimeMs, /* isAutoAdvancing= */ true)) .build(); Timeline initialTimeline = new FakeTimeline( @@ -8981,7 +8984,8 @@ public final class ExoPlayerTest { long nowUnixTimeMs = windowStartUnixTimeMs + 20_000; ExoPlayer player = new TestExoPlayerBuilder(context) - .setClock(new AutoAdvancingFakeClock(/* initialTimeMs= */ nowUnixTimeMs)) + .setClock( + new FakeClock(/* initialTimeMs= */ nowUnixTimeMs, /* isAutoAdvancing= */ true)) .build(); Timeline timeline = new FakeTimeline( @@ -9028,7 +9032,8 @@ public final class ExoPlayerTest { long nowUnixTimeMs = windowStartUnixTimeMs + 10_000; ExoPlayer player = new TestExoPlayerBuilder(context) - .setClock(new AutoAdvancingFakeClock(/* initialTimeMs= */ nowUnixTimeMs)) + .setClock( + new FakeClock(/* initialTimeMs= */ nowUnixTimeMs, /* isAutoAdvancing= */ true)) .build(); Timeline nonLiveTimeline = new FakeTimeline(); Timeline liveTimeline = @@ -9068,7 +9073,8 @@ public final class ExoPlayerTest { long nowUnixTimeMs = windowStartUnixTimeMs + 20_000; ExoPlayer player = new TestExoPlayerBuilder(context) - .setClock(new AutoAdvancingFakeClock(/* initialTimeMs= */ nowUnixTimeMs)) + .setClock( + new FakeClock(/* initialTimeMs= */ nowUnixTimeMs, /* isAutoAdvancing= */ true)) .build(); Timeline liveTimeline1 = new FakeTimeline( @@ -9125,7 +9131,8 @@ public final class ExoPlayerTest { long nowUnixTimeMs = windowStartUnixTimeMs + 20_000; ExoPlayer player = new TestExoPlayerBuilder(context) - .setClock(new AutoAdvancingFakeClock(/* initialTimeMs= */ nowUnixTimeMs)) + .setClock( + new FakeClock(/* initialTimeMs= */ nowUnixTimeMs, /* isAutoAdvancing= */ true)) .build(); Timeline liveTimeline1 = new FakeTimeline( @@ -9177,7 +9184,8 @@ public final class ExoPlayerTest { @Test public void targetLiveOffsetInMedia_unknownWindowStartTime_doesNotAdjustLiveOffset() throws Exception { - FakeClock fakeClock = new AutoAdvancingFakeClock(/* initialTimeMs= */ 987_654_321L); + FakeClock fakeClock = + new FakeClock(/* initialTimeMs= */ 987_654_321L, /* isAutoAdvancing= */ true); ExoPlayer player = new TestExoPlayerBuilder(context).setClock(fakeClock).build(); MediaItem mediaItem = new MediaItem.Builder().setUri(Uri.EMPTY).setLiveTargetOffsetMs(4_000).build(); @@ -9216,7 +9224,8 @@ public final class ExoPlayerTest { long nowUnixTimeMs = windowStartUnixTimeMs + 20_000; ExoPlayer player = new TestExoPlayerBuilder(context) - .setClock(new AutoAdvancingFakeClock(/* initialTimeMs= */ nowUnixTimeMs)) + .setClock( + new FakeClock(/* initialTimeMs= */ nowUnixTimeMs, /* isAutoAdvancing= */ true)) .build(); Timeline liveTimelineWithoutTargetLiveOffset = new FakeTimeline( diff --git a/library/core/src/test/java/com/google/android/exoplayer2/MetadataRetrieverTest.java b/library/core/src/test/java/com/google/android/exoplayer2/MetadataRetrieverTest.java index 154ec0df1b..be110e2dc5 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/MetadataRetrieverTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/MetadataRetrieverTest.java @@ -30,7 +30,7 @@ import com.google.android.exoplayer2.metadata.mp4.MotionPhotoMetadata; import com.google.android.exoplayer2.metadata.mp4.SlowMotionData; import com.google.android.exoplayer2.metadata.mp4.SmtaMetadataEntry; import com.google.android.exoplayer2.source.TrackGroupArray; -import com.google.android.exoplayer2.testutil.AutoAdvancingFakeClock; +import com.google.android.exoplayer2.testutil.FakeClock; import com.google.android.exoplayer2.util.MimeTypes; import com.google.common.util.concurrent.ListenableFuture; import java.util.ArrayList; @@ -49,12 +49,12 @@ public class MetadataRetrieverTest { private static final long TEST_TIMEOUT_SEC = 10; private Context context; - private AutoAdvancingFakeClock clock; + private FakeClock clock; @Before public void setUp() throws Exception { context = ApplicationProvider.getApplicationContext(); - clock = new AutoAdvancingFakeClock(); + clock = new FakeClock(/* isAutoAdvancing= */ true); } @Test diff --git a/library/core/src/test/java/com/google/android/exoplayer2/SimpleExoPlayerTest.java b/library/core/src/test/java/com/google/android/exoplayer2/SimpleExoPlayerTest.java index 6636134f04..64841475e4 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/SimpleExoPlayerTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/SimpleExoPlayerTest.java @@ -29,8 +29,8 @@ import static org.mockito.Mockito.verify; import androidx.test.core.app.ApplicationProvider; import androidx.test.ext.junit.runners.AndroidJUnit4; import com.google.android.exoplayer2.analytics.AnalyticsListener; -import com.google.android.exoplayer2.testutil.AutoAdvancingFakeClock; import com.google.android.exoplayer2.testutil.ExoPlayerTestRunner; +import com.google.android.exoplayer2.testutil.FakeClock; import com.google.android.exoplayer2.testutil.FakeMediaSource; import com.google.android.exoplayer2.testutil.FakeTimeline; import com.google.android.exoplayer2.testutil.FakeVideoRenderer; @@ -67,7 +67,7 @@ public class SimpleExoPlayerTest { ApplicationProvider.getApplicationContext(), (handler, videoListener, audioListener, textOutput, metadataOutput) -> new Renderer[] {new FakeVideoRenderer(handler, videoListener)}) - .setClock(new AutoAdvancingFakeClock()) + .setClock(new FakeClock(/* isAutoAdvancing= */ true)) .build(); AnalyticsListener listener = mock(AnalyticsListener.class); player.addAnalyticsListener(listener); @@ -92,7 +92,7 @@ public class SimpleExoPlayerTest { ApplicationProvider.getApplicationContext(), (handler, videoListener, audioListener, textOutput, metadataOutput) -> new Renderer[] {new FakeVideoRenderer(handler, videoListener)}) - .setClock(new AutoAdvancingFakeClock()) + .setClock(new FakeClock(/* isAutoAdvancing= */ true)) .build(); Player.Listener listener = mock(Player.Listener.class); player.addListener(listener); diff --git a/library/core/src/test/java/com/google/android/exoplayer2/e2etest/EndToEndGaplessTest.java b/library/core/src/test/java/com/google/android/exoplayer2/e2etest/EndToEndGaplessTest.java index 9cd334ac0f..d00d58c740 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/e2etest/EndToEndGaplessTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/e2etest/EndToEndGaplessTest.java @@ -29,7 +29,7 @@ import com.google.android.exoplayer2.SimpleExoPlayer; import com.google.android.exoplayer2.mediacodec.MediaCodecUtil; import com.google.android.exoplayer2.robolectric.RandomizedMp3Decoder; import com.google.android.exoplayer2.robolectric.TestPlayerRunHelper; -import com.google.android.exoplayer2.testutil.AutoAdvancingFakeClock; +import com.google.android.exoplayer2.testutil.FakeClock; import com.google.android.exoplayer2.util.Assertions; import com.google.common.collect.ImmutableList; import com.google.common.primitives.Bytes; @@ -90,7 +90,7 @@ public class EndToEndGaplessTest { public void testPlayback_twoIdenticalMp3Files() throws Exception { SimpleExoPlayer player = new SimpleExoPlayer.Builder(ApplicationProvider.getApplicationContext()) - .setClock(new AutoAdvancingFakeClock()) + .setClock(new FakeClock(/* isAutoAdvancing= */ true)) .build(); player.setMediaItems( diff --git a/library/core/src/test/java/com/google/android/exoplayer2/e2etest/FlacPlaybackTest.java b/library/core/src/test/java/com/google/android/exoplayer2/e2etest/FlacPlaybackTest.java index cb2c945ec3..c98bd52da7 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/e2etest/FlacPlaybackTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/e2etest/FlacPlaybackTest.java @@ -23,9 +23,9 @@ import com.google.android.exoplayer2.SimpleExoPlayer; import com.google.android.exoplayer2.robolectric.PlaybackOutput; import com.google.android.exoplayer2.robolectric.ShadowMediaCodecConfig; import com.google.android.exoplayer2.robolectric.TestPlayerRunHelper; -import com.google.android.exoplayer2.testutil.AutoAdvancingFakeClock; import com.google.android.exoplayer2.testutil.CapturingRenderersFactory; import com.google.android.exoplayer2.testutil.DumpFileAsserts; +import com.google.android.exoplayer2.testutil.FakeClock; import com.google.common.collect.ImmutableList; import org.junit.Rule; import org.junit.Test; @@ -68,7 +68,7 @@ public class FlacPlaybackTest { new CapturingRenderersFactory(applicationContext); SimpleExoPlayer player = new SimpleExoPlayer.Builder(applicationContext, capturingRenderersFactory) - .setClock(new AutoAdvancingFakeClock()) + .setClock(new FakeClock(/* isAutoAdvancing= */ true)) .build(); PlaybackOutput playbackOutput = PlaybackOutput.register(player, capturingRenderersFactory); diff --git a/library/core/src/test/java/com/google/android/exoplayer2/e2etest/FlvPlaybackTest.java b/library/core/src/test/java/com/google/android/exoplayer2/e2etest/FlvPlaybackTest.java index 598aae8249..39055b573b 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/e2etest/FlvPlaybackTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/e2etest/FlvPlaybackTest.java @@ -25,9 +25,9 @@ import com.google.android.exoplayer2.SimpleExoPlayer; import com.google.android.exoplayer2.robolectric.PlaybackOutput; import com.google.android.exoplayer2.robolectric.ShadowMediaCodecConfig; import com.google.android.exoplayer2.robolectric.TestPlayerRunHelper; -import com.google.android.exoplayer2.testutil.AutoAdvancingFakeClock; import com.google.android.exoplayer2.testutil.CapturingRenderersFactory; import com.google.android.exoplayer2.testutil.DumpFileAsserts; +import com.google.android.exoplayer2.testutil.FakeClock; import com.google.common.collect.ImmutableList; import org.junit.Rule; import org.junit.Test; @@ -59,7 +59,7 @@ public final class FlvPlaybackTest { new CapturingRenderersFactory(applicationContext); SimpleExoPlayer player = new SimpleExoPlayer.Builder(applicationContext, capturingRenderersFactory) - .setClock(new AutoAdvancingFakeClock()) + .setClock(new FakeClock(/* isAutoAdvancing= */ true)) .build(); player.setVideoSurface(new Surface(new SurfaceTexture(/* texName= */ 1))); PlaybackOutput playbackOutput = PlaybackOutput.register(player, capturingRenderersFactory); diff --git a/library/core/src/test/java/com/google/android/exoplayer2/e2etest/MkaPlaybackTest.java b/library/core/src/test/java/com/google/android/exoplayer2/e2etest/MkaPlaybackTest.java index 78ff4299d1..fae8974c9d 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/e2etest/MkaPlaybackTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/e2etest/MkaPlaybackTest.java @@ -23,9 +23,9 @@ import com.google.android.exoplayer2.SimpleExoPlayer; import com.google.android.exoplayer2.robolectric.PlaybackOutput; import com.google.android.exoplayer2.robolectric.ShadowMediaCodecConfig; import com.google.android.exoplayer2.robolectric.TestPlayerRunHelper; -import com.google.android.exoplayer2.testutil.AutoAdvancingFakeClock; import com.google.android.exoplayer2.testutil.CapturingRenderersFactory; import com.google.android.exoplayer2.testutil.DumpFileAsserts; +import com.google.android.exoplayer2.testutil.FakeClock; import com.google.common.collect.ImmutableList; import org.junit.Rule; import org.junit.Test; @@ -61,7 +61,7 @@ public final class MkaPlaybackTest { new CapturingRenderersFactory(applicationContext); SimpleExoPlayer player = new SimpleExoPlayer.Builder(applicationContext, capturingRenderersFactory) - .setClock(new AutoAdvancingFakeClock()) + .setClock(new FakeClock(/* isAutoAdvancing= */ true)) .build(); PlaybackOutput playbackOutput = PlaybackOutput.register(player, capturingRenderersFactory); diff --git a/library/core/src/test/java/com/google/android/exoplayer2/e2etest/MkvPlaybackTest.java b/library/core/src/test/java/com/google/android/exoplayer2/e2etest/MkvPlaybackTest.java index 7aa9fff35d..5e96ad2497 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/e2etest/MkvPlaybackTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/e2etest/MkvPlaybackTest.java @@ -25,9 +25,9 @@ import com.google.android.exoplayer2.SimpleExoPlayer; import com.google.android.exoplayer2.robolectric.PlaybackOutput; import com.google.android.exoplayer2.robolectric.ShadowMediaCodecConfig; import com.google.android.exoplayer2.robolectric.TestPlayerRunHelper; -import com.google.android.exoplayer2.testutil.AutoAdvancingFakeClock; import com.google.android.exoplayer2.testutil.CapturingRenderersFactory; import com.google.android.exoplayer2.testutil.DumpFileAsserts; +import com.google.android.exoplayer2.testutil.FakeClock; import com.google.common.collect.ImmutableList; import org.junit.Rule; import org.junit.Test; @@ -65,7 +65,7 @@ public final class MkvPlaybackTest { new CapturingRenderersFactory(applicationContext); SimpleExoPlayer player = new SimpleExoPlayer.Builder(applicationContext, capturingRenderersFactory) - .setClock(new AutoAdvancingFakeClock()) + .setClock(new FakeClock(/* isAutoAdvancing= */ true)) .build(); player.setVideoSurface(new Surface(new SurfaceTexture(/* texName= */ 1))); PlaybackOutput playbackOutput = PlaybackOutput.register(player, capturingRenderersFactory); diff --git a/library/core/src/test/java/com/google/android/exoplayer2/e2etest/Mp3PlaybackTest.java b/library/core/src/test/java/com/google/android/exoplayer2/e2etest/Mp3PlaybackTest.java index 1b1b9a886b..6bd5f711fc 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/e2etest/Mp3PlaybackTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/e2etest/Mp3PlaybackTest.java @@ -23,9 +23,9 @@ import com.google.android.exoplayer2.SimpleExoPlayer; import com.google.android.exoplayer2.robolectric.PlaybackOutput; import com.google.android.exoplayer2.robolectric.ShadowMediaCodecConfig; import com.google.android.exoplayer2.robolectric.TestPlayerRunHelper; -import com.google.android.exoplayer2.testutil.AutoAdvancingFakeClock; import com.google.android.exoplayer2.testutil.CapturingRenderersFactory; import com.google.android.exoplayer2.testutil.DumpFileAsserts; +import com.google.android.exoplayer2.testutil.FakeClock; import com.google.common.collect.ImmutableList; import org.junit.Rule; import org.junit.Test; @@ -64,7 +64,7 @@ public final class Mp3PlaybackTest { new CapturingRenderersFactory(applicationContext); SimpleExoPlayer player = new SimpleExoPlayer.Builder(applicationContext, capturingRenderersFactory) - .setClock(new AutoAdvancingFakeClock()) + .setClock(new FakeClock(/* isAutoAdvancing= */ true)) .build(); PlaybackOutput playbackOutput = PlaybackOutput.register(player, capturingRenderersFactory); diff --git a/library/core/src/test/java/com/google/android/exoplayer2/e2etest/Mp4PlaybackTest.java b/library/core/src/test/java/com/google/android/exoplayer2/e2etest/Mp4PlaybackTest.java index 492276b659..32f9e3e171 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/e2etest/Mp4PlaybackTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/e2etest/Mp4PlaybackTest.java @@ -25,9 +25,9 @@ import com.google.android.exoplayer2.SimpleExoPlayer; import com.google.android.exoplayer2.robolectric.PlaybackOutput; import com.google.android.exoplayer2.robolectric.ShadowMediaCodecConfig; import com.google.android.exoplayer2.robolectric.TestPlayerRunHelper; -import com.google.android.exoplayer2.testutil.AutoAdvancingFakeClock; import com.google.android.exoplayer2.testutil.CapturingRenderersFactory; import com.google.android.exoplayer2.testutil.DumpFileAsserts; +import com.google.android.exoplayer2.testutil.FakeClock; import com.google.common.collect.ImmutableList; import org.junit.Rule; import org.junit.Test; @@ -81,7 +81,7 @@ public class Mp4PlaybackTest { CapturingRenderersFactory renderersFactory = new CapturingRenderersFactory(applicationContext); SimpleExoPlayer player = new SimpleExoPlayer.Builder(applicationContext, renderersFactory) - .setClock(new AutoAdvancingFakeClock()) + .setClock(new FakeClock(/* isAutoAdvancing= */ true)) .build(); player.setVideoSurface(new Surface(new SurfaceTexture(/* texName= */ 1))); diff --git a/library/core/src/test/java/com/google/android/exoplayer2/e2etest/OggPlaybackTest.java b/library/core/src/test/java/com/google/android/exoplayer2/e2etest/OggPlaybackTest.java index f95f5f0084..56d50da290 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/e2etest/OggPlaybackTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/e2etest/OggPlaybackTest.java @@ -23,9 +23,9 @@ import com.google.android.exoplayer2.SimpleExoPlayer; import com.google.android.exoplayer2.robolectric.PlaybackOutput; import com.google.android.exoplayer2.robolectric.ShadowMediaCodecConfig; import com.google.android.exoplayer2.robolectric.TestPlayerRunHelper; -import com.google.android.exoplayer2.testutil.AutoAdvancingFakeClock; import com.google.android.exoplayer2.testutil.CapturingRenderersFactory; import com.google.android.exoplayer2.testutil.DumpFileAsserts; +import com.google.android.exoplayer2.testutil.FakeClock; import com.google.common.collect.ImmutableList; import org.junit.Rule; import org.junit.Test; @@ -62,7 +62,7 @@ public final class OggPlaybackTest { new CapturingRenderersFactory(applicationContext); SimpleExoPlayer player = new SimpleExoPlayer.Builder(applicationContext, capturingRenderersFactory) - .setClock(new AutoAdvancingFakeClock()) + .setClock(new FakeClock(/* isAutoAdvancing= */ true)) .build(); PlaybackOutput playbackOutput = PlaybackOutput.register(player, capturingRenderersFactory); diff --git a/library/core/src/test/java/com/google/android/exoplayer2/e2etest/PlaylistPlaybackTest.java b/library/core/src/test/java/com/google/android/exoplayer2/e2etest/PlaylistPlaybackTest.java index 3e6d1cfb12..e00857cc92 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/e2etest/PlaylistPlaybackTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/e2etest/PlaylistPlaybackTest.java @@ -24,9 +24,9 @@ import com.google.android.exoplayer2.SimpleExoPlayer; import com.google.android.exoplayer2.robolectric.PlaybackOutput; import com.google.android.exoplayer2.robolectric.ShadowMediaCodecConfig; import com.google.android.exoplayer2.robolectric.TestPlayerRunHelper; -import com.google.android.exoplayer2.testutil.AutoAdvancingFakeClock; import com.google.android.exoplayer2.testutil.CapturingRenderersFactory; import com.google.android.exoplayer2.testutil.DumpFileAsserts; +import com.google.android.exoplayer2.testutil.FakeClock; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -49,7 +49,7 @@ public final class PlaylistPlaybackTest { new CapturingRenderersFactory(applicationContext); SimpleExoPlayer player = new SimpleExoPlayer.Builder(applicationContext, capturingRenderersFactory) - .setClock(new AutoAdvancingFakeClock()) + .setClock(new FakeClock(/* isAutoAdvancing= */ true)) .build(); PlaybackOutput playbackOutput = PlaybackOutput.register(player, capturingRenderersFactory); @@ -71,7 +71,7 @@ public final class PlaylistPlaybackTest { new CapturingRenderersFactory(applicationContext); SimpleExoPlayer player = new SimpleExoPlayer.Builder(applicationContext, capturingRenderersFactory) - .setClock(new AutoAdvancingFakeClock()) + .setClock(new FakeClock(/* isAutoAdvancing= */ true)) .build(); PlaybackOutput playbackOutput = PlaybackOutput.register(player, capturingRenderersFactory); diff --git a/library/core/src/test/java/com/google/android/exoplayer2/e2etest/SilencePlaybackTest.java b/library/core/src/test/java/com/google/android/exoplayer2/e2etest/SilencePlaybackTest.java index 886b45aed6..c6206b2fc8 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/e2etest/SilencePlaybackTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/e2etest/SilencePlaybackTest.java @@ -24,9 +24,9 @@ import com.google.android.exoplayer2.robolectric.PlaybackOutput; import com.google.android.exoplayer2.robolectric.ShadowMediaCodecConfig; import com.google.android.exoplayer2.robolectric.TestPlayerRunHelper; import com.google.android.exoplayer2.source.SilenceMediaSource; -import com.google.android.exoplayer2.testutil.AutoAdvancingFakeClock; import com.google.android.exoplayer2.testutil.CapturingRenderersFactory; import com.google.android.exoplayer2.testutil.DumpFileAsserts; +import com.google.android.exoplayer2.testutil.FakeClock; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -49,7 +49,7 @@ public final class SilencePlaybackTest { new CapturingRenderersFactory(applicationContext); SimpleExoPlayer player = new SimpleExoPlayer.Builder(applicationContext, capturingRenderersFactory) - .setClock(new AutoAdvancingFakeClock()) + .setClock(new FakeClock(/* isAutoAdvancing= */ true)) .build(); PlaybackOutput playbackOutput = PlaybackOutput.register(player, capturingRenderersFactory); @@ -70,7 +70,7 @@ public final class SilencePlaybackTest { new CapturingRenderersFactory(applicationContext); SimpleExoPlayer player = new SimpleExoPlayer.Builder(applicationContext, capturingRenderersFactory) - .setClock(new AutoAdvancingFakeClock()) + .setClock(new FakeClock(/* isAutoAdvancing= */ true)) .build(); PlaybackOutput playbackOutput = PlaybackOutput.register(player, capturingRenderersFactory); diff --git a/library/core/src/test/java/com/google/android/exoplayer2/e2etest/TsPlaybackTest.java b/library/core/src/test/java/com/google/android/exoplayer2/e2etest/TsPlaybackTest.java index 0587a105bd..e0a6a32617 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/e2etest/TsPlaybackTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/e2etest/TsPlaybackTest.java @@ -25,9 +25,9 @@ import com.google.android.exoplayer2.SimpleExoPlayer; import com.google.android.exoplayer2.robolectric.PlaybackOutput; import com.google.android.exoplayer2.robolectric.ShadowMediaCodecConfig; import com.google.android.exoplayer2.robolectric.TestPlayerRunHelper; -import com.google.android.exoplayer2.testutil.AutoAdvancingFakeClock; import com.google.android.exoplayer2.testutil.CapturingRenderersFactory; import com.google.android.exoplayer2.testutil.DumpFileAsserts; +import com.google.android.exoplayer2.testutil.FakeClock; import com.google.common.collect.ImmutableList; import org.junit.Rule; import org.junit.Test; @@ -85,7 +85,7 @@ public class TsPlaybackTest { new CapturingRenderersFactory(applicationContext); SimpleExoPlayer player = new SimpleExoPlayer.Builder(applicationContext, capturingRenderersFactory) - .setClock(new AutoAdvancingFakeClock()) + .setClock(new FakeClock(/* isAutoAdvancing= */ true)) .build(); player.setVideoSurface(new Surface(new SurfaceTexture(/* texName= */ 1))); PlaybackOutput playbackOutput = PlaybackOutput.register(player, capturingRenderersFactory); diff --git a/library/core/src/test/java/com/google/android/exoplayer2/e2etest/Vp9PlaybackTest.java b/library/core/src/test/java/com/google/android/exoplayer2/e2etest/Vp9PlaybackTest.java index 1d0fc0cb4d..90c6d16cb4 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/e2etest/Vp9PlaybackTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/e2etest/Vp9PlaybackTest.java @@ -25,9 +25,9 @@ import com.google.android.exoplayer2.SimpleExoPlayer; import com.google.android.exoplayer2.robolectric.PlaybackOutput; import com.google.android.exoplayer2.robolectric.ShadowMediaCodecConfig; import com.google.android.exoplayer2.robolectric.TestPlayerRunHelper; -import com.google.android.exoplayer2.testutil.AutoAdvancingFakeClock; import com.google.android.exoplayer2.testutil.CapturingRenderersFactory; import com.google.android.exoplayer2.testutil.DumpFileAsserts; +import com.google.android.exoplayer2.testutil.FakeClock; import com.google.common.collect.ImmutableList; import org.junit.Rule; import org.junit.Test; @@ -63,7 +63,7 @@ public final class Vp9PlaybackTest { new CapturingRenderersFactory(applicationContext); SimpleExoPlayer player = new SimpleExoPlayer.Builder(applicationContext, capturingRenderersFactory) - .setClock(new AutoAdvancingFakeClock()) + .setClock(new FakeClock(/* isAutoAdvancing= */ true)) .build(); player.setVideoSurface(new Surface(new SurfaceTexture(/* texName= */ 1))); PlaybackOutput playbackOutput = PlaybackOutput.register(player, capturingRenderersFactory); diff --git a/library/core/src/test/java/com/google/android/exoplayer2/e2etest/WavPlaybackTest.java b/library/core/src/test/java/com/google/android/exoplayer2/e2etest/WavPlaybackTest.java index 99418204b6..d1d9c38bf1 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/e2etest/WavPlaybackTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/e2etest/WavPlaybackTest.java @@ -23,9 +23,9 @@ import com.google.android.exoplayer2.SimpleExoPlayer; import com.google.android.exoplayer2.robolectric.PlaybackOutput; import com.google.android.exoplayer2.robolectric.ShadowMediaCodecConfig; import com.google.android.exoplayer2.robolectric.TestPlayerRunHelper; -import com.google.android.exoplayer2.testutil.AutoAdvancingFakeClock; import com.google.android.exoplayer2.testutil.CapturingRenderersFactory; import com.google.android.exoplayer2.testutil.DumpFileAsserts; +import com.google.android.exoplayer2.testutil.FakeClock; import com.google.common.collect.ImmutableList; import org.junit.Rule; import org.junit.Test; @@ -56,7 +56,7 @@ public final class WavPlaybackTest { new CapturingRenderersFactory(applicationContext); SimpleExoPlayer player = new SimpleExoPlayer.Builder(applicationContext, capturingRenderersFactory) - .setClock(new AutoAdvancingFakeClock()) + .setClock(new FakeClock(/* isAutoAdvancing= */ true)) .build(); PlaybackOutput playbackOutput = PlaybackOutput.register(player, capturingRenderersFactory); diff --git a/library/dash/src/test/java/com/google/android/exoplayer2/e2etest/DashPlaybackTest.java b/library/dash/src/test/java/com/google/android/exoplayer2/e2etest/DashPlaybackTest.java index d14c702a25..10b3336bc0 100644 --- a/library/dash/src/test/java/com/google/android/exoplayer2/e2etest/DashPlaybackTest.java +++ b/library/dash/src/test/java/com/google/android/exoplayer2/e2etest/DashPlaybackTest.java @@ -28,9 +28,9 @@ import com.google.android.exoplayer2.SimpleExoPlayer; import com.google.android.exoplayer2.robolectric.PlaybackOutput; import com.google.android.exoplayer2.robolectric.ShadowMediaCodecConfig; import com.google.android.exoplayer2.robolectric.TestPlayerRunHelper; -import com.google.android.exoplayer2.testutil.AutoAdvancingFakeClock; import com.google.android.exoplayer2.testutil.CapturingRenderersFactory; import com.google.android.exoplayer2.testutil.DumpFileAsserts; +import com.google.android.exoplayer2.testutil.FakeClock; import com.google.android.exoplayer2.trackselection.DefaultTrackSelector; import org.junit.Rule; import org.junit.Test; @@ -55,7 +55,7 @@ public final class DashPlaybackTest { new CapturingRenderersFactory(applicationContext); SimpleExoPlayer player = new SimpleExoPlayer.Builder(applicationContext, capturingRenderersFactory) - .setClock(new AutoAdvancingFakeClock()) + .setClock(new FakeClock(/* isAutoAdvancing= */ true)) .build(); player.setVideoSurface(new Surface(new SurfaceTexture(/* texName= */ 1))); PlaybackOutput playbackOutput = PlaybackOutput.register(player, capturingRenderersFactory); diff --git a/library/transformer/src/test/java/com/google/android/exoplayer2/transformer/TransformerTest.java b/library/transformer/src/test/java/com/google/android/exoplayer2/transformer/TransformerTest.java index 9dc96421c0..a99b4a369b 100644 --- a/library/transformer/src/test/java/com/google/android/exoplayer2/transformer/TransformerTest.java +++ b/library/transformer/src/test/java/com/google/android/exoplayer2/transformer/TransformerTest.java @@ -33,8 +33,8 @@ import androidx.test.core.app.ApplicationProvider; import androidx.test.ext.junit.runners.AndroidJUnit4; import com.google.android.exoplayer2.ExoPlaybackException; import com.google.android.exoplayer2.MediaItem; -import com.google.android.exoplayer2.testutil.AutoAdvancingFakeClock; import com.google.android.exoplayer2.testutil.DumpFileAsserts; +import com.google.android.exoplayer2.testutil.FakeClock; import com.google.android.exoplayer2.util.MimeTypes; import com.google.android.exoplayer2.util.Util; import com.google.common.collect.Iterables; @@ -71,14 +71,14 @@ public final class TransformerTest { private Context context; private String outputPath; private TestMuxer testMuxer; - private AutoAdvancingFakeClock clock; + private FakeClock clock; private ProgressHolder progressHolder; @Before public void setUp() throws Exception { context = ApplicationProvider.getApplicationContext(); outputPath = Util.createTempFile(context, "TransformerTest").getPath(); - clock = new AutoAdvancingFakeClock(); + clock = new FakeClock(/* isAutoAdvancing= */ true); progressHolder = new ProgressHolder(); createEncodersAndDecoders(); } diff --git a/testutils/src/main/java/com/google/android/exoplayer2/testutil/AutoAdvancingFakeClock.java b/testutils/src/main/java/com/google/android/exoplayer2/testutil/AutoAdvancingFakeClock.java deleted file mode 100644 index 86b9bb39f3..0000000000 --- a/testutils/src/main/java/com/google/android/exoplayer2/testutil/AutoAdvancingFakeClock.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2018 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.android.exoplayer2.testutil; - -/** - * {@link FakeClock} extension which automatically advances time whenever an empty message is - * enqueued at a future time. - */ -public final class AutoAdvancingFakeClock extends FakeClock { - - /** Creates the auto-advancing clock with an initial time of 0. */ - public AutoAdvancingFakeClock() { - this(/* initialTimeMs= */ 0); - } - - /** - * Creates the auto-advancing clock. - * - * @param initialTimeMs The initial time of the clock in milliseconds. - */ - public AutoAdvancingFakeClock(long initialTimeMs) { - super(initialTimeMs, /* isAutoAdvancing= */ true); - } -} diff --git a/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeClock.java b/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeClock.java index 59a06fc6f6..d432afa3a8 100644 --- a/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeClock.java +++ b/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeClock.java @@ -81,6 +81,17 @@ public class FakeClock implements Clock { this(/* bootTimeMs= */ 0, initialTimeMs, /* isAutoAdvancing= */ false); } + /** + * Creates a fake clock that assumes that the system was booted exactly at time {@code 0} (the + * Unix Epoch) and an {@code initialTimeMs} of {@code 0}. + * + * @param isAutoAdvancing Whether the clock should automatically advance the time to the time of + * next message that is due to be sent. + */ + public FakeClock(boolean isAutoAdvancing) { + this(/* bootTimeMs= */ 0, /* initialTimeMs= */ 0, isAutoAdvancing); + } + /** * Creates a fake clock that assumes that the system was booted exactly at time {@code 0} (the * Unix Epoch) and {@code initialTimeMs} milliseconds have passed since system boot. diff --git a/testutils/src/main/java/com/google/android/exoplayer2/testutil/TestExoPlayerBuilder.java b/testutils/src/main/java/com/google/android/exoplayer2/testutil/TestExoPlayerBuilder.java index ee9ae6b8aa..28f0b8a2ef 100644 --- a/testutils/src/main/java/com/google/android/exoplayer2/testutil/TestExoPlayerBuilder.java +++ b/testutils/src/main/java/com/google/android/exoplayer2/testutil/TestExoPlayerBuilder.java @@ -48,7 +48,7 @@ public class TestExoPlayerBuilder { public TestExoPlayerBuilder(Context context) { this.context = context; - clock = new AutoAdvancingFakeClock(); + clock = new FakeClock(/* isAutoAdvancing= */ true); trackSelector = new DefaultTrackSelector(context); loadControl = new DefaultLoadControl(); bandwidthMeter = new DefaultBandwidthMeter.Builder(context).build(); @@ -176,8 +176,8 @@ public class TestExoPlayerBuilder { } /** - * Sets the {@link Clock} to be used by the player. The default value is a {@link - * AutoAdvancingFakeClock}. + * Sets the {@link Clock} to be used by the player. The default value is an auto-advancing {@link + * FakeClock}. * * @param clock A {@link Clock} to be used by the player. * @return This builder.