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.mediav2.cts;
18 
19 import static org.junit.Assert.assertTrue;
20 
21 import androidx.test.ext.junit.runners.AndroidJUnit4;
22 import androidx.test.filters.SmallTest;
23 
24 import com.android.compatibility.common.util.ApiTest;
25 
26 import org.junit.Rule;
27 import org.junit.Test;
28 import org.junit.rules.Timeout;
29 import org.junit.runner.RunWith;
30 
31 import java.util.concurrent.TimeUnit;
32 
33 @SmallTest
34 @RunWith(AndroidJUnit4.class)
35 public class MediaFormatUnitTest {
36     static final int PER_TEST_TIMEOUT_MS = 10000;
37 
38     static {
39         System.loadLibrary("ctsmediav2utils_jni");
40     }
41 
42     @Rule
43     public Timeout timeout = new Timeout(PER_TEST_TIMEOUT_MS, TimeUnit.MILLISECONDS);
44 
45     @ApiTest(apis = {"AMediaFormat_getInt32", "AMediaFormat_setInt32",
46             "AMediaFormat_copy", "AMediaFormat_clear", "AMediaFormat_toString",
47             "AMediaFormat_new", "AMediaFormat_delete"})
48     @Test
testMediaFormatNativeInt32()49     public void testMediaFormatNativeInt32() {
50         assertTrue(nativeTestMediaFormatInt32());
51     }
52 
nativeTestMediaFormatInt32()53     private native boolean nativeTestMediaFormatInt32();
54 
55     @ApiTest(apis = {"AMediaFormat_getInt64", "AMediaFormat_setInt64",
56             "AMediaFormat_copy", "AMediaFormat_clear", "AMediaFormat_toString",
57             "AMediaFormat_new", "AMediaFormat_delete"})
58     @Test
testMediaFormatNativeInt64()59     public void testMediaFormatNativeInt64() {
60         assertTrue(nativeTestMediaFormatInt64());
61     }
62 
nativeTestMediaFormatInt64()63     private native boolean nativeTestMediaFormatInt64();
64 
65     @ApiTest(apis = {"AMediaFormat_getFloat", "AMediaFormat_setFloat",
66             "AMediaFormat_copy", "AMediaFormat_clear", "AMediaFormat_toString",
67             "AMediaFormat_new", "AMediaFormat_delete"})
68     @Test
testMediaFormatNativeFloat()69     public void testMediaFormatNativeFloat() {
70         assertTrue(nativeTestMediaFormatFloat());
71     }
72 
nativeTestMediaFormatFloat()73     private native boolean nativeTestMediaFormatFloat();
74 
75     @ApiTest(apis = {"AMediaFormat_getDouble", "AMediaFormat_setDouble",
76             "AMediaFormat_copy", "AMediaFormat_clear", "AMediaFormat_toString",
77             "AMediaFormat_new", "AMediaFormat_delete"})
78     @Test
testMediaFormatNativeDouble()79     public void testMediaFormatNativeDouble() {
80         assertTrue(nativeTestMediaFormatDouble());
81     }
82 
nativeTestMediaFormatDouble()83     private native boolean nativeTestMediaFormatDouble();
84 
85     @ApiTest(apis = {"AMediaFormat_getSize", "AMediaFormat_setSize",
86             "AMediaFormat_copy", "AMediaFormat_clear", "AMediaFormat_toString",
87             "AMediaFormat_new", "AMediaFormat_delete"})
88     @Test
testMediaFormatNativeSize()89     public void testMediaFormatNativeSize() {
90         assertTrue(nativeTestMediaFormatSize());
91     }
92 
nativeTestMediaFormatSize()93     private native boolean nativeTestMediaFormatSize();
94 
95     @ApiTest(apis = {"AMediaFormat_getString", "AMediaFormat_setString",
96             "AMediaFormat_copy", "AMediaFormat_clear", "AMediaFormat_toString",
97             "AMediaFormat_new", "AMediaFormat_delete"})
98     @Test
testMediaFormatNativeString()99     public void testMediaFormatNativeString() {
100         assertTrue(nativeTestMediaFormatString());
101     }
102 
nativeTestMediaFormatString()103     private native boolean nativeTestMediaFormatString();
104 
105     @ApiTest(apis = {"AMediaFormat_getRect", "AMediaFormat_setRect",
106             "AMediaFormat_copy", "AMediaFormat_clear", "AMediaFormat_toString",
107             "AMediaFormat_new", "AMediaFormat_delete"})
108     @Test
testMediaFormatNativeRect()109     public void testMediaFormatNativeRect() {
110         assertTrue(nativeTestMediaFormatRect());
111     }
112 
nativeTestMediaFormatRect()113     private native boolean nativeTestMediaFormatRect();
114 
115     @ApiTest(apis = {"AMediaFormat_getBuffer", "AMediaFormat_setBuffer",
116             "AMediaFormat_copy", "AMediaFormat_clear", "AMediaFormat_toString",
117             "AMediaFormat_new", "AMediaFormat_delete"})
118     @Test
testMediaFormatNativeBuffer()119     public void testMediaFormatNativeBuffer() {
120         assertTrue(nativeTestMediaFormatBuffer());
121     }
122 
nativeTestMediaFormatBuffer()123     private native boolean nativeTestMediaFormatBuffer();
124 
125     @ApiTest(apis = {"AMediaFormat_getInt32", "AMediaFormat_setInt32",
126             "AMediaFormat_getInt64", "AMediaFormat_setInt64",
127             "AMediaFormat_getFloat", "AMediaFormat_setFloat",
128             "AMediaFormat_getDouble", "AMediaFormat_setDouble",
129             "AMediaFormat_getString", "AMediaFormat_setString",
130             "AMediaFormat_getSize", "AMediaFormat_setSize",
131             "AMediaFormat_getRect", "AMediaFormat_setRect",
132             "AMediaFormat_getBuffer", "AMediaFormat_setBuffer",
133             "AMediaFormat_copy", "AMediaFormat_clear", "AMediaFormat_toString",
134             "AMediaFormat_new", "AMediaFormat_delete"})
135     @Test
testMediaFormatNativeAll()136     public void testMediaFormatNativeAll() {
137         assertTrue(nativeTestMediaFormatAll());
138     }
139 
nativeTestMediaFormatAll()140     private native boolean nativeTestMediaFormatAll();
141 }
142