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
This commit is contained in:
ibaker 2020-09-01 09:36:43 +01:00 committed by Oliver Woodman
parent 17b370d00c
commit 91185500a1

View File

@ -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,20 +122,20 @@ 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());
try {
testRunner.run();
fail("Playback should fail because the license has been released.");
} catch (RuntimeException expected) {
// Get the root cause
Throwable cause = error.getCause();
Throwable error = expected;
@Nullable Throwable cause = error.getCause();
while (cause != null && cause != error) {
error = cause;
cause = error.getCause();
}
assertThat(error).isInstanceOf(MediaDrmStateException.class);
}
}
@Test
public void widevineOfflineReleasedLicenseV29() throws Throwable {
@ -144,19 +145,20 @@ 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());
try {
testRunner.run();
fail("Playback should fail because the license has been released.");
} catch (RuntimeException expected) {
// Get the root cause
Throwable cause = error.getCause();
Throwable error = expected;
@Nullable Throwable cause = error.getCause();
while (cause != null && cause != error) {
error = cause;
cause = error.getCause();
}
assertThat(error).isInstanceOf(IllegalArgumentException.class);
}
}
@Test
public void widevineOfflineExpiredLicenseV22() throws Exception {