• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 <common/rs_rect.h>
17 #include <gtest/gtest.h>
18 #include <iremote_broker.h>
19 #include <message_option.h>
20 #include <message_parcel.h>
21 #include <transaction/rs_marshalling_helper.h>
22 
23 #include "display_manager_adapter.h"
24 #include "display_manager_agent_default.h"
25 #include "scene_board_judgement.h"
26 #include "session_manager/include/scene_session_manager.h"
27 #include "session_manager/include/zidl/scene_session_manager_interface.h"
28 #include "window_manager_agent.h"
29 #include "zidl/screen_session_manager_proxy.h"
30 #include "zidl/window_manager_agent_interface.h"
31 
32 using namespace testing;
33 using namespace testing::ext;
34 namespace OHOS {
35 namespace Rosen {
36 class ScreenSessionManagerProxyUtTest : public testing::Test {
37 public:
38     static void SetUpTestCase();
39     static void TearDownTestCase();
40     void SetUp() override;
41     void TearDown() override;
42 };
43 
SetUpTestCase()44 void ScreenSessionManagerProxyUtTest::SetUpTestCase()
45 {
46 }
47 
TearDownTestCase()48 void ScreenSessionManagerProxyUtTest::TearDownTestCase()
49 {
50 }
51 
SetUp()52 void ScreenSessionManagerProxyUtTest::SetUp()
53 {
54 }
55 
TearDown()56 void ScreenSessionManagerProxyUtTest::TearDown()
57 {
58 }
59 
60 namespace {
61 /**
62  * @tc.name: SetPrivacyStateByDisplayId
63  * @tc.desc: SetPrivacyStateByDisplayId
64  * @tc.type: FUNC
65  */
66 HWTEST_F(ScreenSessionManagerProxyUtTest, SetPrivacyStateByDisplayId, Function | SmallTest | Level1)
67 {
68     SingletonContainer::Get<ScreenManagerAdapter>().InitDMSProxy();
69     DisplayId id = 0;
70     bool hasPrivate = false;
71 
72     sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject();
73     sptr<ScreenSessionManagerProxy> screenSessionManagerProxy = new ScreenSessionManagerProxy(impl);
74 
75     int resultValue = 0;
76     std::function<void()> func = [&]()
__anon38dd45020202() 77     {
78         screenSessionManagerProxy->SetPrivacyStateByDisplayId(id, hasPrivate);
79         resultValue = 1;
80     };
81     func();
82     ASSERT_EQ(resultValue, 1);
83 }
84 
85 /**
86  * @tc.name: SetScreenPrivacyWindowList
87  * @tc.desc: SetScreenPrivacyWindowList
88  * @tc.type: FUNC
89  */
90 HWTEST_F(ScreenSessionManagerProxyUtTest, SetScreenPrivacyWindowList, Function | SmallTest | Level1)
91 {
92     SingletonContainer::Get<ScreenManagerAdapter>().InitDMSProxy();
93     DisplayId id = 0;
94     std::vector<std::string> privacyWindowList{"win0", "win1"};
95 
96     sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject();
97     sptr<ScreenSessionManagerProxy> screenSessionManagerProxy = new ScreenSessionManagerProxy(impl);
98 
99     int resultValue = 0;
100     std::function<void()> func = [&]()
__anon38dd45020302() 101     {
102         screenSessionManagerProxy->SetScreenPrivacyWindowList(id, privacyWindowList);
103         resultValue = 1;
104     };
105     func();
106     ASSERT_EQ(resultValue, 1);
107 }
108 
109 /**
110  * @tc.name: SetVirtualScreenBlackList
111  * @tc.desc: SetVirtualScreenBlackList
112  * @tc.type: FUNC
113  */
114 HWTEST_F(ScreenSessionManagerProxyUtTest, SetVirtualScreenBlackList, Function | SmallTest | Level1)
115 {
116     SingletonContainer::Get<ScreenManagerAdapter>().InitDMSProxy();
117     ScreenId id = 1001;
118     std::vector<uint64_t> windowIdList{10, 20, 30};
119 
120     sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject();
121     sptr<ScreenSessionManagerProxy> screenSessionManagerProxy = new ScreenSessionManagerProxy(impl);
122 
123     int resultValue = 0;
124     std::function<void()> func = [&]()
__anon38dd45020402() 125     {
126         screenSessionManagerProxy->SetVirtualScreenBlackList(id, windowIdList);
127         resultValue = 1;
128     };
129     func();
130     ASSERT_EQ(resultValue, 1);
131 }
132 
133 /**
134  * @tc.name: ProxyForFreeze
135  * @tc.desc: ProxyForFreeze
136  * @tc.type: FUNC
137  */
138 HWTEST_F(ScreenSessionManagerProxyUtTest, ProxyForFreeze, Function | SmallTest | Level1)
139 {
140     SingletonContainer::Get<ScreenManagerAdapter>().InitDMSProxy();
141     const std::set<int32_t>& pidList = {1, 2, 3};
142     bool isProxy = true;
143 
144     sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject();
145     sptr<ScreenSessionManagerProxy> screenSessionManagerProxy = new ScreenSessionManagerProxy(impl);
146 
147     ASSERT_EQ(DMError::DM_ERROR_IPC_FAILED,
148             screenSessionManagerProxy->ProxyForFreeze(pidList, isProxy));
149 }
150 
151 /**
152  * @tc.name: SetVirtualScreenStatus
153  * @tc.desc: SetVirtualScreenStatus
154  * @tc.type: FUNC
155  */
156 HWTEST_F(ScreenSessionManagerProxyUtTest, SetVirtualScreenStatus, Function | SmallTest | Level1)
157 {
158     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
159         GTEST_SKIP() << "SceneBoard is not enabled, skipping test.";
160     }
161     SingletonContainer::Get<ScreenManagerAdapter>().InitDMSProxy();
162     ScreenId id = 1001;
163     VirtualScreenStatus screenStatus = VirtualScreenStatus::VIRTUAL_SCREEN_PAUSE;
164 
165     sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject();
166     sptr<ScreenSessionManagerProxy> screenSessionManagerProxy = new ScreenSessionManagerProxy(impl);
167 
168     bool expectation = true;
169 
170     EXPECT_EQ(expectation, screenSessionManagerProxy->SetVirtualScreenStatus(id, screenStatus));
171 }
172 
173 /**
174  * @tc.name: SetVirtualScreenSecurityExemption
175  * @tc.desc: SetVirtualScreenSecurityExemption
176  * @tc.type: FUNC
177  */
178 HWTEST_F(ScreenSessionManagerProxyUtTest, SetVirtualScreenSecurityExemption, Function | SmallTest | Level1)
179 {
180     SingletonContainer::Get<ScreenManagerAdapter>().InitDMSProxy();
181     ScreenId id = 1001;
182     uint32_t pid = 1;
183     std::vector<uint64_t> windowIdList{10, 20, 30};
184 
185     sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject();
186     sptr<ScreenSessionManagerProxy> screenSessionManagerProxy = new ScreenSessionManagerProxy(impl);
187 
188     ASSERT_EQ(DMError::DM_ERROR_IPC_FAILED,
189             screenSessionManagerProxy->SetVirtualScreenSecurityExemption(id, pid, windowIdList));
190 }
191 
192 /**
193  * @tc.name: GetAllDisplayPhysicalResolution
194  * @tc.desc: GetAllDisplayPhysicalResolution
195  * @tc.type: FUNC
196  */
197 HWTEST_F(ScreenSessionManagerProxyUtTest, GetAllDisplayPhysicalResolution, Function | SmallTest | Level1)
198 {
199     SingletonContainer::Get<ScreenManagerAdapter>().InitDMSProxy();
200     sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject();
201     sptr<ScreenSessionManagerProxy> screenSessionManagerProxy = new ScreenSessionManagerProxy(impl);
202 
203     std::vector<DisplayPhysicalResolution> allSize {};
204     std::function<void()> func = [&]()
__anon38dd45020502() 205     {
206         allSize = screenSessionManagerProxy->GetAllDisplayPhysicalResolution();
207     };
208     func();
209 
210     ASSERT_FALSE(!allSize.empty());
211 }
212 
213 /**
214  * @tc.name: GetDefaultDisplayInfo
215  * @tc.desc: GetDefaultDisplayInfo
216  * @tc.type: FUNC
217  */
218 HWTEST_F(ScreenSessionManagerProxyUtTest, GetDefaultDisplayInfo, Function | SmallTest | Level1)
219 {
220     SingletonContainer::Get<ScreenManagerAdapter>().InitDMSProxy();
221 
222     sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject();
223     sptr<ScreenSessionManagerProxy> screenSessionManagerProxy = new ScreenSessionManagerProxy(impl);
224 
225     sptr<DisplayInfo> expectation = nullptr;
226     sptr<DisplayInfo> res = nullptr;
227     std::function<void()> func = [&]()
__anon38dd45020602() 228     {
229         res = screenSessionManagerProxy->GetDefaultDisplayInfo();
230     };
231     func();
232 
233     ASSERT_EQ(res, expectation);
234 }
235 
236 /**
237  * @tc.name: SetScreenActiveMode
238  * @tc.desc: SetScreenActiveMode
239  * @tc.type: FUNC
240  */
241 HWTEST_F(ScreenSessionManagerProxyUtTest, SetScreenActiveMode, Function | SmallTest | Level1)
242 {
243     SingletonContainer::Get<ScreenManagerAdapter>().InitDMSProxy();
244     ScreenId id = 1001;
245     uint32_t modeId = 1;
246 
247     sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject();
248     sptr<ScreenSessionManagerProxy> screenSessionManagerProxy = new ScreenSessionManagerProxy(impl);
249 
250 
251     DMError res = DMError::DM_ERROR_NOT_SYSTEM_APP;
252     std::function<void()> func = [&]()
__anon38dd45020702() 253     {
254         res = screenSessionManagerProxy->SetScreenActiveMode(id, modeId);
255     };
256     func();
257 
258     ASSERT_EQ(res, DMError::DM_ERROR_IPC_FAILED);
259 }
260 
261 /**
262  * @tc.name: SetVirtualPixelRatio
263  * @tc.desc: SetVirtualPixelRatio
264  * @tc.type: FUNC
265  */
266 HWTEST_F(ScreenSessionManagerProxyUtTest, SetVirtualPixelRatio, Function | SmallTest | Level1)
267 {
268     SingletonContainer::Get<ScreenManagerAdapter>().InitDMSProxy();
269     ScreenId id = 1001;
270     float virtualPixelRatio = 1.0;
271 
272     sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject();
273     sptr<ScreenSessionManagerProxy> screenSessionManagerProxy = new ScreenSessionManagerProxy(impl);
274 
275 
276     DMError res = DMError::DM_ERROR_NOT_SYSTEM_APP;
277     std::function<void()> func = [&]()
__anon38dd45020802() 278     {
279         res = screenSessionManagerProxy->SetVirtualPixelRatio(id, virtualPixelRatio);
280     };
281     func();
282 
283     ASSERT_EQ(res, DMError::DM_ERROR_IPC_FAILED);
284 }
285 
286 /**
287  * @tc.name: SetVirtualPixelRatioSystem
288  * @tc.desc: SetVirtualPixelRatioSystem
289  * @tc.type: FUNC
290  */
291 HWTEST_F(ScreenSessionManagerProxyUtTest, SetVirtualPixelRatioSystem, Function | SmallTest | Level1)
292 {
293     SingletonContainer::Get<ScreenManagerAdapter>().InitDMSProxy();
294     ScreenId id = 1001;
295     float virtualPixelRatio = 1.0;
296 
297     sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject();
298     sptr<ScreenSessionManagerProxy> screenSessionManagerProxy = new ScreenSessionManagerProxy(impl);
299 
300 
301     DMError res = DMError::DM_ERROR_NOT_SYSTEM_APP;
302     std::function<void()> func = [&]()
__anon38dd45020902() 303     {
304         res = screenSessionManagerProxy->SetVirtualPixelRatioSystem(id, virtualPixelRatio);
305     };
306     func();
307 
308     ASSERT_EQ(res, DMError::DM_ERROR_IPC_FAILED);
309 }
310 
311 /**
312  * @tc.name: SetResolution
313  * @tc.desc: SetResolution
314  * @tc.type: FUNC
315  */
316 HWTEST_F(ScreenSessionManagerProxyUtTest, SetResolution, Function | SmallTest | Level1)
317 {
318     SingletonContainer::Get<ScreenManagerAdapter>().InitDMSProxy();
319     ScreenId id = 1001;
320     uint32_t width = 1024;
321     uint32_t height = 1024;
322     float virtualPixelRatio = 1.0;
323 
324     sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject();
325     sptr<ScreenSessionManagerProxy> screenSessionManagerProxy = new ScreenSessionManagerProxy(impl);
326 
327 
328     DMError res = DMError::DM_ERROR_NOT_SYSTEM_APP;
329     std::function<void()> func = [&]()
__anon38dd45020a02() 330     {
331         res = screenSessionManagerProxy->SetResolution(id, width, height, virtualPixelRatio);
332     };
333     func();
334 
335     ASSERT_EQ(res, DMError::DM_ERROR_IPC_FAILED);
336 }
337 
338 /**
339  * @tc.name: GetDensityInCurResolution
340  * @tc.desc: GetDensityInCurResolution
341  * @tc.type: FUNC
342  */
343 HWTEST_F(ScreenSessionManagerProxyUtTest, GetDensityInCurResolution, Function | SmallTest | Level1)
344 {
345     SingletonContainer::Get<ScreenManagerAdapter>().InitDMSProxy();
346     ScreenId id = 1001;
347     float virtualPixelRatio = 1.0;
348 
349     sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject();
350     sptr<ScreenSessionManagerProxy> screenSessionManagerProxy = new ScreenSessionManagerProxy(impl);
351 
352 
353     DMError res = DMError::DM_ERROR_NOT_SYSTEM_APP;
354     std::function<void()> func = [&]()
__anon38dd45020b02() 355     {
356         res = screenSessionManagerProxy->GetDensityInCurResolution(id, virtualPixelRatio);
357     };
358     func();
359 
360     ASSERT_EQ(res, DMError::DM_ERROR_IPC_FAILED);
361 }
362 
363 /**
364  * @tc.name: GetScreenColorGamut
365  * @tc.desc: GetScreenColorGamut
366  * @tc.type: FUNC
367  */
368 HWTEST_F(ScreenSessionManagerProxyUtTest, GetScreenColorGamut, Function | SmallTest | Level1)
369 {
370     SingletonContainer::Get<ScreenManagerAdapter>().InitDMSProxy();
371     ScreenId id = 1001;
372     ScreenColorGamut colorGamut {0};
373 
374     sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject();
375     sptr<ScreenSessionManagerProxy> screenSessionManagerProxy = new ScreenSessionManagerProxy(impl);
376 
377 
378     DMError res = DMError::DM_ERROR_NOT_SYSTEM_APP;
379     std::function<void()> func = [&]()
__anon38dd45020c02() 380     {
381         res = screenSessionManagerProxy->GetScreenColorGamut(id, colorGamut);
382     };
383     func();
384 
385     ASSERT_EQ(res, DMError::DM_ERROR_IPC_FAILED);
386 }
387 
388 /**
389  * @tc.name: SetScreenColorGamut
390  * @tc.desc: SetScreenColorGamut
391  * @tc.type: FUNC
392  */
393 HWTEST_F(ScreenSessionManagerProxyUtTest, SetScreenColorGamut, Function | SmallTest | Level1)
394 {
395     SingletonContainer::Get<ScreenManagerAdapter>().InitDMSProxy();
396     ScreenId id = 1001;
397     uint32_t colorGamut = 0;
398 
399     sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject();
400     sptr<ScreenSessionManagerProxy> screenSessionManagerProxy = new ScreenSessionManagerProxy(impl);
401 
402 
403     DMError res = DMError::DM_ERROR_NOT_SYSTEM_APP;
404     std::function<void()> func = [&]()
__anon38dd45020d02() 405     {
406         res = screenSessionManagerProxy->SetScreenColorGamut(id, colorGamut);
407     };
408     func();
409 
410     ASSERT_EQ(res, DMError::DM_ERROR_IPC_FAILED);
411 }
412 
413 /**
414  * @tc.name: GetScreenGamutMap
415  * @tc.desc: GetScreenGamutMap
416  * @tc.type: FUNC
417  */
418 HWTEST_F(ScreenSessionManagerProxyUtTest, GetScreenGamutMap, Function | SmallTest | Level1)
419 {
420     SingletonContainer::Get<ScreenManagerAdapter>().InitDMSProxy();
421     ScreenId id = 1001;
422     ScreenGamutMap colorGamut;
423 
424     sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject();
425     sptr<ScreenSessionManagerProxy> screenSessionManagerProxy = new ScreenSessionManagerProxy(impl);
426 
427 
428     DMError res = DMError::DM_ERROR_NOT_SYSTEM_APP;
429     std::function<void()> func = [&]()
__anon38dd45020e02() 430     {
431         res = screenSessionManagerProxy->GetScreenGamutMap(id, colorGamut);
432     };
433     func();
434 
435     ASSERT_EQ(res, DMError::DM_ERROR_IPC_FAILED);
436 }
437 
438 /**
439  * @tc.name: SetScreenGamutMap
440  * @tc.desc: SetScreenGamutMap
441  * @tc.type: FUNC
442  */
443 HWTEST_F(ScreenSessionManagerProxyUtTest, SetScreenGamutMap, Function | SmallTest | Level1)
444 {
445     SingletonContainer::Get<ScreenManagerAdapter>().InitDMSProxy();
446     ScreenId id = 1001;
447     ScreenGamutMap colorGamut {0};
448 
449     sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject();
450     sptr<ScreenSessionManagerProxy> screenSessionManagerProxy = new ScreenSessionManagerProxy(impl);
451 
452 
453     DMError res = DMError::DM_ERROR_NOT_SYSTEM_APP;
454     std::function<void()> func = [&]()
__anon38dd45020f02() 455     {
456         res = screenSessionManagerProxy->SetScreenGamutMap(id, colorGamut);
457     };
458     func();
459 
460     ASSERT_EQ(res, DMError::DM_ERROR_IPC_FAILED);
461 }
462 
463 /**
464  * @tc.name: SetScreenColorTransform
465  * @tc.desc: SetScreenColorTransform
466  * @tc.type: FUNC
467  */
468 HWTEST_F(ScreenSessionManagerProxyUtTest, SetScreenColorTransform, Function | SmallTest | Level1)
469 {
470     SingletonContainer::Get<ScreenManagerAdapter>().InitDMSProxy();
471     ScreenId id = 1001;
472 
473     sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject();
474     sptr<ScreenSessionManagerProxy> screenSessionManagerProxy = new ScreenSessionManagerProxy(impl);
475 
476 
477     DMError res = DMError::DM_ERROR_NOT_SYSTEM_APP;
478     std::function<void()> func = [&]()
__anon38dd45021002() 479     {
480         res = screenSessionManagerProxy->SetScreenColorTransform(id);
481     };
482     func();
483 
484     ASSERT_EQ(res, DMError::DM_ERROR_IPC_FAILED);
485 }
486 
487 /**
488  * @tc.name: GetPixelFormat
489  * @tc.desc: GetPixelFormat
490  * @tc.type: FUNC
491  */
492 HWTEST_F(ScreenSessionManagerProxyUtTest, GetPixelFormat, Function | SmallTest | Level1)
493 {
494     SingletonContainer::Get<ScreenManagerAdapter>().InitDMSProxy();
495     ScreenId id = 1001;
496     GraphicPixelFormat pixelFormat = GraphicPixelFormat {GRAPHIC_PIXEL_FMT_CLUT8};
497 
498     sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject();
499     sptr<ScreenSessionManagerProxy> screenSessionManagerProxy = new ScreenSessionManagerProxy(impl);
500 
501 
502     DMError res = DMError::DM_ERROR_NOT_SYSTEM_APP;
503     std::function<void()> func = [&]()
__anon38dd45021102() 504     {
505         res = screenSessionManagerProxy->GetPixelFormat(id, pixelFormat);
506     };
507     func();
508 
509     ASSERT_EQ(res, DMError::DM_ERROR_IPC_FAILED);
510 }
511 
512 /**
513  * @tc.name: SetPixelFormat
514  * @tc.desc: SetPixelFormat
515  * @tc.type: FUNC
516  */
517 HWTEST_F(ScreenSessionManagerProxyUtTest, SetPixelFormat, Function | SmallTest | Level1)
518 {
519     SingletonContainer::Get<ScreenManagerAdapter>().InitDMSProxy();
520     ScreenId id = 1001;
521     GraphicPixelFormat pixelFormat = GraphicPixelFormat {GRAPHIC_PIXEL_FMT_CLUT8};
522 
523     sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject();
524     sptr<ScreenSessionManagerProxy> screenSessionManagerProxy = new ScreenSessionManagerProxy(impl);
525 
526 
527     DMError res = DMError::DM_ERROR_NOT_SYSTEM_APP;
528     std::function<void()> func = [&]()
__anon38dd45021202() 529     {
530         res = screenSessionManagerProxy->SetPixelFormat(id, pixelFormat);
531     };
532     func();
533 
534     ASSERT_EQ(res, DMError::DM_ERROR_IPC_FAILED);
535 }
536 
537 /**
538  * @tc.name: GetSupportedHDRFormats
539  * @tc.desc: GetSupportedHDRFormats
540  * @tc.type: FUNC
541  */
542 HWTEST_F(ScreenSessionManagerProxyUtTest, GetSupportedHDRFormats, Function | SmallTest | Level1)
543 {
544     SingletonContainer::Get<ScreenManagerAdapter>().InitDMSProxy();
545     ScreenId id = 1001;
546     vector<ScreenHDRFormat> hdrFormats;
547 
548     sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject();
549     sptr<ScreenSessionManagerProxy> screenSessionManagerProxy = new ScreenSessionManagerProxy(impl);
550 
551 
552     DMError res = DMError::DM_ERROR_NOT_SYSTEM_APP;
553     std::function<void()> func = [&]()
__anon38dd45021302() 554     {
555         res = screenSessionManagerProxy->GetSupportedHDRFormats(id, hdrFormats);
556     };
557     func();
558 
559     ASSERT_EQ(res, DMError::DM_ERROR_IPC_FAILED);
560 }
561 
562 /**
563  * @tc.name: GetScreenHDRFormat
564  * @tc.desc: GetScreenHDRFormat
565  * @tc.type: FUNC
566  */
567 HWTEST_F(ScreenSessionManagerProxyUtTest, GetScreenHDRFormat, Function | SmallTest | Level1)
568 {
569     SingletonContainer::Get<ScreenManagerAdapter>().InitDMSProxy();
570     ScreenId id = 1001;
571     ScreenHDRFormat hdrFormatS {0};
572 
573     sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject();
574     sptr<ScreenSessionManagerProxy> screenSessionManagerProxy = new ScreenSessionManagerProxy(impl);
575 
576 
577     DMError res = DMError::DM_ERROR_NOT_SYSTEM_APP;
578     std::function<void()> func = [&]()
__anon38dd45021402() 579     {
580         res = screenSessionManagerProxy->GetScreenHDRFormat(id, hdrFormatS);
581     };
582     func();
583 
584     ASSERT_EQ(res, DMError::DM_ERROR_IPC_FAILED);
585 }
586 
587 /**
588  * @tc.name: SetScreenHDRFormat
589  * @tc.desc: SetScreenHDRFormat
590  * @tc.type: FUNC
591  */
592 HWTEST_F(ScreenSessionManagerProxyUtTest, SetScreenHDRFormat, Function | SmallTest | Level1)
593 {
594     SingletonContainer::Get<ScreenManagerAdapter>().InitDMSProxy();
595     ScreenId id = 1001;
596     ScreenHDRFormat hdrFormatS {0};
597 
598     sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject();
599     sptr<ScreenSessionManagerProxy> screenSessionManagerProxy = new ScreenSessionManagerProxy(impl);
600 
601 
602     DMError res = DMError::DM_ERROR_NOT_SYSTEM_APP;
603     std::function<void()> func = [&]()
__anon38dd45021502() 604     {
605         res = screenSessionManagerProxy->SetScreenHDRFormat(id, hdrFormatS);
606     };
607     func();
608 
609     ASSERT_EQ(res, DMError::DM_ERROR_IPC_FAILED);
610 }
611 
612 /**
613  * @tc.name: RegisterDisplayManagerAgent
614  * @tc.desc: RegisterDisplayManagerAgent
615  * @tc.type: FUNC
616  */
617 HWTEST_F(ScreenSessionManagerProxyUtTest, RegisterDisplayManagerAgent, Function | SmallTest | Level1)
618 {
619     SingletonContainer::Get<ScreenManagerAdapter>().InitDMSProxy();
620     sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject();
621     sptr<ScreenSessionManagerProxy> screenSessionManagerProxy = new ScreenSessionManagerProxy(impl);
622     sptr<IDisplayManagerAgent> displayManagerAgent = new DisplayManagerAgentDefault();
623     DisplayManagerAgentType type = DisplayManagerAgentType::SCREEN_EVENT_LISTENER;
624 
625     EXPECT_NE(DMError::DM_OK, screenSessionManagerProxy->RegisterDisplayManagerAgent(displayManagerAgent, type));
626 
627     displayManagerAgent = nullptr;
628     EXPECT_EQ(DMError::DM_ERROR_INVALID_PARAM,
629               screenSessionManagerProxy->RegisterDisplayManagerAgent(displayManagerAgent, type));
630 }
631 
632 /**
633  * @tc.name: UnregisterDisplayManagerAgent
634  * @tc.desc: UnregisterDisplayManagerAgent
635  * @tc.type: FUNC
636  */
637 HWTEST_F(ScreenSessionManagerProxyUtTest, UnregisterDisplayManagerAgent, Function | SmallTest | Level1)
638 {
639     SingletonContainer::Get<ScreenManagerAdapter>().InitDMSProxy();
640     sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject();
641     sptr<ScreenSessionManagerProxy> screenSessionManagerProxy = new ScreenSessionManagerProxy(impl);
642     sptr<IDisplayManagerAgent> displayManagerAgent = new DisplayManagerAgentDefault();
643     DisplayManagerAgentType type = DisplayManagerAgentType::SCREEN_EVENT_LISTENER;
644 
645     EXPECT_NE(DMError::DM_OK, screenSessionManagerProxy->UnregisterDisplayManagerAgent(displayManagerAgent, type));
646 
647     displayManagerAgent = nullptr;
648     EXPECT_EQ(DMError::DM_ERROR_INVALID_PARAM,
649               screenSessionManagerProxy->UnregisterDisplayManagerAgent(displayManagerAgent, type));
650 }
651 
652 /**
653  * @tc.name: WakeUpBegin
654  * @tc.desc: WakeUpBegin
655  * @tc.type: FUNC
656  */
657 HWTEST_F(ScreenSessionManagerProxyUtTest, WakeUpBegin, Function | SmallTest | Level1)
658 {
659     SingletonContainer::Get<ScreenManagerAdapter>().InitDMSProxy();
660     sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject();
661     sptr<ScreenSessionManagerProxy> screenSessionManagerProxy = new ScreenSessionManagerProxy(impl);
662 
663     PowerStateChangeReason reason {0};
664     bool expectation = true;
665 
666     EXPECT_NE(expectation, screenSessionManagerProxy->WakeUpBegin(reason));
667 }
668 
669 /**
670  * @tc.name: WakeUpEnd
671  * @tc.desc: WakeUpEnd
672  * @tc.type: FUNC
673  */
674 HWTEST_F(ScreenSessionManagerProxyUtTest, WakeUpEnd, Function | SmallTest | Level1)
675 {
676     SingletonContainer::Get<ScreenManagerAdapter>().InitDMSProxy();
677     sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject();
678     sptr<ScreenSessionManagerProxy> screenSessionManagerProxy = new ScreenSessionManagerProxy(impl);
679 
680     bool expectation = true;
681     EXPECT_NE(expectation, screenSessionManagerProxy->WakeUpEnd());
682 }
683 
684 /**
685  * @tc.name: SuspendBegin
686  * @tc.desc: SuspendBegin
687  * @tc.type: FUNC
688  */
689 HWTEST_F(ScreenSessionManagerProxyUtTest, SuspendBegin, Function | SmallTest | Level1)
690 {
691     SingletonContainer::Get<ScreenManagerAdapter>().InitDMSProxy();
692     sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject();
693     sptr<ScreenSessionManagerProxy> screenSessionManagerProxy = new ScreenSessionManagerProxy(impl);
694 
695     PowerStateChangeReason reason {0};
696     bool expectation = true;
697     EXPECT_NE(expectation, screenSessionManagerProxy->SuspendBegin(reason));
698 }
699 
700 /**
701  * @tc.name: SuspendEnd
702  * @tc.desc: SuspendEnd
703  * @tc.type: FUNC
704  */
705 HWTEST_F(ScreenSessionManagerProxyUtTest, SuspendEnd, Function | SmallTest | Level1)
706 {
707     SingletonContainer::Get<ScreenManagerAdapter>().InitDMSProxy();
708     sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject();
709     sptr<ScreenSessionManagerProxy> screenSessionManagerProxy = new ScreenSessionManagerProxy(impl);
710 
711     bool expectation = true;
712 
713     EXPECT_NE(expectation, screenSessionManagerProxy->SuspendEnd());
714 }
715 
716 /**
717  * @tc.name: SetScreenPowerById
718  * @tc.desc: SetScreenPowerById
719  * @tc.type: FUNC
720  */
721 HWTEST_F(ScreenSessionManagerProxyUtTest, SetScreenPowerById, Function | SmallTest | Level1)
722 {
723     SingletonContainer::Get<ScreenManagerAdapter>().InitDMSProxy();
724     ScreenPowerState state {0};
725     ScreenId id = 1001;
726     PowerStateChangeReason reason {1};
727 
728     sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject();
729     sptr<ScreenSessionManagerProxy> screenSessionManagerProxy = new ScreenSessionManagerProxy(impl);
730 
731     bool expectation = true;
732 
733     EXPECT_NE(expectation, screenSessionManagerProxy->SetScreenPowerById(id, state, reason));
734 }
735 
736 /**
737  * @tc.name: SetDisplayState
738  * @tc.desc: SetDisplayState
739  * @tc.type: FUNC
740  */
741 HWTEST_F(ScreenSessionManagerProxyUtTest, SetDisplayState, Function | SmallTest | Level1)
742 {
743     SingletonContainer::Get<ScreenManagerAdapter>().InitDMSProxy();
744     sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject();
745     sptr<ScreenSessionManagerProxy> screenSessionManagerProxy = new ScreenSessionManagerProxy(impl);
746 
747     DisplayState state {1};
748     screenSessionManagerProxy->SetDisplayState(state);
749     int resultValue = 0;
750     ASSERT_EQ(resultValue, 0);
751 }
752 
753 /**
754  * @tc.name: SetSpecifiedScreenPower
755  * @tc.desc: SetSpecifiedScreenPower
756  * @tc.type: FUNC
757  */
758 HWTEST_F(ScreenSessionManagerProxyUtTest, SetSpecifiedScreenPower, Function | SmallTest | Level1)
759 {
760     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
761         GTEST_SKIP() << "SceneBoard is not enabled, skipping test.";
762     }
763     SingletonContainer::Get<ScreenManagerAdapter>().InitDMSProxy();
764     sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject();
765     sptr<ScreenSessionManagerProxy> screenSessionManagerProxy = new ScreenSessionManagerProxy(impl);
766 
767     ScreenPowerState state {0};
768     ScreenId id = 1001;
769     PowerStateChangeReason reason {1};
770     bool expectation = true;
771 
772     EXPECT_NE(expectation, screenSessionManagerProxy->SetSpecifiedScreenPower(id, state, reason));
773 }
774 
775 /**
776  * @tc.name: SetScreenPowerForAll
777  * @tc.desc: SetScreenPowerForAll
778  * @tc.type: FUNC
779  */
780 HWTEST_F(ScreenSessionManagerProxyUtTest, SetScreenPowerForAll, Function | SmallTest | Level1)
781 {
782     SingletonContainer::Get<ScreenManagerAdapter>().InitDMSProxy();
783     sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject();
784     sptr<ScreenSessionManagerProxy> screenSessionManagerProxy = new ScreenSessionManagerProxy(impl);
785 
786     ScreenPowerState state {0};
787     PowerStateChangeReason reason {1};
788     bool expectation = true;
789 
790     EXPECT_NE(expectation, screenSessionManagerProxy->SetScreenPowerForAll(state, reason));
791 }
792 
793 /**
794  * @tc.name: GetDisplayState
795  * @tc.desc: GetDisplayState
796  * @tc.type: FUNC
797  */
798 HWTEST_F(ScreenSessionManagerProxyUtTest, GetDisplayState, Function | SmallTest | Level1)
799 {
800     SingletonContainer::Get<ScreenManagerAdapter>().InitDMSProxy();
801     sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject();
802     sptr<ScreenSessionManagerProxy> screenSessionManagerProxy = new ScreenSessionManagerProxy(impl);
803 
804     DisplayId displayId {0};
805 
806     EXPECT_EQ(DisplayState::UNKNOWN, screenSessionManagerProxy->GetDisplayState(displayId));
807 }
808 
809 /**
810  * @tc.name: TryToCancelScreenOff
811  * @tc.desc: TryToCancelScreenOff
812  * @tc.type: FUNC
813  */
814 HWTEST_F(ScreenSessionManagerProxyUtTest, TryToCancelScreenOff, Function | SmallTest | Level1)
815 {
816     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
817         GTEST_SKIP() << "SceneBoard is not enabled, skipping test.";
818     }
819     SingletonContainer::Get<ScreenManagerAdapter>().InitDMSProxy();
820     sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject();
821     sptr<ScreenSessionManagerProxy> screenSessionManagerProxy = new ScreenSessionManagerProxy(impl);
822 
823     bool expectation = true;
824 
825     EXPECT_EQ(expectation, screenSessionManagerProxy->TryToCancelScreenOff());
826 }
827 
828 /**
829  * @tc.name: NotifyDisplayEvent
830  * @tc.desc: NotifyDisplayEvent
831  * @tc.type: FUNC
832  */
833 HWTEST_F(ScreenSessionManagerProxyUtTest, NotifyDisplayEvent, Function | SmallTest | Level1)
834 {
835     SingletonContainer::Get<ScreenManagerAdapter>().InitDMSProxy();
836     sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject();
837     sptr<ScreenSessionManagerProxy> screenSessionManagerProxy = new ScreenSessionManagerProxy(impl);
838 
839     DisplayEvent event {0};
840     int resultValue = 0;
841     std::function<void()> func = [&]()
__anon38dd45021602() 842     {
843         screenSessionManagerProxy->NotifyDisplayEvent(event);
844         resultValue = 1;
845     };
846     func();
847     ASSERT_EQ(resultValue, 1);
848 }
849 }
850 }
851 }