• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023-2024 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 "hdf_log.h"
17 #include "v2_0/codec_image_type.h"
18 #include "v1_0/display_buffer_type.h"
19 #include "v1_0/display_composer_type.h"
20 #include "v2_0/icodec_image.h"
21 #include "v1_0/include/idisplay_buffer.h"
22 #include <buffer_handle.h>
23 #include <gtest/gtest.h>
24 #define HDF_LOG_TAG codec_jpeg_test
25 
26 using namespace std;
27 using namespace testing::ext;
28 using namespace OHOS::HDI::Display::Buffer::V1_0;
29 using namespace OHOS::HDI::Display::Composer::V1_0;
30 using namespace OHOS::HDI::Codec::Image::V2_0;
31 namespace {
32 constexpr int32_t WIDTH = 640;
33 constexpr int32_t HEIGHT = 480;
34 constexpr uint32_t NORMAL_BUFFER_SIZE = 1000;
35 constexpr uint32_t CODEC_IMAGE_MAX_BUFFER_SIZE = 50 * 1024 * 1024;
36 static OHOS::sptr<ICodecImage> hdiJpeg_;
37 static IDisplayBuffer *hdiBuffer_;
38 class CodecHdiJpegTestAdditional : public testing::Test {
39 public:
InitOutBuffer(CodecImageBuffer & outBuffer)40     void InitOutBuffer(CodecImageBuffer &outBuffer)
41     {
42         AllocInfo alloc = {.width = WIDTH,
43                            .height = HEIGHT,
44                            .usage = HBM_USE_CPU_READ | HBM_USE_CPU_WRITE | HBM_USE_MEM_DMA,
45                            .format = PIXEL_FMT_YCBCR_420_SP};
46 
47         BufferHandle *bufferHandle = nullptr;
48         auto err = hdiBuffer_->AllocMem(alloc, bufferHandle);
49         if (err != HDF_SUCCESS) {
50             return;
51         }
52         outBuffer.buffer = new NativeBuffer(bufferHandle);
53     }
54 
SetUpTestCase()55     static void SetUpTestCase()
56     {
57         hdiJpeg_ = ICodecImage::Get();
58         hdiBuffer_ = IDisplayBuffer::Get();
59     }
TearDownTestCase()60     static void TearDownTestCase()
61     {
62         hdiJpeg_ = nullptr;
63         hdiBuffer_ = nullptr;
64     }
SetUp()65     void SetUp()
66     {
67         if (hdiJpeg_ != nullptr) {
68             hdiJpeg_->Init(CODEC_IMAGE_JPEG);
69         } else {
70             printf("jpeg is not supported!");
71             GTEST_SKIP() << "Device not exist" << std::endl;
72             return;
73         }
74     }
TearDown()75     void TearDown()
76     {
77         if (hdiJpeg_ != nullptr) {
78             hdiJpeg_->DeInit(CODEC_IMAGE_JPEG);
79         }
80     }
81 };
82 
83 /**
84  * @tc.number : SUB_Driver_Codec_ImageCodecHDI_0900
85  * @tc.name   : testCodecDoJpegDecode001
86  * @tc.desc   : Determines the result of the function when the wrong argument is passed
87  */
88 HWTEST_F(CodecHdiJpegTestAdditional, testCodecDoJpegDecode001, TestSize.Level2)
89 {
90     ASSERT_TRUE(hdiJpeg_ != nullptr);
91     struct CodecImageBuffer inBuffer;
92     struct CodecImageBuffer outBuffer;
93     struct CodecJpegDecInfo decInfo;
94     inBuffer.size = -1;
95     auto ret = hdiJpeg_->DoJpegDecode(inBuffer, outBuffer, decInfo);
96     ASSERT_NE(ret, HDF_SUCCESS);
97 }
98 
99 /**
100  * @tc.number : SUB_Driver_Codec_ImageCodecHDI_1000
101  * @tc.name   : testCodecDoJpegDecode002
102  * @tc.desc   : Determines the result of the function when the wrong argument is passed
103  */
104 HWTEST_F(CodecHdiJpegTestAdditional, testCodecDoJpegDecode002, TestSize.Level2)
105 {
106     ASSERT_TRUE(hdiJpeg_ != nullptr);
107     struct CodecImageBuffer inBuffer;
108     struct CodecImageBuffer outBuffer;
109     struct CodecJpegDecInfo decInfo;
110     inBuffer.buffer = 0;
111     auto ret = hdiJpeg_->DoJpegDecode(inBuffer, outBuffer, decInfo);
112     ASSERT_NE(ret, HDF_SUCCESS);
113 }
114 
115 /**
116  * @tc.number : SUB_Driver_Codec_ImageCodecHDI_1100
117  * @tc.name   : testCodecDoJpegDecode003
118  * @tc.desc   : Determines the result of the function when the wrong argument is passed
119  */
120 HWTEST_F(CodecHdiJpegTestAdditional, testCodecDoJpegDecode003, TestSize.Level2)
121 {
122     ASSERT_TRUE(hdiJpeg_ != nullptr);
123     struct CodecImageBuffer inBuffer;
124     struct CodecImageBuffer outBuffer;
125     struct CodecJpegDecInfo decInfo;
126     inBuffer.fenceFd = -1;
127     auto ret = hdiJpeg_->DoJpegDecode(inBuffer, outBuffer, decInfo);
128     ASSERT_NE(ret, HDF_SUCCESS);
129 }
130 
131 /**
132  * @tc.number : SUB_Driver_Codec_ImageCodecHDI_1200
133  * @tc.name   : testCodecDoJpegDecode004
134  * @tc.desc   : Determines the result of the function when the wrong argument is passed
135  */
136 HWTEST_F(CodecHdiJpegTestAdditional, testCodecDoJpegDecode004, TestSize.Level2)
137 {
138     ASSERT_TRUE(hdiJpeg_ != nullptr);
139     struct CodecImageBuffer inBuffer;
140     struct CodecImageBuffer outBuffer;
141     struct CodecJpegDecInfo decInfo;
142     outBuffer.id = -1;
143     auto ret = hdiJpeg_->DoJpegDecode(inBuffer, outBuffer, decInfo);
144     ASSERT_NE(ret, HDF_SUCCESS);
145 }
146 
147 /**
148  * @tc.number : SUB_Driver_Codec_ImageCodecHDI_1300
149  * @tc.name   : testCodecDoJpegDecode005
150  * @tc.desc   : Determines the result of the function when the wrong argument is passed
151  */
152 HWTEST_F(CodecHdiJpegTestAdditional, testCodecDoJpegDecode005, TestSize.Level2)
153 {
154     ASSERT_TRUE(hdiJpeg_ != nullptr);
155     struct CodecImageBuffer inBuffer;
156     struct CodecImageBuffer outBuffer;
157     struct CodecJpegDecInfo decInfo;
158     outBuffer.size = -1;
159     auto ret = hdiJpeg_->DoJpegDecode(inBuffer, outBuffer, decInfo);
160     ASSERT_NE(ret, HDF_SUCCESS);
161 }
162 
163 /**
164  * @tc.number : SUB_Driver_Codec_ImageCodecHDI_1400
165  * @tc.name   : testCodecDoJpegDecode006
166  * @tc.desc   : Determines the result of the function when the wrong argument is passed
167  */
168 HWTEST_F(CodecHdiJpegTestAdditional, testCodecDoJpegDecode006, TestSize.Level2)
169 {
170     ASSERT_TRUE(hdiJpeg_ != nullptr);
171     struct CodecImageBuffer inBuffer;
172     struct CodecImageBuffer outBuffer;
173     struct CodecJpegDecInfo decInfo;
174     outBuffer.buffer = 0;
175     auto ret = hdiJpeg_->DoJpegDecode(inBuffer, outBuffer, decInfo);
176     ASSERT_NE(ret, HDF_SUCCESS);
177 }
178 
179 /**
180  * @tc.number : SUB_Driver_Codec_ImageCodecHDI_1500
181  * @tc.name   : testCodecDoJpegDecode007
182  * @tc.desc   : Determines the result of the function when the wrong argument is passed
183  */
184 HWTEST_F(CodecHdiJpegTestAdditional, testCodecDoJpegDecode007, TestSize.Level2)
185 {
186     ASSERT_TRUE(hdiJpeg_ != nullptr);
187     struct CodecImageBuffer inBuffer;
188     struct CodecImageBuffer outBuffer;
189     struct CodecJpegDecInfo decInfo;
190     outBuffer.fenceFd = -1;
191     auto ret = hdiJpeg_->DoJpegDecode(inBuffer, outBuffer, decInfo);
192     ASSERT_NE(ret, HDF_SUCCESS);
193 }
194 
195 /**
196  * @tc.number : SUB_Driver_Codec_ImageCodecHDI_1600
197  * @tc.name   : testCodecDoJpegDecode008
198  * @tc.desc   : Determines the result of the function when the wrong argument is passed
199  */
200 HWTEST_F(CodecHdiJpegTestAdditional, testCodecDoJpegDecode008, TestSize.Level2)
201 {
202     ASSERT_TRUE(hdiJpeg_ != nullptr);
203     struct CodecImageBuffer inBuffer;
204     struct CodecImageBuffer outBuffer;
205     struct CodecJpegDecInfo decInfo;
206     decInfo.imageWidth = -1;
207     auto ret = hdiJpeg_->DoJpegDecode(inBuffer, outBuffer, decInfo);
208     ASSERT_NE(ret, HDF_SUCCESS);
209 }
210 
211 /**
212  * @tc.number : SUB_Driver_Codec_ImageCodecHDI_1700
213  * @tc.name   : testCodecDoJpegDecode009
214  * @tc.desc   : Determines the result of the function when the wrong argument is passed
215  */
216 HWTEST_F(CodecHdiJpegTestAdditional, testCodecDoJpegDecode009, TestSize.Level2)
217 {
218     ASSERT_TRUE(hdiJpeg_ != nullptr);
219     struct CodecImageBuffer inBuffer;
220     struct CodecImageBuffer outBuffer;
221     struct CodecJpegDecInfo decInfo;
222     decInfo.imageHeight = -1;
223     auto ret = hdiJpeg_->DoJpegDecode(inBuffer, outBuffer, decInfo);
224     ASSERT_NE(ret, HDF_SUCCESS);
225 }
226 
227 /**
228  * @tc.number : SUB_Driver_Codec_ImageCodecHDI_1800
229  * @tc.name   : testCodecDoJpegDecode010
230  * @tc.desc   : Determines the result of the function when the wrong argument is passed
231  */
232 HWTEST_F(CodecHdiJpegTestAdditional, testCodecDoJpegDecode010, TestSize.Level2)
233 {
234     ASSERT_TRUE(hdiJpeg_ != nullptr);
235     struct CodecImageBuffer inBuffer;
236     struct CodecImageBuffer outBuffer;
237     struct CodecJpegDecInfo decInfo;
238     decInfo.dataPrecision = -1;
239     auto ret = hdiJpeg_->DoJpegDecode(inBuffer, outBuffer, decInfo);
240     ASSERT_NE(ret, HDF_SUCCESS);
241 }
242 
243 /**
244  * @tc.number : SUB_Driver_Codec_ImageCodecHDI_1900
245  * @tc.name   : testCodecDoJpegDecode011
246  * @tc.desc   : Determines the result of the function when the wrong argument is passed
247  */
248 HWTEST_F(CodecHdiJpegTestAdditional, testCodecDoJpegDecode011, TestSize.Level2)
249 {
250     ASSERT_TRUE(hdiJpeg_ != nullptr);
251     struct CodecImageBuffer inBuffer;
252     struct CodecImageBuffer outBuffer;
253     struct CodecJpegDecInfo decInfo;
254     decInfo.numComponents = -1;
255     auto ret = hdiJpeg_->DoJpegDecode(inBuffer, outBuffer, decInfo);
256     ASSERT_NE(ret, HDF_SUCCESS);
257 }
258 
259 /**
260  * @tc.number : SUB_Driver_Codec_ImageCodecHDI_2000
261  * @tc.name   : testCodecDoJpegDecode012
262  * @tc.desc   : Determines the result of the function when the wrong argument is passed
263  */
264 HWTEST_F(CodecHdiJpegTestAdditional, testCodecDoJpegDecode012, TestSize.Level2)
265 {
266     ASSERT_TRUE(hdiJpeg_ != nullptr);
267     struct CodecImageBuffer inBuffer;
268     struct CodecImageBuffer outBuffer;
269     struct CodecJpegDecInfo decInfo;
270     decInfo.restartInterval = -1;
271     auto ret = hdiJpeg_->DoJpegDecode(inBuffer, outBuffer, decInfo);
272     ASSERT_NE(ret, HDF_SUCCESS);
273 }
274 
275 /**
276  * @tc.number : SUB_Driver_Codec_ImageCodecHDI_2100
277  * @tc.name   : testCodecFreeInBuffer001
278  * @tc.desc   : Determines the result of the function when the wrong argument is passed
279  */
280 HWTEST_F(CodecHdiJpegTestAdditional, testCodecFreeInBuffer001, TestSize.Level2)
281 {
282     ASSERT_TRUE(hdiJpeg_ != nullptr);
283     struct CodecImageBuffer inBuffer;
284     inBuffer.size = -1;
285     auto ret = hdiJpeg_->FreeInBuffer(inBuffer);
286     ASSERT_EQ(ret, HDF_SUCCESS);
287 }
288 
289 /**
290  * @tc.number : SUB_Driver_Codec_ImageCodecHDI_2200
291  * @tc.name   : testCodecFreeInBuffer002
292  * @tc.desc   : Determines the result of the function when the wrong argument is passed
293  */
294 HWTEST_F(CodecHdiJpegTestAdditional, testCodecFreeInBuffer002, TestSize.Level2)
295 {
296     ASSERT_TRUE(hdiJpeg_ != nullptr);
297     struct CodecImageBuffer inBuffer;
298     inBuffer.buffer = 0;
299     auto ret = hdiJpeg_->FreeInBuffer(inBuffer);
300     ASSERT_EQ(ret, HDF_SUCCESS);
301 }
302 
303 /**
304  * @tc.number : SUB_Driver_Codec_ImageCodecHDI_2300
305  * @tc.name   : testCodecFreeInBuffer003
306  * @tc.desc   : Determines the result of the function when the wrong argument is passed
307  */
308 HWTEST_F(CodecHdiJpegTestAdditional, testCodecFreeInBuffer003, TestSize.Level2)
309 {
310     ASSERT_TRUE(hdiJpeg_ != nullptr);
311     struct CodecImageBuffer inBuffer;
312     inBuffer.fenceFd = -1;
313     auto ret = hdiJpeg_->FreeInBuffer(inBuffer);
314     ASSERT_EQ(ret, HDF_SUCCESS);
315 }
316 
317 /**
318  * @tc.number : SUB_Driver_Codec_ImageCodecHDI_2400
319  * @tc.name   : testCodecGetImageCapability001
320  * @tc.desc   : Determine whether existing values of parameter structures affect function results
321  */
322 HWTEST_F(CodecHdiJpegTestAdditional, testCodecGetImageCapability001, TestSize.Level1)
323 {
324     ASSERT_TRUE(hdiJpeg_ != nullptr);
325     std::vector<CodecImageCapability> capList(1);
326     capList[0].role = CODEC_IMAGE_INVALID;
327     auto ret = hdiJpeg_->GetImageCapability(capList);
328     ASSERT_EQ(ret, HDF_SUCCESS);
329 }
330 
331 /**
332  * @tc.number : SUB_Driver_Codec_ImageCodecHDI_2500
333  * @tc.name   : testCodecGetImageCapability002
334  * @tc.desc   : Determine whether existing values of parameter structures affect function results
335  */
336 HWTEST_F(CodecHdiJpegTestAdditional, testCodecGetImageCapability002, TestSize.Level1)
337 {
338     ASSERT_TRUE(hdiJpeg_ != nullptr);
339     std::vector<CodecImageCapability> capList(1);
340     capList[0].type = CODEC_IMAGE_TYPE_INVALID;
341     auto ret = hdiJpeg_->GetImageCapability(capList);
342     ASSERT_EQ(ret, HDF_SUCCESS);
343     ASSERT_TRUE(!capList[0].name.empty());
344 }
345 /**
346  * @tc.number : SUB_Driver_Codec_ImageCodecHDI_2600
347  * @tc.name   : testCodecGetImageCapability003
348  * @tc.desc   : Determine whether existing values of parameter structures affect function results
349  */
350 HWTEST_F(CodecHdiJpegTestAdditional, testCodecGetImageCapability003, TestSize.Level1)
351 {
352     ASSERT_TRUE(hdiJpeg_ != nullptr);
353     std::vector<CodecImageCapability> capList(1);
354     capList[0].widthAlignment = -1;
355     auto ret = hdiJpeg_->GetImageCapability(capList);
356     ASSERT_TRUE(capList[0].widthAlignment >= 0);
357     ASSERT_EQ(ret, HDF_SUCCESS);
358 }
359 
360 /**
361  * @tc.number : SUB_Driver_Codec_ImageCodecHDI_2700
362  * @tc.name   : testCodecGetImageCapability004
363  * @tc.desc   : Determine whether existing values of parameter structures affect function results
364  */
365 HWTEST_F(CodecHdiJpegTestAdditional, testCodecGetImageCapability004, TestSize.Level1)
366 {
367     ASSERT_TRUE(hdiJpeg_ != nullptr);
368     std::vector<CodecImageCapability> capList(1);
369     capList[0].heightAlignment = -1;
370     auto ret = hdiJpeg_->GetImageCapability(capList);
371     ASSERT_TRUE(capList[0].heightAlignment >= 0);
372     ASSERT_EQ(ret, HDF_SUCCESS);
373 }
374 
375 /**
376  * @tc.number : SUB_Driver_Codec_ImageCodecHDI_2800
377  * @tc.name   : testCodecGetImageCapability005
378  * @tc.desc   : Determine whether existing values of parameter structures affect function results
379  */
380 HWTEST_F(CodecHdiJpegTestAdditional, testCodecGetImageCapability005, TestSize.Level1)
381 {
382     ASSERT_TRUE(hdiJpeg_ != nullptr);
383     std::vector<CodecImageCapability> capList(1);
384     capList[0].maxSample = -1;
385     auto ret = hdiJpeg_->GetImageCapability(capList);
386     ASSERT_TRUE(capList[0].maxSample >= 0);
387     ASSERT_EQ(ret, HDF_SUCCESS);
388 }
389 
390 /**
391  * @tc.number : SUB_Driver_Codec_ImageCodecHDI_2900
392  * @tc.name   : testCodecGetImageCapability006
393  * @tc.desc   : Determine whether existing values of parameter structures affect function results
394  */
395 HWTEST_F(CodecHdiJpegTestAdditional, testCodecGetImageCapability006, TestSize.Level1)
396 {
397     ASSERT_TRUE(hdiJpeg_ != nullptr);
398     std::vector<CodecImageCapability> capList(1);
399     capList[0].maxWidth = -1;
400     auto ret = hdiJpeg_->GetImageCapability(capList);
401     ASSERT_TRUE(capList[0].maxWidth >= 0);
402     ASSERT_EQ(ret, HDF_SUCCESS);
403 }
404 
405 /**
406  * @tc.number : SUB_Driver_Codec_ImageCodecHDI_3000
407  * @tc.name   : testCodecGetImageCapability007
408  * @tc.desc   : Determine whether existing values of parameter structures affect function results
409  */
410 HWTEST_F(CodecHdiJpegTestAdditional, testCodecGetImageCapability007, TestSize.Level1)
411 {
412     ASSERT_TRUE(hdiJpeg_ != nullptr);
413     std::vector<CodecImageCapability> capList(1);
414     capList[0].maxHeight = -1;
415     auto ret = hdiJpeg_->GetImageCapability(capList);
416     ASSERT_TRUE(capList[0].maxHeight >= 0);
417     ASSERT_EQ(ret, HDF_SUCCESS);
418 }
419 
420 /**
421  * @tc.number : SUB_Driver_Codec_ImageCodecHDI_3100
422  * @tc.name   : testCodecGetImageCapability008
423  * @tc.desc   : Determine whether existing values of parameter structures affect function results
424  */
425 HWTEST_F(CodecHdiJpegTestAdditional, testCodecGetImageCapability008, TestSize.Level1)
426 {
427     ASSERT_TRUE(hdiJpeg_ != nullptr);
428     std::vector<CodecImageCapability> capList(1);
429     capList[0].maxInst = -1;
430     auto ret = hdiJpeg_->GetImageCapability(capList);
431     ASSERT_TRUE(capList[0].maxInst >= 0);
432     ASSERT_EQ(ret, HDF_SUCCESS);
433 }
434 
435 /**
436  * @tc.number : SUB_Driver_Codec_ImageCodecHDI_3200
437  * @tc.name   : testCodecAllocateInBuffer001
438  * @tc.desc   : Determine whether existing values of parameter structures affect function results
439  */
440 HWTEST_F(CodecHdiJpegTestAdditional, testCodecAllocateInBuffer001, TestSize.Level1)
441 {
442     ASSERT_TRUE(hdiJpeg_ != nullptr);
443     struct CodecImageBuffer inBuffer;
444     inBuffer.id = -1;
445     auto ret = hdiJpeg_->AllocateInBuffer(inBuffer, NORMAL_BUFFER_SIZE, CODEC_IMAGE_JPEG);
446     if (ret == -1)
447     {
448         printf("jpeg is not supported!");
449         GTEST_SKIP() << "Device not exist" << std::endl;
450         return;
451     }
452     ASSERT_EQ(ret, HDF_SUCCESS);
453 }
454 
455 /**
456  * @tc.number : SUB_Driver_Codec_ImageCodecHDI_3300
457  * @tc.name   : testCodecAllocateInBuffer002
458  * @tc.desc   : Determine whether existing values of parameter structures affect function results
459  */
460 HWTEST_F(CodecHdiJpegTestAdditional, testCodecAllocateInBuffer002, TestSize.Level1)
461 {
462     ASSERT_TRUE(hdiJpeg_ != nullptr);
463     struct CodecImageBuffer inBuffer;
464     inBuffer.size = -1;
465     auto ret = hdiJpeg_->AllocateInBuffer(inBuffer, NORMAL_BUFFER_SIZE, CODEC_IMAGE_JPEG);
466     if (ret == -1)
467     {
468         printf("jpeg is not supported!");
469         GTEST_SKIP() << "Device not exist" << std::endl;
470         return;
471     }
472     ASSERT_EQ(ret, HDF_SUCCESS);
473 }
474 
475 /**
476  * @tc.number : SUB_Driver_Codec_ImageCodecHDI_3400
477  * @tc.name   : testCodecAllocateInBuffer003
478  * @tc.desc   : Determine whether existing values of parameter structures affect function results
479  */
480 HWTEST_F(CodecHdiJpegTestAdditional, testCodecAllocateInBuffer003, TestSize.Level1)
481 {
482     ASSERT_TRUE(hdiJpeg_ != nullptr);
483     struct CodecImageBuffer inBuffer;
484     inBuffer.buffer = 0;
485     auto ret = hdiJpeg_->AllocateInBuffer(inBuffer, NORMAL_BUFFER_SIZE, CODEC_IMAGE_JPEG);
486     if (ret == -1)
487     {
488         printf("jpeg is not supported!");
489         GTEST_SKIP() << "Device not exist" << std::endl;
490         return;
491     }
492     ASSERT_EQ(ret, HDF_SUCCESS);
493 }
494 
495 /**
496  * @tc.number : SUB_Driver_Codec_ImageCodecHDI_3500
497  * @tc.name   : testCodecAllocateInBuffer004
498  * @tc.desc   : Determine whether existing values of parameter structures affect function results
499  */
500 HWTEST_F(CodecHdiJpegTestAdditional, testCodecAllocateInBuffer004, TestSize.Level1)
501 {
502     ASSERT_TRUE(hdiJpeg_ != nullptr);
503     struct CodecImageBuffer inBuffer;
504     inBuffer.fenceFd = -1;
505     auto ret = hdiJpeg_->AllocateInBuffer(inBuffer, NORMAL_BUFFER_SIZE, CODEC_IMAGE_JPEG);
506     if (ret == -1)
507     {
508         printf("jpeg is not supported!");
509         GTEST_SKIP() << "Device not exist" << std::endl;
510         return;
511     }
512     ASSERT_EQ(ret, HDF_SUCCESS);
513 }
514 
515 /**
516  * @tc.number : SUB_Driver_Codec_ImageCodecHDI_3600
517  * @tc.name   : testCodecAllocateInBuffer005
518  * @tc.desc   : Determines the result of the function when the wrong argument is passed
519  */
520 HWTEST_F(CodecHdiJpegTestAdditional, testCodecAllocateInBuffer005, TestSize.Level2)
521 {
522     ASSERT_TRUE(hdiJpeg_ != nullptr);
523     struct CodecImageBuffer inBuffer;
524     auto ret = hdiJpeg_->AllocateInBuffer(inBuffer, -1, CODEC_IMAGE_JPEG);
525     ASSERT_NE(ret, HDF_SUCCESS);
526 }
527 
528 /**
529  * @tc.number : SUB_Driver_Codec_ImageCodecHDI_3700
530  * @tc.name   : testCodecAllocateInBuffer006
531  * @tc.desc   : Determines the result of the function when the correct argument is passed in
532  */
533 HWTEST_F(CodecHdiJpegTestAdditional, testCodecAllocateInBuffer006, TestSize.Level1)
534 {
535     ASSERT_TRUE(hdiJpeg_ != nullptr);
536     struct CodecImageBuffer inBuffer;
537     auto ret = hdiJpeg_->AllocateInBuffer(inBuffer, 200, CODEC_IMAGE_JPEG);
538     if (ret == -1)
539     {
540         printf("jpeg is not supported!");
541         GTEST_SKIP() << "Device not exist" << std::endl;
542         return;
543     }
544     ASSERT_EQ(ret, HDF_SUCCESS);
545 }
546 
547 /**
548  * @tc.number : SUB_Driver_Codec_Init_0100
549  * @tc.name   : testInit001
550  * @tc.desc   : Determines the result of the function when the correct argument is invalid
551  */
552 HWTEST_F(CodecHdiJpegTestAdditional, testInit001, TestSize.Level2)
553 {
554     ASSERT_TRUE(hdiJpeg_ != nullptr);
555     auto ret = hdiJpeg_->Init(CODEC_IMAGE_INVALID);
556     ASSERT_NE(ret, HDF_SUCCESS);
557 }
558 
559 /**
560  * @tc.number : SUB_Driver_Codec_Init_0200
561  * @tc.name   : testInit002
562  * @tc.desc   : Determines the result of the function with CODEC_IMAGE_JPEG
563  */
564 HWTEST_F(CodecHdiJpegTestAdditional, testInit002, Function | MediumTest | Level1)
565 {
566     ASSERT_TRUE(hdiJpeg_ != nullptr);
567     auto ret = hdiJpeg_->DeInit(CODEC_IMAGE_JPEG);
568     ret = hdiJpeg_->Init(CODEC_IMAGE_JPEG);
569     if (ret == -1)
570     {
571         printf("jpeg is not supported!");
572         GTEST_SKIP() << "Device not exist" << std::endl;
573         return;
574     }
575     ASSERT_EQ(ret, HDF_SUCCESS);
576 }
577 
578 /**
579  * @tc.number : SUB_Driver_Codec_Init_0300
580  * @tc.name   : testInit003
581  * @tc.desc   : Determines the result of the function with CODEC_IMAGE_HEIF
582  */
583 HWTEST_F(CodecHdiJpegTestAdditional, testInit003, Function | MediumTest | Level2)
584 {
585     ASSERT_TRUE(hdiJpeg_ != nullptr);
586     auto ret = hdiJpeg_->Init(CODEC_IMAGE_HEIF);
587     ASSERT_NE(ret, HDF_SUCCESS);
588 }
589 
590 /**
591  * @tc.number : SUB_Driver_Codec_DeInit_0100
592  * @tc.name   : testDeInit001
593  * @tc.desc   : Determines the result of the function when the correct argument is invalid
594  */
595 HWTEST_F(CodecHdiJpegTestAdditional, testDeInit001, TestSize.Level2)
596 {
597     ASSERT_TRUE(hdiJpeg_ != nullptr);
598     auto ret = hdiJpeg_->DeInit(CODEC_IMAGE_INVALID);
599     ASSERT_NE(ret, HDF_SUCCESS);
600 }
601 
602 /**
603  * @tc.number : SUB_Driver_Codec_DeInit_0200
604  * @tc.name   : testDeInit002
605  * @tc.desc   : Determines the result of the function with CODEC_IMAGE_JPEG
606  */
607 HWTEST_F(CodecHdiJpegTestAdditional, testDeInit002, Function | MediumTest | Level1)
608 {
609     ASSERT_TRUE(hdiJpeg_ != nullptr);
610     auto ret = hdiJpeg_->DeInit(CODEC_IMAGE_JPEG);
611     ret = hdiJpeg_->DeInit(CODEC_IMAGE_JPEG);
612     ret = hdiJpeg_->Init(CODEC_IMAGE_JPEG);
613 }
614 
615 /**
616  * @tc.number : SUB_Driver_Codec_DeInit_0300
617  * @tc.name   : testDeInit003
618  * @tc.desc   : Determines the result of the function with CODEC_IMAGE_HEIF
619  */
620 HWTEST_F(CodecHdiJpegTestAdditional, testDeInit003, Function | MediumTest | Level2)
621 {
622     ASSERT_TRUE(hdiJpeg_ != nullptr);
623     auto ret = hdiJpeg_->DeInit(CODEC_IMAGE_HEIF);
624     ASSERT_NE(ret, HDF_SUCCESS);
625 }
626 
627 /**
628  * @tc.number : SUB_Driver_Codec_DoJpegDecode_2100
629  * @tc.name   : testCodecDoJpegDecode013
630  * @tc.desc   : When the third argument CodecJpegDecInfo struct ->dataPrecision = 0, the result returns failure
631  */
632 HWTEST_F(CodecHdiJpegTestAdditional, testCodecDoJpegDecode013, TestSize.Level2)
633 {
634     ASSERT_TRUE(hdiJpeg_ != nullptr);
635     struct CodecImageBuffer inBuffer;
636     auto ret = hdiJpeg_->AllocateInBuffer(inBuffer, NORMAL_BUFFER_SIZE, CODEC_IMAGE_JPEG);
637     if (ret == -1)
638     {
639         printf("jpeg is not supported!");
640         GTEST_SKIP() << "Device not exist" << std::endl;
641         return;
642     }
643     ASSERT_EQ(ret, HDF_SUCCESS);
644     struct CodecImageBuffer outBuffer;
645     ASSERT_EQ(hdiJpeg_->AllocateInBuffer(outBuffer, NORMAL_BUFFER_SIZE, CODEC_IMAGE_JPEG), HDF_SUCCESS);
646     struct CodecJpegDecInfo decInfo;
647     decInfo.imageWidth = 1200;
648     decInfo.imageHeight = 960;
649     decInfo.dataPrecision = 0;
650 
651     ret = hdiJpeg_->DoJpegDecode(inBuffer, outBuffer, decInfo);
652     ASSERT_NE(ret, HDF_SUCCESS);
653 
654     ASSERT_EQ(hdiJpeg_->FreeInBuffer(inBuffer), HDF_SUCCESS);
655     ASSERT_EQ(hdiJpeg_->FreeInBuffer(outBuffer), HDF_SUCCESS);
656 }
657 
658 /**
659  * @tc.number : SUB_Driver_Codec_DoJpegDecode_2200
660  * @tc.name   : testCodecDoJpegDecode014
661  * @tc.desc   : When the second parameter CodecImageBuffer structure is empty, the result returns a failure
662  */
663 HWTEST_F(CodecHdiJpegTestAdditional, testCodecDoJpegDecode014, TestSize.Level2)
664 {
665     ASSERT_TRUE(hdiJpeg_ != nullptr);
666     struct CodecImageBuffer inBuffer;
667     auto ret = hdiJpeg_->AllocateInBuffer(inBuffer, NORMAL_BUFFER_SIZE, CODEC_IMAGE_JPEG);
668     if (ret == -1)
669     {
670         printf("jpeg is not supported!");
671         GTEST_SKIP() << "Device not exist" << std::endl;
672         return;
673     }
674     ASSERT_EQ(ret, HDF_SUCCESS);
675     struct CodecImageBuffer outBuffer;
676     struct CodecJpegDecInfo decInfo;
677     decInfo.imageWidth = 1200;
678     decInfo.imageHeight = 960;
679     decInfo.dataPrecision = 8;
680 
681     ret = hdiJpeg_->DoJpegDecode(inBuffer, outBuffer, decInfo);
682     ASSERT_NE(ret, HDF_SUCCESS);
683 
684     ASSERT_EQ(hdiJpeg_->FreeInBuffer(inBuffer), HDF_SUCCESS);
685 }
686 
687 /**
688  * @tc.number : SUB_Driver_Codec_DoJpegDecode_2300
689  * @tc.name   : testCodecDoJpegDecode015
690  * @tc.desc   : When the first argument CodecImageBuffer structure is empty, the result returns a failure
691  */
692 HWTEST_F(CodecHdiJpegTestAdditional, testCodecDoJpegDecode015, TestSize.Level2)
693 {
694     ASSERT_TRUE(hdiJpeg_ != nullptr);
695     struct CodecImageBuffer inBuffer;
696     struct CodecImageBuffer outBuffer;
697     auto ret = hdiJpeg_->AllocateInBuffer(outBuffer, NORMAL_BUFFER_SIZE, CODEC_IMAGE_JPEG);
698     if (ret == -1)
699     {
700         printf("jpeg is not supported!");
701         GTEST_SKIP() << "Device not exist" << std::endl;
702         return;
703     }
704     ASSERT_EQ(ret, HDF_SUCCESS);
705     struct CodecJpegDecInfo decInfo;
706     decInfo.imageWidth = 1200;
707     decInfo.imageHeight = 960;
708     decInfo.dataPrecision = 8;
709 
710     ret = hdiJpeg_->DoJpegDecode(inBuffer, outBuffer, decInfo);
711     ASSERT_NE(ret, HDF_SUCCESS);
712 
713     ASSERT_EQ(hdiJpeg_->FreeInBuffer(outBuffer), HDF_SUCCESS);
714 }
715 
716 /**
717  * @tc.number : SUB_Driver_Codec_DoJpegDecode_2400
718  * @tc.name   : testCodecDoJpegDecode016
719  * @tc.desc   : Verify that the result fails when the second entry of the first prefix function AllocateInBuffer is 0
720  */
721 HWTEST_F(CodecHdiJpegTestAdditional, testCodecDoJpegDecode016, TestSize.Level2)
722 {
723     ASSERT_TRUE(hdiJpeg_ != nullptr);
724     struct CodecImageBuffer inBuffer;
725     ASSERT_NE(hdiJpeg_->AllocateInBuffer(inBuffer, 0, CODEC_IMAGE_JPEG), HDF_SUCCESS);
726     struct CodecImageBuffer outBuffer;
727     auto ret = hdiJpeg_->AllocateInBuffer(outBuffer, NORMAL_BUFFER_SIZE, CODEC_IMAGE_JPEG);
728     if (ret == -1)
729     {
730         printf("jpeg is not supported!");
731         GTEST_SKIP() << "Device not exist" << std::endl;
732         return;
733     }
734     ASSERT_EQ(ret, HDF_SUCCESS);
735     struct CodecJpegDecInfo decInfo;
736     decInfo.imageWidth = WIDTH;
737     decInfo.imageHeight = HEIGHT;
738     decInfo.dataPrecision = 8;
739 
740     ret = hdiJpeg_->DoJpegDecode(inBuffer, outBuffer, decInfo);
741     ASSERT_NE(ret, HDF_SUCCESS);
742 
743     ASSERT_EQ(hdiJpeg_->FreeInBuffer(outBuffer), HDF_SUCCESS);
744 }
745 
746 /**
747  * @tc.number : SUB_Driver_Codec_DoJpegDecode_2500
748  * @tc.name   : testCodecDoJpegDecode017
749  * @tc.desc   : Failure to verify that the third entry of the first prefix function AllocateInBuffer is CODEC_IMAGE_HEIF
750  */
751 HWTEST_F(CodecHdiJpegTestAdditional, testCodecDoJpegDecode017, TestSize.Level2)
752 {
753     ASSERT_TRUE(hdiJpeg_ != nullptr);
754     struct CodecImageBuffer inBuffer;
755     ASSERT_NE(hdiJpeg_->AllocateInBuffer(inBuffer, NORMAL_BUFFER_SIZE, CODEC_IMAGE_HEIF), HDF_SUCCESS);
756     struct CodecImageBuffer outBuffer;
757     auto ret = hdiJpeg_->AllocateInBuffer(outBuffer, NORMAL_BUFFER_SIZE, CODEC_IMAGE_JPEG);
758     if (ret == -1)
759     {
760         printf("jpeg is not supported!");
761         GTEST_SKIP() << "Device not exist" << std::endl;
762         return;
763     }
764     ASSERT_EQ(ret, HDF_SUCCESS);
765     struct CodecJpegDecInfo decInfo;
766     decInfo.imageWidth = WIDTH;
767     decInfo.imageHeight = HEIGHT;
768     decInfo.dataPrecision = 8;
769 
770     ret = hdiJpeg_->DoJpegDecode(inBuffer, outBuffer, decInfo);
771     ASSERT_NE(ret, HDF_SUCCESS);
772 
773     ASSERT_EQ(hdiJpeg_->FreeInBuffer(outBuffer), HDF_SUCCESS);
774 }
775 
776 /**
777  * @tc.number : SUB_Driver_Codec_DoJpegDecode_2600
778  * @tc.name   : testCodecDoJpegDecode018
779  * @tc.desc   : Verify that a failure is returned when the third entry to
780  *              the first prefix function AllocateInBuffer is CODEC_IMAGE_INVALID
781  */
782 HWTEST_F(CodecHdiJpegTestAdditional, testCodecDoJpegDecode018, TestSize.Level2)
783 {
784     ASSERT_TRUE(hdiJpeg_ != nullptr);
785     struct CodecImageBuffer inBuffer;
786     ASSERT_NE(hdiJpeg_->AllocateInBuffer(inBuffer, NORMAL_BUFFER_SIZE, CODEC_IMAGE_INVALID), HDF_SUCCESS);
787     struct CodecImageBuffer outBuffer;
788     auto ret = hdiJpeg_->AllocateInBuffer(outBuffer, NORMAL_BUFFER_SIZE, CODEC_IMAGE_JPEG);
789     if (ret == -1)
790     {
791         printf("jpeg is not supported!");
792         GTEST_SKIP() << "Device not exist" << std::endl;
793         return;
794     }
795     ASSERT_EQ(ret, HDF_SUCCESS);
796     struct CodecJpegDecInfo decInfo;
797     decInfo.imageWidth = WIDTH;
798     decInfo.imageHeight = HEIGHT;
799     decInfo.dataPrecision = 8;
800 
801     ret = hdiJpeg_->DoJpegDecode(inBuffer, outBuffer, decInfo);
802     ASSERT_NE(ret, HDF_SUCCESS);
803 
804     ASSERT_EQ(hdiJpeg_->FreeInBuffer(outBuffer), HDF_SUCCESS);
805 }
806 
807 /**
808  * @tc.number : SUB_Driver_Codec_DoJpegDecode_2700
809  * @tc.name   : testCodecDoJpegDecode019
810  * @tc.desc   : Validation failed when the second entry to the second prefix function AllocateInBuffer is 0
811  */
812 HWTEST_F(CodecHdiJpegTestAdditional, testCodecDoJpegDecode019, TestSize.Level2)
813 {
814     ASSERT_TRUE(hdiJpeg_ != nullptr);
815     struct CodecImageBuffer inBuffer;
816     auto ret = hdiJpeg_->AllocateInBuffer(inBuffer, NORMAL_BUFFER_SIZE, CODEC_IMAGE_JPEG);
817     if (ret == -1)
818     {
819         printf("jpeg is not supported!");
820         GTEST_SKIP() << "Device not exist" << std::endl;
821         return;
822     }
823     ASSERT_EQ(ret, HDF_SUCCESS);
824     struct CodecImageBuffer outBuffer;
825     ASSERT_NE(hdiJpeg_->AllocateInBuffer(outBuffer, 0, CODEC_IMAGE_JPEG), HDF_SUCCESS);
826     struct CodecJpegDecInfo decInfo;
827     decInfo.imageWidth = WIDTH;
828     decInfo.imageHeight = HEIGHT;
829     decInfo.dataPrecision = 8;
830 
831     ret = hdiJpeg_->DoJpegDecode(inBuffer, outBuffer, decInfo);
832     ASSERT_NE(ret, HDF_SUCCESS);
833 
834     ASSERT_EQ(hdiJpeg_->FreeInBuffer(inBuffer), HDF_SUCCESS);
835 }
836 
837 /**
838  * @tc.number : SUB_Driver_Codec_DoJpegDecode_2800
839  * @tc.name   : testCodecDoJpegDecode020
840  * @tc.desc   : Verification fails when the second entry of the second prefix
841  *              function AllocateInBuffer is 50 * 1024 * 1024 +1
842  */
843 HWTEST_F(CodecHdiJpegTestAdditional, testCodecDoJpegDecode020, TestSize.Level2)
844 {
845     ASSERT_TRUE(hdiJpeg_ != nullptr);
846     struct CodecImageBuffer inBuffer;
847     auto ret = hdiJpeg_->AllocateInBuffer(inBuffer, NORMAL_BUFFER_SIZE, CODEC_IMAGE_JPEG);
848     if (ret == -1)
849     {
850         printf("jpeg is not supported!");
851         GTEST_SKIP() << "Device not exist" << std::endl;
852         return;
853     }
854     ASSERT_EQ(ret, HDF_SUCCESS);
855     struct CodecImageBuffer outBuffer;
856     ASSERT_NE(hdiJpeg_->AllocateInBuffer(outBuffer, CODEC_IMAGE_MAX_BUFFER_SIZE + 1, CODEC_IMAGE_JPEG), HDF_SUCCESS);
857     struct CodecJpegDecInfo decInfo;
858     decInfo.imageWidth = WIDTH;
859     decInfo.imageHeight = HEIGHT;
860     decInfo.dataPrecision = 8;
861 
862     ret = hdiJpeg_->DoJpegDecode(inBuffer, outBuffer, decInfo);
863     ASSERT_NE(ret, HDF_SUCCESS);
864 
865     ASSERT_EQ(hdiJpeg_->FreeInBuffer(inBuffer), HDF_SUCCESS);
866 }
867 
868 /**
869  * @tc.number : SUB_Driver_Codec_DoJpegDecode_2900
870  * @tc.name   : testCodecDoJpegDecode021
871  * @tc.desc   : Validation failed when the third entry to the second prefix
872  *              function AllocateInBuffer is CODEC_IMAGE_HEIF
873  */
874 HWTEST_F(CodecHdiJpegTestAdditional, testCodecDoJpegDecode021, TestSize.Level2)
875 {
876     ASSERT_TRUE(hdiJpeg_ != nullptr);
877     struct CodecImageBuffer inBuffer;
878     auto ret = hdiJpeg_->AllocateInBuffer(inBuffer, NORMAL_BUFFER_SIZE, CODEC_IMAGE_JPEG);
879     if (ret == -1)
880     {
881         printf("jpeg is not supported!");
882         GTEST_SKIP() << "Device not exist" << std::endl;
883         return;
884     }
885     ASSERT_EQ(ret, HDF_SUCCESS);
886     struct CodecImageBuffer outBuffer;
887     ASSERT_NE(hdiJpeg_->AllocateInBuffer(outBuffer, NORMAL_BUFFER_SIZE, CODEC_IMAGE_HEIF), HDF_SUCCESS);
888     struct CodecJpegDecInfo decInfo;
889     decInfo.imageWidth = WIDTH;
890     decInfo.imageHeight = HEIGHT;
891     decInfo.dataPrecision = 8;
892 
893     ret = hdiJpeg_->DoJpegDecode(inBuffer, outBuffer, decInfo);
894     ASSERT_NE(ret, HDF_SUCCESS);
895 
896     ASSERT_EQ(hdiJpeg_->FreeInBuffer(inBuffer), HDF_SUCCESS);
897 }
898 
899 /**
900  * @tc.number : SUB_Driver_Codec_DoJpegDecode_3000
901  * @tc.name   : testCodecDoJpegDecode022
902  * @tc.desc   : Validation returns a failure when the third entry to the second prefix
903  *              function AllocateInBuffer is CODEC_IMAGE_INVALID
904  */
905 HWTEST_F(CodecHdiJpegTestAdditional, testCodecDoJpegDecode022, TestSize.Level2)
906 {
907     ASSERT_TRUE(hdiJpeg_ != nullptr);
908     struct CodecImageBuffer inBuffer;
909     auto ret = hdiJpeg_->AllocateInBuffer(inBuffer, NORMAL_BUFFER_SIZE, CODEC_IMAGE_JPEG);
910     if (ret == -1)
911     {
912         printf("jpeg is not supported!");
913         GTEST_SKIP() << "Device not exist" << std::endl;
914         return;
915     }
916     ASSERT_EQ(ret, HDF_SUCCESS);
917     struct CodecImageBuffer outBuffer;
918     ASSERT_NE(hdiJpeg_->AllocateInBuffer(outBuffer, NORMAL_BUFFER_SIZE, CODEC_IMAGE_INVALID), HDF_SUCCESS);
919     struct CodecJpegDecInfo decInfo;
920     decInfo.imageWidth = WIDTH;
921     decInfo.imageHeight = HEIGHT;
922     decInfo.dataPrecision = 8;
923 
924     ret = hdiJpeg_->DoJpegDecode(inBuffer, outBuffer, decInfo);
925     ASSERT_NE(ret, HDF_SUCCESS);
926 
927     ASSERT_EQ(hdiJpeg_->FreeInBuffer(inBuffer), HDF_SUCCESS);
928 }
929 
930 /**
931  * @tc.number : SUB_Driver_Codec_DoJpegDecode_3100
932  * @tc.name   : testCodecDoJpegDecode023
933  * @tc.desc   : Verification fails when the second entry of the first prefix
934  *              function AllocateInBuffer is 50 * 1024 * 1024 +1
935  */
936 HWTEST_F(CodecHdiJpegTestAdditional, testCodecDoJpegDecode023, TestSize.Level2)
937 {
938     ASSERT_TRUE(hdiJpeg_ != nullptr);
939     struct CodecImageBuffer inBuffer;
940     ASSERT_NE(hdiJpeg_->AllocateInBuffer(inBuffer, CODEC_IMAGE_MAX_BUFFER_SIZE + 1, CODEC_IMAGE_JPEG), HDF_SUCCESS);
941     struct CodecImageBuffer outBuffer;
942     auto ret = hdiJpeg_->AllocateInBuffer(outBuffer, NORMAL_BUFFER_SIZE, CODEC_IMAGE_JPEG);
943     if (ret == -1)
944     {
945         printf("jpeg is not supported!");
946         GTEST_SKIP() << "Device not exist" << std::endl;
947         return;
948     }
949     ASSERT_EQ(ret, HDF_SUCCESS);
950     struct CodecJpegDecInfo decInfo;
951     decInfo.imageWidth = WIDTH;
952     decInfo.imageHeight = HEIGHT;
953     decInfo.dataPrecision = 0;
954 
955     ret = hdiJpeg_->DoJpegDecode(inBuffer, outBuffer, decInfo);
956     ASSERT_NE(ret, HDF_SUCCESS);
957 
958     ASSERT_EQ(hdiJpeg_->FreeInBuffer(outBuffer), HDF_SUCCESS);
959 }
960 
961 /**
962  * @tc.number : SUB_Driver_Codec_GetImageCapability_3200
963  * @tc.name   : testCodecGetImageCapability009
964  * @tc.desc   : Verify that the GetImageCapability function returns a successful result when its argument is null
965  */
966 HWTEST_F(CodecHdiJpegTestAdditional, testCodecGetImageCapability009, TestSize.Level1)
967 {
968     ASSERT_TRUE(hdiJpeg_ != nullptr);
969     std::vector<CodecImageCapability> capList;
970     auto ret = hdiJpeg_->GetImageCapability(capList);
971     ASSERT_EQ(ret, HDF_SUCCESS);
972 }
973 
974 /**
975  * @tc.number : SUB_Driver_Codec_GetImageCapability_3300
976  * @tc.name   : testCodecGetImageCapability010
977  * @tc.desc   : Verify that when the GetImageCapability function argument CodecImageCapability
978  *              structure->name = "abc", the result is returned successfully
979  */
980 HWTEST_F(CodecHdiJpegTestAdditional, testCodecGetImageCapability010, TestSize.Level1)
981 {
982     ASSERT_TRUE(hdiJpeg_ != nullptr);
983     std::vector<CodecImageCapability> capList(1);
984     capList[0].name = "abc";
985     auto ret = hdiJpeg_->GetImageCapability(capList);
986     ASSERT_EQ(ret, HDF_SUCCESS);
987     ASSERT_NE(capList[0].name, "abc");
988 }
989 
990 /**
991  * @tc.number : SUB_Driver_Codec_GetImageCapability_3400
992  * @tc.name   : testCodecGetImageCapability011
993  * @tc.desc   : Verify that the GetImageCapability function parameter CodecImageCapability
994  *              structure ->role = CODEC_IMAGE_JPEG returns a successful result
995  */
996 HWTEST_F(CodecHdiJpegTestAdditional, testCodecGetImageCapability011, TestSize.Level1)
997 {
998     ASSERT_TRUE(hdiJpeg_ != nullptr);
999     std::vector<CodecImageCapability> capList(1);
1000     capList[0].role = CODEC_IMAGE_JPEG;
1001     auto ret = hdiJpeg_->GetImageCapability(capList);
1002     ASSERT_EQ(ret, HDF_SUCCESS);
1003 }
1004 
1005 /**
1006  * @tc.number : SUB_Driver_Codec_GetImageCapability_3500
1007  * @tc.name   : testCodecGetImageCapability012
1008  * @tc.desc   : Verify that the GetImageCapability function parameter CodecImageCapability
1009  *              structure ->role = CODEC_IMAGE_HEIF returns a successful result
1010  */
1011 HWTEST_F(CodecHdiJpegTestAdditional, testCodecGetImageCapability012, TestSize.Level1)
1012 {
1013     ASSERT_TRUE(hdiJpeg_ != nullptr);
1014     std::vector<CodecImageCapability> capList(1);
1015     capList[0].role = CODEC_IMAGE_HEIF;
1016     auto ret = hdiJpeg_->GetImageCapability(capList);
1017     ASSERT_EQ(ret, HDF_SUCCESS);
1018 }
1019 
1020 /**
1021  * @tc.number : SUB_Driver_Codec_GetImageCapability_3600
1022  * @tc.name   : testCodecGetImageCapability013
1023  * @tc.desc   : Verify that the GetImageCapability function parameter CodecImageCapability
1024  *              structure ->role = CODEC_IMAGE_INVALID returns a successful result
1025  */
1026 HWTEST_F(CodecHdiJpegTestAdditional, testCodecGetImageCapability013, TestSize.Level1)
1027 {
1028     ASSERT_TRUE(hdiJpeg_ != nullptr);
1029     std::vector<CodecImageCapability> capList(1);
1030     capList[0].role = CODEC_IMAGE_INVALID;
1031     auto ret = hdiJpeg_->GetImageCapability(capList);
1032     ASSERT_EQ(ret, HDF_SUCCESS);
1033 }
1034 
1035 /**
1036  * @tc.number : SUB_Driver_Codec_GetImageCapability_3700
1037  * @tc.name   : testCodecGetImageCapability014
1038  * @tc.desc   : Verify that the GetImageCapability function argument CodecImageCapability
1039  *              structure ->minWidth = 0 returns a successful result
1040  */
1041 HWTEST_F(CodecHdiJpegTestAdditional, testCodecGetImageCapability014, TestSize.Level1)
1042 {
1043     ASSERT_TRUE(hdiJpeg_ != nullptr);
1044     std::vector<CodecImageCapability> capList(1);
1045     capList[0].minWidth = 0;
1046     auto ret = hdiJpeg_->GetImageCapability(capList);
1047     ASSERT_EQ(ret, HDF_SUCCESS);
1048 }
1049 
1050 /**
1051  * @tc.number : SUB_Driver_Codec_GetImageCapability_3800
1052  * @tc.name   : testCodecGetImageCapability015
1053  * @tc.desc   : Verify that when the GetImageCapability function argument CodecImageCapability
1054  *              structure ->minWidth = 1000, the result is successful
1055  */
1056 HWTEST_F(CodecHdiJpegTestAdditional, testCodecGetImageCapability015, TestSize.Level1)
1057 {
1058     ASSERT_TRUE(hdiJpeg_ != nullptr);
1059     std::vector<CodecImageCapability> capList(1);
1060     capList[0].minWidth = 1000;
1061     auto ret = hdiJpeg_->GetImageCapability(capList);
1062     ASSERT_EQ(ret, HDF_SUCCESS);
1063 }
1064 
1065 /**
1066  * @tc.number : SUB_Driver_Codec_GetImageCapability_3900
1067  * @tc.name   : testCodecGetImageCapability016
1068  * @tc.desc   : Verify that when the GetImageCapability function argument CodecImageCapability
1069  *              structure ->minHeight = 0, the result is successful
1070  */
1071 HWTEST_F(CodecHdiJpegTestAdditional, testCodecGetImageCapability016, TestSize.Level1)
1072 {
1073     ASSERT_TRUE(hdiJpeg_ != nullptr);
1074     std::vector<CodecImageCapability> capList(1);
1075     capList[0].minHeight = 0;
1076     auto ret = hdiJpeg_->GetImageCapability(capList);
1077     ASSERT_EQ(ret, HDF_SUCCESS);
1078 }
1079 
1080 /**
1081  * @tc.number : SUB_Driver_Codec_AllocateInBuffer_4000
1082  * @tc.name   : testCodecAllocateInBuffer007
1083  * @tc.desc   : Verify that the AllocateInBuffer function returns a failure
1084  *              when the second argument is 50 * 1024 * 1024 +1
1085  */
1086 HWTEST_F(CodecHdiJpegTestAdditional, testCodecAllocateInBuffer007, TestSize.Level2)
1087 {
1088     ASSERT_TRUE(hdiJpeg_ != nullptr);
1089     struct CodecImageBuffer inBuffer;
1090     auto ret = hdiJpeg_->AllocateInBuffer(inBuffer, CODEC_IMAGE_MAX_BUFFER_SIZE + 1, CODEC_IMAGE_JPEG);
1091     ASSERT_NE(ret, HDF_SUCCESS);
1092 }
1093 
1094 /**
1095  * @tc.number : SUB_Driver_Codec_AllocateInBuffer_4100
1096  * @tc.name   : testCodecAllocateInBuffer008
1097  * @tc.desc   : Verify that failure is returned when the third argument of the AllocateInBuffer
1098  *              function is CODEC_IMAGE_HEIF
1099  */
1100 HWTEST_F(CodecHdiJpegTestAdditional, testCodecAllocateInBuffer008, TestSize.Level2)
1101 {
1102     ASSERT_TRUE(hdiJpeg_ != nullptr);
1103     struct CodecImageBuffer inBuffer;
1104     auto ret = hdiJpeg_->AllocateInBuffer(inBuffer, NORMAL_BUFFER_SIZE, CODEC_IMAGE_HEIF);
1105     ASSERT_NE(ret, HDF_SUCCESS);
1106 }
1107 
1108 /**
1109  * @tc.number : SUB_Driver_Codec_AllocateInBuffer_4200
1110  * @tc.name   : testCodecAllocateInBuffer009
1111  * @tc.desc   : Verify that a failure is returned when the third argument of
1112  *              the AllocateInBuffer function is CODEC_IMAGE_INVALID
1113  */
1114 HWTEST_F(CodecHdiJpegTestAdditional, testCodecAllocateInBuffer009, TestSize.Level2)
1115 {
1116     ASSERT_TRUE(hdiJpeg_ != nullptr);
1117     struct CodecImageBuffer inBuffer;
1118     auto ret = hdiJpeg_->AllocateInBuffer(inBuffer, NORMAL_BUFFER_SIZE, CODEC_IMAGE_INVALID);
1119     ASSERT_NE(ret, HDF_SUCCESS);
1120 }
1121 
1122 /**
1123  * @tc.number : SUB_Driver_Codec_AllocateInBuffer_4300
1124  * @tc.name   : testCodecAllocateInBuffer010
1125  * @tc.desc   : Determines the result of the function with inBuffer.fenceFd = -1 and CODEC_IMAGE_HEIF
1126  */
1127 HWTEST_F(CodecHdiJpegTestAdditional, testCodecAllocateInBuffer010, Function | MediumTest | Level2)
1128 {
1129     ASSERT_TRUE(hdiJpeg_ != nullptr);
1130     struct CodecImageBuffer inBuffer;
1131     inBuffer.fenceFd = -1;
1132     auto ret = hdiJpeg_->AllocateInBuffer(inBuffer, NORMAL_BUFFER_SIZE, CODEC_IMAGE_HEIF);
1133     if (ret == HDF_SUCCESS) {
1134         ret = hdiJpeg_->FreeInBuffer(inBuffer);
1135         ASSERT_EQ(ret, HDF_SUCCESS);
1136     } else {
1137         ASSERT_NE(ret, HDF_SUCCESS);
1138     }
1139 }
1140 
1141 /**
1142  * @tc.number : SUB_Driver_Codec_AllocateInBuffer_4400
1143  * @tc.name   : testCodecAllocateInBuffer011
1144  * @tc.desc   : Determines the result of the function with inBuffer.buffer = 0 and CODEC_IMAGE_HEIF
1145  */
1146 HWTEST_F(CodecHdiJpegTestAdditional, testCodecAllocateInBuffer011, Function | MediumTest | Level2)
1147 {
1148     ASSERT_TRUE(hdiJpeg_ != nullptr);
1149     struct CodecImageBuffer inBuffer;
1150     inBuffer.buffer = 0;
1151     auto ret = hdiJpeg_->AllocateInBuffer(inBuffer, NORMAL_BUFFER_SIZE, CODEC_IMAGE_HEIF);
1152     if (ret == HDF_SUCCESS) {
1153         ret = hdiJpeg_->FreeInBuffer(inBuffer);
1154         ASSERT_EQ(ret, HDF_SUCCESS);
1155     } else {
1156         ASSERT_NE(ret, HDF_SUCCESS);
1157     }
1158 }
1159 
1160 /**
1161  * @tc.number : SUB_Driver_Codec_AllocateInBuffer_4500
1162  * @tc.name   : testCodecAllocateInBuffer012
1163  * @tc.desc   : Determines the result of the function with inBuffer.size = -1 and CODEC_IMAGE_HEIF
1164  */
1165 HWTEST_F(CodecHdiJpegTestAdditional, testCodecAllocateInBuffer012, Function | MediumTest | Level2)
1166 {
1167     ASSERT_TRUE(hdiJpeg_ != nullptr);
1168     struct CodecImageBuffer inBuffer;
1169     inBuffer.size = -1;
1170     auto ret = hdiJpeg_->AllocateInBuffer(inBuffer, NORMAL_BUFFER_SIZE, CODEC_IMAGE_HEIF);
1171     if (ret == HDF_SUCCESS) {
1172         ret = hdiJpeg_->FreeInBuffer(inBuffer);
1173         ASSERT_EQ(ret, HDF_SUCCESS);
1174     } else {
1175         ASSERT_NE(ret, HDF_SUCCESS);
1176     }
1177 }
1178 
1179 /**
1180  * @tc.number : SUB_Driver_Codec_AllocateInBuffer_4600
1181  * @tc.name   : testCodecAllocateInBuffer013
1182  * @tc.desc   : Determines the result of the function with inBuffer.id = -1 and CODEC_IMAGE_HEIF
1183  */
1184 HWTEST_F(CodecHdiJpegTestAdditional, testCodecAllocateInBuffer013, Function | MediumTest | Level2)
1185 {
1186     ASSERT_TRUE(hdiJpeg_ != nullptr);
1187     struct CodecImageBuffer inBuffer;
1188     inBuffer.id = -1;
1189     auto ret = hdiJpeg_->AllocateInBuffer(inBuffer, NORMAL_BUFFER_SIZE, CODEC_IMAGE_HEIF);
1190     if (ret == HDF_SUCCESS) {
1191         ret = hdiJpeg_->FreeInBuffer(inBuffer);
1192         ASSERT_EQ(ret, HDF_SUCCESS);
1193     } else {
1194         ASSERT_NE(ret, HDF_SUCCESS);
1195     }
1196 }
1197 
1198 /**
1199  * @tc.number : SUB_Driver_Codec_FreeInBuffer_4300
1200  * @tc.name   : testCodecFreeInBuffer004
1201  * @tc.desc   : Verify that the FreeInBuffer function returns a failure when its
1202  *              entry is the CodecImageBuffer structure ->size = 0
1203  */
1204 HWTEST_F(CodecHdiJpegTestAdditional, testCodecFreeInBuffer004, TestSize.Level2)
1205 {
1206     ASSERT_TRUE(hdiJpeg_ != nullptr);
1207     struct CodecImageBuffer inBuffer;
1208     inBuffer.size = 0;
1209     auto ret = hdiJpeg_->FreeInBuffer(inBuffer);
1210     ASSERT_EQ(ret, HDF_SUCCESS);
1211 }
1212 
1213 /**
1214  * @tc.number : SUB_Driver_Codec_FreeInBuffer_4400
1215  * @tc.name   : testCodecFreeInBuffer005
1216  * @tc.desc   : Verify that the FreeInBuffer function returns a failure when its entry is
1217  *              CodecImageBuffer structure ->size = 50 * 1024 * 1024 +1
1218  */
1219 HWTEST_F(CodecHdiJpegTestAdditional, testCodecFreeInBuffer005, TestSize.Level2)
1220 {
1221     ASSERT_TRUE(hdiJpeg_ != nullptr);
1222     struct CodecImageBuffer inBuffer;
1223     inBuffer.size = CODEC_IMAGE_MAX_BUFFER_SIZE + 1;
1224     auto ret = hdiJpeg_->FreeInBuffer(inBuffer);
1225     ASSERT_EQ(ret, HDF_SUCCESS);
1226 }
1227 
1228 /**
1229  * @tc.number : SUB_Driver_Codec_FreeInBuffer_4500
1230  * @tc.name   : testCodecFreeInBuffer006
1231  * @tc.desc   : Verify that when the input to the FreeInBuffer function is CodecImageBuffer structure ->size = 1000
1232  *              bufferRole = CODEC_IMAGE_JPEG, the result returns success
1233  */
1234 HWTEST_F(CodecHdiJpegTestAdditional, testCodecFreeInBuffer006, TestSize.Level1)
1235 {
1236     ASSERT_TRUE(hdiJpeg_ != nullptr);
1237     struct CodecImageBuffer inBuffer;
1238     auto ret = hdiJpeg_->AllocateInBuffer(inBuffer, NORMAL_BUFFER_SIZE, CODEC_IMAGE_JPEG);
1239     if (ret == -1)
1240     {
1241         printf("jpeg is not supported!");
1242         GTEST_SKIP() << "Device not exist" << std::endl;
1243         return;
1244     }
1245     ASSERT_EQ(ret, HDF_SUCCESS);
1246     ret = hdiJpeg_->FreeInBuffer(inBuffer);
1247     ASSERT_EQ(ret, HDF_SUCCESS);
1248 }
1249 
1250 /**
1251  * @tc.number : SUB_Driver_Codec_FreeInBuffer_4600
1252  * @tc.name   : testCodecFreeInBuffer007
1253  * @tc.desc   : Verify that the FreeInBuffer function returns a failure when the entry to the function is
1254  *              CodecImageBuffer structure ->bufferRole = CODEC_IMAGE_HEIF
1255  */
1256 HWTEST_F(CodecHdiJpegTestAdditional, testCodecFreeInBuffer007, TestSize.Level2)
1257 {
1258     ASSERT_TRUE(hdiJpeg_ != nullptr);
1259     struct CodecImageBuffer inBuffer;
1260     ASSERT_NE(hdiJpeg_->AllocateInBuffer(inBuffer, NORMAL_BUFFER_SIZE, CODEC_IMAGE_HEIF), HDF_SUCCESS);
1261     auto ret = hdiJpeg_->FreeInBuffer(inBuffer);
1262     ASSERT_EQ(ret, HDF_SUCCESS);
1263 }
1264 
1265 /**
1266  * @tc.number : SUB_Driver_Codec_FreeInBuffer_4700
1267  * @tc.name   : testCodecFreeInBuffer008
1268  * @tc.desc   : Verify that the FreeInBuffer function returns a failure when the entry to the function is
1269  *              CodecImageBuffer structure ->bufferRole = CODEC_IMAGE_INVALID
1270  */
1271 HWTEST_F(CodecHdiJpegTestAdditional, testCodecFreeInBuffer008, TestSize.Level2)
1272 {
1273     ASSERT_TRUE(hdiJpeg_ != nullptr);
1274     struct CodecImageBuffer inBuffer;
1275     ASSERT_NE(hdiJpeg_->AllocateInBuffer(inBuffer, NORMAL_BUFFER_SIZE, CODEC_IMAGE_INVALID), HDF_SUCCESS);
1276     auto ret = hdiJpeg_->FreeInBuffer(inBuffer);
1277     ASSERT_EQ(ret, HDF_SUCCESS);
1278 }
1279 } // namespace