1 /*
2  * Copyright (c) 2021 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 "iconsumer_surface.h"
17 #include "hdi_layer_info.h"
18 #include "surface_tunnel_handle.h"
19 #include "sync_fence.h"
20 
21 #include <gtest/gtest.h>
22 
23 using namespace testing;
24 using namespace testing::ext;
25 
26 namespace OHOS {
27 namespace Rosen {
28 class HdiLayerInfoTest : public testing::Test {
29 public:
30     static void SetUpTestCase();
31     static void TearDownTestCase();
32 
33     static inline std::shared_ptr<HdiLayerInfo> hdiLayerInfo_;
34 };
35 
SetUpTestCase()36 void HdiLayerInfoTest::SetUpTestCase()
37 {
38     hdiLayerInfo_ = HdiLayerInfo::CreateHdiLayerInfo();
39 }
40 
TearDownTestCase()41 void HdiLayerInfoTest::TearDownTestCase() {}
42 
43 namespace {
44 /**
45  * @tc.name: GetZorder001
46  * @tc.desc: Verify the GetZorder of hdilayerinfo
47  * @tc.type:FUNC
48  * @tc.require:AR000GGP0P
49  * @tc.author:
50  */
51 HWTEST_F(HdiLayerInfoTest, GetZorder001, Function | MediumTest| Level3)
52 {
53     HdiLayerInfoTest::hdiLayerInfo_->SetZorder(1);
54     ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetZorder(), 1u);
55 }
56 
57 /**
58  * @tc.name: GetSurface001
59  * @tc.desc: Verify the GetSurface of hdilayerinfo
60  * @tc.type:FUNC
61  * @tc.require:AR000GGP0P
62  * @tc.author:
63  */
64 HWTEST_F(HdiLayerInfoTest, GetSurface001, Function | MediumTest| Level3)
65 {
66     sptr<IConsumerSurface> surface = nullptr;
67     HdiLayerInfoTest::hdiLayerInfo_->SetSurface(surface);
68     ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetSurface(), nullptr);
69 }
70 
71 /**
72  * @tc.name: GetBuffer001
73  * @tc.desc: Verify the GetBuffer of hdilayerinfo
74  * @tc.type:FUNC
75  * @tc.require:AR000GGP0P
76  * @tc.author:
77  */
78 HWTEST_F(HdiLayerInfoTest, GetBuffer001, Function | MediumTest| Level3)
79 {
80     sptr<SyncFence> acquireFence = SyncFence::INVALID_FENCE;
81     sptr<SurfaceBuffer> sbuffer = nullptr;
82     HdiLayerInfoTest::hdiLayerInfo_->SetBuffer(sbuffer, acquireFence);
83     ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetBuffer(), nullptr);
84 }
85 
86 /**
87  * @tc.name: GetAcquireFence001
88  * @tc.desc: Verify the GetAcquireFence of hdilayerinfo
89  * @tc.type:FUNC
90  * @tc.require:AR000GGP0P
91  * @tc.author:
92  */
93 HWTEST_F(HdiLayerInfoTest, GetAcquireFence001, Function | MediumTest| Level3)
94 {
95     ASSERT_NE(HdiLayerInfoTest::hdiLayerInfo_->GetAcquireFence(), nullptr);
96 }
97 
98 /**
99  * @tc.name: GetAlpha001
100  * @tc.desc: Verify the GetAlpha of hdilayerinfo
101  * @tc.type:FUNC
102  * @tc.require:AR000GGP0P
103  * @tc.author:
104  */
105 HWTEST_F(HdiLayerInfoTest, GetAlpha001, Function | MediumTest| Level3)
106 {
107     GraphicLayerAlpha layerAlpha = {
108         .enGlobalAlpha = true,
109         .enPixelAlpha = true,
110         .alpha0 = 0,
111         .alpha1 = 0,
112         .gAlpha = 0,
113     };
114     HdiLayerInfoTest::hdiLayerInfo_->SetAlpha(layerAlpha);
115     ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetAlpha().enGlobalAlpha, layerAlpha.enGlobalAlpha);
116     ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetAlpha().enPixelAlpha, layerAlpha.enPixelAlpha);
117     ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetAlpha().alpha0, layerAlpha.alpha0);
118     ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetAlpha().alpha1, layerAlpha.alpha1);
119     ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetAlpha().gAlpha, layerAlpha.gAlpha);
120 }
121 
122 /**
123  * @tc.name: GetTransformType001
124  * @tc.desc: Verify the GetTransformType of hdilayerinfo
125  * @tc.type:FUNC
126  * @tc.require:AR000GGP0P
127  * @tc.author:
128  */
129 HWTEST_F(HdiLayerInfoTest, GetTransformType001, Function | MediumTest| Level3)
130 {
131     GraphicTransformType type = GraphicTransformType::GRAPHIC_ROTATE_90;
132     HdiLayerInfoTest::hdiLayerInfo_->SetTransform(type);
133     ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetTransformType(), GraphicTransformType::GRAPHIC_ROTATE_90);
134 
135     type = GraphicTransformType::GRAPHIC_ROTATE_180;
136     HdiLayerInfoTest::hdiLayerInfo_->SetTransform(type);
137     ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetTransformType(), GraphicTransformType::GRAPHIC_ROTATE_180);
138 
139     type = GraphicTransformType::GRAPHIC_ROTATE_270;
140     HdiLayerInfoTest::hdiLayerInfo_->SetTransform(type);
141     ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetTransformType(), GraphicTransformType::GRAPHIC_ROTATE_270);
142 }
143 
144 /**
145  * @tc.name: GetCompositionType001
146  * @tc.desc: Verify the GetCompositionType of hdilayerinfo
147  * @tc.type:FUNC
148  * @tc.require:AR000GGP0P
149  * @tc.author:
150  */
151 HWTEST_F(HdiLayerInfoTest, GetCompositionType001, Function | MediumTest| Level3)
152 {
153     GraphicCompositionType type = GRAPHIC_COMPOSITION_CLIENT;
154     HdiLayerInfoTest::hdiLayerInfo_->SetCompositionType(type);
155     ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetCompositionType(), GRAPHIC_COMPOSITION_CLIENT);
156 
157     type = GRAPHIC_COMPOSITION_DEVICE;
158     HdiLayerInfoTest::hdiLayerInfo_->SetCompositionType(type);
159     ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetCompositionType(), GRAPHIC_COMPOSITION_DEVICE);
160 
161     type = GRAPHIC_COMPOSITION_CURSOR;
162     HdiLayerInfoTest::hdiLayerInfo_->SetCompositionType(type);
163     ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetCompositionType(), GRAPHIC_COMPOSITION_CURSOR);
164 }
165 
166 /**
167  * @tc.name: GetVisibleRegion001
168  * @tc.desc: Verify the GetVisibleRegions of hdilayerinfo
169  * @tc.type:FUNC
170  * @tc.require:AR000GGP0P
171  * @tc.author:
172  */
173 HWTEST_F(HdiLayerInfoTest, GetVisibleRegions001, Function | MediumTest| Level3)
174 {
175     GraphicIRect iRect = {
176         .x = 0,
177         .y = 0,
178         .w = 800,
179         .h = 600,
180     };
181     std::vector<GraphicIRect> inVisibles;
182     inVisibles.emplace_back(iRect);
183     HdiLayerInfoTest::hdiLayerInfo_->SetVisibleRegions(inVisibles);
184     const std::vector<GraphicIRect>& outVisibles = HdiLayerInfoTest::hdiLayerInfo_->GetVisibleRegions();
185     ASSERT_EQ(outVisibles.size(), 1);
186     ASSERT_EQ(outVisibles[0].x, iRect.x);
187     ASSERT_EQ(outVisibles[0].y, iRect.y);
188     ASSERT_EQ(outVisibles[0].w, iRect.w);
189     ASSERT_EQ(outVisibles[0].h, iRect.h);
190 }
191 
192 /**
193  * @tc.name: GetDirtyRegion001
194  * @tc.desc: Verify the GetDirtyRegions of hdilayerinfo
195  * @tc.type:FUNC
196  * @tc.require:AR000GGP0P
197  * @tc.author:
198  */
199 HWTEST_F(HdiLayerInfoTest, GetDirtyRegion001, Function | MediumTest| Level3)
200 {
201     GraphicIRect iRect = {
202         .x = 0,
203         .y = 0,
204         .w = 800,
205         .h = 600,
206     };
207     std::vector<GraphicIRect> inDirtyRegions;
208     inDirtyRegions.emplace_back(iRect);
209     HdiLayerInfoTest::hdiLayerInfo_->SetDirtyRegions(inDirtyRegions);
210     const std::vector<GraphicIRect>& outDirtyRegions = HdiLayerInfoTest::hdiLayerInfo_->GetDirtyRegions();
211     ASSERT_EQ(outDirtyRegions.size(), 1);
212     ASSERT_EQ(outDirtyRegions[0].x, iRect.x);
213     ASSERT_EQ(outDirtyRegions[0].y, iRect.y);
214     ASSERT_EQ(outDirtyRegions[0].w, iRect.w);
215     ASSERT_EQ(outDirtyRegions[0].h, iRect.h);
216 }
217 
218 /**
219  * @tc.name: GetBlendType001
220  * @tc.desc: Verify the GetBlendType of hdilayerinfo
221  * @tc.type:FUNC
222  * @tc.require:AR000GGP0P
223  * @tc.author:
224  */
225 HWTEST_F(HdiLayerInfoTest, GetBlendType001, Function | MediumTest| Level3)
226 {
227     GraphicBlendType type = GraphicBlendType::GRAPHIC_BLEND_CLEAR;
228     HdiLayerInfoTest::hdiLayerInfo_->SetBlendType(type);
229     ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetBlendType(), GraphicBlendType::GRAPHIC_BLEND_CLEAR);
230 
231     type = GraphicBlendType::GRAPHIC_BLEND_SRC;
232     HdiLayerInfoTest::hdiLayerInfo_->SetBlendType(type);
233     ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetBlendType(), GraphicBlendType::GRAPHIC_BLEND_SRC);
234 
235     type = GraphicBlendType::GRAPHIC_BLEND_SRCOVER;
236     HdiLayerInfoTest::hdiLayerInfo_->SetBlendType(type);
237     ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetBlendType(), GraphicBlendType::GRAPHIC_BLEND_SRCOVER);
238 }
239 
240 /**
241  * @tc.name: GetCropRect001
242  * @tc.desc: Verify the GetCropRect of hdilayerinfo
243  * @tc.type:FUNC
244  * @tc.require:AR000GGP0P
245  * @tc.author:
246  */
247 HWTEST_F(HdiLayerInfoTest, GetCropRect001, Function | MediumTest| Level3)
248 {
249     GraphicIRect iRect = {
250         .x = 0,
251         .y = 0,
252         .w = 800,
253         .h = 600,
254     };
255     HdiLayerInfoTest::hdiLayerInfo_->SetCropRect(iRect);
256     ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetCropRect().x, iRect.x);
257     ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetCropRect().y, iRect.y);
258     ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetCropRect().w, iRect.w);
259     ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetCropRect().h, iRect.h);
260 }
261 
262 /**
263  * @tc.name: GetLayerSize001
264  * @tc.desc: Verify the GetLayerSize of hdilayerinfo
265  * @tc.type:FUNC
266  * @tc.require:AR000GGP0P
267  * @tc.author:
268  */
269 HWTEST_F(HdiLayerInfoTest, GetLayerSize001, Function | MediumTest| Level3)
270 {
271     GraphicIRect iRect = {
272         .x = 0,
273         .y = 0,
274         .w = 800,
275         .h = 600,
276     };
277     HdiLayerInfoTest::hdiLayerInfo_->SetLayerSize(iRect);
278     ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetLayerSize().x, iRect.x);
279     ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetLayerSize().y, iRect.y);
280     ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetLayerSize().w, iRect.w);
281     ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetLayerSize().h, iRect.h);
282 }
283 
284 /**
285  * @tc.name: IsPreMulti001
286  * @tc.desc: Verify the IsPreMulti of hdilayerinfo
287  * @tc.type:FUNC
288  * @tc.require:AR000GGP0P
289  * @tc.author:
290  */
291 HWTEST_F(HdiLayerInfoTest, IsPreMulti001, Function | MediumTest| Level3)
292 {
293     HdiLayerInfoTest::hdiLayerInfo_->SetPreMulti(true);
294     ASSERT_NE(HdiLayerInfoTest::hdiLayerInfo_->IsPreMulti(), false);
295 
296     HdiLayerInfoTest::hdiLayerInfo_->SetPreMulti(false);
297     ASSERT_NE(HdiLayerInfoTest::hdiLayerInfo_->IsPreMulti(), true);
298 }
299 
300 /*
301 * Function: SetTunnelHandleChange and GetTunnelHandleChange
302 * Type: Function
303 * Rank: Important(1)
304 * EnvConditions: N/A
305 * CaseDescription: 1. call GetTunnelHandleChange with default
306 *                  2. call SetTunnelHandleChange
307 *                  3. call GetTunnelHandleChange and check ret
308  */
309 HWTEST_F(HdiLayerInfoTest, TunnelHandleChange001, Function | MediumTest | Level1)
310 {
311     bool change = HdiLayerInfoTest::hdiLayerInfo_->GetTunnelHandleChange();
312     ASSERT_EQ(change, false);
313     HdiLayerInfoTest::hdiLayerInfo_->SetTunnelHandleChange(true);
314     change = HdiLayerInfoTest::hdiLayerInfo_->GetTunnelHandleChange();
315     ASSERT_EQ(change, true);
316 }
317 
318 /*
319 * Function: SetTunnelHandle and GetTunnelHandle
320 * Type: Function
321 * Rank: Important(1)
322 * EnvConditions: N/A
323 * CaseDescription: 1. call GetTunnelHandle with default
324 * @tc.require: issueI5GMZN issueI5IWHW
325  */
326 HWTEST_F(HdiLayerInfoTest, TunnelHandle001, Function | MediumTest | Level1)
327 {
328     sptr<SurfaceTunnelHandle> handle = HdiLayerInfoTest::hdiLayerInfo_->GetTunnelHandle();
329     ASSERT_EQ(handle, nullptr);
330 }
331 
332 /*
333 * Function: SetTunnelHandle and GetTunnelHandle
334 * Type: Function
335 * Rank: Important(1)
336 * EnvConditions: N/A
337 * CaseDescription: 1. call SetTunnelHandle
338 *                  2. call GetTunnelHandle and check ret
339 * @tc.require: issueI5GMZN issueI5IWHW
340  */
341 HWTEST_F(HdiLayerInfoTest, TunnelHandle002, Function | MediumTest | Level1)
342 {
343     sptr<SurfaceTunnelHandle> handle = HdiLayerInfoTest::hdiLayerInfo_->GetTunnelHandle();
344     ASSERT_EQ(handle, nullptr);
345 
346     sptr<SurfaceTunnelHandle> tunnelHandle = new SurfaceTunnelHandle;
347 
348     uint32_t reserveInts = 1;
349     GraphicExtDataHandle *handleSet = AllocExtDataHandle(reserveInts);
350     ASSERT_EQ(tunnelHandle->SetHandle(handleSet), OHOS::GSERROR_OK);
351     ASSERT_NE(tunnelHandle, nullptr);
352     HdiLayerInfoTest::hdiLayerInfo_->SetTunnelHandle(tunnelHandle);
353     ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetTunnelHandle()->GetHandle()->fd,
354               tunnelHandle->GetHandle()->fd);
355     ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetTunnelHandle()->GetHandle()->reserveInts,
356               tunnelHandle->GetHandle()->reserveInts);
357     ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetTunnelHandle()->GetHandle()->reserve[0],
358               tunnelHandle->GetHandle()->reserve[0]);
359     free(handleSet);
360 }
361 
362 /*
363 * Function: SetColorTransform and GetColorTransform
364 * Type: Function
365 * Rank: Important(1)
366 * EnvConditions: N/A
367 * CaseDescription: 1. call SetColorTransform
368 *                  2. call GetColorTransform and check ret
369 * @tc.require: issueI5H317
370  */
371 HWTEST_F(HdiLayerInfoTest, ColorTransform001, Function | MediumTest | Level1)
372 {
373     std::vector<float> matrix = {1, 0, 0, 0, 1, 0, 0, 0, 1};
374     HdiLayerInfoTest::hdiLayerInfo_->SetColorTransform(matrix);
375     const std::vector<float>& transform = HdiLayerInfoTest::hdiLayerInfo_->GetColorTransform();
376     ASSERT_EQ(transform.size(), 9);
377 }
378 
379 /*
380 * Function: SetLayerColor and GetColorTransform
381 * Type: Function
382 * Rank: Important(1)
383 * EnvConditions: N/A
384 * CaseDescription: 1. call SetLayerColor
385 *                  2. call SetLayerColor and check ret
386 * @tc.require: issueI5H317
387  */
388 HWTEST_F(HdiLayerInfoTest, LayerColor001, Function | MediumTest | Level1)
389 {
390     const uint32_t COLOR_R = 155;
391     const uint32_t COLOR_G = 224;
392     const uint32_t COLOR_B = 88;
393     const uint32_t COLOR_A = 128;
394 
395     GraphicLayerColor layercolor = {
396         .r = COLOR_R,
397         .g = COLOR_G,
398         .b = COLOR_B,
399         .a = COLOR_A
400     };
401 
402     HdiLayerInfoTest::hdiLayerInfo_->SetLayerColor(layercolor);
403     GraphicLayerColor color = HdiLayerInfoTest::hdiLayerInfo_->GetLayerColor();
404     ASSERT_EQ(color.r, layercolor.r);
405     ASSERT_EQ(color.g, layercolor.g);
406     ASSERT_EQ(color.b, layercolor.b);
407     ASSERT_EQ(color.a, layercolor.a);
408 }
409 
410 /*
411 * Function: SetBackgroundColor and GetBackgroundColor
412 * Type: Function
413 * Rank: Important(1)
414 * EnvConditions: N/A
415 * CaseDescription: 1. call SetBackgroundColor
416 *                  2. call GetBackgroundColor and check ret
417 * @tc.require: issueIAX2NE
418  */
419 HWTEST_F(HdiLayerInfoTest, BackgroundColor001, Function | MediumTest | Level1)
420 {
421     const uint32_t COLOR_R = 155;
422     const uint32_t COLOR_G = 224;
423     const uint32_t COLOR_B = 88;
424     const uint32_t COLOR_A = 128;
425 
426     GraphicLayerColor backgroundColor = {
427         .r = COLOR_R,
428         .g = COLOR_G,
429         .b = COLOR_B,
430         .a = COLOR_A
431     };
432 
433     HdiLayerInfoTest::hdiLayerInfo_->SetBackgroundColor(backgroundColor);
434     GraphicLayerColor color = HdiLayerInfoTest::hdiLayerInfo_->GetBackgroundColor();
435     ASSERT_EQ(color.r, backgroundColor.r);
436     ASSERT_EQ(color.g, backgroundColor.g);
437     ASSERT_EQ(color.b, backgroundColor.b);
438     ASSERT_EQ(color.a, backgroundColor.a);
439 }
440 
441 /*
442 * Function: SetCornerRadiusInfoForDRM and GetCornerRadiusInfoForDRM
443 * Type: Function
444 * Rank: Important(1)
445 * EnvConditions: N/A
446 * CaseDescription: 1. call SetCornerRadiusInfoForDRM
447 *                  2. call GetCornerRadiusInfoForDRM and check ret
448 * @tc.require: issueIAX2NE
449  */
450 HWTEST_F(HdiLayerInfoTest, CornerRadiusInfoForDRM001, Function | MediumTest | Level1)
451 {
452     float testNum = 1.0f;
453     std::vector<float> cornerRadiusInfo = {testNum, testNum, testNum, testNum,
454         testNum, testNum, testNum, testNum};
455     HdiLayerInfoTest::hdiLayerInfo_->SetCornerRadiusInfoForDRM(cornerRadiusInfo);
456     const std::vector<float>& res = HdiLayerInfoTest::hdiLayerInfo_->GetCornerRadiusInfoForDRM();
457     int expectResSize = 8;
458     ASSERT_EQ(res.size(), expectResSize);
459 }
460 
461 /*
462 * Function: SetColorDataSpace and GetColorDataSpace
463 * Type: Function
464 * Rank: Important(1)
465 * EnvConditions: N/A
466 * CaseDescription: 1. call GetColorDataSpace with default
467 * @tc.require: issueI5H317
468  */
469 HWTEST_F(HdiLayerInfoTest, ColorDataSpace001, Function | MediumTest | Level1)
470 {
471     GraphicColorDataSpace colorSpace = HdiLayerInfoTest::hdiLayerInfo_->GetColorDataSpace();
472     ASSERT_EQ(colorSpace, GraphicColorDataSpace::GRAPHIC_COLOR_DATA_SPACE_UNKNOWN);
473 }
474 
475 /*
476 * Function: SetColorDataSpace and GetColorDataSpace
477 * Type: Function
478 * Rank: Important(1)
479 * EnvConditions: N/A
480 * CaseDescription: 1. call SetColorDataSpace
481 *                  2. call GetColorDataSpace and check ret
482 * @tc.require: issueI5H317
483  */
484 HWTEST_F(HdiLayerInfoTest, ColorDataSpace002, Function | MediumTest | Level1)
485 {
486     GraphicColorDataSpace colorSpaceSet = GraphicColorDataSpace::GRAPHIC_GAMUT_DISPLAY_P3;
487     HdiLayerInfoTest::hdiLayerInfo_->SetColorDataSpace(colorSpaceSet);
488     GraphicColorDataSpace colorSpaceGet = HdiLayerInfoTest::hdiLayerInfo_->GetColorDataSpace();
489     ASSERT_EQ(colorSpaceSet, colorSpaceGet);
490 }
491 
492 /*
493 * Function: SetMetaData and GetMetaData
494 * Type: Function
495 * Rank: Important(1)
496 * EnvConditions: N/A
497 * CaseDescription: 1. call SetMetaData
498 *                  2. call GetMetaData and check ret
499 * @tc.require: issueI5H317
500  */
501 HWTEST_F(HdiLayerInfoTest, MetaData001, Function | MediumTest | Level1)
502 {
503     std::vector<GraphicHDRMetaData> metaData = {{GRAPHIC_MATAKEY_RED_PRIMARY_X, 1}};
504     HdiLayerInfoTest::hdiLayerInfo_->SetMetaData(metaData);
505     std::vector<GraphicHDRMetaData> metaDataGet = HdiLayerInfoTest::hdiLayerInfo_->GetMetaData();
506     ASSERT_EQ(metaData[0].key, metaDataGet[0].key);
507     ASSERT_EQ(metaData[0].value, metaDataGet[0].value);
508 }
509 
510 /*
511 * Function: SetMetaDataSet and GetMetaDataSet
512 * Type: Function
513 * Rank: Important(1)
514 * EnvConditions: N/A
515 * CaseDescription: 1. call SetMetaDataSet
516 *                  2. call GetMetaDataSet and check ret
517 * @tc.require: issueI5H317
518  */
519 HWTEST_F(HdiLayerInfoTest, MetaDataSet001, Function | MediumTest | Level1)
520 {
521     GraphicHDRMetaDataSet metaDataSet = {GraphicHDRMetadataKey::GRAPHIC_MATAKEY_RED_PRIMARY_X, {1, 2, 3}};
522     HdiLayerInfoTest::hdiLayerInfo_->SetMetaDataSet(metaDataSet);
523     GraphicHDRMetaDataSet metaDataSetGet = HdiLayerInfoTest::hdiLayerInfo_->GetMetaDataSet();
524     ASSERT_EQ(metaDataSet.key, metaDataSetGet.key);
525     ASSERT_EQ(metaDataSet.metaData[0], metaDataSetGet.metaData[0]);
526     ASSERT_EQ(metaDataSet.metaData[1], metaDataSetGet.metaData[1]);
527     ASSERT_EQ(metaDataSet.metaData[2], metaDataSetGet.metaData[2]);
528 }
529 
530 /*
531 * Function: SetIsSupportedPresentTimestamp and IsSupportedPresentTimestamp
532 * Type: Function
533 * Rank: Important(1)
534 * EnvConditions: N/A
535 * CaseDescription: 1. call IsSupportedPresentTimestamp with default
536 * @tc.require: issueI5I57K
537  */
538 HWTEST_F(HdiLayerInfoTest, IsSupportedPresentTimestamp001, Function | MediumTest | Level1)
539 {
540     bool isSupported = HdiLayerInfoTest::hdiLayerInfo_->IsSupportedPresentTimestamp();
541     ASSERT_EQ(isSupported, false);
542 }
543 
544 /*
545 * Function: SetIsSupportedPresentTimestamp and IsSupportedPresentTimestamp
546 * Type: Function
547 * Rank: Important(1)
548 * EnvConditions: N/A
549 * CaseDescription: 1. call SetIsSupportedPresentTimestamp
550 *                  2. call IsSupportedPresentTimestamp and check ret
551 * @tc.require: issueI5I57K
552  */
553 HWTEST_F(HdiLayerInfoTest, IsSupportedPresentTimestamp002, Function | MediumTest | Level1)
554 {
555     HdiLayerInfoTest::hdiLayerInfo_->SetIsSupportedPresentTimestamp(true);
556     bool isSupported = HdiLayerInfoTest::hdiLayerInfo_->IsSupportedPresentTimestamp();
557     ASSERT_EQ(isSupported, true);
558     HdiLayerInfoTest::hdiLayerInfo_->SetIsSupportedPresentTimestamp(false);
559     isSupported = HdiLayerInfoTest::hdiLayerInfo_->IsSupportedPresentTimestamp();
560     ASSERT_EQ(isSupported, false);
561 }
562 
563 /*
564 * Function: SetPresentTimestamp and GetPresentTimestamp
565 * Type: Function
566 * Rank: Important(1)
567 * EnvConditions: N/A
568 * CaseDescription: 1. call GetPresentTimestamp with default
569 * @tc.require: issueI5I57K
570  */
571 HWTEST_F(HdiLayerInfoTest, PresentTimestamp001, Function | MediumTest | Level1)
572 {
573     GraphicPresentTimestamp timestamp = HdiLayerInfoTest::hdiLayerInfo_->GetPresentTimestamp();
574     ASSERT_EQ(timestamp.type, GRAPHIC_DISPLAY_PTS_UNSUPPORTED);
575     ASSERT_EQ(timestamp.time, 0);
576 }
577 
578 /*
579 * Function: SetPresentTimestamp and GetPresentTimestamp
580 * Type: Function
581 * Rank: Important(1)
582 * EnvConditions: N/A
583 * CaseDescription: 1. call SetPresentTimestamp
584 *                  2. call GetPresentTimestamp and check ret
585 * @tc.require: issueI5I57K
586  */
587 HWTEST_F(HdiLayerInfoTest, PresentTimestamp002, Function | MediumTest | Level1)
588 {
589     GraphicPresentTimestamp timestampSet = {GRAPHIC_DISPLAY_PTS_DELAY, 1};  // mock data for test
590     HdiLayerInfoTest::hdiLayerInfo_->SetPresentTimestamp(timestampSet);
591     GraphicPresentTimestamp timestampGet = HdiLayerInfoTest::hdiLayerInfo_->GetPresentTimestamp();
592     ASSERT_EQ(timestampSet.type, timestampGet.type);
593     ASSERT_EQ(timestampSet.time, timestampGet.time);
594 }
595 
596 /*
597 * Function: SetPresentTimestamp and GetPresentTimestamp
598 * Type: Function
599 * Rank: Important(1)
600 * EnvConditions: N/A
601 * CaseDescription: 1. call SetPresentTimestamp
602 *                  2. call GetPresentTimestamp and check ret
603 * @tc.require: issueI5I57K
604  */
605 HWTEST_F(HdiLayerInfoTest, PresentTimestamp003, Function | MediumTest | Level1)
606 {
607     GraphicPresentTimestamp timestampSet = {GRAPHIC_DISPLAY_PTS_TIMESTAMP, 10};  // mock data for test
608     HdiLayerInfoTest::hdiLayerInfo_->SetPresentTimestamp(timestampSet);
609     GraphicPresentTimestamp timestampGet = HdiLayerInfoTest::hdiLayerInfo_->GetPresentTimestamp();
610     ASSERT_EQ(timestampSet.type, timestampGet.type);
611     ASSERT_EQ(timestampSet.time, timestampGet.time);
612 }
613 
614 /*
615 * Function: SetLayerMaskInfo and GetLayerMaskInfo
616 * Type: Function
617 * Rank: Important(1)
618 * EnvConditions: N/A
619 * CaseDescription: 1. call SetLayerMaskInfo
620 *                  2. call GetLayerMaskInfo and check ret
621 * @tc.require: issueI6WBXO
622  */
623 HWTEST_F(HdiLayerInfoTest, SetLayerMaskInfo001, Function | MediumTest | Level1)
624 {
625     HdiLayerInfo::LayerMask layerMask = HdiLayerInfo::LayerMask::LAYER_MASK_NORMAL;
626     HdiLayerInfoTest::hdiLayerInfo_->SetLayerMaskInfo(layerMask);
627     HdiLayerInfo::LayerMask Get = HdiLayerInfoTest::hdiLayerInfo_->GetLayerMaskInfo();
628     ASSERT_EQ(layerMask, Get);
629 }
630 
631 /*
632 * Function: SetLayerMaskInfo and GetLayerMaskInfo
633 * Type: Function
634 * Rank: Important(1)
635 * EnvConditions: N/A
636 * CaseDescription: 1. call SetLayerMaskInfo
637 *                  2. call GetLayerMaskInfo and check ret
638 * @tc.require: issueI6WBXO
639  */
640 HWTEST_F(HdiLayerInfoTest, SetLayerMaskInfo002, Function | MediumTest | Level1)
641 {
642     HdiLayerInfo::LayerMask layerMask = HdiLayerInfo::LayerMask::LAYER_MASK_HBM_SYNC;
643     HdiLayerInfoTest::hdiLayerInfo_->SetLayerMaskInfo(layerMask);
644     HdiLayerInfo::LayerMask Get = HdiLayerInfoTest::hdiLayerInfo_->GetLayerMaskInfo();
645     ASSERT_EQ(layerMask, Get);
646 }
647 } // namespace
648 } // namespace Rosen
649 } // namespace OHOS