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 */
HWTEST_F(DisplayManagerAdapterTest, GetDisplayInfo, Function | SmallTest | Level2)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 */
HWTEST_F(DisplayManagerAdapterTest, GetCutoutInfo, Function | SmallTest | Level2)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 */
HWTEST_F(DisplayManagerAdapterTest, GetScreenSupportedColorGamuts, Function | SmallTest | Level2)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 */
HWTEST_F(DisplayManagerAdapterTest, SetScreenColorGamut, Function | SmallTest | Level2)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 */
HWTEST_F(DisplayManagerAdapterTest, GetScreenColorGamut, Function | SmallTest | Level2)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 */
HWTEST_F(DisplayManagerAdapterTest, GetScreenGamutMap, Function | SmallTest | Level2)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 */
HWTEST_F(DisplayManagerAdapterTest, SetScreenGamutMap, Function | SmallTest | Level2)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 */
HWTEST_F(DisplayManagerAdapterTest, SetScreenColorTransform, Function | SmallTest | Level2)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 */
HWTEST_F(DisplayManagerAdapterTest, SetFreeze, Function | SmallTest | Level2)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 */
HWTEST_F(DisplayManagerAdapterTest, GetScreenGroupInfoById, Function | SmallTest | Level2)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 */
HWTEST_F(DisplayManagerAdapterTest, GetScreenInfo, Function | SmallTest | Level2)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 */
HWTEST_F(DisplayManagerAdapterTest, OnRemoteDied, Function | SmallTest | Level2)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 */
HWTEST_F(DisplayManagerAdapterTest, OnRemoteDied01, Function | SmallTest | Level2)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 */
HWTEST_F(DisplayManagerAdapterTest, Clear, Function | SmallTest | Level2)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 */
HWTEST_F(DisplayManagerAdapterTest, Clear01, Function | SmallTest | Level2)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 */
HWTEST_F(DisplayManagerAdapterTest, DisableMirror, Function | SmallTest | Level2)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 */
HWTEST_F(DisplayManagerAdapterTest, HasImmersiveWindow, Function | SmallTest | Level2)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 */
HWTEST_F(DisplayManagerAdapterTest, GetPixelFormat, Function | SmallTest | Level2)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 */
HWTEST_F(DisplayManagerAdapterTest, SetPixelFormat, Function | SmallTest | Level2)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 */
HWTEST_F(DisplayManagerAdapterTest, GetSupportedHDRFormats, Function | SmallTest | Level2)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 */
HWTEST_F(DisplayManagerAdapterTest, GetScreenHDRFormat, Function | SmallTest | Level2)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 */
HWTEST_F(DisplayManagerAdapterTest, SetScreenHDRFormat, Function | SmallTest | Level2)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 */
HWTEST_F(DisplayManagerAdapterTest, GetSupportedColorSpaces, Function | SmallTest | Level2)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 */
HWTEST_F(DisplayManagerAdapterTest, GetScreenColorSpace, Function | SmallTest | Level2)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 */
HWTEST_F(DisplayManagerAdapterTest, SetScreenColorSpace, Function | SmallTest | Level2)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 */
HWTEST_F(DisplayManagerAdapterTest, DestroyVirtualScreen, Function | SmallTest | Level2)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 */
HWTEST_F(DisplayManagerAdapterTest, SetVirtualMirrorScreenCanvasRotation, Function | SmallTest | Level2)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 */
HWTEST_F(DisplayManagerAdapterTest, SetScreenRotationLocked, Function | SmallTest | Level2)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 */
HWTEST_F(DisplayManagerAdapterTest, IsScreenRotationLocked, Function | SmallTest | Level2)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 */
HWTEST_F(DisplayManagerAdapterTest, SetSpecifiedScreenPower, Function | SmallTest | Level2)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 */
HWTEST_F(DisplayManagerAdapterTest, SetOrientation, Function | SmallTest | Level2)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 */
HWTEST_F(DisplayManagerAdapterTest, WakeUpBegin, Function | SmallTest | Level2)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 */
HWTEST_F(DisplayManagerAdapterTest, WakeUpEnd, Function | SmallTest | Level2)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 */
HWTEST_F(DisplayManagerAdapterTest, SuspendBegin, Function | SmallTest | Level2)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 */
HWTEST_F(DisplayManagerAdapterTest, SuspendEnd, Function | SmallTest | Level2)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 */
HWTEST_F(DisplayManagerAdapterTest, SetDisplayState, Function | SmallTest | Level2)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 } else {
589 ASSERT_FALSE(ret);
590 }
591 }
592
593 /**
594 * @tc.name: MakeMirror
595 * @tc.desc: test success
596 * @tc.type: FUNC
597 */
HWTEST_F(DisplayManagerAdapterTest, MakeMirror, Function | SmallTest | Level2)598 HWTEST_F(DisplayManagerAdapterTest, MakeMirror, Function | SmallTest | Level2)
599 {
600 std::vector<ScreenId> mirrorScreenId;
601 ScreenId screenGroupId;
602 DMError err = SingletonContainer::Get<ScreenManagerAdapter>().MakeMirror(0,
603 mirrorScreenId, screenGroupId);
604 ASSERT_EQ(err, DMError::DM_ERROR_INVALID_PARAM);
605 }
606
607 /**
608 * @tc.name: StopMirror
609 * @tc.desc: test success
610 * @tc.type: FUNC
611 */
HWTEST_F(DisplayManagerAdapterTest, StopMirror, Function | SmallTest | Level2)612 HWTEST_F(DisplayManagerAdapterTest, StopMirror, Function | SmallTest | Level2)
613 {
614 std::vector<ScreenId> mirrorScreenIds;
615 DMError err = SingletonContainer::Get<ScreenManagerAdapter>().StopMirror(mirrorScreenIds);
616 ASSERT_EQ(err, DMError::DM_OK);
617 }
618
619 /**
620 * @tc.name: HasPrivateWindow
621 * @tc.desc: test success
622 * @tc.type: FUNC
623 */
HWTEST_F(DisplayManagerAdapterTest, HasPrivateWindow, Function | SmallTest | Level2)624 HWTEST_F(DisplayManagerAdapterTest, HasPrivateWindow, Function | SmallTest | Level2)
625 {
626 bool hasPrivateWindow = false;
627 DMError err = SingletonContainer::Get<DisplayManagerAdapter>().HasPrivateWindow(0,
628 hasPrivateWindow);
629 if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
630 ASSERT_EQ(DMError::DM_OK, err);
631 } else {
632 ASSERT_EQ(DMError::DM_OK, err);
633 }
634 }
635
636 /**
637 * @tc.name: AddSurfaceNodeToDisplay
638 * @tc.desc: test success
639 * @tc.type: FUNC
640 */
HWTEST_F(DisplayManagerAdapterTest, AddSurfaceNodeToDisplay, Function | SmallTest | Level2)641 HWTEST_F(DisplayManagerAdapterTest, AddSurfaceNodeToDisplay, Function | SmallTest | Level2)
642 {
643 std::shared_ptr<class RSSurfaceNode> surfaceNode;
644 DMError err = SingletonContainer::Get<DisplayManagerAdapter>().AddSurfaceNodeToDisplay(0,
645 surfaceNode);
646 if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
647 ASSERT_EQ(DMError::DM_ERROR_IPC_FAILED, err);
648 } else {
649 ASSERT_EQ(DMError::DM_OK, err);
650 }
651 }
652
653 /**
654 * @tc.name: RemoveSurfaceNodeFromDisplay
655 * @tc.desc: test success
656 * @tc.type: FUNC
657 */
HWTEST_F(DisplayManagerAdapterTest, RemoveSurfaceNodeFromDisplay, Function | SmallTest | Level2)658 HWTEST_F(DisplayManagerAdapterTest, RemoveSurfaceNodeFromDisplay, Function | SmallTest | Level2)
659 {
660 std::shared_ptr<class RSSurfaceNode> surfaceNode;
661 DMError err = SingletonContainer::Get<DisplayManagerAdapter>().RemoveSurfaceNodeFromDisplay(0,
662 surfaceNode);
663 if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
664 ASSERT_EQ(DMError::DM_ERROR_IPC_FAILED, err);
665 } else {
666 ASSERT_EQ(DMError::DM_OK, err);
667 }
668 }
669
670 /**
671 * @tc.name: MakeExpand
672 * @tc.desc: test success
673 * @tc.type: FUNC
674 */
HWTEST_F(DisplayManagerAdapterTest, MakeExpand, Function | SmallTest | Level2)675 HWTEST_F(DisplayManagerAdapterTest, MakeExpand, Function | SmallTest | Level2)
676 {
677 std::vector<ScreenId> screenId;
678 std::vector<Point> startPoint;
679 ScreenId screenGroupId;
680 DMError err = SingletonContainer::Get<ScreenManagerAdapter>().MakeExpand(screenId,
681 startPoint, screenGroupId);
682 ASSERT_EQ(err, DMError::DM_ERROR_INVALID_PARAM);
683 }
684
685 /**
686 * @tc.name: StopExpand
687 * @tc.desc: test success
688 * @tc.type: FUNC
689 */
HWTEST_F(DisplayManagerAdapterTest, StopExpand, Function | SmallTest | Level2)690 HWTEST_F(DisplayManagerAdapterTest, StopExpand, Function | SmallTest | Level2)
691 {
692 std::vector<ScreenId> expandScreenIds;
693 DMError err = SingletonContainer::Get<ScreenManagerAdapter>().StopExpand(expandScreenIds);
694 ASSERT_EQ(err, DMError::DM_OK);
695 }
696
697 /**
698 * @tc.name: RemoveVirtualScreenFromGroup
699 * @tc.desc: test success
700 * @tc.type: FUNC
701 */
HWTEST_F(DisplayManagerAdapterTest, RemoveVirtualScreenFromGroup, Function | SmallTest | Level2)702 HWTEST_F(DisplayManagerAdapterTest, RemoveVirtualScreenFromGroup, Function | SmallTest | Level2)
703 {
704 std::vector<ScreenId> screens;
705 int resultValue = 0;
706 std::function<void()> func = [&]() {
707 SingletonContainer::Get<ScreenManagerAdapter>().RemoveVirtualScreenFromGroup(screens);
708 resultValue = 1;
709 };
710 func();
711 ASSERT_EQ(resultValue, 1);
712 }
713
714 /**
715 * @tc.name: SetScreenActiveMode
716 * @tc.desc: test success
717 * @tc.type: FUNC
718 */
HWTEST_F(DisplayManagerAdapterTest, SetScreenActiveMode, Function | SmallTest | Level2)719 HWTEST_F(DisplayManagerAdapterTest, SetScreenActiveMode, Function | SmallTest | Level2)
720 {
721 VirtualScreenOption defaultOption = {"virtualScreen02", 480, 320, 2.0, nullptr, 0};
722 ScreenId id = ScreenManager::GetInstance().CreateVirtualScreen(defaultOption);
723 DMError err = SingletonContainer::Get<ScreenManagerAdapter>().SetScreenActiveMode(id, 100);
724 ASSERT_EQ(err, DMError::DM_OK);
725 SingletonContainer::Get<ScreenManagerAdapter>().DestroyVirtualScreen(id);
726 }
727
728 /**
729 * @tc.name: SetVirtualPixelRatio
730 * @tc.desc: test success
731 * @tc.type: FUNC
732 */
HWTEST_F(DisplayManagerAdapterTest, SetVirtualPixelRatio, Function | SmallTest | Level2)733 HWTEST_F(DisplayManagerAdapterTest, SetVirtualPixelRatio, Function | SmallTest | Level2)
734 {
735 VirtualScreenOption defaultOption = {"virtualScreen03", 480, 320, 2.0, nullptr, 0};
736 ScreenId id = ScreenManager::GetInstance().CreateVirtualScreen(defaultOption);
737 DMError err = SingletonContainer::Get<ScreenManagerAdapter>().SetVirtualPixelRatio(id, 0);
738 ASSERT_EQ(err, DMError::DM_OK);
739 SingletonContainer::Get<ScreenManagerAdapter>().DestroyVirtualScreen(id);
740 }
741
742 /**
743 * @tc.name: SetResolution
744 * @tc.desc: test success
745 * @tc.type: FUNC
746 */
HWTEST_F(DisplayManagerAdapterTest, SetResolution, Function | SmallTest | Level2)747 HWTEST_F(DisplayManagerAdapterTest, SetResolution, Function | SmallTest | Level2)
748 {
749 VirtualScreenOption defaultOption = {"virtualScreen04", 480, 320, 2.0, nullptr, 0};
750 ScreenId id = ScreenManager::GetInstance().CreateVirtualScreen(defaultOption);
751 DMError err = SingletonContainer::Get<ScreenManagerAdapter>().SetResolution(id, 70, 100, 1);
752 if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
753 ASSERT_EQ(err, DMError::DM_ERROR_IPC_FAILED);
754 } else {
755 ASSERT_EQ(err, DMError::DM_OK);
756 }
757 SingletonContainer::Get<ScreenManagerAdapter>().DestroyVirtualScreen(id);
758 }
759
760 /**
761 * @tc.name: ResizeVirtualScreen
762 * @tc.desc: test success
763 * @tc.type: FUNC
764 */
HWTEST_F(DisplayManagerAdapterTest, ResizeVirtualScreen, Function | SmallTest | Level2)765 HWTEST_F(DisplayManagerAdapterTest, ResizeVirtualScreen, Function | SmallTest | Level2)
766 {
767 DMError err = SingletonContainer::Get<ScreenManagerAdapter>().ResizeVirtualScreen(0, 70, 100);
768 if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
769 ASSERT_EQ(err, DMError::DM_OK);
770 } else {
771 ASSERT_EQ(err, DMError::DM_OK);
772 }
773 }
774
775 /**
776 * @tc.name: MakeUniqueScreen
777 * @tc.desc: test success
778 * @tc.type: FUNC
779 */
HWTEST_F(DisplayManagerAdapterTest, MakeUniqueScreen, Function | SmallTest | Level2)780 HWTEST_F(DisplayManagerAdapterTest, MakeUniqueScreen, Function | SmallTest | Level2)
781 {
782 std::vector<ScreenId> screenIds;
783 DMError err = SingletonContainer::Get<ScreenManagerAdapter>().MakeUniqueScreen(screenIds);
784 if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
785 ASSERT_EQ(err, DMError::DM_OK);
786 } else {
787 ASSERT_EQ(err, DMError::DM_ERROR_INVALID_PARAM);
788 }
789 }
790
791 /**
792 * @tc.name: GetAvailableArea
793 * @tc.desc: test success
794 * @tc.type: FUNC
795 */
HWTEST_F(DisplayManagerAdapterTest, GetAvailableArea, Function | SmallTest | Level2)796 HWTEST_F(DisplayManagerAdapterTest, GetAvailableArea, Function | SmallTest | Level2)
797 {
798 DMRect area;
799 DMError err = SingletonContainer::Get<DisplayManagerAdapter>().GetAvailableArea(0, area);
800 if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
801 ASSERT_EQ(err, DMError::DM_ERROR_DEVICE_NOT_SUPPORT);
802 } else {
803 ASSERT_EQ(err, DMError::DM_OK);
804 }
805 }
806
807 /**
808 * @tc.name: GetAllDisplayPhysicalResolution
809 * @tc.desc: test success
810 * @tc.type: FUNC
811 */
HWTEST_F(DisplayManagerAdapterTest, GetAllDisplayPhysicalResolution, Function | SmallTest | Level2)812 HWTEST_F(DisplayManagerAdapterTest, GetAllDisplayPhysicalResolution, Function | SmallTest | Level2)
813 {
814 std::vector<DisplayPhysicalResolution> allSize =
815 SingletonContainer::Get<DisplayManagerAdapter>().GetAllDisplayPhysicalResolution();
816 ASSERT_TRUE(!allSize.empty());
817 }
818
819 /**
820 * @tc.name: SetDisplayScale
821 * @tc.desc: SetDisplayScale test
822 * @tc.type: FUNC
823 */
HWTEST_F(DisplayManagerAdapterTest, SetDisplayScale, Function | SmallTest | Level2)824 HWTEST_F(DisplayManagerAdapterTest, SetDisplayScale, Function | SmallTest | Level2)
825 {
826 DisplayManagerAdapter& displayManagerAdapter = SingletonContainer::Get<DisplayManagerAdapter>();
827 const float scaleX = 1.0f;
828 const float scaleY = 1.0f;
829 const float pivotX = 0.5f;
830 const float pivotY = 0.5f;
831 sptr<DisplayInfo> displayInfo = displayManagerAdapter.GetDefaultDisplayInfo();
832 ASSERT_NE(displayInfo, nullptr);
833 ScreenId screenId = displayInfo->GetScreenId();
834 displayManagerAdapter.SetDisplayScale(screenId, scaleX, scaleY, pivotX, pivotY);
835 }
836 }
837 }
838 }
839