Remove some occurrences of dummy in core library

Remove occurrences in comments and private fields.

ISSUE: #7565
PiperOrigin-RevId: 320606558
This commit is contained in:
kimvde 2020-07-10 16:23:35 +01:00 committed by kim-vde
parent a0703cb716
commit 702568c3b6
26 changed files with 228 additions and 216 deletions

View File

@ -54,7 +54,7 @@ import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.Timeline; import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.Timeline.Period; import com.google.android.exoplayer2.Timeline.Period;
import com.google.android.exoplayer2.ext.ima.ImaAdsLoader.ImaFactory; import com.google.android.exoplayer2.ext.ima.ImaAdsLoader.ImaFactory;
import com.google.android.exoplayer2.source.MaskingMediaSource.DummyTimeline; import com.google.android.exoplayer2.source.MaskingMediaSource.PlaceholderTimeline;
import com.google.android.exoplayer2.source.ads.AdPlaybackState; import com.google.android.exoplayer2.source.ads.AdPlaybackState;
import com.google.android.exoplayer2.source.ads.AdsLoader; import com.google.android.exoplayer2.source.ads.AdsLoader;
import com.google.android.exoplayer2.source.ads.AdsMediaSource.AdLoadException; import com.google.android.exoplayer2.source.ads.AdsMediaSource.AdLoadException;
@ -170,7 +170,7 @@ public final class ImaAdsLoaderTest {
@Test @Test
public void start_withPlaceholderContent_initializedAdsLoader() { public void start_withPlaceholderContent_initializedAdsLoader() {
Timeline placeholderTimeline = new DummyTimeline(MediaItem.fromUri(Uri.EMPTY)); Timeline placeholderTimeline = new PlaceholderTimeline(MediaItem.fromUri(Uri.EMPTY));
setupPlayback(placeholderTimeline, PREROLL_CUE_POINTS_SECONDS); setupPlayback(placeholderTimeline, PREROLL_CUE_POINTS_SECONDS);
imaAdsLoader.start(adsLoaderListener, adViewProvider); imaAdsLoader.start(adsLoaderListener, adViewProvider);

View File

@ -983,7 +983,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
// The seek position was valid for the timeline that it was performed into, but the // The seek position was valid for the timeline that it was performed into, but the
// timeline has changed or is not ready and a suitable seek position could not be resolved. // timeline has changed or is not ready and a suitable seek position could not be resolved.
Pair<MediaPeriodId, Long> firstPeriodAndPosition = Pair<MediaPeriodId, Long> firstPeriodAndPosition =
getDummyFirstMediaPeriodPosition(playbackInfo.timeline); getPlaceholderFirstMediaPeriodPosition(playbackInfo.timeline);
periodId = firstPeriodAndPosition.first; periodId = firstPeriodAndPosition.first;
periodPositionUs = firstPeriodAndPosition.second; periodPositionUs = firstPeriodAndPosition.second;
requestedContentPosition = C.TIME_UNSET; requestedContentPosition = C.TIME_UNSET;
@ -1267,7 +1267,8 @@ import java.util.concurrent.atomic.AtomicBoolean;
boolean resetTrackInfo = clearMediaSourceList; boolean resetTrackInfo = clearMediaSourceList;
if (resetPosition) { if (resetPosition) {
pendingInitialSeekPosition = null; pendingInitialSeekPosition = null;
Pair<MediaPeriodId, Long> firstPeriodAndPosition = getDummyFirstMediaPeriodPosition(timeline); Pair<MediaPeriodId, Long> firstPeriodAndPosition =
getPlaceholderFirstMediaPeriodPosition(timeline);
mediaPeriodId = firstPeriodAndPosition.first; mediaPeriodId = firstPeriodAndPosition.first;
startPositionUs = firstPeriodAndPosition.second; startPositionUs = firstPeriodAndPosition.second;
requestedContentPositionUs = C.TIME_UNSET; requestedContentPositionUs = C.TIME_UNSET;
@ -1300,7 +1301,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
} }
} }
private Pair<MediaPeriodId, Long> getDummyFirstMediaPeriodPosition(Timeline timeline) { private Pair<MediaPeriodId, Long> getPlaceholderFirstMediaPeriodPosition(Timeline timeline) {
if (timeline.isEmpty()) { if (timeline.isEmpty()) {
return Pair.create(PlaybackInfo.getDummyPeriodForEmptyTimeline(), 0L); return Pair.create(PlaybackInfo.getDummyPeriodForEmptyTimeline(), 0L);
} }

View File

@ -380,7 +380,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
} }
/** /**
* For each renderer of type {@link C#TRACK_TYPE_NONE}, we will remove the dummy {@link * For each renderer of type {@link C#TRACK_TYPE_NONE}, we will remove the {@link
* EmptySampleStream} that was associated with it. * EmptySampleStream} that was associated with it.
*/ */
private void disassociateNoSampleRenderersWithEmptySampleStream( private void disassociateNoSampleRenderersWithEmptySampleStream(
@ -394,7 +394,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
/** /**
* For each renderer of type {@link C#TRACK_TYPE_NONE} that was enabled, we will associate it with * For each renderer of type {@link C#TRACK_TYPE_NONE} that was enabled, we will associate it with
* a dummy {@link EmptySampleStream}. * an {@link EmptySampleStream}.
*/ */
private void associateNoSampleRenderersWithEmptySampleStream( private void associateNoSampleRenderersWithEmptySampleStream(
@NullableType SampleStream[] sampleStreams) { @NullableType SampleStream[] sampleStreams) {

View File

@ -28,10 +28,10 @@ import com.google.android.exoplayer2.trackselection.TrackSelectorResult;
/* package */ final class PlaybackInfo { /* package */ final class PlaybackInfo {
/** /**
* Dummy media period id used while the timeline is empty and no period id is specified. This id * Placeholder media period id used while the timeline is empty and no period id is specified.
* is used when playback infos are created with {@link #createDummy(TrackSelectorResult)}. * This id is used when playback infos are created with {@link #createDummy(TrackSelectorResult)}.
*/ */
private static final MediaPeriodId DUMMY_MEDIA_PERIOD_ID = private static final MediaPeriodId PLACEHOLDER_MEDIA_PERIOD_ID =
new MediaPeriodId(/* periodUid= */ new Object()); new MediaPeriodId(/* periodUid= */ new Object());
/** The current {@link Timeline}. */ /** The current {@link Timeline}. */
@ -81,24 +81,24 @@ import com.google.android.exoplayer2.trackselection.TrackSelectorResult;
public volatile long positionUs; public volatile long positionUs;
/** /**
* Creates empty dummy playback info which can be used for masking as long as no real playback * Creates an empty placeholder playback info which can be used for masking as long as no real
* info is available. * playback info is available.
* *
* @param emptyTrackSelectorResult An empty track selector result with null entries for each * @param emptyTrackSelectorResult An empty track selector result with null entries for each
* renderer. * renderer.
* @return A dummy playback info. * @return A placeholder playback info.
*/ */
public static PlaybackInfo createDummy(TrackSelectorResult emptyTrackSelectorResult) { public static PlaybackInfo createDummy(TrackSelectorResult emptyTrackSelectorResult) {
return new PlaybackInfo( return new PlaybackInfo(
Timeline.EMPTY, Timeline.EMPTY,
DUMMY_MEDIA_PERIOD_ID, PLACEHOLDER_MEDIA_PERIOD_ID,
/* requestedContentPositionUs= */ C.TIME_UNSET, /* requestedContentPositionUs= */ C.TIME_UNSET,
Player.STATE_IDLE, Player.STATE_IDLE,
/* playbackError= */ null, /* playbackError= */ null,
/* isLoading= */ false, /* isLoading= */ false,
TrackGroupArray.EMPTY, TrackGroupArray.EMPTY,
emptyTrackSelectorResult, emptyTrackSelectorResult,
DUMMY_MEDIA_PERIOD_ID, PLACEHOLDER_MEDIA_PERIOD_ID,
/* playWhenReady= */ false, /* playWhenReady= */ false,
Player.PLAYBACK_SUPPRESSION_REASON_NONE, Player.PLAYBACK_SUPPRESSION_REASON_NONE,
/* bufferedPositionUs= */ 0, /* bufferedPositionUs= */ 0,
@ -152,9 +152,9 @@ import com.google.android.exoplayer2.trackselection.TrackSelectorResult;
this.positionUs = positionUs; this.positionUs = positionUs;
} }
/** Returns dummy period id for an empty timeline. */ /** Returns a placeholder period id for an empty timeline. */
public static MediaPeriodId getDummyPeriodForEmptyTimeline() { public static MediaPeriodId getDummyPeriodForEmptyTimeline() {
return DUMMY_MEDIA_PERIOD_ID; return PLACEHOLDER_MEDIA_PERIOD_ID;
} }
/** /**

View File

@ -124,7 +124,7 @@ public abstract class Timeline {
*/ */
public static final Object SINGLE_WINDOW_UID = new Object(); public static final Object SINGLE_WINDOW_UID = new Object();
private static final MediaItem DUMMY_MEDIA_ITEM = private static final MediaItem EMPTY_MEDIA_ITEM =
new MediaItem.Builder() new MediaItem.Builder()
.setMediaId("com.google.android.exoplayer2.Timeline") .setMediaId("com.google.android.exoplayer2.Timeline")
.setUri(Uri.EMPTY) .setUri(Uri.EMPTY)
@ -222,7 +222,7 @@ public abstract class Timeline {
/** Creates window. */ /** Creates window. */
public Window() { public Window() {
uid = SINGLE_WINDOW_UID; uid = SINGLE_WINDOW_UID;
mediaItem = DUMMY_MEDIA_ITEM; mediaItem = EMPTY_MEDIA_ITEM;
} }
/** Sets the data held by this window. */ /** Sets the data held by this window. */
@ -243,7 +243,7 @@ public abstract class Timeline {
int lastPeriodIndex, int lastPeriodIndex,
long positionInFirstPeriodUs) { long positionInFirstPeriodUs) {
this.uid = uid; this.uid = uid;
this.mediaItem = mediaItem != null ? mediaItem : DUMMY_MEDIA_ITEM; this.mediaItem = mediaItem != null ? mediaItem : EMPTY_MEDIA_ITEM;
this.tag = this.tag =
mediaItem != null && mediaItem.playbackProperties != null mediaItem != null && mediaItem.playbackProperties != null
? mediaItem.playbackProperties.tag ? mediaItem.playbackProperties.tag

View File

@ -150,7 +150,7 @@ public final class PlaybackStatsListener
// TODO: Add AnalyticsListener.onAttachedToPlayer and onDetachedFromPlayer to auto-release with // TODO: Add AnalyticsListener.onAttachedToPlayer and onDetachedFromPlayer to auto-release with
// an actual EventTime. Should also simplify other cases where the listener needs to be released // an actual EventTime. Should also simplify other cases where the listener needs to be released
// separately from the player. // separately from the player.
EventTime dummyEventTime = sessionManager.finishAllSessions(
new EventTime( new EventTime(
SystemClock.elapsedRealtime(), SystemClock.elapsedRealtime(),
Timeline.EMPTY, Timeline.EMPTY,
@ -161,8 +161,7 @@ public final class PlaybackStatsListener
/* currentWindowIndex= */ 0, /* currentWindowIndex= */ 0,
/* currentMediaPeriodId= */ null, /* currentMediaPeriodId= */ null,
/* currentPlaybackPositionMs= */ 0, /* currentPlaybackPositionMs= */ 0,
/* totalBufferedDurationMs= */ 0); /* totalBufferedDurationMs= */ 0));
sessionManager.finishAllSessions(dummyEventTime);
} }
// PlaybackSessionManager.Listener implementation. // PlaybackSessionManager.Listener implementation.

View File

@ -98,12 +98,12 @@ public interface AudioRendererEventListener {
@Nullable private final AudioRendererEventListener listener; @Nullable private final AudioRendererEventListener listener;
/** /**
* @param handler A handler for dispatching events, or null if creating a dummy instance. * @param handler A handler for dispatching events, or null if events should not be dispatched.
* @param listener The listener to which events should be dispatched, or null if creating a * @param listener The listener to which events should be dispatched, or null if events should
* dummy instance. * not be dispatched.
*/ */
public EventDispatcher(@Nullable Handler handler, public EventDispatcher(
@Nullable AudioRendererEventListener listener) { @Nullable Handler handler, @Nullable AudioRendererEventListener listener) {
this.handler = listener != null ? Assertions.checkNotNull(handler) : null; this.handler = listener != null ? Assertions.checkNotNull(handler) : null;
this.listener = listener; this.listener = listener;
} }

View File

@ -34,7 +34,7 @@ import java.util.UUID;
@RequiresApi(18) @RequiresApi(18)
public final class OfflineLicenseHelper { public final class OfflineLicenseHelper {
private static final DrmInitData DUMMY_DRM_INIT_DATA = new DrmInitData(); private static final DrmInitData EMPTY_DRM_INIT_DATA = new DrmInitData();
private final ConditionVariable conditionVariable; private final ConditionVariable conditionVariable;
private final DefaultDrmSessionManager drmSessionManager; private final DefaultDrmSessionManager drmSessionManager;
@ -202,7 +202,7 @@ public final class OfflineLicenseHelper {
throws DrmSessionException { throws DrmSessionException {
Assertions.checkNotNull(offlineLicenseKeySetId); Assertions.checkNotNull(offlineLicenseKeySetId);
return blockingKeyRequest( return blockingKeyRequest(
DefaultDrmSessionManager.MODE_DOWNLOAD, offlineLicenseKeySetId, DUMMY_DRM_INIT_DATA); DefaultDrmSessionManager.MODE_DOWNLOAD, offlineLicenseKeySetId, EMPTY_DRM_INIT_DATA);
} }
/** /**
@ -215,7 +215,7 @@ public final class OfflineLicenseHelper {
throws DrmSessionException { throws DrmSessionException {
Assertions.checkNotNull(offlineLicenseKeySetId); Assertions.checkNotNull(offlineLicenseKeySetId);
blockingKeyRequest( blockingKeyRequest(
DefaultDrmSessionManager.MODE_RELEASE, offlineLicenseKeySetId, DUMMY_DRM_INIT_DATA); DefaultDrmSessionManager.MODE_RELEASE, offlineLicenseKeySetId, EMPTY_DRM_INIT_DATA);
} }
/** /**
@ -231,7 +231,7 @@ public final class OfflineLicenseHelper {
drmSessionManager.prepare(); drmSessionManager.prepare();
DrmSession drmSession = DrmSession drmSession =
openBlockingKeyRequest( openBlockingKeyRequest(
DefaultDrmSessionManager.MODE_QUERY, offlineLicenseKeySetId, DUMMY_DRM_INIT_DATA); DefaultDrmSessionManager.MODE_QUERY, offlineLicenseKeySetId, EMPTY_DRM_INIT_DATA);
DrmSessionException error = drmSession.getError(); DrmSessionException error = drmSession.getError();
Pair<Long, Long> licenseDurationRemainingSec = Pair<Long, Long> licenseDurationRemainingSec =
WidevineUtil.getLicenseDurationRemainingSec(drmSession); WidevineUtil.getLicenseDurationRemainingSec(drmSession);

View File

@ -500,7 +500,7 @@ public final class DownloadHelper {
new DefaultTrackSelector(trackSelectorParameters, new DownloadTrackSelection.Factory()); new DefaultTrackSelector(trackSelectorParameters, new DownloadTrackSelection.Factory());
this.rendererCapabilities = rendererCapabilities; this.rendererCapabilities = rendererCapabilities;
this.scratchSet = new SparseIntArray(); this.scratchSet = new SparseIntArray();
trackSelector.init(/* listener= */ () -> {}, new DummyBandwidthMeter()); trackSelector.init(/* listener= */ () -> {}, new FakeBandwidthMeter());
callbackHandler = Util.createHandlerForCurrentOrMainLooper(); callbackHandler = Util.createHandlerForCurrentOrMainLooper();
window = new Timeline.Window(); window = new Timeline.Window();
} }
@ -1152,7 +1152,7 @@ public final class DownloadHelper {
} }
} }
private static final class DummyBandwidthMeter implements BandwidthMeter { private static final class FakeBandwidthMeter implements BandwidthMeter {
@Override @Override
public long getBitrateEstimate() { public long getBitrateEstimate() {

View File

@ -56,7 +56,7 @@ public final class ConcatenatingMediaSource extends CompositeMediaSource<MediaSo
private static final int MSG_UPDATE_TIMELINE = 4; private static final int MSG_UPDATE_TIMELINE = 4;
private static final int MSG_ON_COMPLETION = 5; private static final int MSG_ON_COMPLETION = 5;
private static final MediaItem DUMMY_MEDIA_ITEM = private static final MediaItem EMPTY_MEDIA_ITEM =
new MediaItem.Builder().setUri(Uri.EMPTY).build(); new MediaItem.Builder().setUri(Uri.EMPTY).build();
// Accessed on any thread. // Accessed on any thread.
@ -445,8 +445,8 @@ public final class ConcatenatingMediaSource extends CompositeMediaSource<MediaSo
@Override @Override
public MediaItem getMediaItem() { public MediaItem getMediaItem() {
// This method is actually never called because getInitialTimeline is implemented and hence the // This method is actually never called because getInitialTimeline is implemented and hence the
// MaskingMediaSource does not need to create a dummy timeline for this media source. // MaskingMediaSource does not need to create a placeholder timeline for this media source.
return DUMMY_MEDIA_ITEM; return EMPTY_MEDIA_ITEM;
} }
@Override @Override
@ -476,7 +476,7 @@ public final class ConcatenatingMediaSource extends CompositeMediaSource<MediaSo
@Nullable MediaSourceHolder holder = mediaSourceByUid.get(mediaSourceHolderUid); @Nullable MediaSourceHolder holder = mediaSourceByUid.get(mediaSourceHolderUid);
if (holder == null) { if (holder == null) {
// Stale event. The media source has already been removed. // Stale event. The media source has already been removed.
holder = new MediaSourceHolder(new DummyMediaSource(), useLazyPreparation); holder = new MediaSourceHolder(new FakeMediaSource(), useLazyPreparation);
holder.isRemoved = true; holder.isRemoved = true;
prepareChildSource(holder, holder.mediaSource); prepareChildSource(holder, holder.mediaSource);
} }
@ -988,8 +988,8 @@ public final class ConcatenatingMediaSource extends CompositeMediaSource<MediaSo
} }
} }
/** Dummy media source which does nothing and does not support creating periods. */ /** A media source which does nothing and does not support creating periods. */
private static final class DummyMediaSource extends BaseMediaSource { private static final class FakeMediaSource extends BaseMediaSource {
@Override @Override
protected void prepareSourceInternal(@Nullable TransferListener mediaTransferListener) { protected void prepareSourceInternal(@Nullable TransferListener mediaTransferListener) {
@ -998,7 +998,7 @@ public final class ConcatenatingMediaSource extends CompositeMediaSource<MediaSo
@Override @Override
public MediaItem getMediaItem() { public MediaItem getMediaItem() {
return DUMMY_MEDIA_ITEM; return EMPTY_MEDIA_ITEM;
} }
@Override @Override

View File

@ -67,7 +67,7 @@ public final class MaskingMediaSource extends CompositeMediaSource<Void> {
initialTimeline, /* firstWindowUid= */ null, /* firstPeriodUid= */ null); initialTimeline, /* firstWindowUid= */ null, /* firstPeriodUid= */ null);
hasRealTimeline = true; hasRealTimeline = true;
} else { } else {
timeline = MaskingTimeline.createWithDummyTimeline(mediaSource.getMediaItem()); timeline = MaskingTimeline.createWithPlaceholderTimeline(mediaSource.getMediaItem());
} }
} }
@ -165,7 +165,9 @@ public final class MaskingMediaSource extends CompositeMediaSource<Void> {
hasRealTimeline hasRealTimeline
? timeline.cloneWithUpdatedTimeline(newTimeline) ? timeline.cloneWithUpdatedTimeline(newTimeline)
: MaskingTimeline.createWithRealTimeline( : MaskingTimeline.createWithRealTimeline(
newTimeline, Window.SINGLE_WINDOW_UID, MaskingTimeline.DUMMY_EXTERNAL_PERIOD_UID); newTimeline,
Window.SINGLE_WINDOW_UID,
MaskingTimeline.MASKING_EXTERNAL_PERIOD_UID);
} else { } else {
// Determine first period and the start position. // Determine first period and the start position.
// This will be: // This will be:
@ -174,7 +176,7 @@ public final class MaskingMediaSource extends CompositeMediaSource<Void> {
// a non-zero initial seek position in the window. // a non-zero initial seek position in the window.
// 3. The default window start position if the deferred period has a prepare position of zero // 3. The default window start position if the deferred period has a prepare position of zero
// under the assumption that the prepare position of zero was used because it's the // under the assumption that the prepare position of zero was used because it's the
// default position of the DummyTimeline window. Note that this will override an // default position of the PlaceholderTimeline window. Note that this will override an
// intentional seek to zero for a window with a non-zero default position. This is // intentional seek to zero for a window with a non-zero default position. This is
// unlikely to be a problem as a non-zero default position usually only occurs for live // unlikely to be a problem as a non-zero default position usually only occurs for live
// playbacks and seeking to zero in a live window would cause BehindLiveWindowExceptions // playbacks and seeking to zero in a live window would cause BehindLiveWindowExceptions
@ -230,7 +232,7 @@ public final class MaskingMediaSource extends CompositeMediaSource<Void> {
private Object getInternalPeriodUid(Object externalPeriodUid) { private Object getInternalPeriodUid(Object externalPeriodUid) {
return timeline.replacedInternalPeriodUid != null return timeline.replacedInternalPeriodUid != null
&& externalPeriodUid.equals(MaskingTimeline.DUMMY_EXTERNAL_PERIOD_UID) && externalPeriodUid.equals(MaskingTimeline.MASKING_EXTERNAL_PERIOD_UID)
? timeline.replacedInternalPeriodUid ? timeline.replacedInternalPeriodUid
: externalPeriodUid; : externalPeriodUid;
} }
@ -238,7 +240,7 @@ public final class MaskingMediaSource extends CompositeMediaSource<Void> {
private Object getExternalPeriodUid(Object internalPeriodUid) { private Object getExternalPeriodUid(Object internalPeriodUid) {
return timeline.replacedInternalPeriodUid != null return timeline.replacedInternalPeriodUid != null
&& timeline.replacedInternalPeriodUid.equals(internalPeriodUid) && timeline.replacedInternalPeriodUid.equals(internalPeriodUid)
? MaskingTimeline.DUMMY_EXTERNAL_PERIOD_UID ? MaskingTimeline.MASKING_EXTERNAL_PERIOD_UID
: internalPeriodUid; : internalPeriodUid;
} }
@ -265,34 +267,36 @@ public final class MaskingMediaSource extends CompositeMediaSource<Void> {
/** /**
* Timeline used as placeholder for an unprepared media source. After preparation, a * Timeline used as placeholder for an unprepared media source. After preparation, a
* MaskingTimeline is used to keep the originally assigned dummy period ID. * MaskingTimeline is used to keep the originally assigned masking period ID.
*/ */
private static final class MaskingTimeline extends ForwardingTimeline { private static final class MaskingTimeline extends ForwardingTimeline {
public static final Object DUMMY_EXTERNAL_PERIOD_UID = new Object(); public static final Object MASKING_EXTERNAL_PERIOD_UID = new Object();
@Nullable private final Object replacedInternalWindowUid; @Nullable private final Object replacedInternalWindowUid;
@Nullable private final Object replacedInternalPeriodUid; @Nullable private final Object replacedInternalPeriodUid;
/** /**
* Returns an instance with a dummy timeline using the provided {@link MediaItem}. * Returns an instance with a placeholder timeline using the provided {@link MediaItem}.
* *
* @param mediaItem A {@link MediaItem}. * @param mediaItem A {@link MediaItem}.
*/ */
public static MaskingTimeline createWithDummyTimeline(MediaItem mediaItem) { public static MaskingTimeline createWithPlaceholderTimeline(MediaItem mediaItem) {
return new MaskingTimeline( return new MaskingTimeline(
new DummyTimeline(mediaItem), Window.SINGLE_WINDOW_UID, DUMMY_EXTERNAL_PERIOD_UID); new PlaceholderTimeline(mediaItem),
Window.SINGLE_WINDOW_UID,
MASKING_EXTERNAL_PERIOD_UID);
} }
/** /**
* Returns an instance with a real timeline, replacing the provided period ID with the already * Returns an instance with a real timeline, replacing the provided period ID with the already
* assigned dummy period ID. * assigned masking period ID.
* *
* @param timeline The real timeline. * @param timeline The real timeline.
* @param firstWindowUid The window UID in the timeline which will be replaced by the already * @param firstWindowUid The window UID in the timeline which will be replaced by the already
* assigned {@link Window#SINGLE_WINDOW_UID}. * assigned {@link Window#SINGLE_WINDOW_UID}.
* @param firstPeriodUid The period UID in the timeline which will be replaced by the already * @param firstPeriodUid The period UID in the timeline which will be replaced by the already
* assigned {@link #DUMMY_EXTERNAL_PERIOD_UID}. * assigned {@link #MASKING_EXTERNAL_PERIOD_UID}.
*/ */
public static MaskingTimeline createWithRealTimeline( public static MaskingTimeline createWithRealTimeline(
Timeline timeline, @Nullable Object firstWindowUid, @Nullable Object firstPeriodUid) { Timeline timeline, @Nullable Object firstWindowUid, @Nullable Object firstPeriodUid) {
@ -335,7 +339,7 @@ public final class MaskingMediaSource extends CompositeMediaSource<Void> {
public Period getPeriod(int periodIndex, Period period, boolean setIds) { public Period getPeriod(int periodIndex, Period period, boolean setIds) {
timeline.getPeriod(periodIndex, period, setIds); timeline.getPeriod(periodIndex, period, setIds);
if (Util.areEqual(period.uid, replacedInternalPeriodUid) && setIds) { if (Util.areEqual(period.uid, replacedInternalPeriodUid) && setIds) {
period.uid = DUMMY_EXTERNAL_PERIOD_UID; period.uid = MASKING_EXTERNAL_PERIOD_UID;
} }
return period; return period;
} }
@ -343,7 +347,7 @@ public final class MaskingMediaSource extends CompositeMediaSource<Void> {
@Override @Override
public int getIndexOfPeriod(Object uid) { public int getIndexOfPeriod(Object uid) {
return timeline.getIndexOfPeriod( return timeline.getIndexOfPeriod(
DUMMY_EXTERNAL_PERIOD_UID.equals(uid) && replacedInternalPeriodUid != null MASKING_EXTERNAL_PERIOD_UID.equals(uid) && replacedInternalPeriodUid != null
? replacedInternalPeriodUid ? replacedInternalPeriodUid
: uid); : uid);
} }
@ -351,18 +355,18 @@ public final class MaskingMediaSource extends CompositeMediaSource<Void> {
@Override @Override
public Object getUidOfPeriod(int periodIndex) { public Object getUidOfPeriod(int periodIndex) {
Object uid = timeline.getUidOfPeriod(periodIndex); Object uid = timeline.getUidOfPeriod(periodIndex);
return Util.areEqual(uid, replacedInternalPeriodUid) ? DUMMY_EXTERNAL_PERIOD_UID : uid; return Util.areEqual(uid, replacedInternalPeriodUid) ? MASKING_EXTERNAL_PERIOD_UID : uid;
} }
} }
/** Dummy placeholder timeline with one dynamic window with a period of indeterminate duration. */ /** A timeline with one dynamic window with a period of indeterminate duration. */
@VisibleForTesting @VisibleForTesting
public static final class DummyTimeline extends Timeline { public static final class PlaceholderTimeline extends Timeline {
private final MediaItem mediaItem; private final MediaItem mediaItem;
/** Creates a new instance with the given media item. */ /** Creates a new instance with the given media item. */
public DummyTimeline(MediaItem mediaItem) { public PlaceholderTimeline(MediaItem mediaItem) {
this.mediaItem = mediaItem; this.mediaItem = mediaItem;
} }
@ -402,7 +406,7 @@ public final class MaskingMediaSource extends CompositeMediaSource<Void> {
public Period getPeriod(int periodIndex, Period period, boolean setIds) { public Period getPeriod(int periodIndex, Period period, boolean setIds) {
return period.set( return period.set(
/* id= */ setIds ? 0 : null, /* id= */ setIds ? 0 : null,
/* uid= */ setIds ? MaskingTimeline.DUMMY_EXTERNAL_PERIOD_UID : null, /* uid= */ setIds ? MaskingTimeline.MASKING_EXTERNAL_PERIOD_UID : null,
/* windowIndex= */ 0, /* windowIndex= */ 0,
/* durationUs = */ C.TIME_UNSET, /* durationUs = */ C.TIME_UNSET,
/* positionInWindowUs= */ 0); /* positionInWindowUs= */ 0);
@ -410,12 +414,12 @@ public final class MaskingMediaSource extends CompositeMediaSource<Void> {
@Override @Override
public int getIndexOfPeriod(Object uid) { public int getIndexOfPeriod(Object uid) {
return uid == MaskingTimeline.DUMMY_EXTERNAL_PERIOD_UID ? 0 : C.INDEX_UNSET; return uid == MaskingTimeline.MASKING_EXTERNAL_PERIOD_UID ? 0 : C.INDEX_UNSET;
} }
@Override @Override
public Object getUidOfPeriod(int periodIndex) { public Object getUidOfPeriod(int periodIndex) {
return MaskingTimeline.DUMMY_EXTERNAL_PERIOD_UID; return MaskingTimeline.MASKING_EXTERNAL_PERIOD_UID;
} }
} }
} }

View File

@ -93,8 +93,8 @@ public interface MediaSource {
public final int nextAdGroupIndex; public final int nextAdGroupIndex;
/** /**
* Creates a media period identifier for a dummy period which is not part of a buffered sequence * Creates a media period identifier for a period which is not part of a buffered sequence of
* of windows. * windows.
* *
* @param periodUid The unique id of the timeline period. * @param periodUid The unique id of the timeline period.
*/ */
@ -248,8 +248,8 @@ public interface MediaSource {
void removeDrmEventListener(DrmSessionEventListener eventListener); void removeDrmEventListener(DrmSessionEventListener eventListener);
/** /**
* Returns the initial dummy timeline that is returned immediately when the real timeline is not * Returns the initial placeholder timeline that is returned immediately when the real timeline is
* yet known, or null to let the player create an initial timeline. * not yet known, or null to let the player create an initial timeline.
* *
* <p>The initial timeline must use the same uids for windows and periods that the real timeline * <p>The initial timeline must use the same uids for windows and periods that the real timeline
* will use. It also must provide windows which are marked as dynamic to indicate that the window * will use. It also must provide windows which are marked as dynamic to indicate that the window

View File

@ -66,7 +66,7 @@ public final class MergingMediaSource extends CompositeMediaSource<Integer> {
} }
private static final int PERIOD_COUNT_UNSET = -1; private static final int PERIOD_COUNT_UNSET = -1;
private static final MediaItem DUMMY_MEDIA_ITEM = private static final MediaItem EMPTY_MEDIA_ITEM =
new MediaItem.Builder().setMediaId("MergingMediaSource").build(); new MediaItem.Builder().setMediaId("MergingMediaSource").build();
private final boolean adjustPeriodTimeOffsets; private final boolean adjustPeriodTimeOffsets;
@ -137,7 +137,7 @@ public final class MergingMediaSource extends CompositeMediaSource<Integer> {
@Override @Override
public MediaItem getMediaItem() { public MediaItem getMediaItem() {
return mediaSources.length > 0 ? mediaSources[0].getMediaItem() : DUMMY_MEDIA_ITEM; return mediaSources.length > 0 ? mediaSources[0].getMediaItem() : EMPTY_MEDIA_ITEM;
} }
@Override @Override

View File

@ -121,7 +121,7 @@ public final class AdsMediaSource extends CompositeMediaSource<MediaPeriodId> {
} }
// Used to identify the content "child" source for CompositeMediaSource. // Used to identify the content "child" source for CompositeMediaSource.
private static final MediaPeriodId DUMMY_CONTENT_MEDIA_PERIOD_ID = private static final MediaPeriodId CHILD_SOURCE_MEDIA_PERIOD_ID =
new MediaPeriodId(/* periodUid= */ new Object()); new MediaPeriodId(/* periodUid= */ new Object());
private final MediaSource contentMediaSource; private final MediaSource contentMediaSource;
@ -203,7 +203,7 @@ public final class AdsMediaSource extends CompositeMediaSource<MediaPeriodId> {
super.prepareSourceInternal(mediaTransferListener); super.prepareSourceInternal(mediaTransferListener);
ComponentListener componentListener = new ComponentListener(); ComponentListener componentListener = new ComponentListener();
this.componentListener = componentListener; this.componentListener = componentListener;
prepareChildSource(DUMMY_CONTENT_MEDIA_PERIOD_ID, contentMediaSource); prepareChildSource(CHILD_SOURCE_MEDIA_PERIOD_ID, contentMediaSource);
mainHandler.post(() -> adsLoader.start(componentListener, adViewProvider)); mainHandler.post(() -> adsLoader.start(componentListener, adViewProvider));
} }
@ -284,8 +284,8 @@ public final class AdsMediaSource extends CompositeMediaSource<MediaPeriodId> {
@Override @Override
protected MediaPeriodId getMediaPeriodIdForChildMediaPeriodId( protected MediaPeriodId getMediaPeriodIdForChildMediaPeriodId(
MediaPeriodId childId, MediaPeriodId mediaPeriodId) { MediaPeriodId childId, MediaPeriodId mediaPeriodId) {
// The child id for the content period is just DUMMY_CONTENT_MEDIA_PERIOD_ID. That's why we need // The child id for the content period is just CHILD_SOURCE_MEDIA_PERIOD_ID. That's why
// to forward the reported mediaPeriodId in this case. // we need to forward the reported mediaPeriodId in this case.
return childId.isAd() ? childId : mediaPeriodId; return childId.isAd() ? childId : mediaPeriodId;
} }

View File

@ -41,7 +41,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
*/ */
public final class BundledChunkExtractor implements ExtractorOutput, ChunkExtractor { public final class BundledChunkExtractor implements ExtractorOutput, ChunkExtractor {
private static final PositionHolder DUMMY_POSITION_HOLDER = new PositionHolder(); private static final PositionHolder POSITION_HOLDER = new PositionHolder();
private final Extractor extractor; private final Extractor extractor;
private final int primaryTrackType; private final int primaryTrackType;
@ -106,7 +106,7 @@ public final class BundledChunkExtractor implements ExtractorOutput, ChunkExtrac
@Override @Override
public boolean read(ExtractorInput input) throws IOException { public boolean read(ExtractorInput input) throws IOException {
int result = extractor.read(input, DUMMY_POSITION_HOLDER); int result = extractor.read(input, POSITION_HOLDER);
Assertions.checkState(result != Extractor.RESULT_SEEK); Assertions.checkState(result != Extractor.RESULT_SEEK);
return result == Extractor.RESULT_CONTINUE; return result == Extractor.RESULT_CONTINUE;
} }
@ -149,7 +149,7 @@ public final class BundledChunkExtractor implements ExtractorOutput, ChunkExtrac
private final int id; private final int id;
private final int type; private final int type;
@Nullable private final Format manifestFormat; @Nullable private final Format manifestFormat;
private final DummyTrackOutput dummyTrackOutput; private final DummyTrackOutput fakeTrackOutput;
public @MonotonicNonNull Format sampleFormat; public @MonotonicNonNull Format sampleFormat;
private @MonotonicNonNull TrackOutput trackOutput; private @MonotonicNonNull TrackOutput trackOutput;
@ -159,12 +159,12 @@ public final class BundledChunkExtractor implements ExtractorOutput, ChunkExtrac
this.id = id; this.id = id;
this.type = type; this.type = type;
this.manifestFormat = manifestFormat; this.manifestFormat = manifestFormat;
dummyTrackOutput = new DummyTrackOutput(); fakeTrackOutput = new DummyTrackOutput();
} }
public void bind(@Nullable TrackOutputProvider trackOutputProvider, long endTimeUs) { public void bind(@Nullable TrackOutputProvider trackOutputProvider, long endTimeUs) {
if (trackOutputProvider == null) { if (trackOutputProvider == null) {
trackOutput = dummyTrackOutput; trackOutput = fakeTrackOutput;
return; return;
} }
this.endTimeUs = endTimeUs; this.endTimeUs = endTimeUs;
@ -201,7 +201,7 @@ public final class BundledChunkExtractor implements ExtractorOutput, ChunkExtrac
int offset, int offset,
@Nullable CryptoData cryptoData) { @Nullable CryptoData cryptoData) {
if (endTimeUs != C.TIME_UNSET && timeUs >= endTimeUs) { if (endTimeUs != C.TIME_UNSET && timeUs >= endTimeUs) {
trackOutput = dummyTrackOutput; trackOutput = fakeTrackOutput;
} }
castNonNull(trackOutput).sampleMetadata(timeUs, flags, size, offset, cryptoData); castNonNull(trackOutput).sampleMetadata(timeUs, flags, size, offset, cryptoData);
} }

View File

@ -19,9 +19,7 @@ import android.net.Uri;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import java.io.IOException; import java.io.IOException;
/** /** A DataSource which provides no data. {@link #open(DataSpec)} throws {@link IOException}. */
* A dummy DataSource which provides no data. {@link #open(DataSpec)} throws {@link IOException}.
*/
public final class DummyDataSource implements DataSource { public final class DummyDataSource implements DataSource {
public static final DummyDataSource INSTANCE = new DummyDataSource(); public static final DummyDataSource INSTANCE = new DummyDataSource();
@ -38,7 +36,7 @@ public final class DummyDataSource implements DataSource {
@Override @Override
public long open(DataSpec dataSpec) throws IOException { public long open(DataSpec dataSpec) throws IOException {
throw new IOException("Dummy source"); throw new IOException("DummyDataSource cannot be opened");
} }
@Override @Override

View File

@ -22,7 +22,6 @@ import static com.google.android.exoplayer2.util.EGLSurfaceTexture.SECURE_MODE_S
import android.content.Context; import android.content.Context;
import android.graphics.SurfaceTexture; import android.graphics.SurfaceTexture;
import android.os.Handler; import android.os.Handler;
import android.os.Handler.Callback;
import android.os.HandlerThread; import android.os.HandlerThread;
import android.os.Message; import android.os.Message;
import android.view.Surface; import android.view.Surface;
@ -70,14 +69,14 @@ public final class DummySurface extends Surface {
/** /**
* Returns a newly created dummy surface. The surface must be released by calling {@link #release} * Returns a newly created dummy surface. The surface must be released by calling {@link #release}
* when it's no longer required. * when it's no longer required.
* <p> *
* Must only be called if {@link Util#SDK_INT} is 17 or higher. * <p>Must only be called if {@link Util#SDK_INT} is 17 or higher.
* *
* @param context Any {@link Context}. * @param context Any {@link Context}.
* @param secure Whether a secure surface is required. Must only be requested if * @param secure Whether a secure surface is required. Must only be requested if {@link
* {@link #isSecureSupported(Context)} returns {@code true}. * #isSecureSupported(Context)} returns {@code true}.
* @throws IllegalStateException If a secure surface is requested on a device for which * @throws IllegalStateException If a secure surface is requested on a device for which {@link
* {@link #isSecureSupported(Context)} returns {@code false}. * #isSecureSupported(Context)} returns {@code false}.
*/ */
public static DummySurface newInstanceV17(Context context, boolean secure) { public static DummySurface newInstanceV17(Context context, boolean secure) {
Assertions.checkState(!secure || isSecureSupported(context)); Assertions.checkState(!secure || isSecureSupported(context));
@ -123,7 +122,7 @@ public final class DummySurface extends Surface {
} }
} }
private static class DummySurfaceThread extends HandlerThread implements Callback { private static class DummySurfaceThread extends HandlerThread implements Handler.Callback {
private static final int MSG_INIT = 1; private static final int MSG_INIT = 1;
private static final int MSG_RELEASE = 2; private static final int MSG_RELEASE = 2;

View File

@ -138,12 +138,12 @@ public interface VideoRendererEventListener {
@Nullable private final VideoRendererEventListener listener; @Nullable private final VideoRendererEventListener listener;
/** /**
* @param handler A handler for dispatching events, or null if creating a dummy instance. * @param handler A handler for dispatching events, or null if events should not be dispatched.
* @param listener The listener to which events should be dispatched, or null if creating a * @param listener The listener to which events should be dispatched, or null if events should
* dummy instance. * not be dispatched.
*/ */
public EventDispatcher(@Nullable Handler handler, public EventDispatcher(
@Nullable VideoRendererEventListener listener) { @Nullable Handler handler, @Nullable VideoRendererEventListener listener) {
this.handler = listener != null ? Assertions.checkNotNull(handler) : null; this.handler = listener != null ? Assertions.checkNotNull(handler) : null;
this.listener = listener; this.listener = listener;
} }

View File

@ -126,13 +126,13 @@ public final class ExoPlayerTest {
private static final int TIMEOUT_MS = 10_000; private static final int TIMEOUT_MS = 10_000;
private Context context; private Context context;
private Timeline dummyTimeline; private Timeline placeholderTimeline;
@Before @Before
public void setUp() { public void setUp() {
context = ApplicationProvider.getApplicationContext(); context = ApplicationProvider.getApplicationContext();
dummyTimeline = placeholderTimeline =
new MaskingMediaSource.DummyTimeline( new MaskingMediaSource.PlaceholderTimeline(
FakeTimeline.FAKE_MEDIA_ITEM.buildUpon().setTag(0).build()); FakeTimeline.FAKE_MEDIA_ITEM.buildUpon().setTag(0).build());
} }
@ -144,7 +144,7 @@ public final class ExoPlayerTest {
public void playEmptyTimeline() throws Exception { public void playEmptyTimeline() throws Exception {
Timeline timeline = Timeline.EMPTY; Timeline timeline = Timeline.EMPTY;
Timeline expectedMaskingTimeline = Timeline expectedMaskingTimeline =
new MaskingMediaSource.DummyTimeline(FakeMediaSource.FAKE_MEDIA_ITEM); new MaskingMediaSource.PlaceholderTimeline(FakeMediaSource.FAKE_MEDIA_ITEM);
FakeRenderer renderer = new FakeRenderer(C.TRACK_TYPE_UNKNOWN); FakeRenderer renderer = new FakeRenderer(C.TRACK_TYPE_UNKNOWN);
ExoPlayerTestRunner testRunner = ExoPlayerTestRunner testRunner =
new ExoPlayerTestRunner.Builder(context) new ExoPlayerTestRunner.Builder(context)
@ -178,7 +178,7 @@ public final class ExoPlayerTest {
.start() .start()
.blockUntilEnded(TIMEOUT_MS); .blockUntilEnded(TIMEOUT_MS);
testRunner.assertNoPositionDiscontinuities(); testRunner.assertNoPositionDiscontinuities();
testRunner.assertTimelinesSame(dummyTimeline, timeline); testRunner.assertTimelinesSame(placeholderTimeline, timeline);
testRunner.assertTimelineChangeReasonsEqual( testRunner.assertTimelineChangeReasonsEqual(
Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED, Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED,
Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE); Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE);
@ -234,7 +234,7 @@ public final class ExoPlayerTest {
Integer[] expectedReasons = new Integer[99]; Integer[] expectedReasons = new Integer[99];
Arrays.fill(expectedReasons, Player.DISCONTINUITY_REASON_PERIOD_TRANSITION); Arrays.fill(expectedReasons, Player.DISCONTINUITY_REASON_PERIOD_TRANSITION);
testRunner.assertPositionDiscontinuityReasonsEqual(expectedReasons); testRunner.assertPositionDiscontinuityReasonsEqual(expectedReasons);
testRunner.assertTimelinesSame(dummyTimeline, timeline); testRunner.assertTimelinesSame(placeholderTimeline, timeline);
testRunner.assertTimelineChangeReasonsEqual( testRunner.assertTimelineChangeReasonsEqual(
Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED, Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED,
Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE); Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE);
@ -382,11 +382,15 @@ public final class ExoPlayerTest {
.blockUntilEnded(TIMEOUT_MS); .blockUntilEnded(TIMEOUT_MS);
testRunner.assertNoPositionDiscontinuities(); testRunner.assertNoPositionDiscontinuities();
// The first source's preparation completed with a real timeline. When the second source was // The first source's preparation completed with a real timeline. When the second source was
// prepared, it immediately exposed a dummy timeline, but the source info refresh from the // prepared, it immediately exposed a placeholder timeline, but the source info refresh from the
// second source was suppressed as we replace it with the third source before the update // second source was suppressed as we replace it with the third source before the update
// arrives. // arrives.
testRunner.assertTimelinesSame( testRunner.assertTimelinesSame(
dummyTimeline, firstTimeline, dummyTimeline, dummyTimeline, thirdTimeline); placeholderTimeline,
firstTimeline,
placeholderTimeline,
placeholderTimeline,
thirdTimeline);
testRunner.assertTimelineChangeReasonsEqual( testRunner.assertTimelineChangeReasonsEqual(
Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED, Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED,
Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE, Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE,
@ -881,7 +885,7 @@ public final class ExoPlayerTest {
.build() .build()
.start() .start()
.blockUntilEnded(TIMEOUT_MS); .blockUntilEnded(TIMEOUT_MS);
testRunner.assertTimelinesSame(dummyTimeline, timeline, timeline2); testRunner.assertTimelinesSame(placeholderTimeline, timeline, timeline2);
testRunner.assertTimelineChangeReasonsEqual( testRunner.assertTimelineChangeReasonsEqual(
Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED, Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED,
Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE, Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE,
@ -1083,7 +1087,7 @@ public final class ExoPlayerTest {
.start() .start()
.blockUntilActionScheduleFinished(TIMEOUT_MS) .blockUntilActionScheduleFinished(TIMEOUT_MS)
.blockUntilEnded(TIMEOUT_MS); .blockUntilEnded(TIMEOUT_MS);
testRunner.assertTimelinesSame(dummyTimeline, timeline); testRunner.assertTimelinesSame(placeholderTimeline, timeline);
testRunner.assertTimelineChangeReasonsEqual( testRunner.assertTimelineChangeReasonsEqual(
Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED, Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED,
Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE); Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE);
@ -1117,7 +1121,7 @@ public final class ExoPlayerTest {
.start() .start()
.blockUntilActionScheduleFinished(TIMEOUT_MS) .blockUntilActionScheduleFinished(TIMEOUT_MS)
.blockUntilEnded(TIMEOUT_MS); .blockUntilEnded(TIMEOUT_MS);
testRunner.assertTimelinesSame(dummyTimeline, timeline); testRunner.assertTimelinesSame(placeholderTimeline, timeline);
testRunner.assertTimelineChangeReasonsEqual( testRunner.assertTimelineChangeReasonsEqual(
Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED, Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED,
Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE); Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE);
@ -1151,7 +1155,7 @@ public final class ExoPlayerTest {
.start() .start()
.blockUntilActionScheduleFinished(TIMEOUT_MS) .blockUntilActionScheduleFinished(TIMEOUT_MS)
.blockUntilEnded(TIMEOUT_MS); .blockUntilEnded(TIMEOUT_MS);
testRunner.assertTimelinesSame(dummyTimeline, timeline, Timeline.EMPTY); testRunner.assertTimelinesSame(placeholderTimeline, timeline, Timeline.EMPTY);
testRunner.assertTimelineChangeReasonsEqual( testRunner.assertTimelineChangeReasonsEqual(
Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED, Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED,
Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE, Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE,
@ -1244,7 +1248,7 @@ public final class ExoPlayerTest {
Player.STATE_READY, Player.STATE_READY,
Player.STATE_ENDED); Player.STATE_ENDED);
testRunner.assertTimelinesSame( testRunner.assertTimelinesSame(
dummyTimeline, placeholderTimeline,
timeline, timeline,
Timeline.EMPTY, Timeline.EMPTY,
new FakeMediaSource.InitialTimeline(secondTimeline), new FakeMediaSource.InitialTimeline(secondTimeline),
@ -1267,14 +1271,14 @@ public final class ExoPlayerTest {
new FakeTimeline( new FakeTimeline(
new TimelineWindowDefinition(/* periodCount= */ 1, /* id= */ firstWindowId)); new TimelineWindowDefinition(/* periodCount= */ 1, /* id= */ firstWindowId));
Timeline firstExpectedMaskingTimeline = Timeline firstExpectedMaskingTimeline =
new MaskingMediaSource.DummyTimeline( new MaskingMediaSource.PlaceholderTimeline(
FakeTimeline.FAKE_MEDIA_ITEM.buildUpon().setTag(firstWindowId).build()); FakeTimeline.FAKE_MEDIA_ITEM.buildUpon().setTag(firstWindowId).build());
Object secondWindowId = new Object(); Object secondWindowId = new Object();
Timeline secondTimeline = Timeline secondTimeline =
new FakeTimeline( new FakeTimeline(
new TimelineWindowDefinition(/* periodCount= */ 1, /* id= */ secondWindowId)); new TimelineWindowDefinition(/* periodCount= */ 1, /* id= */ secondWindowId));
Timeline secondExpectedMaskingTimeline = Timeline secondExpectedMaskingTimeline =
new MaskingMediaSource.DummyTimeline( new MaskingMediaSource.PlaceholderTimeline(
FakeTimeline.FAKE_MEDIA_ITEM.buildUpon().setTag(secondWindowId).build()); FakeTimeline.FAKE_MEDIA_ITEM.buildUpon().setTag(secondWindowId).build());
MediaSource secondSource = new FakeMediaSource(secondTimeline); MediaSource secondSource = new FakeMediaSource(secondTimeline);
AtomicLong positionAfterReprepare = new AtomicLong(); AtomicLong positionAfterReprepare = new AtomicLong();
@ -1320,15 +1324,15 @@ public final class ExoPlayerTest {
Timeline timeline = Timeline timeline =
new FakeTimeline( new FakeTimeline(
new TimelineWindowDefinition(/* periodCount= */ 1, /* id= */ firstWindowId)); new TimelineWindowDefinition(/* periodCount= */ 1, /* id= */ firstWindowId));
Timeline firstExpectedDummyTimeline = Timeline firstExpectedPlaceholderTimeline =
new MaskingMediaSource.DummyTimeline( new MaskingMediaSource.PlaceholderTimeline(
FakeTimeline.FAKE_MEDIA_ITEM.buildUpon().setTag(firstWindowId).build()); FakeTimeline.FAKE_MEDIA_ITEM.buildUpon().setTag(firstWindowId).build());
Object secondWindowId = new Object(); Object secondWindowId = new Object();
Timeline secondTimeline = Timeline secondTimeline =
new FakeTimeline( new FakeTimeline(
new TimelineWindowDefinition(/* periodCount= */ 1, /* id= */ secondWindowId)); new TimelineWindowDefinition(/* periodCount= */ 1, /* id= */ secondWindowId));
Timeline secondExpectedDummyTimeline = Timeline secondExpectedPlaceholderTimeline =
new MaskingMediaSource.DummyTimeline( new MaskingMediaSource.PlaceholderTimeline(
FakeTimeline.FAKE_MEDIA_ITEM.buildUpon().setTag(secondWindowId).build()); FakeTimeline.FAKE_MEDIA_ITEM.buildUpon().setTag(secondWindowId).build());
MediaSource secondSource = new FakeMediaSource(secondTimeline); MediaSource secondSource = new FakeMediaSource(secondTimeline);
AtomicLong positionAfterReprepare = new AtomicLong(); AtomicLong positionAfterReprepare = new AtomicLong();
@ -1359,7 +1363,10 @@ public final class ExoPlayerTest {
.blockUntilEnded(TIMEOUT_MS); .blockUntilEnded(TIMEOUT_MS);
testRunner.assertTimelinesSame( testRunner.assertTimelinesSame(
firstExpectedDummyTimeline, timeline, secondExpectedDummyTimeline, secondTimeline); firstExpectedPlaceholderTimeline,
timeline,
secondExpectedPlaceholderTimeline,
secondTimeline);
testRunner.assertTimelineChangeReasonsEqual( testRunner.assertTimelineChangeReasonsEqual(
Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED, Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED,
Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE, Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE,
@ -1374,15 +1381,15 @@ public final class ExoPlayerTest {
Timeline timeline = Timeline timeline =
new FakeTimeline( new FakeTimeline(
new TimelineWindowDefinition(/* periodCount= */ 1, /* id= */ firstWindowId)); new TimelineWindowDefinition(/* periodCount= */ 1, /* id= */ firstWindowId));
Timeline firstExpectedDummyTimeline = Timeline firstExpectedPlaceholderTimeline =
new MaskingMediaSource.DummyTimeline( new MaskingMediaSource.PlaceholderTimeline(
FakeTimeline.FAKE_MEDIA_ITEM.buildUpon().setTag(firstWindowId).build()); FakeTimeline.FAKE_MEDIA_ITEM.buildUpon().setTag(firstWindowId).build());
Object secondWindowId = new Object(); Object secondWindowId = new Object();
Timeline secondTimeline = Timeline secondTimeline =
new FakeTimeline( new FakeTimeline(
new TimelineWindowDefinition(/* periodCount= */ 1, /* id= */ secondWindowId)); new TimelineWindowDefinition(/* periodCount= */ 1, /* id= */ secondWindowId));
Timeline secondExpectedDummyTimeline = Timeline secondExpectedPlaceholderTimeline =
new MaskingMediaSource.DummyTimeline( new MaskingMediaSource.PlaceholderTimeline(
FakeTimeline.FAKE_MEDIA_ITEM.buildUpon().setTag(secondWindowId).build()); FakeTimeline.FAKE_MEDIA_ITEM.buildUpon().setTag(secondWindowId).build());
MediaSource secondSource = new FakeMediaSource(secondTimeline); MediaSource secondSource = new FakeMediaSource(secondTimeline);
AtomicLong positionAfterReprepare = new AtomicLong(); AtomicLong positionAfterReprepare = new AtomicLong();
@ -1413,7 +1420,10 @@ public final class ExoPlayerTest {
.blockUntilEnded(TIMEOUT_MS); .blockUntilEnded(TIMEOUT_MS);
testRunner.assertTimelinesSame( testRunner.assertTimelinesSame(
firstExpectedDummyTimeline, timeline, secondExpectedDummyTimeline, secondTimeline); firstExpectedPlaceholderTimeline,
timeline,
secondExpectedPlaceholderTimeline,
secondTimeline);
testRunner.assertTimelineChangeReasonsEqual( testRunner.assertTimelineChangeReasonsEqual(
Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED, Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED,
Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE, Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE,
@ -1439,7 +1449,7 @@ public final class ExoPlayerTest {
.start() .start()
.blockUntilActionScheduleFinished(TIMEOUT_MS) .blockUntilActionScheduleFinished(TIMEOUT_MS)
.blockUntilEnded(TIMEOUT_MS); .blockUntilEnded(TIMEOUT_MS);
testRunner.assertTimelinesSame(dummyTimeline, Timeline.EMPTY); testRunner.assertTimelinesSame(placeholderTimeline, Timeline.EMPTY);
testRunner.assertTimelineChangeReasonsEqual( testRunner.assertTimelineChangeReasonsEqual(
Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED, Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED,
Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED); Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED);
@ -1465,7 +1475,7 @@ public final class ExoPlayerTest {
.start() .start()
.blockUntilActionScheduleFinished(TIMEOUT_MS) .blockUntilActionScheduleFinished(TIMEOUT_MS)
.blockUntilEnded(TIMEOUT_MS); .blockUntilEnded(TIMEOUT_MS);
testRunner.assertTimelinesSame(dummyTimeline, timeline); testRunner.assertTimelinesSame(placeholderTimeline, timeline);
testRunner.assertTimelineChangeReasonsEqual( testRunner.assertTimelineChangeReasonsEqual(
Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED, Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED,
Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE); Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE);
@ -1493,7 +1503,7 @@ public final class ExoPlayerTest {
} catch (ExoPlaybackException e) { } catch (ExoPlaybackException e) {
// Expected exception. // Expected exception.
} }
testRunner.assertTimelinesSame(dummyTimeline, timeline); testRunner.assertTimelinesSame(placeholderTimeline, timeline);
testRunner.assertTimelineChangeReasonsEqual( testRunner.assertTimelineChangeReasonsEqual(
Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED, Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED,
Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE); Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE);
@ -1542,7 +1552,7 @@ public final class ExoPlayerTest {
.start() .start()
.blockUntilActionScheduleFinished(TIMEOUT_MS) .blockUntilActionScheduleFinished(TIMEOUT_MS)
.blockUntilEnded(TIMEOUT_MS)); .blockUntilEnded(TIMEOUT_MS));
testRunner.assertTimelinesSame(dummyTimeline, timeline); testRunner.assertTimelinesSame(placeholderTimeline, timeline);
testRunner.assertTimelineChangeReasonsEqual( testRunner.assertTimelineChangeReasonsEqual(
Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED, Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED,
Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE); Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE);
@ -1821,7 +1831,7 @@ public final class ExoPlayerTest {
} catch (ExoPlaybackException e) { } catch (ExoPlaybackException e) {
// Expected exception. // Expected exception.
} }
testRunner.assertTimelinesSame(dummyTimeline, timeline, dummyTimeline, timeline); testRunner.assertTimelinesSame(placeholderTimeline, timeline, placeholderTimeline, timeline);
testRunner.assertTimelineChangeReasonsEqual( testRunner.assertTimelineChangeReasonsEqual(
Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED, Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED,
Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE, Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE,
@ -3840,7 +3850,7 @@ public final class ExoPlayerTest {
Timeline timeline2 = new FakeTimeline(secondWindowDefinition); Timeline timeline2 = new FakeTimeline(secondWindowDefinition);
MediaSource mediaSource1 = new FakeMediaSource(timeline1); MediaSource mediaSource1 = new FakeMediaSource(timeline1);
MediaSource mediaSource2 = new FakeMediaSource(timeline2); MediaSource mediaSource2 = new FakeMediaSource(timeline2);
Timeline expectedDummyTimeline = Timeline expectedPlaceholderTimeline =
new FakeTimeline( new FakeTimeline(
TimelineWindowDefinition.createDummy(/* tag= */ 1), TimelineWindowDefinition.createDummy(/* tag= */ 1),
TimelineWindowDefinition.createDummy(/* tag= */ 2)); TimelineWindowDefinition.createDummy(/* tag= */ 2));
@ -3867,7 +3877,7 @@ public final class ExoPlayerTest {
Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE, Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE,
Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED); Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED);
exoPlayerTestRunner.assertTimelinesSame( exoPlayerTestRunner.assertTimelinesSame(
expectedDummyTimeline, expectedRealTimeline, expectedRealTimelineAfterMove); expectedPlaceholderTimeline, expectedRealTimeline, expectedRealTimelineAfterMove);
} }
@Test @Test
@ -3913,7 +3923,7 @@ public final class ExoPlayerTest {
.blockUntilActionScheduleFinished(TIMEOUT_MS) .blockUntilActionScheduleFinished(TIMEOUT_MS)
.blockUntilEnded(TIMEOUT_MS); .blockUntilEnded(TIMEOUT_MS);
Timeline expectedDummyTimeline = Timeline expectedPlaceholderTimeline =
new FakeTimeline( new FakeTimeline(
TimelineWindowDefinition.createDummy(/* tag= */ 1), TimelineWindowDefinition.createDummy(/* tag= */ 1),
TimelineWindowDefinition.createDummy(/* tag= */ 2), TimelineWindowDefinition.createDummy(/* tag= */ 2),
@ -3927,7 +3937,7 @@ public final class ExoPlayerTest {
Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE, Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE,
Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED); Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED);
exoPlayerTestRunner.assertTimelinesSame( exoPlayerTestRunner.assertTimelinesSame(
expectedDummyTimeline, expectedRealTimeline, expectedRealTimelineAfterRemove); expectedPlaceholderTimeline, expectedRealTimeline, expectedRealTimelineAfterRemove);
} }
@Test @Test
@ -3973,7 +3983,7 @@ public final class ExoPlayerTest {
.blockUntilActionScheduleFinished(TIMEOUT_MS) .blockUntilActionScheduleFinished(TIMEOUT_MS)
.blockUntilEnded(TIMEOUT_MS); .blockUntilEnded(TIMEOUT_MS);
Timeline expectedDummyTimeline = Timeline expectedPlaceholderTimeline =
new FakeTimeline( new FakeTimeline(
TimelineWindowDefinition.createDummy(/* tag= */ 1), TimelineWindowDefinition.createDummy(/* tag= */ 1),
TimelineWindowDefinition.createDummy(/* tag= */ 2), TimelineWindowDefinition.createDummy(/* tag= */ 2),
@ -3986,7 +3996,7 @@ public final class ExoPlayerTest {
Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE, Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE,
Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED); Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED);
exoPlayerTestRunner.assertTimelinesSame( exoPlayerTestRunner.assertTimelinesSame(
expectedDummyTimeline, expectedRealTimeline, expectedRealTimelineAfterRemove); expectedPlaceholderTimeline, expectedRealTimeline, expectedRealTimelineAfterRemove);
} }
@Test @Test
@ -4010,7 +4020,7 @@ public final class ExoPlayerTest {
exoPlayerTestRunner.assertPlaybackStatesEqual( exoPlayerTestRunner.assertPlaybackStatesEqual(
Player.STATE_BUFFERING, Player.STATE_READY, Player.STATE_ENDED); Player.STATE_BUFFERING, Player.STATE_READY, Player.STATE_ENDED);
exoPlayerTestRunner.assertTimelinesSame(dummyTimeline, timeline, Timeline.EMPTY); exoPlayerTestRunner.assertTimelinesSame(placeholderTimeline, timeline, Timeline.EMPTY);
exoPlayerTestRunner.assertTimelineChangeReasonsEqual( exoPlayerTestRunner.assertTimelineChangeReasonsEqual(
Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED /* media item set (masked timeline) */, Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED /* media item set (masked timeline) */,
Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE /* source prepared */, Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE /* source prepared */,
@ -4040,7 +4050,7 @@ public final class ExoPlayerTest {
.blockUntilEnded(TIMEOUT_MS); .blockUntilEnded(TIMEOUT_MS);
exoPlayerTestRunner.assertTimelinesSame( exoPlayerTestRunner.assertTimelinesSame(
dummyTimeline, placeholderTimeline,
timeline, timeline,
Timeline.EMPTY, Timeline.EMPTY,
new FakeMediaSource.InitialTimeline(secondTimeline), new FakeMediaSource.InitialTimeline(secondTimeline),
@ -4064,7 +4074,8 @@ public final class ExoPlayerTest {
int[] maskingPlaybackState = {C.INDEX_UNSET}; int[] maskingPlaybackState = {C.INDEX_UNSET};
ActionSchedule actionSchedule = ActionSchedule actionSchedule =
new ActionSchedule.Builder(TAG) new ActionSchedule.Builder(TAG)
.waitForTimelineChanged(dummyTimeline, Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED) .waitForTimelineChanged(
placeholderTimeline, Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED)
.executeRunnable( .executeRunnable(
new PlaybackStateCollector(/* index= */ 0, playbackStates, timelineWindowCounts)) new PlaybackStateCollector(/* index= */ 0, playbackStates, timelineWindowCounts))
.clearMediaItems() .clearMediaItems()
@ -4113,7 +4124,7 @@ public final class ExoPlayerTest {
Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED /* set media items */, Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED /* set media items */,
Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED /* add media items */, Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED /* add media items */,
Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE /* source update after prepare */); Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE /* source update after prepare */);
Timeline expectedSecondDummyTimeline = Timeline expectedSecondPlaceholderTimeline =
new FakeTimeline( new FakeTimeline(
TimelineWindowDefinition.createDummy(/* tag= */ 0), TimelineWindowDefinition.createDummy(/* tag= */ 0),
TimelineWindowDefinition.createDummy(/* tag= */ 0)); TimelineWindowDefinition.createDummy(/* tag= */ 0));
@ -4132,10 +4143,10 @@ public final class ExoPlayerTest {
/* isDynamic= */ false, /* isDynamic= */ false,
/* durationUs= */ 10_000_000)); /* durationUs= */ 10_000_000));
exoPlayerTestRunner.assertTimelinesSame( exoPlayerTestRunner.assertTimelinesSame(
dummyTimeline, placeholderTimeline,
Timeline.EMPTY, Timeline.EMPTY,
dummyTimeline, placeholderTimeline,
expectedSecondDummyTimeline, expectedSecondPlaceholderTimeline,
expectedSecondRealTimeline); expectedSecondRealTimeline);
assertArrayEquals(new int[] {Player.STATE_IDLE}, maskingPlaybackState); assertArrayEquals(new int[] {Player.STATE_IDLE}, maskingPlaybackState);
} }
@ -4179,13 +4190,13 @@ public final class ExoPlayerTest {
Player.STATE_READY, Player.STATE_READY,
Player.STATE_ENDED); Player.STATE_ENDED);
exoPlayerTestRunner.assertTimelinesSame( exoPlayerTestRunner.assertTimelinesSame(
dummyTimeline, placeholderTimeline,
timeline, timeline,
Timeline.EMPTY, Timeline.EMPTY,
dummyTimeline, placeholderTimeline,
timeline, timeline,
Timeline.EMPTY, Timeline.EMPTY,
dummyTimeline, placeholderTimeline,
timeline); timeline);
exoPlayerTestRunner.assertTimelineChangeReasonsEqual( exoPlayerTestRunner.assertTimelineChangeReasonsEqual(
Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED /* media item set (masked timeline) */, Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED /* media item set (masked timeline) */,
@ -4242,7 +4253,7 @@ public final class ExoPlayerTest {
Player.STATE_READY, Player.STATE_READY,
Player.STATE_ENDED); Player.STATE_ENDED);
exoPlayerTestRunner.assertTimelinesSame( exoPlayerTestRunner.assertTimelinesSame(
dummyTimeline, timeline, Timeline.EMPTY, dummyTimeline, timeline); placeholderTimeline, timeline, Timeline.EMPTY, placeholderTimeline, timeline);
exoPlayerTestRunner.assertTimelineChangeReasonsEqual( exoPlayerTestRunner.assertTimelineChangeReasonsEqual(
Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED /* media item set (masked timeline) */, Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED /* media item set (masked timeline) */,
Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE, /* source prepared */ Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE, /* source prepared */
@ -4298,7 +4309,7 @@ public final class ExoPlayerTest {
exoPlayerTestRunner.assertPlaybackStatesEqual( exoPlayerTestRunner.assertPlaybackStatesEqual(
Player.STATE_BUFFERING, Player.STATE_READY, Player.STATE_ENDED); Player.STATE_BUFFERING, Player.STATE_READY, Player.STATE_ENDED);
exoPlayerTestRunner.assertTimelinesSame(dummyTimeline, timeline); exoPlayerTestRunner.assertTimelinesSame(placeholderTimeline, timeline);
exoPlayerTestRunner.assertTimelineChangeReasonsEqual( exoPlayerTestRunner.assertTimelineChangeReasonsEqual(
Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED /* media item set (masked timeline) */, Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED /* media item set (masked timeline) */,
Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE /* source prepared */); Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE /* source prepared */);
@ -4558,8 +4569,8 @@ public final class ExoPlayerTest {
new FakeMediaSource(new FakeTimeline(/* windowCount= */ 1)), new FakeMediaSource(new FakeTimeline(/* windowCount= */ 1)),
new DefaultDataSourceFactory( new DefaultDataSourceFactory(
context, Util.getUserAgent(context, ExoPlayerLibraryInfo.VERSION_SLASHY)), context, Util.getUserAgent(context, ExoPlayerLibraryInfo.VERSION_SLASHY)),
new DummyAdsLoader(), new FakeAdsLoader(),
new DummyAdViewProvider()); new FakeAdViewProvider());
Exception[] exception = {null}; Exception[] exception = {null};
ActionSchedule actionSchedule = ActionSchedule actionSchedule =
new ActionSchedule.Builder(TAG) new ActionSchedule.Builder(TAG)
@ -4596,8 +4607,8 @@ public final class ExoPlayerTest {
mediaSource, mediaSource,
new DefaultDataSourceFactory( new DefaultDataSourceFactory(
context, Util.getUserAgent(context, ExoPlayerLibraryInfo.VERSION_SLASHY)), context, Util.getUserAgent(context, ExoPlayerLibraryInfo.VERSION_SLASHY)),
new DummyAdsLoader(), new FakeAdsLoader(),
new DummyAdViewProvider()); new FakeAdViewProvider());
final Exception[] exception = {null}; final Exception[] exception = {null};
ActionSchedule actionSchedule = ActionSchedule actionSchedule =
new ActionSchedule.Builder(TAG) new ActionSchedule.Builder(TAG)
@ -4636,8 +4647,8 @@ public final class ExoPlayerTest {
mediaSource, mediaSource,
new DefaultDataSourceFactory( new DefaultDataSourceFactory(
context, Util.getUserAgent(context, ExoPlayerLibraryInfo.VERSION_SLASHY)), context, Util.getUserAgent(context, ExoPlayerLibraryInfo.VERSION_SLASHY)),
new DummyAdsLoader(), new FakeAdsLoader(),
new DummyAdViewProvider()); new FakeAdViewProvider());
final Exception[] exception = {null}; final Exception[] exception = {null};
ActionSchedule actionSchedule = ActionSchedule actionSchedule =
new ActionSchedule.Builder(TAG) new ActionSchedule.Builder(TAG)
@ -6471,7 +6482,7 @@ public final class ExoPlayerTest {
@Override @Override
public boolean continueLoading(long positionUs) { public boolean continueLoading(long positionUs) {
loader.startLoading( loader.startLoading(
loadable, new DummyLoaderCallback(), /* defaultMinRetryCount= */ 1); loadable, new FakeLoaderCallback(), /* defaultMinRetryCount= */ 1);
return true; return true;
} }
@ -6862,7 +6873,7 @@ public final class ExoPlayerTest {
} }
} }
private static final class DummyLoaderCallback implements Loader.Callback<Loader.Loadable> { private static final class FakeLoaderCallback implements Loader.Callback<Loader.Loadable> {
@Override @Override
public void onLoadCompleted( public void onLoadCompleted(
Loader.Loadable loadable, long elapsedRealtimeMs, long loadDurationMs) {} Loader.Loadable loadable, long elapsedRealtimeMs, long loadDurationMs) {}
@ -6882,7 +6893,7 @@ public final class ExoPlayerTest {
} }
} }
private static class DummyAdsLoader implements AdsLoader { private static class FakeAdsLoader implements AdsLoader {
@Override @Override
public void setPlayer(@Nullable Player player) {} public void setPlayer(@Nullable Player player) {}
@ -6903,7 +6914,7 @@ public final class ExoPlayerTest {
public void handlePrepareError(int adGroupIndex, int adIndexInAdGroup, IOException exception) {} public void handlePrepareError(int adGroupIndex, int adIndexInAdGroup, IOException exception) {}
} }
private static class DummyAdViewProvider implements AdsLoader.AdViewProvider { private static class FakeAdViewProvider implements AdsLoader.AdViewProvider {
@Override @Override
public ViewGroup getAdViewGroup() { public ViewGroup getAdViewGroup() {

View File

@ -786,7 +786,7 @@ public final class AnalyticsCollectorTest {
assertThat(listener.getEvents(EVENT_TIMELINE_CHANGED)) assertThat(listener.getEvents(EVENT_TIMELINE_CHANGED))
.containsExactly( .containsExactly(
WINDOW_0 /* PLAYLIST_CHANGED */, WINDOW_0 /* PLAYLIST_CHANGED */,
window0Period1Seq0 /* SOURCE_UPDATE (concatenated timeline replaces dummy) */, window0Period1Seq0 /* SOURCE_UPDATE (concatenated timeline replaces placeholder) */,
period1Seq0 /* SOURCE_UPDATE (child sources in concatenating source moved) */) period1Seq0 /* SOURCE_UPDATE (child sources in concatenating source moved) */)
.inOrder(); .inOrder();
assertThat(listener.getEvents(EVENT_LOADING_CHANGED)) assertThat(listener.getEvents(EVENT_LOADING_CHANGED))

View File

@ -94,7 +94,7 @@ public class VersionTableTest {
@Test @Test
public void doesTableExist_existingTable_returnsTrue() { public void doesTableExist_existingTable_returnsTrue() {
String table = "TestTable"; String table = "TestTable";
databaseProvider.getWritableDatabase().execSQL("CREATE TABLE " + table + " (dummy INTEGER)"); databaseProvider.getWritableDatabase().execSQL("CREATE TABLE " + table + " (test INTEGER)");
assertThat(VersionTable.tableExists(database, table)).isTrue(); assertThat(VersionTable.tableExists(database, table)).isTrue();
} }
} }

View File

@ -56,7 +56,7 @@ public class DownloadManagerTest {
private static final int APP_STOP_REASON = 1; private static final int APP_STOP_REASON = 1;
/** The minimum number of times a download must be retried before failing. */ /** The minimum number of times a download must be retried before failing. */
private static final int MIN_RETRY_COUNT = 3; private static final int MIN_RETRY_COUNT = 3;
/** Dummy value for the current time. */ /** Test value for the current time. */
private static final long NOW_MS = 1234; private static final long NOW_MS = 1234;
private static final String ID1 = "id1"; private static final String ID1 = "id1";
@ -68,19 +68,19 @@ public class DownloadManagerTest {
private DownloadManager downloadManager; private DownloadManager downloadManager;
private TestDownloadManagerListener downloadManagerListener; private TestDownloadManagerListener downloadManagerListener;
private DummyMainThread dummyMainThread; private DummyMainThread testThread;
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
ShadowLog.stream = System.out; ShadowLog.stream = System.out;
dummyMainThread = new DummyMainThread(); testThread = new DummyMainThread();
setupDownloadManager(/* maxParallelDownloads= */ 100); setupDownloadManager(/* maxParallelDownloads= */ 100);
} }
@After @After
public void tearDown() throws Exception { public void tearDown() throws Exception {
releaseDownloadManager(); releaseDownloadManager();
dummyMainThread.release(); testThread.release();
} }
@Test @Test
@ -728,7 +728,7 @@ public class DownloadManagerTest {
} }
private void runOnMainThread(TestRunnable r) { private void runOnMainThread(TestRunnable r) {
dummyMainThread.runTestOnMainThread(r); testThread.runTestOnMainThread(r);
} }
private FakeDownloader getDownloaderAt(int index) throws InterruptedException { private FakeDownloader getDownloaderAt(int index) throws InterruptedException {

View File

@ -30,7 +30,7 @@ import com.google.android.exoplayer2.Timeline.Window;
import com.google.android.exoplayer2.drm.DrmSessionEventListener; import com.google.android.exoplayer2.drm.DrmSessionEventListener;
import com.google.android.exoplayer2.drm.DrmSessionManager; import com.google.android.exoplayer2.drm.DrmSessionManager;
import com.google.android.exoplayer2.source.ClippingMediaSource.IllegalClippingException; import com.google.android.exoplayer2.source.ClippingMediaSource.IllegalClippingException;
import com.google.android.exoplayer2.source.MaskingMediaSource.DummyTimeline; import com.google.android.exoplayer2.source.MaskingMediaSource.PlaceholderTimeline;
import com.google.android.exoplayer2.source.MediaSource.MediaPeriodId; import com.google.android.exoplayer2.source.MediaSource.MediaPeriodId;
import com.google.android.exoplayer2.testutil.FakeMediaPeriod; import com.google.android.exoplayer2.testutil.FakeMediaPeriod;
import com.google.android.exoplayer2.testutil.FakeMediaSource; import com.google.android.exoplayer2.testutil.FakeMediaSource;
@ -173,7 +173,7 @@ public final class ClippingMediaSourceTest {
// Timeline that's dynamic and not seekable. A child source might report such a timeline prior // Timeline that's dynamic and not seekable. A child source might report such a timeline prior
// to it having loaded sufficient data to establish its duration and seekability. Such timelines // to it having loaded sufficient data to establish its duration and seekability. Such timelines
// should not result in clipping failure. // should not result in clipping failure.
Timeline timeline = new DummyTimeline(MediaItem.fromUri(Uri.EMPTY)); Timeline timeline = new PlaceholderTimeline(MediaItem.fromUri(Uri.EMPTY));
Timeline clippedTimeline = Timeline clippedTimeline =
getClippedTimeline( getClippedTimeline(

View File

@ -408,15 +408,15 @@ public final class ConcatenatingMediaSourceTest {
public void customCallbackBeforePreparationAddSingle() throws Exception { public void customCallbackBeforePreparationAddSingle() throws Exception {
CountDownLatch runnableInvoked = new CountDownLatch(1); CountDownLatch runnableInvoked = new CountDownLatch(1);
DummyMainThread dummyMainThread = new DummyMainThread(); DummyMainThread testThread = new DummyMainThread();
dummyMainThread.runOnMainThread( testThread.runOnMainThread(
() -> () ->
mediaSource.addMediaSource( mediaSource.addMediaSource(
createFakeMediaSource(), createFakeMediaSource(),
Util.createHandlerForCurrentLooper(), Util.createHandlerForCurrentLooper(),
runnableInvoked::countDown)); runnableInvoked::countDown));
runnableInvoked.await(MediaSourceTestRunner.TIMEOUT_MS, TimeUnit.MILLISECONDS); runnableInvoked.await(MediaSourceTestRunner.TIMEOUT_MS, TimeUnit.MILLISECONDS);
dummyMainThread.release(); testThread.release();
assertThat(runnableInvoked.getCount()).isEqualTo(0); assertThat(runnableInvoked.getCount()).isEqualTo(0);
} }
@ -425,15 +425,15 @@ public final class ConcatenatingMediaSourceTest {
public void customCallbackBeforePreparationAddMultiple() throws Exception { public void customCallbackBeforePreparationAddMultiple() throws Exception {
CountDownLatch runnableInvoked = new CountDownLatch(1); CountDownLatch runnableInvoked = new CountDownLatch(1);
DummyMainThread dummyMainThread = new DummyMainThread(); DummyMainThread testThread = new DummyMainThread();
dummyMainThread.runOnMainThread( testThread.runOnMainThread(
() -> () ->
mediaSource.addMediaSources( mediaSource.addMediaSources(
Arrays.asList(new MediaSource[] {createFakeMediaSource(), createFakeMediaSource()}), Arrays.asList(new MediaSource[] {createFakeMediaSource(), createFakeMediaSource()}),
Util.createHandlerForCurrentLooper(), Util.createHandlerForCurrentLooper(),
runnableInvoked::countDown)); runnableInvoked::countDown));
runnableInvoked.await(MediaSourceTestRunner.TIMEOUT_MS, TimeUnit.MILLISECONDS); runnableInvoked.await(MediaSourceTestRunner.TIMEOUT_MS, TimeUnit.MILLISECONDS);
dummyMainThread.release(); testThread.release();
assertThat(runnableInvoked.getCount()).isEqualTo(0); assertThat(runnableInvoked.getCount()).isEqualTo(0);
} }
@ -442,8 +442,8 @@ public final class ConcatenatingMediaSourceTest {
public void customCallbackBeforePreparationAddSingleWithIndex() throws Exception { public void customCallbackBeforePreparationAddSingleWithIndex() throws Exception {
CountDownLatch runnableInvoked = new CountDownLatch(1); CountDownLatch runnableInvoked = new CountDownLatch(1);
DummyMainThread dummyMainThread = new DummyMainThread(); DummyMainThread testThread = new DummyMainThread();
dummyMainThread.runOnMainThread( testThread.runOnMainThread(
() -> () ->
mediaSource.addMediaSource( mediaSource.addMediaSource(
/* index */ 0, /* index */ 0,
@ -451,7 +451,7 @@ public final class ConcatenatingMediaSourceTest {
Util.createHandlerForCurrentLooper(), Util.createHandlerForCurrentLooper(),
runnableInvoked::countDown)); runnableInvoked::countDown));
runnableInvoked.await(MediaSourceTestRunner.TIMEOUT_MS, TimeUnit.MILLISECONDS); runnableInvoked.await(MediaSourceTestRunner.TIMEOUT_MS, TimeUnit.MILLISECONDS);
dummyMainThread.release(); testThread.release();
assertThat(runnableInvoked.getCount()).isEqualTo(0); assertThat(runnableInvoked.getCount()).isEqualTo(0);
} }
@ -460,8 +460,8 @@ public final class ConcatenatingMediaSourceTest {
public void customCallbackBeforePreparationAddMultipleWithIndex() throws Exception { public void customCallbackBeforePreparationAddMultipleWithIndex() throws Exception {
CountDownLatch runnableInvoked = new CountDownLatch(1); CountDownLatch runnableInvoked = new CountDownLatch(1);
DummyMainThread dummyMainThread = new DummyMainThread(); DummyMainThread testThread = new DummyMainThread();
dummyMainThread.runOnMainThread( testThread.runOnMainThread(
() -> () ->
mediaSource.addMediaSources( mediaSource.addMediaSources(
/* index */ 0, /* index */ 0,
@ -469,7 +469,7 @@ public final class ConcatenatingMediaSourceTest {
Util.createHandlerForCurrentLooper(), Util.createHandlerForCurrentLooper(),
runnableInvoked::countDown)); runnableInvoked::countDown));
runnableInvoked.await(MediaSourceTestRunner.TIMEOUT_MS, TimeUnit.MILLISECONDS); runnableInvoked.await(MediaSourceTestRunner.TIMEOUT_MS, TimeUnit.MILLISECONDS);
dummyMainThread.release(); testThread.release();
assertThat(runnableInvoked.getCount()).isEqualTo(0); assertThat(runnableInvoked.getCount()).isEqualTo(0);
} }
@ -478,15 +478,15 @@ public final class ConcatenatingMediaSourceTest {
public void customCallbackBeforePreparationRemove() throws Exception { public void customCallbackBeforePreparationRemove() throws Exception {
CountDownLatch runnableInvoked = new CountDownLatch(1); CountDownLatch runnableInvoked = new CountDownLatch(1);
DummyMainThread dummyMainThread = new DummyMainThread(); DummyMainThread testThread = new DummyMainThread();
dummyMainThread.runOnMainThread( testThread.runOnMainThread(
() -> { () -> {
mediaSource.addMediaSource(createFakeMediaSource()); mediaSource.addMediaSource(createFakeMediaSource());
mediaSource.removeMediaSource( mediaSource.removeMediaSource(
/* index */ 0, Util.createHandlerForCurrentLooper(), runnableInvoked::countDown); /* index */ 0, Util.createHandlerForCurrentLooper(), runnableInvoked::countDown);
}); });
runnableInvoked.await(MediaSourceTestRunner.TIMEOUT_MS, TimeUnit.MILLISECONDS); runnableInvoked.await(MediaSourceTestRunner.TIMEOUT_MS, TimeUnit.MILLISECONDS);
dummyMainThread.release(); testThread.release();
assertThat(runnableInvoked.getCount()).isEqualTo(0); assertThat(runnableInvoked.getCount()).isEqualTo(0);
} }
@ -495,8 +495,8 @@ public final class ConcatenatingMediaSourceTest {
public void customCallbackBeforePreparationMove() throws Exception { public void customCallbackBeforePreparationMove() throws Exception {
CountDownLatch runnableInvoked = new CountDownLatch(1); CountDownLatch runnableInvoked = new CountDownLatch(1);
DummyMainThread dummyMainThread = new DummyMainThread(); DummyMainThread testThread = new DummyMainThread();
dummyMainThread.runOnMainThread( testThread.runOnMainThread(
() -> { () -> {
mediaSource.addMediaSources( mediaSource.addMediaSources(
Arrays.asList(new MediaSource[] {createFakeMediaSource(), createFakeMediaSource()})); Arrays.asList(new MediaSource[] {createFakeMediaSource(), createFakeMediaSource()}));
@ -507,35 +507,35 @@ public final class ConcatenatingMediaSourceTest {
runnableInvoked::countDown); runnableInvoked::countDown);
}); });
runnableInvoked.await(MediaSourceTestRunner.TIMEOUT_MS, TimeUnit.MILLISECONDS); runnableInvoked.await(MediaSourceTestRunner.TIMEOUT_MS, TimeUnit.MILLISECONDS);
dummyMainThread.release(); testThread.release();
assertThat(runnableInvoked.getCount()).isEqualTo(0); assertThat(runnableInvoked.getCount()).isEqualTo(0);
} }
@Test @Test
public void customCallbackAfterPreparationAddSingle() throws Exception { public void customCallbackAfterPreparationAddSingle() throws Exception {
DummyMainThread dummyMainThread = new DummyMainThread(); DummyMainThread testThread = new DummyMainThread();
try { try {
testRunner.prepareSource(); testRunner.prepareSource();
final TimelineGrabber timelineGrabber = new TimelineGrabber(testRunner); final TimelineGrabber timelineGrabber = new TimelineGrabber(testRunner);
dummyMainThread.runOnMainThread( testThread.runOnMainThread(
() -> () ->
mediaSource.addMediaSource( mediaSource.addMediaSource(
createFakeMediaSource(), Util.createHandlerForCurrentLooper(), timelineGrabber)); createFakeMediaSource(), Util.createHandlerForCurrentLooper(), timelineGrabber));
Timeline timeline = timelineGrabber.assertTimelineChangeBlocking(); Timeline timeline = timelineGrabber.assertTimelineChangeBlocking();
assertThat(timeline.getWindowCount()).isEqualTo(1); assertThat(timeline.getWindowCount()).isEqualTo(1);
} finally { } finally {
dummyMainThread.release(); testThread.release();
} }
} }
@Test @Test
public void customCallbackAfterPreparationAddMultiple() throws Exception { public void customCallbackAfterPreparationAddMultiple() throws Exception {
DummyMainThread dummyMainThread = new DummyMainThread(); DummyMainThread testThread = new DummyMainThread();
try { try {
testRunner.prepareSource(); testRunner.prepareSource();
final TimelineGrabber timelineGrabber = new TimelineGrabber(testRunner); final TimelineGrabber timelineGrabber = new TimelineGrabber(testRunner);
dummyMainThread.runOnMainThread( testThread.runOnMainThread(
() -> () ->
mediaSource.addMediaSources( mediaSource.addMediaSources(
Arrays.asList( Arrays.asList(
@ -545,17 +545,17 @@ public final class ConcatenatingMediaSourceTest {
Timeline timeline = timelineGrabber.assertTimelineChangeBlocking(); Timeline timeline = timelineGrabber.assertTimelineChangeBlocking();
assertThat(timeline.getWindowCount()).isEqualTo(2); assertThat(timeline.getWindowCount()).isEqualTo(2);
} finally { } finally {
dummyMainThread.release(); testThread.release();
} }
} }
@Test @Test
public void customCallbackAfterPreparationAddSingleWithIndex() throws Exception { public void customCallbackAfterPreparationAddSingleWithIndex() throws Exception {
DummyMainThread dummyMainThread = new DummyMainThread(); DummyMainThread testThread = new DummyMainThread();
try { try {
testRunner.prepareSource(); testRunner.prepareSource();
final TimelineGrabber timelineGrabber = new TimelineGrabber(testRunner); final TimelineGrabber timelineGrabber = new TimelineGrabber(testRunner);
dummyMainThread.runOnMainThread( testThread.runOnMainThread(
() -> () ->
mediaSource.addMediaSource( mediaSource.addMediaSource(
/* index */ 0, /* index */ 0,
@ -565,17 +565,17 @@ public final class ConcatenatingMediaSourceTest {
Timeline timeline = timelineGrabber.assertTimelineChangeBlocking(); Timeline timeline = timelineGrabber.assertTimelineChangeBlocking();
assertThat(timeline.getWindowCount()).isEqualTo(1); assertThat(timeline.getWindowCount()).isEqualTo(1);
} finally { } finally {
dummyMainThread.release(); testThread.release();
} }
} }
@Test @Test
public void customCallbackAfterPreparationAddMultipleWithIndex() throws Exception { public void customCallbackAfterPreparationAddMultipleWithIndex() throws Exception {
DummyMainThread dummyMainThread = new DummyMainThread(); DummyMainThread testThread = new DummyMainThread();
try { try {
testRunner.prepareSource(); testRunner.prepareSource();
final TimelineGrabber timelineGrabber = new TimelineGrabber(testRunner); final TimelineGrabber timelineGrabber = new TimelineGrabber(testRunner);
dummyMainThread.runOnMainThread( testThread.runOnMainThread(
() -> () ->
mediaSource.addMediaSources( mediaSource.addMediaSources(
/* index */ 0, /* index */ 0,
@ -586,36 +586,36 @@ public final class ConcatenatingMediaSourceTest {
Timeline timeline = timelineGrabber.assertTimelineChangeBlocking(); Timeline timeline = timelineGrabber.assertTimelineChangeBlocking();
assertThat(timeline.getWindowCount()).isEqualTo(2); assertThat(timeline.getWindowCount()).isEqualTo(2);
} finally { } finally {
dummyMainThread.release(); testThread.release();
} }
} }
@Test @Test
public void customCallbackAfterPreparationRemove() throws Exception { public void customCallbackAfterPreparationRemove() throws Exception {
DummyMainThread dummyMainThread = new DummyMainThread(); DummyMainThread testThread = new DummyMainThread();
try { try {
testRunner.prepareSource(); testRunner.prepareSource();
dummyMainThread.runOnMainThread(() -> mediaSource.addMediaSource(createFakeMediaSource())); testThread.runOnMainThread(() -> mediaSource.addMediaSource(createFakeMediaSource()));
testRunner.assertTimelineChangeBlocking(); testRunner.assertTimelineChangeBlocking();
final TimelineGrabber timelineGrabber = new TimelineGrabber(testRunner); final TimelineGrabber timelineGrabber = new TimelineGrabber(testRunner);
dummyMainThread.runOnMainThread( testThread.runOnMainThread(
() -> () ->
mediaSource.removeMediaSource( mediaSource.removeMediaSource(
/* index */ 0, Util.createHandlerForCurrentLooper(), timelineGrabber)); /* index */ 0, Util.createHandlerForCurrentLooper(), timelineGrabber));
Timeline timeline = timelineGrabber.assertTimelineChangeBlocking(); Timeline timeline = timelineGrabber.assertTimelineChangeBlocking();
assertThat(timeline.getWindowCount()).isEqualTo(0); assertThat(timeline.getWindowCount()).isEqualTo(0);
} finally { } finally {
dummyMainThread.release(); testThread.release();
} }
} }
@Test @Test
public void customCallbackAfterPreparationMove() throws Exception { public void customCallbackAfterPreparationMove() throws Exception {
DummyMainThread dummyMainThread = new DummyMainThread(); DummyMainThread testThread = new DummyMainThread();
try { try {
testRunner.prepareSource(); testRunner.prepareSource();
dummyMainThread.runOnMainThread( testThread.runOnMainThread(
() -> () ->
mediaSource.addMediaSources( mediaSource.addMediaSources(
Arrays.asList( Arrays.asList(
@ -623,7 +623,7 @@ public final class ConcatenatingMediaSourceTest {
testRunner.assertTimelineChangeBlocking(); testRunner.assertTimelineChangeBlocking();
final TimelineGrabber timelineGrabber = new TimelineGrabber(testRunner); final TimelineGrabber timelineGrabber = new TimelineGrabber(testRunner);
dummyMainThread.runOnMainThread( testThread.runOnMainThread(
() -> () ->
mediaSource.moveMediaSource( mediaSource.moveMediaSource(
/* fromIndex */ 1, /* toIndex */ /* fromIndex */ 1, /* toIndex */
@ -633,16 +633,16 @@ public final class ConcatenatingMediaSourceTest {
Timeline timeline = timelineGrabber.assertTimelineChangeBlocking(); Timeline timeline = timelineGrabber.assertTimelineChangeBlocking();
assertThat(timeline.getWindowCount()).isEqualTo(2); assertThat(timeline.getWindowCount()).isEqualTo(2);
} finally { } finally {
dummyMainThread.release(); testThread.release();
} }
} }
@Test @Test
public void customCallbackIsCalledAfterRelease() throws Exception { public void customCallbackIsCalledAfterRelease() throws Exception {
DummyMainThread dummyMainThread = new DummyMainThread(); DummyMainThread testThread = new DummyMainThread();
CountDownLatch callbackCalledCondition = new CountDownLatch(1); CountDownLatch callbackCalledCondition = new CountDownLatch(1);
try { try {
dummyMainThread.runOnMainThread( testThread.runOnMainThread(
() -> { () -> {
MediaSourceCaller caller = mock(MediaSourceCaller.class); MediaSourceCaller caller = mock(MediaSourceCaller.class);
mediaSource.addMediaSources(Arrays.asList(createMediaSources(2))); mediaSource.addMediaSources(Arrays.asList(createMediaSources(2)));
@ -659,7 +659,7 @@ public final class ConcatenatingMediaSourceTest {
MediaSourceTestRunner.TIMEOUT_MS, TimeUnit.MILLISECONDS)) MediaSourceTestRunner.TIMEOUT_MS, TimeUnit.MILLISECONDS))
.isTrue(); .isTrue();
} finally { } finally {
dummyMainThread.release(); testThread.release();
} }
} }
@ -891,10 +891,10 @@ public final class ConcatenatingMediaSourceTest {
@Test @Test
public void clear() throws Exception { public void clear() throws Exception {
DummyMainThread dummyMainThread = new DummyMainThread(); DummyMainThread testThread = new DummyMainThread();
final FakeMediaSource preparedChildSource = createFakeMediaSource(); final FakeMediaSource preparedChildSource = createFakeMediaSource();
final FakeMediaSource unpreparedChildSource = new FakeMediaSource(/* timeline= */ null); final FakeMediaSource unpreparedChildSource = new FakeMediaSource(/* timeline= */ null);
dummyMainThread.runOnMainThread( testThread.runOnMainThread(
() -> { () -> {
mediaSource.addMediaSource(preparedChildSource); mediaSource.addMediaSource(preparedChildSource);
mediaSource.addMediaSource(unpreparedChildSource); mediaSource.addMediaSource(unpreparedChildSource);
@ -902,7 +902,7 @@ public final class ConcatenatingMediaSourceTest {
testRunner.prepareSource(); testRunner.prepareSource();
final TimelineGrabber timelineGrabber = new TimelineGrabber(testRunner); final TimelineGrabber timelineGrabber = new TimelineGrabber(testRunner);
dummyMainThread.runOnMainThread( testThread.runOnMainThread(
() -> mediaSource.clear(Util.createHandlerForCurrentLooper(), timelineGrabber)); () -> mediaSource.clear(Util.createHandlerForCurrentLooper(), timelineGrabber));
Timeline timeline = timelineGrabber.assertTimelineChangeBlocking(); Timeline timeline = timelineGrabber.assertTimelineChangeBlocking();
@ -1050,28 +1050,28 @@ public final class ConcatenatingMediaSourceTest {
public void customCallbackBeforePreparationSetShuffleOrder() throws Exception { public void customCallbackBeforePreparationSetShuffleOrder() throws Exception {
CountDownLatch runnableInvoked = new CountDownLatch(1); CountDownLatch runnableInvoked = new CountDownLatch(1);
DummyMainThread dummyMainThread = new DummyMainThread(); DummyMainThread testThread = new DummyMainThread();
dummyMainThread.runOnMainThread( testThread.runOnMainThread(
() -> () ->
mediaSource.setShuffleOrder( mediaSource.setShuffleOrder(
new ShuffleOrder.UnshuffledShuffleOrder(/* length= */ 0), new ShuffleOrder.UnshuffledShuffleOrder(/* length= */ 0),
Util.createHandlerForCurrentLooper(), Util.createHandlerForCurrentLooper(),
runnableInvoked::countDown)); runnableInvoked::countDown));
runnableInvoked.await(MediaSourceTestRunner.TIMEOUT_MS, TimeUnit.MILLISECONDS); runnableInvoked.await(MediaSourceTestRunner.TIMEOUT_MS, TimeUnit.MILLISECONDS);
dummyMainThread.release(); testThread.release();
assertThat(runnableInvoked.getCount()).isEqualTo(0); assertThat(runnableInvoked.getCount()).isEqualTo(0);
} }
@Test @Test
public void customCallbackAfterPreparationSetShuffleOrder() throws Exception { public void customCallbackAfterPreparationSetShuffleOrder() throws Exception {
DummyMainThread dummyMainThread = new DummyMainThread(); DummyMainThread testThread = new DummyMainThread();
try { try {
mediaSource.addMediaSources( mediaSource.addMediaSources(
Arrays.asList(createFakeMediaSource(), createFakeMediaSource(), createFakeMediaSource())); Arrays.asList(createFakeMediaSource(), createFakeMediaSource(), createFakeMediaSource()));
testRunner.prepareSource(); testRunner.prepareSource();
TimelineGrabber timelineGrabber = new TimelineGrabber(testRunner); TimelineGrabber timelineGrabber = new TimelineGrabber(testRunner);
dummyMainThread.runOnMainThread( testThread.runOnMainThread(
() -> () ->
mediaSource.setShuffleOrder( mediaSource.setShuffleOrder(
new ShuffleOrder.UnshuffledShuffleOrder(/* length= */ 3), new ShuffleOrder.UnshuffledShuffleOrder(/* length= */ 3),
@ -1080,7 +1080,7 @@ public final class ConcatenatingMediaSourceTest {
Timeline timeline = timelineGrabber.assertTimelineChangeBlocking(); Timeline timeline = timelineGrabber.assertTimelineChangeBlocking();
assertThat(timeline.getFirstWindowIndex(/* shuffleModeEnabled= */ true)).isEqualTo(0); assertThat(timeline.getFirstWindowIndex(/* shuffleModeEnabled= */ true)).isEqualTo(0);
} finally { } finally {
dummyMainThread.release(); testThread.release();
} }
} }

View File

@ -123,7 +123,7 @@ public final class SampleQueueTest {
private static final int[] ENCRYPTED_SAMPLE_OFFSETS = new int[] {7, 4, 3, 0}; private static final int[] ENCRYPTED_SAMPLE_OFFSETS = new int[] {7, 4, 3, 0};
private static final byte[] ENCRYPTED_SAMPLE_DATA = new byte[] {1, 1, 1, 1, 1, 1, 1, 1}; private static final byte[] ENCRYPTED_SAMPLE_DATA = new byte[] {1, 1, 1, 1, 1, 1, 1, 1};
private static final TrackOutput.CryptoData DUMMY_CRYPTO_DATA = private static final TrackOutput.CryptoData CRYPTO_DATA =
new TrackOutput.CryptoData(C.CRYPTO_MODE_AES_CTR, new byte[16], 0, 0); new TrackOutput.CryptoData(C.CRYPTO_MODE_AES_CTR, new byte[16], 0, 0);
private Allocator allocator; private Allocator allocator;
@ -1205,7 +1205,7 @@ public final class SampleQueueTest {
sampleFlags[i], sampleFlags[i],
sampleSizes[i], sampleSizes[i],
sampleOffsets[i], sampleOffsets[i],
(sampleFlags[i] & C.BUFFER_FLAG_ENCRYPTED) != 0 ? DUMMY_CRYPTO_DATA : null); (sampleFlags[i] & C.BUFFER_FLAG_ENCRYPTED) != 0 ? CRYPTO_DATA : null);
} }
} }
@ -1222,7 +1222,7 @@ public final class SampleQueueTest {
sampleFlags, sampleFlags,
data.length, data.length,
/* offset= */ 0, /* offset= */ 0,
(sampleFlags & C.BUFFER_FLAG_ENCRYPTED) != 0 ? DUMMY_CRYPTO_DATA : null); (sampleFlags & C.BUFFER_FLAG_ENCRYPTED) != 0 ? CRYPTO_DATA : null);
} }
/** /**

View File

@ -569,7 +569,7 @@ public final class DefaultBandwidthMeterTest {
long[] bitrateEstimates = new long[SIMULATED_TRANSFER_COUNT]; long[] bitrateEstimates = new long[SIMULATED_TRANSFER_COUNT];
Random random = new Random(/* seed= */ 0); Random random = new Random(/* seed= */ 0);
DataSource dataSource = new FakeDataSource(); DataSource dataSource = new FakeDataSource();
DataSpec dataSpec = new DataSpec(Uri.parse("https://dummy.com")); DataSpec dataSpec = new DataSpec(Uri.parse("https://test.com"));
for (int i = 0; i < SIMULATED_TRANSFER_COUNT; i++) { for (int i = 0; i < SIMULATED_TRANSFER_COUNT; i++) {
bandwidthMeter.onTransferStart(dataSource, dataSpec, /* isNetwork= */ true); bandwidthMeter.onTransferStart(dataSource, dataSpec, /* isNetwork= */ true);
clock.advanceTime(random.nextInt(/* bound= */ 5000)); clock.advanceTime(random.nextInt(/* bound= */ 5000));