Remove AutoAdvancingFakeClock.

The class is just an empty shell around the super class and can be
removed.

PiperOrigin-RevId: 363386440
This commit is contained in:
tonihei 2021-03-17 11:02:54 +00:00 committed by Ian Baker
parent 4048033491
commit 31f65f63ff
21 changed files with 74 additions and 91 deletions

View File

@ -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<Player> 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(

View File

@ -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

View File

@ -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);

View File

@ -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(

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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)));

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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();
}

View File

@ -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);
}
}

View File

@ -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.

View File

@ -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.