• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 #include "screen_session.h"
16 #include <gtest/gtest.h>
17 #include "session_manager/include/screen_session_manager.h"
18 #include "scene_board_judgement.h"
19 
20 // using namespace FRAME_TRACE;
21 using namespace testing;
22 using namespace testing::ext;
23 namespace OHOS {
24 namespace Rosen {
25 class MockScreenChangeListener : public IScreenChangeListener {
26 public:
OnConnect(ScreenId screenId)27     void OnConnect(ScreenId screenId) override {}
OnDisconnect(ScreenId screenId)28     void OnDisconnect(ScreenId screenId) override {}
OnPropertyChange(const ScreenProperty & newProperty,ScreenPropertyChangeReason reason,ScreenId screenId)29     void OnPropertyChange(const ScreenProperty& newProperty, ScreenPropertyChangeReason reason,
30         ScreenId screenId) override {}
OnPowerStatusChange(DisplayPowerEvent event,EventStatus status,PowerStateChangeReason reason)31     void OnPowerStatusChange(DisplayPowerEvent event, EventStatus status,
32         PowerStateChangeReason reason) override {}
OnSensorRotationChange(float sensorRotation,ScreenId screenId)33     void OnSensorRotationChange(float sensorRotation, ScreenId screenId) override {}
OnScreenOrientationChange(float screenOrientation,ScreenId screenId)34     void OnScreenOrientationChange(float screenOrientation, ScreenId screenId) override {}
OnScreenRotationLockedChange(bool isLocked,ScreenId screenId)35     void OnScreenRotationLockedChange(bool isLocked, ScreenId screenId) override {}
36 };
37 class ScreenSessionTest : public testing::Test {
38   public:
ScreenSessionTest()39     ScreenSessionTest() {}
~ScreenSessionTest()40     ~ScreenSessionTest() {}
41 };
42 
43 namespace {
44 
45 /**
46  * @tc.name: create ScreenSession
47  * @tc.desc: normal function
48  * @tc.type: FUNC
49  */
50 HWTEST_F(ScreenSessionTest, ScreenSession, Function | SmallTest | Level2)
51 {
52     ScreenSessionConfig config = {
53         .screenId = 0,
54         .rsId = 0,
55         .name = "OpenHarmony",
56     };
57     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_CLIENT);
58     EXPECT_NE(nullptr, screenSession);
59 }
60 
61 /**
62  * @tc.name: create ScreenSession02
63  * @tc.desc: normal function
64  * @tc.type: FUNC
65  */
66 HWTEST_F(ScreenSessionTest, ScreenSession02, Function | SmallTest | Level2)
67 {
68     ScreenSessionConfig config = {
69         .screenId = 0,
70         .rsId = 0,
71         .name = "OpenHarmony",
72     };
73     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
74     EXPECT_NE(nullptr, screenSession);
75 }
76 
77 /**
78  * @tc.name: create ScreenSession03
79  * @tc.desc: normal function
80  * @tc.type: FUNC
81  */
82 HWTEST_F(ScreenSessionTest, ScreenSession03, Function | SmallTest | Level2)
83 {
84     ScreenSessionConfig config = {
85         .screenId = 0,
86         .rsId = 0,
87         .name = "OpenHarmony",
88     };
89     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_MIRROR);
90     EXPECT_NE(nullptr, screenSession);
91 }
92 
93 /**
94  * @tc.name: create ScreenSession03
95  * @tc.desc: normal function
96  * @tc.type: FUNC
97  */
98 HWTEST_F(ScreenSessionTest, ScreenSession04, Function | SmallTest | Level2)
99 {
100     ScreenSessionConfig config = {
101         .screenId = 0,
102         .rsId = 0,
103         .name = "OpenHarmony",
104     };
105     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_REAL);
106     EXPECT_NE(nullptr, screenSession);
107 }
108 
109 /**
110  * @tc.name: create ScreenSession05
111  * @tc.desc: normal function
112  * @tc.type: FUNC
113  */
114 HWTEST_F(ScreenSessionTest, ScreenSession05, Function | SmallTest | Level2)
115 {
116     ScreenSessionConfig config = {
117         .screenId = 0,
118         .rsId = 0,
119         .name = "OpenHarmony",
120     };
121     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::INVALID);
122     EXPECT_NE(nullptr, screenSession);
123 }
124 
125 /**
126  * @tc.name: CreateDisplayNode
127  * @tc.desc: normal function
128  * @tc.type: FUNC
129  */
130 HWTEST_F(ScreenSessionTest, CreateDisplayNode, Function | SmallTest | Level2)
131 {
132     GTEST_LOG_(INFO) << "ScreenSessionTest: CreateDisplayNode start";
133     Rosen::RSDisplayNodeConfig rsConfig;
134     ScreenSessionConfig config = {
135         .screenId = 100,
136         .rsId = 101,
137         .name = "OpenHarmony",
138     };
139     rsConfig.isMirrored = true;
140     rsConfig.screenId = 101;
141     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
142     EXPECT_NE(nullptr, screenSession);
143     screenSession->CreateDisplayNode(rsConfig);
144     GTEST_LOG_(INFO) << "ScreenSessionTest: CreateDisplayNode end";
145 }
146 
147 /**
148  * @tc.name: SetMirrorScreenType
149  * @tc.desc: normal function
150  * @tc.type: FUNC
151  */
152 HWTEST_F(ScreenSessionTest, SetMirrorScreenType, Function | SmallTest | Level2)
153 {
154     GTEST_LOG_(INFO) << "SetMirrorScreenType start";
155     ScreenSessionConfig config = {
156         .screenId = 100,
157         .rsId = 101,
158         .name = "OpenHarmony",
159     };
160     Rosen::RSDisplayNodeConfig rsConfig;
161     rsConfig.isMirrored = true;
162     rsConfig.screenId = 101;
163     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
164     EXPECT_NE(nullptr, screenSession);
165     MirrorScreenType mirrorType = MirrorScreenType::VIRTUAL_MIRROR;
166     screenSession->SetMirrorScreenType(mirrorType);
167     GTEST_LOG_(INFO) << "SetMirrorScreenType end";
168 }
169 
170 /**
171  * @tc.name: GetMirrorScreenType
172  * @tc.desc: normal function
173  * @tc.type: FUNC
174  */
175 HWTEST_F(ScreenSessionTest, GetMirrorScreenType, Function | SmallTest | Level2)
176 {
177     GTEST_LOG_(INFO) << "GetMirrorScreenType start";
178     ScreenSessionConfig config = {
179         .screenId = 100,
180         .rsId = 101,
181         .name = "OpenHarmony",
182     };
183     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
184     EXPECT_NE(nullptr, screenSession);
185     MirrorScreenType mirrorType = MirrorScreenType::VIRTUAL_MIRROR;
186     screenSession->SetMirrorScreenType(mirrorType);
187     MirrorScreenType res = screenSession->GetMirrorScreenType();
188     ASSERT_EQ(mirrorType, res);
189     GTEST_LOG_(INFO) << "GetMirrorScreenType end";
190 }
191 
192 /**
193  * @tc.name: SetDefaultDeviceRotationOffset
194  * @tc.desc: normal function
195  * @tc.type: FUNC
196  */
197 HWTEST_F(ScreenSessionTest, SetDefaultDeviceRotationOffset, Function | SmallTest | Level2)
198 {
199     GTEST_LOG_(INFO) << "SetDefaultDeviceRotationOffset start";
200     ScreenSessionConfig config = {
201         .screenId = 100,
202         .rsId = 101,
203         .name = "OpenHarmony",
204     };
205     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
206     EXPECT_NE(nullptr, screenSession);
207     uint32_t defaultRotationOffset = 0;
208     screenSession->SetDefaultDeviceRotationOffset(defaultRotationOffset);
209     GTEST_LOG_(INFO) << "SetDefaultDeviceRotationOffset end";
210 }
211 
212 /**
213  * @tc.name: UpdateDisplayState
214  * @tc.desc: normal function
215  * @tc.type: FUNC
216  */
217 HWTEST_F(ScreenSessionTest, UpdateDisplayState, Function | SmallTest | Level2)
218 {
219     GTEST_LOG_(INFO) << "UpdateDisplayState start";
220     ScreenSessionConfig config = {
221         .screenId = 100,
222         .rsId = 101,
223         .name = "OpenHarmony",
224     };
225     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
226     EXPECT_NE(nullptr, screenSession);
227     DisplayState displayState = DisplayState::OFF;
228     screenSession->UpdateDisplayState(displayState);
229     GTEST_LOG_(INFO) << "UpdateDisplayState end";
230 }
231 
232 /**
233  * @tc.name: UpdateRefreshRate
234  * @tc.desc: normal function
235  * @tc.type: FUNC
236  */
237 HWTEST_F(ScreenSessionTest, UpdateRefreshRate, Function | SmallTest | Level2)
238 {
239     GTEST_LOG_(INFO) << "UpdateRefreshRate start";
240     ScreenSessionConfig config = {
241         .screenId = 100,
242         .rsId = 101,
243         .name = "OpenHarmony",
244     };
245     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
246     EXPECT_NE(nullptr, screenSession);
247     uint32_t refreshRate = 2;
248     screenSession->UpdateRefreshRate(refreshRate);
249     GTEST_LOG_(INFO) << "UpdateRefreshRate end";
250 }
251 
252 /**
253  * @tc.name: GetRefreshRate
254  * @tc.desc: normal function
255  * @tc.type: FUNC
256  */
257 HWTEST_F(ScreenSessionTest, GetRefreshRate, Function | SmallTest | Level2)
258 {
259     GTEST_LOG_(INFO) << "GetRefreshRate start";
260     ScreenSessionConfig config = {
261         .screenId = 100,
262         .rsId = 101,
263         .name = "OpenHarmony",
264     };
265     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
266     EXPECT_NE(nullptr, screenSession);
267     uint32_t refreshRate = 2;
268     screenSession->UpdateRefreshRate(refreshRate);
269     auto res = screenSession->GetRefreshRate();
270     ASSERT_EQ(refreshRate, res);
271     GTEST_LOG_(INFO) << "GetRefreshRate end";
272 }
273 
274 /**
275  * @tc.name: UpdatePropertyByResolution
276  * @tc.desc: normal function
277  * @tc.type: FUNC
278  */
279 HWTEST_F(ScreenSessionTest, UpdatePropertyByResolution, Function | SmallTest | Level2)
280 {
281     GTEST_LOG_(INFO) << "UpdatePropertyByResolution start";
282     ScreenSessionConfig config = {
283         .screenId = 100,
284         .rsId = 101,
285         .name = "OpenHarmony",
286     };
287     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
288     EXPECT_NE(nullptr, screenSession);
289     uint32_t width = 1000;
290     uint32_t height = 1500;
291     screenSession->UpdatePropertyByResolution(width, height);
292     GTEST_LOG_(INFO) << "UpdatePropertyByResolution end";
293 }
294 
295 /**
296  * @tc.name: HandleSensorRotation
297  * @tc.desc: normal function
298  * @tc.type: FUNC
299  */
300 HWTEST_F(ScreenSessionTest, HandleSensorRotation, Function | SmallTest | Level2)
301 {
302     GTEST_LOG_(INFO) << "HandleSensorRotation start";
303     ScreenSessionConfig config = {
304         .screenId = 100,
305         .rsId = 101,
306         .name = "OpenHarmony",
307     };
308     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
309     EXPECT_NE(nullptr, screenSession);
310     float sensorRotation = 0.0f;
311     screenSession->HandleSensorRotation(sensorRotation);
312     GTEST_LOG_(INFO) << "HandleSensorRotation end";
313 }
314 
315 /**
316  * @tc.name: ConvertIntToRotation
317  * @tc.desc: normal function
318  * @tc.type: FUNC
319  */
320 HWTEST_F(ScreenSessionTest, ConvertIntToRotation, Function | SmallTest | Level2)
321 {
322     GTEST_LOG_(INFO) << "ScreenSessionTest: ConvertIntToRotation start";
323     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
324     int rotation = 0;
325     auto res = session->ConvertIntToRotation(rotation);
326     ASSERT_EQ(res, Rotation::ROTATION_0);
327     rotation = 90;
328     res = session->ConvertIntToRotation(rotation);
329     ASSERT_EQ(res, Rotation::ROTATION_90);
330     rotation = 180;
331     res = session->ConvertIntToRotation(rotation);
332     ASSERT_EQ(res, Rotation::ROTATION_180);
333     rotation = 270;
334     res = session->ConvertIntToRotation(rotation);
335     ASSERT_EQ(res, Rotation::ROTATION_270);
336     GTEST_LOG_(INFO) << "ScreenSessionTest: ConvertIntToRotation end";
337 }
338 
339 /**
340  * @tc.name: SetVirtualScreenFlag
341  * @tc.desc: normal function
342  * @tc.type: FUNC
343  */
344 HWTEST_F(ScreenSessionTest, SetVirtualScreenFlag, Function | SmallTest | Level2)
345 {
346     GTEST_LOG_(INFO) << "SetVirtualScreenFlag start";
347     ScreenSessionConfig config = {
348         .screenId = 100,
349         .rsId = 101,
350         .name = "OpenHarmony",
351     };
352     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
353     EXPECT_NE(nullptr, screenSession);
354     VirtualScreenFlag screenFlag = VirtualScreenFlag::CAST;
355     screenSession->SetVirtualScreenFlag(screenFlag);
356     GTEST_LOG_(INFO) << "SetVirtualScreenFlag end";
357 }
358 
359 /**
360  * @tc.name: GetVirtualScreenFlag
361  * @tc.desc: normal function
362  * @tc.type: FUNC
363  */
364 HWTEST_F(ScreenSessionTest, GetVirtualScreenFlag, Function | SmallTest | Level2)
365 {
366     GTEST_LOG_(INFO) << "GetVirtualScreenFlag start";
367     ScreenSessionConfig config = {
368         .screenId = 100,
369         .rsId = 101,
370         .name = "OpenHarmony",
371     };
372     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
373     EXPECT_NE(nullptr, screenSession);
374     VirtualScreenFlag screenFlag = VirtualScreenFlag::CAST;
375     screenSession->SetVirtualScreenFlag(screenFlag);
376     auto res = screenSession->GetVirtualScreenFlag();
377     ASSERT_EQ(screenFlag, res);
378     GTEST_LOG_(INFO) << "GetVirtualScreenFlag end";
379 }
380 
381 /**
382  * @tc.name: UpdateToInputManager
383  * @tc.desc: normal function
384  * @tc.type: FUNC
385  */
386 HWTEST_F(ScreenSessionTest, UpdateToInputManager, Function | SmallTest | Level2)
387 {
388     GTEST_LOG_(INFO) << "UpdateToInputManager start";
389     ScreenSessionConfig config = {
390         .screenId = 100,
391         .rsId = 101,
392         .name = "OpenHarmony",
393     };
394     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
395     EXPECT_NE(nullptr, screenSession);
396     RRect bounds;
397     int rotation = 90;
398     FoldDisplayMode foldDisplayMode = FoldDisplayMode::FULL;
399     screenSession->UpdateToInputManager(bounds, rotation, foldDisplayMode);
400     bounds.rect_.width_ = 1344;
401     bounds.rect_.height_ = 2772;
402     rotation = 0;
403     foldDisplayMode = FoldDisplayMode::MAIN;
404     screenSession->UpdateToInputManager(bounds, rotation, foldDisplayMode);
405     GTEST_LOG_(INFO) << "UpdateToInputManager end";
406 }
407 
408 /**
409  * @tc.name: UpdatePropertyAfterRotation
410  * @tc.desc: normal function
411  * @tc.type: FUNC
412  */
413 HWTEST_F(ScreenSessionTest, UpdatePropertyAfterRotation, Function | SmallTest | Level2)
414 {
415     GTEST_LOG_(INFO) << "UpdatePropertyAfterRotation start";
416     ScreenSessionConfig config = {
417         .screenId = 100,
418         .rsId = 101,
419         .name = "OpenHarmony",
420     };
421     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
422     EXPECT_NE(nullptr, screenSession);
423     RRect bounds;
424     bounds.rect_.width_ = 1344;
425     bounds.rect_.height_ = 2772;
426     int rotation = 90;
427     FoldDisplayMode foldDisplayMode = FoldDisplayMode::MAIN;
428     screenSession->UpdatePropertyAfterRotation(bounds, rotation, foldDisplayMode);
429     GTEST_LOG_(INFO) << "UpdatePropertyAfterRotation end";
430 }
431 
432 /**
433  * @tc.name: ReportNotifyModeChange
434  * @tc.desc: normal function
435  * @tc.type: FUNC
436  */
437 HWTEST_F(ScreenSessionTest, ReportNotifyModeChange, Function | SmallTest | Level2)
438 {
439     GTEST_LOG_(INFO) << "ReportNotifyModeChange start";
440     ScreenSessionConfig config = {
441         .screenId = 100,
442         .rsId = 101,
443         .name = "OpenHarmony",
444     };
445     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
446     EXPECT_NE(nullptr, screenSession);
447     DisplayOrientation displayOrientation = DisplayOrientation::LANDSCAPE;
448     screenSession->ReportNotifyModeChange(displayOrientation);
449     displayOrientation = DisplayOrientation::PORTRAIT;
450     screenSession->ReportNotifyModeChange(displayOrientation);
451     GTEST_LOG_(INFO) << "ReportNotifyModeChange end";
452 }
453 
454 /**
455  * @tc.name: UpdateRotationAfterBoot
456  * @tc.desc: normal function
457  * @tc.type: FUNC
458  */
459 HWTEST_F(ScreenSessionTest, UpdateRotationAfterBoot, Function | SmallTest | Level2)
460 {
461     GTEST_LOG_(INFO) << "UpdateRotationAfterBoot start";
462     ScreenSessionConfig config = {
463         .screenId = 100,
464         .rsId = 101,
465         .name = "OpenHarmony",
466     };
467     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
468     EXPECT_NE(nullptr, screenSession);
469     bool foldToExpand = true;
470     screenSession->UpdateRotationAfterBoot(foldToExpand);
471     GTEST_LOG_(INFO) << "UpdateRotationAfterBoot end";
472 }
473 
474 /**
475  * @tc.name: SetScreenSceneDpiChangeListener
476  * @tc.desc: normal function
477  * @tc.type: FUNC
478  */
479 HWTEST_F(ScreenSessionTest, SetScreenSceneDpiChangeListener, Function | SmallTest | Level2)
480 {
481     GTEST_LOG_(INFO) << "SetScreenSceneDpiChangeListener start";
482     ScreenSessionConfig config = {
483         .screenId = 100,
484         .rsId = 101,
485         .name = "OpenHarmony",
486     };
487     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
488     EXPECT_NE(nullptr, screenSession);
489     SetScreenSceneDpiFunc func = nullptr;
490     screenSession->SetScreenSceneDpiChangeListener(func);
491     GTEST_LOG_(INFO) << "SetScreenSceneDpiChangeListener end";
492 }
493 
494 /**
495  * @tc.name: SetScreenSceneDestroyListener
496  * @tc.desc: normal function
497  * @tc.type: FUNC
498  */
499 HWTEST_F(ScreenSessionTest, SetScreenSceneDestroyListener, Function | SmallTest | Level2)
500 {
501     GTEST_LOG_(INFO) << "SetScreenSceneDestroyListener start";
502     ScreenSessionConfig config = {
503         .screenId = 100,
504         .rsId = 101,
505         .name = "OpenHarmony",
506     };
507     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
508     EXPECT_NE(nullptr, screenSession);
509     DestroyScreenSceneFunc func = nullptr;
510     screenSession->SetScreenSceneDestroyListener(func);
511     GTEST_LOG_(INFO) << "SetScreenSceneDestroyListener end";
512 }
513 
514 /**
515  * @tc.name: SetScreenSceneDpi
516  * @tc.desc: normal function
517  * @tc.type: FUNC
518  */
519 HWTEST_F(ScreenSessionTest, SetScreenSceneDpi, Function | SmallTest | Level2)
520 {
521     GTEST_LOG_(INFO) << "SetScreenSceneDpi start";
522     ScreenSessionConfig config = {
523         .screenId = 100,
524         .rsId = 101,
525         .name = "OpenHarmony",
526     };
527     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
528     EXPECT_NE(nullptr, screenSession);
529     float density = 1.5f;
530     SetScreenSceneDpiFunc func = nullptr;
531     screenSession->SetScreenSceneDpiChangeListener(func);
532     screenSession->SetScreenSceneDpi(density);
__anon37e36e3f0202(float density) 533     SetScreenSceneDpiFunc func2 = [](float density) {
534             EXPECT_TRUE(true);
535         };
536     screenSession->SetScreenSceneDpiChangeListener(func2);
537     screenSession->SetScreenSceneDpi(density);
538     GTEST_LOG_(INFO) << "SetScreenSceneDpi end";
539 }
540 
541 /**
542  * @tc.name: DestroyScreenScene
543  * @tc.desc: normal function
544  * @tc.type: FUNC
545  */
546 HWTEST_F(ScreenSessionTest, DestroyScreenScene, Function | SmallTest | Level2)
547 {
548     GTEST_LOG_(INFO) << "DestroyScreenScene start";
549     ScreenSessionConfig config = {
550         .screenId = 100,
551         .rsId = 101,
552         .name = "OpenHarmony",
553     };
554     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
555     EXPECT_NE(nullptr, screenSession);
556     DestroyScreenSceneFunc func = nullptr;
557     screenSession->SetScreenSceneDestroyListener(func);
558     screenSession->DestroyScreenScene();
__anon37e36e3f0302() 559     DestroyScreenSceneFunc func2 = []() {
560             EXPECT_TRUE(true);
561         };
562     screenSession->SetScreenSceneDestroyListener(func2);
563     screenSession->DestroyScreenScene();
564     GTEST_LOG_(INFO) << "DestroyScreenScene end";
565 }
566 
567 /**
568  * @tc.name: SetDensityInCurResolution
569  * @tc.desc: normal function
570  * @tc.type: FUNC
571  */
572 HWTEST_F(ScreenSessionTest, SetDensityInCurResolution, Function | SmallTest | Level2)
573 {
574     GTEST_LOG_(INFO) << "SetDensityInCurResolution start";
575     ScreenSessionConfig config = {
576         .screenId = 100,
577         .rsId = 101,
578         .name = "OpenHarmony",
579     };
580     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
581     EXPECT_NE(nullptr, screenSession);
582     float densityInCurResolution = 1.5f;
583     screenSession->SetDensityInCurResolution(densityInCurResolution);
584     GTEST_LOG_(INFO) << "SetDensityInCurResolution end";
585 }
586 
587 /**
588  * @tc.name: GetSourceMode
589  * @tc.desc: normal function
590  * @tc.type: FUNC
591  */
592 HWTEST_F(ScreenSessionTest, GetSourceMode, Function | SmallTest | Level2)
593 {
594     GTEST_LOG_(INFO) << "ScreenSessionTest: GetSourceMode start";
595     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
596     session->screenId_ = session->defaultScreenId_;
597     ScreenSourceMode mode = session->GetSourceMode();
598     ASSERT_EQ(mode, ScreenSourceMode::SCREEN_MAIN);
599     ScreenSessionConfig config = {
600         .screenId = 100,
601         .rsId = 101,
602         .name = "OpenHarmony",
603     };
604     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
605     mode = screenSession->GetSourceMode();
606     ASSERT_EQ(mode, ScreenSourceMode::SCREEN_ALONE);
607     screenSession->SetScreenCombination(ScreenCombination::SCREEN_EXPAND);
608     mode = screenSession->GetSourceMode();
609     ASSERT_EQ(mode, ScreenSourceMode::SCREEN_EXTEND);
610     screenSession->SetScreenCombination(ScreenCombination::SCREEN_MIRROR);
611     mode = screenSession->GetSourceMode();
612     ASSERT_EQ(mode, ScreenSourceMode::SCREEN_MIRROR);
613     screenSession->SetScreenCombination(ScreenCombination::SCREEN_UNIQUE);
614     mode = screenSession->GetSourceMode();
615     ASSERT_EQ(mode, ScreenSourceMode::SCREEN_UNIQUE);
616     GTEST_LOG_(INFO) << "ScreenSessionTest: GetSourceMode end";
617 }
618 
619 /**
620  * @tc.name: GetPixelFormat
621  * @tc.desc: normal function
622  * @tc.type: FUNC
623  */
624 HWTEST_F(ScreenSessionTest, GetPixelFormat, Function | SmallTest | Level2)
625 {
626     GTEST_LOG_(INFO) << "GetPixelFormat start";
627     ScreenSessionConfig config = {
628         .screenId = 100,
629         .rsId = 0,
630         .name = "OpenHarmony",
631     };
632     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
633     EXPECT_NE(nullptr, screenSession);
634     GraphicPixelFormat pixelFormat;
635     auto res = screenSession->GetPixelFormat(pixelFormat);
636     ASSERT_EQ(res, DMError::DM_OK);
637     GTEST_LOG_(INFO) << "GetPixelFormat end";
638 }
639 
640 /**
641  * @tc.name: SetPixelFormat
642  * @tc.desc: normal function
643  * @tc.type: FUNC
644  */
645 HWTEST_F(ScreenSessionTest, SetPixelFormat, Function | SmallTest | Level2)
646 {
647     GTEST_LOG_(INFO) << "SetPixelFormat start";
648     ScreenSessionConfig config = {
649         .screenId = 100,
650         .rsId = 0,
651         .name = "OpenHarmony",
652     };
653     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
654     EXPECT_NE(nullptr, screenSession);
655     GraphicPixelFormat pixelFormat = GraphicPixelFormat{GRAPHIC_PIXEL_FMT_CLUT8};
656     auto res = screenSession->SetPixelFormat(pixelFormat);
657     ASSERT_EQ(res, DMError::DM_OK);
658     GTEST_LOG_(INFO) << "SetPixelFormat end";
659 }
660 
661 /**
662  * @tc.name: GetSupportedHDRFormats
663  * @tc.desc: normal function
664  * @tc.type: FUNC
665  */
666 HWTEST_F(ScreenSessionTest, GetSupportedHDRFormats, Function | SmallTest | Level2)
667 {
668     GTEST_LOG_(INFO) << "GetSupportedHDRFormats start";
669     ScreenSessionConfig config = {
670         .screenId = 100,
671         .rsId = 0,
672         .name = "OpenHarmony",
673     };
674     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
675     EXPECT_NE(nullptr, screenSession);
676     std::vector<ScreenHDRFormat> hdrFormats;
677     auto res = screenSession->GetSupportedHDRFormats(hdrFormats);
678     if (SceneBoardJudgement::IsSceneBoardEnabled()) {
679         ASSERT_EQ(res, DMError::DM_OK);
680     } else {
681         ASSERT_NE(res, DMError::DM_OK);
682     }
683     GTEST_LOG_(INFO) << "GetSupportedHDRFormats end";
684 }
685 
686 /**
687  * @tc.name: GetScreenHDRFormat
688  * @tc.desc: normal function
689  * @tc.type: FUNC
690  */
691 HWTEST_F(ScreenSessionTest, GetScreenHDRFormat, Function | SmallTest | Level2)
692 {
693     GTEST_LOG_(INFO) << "GetScreenHDRFormat start";
694     ScreenSessionConfig config = {
695         .screenId = 100,
696         .rsId = 0,
697         .name = "OpenHarmony",
698     };
699     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
700     EXPECT_NE(nullptr, screenSession);
701     ScreenHDRFormat hdrFormat;
702     auto res = screenSession->GetScreenHDRFormat(hdrFormat);
703     if (SceneBoardJudgement::IsSceneBoardEnabled()) {
704         ASSERT_EQ(res, DMError::DM_OK);
705     } else {
706         ASSERT_NE(res, DMError::DM_OK);
707     }
708     GTEST_LOG_(INFO) << "GetScreenHDRFormat end";
709 }
710 
711 /**
712  * @tc.name: SetScreenHDRFormat
713  * @tc.desc: normal function
714  * @tc.type: FUNC
715  */
716 HWTEST_F(ScreenSessionTest, SetScreenHDRFormat, Function | SmallTest | Level2)
717 {
718     GTEST_LOG_(INFO) << "SetScreenHDRFormat start";
719     ScreenSessionConfig config = {
720         .screenId = 100,
721         .rsId = 0,
722         .name = "OpenHarmony",
723     };
724     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
725     EXPECT_NE(nullptr, screenSession);
726     int32_t modeIdx = 0;
727     auto res = screenSession->SetScreenHDRFormat(modeIdx);
728     if (SceneBoardJudgement::IsSceneBoardEnabled()) {
729         ASSERT_EQ(res, DMError::DM_OK);
730         modeIdx = -1;
731         res = screenSession->SetScreenHDRFormat(modeIdx);
732         ASSERT_EQ(res, DMError::DM_ERROR_INVALID_PARAM);
733     } else {
734         ASSERT_NE(res, DMError::DM_OK);
735     }
736     GTEST_LOG_(INFO) << "SetScreenHDRFormat end";
737 }
738 
739 /**
740  * @tc.name: GetSupportedColorSpaces
741  * @tc.desc: normal function
742  * @tc.type: FUNC
743  */
744 HWTEST_F(ScreenSessionTest, GetSupportedColorSpaces, Function | SmallTest | Level2)
745 {
746     GTEST_LOG_(INFO) << "GetSupportedColorSpaces start";
747     ScreenSessionConfig config = {
748         .screenId = 100,
749         .rsId = 0,
750         .name = "OpenHarmony",
751     };
752     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
753     EXPECT_NE(nullptr, screenSession);
754     std::vector<GraphicCM_ColorSpaceType> colorSpaces;
755     auto res = screenSession->GetSupportedColorSpaces(colorSpaces);
756     if (SceneBoardJudgement::IsSceneBoardEnabled()) {
757         ASSERT_EQ(res, DMError::DM_OK);
758     } else {
759         ASSERT_NE(res, DMError::DM_OK);
760     }
761     GTEST_LOG_(INFO) << "GetSupportedColorSpaces end";
762 }
763 
764 /**
765  * @tc.name: GetScreenColorSpace
766  * @tc.desc: normal function
767  * @tc.type: FUNC
768  */
769 HWTEST_F(ScreenSessionTest, GetScreenColorSpace, Function | SmallTest | Level2)
770 {
771     GTEST_LOG_(INFO) << "GetScreenColorSpace start";
772     ScreenSessionConfig config = {
773         .screenId = 100,
774         .rsId = 0,
775         .name = "OpenHarmony",
776     };
777     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
778     EXPECT_NE(nullptr, screenSession);
779     GraphicCM_ColorSpaceType colorSpace;
780     auto res = screenSession->GetScreenColorSpace(colorSpace);
781     if (SceneBoardJudgement::IsSceneBoardEnabled()) {
782         ASSERT_EQ(res, DMError::DM_OK);
783     } else {
784         ASSERT_NE(res, DMError::DM_OK);
785     }
786     GTEST_LOG_(INFO) << "GetScreenColorSpace end";
787 }
788 
789 /**
790  * @tc.name: SetScreenColorSpace
791  * @tc.desc: normal function
792  * @tc.type: FUNC
793  */
794 HWTEST_F(ScreenSessionTest, SetScreenColorSpace, Function | SmallTest | Level2)
795 {
796     GTEST_LOG_(INFO) << "SetScreenColorSpace start";
797     ScreenSessionConfig config = {
798         .screenId = 100,
799         .rsId = 101,
800         .name = "OpenHarmony",
801     };
802     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
803     EXPECT_NE(nullptr, screenSession);
804     GraphicCM_ColorSpaceType colorSpace = GraphicCM_ColorSpaceType{GRAPHIC_CM_COLORSPACE_NONE};
805     screenSession->SetScreenColorSpace(colorSpace);
806     EXPECT_TRUE(true);
807     GTEST_LOG_(INFO) << "SetScreenColorSpace end";
808 }
809 
810 /**
811  * @tc.name: SetPrivateSessionForeground
812  * @tc.desc: normal function
813  * @tc.type: FUNC
814  */
815 HWTEST_F(ScreenSessionTest, SetPrivateSessionForeground, Function | SmallTest | Level2)
816 {
817     GTEST_LOG_(INFO) << "SetPrivateSessionForeground start";
818     ScreenSessionConfig config = {
819         .screenId = 100,
820         .rsId = 101,
821         .name = "OpenHarmony",
822     };
823     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
824     EXPECT_NE(nullptr, screenSession);
825     bool hasPrivate = true;
826     screenSession->SetPrivateSessionForeground(hasPrivate);
827     auto res = screenSession->HasPrivateSessionForeground();
828     ASSERT_EQ(res, hasPrivate);
829     GTEST_LOG_(INFO) << "SetPrivateSessionForeground end";
830 }
831 
832 /**
833  * @tc.name: GetScreenCombination
834  * @tc.desc: normal function
835  * @tc.type: FUNC
836  */
837 HWTEST_F(ScreenSessionTest, GetScreenCombination, Function | SmallTest | Level2)
838 {
839     GTEST_LOG_(INFO) << "GetScreenCombination start";
840     ScreenSessionConfig config = {
841         .screenId = 100,
842         .rsId = 101,
843         .name = "OpenHarmony",
844     };
845     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
846     EXPECT_NE(nullptr, screenSession);
847     ScreenCombination combination { ScreenCombination::SCREEN_ALONE };
848     screenSession->SetScreenCombination(combination);
849     auto res = screenSession->GetScreenCombination();
850     ASSERT_EQ(res, combination);
851     GTEST_LOG_(INFO) << "GetScreenCombination end";
852 }
853 
854 /**
855  * @tc.name: Resize
856  * @tc.desc: normal function
857  * @tc.type: FUNC
858  */
859 HWTEST_F(ScreenSessionTest, Resize, Function | SmallTest | Level2)
860 {
861     GTEST_LOG_(INFO) << "Resize start";
862     ScreenSessionConfig config = {
863         .screenId = 100,
864         .rsId = 101,
865         .name = "OpenHarmony",
866     };
867     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
868     EXPECT_NE(nullptr, screenSession);
869     uint32_t width = 1000;
870     uint32_t height = 1000;
871     screenSession->Resize(width, height);
872     GTEST_LOG_(INFO) << "Resize end";
873 }
874 
875 /**
876  * @tc.name: UpdateAvailableArea
877  * @tc.desc: normal function
878  * @tc.type: FUNC
879  */
880 HWTEST_F(ScreenSessionTest, UpdateAvailableArea, Function | SmallTest | Level2)
881 {
882     GTEST_LOG_(INFO) << "UpdateAvailableArea start";
883     ScreenSessionConfig config = {
884         .screenId = 100,
885         .rsId = 101,
886         .name = "OpenHarmony",
887     };
888     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
889     EXPECT_NE(nullptr, screenSession);
890     DMRect area = screenSession->GetAvailableArea();
891     auto res = screenSession->UpdateAvailableArea(area);
892     ASSERT_EQ(res, false);
893     area = {2, 2, 2, 2};
894     res = screenSession->UpdateAvailableArea(area);
895     ASSERT_EQ(res, true);
896     GTEST_LOG_(INFO) << "UpdateAvailableArea end";
897 }
898 
899 /**
900  * @tc.name: SetAvailableArea
901  * @tc.desc: normal function
902  * @tc.type: FUNC
903  */
904 HWTEST_F(ScreenSessionTest, SetAvailableArea, Function | SmallTest | Level2)
905 {
906     GTEST_LOG_(INFO) << "SetAvailableArea start";
907     ScreenSessionConfig config = {
908         .screenId = 100,
909         .rsId = 101,
910         .name = "OpenHarmony",
911     };
912     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
913     EXPECT_NE(nullptr, screenSession);
914     DMRect area = {2, 2, 2, 2};
915     screenSession->SetAvailableArea(area);
916     GTEST_LOG_(INFO) << "SetAvailableArea end";
917 }
918 
919 /**
920  * @tc.name: GetAvailableArea
921  * @tc.desc: normal function
922  * @tc.type: FUNC
923  */
924 HWTEST_F(ScreenSessionTest, GetAvailableArea, Function | SmallTest | Level2)
925 {
926     GTEST_LOG_(INFO) << "GetAvailableArea start";
927     ScreenSessionConfig config = {
928         .screenId = 100,
929         .rsId = 101,
930         .name = "OpenHarmony",
931     };
932     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
933     EXPECT_NE(nullptr, screenSession);
934     DMRect area = {2, 2, 2, 2};
935     screenSession->SetAvailableArea(area);
936     auto res = screenSession->GetAvailableArea();
937     ASSERT_EQ(res, area);
938     GTEST_LOG_(INFO) << "GetAvailableArea end";
939 }
940 
941 /**
942  * @tc.name: SetFoldScreen
943  * @tc.desc: normal function
944  * @tc.type: FUNC
945  */
946 HWTEST_F(ScreenSessionTest, SetFoldScreen, Function | SmallTest | Level2)
947 {
948     GTEST_LOG_(INFO) << "SetFoldScreen start";
949     ScreenSessionConfig config = {
950         .screenId = 100,
951         .rsId = 101,
952         .name = "OpenHarmony",
953     };
954     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
955     EXPECT_NE(nullptr, screenSession);
956     bool isFold = false;
957     screenSession->SetFoldScreen(isFold);
958     GTEST_LOG_(INFO) << "SetFoldScreen end";
959 }
960 
961 /**
962  * @tc.name: SetHdrFormats
963  * @tc.desc: normal function
964  * @tc.type: FUNC
965  */
966 HWTEST_F(ScreenSessionTest, SetHdrFormats, Function | SmallTest | Level2)
967 {
968     GTEST_LOG_(INFO) << "SetHdrFormats start";
969     ScreenSessionConfig config = {
970         .screenId = 100,
971         .rsId = 101,
972         .name = "OpenHarmony",
973     };
974     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
975     EXPECT_NE(nullptr, screenSession);
976     std::vector<uint32_t> hdrFormats = { 0, 0, 0, 0 };
977     screenSession->SetHdrFormats(std::move(hdrFormats));
978     GTEST_LOG_(INFO) << "SetHdrFormats end";
979 }
980 
981 /**
982  * @tc.name: SetColorSpaces
983  * @tc.desc: normal function
984  * @tc.type: FUNC
985  */
986 HWTEST_F(ScreenSessionTest, SetColorSpaces, Function | SmallTest | Level2)
987 {
988     GTEST_LOG_(INFO) << "SetColorSpaces start";
989     ScreenSessionConfig config = {
990         .screenId = 100,
991         .rsId = 101,
992         .name = "OpenHarmony",
993     };
994     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
995     EXPECT_NE(nullptr, screenSession);
996     std::vector<uint32_t> colorSpaces = { 0, 0, 0, 0 };
997     screenSession->SetColorSpaces(std::move(colorSpaces));
998     GTEST_LOG_(INFO) << "SetColorSpaces end";
999 }
1000 
1001 /**
1002  * @tc.name: SetDisplayNodeScreenId
1003  * @tc.desc: normal function
1004  * @tc.type: FUNC
1005  */
1006 HWTEST_F(ScreenSessionTest, SetDisplayNodeScreenId, Function | SmallTest | Level2)
1007 {
1008     GTEST_LOG_(INFO) << "ScreenSessionTest: SetDisplayNodeScreenId start";
1009     ScreenId screenId = 0;
1010     ScreenId rsId = 1;
1011     std::string name = "OpenHarmony";
1012     ScreenProperty property;
1013     RSDisplayNodeConfig displayNodeConfig;
1014     std::shared_ptr<RSDisplayNode> displayNode = RSDisplayNode::Create(displayNodeConfig);
1015     EXPECT_NE(nullptr, displayNode);
1016     sptr<ScreenSession> session = new(std::nothrow) ScreenSession(screenId, rsId, name, property, displayNode);
1017     session->SetDisplayNodeScreenId(screenId);
1018     GTEST_LOG_(INFO) << "ScreenSessionTest: SetDisplayNodeScreenId end";
1019 }
1020 
1021 /**
1022  * @tc.name: UnregisterScreenChangeListener
1023  * @tc.desc: normal function
1024  * @tc.type: FUNC
1025  */
1026 HWTEST_F(ScreenSessionTest, UnregisterScreenChangeListener, Function | SmallTest | Level2)
1027 {
1028     GTEST_LOG_(INFO) << "ScreenSessionTest: UnregisterScreenChangeListener start";
1029     IScreenChangeListener* screenChangeListener = nullptr;
1030     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1031     int64_t ret = 0;
1032     session->UnregisterScreenChangeListener(screenChangeListener);
1033     ASSERT_EQ(ret, 0);
1034     GTEST_LOG_(INFO) << "ScreenSessionTest: UnregisterScreenChangeListener end";
1035 }
1036 
1037 /**
1038  * @tc.name: UnregisterScreenChangeListener02
1039  * @tc.desc: normal function
1040  * @tc.type: FUNC
1041  */
1042 HWTEST_F(ScreenSessionTest, UnregisterScreenChangeListener02, Function | SmallTest | Level2)
1043 {
1044     GTEST_LOG_(INFO) << "ScreenSessionTest: UnregisterScreenChangeListener02 start";
1045     IScreenChangeListener* screenChangeListener = new ScreenSessionManager();
1046     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1047     int64_t ret = 0;
1048     session->UnregisterScreenChangeListener(screenChangeListener);
1049     ASSERT_EQ(ret, 0);
1050     GTEST_LOG_(INFO) << "ScreenSessionTest: UnregisterScreenChangeListener02 end";
1051 }
1052 
1053 /**
1054  * @tc.name: ConvertToDisplayInfo
1055  * @tc.desc: normal function
1056  * @tc.type: FUNC
1057  */
1058 HWTEST_F(ScreenSessionTest, ConvertToDisplayInfo, Function | SmallTest | Level2)
1059 {
1060     GTEST_LOG_(INFO) << "ScreenSessionTest: ConvertToDisplayInfo start";
1061     sptr<DisplayInfo> displayInfo = new(std::nothrow) DisplayInfo();
1062     EXPECT_NE(displayInfo, nullptr);
1063     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1064     EXPECT_NE(nullptr, session->ConvertToDisplayInfo());
1065 
1066     sptr<ScreenInfo> info = new(std::nothrow) ScreenInfo();
1067     EXPECT_NE(info, nullptr);
1068     EXPECT_NE(nullptr, session->ConvertToScreenInfo());
1069     GTEST_LOG_(INFO) << "ScreenSessionTest: ConvertToDisplayInfo end";
1070 }
1071 
1072 /**
1073  * @tc.name: GetScreenSupportedColorGamuts
1074  * @tc.desc: normal function
1075  * @tc.type: FUNC
1076  */
1077 HWTEST_F(ScreenSessionTest, GetScreenSupportedColorGamuts, Function | SmallTest | Level2)
1078 {
1079     GTEST_LOG_(INFO) << "ScreenSessionTest: GetScreenSupportedColorGamuts start";
1080     std::vector<ScreenColorGamut> colorGamuts;
1081     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1082     DMError ret = session->GetScreenSupportedColorGamuts(colorGamuts);
1083     if (SceneBoardJudgement::IsSceneBoardEnabled()) {
1084         ASSERT_EQ(ret, DMError::DM_OK);
1085     } else {
1086         ASSERT_NE(ret, DMError::DM_OK);
1087     }
1088     GTEST_LOG_(INFO) << "ScreenSessionTest: GetScreenSupportedColorGamuts end";
1089 }
1090 
1091 /**
1092  * @tc.name: GetActiveScreenMode
1093  * @tc.desc: normal function
1094  * @tc.type: FUNC
1095  */
1096 HWTEST_F(ScreenSessionTest, GetActiveScreenMode, Function | SmallTest | Level2)
1097 {
1098     GTEST_LOG_(INFO) << "ScreenSessionTest: GetActiveScreenMode start";
1099     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1100     session->activeIdx_ = -1;
1101     sptr<SupportedScreenModes> mode1 = session->GetActiveScreenMode();
1102     session->GetActiveScreenMode();
1103     ASSERT_EQ(mode1, nullptr);
1104 
1105     session->activeIdx_ = 100;
1106     sptr<SupportedScreenModes> mode2 = session->GetActiveScreenMode();
1107     session->GetActiveScreenMode();
1108     ASSERT_EQ(mode2, nullptr);
1109 
1110     GTEST_LOG_(INFO) << "ScreenSessionTest: GetActiveScreenMode end";
1111 }
1112 
1113 /**
1114  * @tc.name: SetScreenCombination
1115  * @tc.desc: normal function
1116  * @tc.type: FUNC
1117  */
1118 HWTEST_F(ScreenSessionTest, SetScreenCombination, Function | SmallTest | Level2)
1119 {
1120     GTEST_LOG_(INFO) << "ScreenSessionTest: SetScreenCombination start";
1121     ScreenId screenId = 2024;
1122     ScreenProperty property;
1123     NodeId nodeId = 0;
1124     ScreenId defaultScreenId = 0;
1125     ScreenCombination combination { ScreenCombination::SCREEN_ALONE };
1126     sptr<ScreenSession> session = new(std::nothrow) ScreenSession(screenId, property, nodeId, defaultScreenId);
1127     session->SetScreenCombination(combination);
1128     EXPECT_NE(session, nullptr);
1129     EXPECT_EQ(combination, session->GetScreenCombination());
1130     GTEST_LOG_(INFO) << "ScreenSessionTest: SetScreenCombination end";
1131 }
1132 
1133 /**
1134  * @tc.name: GetScreenColorGamut
1135  * @tc.desc: normal function
1136  * @tc.type: FUNC
1137  */
1138 HWTEST_F(ScreenSessionTest, GetScreenColorGamut, Function | SmallTest | Level2)
1139 {
1140     GTEST_LOG_(INFO) << "ScreenSessionTest: GetScreenColorGamut start";
1141     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1142     ASSERT_NE(session, nullptr);
1143 
1144     ScreenColorGamut colorGamut;
1145     DMError res = session->GetScreenColorGamut(colorGamut);
1146     if (SceneBoardJudgement::IsSceneBoardEnabled()) {
1147         ASSERT_EQ(res, DMError::DM_OK);
1148     } else {
1149         ASSERT_NE(res, DMError::DM_OK);
1150     }
1151     GTEST_LOG_(INFO) << "ScreenSessionTest: GetScreenColorGamut end";
1152 }
1153 
1154 /**
1155  * @tc.name: SetScreenColorGamut
1156  * @tc.desc: normal function
1157  * @tc.type: FUNC
1158  */
1159 HWTEST_F(ScreenSessionTest, SetScreenColorGamut, Function | SmallTest | Level2)
1160 {
1161     GTEST_LOG_(INFO) << "ScreenSessionTest: SetScreenColorGamut start";
1162     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1163     ASSERT_NE(session, nullptr);
1164 
1165     int32_t colorGamut = 1;
1166     DMError res = session->SetScreenColorGamut(colorGamut);
1167     ASSERT_EQ(res, DMError::DM_ERROR_RENDER_SERVICE_FAILED);
1168     GTEST_LOG_(INFO) << "ScreenSessionTest: SetScreenColorGamut end";
1169 }
1170 
1171 /**
1172  * @tc.name: GetScreenGamutMap
1173  * @tc.desc: normal function
1174  * @tc.type: FUNC
1175  */
1176 HWTEST_F(ScreenSessionTest, GetScreenGamutMap, Function | SmallTest | Level2)
1177 {
1178     GTEST_LOG_(INFO) << "ScreenSessionTest: GetScreenGamutMap start";
1179     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1180     ASSERT_NE(session, nullptr);
1181 
1182     ScreenGamutMap gamutMap;
1183     DMError res = session->GetScreenGamutMap(gamutMap);
1184     ASSERT_EQ(res, DMError::DM_ERROR_RENDER_SERVICE_FAILED);
1185     GTEST_LOG_(INFO) << "ScreenSessionTest: GetScreenGamutMap end";
1186 }
1187 
1188 /**
1189  * @tc.name: SetScreenGamutMap
1190  * @tc.desc: normal function
1191  * @tc.type: FUNC
1192  */
1193 HWTEST_F(ScreenSessionTest, SetScreenGamutMap, Function | SmallTest | Level2)
1194 {
1195     GTEST_LOG_(INFO) << "ScreenSessionTest: SetScreenGamutMap start";
1196     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1197     ASSERT_NE(session, nullptr);
1198     ScreenGamutMap gamutMap = GAMUT_MAP_CONSTANT;
1199     DMError res = session->SetScreenGamutMap(gamutMap);
1200     ASSERT_EQ(res, DMError::DM_ERROR_RENDER_SERVICE_FAILED);
1201 
1202     gamutMap = GAMUT_MAP_HDR_EXTENSION;
1203     res = session->SetScreenGamutMap(gamutMap);
1204     ASSERT_EQ(res, DMError::DM_ERROR_RENDER_SERVICE_FAILED);
1205     GTEST_LOG_(INFO) << "ScreenSessionTest: SetScreenGamutMap end";
1206 }
1207 
1208 /**
1209  * @tc.name: InitRSDisplayNode
1210  * @tc.desc: normal function
1211  * @tc.type: FUNC
1212  */
1213 HWTEST_F(ScreenSessionTest, InitRSDisplayNode, Function | SmallTest | Level2)
1214 {
1215     GTEST_LOG_(INFO) << "ScreenSessionTest: InitRSDisplayNode start";
1216     ScreenSessionGroup sessionGroup(1, 1, "create", ScreenCombination::SCREEN_ALONE);
1217     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1218     ASSERT_NE(session, nullptr);
1219     RSDisplayNodeConfig config;
1220     Point startPoint;
1221     int res = 0;
1222     sessionGroup.InitRSDisplayNode(config, startPoint);
1223     ASSERT_EQ(res, 0);
1224     GTEST_LOG_(INFO) << "ScreenSessionTest: InitRSDisplayNode end";
1225 }
1226 
1227 /**
1228  * @tc.name: GetRSDisplayNodeConfig
1229  * @tc.desc: normal function
1230  * @tc.type: FUNC
1231  */
1232 HWTEST_F(ScreenSessionTest, GetRSDisplayNodeConfig, Function | SmallTest | Level2)
1233 {
1234     GTEST_LOG_(INFO) << "ScreenSessionTest: GetRSDisplayNodeConfig start";
1235     ScreenSessionGroup sessionGroup(1, 1, "create", ScreenCombination::SCREEN_ALONE);
1236     sptr<ScreenSession> session0 = nullptr;
1237     RSDisplayNodeConfig config = {1};
1238     sptr<ScreenSession> defaultScreenSession;
1239     bool res = sessionGroup.GetRSDisplayNodeConfig(session0, config, defaultScreenSession);
1240     ASSERT_EQ(res, false);
1241 
1242     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1243     sessionGroup.combination_ = ScreenCombination::SCREEN_ALONE;
1244     res = sessionGroup.GetRSDisplayNodeConfig(session, config, defaultScreenSession);
1245     ASSERT_EQ(res, true);
1246 
1247     sessionGroup.combination_ = ScreenCombination::SCREEN_EXPAND;
1248     res = sessionGroup.GetRSDisplayNodeConfig(session, config, defaultScreenSession);
1249     ASSERT_EQ(res, true);
1250 
1251     sessionGroup.combination_ = ScreenCombination::SCREEN_MIRROR;
1252     res = sessionGroup.GetRSDisplayNodeConfig(session, config, defaultScreenSession);
1253     ASSERT_EQ(res, true);
1254     GTEST_LOG_(INFO) << "ScreenSessionTest: GetRSDisplayNodeConfig end";
1255 }
1256 
1257 /**
1258  * @tc.name: AddChild
1259  * @tc.desc: normal function
1260  * @tc.type: FUNC
1261  */
1262 HWTEST_F(ScreenSessionTest, AddChild, Function | SmallTest | Level2)
1263 {
1264     GTEST_LOG_(INFO) << "ScreenSessionTest: AddChild start";
1265     ScreenSessionGroup sessionGroup(1, 1, "create", ScreenCombination::SCREEN_ALONE);
1266     sptr<ScreenSession> session0 = nullptr;
1267     Point startPoint(0, 0);
1268     sptr<ScreenSession> defaultScreenSession;
1269     bool res = sessionGroup.AddChild(session0, startPoint, defaultScreenSession);
1270     ASSERT_EQ(res, false);
1271 
1272     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1273     res = sessionGroup.AddChild(session, startPoint, defaultScreenSession);
1274     ASSERT_EQ(res, true);
1275     GTEST_LOG_(INFO) << "ScreenSessionTest: AddChild end";
1276 }
1277 
1278 /**
1279  * @tc.name: AddChildren
1280  * @tc.desc: normal function
1281  * @tc.type: FUNC
1282  */
1283 HWTEST_F(ScreenSessionTest, AddChildren, Function | SmallTest | Level2)
1284 {
1285     GTEST_LOG_(INFO) << "ScreenSessionTest: AddChildren start";
1286     ScreenSessionGroup sessionGroup(1, 1, "create", ScreenCombination::SCREEN_ALONE);
1287     std::vector<sptr<ScreenSession>> smsScreens;
1288     std::vector<Point> startPoints;
1289     bool res = sessionGroup.AddChildren(smsScreens, startPoints);
1290     ASSERT_EQ(res, true);
1291     GTEST_LOG_(INFO) << "ScreenSessionTest: AddChildren end";
1292 }
1293 
1294 /**
1295  * @tc.name: RemoveChild
1296  * @tc.desc: normal function
1297  * @tc.type: FUNC
1298  */
1299 HWTEST_F(ScreenSessionTest, RemoveChild, Function | SmallTest | Level2)
1300 {
1301     GTEST_LOG_(INFO) << "ScreenSessionTest: RemoveChild start";
1302     ScreenSessionGroup sessionGroup(1, 1, "create", ScreenCombination::SCREEN_ALONE);
1303     sptr<ScreenSession> session0 = nullptr;
1304     bool res = sessionGroup.RemoveChild(session0);
1305     ASSERT_EQ(res, false);
1306 
1307     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1308     res = sessionGroup.RemoveChild(session);
1309     ASSERT_EQ(res, false);
1310     GTEST_LOG_(INFO) << "ScreenSessionTest: GetRSDisplayNodeConfig end";
1311 }
1312 
1313 /**
1314  * @tc.name: GetChildPosition
1315  * @tc.desc: normal function
1316  * @tc.type: FUNC
1317  */
1318 HWTEST_F(ScreenSessionTest, GetChildPosition, Function | SmallTest | Level2)
1319 {
1320     GTEST_LOG_(INFO) << "ScreenSessionTest: GetChildPosition start";
1321     ScreenSessionGroup sessionGroup(1, 1, "create", ScreenCombination::SCREEN_ALONE);
1322     ScreenId screenId = 1;
1323     Point res = sessionGroup.GetChildPosition(screenId);
1324     ASSERT_EQ(res.posX_, 0);
1325     GTEST_LOG_(INFO) << "ScreenSessionTest: GetChildPosition end";
1326 }
1327 
1328 /**
1329  * @tc.name: ConvertToScreenGroupInfo
1330  * @tc.desc: normal function
1331  * @tc.type: FUNC
1332  */
1333 HWTEST_F(ScreenSessionTest, ConvertToScreenGroupInfo, Function | SmallTest | Level2)
1334 {
1335     GTEST_LOG_(INFO) << "ScreenSessionTest: ConvertToScreenGroupInfo start";
1336     ScreenSessionGroup sessionGroup(1, 1, "create", ScreenCombination::SCREEN_ALONE);
1337     sptr<ScreenGroupInfo> res = sessionGroup.ConvertToScreenGroupInfo();
1338     ASSERT_NE(res, nullptr);
1339     GTEST_LOG_(INFO) << "ScreenSessionTest: ConvertToScreenGroupInfo end";
1340 }
1341 
1342 /**
1343  * @tc.name: RegisterScreenChangeListener
1344  * @tc.desc: normal function
1345  * @tc.type: FUNC
1346  */
1347 HWTEST_F(ScreenSessionTest, RegisterScreenChangeListener01, Function | SmallTest | Level2)
1348 {
1349     GTEST_LOG_(INFO) << "ScreenSessionTest: RegisterScreenChangeListener start";
1350     int res = 0;
1351     IScreenChangeListener* screenChangeListener = nullptr;
1352     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1353     session->RegisterScreenChangeListener(screenChangeListener);
1354     ASSERT_EQ(res, 0);
1355     GTEST_LOG_(INFO) << "ScreenSessionTest: RegisterScreenChangeListener end";
1356 }
1357 
1358 /**
1359  * @tc.name: RegisterScreenChangeListener
1360  * @tc.desc: Repeat to register
1361  * @tc.type: FUNC
1362  */
1363 HWTEST_F(ScreenSessionTest, RegisterScreenChangeListener02, Function | SmallTest | Level2)
1364 {
1365     GTEST_LOG_(INFO) << "ScreenSessionTest: RegisterScreenChangeListener start";
1366     IScreenChangeListener* screenChangeListener = new MockScreenChangeListener();
1367     IScreenChangeListener* screenChangeListener1 = new MockScreenChangeListener();
1368     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1369     session->RegisterScreenChangeListener(screenChangeListener);
1370     session->RegisterScreenChangeListener(screenChangeListener1);
1371     ASSERT_FALSE(session->isFold_);
1372 }
1373 
1374 /**
1375  * @tc.name: RegisterScreenChangeListener
1376  * @tc.desc: screenState_ == ScreenState::CONNECTION
1377  * @tc.type: FUNC
1378  */
1379 HWTEST_F(ScreenSessionTest, RegisterScreenChangeListener03, Function | SmallTest | Level2)
1380 {
1381     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1382     ASSERT_EQ(session->screenState_, ScreenState::INIT);
1383     session->screenState_ = ScreenState::CONNECTION;
1384     IScreenChangeListener* screenChangeListener = new MockScreenChangeListener();
1385     session->RegisterScreenChangeListener(screenChangeListener);
1386     ASSERT_FALSE(session->isFold_);
1387     session->screenState_ = ScreenState::INIT;
1388 }
1389 
1390 /**
1391  * @tc.name: Connect
1392  * @tc.desc: Connect
1393  * @tc.type: FUNC
1394  */
1395 HWTEST_F(ScreenSessionTest, Connect, Function | SmallTest | Level2)
1396 {
1397     IScreenChangeListener* screenChangeListener = new MockScreenChangeListener();
1398     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1399     session->RegisterScreenChangeListener(screenChangeListener);
1400     session->Connect();
1401     ASSERT_FALSE(session->isFold_);
1402 }
1403 
1404 /**
1405  * @tc.name: UpdatePropertyByActiveMode
1406  * @tc.desc: normal function
1407  * @tc.type: FUNC
1408  */
1409 HWTEST_F(ScreenSessionTest, UpdatePropertyByActiveMode, Function | SmallTest | Level2)
1410 {
1411     GTEST_LOG_(INFO) << "ScreenSessionTest: UpdatePropertyByActiveMode start";
1412     int res = 0;
1413     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1414     session->UpdatePropertyByActiveMode();
1415     ASSERT_EQ(res, 0);
1416     GTEST_LOG_(INFO) << "ScreenSessionTest: UpdatePropertyByActiveMode end";
1417 }
1418 
1419 /**
1420  * @tc.name: Disconnect
1421  * @tc.desc: normal function
1422  * @tc.type: FUNC
1423  */
1424 HWTEST_F(ScreenSessionTest, Disconnect, Function | SmallTest | Level2)
1425 {
1426     GTEST_LOG_(INFO) << "ScreenSessionTest: Disconnect start";
1427     int res = 0;
1428     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1429     session->Disconnect();
1430     ASSERT_EQ(res, 0);
1431     GTEST_LOG_(INFO) << "ScreenSessionTest: Disconnect end";
1432 }
1433 
1434 /**
1435  * @tc.name: Disconnect
1436  * @tc.desc: !listener
1437  * @tc.type: FUNC
1438  */
1439 HWTEST_F(ScreenSessionTest, Disconnect02, Function | SmallTest | Level2)
1440 {
1441     IScreenChangeListener* screenChangeListener = new MockScreenChangeListener();
1442     IScreenChangeListener* screenChangeListener1 = new MockScreenChangeListener();
1443     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1444     sptr<ScreenSession> session1 = new(std::nothrow) ScreenSession();
1445     session->RegisterScreenChangeListener(screenChangeListener);
1446     session1->RegisterScreenChangeListener(screenChangeListener1);
1447     session1->Connect();
1448     session1->Disconnect();
1449     ASSERT_FALSE(session->isFold_);
1450 }
1451 
1452 /**
1453  * @tc.name: SensorRotationChange
1454  * @tc.desc: normal function
1455  * @tc.type: FUNC
1456  */
1457 HWTEST_F(ScreenSessionTest, SensorRotationChange01, Function | SmallTest | Level2)
1458 {
1459     GTEST_LOG_(INFO) << "ScreenSessionTest: SensorRotationChange start";
1460     int res = 0;
1461     Rotation sensorRotation = Rotation::ROTATION_0;
1462     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1463     session->SensorRotationChange(sensorRotation);
1464     ASSERT_EQ(res, 0);
1465     GTEST_LOG_(INFO) << "ScreenSessionTest: SensorRotationChange end";
1466 }
1467 
1468 /**
1469  * @tc.name: SensorRotationChange
1470  * @tc.desc: run in for
1471  * @tc.type: FUNC
1472  */
1473 HWTEST_F(ScreenSessionTest, SensorRotationChange02, Function | SmallTest | Level2)
1474 {
1475     IScreenChangeListener* screenChangeListener = new MockScreenChangeListener();
1476     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1477     session->RegisterScreenChangeListener(screenChangeListener);
1478     Rotation sensorRotation = Rotation::ROTATION_90;
1479     session->SensorRotationChange(sensorRotation);
1480     ASSERT_FALSE(session->isFold_);
1481 }
1482 
1483 /**
1484  * @tc.name: SetOrientation
1485  * @tc.desc: normal function
1486  * @tc.type: FUNC
1487  */
1488 HWTEST_F(ScreenSessionTest, SetOrientation, Function | SmallTest | Level2)
1489 {
1490     GTEST_LOG_(INFO) << "ScreenSessionTest: SetOrientation start";
1491     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1492     Orientation orientation = Orientation::UNSPECIFIED;
1493     session->SetOrientation(orientation);
1494     Orientation res = session->GetOrientation();
1495     ASSERT_EQ(res, orientation);
1496     GTEST_LOG_(INFO) << "ScreenSessionTest: SetOrientation end";
1497 }
1498 
1499 /**
1500  * @tc.name: SetScreenRequestedOrientation
1501  * @tc.desc: normal function
1502  * @tc.type: FUNC
1503  */
1504 HWTEST_F(ScreenSessionTest, SetScreenRequestedOrientation, Function | SmallTest | Level2)
1505 {
1506     GTEST_LOG_(INFO) << "ScreenSessionTest: SetScreenRequestedOrientation start";
1507     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1508     Orientation orientation = Orientation::UNSPECIFIED;
1509     session->SetScreenRequestedOrientation(orientation);
1510     Orientation res = session->GetScreenRequestedOrientation();
1511     ASSERT_EQ(res, orientation);
1512     GTEST_LOG_(INFO) << "ScreenSessionTest: SetScreenRequestedOrientation end";
1513 }
1514 
1515 /**
1516  * @tc.name: SetUpdateToInputManagerCallback
1517  * @tc.desc: normal function
1518  * @tc.type: FUNC
1519  */
1520 HWTEST_F(ScreenSessionTest, SetUpdateToInputManagerCallback, Function | SmallTest | Level2)
1521 {
1522     GTEST_LOG_(INFO) << "ScreenSessionTest: SetUpdateToInputManagerCallback start";
1523     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
__anon37e36e3f0402(float x) 1524     auto func = [session](float x) {
1525         session->SetVirtualPixelRatio(x);
1526     };
1527     session->SetUpdateToInputManagerCallback(func);
1528     EXPECT_NE(nullptr, &func);
1529 
1530     ScreenProperty screenPropert = session->GetScreenProperty();
1531     EXPECT_NE(nullptr, &screenPropert);
1532     session->SetVirtualPixelRatio(3.14);
1533 
1534     ScreenType screenType { ScreenType::REAL };
1535     session->SetScreenType(screenType);
1536 
1537     GTEST_LOG_(INFO) << "ScreenSessionTest: SetUpdateToInputManagerCallbackend";
1538 }
1539 /**
1540  * @tc.name: SetScreenRotationLocked
1541  * @tc.desc: normal function
1542  * @tc.type: FUNC
1543  */
1544 HWTEST_F(ScreenSessionTest, SetScreenRotationLocked, Function | SmallTest | Level2)
1545 {
1546     GTEST_LOG_(INFO) << "ScreenSessionTest: SetScreenRotationLocked start";
1547     bool isLocked = true;
1548     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1549     session->SetScreenRotationLocked(isLocked);
1550     bool res = session->IsScreenRotationLocked();
1551     ASSERT_EQ(res, isLocked);
1552     GTEST_LOG_(INFO) << "ScreenSessionTest: SetScreenRotationLocked end";
1553 }
1554 
1555 /**
1556  * @tc.name: SetScreenRotationLockedFromJs
1557  * @tc.desc: normal function
1558  * @tc.type: FUNC
1559  */
1560 HWTEST_F(ScreenSessionTest, SetScreenRotationLockedFromJs, Function | SmallTest | Level2)
1561 {
1562     GTEST_LOG_(INFO) << "ScreenSessionTest: SetScreenRotationLockedFromJs start";
1563     bool isLocked = true;
1564     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1565     session->SetScreenRotationLockedFromJs(isLocked);
1566     bool res = session->IsScreenRotationLocked();
1567     ASSERT_EQ(res, isLocked);
1568     GTEST_LOG_(INFO) << "ScreenSessionTest: SetScreenRotationLockedFromJs end";
1569 }
1570 
1571 /**
1572  * @tc.name: IsScreenRotationLocked
1573  * @tc.desc: normal function
1574  * @tc.type: FUNC
1575  */
1576 HWTEST_F(ScreenSessionTest, IsScreenRotationLocked, Function | SmallTest | Level2)
1577 {
1578     GTEST_LOG_(INFO) << "ScreenSessionTest: IsScreenRotationLocked start";
1579     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1580     bool res = session->IsScreenRotationLocked();
1581     ASSERT_EQ(res, session->isScreenLocked_);
1582     GTEST_LOG_(INFO) << "ScreenSessionTest: IsScreenRotationLocked end";
1583 }
1584 
1585 /**
1586  * @tc.name: GetScreenRequestedOrientation
1587  * @tc.desc: normal function
1588  * @tc.type: FUNC
1589  */
1590 HWTEST_F(ScreenSessionTest, GetScreenRequestedOrientation, Function | SmallTest | Level2)
1591 {
1592     GTEST_LOG_(INFO) << "ScreenSessionTest: GetScreenRequestedOrientation start";
1593     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1594     Orientation res = session->GetScreenRequestedOrientation();
1595     ASSERT_EQ(res, session->property_.GetScreenRequestedOrientation());
1596     GTEST_LOG_(INFO) << "ScreenSessionTest: GetScreenRequestedOrientation end";
1597 }
1598 
1599 /**
1600  * @tc.name: SetVirtualPixelRatio
1601  * @tc.desc: normal function
1602  * @tc.type: FUNC
1603  */
1604 HWTEST_F(ScreenSessionTest, SetVirtualPixelRatio, Function | SmallTest | Level2)
1605 {
1606     GTEST_LOG_(INFO) << "ScreenSessionTest: SetVirtualPixelRatio start";
1607     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1608     float virtualPixelRatio = 1;
1609     session->SetVirtualPixelRatio(virtualPixelRatio);
1610     float res = session->property_.GetVirtualPixelRatio();
1611     ASSERT_EQ(res, virtualPixelRatio);
1612     GTEST_LOG_(INFO) << "ScreenSessionTest: SetVirtualPixelRatio end";
1613 }
1614 
1615 /**
1616  * @tc.name: screen_session_test001
1617  * @tc.desc: normal function
1618  * @tc.type: FUNC
1619  */
1620 HWTEST_F(ScreenSessionTest, screen_session_test001, Function | SmallTest | Level2)
1621 {
1622     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test001 start";
1623     IScreenChangeListener* screenChangeListener = nullptr;
1624     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1625     session->screenState_ = ScreenState::CONNECTION;
1626     int res = 0;
1627     session->RegisterScreenChangeListener(screenChangeListener);
1628     ASSERT_EQ(res, 0);
1629     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test001 end";
1630 }
1631 
1632 /**
1633  * @tc.name: screen_session_test002
1634  * @tc.desc: normal function
1635  * @tc.type: FUNC
1636  */
1637 HWTEST_F(ScreenSessionTest, screen_session_test002, Function | SmallTest | Level2)
1638 {
1639     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test002 start";
1640     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1641     ScreenId res = session->GetScreenId();
1642     ASSERT_EQ(res, session->screenId_);
1643     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test002 end";
1644 }
1645 
1646 /**
1647  * @tc.name: screen_session_test003
1648  * @tc.desc: normal function
1649  * @tc.type: FUNC
1650  */
1651 HWTEST_F(ScreenSessionTest, screen_session_test003, Function | SmallTest | Level2)
1652 {
1653     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test003 start";
1654     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1655     DMError res = session->SetScreenColorTransform();
1656     ASSERT_EQ(res, DMError::DM_OK);
1657     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test003 end";
1658 }
1659 
1660 /**
1661  * @tc.name: screen_session_test004
1662  * @tc.desc: normal function
1663  * @tc.type: FUNC
1664  */
1665 HWTEST_F(ScreenSessionTest, screen_session_test004, Function | SmallTest | Level2)
1666 {
1667     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test004 start";
1668     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1669     ScreenProperty newProperty;
1670     int res = 0;
1671     session->UpdatePropertyByFoldControl(newProperty);
1672     ASSERT_EQ(res, 0);
1673     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test004 end";
1674 }
1675 
1676 /**
1677  * @tc.name: screen_session_test005
1678  * @tc.desc: normal function
1679  * @tc.type: FUNC
1680  */
1681 HWTEST_F(ScreenSessionTest, screen_session_test005, Function | SmallTest | Level2)
1682 {
1683     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test005 start";
1684     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1685     ScreenProperty newProperty;
1686     ScreenPropertyChangeReason reason = ScreenPropertyChangeReason::CHANGE_MODE;
1687     int res = 0;
1688     session->PropertyChange(newProperty, reason);
1689     ASSERT_EQ(res, 0);
1690     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test005 end";
1691 }
1692 
1693 /**
1694  * @tc.name: screen_session_test006
1695  * @tc.desc: normal function
1696  * @tc.type: FUNC
1697  */
1698 HWTEST_F(ScreenSessionTest, screen_session_test006, Function | SmallTest | Level2)
1699 {
1700     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test006 start";
1701     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1702     Rotation sensorRotation = Rotation::ROTATION_90;
1703     float res = session->ConvertRotationToFloat(sensorRotation);
1704     ASSERT_EQ(res, 90.f);
1705     sensorRotation = Rotation::ROTATION_180;
1706     res = session->ConvertRotationToFloat(sensorRotation);
1707     ASSERT_EQ(res, 180.f);
1708     sensorRotation = Rotation::ROTATION_270;
1709     res = session->ConvertRotationToFloat(sensorRotation);
1710     ASSERT_EQ(res, 270.f);
1711     sensorRotation = Rotation::ROTATION_0;
1712     res = session->ConvertRotationToFloat(sensorRotation);
1713     ASSERT_EQ(res, 0.f);
1714     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test006 end";
1715 }
1716 
1717 /**
1718  * @tc.name: screen_session_test007
1719  * @tc.desc: normal function
1720  * @tc.type: FUNC
1721  */
1722 HWTEST_F(ScreenSessionTest, screen_session_test007, Function | SmallTest | Level2)
1723 {
1724     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test007 start";
1725     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1726     Orientation orientation = Orientation::UNSPECIFIED;
1727     int res = 0;
1728     session->ScreenOrientationChange(orientation, FoldDisplayMode::UNKNOWN);
1729     ASSERT_EQ(res, 0);
1730     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test007 end";
1731 }
1732 
1733 /**
1734  * @tc.name: screen_session_test008
1735  * @tc.desc: normal function
1736  * @tc.type: FUNC
1737  */
1738 HWTEST_F(ScreenSessionTest, screen_session_test008, Function | SmallTest | Level2)
1739 {
1740     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test008 start";
1741     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1742     bool res = session->HasPrivateSessionForeground();
1743     ASSERT_EQ(res, false);
1744     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test008 end";
1745 }
1746 
1747 /**
1748  * @tc.name: screen_session_test009
1749  * @tc.desc: normal function
1750  * @tc.type: FUNC
1751  */
1752 HWTEST_F(ScreenSessionTest, screen_session_test009, Function | SmallTest | Level2)
1753 {
1754     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test009 start";
1755     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1756     Rotation rotation = Rotation::ROTATION_90;
1757     session->SetRotation(rotation);
1758     Rotation res = session->GetRotation();
1759     ASSERT_EQ(res, rotation);
1760     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test009 end";
1761 }
1762 
1763 /**
1764  * @tc.name: screen_session_test010
1765  * @tc.desc: normal function
1766  * @tc.type: FUNC
1767  */
1768 HWTEST_F(ScreenSessionTest, screen_session_test010, Function | SmallTest | Level2)
1769 {
1770     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test010 start";
1771     ScreenSessionGroup sessionGroup(1, 1, "create", ScreenCombination::SCREEN_ALONE);
1772     ScreenId childScreen = 1;
1773     bool res = sessionGroup.HasChild(childScreen);
1774     ASSERT_EQ(res, false);
1775     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test010 end";
1776 }
1777 
1778 /**
1779  * @tc.name: screen_session_test011
1780  * @tc.desc: normal function
1781  * @tc.type: FUNC
1782  */
1783 HWTEST_F(ScreenSessionTest, screen_session_test011, Function | SmallTest | Level2)
1784 {
1785     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test011 start";
1786     ScreenSessionGroup sessionGroup(1, 1, "create", ScreenCombination::SCREEN_ALONE);
1787     std::vector<sptr<ScreenSession>> res = sessionGroup.GetChildren();
1788     ASSERT_EQ(res.empty(), true);
1789     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test011 end";
1790 }
1791 
1792 /**
1793  * @tc.name: screen_session_test012
1794  * @tc.desc: normal function
1795  * @tc.type: FUNC
1796  */
1797 HWTEST_F(ScreenSessionTest, screen_session_test012, Function | SmallTest | Level2)
1798 {
1799     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test012 start";
1800     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1801     int res = 0;
1802     RectF rect = RectF(0, 0, 0, 0);
1803     uint32_t offsetY = 0;
1804     session->SetDisplayBoundary(rect, offsetY);
1805     ASSERT_EQ(res, 0);
1806     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test012 end";
1807 }
1808 
1809 /**
1810  * @tc.name: GetName
1811  * @tc.desc: normal function
1812  * @tc.type: FUNC
1813  */
1814 HWTEST_F(ScreenSessionTest, GetName, Function | SmallTest | Level2)
1815 {
1816     GTEST_LOG_(INFO) << "ScreenSessionTest: GetName start";
1817     std::string name { "UNKNOWN" };
1818     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1819     ASSERT_EQ(name, session->GetName());
1820     GTEST_LOG_(INFO) << "ScreenSessionTest: GetName end";
1821 }
1822 
1823 /**
1824  * @tc.name: SetName
1825  * @tc.desc: normal function
1826  * @tc.type: FUNC
1827  */
1828 HWTEST_F(ScreenSessionTest, SetName, Function | SmallTest | Level2)
1829 {
1830     GTEST_LOG_(INFO) << "ScreenSessionTest: SetName start";
1831     std::string name { "UNKNOWN" };
1832     int ret = 0;
1833     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1834     session->SetName(name);
1835     ASSERT_EQ(ret, 0);
1836     GTEST_LOG_(INFO) << "ScreenSessionTest: SetName end";
1837 }
1838 
1839 /**
1840  * @tc.name: GetScreenSnapshot
1841  * @tc.desc: normal function
1842  * @tc.type: FUNC
1843  */
1844 HWTEST_F(ScreenSessionTest, GetScreenSnapshot, Function | SmallTest | Level2)
1845 {
1846     GTEST_LOG_(INFO) << "ScreenSessionTest: GetScreenSnapshot start";
1847     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1848     session->displayNode_ = nullptr;
1849     auto pixelmap = session->GetScreenSnapshot(1.0, 1.0);
1850     EXPECT_EQ(pixelmap, nullptr);
1851 
1852     ScreenProperty newScreenProperty;
1853     session = new(std::nothrow) ScreenSession(0, newScreenProperty, 0);
1854     pixelmap = session->GetScreenSnapshot(1.0, 1.0);
1855     int ret = 0;
1856     ASSERT_EQ(ret, 0);
1857     GTEST_LOG_(INFO) << "ScreenSessionTest: GetScreenSnapshot end";
1858 }
1859 
1860 /**
1861  * @tc.name: GetRSScreenId
1862  * @tc.desc: normal function
1863  * @tc.type: FUNC
1864  */
1865 HWTEST_F(ScreenSessionTest, GetRSScreenId, Function | SmallTest | Level2)
1866 {
1867     GTEST_LOG_(INFO) << "ScreenSessionTest: GetRSScreenId start";
1868     ScreenProperty property;
1869     sptr<ScreenSession> session = new(std::nothrow)
1870         ScreenSession("OpenHarmony", 1, 100, 0);
1871     EXPECT_EQ(100, session->GetRSScreenId());
1872 
1873     RSDisplayNodeConfig displayNodeConfig;
1874     std::shared_ptr<RSDisplayNode> displayNode = RSDisplayNode::Create(displayNodeConfig);
1875     session = new ScreenSession(1, 100, "OpenHarmony",
1876         property, displayNode);
1877     EXPECT_NE(nullptr, session->GetDisplayNode());
1878     session->ReleaseDisplayNode();
1879     EXPECT_EQ(nullptr, session->GetDisplayNode());
1880     GTEST_LOG_(INFO) << "ScreenSessionTest: GetRSScreenId end";
1881 }
1882 
1883 /**
1884  * @tc.name: CalcRotation
1885  * @tc.desc: normal function
1886  * @tc.type: FUNC
1887  */
1888 HWTEST_F(ScreenSessionTest, CalcRotation, Function | SmallTest | Level2)
1889 {
1890     GTEST_LOG_(INFO) << "ScreenSessionTest: CalcRotation start";
1891     Orientation orientation { Orientation::BEGIN };
1892     FoldDisplayMode foldDisplayMode { FoldDisplayMode::COORDINATION };
1893     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1894     session->activeIdx_ = -1;
1895     auto res = session->CalcRotation(orientation, foldDisplayMode);
1896     EXPECT_EQ(Rotation::ROTATION_0, res);
1897 
1898     sptr<SupportedScreenModes> supportedScreenModes = new SupportedScreenModes;
1899     supportedScreenModes->width_ = 40;
1900     supportedScreenModes->height_ = 20;
1901     session->modes_ = { supportedScreenModes };
1902     session->activeIdx_ = 0;
1903 
1904     orientation = Orientation::UNSPECIFIED;
1905     res = session->CalcRotation(orientation, foldDisplayMode);
1906     EXPECT_EQ(Rotation::ROTATION_0, res);
1907 
1908     orientation = Orientation::VERTICAL;
1909     res = session->CalcRotation(orientation, foldDisplayMode);
1910     if (ScreenSessionManager::GetInstance().IsFoldable()) {
1911         EXPECT_EQ(Rotation::ROTATION_0, res);
1912     } else {
1913         EXPECT_EQ(Rotation::ROTATION_90, res);
1914     }
1915 
1916     orientation = Orientation::HORIZONTAL;
1917     res = session->CalcRotation(orientation, foldDisplayMode);
1918     if (ScreenSessionManager::GetInstance().IsFoldable()) {
1919         EXPECT_EQ(Rotation::ROTATION_90, res);
1920     } else {
1921         EXPECT_EQ(Rotation::ROTATION_0, res);
1922     }
1923 
1924     orientation = Orientation::REVERSE_VERTICAL;
1925     res = session->CalcRotation(orientation, foldDisplayMode);
1926     if (ScreenSessionManager::GetInstance().IsFoldable()) {
1927         EXPECT_EQ(Rotation::ROTATION_180, res);
1928     } else {
1929         EXPECT_EQ(Rotation::ROTATION_270, res);
1930     }
1931 
1932     orientation = Orientation::REVERSE_HORIZONTAL;
1933     res = session->CalcRotation(orientation, foldDisplayMode);
1934     if (ScreenSessionManager::GetInstance().IsFoldable()) {
1935         EXPECT_EQ(Rotation::ROTATION_270, res);
1936     } else {
1937         EXPECT_EQ(Rotation::ROTATION_180, res);
1938     }
1939 
1940     orientation = Orientation::LOCKED;
1941     res = session->CalcRotation(orientation, foldDisplayMode);
1942     EXPECT_EQ(Rotation::ROTATION_0, res);
1943 
1944     GTEST_LOG_(INFO) << "ScreenSessionTest: CalcRotation end";
1945 }
1946 
1947 /**
1948  * @tc.name: CalcDisplayOrientation
1949  * @tc.desc: normal function
1950  * @tc.type: FUNC
1951  */
1952 HWTEST_F(ScreenSessionTest, CalcDisplayOrientation, Function | SmallTest | Level2)
1953 {
1954     GTEST_LOG_(INFO) << "ScreenSessionTest: CalcDisplayOrientation start";
1955     Rotation rotation { Rotation::ROTATION_0 };
1956     FoldDisplayMode foldDisplayMode { FoldDisplayMode::COORDINATION };
1957     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1958     session->activeIdx_ = -1;
1959     auto res = session->CalcDisplayOrientation(rotation, foldDisplayMode);
1960     EXPECT_EQ(DisplayOrientation::LANDSCAPE, res);
1961 
1962     sptr<SupportedScreenModes> supportedScreenModes = new SupportedScreenModes;
1963     supportedScreenModes->width_ = 40;
1964     supportedScreenModes->height_ = 20;
1965     session->modes_ = { supportedScreenModes };
1966     session->activeIdx_ = 0;
1967 
1968     rotation = Rotation::ROTATION_0;
1969     res = session->CalcDisplayOrientation(rotation, foldDisplayMode);
1970     EXPECT_EQ(DisplayOrientation::LANDSCAPE, res);
1971 
1972     rotation = Rotation::ROTATION_90;
1973     res = session->CalcDisplayOrientation(rotation, foldDisplayMode);
1974     EXPECT_EQ(DisplayOrientation::PORTRAIT, res);
1975 
1976     rotation = Rotation::ROTATION_180;
1977     res = session->CalcDisplayOrientation(rotation, foldDisplayMode);
1978     EXPECT_EQ(DisplayOrientation::LANDSCAPE_INVERTED, res);
1979 
1980     rotation = Rotation::ROTATION_270;
1981     res = session->CalcDisplayOrientation(rotation, foldDisplayMode);
1982     EXPECT_EQ(DisplayOrientation::PORTRAIT_INVERTED, res);
1983 
1984     GTEST_LOG_(INFO) << "ScreenSessionTest: CalcDisplayOrientation end";
1985 }
1986 
1987 /**
1988  * @tc.name: FillScreenInfo
1989  * @tc.desc: normal function
1990  * @tc.type: FUNC
1991  */
1992 HWTEST_F(ScreenSessionTest, FillScreenInfo, Function | SmallTest | Level2)
1993 {
1994     GTEST_LOG_(INFO) << "ScreenSessionTest: FillScreenInfo start";
1995     ScreenProperty property;
1996     property.SetVirtualPixelRatio(3.1415927);
1997     sptr<ScreenSession> session = new(std::nothrow) ScreenSession(2024, property, 0);
1998     sptr<ScreenInfo> info = nullptr;
1999     session->FillScreenInfo(info);
2000 
2001     sptr<SupportedScreenModes> supportedScreenModes = new SupportedScreenModes;
2002     session->modes_ = { supportedScreenModes };
2003     supportedScreenModes->width_ = 40;
2004     supportedScreenModes->height_ = 20;
2005     info = new ScreenInfo;
2006     session->FillScreenInfo(info);
2007     EXPECT_NE(nullptr, info);
2008     GTEST_LOG_(INFO) << "ScreenSessionTest: FillScreenInfo end";
2009 }
2010 
2011 /**
2012  * @tc.name: SetScreenScale
2013  * @tc.desc: SetScreenScale test
2014  * @tc.type: FUNC
2015 */
2016 HWTEST_F(ScreenSessionTest, SetScreenScale, Function | SmallTest | Level2)
2017 {
2018     ScreenSession session;
2019     float scaleX = 1.0f;
2020     float scaleY = 1.0f;
2021     float pivotX = 0.5f;
2022     float pivotY = 0.5f;
2023     float translateX = 0.0f;
2024     float translateY = 0.0f;
2025     session.SetScreenScale(scaleX, scaleY, pivotX, pivotY, translateX, translateY);
2026     EXPECT_EQ(session.property_.GetScaleX(), scaleX);
2027     EXPECT_EQ(session.property_.GetScaleY(), scaleY);
2028     EXPECT_EQ(session.property_.GetPivotX(), pivotX);
2029     EXPECT_EQ(session.property_.GetPivotY(), pivotY);
2030     EXPECT_EQ(session.property_.GetTranslateX(), translateX);
2031     EXPECT_EQ(session.property_.GetTranslateY(), translateY);
2032 }
2033 } // namespace
2034 } // namespace Rosen
2035 } // namespace OHOS
2036