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 GraphicExtDataHandle *handleSet = new GraphicExtDataHandle();
349 handleSet->fd = -1;
350 handleSet->reserveInts = 1;
351 handleSet->reserve[0] = 0;
352 ASSERT_EQ(tunnelHandle->SetHandle(handleSet), OHOS::GSERROR_OK);
353 ASSERT_NE(tunnelHandle, nullptr);
354 HdiLayerInfoTest::hdiLayerInfo_->SetTunnelHandle(tunnelHandle);
355 ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetTunnelHandle()->GetHandle()->fd,
356 tunnelHandle->GetHandle()->fd);
357 ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetTunnelHandle()->GetHandle()->reserveInts,
358 tunnelHandle->GetHandle()->reserveInts);
359 ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetTunnelHandle()->GetHandle()->reserve[0],
360 tunnelHandle->GetHandle()->reserve[0]);
361 free(handleSet);
362 }
363
364 /*
365 * Function: SetColorTransform and GetColorTransform
366 * Type: Function
367 * Rank: Important(1)
368 * EnvConditions: N/A
369 * CaseDescription: 1. call SetColorTransform
370 * 2. call GetColorTransform and check ret
371 * @tc.require: issueI5H317
372 */
373 HWTEST_F(HdiLayerInfoTest, ColorTransform001, Function | MediumTest | Level1)
374 {
375 std::vector<float> matrix = {1, 0, 0, 0, 1, 0, 0, 0, 1};
376 HdiLayerInfoTest::hdiLayerInfo_->SetColorTransform(matrix);
377 const std::vector<float>& transform = HdiLayerInfoTest::hdiLayerInfo_->GetColorTransform();
378 ASSERT_EQ(transform.size(), 9);
379 }
380
381 /*
382 * Function: SetLayerColor and GetColorTransform
383 * Type: Function
384 * Rank: Important(1)
385 * EnvConditions: N/A
386 * CaseDescription: 1. call SetLayerColor
387 * 2. call SetLayerColor and check ret
388 * @tc.require: issueI5H317
389 */
390 HWTEST_F(HdiLayerInfoTest, LayerColor001, Function | MediumTest | Level1)
391 {
392 const uint32_t COLOR_R = 155;
393 const uint32_t COLOR_G = 224;
394 const uint32_t COLOR_B = 88;
395 const uint32_t COLOR_A = 128;
396
397 GraphicLayerColor layercolor = {
398 .r = COLOR_R,
399 .g = COLOR_G,
400 .b = COLOR_B,
401 .a = COLOR_A
402 };
403
404 HdiLayerInfoTest::hdiLayerInfo_->SetLayerColor(layercolor);
405 GraphicLayerColor color = HdiLayerInfoTest::hdiLayerInfo_->GetLayerColor();
406 ASSERT_EQ(color.r, layercolor.r);
407 ASSERT_EQ(color.g, layercolor.g);
408 ASSERT_EQ(color.b, layercolor.b);
409 ASSERT_EQ(color.a, layercolor.a);
410 }
411
412
413 /*
414 * Function: SetColorDataSpace and GetColorDataSpace
415 * Type: Function
416 * Rank: Important(1)
417 * EnvConditions: N/A
418 * CaseDescription: 1. call GetColorDataSpace with default
419 * @tc.require: issueI5H317
420 */
421 HWTEST_F(HdiLayerInfoTest, ColorDataSpace001, Function | MediumTest | Level1)
422 {
423 GraphicColorDataSpace colorSpace = HdiLayerInfoTest::hdiLayerInfo_->GetColorDataSpace();
424 ASSERT_EQ(colorSpace, GraphicColorDataSpace::GRAPHIC_COLOR_DATA_SPACE_UNKNOWN);
425 }
426
427 /*
428 * Function: SetColorDataSpace and GetColorDataSpace
429 * Type: Function
430 * Rank: Important(1)
431 * EnvConditions: N/A
432 * CaseDescription: 1. call SetColorDataSpace
433 * 2. call GetColorDataSpace and check ret
434 * @tc.require: issueI5H317
435 */
436 HWTEST_F(HdiLayerInfoTest, ColorDataSpace002, Function | MediumTest | Level1)
437 {
438 GraphicColorDataSpace colorSpaceSet = GraphicColorDataSpace::GRAPHIC_GAMUT_DISPLAY_P3;
439 HdiLayerInfoTest::hdiLayerInfo_->SetColorDataSpace(colorSpaceSet);
440 GraphicColorDataSpace colorSpaceGet = HdiLayerInfoTest::hdiLayerInfo_->GetColorDataSpace();
441 ASSERT_EQ(colorSpaceSet, colorSpaceGet);
442 }
443
444 /*
445 * Function: SetMetaData and GetMetaData
446 * Type: Function
447 * Rank: Important(1)
448 * EnvConditions: N/A
449 * CaseDescription: 1. call SetMetaData
450 * 2. call GetMetaData and check ret
451 * @tc.require: issueI5H317
452 */
453 HWTEST_F(HdiLayerInfoTest, MetaData001, Function | MediumTest | Level1)
454 {
455 std::vector<GraphicHDRMetaData> metaData = {{GRAPHIC_MATAKEY_RED_PRIMARY_X, 1}};
456 HdiLayerInfoTest::hdiLayerInfo_->SetMetaData(metaData);
457 std::vector<GraphicHDRMetaData> metaDataGet = HdiLayerInfoTest::hdiLayerInfo_->GetMetaData();
458 ASSERT_EQ(metaData[0].key, metaDataGet[0].key);
459 ASSERT_EQ(metaData[0].value, metaDataGet[0].value);
460 }
461
462 /*
463 * Function: SetMetaDataSet and GetMetaDataSet
464 * Type: Function
465 * Rank: Important(1)
466 * EnvConditions: N/A
467 * CaseDescription: 1. call SetMetaDataSet
468 * 2. call GetMetaDataSet and check ret
469 * @tc.require: issueI5H317
470 */
471 HWTEST_F(HdiLayerInfoTest, MetaDataSet001, Function | MediumTest | Level1)
472 {
473 GraphicHDRMetaDataSet metaDataSet = {GraphicHDRMetadataKey::GRAPHIC_MATAKEY_RED_PRIMARY_X, {1, 2, 3}};
474 HdiLayerInfoTest::hdiLayerInfo_->SetMetaDataSet(metaDataSet);
475 GraphicHDRMetaDataSet metaDataSetGet = HdiLayerInfoTest::hdiLayerInfo_->GetMetaDataSet();
476 ASSERT_EQ(metaDataSet.key, metaDataSetGet.key);
477 ASSERT_EQ(metaDataSet.metaData[0], metaDataSetGet.metaData[0]);
478 ASSERT_EQ(metaDataSet.metaData[1], metaDataSetGet.metaData[1]);
479 ASSERT_EQ(metaDataSet.metaData[2], metaDataSetGet.metaData[2]);
480 }
481
482 /*
483 * Function: SetIsSupportedPresentTimestamp and IsSupportedPresentTimestamp
484 * Type: Function
485 * Rank: Important(1)
486 * EnvConditions: N/A
487 * CaseDescription: 1. call IsSupportedPresentTimestamp with default
488 * @tc.require: issueI5I57K
489 */
490 HWTEST_F(HdiLayerInfoTest, IsSupportedPresentTimestamp001, Function | MediumTest | Level1)
491 {
492 bool isSupported = HdiLayerInfoTest::hdiLayerInfo_->IsSupportedPresentTimestamp();
493 ASSERT_EQ(isSupported, false);
494 }
495
496 /*
497 * Function: SetIsSupportedPresentTimestamp and IsSupportedPresentTimestamp
498 * Type: Function
499 * Rank: Important(1)
500 * EnvConditions: N/A
501 * CaseDescription: 1. call SetIsSupportedPresentTimestamp
502 * 2. call IsSupportedPresentTimestamp and check ret
503 * @tc.require: issueI5I57K
504 */
505 HWTEST_F(HdiLayerInfoTest, IsSupportedPresentTimestamp002, Function | MediumTest | Level1)
506 {
507 HdiLayerInfoTest::hdiLayerInfo_->SetIsSupportedPresentTimestamp(true);
508 bool isSupported = HdiLayerInfoTest::hdiLayerInfo_->IsSupportedPresentTimestamp();
509 ASSERT_EQ(isSupported, true);
510 HdiLayerInfoTest::hdiLayerInfo_->SetIsSupportedPresentTimestamp(false);
511 isSupported = HdiLayerInfoTest::hdiLayerInfo_->IsSupportedPresentTimestamp();
512 ASSERT_EQ(isSupported, false);
513 }
514
515 /*
516 * Function: SetPresentTimestamp and GetPresentTimestamp
517 * Type: Function
518 * Rank: Important(1)
519 * EnvConditions: N/A
520 * CaseDescription: 1. call GetPresentTimestamp with default
521 * @tc.require: issueI5I57K
522 */
523 HWTEST_F(HdiLayerInfoTest, PresentTimestamp001, Function | MediumTest | Level1)
524 {
525 GraphicPresentTimestamp timestamp = HdiLayerInfoTest::hdiLayerInfo_->GetPresentTimestamp();
526 ASSERT_EQ(timestamp.type, GRAPHIC_DISPLAY_PTS_UNSUPPORTED);
527 ASSERT_EQ(timestamp.time, 0);
528 }
529
530 /*
531 * Function: SetPresentTimestamp and GetPresentTimestamp
532 * Type: Function
533 * Rank: Important(1)
534 * EnvConditions: N/A
535 * CaseDescription: 1. call SetPresentTimestamp
536 * 2. call GetPresentTimestamp and check ret
537 * @tc.require: issueI5I57K
538 */
539 HWTEST_F(HdiLayerInfoTest, PresentTimestamp002, Function | MediumTest | Level1)
540 {
541 GraphicPresentTimestamp timestampSet = {GRAPHIC_DISPLAY_PTS_DELAY, 1}; // mock data for test
542 HdiLayerInfoTest::hdiLayerInfo_->SetPresentTimestamp(timestampSet);
543 GraphicPresentTimestamp timestampGet = HdiLayerInfoTest::hdiLayerInfo_->GetPresentTimestamp();
544 ASSERT_EQ(timestampSet.type, timestampGet.type);
545 ASSERT_EQ(timestampSet.time, timestampGet.time);
546 }
547
548 /*
549 * Function: SetPresentTimestamp and GetPresentTimestamp
550 * Type: Function
551 * Rank: Important(1)
552 * EnvConditions: N/A
553 * CaseDescription: 1. call SetPresentTimestamp
554 * 2. call GetPresentTimestamp and check ret
555 * @tc.require: issueI5I57K
556 */
557 HWTEST_F(HdiLayerInfoTest, PresentTimestamp003, Function | MediumTest | Level1)
558 {
559 GraphicPresentTimestamp timestampSet = {GRAPHIC_DISPLAY_PTS_TIMESTAMP, 10}; // mock data for test
560 HdiLayerInfoTest::hdiLayerInfo_->SetPresentTimestamp(timestampSet);
561 GraphicPresentTimestamp timestampGet = HdiLayerInfoTest::hdiLayerInfo_->GetPresentTimestamp();
562 ASSERT_EQ(timestampSet.type, timestampGet.type);
563 ASSERT_EQ(timestampSet.time, timestampGet.time);
564 }
565
566 /*
567 * Function: SetLayerMaskInfo and GetLayerMaskInfo
568 * Type: Function
569 * Rank: Important(1)
570 * EnvConditions: N/A
571 * CaseDescription: 1. call SetLayerMaskInfo
572 * 2. call GetLayerMaskInfo and check ret
573 * @tc.require: issueI6WBXO
574 */
575 HWTEST_F(HdiLayerInfoTest, SetLayerMaskInfo001, Function | MediumTest | Level1)
576 {
577 HdiLayerInfo::LayerMask layerMask = HdiLayerInfo::LayerMask::LAYER_MASK_NORMAL;
578 HdiLayerInfoTest::hdiLayerInfo_->SetLayerMaskInfo(layerMask);
579 HdiLayerInfo::LayerMask Get = HdiLayerInfoTest::hdiLayerInfo_->GetLayerMaskInfo();
580 ASSERT_EQ(layerMask, Get);
581 }
582
583 /*
584 * Function: SetLayerMaskInfo and GetLayerMaskInfo
585 * Type: Function
586 * Rank: Important(1)
587 * EnvConditions: N/A
588 * CaseDescription: 1. call SetLayerMaskInfo
589 * 2. call GetLayerMaskInfo and check ret
590 * @tc.require: issueI6WBXO
591 */
592 HWTEST_F(HdiLayerInfoTest, SetLayerMaskInfo002, Function | MediumTest | Level1)
593 {
594 HdiLayerInfo::LayerMask layerMask = HdiLayerInfo::LayerMask::LAYER_MASK_HBM_SYNC;
595 HdiLayerInfoTest::hdiLayerInfo_->SetLayerMaskInfo(layerMask);
596 HdiLayerInfo::LayerMask Get = HdiLayerInfoTest::hdiLayerInfo_->GetLayerMaskInfo();
597 ASSERT_EQ(layerMask, Get);
598 }
599 } // namespace
600 } // namespace Rosen
601 } // namespace OHOS