diff --git a/constants.gradle b/constants.gradle
index 3f69ab6754..1d6cd4fd73 100644
--- a/constants.gradle
+++ b/constants.gradle
@@ -18,15 +18,12 @@ project.ext {
minSdkVersion = 16
targetSdkVersion = 28
compileSdkVersion = 28
- testSupportLibraryVersion = '0.5'
dexmakerVersion = '1.2'
mockitoVersion = '1.9.5'
- junitVersion = '4.12'
- truthVersion = '0.42'
- robolectricVersion = '4.1'
+ robolectricVersion = '4.2'
autoValueVersion = '1.6'
checkerframeworkVersion = '2.5.0'
- testRunnerVersion = '1.1.0-alpha3'
+ androidXTestVersion = '1.1.0'
modulePrefix = ':'
if (gradle.ext.has('exoplayerModulePrefix')) {
modulePrefix += gradle.ext.exoplayerModulePrefix
diff --git a/extensions/cast/build.gradle b/extensions/cast/build.gradle
index 071a70c545..573426df2e 100644
--- a/extensions/cast/build.gradle
+++ b/extensions/cast/build.gradle
@@ -37,10 +37,6 @@ dependencies {
implementation project(modulePrefix + 'library-ui')
compileOnly 'org.checkerframework:checker-qual:' + checkerframeworkVersion
compileOnly 'org.checkerframework:checker-compat-qual:' + checkerframeworkVersion
- testImplementation project(modulePrefix + 'testutils')
- testImplementation 'junit:junit:' + junitVersion
- testImplementation 'org.mockito:mockito-core:' + mockitoVersion
- testImplementation 'org.robolectric:robolectric:' + robolectricVersion
testImplementation project(modulePrefix + 'testutils-robolectric')
}
diff --git a/extensions/cast/src/test/java/com/google/android/exoplayer2/ext/cast/CastTimelineTrackerTest.java b/extensions/cast/src/test/java/com/google/android/exoplayer2/ext/cast/CastTimelineTrackerTest.java
index 4c60e7c0b3..23c58d4884 100644
--- a/extensions/cast/src/test/java/com/google/android/exoplayer2/ext/cast/CastTimelineTrackerTest.java
+++ b/extensions/cast/src/test/java/com/google/android/exoplayer2/ext/cast/CastTimelineTrackerTest.java
@@ -15,6 +15,7 @@
*/
package com.google.android.exoplayer2.ext.cast;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.testutil.TimelineAsserts;
import com.google.android.exoplayer2.util.MimeTypes;
@@ -25,10 +26,9 @@ import java.util.ArrayList;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
-import org.robolectric.RobolectricTestRunner;
/** Tests for {@link CastTimelineTracker}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public class CastTimelineTrackerTest {
private static final long DURATION_1_MS = 1000;
diff --git a/extensions/cast/src/test/java/com/google/android/exoplayer2/ext/cast/MediaItemTest.java b/extensions/cast/src/test/java/com/google/android/exoplayer2/ext/cast/MediaItemTest.java
index 98df0d5690..9cdc073b06 100644
--- a/extensions/cast/src/test/java/com/google/android/exoplayer2/ext/cast/MediaItemTest.java
+++ b/extensions/cast/src/test/java/com/google/android/exoplayer2/ext/cast/MediaItemTest.java
@@ -18,6 +18,7 @@ package com.google.android.exoplayer2.ext.cast;
import static com.google.common.truth.Truth.assertThat;
import android.net.Uri;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.util.MimeTypes;
import java.util.Arrays;
@@ -26,10 +27,9 @@ import java.util.List;
import java.util.UUID;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** Test for {@link MediaItem}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public class MediaItemTest {
@Test
diff --git a/extensions/cronet/src/test/java/com/google/android/exoplayer2/ext/cronet/ByteArrayUploadDataProviderTest.java b/extensions/cronet/src/test/java/com/google/android/exoplayer2/ext/cronet/ByteArrayUploadDataProviderTest.java
index 117518a1eb..244ba9083b 100644
--- a/extensions/cronet/src/test/java/com/google/android/exoplayer2/ext/cronet/ByteArrayUploadDataProviderTest.java
+++ b/extensions/cronet/src/test/java/com/google/android/exoplayer2/ext/cronet/ByteArrayUploadDataProviderTest.java
@@ -19,6 +19,7 @@ import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.Arrays;
@@ -28,10 +29,9 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-import org.robolectric.RobolectricTestRunner;
/** Tests for {@link ByteArrayUploadDataProvider}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class ByteArrayUploadDataProviderTest {
private static final byte[] TEST_DATA = new byte[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
diff --git a/extensions/cronet/src/test/java/com/google/android/exoplayer2/ext/cronet/CronetDataSourceTest.java b/extensions/cronet/src/test/java/com/google/android/exoplayer2/ext/cronet/CronetDataSourceTest.java
index 7d47b0da64..7c4c03dd87 100644
--- a/extensions/cronet/src/test/java/com/google/android/exoplayer2/ext/cronet/CronetDataSourceTest.java
+++ b/extensions/cronet/src/test/java/com/google/android/exoplayer2/ext/cronet/CronetDataSourceTest.java
@@ -31,6 +31,7 @@ import static org.mockito.Mockito.when;
import android.net.Uri;
import android.os.ConditionVariable;
import android.os.SystemClock;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.upstream.DataSpec;
import com.google.android.exoplayer2.upstream.HttpDataSource;
@@ -62,10 +63,9 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-import org.robolectric.RobolectricTestRunner;
/** Tests for {@link CronetDataSource}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class CronetDataSourceTest {
private static final int TEST_CONNECT_TIMEOUT_MS = 100;
diff --git a/extensions/ffmpeg/build.gradle b/extensions/ffmpeg/build.gradle
index 16796d66e4..ee3358d21a 100644
--- a/extensions/ffmpeg/build.gradle
+++ b/extensions/ffmpeg/build.gradle
@@ -41,7 +41,6 @@ dependencies {
implementation 'androidx.annotation:annotation:1.0.1'
compileOnly 'org.checkerframework:checker-qual:' + checkerframeworkVersion
testImplementation project(modulePrefix + 'testutils-robolectric')
- testImplementation 'junit:junit:' + junitVersion
}
ext {
diff --git a/extensions/ffmpeg/src/test/java/com/google/android/exoplayer2/ext/ffmpeg/DefaultRenderersFactoryTest.java b/extensions/ffmpeg/src/test/java/com/google/android/exoplayer2/ext/ffmpeg/DefaultRenderersFactoryTest.java
index 7e99a11861..a52d1b1d7a 100644
--- a/extensions/ffmpeg/src/test/java/com/google/android/exoplayer2/ext/ffmpeg/DefaultRenderersFactoryTest.java
+++ b/extensions/ffmpeg/src/test/java/com/google/android/exoplayer2/ext/ffmpeg/DefaultRenderersFactoryTest.java
@@ -15,14 +15,14 @@
*/
package com.google.android.exoplayer2.ext.ffmpeg;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.testutil.DefaultRenderersFactoryAsserts;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** Unit test for {@link DefaultRenderersFactoryTest} with {@link FfmpegAudioRenderer}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class DefaultRenderersFactoryTest {
@Test
diff --git a/extensions/flac/build.gradle b/extensions/flac/build.gradle
index 4ed81db030..9a247c3f8f 100644
--- a/extensions/flac/build.gradle
+++ b/extensions/flac/build.gradle
@@ -41,9 +41,8 @@ dependencies {
implementation project(modulePrefix + 'library-core')
implementation 'androidx.annotation:annotation:1.0.1'
androidTestImplementation project(modulePrefix + 'testutils')
- androidTestImplementation 'androidx.test:runner:' + testRunnerVersion
+ androidTestImplementation 'androidx.test:runner:' + androidXTestVersion
testImplementation project(modulePrefix + 'testutils-robolectric')
- testImplementation 'org.robolectric:robolectric:' + robolectricVersion
}
ext {
diff --git a/extensions/flac/src/androidTest/AndroidManifest.xml b/extensions/flac/src/androidTest/AndroidManifest.xml
index 68ab6fe0c3..39b92aa217 100644
--- a/extensions/flac/src/androidTest/AndroidManifest.xml
+++ b/extensions/flac/src/androidTest/AndroidManifest.xml
@@ -19,6 +19,7 @@
package="com.google.android.exoplayer2.ext.flac.test">
+
+
+
+
INIT_DATA;
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/MediaPeriodQueueTest.java b/library/core/src/test/java/com/google/android/exoplayer2/MediaPeriodQueueTest.java
index 37f8a05790..73f42c5fc9 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/MediaPeriodQueueTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/MediaPeriodQueueTest.java
@@ -20,6 +20,7 @@ import static org.junit.Assert.assertNull;
import static org.mockito.Mockito.mock;
import android.net.Uri;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.source.MediaSource;
import com.google.android.exoplayer2.source.MediaSource.MediaPeriodId;
import com.google.android.exoplayer2.source.SinglePeriodTimeline;
@@ -30,10 +31,9 @@ import com.google.android.exoplayer2.upstream.Allocator;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** Unit tests for {@link MediaPeriodQueue}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class MediaPeriodQueueTest {
private static final long CONTENT_DURATION_US = 30 * C.MICROS_PER_SECOND;
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/TimelineTest.java b/library/core/src/test/java/com/google/android/exoplayer2/TimelineTest.java
index 88617ce8ec..d6e65cb34d 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/TimelineTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/TimelineTest.java
@@ -15,15 +15,15 @@
*/
package com.google.android.exoplayer2;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.testutil.FakeTimeline;
import com.google.android.exoplayer2.testutil.FakeTimeline.TimelineWindowDefinition;
import com.google.android.exoplayer2.testutil.TimelineAsserts;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** Unit test for {@link Timeline}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public class TimelineTest {
@Test
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/analytics/AnalyticsCollectorTest.java b/library/core/src/test/java/com/google/android/exoplayer2/analytics/AnalyticsCollectorTest.java
index 49bd634099..5f307d3a88 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/analytics/AnalyticsCollectorTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/analytics/AnalyticsCollectorTest.java
@@ -21,6 +21,8 @@ import android.os.Handler;
import android.os.SystemClock;
import androidx.annotation.Nullable;
import android.view.Surface;
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.PlaybackParameters;
@@ -56,12 +58,10 @@ import java.util.Iterator;
import java.util.List;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
/** Integration test for {@link AnalyticsCollector}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
@Config(shadows = {RobolectricUtil.CustomLooper.class, RobolectricUtil.CustomMessageQueue.class})
public final class AnalyticsCollectorTest {
@@ -727,7 +727,7 @@ public final class AnalyticsCollectorTest {
.setRenderersFactory(renderersFactory)
.setAnalyticsListener(listener)
.setActionSchedule(actionSchedule)
- .build(RuntimeEnvironment.application)
+ .build(ApplicationProvider.getApplicationContext())
.start()
.blockUntilActionScheduleFinished(TIMEOUT_MS)
.blockUntilEnded(TIMEOUT_MS);
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/audio/Ac3UtilTest.java b/library/core/src/test/java/com/google/android/exoplayer2/audio/Ac3UtilTest.java
index e41e270966..8a7d0b6f06 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/audio/Ac3UtilTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/audio/Ac3UtilTest.java
@@ -17,13 +17,13 @@ package com.google.android.exoplayer2.audio;
import static com.google.common.truth.Truth.assertThat;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.util.Util;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** Unit tests for {@link Ac3Util}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class Ac3UtilTest {
private static final int TRUEHD_SYNCFRAME_SAMPLE_COUNT = 40;
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/audio/AudioFocusManagerTest.java b/library/core/src/test/java/com/google/android/exoplayer2/audio/AudioFocusManagerTest.java
index 30d57af4be..272c944e46 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/audio/AudioFocusManagerTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/audio/AudioFocusManagerTest.java
@@ -24,20 +24,20 @@ import static org.junit.Assert.fail;
import android.content.Context;
import android.media.AudioFocusRequest;
import android.media.AudioManager;
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.util.Util;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
import org.robolectric.Shadows;
import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowAudioManager;
/** Unit tests for {@link AudioFocusManager}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public class AudioFocusManagerTest {
private static final int NO_COMMAND_RECEIVED = ~PLAYER_COMMAND_WAIT_FOR_CALLBACK;
@@ -49,10 +49,12 @@ public class AudioFocusManagerTest {
@Before
public void setUp() {
audioManager =
- (AudioManager) RuntimeEnvironment.application.getSystemService(Context.AUDIO_SERVICE);
+ (AudioManager)
+ ApplicationProvider.getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
testPlayerControl = new TestPlayerControl();
- audioFocusManager = new AudioFocusManager(RuntimeEnvironment.application, testPlayerControl);
+ audioFocusManager =
+ new AudioFocusManager(ApplicationProvider.getApplicationContext(), testPlayerControl);
}
@Test
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/audio/DefaultAudioSinkTest.java b/library/core/src/test/java/com/google/android/exoplayer2/audio/DefaultAudioSinkTest.java
index 16c724f583..d41c99183d 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/audio/DefaultAudioSinkTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/audio/DefaultAudioSinkTest.java
@@ -19,6 +19,7 @@ import static com.google.common.truth.Truth.assertThat;
import static org.robolectric.annotation.Config.NEWEST_SDK;
import static org.robolectric.annotation.Config.OLDEST_SDK;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.PlaybackParameters;
import java.nio.ByteBuffer;
@@ -27,7 +28,6 @@ import java.util.Arrays;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
/**
@@ -42,7 +42,7 @@ import org.robolectric.annotation.Config;
* draining to the end of the stream. This could be worked around by having a test-only mode where
* {@link DefaultAudioSink} automatically treats audio as consumed.
*/
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class DefaultAudioSinkTest {
private static final int CHANNEL_COUNT_MONO = 1;
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/audio/SilenceSkippingAudioProcessorTest.java b/library/core/src/test/java/com/google/android/exoplayer2/audio/SilenceSkippingAudioProcessorTest.java
index bd559218c6..128591124d 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/audio/SilenceSkippingAudioProcessorTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/audio/SilenceSkippingAudioProcessorTest.java
@@ -17,6 +17,7 @@ package com.google.android.exoplayer2.audio;
import static com.google.common.truth.Truth.assertThat;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.audio.AudioProcessor.UnhandledFormatException;
import com.google.android.exoplayer2.util.Assertions;
@@ -26,10 +27,9 @@ import java.nio.ShortBuffer;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** Unit tests for {@link SilenceSkippingAudioProcessor}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class SilenceSkippingAudioProcessorTest {
private static final int TEST_SIGNAL_SAMPLE_RATE_HZ = 1000;
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/audio/SimpleDecoderAudioRendererTest.java b/library/core/src/test/java/com/google/android/exoplayer2/audio/SimpleDecoderAudioRendererTest.java
index 3f28999820..950061e9bc 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/audio/SimpleDecoderAudioRendererTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/audio/SimpleDecoderAudioRendererTest.java
@@ -24,6 +24,7 @@ import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.RendererConfiguration;
@@ -39,13 +40,10 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
-/**
- * Unit test for {@link SimpleDecoderAudioRenderer}.
- */
-@RunWith(RobolectricTestRunner.class)
+/** Unit test for {@link SimpleDecoderAudioRenderer}. */
+@RunWith(AndroidJUnit4.class)
public class SimpleDecoderAudioRendererTest {
private static final Format FORMAT = Format.createSampleFormat(null, MimeTypes.AUDIO_RAW, 0);
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/audio/SonicAudioProcessorTest.java b/library/core/src/test/java/com/google/android/exoplayer2/audio/SonicAudioProcessorTest.java
index 1ba462d4af..837d7a97a4 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/audio/SonicAudioProcessorTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/audio/SonicAudioProcessorTest.java
@@ -18,16 +18,14 @@ package com.google.android.exoplayer2.audio;
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.fail;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-/**
- * Unit test for {@link SonicAudioProcessor}.
- */
-@RunWith(RobolectricTestRunner.class)
+/** Unit test for {@link SonicAudioProcessor}. */
+@RunWith(AndroidJUnit4.class)
public final class SonicAudioProcessorTest {
private SonicAudioProcessor sonicAudioProcessor;
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/database/VersionTableTest.java b/library/core/src/test/java/com/google/android/exoplayer2/database/VersionTableTest.java
index 977feaf44b..08b0c52fe5 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/database/VersionTableTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/database/VersionTableTest.java
@@ -18,14 +18,14 @@ package com.google.android.exoplayer2.database;
import static com.google.common.truth.Truth.assertThat;
import android.database.sqlite.SQLiteDatabase;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.testutil.TestUtil;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** Unit tests for {@link VersionTable}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public class VersionTableTest {
private static final int FEATURE_1 = 1;
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/drm/ClearKeyUtilTest.java b/library/core/src/test/java/com/google/android/exoplayer2/drm/ClearKeyUtilTest.java
index 460a237698..d12319ad46 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/drm/ClearKeyUtilTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/drm/ClearKeyUtilTest.java
@@ -17,16 +17,14 @@ package com.google.android.exoplayer2.drm;
import static com.google.common.truth.Truth.assertThat;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.util.Util;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
-/**
- * Unit test for {@link ClearKeyUtil}.
- */
-@RunWith(RobolectricTestRunner.class)
+/** Unit test for {@link ClearKeyUtil}. */
+@RunWith(AndroidJUnit4.class)
public final class ClearKeyUtilTest {
private static final byte[] SINGLE_KEY_RESPONSE =
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/drm/DrmInitDataTest.java b/library/core/src/test/java/com/google/android/exoplayer2/drm/DrmInitDataTest.java
index 2b740de113..36287d0579 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/drm/DrmInitDataTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/drm/DrmInitDataTest.java
@@ -22,6 +22,7 @@ import static com.google.android.exoplayer2.util.MimeTypes.VIDEO_MP4;
import static com.google.common.truth.Truth.assertThat;
import android.os.Parcel;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.drm.DrmInitData.SchemeData;
import com.google.android.exoplayer2.testutil.TestUtil;
@@ -29,12 +30,9 @@ import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-/**
- * Unit test for {@link DrmInitData}.
- */
-@RunWith(RobolectricTestRunner.class)
+/** Unit test for {@link DrmInitData}. */
+@RunWith(AndroidJUnit4.class)
public class DrmInitDataTest {
private static final SchemeData DATA_1 = new SchemeData(WIDEVINE_UUID, VIDEO_MP4,
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/drm/OfflineLicenseHelperTest.java b/library/core/src/test/java/com/google/android/exoplayer2/drm/OfflineLicenseHelperTest.java
index bba487f321..52fbae784a 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/drm/OfflineLicenseHelperTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/drm/OfflineLicenseHelperTest.java
@@ -21,6 +21,7 @@ import static org.mockito.Matchers.any;
import static org.mockito.Mockito.when;
import android.util.Pair;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.drm.DrmInitData.SchemeData;
import com.google.android.exoplayer2.testutil.RobolectricUtil;
@@ -31,11 +32,10 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
/** Tests {@link OfflineLicenseHelper}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
@Config(shadows = {RobolectricUtil.CustomLooper.class, RobolectricUtil.CustomMessageQueue.class})
public class OfflineLicenseHelperTest {
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/extractor/ConstantBitrateSeekMapTest.java b/library/core/src/test/java/com/google/android/exoplayer2/extractor/ConstantBitrateSeekMapTest.java
index 0fa33dd348..bc3ccf499f 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/extractor/ConstantBitrateSeekMapTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/extractor/ConstantBitrateSeekMapTest.java
@@ -18,13 +18,13 @@ package com.google.android.exoplayer2.extractor;
import static com.google.common.truth.Truth.assertThat;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** Unit test for {@link ConstantBitrateSeekMap}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class ConstantBitrateSeekMapTest {
private ConstantBitrateSeekMap constantBitrateSeekMap;
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/extractor/DefaultExtractorInputTest.java b/library/core/src/test/java/com/google/android/exoplayer2/extractor/DefaultExtractorInputTest.java
index 8b26361578..6dbec3ecf4 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/extractor/DefaultExtractorInputTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/extractor/DefaultExtractorInputTest.java
@@ -22,6 +22,7 @@ import static java.util.Arrays.copyOfRange;
import static org.junit.Assert.fail;
import android.net.Uri;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.testutil.FakeDataSource;
import com.google.android.exoplayer2.upstream.DataSpec;
@@ -30,12 +31,9 @@ import java.io.IOException;
import java.util.Arrays;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-/**
- * Test for {@link DefaultExtractorInput}.
- */
-@RunWith(RobolectricTestRunner.class)
+/** Test for {@link DefaultExtractorInput}. */
+@RunWith(AndroidJUnit4.class)
public class DefaultExtractorInputTest {
private static final String TEST_URI = "http://www.google.com";
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/extractor/DefaultExtractorsFactoryTest.java b/library/core/src/test/java/com/google/android/exoplayer2/extractor/DefaultExtractorsFactoryTest.java
index 148e04ca77..8de7441496 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/extractor/DefaultExtractorsFactoryTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/extractor/DefaultExtractorsFactoryTest.java
@@ -17,6 +17,7 @@ package com.google.android.exoplayer2.extractor;
import static com.google.common.truth.Truth.assertThat;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.extractor.amr.AmrExtractor;
import com.google.android.exoplayer2.extractor.flv.FlvExtractor;
import com.google.android.exoplayer2.extractor.mkv.MatroskaExtractor;
@@ -33,10 +34,9 @@ import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** Unit test for {@link DefaultExtractorsFactory}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class DefaultExtractorsFactoryTest {
@Test
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/extractor/ExtractorTest.java b/library/core/src/test/java/com/google/android/exoplayer2/extractor/ExtractorTest.java
index 3271e1ddf6..0401b2be83 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/extractor/ExtractorTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/extractor/ExtractorTest.java
@@ -17,15 +17,13 @@ package com.google.android.exoplayer2.extractor;
import static com.google.common.truth.Truth.assertThat;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-/**
- * Unit test for {@link Extractor}.
- */
-@RunWith(RobolectricTestRunner.class)
+/** Unit test for {@link Extractor}. */
+@RunWith(AndroidJUnit4.class)
public final class ExtractorTest {
@Test
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/extractor/Id3PeekerTest.java b/library/core/src/test/java/com/google/android/exoplayer2/extractor/Id3PeekerTest.java
index f43f356482..59e904a5a4 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/extractor/Id3PeekerTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/extractor/Id3PeekerTest.java
@@ -18,6 +18,7 @@ package com.google.android.exoplayer2.extractor;
import static com.google.common.truth.Truth.assertThat;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.metadata.Metadata;
import com.google.android.exoplayer2.metadata.id3.ApicFrame;
import com.google.android.exoplayer2.metadata.id3.CommentFrame;
@@ -26,10 +27,9 @@ import com.google.android.exoplayer2.testutil.FakeExtractorInput;
import java.io.IOException;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** Unit test for {@link Id3Peeker}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class Id3PeekerTest {
@Test
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/extractor/amr/AmrExtractorSeekTest.java b/library/core/src/test/java/com/google/android/exoplayer2/extractor/amr/AmrExtractorSeekTest.java
index 9f9051087d..d131fce6b7 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/extractor/amr/AmrExtractorSeekTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/extractor/amr/AmrExtractorSeekTest.java
@@ -18,6 +18,8 @@ package com.google.android.exoplayer2.extractor.amr;
import static com.google.common.truth.Truth.assertThat;
import android.net.Uri;
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.extractor.SeekMap;
import com.google.android.exoplayer2.testutil.FakeExtractorOutput;
import com.google.android.exoplayer2.testutil.FakeTrackOutput;
@@ -30,11 +32,9 @@ import java.util.Random;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
/** Unit test for {@link AmrExtractor}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class AmrExtractorSeekTest {
private static final Random random = new Random(1234L);
@@ -51,7 +51,7 @@ public final class AmrExtractorSeekTest {
@Before
public void setUp() {
dataSource =
- new DefaultDataSourceFactory(RuntimeEnvironment.application, "UserAgent")
+ new DefaultDataSourceFactory(ApplicationProvider.getApplicationContext(), "UserAgent")
.createDataSource();
}
@@ -62,7 +62,7 @@ public final class AmrExtractorSeekTest {
Uri fileUri = TestUtil.buildAssetUri(fileName);
expectedTrackOutput =
TestUtil.extractAllSamplesFromFile(
- createAmrExtractor(), RuntimeEnvironment.application, fileName)
+ createAmrExtractor(), ApplicationProvider.getApplicationContext(), fileName)
.trackOutputs
.get(0);
@@ -82,7 +82,7 @@ public final class AmrExtractorSeekTest {
Uri fileUri = TestUtil.buildAssetUri(fileName);
expectedTrackOutput =
TestUtil.extractAllSamplesFromFile(
- createAmrExtractor(), RuntimeEnvironment.application, fileName)
+ createAmrExtractor(), ApplicationProvider.getApplicationContext(), fileName)
.trackOutputs
.get(0);
@@ -109,7 +109,7 @@ public final class AmrExtractorSeekTest {
Uri fileUri = TestUtil.buildAssetUri(fileName);
expectedTrackOutput =
TestUtil.extractAllSamplesFromFile(
- createAmrExtractor(), RuntimeEnvironment.application, fileName)
+ createAmrExtractor(), ApplicationProvider.getApplicationContext(), fileName)
.trackOutputs
.get(0);
AmrExtractor extractor = createAmrExtractor();
@@ -136,7 +136,7 @@ public final class AmrExtractorSeekTest {
Uri fileUri = TestUtil.buildAssetUri(fileName);
expectedTrackOutput =
TestUtil.extractAllSamplesFromFile(
- createAmrExtractor(), RuntimeEnvironment.application, fileName)
+ createAmrExtractor(), ApplicationProvider.getApplicationContext(), fileName)
.trackOutputs
.get(0);
AmrExtractor extractor = createAmrExtractor();
@@ -165,7 +165,7 @@ public final class AmrExtractorSeekTest {
Uri fileUri = TestUtil.buildAssetUri(fileName);
expectedTrackOutput =
TestUtil.extractAllSamplesFromFile(
- createAmrExtractor(), RuntimeEnvironment.application, fileName)
+ createAmrExtractor(), ApplicationProvider.getApplicationContext(), fileName)
.trackOutputs
.get(0);
AmrExtractor extractor = createAmrExtractor();
@@ -194,7 +194,7 @@ public final class AmrExtractorSeekTest {
Uri fileUri = TestUtil.buildAssetUri(fileName);
expectedTrackOutput =
TestUtil.extractAllSamplesFromFile(
- createAmrExtractor(), RuntimeEnvironment.application, fileName)
+ createAmrExtractor(), ApplicationProvider.getApplicationContext(), fileName)
.trackOutputs
.get(0);
AmrExtractor extractor = createAmrExtractor();
@@ -223,7 +223,7 @@ public final class AmrExtractorSeekTest {
Uri fileUri = TestUtil.buildAssetUri(fileName);
expectedTrackOutput =
TestUtil.extractAllSamplesFromFile(
- createAmrExtractor(), RuntimeEnvironment.application, fileName)
+ createAmrExtractor(), ApplicationProvider.getApplicationContext(), fileName)
.trackOutputs
.get(0);
@@ -243,7 +243,7 @@ public final class AmrExtractorSeekTest {
Uri fileUri = TestUtil.buildAssetUri(fileName);
expectedTrackOutput =
TestUtil.extractAllSamplesFromFile(
- createAmrExtractor(), RuntimeEnvironment.application, fileName)
+ createAmrExtractor(), ApplicationProvider.getApplicationContext(), fileName)
.trackOutputs
.get(0);
@@ -270,7 +270,7 @@ public final class AmrExtractorSeekTest {
Uri fileUri = TestUtil.buildAssetUri(fileName);
expectedTrackOutput =
TestUtil.extractAllSamplesFromFile(
- createAmrExtractor(), RuntimeEnvironment.application, fileName)
+ createAmrExtractor(), ApplicationProvider.getApplicationContext(), fileName)
.trackOutputs
.get(0);
AmrExtractor extractor = createAmrExtractor();
@@ -297,7 +297,7 @@ public final class AmrExtractorSeekTest {
Uri fileUri = TestUtil.buildAssetUri(fileName);
expectedTrackOutput =
TestUtil.extractAllSamplesFromFile(
- createAmrExtractor(), RuntimeEnvironment.application, fileName)
+ createAmrExtractor(), ApplicationProvider.getApplicationContext(), fileName)
.trackOutputs
.get(0);
AmrExtractor extractor = createAmrExtractor();
@@ -326,7 +326,7 @@ public final class AmrExtractorSeekTest {
Uri fileUri = TestUtil.buildAssetUri(fileName);
expectedTrackOutput =
TestUtil.extractAllSamplesFromFile(
- createAmrExtractor(), RuntimeEnvironment.application, fileName)
+ createAmrExtractor(), ApplicationProvider.getApplicationContext(), fileName)
.trackOutputs
.get(0);
AmrExtractor extractor = createAmrExtractor();
@@ -355,7 +355,7 @@ public final class AmrExtractorSeekTest {
Uri fileUri = TestUtil.buildAssetUri(fileName);
expectedTrackOutput =
TestUtil.extractAllSamplesFromFile(
- createAmrExtractor(), RuntimeEnvironment.application, fileName)
+ createAmrExtractor(), ApplicationProvider.getApplicationContext(), fileName)
.trackOutputs
.get(0);
AmrExtractor extractor = createAmrExtractor();
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/extractor/amr/AmrExtractorTest.java b/library/core/src/test/java/com/google/android/exoplayer2/extractor/amr/AmrExtractorTest.java
index 912b4bd7c7..de7642a94b 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/extractor/amr/AmrExtractorTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/extractor/amr/AmrExtractorTest.java
@@ -23,6 +23,7 @@ import static com.google.common.truth.Truth.assertThat;
import static junit.framework.Assert.fail;
import androidx.annotation.NonNull;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.ParserException;
import com.google.android.exoplayer2.extractor.Extractor;
import com.google.android.exoplayer2.extractor.PositionHolder;
@@ -34,10 +35,9 @@ import java.io.IOException;
import java.util.Random;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** Unit test for {@link AmrExtractor}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class AmrExtractorTest {
private static final Random RANDOM = new Random(1234);
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/extractor/flv/FlvExtractorTest.java b/library/core/src/test/java/com/google/android/exoplayer2/extractor/flv/FlvExtractorTest.java
index 316148d9b9..e0505095fe 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/extractor/flv/FlvExtractorTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/extractor/flv/FlvExtractorTest.java
@@ -15,13 +15,13 @@
*/
package com.google.android.exoplayer2.extractor.flv;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.testutil.ExtractorAsserts;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** Unit test for {@link FlvExtractor}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class FlvExtractorTest {
@Test
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/extractor/mkv/DefaultEbmlReaderTest.java b/library/core/src/test/java/com/google/android/exoplayer2/extractor/mkv/DefaultEbmlReaderTest.java
index b1c5171746..642b9946ed 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/extractor/mkv/DefaultEbmlReaderTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/extractor/mkv/DefaultEbmlReaderTest.java
@@ -17,6 +17,7 @@ package com.google.android.exoplayer2.extractor.mkv;
import static com.google.common.truth.Truth.assertThat;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.extractor.ExtractorInput;
import com.google.android.exoplayer2.testutil.FakeExtractorInput;
import com.google.android.exoplayer2.testutil.TestUtil;
@@ -26,12 +27,9 @@ import java.util.Arrays;
import java.util.List;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-/**
- * Tests {@link DefaultEbmlReader}.
- */
-@RunWith(RobolectricTestRunner.class)
+/** Tests {@link DefaultEbmlReader}. */
+@RunWith(AndroidJUnit4.class)
public class DefaultEbmlReaderTest {
@Test
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/extractor/mkv/MatroskaExtractorTest.java b/library/core/src/test/java/com/google/android/exoplayer2/extractor/mkv/MatroskaExtractorTest.java
index 2e673037d0..9c20a9668f 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/extractor/mkv/MatroskaExtractorTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/extractor/mkv/MatroskaExtractorTest.java
@@ -15,13 +15,13 @@
*/
package com.google.android.exoplayer2.extractor.mkv;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.testutil.ExtractorAsserts;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** Tests for {@link MatroskaExtractor}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class MatroskaExtractorTest {
@Test
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/extractor/mkv/VarintReaderTest.java b/library/core/src/test/java/com/google/android/exoplayer2/extractor/mkv/VarintReaderTest.java
index a13a185b3e..86df3f50e3 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/extractor/mkv/VarintReaderTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/extractor/mkv/VarintReaderTest.java
@@ -20,6 +20,7 @@ import static com.google.android.exoplayer2.C.RESULT_MAX_LENGTH_EXCEEDED;
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.fail;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.extractor.ExtractorInput;
import com.google.android.exoplayer2.testutil.FakeExtractorInput;
@@ -28,12 +29,9 @@ import java.io.EOFException;
import java.io.IOException;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-/**
- * Tests for {@link VarintReader}.
- */
-@RunWith(RobolectricTestRunner.class)
+/** Tests for {@link VarintReader}. */
+@RunWith(AndroidJUnit4.class)
public final class VarintReaderTest {
private static final byte MAX_BYTE = (byte) 0xFF;
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/extractor/mp3/Mp3ExtractorTest.java b/library/core/src/test/java/com/google/android/exoplayer2/extractor/mp3/Mp3ExtractorTest.java
index 62a4f1a193..670296cc13 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/extractor/mp3/Mp3ExtractorTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/extractor/mp3/Mp3ExtractorTest.java
@@ -15,13 +15,13 @@
*/
package com.google.android.exoplayer2.extractor.mp3;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.testutil.ExtractorAsserts;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** Unit test for {@link Mp3Extractor}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class Mp3ExtractorTest {
@Test
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/extractor/mp3/XingSeekerTest.java b/library/core/src/test/java/com/google/android/exoplayer2/extractor/mp3/XingSeekerTest.java
index 6df40b5dcc..96fee1d07a 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/extractor/mp3/XingSeekerTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/extractor/mp3/XingSeekerTest.java
@@ -17,6 +17,7 @@ package com.google.android.exoplayer2.extractor.mp3;
import static com.google.common.truth.Truth.assertThat;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.extractor.MpegAudioHeader;
import com.google.android.exoplayer2.extractor.SeekMap.SeekPoints;
@@ -26,12 +27,9 @@ import com.google.android.exoplayer2.util.Util;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-/**
- * Tests for {@link XingSeeker}.
- */
-@RunWith(RobolectricTestRunner.class)
+/** Tests for {@link XingSeeker}. */
+@RunWith(AndroidJUnit4.class)
public final class XingSeekerTest {
// Xing header/payload from http://storage.googleapis.com/exoplayer-test-media-0/play.mp3.
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/extractor/mp4/AtomParsersTest.java b/library/core/src/test/java/com/google/android/exoplayer2/extractor/mp4/AtomParsersTest.java
index 9c7f0e8acc..712f8e43fe 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/extractor/mp4/AtomParsersTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/extractor/mp4/AtomParsersTest.java
@@ -17,16 +17,14 @@ package com.google.android.exoplayer2.extractor.mp4;
import static com.google.common.truth.Truth.assertThat;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.util.ParsableByteArray;
import com.google.android.exoplayer2.util.Util;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-/**
- * Tests for {@link AtomParsers}.
- */
-@RunWith(RobolectricTestRunner.class)
+/** Tests for {@link AtomParsers}. */
+@RunWith(AndroidJUnit4.class)
public final class AtomParsersTest {
private static final String ATOM_HEADER = "000000000000000000000000";
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/extractor/mp4/FragmentedMp4ExtractorTest.java b/library/core/src/test/java/com/google/android/exoplayer2/extractor/mp4/FragmentedMp4ExtractorTest.java
index f9362f9cda..a29dfcc310 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/extractor/mp4/FragmentedMp4ExtractorTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/extractor/mp4/FragmentedMp4ExtractorTest.java
@@ -15,6 +15,7 @@
*/
package com.google.android.exoplayer2.extractor.mp4;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.testutil.ExtractorAsserts;
import com.google.android.exoplayer2.testutil.ExtractorAsserts.ExtractorFactory;
@@ -23,10 +24,9 @@ import java.util.Collections;
import java.util.List;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** Unit test for {@link FragmentedMp4Extractor}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class FragmentedMp4ExtractorTest {
@Test
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/extractor/mp4/MdtaMetadataEntryTest.java b/library/core/src/test/java/com/google/android/exoplayer2/extractor/mp4/MdtaMetadataEntryTest.java
index 2f81836540..ea1ec1d8cd 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/extractor/mp4/MdtaMetadataEntryTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/extractor/mp4/MdtaMetadataEntryTest.java
@@ -18,12 +18,12 @@ package com.google.android.exoplayer2.extractor.mp4;
import static com.google.common.truth.Truth.assertThat;
import android.os.Parcel;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** Test for {@link MdtaMetadataEntry}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class MdtaMetadataEntryTest {
@Test
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/extractor/mp4/Mp4ExtractorTest.java b/library/core/src/test/java/com/google/android/exoplayer2/extractor/mp4/Mp4ExtractorTest.java
index 3c84214686..981ee17e92 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/extractor/mp4/Mp4ExtractorTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/extractor/mp4/Mp4ExtractorTest.java
@@ -15,13 +15,13 @@
*/
package com.google.android.exoplayer2.extractor.mp4;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.testutil.ExtractorAsserts;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** Tests for {@link Mp4Extractor}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class Mp4ExtractorTest {
@Test
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/extractor/mp4/PsshAtomUtilTest.java b/library/core/src/test/java/com/google/android/exoplayer2/extractor/mp4/PsshAtomUtilTest.java
index d7a13ab061..13d4529451 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/extractor/mp4/PsshAtomUtilTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/extractor/mp4/PsshAtomUtilTest.java
@@ -21,17 +21,15 @@ import static com.google.android.exoplayer2.extractor.mp4.Atom.parseFullAtomFlag
import static com.google.android.exoplayer2.extractor.mp4.Atom.parseFullAtomVersion;
import static com.google.common.truth.Truth.assertThat;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.util.ParsableByteArray;
import java.util.UUID;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-/**
- * Tests for {@link PsshAtomUtil}.
- */
-@RunWith(RobolectricTestRunner.class)
+/** Tests for {@link PsshAtomUtil}. */
+@RunWith(AndroidJUnit4.class)
public final class PsshAtomUtilTest {
@Test
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/extractor/ogg/DefaultOggSeekerTest.java b/library/core/src/test/java/com/google/android/exoplayer2/extractor/ogg/DefaultOggSeekerTest.java
index 1b6df9c5a4..8d1818845d 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/extractor/ogg/DefaultOggSeekerTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/extractor/ogg/DefaultOggSeekerTest.java
@@ -19,6 +19,7 @@ import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static org.junit.Assert.fail;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.testutil.FakeExtractorInput;
import com.google.android.exoplayer2.util.ParsableByteArray;
@@ -26,10 +27,9 @@ import java.io.IOException;
import java.util.Random;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** Unit test for {@link DefaultOggSeeker}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class DefaultOggSeekerTest {
@Test
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/extractor/ogg/DefaultOggSeekerUtilMethodsTest.java b/library/core/src/test/java/com/google/android/exoplayer2/extractor/ogg/DefaultOggSeekerUtilMethodsTest.java
index ef38282691..d6691f50f8 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/extractor/ogg/DefaultOggSeekerUtilMethodsTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/extractor/ogg/DefaultOggSeekerUtilMethodsTest.java
@@ -18,6 +18,7 @@ package com.google.android.exoplayer2.extractor.ogg;
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.fail;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.extractor.ExtractorInput;
import com.google.android.exoplayer2.testutil.FakeExtractorInput;
import com.google.android.exoplayer2.testutil.OggTestData;
@@ -27,12 +28,9 @@ import java.io.IOException;
import java.util.Random;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-/**
- * Unit test for {@link DefaultOggSeeker} utility methods.
- */
-@RunWith(RobolectricTestRunner.class)
+/** Unit test for {@link DefaultOggSeeker} utility methods. */
+@RunWith(AndroidJUnit4.class)
public final class DefaultOggSeekerUtilMethodsTest {
private final Random random = new Random(0);
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/extractor/ogg/OggExtractorTest.java b/library/core/src/test/java/com/google/android/exoplayer2/extractor/ogg/OggExtractorTest.java
index 289c168725..b09f7f204f 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/extractor/ogg/OggExtractorTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/extractor/ogg/OggExtractorTest.java
@@ -17,6 +17,7 @@ package com.google.android.exoplayer2.extractor.ogg;
import static com.google.common.truth.Truth.assertThat;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.testutil.ExtractorAsserts;
import com.google.android.exoplayer2.testutil.ExtractorAsserts.ExtractorFactory;
import com.google.android.exoplayer2.testutil.FakeExtractorInput;
@@ -25,10 +26,9 @@ import com.google.android.exoplayer2.testutil.TestUtil;
import java.io.IOException;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** Unit test for {@link OggExtractor}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class OggExtractorTest {
private static final ExtractorFactory OGG_EXTRACTOR_FACTORY = OggExtractor::new;
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/extractor/ogg/OggPacketTest.java b/library/core/src/test/java/com/google/android/exoplayer2/extractor/ogg/OggPacketTest.java
index e9af630f83..70f64d3dbe 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/extractor/ogg/OggPacketTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/extractor/ogg/OggPacketTest.java
@@ -17,6 +17,8 @@ package com.google.android.exoplayer2.extractor.ogg;
import static com.google.common.truth.Truth.assertThat;
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.testutil.FakeExtractorInput;
import com.google.android.exoplayer2.testutil.OggTestData;
import com.google.android.exoplayer2.testutil.TestUtil;
@@ -27,11 +29,9 @@ import java.util.Random;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
/** Unit test for {@link OggPacket}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class OggPacketTest {
private static final String TEST_FILE = "ogg/bear.opus";
@@ -233,7 +233,7 @@ public final class OggPacketTest {
@Test
public void testParseRealFile() throws IOException, InterruptedException {
- byte[] data = TestUtil.getByteArray(RuntimeEnvironment.application, TEST_FILE);
+ byte[] data = TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), TEST_FILE);
FakeExtractorInput input = new FakeExtractorInput.Builder().setData(data).build();
int packetCounter = 0;
while (readPacket(input)) {
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/extractor/ogg/OggPageHeaderTest.java b/library/core/src/test/java/com/google/android/exoplayer2/extractor/ogg/OggPageHeaderTest.java
index 930d067d2b..3c8911adec 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/extractor/ogg/OggPageHeaderTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/extractor/ogg/OggPageHeaderTest.java
@@ -17,6 +17,7 @@ package com.google.android.exoplayer2.extractor.ogg;
import static com.google.common.truth.Truth.assertThat;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.testutil.FakeExtractorInput;
import com.google.android.exoplayer2.testutil.FakeExtractorInput.SimulatedIOException;
import com.google.android.exoplayer2.testutil.OggTestData;
@@ -24,12 +25,9 @@ import com.google.android.exoplayer2.testutil.TestUtil;
import java.io.IOException;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-/**
- * Unit test for {@link OggPageHeader}.
- */
-@RunWith(RobolectricTestRunner.class)
+/** Unit test for {@link OggPageHeader}. */
+@RunWith(AndroidJUnit4.class)
public final class OggPageHeaderTest {
@Test
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/extractor/ogg/VorbisBitArrayTest.java b/library/core/src/test/java/com/google/android/exoplayer2/extractor/ogg/VorbisBitArrayTest.java
index eca94f076e..0b36924e55 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/extractor/ogg/VorbisBitArrayTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/extractor/ogg/VorbisBitArrayTest.java
@@ -17,15 +17,13 @@ package com.google.android.exoplayer2.extractor.ogg;
import static com.google.common.truth.Truth.assertThat;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.testutil.TestUtil;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-/**
- * Unit test for {@link VorbisBitArray}.
- */
-@RunWith(RobolectricTestRunner.class)
+/** Unit test for {@link VorbisBitArray}. */
+@RunWith(AndroidJUnit4.class)
public final class VorbisBitArrayTest {
@Test
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/extractor/ogg/VorbisReaderTest.java b/library/core/src/test/java/com/google/android/exoplayer2/extractor/ogg/VorbisReaderTest.java
index f0361c5395..ab521fc99e 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/extractor/ogg/VorbisReaderTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/extractor/ogg/VorbisReaderTest.java
@@ -19,6 +19,7 @@ import static com.google.android.exoplayer2.extractor.ogg.VorbisReader.readBits;
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.fail;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.extractor.ExtractorInput;
import com.google.android.exoplayer2.extractor.ogg.VorbisReader.VorbisSetup;
import com.google.android.exoplayer2.testutil.FakeExtractorInput;
@@ -28,12 +29,9 @@ import com.google.android.exoplayer2.util.ParsableByteArray;
import java.io.IOException;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-/**
- * Unit test for {@link VorbisReader}.
- */
-@RunWith(RobolectricTestRunner.class)
+/** Unit test for {@link VorbisReader}. */
+@RunWith(AndroidJUnit4.class)
public final class VorbisReaderTest {
@Test
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/extractor/ogg/VorbisUtilTest.java b/library/core/src/test/java/com/google/android/exoplayer2/extractor/ogg/VorbisUtilTest.java
index 5b395771fc..dc3b1510ef 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/extractor/ogg/VorbisUtilTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/extractor/ogg/VorbisUtilTest.java
@@ -20,17 +20,15 @@ import static com.google.android.exoplayer2.extractor.ogg.VorbisUtil.verifyVorbi
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.fail;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.ParserException;
import com.google.android.exoplayer2.testutil.OggTestData;
import com.google.android.exoplayer2.util.ParsableByteArray;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-/**
- * Unit test for {@link VorbisUtil}.
- */
-@RunWith(RobolectricTestRunner.class)
+/** Unit test for {@link VorbisUtil}. */
+@RunWith(AndroidJUnit4.class)
public final class VorbisUtilTest {
@Test
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/extractor/rawcc/RawCcExtractorTest.java b/library/core/src/test/java/com/google/android/exoplayer2/extractor/rawcc/RawCcExtractorTest.java
index 9551c9df29..4210bebd54 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/extractor/rawcc/RawCcExtractorTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/extractor/rawcc/RawCcExtractorTest.java
@@ -15,15 +15,15 @@
*/
package com.google.android.exoplayer2.extractor.rawcc;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.testutil.ExtractorAsserts;
import com.google.android.exoplayer2.util.MimeTypes;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** Tests for {@link RawCcExtractor}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class RawCcExtractorTest {
@Test
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/extractor/ts/Ac3ExtractorTest.java b/library/core/src/test/java/com/google/android/exoplayer2/extractor/ts/Ac3ExtractorTest.java
index 92dcf10f19..0fe15ac86e 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/extractor/ts/Ac3ExtractorTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/extractor/ts/Ac3ExtractorTest.java
@@ -15,13 +15,13 @@
*/
package com.google.android.exoplayer2.extractor.ts;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.testutil.ExtractorAsserts;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** Unit test for {@link Ac3Extractor}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class Ac3ExtractorTest {
@Test
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/extractor/ts/AdtsExtractorSeekTest.java b/library/core/src/test/java/com/google/android/exoplayer2/extractor/ts/AdtsExtractorSeekTest.java
index c0a35427b0..4527e41f34 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/extractor/ts/AdtsExtractorSeekTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/extractor/ts/AdtsExtractorSeekTest.java
@@ -18,6 +18,8 @@ package com.google.android.exoplayer2.extractor.ts;
import static com.google.common.truth.Truth.assertThat;
import android.net.Uri;
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.extractor.SeekMap;
import com.google.android.exoplayer2.testutil.FakeExtractorOutput;
import com.google.android.exoplayer2.testutil.FakeTrackOutput;
@@ -30,11 +32,9 @@ import java.util.Random;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
/** Unit test for {@link AdtsExtractor}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class AdtsExtractorSeekTest {
private static final Random random = new Random(1234L);
@@ -49,7 +49,7 @@ public final class AdtsExtractorSeekTest {
@Before
public void setUp() {
dataSource =
- new DefaultDataSourceFactory(RuntimeEnvironment.application, "UserAgent")
+ new DefaultDataSourceFactory(ApplicationProvider.getApplicationContext(), "UserAgent")
.createDataSource();
}
@@ -60,7 +60,7 @@ public final class AdtsExtractorSeekTest {
Uri fileUri = TestUtil.buildAssetUri(fileName);
expectedTrackOutput =
TestUtil.extractAllSamplesFromFile(
- createAdtsExtractor(), RuntimeEnvironment.application, fileName)
+ createAdtsExtractor(), ApplicationProvider.getApplicationContext(), fileName)
.trackOutputs
.get(0);
@@ -80,7 +80,7 @@ public final class AdtsExtractorSeekTest {
Uri fileUri = TestUtil.buildAssetUri(fileName);
expectedTrackOutput =
TestUtil.extractAllSamplesFromFile(
- createAdtsExtractor(), RuntimeEnvironment.application, fileName)
+ createAdtsExtractor(), ApplicationProvider.getApplicationContext(), fileName)
.trackOutputs
.get(0);
@@ -107,7 +107,7 @@ public final class AdtsExtractorSeekTest {
Uri fileUri = TestUtil.buildAssetUri(fileName);
expectedTrackOutput =
TestUtil.extractAllSamplesFromFile(
- createAdtsExtractor(), RuntimeEnvironment.application, fileName)
+ createAdtsExtractor(), ApplicationProvider.getApplicationContext(), fileName)
.trackOutputs
.get(0);
AdtsExtractor extractor = createAdtsExtractor();
@@ -134,7 +134,7 @@ public final class AdtsExtractorSeekTest {
Uri fileUri = TestUtil.buildAssetUri(fileName);
expectedTrackOutput =
TestUtil.extractAllSamplesFromFile(
- createAdtsExtractor(), RuntimeEnvironment.application, fileName)
+ createAdtsExtractor(), ApplicationProvider.getApplicationContext(), fileName)
.trackOutputs
.get(0);
AdtsExtractor extractor = createAdtsExtractor();
@@ -163,7 +163,7 @@ public final class AdtsExtractorSeekTest {
Uri fileUri = TestUtil.buildAssetUri(fileName);
expectedTrackOutput =
TestUtil.extractAllSamplesFromFile(
- createAdtsExtractor(), RuntimeEnvironment.application, fileName)
+ createAdtsExtractor(), ApplicationProvider.getApplicationContext(), fileName)
.trackOutputs
.get(0);
AdtsExtractor extractor = createAdtsExtractor();
@@ -192,7 +192,7 @@ public final class AdtsExtractorSeekTest {
Uri fileUri = TestUtil.buildAssetUri(fileName);
expectedTrackOutput =
TestUtil.extractAllSamplesFromFile(
- createAdtsExtractor(), RuntimeEnvironment.application, fileName)
+ createAdtsExtractor(), ApplicationProvider.getApplicationContext(), fileName)
.trackOutputs
.get(0);
AdtsExtractor extractor = createAdtsExtractor();
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/extractor/ts/AdtsExtractorTest.java b/library/core/src/test/java/com/google/android/exoplayer2/extractor/ts/AdtsExtractorTest.java
index 7f0db67133..25e2a336ff 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/extractor/ts/AdtsExtractorTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/extractor/ts/AdtsExtractorTest.java
@@ -15,13 +15,13 @@
*/
package com.google.android.exoplayer2.extractor.ts;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.testutil.ExtractorAsserts;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** Unit test for {@link AdtsExtractor}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class AdtsExtractorTest {
@Test
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/extractor/ts/AdtsReaderTest.java b/library/core/src/test/java/com/google/android/exoplayer2/extractor/ts/AdtsReaderTest.java
index 62da914f5b..1562475822 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/extractor/ts/AdtsReaderTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/extractor/ts/AdtsReaderTest.java
@@ -17,6 +17,7 @@ package com.google.android.exoplayer2.extractor.ts;
import static com.google.android.exoplayer2.extractor.ts.TsPayloadReader.FLAG_DATA_ALIGNMENT_INDICATOR;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ParserException;
import com.google.android.exoplayer2.extractor.ts.TsPayloadReader.TrackIdGenerator;
@@ -28,10 +29,9 @@ import java.util.Arrays;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** Test for {@link AdtsReader}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public class AdtsReaderTest {
public static final byte[] ID3_DATA_1 =
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/extractor/ts/PsDurationReaderTest.java b/library/core/src/test/java/com/google/android/exoplayer2/extractor/ts/PsDurationReaderTest.java
index 418b2726bf..d522178ceb 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/extractor/ts/PsDurationReaderTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/extractor/ts/PsDurationReaderTest.java
@@ -17,6 +17,8 @@ package com.google.android.exoplayer2.extractor.ts;
import static com.google.common.truth.Truth.assertThat;
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.extractor.Extractor;
import com.google.android.exoplayer2.extractor.PositionHolder;
import com.google.android.exoplayer2.testutil.FakeExtractorInput;
@@ -25,11 +27,9 @@ import java.io.IOException;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
/** Unit test for {@link PsDurationReader}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class PsDurationReaderTest {
private PsDurationReader tsDurationReader;
@@ -50,7 +50,8 @@ public final class PsDurationReaderTest {
public void testReadDuration_returnsCorrectDuration() throws IOException, InterruptedException {
FakeExtractorInput input =
new FakeExtractorInput.Builder()
- .setData(TestUtil.getByteArray(RuntimeEnvironment.application, "ts/sample.ps"))
+ .setData(
+ TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), "ts/sample.ps"))
.build();
int result = Extractor.RESULT_CONTINUE;
@@ -69,7 +70,8 @@ public final class PsDurationReaderTest {
throws IOException, InterruptedException {
FakeExtractorInput input =
new FakeExtractorInput.Builder()
- .setData(TestUtil.getByteArray(RuntimeEnvironment.application, "ts/sample.ps"))
+ .setData(
+ TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), "ts/sample.ps"))
.build();
input.setPosition(1234);
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/extractor/ts/PsExtractorSeekTest.java b/library/core/src/test/java/com/google/android/exoplayer2/extractor/ts/PsExtractorSeekTest.java
index 33be3a26fd..f974a86622 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/extractor/ts/PsExtractorSeekTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/extractor/ts/PsExtractorSeekTest.java
@@ -19,6 +19,8 @@ import static com.google.common.truth.Truth.assertThat;
import android.content.Context;
import android.net.Uri;
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.extractor.DefaultExtractorInput;
import com.google.android.exoplayer2.extractor.Extractor;
@@ -39,11 +41,9 @@ import java.util.Random;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
/** Seeking tests for {@link PsExtractor}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class PsExtractorSeekTest {
private static final String PS_FILE_PATH = "ts/elephants_dream.mpg";
@@ -63,11 +63,12 @@ public final class PsExtractorSeekTest {
public void setUp() throws IOException, InterruptedException {
expectedOutput = new FakeExtractorOutput();
positionHolder = new PositionHolder();
- extractAllSamplesFromFileToExpectedOutput(RuntimeEnvironment.application, PS_FILE_PATH);
+ extractAllSamplesFromFileToExpectedOutput(
+ ApplicationProvider.getApplicationContext(), PS_FILE_PATH);
expectedTrackOutput = expectedOutput.trackOutputs.get(VIDEO_TRACK_ID);
dataSource =
- new DefaultDataSourceFactory(RuntimeEnvironment.application, "UserAgent")
+ new DefaultDataSourceFactory(ApplicationProvider.getApplicationContext(), "UserAgent")
.createDataSource();
totalInputLength = readInputLength();
}
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/extractor/ts/PsExtractorTest.java b/library/core/src/test/java/com/google/android/exoplayer2/extractor/ts/PsExtractorTest.java
index 0e0fd52175..4cf8f817fe 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/extractor/ts/PsExtractorTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/extractor/ts/PsExtractorTest.java
@@ -15,13 +15,13 @@
*/
package com.google.android.exoplayer2.extractor.ts;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.testutil.ExtractorAsserts;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** Unit test for {@link PsExtractor}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class PsExtractorTest {
@Test
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/extractor/ts/SectionReaderTest.java b/library/core/src/test/java/com/google/android/exoplayer2/extractor/ts/SectionReaderTest.java
index 7bff736b4a..a089751464 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/extractor/ts/SectionReaderTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/extractor/ts/SectionReaderTest.java
@@ -20,6 +20,7 @@ import static com.google.common.truth.Truth.assertThat;
import static java.util.Arrays.asList;
import static java.util.Collections.singletonList;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.extractor.ExtractorOutput;
import com.google.android.exoplayer2.testutil.FakeExtractorOutput;
import com.google.android.exoplayer2.util.ParsableByteArray;
@@ -30,12 +31,9 @@ import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-/**
- * Test for {@link SectionReader}.
- */
-@RunWith(RobolectricTestRunner.class)
+/** Test for {@link SectionReader}. */
+@RunWith(AndroidJUnit4.class)
public final class SectionReaderTest {
private byte[] packetPayload;
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/extractor/ts/TsDurationReaderTest.java b/library/core/src/test/java/com/google/android/exoplayer2/extractor/ts/TsDurationReaderTest.java
index e7e100f38c..b1531e91f7 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/extractor/ts/TsDurationReaderTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/extractor/ts/TsDurationReaderTest.java
@@ -17,6 +17,8 @@ package com.google.android.exoplayer2.extractor.ts;
import static com.google.common.truth.Truth.assertThat;
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.extractor.Extractor;
import com.google.android.exoplayer2.extractor.PositionHolder;
import com.google.android.exoplayer2.testutil.FakeExtractorInput;
@@ -25,11 +27,9 @@ import java.io.IOException;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
/** Unit test for {@link TsDurationReader}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class TsDurationReaderTest {
private TsDurationReader tsDurationReader;
@@ -50,7 +50,9 @@ public final class TsDurationReaderTest {
public void testReadDuration_returnsCorrectDuration() throws IOException, InterruptedException {
FakeExtractorInput input =
new FakeExtractorInput.Builder()
- .setData(TestUtil.getByteArray(RuntimeEnvironment.application, "ts/bbb_2500ms.ts"))
+ .setData(
+ TestUtil.getByteArray(
+ ApplicationProvider.getApplicationContext(), "ts/bbb_2500ms.ts"))
.setSimulateIOErrors(false)
.setSimulateUnknownLength(false)
.setSimulatePartialReads(false)
@@ -73,7 +75,9 @@ public final class TsDurationReaderTest {
throws IOException, InterruptedException {
FakeExtractorInput input =
new FakeExtractorInput.Builder()
- .setData(TestUtil.getByteArray(RuntimeEnvironment.application, "ts/bbb_2500ms.ts"))
+ .setData(
+ TestUtil.getByteArray(
+ ApplicationProvider.getApplicationContext(), "ts/bbb_2500ms.ts"))
.setSimulateIOErrors(false)
.setSimulateUnknownLength(false)
.setSimulatePartialReads(false)
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/extractor/ts/TsExtractorSeekTest.java b/library/core/src/test/java/com/google/android/exoplayer2/extractor/ts/TsExtractorSeekTest.java
index 4d421b05a4..956ccc2390 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/extractor/ts/TsExtractorSeekTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/extractor/ts/TsExtractorSeekTest.java
@@ -18,6 +18,8 @@ package com.google.android.exoplayer2.extractor.ts;
import static com.google.common.truth.Truth.assertThat;
import android.net.Uri;
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.extractor.Extractor;
import com.google.android.exoplayer2.extractor.ExtractorInput;
import com.google.android.exoplayer2.extractor.PositionHolder;
@@ -34,11 +36,9 @@ import java.util.Random;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
/** Seeking tests for {@link TsExtractor}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class TsExtractorSeekTest {
private static final String TEST_FILE = "ts/bbb_2500ms.ts";
@@ -57,12 +57,12 @@ public final class TsExtractorSeekTest {
positionHolder = new PositionHolder();
expectedTrackOutput =
TestUtil.extractAllSamplesFromFile(
- new TsExtractor(), RuntimeEnvironment.application, TEST_FILE)
+ new TsExtractor(), ApplicationProvider.getApplicationContext(), TEST_FILE)
.trackOutputs
.get(AUDIO_TRACK_ID);
dataSource =
- new DefaultDataSourceFactory(RuntimeEnvironment.application, "UserAgent")
+ new DefaultDataSourceFactory(ApplicationProvider.getApplicationContext(), "UserAgent")
.createDataSource();
}
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/extractor/ts/TsExtractorTest.java b/library/core/src/test/java/com/google/android/exoplayer2/extractor/ts/TsExtractorTest.java
index beaa5ffa83..f1b962a712 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/extractor/ts/TsExtractorTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/extractor/ts/TsExtractorTest.java
@@ -18,6 +18,8 @@ package com.google.android.exoplayer2.extractor.ts;
import static com.google.common.truth.Truth.assertThat;
import android.util.SparseArray;
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.extractor.Extractor;
@@ -37,11 +39,9 @@ import java.io.ByteArrayOutputStream;
import java.util.Random;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
/** Unit test for {@link TsExtractor}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class TsExtractorTest {
private static final int TS_PACKET_SIZE = 188;
@@ -55,7 +55,8 @@ public final class TsExtractorTest {
@Test
public void testStreamWithJunkData() throws Exception {
Random random = new Random(0);
- byte[] fileData = TestUtil.getByteArray(RuntimeEnvironment.application, "ts/sample.ts");
+ byte[] fileData =
+ TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), "ts/sample.ts");
ByteArrayOutputStream out = new ByteArrayOutputStream(fileData.length * 2);
int bytesLeft = fileData.length;
@@ -74,7 +75,7 @@ public final class TsExtractorTest {
fileData = out.toByteArray();
ExtractorAsserts.assertOutput(
- TsExtractor::new, "ts/sample.ts", fileData, RuntimeEnvironment.application);
+ TsExtractor::new, "ts/sample.ts", fileData, ApplicationProvider.getApplicationContext());
}
@Test
@@ -84,7 +85,8 @@ public final class TsExtractorTest {
new TsExtractor(TsExtractor.MODE_MULTI_PMT, new TimestampAdjuster(0), factory);
FakeExtractorInput input =
new FakeExtractorInput.Builder()
- .setData(TestUtil.getByteArray(RuntimeEnvironment.application, "ts/sample.ts"))
+ .setData(
+ TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), "ts/sample.ts"))
.setSimulateIOErrors(false)
.setSimulateUnknownLength(false)
.setSimulatePartialReads(false)
@@ -114,7 +116,9 @@ public final class TsExtractorTest {
new TsExtractor(TsExtractor.MODE_MULTI_PMT, new TimestampAdjuster(0), factory);
FakeExtractorInput input =
new FakeExtractorInput.Builder()
- .setData(TestUtil.getByteArray(RuntimeEnvironment.application, "ts/sample_with_sdt.ts"))
+ .setData(
+ TestUtil.getByteArray(
+ ApplicationProvider.getApplicationContext(), "ts/sample_with_sdt.ts"))
.setSimulateIOErrors(false)
.setSimulateUnknownLength(false)
.setSimulatePartialReads(false)
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/extractor/wav/WavExtractorTest.java b/library/core/src/test/java/com/google/android/exoplayer2/extractor/wav/WavExtractorTest.java
index f4df4036f6..c617b672e2 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/extractor/wav/WavExtractorTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/extractor/wav/WavExtractorTest.java
@@ -15,13 +15,13 @@
*/
package com.google.android.exoplayer2.extractor.wav;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.testutil.ExtractorAsserts;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** Unit test for {@link WavExtractor}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class WavExtractorTest {
@Test
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/metadata/emsg/EventMessageDecoderTest.java b/library/core/src/test/java/com/google/android/exoplayer2/metadata/emsg/EventMessageDecoderTest.java
index 85d336b439..d870afac3a 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/metadata/emsg/EventMessageDecoderTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/metadata/emsg/EventMessageDecoderTest.java
@@ -17,17 +17,15 @@ package com.google.android.exoplayer2.metadata.emsg;
import static com.google.common.truth.Truth.assertThat;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.metadata.Metadata;
import com.google.android.exoplayer2.metadata.MetadataInputBuffer;
import java.nio.ByteBuffer;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-/**
- * Test for {@link EventMessageDecoder}.
- */
-@RunWith(RobolectricTestRunner.class)
+/** Test for {@link EventMessageDecoder}. */
+@RunWith(AndroidJUnit4.class)
public final class EventMessageDecoderTest {
@Test
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/metadata/emsg/EventMessageEncoderTest.java b/library/core/src/test/java/com/google/android/exoplayer2/metadata/emsg/EventMessageEncoderTest.java
index 2869692272..ca8303d3e2 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/metadata/emsg/EventMessageEncoderTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/metadata/emsg/EventMessageEncoderTest.java
@@ -17,18 +17,16 @@ package com.google.android.exoplayer2.metadata.emsg;
import static com.google.common.truth.Truth.assertThat;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.metadata.Metadata;
import com.google.android.exoplayer2.metadata.MetadataInputBuffer;
import java.io.IOException;
import java.nio.ByteBuffer;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-/**
- * Unit test for {@link EventMessageEncoder}.
- */
-@RunWith(RobolectricTestRunner.class)
+/** Unit test for {@link EventMessageEncoder}. */
+@RunWith(AndroidJUnit4.class)
public final class EventMessageEncoderTest {
@Test
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/metadata/emsg/EventMessageTest.java b/library/core/src/test/java/com/google/android/exoplayer2/metadata/emsg/EventMessageTest.java
index f7970d1a16..d9e9ab7ea7 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/metadata/emsg/EventMessageTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/metadata/emsg/EventMessageTest.java
@@ -18,14 +18,12 @@ package com.google.android.exoplayer2.metadata.emsg;
import static com.google.common.truth.Truth.assertThat;
import android.os.Parcel;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-/**
- * Test for {@link EventMessage}.
- */
-@RunWith(RobolectricTestRunner.class)
+/** Test for {@link EventMessage}. */
+@RunWith(AndroidJUnit4.class)
public final class EventMessageTest {
@Test
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/metadata/icy/IcyDecoderTest.java b/library/core/src/test/java/com/google/android/exoplayer2/metadata/icy/IcyDecoderTest.java
index 66387470e9..9cbcea5814 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/metadata/icy/IcyDecoderTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/metadata/icy/IcyDecoderTest.java
@@ -17,13 +17,13 @@ package com.google.android.exoplayer2.metadata.icy;
import static com.google.common.truth.Truth.assertThat;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.metadata.Metadata;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** Test for {@link IcyDecoder}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class IcyDecoderTest {
@Test
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/metadata/icy/IcyHeadersTest.java b/library/core/src/test/java/com/google/android/exoplayer2/metadata/icy/IcyHeadersTest.java
index a33c3fed8b..93f88c76e7 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/metadata/icy/IcyHeadersTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/metadata/icy/IcyHeadersTest.java
@@ -18,12 +18,12 @@ package com.google.android.exoplayer2.metadata.icy;
import static com.google.common.truth.Truth.assertThat;
import android.os.Parcel;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** Test for {@link IcyHeaders}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class IcyHeadersTest {
@Test
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/metadata/icy/IcyStreamInfoTest.java b/library/core/src/test/java/com/google/android/exoplayer2/metadata/icy/IcyStreamInfoTest.java
index 85823680eb..2bffe171d3 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/metadata/icy/IcyStreamInfoTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/metadata/icy/IcyStreamInfoTest.java
@@ -18,12 +18,12 @@ package com.google.android.exoplayer2.metadata.icy;
import static com.google.common.truth.Truth.assertThat;
import android.os.Parcel;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** Test for {@link IcyInfo}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class IcyStreamInfoTest {
@Test
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/metadata/id3/ChapterFrameTest.java b/library/core/src/test/java/com/google/android/exoplayer2/metadata/id3/ChapterFrameTest.java
index 714f77a752..fbd824c7c1 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/metadata/id3/ChapterFrameTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/metadata/id3/ChapterFrameTest.java
@@ -18,14 +18,12 @@ package com.google.android.exoplayer2.metadata.id3;
import static com.google.common.truth.Truth.assertThat;
import android.os.Parcel;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-/**
- * Test for {@link ChapterFrame}.
- */
-@RunWith(RobolectricTestRunner.class)
+/** Test for {@link ChapterFrame}. */
+@RunWith(AndroidJUnit4.class)
public final class ChapterFrameTest {
@Test
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/metadata/id3/ChapterTocFrameTest.java b/library/core/src/test/java/com/google/android/exoplayer2/metadata/id3/ChapterTocFrameTest.java
index 98a99a4219..daf9ff1bb5 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/metadata/id3/ChapterTocFrameTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/metadata/id3/ChapterTocFrameTest.java
@@ -18,14 +18,12 @@ package com.google.android.exoplayer2.metadata.id3;
import static com.google.common.truth.Truth.assertThat;
import android.os.Parcel;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-/**
- * Test for {@link ChapterTocFrame}.
- */
-@RunWith(RobolectricTestRunner.class)
+/** Test for {@link ChapterTocFrame}. */
+@RunWith(AndroidJUnit4.class)
public final class ChapterTocFrameTest {
@Test
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/metadata/id3/Id3DecoderTest.java b/library/core/src/test/java/com/google/android/exoplayer2/metadata/id3/Id3DecoderTest.java
index 3fa491ea50..a20cbb66a2 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/metadata/id3/Id3DecoderTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/metadata/id3/Id3DecoderTest.java
@@ -17,6 +17,7 @@ package com.google.android.exoplayer2.metadata.id3;
import static com.google.common.truth.Truth.assertThat;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.metadata.Metadata;
import com.google.android.exoplayer2.util.Assertions;
@@ -24,12 +25,9 @@ import java.nio.charset.Charset;
import java.util.Arrays;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-/**
- * Test for {@link Id3Decoder}.
- */
-@RunWith(RobolectricTestRunner.class)
+/** Test for {@link Id3Decoder}. */
+@RunWith(AndroidJUnit4.class)
public final class Id3DecoderTest {
private static final byte[] TAG_HEADER = new byte[] {'I', 'D', '3', 4, 0, 0, 0, 0, 0, 0};
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/metadata/id3/MlltFrameTest.java b/library/core/src/test/java/com/google/android/exoplayer2/metadata/id3/MlltFrameTest.java
index 3e6520beca..d6bbecdf6c 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/metadata/id3/MlltFrameTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/metadata/id3/MlltFrameTest.java
@@ -18,12 +18,12 @@ package com.google.android.exoplayer2.metadata.id3;
import static com.google.common.truth.Truth.assertThat;
import android.os.Parcel;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** Test for {@link MlltFrame}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class MlltFrameTest {
@Test
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/metadata/scte35/SpliceInfoDecoderTest.java b/library/core/src/test/java/com/google/android/exoplayer2/metadata/scte35/SpliceInfoDecoderTest.java
index d8a4e97791..92fa147c30 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/metadata/scte35/SpliceInfoDecoderTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/metadata/scte35/SpliceInfoDecoderTest.java
@@ -18,6 +18,7 @@ package com.google.android.exoplayer2.metadata.scte35;
import static com.google.android.exoplayer2.C.TIME_UNSET;
import static com.google.common.truth.Truth.assertThat;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.metadata.Metadata;
import com.google.android.exoplayer2.metadata.MetadataInputBuffer;
import com.google.android.exoplayer2.util.TimestampAdjuster;
@@ -26,12 +27,9 @@ import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-/**
- * Test for {@link SpliceInfoDecoder}.
- */
-@RunWith(RobolectricTestRunner.class)
+/** Test for {@link SpliceInfoDecoder}. */
+@RunWith(AndroidJUnit4.class)
public final class SpliceInfoDecoderTest {
private SpliceInfoDecoder decoder;
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/offline/ActionFileTest.java b/library/core/src/test/java/com/google/android/exoplayer2/offline/ActionFileTest.java
index 2e3da2cc7f..4f82bdb09c 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/offline/ActionFileTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/offline/ActionFileTest.java
@@ -18,6 +18,8 @@ package com.google.android.exoplayer2.offline;
import static com.google.common.truth.Truth.assertThat;
import android.net.Uri;
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.testutil.TestUtil;
import com.google.android.exoplayer2.util.Util;
import java.io.DataOutputStream;
@@ -30,11 +32,9 @@ import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
/** Unit tests for {@link ActionFile}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public class ActionFileTest {
private File tempFile;
@@ -43,7 +43,7 @@ public class ActionFileTest {
@Before
public void setUp() throws Exception {
- tempFile = Util.createTempFile(RuntimeEnvironment.application, "ExoPlayerTest");
+ tempFile = Util.createTempFile(ApplicationProvider.getApplicationContext(), "ExoPlayerTest");
action1 =
buildAction(
DownloadAction.TYPE_PROGRESSIVE,
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/offline/DefaultDownloadIndexTest.java b/library/core/src/test/java/com/google/android/exoplayer2/offline/DefaultDownloadIndexTest.java
index 1c5ac3e0f7..f967a9c0d7 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/offline/DefaultDownloadIndexTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/offline/DefaultDownloadIndexTest.java
@@ -19,6 +19,8 @@ import static com.google.android.exoplayer2.offline.DefaultDownloadIndex.INSTANC
import static com.google.common.truth.Truth.assertThat;
import android.database.sqlite.SQLiteDatabase;
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.database.DatabaseIOException;
import com.google.android.exoplayer2.database.ExoDatabaseProvider;
import com.google.android.exoplayer2.database.VersionTable;
@@ -26,11 +28,9 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
/** Unit tests for {@link DefaultDownloadIndex}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public class DefaultDownloadIndexTest {
private ExoDatabaseProvider databaseProvider;
@@ -38,7 +38,7 @@ public class DefaultDownloadIndexTest {
@Before
public void setUp() {
- databaseProvider = new ExoDatabaseProvider(RuntimeEnvironment.application);
+ databaseProvider = new ExoDatabaseProvider(ApplicationProvider.getApplicationContext());
downloadIndex = new DefaultDownloadIndex(databaseProvider);
}
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/offline/DefaultDownloaderFactoryTest.java b/library/core/src/test/java/com/google/android/exoplayer2/offline/DefaultDownloaderFactoryTest.java
index 346d033e1a..21152c3341 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/offline/DefaultDownloaderFactoryTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/offline/DefaultDownloaderFactoryTest.java
@@ -18,16 +18,16 @@ package com.google.android.exoplayer2.offline;
import static com.google.common.truth.Truth.assertThat;
import android.net.Uri;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.upstream.DummyDataSource;
import com.google.android.exoplayer2.upstream.cache.Cache;
import java.util.Collections;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
-import org.robolectric.RobolectricTestRunner;
/** Unit tests for {@link DefaultDownloaderFactory}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class DefaultDownloaderFactoryTest {
@Test
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/offline/DownloadActionTest.java b/library/core/src/test/java/com/google/android/exoplayer2/offline/DownloadActionTest.java
index 96aa4e4509..571d76125c 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/offline/DownloadActionTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/offline/DownloadActionTest.java
@@ -22,6 +22,8 @@ import static com.google.android.exoplayer2.offline.DownloadAction.TYPE_SS;
import static com.google.common.truth.Truth.assertThat;
import android.net.Uri;
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.testutil.TestUtil;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -35,11 +37,9 @@ import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
/** Unit tests for {@link DownloadAction}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public class DownloadActionTest {
private Uri uri1;
@@ -291,7 +291,8 @@ public class DownloadActionTest {
private static void assertDeserialization(String fileName, DownloadAction expectedAction)
throws IOException {
InputStream input =
- TestUtil.getInputStream(RuntimeEnvironment.application, "download-actions/" + fileName);
+ TestUtil.getInputStream(
+ ApplicationProvider.getApplicationContext(), "download-actions/" + fileName);
DownloadAction deserializedAction = DownloadAction.deserializeFromStream(input);
assertEqual(deserializedAction, expectedAction);
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/offline/DownloadHelperTest.java b/library/core/src/test/java/com/google/android/exoplayer2/offline/DownloadHelperTest.java
index 6f41e10046..a78b229043 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/offline/DownloadHelperTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/offline/DownloadHelperTest.java
@@ -18,6 +18,7 @@ package com.google.android.exoplayer2.offline;
import static com.google.common.truth.Truth.assertThat;
import android.net.Uri;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.Renderer;
@@ -51,12 +52,11 @@ import java.util.concurrent.atomic.AtomicReference;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowLooper;
/** Unit tests for {@link DownloadHelper}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
@Config(shadows = {RobolectricUtil.CustomLooper.class, RobolectricUtil.CustomMessageQueue.class})
public class DownloadHelperTest {
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/offline/DownloadIndexUtilTest.java b/library/core/src/test/java/com/google/android/exoplayer2/offline/DownloadIndexUtilTest.java
index 3372d41d32..f22024d87c 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/offline/DownloadIndexUtilTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/offline/DownloadIndexUtilTest.java
@@ -19,6 +19,8 @@ import static com.google.android.exoplayer2.offline.DownloadAction.TYPE_DASH;
import static com.google.common.truth.Truth.assertThat;
import android.net.Uri;
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.database.ExoDatabaseProvider;
import com.google.android.exoplayer2.util.Util;
import java.io.File;
@@ -29,11 +31,9 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
/** Unit tests for {@link DownloadIndexUtil}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public class DownloadIndexUtilTest {
private File tempFile;
@@ -42,8 +42,8 @@ public class DownloadIndexUtilTest {
@Before
public void setUp() throws Exception {
- tempFile = Util.createTempFile(RuntimeEnvironment.application, "ExoPlayerTest");
- databaseProvider = new ExoDatabaseProvider(RuntimeEnvironment.application);
+ tempFile = Util.createTempFile(ApplicationProvider.getApplicationContext(), "ExoPlayerTest");
+ databaseProvider = new ExoDatabaseProvider(ApplicationProvider.getApplicationContext());
downloadIndex = new DefaultDownloadIndex(databaseProvider);
}
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/offline/DownloadManagerTest.java b/library/core/src/test/java/com/google/android/exoplayer2/offline/DownloadManagerTest.java
index 74b9c4dfce..ba1238d158 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/offline/DownloadManagerTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/offline/DownloadManagerTest.java
@@ -19,6 +19,8 @@ import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.fail;
import android.net.Uri;
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.offline.DownloadState.State;
import com.google.android.exoplayer2.scheduler.Requirements;
@@ -39,13 +41,11 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.MockitoAnnotations;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowLog;
/** Tests {@link DownloadManager}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
@Config(shadows = {RobolectricUtil.CustomLooper.class, RobolectricUtil.CustomMessageQueue.class})
public class DownloadManagerTest {
@@ -77,7 +77,7 @@ public class DownloadManagerTest {
uri2 = Uri.parse("http://abc.com/media2");
uri3 = Uri.parse("http://abc.com/media3");
dummyMainThread = new DummyMainThread();
- actionFile = Util.createTempFile(RuntimeEnvironment.application, "ExoPlayerTest");
+ actionFile = Util.createTempFile(ApplicationProvider.getApplicationContext(), "ExoPlayerTest");
downloaderFactory = new FakeDownloaderFactory();
setUpDownloadManager(100);
}
@@ -470,7 +470,7 @@ public class DownloadManagerTest {
() -> {
downloadManager =
new DownloadManager(
- RuntimeEnvironment.application,
+ ApplicationProvider.getApplicationContext(),
actionFile,
downloaderFactory,
maxActiveDownloadTasks,
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/offline/DownloadStateTest.java b/library/core/src/test/java/com/google/android/exoplayer2/offline/DownloadStateTest.java
index de6369d1fe..38c8f1bc6e 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/offline/DownloadStateTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/offline/DownloadStateTest.java
@@ -19,15 +19,15 @@ import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.fail;
import android.net.Uri;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import java.util.Arrays;
import java.util.Collections;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** Unit tests for {@link DownloadState}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public class DownloadStateTest {
private Uri testUri;
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/source/ClippingMediaSourceTest.java b/library/core/src/test/java/com/google/android/exoplayer2/source/ClippingMediaSourceTest.java
index 8077b77d7e..fc29e134d9 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/source/ClippingMediaSourceTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/source/ClippingMediaSourceTest.java
@@ -20,6 +20,7 @@ import static org.junit.Assert.fail;
import android.os.Handler;
import androidx.annotation.Nullable;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.Timeline;
@@ -42,11 +43,10 @@ import java.io.IOException;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
/** Unit tests for {@link ClippingMediaSource}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
@Config(shadows = {RobolectricUtil.CustomLooper.class, RobolectricUtil.CustomMessageQueue.class})
public final class ClippingMediaSourceTest {
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/source/CompositeSequenceableLoaderTest.java b/library/core/src/test/java/com/google/android/exoplayer2/source/CompositeSequenceableLoaderTest.java
index 82d7f21852..4a881d53b4 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/source/CompositeSequenceableLoaderTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/source/CompositeSequenceableLoaderTest.java
@@ -17,15 +17,13 @@ package com.google.android.exoplayer2.source;
import static com.google.common.truth.Truth.assertThat;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-/**
- * Unit test for {@link CompositeSequenceableLoader}.
- */
-@RunWith(RobolectricTestRunner.class)
+/** Unit test for {@link CompositeSequenceableLoader}. */
+@RunWith(AndroidJUnit4.class)
public final class CompositeSequenceableLoaderTest {
/**
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/source/ConcatenatingMediaSourceTest.java b/library/core/src/test/java/com/google/android/exoplayer2/source/ConcatenatingMediaSourceTest.java
index 2665b61f8a..685801abdf 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/source/ConcatenatingMediaSourceTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/source/ConcatenatingMediaSourceTest.java
@@ -22,6 +22,7 @@ import static org.mockito.Mockito.verify;
import android.os.ConditionVariable;
import android.os.Handler;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.Timeline;
@@ -44,11 +45,10 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
/** Unit tests for {@link ConcatenatingMediaSource}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
@Config(shadows = {RobolectricUtil.CustomLooper.class, RobolectricUtil.CustomMessageQueue.class})
public final class ConcatenatingMediaSourceTest {
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/source/LoopingMediaSourceTest.java b/library/core/src/test/java/com/google/android/exoplayer2/source/LoopingMediaSourceTest.java
index 9b7455ee37..68de5fef18 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/source/LoopingMediaSourceTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/source/LoopingMediaSourceTest.java
@@ -15,6 +15,7 @@
*/
package com.google.android.exoplayer2.source;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.Timeline;
@@ -28,11 +29,10 @@ import java.io.IOException;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
/** Unit tests for {@link LoopingMediaSource}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
@Config(shadows = {RobolectricUtil.CustomLooper.class, RobolectricUtil.CustomMessageQueue.class})
public class LoopingMediaSourceTest {
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/source/MergingMediaSourceTest.java b/library/core/src/test/java/com/google/android/exoplayer2/source/MergingMediaSourceTest.java
index 3318f5a42f..130ba3c2dd 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/source/MergingMediaSourceTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/source/MergingMediaSourceTest.java
@@ -18,6 +18,7 @@ package com.google.android.exoplayer2.source;
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.fail;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.source.MergingMediaSource.IllegalMergeException;
@@ -29,11 +30,10 @@ import com.google.android.exoplayer2.testutil.RobolectricUtil;
import java.io.IOException;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
/** Unit tests for {@link MergingMediaSource}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
@Config(shadows = {RobolectricUtil.CustomLooper.class, RobolectricUtil.CustomMessageQueue.class})
public class MergingMediaSourceTest {
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/source/SampleQueueTest.java b/library/core/src/test/java/com/google/android/exoplayer2/source/SampleQueueTest.java
index 99dfc1b04e..450f0ecd3a 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/source/SampleQueueTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/source/SampleQueueTest.java
@@ -24,6 +24,7 @@ import static java.lang.Long.MIN_VALUE;
import static java.util.Arrays.copyOfRange;
import androidx.annotation.Nullable;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.FormatHolder;
@@ -36,12 +37,9 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-/**
- * Test for {@link SampleQueue}.
- */
-@RunWith(RobolectricTestRunner.class)
+/** Test for {@link SampleQueue}. */
+@RunWith(AndroidJUnit4.class)
public final class SampleQueueTest {
private static final int ALLOCATION_SIZE = 16;
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/source/ShuffleOrderTest.java b/library/core/src/test/java/com/google/android/exoplayer2/source/ShuffleOrderTest.java
index 430ceb87f1..8fce472c68 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/source/ShuffleOrderTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/source/ShuffleOrderTest.java
@@ -18,17 +18,15 @@ package com.google.android.exoplayer2.source;
import static com.google.android.exoplayer2.C.INDEX_UNSET;
import static com.google.common.truth.Truth.assertThat;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.source.ShuffleOrder.DefaultShuffleOrder;
import com.google.android.exoplayer2.source.ShuffleOrder.UnshuffledShuffleOrder;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-/**
- * Unit test for {@link ShuffleOrder}.
- */
-@RunWith(RobolectricTestRunner.class)
+/** Unit test for {@link ShuffleOrder}. */
+@RunWith(AndroidJUnit4.class)
public final class ShuffleOrderTest {
public static final long RANDOM_SEED = 1234567890L;
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/source/SinglePeriodTimelineTest.java b/library/core/src/test/java/com/google/android/exoplayer2/source/SinglePeriodTimelineTest.java
index 1b57341d33..bdd6820efa 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/source/SinglePeriodTimelineTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/source/SinglePeriodTimelineTest.java
@@ -18,18 +18,16 @@ package com.google.android.exoplayer2.source;
import static com.google.common.truth.Truth.assertThat;
import android.util.Pair;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Timeline.Period;
import com.google.android.exoplayer2.Timeline.Window;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-/**
- * Unit test for {@link SinglePeriodTimeline}.
- */
-@RunWith(RobolectricTestRunner.class)
+/** Unit test for {@link SinglePeriodTimeline}. */
+@RunWith(AndroidJUnit4.class)
public final class SinglePeriodTimelineTest {
private Window window;
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/source/TrackGroupArrayTest.java b/library/core/src/test/java/com/google/android/exoplayer2/source/TrackGroupArrayTest.java
index 86778a0fa0..36adc97147 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/source/TrackGroupArrayTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/source/TrackGroupArrayTest.java
@@ -18,14 +18,14 @@ package com.google.android.exoplayer2.source;
import static com.google.common.truth.Truth.assertThat;
import android.os.Parcel;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.util.MimeTypes;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** Unit test for {@link TrackGroupArray}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class TrackGroupArrayTest {
@Test
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/source/TrackGroupTest.java b/library/core/src/test/java/com/google/android/exoplayer2/source/TrackGroupTest.java
index 1900f3c586..4de1f8eb84 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/source/TrackGroupTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/source/TrackGroupTest.java
@@ -18,14 +18,14 @@ package com.google.android.exoplayer2.source;
import static com.google.common.truth.Truth.assertThat;
import android.os.Parcel;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.util.MimeTypes;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** Unit test for {@link TrackGroup}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class TrackGroupTest {
@Test
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/source/ads/AdPlaybackStateTest.java b/library/core/src/test/java/com/google/android/exoplayer2/source/ads/AdPlaybackStateTest.java
index da03df9b8a..80e7383d12 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/source/ads/AdPlaybackStateTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/source/ads/AdPlaybackStateTest.java
@@ -19,14 +19,14 @@ import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.fail;
import android.net.Uri;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** Unit test for {@link AdPlaybackState}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class AdPlaybackStateTest {
private static final long[] TEST_AD_GROUP_TMES_US = new long[] {0, C.msToUs(10_000)};
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/source/chunk/MediaChunkListIteratorTest.java b/library/core/src/test/java/com/google/android/exoplayer2/source/chunk/MediaChunkListIteratorTest.java
index 590c06f3d5..d2169d0a38 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/source/chunk/MediaChunkListIteratorTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/source/chunk/MediaChunkListIteratorTest.java
@@ -17,16 +17,16 @@ package com.google.android.exoplayer2.source.chunk;
import static com.google.common.truth.Truth.assertThat;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.testutil.FakeMediaChunk;
import java.util.Arrays;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** Tests for {@link MediaChunkListIterator}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public class MediaChunkListIteratorTest {
private static final Format TEST_FORMAT = Format.createSampleFormat(null, null, 0);
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/text/ssa/SsaDecoderTest.java b/library/core/src/test/java/com/google/android/exoplayer2/text/ssa/SsaDecoderTest.java
index 746066cb35..ab67ac115b 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/text/ssa/SsaDecoderTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/text/ssa/SsaDecoderTest.java
@@ -17,16 +17,16 @@ package com.google.android.exoplayer2.text.ssa;
import static com.google.common.truth.Truth.assertThat;
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.testutil.TestUtil;
import java.io.IOException;
import java.util.ArrayList;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
/** Unit test for {@link SsaDecoder}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class SsaDecoderTest {
private static final String EMPTY = "ssa/empty";
@@ -40,7 +40,7 @@ public final class SsaDecoderTest {
@Test
public void testDecodeEmpty() throws IOException {
SsaDecoder decoder = new SsaDecoder();
- byte[] bytes = TestUtil.getByteArray(RuntimeEnvironment.application, EMPTY);
+ byte[] bytes = TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), EMPTY);
SsaSubtitle subtitle = decoder.decode(bytes, bytes.length, false);
assertThat(subtitle.getEventTimeCount()).isEqualTo(0);
@@ -50,7 +50,7 @@ public final class SsaDecoderTest {
@Test
public void testDecodeTypical() throws IOException {
SsaDecoder decoder = new SsaDecoder();
- byte[] bytes = TestUtil.getByteArray(RuntimeEnvironment.application, TYPICAL);
+ byte[] bytes = TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), TYPICAL);
SsaSubtitle subtitle = decoder.decode(bytes, bytes.length, false);
assertThat(subtitle.getEventTimeCount()).isEqualTo(6);
@@ -61,13 +61,16 @@ public final class SsaDecoderTest {
@Test
public void testDecodeTypicalWithInitializationData() throws IOException {
- byte[] headerBytes = TestUtil.getByteArray(RuntimeEnvironment.application, TYPICAL_HEADER_ONLY);
- byte[] formatBytes = TestUtil.getByteArray(RuntimeEnvironment.application, TYPICAL_FORMAT_ONLY);
+ byte[] headerBytes =
+ TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), TYPICAL_HEADER_ONLY);
+ byte[] formatBytes =
+ TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), TYPICAL_FORMAT_ONLY);
ArrayList initializationData = new ArrayList<>();
initializationData.add(formatBytes);
initializationData.add(headerBytes);
SsaDecoder decoder = new SsaDecoder(initializationData);
- byte[] bytes = TestUtil.getByteArray(RuntimeEnvironment.application, TYPICAL_DIALOGUE_ONLY);
+ byte[] bytes =
+ TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), TYPICAL_DIALOGUE_ONLY);
SsaSubtitle subtitle = decoder.decode(bytes, bytes.length, false);
assertThat(subtitle.getEventTimeCount()).isEqualTo(6);
@@ -80,7 +83,8 @@ public final class SsaDecoderTest {
public void testDecodeInvalidTimecodes() throws IOException {
// Parsing should succeed, parsing the third cue only.
SsaDecoder decoder = new SsaDecoder();
- byte[] bytes = TestUtil.getByteArray(RuntimeEnvironment.application, INVALID_TIMECODES);
+ byte[] bytes =
+ TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), INVALID_TIMECODES);
SsaSubtitle subtitle = decoder.decode(bytes, bytes.length, false);
assertThat(subtitle.getEventTimeCount()).isEqualTo(2);
@@ -90,7 +94,8 @@ public final class SsaDecoderTest {
@Test
public void testDecodeNoEndTimecodes() throws IOException {
SsaDecoder decoder = new SsaDecoder();
- byte[] bytes = TestUtil.getByteArray(RuntimeEnvironment.application, NO_END_TIMECODES);
+ byte[] bytes =
+ TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), NO_END_TIMECODES);
SsaSubtitle subtitle = decoder.decode(bytes, bytes.length, false);
assertThat(subtitle.getEventTimeCount()).isEqualTo(3);
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/text/subrip/SubripDecoderTest.java b/library/core/src/test/java/com/google/android/exoplayer2/text/subrip/SubripDecoderTest.java
index 1430c70e09..9520262207 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/text/subrip/SubripDecoderTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/text/subrip/SubripDecoderTest.java
@@ -17,16 +17,16 @@ package com.google.android.exoplayer2.text.subrip;
import static com.google.common.truth.Truth.assertThat;
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.testutil.TestUtil;
import com.google.android.exoplayer2.text.Cue;
import java.io.IOException;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
/** Unit test for {@link SubripDecoder}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class SubripDecoderTest {
private static final String EMPTY_FILE = "subrip/empty";
@@ -43,7 +43,7 @@ public final class SubripDecoderTest {
@Test
public void testDecodeEmpty() throws IOException {
SubripDecoder decoder = new SubripDecoder();
- byte[] bytes = TestUtil.getByteArray(RuntimeEnvironment.application, EMPTY_FILE);
+ byte[] bytes = TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), EMPTY_FILE);
SubripSubtitle subtitle = decoder.decode(bytes, bytes.length, false);
assertThat(subtitle.getEventTimeCount()).isEqualTo(0);
@@ -53,7 +53,7 @@ public final class SubripDecoderTest {
@Test
public void testDecodeTypical() throws IOException {
SubripDecoder decoder = new SubripDecoder();
- byte[] bytes = TestUtil.getByteArray(RuntimeEnvironment.application, TYPICAL_FILE);
+ byte[] bytes = TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), TYPICAL_FILE);
SubripSubtitle subtitle = decoder.decode(bytes, bytes.length, false);
assertThat(subtitle.getEventTimeCount()).isEqualTo(6);
@@ -66,7 +66,8 @@ public final class SubripDecoderTest {
public void testDecodeTypicalWithByteOrderMark() throws IOException {
SubripDecoder decoder = new SubripDecoder();
byte[] bytes =
- TestUtil.getByteArray(RuntimeEnvironment.application, TYPICAL_WITH_BYTE_ORDER_MARK);
+ TestUtil.getByteArray(
+ ApplicationProvider.getApplicationContext(), TYPICAL_WITH_BYTE_ORDER_MARK);
SubripSubtitle subtitle = decoder.decode(bytes, bytes.length, false);
assertThat(subtitle.getEventTimeCount()).isEqualTo(6);
@@ -78,7 +79,9 @@ public final class SubripDecoderTest {
@Test
public void testDecodeTypicalExtraBlankLine() throws IOException {
SubripDecoder decoder = new SubripDecoder();
- byte[] bytes = TestUtil.getByteArray(RuntimeEnvironment.application, TYPICAL_EXTRA_BLANK_LINE);
+ byte[] bytes =
+ TestUtil.getByteArray(
+ ApplicationProvider.getApplicationContext(), TYPICAL_EXTRA_BLANK_LINE);
SubripSubtitle subtitle = decoder.decode(bytes, bytes.length, false);
assertThat(subtitle.getEventTimeCount()).isEqualTo(6);
@@ -91,7 +94,9 @@ public final class SubripDecoderTest {
public void testDecodeTypicalMissingTimecode() throws IOException {
// Parsing should succeed, parsing the first and third cues only.
SubripDecoder decoder = new SubripDecoder();
- byte[] bytes = TestUtil.getByteArray(RuntimeEnvironment.application, TYPICAL_MISSING_TIMECODE);
+ byte[] bytes =
+ TestUtil.getByteArray(
+ ApplicationProvider.getApplicationContext(), TYPICAL_MISSING_TIMECODE);
SubripSubtitle subtitle = decoder.decode(bytes, bytes.length, false);
assertThat(subtitle.getEventTimeCount()).isEqualTo(4);
@@ -103,7 +108,9 @@ public final class SubripDecoderTest {
public void testDecodeTypicalMissingSequence() throws IOException {
// Parsing should succeed, parsing the first and third cues only.
SubripDecoder decoder = new SubripDecoder();
- byte[] bytes = TestUtil.getByteArray(RuntimeEnvironment.application, TYPICAL_MISSING_SEQUENCE);
+ byte[] bytes =
+ TestUtil.getByteArray(
+ ApplicationProvider.getApplicationContext(), TYPICAL_MISSING_SEQUENCE);
SubripSubtitle subtitle = decoder.decode(bytes, bytes.length, false);
assertThat(subtitle.getEventTimeCount()).isEqualTo(4);
@@ -116,7 +123,8 @@ public final class SubripDecoderTest {
// Parsing should succeed, parsing the third cue only.
SubripDecoder decoder = new SubripDecoder();
byte[] bytes =
- TestUtil.getByteArray(RuntimeEnvironment.application, TYPICAL_NEGATIVE_TIMESTAMPS);
+ TestUtil.getByteArray(
+ ApplicationProvider.getApplicationContext(), TYPICAL_NEGATIVE_TIMESTAMPS);
SubripSubtitle subtitle = decoder.decode(bytes, bytes.length, false);
assertThat(subtitle.getEventTimeCount()).isEqualTo(2);
@@ -127,7 +135,8 @@ public final class SubripDecoderTest {
public void testDecodeTypicalUnexpectedEnd() throws IOException {
// Parsing should succeed, parsing the first and second cues only.
SubripDecoder decoder = new SubripDecoder();
- byte[] bytes = TestUtil.getByteArray(RuntimeEnvironment.application, TYPICAL_UNEXPECTED_END);
+ byte[] bytes =
+ TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), TYPICAL_UNEXPECTED_END);
SubripSubtitle subtitle = decoder.decode(bytes, bytes.length, false);
assertThat(subtitle.getEventTimeCount()).isEqualTo(4);
@@ -138,7 +147,8 @@ public final class SubripDecoderTest {
@Test
public void testDecodeNoEndTimecodes() throws IOException {
SubripDecoder decoder = new SubripDecoder();
- byte[] bytes = TestUtil.getByteArray(RuntimeEnvironment.application, NO_END_TIMECODES_FILE);
+ byte[] bytes =
+ TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), NO_END_TIMECODES_FILE);
SubripSubtitle subtitle = decoder.decode(bytes, bytes.length, false);
assertThat(subtitle.getEventTimeCount()).isEqualTo(3);
@@ -159,7 +169,8 @@ public final class SubripDecoderTest {
@Test
public void testDecodeCueWithTag() throws IOException {
SubripDecoder decoder = new SubripDecoder();
- byte[] bytes = TestUtil.getByteArray(RuntimeEnvironment.application, TYPICAL_WITH_TAGS);
+ byte[] bytes =
+ TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), TYPICAL_WITH_TAGS);
SubripSubtitle subtitle = decoder.decode(bytes, bytes.length, false);
assertTypicalCue1(subtitle, 0);
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/text/ttml/TtmlDecoderTest.java b/library/core/src/test/java/com/google/android/exoplayer2/text/ttml/TtmlDecoderTest.java
index 72fff9606c..000d0634ce 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/text/ttml/TtmlDecoderTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/text/ttml/TtmlDecoderTest.java
@@ -30,6 +30,8 @@ import android.text.style.StrikethroughSpan;
import android.text.style.StyleSpan;
import android.text.style.TypefaceSpan;
import android.text.style.UnderlineSpan;
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.testutil.TestUtil;
import com.google.android.exoplayer2.text.Cue;
import com.google.android.exoplayer2.text.SubtitleDecoderException;
@@ -39,11 +41,9 @@ import java.util.List;
import java.util.Map;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
/** Unit test for {@link TtmlDecoder}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class TtmlDecoderTest {
private static final String INLINE_ATTRIBUTES_TTML_FILE = "ttml/inline_style_attributes.xml";
@@ -700,7 +700,7 @@ public final class TtmlDecoderTest {
private TtmlSubtitle getSubtitle(String file) throws IOException, SubtitleDecoderException {
TtmlDecoder ttmlDecoder = new TtmlDecoder();
- byte[] bytes = TestUtil.getByteArray(RuntimeEnvironment.application, file);
+ byte[] bytes = TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), file);
return ttmlDecoder.decode(bytes, bytes.length, false);
}
}
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/text/ttml/TtmlRenderUtilTest.java b/library/core/src/test/java/com/google/android/exoplayer2/text/ttml/TtmlRenderUtilTest.java
index 536ddbabbc..40fd6f288a 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/text/ttml/TtmlRenderUtilTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/text/ttml/TtmlRenderUtilTest.java
@@ -24,16 +24,14 @@ import static com.google.android.exoplayer2.text.ttml.TtmlStyle.STYLE_BOLD_ITALI
import static com.google.common.truth.Truth.assertThat;
import android.graphics.Color;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import java.util.HashMap;
import java.util.Map;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-/**
- * Unit test for {@link TtmlRenderUtil}.
- */
-@RunWith(RobolectricTestRunner.class)
+/** Unit test for {@link TtmlRenderUtil}. */
+@RunWith(AndroidJUnit4.class)
public final class TtmlRenderUtilTest {
@Test
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/text/ttml/TtmlStyleTest.java b/library/core/src/test/java/com/google/android/exoplayer2/text/ttml/TtmlStyleTest.java
index aa46584f54..24b5ca678f 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/text/ttml/TtmlStyleTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/text/ttml/TtmlStyleTest.java
@@ -26,13 +26,13 @@ import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import android.graphics.Color;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** Unit test for {@link TtmlStyle}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class TtmlStyleTest {
private static final String FONT_FAMILY = "serif";
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/text/tx3g/Tx3gDecoderTest.java b/library/core/src/test/java/com/google/android/exoplayer2/text/tx3g/Tx3gDecoderTest.java
index 155b8f5993..16b997e117 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/text/tx3g/Tx3gDecoderTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/text/tx3g/Tx3gDecoderTest.java
@@ -25,6 +25,8 @@ import android.text.style.ForegroundColorSpan;
import android.text.style.StyleSpan;
import android.text.style.TypefaceSpan;
import android.text.style.UnderlineSpan;
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.testutil.TestUtil;
import com.google.android.exoplayer2.text.Cue;
@@ -34,11 +36,9 @@ import java.io.IOException;
import java.util.Collections;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
/** Unit test for {@link Tx3gDecoder}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class Tx3gDecoderTest {
private static final String NO_SUBTITLE = "tx3g/no_subtitle";
@@ -56,7 +56,7 @@ public final class Tx3gDecoderTest {
@Test
public void testDecodeNoSubtitle() throws IOException, SubtitleDecoderException {
Tx3gDecoder decoder = new Tx3gDecoder(Collections.emptyList());
- byte[] bytes = TestUtil.getByteArray(RuntimeEnvironment.application, NO_SUBTITLE);
+ byte[] bytes = TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), NO_SUBTITLE);
Subtitle subtitle = decoder.decode(bytes, bytes.length, false);
assertThat(subtitle.getCues(0)).isEmpty();
}
@@ -64,7 +64,8 @@ public final class Tx3gDecoderTest {
@Test
public void testDecodeJustText() throws IOException, SubtitleDecoderException {
Tx3gDecoder decoder = new Tx3gDecoder(Collections.emptyList());
- byte[] bytes = TestUtil.getByteArray(RuntimeEnvironment.application, SAMPLE_JUST_TEXT);
+ byte[] bytes =
+ TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), SAMPLE_JUST_TEXT);
Subtitle subtitle = decoder.decode(bytes, bytes.length, false);
SpannedString text = new SpannedString(subtitle.getCues(0).get(0).text);
assertThat(text.toString()).isEqualTo("CC Test");
@@ -75,7 +76,8 @@ public final class Tx3gDecoderTest {
@Test
public void testDecodeWithStyl() throws IOException, SubtitleDecoderException {
Tx3gDecoder decoder = new Tx3gDecoder(Collections.emptyList());
- byte[] bytes = TestUtil.getByteArray(RuntimeEnvironment.application, SAMPLE_WITH_STYL);
+ byte[] bytes =
+ TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), SAMPLE_WITH_STYL);
Subtitle subtitle = decoder.decode(bytes, bytes.length, false);
SpannedString text = new SpannedString(subtitle.getCues(0).get(0).text);
assertThat(text.toString()).isEqualTo("CC Test");
@@ -92,7 +94,8 @@ public final class Tx3gDecoderTest {
public void testDecodeWithStylAllDefaults() throws IOException, SubtitleDecoderException {
Tx3gDecoder decoder = new Tx3gDecoder(Collections.emptyList());
byte[] bytes =
- TestUtil.getByteArray(RuntimeEnvironment.application, SAMPLE_WITH_STYL_ALL_DEFAULTS);
+ TestUtil.getByteArray(
+ ApplicationProvider.getApplicationContext(), SAMPLE_WITH_STYL_ALL_DEFAULTS);
Subtitle subtitle = decoder.decode(bytes, bytes.length, false);
SpannedString text = new SpannedString(subtitle.getCues(0).get(0).text);
assertThat(text.toString()).isEqualTo("CC Test");
@@ -103,7 +106,8 @@ public final class Tx3gDecoderTest {
@Test
public void testDecodeUtf16BeNoStyl() throws IOException, SubtitleDecoderException {
Tx3gDecoder decoder = new Tx3gDecoder(Collections.emptyList());
- byte[] bytes = TestUtil.getByteArray(RuntimeEnvironment.application, SAMPLE_UTF16_BE_NO_STYL);
+ byte[] bytes =
+ TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), SAMPLE_UTF16_BE_NO_STYL);
Subtitle subtitle = decoder.decode(bytes, bytes.length, false);
SpannedString text = new SpannedString(subtitle.getCues(0).get(0).text);
assertThat(text.toString()).isEqualTo("ä½ å¥½");
@@ -114,7 +118,8 @@ public final class Tx3gDecoderTest {
@Test
public void testDecodeUtf16LeNoStyl() throws IOException, SubtitleDecoderException {
Tx3gDecoder decoder = new Tx3gDecoder(Collections.emptyList());
- byte[] bytes = TestUtil.getByteArray(RuntimeEnvironment.application, SAMPLE_UTF16_LE_NO_STYL);
+ byte[] bytes =
+ TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), SAMPLE_UTF16_LE_NO_STYL);
Subtitle subtitle = decoder.decode(bytes, bytes.length, false);
SpannedString text = new SpannedString(subtitle.getCues(0).get(0).text);
assertThat(text.toString()).isEqualTo("ä½ å¥½");
@@ -125,7 +130,9 @@ public final class Tx3gDecoderTest {
@Test
public void testDecodeWithMultipleStyl() throws IOException, SubtitleDecoderException {
Tx3gDecoder decoder = new Tx3gDecoder(Collections.emptyList());
- byte[] bytes = TestUtil.getByteArray(RuntimeEnvironment.application, SAMPLE_WITH_MULTIPLE_STYL);
+ byte[] bytes =
+ TestUtil.getByteArray(
+ ApplicationProvider.getApplicationContext(), SAMPLE_WITH_MULTIPLE_STYL);
Subtitle subtitle = decoder.decode(bytes, bytes.length, false);
SpannedString text = new SpannedString(subtitle.getCues(0).get(0).text);
assertThat(text.toString()).isEqualTo("Line 2\nLine 3");
@@ -144,7 +151,8 @@ public final class Tx3gDecoderTest {
public void testDecodeWithOtherExtension() throws IOException, SubtitleDecoderException {
Tx3gDecoder decoder = new Tx3gDecoder(Collections.emptyList());
byte[] bytes =
- TestUtil.getByteArray(RuntimeEnvironment.application, SAMPLE_WITH_OTHER_EXTENSION);
+ TestUtil.getByteArray(
+ ApplicationProvider.getApplicationContext(), SAMPLE_WITH_OTHER_EXTENSION);
Subtitle subtitle = decoder.decode(bytes, bytes.length, false);
SpannedString text = new SpannedString(subtitle.getCues(0).get(0).text);
assertThat(text.toString()).isEqualTo("CC Test");
@@ -158,9 +166,11 @@ public final class Tx3gDecoderTest {
@Test
public void testInitializationDecodeWithStyl() throws IOException, SubtitleDecoderException {
- byte[] initBytes = TestUtil.getByteArray(RuntimeEnvironment.application, INITIALIZATION);
+ byte[] initBytes =
+ TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), INITIALIZATION);
Tx3gDecoder decoder = new Tx3gDecoder(Collections.singletonList(initBytes));
- byte[] bytes = TestUtil.getByteArray(RuntimeEnvironment.application, SAMPLE_WITH_STYL);
+ byte[] bytes =
+ TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), SAMPLE_WITH_STYL);
Subtitle subtitle = decoder.decode(bytes, bytes.length, false);
SpannedString text = new SpannedString(subtitle.getCues(0).get(0).text);
assertThat(text.toString()).isEqualTo("CC Test");
@@ -179,9 +189,11 @@ public final class Tx3gDecoderTest {
@Test
public void testInitializationDecodeWithTbox() throws IOException, SubtitleDecoderException {
- byte[] initBytes = TestUtil.getByteArray(RuntimeEnvironment.application, INITIALIZATION);
+ byte[] initBytes =
+ TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), INITIALIZATION);
Tx3gDecoder decoder = new Tx3gDecoder(Collections.singletonList(initBytes));
- byte[] bytes = TestUtil.getByteArray(RuntimeEnvironment.application, SAMPLE_WITH_TBOX);
+ byte[] bytes =
+ TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), SAMPLE_WITH_TBOX);
Subtitle subtitle = decoder.decode(bytes, bytes.length, false);
SpannedString text = new SpannedString(subtitle.getCues(0).get(0).text);
assertThat(text.toString()).isEqualTo("CC Test");
@@ -200,9 +212,11 @@ public final class Tx3gDecoderTest {
public void testInitializationAllDefaultsDecodeWithStyl()
throws IOException, SubtitleDecoderException {
byte[] initBytes =
- TestUtil.getByteArray(RuntimeEnvironment.application, INITIALIZATION_ALL_DEFAULTS);
+ TestUtil.getByteArray(
+ ApplicationProvider.getApplicationContext(), INITIALIZATION_ALL_DEFAULTS);
Tx3gDecoder decoder = new Tx3gDecoder(Collections.singletonList(initBytes));
- byte[] bytes = TestUtil.getByteArray(RuntimeEnvironment.application, SAMPLE_WITH_STYL);
+ byte[] bytes =
+ TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), SAMPLE_WITH_STYL);
Subtitle subtitle = decoder.decode(bytes, bytes.length, false);
SpannedString text = new SpannedString(subtitle.getCues(0).get(0).text);
assertThat(text.toString()).isEqualTo("CC Test");
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/text/webvtt/CssParserTest.java b/library/core/src/test/java/com/google/android/exoplayer2/text/webvtt/CssParserTest.java
index b81c0c68c3..fb9e1a875f 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/text/webvtt/CssParserTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/text/webvtt/CssParserTest.java
@@ -18,17 +18,15 @@ package com.google.android.exoplayer2.text.webvtt;
import static com.google.android.exoplayer2.text.webvtt.CssParser.parseNextToken;
import static com.google.common.truth.Truth.assertThat;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.util.ParsableByteArray;
import com.google.android.exoplayer2.util.Util;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-/**
- * Unit test for {@link CssParser}.
- */
-@RunWith(RobolectricTestRunner.class)
+/** Unit test for {@link CssParser}. */
+@RunWith(AndroidJUnit4.class)
public final class CssParserTest {
private CssParser parser;
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/text/webvtt/Mp4WebvttDecoderTest.java b/library/core/src/test/java/com/google/android/exoplayer2/text/webvtt/Mp4WebvttDecoderTest.java
index f0c426ea65..f930c4590f 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/text/webvtt/Mp4WebvttDecoderTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/text/webvtt/Mp4WebvttDecoderTest.java
@@ -18,18 +18,16 @@ package com.google.android.exoplayer2.text.webvtt;
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.fail;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.text.Cue;
import com.google.android.exoplayer2.text.Subtitle;
import com.google.android.exoplayer2.text.SubtitleDecoderException;
import java.util.List;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-/**
- * Unit test for {@link Mp4WebvttDecoder}.
- */
-@RunWith(RobolectricTestRunner.class)
+/** Unit test for {@link Mp4WebvttDecoder}. */
+@RunWith(AndroidJUnit4.class)
public final class Mp4WebvttDecoderTest {
private static final byte[] SINGLE_CUE_SAMPLE = {
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/text/webvtt/WebvttCueParserTest.java b/library/core/src/test/java/com/google/android/exoplayer2/text/webvtt/WebvttCueParserTest.java
index 9e42f0c049..32d2dc2060 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/text/webvtt/WebvttCueParserTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/text/webvtt/WebvttCueParserTest.java
@@ -23,15 +23,13 @@ import android.graphics.Typeface;
import android.text.Spanned;
import android.text.style.StyleSpan;
import android.text.style.UnderlineSpan;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import java.util.Collections;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-/**
- * Unit test for {@link WebvttCueParser}.
- */
-@RunWith(RobolectricTestRunner.class)
+/** Unit test for {@link WebvttCueParser}. */
+@RunWith(AndroidJUnit4.class)
public final class WebvttCueParserTest {
@Test
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/text/webvtt/WebvttDecoderTest.java b/library/core/src/test/java/com/google/android/exoplayer2/text/webvtt/WebvttDecoderTest.java
index c4724bc8b9..2a7289c039 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/text/webvtt/WebvttDecoderTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/text/webvtt/WebvttDecoderTest.java
@@ -26,6 +26,8 @@ import android.text.style.ForegroundColorSpan;
import android.text.style.StyleSpan;
import android.text.style.TypefaceSpan;
import android.text.style.UnderlineSpan;
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.testutil.TestUtil;
import com.google.android.exoplayer2.text.Cue;
import com.google.android.exoplayer2.text.SubtitleDecoderException;
@@ -33,11 +35,9 @@ import java.io.IOException;
import java.util.List;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
/** Unit test for {@link WebvttDecoder}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public class WebvttDecoderTest {
private static final String TYPICAL_FILE = "webvtt/typical";
@@ -55,7 +55,7 @@ public class WebvttDecoderTest {
@Test
public void testDecodeEmpty() throws IOException {
WebvttDecoder decoder = new WebvttDecoder();
- byte[] bytes = TestUtil.getByteArray(RuntimeEnvironment.application, EMPTY_FILE);
+ byte[] bytes = TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), EMPTY_FILE);
try {
decoder.decode(bytes, bytes.length, /* reset= */ false);
fail();
@@ -394,7 +394,7 @@ public class WebvttDecoderTest {
private WebvttSubtitle getSubtitleForTestAsset(String asset)
throws IOException, SubtitleDecoderException {
WebvttDecoder decoder = new WebvttDecoder();
- byte[] bytes = TestUtil.getByteArray(RuntimeEnvironment.application, asset);
+ byte[] bytes = TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), asset);
return decoder.decode(bytes, bytes.length, /* reset= */ false);
}
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/text/webvtt/WebvttSubtitleTest.java b/library/core/src/test/java/com/google/android/exoplayer2/text/webvtt/WebvttSubtitleTest.java
index af165ffe9b..0f0f2572b7 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/text/webvtt/WebvttSubtitleTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/text/webvtt/WebvttSubtitleTest.java
@@ -19,18 +19,16 @@ import static com.google.android.exoplayer2.C.INDEX_UNSET;
import static com.google.common.truth.Truth.assertThat;
import static java.lang.Long.MAX_VALUE;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.text.Cue;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-/**
- * Unit test for {@link WebvttSubtitle}.
- */
-@RunWith(RobolectricTestRunner.class)
+/** Unit test for {@link WebvttSubtitle}. */
+@RunWith(AndroidJUnit4.class)
public class WebvttSubtitleTest {
private static final String FIRST_SUBTITLE_STRING = "This is the first subtitle.";
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/trackselection/AdaptiveTrackSelectionTest.java b/library/core/src/test/java/com/google/android/exoplayer2/trackselection/AdaptiveTrackSelectionTest.java
index bf6b935161..666cb9815f 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/trackselection/AdaptiveTrackSelectionTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/trackselection/AdaptiveTrackSelectionTest.java
@@ -26,6 +26,7 @@ import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.source.TrackGroup;
@@ -44,10 +45,9 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentMatcher;
import org.mockito.Mock;
-import org.robolectric.RobolectricTestRunner;
/** Unit test for {@link AdaptiveTrackSelection}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class AdaptiveTrackSelectionTest {
private static final MediaChunkIterator[] THREE_EMPTY_MEDIA_CHUNK_ITERATORS =
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/trackselection/BufferSizeAdaptiveTrackSelectionTest.java b/library/core/src/test/java/com/google/android/exoplayer2/trackselection/BufferSizeAdaptiveTrackSelectionTest.java
index 9fa84e42f3..8b20630a23 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/trackselection/BufferSizeAdaptiveTrackSelectionTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/trackselection/BufferSizeAdaptiveTrackSelectionTest.java
@@ -20,6 +20,7 @@ import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import android.util.Pair;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.LoadControl;
@@ -32,10 +33,9 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.robolectric.RobolectricTestRunner;
/** Unit test for the track selection created by {@link BufferSizeAdaptationBuilder}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class BufferSizeAdaptiveTrackSelectionTest {
private static final int MIN_BUFFER_MS = 15_000;
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/trackselection/DefaultTrackSelectorTest.java b/library/core/src/test/java/com/google/android/exoplayer2/trackselection/DefaultTrackSelectorTest.java
index 53bc9f4eea..94ae1b5898 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/trackselection/DefaultTrackSelectorTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/trackselection/DefaultTrackSelectorTest.java
@@ -30,6 +30,7 @@ import static org.mockito.MockitoAnnotations.initMocks;
import android.os.Parcel;
import android.util.SparseArray;
import android.util.SparseBooleanArray;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.Format;
@@ -53,12 +54,9 @@ import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.robolectric.RobolectricTestRunner;
-/**
- * Unit tests for {@link DefaultTrackSelector}.
- */
-@RunWith(RobolectricTestRunner.class)
+/** Unit tests for {@link DefaultTrackSelector}. */
+@RunWith(AndroidJUnit4.class)
public final class DefaultTrackSelectorTest {
private static final RendererCapabilities ALL_AUDIO_FORMAT_SUPPORTED_RENDERER_CAPABILITIES =
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/trackselection/MappingTrackSelectorTest.java b/library/core/src/test/java/com/google/android/exoplayer2/trackselection/MappingTrackSelectorTest.java
index 140a9733b3..efb828fc57 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/trackselection/MappingTrackSelectorTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/trackselection/MappingTrackSelectorTest.java
@@ -18,6 +18,7 @@ package com.google.android.exoplayer2.trackselection;
import static com.google.common.truth.Truth.assertThat;
import android.util.Pair;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.Format;
@@ -32,12 +33,9 @@ import com.google.android.exoplayer2.util.MimeTypes;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-/**
- * Unit tests for {@link MappingTrackSelector}.
- */
-@RunWith(RobolectricTestRunner.class)
+/** Unit tests for {@link MappingTrackSelector}. */
+@RunWith(AndroidJUnit4.class)
public final class MappingTrackSelectorTest {
private static final RendererCapabilities VIDEO_CAPABILITIES =
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/trackselection/TrackSelectionUtilTest.java b/library/core/src/test/java/com/google/android/exoplayer2/trackselection/TrackSelectionUtilTest.java
index c513b86263..9acef96c0b 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/trackselection/TrackSelectionUtilTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/trackselection/TrackSelectionUtilTest.java
@@ -18,6 +18,7 @@ package com.google.android.exoplayer2.trackselection;
import static com.google.common.truth.Truth.assertThat;
import android.net.Uri;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.source.chunk.MediaChunkIterator;
@@ -28,10 +29,9 @@ import java.util.Arrays;
import java.util.Collections;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** {@link TrackSelectionUtil} tests. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public class TrackSelectionUtilTest {
public static final long MAX_DURATION_US = 30 * C.MICROS_PER_SECOND;
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/trackselection/TrackSelectorTest.java b/library/core/src/test/java/com/google/android/exoplayer2/trackselection/TrackSelectorTest.java
index 3b88c00e2e..477f7226a4 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/trackselection/TrackSelectorTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/trackselection/TrackSelectorTest.java
@@ -18,6 +18,7 @@ package com.google.android.exoplayer2.trackselection;
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.fail;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.RendererCapabilities;
import com.google.android.exoplayer2.Timeline;
@@ -29,10 +30,9 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
-import org.robolectric.RobolectricTestRunner;
/** Unit test for {@link TrackSelector}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public class TrackSelectorTest {
private TrackSelector trackSelector;
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/trackselection/WindowedTrackBitrateEstimatorTest.java b/library/core/src/test/java/com/google/android/exoplayer2/trackselection/WindowedTrackBitrateEstimatorTest.java
index 52b52e1df4..887338078e 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/trackselection/WindowedTrackBitrateEstimatorTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/trackselection/WindowedTrackBitrateEstimatorTest.java
@@ -19,6 +19,7 @@ package com.google.android.exoplayer2.trackselection;
import static com.google.common.truth.Truth.assertThat;
import android.net.Uri;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.source.chunk.MediaChunk;
@@ -29,10 +30,9 @@ import com.google.android.exoplayer2.upstream.DataSpec;
import java.util.Collections;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** {@link WindowedTrackBitrateEstimator} tests. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public class WindowedTrackBitrateEstimatorTest {
private static final long MAX_DURATION_MS = 30_000;
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/upstream/AssetDataSourceTest.java b/library/core/src/test/java/com/google/android/exoplayer2/upstream/AssetDataSourceTest.java
index 7ffc14d51f..7e25eacfe2 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/upstream/AssetDataSourceTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/upstream/AssetDataSourceTest.java
@@ -16,37 +16,37 @@
package com.google.android.exoplayer2.upstream;
import android.net.Uri;
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.testutil.TestUtil;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
/** Unit tests for {@link AssetDataSource}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class AssetDataSourceTest {
private static final String DATA_PATH = "binary/1024_incrementing_bytes.mp3";
@Test
public void testReadFileUri() throws Exception {
- AssetDataSource dataSource = new AssetDataSource(RuntimeEnvironment.application);
+ AssetDataSource dataSource = new AssetDataSource(ApplicationProvider.getApplicationContext());
DataSpec dataSpec = new DataSpec(Uri.parse("file:///android_asset/" + DATA_PATH));
TestUtil.assertDataSourceContent(
dataSource,
dataSpec,
- TestUtil.getByteArray(RuntimeEnvironment.application, DATA_PATH),
+ TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), DATA_PATH),
true);
}
@Test
public void testReadAssetUri() throws Exception {
- AssetDataSource dataSource = new AssetDataSource(RuntimeEnvironment.application);
+ AssetDataSource dataSource = new AssetDataSource(ApplicationProvider.getApplicationContext());
DataSpec dataSpec = new DataSpec(Uri.parse("asset:///" + DATA_PATH));
TestUtil.assertDataSourceContent(
dataSource,
dataSpec,
- TestUtil.getByteArray(RuntimeEnvironment.application, DATA_PATH),
+ TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), DATA_PATH),
true);
}
}
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/upstream/BaseDataSourceTest.java b/library/core/src/test/java/com/google/android/exoplayer2/upstream/BaseDataSourceTest.java
index f962e0d8fd..289de08c47 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/upstream/BaseDataSourceTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/upstream/BaseDataSourceTest.java
@@ -19,14 +19,14 @@ import static com.google.common.truth.Truth.assertThat;
import android.net.Uri;
import androidx.annotation.Nullable;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import java.io.IOException;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** Unit test for {@link BaseDataSource}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public class BaseDataSourceTest {
@Test
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/upstream/ByteArrayDataSourceTest.java b/library/core/src/test/java/com/google/android/exoplayer2/upstream/ByteArrayDataSourceTest.java
index f04f01bd5f..ee64e56c51 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/upstream/ByteArrayDataSourceTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/upstream/ByteArrayDataSourceTest.java
@@ -18,16 +18,14 @@ package com.google.android.exoplayer2.upstream;
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.fail;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import java.io.IOException;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-/**
- * Unit tests for {@link ByteArrayDataSource}.
- */
-@RunWith(RobolectricTestRunner.class)
+/** Unit tests for {@link ByteArrayDataSource}. */
+@RunWith(AndroidJUnit4.class)
public final class ByteArrayDataSourceTest {
private static final byte[] TEST_DATA = new byte[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/upstream/DataSchemeDataSourceTest.java b/library/core/src/test/java/com/google/android/exoplayer2/upstream/DataSchemeDataSourceTest.java
index dd1ae30bdb..2df9a608e9 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/upstream/DataSchemeDataSourceTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/upstream/DataSchemeDataSourceTest.java
@@ -20,17 +20,15 @@ import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.fail;
import android.net.Uri;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.util.Util;
import java.io.IOException;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-/**
- * Unit tests for {@link DataSchemeDataSource}.
- */
-@RunWith(RobolectricTestRunner.class)
+/** Unit tests for {@link DataSchemeDataSource}. */
+@RunWith(AndroidJUnit4.class)
public final class DataSchemeDataSourceTest {
private DataSource schemeDataDataSource;
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/upstream/DataSourceInputStreamTest.java b/library/core/src/test/java/com/google/android/exoplayer2/upstream/DataSourceInputStreamTest.java
index f47cfc4469..257f1c45b3 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/upstream/DataSourceInputStreamTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/upstream/DataSourceInputStreamTest.java
@@ -18,18 +18,16 @@ package com.google.android.exoplayer2.upstream;
import static com.google.common.truth.Truth.assertThat;
import android.net.Uri;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.testutil.FakeDataSource;
import com.google.android.exoplayer2.testutil.TestUtil;
import java.io.IOException;
import java.util.Arrays;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-/**
- * Unit tests for {@link DataSourceInputStream}.
- */
-@RunWith(RobolectricTestRunner.class)
+/** Unit tests for {@link DataSourceInputStream}. */
+@RunWith(AndroidJUnit4.class)
public final class DataSourceInputStreamTest {
private static final byte[] TEST_DATA = TestUtil.buildTestData(16);
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/upstream/DefaultBandwidthMeterTest.java b/library/core/src/test/java/com/google/android/exoplayer2/upstream/DefaultBandwidthMeterTest.java
index ec5d82e712..d8d22a7b2f 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/upstream/DefaultBandwidthMeterTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/upstream/DefaultBandwidthMeterTest.java
@@ -23,6 +23,8 @@ import android.net.NetworkInfo;
import android.net.NetworkInfo.DetailedState;
import android.net.Uri;
import android.telephony.TelephonyManager;
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.testutil.FakeClock;
import com.google.android.exoplayer2.testutil.FakeDataSource;
@@ -30,13 +32,11 @@ import java.util.Random;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
import org.robolectric.Shadows;
import org.robolectric.shadows.ShadowNetworkInfo;
/** Unit test for {@link DefaultBandwidthMeter}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class DefaultBandwidthMeterTest {
private static final int SIMULATED_TRANSFER_COUNT = 100;
@@ -56,10 +56,11 @@ public final class DefaultBandwidthMeterTest {
public void setUp() {
connectivityManager =
(ConnectivityManager)
- RuntimeEnvironment.application.getSystemService(Context.CONNECTIVITY_SERVICE);
+ ApplicationProvider.getApplicationContext()
+ .getSystemService(Context.CONNECTIVITY_SERVICE);
telephonyManager =
(TelephonyManager)
- RuntimeEnvironment.application.getSystemService(Context.TELEPHONY_SERVICE);
+ ApplicationProvider.getApplicationContext().getSystemService(Context.TELEPHONY_SERVICE);
Shadows.shadowOf(telephonyManager).setNetworkCountryIso(FAST_COUNTRY_ISO);
networkInfoOffline =
ShadowNetworkInfo.newInstance(
@@ -109,12 +110,12 @@ public final class DefaultBandwidthMeterTest {
public void defaultInitialBitrateEstimate_forWifi_isGreaterThanEstimateFor2G() {
setActiveNetworkInfo(networkInfoWifi);
DefaultBandwidthMeter bandwidthMeterWifi =
- new DefaultBandwidthMeter.Builder(RuntimeEnvironment.application).build();
+ new DefaultBandwidthMeter.Builder(ApplicationProvider.getApplicationContext()).build();
long initialEstimateWifi = bandwidthMeterWifi.getBitrateEstimate();
setActiveNetworkInfo(networkInfo2g);
DefaultBandwidthMeter bandwidthMeter2g =
- new DefaultBandwidthMeter.Builder(RuntimeEnvironment.application).build();
+ new DefaultBandwidthMeter.Builder(ApplicationProvider.getApplicationContext()).build();
long initialEstimate2g = bandwidthMeter2g.getBitrateEstimate();
assertThat(initialEstimateWifi).isGreaterThan(initialEstimate2g);
@@ -124,12 +125,12 @@ public final class DefaultBandwidthMeterTest {
public void defaultInitialBitrateEstimate_forWifi_isGreaterThanEstimateFor3G() {
setActiveNetworkInfo(networkInfoWifi);
DefaultBandwidthMeter bandwidthMeterWifi =
- new DefaultBandwidthMeter.Builder(RuntimeEnvironment.application).build();
+ new DefaultBandwidthMeter.Builder(ApplicationProvider.getApplicationContext()).build();
long initialEstimateWifi = bandwidthMeterWifi.getBitrateEstimate();
setActiveNetworkInfo(networkInfo3g);
DefaultBandwidthMeter bandwidthMeter3g =
- new DefaultBandwidthMeter.Builder(RuntimeEnvironment.application).build();
+ new DefaultBandwidthMeter.Builder(ApplicationProvider.getApplicationContext()).build();
long initialEstimate3g = bandwidthMeter3g.getBitrateEstimate();
assertThat(initialEstimateWifi).isGreaterThan(initialEstimate3g);
@@ -139,12 +140,12 @@ public final class DefaultBandwidthMeterTest {
public void defaultInitialBitrateEstimate_forEthernet_isGreaterThanEstimateFor2G() {
setActiveNetworkInfo(networkInfoEthernet);
DefaultBandwidthMeter bandwidthMeterEthernet =
- new DefaultBandwidthMeter.Builder(RuntimeEnvironment.application).build();
+ new DefaultBandwidthMeter.Builder(ApplicationProvider.getApplicationContext()).build();
long initialEstimateEthernet = bandwidthMeterEthernet.getBitrateEstimate();
setActiveNetworkInfo(networkInfo2g);
DefaultBandwidthMeter bandwidthMeter2g =
- new DefaultBandwidthMeter.Builder(RuntimeEnvironment.application).build();
+ new DefaultBandwidthMeter.Builder(ApplicationProvider.getApplicationContext()).build();
long initialEstimate2g = bandwidthMeter2g.getBitrateEstimate();
assertThat(initialEstimateEthernet).isGreaterThan(initialEstimate2g);
@@ -154,12 +155,12 @@ public final class DefaultBandwidthMeterTest {
public void defaultInitialBitrateEstimate_forEthernet_isGreaterThanEstimateFor3G() {
setActiveNetworkInfo(networkInfoEthernet);
DefaultBandwidthMeter bandwidthMeterEthernet =
- new DefaultBandwidthMeter.Builder(RuntimeEnvironment.application).build();
+ new DefaultBandwidthMeter.Builder(ApplicationProvider.getApplicationContext()).build();
long initialEstimateEthernet = bandwidthMeterEthernet.getBitrateEstimate();
setActiveNetworkInfo(networkInfo3g);
DefaultBandwidthMeter bandwidthMeter3g =
- new DefaultBandwidthMeter.Builder(RuntimeEnvironment.application).build();
+ new DefaultBandwidthMeter.Builder(ApplicationProvider.getApplicationContext()).build();
long initialEstimate3g = bandwidthMeter3g.getBitrateEstimate();
assertThat(initialEstimateEthernet).isGreaterThan(initialEstimate3g);
@@ -169,12 +170,12 @@ public final class DefaultBandwidthMeterTest {
public void defaultInitialBitrateEstimate_for4G_isGreaterThanEstimateFor2G() {
setActiveNetworkInfo(networkInfo4g);
DefaultBandwidthMeter bandwidthMeter4g =
- new DefaultBandwidthMeter.Builder(RuntimeEnvironment.application).build();
+ new DefaultBandwidthMeter.Builder(ApplicationProvider.getApplicationContext()).build();
long initialEstimate4g = bandwidthMeter4g.getBitrateEstimate();
setActiveNetworkInfo(networkInfo2g);
DefaultBandwidthMeter bandwidthMeter2g =
- new DefaultBandwidthMeter.Builder(RuntimeEnvironment.application).build();
+ new DefaultBandwidthMeter.Builder(ApplicationProvider.getApplicationContext()).build();
long initialEstimate2g = bandwidthMeter2g.getBitrateEstimate();
assertThat(initialEstimate4g).isGreaterThan(initialEstimate2g);
@@ -184,12 +185,12 @@ public final class DefaultBandwidthMeterTest {
public void defaultInitialBitrateEstimate_for4G_isGreaterThanEstimateFor3G() {
setActiveNetworkInfo(networkInfo4g);
DefaultBandwidthMeter bandwidthMeter4g =
- new DefaultBandwidthMeter.Builder(RuntimeEnvironment.application).build();
+ new DefaultBandwidthMeter.Builder(ApplicationProvider.getApplicationContext()).build();
long initialEstimate4g = bandwidthMeter4g.getBitrateEstimate();
setActiveNetworkInfo(networkInfo3g);
DefaultBandwidthMeter bandwidthMeter3g =
- new DefaultBandwidthMeter.Builder(RuntimeEnvironment.application).build();
+ new DefaultBandwidthMeter.Builder(ApplicationProvider.getApplicationContext()).build();
long initialEstimate3g = bandwidthMeter3g.getBitrateEstimate();
assertThat(initialEstimate4g).isGreaterThan(initialEstimate3g);
@@ -199,12 +200,12 @@ public final class DefaultBandwidthMeterTest {
public void defaultInitialBitrateEstimate_for3G_isGreaterThanEstimateFor2G() {
setActiveNetworkInfo(networkInfo3g);
DefaultBandwidthMeter bandwidthMeter3g =
- new DefaultBandwidthMeter.Builder(RuntimeEnvironment.application).build();
+ new DefaultBandwidthMeter.Builder(ApplicationProvider.getApplicationContext()).build();
long initialEstimate3g = bandwidthMeter3g.getBitrateEstimate();
setActiveNetworkInfo(networkInfo2g);
DefaultBandwidthMeter bandwidthMeter2g =
- new DefaultBandwidthMeter.Builder(RuntimeEnvironment.application).build();
+ new DefaultBandwidthMeter.Builder(ApplicationProvider.getApplicationContext()).build();
long initialEstimate2g = bandwidthMeter2g.getBitrateEstimate();
assertThat(initialEstimate3g).isGreaterThan(initialEstimate2g);
@@ -214,7 +215,7 @@ public final class DefaultBandwidthMeterTest {
public void defaultInitialBitrateEstimate_forOffline_isReasonable() {
setActiveNetworkInfo(networkInfoOffline);
DefaultBandwidthMeter bandwidthMeter =
- new DefaultBandwidthMeter.Builder(RuntimeEnvironment.application).build();
+ new DefaultBandwidthMeter.Builder(ApplicationProvider.getApplicationContext()).build();
long initialEstimate = bandwidthMeter.getBitrateEstimate();
assertThat(initialEstimate).isGreaterThan(100_000L);
@@ -227,12 +228,12 @@ public final class DefaultBandwidthMeterTest {
setActiveNetworkInfo(networkInfoWifi);
setNetworkCountryIso(FAST_COUNTRY_ISO);
DefaultBandwidthMeter bandwidthMeterFast =
- new DefaultBandwidthMeter.Builder(RuntimeEnvironment.application).build();
+ new DefaultBandwidthMeter.Builder(ApplicationProvider.getApplicationContext()).build();
long initialEstimateFast = bandwidthMeterFast.getBitrateEstimate();
setNetworkCountryIso(SLOW_COUNTRY_ISO);
DefaultBandwidthMeter bandwidthMeterSlow =
- new DefaultBandwidthMeter.Builder(RuntimeEnvironment.application).build();
+ new DefaultBandwidthMeter.Builder(ApplicationProvider.getApplicationContext()).build();
long initialEstimateSlow = bandwidthMeterSlow.getBitrateEstimate();
assertThat(initialEstimateFast).isGreaterThan(initialEstimateSlow);
@@ -244,12 +245,12 @@ public final class DefaultBandwidthMeterTest {
setActiveNetworkInfo(networkInfoEthernet);
setNetworkCountryIso(FAST_COUNTRY_ISO);
DefaultBandwidthMeter bandwidthMeterFast =
- new DefaultBandwidthMeter.Builder(RuntimeEnvironment.application).build();
+ new DefaultBandwidthMeter.Builder(ApplicationProvider.getApplicationContext()).build();
long initialEstimateFast = bandwidthMeterFast.getBitrateEstimate();
setNetworkCountryIso(SLOW_COUNTRY_ISO);
DefaultBandwidthMeter bandwidthMeterSlow =
- new DefaultBandwidthMeter.Builder(RuntimeEnvironment.application).build();
+ new DefaultBandwidthMeter.Builder(ApplicationProvider.getApplicationContext()).build();
long initialEstimateSlow = bandwidthMeterSlow.getBitrateEstimate();
assertThat(initialEstimateFast).isGreaterThan(initialEstimateSlow);
@@ -261,12 +262,12 @@ public final class DefaultBandwidthMeterTest {
setActiveNetworkInfo(networkInfo2g);
setNetworkCountryIso(FAST_COUNTRY_ISO);
DefaultBandwidthMeter bandwidthMeterFast =
- new DefaultBandwidthMeter.Builder(RuntimeEnvironment.application).build();
+ new DefaultBandwidthMeter.Builder(ApplicationProvider.getApplicationContext()).build();
long initialEstimateFast = bandwidthMeterFast.getBitrateEstimate();
setNetworkCountryIso(SLOW_COUNTRY_ISO);
DefaultBandwidthMeter bandwidthMeterSlow =
- new DefaultBandwidthMeter.Builder(RuntimeEnvironment.application).build();
+ new DefaultBandwidthMeter.Builder(ApplicationProvider.getApplicationContext()).build();
long initialEstimateSlow = bandwidthMeterSlow.getBitrateEstimate();
assertThat(initialEstimateFast).isGreaterThan(initialEstimateSlow);
@@ -278,12 +279,12 @@ public final class DefaultBandwidthMeterTest {
setActiveNetworkInfo(networkInfo3g);
setNetworkCountryIso(FAST_COUNTRY_ISO);
DefaultBandwidthMeter bandwidthMeterFast =
- new DefaultBandwidthMeter.Builder(RuntimeEnvironment.application).build();
+ new DefaultBandwidthMeter.Builder(ApplicationProvider.getApplicationContext()).build();
long initialEstimateFast = bandwidthMeterFast.getBitrateEstimate();
setNetworkCountryIso(SLOW_COUNTRY_ISO);
DefaultBandwidthMeter bandwidthMeterSlow =
- new DefaultBandwidthMeter.Builder(RuntimeEnvironment.application).build();
+ new DefaultBandwidthMeter.Builder(ApplicationProvider.getApplicationContext()).build();
long initialEstimateSlow = bandwidthMeterSlow.getBitrateEstimate();
assertThat(initialEstimateFast).isGreaterThan(initialEstimateSlow);
@@ -295,12 +296,12 @@ public final class DefaultBandwidthMeterTest {
setActiveNetworkInfo(networkInfo4g);
setNetworkCountryIso(FAST_COUNTRY_ISO);
DefaultBandwidthMeter bandwidthMeterFast =
- new DefaultBandwidthMeter.Builder(RuntimeEnvironment.application).build();
+ new DefaultBandwidthMeter.Builder(ApplicationProvider.getApplicationContext()).build();
long initialEstimateFast = bandwidthMeterFast.getBitrateEstimate();
setNetworkCountryIso(SLOW_COUNTRY_ISO);
DefaultBandwidthMeter bandwidthMeterSlow =
- new DefaultBandwidthMeter.Builder(RuntimeEnvironment.application).build();
+ new DefaultBandwidthMeter.Builder(ApplicationProvider.getApplicationContext()).build();
long initialEstimateSlow = bandwidthMeterSlow.getBitrateEstimate();
assertThat(initialEstimateFast).isGreaterThan(initialEstimateSlow);
@@ -310,7 +311,7 @@ public final class DefaultBandwidthMeterTest {
public void initialBitrateEstimateOverwrite_whileConnectedToNetwork_setsInitialEstimate() {
setActiveNetworkInfo(networkInfoWifi);
DefaultBandwidthMeter bandwidthMeter =
- new DefaultBandwidthMeter.Builder(RuntimeEnvironment.application)
+ new DefaultBandwidthMeter.Builder(ApplicationProvider.getApplicationContext())
.setInitialBitrateEstimate(123456789)
.build();
long initialEstimate = bandwidthMeter.getBitrateEstimate();
@@ -322,7 +323,7 @@ public final class DefaultBandwidthMeterTest {
public void initialBitrateEstimateOverwrite_whileOffline_setsInitialEstimate() {
setActiveNetworkInfo(networkInfoOffline);
DefaultBandwidthMeter bandwidthMeter =
- new DefaultBandwidthMeter.Builder(RuntimeEnvironment.application)
+ new DefaultBandwidthMeter.Builder(ApplicationProvider.getApplicationContext())
.setInitialBitrateEstimate(123456789)
.build();
long initialEstimate = bandwidthMeter.getBitrateEstimate();
@@ -334,7 +335,7 @@ public final class DefaultBandwidthMeterTest {
public void initialBitrateEstimateOverwrite_forWifi_whileConnectedToWifi_setsInitialEstimate() {
setActiveNetworkInfo(networkInfoWifi);
DefaultBandwidthMeter bandwidthMeter =
- new DefaultBandwidthMeter.Builder(RuntimeEnvironment.application)
+ new DefaultBandwidthMeter.Builder(ApplicationProvider.getApplicationContext())
.setInitialBitrateEstimate(C.NETWORK_TYPE_WIFI, 123456789)
.build();
long initialEstimate = bandwidthMeter.getBitrateEstimate();
@@ -347,7 +348,7 @@ public final class DefaultBandwidthMeterTest {
initialBitrateEstimateOverwrite_forWifi_whileConnectedToOtherNetwork_doesNotSetInitialEstimate() {
setActiveNetworkInfo(networkInfo2g);
DefaultBandwidthMeter bandwidthMeter =
- new DefaultBandwidthMeter.Builder(RuntimeEnvironment.application)
+ new DefaultBandwidthMeter.Builder(ApplicationProvider.getApplicationContext())
.setInitialBitrateEstimate(C.NETWORK_TYPE_WIFI, 123456789)
.build();
long initialEstimate = bandwidthMeter.getBitrateEstimate();
@@ -360,7 +361,7 @@ public final class DefaultBandwidthMeterTest {
initialBitrateEstimateOverwrite_forEthernet_whileConnectedToEthernet_setsInitialEstimate() {
setActiveNetworkInfo(networkInfoEthernet);
DefaultBandwidthMeter bandwidthMeter =
- new DefaultBandwidthMeter.Builder(RuntimeEnvironment.application)
+ new DefaultBandwidthMeter.Builder(ApplicationProvider.getApplicationContext())
.setInitialBitrateEstimate(C.NETWORK_TYPE_ETHERNET, 123456789)
.build();
long initialEstimate = bandwidthMeter.getBitrateEstimate();
@@ -373,7 +374,7 @@ public final class DefaultBandwidthMeterTest {
initialBitrateEstimateOverwrite_forEthernet_whileConnectedToOtherNetwork_doesNotSetInitialEstimate() {
setActiveNetworkInfo(networkInfo2g);
DefaultBandwidthMeter bandwidthMeter =
- new DefaultBandwidthMeter.Builder(RuntimeEnvironment.application)
+ new DefaultBandwidthMeter.Builder(ApplicationProvider.getApplicationContext())
.setInitialBitrateEstimate(C.NETWORK_TYPE_WIFI, 123456789)
.build();
long initialEstimate = bandwidthMeter.getBitrateEstimate();
@@ -385,7 +386,7 @@ public final class DefaultBandwidthMeterTest {
public void initialBitrateEstimateOverwrite_for2G_whileConnectedTo2G_setsInitialEstimate() {
setActiveNetworkInfo(networkInfo2g);
DefaultBandwidthMeter bandwidthMeter =
- new DefaultBandwidthMeter.Builder(RuntimeEnvironment.application)
+ new DefaultBandwidthMeter.Builder(ApplicationProvider.getApplicationContext())
.setInitialBitrateEstimate(C.NETWORK_TYPE_2G, 123456789)
.build();
long initialEstimate = bandwidthMeter.getBitrateEstimate();
@@ -398,7 +399,7 @@ public final class DefaultBandwidthMeterTest {
initialBitrateEstimateOverwrite_for2G_whileConnectedToOtherNetwork_doesNotSetInitialEstimate() {
setActiveNetworkInfo(networkInfoWifi);
DefaultBandwidthMeter bandwidthMeter =
- new DefaultBandwidthMeter.Builder(RuntimeEnvironment.application)
+ new DefaultBandwidthMeter.Builder(ApplicationProvider.getApplicationContext())
.setInitialBitrateEstimate(C.NETWORK_TYPE_2G, 123456789)
.build();
long initialEstimate = bandwidthMeter.getBitrateEstimate();
@@ -410,7 +411,7 @@ public final class DefaultBandwidthMeterTest {
public void initialBitrateEstimateOverwrite_for3G_whileConnectedTo3G_setsInitialEstimate() {
setActiveNetworkInfo(networkInfo3g);
DefaultBandwidthMeter bandwidthMeter =
- new DefaultBandwidthMeter.Builder(RuntimeEnvironment.application)
+ new DefaultBandwidthMeter.Builder(ApplicationProvider.getApplicationContext())
.setInitialBitrateEstimate(C.NETWORK_TYPE_3G, 123456789)
.build();
long initialEstimate = bandwidthMeter.getBitrateEstimate();
@@ -423,7 +424,7 @@ public final class DefaultBandwidthMeterTest {
initialBitrateEstimateOverwrite_for3G_whileConnectedToOtherNetwork_doesNotSetInitialEstimate() {
setActiveNetworkInfo(networkInfoWifi);
DefaultBandwidthMeter bandwidthMeter =
- new DefaultBandwidthMeter.Builder(RuntimeEnvironment.application)
+ new DefaultBandwidthMeter.Builder(ApplicationProvider.getApplicationContext())
.setInitialBitrateEstimate(C.NETWORK_TYPE_3G, 123456789)
.build();
long initialEstimate = bandwidthMeter.getBitrateEstimate();
@@ -435,7 +436,7 @@ public final class DefaultBandwidthMeterTest {
public void initialBitrateEstimateOverwrite_for4G_whileConnectedTo4G_setsInitialEstimate() {
setActiveNetworkInfo(networkInfo4g);
DefaultBandwidthMeter bandwidthMeter =
- new DefaultBandwidthMeter.Builder(RuntimeEnvironment.application)
+ new DefaultBandwidthMeter.Builder(ApplicationProvider.getApplicationContext())
.setInitialBitrateEstimate(C.NETWORK_TYPE_4G, 123456789)
.build();
long initialEstimate = bandwidthMeter.getBitrateEstimate();
@@ -448,7 +449,7 @@ public final class DefaultBandwidthMeterTest {
initialBitrateEstimateOverwrite_for4G_whileConnectedToOtherNetwork_doesNotSetInitialEstimate() {
setActiveNetworkInfo(networkInfoWifi);
DefaultBandwidthMeter bandwidthMeter =
- new DefaultBandwidthMeter.Builder(RuntimeEnvironment.application)
+ new DefaultBandwidthMeter.Builder(ApplicationProvider.getApplicationContext())
.setInitialBitrateEstimate(C.NETWORK_TYPE_4G, 123456789)
.build();
long initialEstimate = bandwidthMeter.getBitrateEstimate();
@@ -460,7 +461,7 @@ public final class DefaultBandwidthMeterTest {
public void initialBitrateEstimateOverwrite_forOffline_whileOffline_setsInitialEstimate() {
setActiveNetworkInfo(networkInfoOffline);
DefaultBandwidthMeter bandwidthMeter =
- new DefaultBandwidthMeter.Builder(RuntimeEnvironment.application)
+ new DefaultBandwidthMeter.Builder(ApplicationProvider.getApplicationContext())
.setInitialBitrateEstimate(C.NETWORK_TYPE_OFFLINE, 123456789)
.build();
long initialEstimate = bandwidthMeter.getBitrateEstimate();
@@ -473,7 +474,7 @@ public final class DefaultBandwidthMeterTest {
initialBitrateEstimateOverwrite_forOffline_whileConnectedToNetwork_doesNotSetInitialEstimate() {
setActiveNetworkInfo(networkInfoWifi);
DefaultBandwidthMeter bandwidthMeter =
- new DefaultBandwidthMeter.Builder(RuntimeEnvironment.application)
+ new DefaultBandwidthMeter.Builder(ApplicationProvider.getApplicationContext())
.setInitialBitrateEstimate(C.NETWORK_TYPE_OFFLINE, 123456789)
.build();
long initialEstimate = bandwidthMeter.getBitrateEstimate();
@@ -485,12 +486,12 @@ public final class DefaultBandwidthMeterTest {
public void initialBitrateEstimateOverwrite_forCountry_usesDefaultValuesForCountry() {
setNetworkCountryIso(SLOW_COUNTRY_ISO);
DefaultBandwidthMeter bandwidthMeterSlow =
- new DefaultBandwidthMeter.Builder(RuntimeEnvironment.application).build();
+ new DefaultBandwidthMeter.Builder(ApplicationProvider.getApplicationContext()).build();
long initialEstimateSlow = bandwidthMeterSlow.getBitrateEstimate();
setNetworkCountryIso(FAST_COUNTRY_ISO);
DefaultBandwidthMeter bandwidthMeterFastWithSlowOverwrite =
- new DefaultBandwidthMeter.Builder(RuntimeEnvironment.application)
+ new DefaultBandwidthMeter.Builder(ApplicationProvider.getApplicationContext())
.setInitialBitrateEstimate(SLOW_COUNTRY_ISO)
.build();
long initialEstimateFastWithSlowOverwrite =
@@ -503,7 +504,7 @@ public final class DefaultBandwidthMeterTest {
public void networkTypeOverride_updatesBitrateEstimate() {
setActiveNetworkInfo(networkInfoEthernet);
DefaultBandwidthMeter bandwidthMeter =
- new DefaultBandwidthMeter.Builder(RuntimeEnvironment.application).build();
+ new DefaultBandwidthMeter.Builder(ApplicationProvider.getApplicationContext()).build();
long initialEstimateEthernet = bandwidthMeter.getBitrateEstimate();
bandwidthMeter.setNetworkTypeOverride(C.NETWORK_TYPE_2G);
@@ -518,13 +519,17 @@ public final class DefaultBandwidthMeterTest {
setActiveNetworkInfo(networkInfoEthernet);
FakeClock clock = new FakeClock(/* initialTimeMs= */ 0);
DefaultBandwidthMeter bandwidthMeter =
- new DefaultBandwidthMeter.Builder(RuntimeEnvironment.application).setClock(clock).build();
+ new DefaultBandwidthMeter.Builder(ApplicationProvider.getApplicationContext())
+ .setClock(clock)
+ .build();
long[] bitrateEstimatesWithNewInstance = simulateTransfers(bandwidthMeter, clock);
// Create a new instance and seed with some transfers.
setActiveNetworkInfo(networkInfo2g);
bandwidthMeter =
- new DefaultBandwidthMeter.Builder(RuntimeEnvironment.application).setClock(clock).build();
+ new DefaultBandwidthMeter.Builder(ApplicationProvider.getApplicationContext())
+ .setClock(clock)
+ .build();
simulateTransfers(bandwidthMeter, clock);
// Override the network type to ethernet and simulate transfers again.
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/upstream/DefaultLoadErrorHandlingPolicyTest.java b/library/core/src/test/java/com/google/android/exoplayer2/upstream/DefaultLoadErrorHandlingPolicyTest.java
index cf30fce3a6..8840abfcdc 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/upstream/DefaultLoadErrorHandlingPolicyTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/upstream/DefaultLoadErrorHandlingPolicyTest.java
@@ -18,6 +18,7 @@ package com.google.android.exoplayer2.upstream;
import static com.google.common.truth.Truth.assertThat;
import android.net.Uri;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ParserException;
import com.google.android.exoplayer2.upstream.HttpDataSource.InvalidResponseCodeException;
@@ -25,10 +26,9 @@ import java.io.IOException;
import java.util.Collections;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** Unit tests for {@link DefaultLoadErrorHandlingPolicy}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class DefaultLoadErrorHandlingPolicyTest {
@Test
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/CacheDataSourceTest.java b/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/CacheDataSourceTest.java
index 4aa16c6454..4005edc3a6 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/CacheDataSourceTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/CacheDataSourceTest.java
@@ -21,6 +21,8 @@ import static org.junit.Assert.fail;
import android.net.Uri;
import androidx.annotation.Nullable;
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.testutil.CacheAsserts;
import com.google.android.exoplayer2.testutil.FakeDataSet.FakeData;
@@ -37,13 +39,9 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
-/**
- * Unit tests for {@link CacheDataSource}.
- */
-@RunWith(RobolectricTestRunner.class)
+/** Unit tests for {@link CacheDataSource}. */
+@RunWith(AndroidJUnit4.class)
public final class CacheDataSourceTest {
private static final byte[] TEST_DATA = new byte[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
@@ -71,7 +69,8 @@ public final class CacheDataSourceTest {
defaultCacheKey = CacheUtil.DEFAULT_CACHE_KEY_FACTORY.buildCacheKey(unboundedDataSpec);
customCacheKey = "customKey." + defaultCacheKey;
cacheKeyFactory = dataSpec -> customCacheKey;
- tempFolder = Util.createTempDirectory(RuntimeEnvironment.application, "ExoPlayerTest");
+ tempFolder =
+ Util.createTempDirectory(ApplicationProvider.getApplicationContext(), "ExoPlayerTest");
cache = new SimpleCache(tempFolder, new NoOpCacheEvictor());
}
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/CacheDataSourceTest2.java b/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/CacheDataSourceTest2.java
index 1e6febd8a9..bb32f47ba8 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/CacheDataSourceTest2.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/CacheDataSourceTest2.java
@@ -21,6 +21,8 @@ import static java.util.Arrays.copyOfRange;
import android.content.Context;
import android.net.Uri;
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.testutil.FakeDataSource;
import com.google.android.exoplayer2.testutil.TestUtil;
@@ -37,13 +39,9 @@ import java.io.IOException;
import java.util.Random;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
-/**
- * Additional tests for {@link CacheDataSource}.
- */
-@RunWith(RobolectricTestRunner.class)
+/** Additional tests for {@link CacheDataSource}. */
+@RunWith(AndroidJUnit4.class)
public final class CacheDataSourceTest2 {
private static final String EXO_CACHE_DIR = "exo";
@@ -83,7 +81,8 @@ public final class CacheDataSourceTest2 {
private void testReads(boolean useEncryption) throws IOException {
FakeDataSource upstreamSource = buildFakeUpstreamSource();
CacheDataSource source =
- buildCacheDataSource(RuntimeEnvironment.application, upstreamSource, useEncryption);
+ buildCacheDataSource(
+ ApplicationProvider.getApplicationContext(), upstreamSource, useEncryption);
// First read, should arrive from upstream.
testRead(END_ON_BOUNDARY, source);
assertSingleOpen(upstreamSource, 0, OFFSET_ON_BOUNDARY);
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/CacheUtilTest.java b/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/CacheUtilTest.java
index 228567a4bc..6b58e25444 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/CacheUtilTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/CacheUtilTest.java
@@ -22,6 +22,8 @@ import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.fail;
import android.net.Uri;
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.testutil.FakeDataSet;
import com.google.android.exoplayer2.testutil.FakeDataSource;
@@ -39,13 +41,9 @@ import org.junit.runner.RunWith;
import org.mockito.Answers;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
-/**
- * Tests {@link CacheUtil}.
- */
-@RunWith(RobolectricTestRunner.class)
+/** Tests {@link CacheUtil}. */
+@RunWith(AndroidJUnit4.class)
public final class CacheUtilTest {
/**
@@ -96,7 +94,8 @@ public final class CacheUtilTest {
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
mockCache.init();
- tempFolder = Util.createTempDirectory(RuntimeEnvironment.application, "ExoPlayerTest");
+ tempFolder =
+ Util.createTempDirectory(ApplicationProvider.getApplicationContext(), "ExoPlayerTest");
cache = new SimpleCache(tempFolder, new NoOpCacheEvictor());
}
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/CachedContentIndexTest.java b/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/CachedContentIndexTest.java
index fea82fa302..bebcf0ec12 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/CachedContentIndexTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/CachedContentIndexTest.java
@@ -21,6 +21,8 @@ import static com.google.common.truth.Truth.assertWithMessage;
import android.net.Uri;
import androidx.annotation.Nullable;
import android.util.SparseArray;
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.testutil.TestUtil;
import com.google.android.exoplayer2.util.Util;
import java.io.File;
@@ -33,11 +35,9 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
/** Tests {@link CachedContentIndex}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public class CachedContentIndexTest {
private final byte[] testIndexV1File = {
@@ -79,7 +79,7 @@ public class CachedContentIndexTest {
@Before
public void setUp() throws Exception {
cacheDir =
- Util.createTempDirectory(RuntimeEnvironment.application, "ExoPlayerTest");
+ Util.createTempDirectory(ApplicationProvider.getApplicationContext(), "ExoPlayerTest");
}
@After
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/CachedRegionTrackerTest.java b/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/CachedRegionTrackerTest.java
index 231ab3fb2b..5efdf36191 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/CachedRegionTrackerTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/CachedRegionTrackerTest.java
@@ -20,6 +20,8 @@ import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anyString;
import static org.mockito.Mockito.when;
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.extractor.ChunkIndex;
import com.google.android.exoplayer2.testutil.TestUtil;
import com.google.android.exoplayer2.util.Util;
@@ -33,11 +35,9 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
/** Tests for {@link CachedRegionTracker}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class CachedRegionTrackerTest {
private static final String CACHE_KEY = "abc";
@@ -64,7 +64,8 @@ public final class CachedRegionTrackerTest {
MockitoAnnotations.initMocks(this);
when(cache.addListener(anyString(), any(Cache.Listener.class))).thenReturn(new TreeSet<>());
tracker = new CachedRegionTracker(cache, CACHE_KEY, CHUNK_INDEX);
- cacheDir = Util.createTempDirectory(RuntimeEnvironment.application, "ExoPlayerTest");
+ cacheDir =
+ Util.createTempDirectory(ApplicationProvider.getApplicationContext(), "ExoPlayerTest");
index = new CachedContentIndex(TestUtil.getTestDatabaseProvider());
}
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/DefaultContentMetadataTest.java b/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/DefaultContentMetadataTest.java
index e4ec278c22..9c9b7073eb 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/DefaultContentMetadataTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/DefaultContentMetadataTest.java
@@ -17,13 +17,13 @@ package com.google.android.exoplayer2.upstream.cache;
import static com.google.common.truth.Truth.assertThat;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** Tests {@link DefaultContentMetadata}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public class DefaultContentMetadataTest {
private DefaultContentMetadata contentMetadata;
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/LeastRecentlyUsedCacheEvictorTest.java b/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/LeastRecentlyUsedCacheEvictorTest.java
index 84327e1091..482174e3da 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/LeastRecentlyUsedCacheEvictorTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/LeastRecentlyUsedCacheEvictorTest.java
@@ -15,17 +15,15 @@
*/
package com.google.android.exoplayer2.upstream.cache;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
-import org.robolectric.RobolectricTestRunner;
-/**
- * Unit tests for {@link LeastRecentlyUsedCacheEvictor}.
- */
-@RunWith(RobolectricTestRunner.class)
+/** Unit tests for {@link LeastRecentlyUsedCacheEvictor}. */
+@RunWith(AndroidJUnit4.class)
public class LeastRecentlyUsedCacheEvictorTest {
@Before
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/SimpleCacheSpanTest.java b/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/SimpleCacheSpanTest.java
index 475a4ec3d0..028937dc5a 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/SimpleCacheSpanTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/SimpleCacheSpanTest.java
@@ -19,6 +19,8 @@ import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import android.util.LongSparseArray;
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.testutil.TestUtil;
import com.google.android.exoplayer2.util.Util;
import java.io.File;
@@ -30,11 +32,9 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
/** Unit tests for {@link SimpleCacheSpan}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public class SimpleCacheSpanTest {
public static File createCacheSpanFile(
@@ -51,7 +51,7 @@ public class SimpleCacheSpanTest {
@Before
public void setUp() throws Exception {
cacheDir =
- Util.createTempDirectory(RuntimeEnvironment.application, "ExoPlayerTest");
+ Util.createTempDirectory(ApplicationProvider.getApplicationContext(), "ExoPlayerTest");
index = new CachedContentIndex(TestUtil.getTestDatabaseProvider());
}
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/SimpleCacheTest.java b/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/SimpleCacheTest.java
index 9ac126b7c6..da2815f09f 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/SimpleCacheTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/SimpleCacheTest.java
@@ -21,6 +21,8 @@ import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static org.mockito.Mockito.doAnswer;
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.testutil.TestUtil;
import com.google.android.exoplayer2.upstream.cache.Cache.CacheException;
import com.google.android.exoplayer2.util.Util;
@@ -37,13 +39,9 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
-/**
- * Unit tests for {@link SimpleCache}.
- */
-@RunWith(RobolectricTestRunner.class)
+/** Unit tests for {@link SimpleCache}. */
+@RunWith(AndroidJUnit4.class)
public class SimpleCacheTest {
private static final String KEY_1 = "key1";
@@ -54,7 +52,7 @@ public class SimpleCacheTest {
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
- cacheDir = Util.createTempFile(RuntimeEnvironment.application, "ExoPlayerTest");
+ cacheDir = Util.createTempFile(ApplicationProvider.getApplicationContext(), "ExoPlayerTest");
// Delete the file. SimpleCache initialization should create a directory with the same name.
assertThat(cacheDir.delete()).isTrue();
}
@@ -209,7 +207,8 @@ public class SimpleCacheTest {
// Don't release the cache. This means the index file wont have been written to disk after the
// data for KEY_2 was removed. Move the cache instead, so we can reload it without failing the
// folder locking check.
- File cacheDir2 = Util.createTempFile(RuntimeEnvironment.application, "ExoPlayerTest");
+ File cacheDir2 =
+ Util.createTempFile(ApplicationProvider.getApplicationContext(), "ExoPlayerTest");
cacheDir2.delete();
cacheDir.renameTo(cacheDir2);
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/upstream/crypto/AesFlushingCipherTest.java b/library/core/src/test/java/com/google/android/exoplayer2/upstream/crypto/AesFlushingCipherTest.java
index 40b626a7db..fde2bf5a30 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/upstream/crypto/AesFlushingCipherTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/upstream/crypto/AesFlushingCipherTest.java
@@ -17,6 +17,7 @@ package com.google.android.exoplayer2.upstream.crypto;
import static com.google.common.truth.Truth.assertThat;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.testutil.TestUtil;
import com.google.android.exoplayer2.util.Util;
import java.util.Random;
@@ -25,12 +26,9 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-/**
- * Unit tests for {@link AesFlushingCipher}.
- */
-@RunWith(RobolectricTestRunner.class)
+/** Unit tests for {@link AesFlushingCipher}. */
+@RunWith(AndroidJUnit4.class)
public class AesFlushingCipherTest {
private static final int DATA_LENGTH = 65536;
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/util/AtomicFileTest.java b/library/core/src/test/java/com/google/android/exoplayer2/util/AtomicFileTest.java
index 4d80a9647e..c0bf459be8 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/util/AtomicFileTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/util/AtomicFileTest.java
@@ -17,6 +17,8 @@ package com.google.android.exoplayer2.util;
import static com.google.common.truth.Truth.assertThat;
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
@@ -25,13 +27,9 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
-/**
- * Tests {@link AtomicFile}.
- */
-@RunWith(RobolectricTestRunner.class)
+/** Tests {@link AtomicFile}. */
+@RunWith(AndroidJUnit4.class)
public final class AtomicFileTest {
private File tempFolder;
@@ -40,7 +38,8 @@ public final class AtomicFileTest {
@Before
public void setUp() throws Exception {
- tempFolder = Util.createTempDirectory(RuntimeEnvironment.application, "ExoPlayerTest");
+ tempFolder =
+ Util.createTempDirectory(ApplicationProvider.getApplicationContext(), "ExoPlayerTest");
file = new File(tempFolder, "atomicFile");
atomicFile = new AtomicFile(file);
}
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/util/ColorParserTest.java b/library/core/src/test/java/com/google/android/exoplayer2/util/ColorParserTest.java
index af596c35f3..0392f8b26d 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/util/ColorParserTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/util/ColorParserTest.java
@@ -24,14 +24,12 @@ import static com.google.android.exoplayer2.util.ColorParser.parseTtmlColor;
import static com.google.common.truth.Truth.assertThat;
import android.graphics.Color;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-/**
- * Unit test for ColorParser
.
- */
-@RunWith(RobolectricTestRunner.class)
+/** Unit test for ColorParser
. */
+@RunWith(AndroidJUnit4.class)
public final class ColorParserTest {
// Negative tests.
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/util/MimeTypesTest.java b/library/core/src/test/java/com/google/android/exoplayer2/util/MimeTypesTest.java
index c607e92055..288ad918b2 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/util/MimeTypesTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/util/MimeTypesTest.java
@@ -17,12 +17,12 @@ package com.google.android.exoplayer2.util;
import static com.google.common.truth.Truth.assertThat;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** Unit test for {@link MimeTypes}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class MimeTypesTest {
@Test
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/util/NalUnitUtilTest.java b/library/core/src/test/java/com/google/android/exoplayer2/util/NalUnitUtilTest.java
index 473e5a8b05..2cc26feda3 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/util/NalUnitUtilTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/util/NalUnitUtilTest.java
@@ -18,16 +18,14 @@ package com.google.android.exoplayer2.util;
import static com.google.android.exoplayer2.testutil.TestUtil.createByteArray;
import static com.google.common.truth.Truth.assertThat;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import java.nio.ByteBuffer;
import java.util.Arrays;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-/**
- * Tests for {@link NalUnitUtil}.
- */
-@RunWith(RobolectricTestRunner.class)
+/** Tests for {@link NalUnitUtil}. */
+@RunWith(AndroidJUnit4.class)
public final class NalUnitUtilTest {
private static final int TEST_PARTIAL_NAL_POSITION = 4;
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/util/ParsableBitArrayTest.java b/library/core/src/test/java/com/google/android/exoplayer2/util/ParsableBitArrayTest.java
index 438643b933..e2552589fa 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/util/ParsableBitArrayTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/util/ParsableBitArrayTest.java
@@ -17,15 +17,13 @@ package com.google.android.exoplayer2.util;
import static com.google.common.truth.Truth.assertThat;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-/**
- * Tests for {@link ParsableBitArray}.
- */
-@RunWith(RobolectricTestRunner.class)
+/** Tests for {@link ParsableBitArray}. */
+@RunWith(AndroidJUnit4.class)
public final class ParsableBitArrayTest {
private static final byte[] TEST_DATA = new byte[] {0x3C, (byte) 0xD2, (byte) 0x5F, (byte) 0x01,
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/util/ParsableByteArrayTest.java b/library/core/src/test/java/com/google/android/exoplayer2/util/ParsableByteArrayTest.java
index 701f532d6a..7b441b83a1 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/util/ParsableByteArrayTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/util/ParsableByteArrayTest.java
@@ -19,16 +19,14 @@ import static com.google.common.truth.Truth.assertThat;
import static java.nio.charset.Charset.forName;
import static org.junit.Assert.fail;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import java.nio.ByteBuffer;
import java.util.Arrays;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-/**
- * Tests for {@link ParsableByteArray}.
- */
-@RunWith(RobolectricTestRunner.class)
+/** Tests for {@link ParsableByteArray}. */
+@RunWith(AndroidJUnit4.class)
public final class ParsableByteArrayTest {
private static final byte[] TEST_DATA =
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/util/ParsableNalUnitBitArrayTest.java b/library/core/src/test/java/com/google/android/exoplayer2/util/ParsableNalUnitBitArrayTest.java
index 210c42cfa5..3940c3d2a1 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/util/ParsableNalUnitBitArrayTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/util/ParsableNalUnitBitArrayTest.java
@@ -19,14 +19,12 @@ import static com.google.android.exoplayer2.testutil.TestUtil.createByteArray;
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.fail;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-/**
- * Tests for {@link ParsableNalUnitBitArray}.
- */
-@RunWith(RobolectricTestRunner.class)
+/** Tests for {@link ParsableNalUnitBitArray}. */
+@RunWith(AndroidJUnit4.class)
public final class ParsableNalUnitBitArrayTest {
private static final byte[] NO_ESCAPING_TEST_DATA = createByteArray(0, 3, 0, 1, 3, 0, 0);
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/util/ReusableBufferedOutputStreamTest.java b/library/core/src/test/java/com/google/android/exoplayer2/util/ReusableBufferedOutputStreamTest.java
index 4daa29afd0..77f59962d0 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/util/ReusableBufferedOutputStreamTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/util/ReusableBufferedOutputStreamTest.java
@@ -17,15 +17,13 @@ package com.google.android.exoplayer2.util;
import static com.google.common.truth.Truth.assertThat;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import java.io.ByteArrayOutputStream;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-/**
- * Tests {@link ReusableBufferedOutputStream}.
- */
-@RunWith(RobolectricTestRunner.class)
+/** Tests {@link ReusableBufferedOutputStream}. */
+@RunWith(AndroidJUnit4.class)
public final class ReusableBufferedOutputStreamTest {
private static final byte[] TEST_DATA_1 = Util.getUtf8Bytes("test data 1");
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/util/TimedValueQueueTest.java b/library/core/src/test/java/com/google/android/exoplayer2/util/TimedValueQueueTest.java
index ca34bc3216..f21e15a0ed 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/util/TimedValueQueueTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/util/TimedValueQueueTest.java
@@ -17,13 +17,13 @@ package com.google.android.exoplayer2.util;
import static com.google.common.truth.Truth.assertThat;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** Unit test for {@link TimedValueQueue}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public class TimedValueQueueTest {
private TimedValueQueue queue;
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/util/UriUtilTest.java b/library/core/src/test/java/com/google/android/exoplayer2/util/UriUtilTest.java
index 82c62ecb3e..95d8a6b9a0 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/util/UriUtilTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/util/UriUtilTest.java
@@ -20,14 +20,12 @@ import static com.google.android.exoplayer2.util.UriUtil.resolve;
import static com.google.common.truth.Truth.assertThat;
import android.net.Uri;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-/**
- * Unit tests for {@link UriUtil}.
- */
-@RunWith(RobolectricTestRunner.class)
+/** Unit tests for {@link UriUtil}. */
+@RunWith(AndroidJUnit4.class)
public final class UriUtilTest {
/**
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/util/UtilTest.java b/library/core/src/test/java/com/google/android/exoplayer2/util/UtilTest.java
index baf8aa7c40..8f4aad42a5 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/util/UtilTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/util/UtilTest.java
@@ -24,6 +24,7 @@ import static com.google.android.exoplayer2.util.Util.parseXsDuration;
import static com.google.android.exoplayer2.util.Util.unescapeFileName;
import static com.google.common.truth.Truth.assertThat;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.testutil.TestUtil;
import java.util.ArrayList;
@@ -33,12 +34,9 @@ import java.util.Random;
import java.util.zip.Deflater;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-/**
- * Unit tests for {@link Util}.
- */
-@RunWith(RobolectricTestRunner.class)
+/** Unit tests for {@link Util}. */
+@RunWith(AndroidJUnit4.class)
public class UtilTest {
@Test
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/video/spherical/FrameRotationQueueTest.java b/library/core/src/test/java/com/google/android/exoplayer2/video/spherical/FrameRotationQueueTest.java
index 071cd582d5..887c8da09f 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/video/spherical/FrameRotationQueueTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/video/spherical/FrameRotationQueueTest.java
@@ -18,13 +18,13 @@ package com.google.android.exoplayer2.video.spherical;
import static com.google.common.truth.Truth.assertThat;
import android.opengl.Matrix;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** Tests {@link FrameRotationQueue}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public class FrameRotationQueueTest {
private FrameRotationQueue frameRotationQueue;
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/video/spherical/ProjectionDecoderTest.java b/library/core/src/test/java/com/google/android/exoplayer2/video/spherical/ProjectionDecoderTest.java
index af1a8421b4..1dadfe9909 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/video/spherical/ProjectionDecoderTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/video/spherical/ProjectionDecoderTest.java
@@ -17,16 +17,16 @@ package com.google.android.exoplayer2.video.spherical;
import static com.google.common.truth.Truth.assertThat;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.util.Util;
import java.util.Arrays;
import junit.framework.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** Tests for {@link ProjectionDecoder}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class ProjectionDecoderTest {
private static final byte[] PROJ_DATA =
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/video/spherical/ProjectionTest.java b/library/core/src/test/java/com/google/android/exoplayer2/video/spherical/ProjectionTest.java
index 0e2d0999fb..8add0eac61 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/video/spherical/ProjectionTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/video/spherical/ProjectionTest.java
@@ -19,13 +19,13 @@ import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** Tests for {@link Projection}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public class ProjectionTest {
private static final float EPSILON = .00001f;
diff --git a/library/dash/src/test/java/com/google/android/exoplayer2/source/dash/DashMediaPeriodTest.java b/library/dash/src/test/java/com/google/android/exoplayer2/source/dash/DashMediaPeriodTest.java
index 04820fd20c..87656422e1 100644
--- a/library/dash/src/test/java/com/google/android/exoplayer2/source/dash/DashMediaPeriodTest.java
+++ b/library/dash/src/test/java/com/google/android/exoplayer2/source/dash/DashMediaPeriodTest.java
@@ -19,6 +19,7 @@ import static org.mockito.Mockito.mock;
import android.net.Uri;
import androidx.annotation.Nullable;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.source.CompositeSequenceableLoaderFactory;
@@ -44,11 +45,10 @@ import java.util.Arrays;
import java.util.Collections;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
/** Unit tests for {@link DashMediaPeriod}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
@Config(shadows = {RobolectricUtil.CustomLooper.class, RobolectricUtil.CustomMessageQueue.class})
public final class DashMediaPeriodTest {
diff --git a/library/dash/src/test/java/com/google/android/exoplayer2/source/dash/DashMediaSourceTest.java b/library/dash/src/test/java/com/google/android/exoplayer2/source/dash/DashMediaSourceTest.java
index 1c440c70be..2aca8c3c05 100644
--- a/library/dash/src/test/java/com/google/android/exoplayer2/source/dash/DashMediaSourceTest.java
+++ b/library/dash/src/test/java/com/google/android/exoplayer2/source/dash/DashMediaSourceTest.java
@@ -18,6 +18,7 @@ package com.google.android.exoplayer2.source.dash;
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.fail;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.ParserException;
import com.google.android.exoplayer2.upstream.ParsingLoadable;
import com.google.android.exoplayer2.util.Util;
@@ -25,10 +26,9 @@ import java.io.ByteArrayInputStream;
import java.io.IOException;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** Unit test for {@link DashMediaSource}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class DashMediaSourceTest {
@Test
diff --git a/library/dash/src/test/java/com/google/android/exoplayer2/source/dash/DashUtilTest.java b/library/dash/src/test/java/com/google/android/exoplayer2/source/dash/DashUtilTest.java
index 3f5d317519..5bef7d1bf2 100644
--- a/library/dash/src/test/java/com/google/android/exoplayer2/source/dash/DashUtilTest.java
+++ b/library/dash/src/test/java/com/google/android/exoplayer2/source/dash/DashUtilTest.java
@@ -17,6 +17,7 @@ package com.google.android.exoplayer2.source.dash;
import static com.google.common.truth.Truth.assertThat;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.drm.DrmInitData;
@@ -30,10 +31,9 @@ import com.google.android.exoplayer2.util.MimeTypes;
import java.util.Arrays;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** Unit tests for {@link DashUtil}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class DashUtilTest {
@Test
diff --git a/library/dash/src/test/java/com/google/android/exoplayer2/source/dash/EventSampleStreamTest.java b/library/dash/src/test/java/com/google/android/exoplayer2/source/dash/EventSampleStreamTest.java
index 9621381eed..b946931f59 100644
--- a/library/dash/src/test/java/com/google/android/exoplayer2/source/dash/EventSampleStreamTest.java
+++ b/library/dash/src/test/java/com/google/android/exoplayer2/source/dash/EventSampleStreamTest.java
@@ -17,6 +17,7 @@ package com.google.android.exoplayer2.source.dash;
import static com.google.common.truth.Truth.assertThat;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.FormatHolder;
@@ -29,12 +30,9 @@ import com.google.android.exoplayer2.util.MimeTypes;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-/**
- * Unit test for {@link EventSampleStream}.
- */
-@RunWith(RobolectricTestRunner.class)
+/** Unit test for {@link EventSampleStream}. */
+@RunWith(AndroidJUnit4.class)
public final class EventSampleStreamTest {
private static final String SCHEME_ID = "urn:test";
diff --git a/library/dash/src/test/java/com/google/android/exoplayer2/source/dash/manifest/DashManifestParserTest.java b/library/dash/src/test/java/com/google/android/exoplayer2/source/dash/manifest/DashManifestParserTest.java
index 67d8dbecac..d1e795e643 100644
--- a/library/dash/src/test/java/com/google/android/exoplayer2/source/dash/manifest/DashManifestParserTest.java
+++ b/library/dash/src/test/java/com/google/android/exoplayer2/source/dash/manifest/DashManifestParserTest.java
@@ -18,6 +18,8 @@ package com.google.android.exoplayer2.source.dash.manifest;
import static com.google.common.truth.Truth.assertThat;
import android.net.Uri;
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.metadata.emsg.EventMessage;
@@ -29,11 +31,9 @@ import java.util.Collections;
import java.util.List;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
/** Unit tests for {@link DashManifestParser}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public class DashManifestParserTest {
private static final String SAMPLE_MPD_1 = "sample_mpd_1";
@@ -47,10 +47,11 @@ public class DashManifestParserTest {
DashManifestParser parser = new DashManifestParser();
parser.parse(
Uri.parse("https://example.com/test.mpd"),
- TestUtil.getInputStream(RuntimeEnvironment.application, SAMPLE_MPD_1));
+ TestUtil.getInputStream(ApplicationProvider.getApplicationContext(), SAMPLE_MPD_1));
parser.parse(
Uri.parse("https://example.com/test.mpd"),
- TestUtil.getInputStream(RuntimeEnvironment.application, SAMPLE_MPD_2_UNKNOWN_MIME_TYPE));
+ TestUtil.getInputStream(
+ ApplicationProvider.getApplicationContext(), SAMPLE_MPD_2_UNKNOWN_MIME_TYPE));
}
@Test
@@ -59,7 +60,8 @@ public class DashManifestParserTest {
DashManifest mpd =
parser.parse(
Uri.parse("https://example.com/test.mpd"),
- TestUtil.getInputStream(RuntimeEnvironment.application, SAMPLE_MPD_3_SEGMENT_TEMPLATE));
+ TestUtil.getInputStream(
+ ApplicationProvider.getApplicationContext(), SAMPLE_MPD_3_SEGMENT_TEMPLATE));
assertThat(mpd.getPeriodCount()).isEqualTo(1);
@@ -90,7 +92,8 @@ public class DashManifestParserTest {
DashManifest mpd =
parser.parse(
Uri.parse("https://example.com/test.mpd"),
- TestUtil.getInputStream(RuntimeEnvironment.application, SAMPLE_MPD_4_EVENT_STREAM));
+ TestUtil.getInputStream(
+ ApplicationProvider.getApplicationContext(), SAMPLE_MPD_4_EVENT_STREAM));
Period period = mpd.getPeriod(0);
assertThat(period.eventStreams).hasSize(3);
@@ -159,7 +162,7 @@ public class DashManifestParserTest {
DashManifest mpd =
parser.parse(
Uri.parse("Https://example.com/test.mpd"),
- TestUtil.getInputStream(RuntimeEnvironment.application, SAMPLE_MPD_1));
+ TestUtil.getInputStream(ApplicationProvider.getApplicationContext(), SAMPLE_MPD_1));
ProgramInformation expectedProgramInformation =
new ProgramInformation(
"MediaTitle", "MediaSource", "MediaCopyright", "www.example.com", "enUs");
diff --git a/library/dash/src/test/java/com/google/android/exoplayer2/source/dash/manifest/DashManifestTest.java b/library/dash/src/test/java/com/google/android/exoplayer2/source/dash/manifest/DashManifestTest.java
index d0820aa9b7..a336602965 100644
--- a/library/dash/src/test/java/com/google/android/exoplayer2/source/dash/manifest/DashManifestTest.java
+++ b/library/dash/src/test/java/com/google/android/exoplayer2/source/dash/manifest/DashManifestTest.java
@@ -18,6 +18,7 @@ package com.google.android.exoplayer2.source.dash.manifest;
import static com.google.common.truth.Truth.assertThat;
import android.net.Uri;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.offline.StreamKey;
import com.google.android.exoplayer2.source.dash.manifest.SegmentBase.SingleSegmentBase;
@@ -27,10 +28,9 @@ import java.util.List;
import java.util.Random;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** Unit tests for {@link DashManifest}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public class DashManifestTest {
private static final UtcTimingElement DUMMY_UTC_TIMING = new UtcTimingElement("", "");
diff --git a/library/dash/src/test/java/com/google/android/exoplayer2/source/dash/manifest/RangedUriTest.java b/library/dash/src/test/java/com/google/android/exoplayer2/source/dash/manifest/RangedUriTest.java
index 16c9a4706e..be1866206d 100644
--- a/library/dash/src/test/java/com/google/android/exoplayer2/source/dash/manifest/RangedUriTest.java
+++ b/library/dash/src/test/java/com/google/android/exoplayer2/source/dash/manifest/RangedUriTest.java
@@ -17,13 +17,13 @@ package com.google.android.exoplayer2.source.dash.manifest;
import static com.google.common.truth.Truth.assertThat;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** Unit test for {@link RangedUri}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public class RangedUriTest {
private static final String BASE_URI = "http://www.test.com/";
diff --git a/library/dash/src/test/java/com/google/android/exoplayer2/source/dash/manifest/UrlTemplateTest.java b/library/dash/src/test/java/com/google/android/exoplayer2/source/dash/manifest/UrlTemplateTest.java
index 4192280c81..c65c2d0b0c 100644
--- a/library/dash/src/test/java/com/google/android/exoplayer2/source/dash/manifest/UrlTemplateTest.java
+++ b/library/dash/src/test/java/com/google/android/exoplayer2/source/dash/manifest/UrlTemplateTest.java
@@ -18,12 +18,12 @@ package com.google.android.exoplayer2.source.dash.manifest;
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.fail;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** Unit test for {@link UrlTemplate}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public class UrlTemplateTest {
@Test
diff --git a/library/dash/src/test/java/com/google/android/exoplayer2/source/dash/offline/DashDownloaderTest.java b/library/dash/src/test/java/com/google/android/exoplayer2/source/dash/offline/DashDownloaderTest.java
index 76699217e3..fb7a19ba34 100644
--- a/library/dash/src/test/java/com/google/android/exoplayer2/source/dash/offline/DashDownloaderTest.java
+++ b/library/dash/src/test/java/com/google/android/exoplayer2/source/dash/offline/DashDownloaderTest.java
@@ -26,6 +26,8 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import android.net.Uri;
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.offline.DefaultDownloaderFactory;
import com.google.android.exoplayer2.offline.DownloadAction;
import com.google.android.exoplayer2.offline.DownloadException;
@@ -53,11 +55,9 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
/** Unit tests for {@link DashDownloader}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public class DashDownloaderTest {
private SimpleCache cache;
@@ -66,7 +66,8 @@ public class DashDownloaderTest {
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
- tempFolder = Util.createTempDirectory(RuntimeEnvironment.application, "ExoPlayerTest");
+ tempFolder =
+ Util.createTempDirectory(ApplicationProvider.getApplicationContext(), "ExoPlayerTest");
cache = new SimpleCache(tempFolder, new NoOpCacheEvictor());
}
diff --git a/library/dash/src/test/java/com/google/android/exoplayer2/source/dash/offline/DownloadHelperTest.java b/library/dash/src/test/java/com/google/android/exoplayer2/source/dash/offline/DownloadHelperTest.java
index eb4af58675..0b7c06f813 100644
--- a/library/dash/src/test/java/com/google/android/exoplayer2/source/dash/offline/DownloadHelperTest.java
+++ b/library/dash/src/test/java/com/google/android/exoplayer2/source/dash/offline/DownloadHelperTest.java
@@ -16,15 +16,15 @@
package com.google.android.exoplayer2.source.dash.offline;
import android.net.Uri;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.Renderer;
import com.google.android.exoplayer2.offline.DownloadHelper;
import com.google.android.exoplayer2.testutil.FakeDataSource;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** Unit test to verify creation of a DASH {@link DownloadHelper}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class DownloadHelperTest {
@Test
diff --git a/library/dash/src/test/java/com/google/android/exoplayer2/source/dash/offline/DownloadManagerDashTest.java b/library/dash/src/test/java/com/google/android/exoplayer2/source/dash/offline/DownloadManagerDashTest.java
index e1aec6d4ed..d1d9c0f488 100644
--- a/library/dash/src/test/java/com/google/android/exoplayer2/source/dash/offline/DownloadManagerDashTest.java
+++ b/library/dash/src/test/java/com/google/android/exoplayer2/source/dash/offline/DownloadManagerDashTest.java
@@ -25,6 +25,8 @@ import android.content.Context;
import android.net.Uri;
import android.os.ConditionVariable;
import androidx.annotation.Nullable;
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.offline.DefaultDownloaderFactory;
import com.google.android.exoplayer2.offline.DownloadAction;
import com.google.android.exoplayer2.offline.DownloadManager;
@@ -50,13 +52,11 @@ import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.MockitoAnnotations;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowLog;
/** Tests {@link DownloadManager}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
@Config(shadows = {RobolectricUtil.CustomLooper.class, RobolectricUtil.CustomMessageQueue.class})
public class DownloadManagerDashTest {
@@ -76,7 +76,7 @@ public class DownloadManagerDashTest {
public void setUp() throws Exception {
ShadowLog.stream = System.out;
dummyMainThread = new DummyMainThread();
- Context context = RuntimeEnvironment.application;
+ Context context = ApplicationProvider.getApplicationContext();
tempFolder = Util.createTempDirectory(context, "ExoPlayerTest");
File cacheFolder = new File(tempFolder, "cache");
cacheFolder.mkdir();
@@ -244,7 +244,7 @@ public class DownloadManagerDashTest {
Factory fakeDataSourceFactory = new FakeDataSource.Factory().setFakeDataSet(fakeDataSet);
downloadManager =
new DownloadManager(
- RuntimeEnvironment.application,
+ ApplicationProvider.getApplicationContext(),
actionFile,
new DefaultDownloaderFactory(
new DownloaderConstructorHelper(cache, fakeDataSourceFactory)),
diff --git a/library/dash/src/test/java/com/google/android/exoplayer2/source/dash/offline/DownloadServiceDashTest.java b/library/dash/src/test/java/com/google/android/exoplayer2/source/dash/offline/DownloadServiceDashTest.java
index 168fd9bf6e..7533f3a8cc 100644
--- a/library/dash/src/test/java/com/google/android/exoplayer2/source/dash/offline/DownloadServiceDashTest.java
+++ b/library/dash/src/test/java/com/google/android/exoplayer2/source/dash/offline/DownloadServiceDashTest.java
@@ -24,6 +24,8 @@ import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import androidx.annotation.Nullable;
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.offline.DefaultDownloaderFactory;
import com.google.android.exoplayer2.offline.DownloadAction;
import com.google.android.exoplayer2.offline.DownloadManager;
@@ -52,12 +54,10 @@ import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
/** Unit tests for {@link DownloadService}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
@Config(shadows = {RobolectricUtil.CustomLooper.class, RobolectricUtil.CustomMessageQueue.class})
public class DownloadServiceDashTest {
@@ -75,7 +75,7 @@ public class DownloadServiceDashTest {
@Before
public void setUp() throws IOException {
dummyMainThread = new DummyMainThread();
- context = RuntimeEnvironment.application;
+ context = ApplicationProvider.getApplicationContext();
tempFolder = Util.createTempDirectory(context, "ExoPlayerTest");
cache = new SimpleCache(tempFolder, new NoOpCacheEvictor());
@@ -118,7 +118,7 @@ public class DownloadServiceDashTest {
actionFile.delete();
final DownloadManager dashDownloadManager =
new DownloadManager(
- RuntimeEnvironment.application,
+ ApplicationProvider.getApplicationContext(),
actionFile,
new DefaultDownloaderFactory(
new DownloaderConstructorHelper(cache, fakeDataSourceFactory)),
diff --git a/library/hls/src/test/java/com/google/android/exoplayer2/source/hls/Aes128DataSourceTest.java b/library/hls/src/test/java/com/google/android/exoplayer2/source/hls/Aes128DataSourceTest.java
index defc838c6a..3eef5c36d2 100644
--- a/library/hls/src/test/java/com/google/android/exoplayer2/source/hls/Aes128DataSourceTest.java
+++ b/library/hls/src/test/java/com/google/android/exoplayer2/source/hls/Aes128DataSourceTest.java
@@ -18,6 +18,7 @@ package com.google.android.exoplayer2.source.hls;
import static com.google.common.truth.Truth.assertThat;
import android.net.Uri;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.DataSpec;
@@ -28,10 +29,9 @@ import javax.crypto.Cipher;
import javax.crypto.NoSuchPaddingException;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** Test for {@link Aes128DataSource}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public class Aes128DataSourceTest {
@Test
diff --git a/library/hls/src/test/java/com/google/android/exoplayer2/source/hls/HlsMediaPeriodTest.java b/library/hls/src/test/java/com/google/android/exoplayer2/source/hls/HlsMediaPeriodTest.java
index 2793f31af4..41d78ae099 100644
--- a/library/hls/src/test/java/com/google/android/exoplayer2/source/hls/HlsMediaPeriodTest.java
+++ b/library/hls/src/test/java/com/google/android/exoplayer2/source/hls/HlsMediaPeriodTest.java
@@ -19,6 +19,7 @@ import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.source.CompositeSequenceableLoaderFactory;
import com.google.android.exoplayer2.source.MediaSource.MediaPeriodId;
@@ -40,11 +41,10 @@ import java.util.Collections;
import java.util.List;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
/** Unit test for {@link HlsMediaPeriod}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
@Config(shadows = {RobolectricUtil.CustomLooper.class, RobolectricUtil.CustomMessageQueue.class})
public final class HlsMediaPeriodTest {
diff --git a/library/hls/src/test/java/com/google/android/exoplayer2/source/hls/WebvttExtractorTest.java b/library/hls/src/test/java/com/google/android/exoplayer2/source/hls/WebvttExtractorTest.java
index e3e2feed8b..4f7e26fce0 100644
--- a/library/hls/src/test/java/com/google/android/exoplayer2/source/hls/WebvttExtractorTest.java
+++ b/library/hls/src/test/java/com/google/android/exoplayer2/source/hls/WebvttExtractorTest.java
@@ -17,6 +17,7 @@ package com.google.android.exoplayer2.source.hls;
import static com.google.common.truth.Truth.assertThat;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.extractor.ExtractorInput;
import com.google.android.exoplayer2.testutil.FakeExtractorInput;
import com.google.android.exoplayer2.util.TimestampAdjuster;
@@ -24,10 +25,9 @@ import java.io.EOFException;
import java.io.IOException;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** Tests for {@link WebvttExtractor}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public class WebvttExtractorTest {
@Test
diff --git a/library/hls/src/test/java/com/google/android/exoplayer2/source/hls/offline/DownloadHelperTest.java b/library/hls/src/test/java/com/google/android/exoplayer2/source/hls/offline/DownloadHelperTest.java
index dca8f9c3e8..c7a8034ee7 100644
--- a/library/hls/src/test/java/com/google/android/exoplayer2/source/hls/offline/DownloadHelperTest.java
+++ b/library/hls/src/test/java/com/google/android/exoplayer2/source/hls/offline/DownloadHelperTest.java
@@ -16,15 +16,15 @@
package com.google.android.exoplayer2.source.hls.offline;
import android.net.Uri;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.Renderer;
import com.google.android.exoplayer2.offline.DownloadHelper;
import com.google.android.exoplayer2.testutil.FakeDataSource;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** Unit test to verify creation of a HLS {@link DownloadHelper}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class DownloadHelperTest {
@Test
diff --git a/library/hls/src/test/java/com/google/android/exoplayer2/source/hls/offline/HlsDownloaderTest.java b/library/hls/src/test/java/com/google/android/exoplayer2/source/hls/offline/HlsDownloaderTest.java
index 90ccbba2de..728f2d1dcd 100644
--- a/library/hls/src/test/java/com/google/android/exoplayer2/source/hls/offline/HlsDownloaderTest.java
+++ b/library/hls/src/test/java/com/google/android/exoplayer2/source/hls/offline/HlsDownloaderTest.java
@@ -35,6 +35,8 @@ import static com.google.android.exoplayer2.testutil.CacheAsserts.assertCachedDa
import static com.google.common.truth.Truth.assertThat;
import android.net.Uri;
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.offline.DefaultDownloaderFactory;
import com.google.android.exoplayer2.offline.DownloadAction;
import com.google.android.exoplayer2.offline.Downloader;
@@ -58,11 +60,9 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
/** Unit tests for {@link HlsDownloader}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public class HlsDownloaderTest {
private SimpleCache cache;
@@ -71,7 +71,8 @@ public class HlsDownloaderTest {
@Before
public void setUp() throws Exception {
- tempFolder = Util.createTempDirectory(RuntimeEnvironment.application, "ExoPlayerTest");
+ tempFolder =
+ Util.createTempDirectory(ApplicationProvider.getApplicationContext(), "ExoPlayerTest");
cache = new SimpleCache(tempFolder, new NoOpCacheEvictor());
fakeDataSet =
diff --git a/library/hls/src/test/java/com/google/android/exoplayer2/source/hls/playlist/HlsMasterPlaylistParserTest.java b/library/hls/src/test/java/com/google/android/exoplayer2/source/hls/playlist/HlsMasterPlaylistParserTest.java
index 80a9bd3eab..59924bf1a5 100644
--- a/library/hls/src/test/java/com/google/android/exoplayer2/source/hls/playlist/HlsMasterPlaylistParserTest.java
+++ b/library/hls/src/test/java/com/google/android/exoplayer2/source/hls/playlist/HlsMasterPlaylistParserTest.java
@@ -19,6 +19,7 @@ import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.fail;
import android.net.Uri;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.ParserException;
@@ -29,10 +30,9 @@ import java.nio.charset.Charset;
import java.util.List;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** Test for {@link HlsMasterPlaylistParserTest}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public class HlsMasterPlaylistParserTest {
private static final String PLAYLIST_URI = "https://example.com/test.m3u8";
diff --git a/library/hls/src/test/java/com/google/android/exoplayer2/source/hls/playlist/HlsMediaPlaylistParserTest.java b/library/hls/src/test/java/com/google/android/exoplayer2/source/hls/playlist/HlsMediaPlaylistParserTest.java
index 9fc761badb..83d9731dca 100644
--- a/library/hls/src/test/java/com/google/android/exoplayer2/source/hls/playlist/HlsMediaPlaylistParserTest.java
+++ b/library/hls/src/test/java/com/google/android/exoplayer2/source/hls/playlist/HlsMediaPlaylistParserTest.java
@@ -19,6 +19,7 @@ import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.fail;
import android.net.Uri;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ParserException;
import com.google.android.exoplayer2.source.hls.playlist.HlsMediaPlaylist.Segment;
@@ -31,10 +32,9 @@ import java.util.HashMap;
import java.util.List;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** Test for {@link HlsMediaPlaylistParserTest}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public class HlsMediaPlaylistParserTest {
@Test
diff --git a/library/smoothstreaming/src/test/java/com/google/android/exoplayer2/source/smoothstreaming/SsMediaPeriodTest.java b/library/smoothstreaming/src/test/java/com/google/android/exoplayer2/source/smoothstreaming/SsMediaPeriodTest.java
index bceaf8cdf2..948be70712 100644
--- a/library/smoothstreaming/src/test/java/com/google/android/exoplayer2/source/smoothstreaming/SsMediaPeriodTest.java
+++ b/library/smoothstreaming/src/test/java/com/google/android/exoplayer2/source/smoothstreaming/SsMediaPeriodTest.java
@@ -19,6 +19,7 @@ import static com.google.android.exoplayer2.source.smoothstreaming.SsTestUtils.c
import static com.google.android.exoplayer2.source.smoothstreaming.SsTestUtils.createStreamElement;
import static org.mockito.Mockito.mock;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.source.CompositeSequenceableLoaderFactory;
@@ -35,11 +36,10 @@ import com.google.android.exoplayer2.upstream.TransferListener;
import com.google.android.exoplayer2.util.MimeTypes;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
/** Unit tests for {@link SsMediaPeriod}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
@Config(shadows = {RobolectricUtil.CustomLooper.class, RobolectricUtil.CustomMessageQueue.class})
public class SsMediaPeriodTest {
diff --git a/library/smoothstreaming/src/test/java/com/google/android/exoplayer2/source/smoothstreaming/manifest/SsManifestParserTest.java b/library/smoothstreaming/src/test/java/com/google/android/exoplayer2/source/smoothstreaming/manifest/SsManifestParserTest.java
index 2ce9fec970..94be71e84e 100644
--- a/library/smoothstreaming/src/test/java/com/google/android/exoplayer2/source/smoothstreaming/manifest/SsManifestParserTest.java
+++ b/library/smoothstreaming/src/test/java/com/google/android/exoplayer2/source/smoothstreaming/manifest/SsManifestParserTest.java
@@ -16,15 +16,15 @@
package com.google.android.exoplayer2.source.smoothstreaming.manifest;
import android.net.Uri;
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.testutil.TestUtil;
import java.io.IOException;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
/** Unit tests for {@link SsManifestParser}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class SsManifestParserTest {
private static final String SAMPLE_ISMC_1 = "sample_ismc_1";
@@ -36,9 +36,9 @@ public final class SsManifestParserTest {
SsManifestParser parser = new SsManifestParser();
parser.parse(
Uri.parse("https://example.com/test.ismc"),
- TestUtil.getInputStream(RuntimeEnvironment.application, SAMPLE_ISMC_1));
+ TestUtil.getInputStream(ApplicationProvider.getApplicationContext(), SAMPLE_ISMC_1));
parser.parse(
Uri.parse("https://example.com/test.ismc"),
- TestUtil.getInputStream(RuntimeEnvironment.application, SAMPLE_ISMC_2));
+ TestUtil.getInputStream(ApplicationProvider.getApplicationContext(), SAMPLE_ISMC_2));
}
}
diff --git a/library/smoothstreaming/src/test/java/com/google/android/exoplayer2/source/smoothstreaming/manifest/SsManifestTest.java b/library/smoothstreaming/src/test/java/com/google/android/exoplayer2/source/smoothstreaming/manifest/SsManifestTest.java
index ea32c34348..26afe5d666 100644
--- a/library/smoothstreaming/src/test/java/com/google/android/exoplayer2/source/smoothstreaming/manifest/SsManifestTest.java
+++ b/library/smoothstreaming/src/test/java/com/google/android/exoplayer2/source/smoothstreaming/manifest/SsManifestTest.java
@@ -18,6 +18,7 @@ package com.google.android.exoplayer2.source.smoothstreaming.manifest;
import static com.google.android.exoplayer2.source.smoothstreaming.SsTestUtils.createSsManifest;
import static com.google.common.truth.Truth.assertThat;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.offline.StreamKey;
@@ -30,10 +31,9 @@ import java.util.List;
import java.util.Random;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** Unit tests for {@link SsManifest}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public class SsManifestTest {
@Test
diff --git a/library/smoothstreaming/src/test/java/com/google/android/exoplayer2/source/smoothstreaming/offline/DownloadHelperTest.java b/library/smoothstreaming/src/test/java/com/google/android/exoplayer2/source/smoothstreaming/offline/DownloadHelperTest.java
index 071fc46313..4da08f7631 100644
--- a/library/smoothstreaming/src/test/java/com/google/android/exoplayer2/source/smoothstreaming/offline/DownloadHelperTest.java
+++ b/library/smoothstreaming/src/test/java/com/google/android/exoplayer2/source/smoothstreaming/offline/DownloadHelperTest.java
@@ -16,15 +16,15 @@
package com.google.android.exoplayer2.source.smoothstreaming.offline;
import android.net.Uri;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.Renderer;
import com.google.android.exoplayer2.offline.DownloadHelper;
import com.google.android.exoplayer2.testutil.FakeDataSource;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** Unit test to verify creation of a SmoothStreaming {@link DownloadHelper}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class DownloadHelperTest {
@Test
diff --git a/library/smoothstreaming/src/test/java/com/google/android/exoplayer2/source/smoothstreaming/offline/SsDownloaderTest.java b/library/smoothstreaming/src/test/java/com/google/android/exoplayer2/source/smoothstreaming/offline/SsDownloaderTest.java
index e47ffec64f..e0304c1864 100644
--- a/library/smoothstreaming/src/test/java/com/google/android/exoplayer2/source/smoothstreaming/offline/SsDownloaderTest.java
+++ b/library/smoothstreaming/src/test/java/com/google/android/exoplayer2/source/smoothstreaming/offline/SsDownloaderTest.java
@@ -18,6 +18,7 @@ package com.google.android.exoplayer2.source.smoothstreaming.offline;
import static com.google.common.truth.Truth.assertThat;
import android.net.Uri;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.offline.DefaultDownloaderFactory;
import com.google.android.exoplayer2.offline.DownloadAction;
import com.google.android.exoplayer2.offline.Downloader;
@@ -30,10 +31,9 @@ import java.util.Collections;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
-import org.robolectric.RobolectricTestRunner;
/** Unit tests for {@link SsDownloader}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class SsDownloaderTest {
@Test
diff --git a/library/ui/src/test/java/com/google/android/exoplayer2/ui/spherical/CanvasRendererTest.java b/library/ui/src/test/java/com/google/android/exoplayer2/ui/spherical/CanvasRendererTest.java
index e3ec5e4ece..098f4157ef 100644
--- a/library/ui/src/test/java/com/google/android/exoplayer2/ui/spherical/CanvasRendererTest.java
+++ b/library/ui/src/test/java/com/google/android/exoplayer2/ui/spherical/CanvasRendererTest.java
@@ -19,12 +19,12 @@ import static com.google.common.truth.Truth.assertThat;
import android.graphics.PointF;
import androidx.annotation.Nullable;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** Tests for {@link CanvasRenderer}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public class CanvasRendererTest {
private static final float JUST_BELOW_45_DEGREES = (float) (Math.PI / 4 - 1.0E-08);
diff --git a/library/ui/src/test/java/com/google/android/exoplayer2/ui/spherical/TouchTrackerTest.java b/library/ui/src/test/java/com/google/android/exoplayer2/ui/spherical/TouchTrackerTest.java
index 337fb4c593..6212a74f30 100644
--- a/library/ui/src/test/java/com/google/android/exoplayer2/ui/spherical/TouchTrackerTest.java
+++ b/library/ui/src/test/java/com/google/android/exoplayer2/ui/spherical/TouchTrackerTest.java
@@ -19,14 +19,14 @@ import static com.google.common.truth.Truth.assertThat;
import android.content.Context;
import android.view.MotionEvent;
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
/** Tests for {@link TouchTracker}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public class TouchTrackerTest {
private static final float EPSILON = 0.00001f;
private static final int SWIPE_PX = 100;
@@ -45,7 +45,7 @@ public class TouchTrackerTest {
@Before
public void setUp() {
- Context context = RuntimeEnvironment.application;
+ Context context = ApplicationProvider.getApplicationContext();
tracker =
new TouchTracker(
context,
diff --git a/playbacktests/build.gradle b/playbacktests/build.gradle
index 11b7c00906..0e1c8a1268 100644
--- a/playbacktests/build.gradle
+++ b/playbacktests/build.gradle
@@ -32,8 +32,8 @@ android {
}
dependencies {
- androidTestImplementation 'androidx.test:rules:' + testRunnerVersion
- androidTestImplementation 'androidx.test:runner:' + testRunnerVersion
+ androidTestImplementation 'androidx.test:rules:' + androidXTestVersion
+ androidTestImplementation 'androidx.test:runner:' + androidXTestVersion
androidTestImplementation 'androidx.annotation:annotation:1.0.1'
androidTestImplementation project(modulePrefix + 'library-core')
androidTestImplementation project(modulePrefix + 'library-dash')
diff --git a/playbacktests/src/androidTest/AndroidManifest.xml b/playbacktests/src/androidTest/AndroidManifest.xml
index 4165a42568..be71884846 100644
--- a/playbacktests/src/androidTest/AndroidManifest.xml
+++ b/playbacktests/src/androidTest/AndroidManifest.xml
@@ -21,6 +21,7 @@
+
= 24;
@@ -92,7 +88,6 @@ public final class DashTestRunner {
private final String tag;
private final HostActivity activity;
- private final Instrumentation instrumentation;
private String streamName;
private boolean fullPlaybackNoSeeking;
@@ -125,10 +120,9 @@ public final class DashTestRunner {
return false;
}
- public DashTestRunner(String tag, HostActivity activity, Instrumentation instrumentation) {
+ public DashTestRunner(String tag, HostActivity activity) {
this.tag = tag;
this.activity = activity;
- this.instrumentation = instrumentation;
}
public DashTestRunner setStreamName(String streamName) {
@@ -182,20 +176,18 @@ public final class DashTestRunner {
}
public void run() {
- DashHostedTest test = createDashHostedTest(canIncludeAdditionalVideoFormats, false,
- instrumentation);
+ DashHostedTest test = createDashHostedTest(canIncludeAdditionalVideoFormats, false);
activity.runTest(test, TEST_TIMEOUT_MS);
// Retry test exactly once if adaptive test fails due to excessive dropped buffers when
// playing non-CDD required formats (b/28220076).
if (test.needsCddLimitedRetry) {
- activity.runTest(createDashHostedTest(false, true, instrumentation), TEST_TIMEOUT_MS);
+ activity.runTest(createDashHostedTest(false, true), TEST_TIMEOUT_MS);
}
}
- private DashHostedTest createDashHostedTest(boolean canIncludeAdditionalVideoFormats,
- boolean isCddLimitedRetry, Instrumentation instrumentation) {
- MetricsLogger metricsLogger = MetricsLogger.Factory.createDefault(instrumentation, tag,
- REPORT_NAME, REPORT_OBJECT_NAME);
+ private DashHostedTest createDashHostedTest(
+ boolean canIncludeAdditionalVideoFormats, boolean isCddLimitedRetry) {
+ MetricsLogger metricsLogger = MetricsLogger.Factory.createDefault(tag);
return new DashHostedTest(tag, streamName, manifestUrl, metricsLogger, fullPlaybackNoSeeking,
audioFormat, canIncludeAdditionalVideoFormats, isCddLimitedRetry, actionSchedule,
offlineLicenseKeySetId, widevineLicenseUrl, useL1Widevine, dataSourceFactory,
diff --git a/playbacktests/src/androidTest/java/com/google/android/exoplayer2/playbacktests/gts/DashWidevineOfflineTest.java b/playbacktests/src/androidTest/java/com/google/android/exoplayer2/playbacktests/gts/DashWidevineOfflineTest.java
index 7beaafd143..efc6c011cc 100644
--- a/playbacktests/src/androidTest/java/com/google/android/exoplayer2/playbacktests/gts/DashWidevineOfflineTest.java
+++ b/playbacktests/src/androidTest/java/com/google/android/exoplayer2/playbacktests/gts/DashWidevineOfflineTest.java
@@ -15,7 +15,6 @@
*/
package com.google.android.exoplayer2.playbacktests.gts;
-import static androidx.test.InstrumentationRegistry.getInstrumentation;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static org.junit.Assert.fail;
@@ -23,8 +22,8 @@ import static org.junit.Assert.fail;
import android.media.MediaDrm.MediaDrmStateException;
import android.net.Uri;
import android.util.Pair;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
-import androidx.test.runner.AndroidJUnit4;
import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.drm.DrmInitData;
import com.google.android.exoplayer2.drm.DrmSession.DrmSessionException;
@@ -62,7 +61,7 @@ public final class DashWidevineOfflineTest {
@Before
public void setUp() throws Exception {
testRunner =
- new DashTestRunner(TAG, testRule.getActivity(), getInstrumentation())
+ new DashTestRunner(TAG, testRule.getActivity())
.setStreamName("test_widevine_h264_fixed_offline")
.setManifestUrl(DashTestData.WIDEVINE_H264_MANIFEST)
.setWidevineInfo(MimeTypes.VIDEO_H264, true)
diff --git a/playbacktests/src/androidTest/java/com/google/android/exoplayer2/playbacktests/gts/EnumerateDecodersTest.java b/playbacktests/src/androidTest/java/com/google/android/exoplayer2/playbacktests/gts/EnumerateDecodersTest.java
index b9c513fe72..d40a705414 100644
--- a/playbacktests/src/androidTest/java/com/google/android/exoplayer2/playbacktests/gts/EnumerateDecodersTest.java
+++ b/playbacktests/src/androidTest/java/com/google/android/exoplayer2/playbacktests/gts/EnumerateDecodersTest.java
@@ -15,13 +15,12 @@
*/
package com.google.android.exoplayer2.playbacktests.gts;
-import static androidx.test.InstrumentationRegistry.getInstrumentation;
import android.media.MediaCodecInfo.AudioCapabilities;
import android.media.MediaCodecInfo.CodecCapabilities;
import android.media.MediaCodecInfo.CodecProfileLevel;
import android.media.MediaCodecInfo.VideoCapabilities;
-import androidx.test.runner.AndroidJUnit4;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.mediacodec.MediaCodecInfo;
import com.google.android.exoplayer2.mediacodec.MediaCodecUtil;
import com.google.android.exoplayer2.mediacodec.MediaCodecUtil.DecoderQueryException;
@@ -41,16 +40,11 @@ public class EnumerateDecodersTest {
private static final String TAG = "EnumerateDecodersTest";
- private static final String REPORT_NAME = "GtsExoPlayerTestCases";
- private static final String REPORT_OBJECT_NAME = "enumeratedecoderstest";
-
private MetricsLogger metricsLogger;
@Before
public void setUp() {
- metricsLogger =
- MetricsLogger.Factory.createDefault(
- getInstrumentation(), TAG, REPORT_NAME, REPORT_OBJECT_NAME);
+ metricsLogger = MetricsLogger.Factory.createDefault(TAG);
}
@Test
diff --git a/testutils/build.gradle b/testutils/build.gradle
index 322d7f75b8..ab78e6673f 100644
--- a/testutils/build.gradle
+++ b/testutils/build.gradle
@@ -39,7 +39,8 @@ android {
dependencies {
api 'org.mockito:mockito-core:' + mockitoVersion
- api 'com.google.truth:truth:' + truthVersion
+ api 'androidx.test.ext:junit:' + androidXTestVersion
+ api 'androidx.test.ext:truth:' + androidXTestVersion
implementation 'androidx.annotation:annotation:1.0.1'
implementation project(modulePrefix + 'library-core')
implementation 'com.google.auto.value:auto-value-annotations:' + autoValueVersion
diff --git a/testutils/src/main/java/com/google/android/exoplayer2/testutil/ExtractorAsserts.java b/testutils/src/main/java/com/google/android/exoplayer2/testutil/ExtractorAsserts.java
index 1e4811aadf..3937dabcaf 100644
--- a/testutils/src/main/java/com/google/android/exoplayer2/testutil/ExtractorAsserts.java
+++ b/testutils/src/main/java/com/google/android/exoplayer2/testutil/ExtractorAsserts.java
@@ -18,6 +18,7 @@ package com.google.android.exoplayer2.testutil;
import static com.google.common.truth.Truth.assertThat;
import android.content.Context;
+import androidx.test.core.app.ApplicationProvider;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.extractor.Extractor;
import com.google.android.exoplayer2.extractor.ExtractorInput;
@@ -27,7 +28,6 @@ import com.google.android.exoplayer2.extractor.SeekMap;
import com.google.android.exoplayer2.testutil.FakeExtractorInput.SimulatedIOException;
import com.google.android.exoplayer2.util.Assertions;
import java.io.IOException;
-import java.lang.reflect.Field;
import java.util.Arrays;
/**
@@ -35,22 +35,6 @@ import java.util.Arrays;
*/
public final class ExtractorAsserts {
- private static Context robolectricContext;
-
- static {
- try {
- Class> runtimeEnvironmentClass = Class.forName("org.robolectric.RuntimeEnvironment");
- Field applicationField = runtimeEnvironmentClass.getDeclaredField("application");
- robolectricContext = (Context) applicationField.get(null);
- } catch (ClassNotFoundException e) {
- // Keep Robolectric context at null if not found.
- } catch (NoSuchFieldException e) {
- // Keep Robolectric context at null if not found.
- } catch (IllegalAccessException e) {
- // Keep Robolectric context at null if not found.
- }
- }
-
/**
* A factory for {@link Extractor} instances.
*/
@@ -85,8 +69,8 @@ public final class ExtractorAsserts {
extractor.seek(0, 0);
extractor.release();
// Assert output.
- byte[] fileData = TestUtil.getByteArray(robolectricContext, file);
- assertOutput(factory, file, fileData, robolectricContext);
+ byte[] fileData = TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), file);
+ assertOutput(factory, file, fileData, ApplicationProvider.getApplicationContext());
}
/**
diff --git a/testutils/src/main/java/com/google/android/exoplayer2/testutil/MetricsLogger.java b/testutils/src/main/java/com/google/android/exoplayer2/testutil/MetricsLogger.java
index 64d1944927..9edccadcab 100644
--- a/testutils/src/main/java/com/google/android/exoplayer2/testutil/MetricsLogger.java
+++ b/testutils/src/main/java/com/google/android/exoplayer2/testutil/MetricsLogger.java
@@ -15,8 +15,6 @@
*/
package com.google.android.exoplayer2.testutil;
-import android.app.Instrumentation;
-
/**
* Metric Logging interface for ExoPlayer playback tests.
*/
@@ -76,13 +74,9 @@ public interface MetricsLogger {
/**
* Obtains a new instance of {@link MetricsLogger}.
*
- * @param instrumentation The test instrumentation.
* @param tag The tag to be used for logcat logs.
- * @param reportName The name of the report log.
- * @param streamName The name of the stream of metrics.
*/
- public static MetricsLogger createDefault(Instrumentation instrumentation, String tag,
- String reportName, String streamName) {
+ public static MetricsLogger createDefault(String tag) {
return new LogcatMetricsLogger(tag);
}
}
diff --git a/testutils/src/test/java/com/google/android/exoplayer2/testutil/FakeAdaptiveDataSetTest.java b/testutils/src/test/java/com/google/android/exoplayer2/testutil/FakeAdaptiveDataSetTest.java
index 7fd84f6287..714c77f8d3 100644
--- a/testutils/src/test/java/com/google/android/exoplayer2/testutil/FakeAdaptiveDataSetTest.java
+++ b/testutils/src/test/java/com/google/android/exoplayer2/testutil/FakeAdaptiveDataSetTest.java
@@ -17,6 +17,7 @@ package com.google.android.exoplayer2.testutil;
import static com.google.common.truth.Truth.assertThat;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.source.TrackGroup;
@@ -27,10 +28,9 @@ import java.util.List;
import java.util.Random;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** Unit test for {@link FakeAdaptiveDataSet}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class FakeAdaptiveDataSetTest {
private static final Format[] TEST_FORMATS = {
diff --git a/testutils/src/test/java/com/google/android/exoplayer2/testutil/FakeClockTest.java b/testutils/src/test/java/com/google/android/exoplayer2/testutil/FakeClockTest.java
index 90e70e4538..65b0efa72a 100644
--- a/testutils/src/test/java/com/google/android/exoplayer2/testutil/FakeClockTest.java
+++ b/testutils/src/test/java/com/google/android/exoplayer2/testutil/FakeClockTest.java
@@ -19,17 +19,17 @@ import static com.google.common.truth.Truth.assertThat;
import android.os.ConditionVariable;
import android.os.HandlerThread;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.util.Clock;
import com.google.android.exoplayer2.util.HandlerWrapper;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
/** Unit test for {@link FakeClock}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
@Config(shadows = {RobolectricUtil.CustomLooper.class, RobolectricUtil.CustomMessageQueue.class})
public final class FakeClockTest {
diff --git a/testutils/src/test/java/com/google/android/exoplayer2/testutil/FakeDataSetTest.java b/testutils/src/test/java/com/google/android/exoplayer2/testutil/FakeDataSetTest.java
index 99469295bb..0f7aabffc1 100644
--- a/testutils/src/test/java/com/google/android/exoplayer2/testutil/FakeDataSetTest.java
+++ b/testutils/src/test/java/com/google/android/exoplayer2/testutil/FakeDataSetTest.java
@@ -18,15 +18,15 @@ package com.google.android.exoplayer2.testutil;
import static com.google.common.truth.Truth.assertThat;
import android.net.Uri;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.testutil.FakeDataSet.FakeData.Segment;
import java.io.IOException;
import java.util.List;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** Unit test for {@link FakeDataSet} */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class FakeDataSetTest {
@Test
diff --git a/testutils/src/test/java/com/google/android/exoplayer2/testutil/FakeDataSourceTest.java b/testutils/src/test/java/com/google/android/exoplayer2/testutil/FakeDataSourceTest.java
index c88aba4e08..9af0c6e1ca 100644
--- a/testutils/src/test/java/com/google/android/exoplayer2/testutil/FakeDataSourceTest.java
+++ b/testutils/src/test/java/com/google/android/exoplayer2/testutil/FakeDataSourceTest.java
@@ -19,6 +19,7 @@ import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.fail;
import android.net.Uri;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.upstream.DataSpec;
import java.io.IOException;
@@ -26,10 +27,9 @@ import java.util.Arrays;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
/** Unit test for {@link FakeDataSource}. */
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
public final class FakeDataSourceTest {
private static final String URI_STRING = "test://test.test";
diff --git a/testutils_robolectric/build.gradle b/testutils_robolectric/build.gradle
index 61c81bc326..44459ea272 100644
--- a/testutils_robolectric/build.gradle
+++ b/testutils_robolectric/build.gradle
@@ -37,6 +37,7 @@ android {
}
dependencies {
+ api 'androidx.test:core:' + androidXTestVersion
api 'org.robolectric:robolectric:' + robolectricVersion
api project(modulePrefix + 'testutils')
implementation project(modulePrefix + 'library-core')
diff --git a/testutils_robolectric/src/main/java/com/google/android/exoplayer2/testutil/DefaultRenderersFactoryAsserts.java b/testutils_robolectric/src/main/java/com/google/android/exoplayer2/testutil/DefaultRenderersFactoryAsserts.java
index ea6633c695..3720b8a0b3 100644
--- a/testutils_robolectric/src/main/java/com/google/android/exoplayer2/testutil/DefaultRenderersFactoryAsserts.java
+++ b/testutils_robolectric/src/main/java/com/google/android/exoplayer2/testutil/DefaultRenderersFactoryAsserts.java
@@ -22,6 +22,7 @@ import static com.google.common.truth.Truth.assertThat;
import android.os.Handler;
import android.os.Looper;
+import androidx.test.core.app.ApplicationProvider;
import com.google.android.exoplayer2.DefaultRenderersFactory;
import com.google.android.exoplayer2.Renderer;
import com.google.android.exoplayer2.audio.AudioRendererEventListener;
@@ -29,7 +30,6 @@ import com.google.android.exoplayer2.metadata.Metadata;
import com.google.android.exoplayer2.text.Cue;
import com.google.android.exoplayer2.video.VideoRendererEventListener;
import java.util.List;
-import org.robolectric.RuntimeEnvironment;
/** Assertions for {@link DefaultRenderersFactory}. */
public final class DefaultRenderersFactoryAsserts {
@@ -86,7 +86,7 @@ public final class DefaultRenderersFactoryAsserts {
private static Renderer[] createRenderers(
@DefaultRenderersFactory.ExtensionRendererMode int extensionRendererMode) {
DefaultRenderersFactory factory =
- new DefaultRenderersFactory(RuntimeEnvironment.application)
+ new DefaultRenderersFactory(ApplicationProvider.getApplicationContext())
.setExtensionRendererMode(extensionRendererMode);
return factory.createRenderers(
new Handler(Looper.getMainLooper()),