|
| 1 | +/* |
| 2 | + * Copyright 2025 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 | +package androidx.media3.transformer; |
| 17 | + |
| 18 | +import static com.google.common.truth.Truth.assertThat; |
| 19 | + |
| 20 | +import androidx.media3.common.MimeTypes; |
| 21 | +import com.google.common.collect.ImmutableList; |
| 22 | +import org.junit.Test; |
| 23 | +import org.junit.runner.RunWith; |
| 24 | +import org.robolectric.ParameterizedRobolectricTestRunner; |
| 25 | +import org.robolectric.ParameterizedRobolectricTestRunner.Parameter; |
| 26 | +import org.robolectric.ParameterizedRobolectricTestRunner.Parameters; |
| 27 | +import org.robolectric.shadows.ShadowBuild; |
| 28 | + |
| 29 | +@RunWith(ParameterizedRobolectricTestRunner.class) |
| 30 | +public class CodecDbLiteTest { |
| 31 | + |
| 32 | + @Parameter public TestParameters params; |
| 33 | + |
| 34 | + @Parameters(name = "{index}: {0}") |
| 35 | + public static ImmutableList<TestParameters> parameters() { |
| 36 | + return ImmutableList.of( |
| 37 | + new TestParameters("QTI", "SM6375", MimeTypes.VIDEO_H265), |
| 38 | + new TestParameters("QTI", "SM8350", MimeTypes.VIDEO_H265), |
| 39 | + new TestParameters("Mediatek", "MT6769T", MimeTypes.VIDEO_H265), |
| 40 | + new TestParameters("Google", "Tensor G3", MimeTypes.VIDEO_H265), |
| 41 | + new TestParameters("Mediatek", "MT6762", MimeTypes.VIDEO_H264), |
| 42 | + new TestParameters("QTI", "SM6225", MimeTypes.VIDEO_H265), |
| 43 | + new TestParameters("QTI", "SM8475", MimeTypes.VIDEO_H265), |
| 44 | + new TestParameters("Mediatek", "MT6893", MimeTypes.VIDEO_H265), |
| 45 | + new TestParameters("Spreadtrum", "SC9863A", MimeTypes.VIDEO_H264), |
| 46 | + new TestParameters("QTI", "SM8450", MimeTypes.VIDEO_H265), |
| 47 | + new TestParameters("Mediatek", "MT6765", MimeTypes.VIDEO_H264), |
| 48 | + new TestParameters("Mediatek", "MT6789V/CD", MimeTypes.VIDEO_H265), |
| 49 | + new TestParameters("QTI", "SM8250", MimeTypes.VIDEO_H265), |
| 50 | + new TestParameters("Google", "Tensor G2", MimeTypes.VIDEO_H265), |
| 51 | + new TestParameters("Mediatek", "MT6983", MimeTypes.VIDEO_H265), |
| 52 | + new TestParameters("Mediatek", "MT6769Z", MimeTypes.VIDEO_H265), |
| 53 | + new TestParameters("Samsung", "Exynos 850", MimeTypes.VIDEO_H265), |
| 54 | + new TestParameters("QTI", "SM8650", MimeTypes.VIDEO_H265), |
| 55 | + new TestParameters("QTI", "SDM450", MimeTypes.VIDEO_H264), |
| 56 | + new TestParameters("Spreadtrum", "T606", MimeTypes.VIDEO_H264), |
| 57 | + new TestParameters("Samsung", "s5e9925", MimeTypes.VIDEO_H265), |
| 58 | + new TestParameters("QTI", "SM8550", MimeTypes.VIDEO_H265), |
| 59 | + new TestParameters("QTI", "SM4350", MimeTypes.VIDEO_H265), |
| 60 | + new TestParameters("Samsung", "s5e8825", MimeTypes.VIDEO_H265), |
| 61 | + new TestParameters("QTI", "SM6125", MimeTypes.VIDEO_H265), |
| 62 | + new TestParameters("Mediatek", "MT6833V/NZA", MimeTypes.VIDEO_H265), |
| 63 | + new TestParameters("Mediatek", "MT6761", MimeTypes.VIDEO_H264), |
| 64 | + new TestParameters("Mediatek", "MT6785", MimeTypes.VIDEO_H265)); |
| 65 | + } |
| 66 | + |
| 67 | + @Test |
| 68 | + public void getRecommendedVideoMimeType_returnsCorrectMimeType() { |
| 69 | + ShadowBuild.setSystemOnChipManufacturer(params.socManufacturer); |
| 70 | + ShadowBuild.setSystemOnChipModel(params.socModel); |
| 71 | + |
| 72 | + assertThat(CodecDbLite.getRecommendedVideoMimeType()).isEqualTo(params.recommendedMimeType); |
| 73 | + } |
| 74 | + |
| 75 | + /** Parameters for a single CodecDB Lite test case. */ |
| 76 | + private static final class TestParameters { |
| 77 | + private final String socManufacturer; |
| 78 | + private final String socModel; |
| 79 | + |
| 80 | + private final String recommendedMimeType; |
| 81 | + |
| 82 | + public TestParameters(String socManufacturer, String socModel, String recommendedMimeType) { |
| 83 | + this.socManufacturer = socManufacturer; |
| 84 | + this.socModel = socModel; |
| 85 | + this.recommendedMimeType = recommendedMimeType; |
| 86 | + } |
| 87 | + |
| 88 | + @Override |
| 89 | + public String toString() { |
| 90 | + return String.format("%s %s", socManufacturer, socModel); |
| 91 | + } |
| 92 | + } |
| 93 | +} |
0 commit comments