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 "hdi_device_test.h"
17 #include <chrono>
18 #include <cinttypes>
19 #include <algorithm>
20 #include "v1_2/include/idisplay_composer_interface.h"
21 #include "v1_1/display_composer_type.h"
22 #include "v1_0/display_buffer_type.h"
23 #include "display_test.h"
24 #include "display_test_utils.h"
25 #include "hdi_composition_check.h"
26 #include "hdi_test_device.h"
27 #include "hdi_test_device_common.h"
28 #include "hdi_test_display.h"
29 #include "hdi_test_render_utils.h"
30
31 using namespace OHOS::HDI::Display::Buffer::V1_0;
32 using namespace OHOS::HDI::Display::Composer::V1_1;
33 using namespace OHOS::HDI::Display::TEST;
34
35 const int SLEEP_CONT_100 = 100;
36 const int SLEEP_CONT_2000 = 2000;
37
38 static const std::vector<std::vector<LayerSettings>> TEST_SINGLE_LAYER = {
39 // one layer display test
40 {
41 {
42 .rectRatio = { 0, 0, 1.0f, 0.125f },
43 .color = RED
44 },
45 },
46 {
47 {
48 .rectRatio = { 0, 0.875f, 1.0f, 0.125f },
49 .color = GREEN
50 },
51 },
52 {
53 {
54 .rectRatio = { 0, 0.0, 1.0f, 1.0f },
55 .color = YELLOW
56 },
57 },
58 };
59
60 static const std::vector<std::vector<LayerSettings>> TEST_MULTILAYER = {
61
62 // three layer displayrect test
63 {
64 {
65 .rectRatio = { 0, 0, 1.0f, 1.0f },
66 .color = RED
67 },
68 {
69 .rectRatio = { 0, 0, 1.0f, 0.125f },
70 .color = GREEN
71 },
72 {
73 .rectRatio = { 0, 0.875f, 1.0f, 0.125f },
74 .color = YELLOW
75 },
76 }
77
78 };
79
80 static const std::vector<std::vector<LayerSettings>> TEST_SCALE = {
81 // scale layer test
82 {
83 {
84 .rectRatio = { 0, 0, 1.0f, 1.0f },
85 .color = RED,
86 .bufferRatio = { 1, 1 }
87 },
88 },
89 {
90 {
91 .rectRatio = { 0, 0, 1.0f, 0.125f },
92 .color = GREEN,
93 .bufferRatio = { 1, 1 }
94 },
95 },
96 {
97 {
98 .rectRatio = { 0, 0.875f, 1.0f, 0.125f },
99 .color = YELLOW,
100 .bufferRatio = { 1, 1 }
101 },
102 }
103 };
104
105 static const std::vector<std::vector<LayerSettings>> TEST_VIDEO = {
106 // video layer test
107 {
108 {
109 .rectRatio = { 0, 0, 1.0f, 0.125f },
110 .color = GREEN,
111 .compositionType = Composer::V1_0::CompositionType::COMPOSITION_VIDEO
112 },
113 },
114
115 {
116 {
117 .rectRatio = { 0, 0, 1.0f, 1.0f },
118 .color = RED },
119 {
120 .rectRatio = { 0, 0, 1.0f, 1.0f },
121 .color = RED,
122 .compositionType = Composer::V1_0::CompositionType::COMPOSITION_VIDEO
123 },
124 },
125 {
126 {
127 .rectRatio = { 0, 0, 1.0f, 1.0f },
128 .color = RED },
129 {
130 .rectRatio = { 0, 0, 1.0f, 0.125f },
131 .color = GREEN,
132 .compositionType = Composer::V1_0::CompositionType::COMPOSITION_VIDEO
133 },
134 },
135 {
136 {
137 .rectRatio = { 0, 0, 1.0f, 1.0f },
138 .color = RED },
139 {
140 .rectRatio = { 0, 0.875f, 1.0f, 0.125f },
141 .color = YELLOW,
142 .compositionType = Composer::V1_0::CompositionType::COMPOSITION_VIDEO
143 },
144 }
145 };
146
147 static const std::vector<std::vector<LayerSettings>> TEST_ALPHA = {
148 // alpha layer test
149 {
150 {
151 .rectRatio = { 0, 0, 1.0f, 1.0f },
152 .color = RED,
153 .alpha = 0xFF
154 },
155 },
156 {
157 {
158 .rectRatio = { 0, 0, 1.0f, 1.0f },
159 .color = RED,
160 .alpha = 0xFF
161 },
162 },
163 {
164 {
165 .rectRatio = { 0, 0, 1.0f, 1.0f },
166 .color = RED,
167 .alpha = 0xFF
168 },
169 },
170 // RED float will override, must use green now
171 {
172 {
173 .rectRatio = { 0, 0, 1.0f, 1.0f },
174 .color = GREEN,
175 .alpha = 0xFF,
176 .blendType = BLEND_SRCOVER
177 },
178 },
179 {
180 {
181 .rectRatio = { 0, 0, 1.0f, 1.0f },
182 .color = GREEN,
183 .alpha = 0xFF,
184 .blendType = BLEND_SRCOVER
185 },
186 },
187 {
188 {
189 .rectRatio = { 0, 0, 1.0f, 1.0f },
190 .color = GREEN,
191 .alpha = 0xFF,
192 .blendType = BLEND_SRCOVER
193 },
194 },
195 };
196
197 static const std::vector<LayerSettings> TEST_ROTATE = {
198 {
199 .rectRatio = { 0, 0, 1.0f, 1.0f },
200 .color = RED,
201 .rotate = ROTATE_NONE
202 },
203 {
204 .rectRatio = { 0, 0, 1.0f, 1.0f },
205 .color = RED,
206 .rotate = ROTATE_90
207 },
208 {
209 .rectRatio = { 0, 0, 1.0f, 1.0f },
210 .color = RED,
211 .rotate = ROTATE_180
212 },
213 {
214 .rectRatio = { 0, 0, 1.0f, 1.0f },
215 .color = RED,
216 .rotate = ROTATE_270
217 },
218 };
219
GetFirstDisplay()220 static inline std::shared_ptr<HdiTestDisplay> GetFirstDisplay()
221 {
222 return HdiTestDevice::GetInstance().GetFirstDisplay();
223 }
224
CheckComposition(std::vector<LayerSettings> & layers,BufferHandle * clientBuffer,uint32_t checkType=HdiCompositionCheck::CHECK_VERTEX)225 static int32_t CheckComposition(std::vector<LayerSettings> &layers, BufferHandle* clientBuffer,
226 uint32_t checkType = HdiCompositionCheck::CHECK_VERTEX)
227 {
228 DISPLAY_TEST_CHK_RETURN((clientBuffer == nullptr), DISPLAY_NULL_PTR, DISPLAY_TEST_LOGE("client buffer is nullptr"));
229 return HdiCompositionCheck::GetInstance().Check(layers, *clientBuffer, checkType);
230 }
231
CreateTestLayer(LayerSettings setting,uint32_t zorder)232 static std::shared_ptr<HdiTestLayer> CreateTestLayer(LayerSettings setting, uint32_t zorder)
233 {
234 int ret;
235 HdiTestDevice::GetInstance();
236 DISPLAY_TEST_LOGE("color 0x%x", setting.color);
237 std::shared_ptr<HdiTestDisplay> display = HdiTestDevice::GetInstance().GetFirstDisplay();
238 DISPLAY_TEST_CHK_RETURN((display == nullptr), nullptr, DISPLAY_TEST_LOGE("can not get display"));
239
240 std::shared_ptr<HdiTestLayer> layer = display->CreateHdiTestLayer(setting.bufferSize.w, setting.bufferSize.h);
241 DISPLAY_TEST_CHK_RETURN((layer == nullptr), nullptr, DISPLAY_TEST_LOGE("can not create hdi test layer"));
242
243 layer->SetLayerPosition(setting.displayRect);
244
245 layer->SetCompType(setting.compositionType);
246
247 if ((setting.alpha >= 0) && (setting.alpha <= 0xff)) { // alpha rang 0x00 ~ 0xff
248 LayerAlpha alpha = { 0 };
249 alpha.gAlpha = setting.alpha;
250 alpha.enGlobalAlpha = true;
251 layer->SetAlpha(alpha);
252 }
253 HdiGrallocBuffer* handle = layer->GetFrontBuffer();
254 DISPLAY_TEST_CHK_RETURN((handle == nullptr), nullptr, DISPLAY_TEST_LOGE("can not get front buffer"));
255 ClearColor(*(handle->Get()), setting.color);
256 ret = layer->SwapFrontToBackQ();
257 DISPLAY_TEST_CHK_RETURN((ret != DISPLAY_SUCCESS), nullptr, DISPLAY_TEST_LOGE("SwapFrontToBackQ failed"));
258 layer->SetZorder(zorder);
259 layer->SetBlendType(setting.blendType);
260 layer->SetTransform(setting.rotate);
261 return layer;
262 }
263
PrepareAndPrensent()264 static int PrepareAndPrensent()
265 {
266 int ret;
267 DISPLAY_TEST_LOGE();
268 std::shared_ptr<HdiTestDisplay> display = HdiTestDevice::GetInstance().GetFirstDisplay();
269 DISPLAY_TEST_CHK_RETURN((display == nullptr), DISPLAY_FAILURE, DISPLAY_TEST_LOGE("can not get display"));
270
271 ret = display->PrepareDisplayLayers();
272 DISPLAY_TEST_CHK_RETURN((ret != DISPLAY_SUCCESS), DISPLAY_FAILURE,
273 DISPLAY_TEST_LOGE("PrepareDisplayLayers failed"));
274
275 ret = display->Commit();
276 DISPLAY_TEST_CHK_RETURN((ret != DISPLAY_SUCCESS), DISPLAY_FAILURE, DISPLAY_TEST_LOGE("Commit failed"));
277 return DISPLAY_SUCCESS;
278 }
279
TestVBlankCallback(unsigned int sequence,uint64_t ns,void * data)280 static void TestVBlankCallback(unsigned int sequence, uint64_t ns, void* data)
281 {
282 static uint64_t lastns;
283 DISPLAY_TEST_LOGE("seq %{public}d ns %" PRId64 " duration %" PRId64 " ns", sequence, ns, (ns - lastns));
284 lastns = ns;
285 VblankCtr::GetInstance().NotifyVblank(sequence, ns, data);
286 }
287
AdjustLayerSettings(std::vector<LayerSettings> & settings,uint32_t w,uint32_t h)288 static void AdjustLayerSettings(std::vector<LayerSettings> &settings, uint32_t w, uint32_t h)
289 {
290 DISPLAY_TEST_LOGE();
291 for (uint32_t i = 0; i < settings.size(); i++) {
292 LayerSettings& setting = settings[i];
293 DISPLAY_TEST_LOGE(" ratio w: %f ratio h: %f", setting.rectRatio.w, setting.rectRatio.h);
294 if ((setting.rectRatio.w > 0.0f) && (setting.rectRatio.h > 0.0f)) {
295 setting.displayRect.h = static_cast<uint32_t>(setting.rectRatio.h * h);
296 setting.displayRect.w = static_cast<uint32_t>(setting.rectRatio.w * w);
297 setting.displayRect.x = static_cast<uint32_t>(setting.rectRatio.x * w);
298 setting.displayRect.y = static_cast<uint32_t>(setting.rectRatio.y * h);
299 DISPLAY_TEST_LOGE("display rect adust form %f %f %f %f to %{public}d %{public}d %{public}d %{public}d ",
300 setting.rectRatio.x, setting.rectRatio.y, setting.rectRatio.w, setting.rectRatio.h,
301 setting.displayRect.x, setting.displayRect.y, setting.displayRect.w, setting.displayRect.h);
302 }
303
304 if ((setting.bufferRatio.h > 0.0f) || (setting.bufferRatio.w > 0.0f)) {
305 setting.bufferSize.h = static_cast<uint32_t>(setting.bufferRatio.h * h);
306 setting.bufferSize.w = static_cast<uint32_t>(setting.bufferRatio.w * w);
307 DISPLAY_TEST_LOGE("buffer size adjust for %f %f to %{public}d %{public}d", setting.bufferRatio.w,
308 setting.bufferRatio.h, setting.bufferSize.w, setting.bufferSize.h);
309 }
310
311 if ((setting.bufferSize.w == 0) || (setting.bufferSize.h == 0)) {
312 DISPLAY_TEST_LOGE("buffer size adjust for %{public}d %{public}d to %{public}d %{public}d",
313 setting.bufferSize.w, setting.bufferSize.h, setting.displayRect.w, setting.displayRect.h);
314
315 setting.bufferSize.w = setting.displayRect.w;
316 setting.bufferSize.h = setting.displayRect.h;
317 }
318 }
319 }
320
CreateLayers(std::vector<LayerSettings> & settings)321 static std::vector<std::shared_ptr<HdiTestLayer>> CreateLayers(std::vector<LayerSettings> &settings)
322 {
323 DISPLAY_TEST_LOGE("settings %{public}zd", settings.size());
324 std::vector<std::shared_ptr<HdiTestLayer>> layers;
325 DisplayModeInfo mode = GetFirstDisplay()->GetCurrentMode();
326 AdjustLayerSettings(settings, mode.width, mode.height);
327 for (uint32_t i = 0; i < settings.size(); i++) {
328 LayerSettings setting = settings[i];
329
330 auto layer = CreateTestLayer(setting, i);
331 layers.push_back(layer);
332 }
333
334 return layers;
335 }
336
PresentAndCheck(std::vector<LayerSettings> & layerSettings,uint32_t checkType=HdiCompositionCheck::CHECK_VERTEX)337 static inline void PresentAndCheck(std::vector<LayerSettings> &layerSettings,
338 uint32_t checkType = HdiCompositionCheck::CHECK_VERTEX)
339 {
340 int ret = PrepareAndPrensent();
341 ASSERT_TRUE((ret == DISPLAY_SUCCESS));
342 if ((GetFirstDisplay()->SnapShot()) != nullptr) {
343 HdiTestDevice::GetInstance().GetGrallocInterface()->InvalidateCache(*(GetFirstDisplay()->SnapShot()));
344 ret = CheckComposition(layerSettings, GetFirstDisplay()->SnapShot(), checkType);
345 ASSERT_TRUE((ret == DISPLAY_SUCCESS));
346 }
347 }
348
PrepareAndCommit()349 static int PrepareAndCommit()
350 {
351 DISPLAY_TEST_LOGE();
352 std::shared_ptr<HdiTestDisplay> display = HdiTestDevice::GetInstance().GetFirstDisplay();
353 DISPLAY_TEST_CHK_RETURN((display == nullptr), DISPLAY_FAILURE, DISPLAY_TEST_LOGE("can not get display"));
354
355 int ret = display->PrepareDisplayLayers(); // 确定顶压策略(是否走GPU合成)、刷新layer列表
356 DISPLAY_TEST_CHK_RETURN((ret != DISPLAY_SUCCESS), DISPLAY_FAILURE,
357 DISPLAY_TEST_LOGE("PrepareDisplayLayers failed"));
358
359 ret = display->Commit(); // 送显
360 DISPLAY_TEST_CHK_RETURN((ret != DISPLAY_SUCCESS), DISPLAY_FAILURE, DISPLAY_TEST_LOGE("Commit failed"));
361 return DISPLAY_SUCCESS;
362 }
363
TearDown()364 void LayerRotateTest::TearDown()
365 {
366 HdiTestDevice::GetInstance().Clear();
367 }
368
TearDownTestCase()369 void LayerRotateTest::TearDownTestCase()
370 {
371 HdiTestDevice::GetInstance().GetFirstDisplay()->ResetClientLayer();
372 }
373
SetUpTestCase()374 void DeviceTest::SetUpTestCase()
375 {
376 int ret = HdiTestDevice::GetInstance().InitDevice();
377 ASSERT_TRUE(ret == DISPLAY_SUCCESS);
378 }
379
TearDown()380 void DeviceTest::TearDown()
381 {
382 HdiTestDevice::GetInstance().Clear();
383 }
384
TearDown()385 void DeviceLayerDisplay::TearDown()
386 {
387 #ifdef DISPLAY_COMMUNITY
388 HdiTestDevice::GetInstance().Clear();
389 #else
390 HdiTestDevice::GetInstance().Clear();
391 HdiTestDevice::GetInstance().GetFirstDisplay()->ResetClientLayer();
392 #endif // DISPLAY_COMMUNITY
393 }
394
NotifyVblank(unsigned int sequence,uint64_t ns,const void * data)395 void VblankCtr::NotifyVblank(unsigned int sequence, uint64_t ns, const void* data)
396 {
397 DISPLAY_TEST_LOGE();
398 if (data != nullptr) {
399 DISPLAY_TEST_LOGE("sequence = %{public}u, ns = %" PRIu64 "", sequence, ns);
400 }
401 std::unique_lock<std::mutex> lg(vblankMutex_);
402 hasVblank_ = true;
403 vblankCondition_.notify_one();
404 DISPLAY_TEST_LOGE();
405 }
406
~VblankCtr()407 VblankCtr::~VblankCtr() {}
408
WaitVblank(uint32_t ms)409 int32_t VblankCtr::WaitVblank(uint32_t ms)
410 {
411 bool ret = false;
412 DISPLAY_TEST_LOGE();
413 std::unique_lock<std::mutex> lck(vblankMutex_);
414 ret = vblankCondition_.wait_for(lck, std::chrono::milliseconds(ms), [=] { return hasVblank_; });
415 DISPLAY_TEST_LOGE();
416 if (!ret) {
417 return DISPLAY_FAILURE;
418 }
419 return DISPLAY_SUCCESS;
420 }
421
422 namespace {
TEST_P(DeviceLayerDisplay,LayerDisplay)423 TEST_P(DeviceLayerDisplay, LayerDisplay)
424 {
425 std::vector<LayerSettings> layerSettings = GetParam();
426 CreateLayers(layerSettings);
427 PresentAndCheck(layerSettings);
428 if (TestParemeter::GetInstance().mTestSleep > 0) {
429 sleep(TestParemeter::GetInstance().mTestSleep);
430 }
431 }
432
433 /**
434 * @tc.number: SUB_Driver_Display_HDI_2200
435 * @tc.name: test_SetLayerTransformMode_001
436 * @tc.desc: Testing the z-order values of layers, Please note that failing to save the composite
437 * data using clientLayer during display HDI adaptation image synthesis will cause this use case to fail
438 * @tc.size: MediumTest
439 * @tc.type: Function
440 */
TEST_F(DeviceTest,zorder)441 TEST_F(DeviceTest, zorder)
442 {
443 std::vector<LayerSettings> settings = {
444 {
445 .rectRatio = { 0, 0, 1.0f, 1.0f },
446 .color = RED },
447 {
448 .rectRatio = { 0, 0, 1.0f, 0.125f },
449 .color = GREEN },
450 {
451 .rectRatio = { 0, 0.875f, 1.0f, 0.125f },
452 .color = YELLOW },
453 };
454
455 std::vector<std::vector<int>> zorders = {
456 #ifdef DISPLAY_COMMUNITY
457 { 3, 2, 1 }, { 1, 3, 2 }, { 3, 1, 2 }, { 1, 2, 3 }, { 2, 1, 3 }, { 9, 100, 3 },
458 #else
459 { 0, 2, 1 }, { 1, 0, 2 }, { 0, 1, 2 }, { 1, 2, 0 }, { 2, 1, 0 },
460 #endif // DISPLAY_COMMUNITY
461 };
462 std::vector<std::shared_ptr<HdiTestLayer>> layers = CreateLayers(settings);
463
464 for (const auto& zorderList : zorders) {
465 // adjust the zorder
466 for (uint32_t i = 0; i < zorderList.size(); i++) {
467 settings[i].zorder = zorderList[i];
468 layers[i]->SetZorder(zorderList[i]);
469 }
470 std::vector<LayerSettings> tempSettings = settings;
471 std::sort(tempSettings.begin(), tempSettings.end(),
472 [=](const auto& l, auto const& r) { return l.zorder < r.zorder; });
473 // present and check
474 PresentAndCheck(tempSettings);
475 }
476 HdiTestDevice::GetInstance().Clear();
477 }
478
479 #ifdef DISPLAY_COMMUNITY
TEST_P(LayerRotateTest,SplitCheck)480 TEST_P(LayerRotateTest, SplitCheck)
481 {
482 LayerSettings settings = GetParam();
483 std::vector<LayerSettings> layersSetting = { settings };
484 std::vector<uint32_t> splitColors = { RED, GREEN, YELLOW, TRANSPARENT };
485 std::vector<std::shared_ptr<HdiTestLayer>> layers = CreateLayers(layersSetting);
486 ASSERT_TRUE((layers.size() > 0));
487 // split the buffer
488 auto layer = layers[0];
489 HdiGrallocBuffer* handle = layer->GetBackBuffer(); // the backbuffer has not present now
490 ASSERT_TRUE((handle != nullptr));
491 auto splitRects = SplitBuffer(*(handle->Get()), splitColors);
492 ASSERT_TRUE(splitRects.size() == splitColors.size()); // ensure the splitRects size
493 PrepareAndPrensent();
494 // change the rect and color to clockwise.
495 std::swap(splitColors[2], splitColors[1]);
496 std::swap(splitColors[2], splitColors[3]);
497 std::swap(splitRects[2], splitRects[1]);
498 std::swap(splitRects[2], splitRects[3]);
499
500 // rotation is clockwise,the color will change clockwise, we just change the color start index
501 uint32_t startIndex = 0;
502 switch (settings.rotate) {
503 case ROTATE_90:
504 startIndex = 3; // start form color index 3
505 break;
506 case ROTATE_180:
507 startIndex = 2; // start form color index 2
508 break;
509 case ROTATE_270:
510 startIndex = 1; // start form color index 1
511 break;
512 default:
513 startIndex = 0;
514 break;
515 }
516 std::vector<LayerSettings> layersCheck;
517 for (uint32_t i = 0; i < splitRects.size(); i++) {
518 uint32_t color = splitColors[(i + startIndex) % 4];
519 layersCheck.push_back({.displayRect = splitRects[i], .color = color});
520 }
521 ASSERT_TRUE((handle != nullptr));
522 /* for rotation may scale the buffer, Near the edge of rect the color will Smooth gradient,
523 so we must use the center to check.
524 */
525 PresentAndCheck(layersCheck, HdiCompositionCheck::CHECK_CENTER);
526 }
527 #endif // DISPLAY_COMMUNITY
528
529 /**
530 * @tc.number: SUB_Driver_Display_HDI_2300
531 * @tc.desc: Test layer cropping, Please note that failing to save the composite data using
532 * clientLayer during display HDI adaptation image synthesis will cause this use case to fail
533 * @tc.size: MediumTest
534 * @tc.type: Function
535 */
TEST_F(DeviceTest,crop)536 TEST_F(DeviceTest, crop)
537 {
538 std::vector<LayerSettings> settings = {
539 {
540 .rectRatio = { 0, 0, 1.0f, 1.0f },
541 .color = RED },
542 };
543 std::vector<uint32_t> splitColors = { { RED, GREEN, YELLOW, TRANSPARENT } };
544
545 std::vector<std::shared_ptr<HdiTestLayer>> layers = CreateLayers(settings);
546 ASSERT_TRUE((layers.size() > 0));
547 // split the buffer
548 auto layer = layers[0];
549 HdiGrallocBuffer* handle = layer->GetBackBuffer(); // the backbuffer has not present now
550 ASSERT_TRUE((handle != nullptr));
551 auto splitRects = SplitBuffer(*(handle->Get()), splitColors);
552 PrepareAndPrensent();
553 for (uint32_t i = 0; i < splitRects.size(); i++) {
554 settings[0].color = splitColors[i];
555 layer->SetLayerCrop(splitRects[i]);
556 PresentAndCheck(settings);
557 }
558 }
559
560 /**
561 * @tc.number: SUB_Driver_Display_HDI_2400
562 * @tc.desc: Control testing of graphic devices
563 * @tc.size: MediumTest
564 * @tc.type: Function
565 */
TEST_F(DeviceTest,CtrlTest)566 TEST_F(DeviceTest, CtrlTest)
567 {
568 int ret;
569 DISPLAY_TEST_LOGE();
570 std::shared_ptr<HdiTestDisplay> display = HdiTestDevice::GetInstance().GetFirstDisplay();
571 ASSERT_TRUE(display != nullptr) << "get display failed";
572 ret = display->RegDisplayVBlankCallback(TestVBlankCallback, nullptr);
573 ASSERT_TRUE(ret == DISPLAY_SUCCESS) << "RegDisplayVBlankCallback failed";
574 ret = display->SetDisplayVsyncEnabled(true);
575 ASSERT_TRUE(ret == DISPLAY_SUCCESS) << "SetDisplayVsyncEnabled failed";
576
577 std::vector<LayerSettings> settings = {
578 {
579 .rectRatio = { 0, 0, 1.0f, 1.0f },
580 .color = PINK
581 },
582 };
583 std::vector<std::shared_ptr<HdiTestLayer>> layers = CreateLayers(settings);
584 ASSERT_TRUE((layers.size() > 0));
585 VblankCtr::GetInstance().hasVblank_ = false;
586 PrepareAndCommit();
587 ret = VblankCtr::GetInstance().WaitVblank(SLEEP_CONT_2000); // 2000ms
588 ASSERT_TRUE(ret == DISPLAY_SUCCESS) << "WaitVblank timeout";
589 ret = display->SetDisplayVsyncEnabled(false);
590 ASSERT_TRUE(ret == DISPLAY_SUCCESS) << "SetDisplayVsyncEnabled failed";
591 usleep(SLEEP_CONT_100 * SLEEP_CONT_2000); // wait for 100ms avoid the last vsync.
592 VblankCtr::GetInstance().hasVblank_ = false;
593 ret = VblankCtr::GetInstance().WaitVblank(SLEEP_CONT_2000); // 2000ms
594 ASSERT_TRUE(ret != DISPLAY_SUCCESS) << "vblank do not disable";
595 }
596
597 /**
598 * @tc.number: SUB_Driver_Display_HDI_2500
599 * @tc.desc: Multi layer testing, Please note that failing to save the composite data using
600 * clientLayer during display HDI adaptation image synthesis will cause this use case to fail
601 * @tc.size: MediumTest
602 * @tc.type: Function
603 */
604 INSTANTIATE_TEST_SUITE_P(MultiLayer, DeviceLayerDisplay, ::testing::ValuesIn(TEST_MULTILAYER));
605
606 /**
607 * @tc.number: SUB_Driver_Display_HDI_2600-2800
608 * @tc.desc: Single layer testing, Please note that failing to save the composite data using
609 * clientLayer during display HDI adaptation image synthesis will cause this use case to fail
610 * @tc.size: MediumTest
611 * @tc.type: Function
612 */
613 INSTANTIATE_TEST_SUITE_P(SingleLayer, DeviceLayerDisplay, ::testing::ValuesIn(TEST_SINGLE_LAYER));
614
615 /**
616 * @tc.number: SUB_Driver_Display_HDI_2900-3100
617 * @tc.desc: Test for Scaling Layers, Please note that failing to save the composite data using
618 * clientLayer during display HDI adaptation image synthesis will cause this use case to fail
619 * @tc.size: MediumTest
620 * @tc.type: Function
621 */
622 INSTANTIATE_TEST_SUITE_P(ScaleLayer, DeviceLayerDisplay, ::testing::ValuesIn(TEST_SCALE));
623
624 /**
625 * @tc.number: SUB_Driver_Display_HDI_3200-3700
626 * @tc.desc: Transparency testing of layers, Please note that failing to save the composite data using
627 * clientLayer during display HDI adaptation image synthesis will cause this use case to fail
628 * @tc.size: MediumTest
629 * @tc.type: Function
630 */
631 INSTANTIATE_TEST_SUITE_P(LayerAlpha, DeviceLayerDisplay, ::testing::ValuesIn(TEST_ALPHA));
632
633 #ifdef DISPLAY_COMMUNITY
634 /**
635 * @tc.number: SUB_Driver_Display_HDI_3800-4100
636 * @tc.desc: Testing of video layers, , Please note that failing to save the composite data using
637 * clientLayer during display HDI adaptation image synthesis will cause this use case to fail
638 * @tc.size: MediumTest
639 * @tc.type: Function
640 */
641 INSTANTIATE_TEST_SUITE_P(VideoLayer, DeviceLayerDisplay, ::testing::ValuesIn(TEST_VIDEO));
642
643 /**
644 * @tc.number: SUB_Driver_Display_HDI_4200-4500
645 * @tc.desc: Layer Rotation Test, Please note that failing to save the composite data using
646 * clientLayer during display HDI adaptation image synthesis will cause this use case to fail
647 * @tc.size: MediumTest
648 * @tc.type: Function
649 */
650 INSTANTIATE_TEST_SUITE_P(Rotation, LayerRotateTest, ::testing::ValuesIn(TEST_ROTATE));
651 #endif // DISPLAY_COMMUNITY
652 }