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_composer_ut.h"
17 #include <chrono>
18 #include <cinttypes>
19 #include <algorithm>
20 #include "v1_2/include/idisplay_composer_interface.h"
21 #include "v1_2/include/idisplay_composer_interface.h"
22 #include "v1_1/display_composer_type.h"
23 #include "v1_0/display_buffer_type.h"
24 #include "display_test.h"
25 #include "display_test_utils.h"
26 #include "hdi_composition_check.h"
27 #include "hdi_test_device.h"
28 #include "hdi_test_device_common.h"
29 #include "hdi_test_display.h"
30 #include "hdi_test_render_utils.h"
31 #include "timer.h"
32 #include <sys/time.h>
33 #include <thread>
34 
35 using namespace OHOS::HDI::Display::Buffer::V1_0;
36 using namespace OHOS::HDI::Display::Composer::V1_1;
37 using namespace OHOS::HDI::Display::TEST;
38 using namespace testing::ext;
39 
40 static sptr<Composer::V1_2::IDisplayComposerInterface> g_composerDevice = nullptr;
41 static std::shared_ptr<IDisplayBuffer> g_gralloc = nullptr;
42 static std::vector<uint32_t> g_displayIds;
43 const int SLEEP_CONT_10 = 10;
44 const int SLEEP_CONT_100 = 100;
45 const int SLEEP_CONT_2000 = 2000;
46 static bool g_isOnSeamlessChangeCalled = false;
47 static bool g_isOnModeCalled = false;
48 static bool g_threadCtrl = false;
49 
GetFirstDisplay()50 static inline std::shared_ptr<HdiTestDisplay> GetFirstDisplay()
51 {
52     return HdiTestDevice::GetInstance().GetFirstDisplay();
53 }
54 
CheckComposition(std::vector<LayerSettings> &layers, BufferHandle* clientBuffer, uint32_t checkType = HdiCompositionCheck::CHECK_VERTEX)55 static int32_t CheckComposition(std::vector<LayerSettings> &layers, BufferHandle* clientBuffer,
56     uint32_t checkType = HdiCompositionCheck::CHECK_VERTEX)
57 {
58     DISPLAY_TEST_CHK_RETURN((clientBuffer == nullptr), DISPLAY_NULL_PTR, DISPLAY_TEST_LOGE("client buffer is nullptr"));
59     return HdiCompositionCheck::GetInstance().Check(layers, *clientBuffer, checkType);
60 }
61 
CreateTestLayer(LayerSettings setting, uint32_t zorder)62 static std::shared_ptr<HdiTestLayer> CreateTestLayer(LayerSettings setting, uint32_t zorder)
63 {
64     int ret;
65     HdiTestDevice::GetInstance();
66     DISPLAY_TEST_LOGE("color 0x%x", setting.color);
67     std::shared_ptr<HdiTestDisplay> display = HdiTestDevice::GetInstance().GetFirstDisplay();
68     DISPLAY_TEST_CHK_RETURN((display == nullptr), nullptr, DISPLAY_TEST_LOGE("can not get display"));
69 
70     std::shared_ptr<HdiTestLayer> layer = display->CreateHdiTestLayer(setting.bufferSize.w, setting.bufferSize.h);
71     DISPLAY_TEST_CHK_RETURN((layer == nullptr), nullptr, DISPLAY_TEST_LOGE("can not create hdi test layer"));
72 
73     layer->SetLayerPosition(setting.displayRect);
74 
75     layer->SetCompType(setting.compositionType);
76 
77     if ((setting.alpha >= 0) && (setting.alpha <= 0xff)) { // alpha rang 0x00 ~ 0xff
78         LayerAlpha alpha = { 0 };
79         alpha.gAlpha = setting.alpha;
80         alpha.enGlobalAlpha = true;
81         layer->SetAlpha(alpha);
82     }
83     HdiGrallocBuffer* handle = layer->GetFrontBuffer();
84     DISPLAY_TEST_CHK_RETURN((handle == nullptr), nullptr, DISPLAY_TEST_LOGE("can not get front buffer"));
85     ClearColor(*(handle->Get()), setting.color);
86     ret = layer->SwapFrontToBackQ();
87     DISPLAY_TEST_CHK_RETURN((ret != DISPLAY_SUCCESS), nullptr, DISPLAY_TEST_LOGE("SwapFrontToBackQ failed"));
88     layer->SetZorder(zorder);
89     layer->SetBlendType(setting.blendType);
90     layer->SetTransform(setting.rotate);
91     return layer;
92 }
93 
PrepareAndCommit()94 static int PrepareAndCommit()
95 {
96     int ret;
97     DISPLAY_TEST_LOGE();
98     std::shared_ptr<HdiTestDisplay> display = HdiTestDevice::GetInstance().GetFirstDisplay();
99     DISPLAY_TEST_CHK_RETURN((display == nullptr), DISPLAY_FAILURE, DISPLAY_TEST_LOGE("can not get display"));
100 
101     ret = display->PrepareDisplayLayers(); // 确定顶压策略(是否走GPU合成)、刷新layer列表
102     DISPLAY_TEST_CHK_RETURN((ret != DISPLAY_SUCCESS), DISPLAY_FAILURE,
103         DISPLAY_TEST_LOGE("PrepareDisplayLayers failed"));
104 
105     ret = display->Commit(); // 送显
106     DISPLAY_TEST_CHK_RETURN((ret != DISPLAY_SUCCESS), DISPLAY_FAILURE, DISPLAY_TEST_LOGE("Commit failed"));
107     return DISPLAY_SUCCESS;
108 }
109 
LoopCommit()110 static void LoopCommit()
111 {
112     while (!g_threadCtrl) {
113         PrepareAndCommit();
114         std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_CONT_10));
115     }
116 }
117 
TestVBlankCallback(unsigned int sequence, uint64_t ns, void* data)118 static void TestVBlankCallback(unsigned int sequence, uint64_t ns, void* data)
119 {
120     static uint64_t lastns;
121     DISPLAY_TEST_LOGE("seq %{public}d  ns %" PRId64 " duration %" PRId64 " ns", sequence, ns, (ns - lastns));
122     lastns = ns;
123     VblankCtr::GetInstance().NotifyVblank(sequence, ns, data);
124 }
125 
AdjustLayerSettings(std::vector<LayerSettings> &settings, uint32_t w, uint32_t h)126 static void AdjustLayerSettings(std::vector<LayerSettings> &settings, uint32_t w, uint32_t h)
127 {
128     DISPLAY_TEST_LOGE();
129     for (uint32_t i = 0; i < settings.size(); i++) {
130         LayerSettings& setting = settings[i];
131         DISPLAY_TEST_LOGE(" ratio w: %f  ratio h: %f", setting.rectRatio.w, setting.rectRatio.h);
132         if ((setting.rectRatio.w > 0.0f) && (setting.rectRatio.h > 0.0f)) {
133             setting.displayRect.h = static_cast<uint32_t>(setting.rectRatio.h * h);
134             setting.displayRect.w = static_cast<uint32_t>(setting.rectRatio.w * w);
135             setting.displayRect.x = static_cast<uint32_t>(setting.rectRatio.x * w);
136             setting.displayRect.y = static_cast<uint32_t>(setting.rectRatio.y * h);
137             DISPLAY_TEST_LOGE("display rect adust form %f %f %f %f to %{public}d %{public}d %{public}d %{public}d ",
138             setting.rectRatio.x, setting.rectRatio.y, setting.rectRatio.w, setting.rectRatio.h, setting.displayRect.x,
139                 setting.displayRect.y, setting.displayRect.w, setting.displayRect.h);
140         }
141 
142         if ((setting.bufferRatio.h > 0.0f) || (setting.bufferRatio.w > 0.0f)) {
143             setting.bufferSize.h = static_cast<uint32_t>(setting.bufferRatio.h * h);
144             setting.bufferSize.w = static_cast<uint32_t>(setting.bufferRatio.w * w);
145             DISPLAY_TEST_LOGE("buffer size adjust for %f %f to %{public}d %{public}d",
146                 setting.bufferRatio.w, setting.bufferRatio.h, setting.bufferSize.w, setting.bufferSize.h);
147         }
148 
149         if ((setting.bufferSize.w == 0) || (setting.bufferSize.h == 0)) {
150             DISPLAY_TEST_LOGE("buffer size adjust for %{public}d %{public}d to %{public}d %{public}d",
151                 setting.bufferSize.w, setting.bufferSize.h, setting.displayRect.w, setting.displayRect.h);
152 
153             setting.bufferSize.w = setting.displayRect.w;
154             setting.bufferSize.h = setting.displayRect.h;
155         }
156     }
157 }
158 
CreateLayers(std::vector<LayerSettings> &settings)159 static std::vector<std::shared_ptr<HdiTestLayer>> CreateLayers(std::vector<LayerSettings> &settings)
160 {
161     DISPLAY_TEST_LOGE("settings %{public}zd", settings.size());
162     std::vector<std::shared_ptr<HdiTestLayer>> layers;
163     DisplayModeInfo mode = GetFirstDisplay()->GetCurrentMode();
164     AdjustLayerSettings(settings, mode.width, mode.height);
165     for (uint32_t i = 0; i < settings.size(); i++) {
166         LayerSettings setting = settings[i];
167 
168         auto layer = CreateTestLayer(setting, i);
169         layers.push_back(layer);
170     }
171 
172     return layers;
173 }
174 
PresentAndCheck(std::vector<LayerSettings> &layerSettings, uint32_t checkType = HdiCompositionCheck::CHECK_VERTEX)175 static inline void PresentAndCheck(std::vector<LayerSettings> &layerSettings,
176     uint32_t checkType = HdiCompositionCheck::CHECK_VERTEX)
177 {
178     int ret = PrepareAndCommit();
179     ASSERT_TRUE((ret == DISPLAY_SUCCESS));
180     if ((GetFirstDisplay()->SnapShot()) != nullptr) {
181         HdiTestDevice::GetInstance().GetGrallocInterface()->InvalidateCache(*(GetFirstDisplay()->SnapShot()));
182         ret = CheckComposition(layerSettings, GetFirstDisplay()->SnapShot(), checkType);
183         ASSERT_TRUE((ret == DISPLAY_SUCCESS));
184     }
185 }
186 
DestroyLayer(std::shared_ptr<HdiTestLayer> layer)187 static void DestroyLayer(std::shared_ptr<HdiTestLayer> layer)
188 {
189     std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_CONT_100));
190     auto ret = g_composerDevice->DestroyLayer(g_displayIds[0], layer->GetId());
191     if (ret != DISPLAY_SUCCESS && ret != DISPLAY_NOT_SUPPORT) {
192         DISPLAY_TEST_LOGE("DestroyLayer fail or not support, ret: %{public}d", ret);
193         return;
194     }
195     std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_CONT_100));
196 }
197 
SetUpTestCase()198 void DeviceTest::SetUpTestCase()
199 {
200     int ret = HdiTestDevice::GetInstance().InitDevice();
201     ASSERT_TRUE(ret == DISPLAY_SUCCESS);
202 
203     g_composerDevice = HdiTestDevice::GetInstance().GetDeviceInterface();
204     ASSERT_TRUE(g_composerDevice != nullptr);
205 
206     g_gralloc.reset(IDisplayBuffer::Get());
207     ASSERT_TRUE(g_gralloc != nullptr);
208 
209     g_displayIds = HdiTestDevice::GetInstance().GetDevIds();
210     ASSERT_TRUE(g_displayIds.size() > 0);
211 }
212 
TearDownTestCase()213 void DeviceTest::TearDownTestCase()
214 {
215     HdiTestDevice::GetInstance().Clear();
216     HdiTestDevice::GetInstance().GetFirstDisplay()->ResetClientLayer();
217 }
218 
NotifyVblank(unsigned int sequence, uint64_t ns, const void* data)219 void VblankCtr::NotifyVblank(unsigned int sequence, uint64_t ns, const void* data)
220 {
221     DISPLAY_TEST_LOGE();
222     if (data != nullptr) {
223         DISPLAY_TEST_LOGE("sequence = %{public}u, ns = %" PRIu64 "", sequence, ns);
224     }
225     std::unique_lock<std::mutex> lg(vblankMutex_);
226     hasVblank_ = true;
227     vblankCondition_.notify_one();
228     DISPLAY_TEST_LOGE();
229 }
230 
~VblankCtr()231 VblankCtr::~VblankCtr() {}
232 
WaitVblank(uint32_t ms)233 int32_t VblankCtr::WaitVblank(uint32_t ms)
234 {
235     bool ret = false;
236     DISPLAY_TEST_LOGE();
237     std::unique_lock<std::mutex> lck(vblankMutex_);
238     ret = vblankCondition_.wait_for(lck, std::chrono::milliseconds(ms), [=] { return hasVblank_; });
239     DISPLAY_TEST_LOGE();
240     if (!ret) {
241         return DISPLAY_FAILURE;
242     }
243     return DISPLAY_SUCCESS;
244 }
245 
246 /**
247  * @tc.number: SUB_Driver_Display_HDI_4600
248  * @tc.name: test_SetClientBufferCacheCount
249  * @tc.desc: test cache count Random
250  * @tc.size: MediumTest
251  * @tc.type: Function
252  */
HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_4600, TestSize.Level1)253 HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_4600, TestSize.Level1)
254 {
255     const uint32_t CACHE_COUNT = 5;
256     auto ret = g_composerDevice->SetClientBufferCacheCount(g_displayIds[0], CACHE_COUNT);
257     EXPECT_EQ(DISPLAY_SUCCESS, ret);
258 }
259 
260 /**
261  * @tc.number: SUB_Driver_Display_HDI_4700
262  * @tc.name: test_GetDisplayCapability
263  * @tc.desc: Obtains the display modes supported by a display device
264  * @tc.size: MediumTest
265  * @tc.type: Function
266  */
HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_4700, TestSize.Level1)267 HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_4700, TestSize.Level1)
268 {
269     DisplayCapability info;
270     auto ret = g_composerDevice->GetDisplayCapability(g_displayIds[0], info);
271     EXPECT_EQ(DISPLAY_SUCCESS, ret);
272 }
273 
274 /**
275  * @tc.number: SUB_Driver_Display_HDI_4800
276  * @tc.name: test_GetDisplaySupportedModes
277  * @tc.desc:  Obtains the current display mode of a display device
278  * @tc.size: MediumTest
279  * @tc.type: Function
280  */
HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_4800, TestSize.Level1)281 HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_4800, TestSize.Level1)
282 {
283     std::vector<DisplayModeInfo> modes;
284     auto ret = g_composerDevice->GetDisplaySupportedModes(g_displayIds[0], modes);
285     EXPECT_EQ(DISPLAY_SUCCESS, ret);
286 }
287 
288 /**
289  * @tc.number: SUB_Driver_Display_HDI_4900
290  * @tc.name: test_GetDisplayMode
291  * @tc.desc: Get the pattern with pattern ID 0
292  * @tc.size: MediumTest
293  * @tc.type: Function
294  */
HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_4900, TestSize.Level1)295 HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_4900, TestSize.Level1)
296 {
297     uint32_t MODE = 0;
298     auto ret = g_composerDevice->GetDisplayMode(g_displayIds[0], MODE);
299     EXPECT_EQ(DISPLAY_SUCCESS, ret);
300 }
301 
302 /**
303  * @tc.number: SUB_Driver_Display_HDI_5000
304  * @tc.name: test_SetDisplayMode
305  * @tc.desc: Set the display mode ID to 0
306  * @tc.size: MediumTest
307  * @tc.type: Function
308  */
HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_5000, TestSize.Level1)309 HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_5000, TestSize.Level1)
310 {
311     const uint32_t MODE = 0;
312     auto ret = g_composerDevice->SetDisplayMode(g_displayIds[0], MODE);
313     EXPECT_EQ(DISPLAY_SUCCESS, ret);
314 }
315 
316 /**
317  * @tc.number: SUB_Driver_Display_HDI_5100
318  * @tc.name: test_GetDisplayPowerStatus
319  * @tc.desc: Set the power status of the display device POWER_STATUS_OFF
320  * @tc.size: MediumTest
321  * @tc.type: Function
322  */
HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_5100, TestSize.Level1)323 HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_5100, TestSize.Level1)
324 {
325     Composer::V1_0::DispPowerStatus powerStatus = Composer::V1_0::DispPowerStatus::POWER_STATUS_OFF;
326     auto ret = g_composerDevice->GetDisplayPowerStatus(g_displayIds[0], powerStatus);
327     EXPECT_EQ(DISPLAY_SUCCESS, ret);
328 }
329 
330 /**
331  * @tc.number: SUB_Driver_Display_HDI_5200
332  * @tc.name: test_SetDisplayPowerStatus_001
333  * @tc.desc: Set the power status of the display device
334  * @tc.size: MediumTest
335  * @tc.type: Function
336  */
HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_5200, TestSize.Level1)337 HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_5200, TestSize.Level1)
338 {
339     auto ret = g_composerDevice->SetDisplayPowerStatus(g_displayIds[0],
340         Composer::V1_0::DispPowerStatus::POWER_STATUS_STANDBY);
341     EXPECT_EQ(DISPLAY_SUCCESS, ret);
342 
343     ret = g_composerDevice->SetDisplayPowerStatus(g_displayIds[0],
344         Composer::V1_0::DispPowerStatus::POWER_STATUS_ON);
345     EXPECT_EQ(DISPLAY_SUCCESS, ret);
346 }
347 
348 /**
349  * @tc.number: SUB_Driver_Display_HDI_5300
350  * @tc.name: test_GetDisplayBacklight
351  * @tc.desc: Set the backlight value of the display device to leve1
352  * @tc.size: MediumTest
353  * @tc.type: Function
354  */
355 #ifdef DISPLAY_COMMUNITY
HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_5300, TestSize.Level1)356 HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_5300, TestSize.Level1)
357 {
358     uint32_t level;
359     auto ret = g_composerDevice->GetDisplayBacklight(g_displayIds[0], level);
360     EXPECT_EQ(DISPLAY_SUCCESS, ret);
361 }
362 #endif
363 
364 /**
365  * @tc.number: SUB_Driver_Display_HDI_5400
366  * @tc.name: test_SetDisplayBacklight
367  * @tc.desc: Sets the backlight value for a display device
368  * @tc.size: MediumTest
369  * @tc.type: Function
370  */
HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_5400, TestSize.Level1)371 HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_5400, TestSize.Level1)
372 {
373     const uint32_t LEVEL = 10;
374     auto ret = g_composerDevice->SetDisplayBacklight(g_displayIds[0], LEVEL);
375     EXPECT_EQ(DISPLAY_SUCCESS, ret);
376 }
377 
378 /**
379  * @tc.number: SUB_Driver_Display_HDI_5500
380  * @tc.name: test_GetDisplayProperty
381  * @tc.desc: Obtains the property for a display device
382  * @tc.size: MediumTest
383  * @tc.type: Function
384  */
HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_5500, TestSize.Level1)385 HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_5500, TestSize.Level1)
386 {
387     const uint32_t PROPERTY_ID = 1;
388     uint64_t propertyValue = 0;
389     auto ret = g_composerDevice->GetDisplayProperty(g_displayIds[0], PROPERTY_ID, propertyValue);
390 #ifdef DISPLAY_COMMUNITY
391     EXPECT_EQ(DISPLAY_NOT_SUPPORT, ret);
392 #else
393     if (ret == DISPLAY_NOT_SUPPORT) {
394         DISPLAY_TEST_LOGE("GetDisplayProperty not support");
395         return;
396     }
397     EXPECT_EQ(DISPLAY_SUCCESS, ret);
398 #endif
399 }
400 
401 /**
402  * @tc.number: SUB_Driver_Display_HDI_5600
403  * @tc.name: test_GetDisplayCompChange
404  * @tc.desc: Obtains the layers whose composition types have changed
405  * @tc.size: MediumTest
406  * @tc.type: Function
407  */
HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_5600, TestSize.Level1)408 HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_5600, TestSize.Level1)
409 {
410     std::vector<uint32_t> layers {};
411     std::vector<int32_t> type {};
412     auto ret = g_composerDevice->GetDisplayCompChange(g_displayIds[0], layers, type);
413     EXPECT_EQ(DISPLAY_SUCCESS, ret);
414 }
415 
416 /**
417  * @tc.number: SUB_Driver_Display_HDI_5700
418  * @tc.name: test_SetDisplayClientCrop
419  * @tc.desc: Sets the cropped region for a display device
420  * @tc.size: MediumTest
421  * @tc.type: Function
422  */
HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_5700, TestSize.Level1)423 HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_5700, TestSize.Level1)
424 {
425     const int32_t WIDTH = 1920;
426     const int32_t HEIGHT = 1080;
427     IRect rect = {0, 0, WIDTH, HEIGHT};
428     auto ret = g_composerDevice->SetDisplayClientCrop(g_displayIds[0], rect);
429     // not support
430     EXPECT_EQ(DISPLAY_FAILURE, ret);
431 }
432 
433 /**
434  * @tc.number: SUB_Driver_Display_HDI_5800
435  * @tc.name: test_GetDisplayReleaseFence
436  * @tc.desc: Obtains the fences of the display layers after the commit operation
437  * @tc.size: MediumTest
438  * @tc.type: Function
439  */
HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_5800, TestSize.Level1)440 HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_5800, TestSize.Level1)
441 {
442     std::vector<uint32_t> layers {};
443     std::vector<int32_t> fences {};
444     auto ret = g_composerDevice->GetDisplayReleaseFence(g_displayIds[0], layers, fences);
445     EXPECT_EQ(DISPLAY_SUCCESS, ret);
446 }
447 
448 /**
449  * @tc.number: SUB_Driver_Display_HDI_5900
450  * @tc.name: test_SetDisplayClientBuffer
451  * @tc.desc: Sets the display buffer for a display device
452  * @tc.size: MediumTest
453  * @tc.type: Function
454  */
HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_5900, TestSize.Level1)455 HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_5900, TestSize.Level1)
456 {
457     BufferHandle* buffer = nullptr;
458     const int32_t WIDTH = 800;
459     const int32_t HEIGHT = 600;
460 
461     AllocInfo info;
462     info.width  = WIDTH;
463     info.height = HEIGHT;
464     info.usage = OHOS::HDI::Display::Composer::V1_0::HBM_USE_MEM_DMA |
465             OHOS::HDI::Display::Composer::V1_0::HBM_USE_CPU_READ |
466             OHOS::HDI::Display::Composer::V1_0::HBM_USE_CPU_WRITE;
467     info.format = Composer::V1_0::PIXEL_FMT_RGBA_8888;
468 
469     g_gralloc->AllocMem(info, buffer);
470     ASSERT_TRUE(buffer != nullptr);
471 
472     uint32_t bufferSeq = 1;
473     auto ret = g_composerDevice->SetDisplayClientBuffer(g_displayIds[0], buffer, bufferSeq, -1);
474     g_gralloc->FreeMem(*buffer);
475     EXPECT_EQ(DISPLAY_SUCCESS, ret);
476 }
477 
478 /**
479  * @tc.number: SUB_Driver_Display_HDI_6000
480  * @tc.name: test_SetDisplayClientDamage
481  * @tc.desc: Sets the dirty region for a display device
482  * @tc.size: MediumTest
483  * @tc.type: Function
484  */
HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_6000, TestSize.Level1)485 HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_6000, TestSize.Level1)
486 {
487     const int32_t WIDTH = 1920;
488     const int32_t HEIGHT = 1080;
489     IRect rect = {0, 0, WIDTH, HEIGHT};
490     std::vector<IRect> vRects;
491     vRects.push_back(rect);
492     auto ret = g_composerDevice->SetDisplayClientDamage(g_displayIds[0], vRects);
493     // not support
494     EXPECT_EQ(DISPLAY_SUCCESS, ret);
495 }
496 
497 /**
498  * @tc.number: SUB_Driver_Display_HDI_6100
499  * @tc.name: test_CreateVirtualDisplay
500  * @tc.desc: Creates a virtual display device
501  * @tc.size: MediumTest
502  * @tc.type: Function
503  */
HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_6100, TestSize.Level1)504 HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_6100, TestSize.Level1)
505 {
506     const uint32_t WIDTH = 1920;
507     const uint32_t HEIGHT = 1080;
508     int32_t format = 0;
509     uint32_t devId = 0;
510     auto ret = g_composerDevice->CreateVirtualDisplay(WIDTH, HEIGHT, format, devId);
511     // not support
512     EXPECT_EQ(DISPLAY_FAILURE, ret);
513 }
514 
515 /**
516  * @tc.number: SUB_Driver_Display_HDI_6200
517  * @tc.name: test_DestroyVirtualDisplay
518  * @tc.desc: UpdateSettings, OHOS_CONTROL_AE_MODE
519  * @tc.size: MediumTest
520  * @tc.type: Function
521  */
HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_6200, TestSize.Level1)522 HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_6200, TestSize.Level1)
523 {
524     uint32_t devId = 0;
525     auto ret = g_composerDevice->DestroyVirtualDisplay(devId);
526     // not support
527     EXPECT_EQ(DISPLAY_FAILURE, ret);
528 }
529 
530 /**
531  * @tc.number: SUB_Driver_Display_HDI_6300
532  * @tc.name: test_SetVirtualDisplayBuffer
533  * @tc.desc: Destroys a virtual display device
534  * @tc.size: MediumTest
535  * @tc.type: Function
536  */
HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_6300, TestSize.Level1)537 HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_6300, TestSize.Level1)
538 {
539     BufferHandle* buffer = nullptr;
540     int32_t fence = -1;
541     const int32_t WIDTH = 800;
542     const int32_t HEIGHT = 600;
543 
544     AllocInfo info;
545     info.width  = WIDTH;
546     info.height = HEIGHT;
547     info.usage = OHOS::HDI::Display::Composer::V1_0::HBM_USE_MEM_DMA |
548             OHOS::HDI::Display::Composer::V1_0::HBM_USE_CPU_READ |
549             OHOS::HDI::Display::Composer::V1_0::HBM_USE_CPU_WRITE;
550     info.format = Composer::V1_0::PIXEL_FMT_RGBA_8888;
551 
552     g_gralloc->AllocMem(info, buffer);
553     ASSERT_TRUE(buffer != nullptr);
554 
555     auto ret = g_composerDevice->SetVirtualDisplayBuffer(g_displayIds[0], *buffer, fence);
556     g_gralloc->FreeMem(*buffer);
557     // not support
558     EXPECT_EQ(DISPLAY_FAILURE, ret);
559 }
560 
561 /**
562  * @tc.number: SUB_Driver_Display_HDI_6400
563  * @tc.name: test_SetDisplayProperty
564  * @tc.desc: Sets the property for a display device
565  * @tc.size: MediumTest
566  * @tc.type: Function
567  */
HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_6400, TestSize.Level1)568 HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_6400, TestSize.Level1)
569 {
570     const uint32_t PROPERTY_ID = 1;
571     const uint64_t PROPERTY_VALUE = 0;
572     auto ret = g_composerDevice->SetDisplayProperty(g_displayIds[0], PROPERTY_ID, PROPERTY_VALUE);
573     // not support
574     EXPECT_EQ(DISPLAY_FAILURE, ret);
575 }
576 
577 /**
578  * @tc.number: SUB_Driver_Display_HDI_6500
579  * @tc.name: test_SetLayerCrop
580  * @tc.desc: Sets the rectangular area to crop for a layer, Please note that failing to save the composite
581  * data using clientLayer during display HDI adaptation image synthesis will cause this use case to fail
582  * @tc.size: MediumTest
583  * @tc.type: Function
584  */
HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_6500, TestSize.Level1)585 HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_6500, TestSize.Level1)
586 {
587     std::vector<LayerSettings> settings = {
588         {
589             .rectRatio = { 0, 0, 1.0f, 1.0f },
590             .color = RED
591         },
592     };
593     std::vector<uint32_t> splitColors = { { RED, GREEN, YELLOW, BLUE, PINK, PURPLE, CYAN, TRANSPARENT } };
594 
595     std::vector<std::shared_ptr<HdiTestLayer>> layers = CreateLayers(settings);
596     ASSERT_TRUE((layers.size() > 0));
597     // split the buffer
598     auto layer = layers[0];
599     HdiGrallocBuffer* handle = layer->GetBackBuffer(); // the backbuffer has not present now
600     ASSERT_TRUE((handle != nullptr));
601     auto splitRects = SplitBuffer(*(handle->Get()), splitColors);
602     PrepareAndCommit();
603     for (uint32_t i = 0; i < splitRects.size(); i++) {
604         settings[0].color = splitColors[i];
605         layer->SetLayerCrop(splitRects[i]);
606         PresentAndCheck(settings);
607     }
608 
609     DestroyLayer(layer);
610 }
611 
612 /**
613  * @tc.number: SUB_Driver_Display_HDI_6600
614  * @tc.name: test_SetLayerZorder
615  * @tc.desc: Sets the z-order for a layer, Please note that failing to save the composite data
616  * using clientLayer during display HDI adaptation image synthesis will cause this use case to fail
617  * @tc.size: MediumTest
618  * @tc.type: Function
619  */
HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_6600, TestSize.Level1)620 HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_6600, TestSize.Level1)
621 {
622     std::vector<LayerSettings> settings = {
623         {
624             .rectRatio = { 0, 0, 1.0f, 1.0f },
625             .color = RED
626         },
627         {
628             .rectRatio = { 0, 0, 1.0f, 1.0f },
629             .color = GREEN
630         },
631         {
632             .rectRatio = { 0, 0, 1.0f, 1.0f },
633             .color = YELLOW
634         },
635     };
636 
637     std::vector<std::vector<int>> zorders = {
638         { 3, 2, 1 }, { 1, 3, 2 }, { 3, 1, 2 }, { 1, 2, 3 }, { 2, 1, 3 }, { 2, 3, 1 },
639     };
640     std::vector<std::shared_ptr<HdiTestLayer>> layers = CreateLayers(settings);
641 
642     for (const auto& zorderList : zorders) {
643         // adjust the zorder
644         for (uint32_t i = 0; i < zorderList.size(); i++) {
645             settings[i].zorder = zorderList[i];
646             layers[i]->SetZorder(zorderList[i]);
647         }
648         std::vector<LayerSettings> tempSettings = settings;
649         std::sort(tempSettings.begin(), tempSettings.end(),
650             [=](const auto& l, auto const & r) { return l.zorder < r.zorder; });
651         // present and check
652         PresentAndCheck(tempSettings);
653     }
654     HdiTestDevice::GetInstance().Clear();
655 }
656 
657 /**
658  * @tc.number: SUB_Driver_Display_HDI_6700
659  * @tc.name: test_SetLayerPreMulti
660  * @tc.desc: Sets layer premultiplication
661  * @tc.size: MediumTest
662  * @tc.type: Function
663  */
HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_6700, TestSize.Level1)664 HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_6700, TestSize.Level1)
665 {
666     std::vector<LayerSettings> settings = {
667         {
668             .rectRatio = { 0, 0, 1.0f, 1.0f },
669             .color = GREEN
670         },
671     };
672 
673     std::vector<std::shared_ptr<HdiTestLayer>> layers = CreateLayers(settings);
674     ASSERT_TRUE((layers.size() > 0));
675     PrepareAndCommit();
676 
677     auto layer = layers[0];
678     bool preMul = true;
679     auto ret = g_composerDevice->SetLayerPreMulti(g_displayIds[0], layer->GetId(), preMul);
680 
681     PrepareAndCommit();
682     HdiTestDevice::GetInstance().Clear();
683     EXPECT_EQ(DISPLAY_SUCCESS, ret);
684 
685     DestroyLayer(layer);
686 }
687 
688 /**
689  * @tc.number: SUB_Driver_Display_HDI_6800
690  * @tc.name: test_SetLayerAlpha
691  * @tc.desc: Sets the alpha value for a layer
692  * @tc.size: MediumTest
693  * @tc.type: Function
694  */
HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_6800, TestSize.Level1)695 HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_6800, TestSize.Level1)
696 {
697     std::vector<LayerSettings> settings = {
698         {
699             .rectRatio = { 0, 0, 1.0f, 1.0f },
700             .color = GREEN
701         },
702         {
703             .rectRatio = { 0, 0, 1.0f, 1.0f },
704             .color = RED
705         },
706     };
707 
708     std::vector<std::shared_ptr<HdiTestLayer>> layers = CreateLayers(settings);
709     ASSERT_TRUE((layers.size() > 0));
710 
711     auto layer = layers[1];
712     LayerAlpha alpha = { 0 };
713     alpha.enGlobalAlpha = true;
714     alpha.enPixelAlpha = true;
715     alpha.gAlpha = 0;
716     alpha.alpha0 = 0;
717     alpha.alpha1 = 0;
718     layer->SetAlpha(alpha);
719 
720     PrepareAndCommit();
721     HdiTestDevice::GetInstance().Clear();
722 
723     DestroyLayer(layer);
724 }
725 
726 /**
727  * @tc.number: SUB_Driver_Display_HDI_6900
728  * @tc.name: test_SetLayerRegion
729  * @tc.desc: Sets the region for a layer
730  * @tc.size: MediumTest
731  * @tc.type: Function
732  */
HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_6900, TestSize.Level1)733 HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_6900, TestSize.Level1)
734 {
735     std::vector<LayerSettings> settings = {
736         {.rectRatio = {0, 0, 1.0f, 1.0f}, .color = GREEN, .alpha = 0xFF}
737     };
738 
739     std::vector<std::shared_ptr<HdiTestLayer>> layers = CreateLayers(settings);
740     ASSERT_TRUE((layers.size() > 0));
741 
742     const int32_t WIDTH = 100;
743     const int32_t HEIGHT = 100;
744     auto layer = layers[0];
745     IRect rect = {0, 0, WIDTH, HEIGHT};
746     auto ret = g_composerDevice->SetLayerRegion(g_displayIds[0], layer->GetId(), rect);
747 
748     PrepareAndCommit();
749     EXPECT_EQ(DISPLAY_SUCCESS, ret);
750 
751     DestroyLayer(layer);
752 }
753 
754 /**
755  * @tc.number: SUB_Driver_Display_HDI_7000
756  * @tc.name: test_SetLayerDirtyRegion
757  * @tc.desc: Sets the flushing area for a layer
758  * @tc.size: MediumTest
759  * @tc.type: Function
760  */
HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_7000, TestSize.Level1)761 HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_7000, TestSize.Level1)
762 {
763     std::vector<LayerSettings> settings = {
764         {
765             .rectRatio = { 0, 0, 1.0f, 1.0f },
766             .color = BLUE
767         }
768     };
769 
770     std::vector<std::shared_ptr<HdiTestLayer>> layers = CreateLayers(settings);
771     ASSERT_TRUE((layers.size() > 0));
772 
773     auto layer = layers[0];
774 
775     const int32_t WIDTH = 100;
776     const int32_t HEIGHT = 100;
777     IRect rect = {0, 0, WIDTH, HEIGHT};
778     std::vector<IRect> vRects;
779     vRects.push_back(rect);
780     auto ret = g_composerDevice->SetLayerDirtyRegion(g_displayIds[0], layer->GetId(), vRects);
781 
782     PrepareAndCommit();
783     HdiTestDevice::GetInstance().Clear();
784 
785     EXPECT_EQ(DISPLAY_SUCCESS, ret);
786 
787     DestroyLayer(layer);
788 }
789 
790 /**
791  * @tc.number: SUB_Driver_Display_HDI_7100
792  * @tc.name: test_SetLayerTransformMode_001
793  * @tc.desc: Sets the type of graphic rotation
794  * @tc.size: MediumTest
795  * @tc.type: Function
796  */
HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_7100, TestSize.Level1)797 HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_7100, TestSize.Level1)
798 {
799     std::vector<LayerSettings> settings = {
800         {
801             .rectRatio = { 0, 0, 1.0f, 1.0f },
802             .color = RED
803         }
804     };
805 
806     std::vector<std::shared_ptr<HdiTestLayer>> layers = CreateLayers(settings);
807     ASSERT_TRUE((layers.size() > 0));
808 
809     PrepareAndCommit();
810 
811     auto layer = layers[0];
812 
813     TransformType type = TransformType::ROTATE_90;
814     auto ret = g_composerDevice->SetLayerTransformMode(g_displayIds[0], layer->GetId(), type);
815     PrepareAndCommit();
816 
817     type = TransformType::ROTATE_180;
818     ret = g_composerDevice->SetLayerTransformMode(g_displayIds[0], layer->GetId(), type);
819     PrepareAndCommit();
820 
821     type = TransformType::ROTATE_270;
822     ret = g_composerDevice->SetLayerTransformMode(g_displayIds[0], layer->GetId(), type);
823     PrepareAndCommit();
824 
825     EXPECT_EQ(DISPLAY_SUCCESS, ret);
826 
827     DestroyLayer(layer);
828 }
829 
830 /**
831  * @tc.number: SUB_Driver_Display_HDI_7200
832  * @tc.name: test_SetLayerVisibleRegion
833  * @tc.desc: Set the visible region for a layer
834  * @tc.size: MediumTest
835  * @tc.type: Function
836  */
HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_7200, TestSize.Level1)837 HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_7200, TestSize.Level1)
838 {
839     std::vector<LayerSettings> settings = {
840         {
841             .rectRatio = { 0, 0, 1.0f, 1.0f },
842             .color = BLUE
843         }
844     };
845 
846     std::vector<std::shared_ptr<HdiTestLayer>> layers = CreateLayers(settings);
847     ASSERT_TRUE((layers.size() > 0));
848     PrepareAndCommit();
849     auto layer = layers[0];
850 
851     const int32_t WIDTH = 500;
852     const int32_t HEIGHT = 500;
853     IRect region = {0, 0, WIDTH, HEIGHT};
854     std::vector<IRect> regions = {};
855     regions.push_back(region);
856     auto ret = g_composerDevice->SetLayerVisibleRegion(g_displayIds[0], layer->GetId(), regions);
857     PrepareAndCommit();
858 
859     EXPECT_EQ(DISPLAY_SUCCESS, ret);
860 
861     DestroyLayer(layer);
862 }
863 
864 /**
865  * @tc.number: SUB_Driver_Display_HDI_7300
866  * @tc.name: test_SetLayerBuffer
867  * @tc.desc: Set the buffer for a layer
868  * @tc.size: MediumTest
869  * @tc.type: Function
870  */
HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_7300, TestSize.Level1)871 HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_7300, TestSize.Level1)
872 {
873     std::vector<LayerSettings> settings = {
874         {
875             .rectRatio = { 0, 0, 1.0f, 1.0f },
876             .color = GREEN
877         }
878     };
879 
880     std::vector<std::shared_ptr<HdiTestLayer>> layers = CreateLayers(settings);
881     ASSERT_TRUE((layers.size() > 0));
882 
883     auto layer = layers[0];
884 
885     auto graphicBuffer = layer->AcquireBackBuffer();
886     int32_t ret = graphicBuffer->SetGraphicBuffer([&](const BufferHandle* buffer, uint32_t seqNo) -> int32_t {
887         std::vector<uint32_t> deletingList;
888         int32_t result = g_composerDevice->SetLayerBuffer(g_displayIds[0], layer->GetId(), buffer, seqNo, -1,
889             deletingList);
890         return result;
891     });
892     PrepareAndCommit();
893 
894     EXPECT_EQ(DISPLAY_SUCCESS, ret);
895 
896     DestroyLayer(layer);
897 }
898 
899 /**
900  * @tc.number: SUB_Driver_Display_HDI_7400
901  * @tc.name: test_SetLayerCompositionType_001
902  * @tc.desc: set the composition type which the client expect
903  * @tc.size: MediumTest
904  * @tc.type: Function
905  */
HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_7400, TestSize.Level1)906 HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_7400, TestSize.Level1)
907 {
908     std::vector<LayerSettings> settings = {
909         {
910             .rectRatio = { 0, 0, 1.0f, 1.0f },
911             .color = BLUE
912         }
913     };
914 
915     std::vector<std::shared_ptr<HdiTestLayer>> layers = CreateLayers(settings);
916     ASSERT_TRUE((layers.size() > 0));
917 
918     auto layer = layers[0];
919 
920     Composer::V1_0::CompositionType type = Composer::V1_0::CompositionType::COMPOSITION_CLIENT;
921     auto ret = g_composerDevice->SetLayerCompositionType(g_displayIds[0], layer->GetId(), type);
922 
923     PrepareAndCommit();
924 
925     EXPECT_EQ(DISPLAY_SUCCESS, ret);
926 
927     DestroyLayer(layer);
928 }
929 
930 /**
931  * @tc.number: SUB_Driver_Display_HDI_7500
932  * @tc.name: test_SetLayerBlendType_001
933  * @tc.desc: Set the blend type to BLEND-NONE
934  * @tc.size: MediumTest
935  * @tc.type: Function
936  */
HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_7500, TestSize.Level1)937 HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_7500, TestSize.Level1)
938 {
939     std::vector<LayerSettings> settings = {
940         {
941             .rectRatio = { 0, 0, 1.0f, 1.0f },
942             .color = GREEN
943         }
944     };
945 
946     std::vector<std::shared_ptr<HdiTestLayer>> layers = CreateLayers(settings);
947     ASSERT_TRUE((layers.size() > 0));
948 
949     auto layer = layers[0];
950 
951     BlendType type = BlendType::BLEND_NONE;
952     auto ret = g_composerDevice->SetLayerBlendType(g_displayIds[0], layer->GetId(), type);
953 
954     PrepareAndCommit();
955 
956     EXPECT_EQ(DISPLAY_SUCCESS, ret);
957 
958     DestroyLayer(layer);
959 }
960 
961 /**
962  * @tc.number: SUB_Driver_Display_MaskInfo_0100
963  * @tc.name: test_SetLayerMaskInfo_001
964  * @tc.desc: Sets the current mask frame information to the vendor driver
965  * @tc.size: MediumTest
966  * @tc.type: Function
967  */
HWTEST_F(DeviceTest, SUB_Driver_Display_MaskInfo_0100, TestSize.Level1)968 HWTEST_F(DeviceTest, SUB_Driver_Display_MaskInfo_0100, TestSize.Level1)
969 {
970     std::vector<LayerSettings> settings = {
971         {
972             .rectRatio = { 0, 0, 1.0f, 1.0f },
973             .color = GREEN
974         }
975     };
976 
977     std::vector<std::shared_ptr<HdiTestLayer>> layers = CreateLayers(settings);
978     ASSERT_TRUE((layers.size() > 0));
979 
980     auto layer = layers[0];
981 
982     MaskInfo maskInfo = MaskInfo::LAYER_HBM_SYNC;
983     auto ret = g_composerDevice->SetLayerMaskInfo(g_displayIds[0], layer->GetId(), maskInfo);
984 
985     PrepareAndCommit();
986 
987     EXPECT_EQ(DISPLAY_SUCCESS, ret);
988 
989     DestroyLayer(layer);
990 }
991 
992 /**
993  * @tc.number: SUB_Driver_Display_Luminance_0100
994  * @tc.name: test_SetLayerColor
995  * @tc.desc: Sets the solid color layer
996  * @tc.size: MediumTest
997  * @tc.type: Function
998  */
HWTEST_F(DeviceTest, SUB_Driver_Display_Luminance_0100, TestSize.Level1)999 HWTEST_F(DeviceTest, SUB_Driver_Display_Luminance_0100, TestSize.Level1)
1000 {
1001     std::vector<LayerSettings> settings = {
1002         {
1003             .rectRatio = { 0, 0, 1.0f, 1.0f },
1004             .color = GREEN
1005         }
1006     };
1007 
1008     std::vector<std::shared_ptr<HdiTestLayer>> layers = CreateLayers(settings);
1009     ASSERT_TRUE((layers.size() > 0));
1010 
1011     auto layer = layers[0];
1012     const uint32_t COLOR_R = 155;
1013     const uint32_t COLOR_G = 224;
1014     const uint32_t COLOR_B = 88;
1015     const uint32_t COLOR_A = 128;
1016 
1017     LayerColor layerColor = {
1018         .r = COLOR_R,
1019         .g = COLOR_G,
1020         .b = COLOR_B,
1021         .a = COLOR_A
1022     };
1023 
1024     auto ret = g_composerDevice->SetLayerColor(g_displayIds[0], layer->GetId(), layerColor);
1025 
1026     PrepareAndCommit();
1027 
1028     EXPECT_EQ(DISPLAY_SUCCESS, ret);
1029 
1030     DestroyLayer(layer);
1031 }
1032 
1033 /**
1034  * @tc.number: SUB_Driver_Display_HDI_7600
1035  * @tc.name: test_DestroyLayer
1036  * @tc.desc: Closes a layer that is no longer required on a specified display device
1037  * @tc.size: MediumTest
1038  * @tc.type: Function
1039  */
HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_7600, TestSize.Level1)1040 HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_7600, TestSize.Level1)
1041 {
1042     std::vector<LayerSettings> settings = {
1043         {
1044             .rectRatio = { 0, 0, 1.0f, 1.0f },
1045             .color = PURPLE
1046         }
1047     };
1048 
1049     std::vector<std::shared_ptr<HdiTestLayer>> layers = CreateLayers(settings);
1050     ASSERT_TRUE((layers.size() > 0));
1051     auto layer = layers[0];
1052     PrepareAndCommit();
1053 
1054     sleep(1);
1055     auto ret = g_composerDevice->DestroyLayer(g_displayIds[0], layer->GetId());
1056     EXPECT_EQ(DISPLAY_SUCCESS, ret);
1057     std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_CONT_100));
1058 }
1059 
1060 /**
1061  * @tc.number: SUB_Driver_Display_HDI_7700
1062  * @tc.name: test_RegDisplayVBlankCallback
1063  * @tc.desc: Registers the callback to be invoked when a VBLANK event occurs
1064  * @tc.size: MediumTest
1065  * @tc.type: Function
1066  */
HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_7700, TestSize.Level1)1067 HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_7700, TestSize.Level1)
1068 {
1069     int ret;
1070     DISPLAY_TEST_LOGE();
1071     std::shared_ptr<HdiTestDisplay> display = HdiTestDevice::GetInstance().GetFirstDisplay();
1072     ASSERT_TRUE(display != nullptr) << "get display failed";
1073     ret = display->RegDisplayVBlankCallback(TestVBlankCallback, nullptr);
1074     ASSERT_TRUE(ret == DISPLAY_SUCCESS) << "RegDisplayVBlankCallback failed";
1075     ret = display->SetDisplayVsyncEnabled(true);
1076     ASSERT_TRUE(ret == DISPLAY_SUCCESS) << "SetDisplayVsyncEnabled failed";
1077 
1078     std::vector<LayerSettings> settings = {
1079         {
1080             .rectRatio = { 0, 0, 1.0f, 1.0f },
1081             .color = PINK
1082         },
1083     };
1084     std::vector<std::shared_ptr<HdiTestLayer>> layers = CreateLayers(settings);
1085     ASSERT_TRUE((layers.size() > 0));
1086     VblankCtr::GetInstance().hasVblank_ = false;
1087     PrepareAndCommit();
1088     ret = VblankCtr::GetInstance().WaitVblank(SLEEP_CONT_100); // 100ms
1089     ASSERT_TRUE(ret == DISPLAY_SUCCESS) << "WaitVblank timeout";
1090     ret = display->SetDisplayVsyncEnabled(false);
1091     ASSERT_TRUE(ret == DISPLAY_SUCCESS) << "SetDisplayVsyncEnabled failed";
1092     usleep(SLEEP_CONT_100 * SLEEP_CONT_2000); // wait for 100ms avoid the last vsync.
1093     VblankCtr::GetInstance().hasVblank_ = false;
1094     ret = VblankCtr::GetInstance().WaitVblank(SLEEP_CONT_100); // 100ms
1095     ASSERT_TRUE(ret != DISPLAY_SUCCESS) << "vblank do not disable";
1096 
1097     DestroyLayer(layers[0]);
1098 }
1099 
OnMode(uint32_t modeId, uint64_t vBlankPeriod, void* data)1100 void DeviceTest::OnMode(uint32_t modeId, uint64_t vBlankPeriod, void* data)
1101 {
1102     g_isOnModeCalled = true;
1103 }
1104 
OnSeamlessChange(uint32_t devId, void* data)1105 void DeviceTest::OnSeamlessChange(uint32_t devId, void* data)
1106 {
1107     g_isOnSeamlessChangeCalled = true;
1108 }
1109 
1110 /**
1111  * @tc.number: SUB_Driver_Display_HDI_7800
1112  * @tc.name: test_GetDisplaySupportedModesExt
1113  * @tc.desc: Obtains the display modes supported by a display device
1114  * @tc.size: MediumTest
1115  * @tc.type: Function
1116  */
HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_7800, TestSize.Level1)1117 HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_7800, TestSize.Level1)
1118 {
1119     std::vector<DisplayModeInfoExt> modes;
1120     auto ret = g_composerDevice->GetDisplaySupportedModesExt(g_displayIds[0], modes);
1121     if (ret == DISPLAY_NOT_SUPPORT) {
1122         DISPLAY_TEST_LOGE("GetDisplaySupportedModesExt not support");
1123         return;
1124     }
1125     EXPECT_EQ(DISPLAY_SUCCESS, ret);
1126 }
1127 
1128 /**
1129  * @tc.number: SUB_Driver_Display_HDI_7900
1130  * @tc.name: test_SetDisplayModeAsync
1131  * @tc.desc: Sets the display mode of a display device
1132  * @tc.size: MediumTest
1133  * @tc.type: Function
1134  */
HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_7900, TestSize.Level1)1135 HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_7900, TestSize.Level1)
1136 {
1137     g_isOnModeCalled = false;
1138     std::vector<DisplayModeInfo> oldModes;
1139     std::vector<LayerSettings> settings = {
1140         {
1141             .rectRatio = { 0, 0, 1.0f, 1.0f },
1142             .color = RED
1143         }
1144     };
1145 
1146     // 先注册VBlankCallback
1147     auto ret = g_composerDevice->RegDisplayVBlankCallback(g_displayIds[0], TestVBlankCallback, nullptr);
1148     ASSERT_TRUE(ret == DISPLAY_SUCCESS) << "RegDisplayVBlankCallback failed";
1149 
1150     ret = g_composerDevice->GetDisplaySupportedModes(g_displayIds[0], oldModes);
1151     ASSERT_EQ(DISPLAY_SUCCESS, ret);
1152     ASSERT_EQ(oldModes.size() > 0, true);
1153 
1154     uint32_t modeid = oldModes[0].id;
1155     ret = g_composerDevice->SetDisplayModeAsync(g_displayIds[0], modeid, OnMode);
1156     if (ret == DISPLAY_NOT_SUPPORT) {
1157         return;
1158     }
1159     EXPECT_EQ(DISPLAY_SUCCESS, ret);
1160     if (ret == DISPLAY_SUCCESS) {
1161         std::vector<std::shared_ptr<HdiTestLayer>> layers = CreateLayers(settings);
1162         ASSERT_TRUE((layers.size() > 0));
1163         g_threadCtrl = false;
1164         std::thread commitThread(LoopCommit);
1165         std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_CONT_100));
1166         g_threadCtrl = true;
1167         commitThread.join();
1168         ASSERT_EQ(g_isOnModeCalled, true);
1169 
1170         DestroyLayer(layers[0]);
1171     }
1172 }
1173 
1174 /**
1175  * @tc.number: SUB_Driver_Display_HDI_8000
1176  * @tc.name: test_GetDisplayVBlankPeriod
1177  * @tc.desc: Get the current vblank period
1178  * @tc.size: MediumTest
1179  * @tc.type: Function
1180  */
HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_8000, TestSize.Level1)1181 HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_8000, TestSize.Level1)
1182 {
1183     uint64_t period = 0;
1184     auto ret = g_composerDevice->GetDisplayVBlankPeriod(g_displayIds[0], period);
1185     if (ret == DISPLAY_NOT_SUPPORT) {
1186         DISPLAY_TEST_LOGE("GetDisplayVBlankPeriod not support");
1187         return;
1188     }
1189     EXPECT_EQ(DISPLAY_SUCCESS, ret);
1190     EXPECT_EQ(period != 0, true);
1191 }
1192 
1193 /**
1194  * @tc.number: SUB_Driver_Display_HDI_8100
1195  * @tc.name: test_RegSeamlessChangeCallback
1196  * @tc.desc: UpdateSettings, OHOS_CONTROL_AE_MODE
1197  * @tc.size: MediumTest
1198  * @tc.type: Function
1199  */
HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_8100, TestSize.Level1)1200 HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_8100, TestSize.Level1)
1201 {
1202     g_isOnSeamlessChangeCalled = false;
1203     auto ret = g_composerDevice->RegSeamlessChangeCallback(OnSeamlessChange, nullptr);
1204     if (ret == DISPLAY_NOT_SUPPORT) {
1205         DISPLAY_TEST_LOGE("RegSeamlessChangeCallback not support");
1206         return;
1207     }
1208     EXPECT_EQ(DISPLAY_SUCCESS, ret);
1209     if (ret == DISPLAY_SUCCESS) {
1210         std::this_thread::sleep_for(std::chrono::milliseconds(5000));
1211         ASSERT_EQ(g_isOnSeamlessChangeCalled, true);
1212     }
1213 }
1214 
1215 /**
1216  * @tc.number: SUB_Driver_Display_HDI_8200
1217  * @tc.name: test_SetLayerPerFrameParameter
1218  * @tc.desc: Sets parameter for the given layer
1219  * @tc.size: MediumTest
1220  * @tc.type: Function
1221  */
HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_8200, TestSize.Level1)1222 HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_8200, TestSize.Level1)
1223 {
1224     std::vector<LayerSettings> settings = {
1225         {
1226             .rectRatio = { 0, 0, 1.0f, 1.0f },
1227             .color = GREEN
1228         },
1229     };
1230 
1231     std::vector<std::shared_ptr<HdiTestLayer>> layers = CreateLayers(settings);
1232     ASSERT_TRUE((layers.size() > 0));
1233     auto layer = layers[0];
1234     std::vector<std::string> ValidKeys = { "FilmFilter", "ArsrDoEnhance", "SDRBrightnessRatio", "BrightnessNit",
1235         "ViewGroupHasValidAlpha", "SourceCropTuning" };
1236     std::string key;
1237     std::vector<int8_t> value = { 1 };
1238     key = "NotSupportKey";
1239     auto ret = g_composerDevice->SetLayerPerFrameParameter(g_displayIds[0], layer->GetId(), key, value);
1240     if (ret == DISPLAY_NOT_SUPPORT) {
1241         DISPLAY_TEST_LOGE("SetLayerPerFrameParameter not support");
1242         return;
1243     }
1244     ASSERT_EQ(ret, -1) << "key not support, ret:" << ret;
1245     key = ValidKeys[0];
1246     ret = g_composerDevice->SetLayerPerFrameParameter(g_displayIds[0], layer->GetId(), key, value);
1247     ASSERT_EQ(ret, 0) << "key support, ret:" << ret;
1248     if (ret == DISPLAY_NOT_SUPPORT) {
1249         DISPLAY_TEST_LOGE("SetLayerPerFrameParameter not support");
1250         return;
1251     }
1252     EXPECT_EQ(DISPLAY_SUCCESS, ret);
1253 }
1254 
1255 /**
1256  * @tc.number: SUB_Driver_Display_HDI_8300
1257  * @tc.name: test_GetSupportedLayerPerFrameParameterKey
1258  * @tc.desc: returns the list of supported parameter keys
1259  * @tc.size: MediumTest
1260  * @tc.type: Function
1261  */
HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_8300, TestSize.Level1)1262 HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_8300, TestSize.Level1)
1263 {
1264     std::vector<std::string> keys;
1265     auto ret = g_composerDevice->GetSupportedLayerPerFrameParameterKey(keys);
1266     if (ret == DISPLAY_NOT_SUPPORT) {
1267         DISPLAY_TEST_LOGE("GetSupportedLayerPerFrameParameterKey not support");
1268         return;
1269     }
1270     EXPECT_EQ(DISPLAY_SUCCESS, ret);
1271 }
1272 
1273 /**
1274  * @tc.number: SUB_Driver_Display_HDI_8400
1275  * @tc.name: test_SetDisplayOverlayResolution
1276  * @tc.desc: Sets parameter for the given layer
1277  * @tc.size: MediumTest
1278  * @tc.type: Function
1279  */
HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_8400, TestSize.Level1)1280 HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_8400, TestSize.Level1)
1281 {
1282     DisplayModeInfo mode = GetFirstDisplay()->GetCurrentMode();
1283     auto ret = g_composerDevice->SetDisplayOverlayResolution(g_displayIds[0], mode.width, mode.height);
1284     if (ret == DISPLAY_NOT_SUPPORT) {
1285         DISPLAY_TEST_LOGE("SetDisplayOverlayResolution not support");
1286         return;
1287     }
1288     EXPECT_EQ(DISPLAY_SUCCESS, ret);
1289 }
1290 
TestRefreshCallback(uint32_t devId, void* data)1291 static void TestRefreshCallback(uint32_t devId, void* data)
1292 {
1293 }
1294 
1295 /**
1296  * @tc.number: SUB_Driver_Display_HDI_8500
1297  * @tc.name: test_RegRefreshCallback
1298  * @tc.desc: Registers the callback to be invoked when a refresh event occurs
1299  * @tc.size: MediumTest
1300  * @tc.type: Function
1301  */
HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_8500, TestSize.Level1)1302 HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_8500, TestSize.Level1)
1303 {
1304     auto ret = g_composerDevice->RegRefreshCallback(TestRefreshCallback, nullptr);
1305     if (ret == DISPLAY_NOT_SUPPORT) {
1306         DISPLAY_TEST_LOGE("RegRefreshCallback not support");
1307         return;
1308     }
1309     EXPECT_EQ(DISPLAY_SUCCESS, ret);
1310 }
1311 
1312 /**
1313  * @tc.number: SUB_Driver_Display_HDI_8600
1314  * @tc.name: test_GetDisplaySupportedColorGamuts
1315  * @tc.desc: Obtains the color gamuts of a display device
1316  * @tc.size: MediumTest
1317  * @tc.type: Function
1318  */
HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_8600, TestSize.Level1)1319 HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_8600, TestSize.Level1)
1320 {
1321     std::vector<ColorGamut> gamuts;
1322     auto ret = g_composerDevice->GetDisplaySupportedColorGamuts(g_displayIds[0], gamuts);
1323     if (ret == DISPLAY_NOT_SUPPORT) {
1324         DISPLAY_TEST_LOGE("GetDisplaySupportedColorGamuts not support");
1325         return;
1326     }
1327     EXPECT_EQ(DISPLAY_SUCCESS, ret);
1328 }
1329 
1330 /**
1331  * @tc.number: SUB_Driver_Display_HDI_8700
1332  * @tc.name: test_GetHDRCapabilityInfos
1333  * @tc.desc: Obtains the capabilities of a display device
1334  * @tc.size: MediumTest
1335  * @tc.type: Function
1336  */
HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_8700, TestSize.Level1)1337 HWTEST_F(DeviceTest, SUB_Driver_Display_HDI_8700, TestSize.Level1)
1338 {
1339     HDRCapability info = { 0 };
1340     auto ret = g_composerDevice->GetHDRCapabilityInfos(g_displayIds[0], info);
1341     if (ret == DISPLAY_NOT_SUPPORT) {
1342         DISPLAY_TEST_LOGE("GetHDRCapabilityInfos not support");
1343         return;
1344     }
1345     EXPECT_EQ(DISPLAY_SUCCESS, ret);
1346 }
1347 
1348 /**
1349  * @tc.number: SUB_DriverSystem_DisplayComposer_0340
1350  * @tc.name: test_SetLayerTransformMode_002
1351  * @tc.desc: Sets the type of graphic rotation
1352  * @tc.size: MediumTest
1353  * @tc.type: Function
1354  */
HWTEST_F(DeviceTest, SUB_DriverSystem_DisplayComposer_0340, TestSize.Level1)1355 HWTEST_F(DeviceTest, SUB_DriverSystem_DisplayComposer_0340, TestSize.Level1)
1356 {
1357     std::vector<LayerSettings> settings = {
1358         {
1359             .rectRatio = { 0, 0, 1.0f, 1.0f },
1360             .color = RED
1361         }
1362     };
1363 
1364     std::vector<std::shared_ptr<HdiTestLayer>> layers = CreateLayers(settings);
1365     ASSERT_TRUE((layers.size() > 0));
1366 
1367     PrepareAndCommit();
1368 
1369     auto layer = layers[0];
1370 
1371     TransformType type = TransformType::MIRROR_H;
1372     auto ret = g_composerDevice->SetLayerTransformMode(g_displayIds[0], layer->GetId(), type);
1373     PrepareAndCommit();
1374 
1375     type = TransformType::MIRROR_V;
1376     ret = g_composerDevice->SetLayerTransformMode(g_displayIds[0], layer->GetId(), type);
1377     PrepareAndCommit();
1378 
1379     EXPECT_EQ(DISPLAY_SUCCESS, ret);
1380 
1381     DestroyLayer(layer);
1382 }
1383 
1384 /**
1385  * @tc.number: SUB_DriverSystem_DisplayComposer_0350
1386  * @tc.name: test_SetLayerTransformMode_003
1387  * @tc.desc: Sets the type of graphic rotation
1388  * @tc.size: MediumTest
1389  * @tc.type: Function
1390  */
HWTEST_F(DeviceTest, SUB_DriverSystem_DisplayComposer_0350, TestSize.Level1)1391 HWTEST_F(DeviceTest, SUB_DriverSystem_DisplayComposer_0350, TestSize.Level1)
1392 {
1393     std::vector<LayerSettings> settings = {
1394         {
1395             .rectRatio = { 0, 0, 1.0f, 1.0f },
1396             .color = RED
1397         }
1398     };
1399 
1400     std::vector<std::shared_ptr<HdiTestLayer>> layers = CreateLayers(settings);
1401     ASSERT_TRUE((layers.size() > 0));
1402 
1403     PrepareAndCommit();
1404 
1405     auto layer = layers[0];
1406 
1407     TransformType type = TransformType::MIRROR_H_ROTATE_90;
1408     auto ret = g_composerDevice->SetLayerTransformMode(g_displayIds[0], layer->GetId(), type);
1409     PrepareAndCommit();
1410 
1411     type = TransformType::MIRROR_V_ROTATE_90;
1412     ret = g_composerDevice->SetLayerTransformMode(g_displayIds[0], layer->GetId(), type);
1413     PrepareAndCommit();
1414 
1415     EXPECT_EQ(DISPLAY_SUCCESS, ret);
1416 
1417     DestroyLayer(layer);
1418 }
1419 
1420 /**
1421  * @tc.number: SUB_DriverSystem_DisplayComposer_0360
1422  * @tc.name: test_SetLayerTransformMode_004
1423  * @tc.desc: Sets the type of graphic rotation
1424  * @tc.size: MediumTest
1425  * @tc.type: Function
1426  */
HWTEST_F(DeviceTest, SUB_DriverSystem_DisplayComposer_0360, TestSize.Level1)1427 HWTEST_F(DeviceTest, SUB_DriverSystem_DisplayComposer_0360, TestSize.Level1)
1428 {
1429     std::vector<LayerSettings> settings = {
1430         {
1431             .rectRatio = { 0, 0, 1.0f, 1.0f },
1432             .color = RED
1433         }
1434     };
1435 
1436     std::vector<std::shared_ptr<HdiTestLayer>> layers = CreateLayers(settings);
1437     ASSERT_TRUE((layers.size() > 0));
1438 
1439     PrepareAndCommit();
1440 
1441     auto layer = layers[0];
1442 
1443     TransformType type = TransformType::ROTATE_BUTT;
1444     auto ret = g_composerDevice->SetLayerTransformMode(g_displayIds[0], layer->GetId(), type);
1445     PrepareAndCommit();
1446     EXPECT_EQ(DISPLAY_SUCCESS, ret);
1447     DestroyLayer(layer);
1448 }
1449 
1450 /**
1451  * @tc.number: SUB_DriverSystem_DisplayComposer_0370
1452  * @tc.name: test_SetDisplayPowerStatus_002
1453  * @tc.desc: Set the power status of the display device
1454  * @tc.size: MediumTest
1455  * @tc.type: Function
1456  */
1457 #ifdef DISPLAY_COMMUNITY
HWTEST_F(DeviceTest, SUB_DriverSystem_DisplayComposer_0370, TestSize.Level1)1458 HWTEST_F(DeviceTest, SUB_DriverSystem_DisplayComposer_0370, TestSize.Level1)
1459 {
1460     auto ret = g_composerDevice->SetDisplayPowerStatus(g_displayIds[0],
1461         Composer::V1_0::DispPowerStatus::POWER_STATUS_SUSPEND);
1462     EXPECT_EQ(DISPLAY_SUCCESS, ret);
1463 
1464     ret = g_composerDevice->SetDisplayPowerStatus(g_displayIds[0],
1465         Composer::V1_0::DispPowerStatus::POWER_STATUS_BUTT);
1466     EXPECT_EQ(DISPLAY_FAILURE, ret);
1467 }
1468 #endif
1469 
1470 /**
1471  * @tc.number: SUB_DriverSystem_DisplayComposer_0380
1472  * @tc.name: test_SetLayerBlendType_002
1473  * @tc.desc: Set the blend type to BLEND_CLEAR
1474  * @tc.size: MediumTest
1475  * @tc.type: Function
1476  */
HWTEST_F(DeviceTest, SUB_DriverSystem_DisplayComposer_0380, TestSize.Level1)1477 HWTEST_F(DeviceTest, SUB_DriverSystem_DisplayComposer_0380, TestSize.Level1)
1478 {
1479     std::vector<LayerSettings> settings = {
1480         {
1481             .rectRatio = { 0, 0, 1.0f, 1.0f },
1482             .color = GREEN
1483         }
1484     };
1485 
1486     std::vector<std::shared_ptr<HdiTestLayer>> layers = CreateLayers(settings);
1487     ASSERT_TRUE((layers.size() > 0));
1488 
1489     auto layer = layers[0];
1490 
1491     BlendType type = BlendType::BLEND_CLEAR;
1492     auto ret = g_composerDevice->SetLayerBlendType(g_displayIds[0], layer->GetId(), type);
1493 
1494     PrepareAndCommit();
1495 
1496     EXPECT_EQ(DISPLAY_SUCCESS, ret);
1497     DestroyLayer(layer);
1498 }
1499 
1500 /**
1501  * @tc.number: SUB_DriverSystem_DisplayComposer_0390
1502  * @tc.name: test_SetLayerBlendType_003
1503  * @tc.desc: Set the blend type to BLEND_SRC
1504  * @tc.size: MediumTest
1505  * @tc.type: Function
1506  */
HWTEST_F(DeviceTest, SUB_DriverSystem_DisplayComposer_0390, TestSize.Level1)1507 HWTEST_F(DeviceTest, SUB_DriverSystem_DisplayComposer_0390, TestSize.Level1)
1508 {
1509     std::vector<LayerSettings> settings = {
1510         {
1511             .rectRatio = { 0, 0, 1.0f, 1.0f },
1512             .color = GREEN
1513         }
1514     };
1515 
1516     std::vector<std::shared_ptr<HdiTestLayer>> layers = CreateLayers(settings);
1517     ASSERT_TRUE((layers.size() > 0));
1518 
1519     auto layer = layers[0];
1520 
1521     BlendType type = BlendType::BLEND_SRC;
1522     auto ret = g_composerDevice->SetLayerBlendType(g_displayIds[0], layer->GetId(), type);
1523 
1524     PrepareAndCommit();
1525 
1526     EXPECT_EQ(DISPLAY_SUCCESS, ret);
1527     DestroyLayer(layer);
1528 }
1529 
1530 /**
1531  * @tc.number: SUB_DriverSystem_DisplayComposer_0400
1532  * @tc.name: test_SetLayerBlendType_004
1533  * @tc.desc: Set the blend type to BLEND_SRCOVER
1534  * @tc.size: MediumTest
1535  * @tc.type: Function
1536  */
HWTEST_F(DeviceTest, SUB_DriverSystem_DisplayComposer_0400, TestSize.Level1)1537 HWTEST_F(DeviceTest, SUB_DriverSystem_DisplayComposer_0400, TestSize.Level1)
1538 {
1539     std::vector<LayerSettings> settings = {
1540         {
1541             .rectRatio = { 0, 0, 1.0f, 1.0f },
1542             .color = GREEN
1543         }
1544     };
1545 
1546     std::vector<std::shared_ptr<HdiTestLayer>> layers = CreateLayers(settings);
1547     ASSERT_TRUE((layers.size() > 0));
1548 
1549     auto layer = layers[0];
1550 
1551     BlendType type = BlendType::BLEND_SRCOVER;
1552     auto ret = g_composerDevice->SetLayerBlendType(g_displayIds[0], layer->GetId(), type);
1553 
1554     PrepareAndCommit();
1555 
1556     EXPECT_EQ(DISPLAY_SUCCESS, ret);
1557     DestroyLayer(layer);
1558 }
1559 
1560 /**
1561  * @tc.number: SUB_DriverSystem_DisplayComposer_0410
1562  * @tc.name: test_SetLayerBlendType_005
1563  * @tc.desc: Set the blend type to BLEND_DSTOVER
1564  * @tc.size: MediumTest
1565  * @tc.type: Function
1566  */
HWTEST_F(DeviceTest, SUB_DriverSystem_DisplayComposer_0410, TestSize.Level1)1567 HWTEST_F(DeviceTest, SUB_DriverSystem_DisplayComposer_0410, TestSize.Level1)
1568 {
1569     std::vector<LayerSettings> settings = {
1570         {
1571             .rectRatio = { 0, 0, 1.0f, 1.0f },
1572             .color = GREEN
1573         }
1574     };
1575 
1576     std::vector<std::shared_ptr<HdiTestLayer>> layers = CreateLayers(settings);
1577     ASSERT_TRUE((layers.size() > 0));
1578 
1579     auto layer = layers[0];
1580 
1581     BlendType type = BlendType::BLEND_DSTOVER;
1582     auto ret = g_composerDevice->SetLayerBlendType(g_displayIds[0], layer->GetId(), type);
1583 
1584     PrepareAndCommit();
1585 
1586     EXPECT_EQ(DISPLAY_SUCCESS, ret);
1587     DestroyLayer(layer);
1588 }
1589 
1590 /**
1591  * @tc.number: SUB_DriverSystem_DisplayComposer_0420
1592  * @tc.name: test_SetLayerBlendType_006
1593  * @tc.desc: Set the blend type to BLEND_SRCIN
1594  * @tc.size: MediumTest
1595  * @tc.type: Function
1596  */
HWTEST_F(DeviceTest, SUB_DriverSystem_DisplayComposer_0420, TestSize.Level1)1597 HWTEST_F(DeviceTest, SUB_DriverSystem_DisplayComposer_0420, TestSize.Level1)
1598 {
1599     std::vector<LayerSettings> settings = {
1600         {
1601             .rectRatio = { 0, 0, 1.0f, 1.0f },
1602             .color = GREEN
1603         }
1604     };
1605 
1606     std::vector<std::shared_ptr<HdiTestLayer>> layers = CreateLayers(settings);
1607     ASSERT_TRUE((layers.size() > 0));
1608 
1609     auto layer = layers[0];
1610 
1611     BlendType type = BlendType::BLEND_SRCIN;
1612     auto ret = g_composerDevice->SetLayerBlendType(g_displayIds[0], layer->GetId(), type);
1613 
1614     PrepareAndCommit();
1615 
1616     EXPECT_EQ(DISPLAY_SUCCESS, ret);
1617     DestroyLayer(layer);
1618 }
1619 
1620 /**
1621  * @tc.number: SUB_DriverSystem_DisplayComposer_0430
1622  * @tc.name: test_SetLayerBlendType_007
1623  * @tc.desc: Set the blend type to BLEND_DSTIN
1624  * @tc.size: MediumTest
1625  * @tc.type: Function
1626  */
HWTEST_F(DeviceTest, SUB_DriverSystem_DisplayComposer_0430, TestSize.Level1)1627 HWTEST_F(DeviceTest, SUB_DriverSystem_DisplayComposer_0430, TestSize.Level1)
1628 {
1629     std::vector<LayerSettings> settings = {
1630         {
1631             .rectRatio = { 0, 0, 1.0f, 1.0f },
1632             .color = GREEN
1633         }
1634     };
1635 
1636     std::vector<std::shared_ptr<HdiTestLayer>> layers = CreateLayers(settings);
1637     ASSERT_TRUE((layers.size() > 0));
1638 
1639     auto layer = layers[0];
1640 
1641     BlendType type = BlendType::BLEND_DSTIN;
1642     auto ret = g_composerDevice->SetLayerBlendType(g_displayIds[0], layer->GetId(), type);
1643 
1644     PrepareAndCommit();
1645 
1646     EXPECT_EQ(DISPLAY_SUCCESS, ret);
1647     DestroyLayer(layer);
1648 }
1649 
1650 /**
1651  * @tc.number: SUB_DriverSystem_DisplayComposer_0440
1652  * @tc.name: test_SetLayerBlendType_008
1653  * @tc.desc: Set the blend type to BLEND_SRCOUT
1654  * @tc.size: MediumTest
1655  * @tc.type: Function
1656  */
HWTEST_F(DeviceTest, SUB_DriverSystem_DisplayComposer_0440, TestSize.Level1)1657 HWTEST_F(DeviceTest, SUB_DriverSystem_DisplayComposer_0440, TestSize.Level1)
1658 {
1659     std::vector<LayerSettings> settings = {
1660         {
1661             .rectRatio = { 0, 0, 1.0f, 1.0f },
1662             .color = GREEN
1663         }
1664     };
1665 
1666     std::vector<std::shared_ptr<HdiTestLayer>> layers = CreateLayers(settings);
1667     ASSERT_TRUE((layers.size() > 0));
1668 
1669     auto layer = layers[0];
1670 
1671     BlendType type = BlendType::BLEND_SRCOUT;
1672     auto ret = g_composerDevice->SetLayerBlendType(g_displayIds[0], layer->GetId(), type);
1673 
1674     PrepareAndCommit();
1675 
1676     EXPECT_EQ(DISPLAY_SUCCESS, ret);
1677     DestroyLayer(layer);
1678 }
1679 
1680 /**
1681  * @tc.number: SUB_DriverSystem_DisplayComposer_0450
1682  * @tc.name: test_SetLayerBlendType_009
1683  * @tc.desc: Set the blend type to BLEND_DSTOUT
1684  * @tc.size: MediumTest
1685  * @tc.type: Function
1686  */
HWTEST_F(DeviceTest, SUB_DriverSystem_DisplayComposer_0450, TestSize.Level1)1687 HWTEST_F(DeviceTest, SUB_DriverSystem_DisplayComposer_0450, TestSize.Level1)
1688 {
1689     std::vector<LayerSettings> settings = {
1690         {
1691             .rectRatio = { 0, 0, 1.0f, 1.0f },
1692             .color = GREEN
1693         }
1694     };
1695 
1696     std::vector<std::shared_ptr<HdiTestLayer>> layers = CreateLayers(settings);
1697     ASSERT_TRUE((layers.size() > 0));
1698 
1699     auto layer = layers[0];
1700 
1701     BlendType type = BlendType::BLEND_DSTOUT;
1702     auto ret = g_composerDevice->SetLayerBlendType(g_displayIds[0], layer->GetId(), type);
1703 
1704     PrepareAndCommit();
1705 
1706     EXPECT_EQ(DISPLAY_SUCCESS, ret);
1707     DestroyLayer(layer);
1708 }
1709 
1710 /**
1711  * @tc.number: SUB_DriverSystem_DisplayComposer_0460
1712  * @tc.name: test_SetLayerBlendType_010
1713  * @tc.desc: Set the blend type to BLEND_SRCATOP
1714  * @tc.size: MediumTest
1715  * @tc.type: Function
1716  */
HWTEST_F(DeviceTest, SUB_DriverSystem_DisplayComposer_0460, TestSize.Level1)1717 HWTEST_F(DeviceTest, SUB_DriverSystem_DisplayComposer_0460, TestSize.Level1)
1718 {
1719     std::vector<LayerSettings> settings = {
1720         {
1721             .rectRatio = { 0, 0, 1.0f, 1.0f },
1722             .color = GREEN
1723         }
1724     };
1725 
1726     std::vector<std::shared_ptr<HdiTestLayer>> layers = CreateLayers(settings);
1727     ASSERT_TRUE((layers.size() > 0));
1728 
1729     auto layer = layers[0];
1730 
1731     BlendType type = BlendType::BLEND_SRCATOP;
1732     auto ret = g_composerDevice->SetLayerBlendType(g_displayIds[0], layer->GetId(), type);
1733 
1734     PrepareAndCommit();
1735 
1736     EXPECT_EQ(DISPLAY_SUCCESS, ret);
1737     DestroyLayer(layer);
1738 }
1739 
1740 /**
1741  * @tc.number: SUB_DriverSystem_DisplayComposer_0470
1742  * @tc.name: test_SetLayerBlendType_011
1743  * @tc.desc: Set the blend type to BLEND_DSTATOP
1744  * @tc.size: MediumTest
1745  * @tc.type: Function
1746  */
HWTEST_F(DeviceTest, SUB_DriverSystem_DisplayComposer_0470, TestSize.Level1)1747 HWTEST_F(DeviceTest, SUB_DriverSystem_DisplayComposer_0470, TestSize.Level1)
1748 {
1749     std::vector<LayerSettings> settings = {
1750         {
1751             .rectRatio = { 0, 0, 1.0f, 1.0f },
1752             .color = GREEN
1753         }
1754     };
1755 
1756     std::vector<std::shared_ptr<HdiTestLayer>> layers = CreateLayers(settings);
1757     ASSERT_TRUE((layers.size() > 0));
1758 
1759     auto layer = layers[0];
1760 
1761     BlendType type = BlendType::BLEND_DSTATOP;
1762     auto ret = g_composerDevice->SetLayerBlendType(g_displayIds[0], layer->GetId(), type);
1763 
1764     PrepareAndCommit();
1765 
1766     EXPECT_EQ(DISPLAY_SUCCESS, ret);
1767     DestroyLayer(layer);
1768 }
1769 
1770 /**
1771  * @tc.number: SUB_DriverSystem_DisplayComposer_0480
1772  * @tc.name: test_SetLayerBlendType_012
1773  * @tc.desc: Set the blend type to BLEND_ADD
1774  * @tc.size: MediumTest
1775  * @tc.type: Function
1776  */
HWTEST_F(DeviceTest, SUB_DriverSystem_DisplayComposer_0480, TestSize.Level1)1777 HWTEST_F(DeviceTest, SUB_DriverSystem_DisplayComposer_0480, TestSize.Level1)
1778 {
1779     std::vector<LayerSettings> settings = {
1780         {
1781             .rectRatio = { 0, 0, 1.0f, 1.0f },
1782             .color = GREEN
1783         }
1784     };
1785 
1786     std::vector<std::shared_ptr<HdiTestLayer>> layers = CreateLayers(settings);
1787     ASSERT_TRUE((layers.size() > 0));
1788 
1789     auto layer = layers[0];
1790 
1791     BlendType type = BlendType::BLEND_ADD;
1792     auto ret = g_composerDevice->SetLayerBlendType(g_displayIds[0], layer->GetId(), type);
1793 
1794     PrepareAndCommit();
1795 
1796     EXPECT_EQ(DISPLAY_SUCCESS, ret);
1797     DestroyLayer(layer);
1798 }
1799 
1800 /**
1801  * @tc.number: SUB_DriverSystem_DisplayComposer_0490
1802  * @tc.name: test_SetLayerBlendType_013
1803  * @tc.desc: Set the blend type to BLEND_XOR
1804  * @tc.size: MediumTest
1805  * @tc.type: Function
1806  */
HWTEST_F(DeviceTest, SUB_DriverSystem_DisplayComposer_0490, TestSize.Level1)1807 HWTEST_F(DeviceTest, SUB_DriverSystem_DisplayComposer_0490, TestSize.Level1)
1808 {
1809     std::vector<LayerSettings> settings = {
1810         {
1811             .rectRatio = { 0, 0, 1.0f, 1.0f },
1812             .color = GREEN
1813         }
1814     };
1815 
1816     std::vector<std::shared_ptr<HdiTestLayer>> layers = CreateLayers(settings);
1817     ASSERT_TRUE((layers.size() > 0));
1818 
1819     auto layer = layers[0];
1820 
1821     BlendType type = BlendType::BLEND_XOR;
1822     auto ret = g_composerDevice->SetLayerBlendType(g_displayIds[0], layer->GetId(), type);
1823 
1824     PrepareAndCommit();
1825 
1826     EXPECT_EQ(DISPLAY_SUCCESS, ret);
1827     DestroyLayer(layer);
1828 }
1829 
1830 /**
1831  * @tc.number: SUB_DriverSystem_DisplayComposer_0500
1832  * @tc.name: test_SetLayerBlendType_014
1833  * @tc.desc: Set the blend type to BLEND_DST
1834  * @tc.size: MediumTest
1835  * @tc.type: Function
1836  */
HWTEST_F(DeviceTest, SUB_DriverSystem_DisplayComposer_0500, TestSize.Level1)1837 HWTEST_F(DeviceTest, SUB_DriverSystem_DisplayComposer_0500, TestSize.Level1)
1838 {
1839     std::vector<LayerSettings> settings = {
1840         {
1841             .rectRatio = { 0, 0, 1.0f, 1.0f },
1842             .color = GREEN
1843         }
1844     };
1845 
1846     std::vector<std::shared_ptr<HdiTestLayer>> layers = CreateLayers(settings);
1847     ASSERT_TRUE((layers.size() > 0));
1848 
1849     auto layer = layers[0];
1850 
1851     BlendType type = BlendType::BLEND_DST;
1852     auto ret = g_composerDevice->SetLayerBlendType(g_displayIds[0], layer->GetId(), type);
1853 
1854     PrepareAndCommit();
1855 
1856     EXPECT_EQ(DISPLAY_SUCCESS, ret);
1857     DestroyLayer(layer);
1858 }
1859 
1860 /**
1861  * @tc.number: SUB_DriverSystem_DisplayComposer_0510
1862  * @tc.name: test_SetLayerBlendType_015
1863  * @tc.desc: Set the blend type to BLEND_AKS
1864  * @tc.size: MediumTest
1865  * @tc.type: Function
1866  */
HWTEST_F(DeviceTest, SUB_DriverSystem_DisplayComposer_0510, TestSize.Level1)1867 HWTEST_F(DeviceTest, SUB_DriverSystem_DisplayComposer_0510, TestSize.Level1)
1868 {
1869     std::vector<LayerSettings> settings = {
1870         {
1871             .rectRatio = { 0, 0, 1.0f, 1.0f },
1872             .color = GREEN
1873         }
1874     };
1875 
1876     std::vector<std::shared_ptr<HdiTestLayer>> layers = CreateLayers(settings);
1877     ASSERT_TRUE((layers.size() > 0));
1878 
1879     auto layer = layers[0];
1880 
1881     BlendType type = BlendType::BLEND_AKS;
1882     auto ret = g_composerDevice->SetLayerBlendType(g_displayIds[0], layer->GetId(), type);
1883 
1884     PrepareAndCommit();
1885 
1886     EXPECT_EQ(DISPLAY_SUCCESS, ret);
1887     DestroyLayer(layer);
1888 }
1889 
1890 /**
1891  * @tc.number: SUB_DriverSystem_DisplayComposer_0520
1892  * @tc.name: test_SetLayerBlendType_016
1893  * @tc.desc: Set the blend type to BLEND_AKD
1894  * @tc.size: MediumTest
1895  * @tc.type: Function
1896  */
HWTEST_F(DeviceTest, SUB_DriverSystem_DisplayComposer_0520, TestSize.Level1)1897 HWTEST_F(DeviceTest, SUB_DriverSystem_DisplayComposer_0520, TestSize.Level1)
1898 {
1899     std::vector<LayerSettings> settings = {
1900         {
1901             .rectRatio = { 0, 0, 1.0f, 1.0f },
1902             .color = GREEN
1903         }
1904     };
1905 
1906     std::vector<std::shared_ptr<HdiTestLayer>> layers = CreateLayers(settings);
1907     ASSERT_TRUE((layers.size() > 0));
1908 
1909     auto layer = layers[0];
1910 
1911     BlendType type = BlendType::BLEND_AKD;
1912     auto ret = g_composerDevice->SetLayerBlendType(g_displayIds[0], layer->GetId(), type);
1913 
1914     PrepareAndCommit();
1915 
1916     EXPECT_EQ(DISPLAY_SUCCESS, ret);
1917     DestroyLayer(layer);
1918 }
1919 
1920 /**
1921  * @tc.number: SUB_DriverSystem_DisplayComposer_0530
1922  * @tc.name: test_SetLayerBlendType_017
1923  * @tc.desc: Set the blend type to BLEND_BUTT
1924  * @tc.size: MediumTest
1925  * @tc.type: Function
1926  */
HWTEST_F(DeviceTest, SUB_DriverSystem_DisplayComposer_0530, TestSize.Level1)1927 HWTEST_F(DeviceTest, SUB_DriverSystem_DisplayComposer_0530, TestSize.Level1)
1928 {
1929     std::vector<LayerSettings> settings = {
1930         {
1931             .rectRatio = { 0, 0, 1.0f, 1.0f },
1932             .color = GREEN
1933         }
1934     };
1935 
1936     std::vector<std::shared_ptr<HdiTestLayer>> layers = CreateLayers(settings);
1937     ASSERT_TRUE((layers.size() > 0));
1938 
1939     auto layer = layers[0];
1940 
1941     BlendType type = BlendType::BLEND_BUTT;
1942     auto ret = g_composerDevice->SetLayerBlendType(g_displayIds[0], layer->GetId(), type);
1943 
1944     PrepareAndCommit();
1945 
1946     EXPECT_EQ(DISPLAY_SUCCESS, ret);
1947     DestroyLayer(layer);
1948 }
1949 
1950 /**
1951  * @tc.number: SUB_DriverSystem_DisplayComposer_0540
1952  * @tc.name: test_SetLayerMaskInfo_002
1953  * @tc.desc: Sets the current mask frame information to the vendor driver
1954  * @tc.size: MediumTest
1955  * @tc.type: Function
1956  */
HWTEST_F(DeviceTest, SUB_DriverSystem_DisplayComposer_0540, TestSize.Level1)1957 HWTEST_F(DeviceTest, SUB_DriverSystem_DisplayComposer_0540, TestSize.Level1)
1958 {
1959     std::vector<LayerSettings> settings = {
1960         {
1961             .rectRatio = { 0, 0, 1.0f, 1.0f },
1962             .color = GREEN
1963         }
1964     };
1965 
1966     std::vector<std::shared_ptr<HdiTestLayer>> layers = CreateLayers(settings);
1967     ASSERT_TRUE((layers.size() > 0));
1968 
1969     auto layer = layers[0];
1970 
1971     MaskInfo maskInfo = MaskInfo::LAYER_NORAML;
1972     auto ret = g_composerDevice->SetLayerMaskInfo(g_displayIds[0], layer->GetId(), maskInfo);
1973 
1974     PrepareAndCommit();
1975 
1976     EXPECT_EQ(DISPLAY_SUCCESS, ret);
1977 
1978     DestroyLayer(layer);
1979 }
1980 
1981 /**
1982  * @tc.number: SUB_DriverSystem_DisplayComposer_0550
1983  * @tc.name: test_SetLayerCompositionType_002
1984  * @tc.desc: set the composition type which the client expect
1985  * @tc.size: MediumTest
1986  * @tc.type: Function
1987  */
HWTEST_F(DeviceTest, SUB_DriverSystem_DisplayComposer_0550, TestSize.Level1)1988 HWTEST_F(DeviceTest, SUB_DriverSystem_DisplayComposer_0550, TestSize.Level1)
1989 {
1990     std::vector<LayerSettings> settings = {
1991         {
1992             .rectRatio = { 0, 0, 1.0f, 1.0f },
1993             .color = BLUE
1994         }
1995     };
1996 
1997     std::vector<std::shared_ptr<HdiTestLayer>> layers = CreateLayers(settings);
1998     ASSERT_TRUE((layers.size() > 0));
1999 
2000     auto layer = layers[0];
2001 
2002     Composer::V1_0::CompositionType type = Composer::V1_0::CompositionType::COMPOSITION_DEVICE;
2003     auto ret = g_composerDevice->SetLayerCompositionType(g_displayIds[0], layer->GetId(), type);
2004 
2005     PrepareAndCommit();
2006 
2007     EXPECT_EQ(DISPLAY_SUCCESS, ret);
2008     DestroyLayer(layer);
2009 }
2010 
2011 /**
2012  * @tc.number: SUB_DriverSystem_DisplayComposer_0560
2013  * @tc.name: test_SetLayerCompositionType_003
2014  * @tc.desc: set the composition type which the client expect
2015  * @tc.size: MediumTest
2016  * @tc.type: Function
2017  */
HWTEST_F(DeviceTest, SUB_DriverSystem_DisplayComposer_0560, TestSize.Level1)2018 HWTEST_F(DeviceTest, SUB_DriverSystem_DisplayComposer_0560, TestSize.Level1)
2019 {
2020     std::vector<LayerSettings> settings = {
2021         {
2022             .rectRatio = { 0, 0, 1.0f, 1.0f },
2023             .color = BLUE
2024         }
2025     };
2026 
2027     std::vector<std::shared_ptr<HdiTestLayer>> layers = CreateLayers(settings);
2028     ASSERT_TRUE((layers.size() > 0));
2029 
2030     auto layer = layers[0];
2031 
2032     Composer::V1_0::CompositionType type = Composer::V1_0::CompositionType::COMPOSITION_CURSOR;
2033     auto ret = g_composerDevice->SetLayerCompositionType(g_displayIds[0], layer->GetId(), type);
2034 
2035     PrepareAndCommit();
2036 
2037     EXPECT_EQ(DISPLAY_SUCCESS, ret);
2038     DestroyLayer(layer);
2039 }
2040 
2041 /**
2042  * @tc.number: SUB_DriverSystem_DisplayComposer_0570
2043  * @tc.name: test_SetLayerCompositionType_004
2044  * @tc.desc: set the composition type which the client expect
2045  * @tc.size: MediumTest
2046  * @tc.type: Function
2047  */
HWTEST_F(DeviceTest, SUB_DriverSystem_DisplayComposer_0570, TestSize.Level1)2048 HWTEST_F(DeviceTest, SUB_DriverSystem_DisplayComposer_0570, TestSize.Level1)
2049 {
2050     std::vector<LayerSettings> settings = {
2051         {
2052             .rectRatio = { 0, 0, 1.0f, 1.0f },
2053             .color = BLUE
2054         }
2055     };
2056 
2057     std::vector<std::shared_ptr<HdiTestLayer>> layers = CreateLayers(settings);
2058     ASSERT_TRUE((layers.size() > 0));
2059 
2060     auto layer = layers[0];
2061 
2062     Composer::V1_0::CompositionType type = Composer::V1_0::CompositionType::COMPOSITION_VIDEO;
2063     auto ret = g_composerDevice->SetLayerCompositionType(g_displayIds[0], layer->GetId(), type);
2064 
2065     PrepareAndCommit();
2066 
2067     EXPECT_EQ(DISPLAY_SUCCESS, ret);
2068     DestroyLayer(layer);
2069 }
2070 
2071 /**
2072  * @tc.number: SUB_DriverSystem_DisplayComposer_0580
2073  * @tc.name: test_SetLayerCompositionType_005
2074  * @tc.desc: set the composition type which the client expect
2075  * @tc.size: MediumTest
2076  * @tc.type: Function
2077  */
HWTEST_F(DeviceTest, SUB_DriverSystem_DisplayComposer_0580, TestSize.Level1)2078 HWTEST_F(DeviceTest, SUB_DriverSystem_DisplayComposer_0580, TestSize.Level1)
2079 {
2080     std::vector<LayerSettings> settings = {
2081         {
2082             .rectRatio = { 0, 0, 1.0f, 1.0f },
2083             .color = BLUE
2084         }
2085     };
2086 
2087     std::vector<std::shared_ptr<HdiTestLayer>> layers = CreateLayers(settings);
2088     ASSERT_TRUE((layers.size() > 0));
2089 
2090     auto layer = layers[0];
2091 
2092     Composer::V1_0::CompositionType type = Composer::V1_0::CompositionType::COMPOSITION_DEVICE_CLEAR;
2093     auto ret = g_composerDevice->SetLayerCompositionType(g_displayIds[0], layer->GetId(), type);
2094 
2095     PrepareAndCommit();
2096 
2097     EXPECT_EQ(DISPLAY_SUCCESS, ret);
2098     DestroyLayer(layer);
2099 }
2100 
2101 /**
2102  * @tc.number: SUB_DriverSystem_DisplayComposer_0590
2103  * @tc.name: test_SetLayerCompositionType_006
2104  * @tc.desc: set the composition type which the client expect
2105  * @tc.size: MediumTest
2106  * @tc.type: Function
2107  */
HWTEST_F(DeviceTest, SUB_DriverSystem_DisplayComposer_0590, TestSize.Level1)2108 HWTEST_F(DeviceTest, SUB_DriverSystem_DisplayComposer_0590, TestSize.Level1)
2109 {
2110     std::vector<LayerSettings> settings = {
2111         {
2112             .rectRatio = { 0, 0, 1.0f, 1.0f },
2113             .color = BLUE
2114         }
2115     };
2116 
2117     std::vector<std::shared_ptr<HdiTestLayer>> layers = CreateLayers(settings);
2118     ASSERT_TRUE((layers.size() > 0));
2119 
2120     auto layer = layers[0];
2121 
2122     Composer::V1_0::CompositionType type = Composer::V1_0::CompositionType::COMPOSITION_CLIENT_CLEAR;
2123     auto ret = g_composerDevice->SetLayerCompositionType(g_displayIds[0], layer->GetId(), type);
2124 
2125     PrepareAndCommit();
2126 
2127     EXPECT_EQ(DISPLAY_SUCCESS, ret);
2128     DestroyLayer(layer);
2129 }
2130 
2131 /**
2132  * @tc.number: SUB_DriverSystem_DisplayComposer_0600
2133  * @tc.name: test_SetLayerCompositionType_007
2134  * @tc.desc: set the composition type which the client expect
2135  * @tc.size: MediumTest
2136  * @tc.type: Function
2137  */
HWTEST_F(DeviceTest, SUB_DriverSystem_DisplayComposer_0600, TestSize.Level1)2138 HWTEST_F(DeviceTest, SUB_DriverSystem_DisplayComposer_0600, TestSize.Level1)
2139 {
2140     std::vector<LayerSettings> settings = {
2141         {
2142             .rectRatio = { 0, 0, 1.0f, 1.0f },
2143             .color = BLUE
2144         }
2145     };
2146 
2147     std::vector<std::shared_ptr<HdiTestLayer>> layers = CreateLayers(settings);
2148     ASSERT_TRUE((layers.size() > 0));
2149 
2150     auto layer = layers[0];
2151 
2152     Composer::V1_0::CompositionType type = Composer::V1_0::CompositionType::COMPOSITION_TUNNEL;
2153     auto ret = g_composerDevice->SetLayerCompositionType(g_displayIds[0], layer->GetId(), type);
2154 
2155     PrepareAndCommit();
2156 
2157     EXPECT_EQ(DISPLAY_SUCCESS, ret);
2158     DestroyLayer(layer);
2159 }
2160 
2161 /**
2162  * @tc.number: SUB_DriverSystem_DisplayComposer_0610
2163  * @tc.name: test_SetLayerCompositionType_008
2164  * @tc.desc: set the composition type which the client expect
2165  * @tc.size: MediumTest
2166  * @tc.type: Function
2167  */
HWTEST_F(DeviceTest, SUB_DriverSystem_DisplayComposer_0610, TestSize.Level1)2168 HWTEST_F(DeviceTest, SUB_DriverSystem_DisplayComposer_0610, TestSize.Level1)
2169 {
2170     std::vector<LayerSettings> settings = {
2171         {
2172             .rectRatio = { 0, 0, 1.0f, 1.0f },
2173             .color = BLUE
2174         }
2175     };
2176 
2177     std::vector<std::shared_ptr<HdiTestLayer>> layers = CreateLayers(settings);
2178     ASSERT_TRUE((layers.size() > 0));
2179 
2180     auto layer = layers[0];
2181 
2182     Composer::V1_0::CompositionType type = Composer::V1_0::CompositionType::COMPOSITION_BUTT;
2183     auto ret = g_composerDevice->SetLayerCompositionType(g_displayIds[0], layer->GetId(), type);
2184 
2185     PrepareAndCommit();
2186 
2187     EXPECT_EQ(DISPLAY_SUCCESS, ret);
2188     DestroyLayer(layer);
2189 }
2190 
2191 /**
2192  * @tc.number: SUB_DriverSystem_DisplayComposer_0620
2193  * @tc.name: test_SetLayerTransformMode_005
2194  * @tc.desc: Sets the type of graphic rotation
2195  * @tc.size: MediumTest
2196  * @tc.type: Function
2197  */
HWTEST_F(DeviceTest, SUB_DriverSystem_DisplayComposer_0620, TestSize.Level1)2198 HWTEST_F(DeviceTest, SUB_DriverSystem_DisplayComposer_0620, TestSize.Level1)
2199 {
2200     std::vector<LayerSettings> settings = {
2201         {
2202             .rectRatio = { 0, 0, 1.0f, 1.0f },
2203             .color = RED
2204         }
2205     };
2206 
2207     std::vector<std::shared_ptr<HdiTestLayer>> layers = CreateLayers(settings);
2208     ASSERT_TRUE((layers.size() > 0));
2209 
2210     PrepareAndCommit();
2211 
2212     auto layer = layers[0];
2213 
2214     TransformType type = TransformType::ROTATE_NONE;
2215     auto ret = g_composerDevice->SetLayerTransformMode(g_displayIds[0], layer->GetId(), type);
2216     PrepareAndCommit();
2217     EXPECT_EQ(DISPLAY_SUCCESS, ret);
2218     DestroyLayer(layer);
2219 }