• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 
18 #include "metadata_helper.h"
19 #include "surface_buffer_impl.h"
20 
21 using namespace testing::ext;
22 using namespace OHOS::HDI::Display::Graphic::Common::V1_0;
23 
24 namespace OHOS {
25 class MetadataManagerTest : public testing::Test {
26 public:
27     static void SetUpTestCase();
28     static void TearDownTestCase();
29 
30     static inline BufferRequestConfig requestConfig = {
31         .width = 0x100,
32         .height = 0x100,
33         .strideAlignment = 0x8,
34         .format = GRAPHIC_PIXEL_FMT_RGBA_8888,
35         .usage = BUFFER_USAGE_CPU_READ | BUFFER_USAGE_CPU_WRITE | BUFFER_USAGE_MEM_DMA,
36         .timeout = 0,
37         .colorGamut = GraphicColorGamut::GRAPHIC_COLOR_GAMUT_SRGB,
38     };
39     static inline sptr<SurfaceBuffer> buffer_ = nullptr;
40     static inline sptr<SurfaceBuffer> nullBuffer_ = nullptr;
41 };
42 
SetUpTestCase()43 void MetadataManagerTest::SetUpTestCase()
44 {
45     buffer_ = new SurfaceBufferImpl(0);
46     auto ret = buffer_->Alloc(requestConfig);
47     ASSERT_EQ(ret, GSERROR_OK);
48 }
49 
TearDownTestCase()50 void MetadataManagerTest::TearDownTestCase()
51 {
52     nullBuffer_ = nullptr;
53     buffer_ = nullptr;
54 }
55 
56 /*
57 * Function: MetadataManagerTest
58 * Type: Function
59 * Rank: Important(2)
60 * EnvConditions: N/A
61 * CaseDescription: test ConvertMetadataToVec
62 */
63 HWTEST_F(MetadataManagerTest, ConvertMetadataToVecTest, Function | SmallTest | Level1)
64 {
65     uint32_t metadata = 0;
66     std::vector<uint8_t> vec;
67     ASSERT_EQ(MetadataHelper::ConvertMetadataToVec(metadata, vec), GSERROR_OK);
68 
69     ASSERT_EQ(vec.size(), 4);
70     for (uint32_t i = 0; i < vec.size(); ++i) {
71         ASSERT_EQ(vec[i], 0);
72     }
73 }
74 
75 /*
76 * Function: MetadataManagerTest
77 * Type: Function
78 * Rank: Important(2)
79 * EnvConditions: N/A
80 * CaseDescription: test ConvertVecToMetadata
81 */
82 HWTEST_F(MetadataManagerTest, ConvertVecToMetadataTest, Function | SmallTest | Level1)
83 {
84     std::vector<uint8_t> vec;
85     uint32_t metadata = 1;
86     ASSERT_EQ(MetadataHelper::ConvertVecToMetadata(vec, metadata), GSERROR_NOT_SUPPORT);
87 
88     vec.assign(4, 0);
89     ASSERT_EQ(MetadataHelper::ConvertVecToMetadata(vec, metadata), GSERROR_OK);
90     ASSERT_EQ(metadata, 0);
91 }
92 
93 /*
94 * Function: MetadataManagerTest
95 * Type: Function
96 * Rank: Important(2)
97 * EnvConditions: N/A
98 * CaseDescription: test ConvertColorSpaceTypeToInfo
99 */
100 HWTEST_F(MetadataManagerTest, ConvertColorSpaceTypeToInfoTest, Function | SmallTest | Level1)
101 {
102     CM_ColorSpaceInfo colorSpaceInfo;
103     ASSERT_EQ(MetadataHelper::ConvertColorSpaceTypeToInfo(CM_SRGB_FULL, colorSpaceInfo), GSERROR_OK);
104 
105     ASSERT_EQ(colorSpaceInfo.primaries, COLORPRIMARIES_SRGB);
106     ASSERT_EQ(colorSpaceInfo.transfunc, TRANSFUNC_SRGB);
107     ASSERT_EQ(colorSpaceInfo.matrix, MATRIX_BT601_N);
108     ASSERT_EQ(colorSpaceInfo.range, RANGE_FULL);
109 }
110 
111 /*
112 * Function: MetadataManagerTest
113 * Type: Function
114 * Rank: Important(2)
115 * EnvConditions: N/A
116 * CaseDescription: test ConvertColorSpaceInfoToType
117 */
118 HWTEST_F(MetadataManagerTest, ConvertColorSpaceInfoToTypeTest, Function | SmallTest | Level1)
119 {
120     CM_ColorSpaceInfo colorSpaceInfo = {
121         .primaries = COLORPRIMARIES_SRGB,
122         .transfunc = TRANSFUNC_SRGB,
123         .matrix = MATRIX_BT601_N,
124         .range = RANGE_FULL,
125     };
126     CM_ColorSpaceType colorSpaceType;
127     ASSERT_EQ(MetadataHelper::ConvertColorSpaceInfoToType(colorSpaceInfo, colorSpaceType), GSERROR_OK);
128 
129     ASSERT_EQ(colorSpaceType, CM_SRGB_FULL);
130 }
131 
132 /*
133 * Function: MetadataManagerTest
134 * Type: Function
135 * Rank: Important(2)
136 * EnvConditions: N/A
137 * CaseDescription: test SetColorSpaceInfo and GetColorSpaceInfo
138 */
139 HWTEST_F(MetadataManagerTest, ColorSpaceInfoTest, Function | SmallTest | Level1)
140 {
141     CM_ColorSpaceInfo infoSet = {
142         .primaries = COLORPRIMARIES_SRGB,
143         .transfunc = TRANSFUNC_SRGB,
144         .matrix = MATRIX_BT709,
145         .range = RANGE_FULL,
146     };
147 
148     auto retSet = MetadataHelper::SetColorSpaceInfo(buffer_, infoSet);
149     ASSERT_TRUE(retSet == GSERROR_OK || retSet == GSERROR_HDI_ERROR);
150 
151     CM_ColorSpaceInfo infoGet;
152     auto retGet = MetadataHelper::GetColorSpaceInfo(buffer_, infoGet);
153     ASSERT_TRUE(retGet == GSERROR_OK || retSet == GSERROR_HDI_ERROR);
154 
155     if (retSet == GSERROR_OK && retGet == GSERROR_OK) {
156         ASSERT_EQ(infoSet.primaries, infoGet.primaries);
157         ASSERT_EQ(infoSet.transfunc, infoGet.transfunc);
158         ASSERT_EQ(infoSet.matrix, infoGet.matrix);
159         ASSERT_EQ(infoSet.range, infoGet.range);
160     }
161 
162     ASSERT_EQ(MetadataHelper::SetColorSpaceInfo(nullBuffer_, infoSet), GSERROR_NO_BUFFER);
163     ASSERT_EQ(MetadataHelper::GetColorSpaceInfo(nullBuffer_, infoGet), GSERROR_NO_BUFFER);
164 }
165 
166 /*
167 * Function: MetadataManagerTest
168 * Type: Function
169 * Rank: Important(2)
170 * EnvConditions: N/A
171 * CaseDescription: test SetColorSpaceType and GetColorSpaceType
172 */
173 HWTEST_F(MetadataManagerTest, ColorSpaceTypeTest, Function | SmallTest | Level1)
174 {
175     auto retSet = MetadataHelper::SetColorSpaceType(buffer_, CM_SRGB_FULL);
176     ASSERT_TRUE(retSet == GSERROR_OK || retSet == GSERROR_HDI_ERROR);
177 
178     CM_ColorSpaceType colorSpaceType;
179     auto retGet = MetadataHelper::GetColorSpaceType(buffer_, colorSpaceType);
180     ASSERT_TRUE(retGet == GSERROR_OK || retSet == GSERROR_HDI_ERROR);
181 
182     if (retSet == GSERROR_OK && retGet == GSERROR_OK) {
183         ASSERT_EQ(colorSpaceType, CM_SRGB_FULL);
184     }
185 
186     ASSERT_EQ(MetadataHelper::SetColorSpaceType(nullBuffer_, CM_SRGB_FULL), GSERROR_NO_BUFFER);
187     ASSERT_EQ(MetadataHelper::GetColorSpaceType(nullBuffer_, colorSpaceType), GSERROR_NO_BUFFER);
188 }
189 
190 /*
191 * Function: MetadataManagerTest
192 * Type: Function
193 * Rank: Important(2)
194 * EnvConditions: N/A
195 * CaseDescription: test SetHDRMetadataType and GetHDRMetadataType
196 */
197 HWTEST_F(MetadataManagerTest, HDRMetadataTypeTest, Function | SmallTest | Level1)
198 {
199     auto retSet = MetadataHelper::SetHDRMetadataType(buffer_, CM_VIDEO_HDR_VIVID);
200     ASSERT_TRUE(retSet == GSERROR_OK || retSet == GSERROR_HDI_ERROR);
201 
202     CM_HDR_Metadata_Type hdrMetadataType;
203     auto retGet = MetadataHelper::GetHDRMetadataType(buffer_, hdrMetadataType);
204     ASSERT_TRUE(retGet == GSERROR_OK || retSet == GSERROR_HDI_ERROR);
205 
206     if (retSet == GSERROR_OK && retGet == GSERROR_OK) {
207         ASSERT_EQ(hdrMetadataType, CM_VIDEO_HDR_VIVID);
208     }
209 
210     ASSERT_EQ(MetadataHelper::SetHDRMetadataType(nullBuffer_, CM_VIDEO_HDR_VIVID), GSERROR_NO_BUFFER);
211     ASSERT_EQ(MetadataHelper::GetHDRMetadataType(nullBuffer_, hdrMetadataType), GSERROR_NO_BUFFER);
212 }
213 
214 /*
215 * Function: MetadataManagerTest
216 * Type: Function
217 * Rank: Important(2)
218 * EnvConditions: N/A
219 * CaseDescription: test SetHDRStaticMetadata and GetHDRStaticMetadata
220 */
221 HWTEST_F(MetadataManagerTest, HDRStaticMetadataTest, Function | SmallTest | Level1)
222 {
223     HdrStaticMetadata metadataSet = {
224         .smpte2086 = {
225             .displayPrimaryRed = {0.1f, 0.1f},
226             .displayPrimaryGreen = {0.2f, 0.2f},
227             .displayPrimaryBlue = {0.3f, 0.3f},
228             .whitePoint = {0.4f, 0.4f},
229             .maxLuminance = 1000.0f,
230             .minLuminance = 0.1f,
231         },
232         .cta861 = {
233             .maxContentLightLevel = 500.0f,
234             .maxFrameAverageLightLevel = 300.0f,
235         },
236     };
237 
238     auto retSet = MetadataHelper::SetHDRStaticMetadata(buffer_, metadataSet);
239     ASSERT_TRUE(retSet == GSERROR_OK || retSet == GSERROR_HDI_ERROR);
240 
241     HdrStaticMetadata metadataGet;
242     auto retGet = MetadataHelper::GetHDRStaticMetadata(buffer_, metadataGet);
243     ASSERT_TRUE(retGet == GSERROR_OK || retSet == GSERROR_HDI_ERROR);
244 
245     if (retSet == GSERROR_OK && retGet == GSERROR_OK) {
246         ASSERT_EQ(metadataSet.smpte2086.displayPrimaryRed.x, metadataGet.smpte2086.displayPrimaryRed.x);
247         ASSERT_EQ(metadataSet.smpte2086.displayPrimaryRed.y, metadataGet.smpte2086.displayPrimaryRed.y);
248         ASSERT_EQ(metadataSet.smpte2086.displayPrimaryGreen.x, metadataGet.smpte2086.displayPrimaryGreen.x);
249         ASSERT_EQ(metadataSet.smpte2086.displayPrimaryGreen.y, metadataGet.smpte2086.displayPrimaryGreen.y);
250         ASSERT_EQ(metadataSet.smpte2086.displayPrimaryBlue.x, metadataGet.smpte2086.displayPrimaryBlue.x);
251         ASSERT_EQ(metadataSet.smpte2086.displayPrimaryBlue.y, metadataGet.smpte2086.displayPrimaryBlue.y);
252         ASSERT_EQ(metadataSet.smpte2086.whitePoint.x, metadataGet.smpte2086.whitePoint.x);
253         ASSERT_EQ(metadataSet.smpte2086.whitePoint.y, metadataGet.smpte2086.whitePoint.y);
254         ASSERT_EQ(metadataSet.smpte2086.maxLuminance, metadataGet.smpte2086.maxLuminance);
255         ASSERT_EQ(metadataSet.smpte2086.minLuminance, metadataGet.smpte2086.minLuminance);
256         ASSERT_EQ(metadataSet.cta861.maxContentLightLevel, metadataGet.cta861.maxContentLightLevel);
257         ASSERT_EQ(metadataSet.cta861.maxFrameAverageLightLevel, metadataGet.cta861.maxFrameAverageLightLevel);
258     }
259 
260     ASSERT_EQ(MetadataHelper::SetHDRStaticMetadata(nullBuffer_, metadataSet), GSERROR_NO_BUFFER);
261     ASSERT_EQ(MetadataHelper::GetHDRStaticMetadata(nullBuffer_, metadataGet), GSERROR_NO_BUFFER);
262 }
263 
264 /*
265 * Function: MetadataManagerTest
266 * Type: Function
267 * Rank: Important(2)
268 * EnvConditions: N/A
269 * CaseDescription: test SetHDRDynamicMetadata and GetHDRDynamicMetadata
270 */
271 HWTEST_F(MetadataManagerTest, HDRDynamicMetadataTest, Function | SmallTest | Level1)
272 {
273     std::vector<uint8_t> metadataSet{1, 18, 119, 33, 196, 253, 112, 171, 74, 230, 99, 23, 0, 244, 82, 138, 13, 158, 100,
274         41, 50, 189, 111, 144, 3, 153, 75, 210, 243, 237, 19, 12, 128};
275 
276     auto retSet = MetadataHelper::SetHDRDynamicMetadata(buffer_, metadataSet);
277     ASSERT_TRUE(retSet == GSERROR_OK || retSet == GSERROR_HDI_ERROR);
278 
279     std::vector<uint8_t> metadataGet;
280     auto retGet = MetadataHelper::GetHDRDynamicMetadata(buffer_, metadataGet);
281     ASSERT_TRUE(retGet == GSERROR_OK || retSet == GSERROR_HDI_ERROR);
282 
283     if (retSet == GSERROR_OK && retGet == GSERROR_OK) {
284         ASSERT_EQ(metadataSet.size(), metadataGet.size());
285         for (uint32_t i = 0; i < metadataSet.size(); i++) {
286             ASSERT_EQ(metadataSet[i], metadataGet[i]);
287         }
288     }
289 
290     ASSERT_EQ(MetadataHelper::SetHDRDynamicMetadata(nullBuffer_, metadataSet), GSERROR_NO_BUFFER);
291     ASSERT_EQ(MetadataHelper::GetHDRDynamicMetadata(nullBuffer_, metadataGet), GSERROR_NO_BUFFER);
292 }
293 
294 /*
295 * Function: MetadataManagerTest
296 * Type: Function
297 * Rank: Important(2)
298 * EnvConditions: N/A
299 * CaseDescription: test SetHDRStaticMetadata and GetHDRStaticMetadata
300 */
301 HWTEST_F(MetadataManagerTest, HDRStaticMetadataVecTest, Function | SmallTest | Level1)
302 {
303     HdrStaticMetadata metadata = {
304         .smpte2086 = {
305             .displayPrimaryRed = {0.1f, 0.1f},
306             .displayPrimaryGreen = {0.2f, 0.2f},
307             .displayPrimaryBlue = {0.3f, 0.3f},
308             .whitePoint = {0.4f, 0.4f},
309             .maxLuminance = 1000.0f,
310             .minLuminance = 0.1f,
311         },
312         .cta861 = {
313             .maxContentLightLevel = 500.0f,
314             .maxFrameAverageLightLevel = 300.0f,
315         },
316     };
317 
318     std::vector<uint8_t> metadataSet;
319     ASSERT_EQ(MetadataHelper::ConvertMetadataToVec(metadata, metadataSet), GSERROR_OK);
320 
321     auto retSet = MetadataHelper::SetHDRStaticMetadata(buffer_, metadataSet);
322     ASSERT_TRUE(retSet == GSERROR_OK || retSet == GSERROR_HDI_ERROR);
323 
324     std::vector<uint8_t> metadataGet;
325     auto retGet = MetadataHelper::GetHDRStaticMetadata(buffer_, metadataGet);
326     ASSERT_TRUE(retGet == GSERROR_OK || retSet == GSERROR_HDI_ERROR);
327 
328     if (retSet == GSERROR_OK && retGet == GSERROR_OK) {
329         ASSERT_EQ(metadataSet.size(), metadataGet.size());
330         for (uint32_t i = 0; i < metadataSet.size(); i++) {
331             ASSERT_EQ(metadataSet[i], metadataGet[i]);
332         }
333     }
334 
335     ASSERT_EQ(MetadataHelper::SetHDRStaticMetadata(nullBuffer_, metadataSet), GSERROR_NO_BUFFER);
336     ASSERT_EQ(MetadataHelper::GetHDRStaticMetadata(nullBuffer_, metadataGet), GSERROR_NO_BUFFER);
337 }
338 
339 /*
340 * Function: MetadataManagerTest
341 * Type: Function
342 * Rank: Important(2)
343 * EnvConditions: N/A
344 * CaseDescription: test SetAdaptiveFOVMetadata and GetAdaptiveFOVMetadata
345 */
346 HWTEST_F(MetadataManagerTest, AdaptiveFOVMetadataTest, Function | SmallTest | Level1)
347 {
348     std::vector<uint8_t> metadataSet{1, 18, 119, 33, 196, 253, 112, 171, 74, 230, 99, 23, 0, 244, 82,
349         138, 13, 158, 100, 41, 50, 189, 111, 144, 3, 153, 75, 210, 243, 237, 19, 12, 128};
350 
351     auto retSet = MetadataHelper::SetAdaptiveFOVMetadata(buffer_, metadataSet);
352     ASSERT_TRUE(retSet == GSERROR_OK || retSet == GSERROR_HDI_ERROR);
353 
354     std::vector<uint8_t> metadataGet;
355     auto retGet = MetadataHelper::GetAdaptiveFOVMetadata(buffer_, metadataGet);
356     ASSERT_TRUE(retGet == GSERROR_OK || retSet == GSERROR_HDI_ERROR);
357 
358     if (retSet == GSERROR_OK && retGet == GSERROR_OK) {
359         ASSERT_EQ(metadataSet.size(), metadataGet.size());
360         for (uint32_t i = 0; i < metadataSet.size(); i++) {
361             ASSERT_EQ(metadataSet[i], metadataGet[i]);
362         }
363     }
364 
365     ASSERT_EQ(MetadataHelper::SetAdaptiveFOVMetadata(nullBuffer_, metadataSet), GSERROR_NO_BUFFER);
366     ASSERT_EQ(MetadataHelper::GetAdaptiveFOVMetadata(nullBuffer_, metadataGet), GSERROR_NO_BUFFER);
367 }
368 
369 /*
370  * Function: MetadataManagerTest
371  * Type: Function
372  * Rank: Important(2)
373  * EnvConditions: N/A
374  * CaseDescription: test for image metaData
375  */
376 HWTEST_F(MetadataManagerTest, SetImageHDRMetadataTypeTest, Function | SmallTest | Level1)
377 {
378     uint8_t errorValue = 1;
379     ASSERT_EQ(MetadataHelper::IsImageMetadataType(&errorValue), false);
380     uint8_t value = 4;
381     ASSERT_EQ(MetadataHelper::IsImageMetadataType(&value), true);
382     auto ret = MetadataHelper::SetImageHDRMetadataType(buffer_, &value);
383     ASSERT_TRUE(ret == GSERROR_OK || ret == SURFACE_ERROR_NOT_SUPPORT);
384 }
385 
386 #ifdef RS_ENABLE_TV_PQ_METADATA
387 /*
388  * Function: MetadataManagerTest
389  * Type: Function
390  * Rank: Important(2)
391  * EnvConditions: N/A
392  * CaseDescription: test SetSceneTag
393  */
394 HWTEST_F(MetadataManagerTest, SetSceneTagTest, Function | SmallTest | Level1)
395 {
396     unsigned char value = 3;
397     GSError retSet = MetadataHelper::SetSceneTag(buffer_, value);
398     ASSERT_EQ(retSet, GSERROR_OK);
399 
400     TvPQMetadata tvPQMetadata;
401     GSError retGet = MetadataHelper::GetVideoTVMetadata(buffer_, tvPQMetadata);
402     ASSERT_EQ(retGet, GSERROR_OK);
403     ASSERT_EQ(tvPQMetadata.sceneTag, 3);
404 }
405 
406 /*
407  * Function: MetadataManagerTest
408  * Type: Function
409  * Rank: Important(2)
410  * EnvConditions: N/A
411  * CaseDescription: test SetUIFrameCount
412  */
413 HWTEST_F(MetadataManagerTest, SetUIFrameCountTest, Function | SmallTest | Level1)
414 {
415     unsigned char value = 60;
416     GSError retSet = MetadataHelper::SetUIFrameCount(buffer_, value);
417     ASSERT_EQ(retSet, GSERROR_OK);
418 
419     TvPQMetadata tvPQMetadata;
420     GSError retGet = MetadataHelper::GetVideoTVMetadata(buffer_, tvPQMetadata);
421     ASSERT_EQ(retGet, GSERROR_OK);
422     ASSERT_EQ(tvPQMetadata.uiFrameCnt, 60);
423 }
424 
425 /*
426  * Function: MetadataManagerTest
427  * Type: Function
428  * Rank: Important(2)
429  * EnvConditions: N/A
430  * CaseDescription: test SetVideoFrameCount
431  */
432 HWTEST_F(MetadataManagerTest, SetVideoFrameCountTest, Function | SmallTest | Level1)
433 {
434     unsigned char value = 168;
435     GSError retSet = MetadataHelper::SetVideoFrameCount(buffer_, value);
436     ASSERT_EQ(retSet, GSERROR_OK);
437 
438     TvPQMetadata tvPQMetadata;
439     GSError retGet = MetadataHelper::GetVideoTVMetadata(buffer_, tvPQMetadata);
440     ASSERT_EQ(retGet, GSERROR_OK);
441     ASSERT_EQ(tvPQMetadata.vidFrameCnt, 168);
442 }
443 
444 /*
445  * Function: MetadataManagerTest
446  * Type: Function
447  * Rank: Important(2)
448  * EnvConditions: N/A
449  * CaseDescription: test SetVideoFrameRate
450  */
451 HWTEST_F(MetadataManagerTest, SetVideoFrameRateTest, Function | SmallTest | Level1)
452 {
453     unsigned char value = 24;
454     GSError retSet = MetadataHelper::SetVideoFrameRate(buffer_, value);
455     ASSERT_EQ(retSet, GSERROR_OK);
456 
457     TvPQMetadata tvPQMetadata;
458     GSError retGet = MetadataHelper::GetVideoTVMetadata(buffer_, tvPQMetadata);
459     ASSERT_EQ(retGet, GSERROR_OK);
460     ASSERT_EQ(tvPQMetadata.vidFps, 24);
461 }
462 
463 /*
464  * Function: MetadataManagerTest
465  * Type: Function
466  * Rank: Important(2)
467  * EnvConditions: N/A
468  * CaseDescription: test SetVideoTVInfo
469  */
470 HWTEST_F(MetadataManagerTest, SetVideoTVInfoTest, Function | SmallTest | Level1)
471 {
472     TvVideoWindow tvVideoWindow = {400, 600, 1080, 720, 1};
473     GSError retSet = MetadataHelper::SetVideoTVInfo(buffer_, tvVideoWindow);
474     ASSERT_EQ(retSet, GSERROR_OK);
475 
476     TvPQMetadata tvPQMetadata;
477     GSError retGet = MetadataHelper::GetVideoTVMetadata(buffer_, tvPQMetadata);
478     ASSERT_EQ(retGet, GSERROR_OK);
479     ASSERT_EQ(tvPQMetadata.vidWinX, 400);
480     ASSERT_EQ(tvPQMetadata.vidWinY, 600);
481     ASSERT_EQ(tvPQMetadata.vidWinWidth, 1080);
482     ASSERT_EQ(tvPQMetadata.vidWinHeight, 720);
483     ASSERT_EQ(tvPQMetadata.vidWinSize, 1);
484 }
485 
486 /*
487  * Function: MetadataManagerTest
488  * Type: Function
489  * Rank: Important(2)
490  * EnvConditions: N/A
491  * CaseDescription: test SetVideoDecoderHigh
492  */
493 HWTEST_F(MetadataManagerTest, SetVideoDecoderHighTest, Function | SmallTest | Level1)
494 {
495     unsigned short vidVdhWidth = 1920;
496     unsigned short vidVdhHeight = 1080;
497     GSError retSet = MetadataHelper::SetVideoDecoderHigh(buffer_, vidVdhWidth, vidVdhHeight);
498     ASSERT_EQ(retSet, GSERROR_OK);
499 
500     TvPQMetadata tvPQMetadata;
501     GSError retGet = MetadataHelper::GetVideoTVMetadata(buffer_, tvPQMetadata);
502     ASSERT_EQ(retGet, GSERROR_OK);
503     ASSERT_EQ(tvPQMetadata.vidVdhWidth, 1920);
504     ASSERT_EQ(tvPQMetadata.vidVdhHeight, 1080);
505 }
506 
507 /*
508  * Function: MetadataManagerTest
509  * Type: Function
510  * Rank: Important(2)
511  * EnvConditions: N/A
512  * CaseDescription: test SetVideoTVScaleMode
513  */
514 HWTEST_F(MetadataManagerTest, SetVideoTVScaleModeTest, Function | SmallTest | Level1)
515 {
516     unsigned char value = 2;
517     GSError retSet = MetadataHelper::SetVideoTVScaleMode(buffer_, value);
518     ASSERT_EQ(retSet, GSERROR_OK);
519 
520     TvPQMetadata tvPQMetadata;
521     GSError retGet = MetadataHelper::GetVideoTVMetadata(buffer_, tvPQMetadata);
522     ASSERT_EQ(retGet, GSERROR_OK);
523     ASSERT_EQ(tvPQMetadata.scaleMode, 2);
524 }
525 
526 /*
527  * Function: MetadataManagerTest
528  * Type: Function
529  * Rank: Important(2)
530  * EnvConditions: N/A
531  * CaseDescription: test SetVideoTVDpPixelFormat
532  */
533 HWTEST_F(MetadataManagerTest, SetVideoTVDpPixelFormatTest, Function | SmallTest | Level1)
534 {
535     unsigned int value = 1;
536     GSError retSet = MetadataHelper::SetVideoTVDpPixelFormat(buffer_, value);
537     ASSERT_EQ(retSet, GSERROR_OK);
538 
539     TvPQMetadata tvPQMetadata;
540     GSError retGet = MetadataHelper::GetVideoTVMetadata(buffer_, tvPQMetadata);
541     ASSERT_EQ(retGet, GSERROR_OK);
542     ASSERT_EQ(tvPQMetadata.dpPixFmt, 1);
543 }
544 
545 /*
546  * Function: MetadataManagerTest
547  * Type: Function
548  * Rank: Important(2)
549  * EnvConditions: N/A
550  * CaseDescription: test SetVideoColorimetryHdr
551  */
552 HWTEST_F(MetadataManagerTest, SetVideoColorimetryHdrTest, Function | SmallTest | Level1)
553 {
554     unsigned char hdr = 3;
555     unsigned char colorimetry = 4;
556     GSError retSet = MetadataHelper::SetVideoColorimetryHdr(buffer_, hdr, colorimetry);
557     ASSERT_EQ(retSet, GSERROR_OK);
558 
559     TvPQMetadata tvPQMetadata;
560     GSError retGet = MetadataHelper::GetVideoTVMetadata(buffer_, tvPQMetadata);
561     ASSERT_EQ(retGet, GSERROR_OK);
562     ASSERT_EQ(tvPQMetadata.hdr, 3);
563     ASSERT_EQ(tvPQMetadata.colorimetry, 4);
564 }
565 
566 /*
567  * Function: MetadataManagerTest
568  * Type: Function
569  * Rank: Important(2)
570  * EnvConditions: N/A
571  * CaseDescription: test EraseVideoTVInfoKey
572  */
573 HWTEST_F(MetadataManagerTest, EraseVideoTVInfoKeyTest, Function | SmallTest | Level1)
574 {
575     unsigned char hdr = 3;
576     unsigned char colorimetry = 4;
577     GSError retSet = MetadataHelper::SetVideoColorimetryHdr(buffer_, hdr, colorimetry);
578     ASSERT_EQ(retSet, GSERROR_OK);
579 
580     TvPQMetadata tvPQMetadata;
581     GSError retGet = MetadataHelper::GetVideoTVMetadata(buffer_, tvPQMetadata);
582     ASSERT_EQ(retGet, GSERROR_OK);
583     ASSERT_EQ(tvPQMetadata.hdr, 3);
584     ASSERT_EQ(tvPQMetadata.colorimetry, 4);
585 
586     ASSERT_EQ(MetadataHelper::EraseVideoTVInfoKey(buffer_), GSERROR_OK);
587     ASSERT_NE(MetadataHelper::GetVideoTVMetadata(buffer_, tvPQMetadata), GSERROR_OK);
588 }
589 
590 /*
591  * Function: MetadataManagerTest
592  * Type: Function
593  * Rank: Important(2)
594  * EnvConditions: N/A
595  * CaseDescription: test for abnormal
596  */
597 HWTEST_F(MetadataManagerTest, TvMetadataAbnormalTest, Function | SmallTest | Level1)
598 {
599     TvPQMetadata tvMetadata = { 0 };
600     TvVideoWindow tvVideoWindow = { 0 };
601     sptr<OHOS::SurfaceBuffer> bufferPtr = nullptr;
602     ASSERT_NE(MetadataHelper::SetVideoTVMetadata(bufferPtr, tvMetadata), GSERROR_OK);
603     ASSERT_NE(MetadataHelper::GetVideoTVMetadata(bufferPtr, tvMetadata), GSERROR_OK);
604     ASSERT_NE(MetadataHelper::SetSceneTag(bufferPtr, 1), GSERROR_OK);
605     ASSERT_NE(MetadataHelper::SetUIFrameCount(bufferPtr, 1), GSERROR_OK);
606     ASSERT_NE(MetadataHelper::SetVideoFrameCount(bufferPtr, 1), GSERROR_OK);
607     ASSERT_NE(MetadataHelper::SetVideoFrameRate(bufferPtr, 1), GSERROR_OK);
608     ASSERT_NE(MetadataHelper::SetVideoDecoderHigh(bufferPtr, 1, 1), GSERROR_OK);
609     ASSERT_NE(MetadataHelper::SetVideoTVScaleMode(bufferPtr, 1), GSERROR_OK);
610     ASSERT_NE(MetadataHelper::SetVideoTVDpPixelFormat(bufferPtr, 1), GSERROR_OK);
611     ASSERT_NE(MetadataHelper::SetVideoColorimetryHdr(bufferPtr, 1, 1), GSERROR_OK);
612     ASSERT_NE(MetadataHelper::SetVideoTVInfo(bufferPtr, tvVideoWindow), GSERROR_OK);
613     ASSERT_NE(MetadataHelper::EraseVideoTVInfoKey(bufferPtr), GSERROR_OK);
614     ASSERT_EQ(MetadataHelper::EraseVideoTVInfoKey(bufferPtr), GSERROR_NO_BUFFER);
615 }
616 #endif
617 }