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