Commit e5e8d9dc by samrobinson Committed by Christos Tsilopoulos

Make StubExoPlayer take a context in constructor.

This is a pre-requisite step for merging SimpleExoPlayer into
ExoPlayer, because when StubExoPlayer extends ExoPlayer, it needs
a matching constructor.

PiperOrigin-RevId: 397065374
parent 2f0aae0d
......@@ -15,6 +15,7 @@
*/
package com.google.android.exoplayer2.ext.ima;
import android.content.Context;
import android.os.Looper;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.MediaItem;
......@@ -45,7 +46,8 @@ import com.google.android.exoplayer2.util.ListenerSet;
private int adGroupIndex;
private int adIndexInAdGroup;
public FakePlayer() {
public FakePlayer(Context context) {
super(context);
listeners =
new ListenerSet<>(
Looper.getMainLooper(),
......
......@@ -145,7 +145,7 @@ public final class ImaAdsLoaderTest {
@Before
public void setUp() {
setupMocks();
fakePlayer = new FakePlayer();
fakePlayer = new FakePlayer(getApplicationContext());
adViewGroup = new FrameLayout(getApplicationContext());
View adOverlayView = new View(getApplicationContext());
adViewProvider =
......
......@@ -24,6 +24,8 @@ import static org.mockito.ArgumentMatchers.same;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import android.content.Context;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.testutil.StubExoPlayer;
import com.google.android.exoplayer2.util.FlagSet;
......@@ -46,7 +48,7 @@ public class ForwardingPlayerTest {
@Test
public void addListener_addsForwardingListener() {
FakePlayer player = new FakePlayer();
FakePlayer player = new FakePlayer(ApplicationProvider.getApplicationContext());
Player.Listener listener1 = mock(Player.Listener.class);
Player.Listener listener2 = mock(Player.Listener.class);
......@@ -62,7 +64,7 @@ public class ForwardingPlayerTest {
@Test
@SuppressWarnings("deprecation") // Testing backwards compatibility with deprecated method.
public void addEventListener_addsForwardingListener() {
FakePlayer player = new FakePlayer();
FakePlayer player = new FakePlayer(ApplicationProvider.getApplicationContext());
Player.EventListener listener1 = mock(Player.EventListener.class);
Player.EventListener listener2 = mock(Player.EventListener.class);
......@@ -77,7 +79,7 @@ public class ForwardingPlayerTest {
@Test
public void removeListener_removesForwardingListener() {
FakePlayer player = new FakePlayer();
FakePlayer player = new FakePlayer(ApplicationProvider.getApplicationContext());
Player.Listener listener1 = mock(Player.Listener.class);
Player.Listener listener2 = mock(Player.Listener.class);
ForwardingPlayer forwardingPlayer = new ForwardingPlayer(player);
......@@ -96,7 +98,7 @@ public class ForwardingPlayerTest {
@Test
@SuppressWarnings("deprecation") // Testing backwards compatibility with deprecated method.
public void removeEventListener_removesForwardingListener() {
FakePlayer player = new FakePlayer();
FakePlayer player = new FakePlayer(ApplicationProvider.getApplicationContext());
Player.EventListener listener1 = mock(Player.EventListener.class);
Player.EventListener listener2 = mock(Player.EventListener.class);
ForwardingPlayer forwardingPlayer = new ForwardingPlayer(player);
......@@ -114,7 +116,7 @@ public class ForwardingPlayerTest {
@Test
public void onEvents_passesForwardingPlayerAsArgument() {
FakePlayer player = new FakePlayer();
FakePlayer player = new FakePlayer(ApplicationProvider.getApplicationContext());
Player.Listener listener = mock(Player.Listener.class);
ForwardingPlayer forwardingPlayer = new ForwardingPlayer(player);
forwardingPlayer.addListener(listener);
......@@ -220,6 +222,10 @@ public class ForwardingPlayerTest {
private final Set<Listener> listeners = new HashSet<>();
public FakePlayer(Context context) {
super(context);
}
@Override
@SuppressWarnings("deprecation") // Implementing deprecated method.
public void addListener(EventListener listener) {
......
......@@ -15,6 +15,7 @@
*/
package com.google.android.exoplayer2.testutil;
import android.content.Context;
import android.os.Looper;
import android.view.Surface;
import android.view.SurfaceHolder;
......@@ -53,6 +54,10 @@ import java.util.List;
*/
public class StubExoPlayer extends BasePlayer implements ExoPlayer {
public StubExoPlayer(Context context) {
super();
}
@Override
@Deprecated
public AudioComponent getAudioComponent() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment