1 /* 2 * Copyright 2022 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.media.cts; 18 19 import android.util.Log; 20 21 import androidx.test.platform.app.InstrumentationRegistry; 22 23 /** 24 * Contains arguments passed to the tests. 25 */ 26 public final class TestArgs { 27 private final static String TAG = "TestArgs"; 28 private static final String CODEC_PREFIX_KEY = "codec-prefix"; 29 private static final String CODEC_PREFIX; 30 private static final String MEDIA_TYPE_PREFIX_KEY = "media-type-prefix"; 31 private static final String MEDIA_TYPE_PREFIX; 32 33 static { 34 android.os.Bundle args = InstrumentationRegistry.getArguments(); 35 CODEC_PREFIX = args.getString(CODEC_PREFIX_KEY); 36 MEDIA_TYPE_PREFIX = args.getString(MEDIA_TYPE_PREFIX_KEY); 37 } 38 shouldSkipMediaType(String mediaType)39 public static boolean shouldSkipMediaType(String mediaType) { 40 if (MEDIA_TYPE_PREFIX != null && !mediaType.startsWith(MEDIA_TYPE_PREFIX)) { 41 Log.d(TAG, "Skipping tests for mediaType: " + mediaType); 42 return true; 43 } 44 return false; 45 } 46 shouldSkipCodec(String name)47 public static boolean shouldSkipCodec(String name) { 48 if (CODEC_PREFIX != null && !name.startsWith(CODEC_PREFIX)) { 49 Log.d(TAG, "Skipping tests for codec: " + name); 50 return true; 51 } 52 return false; 53 } 54 } 55