• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 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.mediapc.cts;
18 
19 import android.mediapc.cts.common.PerformanceClassEvaluator;
20 import android.mediapc.cts.common.Utils;
21 
22 import androidx.test.filters.LargeTest;
23 
24 import com.android.compatibility.common.util.CddTest;
25 
26 import org.junit.Assume;
27 import org.junit.Rule;
28 import org.junit.Test;
29 import org.junit.rules.TestName;
30 import org.junit.runner.RunWith;
31 import org.junit.runners.Parameterized;
32 
33 import java.util.Collection;
34 
35 /**
36  * The following test class validates the frame drops of a playback for the hardware decoders
37  * under the load condition (Transcode + Audio Playback).
38  */
39 @RunWith(Parameterized.class)
40 public class FrameDropTest extends FrameDropTestBase {
41     private static final String LOG_TAG = FrameDropTest.class.getSimpleName();
42 
FrameDropTest(String mimeType, String decoderName, boolean isAsync)43     public FrameDropTest(String mimeType, String decoderName, boolean isAsync) {
44         super(mimeType, decoderName, isAsync);
45     }
46 
47     @Rule
48     public final TestName mTestName = new TestName();
49 
50     // Returns the list of parameters with mimeTypes and their hardware decoders
51     // combining with sync and async modes.
52     // Parameters {0}_{1}_{2} -- Mime_DecoderName_isAsync
53     @Parameterized.Parameters(name = "{index}_{0}_{1}_{2}")
inputParams()54     public static Collection<Object[]> inputParams() {
55         return prepareArgumentsList(null);
56     }
57 
testDecodeToSurface(int frameRate, String[] testFiles)58     private int testDecodeToSurface(int frameRate, String[] testFiles) throws Exception {
59         PlaybackFrameDrop playbackFrameDrop = new PlaybackFrameDrop(mMime, mDecoderName, testFiles,
60                 mSurface, frameRate, mIsAsync);
61         return playbackFrameDrop.getFrameDropCount();
62     }
63 
64     /**
65      * This test validates that the playback of 1920x1080 resolution asset of 3 seconds duration
66      * at 30 fps for R perf class, for at least 30 seconds worth of  frames or for 31 seconds of
67      * elapsed time. must not drop more than 3 frames for R perf class.
68      */
69     @LargeTest
70     @Test(timeout = CodecTestBase.PER_TEST_TIMEOUT_LARGE_TEST_MS)
71     @CddTest(requirement="2.2.7.1/5.3/H-1-1")
test30Fps()72     public void test30Fps() throws Exception {
73         Assume.assumeTrue("Test is limited to R performance class devices or devices that do not " +
74                         "advertise performance class",
75                 Utils.isRPerfClass() || !Utils.isPerfClass());
76         int frameRate = 30;
77 
78         PerformanceClassEvaluator pce = new PerformanceClassEvaluator(this.mTestName);
79         PerformanceClassEvaluator.FrameDropRequirement r5_3__H_1_1_R = pce.addR5_3__H_1_1_R();
80 
81         String[] testFiles = new String[]{m1080p30FpsTestFiles.get(mMime)};
82         int framesDropped = testDecodeToSurface(frameRate, testFiles);
83 
84         r5_3__H_1_1_R.setFramesDropped(framesDropped);
85         r5_3__H_1_1_R.setFrameRate(frameRate);
86         r5_3__H_1_1_R.setTestResolution(1080);
87         pce.submitAndCheck();
88     }
89 
90     /**
91      * This test validates that the playback of 1920x1080 resolution asset of 3 seconds duration
92      * at 60 fps for S/T perf class,  for at least 30 seconds worth of  frames or for 31 seconds of
93      * elapsed time. must not drop more than 6 frames for S perf class / 3 frames for T perf class.
94      */
95     @LargeTest
96     @Test(timeout = CodecTestBase.PER_TEST_TIMEOUT_LARGE_TEST_MS)
97     @CddTest(requirement="2.2.7.1/5.3/H-1-1")
test60Fps()98     public void test60Fps() throws Exception {
99         Assume.assumeTrue("Test is limited to S/T performance class devices or devices that do " +
100                         "not advertise performance class",
101                 Utils.isSPerfClass() || Utils.isTPerfClass() || !Utils.isPerfClass());
102         int frameRate = 60;
103 
104         PerformanceClassEvaluator pce = new PerformanceClassEvaluator(this.mTestName);
105         PerformanceClassEvaluator.FrameDropRequirement r5_3__H_1_1_ST = pce.addR5_3__H_1_1_ST();
106 
107         String[] testFiles = new String[]{m1080p60FpsTestFiles.get(mMime)};
108         int framesDropped = testDecodeToSurface(frameRate, testFiles);
109 
110         r5_3__H_1_1_ST.setFramesDropped(framesDropped);
111         r5_3__H_1_1_ST.setFrameRate(frameRate);
112         r5_3__H_1_1_ST.setTestResolution(1080);
113         pce.submitAndCheck();
114     }
115 
116     /**
117      * This test validates that the playback of 3840x2160 resolution asset of 3 seconds duration
118      * at 60 fps for U perf class, for at least 30 seconds worth of frames or for 31 seconds of
119      * elapsed time. must not drop more than 3 frames for U perf class.
120      */
121     @LargeTest
122     @Test(timeout = CodecTestBase.PER_TEST_TIMEOUT_LARGE_TEST_MS)
123     @CddTest(requirement="2.2.7.1/5.3/H-1-1")
test4k()124     public void test4k() throws Exception {
125         Assume.assumeTrue("Test is limited to U performance class devices or devices that do not " +
126                         "advertise performance class",
127                 Utils.isUPerfClass() || !Utils.isPerfClass());
128         int frameRate = 60;
129 
130         PerformanceClassEvaluator pce = new PerformanceClassEvaluator(this.mTestName);
131         PerformanceClassEvaluator.FrameDropRequirement r5_3__H_1_1_U = pce.addR5_3__H_1_1_U();
132 
133         String[] testFiles = new String[]{m2160p60FpsTestFiles.get(mMime)};
134         int framesDropped = testDecodeToSurface(frameRate, testFiles);
135 
136         r5_3__H_1_1_U.setFramesDropped(framesDropped);
137         r5_3__H_1_1_U.setFrameRate(frameRate);
138         r5_3__H_1_1_U.setTestResolution(2160);
139         pce.submitAndCheck();
140     }
141 }
142