Commit 13c668f9 by tonihei Committed by Ian Baker

Fix Widevine offline test assertion for API29+.

The error type thrown when acquiring a license that has already
been released changed from MediaDrmStateException to IllegalStateException
from API 29.

Update the tests to assert the correct type of error based on API version.

PiperOrigin-RevId: 308239508
parent 30c55d11
...@@ -17,7 +17,7 @@ package com.google.android.exoplayer2.playbacktests.gts; ...@@ -17,7 +17,7 @@ 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.fail; import static org.junit.Assert.assertThrows;
import android.media.MediaDrm.MediaDrmStateException; import android.media.MediaDrm.MediaDrmStateException;
import android.net.Uri; import android.net.Uri;
...@@ -111,29 +111,47 @@ public final class DashWidevineOfflineTest { ...@@ -111,29 +111,47 @@ public final class DashWidevineOfflineTest {
@Test @Test
public void widevineOfflineReleasedLicenseV22() throws Throwable { public void widevineOfflineReleasedLicenseV22() throws Throwable {
if (Util.SDK_INT < 22) { if (Util.SDK_INT < 22 || Util.SDK_INT > 28) {
return; // Pass. return; // Pass.
} }
downloadLicense(); downloadLicense();
releaseLicense(); // keySetId no longer valid. releaseLicense(); // keySetId no longer valid.
try { Throwable error =
testRunner.run(); assertThrows(
fail("Playback should fail because the license has been released."); "Playback should fail because the license has been released.",
} catch (Throwable e) { Throwable.class,
// Get the root cause () -> testRunner.run());
while (true) {
Throwable cause = e.getCause(); // Get the root cause
if (cause == null || cause == e) { Throwable cause = error.getCause();
break; while (cause != null && cause != error) {
} error = cause;
e = cause; cause = error.getCause();
} }
// It should be a MediaDrmStateException instance assertThat(error).isInstanceOf(MediaDrmStateException.class);
if (!(e instanceof MediaDrmStateException)) { }
throw e;
} @Test
public void widevineOfflineReleasedLicenseV29() throws Throwable {
if (Util.SDK_INT < 29) {
return; // Pass.
}
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();
} }
assertThat(error).isInstanceOf(IllegalArgumentException.class);
} }
@Test @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