1 /*
2 * Copyright (c) 2022-2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include <gtest/gtest.h>
17 #include <osal_mem.h>
18 #include <securec.h>
19 #include <unistd.h>
20 #include "codec_callback_stub.h"
21 #include "hdf_log.h"
22 #include "icodec.h"
23 #include "share_mem.h"
24
25 #define HDF_LOG_TAG codec_hdi_uinttest
26
27 using namespace std;
28 using namespace testing::ext;
29
30 namespace {
31 constexpr const char *TEST_SERVICE_NAME = "codec_hdi_service";
32 constexpr const int TEST_PACKET_BUFFER_SIZE = 4096;
33 constexpr const int TEST_FRAME_BUFFER_SIZE = (640 * 480 * 3 / 2);
34 constexpr const uint32_t QUEUE_TIME_OUT = 10;
35 constexpr const int CAPABILITY_COUNT = 9;
36 constexpr int32_t INT_TO_STR_LEN = 32;
37 constexpr int32_t ARRAY_TO_STR_LEN = 1000;
38 constexpr int32_t VIDEO_WIDHT = 640;
39 constexpr int32_t VIDEO_HEIGHT = 480;
40 struct ICodec *g_codecObj = nullptr;
41 ShareMemory g_inputBuffer;
42 ShareMemory g_outputBuffer;
43 CodecBuffer *g_inputInfoData = nullptr;
44 CodecBuffer *g_outputInfoData = nullptr;
45 CODEC_HANDLETYPE g_handle = NULL;
46
47 typedef struct {
48 VideoCodecGopMode gopMode;
49 uint32_t gopLen;
50 int32_t gop;
51 int32_t viLen;
52 } HdiGopSetup;
53
54 class CodecProxyTest : public testing::Test {
55 public:
SetUpTestCase()56 static void SetUpTestCase() {}
TearDownTestCase()57 static void TearDownTestCase() {}
SetUp()58 void SetUp() {}
TearDown()59 void TearDown() {}
60 };
61
62 static char arrayStr[ARRAY_TO_STR_LEN];
GetArrayStr(int32_t * array,int32_t arrayLen,int32_t endValue)63 static char *GetArrayStr(int32_t *array, int32_t arrayLen, int32_t endValue)
64 {
65 int32_t len = 0;
66 int32_t totalLen = 0;
67 int32_t ret;
68 char value[INT_TO_STR_LEN];
69 ret = memset_s(arrayStr, sizeof(arrayStr), 0, sizeof(arrayStr));
70 if (ret != EOK) {
71 HDF_LOGE("%{public}s: memset_s arrayStr failed, error code: %{public}d", __func__, ret);
72 return arrayStr;
73 }
74 for (int32_t i = 0; i < arrayLen; i++) {
75 if (array[i] == endValue) {
76 break;
77 }
78 ret = memset_s(value, sizeof(value), 0, sizeof(value));
79 if (ret != EOK) {
80 HDF_LOGE("%{public}s: memset_s value failed, error code: %{public}d", __func__, ret);
81 return arrayStr;
82 }
83 ret = sprintf_s(value, sizeof(value) - 1, "0x0%X, ", array[i]);
84 if (ret < 0) {
85 HDF_LOGE("%{public}s: sprintf_s value failed, error code: %{public}d", __func__, ret);
86 return arrayStr;
87 }
88 len = strlen(value);
89 ret = memcpy_s(arrayStr + totalLen, len, value, len);
90 if (ret != EOK) {
91 HDF_LOGE("%{public}s: memcpy_s arrayStr failed, error code: %{public}d", __func__, ret);
92 return arrayStr;
93 }
94 totalLen += len;
95 }
96 return arrayStr;
97 }
98
PrintCapability(CodecCapability * cap,int index)99 static void PrintCapability(CodecCapability *cap, int index)
100 {
101 int32_t mime = 0;
102 if (cap == NULL) {
103 HDF_LOGE("null capability!");
104 return;
105 }
106 mime = (int32_t)cap->mime;
107 if (mime < 0) {
108 HDF_LOGE("print invalid capability!");
109 return;
110 }
111 HDF_LOGI("-------------------------- capability %{public}d ---------------------------", index + 1);
112 HDF_LOGI("mime:%{public}d", cap->mime);
113 HDF_LOGI("type:%{public}d", cap->type);
114 HDF_LOGI("name:%{public}s", cap->name);
115 HDF_LOGI("supportProfiles:%{public}s", GetArrayStr(cap->supportProfiles, PROFILE_NUM, INVALID_PROFILE));
116 HDF_LOGI("isSoftwareCodec:%{public}d", cap->isSoftwareCodec);
117 HDF_LOGI("processModeMask:0x0%{public}x", cap->processModeMask);
118 HDF_LOGI("capsMask:0x0%{public}x", cap->capsMask);
119 HDF_LOGI("allocateMask:0x0%{public}x", cap->allocateMask);
120 HDF_LOGI("inputBufferNum.min:%{public}d", cap->inputBufferNum.min);
121 HDF_LOGI("inputBufferNum.max:%{public}d", cap->inputBufferNum.max);
122 HDF_LOGI("outputBufferNum.min:%{public}d", cap->outputBufferNum.min);
123 HDF_LOGI("outputBufferNum.max:%{public}d", cap->outputBufferNum.max);
124 HDF_LOGI("bitRate.min:%{public}d", cap->bitRate.min);
125 HDF_LOGI("bitRate.max:%{public}d", cap->bitRate.max);
126 HDF_LOGI("inputBufferSize:%{public}d", cap->inputBufferSize);
127 HDF_LOGI("outputBufferSize:%{public}d", cap->outputBufferSize);
128 if (cap->mime < MEDIA_MIMETYPE_AUDIO_FIRST) {
129 HDF_LOGI("minSize.width:%{public}d", cap->port.video.minSize.width);
130 HDF_LOGI("minSize.height:%{public}d", cap->port.video.minSize.height);
131 HDF_LOGI("maxSize.width:%{public}d", cap->port.video.maxSize.width);
132 HDF_LOGI("maxSize.height:%{public}d", cap->port.video.maxSize.height);
133 HDF_LOGI("widthAlignment:%{public}d", cap->port.video.whAlignment.widthAlignment);
134 HDF_LOGI("heightAlignment:%{public}d", cap->port.video.whAlignment.heightAlignment);
135 HDF_LOGI("supportPixFmts:%{public}s", GetArrayStr(cap->port.video.supportPixFmts, PIX_FMT_NUM, 0));
136 } else {
137 HDF_LOGI(":%{public}s", GetArrayStr(cap->port.audio.sampleFormats, SAMPLE_FORMAT_NUM, 0));
138 HDF_LOGI(":%{public}s", GetArrayStr(cap->port.audio.sampleRate, SAMPLE_RATE_NUM, 0));
139 HDF_LOGI(":%{public}s", GetArrayStr(cap->port.audio.channelLayouts, CHANNEL_NUM, -1));
140 }
141 HDF_LOGI("-------------------------------------------------------------------");
142 }
143
144 HWTEST_F(CodecProxyTest, SUB_DriverSystem_CodecHdi_V1_0010, TestSize.Level1)
145 {
146 g_codecObj = HdiCodecGet(TEST_SERVICE_NAME);
147 ASSERT_TRUE(g_codecObj != nullptr);
148 }
149
150 HWTEST_F(CodecProxyTest, SUB_DriverSystem_CodecHdi_V1_0020, TestSize.Level1)
151 {
152 int32_t ret = HDF_SUCCESS;
153 for (int index = 0; index < CAPABILITY_COUNT; index++) {
154 CodecCapability cap;
155 ret = g_codecObj->CodecEnumerateCapability(g_codecObj, index, &cap);
156 ASSERT_EQ(ret, HDF_SUCCESS);
157 PrintCapability(&cap, index);
158 }
159 }
160
161 HWTEST_F(CodecProxyTest, SUB_DriverSystem_CodecHdi_V1_0030, TestSize.Level1)
162 {
163 CodecCapability cap;
164 int32_t ret = g_codecObj->CodecGetCapability(g_codecObj, MEDIA_MIMETYPE_IMAGE_JPEG, VIDEO_DECODER, 0, &cap);
165 ASSERT_EQ(ret, HDF_SUCCESS);
166 PrintCapability(&cap, 0);
167 }
168
169 HWTEST_F(CodecProxyTest, SUB_DriverSystem_CodecHdi_V1_0031, TestSize.Level1)
170 {
171 CodecCapability cap;
172 int32_t ret = g_codecObj->CodecGetCapability(g_codecObj, MEDIA_MIMETYPE_VIDEO_HEVC, VIDEO_DECODER, 0, &cap);
173 ASSERT_EQ(ret, HDF_SUCCESS);
174 PrintCapability(&cap, 0);
175 }
176
177 HWTEST_F(CodecProxyTest, SUB_DriverSystem_CodecHdi_V1_0032, TestSize.Level1)
178 {
179 CodecCapability cap;
180 int32_t ret = g_codecObj->CodecGetCapability(g_codecObj, MEDIA_MIMETYPE_VIDEO_AVC, VIDEO_DECODER, 0, &cap);
181 ASSERT_EQ(ret, HDF_SUCCESS);
182 PrintCapability(&cap, 0);
183 }
184
185 HWTEST_F(CodecProxyTest, SUB_DriverSystem_CodecHdi_V1_0040, TestSize.Level1)
186 {
187 ASSERT_TRUE(g_codecObj != nullptr);
188 int32_t errorCode = g_codecObj->CodecInit(g_codecObj);
189 ASSERT_EQ(errorCode, HDF_SUCCESS);
190 }
191
192 HWTEST_F(CodecProxyTest, SUB_DriverSystem_CodecHdi_V1_0050, TestSize.Level1)
193 {
194 const char* name = "codec.avc.hardware.encoder";
195 int32_t errorCode = g_codecObj->CodecCreate(g_codecObj, name, &g_handle);
196 ASSERT_EQ(errorCode, HDF_SUCCESS);
197 ASSERT_TRUE(g_handle != nullptr);
198 }
199
200 HWTEST_F(CodecProxyTest, SUB_DriverSystem_CodecHdi_V1_0060, TestSize.Level1)
201 {
202 CodecType type = VIDEO_DECODER;
203 AvCodecMime mime = MEDIA_MIMETYPE_VIDEO_AVC;
204 int32_t errorCode = g_codecObj->CodecCreateByType(g_codecObj, type, mime, &g_handle);
205 ASSERT_EQ(errorCode, HDF_ERR_NOT_SUPPORT);
206 }
207
208 HWTEST_F(CodecProxyTest, SUB_DriverSystem_CodecHdi_V1_0070, TestSize.Level1)
209 {
210 CodecType type = VIDEO_ENCODER;
211 AvCodecMime mime = MEDIA_MIMETYPE_VIDEO_AVC;
212 int32_t errorCode = g_codecObj->CodecCreateByType(g_codecObj, type, mime, &g_handle);
213 ASSERT_EQ(errorCode, HDF_ERR_NOT_SUPPORT);
214 }
215
216 HWTEST_F(CodecProxyTest, SUB_DriverSystem_CodecHdi_V1_0080, TestSize.Level1)
217 {
218 CodecType type = AUDIO_DECODER;
219 AvCodecMime mime = MEDIA_MIMETYPE_VIDEO_AVC;
220 int32_t errorCode = g_codecObj->CodecCreateByType(g_codecObj, type, mime, &g_handle);
221 ASSERT_EQ(errorCode, HDF_ERR_NOT_SUPPORT);
222 }
223
224 HWTEST_F(CodecProxyTest, SUB_DriverSystem_CodecHdi_V1_0090, TestSize.Level1)
225 {
226 AvCodecMime mime = MEDIA_MIMETYPE_VIDEO_AVC;
227 int32_t errorCode = g_codecObj->CodecCreateByType(g_codecObj, AUDIO_ENCODER, mime, &g_handle);
228 ASSERT_EQ(errorCode, HDF_ERR_NOT_SUPPORT);
229 }
230
231 HWTEST_F(CodecProxyTest, SUB_DriverSystem_CodecHdi_V1_0100, TestSize.Level1)
232 {
233 AvCodecMime mime = MEDIA_MIMETYPE_VIDEO_AVC;
234 int32_t errorCode = g_codecObj->CodecCreateByType(g_codecObj, INVALID_TYPE, mime, &g_handle);
235 ASSERT_EQ(errorCode, HDF_ERR_NOT_SUPPORT);
236 }
237
238 HWTEST_F(CodecProxyTest, SUB_DriverSystem_CodecHdi_V1_0110, TestSize.Level1)
239 {
240 DirectionType direct = OUTPUT_TYPE;
241 AllocateBufferMode mode = ALLOCATE_INPUT_BUFFER_CODEC_PRESET;
242 BufferType type = BUFFER_TYPE_FD;
243 int32_t errorCode = g_codecObj->CodecSetPortMode(g_codecObj, g_handle, direct, mode, type);
244 ASSERT_EQ(errorCode, HDF_ERR_NOT_SUPPORT);
245 }
246
247 HWTEST_F(CodecProxyTest, SUB_DriverSystem_CodecHdi_V1_0120, TestSize.Level1)
248 {
249 DirectionType direct = OUTPUT_TYPE;
250 AllocateBufferMode mode;
251 BufferType type;
252 int32_t errorCode = g_codecObj->CodecGetPortMode(g_codecObj, g_handle, direct, &mode, &type);
253 ASSERT_EQ(errorCode, HDF_ERR_NOT_SUPPORT);
254 }
255
256 HWTEST_F(CodecProxyTest, SUB_DriverSystem_CodecHdi_V1_0130, TestSize.Level1)
257 {
258 Param *params;
259 int paramCnt = 1;
260 params = (Param *)OsalMemAlloc(sizeof(Param)*paramCnt);
261 ASSERT_TRUE(params != nullptr);
262 params->key = KEY_VIDEO_WIDTH;
263 int32_t width = VIDEO_WIDHT;
264 params->val = (void *)&width;
265 params->size = sizeof(width);
266
267 int32_t errorCode = g_codecObj->CodecSetParameter(g_codecObj, g_handle, params, paramCnt);
268 OsalMemFree(params);
269 ASSERT_EQ(errorCode, HDF_SUCCESS);
270 }
271
272 HWTEST_F(CodecProxyTest, SUB_DriverSystem_CodecHdi_V1_0131, TestSize.Level1)
273 {
274 Param *params;
275 int paramCnt = 1;
276 params = (Param *)OsalMemAlloc(sizeof(Param)*paramCnt);
277 ASSERT_TRUE(params != nullptr);
278 params->key = KEY_VIDEO_HEIGHT;
279 int32_t height = VIDEO_HEIGHT;
280 params->val = (void *)&height;
281 params->size = sizeof(height);
282
283 int32_t errorCode = g_codecObj->CodecSetParameter(g_codecObj, g_handle, params, paramCnt);
284 OsalMemFree(params);
285 ASSERT_EQ(errorCode, HDF_SUCCESS);
286 }
287
288 HWTEST_F(CodecProxyTest, SUB_DriverSystem_CodecHdi_V1_0132, TestSize.Level1)
289 {
290 Param *params;
291 int paramCnt = 1;
292 params = (Param *)OsalMemAlloc(sizeof(Param)*paramCnt);
293 ASSERT_TRUE(params != nullptr);
294 params->key = KEY_CODEC_TYPE;
295 CodecType type = VIDEO_DECODER;
296 params->val = (void *)&type;
297 params->size = sizeof(type);
298
299 int32_t errorCode = g_codecObj->CodecSetParameter(g_codecObj, g_handle, params, paramCnt);
300 OsalMemFree(params);
301 ASSERT_EQ(errorCode, HDF_SUCCESS);
302 }
303
304 HWTEST_F(CodecProxyTest, SUB_DriverSystem_CodecHdi_V1_0133, TestSize.Level1)
305 {
306 Param *params;
307 int paramCnt = 1;
308 params = (Param *)OsalMemAlloc(sizeof(Param)*paramCnt);
309 ASSERT_TRUE(params != nullptr);
310 HdiGopSetup gop;
311 gop.gopMode = VID_CODEC_GOPMODE_NORMALP;
312 gop.gopLen = 0;
313 gop.viLen = 0;
314 gop.gop = 48;
315 params->key = KEY_VIDEO_GOP_MODE;
316 params->val = (void *)&gop;
317 params->size = sizeof(gop);
318
319 int32_t errorCode = g_codecObj->CodecSetParameter(g_codecObj, g_handle, params, paramCnt);
320 OsalMemFree(params);
321 ASSERT_EQ(errorCode, HDF_SUCCESS);
322 }
323
324 HWTEST_F(CodecProxyTest, SUB_DriverSystem_CodecHdi_V1_0134, TestSize.Level1)
325 {
326 Param *params;
327 int paramCnt = 1;
328 params = (Param *)OsalMemAlloc(sizeof(Param)*paramCnt);
329 ASSERT_TRUE(params != nullptr);
330 params->key = KEY_MIMETYPE;
331 AvCodecMime mime = MEDIA_MIMETYPE_IMAGE_JPEG;
332 params->val = (void *)&mime;
333 params->size = sizeof(mime);
334
335 int32_t errorCode = g_codecObj->CodecSetParameter(g_codecObj, g_handle, params, paramCnt);
336 OsalMemFree(params);
337 ASSERT_EQ(errorCode, HDF_SUCCESS);
338 }
339
340 HWTEST_F(CodecProxyTest, SUB_DriverSystem_CodecHdi_V1_0135, TestSize.Level1)
341 {
342 Param *params;
343 int paramCnt = 1;
344 params = (Param *)OsalMemAlloc(sizeof(Param)*paramCnt);
345 ASSERT_TRUE(params != nullptr);
346 params->key = KEY_PIXEL_FORMAT;
347 PixelFormat format = PIXEL_FMT_YCBCR_420_SP;
348 params->val = (void *)&format;
349 params->size = sizeof(format);
350
351 int32_t errorCode = g_codecObj->CodecSetParameter(g_codecObj, g_handle, params, paramCnt);
352 OsalMemFree(params);
353 ASSERT_EQ(errorCode, HDF_SUCCESS);
354 }
355
356 HWTEST_F(CodecProxyTest, SUB_DriverSystem_CodecHdi_V1_0150, TestSize.Level1)
357 {
358 g_inputBuffer.id = 0;
359 g_inputBuffer.size = TEST_PACKET_BUFFER_SIZE;
360 int32_t ret = CreateFdShareMemory(&g_inputBuffer);
361 ASSERT_EQ(ret, HDF_SUCCESS);
362
363 g_inputInfoData = (CodecBuffer *)OsalMemAlloc(sizeof(CodecBuffer) + sizeof(CodecBufferInfo) * 1);
364 g_inputInfoData->bufferId = 0;
365 g_inputInfoData->bufferCnt = 1;
366 g_inputInfoData->flag = 1;
367 g_inputInfoData->timeStamp = 1;
368 g_inputInfoData->buffer[0].type = BUFFER_TYPE_FD;
369 g_inputInfoData->buffer[0].offset = 1;
370 g_inputInfoData->buffer[0].length = 1;
371 g_inputInfoData->buffer[0].capacity = TEST_PACKET_BUFFER_SIZE;
372 g_inputInfoData->buffer[0].buf = (intptr_t)g_inputBuffer.fd;
373
374 int32_t errorCode = g_codecObj->CodecQueueInput(g_codecObj,
375 g_handle, g_inputInfoData, (uint32_t)QUEUE_TIME_OUT, -1);
376 ASSERT_EQ(errorCode, HDF_SUCCESS);
377 }
378
379 HWTEST_F(CodecProxyTest, SUB_DriverSystem_CodecHdi_V1_0160, TestSize.Level1)
380 {
381 int32_t acquireFd;
382 CodecBuffer *inputInfo = (CodecBuffer *)OsalMemAlloc(sizeof(CodecBuffer) + sizeof(CodecBufferInfo) * 1);
383 inputInfo->bufferCnt = 1;
384
385 int32_t errorCode = g_codecObj->CodecDequeueInput(g_codecObj, g_handle, QUEUE_TIME_OUT, &acquireFd, inputInfo);
386 ASSERT_EQ(errorCode, HDF_SUCCESS);
387 ASSERT_EQ(inputInfo->bufferId, g_inputInfoData->bufferId);
388 ASSERT_EQ(inputInfo->bufferCnt, g_inputInfoData->bufferCnt);
389 ASSERT_EQ(inputInfo->buffer[0].type, g_inputInfoData->buffer[0].type);
390 ASSERT_EQ(inputInfo->buffer[0].offset, g_inputInfoData->buffer[0].offset);
391 ASSERT_EQ(inputInfo->buffer[0].length, g_inputInfoData->buffer[0].length);
392 ASSERT_EQ(inputInfo->buffer[0].capacity, g_inputInfoData->buffer[0].capacity);
393 OsalMemFree(inputInfo);
394 OsalMemFree(g_inputInfoData);
395 }
396
397 HWTEST_F(CodecProxyTest, SUB_DriverSystem_CodecHdi_V1_0170, TestSize.Level1)
398 {
399 int32_t errorCode = g_codecObj->CodecStart(g_codecObj, g_handle);
400 ASSERT_EQ(errorCode, HDF_SUCCESS);
401 }
402
403 HWTEST_F(CodecProxyTest, SUB_DriverSystem_CodecHdi_V1_0180, TestSize.Level1)
404 {
405 int32_t errorCode = g_codecObj->CodecStop(g_codecObj, g_handle);
406 ASSERT_EQ(errorCode, HDF_SUCCESS);
407 }
408
409 HWTEST_F(CodecProxyTest, SUB_DriverSystem_CodecHdi_V1_0190, TestSize.Level1)
410 {
411 int32_t errorCode = g_codecObj->CodecReset(g_codecObj, g_handle);
412 ASSERT_EQ(errorCode, HDF_ERR_NOT_SUPPORT);
413 }
414
415 HWTEST_F(CodecProxyTest, SUB_DriverSystem_CodecHdi_V1_0200, TestSize.Level1)
416 {
417 g_outputBuffer.id = 1;
418 g_outputBuffer.size = TEST_FRAME_BUFFER_SIZE;
419 int32_t ret = CreateFdShareMemory(&g_outputBuffer);
420 ASSERT_EQ(ret, HDF_SUCCESS);
421
422 g_outputInfoData = (CodecBuffer *)OsalMemAlloc(sizeof(CodecBuffer) + sizeof(CodecBufferInfo) * 1);
423 g_outputInfoData->bufferId = 1;
424 g_outputInfoData->bufferCnt = 1;
425 g_outputInfoData->flag = 1;
426 g_outputInfoData->timeStamp = 1;
427 g_outputInfoData->buffer[0].type = BUFFER_TYPE_FD;
428 g_outputInfoData->buffer[0].offset = 1;
429 g_outputInfoData->buffer[0].length = 1;
430 g_outputInfoData->buffer[0].capacity = TEST_FRAME_BUFFER_SIZE;
431 g_outputInfoData->buffer[0].buf = (intptr_t)g_outputBuffer.fd;
432
433 int32_t errorCode = g_codecObj->CodecQueueOutput(g_codecObj, g_handle, g_outputInfoData, (uint32_t)0, -1);
434 ASSERT_EQ(errorCode, HDF_SUCCESS);
435 }
436
437 HWTEST_F(CodecProxyTest, SUB_DriverSystem_CodecHdi_V1_0210, TestSize.Level1)
438 {
439 int32_t errorCode = 0;
440 int32_t acquireFd;
441 CodecBuffer *outInfo = (CodecBuffer *)OsalMemAlloc(sizeof(CodecBuffer) + sizeof(CodecBufferInfo) * 1);
442 outInfo->bufferCnt = 1;
443
444 errorCode = g_codecObj->CodecDequeueOutput(g_codecObj, g_handle, QUEUE_TIME_OUT, &acquireFd, outInfo);
445 ASSERT_EQ(errorCode, HDF_SUCCESS);
446 ASSERT_EQ(outInfo->bufferId, g_outputInfoData->bufferId);
447 ASSERT_EQ(outInfo->bufferCnt, g_outputInfoData->bufferCnt);
448 ASSERT_EQ(outInfo->buffer[0].type, g_outputInfoData->buffer[0].type);
449 ASSERT_EQ(outInfo->buffer[0].offset, g_outputInfoData->buffer[0].offset);
450 ASSERT_EQ(outInfo->buffer[0].length, g_outputInfoData->buffer[0].length);
451 ASSERT_EQ(outInfo->buffer[0].capacity, g_outputInfoData->buffer[0].capacity);
452 OsalMemFree(outInfo);
453 OsalMemFree(g_outputInfoData);
454 }
455
456 HWTEST_F(CodecProxyTest, SUB_DriverSystem_CodecHdi_V1_0220, TestSize.Level1)
457 {
458 DirectionType directType = OUTPUT_TYPE;
459
460 int32_t errorCode = g_codecObj->CodecFlush(g_codecObj, g_handle, directType);
461 ASSERT_EQ(errorCode, HDF_SUCCESS);
462 ASSERT_EQ(directType, OUTPUT_TYPE);
463 }
464
465 HWTEST_F(CodecProxyTest, SUB_DriverSystem_CodecHdi_V1_0221, TestSize.Level1)
466 {
467 DirectionType directType = INPUT_TYPE;
468
469 int32_t errorCode = g_codecObj->CodecFlush(g_codecObj, g_handle, directType);
470 ASSERT_EQ(errorCode, HDF_SUCCESS);
471 ASSERT_EQ(directType, INPUT_TYPE);
472 }
473
474 HWTEST_F(CodecProxyTest, SUB_DriverSystem_CodecHdi_V1_0222, TestSize.Level1)
475 {
476 DirectionType directType = ALL_TYPE;
477
478 int32_t errorCode = g_codecObj->CodecFlush(g_codecObj, g_handle, directType);
479 ASSERT_EQ(errorCode, HDF_SUCCESS);
480 ASSERT_EQ(directType, ALL_TYPE);
481 }
482
483 HWTEST_F(CodecProxyTest, SUB_DriverSystem_CodecHdi_V1_0230, TestSize.Level1)
484 {
485 UINTPTR instance = 0;
486 CodecCallback callback;
487 struct CodecCallbackStub *stub = CodecCallbackStubObtain(&callback);
488 ASSERT_TRUE(stub != nullptr);
489
490 int32_t errorCode = g_codecObj->CodecSetCallback(g_codecObj, g_handle, &stub->service, instance);
491 ASSERT_EQ(errorCode, HDF_SUCCESS);
492 }
493
494 HWTEST_F(CodecProxyTest, SUB_DriverSystem_CodecHdi_V1_0240, TestSize.Level1)
495 {
496 int32_t errorCode = g_codecObj->CodecDestroy(g_codecObj, g_handle);
497 ASSERT_EQ(errorCode, HDF_SUCCESS);
498 }
499
500 HWTEST_F(CodecProxyTest, SUB_DriverSystem_CodecHdi_V1_0250, TestSize.Level1)
501 {
502 int32_t errorCode = g_codecObj->CodecDeinit(g_codecObj);
503 ASSERT_EQ(errorCode, HDF_SUCCESS);
504 HdiCodecRelease(g_codecObj);
505 }
506 }
507