Commit 5c2dd9ca by andrewlewis Committed by Oliver Woodman

Move all tests to JUnit 4

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=209412403
parent 05dcf502
...@@ -27,6 +27,7 @@ android { ...@@ -27,6 +27,7 @@ android {
minSdkVersion project.ext.minSdkVersion minSdkVersion project.ext.minSdkVersion
targetSdkVersion project.ext.targetSdkVersion targetSdkVersion project.ext.targetSdkVersion
consumerProguardFiles 'proguard-rules.txt' consumerProguardFiles 'proguard-rules.txt'
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
} }
sourceSets.main { sourceSets.main {
...@@ -38,6 +39,7 @@ android { ...@@ -38,6 +39,7 @@ android {
dependencies { dependencies {
implementation 'com.android.support:support-annotations:' + supportLibraryVersion implementation 'com.android.support:support-annotations:' + supportLibraryVersion
implementation project(modulePrefix + 'library-core') implementation project(modulePrefix + 'library-core')
androidTestImplementation 'androidx.test:runner:' + testRunnerVersion
androidTestImplementation project(modulePrefix + 'testutils') androidTestImplementation project(modulePrefix + 'testutils')
testImplementation project(modulePrefix + 'testutils-robolectric') testImplementation project(modulePrefix + 'testutils-robolectric')
} }
......
...@@ -26,6 +26,6 @@ ...@@ -26,6 +26,6 @@
<instrumentation <instrumentation
android:targetPackage="com.google.android.exoplayer2.ext.flac.test" android:targetPackage="com.google.android.exoplayer2.ext.flac.test"
android:name="android.test.InstrumentationTestRunner"/> android:name="androidx.test.runner.AndroidJUnitRunner"/>
</manifest> </manifest>
...@@ -15,10 +15,13 @@ ...@@ -15,10 +15,13 @@
*/ */
package com.google.android.exoplayer2.ext.flac; package com.google.android.exoplayer2.ext.flac;
import static androidx.test.InstrumentationRegistry.getContext;
import static org.junit.Assert.fail;
import android.content.Context; import android.content.Context;
import android.net.Uri; import android.net.Uri;
import android.os.Looper; import android.os.Looper;
import android.test.InstrumentationTestCase; import androidx.test.runner.AndroidJUnit4;
import com.google.android.exoplayer2.ExoPlaybackException; import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.ExoPlayer; import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.ExoPlayerFactory; import com.google.android.exoplayer2.ExoPlayerFactory;
...@@ -29,29 +32,31 @@ import com.google.android.exoplayer2.source.ExtractorMediaSource; ...@@ -29,29 +32,31 @@ import com.google.android.exoplayer2.source.ExtractorMediaSource;
import com.google.android.exoplayer2.source.MediaSource; import com.google.android.exoplayer2.source.MediaSource;
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector; import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory; import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
/** /** Playback tests using {@link LibflacAudioRenderer}. */
* Playback tests using {@link LibflacAudioRenderer}. @RunWith(AndroidJUnit4.class)
*/ public class FlacPlaybackTest {
public class FlacPlaybackTest extends InstrumentationTestCase {
private static final String BEAR_FLAC_URI = "asset:///bear-flac.mka"; private static final String BEAR_FLAC_URI = "asset:///bear-flac.mka";
@Override @Before
protected void setUp() throws Exception { public void setUp() {
super.setUp();
if (!FlacLibrary.isAvailable()) { if (!FlacLibrary.isAvailable()) {
fail("Flac library not available."); fail("Flac library not available.");
} }
} }
@Test
public void testBasicPlayback() throws ExoPlaybackException { public void testBasicPlayback() throws ExoPlaybackException {
playUri(BEAR_FLAC_URI); playUri(BEAR_FLAC_URI);
} }
private void playUri(String uri) throws ExoPlaybackException { private void playUri(String uri) throws ExoPlaybackException {
TestPlaybackRunnable testPlaybackRunnable = new TestPlaybackRunnable(Uri.parse(uri), TestPlaybackRunnable testPlaybackRunnable =
getInstrumentation().getContext()); new TestPlaybackRunnable(Uri.parse(uri), getContext());
Thread thread = new Thread(testPlaybackRunnable); Thread thread = new Thread(testPlaybackRunnable);
thread.start(); thread.start();
try { try {
......
...@@ -27,6 +27,7 @@ android { ...@@ -27,6 +27,7 @@ android {
minSdkVersion project.ext.minSdkVersion minSdkVersion project.ext.minSdkVersion
targetSdkVersion project.ext.targetSdkVersion targetSdkVersion project.ext.targetSdkVersion
consumerProguardFiles 'proguard-rules.txt' consumerProguardFiles 'proguard-rules.txt'
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
} }
sourceSets.main { sourceSets.main {
...@@ -37,6 +38,7 @@ android { ...@@ -37,6 +38,7 @@ android {
dependencies { dependencies {
implementation project(modulePrefix + 'library-core') implementation project(modulePrefix + 'library-core')
androidTestImplementation 'androidx.test:runner:' + testRunnerVersion
} }
ext { ext {
......
...@@ -26,6 +26,6 @@ ...@@ -26,6 +26,6 @@
<instrumentation <instrumentation
android:targetPackage="com.google.android.exoplayer2.ext.opus.test" android:targetPackage="com.google.android.exoplayer2.ext.opus.test"
android:name="android.test.InstrumentationTestRunner"/> android:name="androidx.test.runner.AndroidJUnitRunner"/>
</manifest> </manifest>
...@@ -15,10 +15,13 @@ ...@@ -15,10 +15,13 @@
*/ */
package com.google.android.exoplayer2.ext.opus; package com.google.android.exoplayer2.ext.opus;
import static androidx.test.InstrumentationRegistry.getContext;
import static org.junit.Assert.fail;
import android.content.Context; import android.content.Context;
import android.net.Uri; import android.net.Uri;
import android.os.Looper; import android.os.Looper;
import android.test.InstrumentationTestCase; import androidx.test.runner.AndroidJUnit4;
import com.google.android.exoplayer2.ExoPlaybackException; import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.ExoPlayer; import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.ExoPlayerFactory; import com.google.android.exoplayer2.ExoPlayerFactory;
...@@ -29,29 +32,31 @@ import com.google.android.exoplayer2.source.ExtractorMediaSource; ...@@ -29,29 +32,31 @@ import com.google.android.exoplayer2.source.ExtractorMediaSource;
import com.google.android.exoplayer2.source.MediaSource; import com.google.android.exoplayer2.source.MediaSource;
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector; import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory; import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
/** /** Playback tests using {@link LibopusAudioRenderer}. */
* Playback tests using {@link LibopusAudioRenderer}. @RunWith(AndroidJUnit4.class)
*/ public class OpusPlaybackTest {
public class OpusPlaybackTest extends InstrumentationTestCase {
private static final String BEAR_OPUS_URI = "asset:///bear-opus.webm"; private static final String BEAR_OPUS_URI = "asset:///bear-opus.webm";
@Override @Before
protected void setUp() throws Exception { public void setUp() {
super.setUp();
if (!OpusLibrary.isAvailable()) { if (!OpusLibrary.isAvailable()) {
fail("Opus library not available."); fail("Opus library not available.");
} }
} }
@Test
public void testBasicPlayback() throws ExoPlaybackException { public void testBasicPlayback() throws ExoPlaybackException {
playUri(BEAR_OPUS_URI); playUri(BEAR_OPUS_URI);
} }
private void playUri(String uri) throws ExoPlaybackException { private void playUri(String uri) throws ExoPlaybackException {
TestPlaybackRunnable testPlaybackRunnable = new TestPlaybackRunnable(Uri.parse(uri), TestPlaybackRunnable testPlaybackRunnable =
getInstrumentation().getContext()); new TestPlaybackRunnable(Uri.parse(uri), getContext());
Thread thread = new Thread(testPlaybackRunnable); Thread thread = new Thread(testPlaybackRunnable);
thread.start(); thread.start();
try { try {
......
...@@ -27,6 +27,7 @@ android { ...@@ -27,6 +27,7 @@ android {
minSdkVersion project.ext.minSdkVersion minSdkVersion project.ext.minSdkVersion
targetSdkVersion project.ext.targetSdkVersion targetSdkVersion project.ext.targetSdkVersion
consumerProguardFiles 'proguard-rules.txt' consumerProguardFiles 'proguard-rules.txt'
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
} }
sourceSets.main { sourceSets.main {
...@@ -38,6 +39,7 @@ android { ...@@ -38,6 +39,7 @@ android {
dependencies { dependencies {
implementation project(modulePrefix + 'library-core') implementation project(modulePrefix + 'library-core')
implementation 'com.android.support:support-annotations:' + supportLibraryVersion implementation 'com.android.support:support-annotations:' + supportLibraryVersion
androidTestImplementation 'androidx.test:runner:' + testRunnerVersion
androidTestImplementation 'com.google.truth:truth:' + truthVersion androidTestImplementation 'com.google.truth:truth:' + truthVersion
} }
......
...@@ -26,6 +26,6 @@ ...@@ -26,6 +26,6 @@
<instrumentation <instrumentation
android:targetPackage="com.google.android.exoplayer2.ext.vp9.test" android:targetPackage="com.google.android.exoplayer2.ext.vp9.test"
android:name="android.test.InstrumentationTestRunner"/> android:name="androidx.test.runner.AndroidJUnitRunner"/>
</manifest> </manifest>
...@@ -15,13 +15,15 @@ ...@@ -15,13 +15,15 @@
*/ */
package com.google.android.exoplayer2.ext.vp9; package com.google.android.exoplayer2.ext.vp9;
import static androidx.test.InstrumentationRegistry.getContext;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.fail;
import android.content.Context; import android.content.Context;
import android.net.Uri; import android.net.Uri;
import android.os.Looper; import android.os.Looper;
import android.test.InstrumentationTestCase;
import android.util.Log; import android.util.Log;
import androidx.test.runner.AndroidJUnit4;
import com.google.android.exoplayer2.ExoPlaybackException; import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.ExoPlayer; import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.ExoPlayerFactory; import com.google.android.exoplayer2.ExoPlayerFactory;
...@@ -32,11 +34,13 @@ import com.google.android.exoplayer2.source.ExtractorMediaSource; ...@@ -32,11 +34,13 @@ import com.google.android.exoplayer2.source.ExtractorMediaSource;
import com.google.android.exoplayer2.source.MediaSource; import com.google.android.exoplayer2.source.MediaSource;
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector; import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory; import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
/** /** Playback tests using {@link LibvpxVideoRenderer}. */
* Playback tests using {@link LibvpxVideoRenderer}. @RunWith(AndroidJUnit4.class)
*/ public class VpxPlaybackTest {
public class VpxPlaybackTest extends InstrumentationTestCase {
private static final String BEAR_URI = "asset:///bear-vp9.webm"; private static final String BEAR_URI = "asset:///bear-vp9.webm";
private static final String BEAR_ODD_DIMENSIONS_URI = "asset:///bear-vp9-odd-dimensions.webm"; private static final String BEAR_ODD_DIMENSIONS_URI = "asset:///bear-vp9-odd-dimensions.webm";
...@@ -45,22 +49,24 @@ public class VpxPlaybackTest extends InstrumentationTestCase { ...@@ -45,22 +49,24 @@ public class VpxPlaybackTest extends InstrumentationTestCase {
private static final String TAG = "VpxPlaybackTest"; private static final String TAG = "VpxPlaybackTest";
@Override @Before
protected void setUp() throws Exception { public void setUp() {
super.setUp();
if (!VpxLibrary.isAvailable()) { if (!VpxLibrary.isAvailable()) {
fail("Vpx library not available."); fail("Vpx library not available.");
} }
} }
@Test
public void testBasicPlayback() throws ExoPlaybackException { public void testBasicPlayback() throws ExoPlaybackException {
playUri(BEAR_URI); playUri(BEAR_URI);
} }
@Test
public void testOddDimensionsPlayback() throws ExoPlaybackException { public void testOddDimensionsPlayback() throws ExoPlaybackException {
playUri(BEAR_ODD_DIMENSIONS_URI); playUri(BEAR_ODD_DIMENSIONS_URI);
} }
@Test
public void test10BitProfile2Playback() throws ExoPlaybackException { public void test10BitProfile2Playback() throws ExoPlaybackException {
if (VpxLibrary.isHighBitDepthSupported()) { if (VpxLibrary.isHighBitDepthSupported()) {
Log.d(TAG, "High Bit Depth supported."); Log.d(TAG, "High Bit Depth supported.");
...@@ -70,6 +76,7 @@ public class VpxPlaybackTest extends InstrumentationTestCase { ...@@ -70,6 +76,7 @@ public class VpxPlaybackTest extends InstrumentationTestCase {
Log.d(TAG, "High Bit Depth not supported."); Log.d(TAG, "High Bit Depth not supported.");
} }
@Test
public void testInvalidBitstream() { public void testInvalidBitstream() {
try { try {
playUri(INVALID_BITSTREAM_URI); playUri(INVALID_BITSTREAM_URI);
...@@ -81,8 +88,8 @@ public class VpxPlaybackTest extends InstrumentationTestCase { ...@@ -81,8 +88,8 @@ public class VpxPlaybackTest extends InstrumentationTestCase {
} }
private void playUri(String uri) throws ExoPlaybackException { private void playUri(String uri) throws ExoPlaybackException {
TestPlaybackRunnable testPlaybackRunnable = new TestPlaybackRunnable(Uri.parse(uri), TestPlaybackRunnable testPlaybackRunnable =
getInstrumentation().getContext()); new TestPlaybackRunnable(Uri.parse(uri), getContext());
Thread thread = new Thread(testPlaybackRunnable); Thread thread = new Thread(testPlaybackRunnable);
thread.start(); thread.start();
try { try {
......
...@@ -28,7 +28,7 @@ android { ...@@ -28,7 +28,7 @@ android {
targetSdkVersion project.ext.targetSdkVersion targetSdkVersion project.ext.targetSdkVersion
consumerProguardFiles 'proguard-rules.txt' consumerProguardFiles 'proguard-rules.txt'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
// The following argument makes the Android Test Orchestrator run its // The following argument makes the Android Test Orchestrator run its
// "pm clear" command after each test invocation. This command ensures // "pm clear" command after each test invocation. This command ensures
...@@ -39,11 +39,11 @@ android { ...@@ -39,11 +39,11 @@ android {
// Workaround to prevent circular dependency on project :testutils. // Workaround to prevent circular dependency on project :testutils.
sourceSets { sourceSets {
androidTest { androidTest {
java.srcDirs += "../../testutils/src/main/java/" java.srcDirs += '../../testutils/src/main/java/'
} }
test { test {
java.srcDirs += "../../testutils/src/main/java/" java.srcDirs += '../../testutils/src/main/java/'
java.srcDirs += "../../testutils_robolectric/src/main/java/" java.srcDirs += '../../testutils_robolectric/src/main/java/'
} }
} }
...@@ -60,12 +60,12 @@ dependencies { ...@@ -60,12 +60,12 @@ dependencies {
implementation 'com.android.support:support-annotations:' + supportLibraryVersion implementation 'com.android.support:support-annotations:' + supportLibraryVersion
compileOnly 'org.checkerframework:checker-qual:' + checkerframeworkVersion compileOnly 'org.checkerframework:checker-qual:' + checkerframeworkVersion
compileOnly 'org.checkerframework:checker-compat-qual:' + checkerframeworkVersion compileOnly 'org.checkerframework:checker-compat-qual:' + checkerframeworkVersion
androidTestImplementation 'androidx.test:runner:' + testRunnerVersion
androidTestImplementation 'com.google.auto.value:auto-value-annotations:' + autoValueVersion
androidTestImplementation 'com.google.dexmaker:dexmaker:' + dexmakerVersion androidTestImplementation 'com.google.dexmaker:dexmaker:' + dexmakerVersion
androidTestImplementation 'com.google.dexmaker:dexmaker-mockito:' + dexmakerVersion androidTestImplementation 'com.google.dexmaker:dexmaker-mockito:' + dexmakerVersion
androidTestImplementation 'com.google.truth:truth:' + truthVersion androidTestImplementation 'com.google.truth:truth:' + truthVersion
androidTestImplementation 'org.mockito:mockito-core:' + mockitoVersion androidTestImplementation 'org.mockito:mockito-core:' + mockitoVersion
androidTestImplementation 'androidx.test:runner:' + testRunnerVersion
androidTestImplementation 'com.google.auto.value:auto-value-annotations:' + autoValueVersion
androidTestAnnotationProcessor 'com.google.auto.value:auto-value:' + autoValueVersion androidTestAnnotationProcessor 'com.google.auto.value:auto-value:' + autoValueVersion
testImplementation 'com.google.truth:truth:' + truthVersion testImplementation 'com.google.truth:truth:' + truthVersion
testImplementation 'junit:junit:' + junitVersion testImplementation 'junit:junit:' + junitVersion
......
...@@ -29,6 +29,6 @@ ...@@ -29,6 +29,6 @@
<instrumentation <instrumentation
android:targetPackage="com.google.android.exoplayer2.core.test" android:targetPackage="com.google.android.exoplayer2.core.test"
android:name="android.test.InstrumentationTestRunner"/> android:name="androidx.test.runner.AndroidJUnitRunner"/>
</manifest> </manifest>
...@@ -26,10 +26,13 @@ android { ...@@ -26,10 +26,13 @@ android {
defaultConfig { defaultConfig {
minSdkVersion project.ext.minSdkVersion minSdkVersion project.ext.minSdkVersion
targetSdkVersion project.ext.targetSdkVersion targetSdkVersion project.ext.targetSdkVersion
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
} }
} }
dependencies { dependencies {
androidTestImplementation 'androidx.test:rules:' + testRunnerVersion
androidTestImplementation 'androidx.test:runner:' + testRunnerVersion
androidTestImplementation project(modulePrefix + 'library-core') androidTestImplementation project(modulePrefix + 'library-core')
androidTestImplementation project(modulePrefix + 'library-dash') androidTestImplementation project(modulePrefix + 'library-dash')
androidTestImplementation project(modulePrefix + 'library-hls') androidTestImplementation project(modulePrefix + 'library-hls')
......
...@@ -34,6 +34,6 @@ ...@@ -34,6 +34,6 @@
<instrumentation <instrumentation
android:targetPackage="com.google.android.exoplayer2.playbacktests" android:targetPackage="com.google.android.exoplayer2.playbacktests"
android:name="android.test.InstrumentationTestRunner"/> android:name="androidx.test.runner.AndroidJUnitRunner"/>
</manifest> </manifest>
...@@ -15,17 +15,24 @@ ...@@ -15,17 +15,24 @@
*/ */
package com.google.android.exoplayer2.playbacktests.gts; package com.google.android.exoplayer2.playbacktests.gts;
import android.test.ActivityInstrumentationTestCase2; import static androidx.test.InstrumentationRegistry.getInstrumentation;
import androidx.test.rule.ActivityTestRule;
import androidx.test.runner.AndroidJUnit4;
import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.testutil.ActionSchedule; import com.google.android.exoplayer2.testutil.ActionSchedule;
import com.google.android.exoplayer2.testutil.HostActivity; import com.google.android.exoplayer2.testutil.HostActivity;
import com.google.android.exoplayer2.util.MimeTypes; import com.google.android.exoplayer2.util.MimeTypes;
import com.google.android.exoplayer2.util.Util; import com.google.android.exoplayer2.util.Util;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
/** /** Test playback of encrypted DASH streams using different CENC scheme types. */
* Test playback of encrypted DASH streams using different CENC scheme types. @RunWith(AndroidJUnit4.class)
*/ public final class CommonEncryptionDrmTest {
public final class CommonEncryptionDrmTest extends ActivityInstrumentationTestCase2<HostActivity> {
private static final String TAG = "CencDrmTest"; private static final String TAG = "CencDrmTest";
...@@ -44,29 +51,26 @@ public final class CommonEncryptionDrmTest extends ActivityInstrumentationTestCa ...@@ -44,29 +51,26 @@ public final class CommonEncryptionDrmTest extends ActivityInstrumentationTestCa
.seekAndWait(270000).delay(10000).seekAndWait(200000).delay(10000).seekAndWait(732000) .seekAndWait(270000).delay(10000).seekAndWait(200000).delay(10000).seekAndWait(732000)
.build(); .build();
private DashTestRunner testRunner; @Rule public ActivityTestRule<HostActivity> testRule = new ActivityTestRule<>(HostActivity.class);
public CommonEncryptionDrmTest() { private DashTestRunner testRunner;
super(HostActivity.class);
}
@Override
protected void setUp() throws Exception {
super.setUp();
testRunner = new DashTestRunner(TAG, getActivity(), getInstrumentation()) @Before
public void setUp() {
testRunner =
new DashTestRunner(TAG, testRule.getActivity(), getInstrumentation())
.setWidevineInfo(MimeTypes.VIDEO_H264, false) .setWidevineInfo(MimeTypes.VIDEO_H264, false)
.setActionSchedule(ACTION_SCHEDULE_WITH_SEEKS) .setActionSchedule(ACTION_SCHEDULE_WITH_SEEKS)
.setAudioVideoFormats(ID_AUDIO, IDS_VIDEO) .setAudioVideoFormats(ID_AUDIO, IDS_VIDEO)
.setCanIncludeAdditionalVideoFormats(true); .setCanIncludeAdditionalVideoFormats(true);
} }
@Override @After
protected void tearDown() throws Exception { public void tearDown() {
testRunner = null; testRunner = null;
super.tearDown();
} }
@Test
public void testCencSchemeTypeV18() { public void testCencSchemeTypeV18() {
if (Util.SDK_INT < 18) { if (Util.SDK_INT < 18) {
// Pass. // Pass.
...@@ -75,6 +79,7 @@ public final class CommonEncryptionDrmTest extends ActivityInstrumentationTestCa ...@@ -75,6 +79,7 @@ public final class CommonEncryptionDrmTest extends ActivityInstrumentationTestCa
testRunner.setStreamName("test_widevine_h264_scheme_cenc").setManifestUrl(URL_cenc).run(); testRunner.setStreamName("test_widevine_h264_scheme_cenc").setManifestUrl(URL_cenc).run();
} }
@Test
public void testCbc1SchemeTypeV25() { public void testCbc1SchemeTypeV25() {
if (Util.SDK_INT < 25) { if (Util.SDK_INT < 25) {
// cbc1 support was added in API 24, but it is stable from API 25 onwards. // cbc1 support was added in API 24, but it is stable from API 25 onwards.
...@@ -85,6 +90,7 @@ public final class CommonEncryptionDrmTest extends ActivityInstrumentationTestCa ...@@ -85,6 +90,7 @@ public final class CommonEncryptionDrmTest extends ActivityInstrumentationTestCa
testRunner.setStreamName("test_widevine_h264_scheme_cbc1").setManifestUrl(URL_cbc1).run(); testRunner.setStreamName("test_widevine_h264_scheme_cbc1").setManifestUrl(URL_cbc1).run();
} }
@Test
public void testCbcsSchemeTypeV25() { public void testCbcsSchemeTypeV25() {
if (Util.SDK_INT < 25) { if (Util.SDK_INT < 25) {
// cbcs support was added in API 24, but it is stable from API 25 onwards. // cbcs support was added in API 24, but it is stable from API 25 onwards.
...@@ -95,8 +101,8 @@ public final class CommonEncryptionDrmTest extends ActivityInstrumentationTestCa ...@@ -95,8 +101,8 @@ public final class CommonEncryptionDrmTest extends ActivityInstrumentationTestCa
testRunner.setStreamName("test_widevine_h264_scheme_cbcs").setManifestUrl(URL_cbcs).run(); testRunner.setStreamName("test_widevine_h264_scheme_cbcs").setManifestUrl(URL_cbcs).run();
} }
@Test
public void testCensSchemeTypeV25() { public void testCensSchemeTypeV25() {
// TODO: Implement once content is available. Track [internal: b/31219813]. // TODO: Implement once content is available. Track [internal: b/31219813].
} }
} }
...@@ -15,10 +15,12 @@ ...@@ -15,10 +15,12 @@
*/ */
package com.google.android.exoplayer2.playbacktests.gts; package com.google.android.exoplayer2.playbacktests.gts;
import static androidx.test.InstrumentationRegistry.getInstrumentation;
import static com.google.common.truth.Truth.assertWithMessage; import static com.google.common.truth.Truth.assertWithMessage;
import android.net.Uri; import android.net.Uri;
import android.test.ActivityInstrumentationTestCase2; import androidx.test.rule.ActivityTestRule;
import androidx.test.runner.AndroidJUnit4;
import com.google.android.exoplayer2.offline.DownloaderConstructorHelper; import com.google.android.exoplayer2.offline.DownloaderConstructorHelper;
import com.google.android.exoplayer2.offline.StreamKey; import com.google.android.exoplayer2.offline.StreamKey;
import com.google.android.exoplayer2.source.dash.DashUtil; import com.google.android.exoplayer2.source.dash.DashUtil;
...@@ -37,36 +39,38 @@ import com.google.android.exoplayer2.util.Util; ...@@ -37,36 +39,38 @@ import com.google.android.exoplayer2.util.Util;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
/** /** Tests downloaded DASH playbacks. */
* Tests downloaded DASH playbacks. @RunWith(AndroidJUnit4.class)
*/ public final class DashDownloadTest {
public final class DashDownloadTest extends ActivityInstrumentationTestCase2<HostActivity> {
private static final String TAG = "DashDownloadTest"; private static final String TAG = "DashDownloadTest";
private static final Uri MANIFEST_URI = Uri.parse(DashTestData.H264_MANIFEST); private static final Uri MANIFEST_URI = Uri.parse(DashTestData.H264_MANIFEST);
@Rule public ActivityTestRule<HostActivity> testRule = new ActivityTestRule<>(HostActivity.class);
private DashTestRunner testRunner; private DashTestRunner testRunner;
private File tempFolder; private File tempFolder;
private SimpleCache cache; private SimpleCache cache;
private DefaultHttpDataSourceFactory httpDataSourceFactory; private DefaultHttpDataSourceFactory httpDataSourceFactory;
private CacheDataSourceFactory offlineDataSourceFactory; private CacheDataSourceFactory offlineDataSourceFactory;
public DashDownloadTest() { @Before
super(HostActivity.class); public void setUp() throws Exception {
} testRunner =
new DashTestRunner(TAG, testRule.getActivity(), getInstrumentation())
@Override
protected void setUp() throws Exception {
super.setUp();
testRunner = new DashTestRunner(TAG, getActivity(), getInstrumentation())
.setManifestUrl(DashTestData.H264_MANIFEST) .setManifestUrl(DashTestData.H264_MANIFEST)
.setFullPlaybackNoSeeking(true) .setFullPlaybackNoSeeking(true)
.setCanIncludeAdditionalVideoFormats(false) .setCanIncludeAdditionalVideoFormats(false)
.setAudioVideoFormats(DashTestData.AAC_AUDIO_REPRESENTATION_ID, .setAudioVideoFormats(
DashTestData.H264_CDD_FIXED); DashTestData.AAC_AUDIO_REPRESENTATION_ID, DashTestData.H264_CDD_FIXED);
tempFolder = Util.createTempDirectory(getActivity(), "ExoPlayerTest"); tempFolder = Util.createTempDirectory(testRule.getActivity(), "ExoPlayerTest");
cache = new SimpleCache(tempFolder, new NoOpCacheEvictor()); cache = new SimpleCache(tempFolder, new NoOpCacheEvictor());
httpDataSourceFactory = new DefaultHttpDataSourceFactory("ExoPlayer", null); httpDataSourceFactory = new DefaultHttpDataSourceFactory("ExoPlayer", null);
offlineDataSourceFactory = offlineDataSourceFactory =
...@@ -74,16 +78,16 @@ public final class DashDownloadTest extends ActivityInstrumentationTestCase2<Hos ...@@ -74,16 +78,16 @@ public final class DashDownloadTest extends ActivityInstrumentationTestCase2<Hos
cache, DummyDataSource.FACTORY, CacheDataSource.FLAG_BLOCK_ON_CACHE); cache, DummyDataSource.FACTORY, CacheDataSource.FLAG_BLOCK_ON_CACHE);
} }
@Override @After
protected void tearDown() throws Exception { public void tearDown() {
testRunner = null; testRunner = null;
Util.recursiveDelete(tempFolder); Util.recursiveDelete(tempFolder);
cache = null; cache = null;
super.tearDown();
} }
// Download tests // Download tests
@Test
public void testDownload() throws Exception { public void testDownload() throws Exception {
if (Util.SDK_INT < 16) { if (Util.SDK_INT < 16) {
return; // Pass. return; // Pass.
......
...@@ -15,13 +15,16 @@ ...@@ -15,13 +15,16 @@
*/ */
package com.google.android.exoplayer2.playbacktests.gts; 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.assertThat;
import static com.google.common.truth.Truth.assertWithMessage; import static com.google.common.truth.Truth.assertWithMessage;
import static org.junit.Assert.fail;
import android.media.MediaDrm.MediaDrmStateException; import android.media.MediaDrm.MediaDrmStateException;
import android.net.Uri; import android.net.Uri;
import android.test.ActivityInstrumentationTestCase2;
import android.util.Pair; import android.util.Pair;
import androidx.test.rule.ActivityTestRule;
import androidx.test.runner.AndroidJUnit4;
import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.drm.DrmInitData; import com.google.android.exoplayer2.drm.DrmInitData;
import com.google.android.exoplayer2.drm.DrmSession.DrmSessionException; import com.google.android.exoplayer2.drm.DrmSession.DrmSessionException;
...@@ -36,11 +39,15 @@ import com.google.android.exoplayer2.upstream.DefaultHttpDataSourceFactory; ...@@ -36,11 +39,15 @@ import com.google.android.exoplayer2.upstream.DefaultHttpDataSourceFactory;
import com.google.android.exoplayer2.util.MimeTypes; import com.google.android.exoplayer2.util.MimeTypes;
import com.google.android.exoplayer2.util.Util; import com.google.android.exoplayer2.util.Util;
import java.io.IOException; import java.io.IOException;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
/** /** Tests Widevine encrypted DASH playbacks using offline keys. */
* Tests Widevine encrypted DASH playbacks using offline keys. @RunWith(AndroidJUnit4.class)
*/ public final class DashWidevineOfflineTest {
public final class DashWidevineOfflineTest extends ActivityInstrumentationTestCase2<HostActivity> {
private static final String TAG = "DashWidevineOfflineTest"; private static final String TAG = "DashWidevineOfflineTest";
private static final String USER_AGENT = "ExoPlayerPlaybackTests"; private static final String USER_AGENT = "ExoPlayerPlaybackTests";
...@@ -50,20 +57,19 @@ public final class DashWidevineOfflineTest extends ActivityInstrumentationTestCa ...@@ -50,20 +57,19 @@ public final class DashWidevineOfflineTest extends ActivityInstrumentationTestCa
private OfflineLicenseHelper<FrameworkMediaCrypto> offlineLicenseHelper; private OfflineLicenseHelper<FrameworkMediaCrypto> offlineLicenseHelper;
private byte[] offlineLicenseKeySetId; private byte[] offlineLicenseKeySetId;
public DashWidevineOfflineTest() { @Rule public ActivityTestRule<HostActivity> testRule = new ActivityTestRule<>(HostActivity.class);
super(HostActivity.class);
}
@Override @Before
protected void setUp() throws Exception { public void setUp() throws Exception {
super.setUp(); testRunner =
testRunner = new DashTestRunner(TAG, getActivity(), getInstrumentation()) new DashTestRunner(TAG, testRule.getActivity(), getInstrumentation())
.setStreamName("test_widevine_h264_fixed_offline") .setStreamName("test_widevine_h264_fixed_offline")
.setManifestUrl(DashTestData.WIDEVINE_H264_MANIFEST) .setManifestUrl(DashTestData.WIDEVINE_H264_MANIFEST)
.setWidevineInfo(MimeTypes.VIDEO_H264, true) .setWidevineInfo(MimeTypes.VIDEO_H264, true)
.setFullPlaybackNoSeeking(true) .setFullPlaybackNoSeeking(true)
.setCanIncludeAdditionalVideoFormats(false) .setCanIncludeAdditionalVideoFormats(false)
.setAudioVideoFormats(DashTestData.WIDEVINE_AAC_AUDIO_REPRESENTATION_ID, .setAudioVideoFormats(
DashTestData.WIDEVINE_AAC_AUDIO_REPRESENTATION_ID,
DashTestData.WIDEVINE_H264_CDD_FIXED); DashTestData.WIDEVINE_H264_CDD_FIXED);
boolean useL1Widevine = DashTestRunner.isL1WidevineAvailable(MimeTypes.VIDEO_H264); boolean useL1Widevine = DashTestRunner.isL1WidevineAvailable(MimeTypes.VIDEO_H264);
...@@ -75,8 +81,8 @@ public final class DashWidevineOfflineTest extends ActivityInstrumentationTestCa ...@@ -75,8 +81,8 @@ public final class DashWidevineOfflineTest extends ActivityInstrumentationTestCa
} }
} }
@Override @After
protected void tearDown() throws Exception { public void tearDown() throws Exception {
testRunner = null; testRunner = null;
if (offlineLicenseKeySetId != null) { if (offlineLicenseKeySetId != null) {
releaseLicense(); releaseLicense();
...@@ -86,11 +92,11 @@ public final class DashWidevineOfflineTest extends ActivityInstrumentationTestCa ...@@ -86,11 +92,11 @@ public final class DashWidevineOfflineTest extends ActivityInstrumentationTestCa
} }
offlineLicenseHelper = null; offlineLicenseHelper = null;
httpDataSourceFactory = null; httpDataSourceFactory = null;
super.tearDown();
} }
// Offline license tests // Offline license tests
@Test
public void testWidevineOfflineLicenseV22() throws Exception { public void testWidevineOfflineLicenseV22() throws Exception {
if (Util.SDK_INT < 22) { if (Util.SDK_INT < 22) {
return; // Pass. return; // Pass.
...@@ -103,6 +109,7 @@ public final class DashWidevineOfflineTest extends ActivityInstrumentationTestCa ...@@ -103,6 +109,7 @@ public final class DashWidevineOfflineTest extends ActivityInstrumentationTestCa
assertThat(offlineLicenseKeySetId).isNotNull(); assertThat(offlineLicenseKeySetId).isNotNull();
} }
@Test
public void testWidevineOfflineReleasedLicenseV22() throws Throwable { public void testWidevineOfflineReleasedLicenseV22() throws Throwable {
if (Util.SDK_INT < 22) { if (Util.SDK_INT < 22) {
return; // Pass. return; // Pass.
...@@ -129,6 +136,7 @@ public final class DashWidevineOfflineTest extends ActivityInstrumentationTestCa ...@@ -129,6 +136,7 @@ public final class DashWidevineOfflineTest extends ActivityInstrumentationTestCa
} }
} }
@Test
public void testWidevineOfflineExpiredLicenseV22() throws Exception { public void testWidevineOfflineExpiredLicenseV22() throws Exception {
if (Util.SDK_INT < 22) { if (Util.SDK_INT < 22) {
return; // Pass. return; // Pass.
...@@ -158,6 +166,7 @@ public final class DashWidevineOfflineTest extends ActivityInstrumentationTestCa ...@@ -158,6 +166,7 @@ public final class DashWidevineOfflineTest extends ActivityInstrumentationTestCa
testRunner.run(); testRunner.run();
} }
@Test
public void testWidevineOfflineLicenseExpiresOnPauseV22() throws Exception { public void testWidevineOfflineLicenseExpiresOnPauseV22() throws Exception {
if (Util.SDK_INT < 22) { if (Util.SDK_INT < 22) {
return; // Pass. return; // Pass.
......
...@@ -15,11 +15,13 @@ ...@@ -15,11 +15,13 @@
*/ */
package com.google.android.exoplayer2.playbacktests.gts; package com.google.android.exoplayer2.playbacktests.gts;
import static androidx.test.InstrumentationRegistry.getInstrumentation;
import android.media.MediaCodecInfo.AudioCapabilities; import android.media.MediaCodecInfo.AudioCapabilities;
import android.media.MediaCodecInfo.CodecCapabilities; import android.media.MediaCodecInfo.CodecCapabilities;
import android.media.MediaCodecInfo.CodecProfileLevel; import android.media.MediaCodecInfo.CodecProfileLevel;
import android.media.MediaCodecInfo.VideoCapabilities; import android.media.MediaCodecInfo.VideoCapabilities;
import android.test.InstrumentationTestCase; import androidx.test.runner.AndroidJUnit4;
import com.google.android.exoplayer2.mediacodec.MediaCodecInfo; import com.google.android.exoplayer2.mediacodec.MediaCodecInfo;
import com.google.android.exoplayer2.mediacodec.MediaCodecUtil; import com.google.android.exoplayer2.mediacodec.MediaCodecUtil;
import com.google.android.exoplayer2.mediacodec.MediaCodecUtil.DecoderQueryException; import com.google.android.exoplayer2.mediacodec.MediaCodecUtil.DecoderQueryException;
...@@ -29,9 +31,13 @@ import com.google.android.exoplayer2.util.MimeTypes; ...@@ -29,9 +31,13 @@ import com.google.android.exoplayer2.util.MimeTypes;
import com.google.android.exoplayer2.util.Util; import com.google.android.exoplayer2.util.Util;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
/** Tests enumeration of decoders using {@link MediaCodecUtil}. */ /** Tests enumeration of decoders using {@link MediaCodecUtil}. */
public class EnumerateDecodersTest extends InstrumentationTestCase { @RunWith(AndroidJUnit4.class)
public class EnumerateDecodersTest {
private static final String TAG = "EnumerateDecodersTest"; private static final String TAG = "EnumerateDecodersTest";
...@@ -40,14 +46,14 @@ public class EnumerateDecodersTest extends InstrumentationTestCase { ...@@ -40,14 +46,14 @@ public class EnumerateDecodersTest extends InstrumentationTestCase {
private MetricsLogger metricsLogger; private MetricsLogger metricsLogger;
@Override @Before
protected void setUp() throws Exception { public void setUp() {
super.setUp();
metricsLogger = metricsLogger =
MetricsLogger.Factory.createDefault( MetricsLogger.Factory.createDefault(
getInstrumentation(), TAG, REPORT_NAME, REPORT_OBJECT_NAME); getInstrumentation(), TAG, REPORT_NAME, REPORT_OBJECT_NAME);
} }
@Test
public void testEnumerateDecoders() throws Exception { public void testEnumerateDecoders() throws Exception {
enumerateDecoders(MimeTypes.VIDEO_H263); enumerateDecoders(MimeTypes.VIDEO_H263);
enumerateDecoders(MimeTypes.VIDEO_H264); enumerateDecoders(MimeTypes.VIDEO_H264);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment