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:
parent
17b370d00c
commit
91185500a1
@ -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,19 +122,19 @@ 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
|
||||||
|
Throwable error = expected;
|
||||||
// Get the root cause
|
@Nullable Throwable cause = error.getCause();
|
||||||
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
|
||||||
@ -144,18 +145,19 @@ 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 error = expected;
|
||||||
Throwable cause = error.getCause();
|
@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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user