summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-07-13 03:23:07 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-07-13 03:23:07 +0000
commitd6e34ae333d3fea2a65a7223e803c5a1bddf5061 (patch)
tree0b29f53370d63eac7c76c1ae9a76f9b00b289de3
parent67f2ec5afe6d09dd56acc0e3c5d83624974e0191 (diff)
parent896bdbe96c54e3000f9b2e3a0df57051aa75cafd (diff)
downloadcts-android13-frc-media-swcodec-release.tar.gz
Merge cherrypicks of [19042674] into sparse-8762339-L68000000955468217.t_frc_swc_330443040t_frc_swc_330443010android13-frc-media-swcodec-release
Change-Id: I80be442e3e1cb2da2f68cda68bea7aad541f6177
-rw-r--r--tests/tests/media/codec/src/android/media/codec/cts/MediaCodecTest.java12
-rw-r--r--tests/tests/media/common/src/android/media/cts/TestUtils.java42
2 files changed, 48 insertions, 6 deletions
diff --git a/tests/tests/media/codec/src/android/media/codec/cts/MediaCodecTest.java b/tests/tests/media/codec/src/android/media/codec/cts/MediaCodecTest.java
index a7bb37fe152..4294059d0cd 100644
--- a/tests/tests/media/codec/src/android/media/codec/cts/MediaCodecTest.java
+++ b/tests/tests/media/codec/src/android/media/codec/cts/MediaCodecTest.java
@@ -35,14 +35,13 @@ import android.media.MediaCodecInfo.CodecProfileLevel;
import android.media.MediaCodecInfo.EncoderCapabilities;
import android.media.MediaCodecInfo.VideoCapabilities;
import android.media.MediaCodecList;
-import android.media.MediaCrypto;
import android.media.MediaExtractor;
import android.media.MediaFormat;
-import android.media.cts.AudioHelper;
import android.media.cts.InputSurface;
import android.media.cts.OutputSurface;
import android.media.cts.Preconditions;
import android.media.cts.StreamUtils;
+import android.media.cts.TestUtils;
import android.opengl.GLES20;
import android.os.Build;
import android.os.ConditionVariable;
@@ -64,13 +63,9 @@ import androidx.test.filters.SmallTest;
import com.android.compatibility.common.util.ApiLevelUtil;
import com.android.compatibility.common.util.MediaUtils;
-import java.io.BufferedInputStream;
import java.io.File;
import java.io.IOException;
-import java.io.InputStream;
import java.nio.ByteBuffer;
-import java.nio.FloatBuffer;
-import java.nio.ShortBuffer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -2429,6 +2424,11 @@ public class MediaCodecTest extends AndroidTestCase {
continue;
}
MediaCodec codec = null;
+ if (!TestUtils.isTestableCodecInCurrentMode(info.getName())) {
+ Log.d(TAG, "skip testing codec " + info.getName() + " in current mode:"
+ + (TestUtils.isMtsMode() ? " MTS" : " CTS"));
+ continue;
+ }
try {
codec = MediaCodec.createByCodecName(info.getName());
List<String> vendorParams = codec.getSupportedVendorParameters();
diff --git a/tests/tests/media/common/src/android/media/cts/TestUtils.java b/tests/tests/media/common/src/android/media/cts/TestUtils.java
index b09d333d958..f98b3abf936 100644
--- a/tests/tests/media/common/src/android/media/cts/TestUtils.java
+++ b/tests/tests/media/common/src/android/media/cts/TestUtils.java
@@ -25,8 +25,10 @@ import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
+import android.text.TextUtils;
import android.util.Log;
+import androidx.test.InstrumentationRegistry;
import androidx.test.core.app.ApplicationProvider;
import org.junit.Assert;
@@ -151,6 +153,46 @@ public final class TestUtils {
return true;
}
+ /*
+ * Report whether we are in MTS mode (vs in CTS) mode.
+ * Some tests (or parts of tests) are restricted to a particular mode.
+ */
+ public static boolean isMtsMode() {
+ Bundle bundle = InstrumentationRegistry.getArguments();
+ // null if not set
+ boolean isMTS = TextUtils.equals("true", bundle.getString("mts-media"));
+
+ return isMTS;
+ }
+
+ /*
+ * Report whether we want to test a particular code in the current test mode.
+ * CTS is pretty much "test them all".
+ * MTS should only be testing codecs that are part of the swcodec module; all of these
+ * begin with "c2.android."
+ *
+ * Used in spots throughout the test suite where we want to limit our testing to relevant
+ * codecs. This avoids false alarms that are sometimes triggered by non-compliant,
+ * non-mainline codecs.
+ *
+ * @param name the name of a codec
+ * @return {@code} true is the codec should be tested in the current operating mode.
+ */
+ public static boolean isTestableCodecInCurrentMode(String name) {
+ if (name == null) {
+ return false;
+ }
+ if (!isMtsMode()) {
+ // CTS mode -- test everything
+ return true;
+ }
+ // MTS mode, just the codecs that live in the modules
+ if (name.startsWith("c2.android.")) {
+ return true;
+ }
+ return false;
+ }
+
private TestUtils() {
}