Skip to content

Commit

Permalink
Make tests use DefaultTrackSelector
Browse files Browse the repository at this point in the history
Issue: #3915

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=192259167
  • Loading branch information
ojw28 committed Apr 10, 2018
1 parent 986095a commit 3568dca
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import com.google.android.exoplayer2.testutil.HostActivity;
import com.google.android.exoplayer2.testutil.HostActivity.HostedTest;
import com.google.android.exoplayer2.testutil.MetricsLogger;
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
import com.google.android.exoplayer2.trackselection.FixedTrackSelection;
import com.google.android.exoplayer2.trackselection.MappingTrackSelector;
import com.google.android.exoplayer2.trackselection.RandomTrackSelection;
Expand Down Expand Up @@ -264,8 +265,8 @@ private DashHostedTest(String tag, String streamName, String manifestUrl,
}

@Override
protected MappingTrackSelector buildTrackSelector(HostActivity host,
BandwidthMeter bandwidthMeter) {
protected DefaultTrackSelector buildTrackSelector(
HostActivity host, BandwidthMeter bandwidthMeter) {
return trackSelector;
}

Expand Down Expand Up @@ -375,7 +376,7 @@ protected void assertPassed(DecoderCounters audioCounters, DecoderCounters video

}

private static final class DashTestTrackSelector extends MappingTrackSelector {
private static final class DashTestTrackSelector extends DefaultTrackSelector {

private final String tag;
private final String audioFormatId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import com.google.android.exoplayer2.testutil.ActionSchedule.ActionNode;
import com.google.android.exoplayer2.testutil.ActionSchedule.PlayerRunnable;
import com.google.android.exoplayer2.testutil.ActionSchedule.PlayerTarget;
import com.google.android.exoplayer2.trackselection.MappingTrackSelector;
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
import com.google.android.exoplayer2.util.HandlerWrapper;

/**
Expand Down Expand Up @@ -64,7 +64,7 @@ public Action(String tag, @Nullable String description) {
*/
public final void doActionAndScheduleNext(
SimpleExoPlayer player,
MappingTrackSelector trackSelector,
DefaultTrackSelector trackSelector,
Surface surface,
HandlerWrapper handler,
ActionNode nextAction) {
Expand All @@ -75,7 +75,7 @@ public final void doActionAndScheduleNext(
}

/**
* Called by {@link #doActionAndScheduleNext(SimpleExoPlayer, MappingTrackSelector, Surface,
* Called by {@link #doActionAndScheduleNext(SimpleExoPlayer, DefaultTrackSelector, Surface,
* HandlerWrapper, ActionNode)} to perform the action and to schedule the next action node.
*
* @param player The player to which the action should be applied.
Expand All @@ -86,7 +86,7 @@ public final void doActionAndScheduleNext(
*/
protected void doActionAndScheduleNextImpl(
SimpleExoPlayer player,
MappingTrackSelector trackSelector,
DefaultTrackSelector trackSelector,
Surface surface,
HandlerWrapper handler,
ActionNode nextAction) {
Expand All @@ -97,15 +97,15 @@ protected void doActionAndScheduleNextImpl(
}

/**
* Called by {@link #doActionAndScheduleNextImpl(SimpleExoPlayer, MappingTrackSelector, Surface,
* Called by {@link #doActionAndScheduleNextImpl(SimpleExoPlayer, DefaultTrackSelector, Surface,
* HandlerWrapper, ActionNode)} to perform the action.
*
* @param player The player to which the action should be applied.
* @param trackSelector The track selector to which the action should be applied.
* @param surface The surface to use when applying actions.
*/
protected abstract void doActionImpl(
SimpleExoPlayer player, MappingTrackSelector trackSelector, Surface surface);
SimpleExoPlayer player, DefaultTrackSelector trackSelector, Surface surface);

/**
* Calls {@link Player#seekTo(long)} or {@link Player#seekTo(int, long)}.
Expand Down Expand Up @@ -141,8 +141,8 @@ public Seek(String tag, int windowIndex, long positionMs) {
}

@Override
protected void doActionImpl(SimpleExoPlayer player, MappingTrackSelector trackSelector,
Surface surface) {
protected void doActionImpl(
SimpleExoPlayer player, DefaultTrackSelector trackSelector, Surface surface) {
if (windowIndex == null) {
player.seekTo(positionMs);
} else {
Expand Down Expand Up @@ -183,8 +183,8 @@ public Stop(String tag, boolean reset) {
}

@Override
protected void doActionImpl(SimpleExoPlayer player, MappingTrackSelector trackSelector,
Surface surface) {
protected void doActionImpl(
SimpleExoPlayer player, DefaultTrackSelector trackSelector, Surface surface) {
if (reset == null) {
player.stop();
} else {
Expand Down Expand Up @@ -212,16 +212,14 @@ public SetPlayWhenReady(String tag, boolean playWhenReady) {
}

@Override
protected void doActionImpl(SimpleExoPlayer player, MappingTrackSelector trackSelector,
Surface surface) {
protected void doActionImpl(
SimpleExoPlayer player, DefaultTrackSelector trackSelector, Surface surface) {
player.setPlayWhenReady(playWhenReady);
}

}

/**
* Calls {@link MappingTrackSelector#setRendererDisabled(int, boolean)}.
*/
/** Calls {@link DefaultTrackSelector#setRendererDisabled(int, boolean)}. */
public static final class SetRendererDisabled extends Action {

private final int rendererIndex;
Expand All @@ -239,8 +237,8 @@ public SetRendererDisabled(String tag, int rendererIndex, boolean disabled) {
}

@Override
protected void doActionImpl(SimpleExoPlayer player, MappingTrackSelector trackSelector,
Surface surface) {
protected void doActionImpl(
SimpleExoPlayer player, DefaultTrackSelector trackSelector, Surface surface) {
trackSelector.setRendererDisabled(rendererIndex, disabled);
}

Expand All @@ -259,8 +257,8 @@ public ClearVideoSurface(String tag) {
}

@Override
protected void doActionImpl(SimpleExoPlayer player, MappingTrackSelector trackSelector,
Surface surface) {
protected void doActionImpl(
SimpleExoPlayer player, DefaultTrackSelector trackSelector, Surface surface) {
player.clearVideoSurface();
}

Expand All @@ -279,8 +277,8 @@ public SetVideoSurface(String tag) {
}

@Override
protected void doActionImpl(SimpleExoPlayer player, MappingTrackSelector trackSelector,
Surface surface) {
protected void doActionImpl(
SimpleExoPlayer player, DefaultTrackSelector trackSelector, Surface surface) {
player.setVideoSurface(surface);
}

Expand Down Expand Up @@ -314,8 +312,8 @@ public PrepareSource(String tag, MediaSource mediaSource, boolean resetPosition,
}

@Override
protected void doActionImpl(SimpleExoPlayer player, MappingTrackSelector trackSelector,
Surface surface) {
protected void doActionImpl(
SimpleExoPlayer player, DefaultTrackSelector trackSelector, Surface surface) {
player.prepare(mediaSource, resetPosition, resetState);
}

Expand All @@ -337,8 +335,8 @@ public SetRepeatMode(String tag, @Player.RepeatMode int repeatMode) {
}

@Override
protected void doActionImpl(SimpleExoPlayer player, MappingTrackSelector trackSelector,
Surface surface) {
protected void doActionImpl(
SimpleExoPlayer player, DefaultTrackSelector trackSelector, Surface surface) {
player.setRepeatMode(repeatMode);
}

Expand All @@ -360,8 +358,8 @@ public SetShuffleModeEnabled(String tag, boolean shuffleModeEnabled) {
}

@Override
protected void doActionImpl(SimpleExoPlayer player, MappingTrackSelector trackSelector,
Surface surface) {
protected void doActionImpl(
SimpleExoPlayer player, DefaultTrackSelector trackSelector, Surface surface) {
player.setShuffleModeEnabled(shuffleModeEnabled);
}
}
Expand Down Expand Up @@ -407,7 +405,7 @@ public SendMessages(

@Override
protected void doActionImpl(
final SimpleExoPlayer player, MappingTrackSelector trackSelector, Surface surface) {
final SimpleExoPlayer player, DefaultTrackSelector trackSelector, Surface surface) {
if (target instanceof PlayerTarget) {
((PlayerTarget) target).setPlayer(player);
}
Expand Down Expand Up @@ -440,8 +438,8 @@ public SetPlaybackParameters(String tag, PlaybackParameters playbackParameters)
}

@Override
protected void doActionImpl(SimpleExoPlayer player, MappingTrackSelector trackSelector,
Surface surface) {
protected void doActionImpl(
SimpleExoPlayer player, DefaultTrackSelector trackSelector, Surface surface) {
player.setPlaybackParameters(playbackParameters);
}

Expand All @@ -463,7 +461,7 @@ public ThrowPlaybackException(String tag, ExoPlaybackException exception) {

@Override
protected void doActionImpl(
SimpleExoPlayer player, MappingTrackSelector trackSelector, Surface surface) {
SimpleExoPlayer player, DefaultTrackSelector trackSelector, Surface surface) {
player
.createMessage(
new Target() {
Expand Down Expand Up @@ -500,7 +498,7 @@ public PlayUntilPosition(String tag, int windowIndex, long positionMs) {
@Override
protected void doActionAndScheduleNextImpl(
final SimpleExoPlayer player,
final MappingTrackSelector trackSelector,
final DefaultTrackSelector trackSelector,
final Surface surface,
final HandlerWrapper handler,
final ActionNode nextAction) {
Expand Down Expand Up @@ -534,7 +532,7 @@ public void handleMessage(int messageType, Object payload)

@Override
protected void doActionImpl(
SimpleExoPlayer player, MappingTrackSelector trackSelector, Surface surface) {
SimpleExoPlayer player, DefaultTrackSelector trackSelector, Surface surface) {
// Not triggered.
}
}
Expand All @@ -561,7 +559,7 @@ public WaitForTimelineChanged(String tag, @Nullable Timeline expectedTimeline) {
@Override
protected void doActionAndScheduleNextImpl(
final SimpleExoPlayer player,
final MappingTrackSelector trackSelector,
final DefaultTrackSelector trackSelector,
final Surface surface,
final HandlerWrapper handler,
final ActionNode nextAction) {
Expand All @@ -587,11 +585,10 @@ public void onTimelineChanged(
}

@Override
protected void doActionImpl(SimpleExoPlayer player, MappingTrackSelector trackSelector,
Surface surface) {
protected void doActionImpl(
SimpleExoPlayer player, DefaultTrackSelector trackSelector, Surface surface) {
// Not triggered.
}

}

/**
Expand All @@ -609,7 +606,7 @@ public WaitForPositionDiscontinuity(String tag) {
@Override
protected void doActionAndScheduleNextImpl(
final SimpleExoPlayer player,
final MappingTrackSelector trackSelector,
final DefaultTrackSelector trackSelector,
final Surface surface,
final HandlerWrapper handler,
final ActionNode nextAction) {
Expand All @@ -626,11 +623,10 @@ public void onPositionDiscontinuity(@Player.DiscontinuityReason int reason) {
}

@Override
protected void doActionImpl(SimpleExoPlayer player, MappingTrackSelector trackSelector,
Surface surface) {
protected void doActionImpl(
SimpleExoPlayer player, DefaultTrackSelector trackSelector, Surface surface) {
// Not triggered.
}

}

/**
Expand All @@ -652,7 +648,7 @@ public WaitForPlaybackState(String tag, int targetPlaybackState) {
@Override
protected void doActionAndScheduleNextImpl(
final SimpleExoPlayer player,
final MappingTrackSelector trackSelector,
final DefaultTrackSelector trackSelector,
final Surface surface,
final HandlerWrapper handler,
final ActionNode nextAction) {
Expand All @@ -675,11 +671,10 @@ public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
}

@Override
protected void doActionImpl(SimpleExoPlayer player, MappingTrackSelector trackSelector,
Surface surface) {
protected void doActionImpl(
SimpleExoPlayer player, DefaultTrackSelector trackSelector, Surface surface) {
// Not triggered.
}

}

/**
Expand All @@ -697,7 +692,7 @@ public WaitForSeekProcessed(String tag) {
@Override
protected void doActionAndScheduleNextImpl(
final SimpleExoPlayer player,
final MappingTrackSelector trackSelector,
final DefaultTrackSelector trackSelector,
final Surface surface,
final HandlerWrapper handler,
final ActionNode nextAction) {
Expand All @@ -714,11 +709,10 @@ public void onSeekProcessed() {
}

@Override
protected void doActionImpl(SimpleExoPlayer player, MappingTrackSelector trackSelector,
Surface surface) {
protected void doActionImpl(
SimpleExoPlayer player, DefaultTrackSelector trackSelector, Surface surface) {
// Not triggered.
}

}

/**
Expand All @@ -737,8 +731,8 @@ public ExecuteRunnable(String tag, Runnable runnable) {
}

@Override
protected void doActionImpl(SimpleExoPlayer player, MappingTrackSelector trackSelector,
Surface surface) {
protected void doActionImpl(
SimpleExoPlayer player, DefaultTrackSelector trackSelector, Surface surface) {
if (runnable instanceof PlayerRunnable) {
((PlayerRunnable) runnable).setPlayer(player);
}
Expand Down
Loading

0 comments on commit 3568dca

Please sign in to comment.