Commit 91185500 by ibaker Committed by Oliver Woodman

Remove usage of assertThrows from ExoPlayer GTS tests

The environment these tests are executed in is only using JUnit 4.10,
which doesn't have assertThrows.

PiperOrigin-RevId: 329462985
parent 17b370d0
...@@ -17,11 +17,12 @@ package com.google.android.exoplayer2.playbacktests.gts; ...@@ -17,11 +17,12 @@ package com.google.android.exoplayer2.playbacktests.gts;
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.assertThrows; 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.util.Pair; import android.util.Pair;
import androidx.annotation.Nullable;
import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule; import androidx.test.rule.ActivityTestRule;
import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.Format;
...@@ -121,20 +122,20 @@ public final class DashWidevineOfflineTest { ...@@ -121,20 +122,20 @@ public final class DashWidevineOfflineTest {
downloadLicense(); downloadLicense();
releaseLicense(); // keySetId no longer valid. releaseLicense(); // keySetId no longer valid.
Throwable error = try {
assertThrows( testRunner.run();
"Playback should fail because the license has been released.", fail("Playback should fail because the license has been released.");
Throwable.class, } catch (RuntimeException expected) {
() -> testRunner.run());
// Get the root cause // Get the root cause
Throwable cause = error.getCause(); Throwable error = expected;
@Nullable Throwable cause = error.getCause();
while (cause != null && cause != error) { while (cause != null && cause != error) {
error = cause; error = cause;
cause = error.getCause(); cause = error.getCause();
} }
assertThat(error).isInstanceOf(MediaDrmStateException.class); assertThat(error).isInstanceOf(MediaDrmStateException.class);
} }
}
@Test @Test
public void widevineOfflineReleasedLicenseV29() throws Throwable { public void widevineOfflineReleasedLicenseV29() throws Throwable {
...@@ -144,19 +145,20 @@ public final class DashWidevineOfflineTest { ...@@ -144,19 +145,20 @@ public final class DashWidevineOfflineTest {
downloadLicense(); downloadLicense();
releaseLicense(); // keySetId no longer valid. releaseLicense(); // keySetId no longer valid.
Throwable error = try {
assertThrows( testRunner.run();
"Playback should fail because the license has been released.", fail("Playback should fail because the license has been released.");
Throwable.class, } catch (RuntimeException expected) {
() -> testRunner.run());
// Get the root cause // Get the root cause
Throwable cause = error.getCause(); Throwable error = expected;
@Nullable Throwable cause = error.getCause();
while (cause != null && cause != error) { while (cause != null && cause != error) {
error = cause; error = cause;
cause = error.getCause(); cause = error.getCause();
} }
assertThat(error).isInstanceOf(IllegalArgumentException.class); assertThat(error).isInstanceOf(IllegalArgumentException.class);
} }
}
@Test @Test
public void widevineOfflineExpiredLicenseV22() throws Exception { public void widevineOfflineExpiredLicenseV22() throws Exception {
......
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