• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <gtest/gtest.h>
17 #include "display_manager_adapter.h"
18 #include "display_manager.h"
19 #include "screen_manager.h"
20 #include "display_manager_proxy.h"
21 #include "window_scene.h"
22 #include "scene_board_judgement.h"
23 
24 using namespace testing;
25 using namespace testing::ext;
26 
27 namespace OHOS {
28 namespace Rosen {
29 class DisplayManagerAdapterTest : public testing::Test {
30 public:
31     static void SetUpTestCase();
32     static void TearDownTestCase();
33     void SetUp() override;
34     void TearDown() override;
35 };
36 
SetUpTestCase()37 void DisplayManagerAdapterTest::SetUpTestCase()
38 {
39 }
40 
TearDownTestCase()41 void DisplayManagerAdapterTest::TearDownTestCase()
42 {
43 }
44 
SetUp()45 void DisplayManagerAdapterTest::SetUp()
46 {
47 }
48 
TearDown()49 void DisplayManagerAdapterTest::TearDown()
50 {
51 }
52 
53 namespace {
54 /**
55  * @tc.name: GetDisplayInfo
56  * @tc.desc: test nullptr
57  * @tc.type: FUNC
58  */
59 HWTEST_F(DisplayManagerAdapterTest, GetDisplayInfo, Function | SmallTest | Level2)
60 {
61     sptr<DisplayInfo> info = SingletonContainer::Get<DisplayManagerAdapter>().GetDisplayInfo(DISPLAY_ID_INVALID);
62     ASSERT_EQ(info, nullptr);
63 }
64 
65 /**
66  * @tc.name: GetCutoutInfo
67  * @tc.desc: test nullptr
68  * @tc.type: FUNC
69  */
70 HWTEST_F(DisplayManagerAdapterTest, GetCutoutInfo, Function | SmallTest | Level2)
71 {
72     sptr<CutoutInfo> info = SingletonContainer::Get<DisplayManagerAdapter>().GetCutoutInfo(DISPLAY_ID_INVALID);
73     ASSERT_EQ(info, nullptr);
74 }
75 
76 /**
77  * @tc.name: GetScreenSupportedColorGamuts
78  * @tc.desc: test success
79  * @tc.type: FUNC
80  */
81 HWTEST_F(DisplayManagerAdapterTest, GetScreenSupportedColorGamuts, Function | SmallTest | Level2)
82 {
83     std::vector<ScreenColorGamut> colorGamuts;
84     DMError err = SingletonContainer::Get<ScreenManagerAdapter>().GetScreenSupportedColorGamuts(0, colorGamuts);
85     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
86         ASSERT_EQ(err, DMError::DM_ERROR_RENDER_SERVICE_FAILED);
87     } else {
88         ASSERT_EQ(err, DMError::DM_OK);
89     }
90 }
91 
92 /**
93  * @tc.name: SetScreenColorGamut
94  * @tc.desc: test success
95  * @tc.type: FUNC
96  */
97 HWTEST_F(DisplayManagerAdapterTest, SetScreenColorGamut, Function | SmallTest | Level2)
98 {
99     std::vector<ScreenColorGamut> colorGamuts;
100     DMError err = SingletonContainer::Get<ScreenManagerAdapter>().SetScreenColorGamut(0, -1);
101     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
102         ASSERT_EQ(err, DMError::DM_ERROR_RENDER_SERVICE_FAILED);
103     } else {
104         ASSERT_EQ(err, DMError::DM_ERROR_INVALID_PARAM);
105     }
106 }
107 
108 /**
109  * @tc.name: GetScreenColorGamut
110  * @tc.desc: test success
111  * @tc.type: FUNC
112  */
113 HWTEST_F(DisplayManagerAdapterTest, GetScreenColorGamut, Function | SmallTest | Level2)
114 {
115     ScreenColorGamut colorGamut;
116     DMError err = SingletonContainer::Get<ScreenManagerAdapter>().GetScreenColorGamut(0, colorGamut);
117     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
118         ASSERT_EQ(err, DMError::DM_ERROR_RENDER_SERVICE_FAILED);
119     } else {
120         ASSERT_EQ(err, DMError::DM_OK);
121     }
122 }
123 
124 /**
125  * @tc.name: GetScreenGamutMap
126  * @tc.desc: test success
127  * @tc.type: FUNC
128  */
129 HWTEST_F(DisplayManagerAdapterTest, GetScreenGamutMap, Function | SmallTest | Level2)
130 {
131     ScreenGamutMap gamutMap;
132     DMError err = SingletonContainer::Get<ScreenManagerAdapter>().GetScreenGamutMap(0, gamutMap);
133     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
134         ASSERT_EQ(err, DMError::DM_ERROR_RENDER_SERVICE_FAILED);
135     } else {
136         ASSERT_EQ(err, DMError::DM_ERROR_RENDER_SERVICE_FAILED);
137     }
138 }
139 
140 /**
141  * @tc.name: SetScreenGamutMap
142  * @tc.desc: test success
143  * @tc.type: FUNC
144  */
145 HWTEST_F(DisplayManagerAdapterTest, SetScreenGamutMap, Function | SmallTest | Level2)
146 {
147     DMError err = SingletonContainer::Get<ScreenManagerAdapter>().SetScreenGamutMap(0, GAMUT_MAP_CONSTANT);
148     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
149         ASSERT_EQ(err, DMError::DM_ERROR_RENDER_SERVICE_FAILED);
150     } else {
151         ASSERT_EQ(err, DMError::DM_ERROR_RENDER_SERVICE_FAILED);
152     }
153 }
154 
155 /**
156  * @tc.name: SetScreenColorTransform
157  * @tc.desc: test success
158  * @tc.type: FUNC
159  */
160 HWTEST_F(DisplayManagerAdapterTest, SetScreenColorTransform, Function | SmallTest | Level2)
161 {
162     DMError err = SingletonContainer::Get<ScreenManagerAdapter>().SetScreenColorTransform(0);
163     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
164         ASSERT_EQ(err, DMError::DM_OK);
165     } else {
166         ASSERT_EQ(err, DMError::DM_OK);
167     }
168 }
169 
170 /**
171  * @tc.name: SetFreeze
172  * @tc.desc: test success
173  * @tc.type: FUNC
174  */
175 HWTEST_F(DisplayManagerAdapterTest, SetFreeze, Function | SmallTest | Level2)
176 {
177     std::vector<DisplayId> displayIds;
178     bool ret = SingletonContainer::Get<DisplayManagerAdapter>().SetFreeze(displayIds, false);
179     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
180         ASSERT_TRUE(ret);
181     } else {
182         ASSERT_FALSE(ret);
183     }
184 }
185 
186 /**
187  * @tc.name: GetScreenGroupInfoById
188  * @tc.desc: test nullptr
189  * @tc.type: FUNC
190  */
191 HWTEST_F(DisplayManagerAdapterTest, GetScreenGroupInfoById, Function | SmallTest | Level2)
192 {
193     auto info = SingletonContainer::Get<ScreenManagerAdapter>().GetScreenGroupInfoById(SCREEN_ID_INVALID);
194     ASSERT_EQ(info, nullptr);
195 }
196 
197 /**
198  * @tc.name: GetScreenInfo
199  * @tc.desc: test nullptr
200  * @tc.type: FUNC
201  */
202 HWTEST_F(DisplayManagerAdapterTest, GetScreenInfo, Function | SmallTest | Level2)
203 {
204     sptr<ScreenInfo> info = SingletonContainer::Get<ScreenManagerAdapter>().GetScreenInfo(SCREEN_ID_INVALID);
205     ASSERT_EQ(info, nullptr);
206 }
207 
208 /**
209  * @tc.name: OnRemoteDied
210  * @tc.desc: test nullptr
211  * @tc.type: FUNC
212  */
213 HWTEST_F(DisplayManagerAdapterTest, OnRemoteDied, Function | SmallTest | Level2)
214 {
215     sptr<IRemoteObject::DeathRecipient> dmsDeath_ = nullptr;
216     dmsDeath_ = new(std::nothrow) DMSDeathRecipient(SingletonContainer::Get<ScreenManagerAdapter>());
217     dmsDeath_->OnRemoteDied(nullptr);
218     EXPECT_NE(nullptr, dmsDeath_);
219 }
220 
221 /**
222  * @tc.name: OnRemoteDied01
223  * @tc.desc: test nullptr
224  * @tc.type: FUNC
225  */
226 HWTEST_F(DisplayManagerAdapterTest, OnRemoteDied01, Function | SmallTest | Level2)
227 {
228     sptr<IRemoteObject::DeathRecipient> dmsDeath_ = nullptr;
229     dmsDeath_ = new(std::nothrow) DMSDeathRecipient(SingletonContainer::Get<ScreenManagerAdapter>());
230     SingletonContainer::Get<ScreenManagerAdapter>().InitDMSProxy();
231     sptr<IRemoteObject> obj = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject();
232     wptr<IRemoteObject> wptrDeath = obj;
233     dmsDeath_->OnRemoteDied(wptrDeath);
234     EXPECT_NE(nullptr, dmsDeath_);
235 }
236 
237 /**
238  * @tc.name: Clear
239  * @tc.desc: test success
240  * @tc.type: FUNC
241  */
242 HWTEST_F(DisplayManagerAdapterTest, Clear, Function | SmallTest | Level2)
243 {
244     SingletonContainer::Get<ScreenManagerAdapter>().InitDMSProxy();
245     SingletonContainer::Get<ScreenManagerAdapter>().Clear();
246     ASSERT_FALSE(SingletonContainer::Get<ScreenManagerAdapter>().isProxyValid_);
247 }
248 
249 /**
250  * @tc.name: Clear01
251  * @tc.desc: test success
252  * @tc.type: FUNC
253  */
254 HWTEST_F(DisplayManagerAdapterTest, Clear01, Function | SmallTest | Level2)
255 {
256     SingletonContainer::Get<ScreenManagerAdapter>().InitDMSProxy();
257     SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_ = nullptr;
258     SingletonContainer::Get<ScreenManagerAdapter>().Clear();
259     ASSERT_FALSE(SingletonContainer::Get<ScreenManagerAdapter>().isProxyValid_);
260 }
261 
262 /**
263  * @tc.name: DisableMirror
264  * @tc.desc: DisableMirror test
265  * @tc.type: FUNC
266  */
267 HWTEST_F(DisplayManagerAdapterTest, DisableMirror, Function | SmallTest | Level2)
268 {
269     DMError ret = SingletonContainer::Get<ScreenManagerAdapter>().DisableMirror(false);
270     if (SceneBoardJudgement::IsSceneBoardEnabled()) {
271         ASSERT_EQ(DMError::DM_OK, ret);
272     } else {
273         ASSERT_NE(DMError::DM_OK, ret);
274     }
275 }
276 
277 /**
278  * @tc.name: HasImmersiveWindow
279  * @tc.desc: test HasImmersiveWindow
280  * @tc.type: FUNC
281  */
282 HWTEST_F(DisplayManagerAdapterTest, HasImmersiveWindow, Function | SmallTest | Level2)
283 {
284     bool immersive = false;
285     DMError ret = SingletonContainer::Get<DisplayManagerAdapter>().HasImmersiveWindow(0u, immersive);
286     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
287         ASSERT_EQ(ret, DMError::DM_ERROR_DEVICE_NOT_SUPPORT);
288     } else {
289         ASSERT_EQ(ret, DMError::DM_OK);
290     }
291 }
292 
293 /**
294  * @tc.name: GetPixelFormat
295  * @tc.desc: test success
296  * @tc.type: FUNC
297  */
298 HWTEST_F(DisplayManagerAdapterTest, GetPixelFormat, Function | SmallTest | Level2)
299 {
300     GraphicPixelFormat pixelFormat = GraphicPixelFormat{GRAPHIC_PIXEL_FMT_CLUT8};
301     DMError err = SingletonContainer::Get<ScreenManagerAdapter>().GetPixelFormat(0, pixelFormat);
302     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
303         ASSERT_EQ(err, DMError::DM_ERROR_IPC_FAILED);
304     } else {
305         ASSERT_EQ(err, DMError::DM_OK);
306     }
307 }
308 
309 /**
310  * @tc.name: SetPixelFormat
311  * @tc.desc: test success
312  * @tc.type: FUNC
313  */
314 HWTEST_F(DisplayManagerAdapterTest, SetPixelFormat, Function | SmallTest | Level2)
315 {
316     GraphicPixelFormat pixelFormat = GraphicPixelFormat{GRAPHIC_PIXEL_FMT_CLUT8};
317     DMError err = SingletonContainer::Get<ScreenManagerAdapter>().SetPixelFormat(0, pixelFormat);
318     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
319         ASSERT_EQ(err, DMError::DM_ERROR_IPC_FAILED);
320     } else {
321         ASSERT_EQ(err, DMError::DM_OK);
322     }
323 }
324 
325 /**
326  * @tc.name: GetSupportedHDRFormats
327  * @tc.desc: test success
328  * @tc.type: FUNC
329  */
330 HWTEST_F(DisplayManagerAdapterTest, GetSupportedHDRFormats, Function | SmallTest | Level2)
331 {
332     std::vector<ScreenHDRFormat> hdrFormats;
333     DMError err = SingletonContainer::Get<ScreenManagerAdapter>().GetSupportedHDRFormats(0, hdrFormats);
334     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
335         ASSERT_EQ(err, DMError::DM_ERROR_IPC_FAILED);
336     } else {
337         ASSERT_EQ(err, DMError::DM_OK);
338     }
339 }
340 
341 /**
342  * @tc.name: GetScreenHDRFormat
343  * @tc.desc: test success
344  * @tc.type: FUNC
345  */
346 HWTEST_F(DisplayManagerAdapterTest, GetScreenHDRFormat, Function | SmallTest | Level2)
347 {
348     ScreenHDRFormat hdrFormat = ScreenHDRFormat{NOT_SUPPORT_HDR};
349     DMError err = SingletonContainer::Get<ScreenManagerAdapter>().GetScreenHDRFormat(0, hdrFormat);
350     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
351         ASSERT_EQ(err, DMError::DM_ERROR_IPC_FAILED);
352     } else {
353         ASSERT_EQ(err, DMError::DM_OK);
354     }
355 }
356 
357 /**
358  * @tc.name: SetScreenHDRFormat
359  * @tc.desc: test success
360  * @tc.type: FUNC
361  */
362 HWTEST_F(DisplayManagerAdapterTest, SetScreenHDRFormat, Function | SmallTest | Level2)
363 {
364     DMError err = SingletonContainer::Get<ScreenManagerAdapter>().SetScreenHDRFormat(0, 0);
365     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
366         ASSERT_EQ(err, DMError::DM_ERROR_IPC_FAILED);
367     } else {
368         ASSERT_EQ(err, DMError::DM_OK);
369     }
370 }
371 
372 /**
373  * @tc.name: GetSupportedColorSpaces
374  * @tc.desc: test success
375  * @tc.type: FUNC
376  */
377 HWTEST_F(DisplayManagerAdapterTest, GetSupportedColorSpaces, Function | SmallTest | Level2)
378 {
379     std::vector<GraphicCM_ColorSpaceType> colorSpaces;
380     DMError err = SingletonContainer::Get<ScreenManagerAdapter>().GetSupportedColorSpaces(0, colorSpaces);
381     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
382         ASSERT_EQ(err, DMError::DM_ERROR_IPC_FAILED);
383     } else {
384         ASSERT_EQ(err, DMError::DM_OK);
385     }
386 }
387 
388 /**
389  * @tc.name: GetScreenColorSpace
390  * @tc.desc: test success
391  * @tc.type: FUNC
392  */
393 HWTEST_F(DisplayManagerAdapterTest, GetScreenColorSpace, Function | SmallTest | Level2)
394 {
395     GraphicCM_ColorSpaceType colorSpace = GraphicCM_ColorSpaceType{GRAPHIC_CM_COLORSPACE_NONE};
396     DMError err = SingletonContainer::Get<ScreenManagerAdapter>().GetScreenColorSpace(0, colorSpace);
397     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
398         ASSERT_EQ(err, DMError::DM_ERROR_IPC_FAILED);
399     } else {
400         ASSERT_EQ(err, DMError::DM_OK);
401     }
402 }
403 
404 /**
405  * @tc.name: SetScreenColorSpace
406  * @tc.desc: test success
407  * @tc.type: FUNC
408  */
409 HWTEST_F(DisplayManagerAdapterTest, SetScreenColorSpace, Function | SmallTest | Level2)
410 {
411     GraphicCM_ColorSpaceType colorSpace = GraphicCM_ColorSpaceType{GRAPHIC_CM_COLORSPACE_NONE};
412     DMError err = SingletonContainer::Get<ScreenManagerAdapter>().SetScreenColorSpace(0, colorSpace);
413     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
414         ASSERT_EQ(err, DMError::DM_ERROR_IPC_FAILED);
415     } else {
416         ASSERT_EQ(err, DMError::DM_ERROR_RENDER_SERVICE_FAILED);
417     }
418 }
419 
420 /**
421  * @tc.name: DestroyVirtualScreen
422  * @tc.desc: test success
423  * @tc.type: FUNC
424  */
425 HWTEST_F(DisplayManagerAdapterTest, DestroyVirtualScreen, Function | SmallTest | Level2)
426 {
427     VirtualScreenOption defaultOption = {"virtualScreen01", 480, 320, 2.0, nullptr, 0};
428     ScreenId id = ScreenManager::GetInstance().CreateVirtualScreen(defaultOption);
429     DMError err = SingletonContainer::Get<ScreenManagerAdapter>().DestroyVirtualScreen(id);
430     ASSERT_EQ(err, DMError::DM_OK);
431 }
432 
433 /**
434  * @tc.name: SetVirtualMirrorScreenCanvasRotation
435  * @tc.desc: test SetVirtualMirrorScreenCanvasRotation
436  * @tc.type: FUNC
437  */
438 HWTEST_F(DisplayManagerAdapterTest, SetVirtualMirrorScreenCanvasRotation, Function | SmallTest | Level2)
439 {
440     bool canvasRotation = false;
441     DMError ret = SingletonContainer::Get<ScreenManagerAdapter>().
442                     SetVirtualMirrorScreenCanvasRotation(0, canvasRotation);
443     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
444         ASSERT_EQ(ret, DMError::DM_OK);
445     } else {
446         ASSERT_EQ(ret, DMError::DM_ERROR_RENDER_SERVICE_FAILED);
447     }
448 }
449 
450 /**
451  * @tc.name: SetScreenRotationLocked
452  * @tc.desc: test SetScreenRotationLocked
453  * @tc.type: FUNC
454  */
455 HWTEST_F(DisplayManagerAdapterTest, SetScreenRotationLocked, Function | SmallTest | Level2)
456 {
457     bool isLocked = false;
458     DMError ret = SingletonContainer::Get<ScreenManagerAdapter>().SetScreenRotationLocked(isLocked);
459     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
460         ASSERT_EQ(ret, DMError::DM_OK);
461     } else {
462         ASSERT_EQ(ret, DMError::DM_OK);
463     }
464 }
465 
466 /**
467  * @tc.name: IsScreenRotationLocked
468  * @tc.desc: test IsScreenRotationLocked
469  * @tc.type: FUNC
470  */
471 HWTEST_F(DisplayManagerAdapterTest, IsScreenRotationLocked, Function | SmallTest | Level2)
472 {
473     bool isLocked = false;
474     DMError ret = SingletonContainer::Get<ScreenManagerAdapter>().IsScreenRotationLocked(isLocked);
475     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
476         ASSERT_EQ(ret, DMError::DM_OK);
477     } else {
478         ASSERT_EQ(ret, DMError::DM_OK);
479     }
480 }
481 
482 /**
483  * @tc.name: SetSpecifiedScreenPower
484  * @tc.desc: test SetSpecifiedScreenPower
485  * @tc.type: FUNC
486  */
487 HWTEST_F(DisplayManagerAdapterTest, SetSpecifiedScreenPower, Function | SmallTest | Level2)
488 {
489     ScreenPowerState state = ScreenPowerState{0};
490     PowerStateChangeReason reason = PowerStateChangeReason{0};
491     bool ret = SingletonContainer::Get<ScreenManagerAdapter>().SetSpecifiedScreenPower(0, state, reason);
492     if (SceneBoardJudgement::IsSceneBoardEnabled()) {
493         ASSERT_TRUE(ret);
494     } else {
495         ASSERT_FALSE(ret);
496     }
497 }
498 
499 /**
500  * @tc.name: SetOrientation
501  * @tc.desc: SetOrientation success
502  * @tc.type: FUNC
503  */
504 HWTEST_F(DisplayManagerAdapterTest, SetOrientation, Function | SmallTest | Level2)
505 {
506     Orientation orientation = Orientation{0};
507     DMError err = SingletonContainer::Get<ScreenManagerAdapter>().SetOrientation(0, orientation);
508     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
509         ASSERT_EQ(err, DMError::DM_OK);
510     } else {
511         ASSERT_EQ(err, DMError::DM_OK);
512     }
513 }
514 
515 /**
516  * @tc.name: WakeUpBegin
517  * @tc.desc: test WakeUpBegin
518  * @tc.type: FUNC
519  */
520 HWTEST_F(DisplayManagerAdapterTest, WakeUpBegin, Function | SmallTest | Level2)
521 {
522     PowerStateChangeReason reason = PowerStateChangeReason{0};
523     bool ret = SingletonContainer::Get<DisplayManagerAdapter>().WakeUpBegin(reason);
524     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
525         ASSERT_TRUE(ret);
526     } else {
527         ASSERT_TRUE(ret);
528     }
529 }
530 
531 /**
532  * @tc.name: WakeUpEnd
533  * @tc.desc: test WakeUpEnd
534  * @tc.type: FUNC
535  */
536 HWTEST_F(DisplayManagerAdapterTest, WakeUpEnd, Function | SmallTest | Level2)
537 {
538     bool ret = SingletonContainer::Get<DisplayManagerAdapter>().WakeUpEnd();
539     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
540         ASSERT_TRUE(ret);
541     } else {
542         ASSERT_TRUE(ret);
543     }
544 }
545 
546 /**
547  * @tc.name: SuspendBegin
548  * @tc.desc: test SuspendBegin
549  * @tc.type: FUNC
550  */
551 HWTEST_F(DisplayManagerAdapterTest, SuspendBegin, Function | SmallTest | Level2)
552 {
553     PowerStateChangeReason reason = PowerStateChangeReason{0};
554     bool ret = SingletonContainer::Get<DisplayManagerAdapter>().SuspendBegin(reason);
555     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
556         ASSERT_TRUE(ret);
557     } else {
558         ASSERT_TRUE(ret);
559     }
560 }
561 
562 /**
563  * @tc.name: SuspendEnd
564  * @tc.desc: test SuspendEnd
565  * @tc.type: FUNC
566  */
567 HWTEST_F(DisplayManagerAdapterTest, SuspendEnd, Function | SmallTest | Level2)
568 {
569     bool ret = SingletonContainer::Get<DisplayManagerAdapter>().SuspendEnd();
570     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
571         ASSERT_TRUE(ret);
572     } else {
573         ASSERT_TRUE(ret);
574     }
575 }
576 
577 /**
578  * @tc.name: SetDisplayState
579  * @tc.desc: test SetDisplayState
580  * @tc.type: FUNC
581  */
582 HWTEST_F(DisplayManagerAdapterTest, SetDisplayState, Function | SmallTest | Level2)
583 {
584     DisplayState state = DisplayState{1};
585     bool ret = SingletonContainer::Get<DisplayManagerAdapter>().SetDisplayState(state);
586     if (SceneBoardJudgement::IsSceneBoardEnabled()) {
587         ASSERT_TRUE(ret);
588     }
589 }
590 
591 /**
592  * @tc.name: MakeMirror
593  * @tc.desc: test success
594  * @tc.type: FUNC
595  */
596 HWTEST_F(DisplayManagerAdapterTest, MakeMirror, Function | SmallTest | Level2)
597 {
598     std::vector<ScreenId> mirrorScreenId;
599     ScreenId screenGroupId;
600     DMError err = SingletonContainer::Get<ScreenManagerAdapter>().MakeMirror(0,
601         mirrorScreenId, screenGroupId);
602     ASSERT_EQ(err, DMError::DM_ERROR_INVALID_PARAM);
603 }
604 
605 /**
606  * @tc.name: StopMirror
607  * @tc.desc: test success
608  * @tc.type: FUNC
609  */
610 HWTEST_F(DisplayManagerAdapterTest, StopMirror, Function | SmallTest | Level2)
611 {
612     std::vector<ScreenId> mirrorScreenIds;
613     DMError err = SingletonContainer::Get<ScreenManagerAdapter>().StopMirror(mirrorScreenIds);
614     ASSERT_EQ(err, DMError::DM_OK);
615 }
616 
617 /**
618  * @tc.name: HasPrivateWindow
619  * @tc.desc: test success
620  * @tc.type: FUNC
621  */
622 HWTEST_F(DisplayManagerAdapterTest, HasPrivateWindow, Function | SmallTest | Level2)
623 {
624     bool hasPrivateWindow = false;
625     DMError err = SingletonContainer::Get<DisplayManagerAdapter>().HasPrivateWindow(0,
626         hasPrivateWindow);
627     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
628         ASSERT_EQ(DMError::DM_OK, err);
629     } else {
630         ASSERT_EQ(DMError::DM_OK, err);
631     }
632 }
633 
634 /**
635  * @tc.name: AddSurfaceNodeToDisplay
636  * @tc.desc: test success
637  * @tc.type: FUNC
638  */
639 HWTEST_F(DisplayManagerAdapterTest, AddSurfaceNodeToDisplay, Function | SmallTest | Level2)
640 {
641     std::shared_ptr<class RSSurfaceNode> surfaceNode;
642     DMError err = SingletonContainer::Get<DisplayManagerAdapter>().AddSurfaceNodeToDisplay(0,
643         surfaceNode);
644     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
645         ASSERT_EQ(DMError::DM_ERROR_IPC_FAILED, err);
646     } else {
647         ASSERT_EQ(DMError::DM_OK, err);
648     }
649 }
650 
651 /**
652  * @tc.name: RemoveSurfaceNodeFromDisplay
653  * @tc.desc: test success
654  * @tc.type: FUNC
655  */
656 HWTEST_F(DisplayManagerAdapterTest, RemoveSurfaceNodeFromDisplay, Function | SmallTest | Level2)
657 {
658     std::shared_ptr<class RSSurfaceNode> surfaceNode;
659     DMError err = SingletonContainer::Get<DisplayManagerAdapter>().RemoveSurfaceNodeFromDisplay(0,
660         surfaceNode);
661     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
662         ASSERT_EQ(DMError::DM_ERROR_IPC_FAILED, err);
663     } else {
664         ASSERT_EQ(DMError::DM_OK, err);
665     }
666 }
667 
668 /**
669  * @tc.name: MakeExpand
670  * @tc.desc: test success
671  * @tc.type: FUNC
672  */
673 HWTEST_F(DisplayManagerAdapterTest, MakeExpand, Function | SmallTest | Level2)
674 {
675     std::vector<ScreenId> screenId;
676     std::vector<Point> startPoint;
677     ScreenId screenGroupId;
678     DMError err = SingletonContainer::Get<ScreenManagerAdapter>().MakeExpand(screenId,
679         startPoint, screenGroupId);
680     ASSERT_EQ(err, DMError::DM_ERROR_INVALID_PARAM);
681 }
682 
683 /**
684  * @tc.name: StopExpand
685  * @tc.desc: test success
686  * @tc.type: FUNC
687  */
688 HWTEST_F(DisplayManagerAdapterTest, StopExpand, Function | SmallTest | Level2)
689 {
690     std::vector<ScreenId> expandScreenIds;
691     DMError err = SingletonContainer::Get<ScreenManagerAdapter>().StopExpand(expandScreenIds);
692     ASSERT_EQ(err, DMError::DM_OK);
693 }
694 
695 /**
696  * @tc.name: RemoveVirtualScreenFromGroup
697  * @tc.desc: test success
698  * @tc.type: FUNC
699  */
700 HWTEST_F(DisplayManagerAdapterTest, RemoveVirtualScreenFromGroup, Function | SmallTest | Level2)
701 {
702     std::vector<ScreenId> screens;
703     int resultValue = 0;
__anon37da98d50202() 704     std::function<void()> func = [&]() {
705         SingletonContainer::Get<ScreenManagerAdapter>().RemoveVirtualScreenFromGroup(screens);
706         resultValue = 1;
707     };
708     func();
709     ASSERT_EQ(resultValue, 1);
710 }
711 
712 /**
713  * @tc.name: SetScreenActiveMode
714  * @tc.desc: test success
715  * @tc.type: FUNC
716  */
717 HWTEST_F(DisplayManagerAdapterTest, SetScreenActiveMode, Function | SmallTest | Level2)
718 {
719     VirtualScreenOption defaultOption = {"virtualScreen02", 480, 320, 2.0, nullptr, 0};
720     ScreenId id = ScreenManager::GetInstance().CreateVirtualScreen(defaultOption);
721     DMError err = SingletonContainer::Get<ScreenManagerAdapter>().SetScreenActiveMode(id, 100);
722     ASSERT_EQ(err, DMError::DM_OK);
723     SingletonContainer::Get<ScreenManagerAdapter>().DestroyVirtualScreen(id);
724 }
725 
726 /**
727  * @tc.name: SetVirtualPixelRatio
728  * @tc.desc: test success
729  * @tc.type: FUNC
730  */
731 HWTEST_F(DisplayManagerAdapterTest, SetVirtualPixelRatio, Function | SmallTest | Level2)
732 {
733     VirtualScreenOption defaultOption = {"virtualScreen03", 480, 320, 2.0, nullptr, 0};
734     ScreenId id = ScreenManager::GetInstance().CreateVirtualScreen(defaultOption);
735     DMError err = SingletonContainer::Get<ScreenManagerAdapter>().SetVirtualPixelRatio(id, 0);
736     ASSERT_EQ(err, DMError::DM_OK);
737     SingletonContainer::Get<ScreenManagerAdapter>().DestroyVirtualScreen(id);
738 }
739 
740 /**
741  * @tc.name: SetResolution
742  * @tc.desc: test success
743  * @tc.type: FUNC
744  */
745 HWTEST_F(DisplayManagerAdapterTest, SetResolution, Function | SmallTest | Level2)
746 {
747     VirtualScreenOption defaultOption = {"virtualScreen04", 480, 320, 2.0, nullptr, 0};
748     ScreenId id = ScreenManager::GetInstance().CreateVirtualScreen(defaultOption);
749     DMError err = SingletonContainer::Get<ScreenManagerAdapter>().SetResolution(id, 70, 100, 1);
750     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
751         ASSERT_EQ(err, DMError::DM_ERROR_IPC_FAILED);
752     } else {
753         ASSERT_EQ(err, DMError::DM_OK);
754     }
755     SingletonContainer::Get<ScreenManagerAdapter>().DestroyVirtualScreen(id);
756 }
757 
758 /**
759  * @tc.name: ResizeVirtualScreen
760  * @tc.desc: test success
761  * @tc.type: FUNC
762  */
763 HWTEST_F(DisplayManagerAdapterTest, ResizeVirtualScreen, Function | SmallTest | Level2)
764 {
765     DMError err = SingletonContainer::Get<ScreenManagerAdapter>().ResizeVirtualScreen(0, 70, 100);
766     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
767         ASSERT_EQ(err, DMError::DM_OK);
768     } else {
769         ASSERT_EQ(err, DMError::DM_OK);
770     }
771 }
772 
773 /**
774  * @tc.name: MakeUniqueScreen
775  * @tc.desc: test success
776  * @tc.type: FUNC
777  */
778 HWTEST_F(DisplayManagerAdapterTest, MakeUniqueScreen, Function | SmallTest | Level2)
779 {
780     std::vector<ScreenId> screenIds;
781     std::vector<DisplayId> displayIds;
782     DMError err = SingletonContainer::Get<ScreenManagerAdapter>().MakeUniqueScreen(screenIds, displayIds);
783     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
784         ASSERT_EQ(err, DMError::DM_OK);
785     } else {
786         ASSERT_EQ(err, DMError::DM_ERROR_INVALID_PARAM);
787     }
788 }
789 
790 /**
791  * @tc.name: GetAvailableArea
792  * @tc.desc: test success
793  * @tc.type: FUNC
794  */
795 HWTEST_F(DisplayManagerAdapterTest, GetAvailableArea, Function | SmallTest | Level2)
796 {
797     DMRect area;
798     DMError err = SingletonContainer::Get<DisplayManagerAdapter>().GetAvailableArea(0, area);
799     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
800         ASSERT_EQ(err, DMError::DM_ERROR_DEVICE_NOT_SUPPORT);
801     } else {
802         ASSERT_EQ(err, DMError::DM_OK);
803     }
804 }
805 
806 /**
807  * @tc.name: GetAllDisplayPhysicalResolution
808  * @tc.desc: test success
809  * @tc.type: FUNC
810  */
811 HWTEST_F(DisplayManagerAdapterTest, GetAllDisplayPhysicalResolution, Function | SmallTest | Level2)
812 {
813     std::vector<DisplayPhysicalResolution> allSize =
814         SingletonContainer::Get<DisplayManagerAdapter>().GetAllDisplayPhysicalResolution();
815     ASSERT_TRUE(!allSize.empty());
816 }
817 
818 /**
819  * @tc.name: SetDisplayScale
820  * @tc.desc: SetDisplayScale test
821  * @tc.type: FUNC
822  */
823 HWTEST_F(DisplayManagerAdapterTest, SetDisplayScale, Function | SmallTest | Level2)
824 {
825     DisplayManagerAdapter& displayManagerAdapter = SingletonContainer::Get<DisplayManagerAdapter>();
826     const float scaleX = 1.0f;
827     const float scaleY = 1.0f;
828     const float pivotX = 0.5f;
829     const float pivotY = 0.5f;
830     sptr<DisplayInfo> displayInfo = displayManagerAdapter.GetDefaultDisplayInfo();
831     ASSERT_NE(displayInfo, nullptr);
832     ScreenId screenId = displayInfo->GetScreenId();
833     displayManagerAdapter.SetDisplayScale(screenId, scaleX, scaleY, pivotX, pivotY);
834 }
835 
836 /**
837  * @tc.name: GetPrimaryDisplayInfo
838  * @tc.desc: GetPrimaryDisplayInfo test
839  * @tc.type: FUNC
840  */
841 HWTEST_F(DisplayManagerAdapterTest, GetPrimaryDisplayInfo, Function | SmallTest | Level2)
842 {
843     DisplayManagerAdapter& displayManagerAdapter = SingletonContainer::Get<DisplayManagerAdapter>();
844     sptr<DisplayInfo> displayInfo = displayManagerAdapter.GetPrimaryDisplayInfo();
845     ASSERT_NE(displayInfo, nullptr);
846 }
847 
848 /**
849  * @tc.name: SetScreenSkipProtectedWindow
850  * @tc.desc: SetScreenSkipProtectedWindow test
851  * @tc.type: FUNC
852  */
853 HWTEST_F(DisplayManagerAdapterTest, SetScreenSkipProtectedWindow, Function | SmallTest | Level2)
854 {
855     const std::vector<ScreenId> screenIds = {1001, 1002};
856     bool isEnable = true;
857     auto result = SingletonContainer::Get<ScreenManagerAdapter>().SetScreenSkipProtectedWindow(screenIds, isEnable);
858     ASSERT_EQ(result, DMError::DM_OK);
859 }
860 
861 /**
862  * @tc.name: GetDisplayCapability
863  * @tc.desc: GetDisplayCapability test success
864  * @tc.type: FUNC
865  */
866 HWTEST_F(DisplayManagerAdapterTest, GetDisplayCapability, Function | SmallTest | Level2)
867 {
868     std::string capabilitInfo;
869     auto result = SingletonContainer::Get<DisplayManagerAdapter>().GetDisplayCapability(capabilitInfo);
870     ASSERT_EQ(result, DMError::DM_OK);
871 }
872 }
873 }
874 }
875