Remove dependency from common tests to exoplayer

PiperOrigin-RevId: 406354526
This commit is contained in:
olly 2021-10-29 14:27:32 +00:00 committed by tonihei
parent 405b811454
commit 8e2083a27b
13 changed files with 510 additions and 428 deletions

View File

@ -15,9 +15,9 @@
*/ */
package com.google.android.exoplayer2.ext.ima; package com.google.android.exoplayer2.ext.ima;
import android.content.Context;
import android.os.Looper; import android.os.Looper;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.MediaItem; import com.google.android.exoplayer2.MediaItem;
import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.Timeline; import com.google.android.exoplayer2.Timeline;
@ -29,8 +29,8 @@ import com.google.android.exoplayer2.util.Clock;
import com.google.android.exoplayer2.util.ListenerSet; import com.google.android.exoplayer2.util.ListenerSet;
import com.google.android.exoplayer2.util.Util; import com.google.android.exoplayer2.util.Util;
/** A fake player for testing content/ad playback. */ /** A fake {@link ExoPlayer} for testing content/ad playback. */
/* package */ final class FakePlayer extends StubExoPlayer { /* package */ final class FakeExoPlayer extends StubExoPlayer {
private final ListenerSet<Listener> listeners; private final ListenerSet<Listener> listeners;
private final Timeline.Period period; private final Timeline.Period period;
@ -48,8 +48,7 @@ import com.google.android.exoplayer2.util.Util;
private int adGroupIndex; private int adGroupIndex;
private int adIndexInAdGroup; private int adIndexInAdGroup;
public FakePlayer(Context context) { public FakeExoPlayer() {
super(context);
listeners = listeners =
new ListenerSet<>( new ListenerSet<>(
Looper.getMainLooper(), Looper.getMainLooper(),

View File

@ -139,13 +139,13 @@ public final class ImaAdsLoaderTest {
private ContentProgressProvider contentProgressProvider; private ContentProgressProvider contentProgressProvider;
private VideoAdPlayer videoAdPlayer; private VideoAdPlayer videoAdPlayer;
private TestAdsLoaderListener adsLoaderListener; private TestAdsLoaderListener adsLoaderListener;
private FakePlayer fakePlayer; private FakeExoPlayer fakePlayer;
private ImaAdsLoader imaAdsLoader; private ImaAdsLoader imaAdsLoader;
@Before @Before
public void setUp() { public void setUp() {
setupMocks(); setupMocks();
fakePlayer = new FakePlayer(getApplicationContext()); fakePlayer = new FakeExoPlayer();
adViewGroup = new FrameLayout(getApplicationContext()); adViewGroup = new FrameLayout(getApplicationContext());
View adOverlayView = new View(getApplicationContext()); View adOverlayView = new View(getApplicationContext());
adViewProvider = adViewProvider =

View File

@ -49,7 +49,6 @@ dependencies {
testImplementation 'junit:junit:' + junitVersion testImplementation 'junit:junit:' + junitVersion
testImplementation 'com.google.truth:truth:' + truthVersion testImplementation 'com.google.truth:truth:' + truthVersion
testImplementation 'org.robolectric:robolectric:' + robolectricVersion testImplementation 'org.robolectric:robolectric:' + robolectricVersion
testImplementation project(modulePrefix + 'library-core')
testImplementation project(modulePrefix + 'testutils') testImplementation project(modulePrefix + 'testutils')
} }

View File

@ -23,7 +23,7 @@ import static com.google.common.truth.Truth.assertThat;
import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.drm.DrmInitData; import com.google.android.exoplayer2.drm.DrmInitData;
import com.google.android.exoplayer2.metadata.Metadata; import com.google.android.exoplayer2.metadata.Metadata;
import com.google.android.exoplayer2.metadata.id3.TextInformationFrame; import com.google.android.exoplayer2.testutil.FakeMetadataEntry;
import com.google.android.exoplayer2.util.MimeTypes; import com.google.android.exoplayer2.util.MimeTypes;
import com.google.android.exoplayer2.video.ColorInfo; import com.google.android.exoplayer2.video.ColorInfo;
import java.util.ArrayList; import java.util.ArrayList;
@ -65,10 +65,7 @@ public final class FormatTest {
byte[] projectionData = new byte[] {1, 2, 3}; byte[] projectionData = new byte[] {1, 2, 3};
Metadata metadata = Metadata metadata = new Metadata(new FakeMetadataEntry("id1"), new FakeMetadataEntry("id2"));
new Metadata(
new TextInformationFrame("id1", "description1", "value1"),
new TextInformationFrame("id2", "description2", "value2"));
ColorInfo colorInfo = ColorInfo colorInfo =
new ColorInfo( new ColorInfo(

View File

@ -24,10 +24,8 @@ import static org.mockito.ArgumentMatchers.same;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import android.content.Context;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.testutil.StubExoPlayer; import com.google.android.exoplayer2.testutil.StubPlayer;
import com.google.android.exoplayer2.util.FlagSet; import com.google.android.exoplayer2.util.FlagSet;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
@ -48,7 +46,7 @@ public class ForwardingPlayerTest {
@Test @Test
public void addListener_addsForwardingListener() { public void addListener_addsForwardingListener() {
FakePlayer player = new FakePlayer(ApplicationProvider.getApplicationContext()); FakePlayer player = new FakePlayer();
Player.Listener listener1 = mock(Player.Listener.class); Player.Listener listener1 = mock(Player.Listener.class);
Player.Listener listener2 = mock(Player.Listener.class); Player.Listener listener2 = mock(Player.Listener.class);
@ -63,7 +61,7 @@ public class ForwardingPlayerTest {
@Test @Test
public void removeListener_removesForwardingListener() { public void removeListener_removesForwardingListener() {
FakePlayer player = new FakePlayer(ApplicationProvider.getApplicationContext()); FakePlayer player = new FakePlayer();
Player.Listener listener1 = mock(Player.Listener.class); Player.Listener listener1 = mock(Player.Listener.class);
Player.Listener listener2 = mock(Player.Listener.class); Player.Listener listener2 = mock(Player.Listener.class);
ForwardingPlayer forwardingPlayer = new ForwardingPlayer(player); ForwardingPlayer forwardingPlayer = new ForwardingPlayer(player);
@ -81,7 +79,7 @@ public class ForwardingPlayerTest {
@Test @Test
public void onEvents_passesForwardingPlayerAsArgument() { public void onEvents_passesForwardingPlayerAsArgument() {
FakePlayer player = new FakePlayer(ApplicationProvider.getApplicationContext()); FakePlayer player = new FakePlayer();
Player.Listener listener = mock(Player.Listener.class); Player.Listener listener = mock(Player.Listener.class);
ForwardingPlayer forwardingPlayer = new ForwardingPlayer(player); ForwardingPlayer forwardingPlayer = new ForwardingPlayer(player);
forwardingPlayer.addListener(listener); forwardingPlayer.addListener(listener);
@ -180,14 +178,10 @@ public class ForwardingPlayerTest {
throw new IllegalStateException(); throw new IllegalStateException();
} }
private static class FakePlayer extends StubExoPlayer { private static class FakePlayer extends StubPlayer {
private final Set<Listener> listeners = new HashSet<>(); private final Set<Listener> listeners = new HashSet<>();
public FakePlayer(Context context) {
super(context);
}
@Override @Override
public void addListener(Listener listener) { public void addListener(Listener listener) {
listeners.add(listener); listeners.add(listener);

View File

@ -19,7 +19,7 @@ import static com.google.common.truth.Truth.assertThat;
import android.os.Parcel; import android.os.Parcel;
import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.metadata.id3.BinaryFrame; import com.google.android.exoplayer2.testutil.FakeMetadataEntry;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -30,8 +30,7 @@ public class MetadataTest {
@Test @Test
public void parcelable() { public void parcelable() {
Metadata metadataToParcel = Metadata metadataToParcel =
new Metadata( new Metadata(new FakeMetadataEntry("id1"), new FakeMetadataEntry("id2"));
new BinaryFrame("id1", new byte[] {1}), new BinaryFrame("id2", new byte[] {2}));
Parcel parcel = Parcel.obtain(); Parcel parcel = Parcel.obtain();
metadataToParcel.writeToParcel(parcel, 0); metadataToParcel.writeToParcel(parcel, 0);

View File

@ -19,10 +19,8 @@ import static androidx.test.core.app.ApplicationProvider.getApplicationContext;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.Bundleable;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector.SelectionOverride;
import com.google.android.exoplayer2.trackselection.TrackSelectionOverrides.TrackSelectionOverride; import com.google.android.exoplayer2.trackselection.TrackSelectionOverrides.TrackSelectionOverride;
import com.google.android.exoplayer2.util.MimeTypes; import com.google.android.exoplayer2.util.MimeTypes;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
@ -183,17 +181,4 @@ public final class TrackSelectionParametersTest {
assertThat(parameters.viewportHeight).isEqualTo(Integer.MAX_VALUE); assertThat(parameters.viewportHeight).isEqualTo(Integer.MAX_VALUE);
assertThat(parameters.viewportOrientationMayChange).isTrue(); assertThat(parameters.viewportOrientationMayChange).isTrue();
} }
/** Tests {@link SelectionOverride}'s {@link Bundleable} implementation. */
@Test
public void roundTripViaBundle_ofSelectionOverride_yieldsEqualInstance() {
SelectionOverride selectionOverrideToBundle =
new SelectionOverride(/* groupIndex= */ 1, /* tracks...= */ 2, 3);
SelectionOverride selectionOverrideFromBundle =
DefaultTrackSelector.SelectionOverride.CREATOR.fromBundle(
selectionOverrideToBundle.toBundle());
assertThat(selectionOverrideFromBundle).isEqualTo(selectionOverrideToBundle);
}
} }

View File

@ -39,7 +39,7 @@ public final class AtomicFileTest {
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
tempFolder = tempFolder =
Util.createTempDirectory(ApplicationProvider.getApplicationContext(), "ExoPlayerTest"); Util.createTempDirectory(ApplicationProvider.getApplicationContext(), "AtomicFileTest");
file = new File(tempFolder, "atomicFile"); file = new File(tempFolder, "atomicFile");
atomicFile = new AtomicFile(file); atomicFile = new AtomicFile(file);
} }

View File

@ -31,7 +31,7 @@ import org.junit.runner.RunWith;
public class MediaFormatUtilTest { public class MediaFormatUtilTest {
@Test @Test
public void createMediaFormatFromEmptyExoPlayerFormat_generatesExpectedEntries() { public void createMediaFormatFromFormat_withEmptyFormat_generatesExpectedEntries() {
MediaFormat mediaFormat = MediaFormat mediaFormat =
MediaFormatUtil.createMediaFormatFromFormat(new Format.Builder().build()); MediaFormatUtil.createMediaFormatFromFormat(new Format.Builder().build());
// Assert that no invalid keys are accidentally being populated. // Assert that no invalid keys are accidentally being populated.
@ -59,7 +59,7 @@ public class MediaFormatUtilTest {
} }
@Test @Test
public void createMediaFormatFromPopulatedExoPlayerFormat_generatesExpectedMediaFormatEntries() { public void createMediaFormatFromFormat_withPopulatedFormat_generatesExpectedEntries() {
Format format = Format format =
new Format.Builder() new Format.Builder()
.setAverageBitrate(1) .setAverageBitrate(1)
@ -145,7 +145,7 @@ public class MediaFormatUtilTest {
} }
@Test @Test
public void createMediaFormatWithExoPlayerPcmEncoding_containsExoPlayerSpecificEncoding() { public void createMediaFormatFromFormat_withPcmEncoding_setsCustomPcmEncodingEntry() {
Format format = new Format.Builder().setPcmEncoding(C.ENCODING_PCM_32BIT).build(); Format format = new Format.Builder().setPcmEncoding(C.ENCODING_PCM_32BIT).build();
MediaFormat mediaFormat = MediaFormatUtil.createMediaFormatFromFormat(format); MediaFormat mediaFormat = MediaFormatUtil.createMediaFormatFromFormat(format);
assertThat(mediaFormat.getInteger(MediaFormatUtil.KEY_EXO_PCM_ENCODING)) assertThat(mediaFormat.getInteger(MediaFormatUtil.KEY_EXO_PCM_ENCODING))

View File

@ -1750,6 +1750,19 @@ public final class DefaultTrackSelectorTest {
assertThat(trackGroupInfos.get(0).getTrackSupport(0)).isEqualTo(FORMAT_HANDLED); assertThat(trackGroupInfos.get(0).getTrackSupport(0)).isEqualTo(FORMAT_HANDLED);
} }
/** Tests {@link SelectionOverride}'s {@link Bundleable} implementation. */
@Test
public void roundTripViaBundle_ofSelectionOverride_yieldsEqualInstance() {
SelectionOverride selectionOverrideToBundle =
new SelectionOverride(/* groupIndex= */ 1, /* tracks...= */ 2, 3);
SelectionOverride selectionOverrideFromBundle =
DefaultTrackSelector.SelectionOverride.CREATOR.fromBundle(
selectionOverrideToBundle.toBundle());
assertThat(selectionOverrideFromBundle).isEqualTo(selectionOverrideToBundle);
}
private static void assertSelections(TrackSelectorResult result, TrackSelection[] expected) { private static void assertSelections(TrackSelectorResult result, TrackSelection[] expected) {
assertThat(result.length).isEqualTo(expected.length); assertThat(result.length).isEqualTo(expected.length);
for (int i = 0; i < expected.length; i++) { for (int i = 0; i < expected.length; i++) {

View File

@ -0,0 +1,78 @@
/*
* Copyright (C) 2021 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.exoplayer2.testutil;
import static com.google.android.exoplayer2.util.Util.castNonNull;
import android.os.Parcel;
import android.os.Parcelable;
import androidx.annotation.Nullable;
import com.google.android.exoplayer2.metadata.Metadata;
/** A fake {@link Metadata.Entry}. */
public final class FakeMetadataEntry implements Metadata.Entry {
public final String data;
public FakeMetadataEntry(String data) {
this.data = data;
}
/* package */ FakeMetadataEntry(Parcel in) {
data = castNonNull(in.readString());
}
@Override
public int describeContents() {
return 0;
}
@Override
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
FakeMetadataEntry other = (FakeMetadataEntry) obj;
return data.equals(other.data);
}
@Override
public int hashCode() {
return data.hashCode();
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(data);
}
public static final Parcelable.Creator<FakeMetadataEntry> CREATOR =
new Parcelable.Creator<FakeMetadataEntry>() {
@Override
public FakeMetadataEntry createFromParcel(Parcel in) {
return new FakeMetadataEntry(in);
}
@Override
public FakeMetadataEntry[] newArray(int size) {
return new FakeMetadataEntry[size];
}
};
}

View File

@ -15,26 +15,14 @@
*/ */
package com.google.android.exoplayer2.testutil; package com.google.android.exoplayer2.testutil;
import android.content.Context;
import android.os.Looper; import android.os.Looper;
import android.view.Surface;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.TextureView;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import com.google.android.exoplayer2.BasePlayer;
import com.google.android.exoplayer2.DeviceInfo;
import com.google.android.exoplayer2.ExoPlaybackException; import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.ExoPlayer; import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.MediaItem;
import com.google.android.exoplayer2.MediaMetadata;
import com.google.android.exoplayer2.PlaybackParameters;
import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.PlayerMessage; import com.google.android.exoplayer2.PlayerMessage;
import com.google.android.exoplayer2.SeekParameters; import com.google.android.exoplayer2.SeekParameters;
import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.TracksInfo;
import com.google.android.exoplayer2.analytics.AnalyticsCollector; import com.google.android.exoplayer2.analytics.AnalyticsCollector;
import com.google.android.exoplayer2.analytics.AnalyticsListener; import com.google.android.exoplayer2.analytics.AnalyticsListener;
import com.google.android.exoplayer2.audio.AudioAttributes; import com.google.android.exoplayer2.audio.AudioAttributes;
@ -42,15 +30,10 @@ import com.google.android.exoplayer2.audio.AuxEffectInfo;
import com.google.android.exoplayer2.decoder.DecoderCounters; import com.google.android.exoplayer2.decoder.DecoderCounters;
import com.google.android.exoplayer2.source.MediaSource; import com.google.android.exoplayer2.source.MediaSource;
import com.google.android.exoplayer2.source.ShuffleOrder; import com.google.android.exoplayer2.source.ShuffleOrder;
import com.google.android.exoplayer2.source.TrackGroupArray;
import com.google.android.exoplayer2.text.Cue;
import com.google.android.exoplayer2.trackselection.TrackSelectionArray;
import com.google.android.exoplayer2.trackselection.TrackSelectionParameters;
import com.google.android.exoplayer2.trackselection.TrackSelector; import com.google.android.exoplayer2.trackselection.TrackSelector;
import com.google.android.exoplayer2.util.Clock; import com.google.android.exoplayer2.util.Clock;
import com.google.android.exoplayer2.util.PriorityTaskManager; import com.google.android.exoplayer2.util.PriorityTaskManager;
import com.google.android.exoplayer2.video.VideoFrameMetadataListener; import com.google.android.exoplayer2.video.VideoFrameMetadataListener;
import com.google.android.exoplayer2.video.VideoSize;
import com.google.android.exoplayer2.video.spherical.CameraMotionListener; import com.google.android.exoplayer2.video.spherical.CameraMotionListener;
import java.util.List; import java.util.List;
@ -58,11 +41,7 @@ import java.util.List;
* An abstract {@link ExoPlayer} implementation that throws {@link UnsupportedOperationException} * An abstract {@link ExoPlayer} implementation that throws {@link UnsupportedOperationException}
* from every method. * from every method.
*/ */
public class StubExoPlayer extends BasePlayer implements ExoPlayer { public class StubExoPlayer extends StubPlayer implements ExoPlayer {
public StubExoPlayer(Context context) {
super();
}
@Override @Override
@Deprecated @Deprecated
@ -93,31 +72,16 @@ public class StubExoPlayer extends BasePlayer implements ExoPlayer {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public Looper getApplicationLooper() {
throw new UnsupportedOperationException();
}
@Override @Override
public Clock getClock() { public Clock getClock() {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public void addListener(Listener listener) {
throw new UnsupportedOperationException();
}
@Override @Override
public void addListener(Player.EventListener listener) { public void addListener(Player.EventListener listener) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public void removeListener(Listener listener) {
throw new UnsupportedOperationException();
}
@Override @Override
public void removeListener(Player.EventListener listener) { public void removeListener(Player.EventListener listener) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
@ -148,68 +112,29 @@ public class StubExoPlayer extends BasePlayer implements ExoPlayer {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
@State
public int getPlaybackState() {
throw new UnsupportedOperationException();
}
@Override
@PlaybackSuppressionReason
public int getPlaybackSuppressionReason() {
throw new UnsupportedOperationException();
}
@Override @Override
public ExoPlaybackException getPlayerError() { public ExoPlaybackException getPlayerError() {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
/** @deprecated Use {@link #prepare()} instead. */
@Deprecated @Deprecated
@Override @Override
public void retry() { public void retry() {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
/**
* @deprecated Use {@link #setMediaSource(MediaSource)} and {@link ExoPlayer#prepare()} instead.
*/
@Deprecated
@Override
public void prepare() {
throw new UnsupportedOperationException();
}
/**
* @deprecated Use {@link #setMediaSource(MediaSource)} and {@link ExoPlayer#prepare()} instead.
*/
@Deprecated @Deprecated
@Override @Override
public void prepare(MediaSource mediaSource) { public void prepare(MediaSource mediaSource) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
/**
* @deprecated Use {@link #setMediaSource(MediaSource, boolean)} and {@link ExoPlayer#prepare()}
* instead.
*/
@Deprecated @Deprecated
@Override @Override
public void prepare(MediaSource mediaSource, boolean resetPosition, boolean resetState) { public void prepare(MediaSource mediaSource, boolean resetPosition, boolean resetState) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public void setMediaItems(List<MediaItem> mediaItems, boolean resetPosition) {
throw new UnsupportedOperationException();
}
@Override
public void setMediaItems(List<MediaItem> mediaItems, int startIndex, long startPositionMs) {
throw new UnsupportedOperationException();
}
@Override @Override
public void setMediaSource(MediaSource mediaSource) { public void setMediaSource(MediaSource mediaSource) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
@ -241,11 +166,6 @@ public class StubExoPlayer extends BasePlayer implements ExoPlayer {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public void addMediaItems(int index, List<MediaItem> mediaItems) {
throw new UnsupportedOperationException();
}
@Override @Override
public void addMediaSource(MediaSource mediaSource) { public void addMediaSource(MediaSource mediaSource) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
@ -266,41 +186,6 @@ public class StubExoPlayer extends BasePlayer implements ExoPlayer {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public void moveMediaItems(int fromIndex, int toIndex, int newIndex) {
throw new UnsupportedOperationException();
}
@Override
public void removeMediaItems(int fromIndex, int toIndex) {
throw new UnsupportedOperationException();
}
@Override
public Commands getAvailableCommands() {
throw new UnsupportedOperationException();
}
@Override
public void setPlayWhenReady(boolean playWhenReady) {
throw new UnsupportedOperationException();
}
@Override
public boolean getPlayWhenReady() {
throw new UnsupportedOperationException();
}
@Override
public void setRepeatMode(@RepeatMode int repeatMode) {
throw new UnsupportedOperationException();
}
@Override
public int getRepeatMode() {
throw new UnsupportedOperationException();
}
@Override @Override
public void setShuffleOrder(ShuffleOrder shuffleOrder) { public void setShuffleOrder(ShuffleOrder shuffleOrder) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
@ -381,51 +266,6 @@ public class StubExoPlayer extends BasePlayer implements ExoPlayer {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public void setShuffleModeEnabled(boolean shuffleModeEnabled) {
throw new UnsupportedOperationException();
}
@Override
public boolean getShuffleModeEnabled() {
throw new UnsupportedOperationException();
}
@Override
public boolean isLoading() {
throw new UnsupportedOperationException();
}
@Override
public void seekTo(int mediaItemIndex, long positionMs) {
throw new UnsupportedOperationException();
}
@Override
public long getSeekBackIncrement() {
throw new UnsupportedOperationException();
}
@Override
public long getSeekForwardIncrement() {
throw new UnsupportedOperationException();
}
@Override
public long getMaxSeekToPreviousPosition() {
throw new UnsupportedOperationException();
}
@Override
public void setPlaybackParameters(PlaybackParameters playbackParameters) {
throw new UnsupportedOperationException();
}
@Override
public PlaybackParameters getPlaybackParameters() {
throw new UnsupportedOperationException();
}
@Override @Override
public void setSeekParameters(@Nullable SeekParameters seekParameters) { public void setSeekParameters(@Nullable SeekParameters seekParameters) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
@ -436,22 +276,6 @@ public class StubExoPlayer extends BasePlayer implements ExoPlayer {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public void stop() {
throw new UnsupportedOperationException();
}
@Deprecated
@Override
public void stop(boolean reset) {
throw new UnsupportedOperationException();
}
@Override
public void release() {
throw new UnsupportedOperationException();
}
@Override @Override
public PlayerMessage createMessage(PlayerMessage.Target target) { public PlayerMessage createMessage(PlayerMessage.Target target) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
@ -473,211 +297,6 @@ public class StubExoPlayer extends BasePlayer implements ExoPlayer {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public TrackGroupArray getCurrentTrackGroups() {
throw new UnsupportedOperationException();
}
@Override
public TrackSelectionArray getCurrentTrackSelections() {
throw new UnsupportedOperationException();
}
@Override
public TracksInfo getCurrentTracksInfo() {
throw new UnsupportedOperationException();
}
@Override
public TrackSelectionParameters getTrackSelectionParameters() {
throw new UnsupportedOperationException();
}
@Override
public void setTrackSelectionParameters(TrackSelectionParameters parameters) {
throw new UnsupportedOperationException();
}
@Override
public MediaMetadata getMediaMetadata() {
throw new UnsupportedOperationException();
}
@Override
public MediaMetadata getPlaylistMetadata() {
throw new UnsupportedOperationException();
}
@Override
public void setPlaylistMetadata(MediaMetadata mediaMetadata) {
throw new UnsupportedOperationException();
}
@Override
public Timeline getCurrentTimeline() {
throw new UnsupportedOperationException();
}
@Override
public int getCurrentPeriodIndex() {
throw new UnsupportedOperationException();
}
@Override
public int getCurrentMediaItemIndex() {
throw new UnsupportedOperationException();
}
@Override
public long getDuration() {
throw new UnsupportedOperationException();
}
@Override
public long getCurrentPosition() {
throw new UnsupportedOperationException();
}
@Override
public long getBufferedPosition() {
throw new UnsupportedOperationException();
}
@Override
public long getTotalBufferedDuration() {
throw new UnsupportedOperationException();
}
@Override
public boolean isPlayingAd() {
throw new UnsupportedOperationException();
}
@Override
public int getCurrentAdGroupIndex() {
throw new UnsupportedOperationException();
}
@Override
public int getCurrentAdIndexInAdGroup() {
throw new UnsupportedOperationException();
}
@Override
public long getContentPosition() {
throw new UnsupportedOperationException();
}
@Override
public long getContentBufferedPosition() {
throw new UnsupportedOperationException();
}
@Override
public AudioAttributes getAudioAttributes() {
throw new UnsupportedOperationException();
}
@Override
public void setVolume(float volume) {
throw new UnsupportedOperationException();
}
@Override
public float getVolume() {
throw new UnsupportedOperationException();
}
@Override
public void clearVideoSurface() {
throw new UnsupportedOperationException();
}
@Override
public void clearVideoSurface(@Nullable Surface surface) {
throw new UnsupportedOperationException();
}
@Override
public void setVideoSurface(@Nullable Surface surface) {
throw new UnsupportedOperationException();
}
@Override
public void setVideoSurfaceHolder(@Nullable SurfaceHolder surfaceHolder) {
throw new UnsupportedOperationException();
}
@Override
public void clearVideoSurfaceHolder(@Nullable SurfaceHolder surfaceHolder) {
throw new UnsupportedOperationException();
}
@Override
public void setVideoSurfaceView(@Nullable SurfaceView surfaceView) {
throw new UnsupportedOperationException();
}
@Override
public void clearVideoSurfaceView(@Nullable SurfaceView surfaceView) {
throw new UnsupportedOperationException();
}
@Override
public void setVideoTextureView(@Nullable TextureView textureView) {
throw new UnsupportedOperationException();
}
@Override
public void clearVideoTextureView(@Nullable TextureView textureView) {
throw new UnsupportedOperationException();
}
@Override
public VideoSize getVideoSize() {
throw new UnsupportedOperationException();
}
@Override
public List<Cue> getCurrentCues() {
throw new UnsupportedOperationException();
}
@Override
public DeviceInfo getDeviceInfo() {
throw new UnsupportedOperationException();
}
@Override
public int getDeviceVolume() {
throw new UnsupportedOperationException();
}
@Override
public boolean isDeviceMuted() {
throw new UnsupportedOperationException();
}
@Override
public void setDeviceVolume(int volume) {
throw new UnsupportedOperationException();
}
@Override
public void increaseDeviceVolume() {
throw new UnsupportedOperationException();
}
@Override
public void decreaseDeviceVolume() {
throw new UnsupportedOperationException();
}
@Override
public void setDeviceMuted(boolean muted) {
throw new UnsupportedOperationException();
}
@Override @Override
public void setForegroundMode(boolean foregroundMode) { public void setForegroundMode(boolean foregroundMode) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();

View File

@ -0,0 +1,399 @@
/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.exoplayer2.testutil;
import android.os.Looper;
import android.view.Surface;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.TextureView;
import androidx.annotation.Nullable;
import com.google.android.exoplayer2.BasePlayer;
import com.google.android.exoplayer2.DeviceInfo;
import com.google.android.exoplayer2.MediaItem;
import com.google.android.exoplayer2.MediaMetadata;
import com.google.android.exoplayer2.PlaybackException;
import com.google.android.exoplayer2.PlaybackParameters;
import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.TracksInfo;
import com.google.android.exoplayer2.audio.AudioAttributes;
import com.google.android.exoplayer2.source.TrackGroupArray;
import com.google.android.exoplayer2.text.Cue;
import com.google.android.exoplayer2.trackselection.TrackSelectionArray;
import com.google.android.exoplayer2.trackselection.TrackSelectionParameters;
import com.google.android.exoplayer2.video.VideoSize;
import java.util.List;
/**
* An abstract {@link Player} implementation that throws {@link UnsupportedOperationException} from
* every method.
*/
public class StubPlayer extends BasePlayer {
@Override
public Looper getApplicationLooper() {
throw new UnsupportedOperationException();
}
@Override
public void addListener(Listener listener) {
throw new UnsupportedOperationException();
}
@Override
public void removeListener(Listener listener) {
throw new UnsupportedOperationException();
}
@Override
@State
public int getPlaybackState() {
throw new UnsupportedOperationException();
}
@Override
@PlaybackSuppressionReason
public int getPlaybackSuppressionReason() {
throw new UnsupportedOperationException();
}
@Override
public PlaybackException getPlayerError() {
throw new UnsupportedOperationException();
}
@Override
public void prepare() {
throw new UnsupportedOperationException();
}
@Override
public void setMediaItems(List<MediaItem> mediaItems, boolean resetPosition) {
throw new UnsupportedOperationException();
}
@Override
public void setMediaItems(List<MediaItem> mediaItems, int startIndex, long startPositionMs) {
throw new UnsupportedOperationException();
}
@Override
public void addMediaItems(int index, List<MediaItem> mediaItems) {
throw new UnsupportedOperationException();
}
@Override
public void moveMediaItems(int fromIndex, int toIndex, int newIndex) {
throw new UnsupportedOperationException();
}
@Override
public void removeMediaItems(int fromIndex, int toIndex) {
throw new UnsupportedOperationException();
}
@Override
public Commands getAvailableCommands() {
throw new UnsupportedOperationException();
}
@Override
public void setPlayWhenReady(boolean playWhenReady) {
throw new UnsupportedOperationException();
}
@Override
public boolean getPlayWhenReady() {
throw new UnsupportedOperationException();
}
@Override
public void setRepeatMode(@RepeatMode int repeatMode) {
throw new UnsupportedOperationException();
}
@Override
public int getRepeatMode() {
throw new UnsupportedOperationException();
}
@Override
public void setShuffleModeEnabled(boolean shuffleModeEnabled) {
throw new UnsupportedOperationException();
}
@Override
public boolean getShuffleModeEnabled() {
throw new UnsupportedOperationException();
}
@Override
public boolean isLoading() {
throw new UnsupportedOperationException();
}
@Override
public void seekTo(int mediaItemIndex, long positionMs) {
throw new UnsupportedOperationException();
}
@Override
public long getSeekBackIncrement() {
throw new UnsupportedOperationException();
}
@Override
public long getSeekForwardIncrement() {
throw new UnsupportedOperationException();
}
@Override
public long getMaxSeekToPreviousPosition() {
throw new UnsupportedOperationException();
}
@Override
public void setPlaybackParameters(PlaybackParameters playbackParameters) {
throw new UnsupportedOperationException();
}
@Override
public PlaybackParameters getPlaybackParameters() {
throw new UnsupportedOperationException();
}
@Override
public void stop() {
throw new UnsupportedOperationException();
}
@Deprecated
@Override
public void stop(boolean reset) {
throw new UnsupportedOperationException();
}
@Override
public void release() {
throw new UnsupportedOperationException();
}
@Override
public TrackGroupArray getCurrentTrackGroups() {
throw new UnsupportedOperationException();
}
@Override
public TrackSelectionArray getCurrentTrackSelections() {
throw new UnsupportedOperationException();
}
@Override
public TracksInfo getCurrentTracksInfo() {
throw new UnsupportedOperationException();
}
@Override
public TrackSelectionParameters getTrackSelectionParameters() {
throw new UnsupportedOperationException();
}
@Override
public void setTrackSelectionParameters(TrackSelectionParameters parameters) {
throw new UnsupportedOperationException();
}
@Override
public MediaMetadata getMediaMetadata() {
throw new UnsupportedOperationException();
}
@Override
public MediaMetadata getPlaylistMetadata() {
throw new UnsupportedOperationException();
}
@Override
public void setPlaylistMetadata(MediaMetadata mediaMetadata) {
throw new UnsupportedOperationException();
}
@Override
public Timeline getCurrentTimeline() {
throw new UnsupportedOperationException();
}
@Override
public int getCurrentPeriodIndex() {
throw new UnsupportedOperationException();
}
@Override
public int getCurrentMediaItemIndex() {
throw new UnsupportedOperationException();
}
@Override
public long getDuration() {
throw new UnsupportedOperationException();
}
@Override
public long getCurrentPosition() {
throw new UnsupportedOperationException();
}
@Override
public long getBufferedPosition() {
throw new UnsupportedOperationException();
}
@Override
public long getTotalBufferedDuration() {
throw new UnsupportedOperationException();
}
@Override
public boolean isPlayingAd() {
throw new UnsupportedOperationException();
}
@Override
public int getCurrentAdGroupIndex() {
throw new UnsupportedOperationException();
}
@Override
public int getCurrentAdIndexInAdGroup() {
throw new UnsupportedOperationException();
}
@Override
public long getContentPosition() {
throw new UnsupportedOperationException();
}
@Override
public long getContentBufferedPosition() {
throw new UnsupportedOperationException();
}
@Override
public AudioAttributes getAudioAttributes() {
throw new UnsupportedOperationException();
}
@Override
public void setVolume(float volume) {
throw new UnsupportedOperationException();
}
@Override
public float getVolume() {
throw new UnsupportedOperationException();
}
@Override
public void clearVideoSurface() {
throw new UnsupportedOperationException();
}
@Override
public void clearVideoSurface(@Nullable Surface surface) {
throw new UnsupportedOperationException();
}
@Override
public void setVideoSurface(@Nullable Surface surface) {
throw new UnsupportedOperationException();
}
@Override
public void setVideoSurfaceHolder(@Nullable SurfaceHolder surfaceHolder) {
throw new UnsupportedOperationException();
}
@Override
public void clearVideoSurfaceHolder(@Nullable SurfaceHolder surfaceHolder) {
throw new UnsupportedOperationException();
}
@Override
public void setVideoSurfaceView(@Nullable SurfaceView surfaceView) {
throw new UnsupportedOperationException();
}
@Override
public void clearVideoSurfaceView(@Nullable SurfaceView surfaceView) {
throw new UnsupportedOperationException();
}
@Override
public void setVideoTextureView(@Nullable TextureView textureView) {
throw new UnsupportedOperationException();
}
@Override
public void clearVideoTextureView(@Nullable TextureView textureView) {
throw new UnsupportedOperationException();
}
@Override
public VideoSize getVideoSize() {
throw new UnsupportedOperationException();
}
@Override
public List<Cue> getCurrentCues() {
throw new UnsupportedOperationException();
}
@Override
public DeviceInfo getDeviceInfo() {
throw new UnsupportedOperationException();
}
@Override
public int getDeviceVolume() {
throw new UnsupportedOperationException();
}
@Override
public boolean isDeviceMuted() {
throw new UnsupportedOperationException();
}
@Override
public void setDeviceVolume(int volume) {
throw new UnsupportedOperationException();
}
@Override
public void increaseDeviceVolume() {
throw new UnsupportedOperationException();
}
@Override
public void decreaseDeviceVolume() {
throw new UnsupportedOperationException();
}
@Override
public void setDeviceMuted(boolean muted) {
throw new UnsupportedOperationException();
}
}