1 /*
2 * Copyright (c) 2022 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 "hdi_mpp_ext_param_keys.h"
23 #include "icodec.h"
24 #include "share_mem.h"
25
26 #define HDF_LOG_TAG codec_hdi_uinttest
27
28 using namespace std;
29 using namespace testing::ext;
30
31 namespace {
32 constexpr const char *TEST_SERVICE_NAME = "codec_hdi_service";
33 constexpr const int TEST_PACKET_BUFFER_SIZE = 4096;
34 constexpr const int TEST_FRAME_BUFFER_SIZE = 640 * 480 * 3 / 2;
35 constexpr const uint32_t QUEUE_TIME_OUT = 10;
36 constexpr const int CAPABILITY_COUNT = 9;
37 constexpr int32_t INT_TO_STR_LEN = 32;
38 constexpr int32_t ARRAY_TO_STR_LEN = 1000;
39 struct ICodec *g_codecObj = nullptr;
40 ShareMemory g_inputBuffer;
41 ShareMemory g_outputBuffer;
42 CodecBuffer *g_inputInfoData = nullptr;
43 CodecBuffer *g_outputInfoData = nullptr;
44 CODEC_HANDLETYPE g_handle = NULL;
45
46 class CodecProxyTest : public testing::Test {
47 public:
SetUpTestCase()48 static void SetUpTestCase() {}
TearDownTestCase()49 static void TearDownTestCase() {}
SetUp()50 void SetUp() {}
TearDown()51 void TearDown() {}
52 };
53
54 static char arrayStr[ARRAY_TO_STR_LEN];
GetArrayStr(int32_t * array,int32_t arrayLen,int32_t endValue)55 static char *GetArrayStr(int32_t *array, int32_t arrayLen, int32_t endValue)
56 {
57 int32_t len = 0;
58 int32_t totalLen = 0;
59 int32_t ret;
60 char value[INT_TO_STR_LEN];
61 ret = memset_s(arrayStr, sizeof(arrayStr), 0, sizeof(arrayStr));
62 if (ret != EOK) {
63 HDF_LOGE("%{public}s: memset_s arrayStr failed, error code: %{public}d", __func__, ret);
64 return arrayStr;
65 }
66 for (int32_t i = 0; i < arrayLen; i++) {
67 if (array[i] == endValue) {
68 break;
69 }
70 ret = memset_s(value, sizeof(value), 0, sizeof(value));
71 if (ret != EOK) {
72 HDF_LOGE("%{public}s: memset_s value failed, error code: %{public}d", __func__, ret);
73 return arrayStr;
74 }
75 ret = sprintf_s(value, sizeof(value) - 1, "0x0%X, ", array[i]);
76 if (ret < 0) {
77 HDF_LOGE("%{public}s: sprintf_s value failed, error code: %{public}d", __func__, ret);
78 return arrayStr;
79 }
80 len = strlen(value);
81 ret = memcpy_s(arrayStr + totalLen, len, value, len);
82 if (ret != EOK) {
83 HDF_LOGE("%{public}s: memcpy_s arrayStr failed, error code: %{public}d", __func__, ret);
84 return arrayStr;
85 }
86 totalLen += len;
87 }
88 return arrayStr;
89 }
90
PrintCapability(CodecCapability * cap,int index)91 static void PrintCapability(CodecCapability *cap, int index)
92 {
93 int32_t mime = 0;
94 if (cap == NULL) {
95 HDF_LOGE("null capability!");
96 return;
97 }
98 mime = (int32_t)cap->mime;
99 if (mime < 0) {
100 HDF_LOGE("print invalid capability!");
101 return;
102 }
103 HDF_LOGI("-------------------------- capability %{public}d ---------------------------", index + 1);
104 HDF_LOGI("mime:%{public}d", cap->mime);
105 HDF_LOGI("type:%{public}d", cap->type);
106 HDF_LOGI("name:%{public}s", cap->name);
107 HDF_LOGI("supportProfiles:%{public}s", GetArrayStr(cap->supportProfiles, PROFILE_NUM, INVALID_PROFILE));
108 HDF_LOGI("isSoftwareCodec:%{public}d", cap->isSoftwareCodec);
109 HDF_LOGI("processModeMask:0x0%{public}x", cap->processModeMask);
110 HDF_LOGI("capsMask:0x0%{public}x", cap->capsMask);
111 HDF_LOGI("allocateMask:0x0%{public}x", cap->allocateMask);
112 HDF_LOGI("inputBufferNum.min:%{public}d", cap->inputBufferNum.min);
113 HDF_LOGI("inputBufferNum.max:%{public}d", cap->inputBufferNum.max);
114 HDF_LOGI("outputBufferNum.min:%{public}d", cap->outputBufferNum.min);
115 HDF_LOGI("outputBufferNum.max:%{public}d", cap->outputBufferNum.max);
116 HDF_LOGI("bitRate.min:%{public}d", cap->bitRate.min);
117 HDF_LOGI("bitRate.max:%{public}d", cap->bitRate.max);
118 HDF_LOGI("inputBufferSize:%{public}d", cap->inputBufferSize);
119 HDF_LOGI("outputBufferSize:%{public}d", cap->outputBufferSize);
120 if (cap->mime < MEDIA_MIMETYPE_AUDIO_FIRST) {
121 HDF_LOGI("minSize.width:%{public}d", cap->port.video.minSize.width);
122 HDF_LOGI("minSize.height:%{public}d", cap->port.video.minSize.height);
123 HDF_LOGI("maxSize.width:%{public}d", cap->port.video.maxSize.width);
124 HDF_LOGI("maxSize.height:%{public}d", cap->port.video.maxSize.height);
125 HDF_LOGI("widthAlignment:%{public}d", cap->port.video.whAlignment.widthAlignment);
126 HDF_LOGI("heightAlignment:%{public}d", cap->port.video.whAlignment.heightAlignment);
127 HDF_LOGI("supportPixFmts:%{public}s", GetArrayStr(cap->port.video.supportPixFmts, PIX_FMT_NUM, 0));
128 } else {
129 HDF_LOGI(":%{public}s", GetArrayStr(cap->port.audio.sampleFormats, SAMPLE_FORMAT_NUM, 0));
130 HDF_LOGI(":%{public}s", GetArrayStr(cap->port.audio.sampleRate, SAMPLE_RATE_NUM, 0));
131 HDF_LOGI(":%{public}s", GetArrayStr(cap->port.audio.channelLayouts, CHANNEL_NUM, -1));
132 }
133 HDF_LOGI("-------------------------------------------------------------------");
134 }
135
136 HWTEST_F(CodecProxyTest, HdfCodecHdiV1GetCodecObjTest_001, TestSize.Level1)
137 {
138 g_codecObj = HdiCodecGet(TEST_SERVICE_NAME);
139 ASSERT_TRUE(g_codecObj != nullptr);
140 }
141
142 HWTEST_F(CodecProxyTest, HdfCodecHdiV1EnumerateCapabilityTest_001, TestSize.Level1)
143 {
144 int32_t ret = HDF_SUCCESS;
145 for (int index = 0; index < CAPABILITY_COUNT; index++) {
146 CodecCapability cap;
147 ret = g_codecObj->CodecEnumerateCapability(g_codecObj, index, &cap);
148 ASSERT_EQ(ret, HDF_SUCCESS);
149 PrintCapability(&cap, index);
150 }
151 }
152
153 HWTEST_F(CodecProxyTest, HdfCodecHdiV1GetCapabilityTest_001, TestSize.Level1)
154 {
155 CodecCapability cap;
156 int32_t ret = g_codecObj->CodecGetCapability(g_codecObj, MEDIA_MIMETYPE_IMAGE_JPEG, VIDEO_DECODER, 0, &cap);
157 ASSERT_EQ(ret, HDF_SUCCESS);
158 PrintCapability(&cap, 0);
159 }
160
161 HWTEST_F(CodecProxyTest, HdfCodecHdiV1GetCapabilityTest_002, TestSize.Level1)
162 {
163 CodecCapability cap;
164 int32_t ret = g_codecObj->CodecGetCapability(g_codecObj, MEDIA_MIMETYPE_VIDEO_HEVC, VIDEO_DECODER, 0, &cap);
165 ASSERT_EQ(ret, HDF_SUCCESS);
166 PrintCapability(&cap, 0);
167 }
168
169 HWTEST_F(CodecProxyTest, HdfCodecHdiV1GetCapabilityTest_003, TestSize.Level1)
170 {
171 CodecCapability cap;
172 int32_t ret = g_codecObj->CodecGetCapability(g_codecObj, MEDIA_MIMETYPE_VIDEO_AVC, VIDEO_DECODER, 0, &cap);
173 ASSERT_EQ(ret, HDF_SUCCESS);
174 PrintCapability(&cap, 0);
175 }
176
177 HWTEST_F(CodecProxyTest, HdfCodecHdiV1InitCodecTest_001, TestSize.Level1)
178 {
179 ASSERT_TRUE(g_codecObj != nullptr);
180 int32_t errorCode = g_codecObj->CodecInit(g_codecObj);
181 ASSERT_EQ(errorCode, HDF_SUCCESS);
182 }
183
184 HWTEST_F(CodecProxyTest, HdfCodecHdiV1CreateCodecTest_001, TestSize.Level1)
185 {
186 const char* name = "codec.avc.hardware.decoder";
187 int32_t errorCode = g_codecObj->CodecCreate(g_codecObj, name, &g_handle);
188 ASSERT_EQ(errorCode, HDF_SUCCESS);
189 ASSERT_TRUE(g_handle != nullptr);
190 }
191
192 HWTEST_F(CodecProxyTest, HdfCodecHdiV1CreateCodecByTypeTest_001, TestSize.Level1)
193 {
194 CodecType type = VIDEO_DECODER;
195 AvCodecMime mime = MEDIA_MIMETYPE_VIDEO_AVC;
196 int32_t errorCode = g_codecObj->CodecCreateByType(g_codecObj, type, mime, &g_handle);
197 ASSERT_EQ(errorCode, HDF_ERR_NOT_SUPPORT);
198 }
199
200 HWTEST_F(CodecProxyTest, HdfCodecHdiV1SetPortModeTest_001, TestSize.Level1)
201 {
202 DirectionType direct = OUTPUT_TYPE;
203 AllocateBufferMode mode = ALLOCATE_INPUT_BUFFER_CODEC_PRESET;
204 BufferType type = BUFFER_TYPE_FD;
205 int32_t errorCode = g_codecObj->CodecSetPortMode(g_codecObj, g_handle, direct, mode, type);
206 ASSERT_EQ(errorCode, HDF_ERR_NOT_SUPPORT);
207 }
208
209 HWTEST_F(CodecProxyTest, HdfCodecHdiV1GetPortModeTest_001, TestSize.Level1)
210 {
211 DirectionType direct = OUTPUT_TYPE;
212 AllocateBufferMode mode;
213 BufferType type;
214 int32_t errorCode = g_codecObj->CodecGetPortMode(g_codecObj, g_handle, direct, &mode, &type);
215 ASSERT_EQ(errorCode, HDF_ERR_NOT_SUPPORT);
216 }
217
218 HWTEST_F(CodecProxyTest, HdfCodecHdiV1SetCodecTypeTest_001, TestSize.Level1)
219 {
220 Param *params;
221 int paramCnt = 1;
222 params = (Param *)OsalMemAlloc(sizeof(Param)*paramCnt);
223 ASSERT_TRUE(params != nullptr);
224 params->key = KEY_CODEC_TYPE;
225 CodecType type = VIDEO_DECODER;
226 params->val = (void *)&type;
227 params->size = sizeof(type);
228
229 int32_t errorCode = g_codecObj->CodecSetParameter(g_codecObj, g_handle, params, paramCnt);
230 OsalMemFree(params);
231 ASSERT_EQ(errorCode, HDF_SUCCESS);
232 }
233
234 HWTEST_F(CodecProxyTest, HdfCodecHdiV1SetGopModeTest_001, TestSize.Level1)
235 {
236 Param *params;
237 int paramCnt = 1;
238 params = (Param *)OsalMemAlloc(sizeof(Param)*paramCnt);
239 ASSERT_TRUE(params != nullptr);
240 params->key = KEY_VIDEO_GOP_MODE;
241 VideoCodecGopMode mode = VID_CODEC_GOPMODE_NORMALP;
242 params->val = (void *)&mode;
243 params->size = sizeof(mode);
244
245 int32_t errorCode = g_codecObj->CodecSetParameter(g_codecObj, g_handle, params, paramCnt);
246 OsalMemFree(params);
247 ASSERT_EQ(errorCode, HDF_SUCCESS);
248 }
249
250 HWTEST_F(CodecProxyTest, HdfCodecHdiV1SetMimeTypeTest_001, TestSize.Level1)
251 {
252 Param *params;
253 int paramCnt = 1;
254 params = (Param *)OsalMemAlloc(sizeof(Param)*paramCnt);
255 ASSERT_TRUE(params != nullptr);
256 params->key = KEY_MIMETYPE;
257 AvCodecMime mime = MEDIA_MIMETYPE_IMAGE_JPEG;
258 params->val = (void *)&mime;
259 params->size = sizeof(mime);
260
261 int32_t errorCode = g_codecObj->CodecSetParameter(g_codecObj, g_handle, params, paramCnt);
262 OsalMemFree(params);
263 ASSERT_EQ(errorCode, HDF_SUCCESS);
264 }
265
266 HWTEST_F(CodecProxyTest, HdfCodecHdiV1SetPixelFormatTest_001, TestSize.Level1)
267 {
268 Param *params;
269 int paramCnt = 1;
270 params = (Param *)OsalMemAlloc(sizeof(Param)*paramCnt);
271 ASSERT_TRUE(params != nullptr);
272 params->key = KEY_PIXEL_FORMAT;
273 CodecPixelFormat format = PIXEL_FORMAT_YUV_422_I;
274 params->val = (void *)&format;
275 params->size = sizeof(format);
276
277 int32_t errorCode = g_codecObj->CodecSetParameter(g_codecObj, g_handle, params, paramCnt);
278 OsalMemFree(params);
279 ASSERT_EQ(errorCode, HDF_SUCCESS);
280 }
281
282 HWTEST_F(CodecProxyTest, HdfCodecHdiV1GetDefaultCfgTest_001, TestSize.Level1)
283 {
284 Param *params;
285 int paramCnt = 1;
286 params = (Param *)OsalMemAlloc(sizeof(Param)*paramCnt);
287 ASSERT_TRUE(params != nullptr);
288 params->key = (ParamKey)ParamExtKey::KEY_EXT_DEFAULT_CFG_RK;
289 params->val = nullptr;
290 params->size = 0;
291
292 int32_t errorCode = g_codecObj->CodecGetParameter(g_codecObj, g_handle, params, paramCnt);
293 OsalMemFree(params);
294 ASSERT_EQ(errorCode, HDF_SUCCESS);
295 }
296
297 HWTEST_F(CodecProxyTest, HdfCodecHdiV1SetSplitModeTest_001, TestSize.Level1)
298 {
299 Param *params;
300 int paramCnt = 1;
301 params = (Param *)OsalMemAlloc(sizeof(Param)*paramCnt);
302 ASSERT_TRUE(params != nullptr);
303 params->key = (ParamKey)ParamExtKey::KEY_EXT_SPLIT_PARSE_RK;
304 int32_t needSplit = 1;
305 params->val = (void *)&needSplit;
306 params->size = sizeof(needSplit);
307
308 int32_t errorCode = g_codecObj->CodecSetParameter(g_codecObj, g_handle, params, paramCnt);
309 OsalMemFree(params);
310 ASSERT_EQ(errorCode, HDF_SUCCESS);
311 }
312
313 HWTEST_F(CodecProxyTest, HdfCodecHdiV1GetSplitParseTest_001, TestSize.Level1)
314 {
315 Param *params;
316 int paramCnt = 1;
317 params = (Param *)OsalMemAlloc(sizeof(Param)*paramCnt);
318 ASSERT_TRUE(params != nullptr);
319 params->key = (ParamKey)ParamExtKey::KEY_EXT_SPLIT_PARSE_RK;
320 params->val = nullptr;
321 params->size = 0;
322
323 int32_t errorCode = g_codecObj->CodecGetParameter(g_codecObj, g_handle, params, paramCnt);
324 OsalMemFree(params);
325 ASSERT_EQ(errorCode, HDF_SUCCESS);
326 }
327
328 HWTEST_F(CodecProxyTest, HdfCodecHdiV1SetDecFrameNumTest_001, TestSize.Level1)
329 {
330 Param *params;
331 int paramCnt = 1;
332 params = (Param *)OsalMemAlloc(sizeof(Param)*paramCnt);
333 ASSERT_TRUE(params != nullptr);
334 params->key = (ParamKey)ParamExtKey::KEY_EXT_DEC_FRAME_NUM_RK;
335 int32_t frameNum = 1;
336 params->val = (void *)&frameNum;
337 params->size = sizeof(frameNum);
338
339 int32_t errorCode = g_codecObj->CodecSetParameter(g_codecObj, g_handle, params, paramCnt);
340 OsalMemFree(params);
341 ASSERT_EQ(errorCode, HDF_SUCCESS);
342 }
343
344 HWTEST_F(CodecProxyTest, HdfCodecHdiV1GetDecFrameTest_001, TestSize.Level1)
345 {
346 Param *params;
347 int paramCnt = 1;
348 params = (Param *)OsalMemAlloc(sizeof(Param)*paramCnt);
349 ASSERT_TRUE(params != nullptr);
350 params->key = (ParamKey)ParamExtKey::KEY_EXT_DEC_FRAME_NUM_RK;
351 params->val = nullptr;
352 params->size = 0;
353
354 int32_t errorCode = g_codecObj->CodecGetParameter(g_codecObj, g_handle, params, paramCnt);
355 OsalMemFree(params);
356 ASSERT_EQ(errorCode, HDF_SUCCESS);
357 }
358
359
360 HWTEST_F(CodecProxyTest, HdfCodecHdiV1QueueInputTest_001, TestSize.Level1)
361 {
362 g_inputBuffer.id = 0;
363 g_inputBuffer.size = TEST_PACKET_BUFFER_SIZE;
364 int32_t ret = CreateFdShareMemory(&g_inputBuffer);
365 ASSERT_EQ(ret, HDF_SUCCESS);
366
367 g_inputInfoData = (CodecBuffer *)OsalMemAlloc(sizeof(CodecBuffer) + sizeof(CodecBufferInfo) * 1);
368 g_inputInfoData->bufferId = 0;
369 g_inputInfoData->bufferCnt = 1;
370 g_inputInfoData->flag = 1;
371 g_inputInfoData->timeStamp = 1;
372 g_inputInfoData->buffer[0].type = BUFFER_TYPE_FD;
373 g_inputInfoData->buffer[0].offset = 1;
374 g_inputInfoData->buffer[0].length = 1;
375 g_inputInfoData->buffer[0].capacity = TEST_PACKET_BUFFER_SIZE;
376 g_inputInfoData->buffer[0].buf = (intptr_t)g_inputBuffer.fd;
377
378 int32_t errorCode = g_codecObj->CodecQueueInput(g_codecObj, g_handle, g_inputInfoData,
379 (uint32_t)QUEUE_TIME_OUT, -1);
380 ASSERT_EQ(errorCode, HDF_SUCCESS);
381 }
382
383 HWTEST_F(CodecProxyTest, HdfCodecHdiV1DequeInputTest_001, TestSize.Level1)
384 {
385 int32_t acquireFd;
386 CodecBuffer *inputInfo = (CodecBuffer *)OsalMemAlloc(sizeof(CodecBuffer) + sizeof(CodecBufferInfo) * 1);
387 inputInfo->bufferCnt = 1;
388
389 int32_t errorCode = g_codecObj->CodecDequeueInput(g_codecObj, g_handle, QUEUE_TIME_OUT, &acquireFd, inputInfo);
390 ASSERT_EQ(errorCode, HDF_SUCCESS);
391 ASSERT_EQ(inputInfo->bufferId, g_inputInfoData->bufferId);
392 ASSERT_EQ(inputInfo->bufferCnt, g_inputInfoData->bufferCnt);
393 ASSERT_EQ(inputInfo->buffer[0].type, g_inputInfoData->buffer[0].type);
394 ASSERT_EQ(inputInfo->buffer[0].offset, g_inputInfoData->buffer[0].offset);
395 ASSERT_EQ(inputInfo->buffer[0].length, g_inputInfoData->buffer[0].length);
396 ASSERT_EQ(inputInfo->buffer[0].capacity, g_inputInfoData->buffer[0].capacity);
397 OsalMemFree(inputInfo);
398 OsalMemFree(g_inputInfoData);
399 }
400
401 HWTEST_F(CodecProxyTest, HdfCodecHdiV1StartCodecTest_001, TestSize.Level1)
402 {
403 int32_t errorCode = g_codecObj->CodecStart(g_codecObj, g_handle);
404 ASSERT_EQ(errorCode, HDF_SUCCESS);
405 }
406
407 HWTEST_F(CodecProxyTest, HdfCodecHdiV1StopCodecTest_001, TestSize.Level1)
408 {
409 int32_t errorCode = g_codecObj->CodecStop(g_codecObj, g_handle);
410 ASSERT_EQ(errorCode, HDF_SUCCESS);
411 }
412
413 HWTEST_F(CodecProxyTest, HdfCodecHdiV1ResetCodecTest_001, TestSize.Level1)
414 {
415 int32_t errorCode = g_codecObj->CodecReset(g_codecObj, g_handle);
416 ASSERT_EQ(errorCode, HDF_ERR_NOT_SUPPORT);
417 }
418
419 HWTEST_F(CodecProxyTest, HdfCodecHdiV1QueueOutputTest_001, TestSize.Level1)
420 {
421 g_outputBuffer.id = 1;
422 g_outputBuffer.size = TEST_FRAME_BUFFER_SIZE;
423 int32_t ret = CreateFdShareMemory(&g_outputBuffer);
424 ASSERT_EQ(ret, HDF_SUCCESS);
425
426 g_outputInfoData = (CodecBuffer *)OsalMemAlloc(sizeof(CodecBuffer) + sizeof(CodecBufferInfo) * 1);
427 g_outputInfoData->bufferId = 1;
428 g_outputInfoData->bufferCnt = 1;
429 g_outputInfoData->flag = 1;
430 g_outputInfoData->timeStamp = 1;
431 g_outputInfoData->buffer[0].type = BUFFER_TYPE_FD;
432 g_outputInfoData->buffer[0].offset = 1;
433 g_outputInfoData->buffer[0].length = 1;
434 g_outputInfoData->buffer[0].capacity = TEST_FRAME_BUFFER_SIZE;
435 g_outputInfoData->buffer[0].buf = (intptr_t)g_outputBuffer.fd;
436
437 int32_t errorCode = g_codecObj->CodecQueueOutput(g_codecObj, g_handle, g_outputInfoData, (uint32_t)0, -1);
438 ASSERT_EQ(errorCode, HDF_SUCCESS);
439 }
440
441 HWTEST_F(CodecProxyTest, HdfCodecHdiV1DequeueOutputTest_001, TestSize.Level1)
442 {
443 int32_t errorCode = 0;
444 int32_t acquireFd;
445 CodecBuffer *outInfo = (CodecBuffer *)OsalMemAlloc(sizeof(CodecBuffer) + sizeof(CodecBufferInfo) * 1);
446 outInfo->bufferCnt = 1;
447
448 errorCode = g_codecObj->CodecDequeueOutput(g_codecObj, g_handle, QUEUE_TIME_OUT, &acquireFd, outInfo);
449 ASSERT_EQ(errorCode, HDF_SUCCESS);
450 ASSERT_EQ(outInfo->bufferId, g_outputInfoData->bufferId);
451 ASSERT_EQ(outInfo->bufferCnt, g_outputInfoData->bufferCnt);
452 ASSERT_EQ(outInfo->buffer[0].type, g_outputInfoData->buffer[0].type);
453 ASSERT_EQ(outInfo->buffer[0].offset, g_outputInfoData->buffer[0].offset);
454 ASSERT_EQ(outInfo->buffer[0].length, g_outputInfoData->buffer[0].length);
455 ASSERT_EQ(outInfo->buffer[0].capacity, g_outputInfoData->buffer[0].capacity);
456 OsalMemFree(outInfo);
457 OsalMemFree(g_outputInfoData);
458 }
459
460 HWTEST_F(CodecProxyTest, HdfCodecHdiV1FlushTest_001, TestSize.Level1)
461 {
462 DirectionType directType = OUTPUT_TYPE;
463
464 int32_t errorCode = g_codecObj->CodecFlush(g_codecObj, g_handle, directType);
465 ASSERT_EQ(errorCode, HDF_SUCCESS);
466 ASSERT_EQ(directType, OUTPUT_TYPE);
467 }
468
469 HWTEST_F(CodecProxyTest, HdfCodecHdiV1FlushTest_002, TestSize.Level1)
470 {
471 DirectionType directType = INPUT_TYPE;
472
473 int32_t errorCode = g_codecObj->CodecFlush(g_codecObj, g_handle, directType);
474 ASSERT_EQ(errorCode, HDF_SUCCESS);
475 ASSERT_EQ(directType, INPUT_TYPE);
476 }
477
478 HWTEST_F(CodecProxyTest, HdfCodecHdiV1FlushTest_003, TestSize.Level1)
479 {
480 DirectionType directType = ALL_TYPE;
481
482 int32_t errorCode = g_codecObj->CodecFlush(g_codecObj, g_handle, directType);
483 ASSERT_EQ(errorCode, HDF_SUCCESS);
484 ASSERT_EQ(directType, ALL_TYPE);
485 }
486
487 HWTEST_F(CodecProxyTest, HdfCodecHdiV1SetCallbackTest_001, TestSize.Level1)
488 {
489 UINTPTR instance = 0;
490 ICodecCallback *callback = CodecCallbackStubObtain();
491 ASSERT_TRUE(callback != nullptr);
492
493 int32_t errorCode = g_codecObj->CodecSetCallback(g_codecObj, g_handle, callback, instance);
494 ASSERT_EQ(errorCode, HDF_SUCCESS);
495 }
496
497 HWTEST_F(CodecProxyTest, HdfCodecHdiV1DestroyCodecTest_001, TestSize.Level1)
498 {
499 int32_t errorCode = g_codecObj->CodecDestroy(g_codecObj, g_handle);
500 ASSERT_EQ(errorCode, HDF_SUCCESS);
501 }
502
503 HWTEST_F(CodecProxyTest, HdfCodecHdiV1DeinitTest_001, TestSize.Level1)
504 {
505 int32_t errorCode = g_codecObj->CodecDeinit(g_codecObj);
506 ASSERT_EQ(errorCode, HDF_SUCCESS);
507 HdiCodecRelease(g_codecObj);
508 }
509 }