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;
import static com.google.common.truth.Truth.assertThat;
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.net.Uri;
import android.util.Pair;
import androidx.annotation.Nullable;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
import com.google.android.exoplayer2.Format;
......@@ -121,19 +122,19 @@ public final class DashWidevineOfflineTest {
downloadLicense();
releaseLicense(); // keySetId no longer valid.
Throwable error =
assertThrows(
"Playback should fail because the license has been released.",
Throwable.class,
() -> testRunner.run());
// Get the root cause
Throwable cause = error.getCause();
while (cause != null && cause != error) {
error = cause;
cause = error.getCause();
try {
testRunner.run();
fail("Playback should fail because the license has been released.");
} catch (RuntimeException expected) {
// Get the root cause
Throwable error = expected;
@Nullable Throwable cause = error.getCause();
while (cause != null && cause != error) {
error = cause;
cause = error.getCause();
}
assertThat(error).isInstanceOf(MediaDrmStateException.class);
}
assertThat(error).isInstanceOf(MediaDrmStateException.class);
}
@Test
......@@ -144,18 +145,19 @@ public final class DashWidevineOfflineTest {
downloadLicense();
releaseLicense(); // keySetId no longer valid.
Throwable error =
assertThrows(
"Playback should fail because the license has been released.",
Throwable.class,
() -> testRunner.run());
// Get the root cause
Throwable cause = error.getCause();
while (cause != null && cause != error) {
error = cause;
cause = error.getCause();
try {
testRunner.run();
fail("Playback should fail because the license has been released.");
} catch (RuntimeException expected) {
// Get the root cause
Throwable error = expected;
@Nullable Throwable cause = error.getCause();
while (cause != null && cause != error) {
error = cause;
cause = error.getCause();
}
assertThat(error).isInstanceOf(IllegalArgumentException.class);
}
assertThat(error).isInstanceOf(IllegalArgumentException.class);
}
@Test
......
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