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(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 if (SceneBoardJudgement::IsSceneBoardEnabled()) {
431 ASSERT_EQ(err, DMError::DM_OK);
432 } else {
433 ASSERT_EQ(err, DMError::DM_OK);
434 }
435 }
436
437 /**
438 * @tc.name: SetVirtualMirrorScreenCanvasRotation
439 * @tc.desc: test SetVirtualMirrorScreenCanvasRotation
440 * @tc.type: FUNC
441 */
442 HWTEST_F(DisplayManagerAdapterTest, SetVirtualMirrorScreenCanvasRotation, Function | SmallTest | Level2)
443 {
444 bool canvasRotation = false;
445 DMError ret = SingletonContainer::Get<ScreenManagerAdapter>().
446 SetVirtualMirrorScreenCanvasRotation(0, canvasRotation);
447 if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
448 ASSERT_EQ(ret, DMError::DM_OK);
449 } else {
450 ASSERT_EQ(ret, DMError::DM_ERROR_RENDER_SERVICE_FAILED);
451 }
452 }
453
454 /**
455 * @tc.name: SetScreenRotationLocked
456 * @tc.desc: test SetScreenRotationLocked
457 * @tc.type: FUNC
458 */
459 HWTEST_F(DisplayManagerAdapterTest, SetScreenRotationLocked, Function | SmallTest | Level2)
460 {
461 bool isLocked = false;
462 DMError ret = SingletonContainer::Get<ScreenManagerAdapter>().SetScreenRotationLocked(isLocked);
463 if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
464 ASSERT_EQ(ret, DMError::DM_OK);
465 } else {
466 ASSERT_EQ(ret, DMError::DM_OK);
467 }
468 }
469
470 /**
471 * @tc.name: IsScreenRotationLocked
472 * @tc.desc: test IsScreenRotationLocked
473 * @tc.type: FUNC
474 */
475 HWTEST_F(DisplayManagerAdapterTest, IsScreenRotationLocked, Function | SmallTest | Level2)
476 {
477 bool isLocked = false;
478 DMError ret = SingletonContainer::Get<ScreenManagerAdapter>().IsScreenRotationLocked(isLocked);
479 if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
480 ASSERT_EQ(ret, DMError::DM_OK);
481 } else {
482 ASSERT_EQ(ret, DMError::DM_OK);
483 }
484 }
485
486 /**
487 * @tc.name: SetSpecifiedScreenPower
488 * @tc.desc: test SetSpecifiedScreenPower
489 * @tc.type: FUNC
490 */
491 HWTEST_F(DisplayManagerAdapterTest, SetSpecifiedScreenPower, Function | SmallTest | Level2)
492 {
493 ScreenPowerState state = ScreenPowerState{0};
494 PowerStateChangeReason reason = PowerStateChangeReason{0};
495 bool ret = SingletonContainer::Get<ScreenManagerAdapter>().SetSpecifiedScreenPower(0, state, reason);
496 if (SceneBoardJudgement::IsSceneBoardEnabled()) {
497 ASSERT_TRUE(ret);
498 } else {
499 ASSERT_FALSE(ret);
500 }
501 }
502
503 /**
504 * @tc.name: SetOrientation
505 * @tc.desc: SetOrientation success
506 * @tc.type: FUNC
507 */
508 HWTEST_F(DisplayManagerAdapterTest, SetOrientation, Function | SmallTest | Level2)
509 {
510 Orientation orientation = Orientation{0};
511 DMError err = SingletonContainer::Get<ScreenManagerAdapter>().SetOrientation(0, orientation);
512 if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
513 ASSERT_EQ(err, DMError::DM_OK);
514 } else {
515 ASSERT_EQ(err, DMError::DM_OK);
516 }
517 }
518
519 /**
520 * @tc.name: WakeUpBegin
521 * @tc.desc: test WakeUpBegin
522 * @tc.type: FUNC
523 */
524 HWTEST_F(DisplayManagerAdapterTest, WakeUpBegin, Function | SmallTest | Level2)
525 {
526 PowerStateChangeReason reason = PowerStateChangeReason{0};
527 bool ret = SingletonContainer::Get<DisplayManagerAdapter>().WakeUpBegin(reason);
528 if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
529 ASSERT_TRUE(ret);
530 } else {
531 ASSERT_TRUE(ret);
532 }
533 }
534
535 /**
536 * @tc.name: WakeUpEnd
537 * @tc.desc: test WakeUpEnd
538 * @tc.type: FUNC
539 */
540 HWTEST_F(DisplayManagerAdapterTest, WakeUpEnd, Function | SmallTest | Level2)
541 {
542 bool ret = SingletonContainer::Get<DisplayManagerAdapter>().WakeUpEnd();
543 if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
544 ASSERT_TRUE(ret);
545 } else {
546 ASSERT_TRUE(ret);
547 }
548 }
549
550 /**
551 * @tc.name: SuspendBegin
552 * @tc.desc: test SuspendBegin
553 * @tc.type: FUNC
554 */
555 HWTEST_F(DisplayManagerAdapterTest, SuspendBegin, Function | SmallTest | Level2)
556 {
557 PowerStateChangeReason reason = PowerStateChangeReason{0};
558 bool ret = SingletonContainer::Get<DisplayManagerAdapter>().SuspendBegin(reason);
559 if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
560 ASSERT_TRUE(ret);
561 } else {
562 ASSERT_TRUE(ret);
563 }
564 }
565
566 /**
567 * @tc.name: SuspendEnd
568 * @tc.desc: test SuspendEnd
569 * @tc.type: FUNC
570 */
571 HWTEST_F(DisplayManagerAdapterTest, SuspendEnd, Function | SmallTest | Level2)
572 {
573 bool ret = SingletonContainer::Get<DisplayManagerAdapter>().SuspendEnd();
574 if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
575 ASSERT_TRUE(ret);
576 } else {
577 ASSERT_TRUE(ret);
578 }
579 }
580
581 /**
582 * @tc.name: SetDisplayState
583 * @tc.desc: test SetDisplayState
584 * @tc.type: FUNC
585 */
586 HWTEST_F(DisplayManagerAdapterTest, SetDisplayState, Function | SmallTest | Level2)
587 {
588 DisplayState state = DisplayState{1};
589 bool ret = SingletonContainer::Get<DisplayManagerAdapter>().SetDisplayState(state);
590 if (SceneBoardJudgement::IsSceneBoardEnabled()) {
591 ASSERT_TRUE(ret);
592 } else {
593 ASSERT_FALSE(ret);
594 }
595 }
596
597 /**
598 * @tc.name: MakeMirror
599 * @tc.desc: test success
600 * @tc.type: FUNC
601 */
602 HWTEST_F(DisplayManagerAdapterTest, MakeMirror, Function | SmallTest | Level2)
603 {
604 std::vector<ScreenId> mirrorScreenId;
605 ScreenId screenGroupId;
606 DMError err = SingletonContainer::Get<ScreenManagerAdapter>().MakeMirror(0,
607 mirrorScreenId, screenGroupId);
608 ASSERT_EQ(err, DMError::DM_ERROR_INVALID_PARAM);
609 }
610
611 /**
612 * @tc.name: StopMirror
613 * @tc.desc: test success
614 * @tc.type: FUNC
615 */
616 HWTEST_F(DisplayManagerAdapterTest, StopMirror, Function | SmallTest | Level2)
617 {
618 std::vector<ScreenId> mirrorScreenIds;
619 DMError err = SingletonContainer::Get<ScreenManagerAdapter>().StopMirror(mirrorScreenIds);
620 ASSERT_EQ(err, DMError::DM_OK);
621 }
622
623 /**
624 * @tc.name: HasPrivateWindow
625 * @tc.desc: test success
626 * @tc.type: FUNC
627 */
628 HWTEST_F(DisplayManagerAdapterTest, HasPrivateWindow, Function | SmallTest | Level2)
629 {
630 bool hasPrivateWindow = false;
631 DMError err = SingletonContainer::Get<DisplayManagerAdapter>().HasPrivateWindow(0,
632 hasPrivateWindow);
633 if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
634 ASSERT_EQ(DMError::DM_OK, err);
635 } else {
636 ASSERT_EQ(DMError::DM_OK, err);
637 }
638 }
639
640 /**
641 * @tc.name: AddSurfaceNodeToDisplay
642 * @tc.desc: test success
643 * @tc.type: FUNC
644 */
645 HWTEST_F(DisplayManagerAdapterTest, AddSurfaceNodeToDisplay, Function | SmallTest | Level2)
646 {
647 std::shared_ptr<class RSSurfaceNode> surfaceNode;
648 DMError err = SingletonContainer::Get<DisplayManagerAdapter>().AddSurfaceNodeToDisplay(0,
649 surfaceNode);
650 if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
651 ASSERT_EQ(DMError::DM_ERROR_IPC_FAILED, err);
652 } else {
653 ASSERT_EQ(DMError::DM_OK, err);
654 }
655 }
656
657 /**
658 * @tc.name: RemoveSurfaceNodeFromDisplay
659 * @tc.desc: test success
660 * @tc.type: FUNC
661 */
662 HWTEST_F(DisplayManagerAdapterTest, RemoveSurfaceNodeFromDisplay, Function | SmallTest | Level2)
663 {
664 std::shared_ptr<class RSSurfaceNode> surfaceNode;
665 DMError err = SingletonContainer::Get<DisplayManagerAdapter>().RemoveSurfaceNodeFromDisplay(0,
666 surfaceNode);
667 if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
668 ASSERT_EQ(DMError::DM_ERROR_IPC_FAILED, err);
669 } else {
670 ASSERT_EQ(DMError::DM_OK, err);
671 }
672 }
673
674 /**
675 * @tc.name: MakeExpand
676 * @tc.desc: test success
677 * @tc.type: FUNC
678 */
679 HWTEST_F(DisplayManagerAdapterTest, MakeExpand, Function | SmallTest | Level2)
680 {
681 std::vector<ScreenId> screenId;
682 std::vector<Point> startPoint;
683 ScreenId screenGroupId;
684 DMError err = SingletonContainer::Get<ScreenManagerAdapter>().MakeExpand(screenId,
685 startPoint, screenGroupId);
686 ASSERT_EQ(err, DMError::DM_ERROR_INVALID_PARAM);
687 }
688
689 /**
690 * @tc.name: StopExpand
691 * @tc.desc: test success
692 * @tc.type: FUNC
693 */
694 HWTEST_F(DisplayManagerAdapterTest, StopExpand, Function | SmallTest | Level2)
695 {
696 std::vector<ScreenId> expandScreenIds;
697 DMError err = SingletonContainer::Get<ScreenManagerAdapter>().StopExpand(expandScreenIds);
698 ASSERT_EQ(err, DMError::DM_OK);
699 }
700
701 /**
702 * @tc.name: RemoveVirtualScreenFromGroup
703 * @tc.desc: test success
704 * @tc.type: FUNC
705 */
706 HWTEST_F(DisplayManagerAdapterTest, RemoveVirtualScreenFromGroup, Function | SmallTest | Level2)
707 {
708 std::vector<ScreenId> screens;
709 int resultValue = 0;
__anon08e8dacd0202() 710 std::function<void()> func = [&]() {
711 SingletonContainer::Get<ScreenManagerAdapter>().RemoveVirtualScreenFromGroup(screens);
712 resultValue = 1;
713 };
714 func();
715 ASSERT_EQ(resultValue, 1);
716 }
717
718 /**
719 * @tc.name: SetScreenActiveMode
720 * @tc.desc: test success
721 * @tc.type: FUNC
722 */
723 HWTEST_F(DisplayManagerAdapterTest, SetScreenActiveMode, Function | SmallTest | Level2)
724 {
725 VirtualScreenOption defaultOption = {"virtualScreen02", 480, 320, 2.0, nullptr, 0};
726 ScreenId id = ScreenManager::GetInstance().CreateVirtualScreen(defaultOption);
727 DMError err = SingletonContainer::Get<ScreenManagerAdapter>().SetScreenActiveMode(id, 100);
728 ASSERT_EQ(err, DMError::DM_OK);
729 SingletonContainer::Get<ScreenManagerAdapter>().DestroyVirtualScreen(id);
730 }
731
732 /**
733 * @tc.name: SetVirtualPixelRatio
734 * @tc.desc: test success
735 * @tc.type: FUNC
736 */
737 HWTEST_F(DisplayManagerAdapterTest, SetVirtualPixelRatio, Function | SmallTest | Level2)
738 {
739 VirtualScreenOption defaultOption = {"virtualScreen03", 480, 320, 2.0, nullptr, 0};
740 ScreenId id = ScreenManager::GetInstance().CreateVirtualScreen(defaultOption);
741 DMError err = SingletonContainer::Get<ScreenManagerAdapter>().SetVirtualPixelRatio(id, 0);
742 ASSERT_EQ(err, DMError::DM_OK);
743 SingletonContainer::Get<ScreenManagerAdapter>().DestroyVirtualScreen(id);
744 }
745
746 /**
747 * @tc.name: SetResolution
748 * @tc.desc: test success
749 * @tc.type: FUNC
750 */
751 HWTEST_F(DisplayManagerAdapterTest, SetResolution, Function | SmallTest | Level2)
752 {
753 VirtualScreenOption defaultOption = {"virtualScreen04", 480, 320, 2.0, nullptr, 0};
754 ScreenId id = ScreenManager::GetInstance().CreateVirtualScreen(defaultOption);
755 DMError err = SingletonContainer::Get<ScreenManagerAdapter>().SetResolution(id, 70, 100, 1);
756 if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
757 ASSERT_EQ(err, DMError::DM_ERROR_IPC_FAILED);
758 } else {
759 ASSERT_EQ(err, DMError::DM_OK);
760 }
761 SingletonContainer::Get<ScreenManagerAdapter>().DestroyVirtualScreen(id);
762 }
763
764 /**
765 * @tc.name: ResizeVirtualScreen
766 * @tc.desc: test success
767 * @tc.type: FUNC
768 */
769 HWTEST_F(DisplayManagerAdapterTest, ResizeVirtualScreen, Function | SmallTest | Level2)
770 {
771 DMError err = SingletonContainer::Get<ScreenManagerAdapter>().ResizeVirtualScreen(0, 70, 100);
772 if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
773 ASSERT_EQ(err, DMError::DM_OK);
774 } else {
775 ASSERT_EQ(err, DMError::DM_OK);
776 }
777 }
778
779 /**
780 * @tc.name: MakeUniqueScreen
781 * @tc.desc: test success
782 * @tc.type: FUNC
783 */
784 HWTEST_F(DisplayManagerAdapterTest, MakeUniqueScreen, Function | SmallTest | Level2)
785 {
786 std::vector<ScreenId> screenIds;
787 DMError err = SingletonContainer::Get<ScreenManagerAdapter>().MakeUniqueScreen(screenIds);
788 if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
789 ASSERT_EQ(err, DMError::DM_OK);
790 } else {
791 ASSERT_EQ(err, DMError::DM_ERROR_INVALID_PARAM);
792 }
793 }
794
795 /**
796 * @tc.name: GetAvailableArea
797 * @tc.desc: test success
798 * @tc.type: FUNC
799 */
800 HWTEST_F(DisplayManagerAdapterTest, GetAvailableArea, Function | SmallTest | Level2)
801 {
802 DMRect area;
803 DMError err = SingletonContainer::Get<DisplayManagerAdapter>().GetAvailableArea(0, area);
804 if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
805 ASSERT_EQ(err, DMError::DM_ERROR_DEVICE_NOT_SUPPORT);
806 } else {
807 ASSERT_EQ(err, DMError::DM_OK);
808 }
809 }
810
811 /**
812 * @tc.name: GetAllDisplayPhysicalResolution
813 * @tc.desc: test success
814 * @tc.type: FUNC
815 */
816 HWTEST_F(DisplayManagerAdapterTest, GetAllDisplayPhysicalResolution, Function | SmallTest | Level2)
817 {
818 std::vector<DisplayPhysicalResolution> allSize =
819 SingletonContainer::Get<DisplayManagerAdapter>().GetAllDisplayPhysicalResolution();
820 if (SceneBoardJudgement::IsSceneBoardEnabled()) {
821 ASSERT_TRUE(!allSize.empty());
822 } else {
823 ASSERT_TRUE(!allSize.empty());
824 }
825 }
826
827 /**
828 * @tc.name: SetDisplayScale
829 * @tc.desc: SetDisplayScale test
830 * @tc.type: FUNC
831 */
832 HWTEST_F(DisplayManagerAdapterTest, SetDisplayScale, Function | SmallTest | Level2)
833 {
834 DisplayManagerAdapter& displayManagerAdapter = SingletonContainer::Get<DisplayManagerAdapter>();
835 const float scaleX = 1.0f;
836 const float scaleY = 1.0f;
837 const float pivotX = 0.5f;
838 const float pivotY = 0.5f;
839 sptr<DisplayInfo> displayInfo = displayManagerAdapter.GetDefaultDisplayInfo();
840 ASSERT_NE(displayInfo, nullptr);
841 ScreenId screenId = displayInfo->GetScreenId();
842 displayManagerAdapter.SetDisplayScale(screenId, scaleX, scaleY, pivotX, pivotY);
843 }
844
845 /**
846 * @tc.name: GetPrimaryDisplayInfo
847 * @tc.desc: GetPrimaryDisplayInfo test
848 * @tc.type: FUNC
849 */
850 HWTEST_F(DisplayManagerAdapterTest, GetPrimaryDisplayInfo, Function | SmallTest | Level2)
851 {
852 DisplayManagerAdapter& displayManagerAdapter = SingletonContainer::Get<DisplayManagerAdapter>();
853 sptr<DisplayInfo> displayInfo = displayManagerAdapter.GetPrimaryDisplayInfo();
854 ASSERT_NE(displayInfo, nullptr);
855 }
856 }
857 }
858 }
859