Skip WV tests on devices where WV is unsupported

PiperOrigin-RevId: 327392056
This commit is contained in:
ibaker 2020-08-19 09:33:31 +01:00 committed by Oliver Woodman
parent b85ff574a9
commit 3af82b2a8b
4 changed files with 84 additions and 23 deletions

View file

@ -15,6 +15,8 @@
*/
package com.google.android.exoplayer2.playbacktests.gts;
import static com.google.android.exoplayer2.playbacktests.gts.GtsTestUtil.shouldSkipWidevineTest;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
import com.google.android.exoplayer2.Player;
@ -64,7 +66,7 @@ public final class CommonEncryptionDrmTest {
@Test
public void cencSchemeTypeV18() {
if (Util.SDK_INT < 18) {
if (Util.SDK_INT < 18 || shouldSkipWidevineTest(testRule.getActivity())) {
// Pass.
return;
}
@ -76,7 +78,7 @@ public final class CommonEncryptionDrmTest {
@Test
public void cbcsSchemeTypeV25() {
if (Util.SDK_INT < 25) {
if (Util.SDK_INT < 25 || shouldSkipWidevineTest(testRule.getActivity())) {
// cbcs support was added in API 24, but it is stable from API 25 onwards.
// See [internal: b/65634809].
// Pass.

View file

@ -15,6 +15,7 @@
*/
package com.google.android.exoplayer2.playbacktests.gts;
import static com.google.android.exoplayer2.playbacktests.gts.GtsTestUtil.shouldSkipWidevineTest;
import static com.google.common.truth.Truth.assertThat;
import androidx.test.ext.junit.runners.AndroidJUnit4;
@ -356,7 +357,7 @@ public final class DashStreamingTest {
@Test
public void widevineH264FixedV18() throws Exception {
if (Util.SDK_INT < 18) {
if (Util.SDK_INT < 18 || shouldSkipWidevineTest(testRule.getActivity())) {
// Pass.
return;
}
@ -373,7 +374,9 @@ public final class DashStreamingTest {
@Test
public void widevineH264AdaptiveV18() throws Exception {
if (Util.SDK_INT < 18 || shouldSkipAdaptiveTest(MimeTypes.VIDEO_H264)) {
if (Util.SDK_INT < 18
|| shouldSkipAdaptiveTest(MimeTypes.VIDEO_H264)
|| shouldSkipWidevineTest(testRule.getActivity())) {
// Pass.
return;
}
@ -390,7 +393,9 @@ public final class DashStreamingTest {
@Test
public void widevineH264AdaptiveWithSeekingV18() throws Exception {
if (Util.SDK_INT < 18 || shouldSkipAdaptiveTest(MimeTypes.VIDEO_H264)) {
if (Util.SDK_INT < 18
|| shouldSkipAdaptiveTest(MimeTypes.VIDEO_H264)
|| shouldSkipWidevineTest(testRule.getActivity())) {
// Pass.
return;
}
@ -408,7 +413,9 @@ public final class DashStreamingTest {
@Test
public void widevineH264AdaptiveWithRendererDisablingV18() throws Exception {
if (Util.SDK_INT < 18 || shouldSkipAdaptiveTest(MimeTypes.VIDEO_H264)) {
if (Util.SDK_INT < 18
|| shouldSkipAdaptiveTest(MimeTypes.VIDEO_H264)
|| GtsTestUtil.shouldSkipWidevineTest(testRule.getActivity())) {
// Pass.
return;
}
@ -428,7 +435,7 @@ public final class DashStreamingTest {
@Test
public void widevineH265FixedV23() throws Exception {
if (Util.SDK_INT < 23) {
if (Util.SDK_INT < 23 || GtsTestUtil.shouldSkipWidevineTest(testRule.getActivity())) {
// Pass.
return;
}
@ -445,7 +452,7 @@ public final class DashStreamingTest {
@Test
public void widevineH265AdaptiveV24() throws Exception {
if (Util.SDK_INT < 24) {
if (Util.SDK_INT < 24 || GtsTestUtil.shouldSkipWidevineTest(testRule.getActivity())) {
// Pass.
return;
}
@ -462,7 +469,7 @@ public final class DashStreamingTest {
@Test
public void widevineH265AdaptiveWithSeekingV24() throws Exception {
if (Util.SDK_INT < 24) {
if (Util.SDK_INT < 24 || GtsTestUtil.shouldSkipWidevineTest(testRule.getActivity())) {
// Pass.
return;
}
@ -480,7 +487,7 @@ public final class DashStreamingTest {
@Test
public void widevineH265AdaptiveWithRendererDisablingV24() throws Exception {
if (Util.SDK_INT < 24) {
if (Util.SDK_INT < 24 || GtsTestUtil.shouldSkipWidevineTest(testRule.getActivity())) {
// Pass.
return;
}
@ -500,7 +507,7 @@ public final class DashStreamingTest {
@Test
public void widevineVp9Fixed360pV23() throws Exception {
if (Util.SDK_INT < 23) {
if (Util.SDK_INT < 23 || GtsTestUtil.shouldSkipWidevineTest(testRule.getActivity())) {
// Pass.
return;
}
@ -517,7 +524,7 @@ public final class DashStreamingTest {
@Test
public void widevineVp9AdaptiveV24() throws Exception {
if (Util.SDK_INT < 24) {
if (Util.SDK_INT < 24 || GtsTestUtil.shouldSkipWidevineTest(testRule.getActivity())) {
// Pass.
return;
}
@ -534,7 +541,7 @@ public final class DashStreamingTest {
@Test
public void widevineVp9AdaptiveWithSeekingV24() throws Exception {
if (Util.SDK_INT < 24) {
if (Util.SDK_INT < 24 || GtsTestUtil.shouldSkipWidevineTest(testRule.getActivity())) {
// Pass.
return;
}
@ -552,7 +559,7 @@ public final class DashStreamingTest {
@Test
public void widevineVp9AdaptiveWithRendererDisablingV24() throws Exception {
if (Util.SDK_INT < 24) {
if (Util.SDK_INT < 24 || GtsTestUtil.shouldSkipWidevineTest(testRule.getActivity())) {
// Pass.
return;
}
@ -573,7 +580,7 @@ public final class DashStreamingTest {
// 23.976 fps.
@Test
public void widevine23FpsH264FixedV23() throws Exception {
if (Util.SDK_INT < 23) {
if (Util.SDK_INT < 23 || GtsTestUtil.shouldSkipWidevineTest(testRule.getActivity())) {
// Pass.
return;
}
@ -591,7 +598,7 @@ public final class DashStreamingTest {
// 24 fps.
@Test
public void widevine24FpsH264FixedV23() throws Exception {
if (Util.SDK_INT < 23) {
if (Util.SDK_INT < 23 || GtsTestUtil.shouldSkipWidevineTest(testRule.getActivity())) {
// Pass.
return;
}
@ -609,7 +616,7 @@ public final class DashStreamingTest {
// 29.97 fps.
@Test
public void widevine29FpsH264FixedV23() throws Exception {
if (Util.SDK_INT < 23) {
if (Util.SDK_INT < 23 || GtsTestUtil.shouldSkipWidevineTest(testRule.getActivity())) {
// Pass.
return;
}

View file

@ -100,7 +100,7 @@ public final class DashWidevineOfflineTest {
@Test
public void widevineOfflineLicenseV22() throws Exception {
if (Util.SDK_INT < 22) {
if (Util.SDK_INT < 22 || GtsTestUtil.shouldSkipWidevineTest(testRule.getActivity())) {
return; // Pass.
}
downloadLicense();
@ -113,7 +113,9 @@ public final class DashWidevineOfflineTest {
@Test
public void widevineOfflineReleasedLicenseV22() throws Throwable {
if (Util.SDK_INT < 22 || Util.SDK_INT > 28) {
if (Util.SDK_INT < 22
|| Util.SDK_INT > 28
|| GtsTestUtil.shouldSkipWidevineTest(testRule.getActivity())) {
return; // Pass.
}
downloadLicense();
@ -136,7 +138,7 @@ public final class DashWidevineOfflineTest {
@Test
public void widevineOfflineReleasedLicenseV29() throws Throwable {
if (Util.SDK_INT < 29) {
if (Util.SDK_INT < 29 || GtsTestUtil.shouldSkipWidevineTest(testRule.getActivity())) {
return; // Pass.
}
downloadLicense();
@ -158,7 +160,7 @@ public final class DashWidevineOfflineTest {
@Test
public void widevineOfflineExpiredLicenseV22() throws Exception {
if (Util.SDK_INT < 22) {
if (Util.SDK_INT < 22 || GtsTestUtil.shouldSkipWidevineTest(testRule.getActivity())) {
return; // Pass.
}
downloadLicense();
@ -188,7 +190,7 @@ public final class DashWidevineOfflineTest {
@Test
public void widevineOfflineLicenseExpiresOnPauseV22() throws Exception {
if (Util.SDK_INT < 22) {
if (Util.SDK_INT < 22 || GtsTestUtil.shouldSkipWidevineTest(testRule.getActivity())) {
return; // Pass.
}
downloadLicense();
@ -198,7 +200,7 @@ public final class DashWidevineOfflineTest {
offlineLicenseHelper.getLicenseDurationRemainingSec(offlineLicenseKeySetId);
long licenseDuration = licenseDurationRemainingSec.first;
assertWithMessage(
"License duration should be less than 30 sec. " + "Server settings might have changed.")
"License duration should be less than 30 sec. Server settings might have changed.")
.that(licenseDuration < 30)
.isTrue();
ActionSchedule schedule = new ActionSchedule.Builder(TAG)

View file

@ -0,0 +1,50 @@
/*
* Copyright (C) 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.exoplayer2.playbacktests.gts;
import static com.google.android.exoplayer2.C.WIDEVINE_UUID;
import android.content.Context;
import android.content.pm.PackageManager;
import android.media.MediaDrm;
/** Utility methods for GTS tests. */
public final class GtsTestUtil {
private GtsTestUtil() {}
/** Returns true if the device doesn't support Widevine and this is permitted. */
public static boolean shouldSkipWidevineTest(Context context) {
if (isGmsInstalled(context)) {
// GMS devices are required to support Widevine.
return false;
}
// For non-GMS devices Widevine is optional.
return !MediaDrm.isCryptoSchemeSupported(WIDEVINE_UUID);
}
private static boolean isGmsInstalled(Context context) {
try {
context
.getPackageManager()
.getPackageInfo("com.google.android.gms", PackageManager.GET_SIGNATURES);
} catch (PackageManager.NameNotFoundException e) {
return false;
}
return true;
}
}