summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-07-20 21:45:26 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-07-20 21:45:26 +0000
commit38a091c896997968d11375bd748594e9f2977492 (patch)
tree0b29f53370d63eac7c76c1ae9a76f9b00b289de3
parenta9be09aae17bd2fcc045391c5c2bac17b5059675 (diff)
parent9c0da385584c4ecee49ca617cc638254afd5b091 (diff)
downloadcts-android13-frc-media-release.tar.gz
Merge cherrypicks of [19042674] into sparse-8843490-L48800000955563757.t_frc_med_330443030android13-frc-media-release
Change-Id: If8bd6671dffc395c315583b93b693c951885e4f8
-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() {
}