• 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 
16 #include "screen_session.h"
17 #include <gtest/gtest.h>
18 #include "screen_session_manager/include/screen_session_manager.h"
19 #include "scene_board_judgement.h"
20 #include "fold_screen_state_internel.h"
21 #include "window_manager_hilog.h"
22 
23 // using namespace FRAME_TRACE;
24 using namespace testing;
25 using namespace testing::ext;
26 namespace OHOS {
27 namespace Rosen {
28 namespace {
29     constexpr uint32_t SLEEP_TIME_IN_US = 100000; // 100ms
30     std::string g_errLog;
MyLogCallback(const LogType type,const LogLevel level,const unsigned int domain,const char * tag,const char * msg)31     void MyLogCallback(const LogType type, const LogLevel level, const unsigned int domain, const char *tag,
32         const char *msg)
33     {
34     g_errLog = msg;
35     }
36 }
37 class MockScreenChangeListener : public IScreenChangeListener {
38 public:
OnConnect(ScreenId screenId)39     void OnConnect(ScreenId screenId) override {}
OnDisconnect(ScreenId screenId)40     void OnDisconnect(ScreenId screenId) override {}
OnPropertyChange(const ScreenProperty & newProperty,ScreenPropertyChangeReason reason,ScreenId screenId)41     void OnPropertyChange(const ScreenProperty& newProperty, ScreenPropertyChangeReason reason,
42         ScreenId screenId) override {}
OnPowerStatusChange(DisplayPowerEvent event,EventStatus status,PowerStateChangeReason reason)43     void OnPowerStatusChange(DisplayPowerEvent event, EventStatus status,
44         PowerStateChangeReason reason) override {}
OnSensorRotationChange(float sensorRotation,ScreenId screenId)45     void OnSensorRotationChange(float sensorRotation, ScreenId screenId) override {}
OnScreenOrientationChange(float screenOrientation,ScreenId screenId)46     void OnScreenOrientationChange(float screenOrientation, ScreenId screenId) override {}
OnScreenRotationLockedChange(bool isLocked,ScreenId screenId)47     void OnScreenRotationLockedChange(bool isLocked, ScreenId screenId) override {}
OnScreenExtendChange(ScreenId mainScreenId,ScreenId extendScreenId)48     void OnScreenExtendChange(ScreenId mainScreenId, ScreenId extendScreenId) override {}
OnHoverStatusChange(int32_t hoverStatus,bool needRotate,ScreenId screenId)49     void OnHoverStatusChange(int32_t hoverStatus, bool needRotate, ScreenId screenId) override {}
OnScreenCaptureNotify(ScreenId mainScreenId,int32_t uid,const std::string & clientName)50     void OnScreenCaptureNotify(ScreenId mainScreenId, int32_t uid, const std::string& clientName) override {}
OnCameraBackSelfieChange(bool isCameraBackSelfie,ScreenId screenId)51     void OnCameraBackSelfieChange(bool isCameraBackSelfie, ScreenId screenId) override {}
OnSuperFoldStatusChange(ScreenId screenId,SuperFoldStatus superFoldStatus)52     void OnSuperFoldStatusChange(ScreenId screenId, SuperFoldStatus superFoldStatus) override {}
OnSecondaryReflexionChange(ScreenId screenId,bool isSecondaryReflexion)53     void OnSecondaryReflexionChange(ScreenId screenId, bool isSecondaryReflexion) override {}
OnExtendScreenConnectStatusChange(ScreenId screenId,ExtendScreenConnectStatus extendScreenConnectStatus)54     void OnExtendScreenConnectStatusChange(ScreenId screenId,
55         ExtendScreenConnectStatus extendScreenConnectStatus) override {}
OnBeforeScreenPropertyChange(FoldStatus foldStatus)56     void OnBeforeScreenPropertyChange(FoldStatus foldStatus) override {}
OnScreenModeChange(ScreenModeChangeEvent screenModeChangeEvent)57     void OnScreenModeChange(ScreenModeChangeEvent screenModeChangeEvent) override {}
58 };
59 class ScreenSessionTest : public testing::Test {
60   public:
61     void TearDown() override;
ScreenSessionTest()62     ScreenSessionTest() {}
~ScreenSessionTest()63     ~ScreenSessionTest() {}
64 };
65 
TearDown()66 void ScreenSessionTest::TearDown()
67 {
68     usleep(SLEEP_TIME_IN_US);
69 }
70 
71 namespace {
72 
73 /**
74  * @tc.name: create ScreenSession
75  * @tc.desc: normal function
76  * @tc.type: FUNC
77  */
78 HWTEST_F(ScreenSessionTest, ScreenSession, TestSize.Level1)
79 {
80     ScreenSessionConfig config = {
81         .screenId = 0,
82         .rsId = 0,
83         .name = "OpenHarmony",
84     };
85     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
86         ScreenSessionReason::CREATE_SESSION_FOR_CLIENT);
87     EXPECT_NE(nullptr, screenSession);
88 }
89 
90 /**
91  * @tc.name: create ScreenSession02
92  * @tc.desc: normal function
93  * @tc.type: FUNC
94  */
95 HWTEST_F(ScreenSessionTest, ScreenSession02, TestSize.Level1)
96 {
97     ScreenSessionConfig config = {
98         .screenId = 0,
99         .rsId = 0,
100         .name = "OpenHarmony",
101     };
102     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
103         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
104     EXPECT_NE(nullptr, screenSession);
105 }
106 
107 /**
108  * @tc.name: create ScreenSession03
109  * @tc.desc: normal function
110  * @tc.type: FUNC
111  */
112 HWTEST_F(ScreenSessionTest, ScreenSession03, TestSize.Level1)
113 {
114     ScreenSessionConfig config = {
115         .screenId = 0,
116         .rsId = 0,
117         .name = "OpenHarmony",
118     };
119     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
120         ScreenSessionReason::CREATE_SESSION_FOR_MIRROR);
121     EXPECT_NE(nullptr, screenSession);
122 }
123 
124 /**
125  * @tc.name: create ScreenSession03
126  * @tc.desc: normal function
127  * @tc.type: FUNC
128  */
129 HWTEST_F(ScreenSessionTest, ScreenSession04, TestSize.Level1)
130 {
131     ScreenSessionConfig config = {
132         .screenId = 0,
133         .rsId = 0,
134         .name = "OpenHarmony",
135     };
136     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
137         ScreenSessionReason::CREATE_SESSION_FOR_REAL);
138     EXPECT_NE(nullptr, screenSession);
139 }
140 
141 /**
142  * @tc.name: create ScreenSession05
143  * @tc.desc: normal function
144  * @tc.type: FUNC
145  */
146 HWTEST_F(ScreenSessionTest, ScreenSession05, TestSize.Level1)
147 {
148     ScreenSessionConfig config = {
149         .screenId = 0,
150         .rsId = 0,
151         .name = "OpenHarmony",
152     };
153     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
154         ScreenSessionReason::INVALID);
155     EXPECT_NE(nullptr, screenSession);
156 }
157 
158 /**
159  * @tc.name: CreateDisplayNode
160  * @tc.desc: normal function
161  * @tc.type: FUNC
162  */
163 HWTEST_F(ScreenSessionTest, CreateDisplayNode, TestSize.Level0)
164 {
165     GTEST_LOG_(INFO) << "ScreenSessionTest: CreateDisplayNode start";
166     Rosen::RSDisplayNodeConfig rsConfig;
167     ScreenSessionConfig config = {
168         .screenId = 100,
169         .rsId = 101,
170         .name = "OpenHarmony",
171     };
172     rsConfig.isMirrored = true;
173     rsConfig.screenId = 101;
174     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
175         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
176     EXPECT_NE(nullptr, screenSession);
177     screenSession->CreateDisplayNode(rsConfig);
178     GTEST_LOG_(INFO) << "ScreenSessionTest: CreateDisplayNode end";
179 }
180 
181 /**
182  * @tc.name: SetMirrorScreenType
183  * @tc.desc: normal function
184  * @tc.type: FUNC
185  */
186 HWTEST_F(ScreenSessionTest, SetMirrorScreenType, TestSize.Level1)
187 {
188     GTEST_LOG_(INFO) << "SetMirrorScreenType start";
189     ScreenSessionConfig config = {
190         .screenId = 100,
191         .rsId = 101,
192         .name = "OpenHarmony",
193     };
194     Rosen::RSDisplayNodeConfig rsConfig;
195     rsConfig.isMirrored = true;
196     rsConfig.screenId = 101;
197     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
198         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
199     EXPECT_NE(nullptr, screenSession);
200     MirrorScreenType mirrorType = MirrorScreenType::VIRTUAL_MIRROR;
201     screenSession->SetMirrorScreenType(mirrorType);
202     GTEST_LOG_(INFO) << "SetMirrorScreenType end";
203 }
204 
205 /**
206  * @tc.name: GetMirrorScreenType
207  * @tc.desc: normal function
208  * @tc.type: FUNC
209  */
210 HWTEST_F(ScreenSessionTest, GetMirrorScreenType, TestSize.Level1)
211 {
212     GTEST_LOG_(INFO) << "GetMirrorScreenType start";
213     ScreenSessionConfig config = {
214         .screenId = 100,
215         .rsId = 101,
216         .name = "OpenHarmony",
217     };
218     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
219         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
220     EXPECT_NE(nullptr, screenSession);
221     MirrorScreenType mirrorType = MirrorScreenType::VIRTUAL_MIRROR;
222     screenSession->SetMirrorScreenType(mirrorType);
223     MirrorScreenType res = screenSession->GetMirrorScreenType();
224     ASSERT_EQ(mirrorType, res);
225     GTEST_LOG_(INFO) << "GetMirrorScreenType end";
226 }
227 
228 /**
229  * @tc.name: SetDefaultDeviceRotationOffset
230  * @tc.desc: normal function
231  * @tc.type: FUNC
232  */
233 HWTEST_F(ScreenSessionTest, SetDefaultDeviceRotationOffset, TestSize.Level1)
234 {
235     GTEST_LOG_(INFO) << "SetDefaultDeviceRotationOffset start";
236     ScreenSessionConfig config = {
237         .screenId = 100,
238         .rsId = 101,
239         .name = "OpenHarmony",
240     };
241     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
242         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
243     EXPECT_NE(nullptr, screenSession);
244     uint32_t defaultRotationOffset = 0;
245     screenSession->SetDefaultDeviceRotationOffset(defaultRotationOffset);
246     GTEST_LOG_(INFO) << "SetDefaultDeviceRotationOffset end";
247 }
248 
249 /**
250  * @tc.name: UpdateDisplayState
251  * @tc.desc: normal function
252  * @tc.type: FUNC
253  */
254 HWTEST_F(ScreenSessionTest, UpdateDisplayState, TestSize.Level1)
255 {
256     GTEST_LOG_(INFO) << "UpdateDisplayState start";
257     ScreenSessionConfig config = {
258         .screenId = 100,
259         .rsId = 101,
260         .name = "OpenHarmony",
261     };
262     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
263         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
264     EXPECT_NE(nullptr, screenSession);
265     DisplayState displayState = DisplayState::OFF;
266     screenSession->UpdateDisplayState(displayState);
267     GTEST_LOG_(INFO) << "UpdateDisplayState end";
268 }
269 
270 /**
271  * @tc.name: UpdateRefreshRate
272  * @tc.desc: normal function
273  * @tc.type: FUNC
274  */
275 HWTEST_F(ScreenSessionTest, UpdateRefreshRate, TestSize.Level1)
276 {
277     GTEST_LOG_(INFO) << "UpdateRefreshRate start";
278     ScreenSessionConfig config = {
279         .screenId = 100,
280         .rsId = 101,
281         .name = "OpenHarmony",
282     };
283     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
284         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
285     EXPECT_NE(nullptr, screenSession);
286     uint32_t refreshRate = 2;
287     screenSession->UpdateRefreshRate(refreshRate);
288     GTEST_LOG_(INFO) << "UpdateRefreshRate end";
289 }
290 
291 /**
292  * @tc.name: GetRefreshRate
293  * @tc.desc: normal function
294  * @tc.type: FUNC
295  */
296 HWTEST_F(ScreenSessionTest, GetRefreshRate, TestSize.Level1)
297 {
298     GTEST_LOG_(INFO) << "GetRefreshRate start";
299     ScreenSessionConfig config = {
300         .screenId = 100,
301         .rsId = 101,
302         .name = "OpenHarmony",
303     };
304     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
305         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
306     EXPECT_NE(nullptr, screenSession);
307     uint32_t refreshRate = 2;
308     screenSession->UpdateRefreshRate(refreshRate);
309     auto res = screenSession->GetRefreshRate();
310     ASSERT_EQ(refreshRate, res);
311     GTEST_LOG_(INFO) << "GetRefreshRate end";
312 }
313 
314 /**
315  * @tc.name: UpdatePropertyByResolution
316  * @tc.desc: normal function
317  * @tc.type: FUNC
318  */
319 HWTEST_F(ScreenSessionTest, UpdatePropertyByResolution, TestSize.Level1)
320 {
321     GTEST_LOG_(INFO) << "UpdatePropertyByResolution start";
322     ScreenSessionConfig config = {
323         .screenId = 100,
324         .rsId = 101,
325         .name = "OpenHarmony",
326     };
327     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
328         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
329     EXPECT_NE(nullptr, screenSession);
330     uint32_t width = 1000;
331     uint32_t height = 1500;
332     screenSession->UpdatePropertyByResolution(width, height);
333     GTEST_LOG_(INFO) << "UpdatePropertyByResolution end";
334 }
335 
336 /**
337  * @tc.name: HandleSensorRotation
338  * @tc.desc: normal function
339  * @tc.type: FUNC
340  */
341 HWTEST_F(ScreenSessionTest, HandleSensorRotation, TestSize.Level1)
342 {
343     GTEST_LOG_(INFO) << "HandleSensorRotation start";
344     ScreenSessionConfig config = {
345         .screenId = 100,
346         .rsId = 101,
347         .name = "OpenHarmony",
348     };
349     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
350         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
351     EXPECT_NE(nullptr, screenSession);
352     float sensorRotation = 0.0f;
353     screenSession->HandleSensorRotation(sensorRotation);
354     GTEST_LOG_(INFO) << "HandleSensorRotation end";
355 }
356 
357 /**
358  * @tc.name: ConvertIntToRotation
359  * @tc.desc: normal function
360  * @tc.type: FUNC
361  */
362 HWTEST_F(ScreenSessionTest, ConvertIntToRotation, TestSize.Level1)
363 {
364     GTEST_LOG_(INFO) << "ScreenSessionTest: ConvertIntToRotation start";
365     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
366     int rotation = 0;
367     auto res = session->ConvertIntToRotation(rotation);
368     ASSERT_EQ(res, Rotation::ROTATION_0);
369     rotation = 90;
370     res = session->ConvertIntToRotation(rotation);
371     ASSERT_EQ(res, Rotation::ROTATION_90);
372     rotation = 180;
373     res = session->ConvertIntToRotation(rotation);
374     ASSERT_EQ(res, Rotation::ROTATION_180);
375     rotation = 270;
376     res = session->ConvertIntToRotation(rotation);
377     ASSERT_EQ(res, Rotation::ROTATION_270);
378     GTEST_LOG_(INFO) << "ScreenSessionTest: ConvertIntToRotation end";
379 }
380 
381 /**
382  * @tc.name: SetVirtualScreenFlag
383  * @tc.desc: normal function
384  * @tc.type: FUNC
385  */
386 HWTEST_F(ScreenSessionTest, SetVirtualScreenFlag, TestSize.Level0)
387 {
388     GTEST_LOG_(INFO) << "SetVirtualScreenFlag start";
389     ScreenSessionConfig config = {
390         .screenId = 100,
391         .rsId = 101,
392         .name = "OpenHarmony",
393     };
394     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
395         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
396     EXPECT_NE(nullptr, screenSession);
397     VirtualScreenFlag screenFlag = VirtualScreenFlag::CAST;
398     screenSession->SetVirtualScreenFlag(screenFlag);
399     GTEST_LOG_(INFO) << "SetVirtualScreenFlag end";
400 }
401 
402 /**
403  * @tc.name: GetVirtualScreenFlag
404  * @tc.desc: normal function
405  * @tc.type: FUNC
406  */
407 HWTEST_F(ScreenSessionTest, GetVirtualScreenFlag, TestSize.Level0)
408 {
409     GTEST_LOG_(INFO) << "GetVirtualScreenFlag start";
410     ScreenSessionConfig config = {
411         .screenId = 100,
412         .rsId = 101,
413         .name = "OpenHarmony",
414     };
415     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
416         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
417     EXPECT_NE(nullptr, screenSession);
418     VirtualScreenFlag screenFlag = VirtualScreenFlag::CAST;
419     screenSession->SetVirtualScreenFlag(screenFlag);
420     auto res = screenSession->GetVirtualScreenFlag();
421     ASSERT_EQ(screenFlag, res);
422     GTEST_LOG_(INFO) << "GetVirtualScreenFlag end";
423 }
424 
425 /**
426  * @tc.name: SetPhysicalRotation
427  * @tc.desc: normal function
428  * @tc.type: FUNC
429  */
430 HWTEST_F(ScreenSessionTest, SetPhysicalRotation, TestSize.Level1)
431 {
432     GTEST_LOG_(INFO) << "SetPhysicalRotation start";
433     ScreenSessionConfig config = {
434         .screenId = 100,
435         .rsId = 101,
436         .name = "OpenHarmony",
437     };
438     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
439         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
440     EXPECT_NE(nullptr, screenSession);
441     int rotation = 0;
442     screenSession->SetPhysicalRotation(rotation);
443     GTEST_LOG_(INFO) << "SetPhysicalRotation end";
444 }
445 
446 /**
447  * @tc.name: SetScreenComponentRotation
448  * @tc.desc: normal function
449  * @tc.type: FUNC
450  */
451 HWTEST_F(ScreenSessionTest, SetScreenComponentRotation, TestSize.Level1)
452 {
453     GTEST_LOG_(INFO) << "SetScreenComponentRotation start";
454     ScreenSessionConfig config = {
455         .screenId = 100,
456         .rsId = 101,
457         .name = "OpenHarmony",
458     };
459     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
460         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
461     EXPECT_NE(nullptr, screenSession);
462     int rotation = 0;
463     screenSession->SetScreenComponentRotation(rotation);
464     GTEST_LOG_(INFO) << "SetScreenComponentRotation end";
465 }
466 
467 /**
468  * @tc.name: UpdateToInputManager
469  * @tc.desc: normal function
470  * @tc.type: FUNC
471  */
472 HWTEST_F(ScreenSessionTest, UpdateToInputManager, TestSize.Level1)
473 {
474     GTEST_LOG_(INFO) << "UpdateToInputManager start";
475     ScreenSessionConfig config = {
476         .screenId = 100,
477         .rsId = 101,
478         .name = "OpenHarmony",
479     };
480     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
481         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
482     EXPECT_NE(nullptr, screenSession);
483     RRect bounds;
484     int rotation = 90;
485     int deviceRotation = 90;
486     FoldDisplayMode foldDisplayMode = FoldDisplayMode::FULL;
487     screenSession->UpdateToInputManager(bounds, rotation, deviceRotation, foldDisplayMode);
488     bounds.rect_.width_ = 1344;
489     bounds.rect_.height_ = 2772;
490     rotation = 0;
491     foldDisplayMode = FoldDisplayMode::MAIN;
492     screenSession->UpdateToInputManager(bounds, rotation, deviceRotation, foldDisplayMode);
493     GTEST_LOG_(INFO) << "UpdateToInputManager end";
494 }
495 
496 /**
497  * @tc.name: UpdatePropertyAfterRotation
498  * @tc.desc: normal function
499  * @tc.type: FUNC
500  */
501 HWTEST_F(ScreenSessionTest, UpdatePropertyAfterRotation, TestSize.Level1)
502 {
503     GTEST_LOG_(INFO) << "UpdatePropertyAfterRotation start";
504     ScreenSessionConfig config = {
505         .screenId = 100,
506         .rsId = 101,
507         .name = "OpenHarmony",
508     };
509     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
510         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
511     EXPECT_NE(nullptr, screenSession);
512     RRect bounds;
513     bounds.rect_.width_ = 1344;
514     bounds.rect_.height_ = 2772;
515     int rotation = 90;
516     FoldDisplayMode foldDisplayMode = FoldDisplayMode::MAIN;
517     screenSession->UpdatePropertyAfterRotation(bounds, rotation, foldDisplayMode);
518     GTEST_LOG_(INFO) << "UpdatePropertyAfterRotation end";
519 }
520 
521 /**
522  * @tc.name: ReportNotifyModeChange
523  * @tc.desc: normal function
524  * @tc.type: FUNC
525  */
526 HWTEST_F(ScreenSessionTest, ReportNotifyModeChange, TestSize.Level1)
527 {
528     GTEST_LOG_(INFO) << "ReportNotifyModeChange start";
529     ScreenSessionConfig config = {
530         .screenId = 100,
531         .rsId = 101,
532         .name = "OpenHarmony",
533     };
534     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
535         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
536     EXPECT_NE(nullptr, screenSession);
537     DisplayOrientation displayOrientation = DisplayOrientation::LANDSCAPE;
538     screenSession->ReportNotifyModeChange(displayOrientation);
539     displayOrientation = DisplayOrientation::PORTRAIT;
540     screenSession->ReportNotifyModeChange(displayOrientation);
541     displayOrientation = DisplayOrientation::PORTRAIT_INVERTED;
542     screenSession->ReportNotifyModeChange(displayOrientation);
543     GTEST_LOG_(INFO) << "ReportNotifyModeChange end";
544 }
545 
546 /**
547  * @tc.name: SuperFoldStatusChange
548  * @tc.desc: normal function
549  * @tc.type: FUNC
550  */
551 HWTEST_F(ScreenSessionTest, SuperFoldStatusChange, TestSize.Level1)
552 {
553     GTEST_LOG_(INFO) << "SuperFoldStatusChange start";
554     ScreenSessionConfig config = {
555         .screenId = 100,
556         .rsId = 101,
557         .name = "OpenHarmony",
558     };
559     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
560         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
561     EXPECT_NE(nullptr, screenSession);
562     ScreenId screenId = 0;
563     SuperFoldStatus superFoldStatus = SuperFoldStatus::UNKNOWN;
564     screenSession->SuperFoldStatusChange(screenId, superFoldStatus);
565     superFoldStatus = SuperFoldStatus::EXPANDED;
566     screenSession->SuperFoldStatusChange(screenId, superFoldStatus);
567     superFoldStatus = SuperFoldStatus::FOLDED;
568     screenSession->SuperFoldStatusChange(screenId, superFoldStatus);
569     superFoldStatus = SuperFoldStatus::KEYBOARD;
570     screenSession->SuperFoldStatusChange(screenId, superFoldStatus);
571     superFoldStatus = SuperFoldStatus::HALF_FOLDED;
572     screenSession->SuperFoldStatusChange(screenId, superFoldStatus);
573     GTEST_LOG_(INFO) << "SuperFoldStatusChange end";
574 }
575 
576 /**
577  * @tc.name: UpdateRotationAfterBoot01
578  * @tc.desc: normal function
579  * @tc.type: FUNC
580  */
581 HWTEST_F(ScreenSessionTest, UpdateRotationAfterBoot01, TestSize.Level1)
582 {
583     GTEST_LOG_(INFO) << "UpdateRotationAfterBoot start";
584     ScreenSessionConfig config = {
585         .screenId = 100,
586         .rsId = 101,
587         .name = "OpenHarmony",
588     };
589     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
590         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
591     EXPECT_NE(nullptr, screenSession);
592     bool foldToExpand = true;
593     screenSession->UpdateRotationAfterBoot(foldToExpand);
594     GTEST_LOG_(INFO) << "UpdateRotationAfterBoot end";
595 }
596 
597 /**
598  * @tc.name: UpdateRotationAfterBoot02
599  * @tc.desc: normal function
600  * @tc.type: FUNC
601  */
602 HWTEST_F(ScreenSessionTest, UpdateRotationAfterBoot02, TestSize.Level1)
603 {
604     GTEST_LOG_(INFO) << "UpdateRotationAfterBoot start";
605     ScreenSessionConfig config = {
606         .screenId = 100,
607         .rsId = 101,
608         .name = "OpenHarmony",
609     };
610     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
611         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
612     EXPECT_NE(nullptr, screenSession);
613     bool foldToExpand = false;
614     screenSession->UpdateRotationAfterBoot(foldToExpand);
615     GTEST_LOG_(INFO) << "UpdateRotationAfterBoot end";
616 }
617 
618 /**
619  * @tc.name: UpdateValidRotationToScb
620  * @tc.desc: normal function
621  * @tc.type: FUNC
622  */
623 HWTEST_F(ScreenSessionTest, UpdateValidRotationToScb, TestSize.Level1)
624 {
625     GTEST_LOG_(INFO) << "UpdateValidRotationToScb start";
626     ScreenSessionConfig config = {
627         .screenId = 100,
628         .rsId = 101,
629         .name = "OpenHarmony",
630     };
631     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
632         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
633     EXPECT_NE(nullptr, screenSession);
634     screenSession->UpdateValidRotationToScb();
635     GTEST_LOG_(INFO) << "UpdateValidRotationToScb end";
636 }
637 
638 /**
639  * @tc.name: SetScreenSceneDpiChangeListener
640  * @tc.desc: normal function
641  * @tc.type: FUNC
642  */
643 HWTEST_F(ScreenSessionTest, SetScreenSceneDpiChangeListener, TestSize.Level1)
644 {
645     GTEST_LOG_(INFO) << "SetScreenSceneDpiChangeListener start";
646     ScreenSessionConfig config = {
647         .screenId = 100,
648         .rsId = 101,
649         .name = "OpenHarmony",
650     };
651     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
652         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
653     EXPECT_NE(nullptr, screenSession);
654     SetScreenSceneDpiFunc func = nullptr;
655     screenSession->SetScreenSceneDpiChangeListener(func);
656     GTEST_LOG_(INFO) << "SetScreenSceneDpiChangeListener end";
657 }
658 
659 /**
660  * @tc.name: SetScreenSceneDestroyListener
661  * @tc.desc: normal function
662  * @tc.type: FUNC
663  */
664 HWTEST_F(ScreenSessionTest, SetScreenSceneDestroyListener, TestSize.Level1)
665 {
666     GTEST_LOG_(INFO) << "SetScreenSceneDestroyListener start";
667     ScreenSessionConfig config = {
668         .screenId = 100,
669         .rsId = 101,
670         .name = "OpenHarmony",
671     };
672     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
673         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
674     EXPECT_NE(nullptr, screenSession);
675     DestroyScreenSceneFunc func = nullptr;
676     screenSession->SetScreenSceneDestroyListener(func);
677     GTEST_LOG_(INFO) << "SetScreenSceneDestroyListener end";
678 }
679 
680 /**
681  * @tc.name: SetScreenSceneDpi
682  * @tc.desc: normal function
683  * @tc.type: FUNC
684  */
685 HWTEST_F(ScreenSessionTest, SetScreenSceneDpi, TestSize.Level1)
686 {
687     GTEST_LOG_(INFO) << "SetScreenSceneDpi start";
688     ScreenSessionConfig config = {
689         .screenId = 100,
690         .rsId = 101,
691         .name = "OpenHarmony",
692     };
693     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
694         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
695     EXPECT_NE(nullptr, screenSession);
696     float density = 1.5f;
697     SetScreenSceneDpiFunc func = nullptr;
698     screenSession->SetScreenSceneDpiChangeListener(func);
699     screenSession->SetScreenSceneDpi(density);
__anon9ac455210302(float density) 700     SetScreenSceneDpiFunc func2 = [](float density) {
701             EXPECT_TRUE(true);
702         };
703     screenSession->SetScreenSceneDpiChangeListener(func2);
704     screenSession->SetScreenSceneDpi(density);
705     GTEST_LOG_(INFO) << "SetScreenSceneDpi end";
706 }
707 
708 /**
709  * @tc.name: DestroyScreenScene
710  * @tc.desc: normal function
711  * @tc.type: FUNC
712  */
713 HWTEST_F(ScreenSessionTest, DestroyScreenScene, TestSize.Level1)
714 {
715     GTEST_LOG_(INFO) << "DestroyScreenScene start";
716     ScreenSessionConfig config = {
717         .screenId = 100,
718         .rsId = 101,
719         .name = "OpenHarmony",
720     };
721     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
722         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
723     EXPECT_NE(nullptr, screenSession);
724     DestroyScreenSceneFunc func = nullptr;
725     screenSession->SetScreenSceneDestroyListener(func);
726     screenSession->DestroyScreenScene();
__anon9ac455210402() 727     DestroyScreenSceneFunc func2 = []() {
728             EXPECT_TRUE(true);
729         };
730     screenSession->SetScreenSceneDestroyListener(func2);
731     screenSession->DestroyScreenScene();
732     GTEST_LOG_(INFO) << "DestroyScreenScene end";
733 }
734 
735 /**
736  * @tc.name: SetDensityInCurResolution
737  * @tc.desc: normal function
738  * @tc.type: FUNC
739  */
740 HWTEST_F(ScreenSessionTest, SetDensityInCurResolution, TestSize.Level1)
741 {
742     GTEST_LOG_(INFO) << "SetDensityInCurResolution start";
743     ScreenSessionConfig config = {
744         .screenId = 100,
745         .rsId = 101,
746         .name = "OpenHarmony",
747     };
748     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
749         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
750     EXPECT_NE(nullptr, screenSession);
751     float densityInCurResolution = 1.5f;
752     screenSession->SetDensityInCurResolution(densityInCurResolution);
753     GTEST_LOG_(INFO) << "SetDensityInCurResolution end";
754 }
755 
756 /**
757  * @tc.name: GetSourceMode
758  * @tc.desc: normal function
759  * @tc.type: FUNC
760  */
761 HWTEST_F(ScreenSessionTest, GetSourceMode, TestSize.Level0)
762 {
763     GTEST_LOG_(INFO) << "ScreenSessionTest: GetSourceMode start";
764     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
765     session->screenId_ = session->defaultScreenId_;
766     ScreenSourceMode mode = session->GetSourceMode();
767     ASSERT_EQ(mode, ScreenSourceMode::SCREEN_MAIN);
768     ScreenSessionConfig config = {
769         .screenId = 100,
770         .rsId = 101,
771         .name = "OpenHarmony",
772     };
773     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
774         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
775     mode = screenSession->GetSourceMode();
776     ASSERT_EQ(mode, ScreenSourceMode::SCREEN_ALONE);
777     screenSession->SetScreenCombination(ScreenCombination::SCREEN_EXPAND);
778     mode = screenSession->GetSourceMode();
779     ASSERT_EQ(mode, ScreenSourceMode::SCREEN_EXTEND);
780     screenSession->SetScreenCombination(ScreenCombination::SCREEN_MIRROR);
781     mode = screenSession->GetSourceMode();
782     ASSERT_EQ(mode, ScreenSourceMode::SCREEN_MIRROR);
783     screenSession->SetScreenCombination(ScreenCombination::SCREEN_UNIQUE);
784     mode = screenSession->GetSourceMode();
785     ASSERT_EQ(mode, ScreenSourceMode::SCREEN_UNIQUE);
786     screenSession->SetScreenCombination(ScreenCombination::SCREEN_EXTEND);
787     mode = screenSession->GetSourceMode();
788     ASSERT_EQ(mode, ScreenSourceMode::SCREEN_EXTEND);
789     screenSession->SetScreenCombination(ScreenCombination::SCREEN_MAIN);
790     mode = screenSession->GetSourceMode();
791     ASSERT_EQ(mode, ScreenSourceMode::SCREEN_MAIN);
792     GTEST_LOG_(INFO) << "ScreenSessionTest: GetSourceMode end";
793 }
794 
795 /**
796  * @tc.name: GetSourceMode02
797  * @tc.desc: normal function
798  * @tc.type: FUNC
799  */
800 HWTEST_F(ScreenSessionTest, GetSourceMode02, TestSize.Level0)
801 {
802     GTEST_LOG_(INFO) << "ScreenSessionTest: GetSourceMode02 start";
803     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
804     session->screenId_ = session->defaultScreenId_;
805     ScreenSourceMode mode = session->GetSourceMode();
806     ASSERT_EQ(mode, ScreenSourceMode::SCREEN_MAIN);
807     ScreenSessionConfig config = {
808         .screenId = 100,
809         .rsId = 101,
810         .name = "OpenHarmony",
811     };
812     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
813         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
814 
815     screenSession->SetScreenCombination(ScreenCombination::SCREEN_MAIN);
816     mode = screenSession->GetSourceMode();
817     ASSERT_EQ(mode, ScreenSourceMode::SCREEN_MAIN);
818     screenSession->SetScreenCombination(ScreenCombination::SCREEN_EXTEND);
819     mode = screenSession->GetSourceMode();
820     ASSERT_EQ(mode, ScreenSourceMode::SCREEN_EXTEND);
821     GTEST_LOG_(INFO) << "ScreenSessionTest: GetSourceMode02 end";
822 }
823 
824 /**
825  * @tc.name: GetPixelFormat
826  * @tc.desc: normal function
827  * @tc.type: FUNC
828  */
829 HWTEST_F(ScreenSessionTest, GetPixelFormat, TestSize.Level1)
830 {
831     GTEST_LOG_(INFO) << "GetPixelFormat start";
832     ScreenSessionConfig config = {
833         .screenId = 100,
834         .rsId = 0,
835         .name = "OpenHarmony",
836     };
837     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
838         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
839     EXPECT_NE(nullptr, screenSession);
840     GraphicPixelFormat pixelFormat;
841     auto res = screenSession->GetPixelFormat(pixelFormat);
842     ASSERT_EQ(res, DMError::DM_OK);
843     GTEST_LOG_(INFO) << "GetPixelFormat end";
844 }
845 
846 /**
847  * @tc.name: SetPixelFormat
848  * @tc.desc: normal function
849  * @tc.type: FUNC
850  */
851 HWTEST_F(ScreenSessionTest, SetPixelFormat, TestSize.Level1)
852 {
853     GTEST_LOG_(INFO) << "SetPixelFormat start";
854     ScreenSessionConfig config = {
855         .screenId = 100,
856         .rsId = 0,
857         .name = "OpenHarmony",
858     };
859     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
860         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
861     EXPECT_NE(nullptr, screenSession);
862     GraphicPixelFormat pixelFormat = GraphicPixelFormat{GRAPHIC_PIXEL_FMT_CLUT8};
863     auto res = screenSession->SetPixelFormat(pixelFormat);
864     ASSERT_EQ(res, DMError::DM_OK);
865     GTEST_LOG_(INFO) << "SetPixelFormat end";
866 }
867 
868 /**
869  * @tc.name: GetSupportedHDRFormats
870  * @tc.desc: normal function
871  * @tc.type: FUNC
872  */
873 HWTEST_F(ScreenSessionTest, GetSupportedHDRFormats, TestSize.Level1)
874 {
875 #ifdef WM_SCREEN_HDR_FORMAT_ENABLE
876     GTEST_LOG_(INFO) << "GetSupportedHDRFormats start";
877     ScreenSessionConfig config = {
878         .screenId = 100,
879         .rsId = 0,
880         .name = "OpenHarmony",
881     };
882     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
883         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
884     EXPECT_NE(nullptr, screenSession);
885     std::vector<ScreenHDRFormat> hdrFormats;
886     auto res = screenSession->GetSupportedHDRFormats(hdrFormats);
887     if (SceneBoardJudgement::IsSceneBoardEnabled()) {
888         ASSERT_EQ(res, DMError::DM_OK);
889     } else {
890         ASSERT_NE(res, DMError::DM_OK);
891     }
892     GTEST_LOG_(INFO) << "GetSupportedHDRFormats end";
893 #endif
894 }
895 
896 /**
897  * @tc.name: GetScreenHDRFormat
898  * @tc.desc: normal function
899  * @tc.type: FUNC
900  */
901 HWTEST_F(ScreenSessionTest, GetScreenHDRFormat, TestSize.Level1)
902 {
903     GTEST_LOG_(INFO) << "GetScreenHDRFormat start";
904     ScreenSessionConfig config = {
905         .screenId = 100,
906         .rsId = 0,
907         .name = "OpenHarmony",
908     };
909     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
910         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
911     EXPECT_NE(nullptr, screenSession);
912     ScreenHDRFormat hdrFormat;
913     auto res = screenSession->GetScreenHDRFormat(hdrFormat);
914     if (SceneBoardJudgement::IsSceneBoardEnabled()) {
915         ASSERT_EQ(res, DMError::DM_OK);
916     } else {
917         ASSERT_NE(res, DMError::DM_OK);
918     }
919     GTEST_LOG_(INFO) << "GetScreenHDRFormat end";
920 }
921 
922 /**
923  * @tc.name: SetScreenHDRFormat
924  * @tc.desc: normal function
925  * @tc.type: FUNC
926  */
927 HWTEST_F(ScreenSessionTest, SetScreenHDRFormat, TestSize.Level1)
928 {
929 #ifdef WM_SCREEN_HDR_FORMAT_ENABLE
930     GTEST_LOG_(INFO) << "SetScreenHDRFormat start";
931     ScreenSessionConfig config = {
932         .screenId = 100,
933         .rsId = 0,
934         .name = "OpenHarmony",
935     };
936     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
937         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
938     EXPECT_NE(nullptr, screenSession);
939     int32_t modeIdx = 0;
940     auto res = screenSession->SetScreenHDRFormat(modeIdx);
941     if (SceneBoardJudgement::IsSceneBoardEnabled()) {
942         ASSERT_EQ(res, DMError::DM_OK);
943         modeIdx = -1;
944         res = screenSession->SetScreenHDRFormat(modeIdx);
945         ASSERT_EQ(res, DMError::DM_ERROR_INVALID_PARAM);
946     } else {
947         ASSERT_NE(res, DMError::DM_OK);
948     }
949     GTEST_LOG_(INFO) << "SetScreenHDRFormat end";
950 #endif
951 }
952 
953 /**
954  * @tc.name: GetSupportedColorSpaces
955  * @tc.desc: normal function
956  * @tc.type: FUNC
957  */
958 HWTEST_F(ScreenSessionTest, GetSupportedColorSpaces, TestSize.Level1)
959 {
960     GTEST_LOG_(INFO) << "GetSupportedColorSpaces start";
961     ScreenSessionConfig config = {
962         .screenId = 100,
963         .rsId = 0,
964         .name = "OpenHarmony",
965     };
966     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
967         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
968     EXPECT_NE(nullptr, screenSession);
969     std::vector<GraphicCM_ColorSpaceType> colorSpaces;
970     auto res = screenSession->GetSupportedColorSpaces(colorSpaces);
971     if (SceneBoardJudgement::IsSceneBoardEnabled()) {
972         ASSERT_EQ(res, DMError::DM_OK);
973     } else {
974         ASSERT_NE(res, DMError::DM_OK);
975     }
976     GTEST_LOG_(INFO) << "GetSupportedColorSpaces end";
977 }
978 
979 /**
980  * @tc.name: GetScreenColorSpace
981  * @tc.desc: normal function
982  * @tc.type: FUNC
983  */
984 HWTEST_F(ScreenSessionTest, GetScreenColorSpace, TestSize.Level1)
985 {
986     GTEST_LOG_(INFO) << "GetScreenColorSpace start";
987     ScreenSessionConfig config = {
988         .screenId = 100,
989         .rsId = 0,
990         .name = "OpenHarmony",
991     };
992     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
993         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
994     EXPECT_NE(nullptr, screenSession);
995     GraphicCM_ColorSpaceType colorSpace;
996     auto res = screenSession->GetScreenColorSpace(colorSpace);
997     if (SceneBoardJudgement::IsSceneBoardEnabled()) {
998         ASSERT_EQ(res, DMError::DM_OK);
999     } else {
1000         ASSERT_NE(res, DMError::DM_OK);
1001     }
1002     GTEST_LOG_(INFO) << "GetScreenColorSpace end";
1003 }
1004 
1005 /**
1006  * @tc.name: SetScreenColorSpace
1007  * @tc.desc: normal function
1008  * @tc.type: FUNC
1009  */
1010 HWTEST_F(ScreenSessionTest, SetScreenColorSpace, TestSize.Level1)
1011 {
1012     GTEST_LOG_(INFO) << "SetScreenColorSpace start";
1013     ScreenSessionConfig config = {
1014         .screenId = 100,
1015         .rsId = 101,
1016         .name = "OpenHarmony",
1017     };
1018     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
1019         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
1020     EXPECT_NE(nullptr, screenSession);
1021     GraphicCM_ColorSpaceType colorSpace = GraphicCM_ColorSpaceType{GRAPHIC_CM_COLORSPACE_NONE};
1022     screenSession->SetScreenColorSpace(colorSpace);
1023     EXPECT_TRUE(true);
1024     GTEST_LOG_(INFO) << "SetScreenColorSpace end";
1025 }
1026 
1027 /**
1028  * @tc.name: SetPrivateSessionForeground
1029  * @tc.desc: normal function
1030  * @tc.type: FUNC
1031  */
1032 HWTEST_F(ScreenSessionTest, SetPrivateSessionForeground, TestSize.Level1)
1033 {
1034     GTEST_LOG_(INFO) << "SetPrivateSessionForeground start";
1035     ScreenSessionConfig config = {
1036         .screenId = 100,
1037         .rsId = 101,
1038         .name = "OpenHarmony",
1039     };
1040     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
1041         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
1042     EXPECT_NE(nullptr, screenSession);
1043     bool hasPrivate = true;
1044     screenSession->SetPrivateSessionForeground(hasPrivate);
1045     auto res = screenSession->HasPrivateSessionForeground();
1046     ASSERT_EQ(res, hasPrivate);
1047     GTEST_LOG_(INFO) << "SetPrivateSessionForeground end";
1048 }
1049 
1050 /**
1051  * @tc.name: GetScreenCombination
1052  * @tc.desc: normal function
1053  * @tc.type: FUNC
1054  */
1055 HWTEST_F(ScreenSessionTest, GetScreenCombination, TestSize.Level0)
1056 {
1057     GTEST_LOG_(INFO) << "GetScreenCombination start";
1058     ScreenSessionConfig config = {
1059         .screenId = 100,
1060         .rsId = 101,
1061         .name = "OpenHarmony",
1062     };
1063     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
1064         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
1065     EXPECT_NE(nullptr, screenSession);
1066     ScreenCombination combination { ScreenCombination::SCREEN_ALONE };
1067     screenSession->SetScreenCombination(combination);
1068     auto res = screenSession->GetScreenCombination();
1069     ASSERT_EQ(res, combination);
1070     GTEST_LOG_(INFO) << "GetScreenCombination end";
1071 }
1072 
1073 /**
1074  * @tc.name: Resize001
1075  * @tc.desc: Resize001 test
1076  * @tc.type: FUNC
1077  */
1078 HWTEST_F(ScreenSessionTest, Resize001, TestSize.Level1)
1079 {
1080     GTEST_LOG_(INFO) << "Resize001 start";
1081     ScreenSessionConfig config = {
1082         .screenId = 100,
1083         .rsId = 101,
1084         .name = "OpenHarmony",
1085     };
1086     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
1087         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
1088     ASSERT_NE(nullptr, screenSession);
1089     uint32_t width = 1000;
1090     uint32_t height = 1000;
1091     screenSession->Resize(width, height);
1092     GTEST_LOG_(INFO) << "Resize001 end";
1093 }
1094 
1095 /**
1096  * @tc.name: Resize002
1097  * @tc.desc: Resize002 test
1098  * @tc.type: FUNC
1099  */
1100 HWTEST_F(ScreenSessionTest, Resize002, TestSize.Level1)
1101 {
1102     GTEST_LOG_(INFO) << "Resize002 start";
1103     ScreenSessionConfig config = {
1104         .screenId = 100,
1105         .rsId = 101,
1106         .name = "OpenHarmony",
1107     };
1108     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
1109         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
1110     ASSERT_NE(nullptr, screenSession);
1111     uint32_t width = 1000;
1112     uint32_t height = 1000;
1113     screenSession->Resize(width, height, false);
1114     GTEST_LOG_(INFO) << "Resize002 end";
1115 }
1116 
1117 /**
1118  * @tc.name: UpdateAvailableArea
1119  * @tc.desc: normal function
1120  * @tc.type: FUNC
1121  */
1122 HWTEST_F(ScreenSessionTest, UpdateAvailableArea, TestSize.Level0)
1123 {
1124     GTEST_LOG_(INFO) << "UpdateAvailableArea start";
1125     ScreenSessionConfig config = {
1126         .screenId = 100,
1127         .rsId = 101,
1128         .name = "OpenHarmony",
1129     };
1130     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
1131         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
1132     EXPECT_NE(nullptr, screenSession);
1133     DMRect area = screenSession->GetAvailableArea();
1134     auto res = screenSession->UpdateAvailableArea(area);
1135     ASSERT_EQ(res, false);
1136     area = {2, 2, 2, 2};
1137     res = screenSession->UpdateAvailableArea(area);
1138     ASSERT_EQ(res, true);
1139     GTEST_LOG_(INFO) << "UpdateAvailableArea end";
1140 }
1141 
1142 /**
1143  * @tc.name: SetAvailableArea
1144  * @tc.desc: normal function
1145  * @tc.type: FUNC
1146  */
1147 HWTEST_F(ScreenSessionTest, SetAvailableArea, TestSize.Level1)
1148 {
1149     GTEST_LOG_(INFO) << "SetAvailableArea start";
1150     ScreenSessionConfig config = {
1151         .screenId = 100,
1152         .rsId = 101,
1153         .name = "OpenHarmony",
1154     };
1155     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
1156         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
1157     EXPECT_NE(nullptr, screenSession);
1158     DMRect area = {2, 2, 2, 2};
1159     screenSession->SetAvailableArea(area);
1160     GTEST_LOG_(INFO) << "SetAvailableArea end";
1161 }
1162 
1163 /**
1164  * @tc.name: GetAvailableArea
1165  * @tc.desc: normal function
1166  * @tc.type: FUNC
1167  */
1168 HWTEST_F(ScreenSessionTest, GetAvailableArea, TestSize.Level1)
1169 {
1170     GTEST_LOG_(INFO) << "GetAvailableArea start";
1171     ScreenSessionConfig config = {
1172         .screenId = 100,
1173         .rsId = 101,
1174         .name = "OpenHarmony",
1175     };
1176     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
1177         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
1178     EXPECT_NE(nullptr, screenSession);
1179     DMRect area = {2, 2, 2, 2};
1180     screenSession->SetAvailableArea(area);
1181     auto res = screenSession->GetAvailableArea();
1182     ASSERT_EQ(res, area);
1183     GTEST_LOG_(INFO) << "GetAvailableArea end";
1184 }
1185 
1186 /**
1187  * @tc.name: SetFoldScreen
1188  * @tc.desc: normal function
1189  * @tc.type: FUNC
1190  */
1191 HWTEST_F(ScreenSessionTest, SetFoldScreen, TestSize.Level1)
1192 {
1193     GTEST_LOG_(INFO) << "SetFoldScreen start";
1194     ScreenSessionConfig config = {
1195         .screenId = 100,
1196         .rsId = 101,
1197         .name = "OpenHarmony",
1198     };
1199     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
1200         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
1201     EXPECT_NE(nullptr, screenSession);
1202     bool isFold = false;
1203     screenSession->SetFoldScreen(isFold);
1204     GTEST_LOG_(INFO) << "SetFoldScreen end";
1205 }
1206 
1207 /**
1208  * @tc.name: SetHdrFormats
1209  * @tc.desc: normal function
1210  * @tc.type: FUNC
1211  */
1212 HWTEST_F(ScreenSessionTest, SetHdrFormats, TestSize.Level1)
1213 {
1214     GTEST_LOG_(INFO) << "SetHdrFormats start";
1215     ScreenSessionConfig config = {
1216         .screenId = 100,
1217         .rsId = 101,
1218         .name = "OpenHarmony",
1219     };
1220     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
1221         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
1222     EXPECT_NE(nullptr, screenSession);
1223     std::vector<uint32_t> hdrFormats = { 0, 0, 0, 0 };
1224     screenSession->SetHdrFormats(std::move(hdrFormats));
1225     GTEST_LOG_(INFO) << "SetHdrFormats end";
1226 }
1227 
1228 /**
1229  * @tc.name: SetColorSpaces
1230  * @tc.desc: normal function
1231  * @tc.type: FUNC
1232  */
1233 HWTEST_F(ScreenSessionTest, SetColorSpaces, TestSize.Level1)
1234 {
1235     GTEST_LOG_(INFO) << "SetColorSpaces start";
1236     ScreenSessionConfig config = {
1237         .screenId = 100,
1238         .rsId = 101,
1239         .name = "OpenHarmony",
1240     };
1241     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
1242         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
1243     EXPECT_NE(nullptr, screenSession);
1244     std::vector<uint32_t> colorSpaces = { 0, 0, 0, 0 };
1245     screenSession->SetColorSpaces(std::move(colorSpaces));
1246     GTEST_LOG_(INFO) << "SetColorSpaces end";
1247 }
1248 
1249 /**
1250  * @tc.name: SetSupportedRefreshRate
1251  * @tc.desc: normal function
1252  * @tc.type: FUNC
1253  */
1254 HWTEST_F(ScreenSessionTest, SetSupportedRefreshRate, TestSize.Level1)
1255 {
1256     GTEST_LOG_(INFO) << "SetSupportedRefreshRate start";
1257     ScreenSessionConfig config = {
1258         .screenId = 100,
1259         .rsId = 101,
1260         .name = "OpenHarmony",
1261     };
1262     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
1263         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
1264     EXPECT_NE(nullptr, screenSession);
1265     std::vector<uint32_t> supportedRefreshRate = { 0, 0, 0, 0 };
1266     std::vector<uint32_t> supportedRefreshRate_cmp = { 0, 0, 0, 0 };
1267     screenSession->SetSupportedRefreshRate(std::move(supportedRefreshRate));
1268     EXPECT_EQ(screenSession->supportedRefreshRate_, supportedRefreshRate_cmp);
1269     GTEST_LOG_(INFO) << "SetSupportedRefreshRate end";
1270 }
1271 
1272 /**
1273  * @tc.name: SetDisplayNodeScreenId
1274  * @tc.desc: normal function
1275  * @tc.type: FUNC
1276  */
1277 HWTEST_F(ScreenSessionTest, SetDisplayNodeScreenId, TestSize.Level1)
1278 {
1279     GTEST_LOG_(INFO) << "ScreenSessionTest: SetDisplayNodeScreenId start";
1280     ScreenId screenId = 0;
1281     ScreenId rsId = 1;
1282     std::string name = "OpenHarmony";
1283     ScreenProperty property;
1284     RSDisplayNodeConfig displayNodeConfig;
1285     std::shared_ptr<RSDisplayNode> displayNode = RSDisplayNode::Create(displayNodeConfig);
1286     EXPECT_NE(nullptr, displayNode);
1287     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr(screenId, rsId, name, property, displayNode);
1288     session->SetDisplayNodeScreenId(screenId);
1289     GTEST_LOG_(INFO) << "ScreenSessionTest: SetDisplayNodeScreenId end";
1290 }
1291 
1292 /**
1293  * @tc.name: UnregisterScreenChangeListener
1294  * @tc.desc: normal function
1295  * @tc.type: FUNC
1296  */
1297 HWTEST_F(ScreenSessionTest, UnregisterScreenChangeListener, TestSize.Level1)
1298 {
1299     GTEST_LOG_(INFO) << "ScreenSessionTest: UnregisterScreenChangeListener start";
1300     IScreenChangeListener* screenChangeListener = nullptr;
1301     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
1302     int64_t ret = 0;
1303     session->UnregisterScreenChangeListener(screenChangeListener);
1304     ASSERT_EQ(ret, 0);
1305     GTEST_LOG_(INFO) << "ScreenSessionTest: UnregisterScreenChangeListener end";
1306 }
1307 
1308 /**
1309  * @tc.name: UnregisterScreenChangeListener02
1310  * @tc.desc: normal function
1311  * @tc.type: FUNC
1312  */
1313 HWTEST_F(ScreenSessionTest, UnregisterScreenChangeListener02, TestSize.Level1)
1314 {
1315     GTEST_LOG_(INFO) << "ScreenSessionTest: UnregisterScreenChangeListener02 start";
1316     IScreenChangeListener* screenChangeListener = new ScreenSessionManager();
1317     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
1318     int64_t ret = 0;
1319     session->UnregisterScreenChangeListener(screenChangeListener);
1320     ASSERT_EQ(ret, 0);
1321     GTEST_LOG_(INFO) << "ScreenSessionTest: UnregisterScreenChangeListener02 end";
1322 }
1323 
1324 /**
1325  * @tc.name: ConvertToDisplayInfo
1326  * @tc.desc: normal function
1327  * @tc.type: FUNC
1328  */
1329 HWTEST_F(ScreenSessionTest, ConvertToDisplayInfo, TestSize.Level1)
1330 {
1331     GTEST_LOG_(INFO) << "ScreenSessionTest: ConvertToDisplayInfo start";
1332     sptr<DisplayInfo> displayInfo = sptr<DisplayInfo>::MakeSptr();
1333     EXPECT_NE(displayInfo, nullptr);
1334     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
1335     EXPECT_NE(nullptr, session->ConvertToDisplayInfo());
1336 
1337     sptr<ScreenInfo> info = sptr<ScreenInfo>::MakeSptr();
1338     EXPECT_NE(info, nullptr);
1339     EXPECT_NE(nullptr, session->ConvertToScreenInfo());
1340     GTEST_LOG_(INFO) << "ScreenSessionTest: ConvertToDisplayInfo end";
1341 }
1342 
1343 /**
1344  * @tc.name: SetMirrorScreenRegion
1345  * @tc.desc: SetMirrorScreenRegion test
1346  * @tc.type: FUNC
1347  */
1348 HWTEST_F(ScreenSessionTest, SetMirrorScreenRegion, Function | SmallTest | Level2)
1349 {
1350     GTEST_LOG_(INFO) << "ScreenSessionTest: SetMirrorScreenRegion start";
1351     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
1352     ASSERT_NE(session, nullptr);
1353     DMRect area = {2, 2, 2, 2};
1354     ScreenId screenId = 0;
1355     session->SetMirrorScreenRegion(screenId, area);
1356     std::pair<ScreenId, DMRect> mode1 = session->GetMirrorScreenRegion();
1357     EXPECT_EQ(screenId, mode1.first);
1358     EXPECT_EQ(area, mode1.second);
1359     GTEST_LOG_(INFO) << "ScreenSessionTest: SetMirrorScreenRegion end";
1360 }
1361 
1362 /**
1363  * @tc.name: GetScreenSupportedColorGamuts
1364  * @tc.desc: normal function
1365  * @tc.type: FUNC
1366  */
1367 HWTEST_F(ScreenSessionTest, GetScreenSupportedColorGamuts, TestSize.Level1)
1368 {
1369     GTEST_LOG_(INFO) << "ScreenSessionTest: GetScreenSupportedColorGamuts start";
1370     std::vector<ScreenColorGamut> colorGamuts;
1371     ScreenSessionConfig config = {
1372         .screenId = 0,
1373         .rsId = 0,
1374         .name = "OpenHarmony",
1375     };
1376     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
1377         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
1378     ASSERT_NE(screenSession, nullptr);
1379     DMError ret = screenSession->GetScreenSupportedColorGamuts(colorGamuts);
1380     if (SceneBoardJudgement::IsSceneBoardEnabled()) {
1381         ASSERT_EQ(ret, DMError::DM_OK);
1382     } else {
1383         ASSERT_NE(ret, DMError::DM_OK);
1384     }
1385     GTEST_LOG_(INFO) << "ScreenSessionTest: GetScreenSupportedColorGamuts end";
1386 }
1387 
1388 /**
1389  * @tc.name: GetActiveScreenMode
1390  * @tc.desc: normal function
1391  * @tc.type: FUNC
1392  */
1393 HWTEST_F(ScreenSessionTest, GetActiveScreenMode, TestSize.Level1)
1394 {
1395     GTEST_LOG_(INFO) << "ScreenSessionTest: GetActiveScreenMode start";
1396     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
1397     session->activeIdx_ = -1;
1398     sptr<SupportedScreenModes> mode1 = session->GetActiveScreenMode();
1399     session->GetActiveScreenMode();
1400     ASSERT_EQ(mode1, nullptr);
1401 
1402     session->activeIdx_ = 100;
1403     sptr<SupportedScreenModes> mode2 = session->GetActiveScreenMode();
1404     session->GetActiveScreenMode();
1405     ASSERT_EQ(mode2, nullptr);
1406 
1407     GTEST_LOG_(INFO) << "ScreenSessionTest: GetActiveScreenMode end";
1408 }
1409 
1410 /**
1411  * @tc.name: SetScreenCombination
1412  * @tc.desc: normal function
1413  * @tc.type: FUNC
1414  */
1415 HWTEST_F(ScreenSessionTest, SetScreenCombination, TestSize.Level1)
1416 {
1417     GTEST_LOG_(INFO) << "ScreenSessionTest: SetScreenCombination start";
1418     ScreenId screenId = 2024;
1419     ScreenProperty property;
1420     NodeId nodeId = 0;
1421     ScreenId defaultScreenId = 0;
1422     ScreenCombination combination { ScreenCombination::SCREEN_ALONE };
1423     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr(screenId, property, nodeId, defaultScreenId);
1424     session->SetScreenCombination(combination);
1425     EXPECT_NE(session, nullptr);
1426     EXPECT_EQ(combination, session->GetScreenCombination());
1427     GTEST_LOG_(INFO) << "ScreenSessionTest: SetScreenCombination end";
1428 }
1429 
1430 /**
1431  * @tc.name: GetScreenColorGamut
1432  * @tc.desc: normal function
1433  * @tc.type: FUNC
1434  */
1435 HWTEST_F(ScreenSessionTest, GetScreenColorGamut, TestSize.Level1)
1436 {
1437 #ifdef WM_SCREEN_COLOR_GAMUT_ENABLE
1438     GTEST_LOG_(INFO) << "ScreenSessionTest: GetScreenColorGamut start";
1439     ScreenSessionConfig config = {
1440         .screenId = 0,
1441         .rsId = 0,
1442         .name = "OpenHarmony",
1443     };
1444     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
1445         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
1446     ASSERT_NE(screenSession, nullptr);
1447     ScreenColorGamut colorGamut;
1448     DMError res = screenSession->GetScreenColorGamut(colorGamut);
1449     if (SceneBoardJudgement::IsSceneBoardEnabled()) {
1450         ASSERT_EQ(res, DMError::DM_OK);
1451     } else {
1452         ASSERT_NE(res, DMError::DM_OK);
1453     }
1454     GTEST_LOG_(INFO) << "ScreenSessionTest: GetScreenColorGamut end";
1455 #endif
1456 }
1457 
1458 /**
1459  * @tc.name: SetScreenColorGamut01
1460  * @tc.desc: normal function
1461  * @tc.type: FUNC
1462  */
1463 HWTEST_F(ScreenSessionTest, SetScreenColorGamut01, TestSize.Level1)
1464 {
1465 #ifdef WM_SCREEN_COLOR_GAMUT_ENABLE
1466     GTEST_LOG_(INFO) << "ScreenSessionTest: SetScreenColorGamut start";
1467     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
1468     ASSERT_NE(session, nullptr);
1469 
1470     int32_t colorGamut = 1;
1471     DMError res = session->SetScreenColorGamut(colorGamut);
1472     ASSERT_EQ(res, DMError::DM_ERROR_RENDER_SERVICE_FAILED);
1473     GTEST_LOG_(INFO) << "ScreenSessionTest: SetScreenColorGamut end";
1474 #endif
1475 }
1476 
1477 /**
1478  * @tc.name: SetScreenColorGamut02
1479  * @tc.desc: normal function
1480  * @tc.type: FUNC
1481  */
1482 HWTEST_F(ScreenSessionTest, SetScreenColorGamut02, TestSize.Level1)
1483 {
1484 #ifdef WM_SCREEN_COLOR_GAMUT_ENABLE
1485     GTEST_LOG_(INFO) << "ScreenSessionTest: SetScreenColorGamut start";
1486     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
1487     ASSERT_NE(session, nullptr);
1488 
1489     int32_t colorGamut = -1;
1490     DMError res = session->SetScreenColorGamut(colorGamut);
1491     EXPECT_NE(res, DMError::DM_OK);
1492     GTEST_LOG_(INFO) << "ScreenSessionTest: SetScreenColorGamut end";
1493 #endif
1494 }
1495 
1496 /**
1497  * @tc.name: GetScreenGamutMap
1498  * @tc.desc: normal function
1499  * @tc.type: FUNC
1500  */
1501 HWTEST_F(ScreenSessionTest, GetScreenGamutMap, TestSize.Level1)
1502 {
1503 #ifdef WM_SCREEN_COLOR_GAMUT_ENABLE
1504     GTEST_LOG_(INFO) << "ScreenSessionTest: GetScreenGamutMap start";
1505     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
1506     ASSERT_NE(session, nullptr);
1507 
1508     ScreenGamutMap gamutMap;
1509     DMError res = session->GetScreenGamutMap(gamutMap);
1510     ASSERT_EQ(res, DMError::DM_ERROR_RENDER_SERVICE_FAILED);
1511     GTEST_LOG_(INFO) << "ScreenSessionTest: GetScreenGamutMap end";
1512 #endif
1513 }
1514 
1515 /**
1516  * @tc.name: SetScreenGamutMap
1517  * @tc.desc: normal function
1518  * @tc.type: FUNC
1519  */
1520 HWTEST_F(ScreenSessionTest, SetScreenGamutMap, TestSize.Level1)
1521 {
1522 #ifdef WM_SCREEN_COLOR_GAMUT_ENABLE
1523     GTEST_LOG_(INFO) << "ScreenSessionTest: SetScreenGamutMap start";
1524     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
1525     ASSERT_NE(session, nullptr);
1526     ScreenGamutMap gamutMap = GAMUT_MAP_CONSTANT;
1527     DMError res = session->SetScreenGamutMap(gamutMap);
1528     ASSERT_EQ(res, DMError::DM_ERROR_RENDER_SERVICE_FAILED);
1529 
1530     gamutMap = GAMUT_MAP_HDR_EXTENSION;
1531     res = session->SetScreenGamutMap(gamutMap);
1532     ASSERT_EQ(res, DMError::DM_ERROR_RENDER_SERVICE_FAILED);
1533     GTEST_LOG_(INFO) << "ScreenSessionTest: SetScreenGamutMap end";
1534 #endif
1535 }
1536 
1537 /**
1538  * @tc.name: InitRSDisplayNode
1539  * @tc.desc: normal function
1540  * @tc.type: FUNC
1541  */
1542 HWTEST_F(ScreenSessionTest, InitRSDisplayNode, TestSize.Level1)
1543 {
1544     GTEST_LOG_(INFO) << "ScreenSessionTest: InitRSDisplayNode start";
1545     ScreenSessionGroup sessionGroup(1, 1, "create", ScreenCombination::SCREEN_ALONE);
1546     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
1547     ASSERT_NE(session, nullptr);
1548     RSDisplayNodeConfig config;
1549     Point startPoint;
1550     int res = 0;
1551     sessionGroup.InitRSDisplayNode(config, startPoint);
1552     ASSERT_EQ(res, 0);
1553     GTEST_LOG_(INFO) << "ScreenSessionTest: InitRSDisplayNode end";
1554 }
1555 
1556 /**
1557  * @tc.name: GetRSDisplayNodeConfig
1558  * @tc.desc: normal function
1559  * @tc.type: FUNC
1560  */
1561 HWTEST_F(ScreenSessionTest, GetRSDisplayNodeConfig, TestSize.Level1)
1562 {
1563     GTEST_LOG_(INFO) << "ScreenSessionTest: GetRSDisplayNodeConfig start";
1564     ScreenSessionGroup sessionGroup(1, 1, "create", ScreenCombination::SCREEN_ALONE);
1565     sptr<ScreenSession> session0 = nullptr;
1566     RSDisplayNodeConfig config = {1};
1567     sptr<ScreenSession> defaultScreenSession;
1568     bool res = sessionGroup.GetRSDisplayNodeConfig(session0, config, defaultScreenSession);
1569     ASSERT_EQ(res, false);
1570 
1571     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
1572     sessionGroup.combination_ = ScreenCombination::SCREEN_ALONE;
1573     res = sessionGroup.GetRSDisplayNodeConfig(session, config, defaultScreenSession);
1574     ASSERT_EQ(res, true);
1575 
1576     sessionGroup.combination_ = ScreenCombination::SCREEN_EXPAND;
1577     res = sessionGroup.GetRSDisplayNodeConfig(session, config, defaultScreenSession);
1578     ASSERT_EQ(res, true);
1579 
1580     sessionGroup.combination_ = ScreenCombination::SCREEN_MIRROR;
1581     res = sessionGroup.GetRSDisplayNodeConfig(session, config, defaultScreenSession);
1582     ASSERT_EQ(res, true);
1583     GTEST_LOG_(INFO) << "ScreenSessionTest: GetRSDisplayNodeConfig end";
1584 }
1585 
1586 /**
1587  * @tc.name: AddChild
1588  * @tc.desc: normal function
1589  * @tc.type: FUNC
1590  */
1591 HWTEST_F(ScreenSessionTest, AddChild, TestSize.Level1)
1592 {
1593     GTEST_LOG_(INFO) << "ScreenSessionTest: AddChild start";
1594     ScreenSessionGroup sessionGroup(1, 1, "create", ScreenCombination::SCREEN_ALONE);
1595     sptr<ScreenSession> session0 = nullptr;
1596     Point startPoint(0, 0);
1597     sptr<ScreenSession> defaultScreenSession;
1598     bool res = sessionGroup.AddChild(session0, startPoint, defaultScreenSession);
1599     ASSERT_EQ(res, false);
1600 
1601     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
1602     res = sessionGroup.AddChild(session, startPoint, defaultScreenSession);
1603     ASSERT_EQ(res, true);
1604     GTEST_LOG_(INFO) << "ScreenSessionTest: AddChild end";
1605 }
1606 
1607 /**
1608  * @tc.name: AddChildren01
1609  * @tc.desc: normal function
1610  * @tc.type: FUNC
1611  */
1612 HWTEST_F(ScreenSessionTest, AddChildren01, TestSize.Level1)
1613 {
1614     GTEST_LOG_(INFO) << "ScreenSessionTest: AddChildren start";
1615     ScreenSessionGroup sessionGroup(1, 1, "create", ScreenCombination::SCREEN_ALONE);
1616     std::vector<sptr<ScreenSession>> smsScreens;
1617     std::vector<Point> startPoints;
1618     bool res = sessionGroup.AddChildren(smsScreens, startPoints);
1619     ASSERT_EQ(res, true);
1620     GTEST_LOG_(INFO) << "ScreenSessionTest: AddChildren end";
1621 }
1622 
1623 /**
1624  * @tc.name: AddChildren02
1625  * @tc.desc: normal function
1626  * @tc.type: FUNC
1627  */
1628 HWTEST_F(ScreenSessionTest, AddChildren02, TestSize.Level1)
1629 {
1630     GTEST_LOG_(INFO) << "ScreenSessionTest: AddChildren start";
1631     ScreenSessionGroup sessionGroup(1, 1, "create", ScreenCombination::SCREEN_ALONE);
1632     std::vector<sptr<ScreenSession>> smsScreens(2);
1633     std::vector<Point> startPoints(1);
1634     bool res = sessionGroup.AddChildren(smsScreens, startPoints);
1635     ASSERT_EQ(res, false);
1636     GTEST_LOG_(INFO) << "ScreenSessionTest: AddChildren end";
1637 }
1638 
1639 /**
1640  * @tc.name: RemoveChild
1641  * @tc.desc: normal function
1642  * @tc.type: FUNC
1643  */
1644 HWTEST_F(ScreenSessionTest, RemoveChild, TestSize.Level1)
1645 {
1646     GTEST_LOG_(INFO) << "ScreenSessionTest: RemoveChild start";
1647     ScreenSessionGroup sessionGroup(1, 1, "create", ScreenCombination::SCREEN_ALONE);
1648     sptr<ScreenSession> session0 = nullptr;
1649     bool res = sessionGroup.RemoveChild(session0);
1650     ASSERT_EQ(res, false);
1651 
1652     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
1653     res = sessionGroup.RemoveChild(session);
1654     ASSERT_EQ(res, false);
1655     GTEST_LOG_(INFO) << "ScreenSessionTest: GetRSDisplayNodeConfig end";
1656 }
1657 
1658 /**
1659  * @tc.name: GetChildPosition
1660  * @tc.desc: normal function
1661  * @tc.type: FUNC
1662  */
1663 HWTEST_F(ScreenSessionTest, GetChildPosition, TestSize.Level1)
1664 {
1665     GTEST_LOG_(INFO) << "ScreenSessionTest: GetChildPosition start";
1666     ScreenSessionGroup sessionGroup(1, 1, "create", ScreenCombination::SCREEN_ALONE);
1667     ScreenId screenId = 1;
1668     Point res = sessionGroup.GetChildPosition(screenId);
1669     ASSERT_EQ(res.posX_, 0);
1670     GTEST_LOG_(INFO) << "ScreenSessionTest: GetChildPosition end";
1671 }
1672 
1673 /**
1674  * @tc.name: ConvertToScreenGroupInfo
1675  * @tc.desc: normal function
1676  * @tc.type: FUNC
1677  */
1678 HWTEST_F(ScreenSessionTest, ConvertToScreenGroupInfo, TestSize.Level1)
1679 {
1680     GTEST_LOG_(INFO) << "ScreenSessionTest: ConvertToScreenGroupInfo start";
1681     ScreenSessionGroup sessionGroup(1, 1, "create", ScreenCombination::SCREEN_ALONE);
1682     sptr<ScreenGroupInfo> res = sessionGroup.ConvertToScreenGroupInfo();
1683     ASSERT_NE(res, nullptr);
1684     GTEST_LOG_(INFO) << "ScreenSessionTest: ConvertToScreenGroupInfo end";
1685 }
1686 
1687 /**
1688  * @tc.name: RegisterScreenChangeListener
1689  * @tc.desc: normal function
1690  * @tc.type: FUNC
1691  */
1692 HWTEST_F(ScreenSessionTest, RegisterScreenChangeListener01, TestSize.Level1)
1693 {
1694     GTEST_LOG_(INFO) << "ScreenSessionTest: RegisterScreenChangeListener start";
1695     int res = 0;
1696     IScreenChangeListener* screenChangeListener = nullptr;
1697     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
1698     session->RegisterScreenChangeListener(screenChangeListener);
1699     ASSERT_EQ(res, 0);
1700     GTEST_LOG_(INFO) << "ScreenSessionTest: RegisterScreenChangeListener end";
1701 }
1702 
1703 /**
1704  * @tc.name: RegisterScreenChangeListener
1705  * @tc.desc: Repeat to register
1706  * @tc.type: FUNC
1707  */
1708 HWTEST_F(ScreenSessionTest, RegisterScreenChangeListener02, TestSize.Level1)
1709 {
1710     GTEST_LOG_(INFO) << "ScreenSessionTest: RegisterScreenChangeListener start";
1711     IScreenChangeListener* screenChangeListener = new MockScreenChangeListener();
1712     IScreenChangeListener* screenChangeListener1 = new MockScreenChangeListener();
1713     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
1714     session->RegisterScreenChangeListener(screenChangeListener);
1715     session->RegisterScreenChangeListener(screenChangeListener1);
1716     ASSERT_FALSE(session->isFold_);
1717 }
1718 
1719 /**
1720  * @tc.name: RegisterScreenChangeListener
1721  * @tc.desc: screenState_ == ScreenState::CONNECTION
1722  * @tc.type: FUNC
1723  */
1724 HWTEST_F(ScreenSessionTest, RegisterScreenChangeListener03, TestSize.Level1)
1725 {
1726     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
1727     ASSERT_EQ(session->screenState_, ScreenState::INIT);
1728     session->screenState_ = ScreenState::CONNECTION;
1729     IScreenChangeListener* screenChangeListener = new MockScreenChangeListener();
1730     session->RegisterScreenChangeListener(screenChangeListener);
1731     ASSERT_FALSE(session->isFold_);
1732     session->screenState_ = ScreenState::INIT;
1733 }
1734 
1735 /**
1736  * @tc.name: Connect
1737  * @tc.desc: Connect
1738  * @tc.type: FUNC
1739  */
1740 HWTEST_F(ScreenSessionTest, Connect, TestSize.Level1)
1741 {
1742     IScreenChangeListener* screenChangeListener = new MockScreenChangeListener();
1743     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
1744     session->RegisterScreenChangeListener(screenChangeListener);
1745     session->Connect();
1746     ASSERT_FALSE(session->isFold_);
1747 }
1748 
1749 /**
1750  * @tc.name: UpdatePropertyByActiveMode
1751  * @tc.desc: normal function
1752  * @tc.type: FUNC
1753  */
1754 HWTEST_F(ScreenSessionTest, UpdatePropertyByActiveMode, TestSize.Level1)
1755 {
1756     GTEST_LOG_(INFO) << "ScreenSessionTest: UpdatePropertyByActiveMode start";
1757     int res = 0;
1758     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
1759     session->UpdatePropertyByActiveMode();
1760     ASSERT_EQ(res, 0);
1761     GTEST_LOG_(INFO) << "ScreenSessionTest: UpdatePropertyByActiveMode end";
1762 }
1763 
1764 /**
1765  * @tc.name: Disconnect
1766  * @tc.desc: normal function
1767  * @tc.type: FUNC
1768  */
1769 HWTEST_F(ScreenSessionTest, Disconnect, TestSize.Level1)
1770 {
1771     GTEST_LOG_(INFO) << "ScreenSessionTest: Disconnect start";
1772     int res = 0;
1773     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
1774     session->Disconnect();
1775     ASSERT_EQ(res, 0);
1776     GTEST_LOG_(INFO) << "ScreenSessionTest: Disconnect end";
1777 }
1778 
1779 /**
1780  * @tc.name: Disconnect
1781  * @tc.desc: !listener
1782  * @tc.type: FUNC
1783  */
1784 HWTEST_F(ScreenSessionTest, Disconnect02, TestSize.Level1)
1785 {
1786     IScreenChangeListener* screenChangeListener = new MockScreenChangeListener();
1787     IScreenChangeListener* screenChangeListener1 = new MockScreenChangeListener();
1788     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
1789     sptr<ScreenSession> session1 = sptr<ScreenSession>::MakeSptr();
1790     session->RegisterScreenChangeListener(screenChangeListener);
1791     session1->RegisterScreenChangeListener(screenChangeListener1);
1792     session1->Connect();
1793     session1->Disconnect();
1794     ASSERT_FALSE(session->isFold_);
1795 }
1796 
1797 /**
1798  * @tc.name: SensorRotationChange
1799  * @tc.desc: normal function
1800  * @tc.type: FUNC
1801  */
1802 HWTEST_F(ScreenSessionTest, SensorRotationChange01, TestSize.Level1)
1803 {
1804     GTEST_LOG_(INFO) << "ScreenSessionTest: SensorRotationChange start";
1805     int res = 0;
1806     Rotation sensorRotation = Rotation::ROTATION_0;
1807     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
1808     session->SensorRotationChange(sensorRotation);
1809     ASSERT_EQ(res, 0);
1810     GTEST_LOG_(INFO) << "ScreenSessionTest: SensorRotationChange end";
1811 }
1812 
1813 /**
1814  * @tc.name: SensorRotationChange
1815  * @tc.desc: run in for
1816  * @tc.type: FUNC
1817  */
1818 HWTEST_F(ScreenSessionTest, SensorRotationChange02, TestSize.Level1)
1819 {
1820     IScreenChangeListener* screenChangeListener = new MockScreenChangeListener();
1821     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
1822     session->RegisterScreenChangeListener(screenChangeListener);
1823     Rotation sensorRotation = Rotation::ROTATION_90;
1824     session->SensorRotationChange(sensorRotation);
1825     ASSERT_FALSE(session->isFold_);
1826 }
1827 
1828 /**
1829  * @tc.name: SetOrientation
1830  * @tc.desc: normal function
1831  * @tc.type: FUNC
1832  */
1833 HWTEST_F(ScreenSessionTest, SetOrientation, TestSize.Level1)
1834 {
1835     GTEST_LOG_(INFO) << "ScreenSessionTest: SetOrientation start";
1836     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
1837     Orientation orientation = Orientation::UNSPECIFIED;
1838     session->SetOrientation(orientation);
1839     Orientation res = session->GetOrientation();
1840     ASSERT_EQ(res, orientation);
1841     GTEST_LOG_(INFO) << "ScreenSessionTest: SetOrientation end";
1842 }
1843 
1844 /**
1845  * @tc.name: SetScreenRequestedOrientation
1846  * @tc.desc: normal function
1847  * @tc.type: FUNC
1848  */
1849 HWTEST_F(ScreenSessionTest, SetScreenRequestedOrientation, TestSize.Level1)
1850 {
1851     GTEST_LOG_(INFO) << "ScreenSessionTest: SetScreenRequestedOrientation start";
1852     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
1853     Orientation orientation = Orientation::UNSPECIFIED;
1854     session->SetScreenRequestedOrientation(orientation);
1855     Orientation res = session->GetScreenRequestedOrientation();
1856     ASSERT_EQ(res, orientation);
1857     GTEST_LOG_(INFO) << "ScreenSessionTest: SetScreenRequestedOrientation end";
1858 }
1859 
1860 /**
1861  * @tc.name: SetUpdateToInputManagerCallback
1862  * @tc.desc: normal function
1863  * @tc.type: FUNC
1864  */
1865 HWTEST_F(ScreenSessionTest, SetUpdateToInputManagerCallback, TestSize.Level1)
1866 {
1867     GTEST_LOG_(INFO) << "ScreenSessionTest: SetUpdateToInputManagerCallback start";
1868     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
__anon9ac455210502(float x) 1869     auto func = [session](float x) {
1870         session->SetVirtualPixelRatio(x);
1871     };
1872     session->SetUpdateToInputManagerCallback(func);
1873     EXPECT_NE(nullptr, &func);
1874 
1875     ScreenProperty screenPropert = session->GetScreenProperty();
1876     EXPECT_NE(nullptr, &screenPropert);
1877     session->SetVirtualPixelRatio(3.14);
1878 
1879     ScreenType screenType { ScreenType::REAL };
1880     session->SetScreenType(screenType);
1881 
1882     GTEST_LOG_(INFO) << "ScreenSessionTest: SetUpdateToInputManagerCallbackend";
1883 }
1884 
1885 /**
1886  * @tc.name: SetScreenRotationLocked
1887  * @tc.desc: normal function
1888  * @tc.type: FUNC
1889  */
1890 HWTEST_F(ScreenSessionTest, SetScreenRotationLocked, TestSize.Level1)
1891 {
1892     GTEST_LOG_(INFO) << "ScreenSessionTest: SetScreenRotationLocked start";
1893     bool isLocked = true;
1894     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
1895     session->SetScreenRotationLocked(isLocked);
1896     bool res = session->IsScreenRotationLocked();
1897     ASSERT_EQ(res, isLocked);
1898     GTEST_LOG_(INFO) << "ScreenSessionTest: SetScreenRotationLocked end";
1899 }
1900 
1901 /**
1902  * @tc.name: SetScreenRotationLockedFromJs
1903  * @tc.desc: normal function
1904  * @tc.type: FUNC
1905  */
1906 HWTEST_F(ScreenSessionTest, SetScreenRotationLockedFromJs, TestSize.Level1)
1907 {
1908     GTEST_LOG_(INFO) << "ScreenSessionTest: SetScreenRotationLockedFromJs start";
1909     bool isLocked = true;
1910     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
1911     session->SetScreenRotationLockedFromJs(isLocked);
1912     bool res = session->IsScreenRotationLocked();
1913     ASSERT_EQ(res, isLocked);
1914     GTEST_LOG_(INFO) << "ScreenSessionTest: SetScreenRotationLockedFromJs end";
1915 }
1916 
1917 /**
1918  * @tc.name: IsScreenRotationLocked
1919  * @tc.desc: normal function
1920  * @tc.type: FUNC
1921  */
1922 HWTEST_F(ScreenSessionTest, IsScreenRotationLocked, TestSize.Level1)
1923 {
1924     GTEST_LOG_(INFO) << "ScreenSessionTest: IsScreenRotationLocked start";
1925     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
1926     bool res = session->IsScreenRotationLocked();
1927     ASSERT_EQ(res, session->isScreenLocked_);
1928     GTEST_LOG_(INFO) << "ScreenSessionTest: IsScreenRotationLocked end";
1929 }
1930 
1931 /**
1932  * @tc.name: GetScreenRequestedOrientation
1933  * @tc.desc: normal function
1934  * @tc.type: FUNC
1935  */
1936 HWTEST_F(ScreenSessionTest, GetScreenRequestedOrientation, TestSize.Level1)
1937 {
1938     GTEST_LOG_(INFO) << "ScreenSessionTest: GetScreenRequestedOrientation start";
1939     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
1940     Orientation res = session->GetScreenRequestedOrientation();
1941     ASSERT_EQ(res, session->property_.GetScreenRequestedOrientation());
1942     GTEST_LOG_(INFO) << "ScreenSessionTest: GetScreenRequestedOrientation end";
1943 }
1944 
1945 /**
1946  * @tc.name: SetVirtualPixelRatio
1947  * @tc.desc: normal function
1948  * @tc.type: FUNC
1949  */
1950 HWTEST_F(ScreenSessionTest, SetVirtualPixelRatio, TestSize.Level1)
1951 {
1952     GTEST_LOG_(INFO) << "ScreenSessionTest: SetVirtualPixelRatio start";
1953     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
1954     float virtualPixelRatio = 1;
1955     session->SetVirtualPixelRatio(virtualPixelRatio);
1956     float res = session->property_.GetVirtualPixelRatio();
1957     ASSERT_EQ(res, virtualPixelRatio);
1958     GTEST_LOG_(INFO) << "ScreenSessionTest: SetVirtualPixelRatio end";
1959 }
1960 
1961 /**
1962  * @tc.name: screen_session_test001
1963  * @tc.desc: normal function
1964  * @tc.type: FUNC
1965  */
1966 HWTEST_F(ScreenSessionTest, screen_session_test001, TestSize.Level1)
1967 {
1968     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test001 start";
1969     IScreenChangeListener* screenChangeListener = nullptr;
1970     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
1971     session->screenState_ = ScreenState::CONNECTION;
1972     int res = 0;
1973     session->RegisterScreenChangeListener(screenChangeListener);
1974     ASSERT_EQ(res, 0);
1975     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test001 end";
1976 }
1977 
1978 /**
1979  * @tc.name: screen_session_test002
1980  * @tc.desc: normal function
1981  * @tc.type: FUNC
1982  */
1983 HWTEST_F(ScreenSessionTest, screen_session_test002, TestSize.Level1)
1984 {
1985     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test002 start";
1986     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
1987     ScreenId res = session->GetScreenId();
1988     ASSERT_EQ(res, session->screenId_);
1989     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test002 end";
1990 }
1991 
1992 /**
1993  * @tc.name: screen_session_test003
1994  * @tc.desc: normal function
1995  * @tc.type: FUNC
1996  */
1997 HWTEST_F(ScreenSessionTest, screen_session_test003, TestSize.Level1)
1998 {
1999     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test003 start";
2000     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
2001     DMError res = session->SetScreenColorTransform();
2002     ASSERT_EQ(res, DMError::DM_OK);
2003     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test003 end";
2004 }
2005 
2006 /**
2007  * @tc.name: screen_session_test004
2008  * @tc.desc: normal function
2009  * @tc.type: FUNC
2010  */
2011 HWTEST_F(ScreenSessionTest, screen_session_test004, TestSize.Level1)
2012 {
2013     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test004 start";
2014     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
2015     ScreenProperty newProperty;
2016     int res = 0;
2017     session->UpdatePropertyByFoldControl(newProperty);
2018     ASSERT_EQ(res, 0);
2019     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test004 end";
2020 }
2021 
2022 /**
2023  * @tc.name: screen_session_test005
2024  * @tc.desc: normal function
2025  * @tc.type: FUNC
2026  */
2027 HWTEST_F(ScreenSessionTest, screen_session_test005, TestSize.Level1)
2028 {
2029     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test005 start";
2030     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
2031     ScreenProperty newProperty;
2032     ScreenPropertyChangeReason reason = ScreenPropertyChangeReason::CHANGE_MODE;
2033     int res = 0;
2034     session->PropertyChange(newProperty, reason);
2035     reason = ScreenPropertyChangeReason::VIRTUAL_PIXEL_RATIO_CHANGE;
2036     session->PropertyChange(newProperty, reason);
2037     ASSERT_EQ(res, 0);
2038     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test005 end";
2039 }
2040 
2041 /**
2042  * @tc.name: screen_session_test006
2043  * @tc.desc: normal function
2044  * @tc.type: FUNC
2045  */
2046 HWTEST_F(ScreenSessionTest, screen_session_test006, TestSize.Level1)
2047 {
2048     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test006 start";
2049     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
2050     Rotation sensorRotation = Rotation::ROTATION_90;
2051     float res = session->ConvertRotationToFloat(sensorRotation);
2052     ASSERT_EQ(res, 90.f);
2053     sensorRotation = Rotation::ROTATION_180;
2054     res = session->ConvertRotationToFloat(sensorRotation);
2055     ASSERT_EQ(res, 180.f);
2056     sensorRotation = Rotation::ROTATION_270;
2057     res = session->ConvertRotationToFloat(sensorRotation);
2058     ASSERT_EQ(res, 270.f);
2059     sensorRotation = Rotation::ROTATION_0;
2060     res = session->ConvertRotationToFloat(sensorRotation);
2061     ASSERT_EQ(res, 0.f);
2062     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test006 end";
2063 }
2064 
2065 /**
2066  * @tc.name: screen_session_test007
2067  * @tc.desc: normal function
2068  * @tc.type: FUNC
2069  */
2070 HWTEST_F(ScreenSessionTest, screen_session_test007, TestSize.Level1)
2071 {
2072     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test007 start";
2073     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
2074     Orientation orientation = Orientation::UNSPECIFIED;
2075     int res = 0;
2076     session->ScreenOrientationChange(orientation, FoldDisplayMode::UNKNOWN);
2077     ASSERT_EQ(res, 0);
2078     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test007 end";
2079 }
2080 
2081 /**
2082  * @tc.name: screen_session_test008
2083  * @tc.desc: normal function
2084  * @tc.type: FUNC
2085  */
2086 HWTEST_F(ScreenSessionTest, screen_session_test008, TestSize.Level1)
2087 {
2088     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test008 start";
2089     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
2090     bool res = session->HasPrivateSessionForeground();
2091     ASSERT_EQ(res, false);
2092     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test008 end";
2093 }
2094 
2095 /**
2096  * @tc.name: screen_session_test009
2097  * @tc.desc: normal function
2098  * @tc.type: FUNC
2099  */
2100 HWTEST_F(ScreenSessionTest, screen_session_test009, TestSize.Level1)
2101 {
2102     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test009 start";
2103     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
2104     Rotation rotation = Rotation::ROTATION_90;
2105     session->SetRotation(rotation);
2106     Rotation res = session->GetRotation();
2107     ASSERT_EQ(res, rotation);
2108     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test009 end";
2109 }
2110 
2111 /**
2112  * @tc.name: screen_session_test010
2113  * @tc.desc: normal function
2114  * @tc.type: FUNC
2115  */
2116 HWTEST_F(ScreenSessionTest, screen_session_test010, TestSize.Level1)
2117 {
2118     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test010 start";
2119     ScreenSessionGroup sessionGroup(1, 1, "create", ScreenCombination::SCREEN_ALONE);
2120     ScreenId childScreen = 1;
2121     bool res = sessionGroup.HasChild(childScreen);
2122     ASSERT_EQ(res, false);
2123     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test010 end";
2124 }
2125 
2126 /**
2127  * @tc.name: screen_session_test011
2128  * @tc.desc: normal function
2129  * @tc.type: FUNC
2130  */
2131 HWTEST_F(ScreenSessionTest, screen_session_test011, TestSize.Level1)
2132 {
2133     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test011 start";
2134     ScreenSessionGroup sessionGroup(1, 1, "create", ScreenCombination::SCREEN_ALONE);
2135     std::vector<sptr<ScreenSession>> res = sessionGroup.GetChildren();
2136     ASSERT_EQ(res.empty(), true);
2137     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test011 end";
2138 }
2139 
2140 /**
2141  * @tc.name: screen_session_test012
2142  * @tc.desc: normal function
2143  * @tc.type: FUNC
2144  */
2145 HWTEST_F(ScreenSessionTest, screen_session_test012, TestSize.Level1)
2146 {
2147     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test012 start";
2148     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
2149     int res = 0;
2150     RectF rect = RectF(0, 0, 0, 0);
2151     uint32_t offsetY = 0;
2152     session->SetDisplayBoundary(rect, offsetY);
2153     ASSERT_EQ(res, 0);
2154     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test012 end";
2155 }
2156 
2157 /**
2158  * @tc.name: GetName
2159  * @tc.desc: normal function
2160  * @tc.type: FUNC
2161  */
2162 HWTEST_F(ScreenSessionTest, GetName, TestSize.Level1)
2163 {
2164     GTEST_LOG_(INFO) << "ScreenSessionTest: GetName start";
2165     std::string name { "UNKNOWN" };
2166     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
2167     ASSERT_EQ(name, session->GetName());
2168     GTEST_LOG_(INFO) << "ScreenSessionTest: GetName end";
2169 }
2170 
2171 /**
2172  * @tc.name: SetName
2173  * @tc.desc: normal function
2174  * @tc.type: FUNC
2175  */
2176 HWTEST_F(ScreenSessionTest, SetName, TestSize.Level1)
2177 {
2178     GTEST_LOG_(INFO) << "ScreenSessionTest: SetName start";
2179     std::string name { "UNKNOWN" };
2180     int ret = 0;
2181     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
2182     session->SetName(name);
2183     ASSERT_EQ(ret, 0);
2184     GTEST_LOG_(INFO) << "ScreenSessionTest: SetName end";
2185 }
2186 
2187 /**
2188  * @tc.name: GetScreenSnapshot
2189  * @tc.desc: normal function
2190  * @tc.type: FUNC
2191  */
2192 HWTEST_F(ScreenSessionTest, GetScreenSnapshot, TestSize.Level1)
2193 {
2194     GTEST_LOG_(INFO) << "ScreenSessionTest: GetScreenSnapshot start";
2195     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
2196     session->displayNode_ = nullptr;
2197     auto pixelmap = session->GetScreenSnapshot(1.0, 1.0);
2198     EXPECT_EQ(pixelmap, nullptr);
2199 
2200     ScreenProperty newScreenProperty;
2201     session = sptr<ScreenSession>::MakeSptr(0, newScreenProperty, 0);
2202     pixelmap = session->GetScreenSnapshot(1.0, 1.0);
2203     int ret = 0;
2204     ASSERT_EQ(ret, 0);
2205     GTEST_LOG_(INFO) << "ScreenSessionTest: GetScreenSnapshot end";
2206 }
2207 
2208 /**
2209  * @tc.name: GetRSScreenId
2210  * @tc.desc: normal function
2211  * @tc.type: FUNC
2212  */
2213 HWTEST_F(ScreenSessionTest, GetRSScreenId, TestSize.Level1)
2214 {
2215     GTEST_LOG_(INFO) << "ScreenSessionTest: GetRSScreenId start";
2216     ScreenProperty property;
2217     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr("OpenHarmony", 1, 100, 0);
2218     EXPECT_EQ(100, session->GetRSScreenId());
2219 
2220     RSDisplayNodeConfig displayNodeConfig;
2221     std::shared_ptr<RSDisplayNode> displayNode = RSDisplayNode::Create(displayNodeConfig);
2222     session = sptr<ScreenSession>::MakeSptr(1, 100, "OpenHarmony",
2223         property, displayNode);
2224     EXPECT_NE(nullptr, session->GetDisplayNode());
2225     session->ReleaseDisplayNode();
2226     EXPECT_EQ(nullptr, session->GetDisplayNode());
2227     GTEST_LOG_(INFO) << "ScreenSessionTest: GetRSScreenId end";
2228 }
2229 
2230 /**
2231  * @tc.name: CalcRotation01
2232  * @tc.desc: normal function
2233  * @tc.type: FUNC
2234  */
2235 HWTEST_F(ScreenSessionTest, CalcRotation01, TestSize.Level1)
2236 {
2237     GTEST_LOG_(INFO) << "ScreenSessionTest: CalcRotation start";
2238     Orientation orientation { Orientation::BEGIN };
2239     FoldDisplayMode foldDisplayMode { FoldDisplayMode::COORDINATION };
2240     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
2241     session->activeIdx_ = -1;
2242     auto res = session->CalcRotation(orientation, foldDisplayMode);
2243     EXPECT_EQ(Rotation::ROTATION_0, res);
2244 
2245     sptr<SupportedScreenModes> supportedScreenModes = new SupportedScreenModes;
2246     supportedScreenModes->width_ = 40;
2247     supportedScreenModes->height_ = 20;
2248     session->modes_ = { supportedScreenModes };
2249     session->activeIdx_ = 0;
2250 
2251     orientation = Orientation::UNSPECIFIED;
2252     res = session->CalcRotation(orientation, foldDisplayMode);
2253     EXPECT_EQ(Rotation::ROTATION_0, res);
2254 
2255     orientation = Orientation::VERTICAL;
2256     res = session->CalcRotation(orientation, foldDisplayMode);
2257     if (ScreenSessionManager::GetInstance().IsFoldable() && !FoldScreenStateInternel::IsSuperFoldDisplayDevice()) {
2258         EXPECT_EQ(Rotation::ROTATION_0, res);
2259     } else {
2260         EXPECT_EQ(Rotation::ROTATION_90, res);
2261     }
2262 
2263     orientation = Orientation::HORIZONTAL;
2264     res = session->CalcRotation(orientation, foldDisplayMode);
2265     if (ScreenSessionManager::GetInstance().IsFoldable() && !FoldScreenStateInternel::IsSuperFoldDisplayDevice()) {
2266         EXPECT_EQ(Rotation::ROTATION_90, res);
2267     } else {
2268         EXPECT_EQ(Rotation::ROTATION_0, res);
2269     }
2270 
2271     orientation = Orientation::REVERSE_VERTICAL;
2272     res = session->CalcRotation(orientation, foldDisplayMode);
2273     if (ScreenSessionManager::GetInstance().IsFoldable() && !FoldScreenStateInternel::IsSuperFoldDisplayDevice()) {
2274         EXPECT_EQ(Rotation::ROTATION_180, res);
2275     } else {
2276         EXPECT_EQ(Rotation::ROTATION_270, res);
2277     }
2278 
2279     orientation = Orientation::REVERSE_HORIZONTAL;
2280     res = session->CalcRotation(orientation, foldDisplayMode);
2281     if (ScreenSessionManager::GetInstance().IsFoldable() && !FoldScreenStateInternel::IsSuperFoldDisplayDevice()) {
2282         EXPECT_EQ(Rotation::ROTATION_270, res);
2283     } else {
2284         EXPECT_EQ(Rotation::ROTATION_180, res);
2285     }
2286 
2287     orientation = Orientation::LOCKED;
2288     res = session->CalcRotation(orientation, foldDisplayMode);
2289     EXPECT_EQ(Rotation::ROTATION_0, res);
2290 
2291     GTEST_LOG_(INFO) << "ScreenSessionTest: CalcRotation end";
2292 }
2293 
2294 /**
2295  * @tc.name: CalcRotation02
2296  * @tc.desc: normal function
2297  * @tc.type: FUNC
2298  */
2299 HWTEST_F(ScreenSessionTest, CalcRotation02, TestSize.Level1)
2300 {
2301     GTEST_LOG_(INFO) << "ScreenSessionTest: CalcRotation start";
2302     Orientation orientation { Orientation::BEGIN };
2303     FoldDisplayMode foldDisplayMode { FoldDisplayMode::UNKNOWN };
2304     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
2305     session->activeIdx_ = -1;
2306     auto res = session->CalcRotation(orientation, foldDisplayMode);
2307     EXPECT_EQ(Rotation::ROTATION_0, res);
2308 
2309     sptr<SupportedScreenModes> supportedScreenModes = new SupportedScreenModes;
2310     supportedScreenModes->width_ = 40;
2311     supportedScreenModes->height_ = 20;
2312     session->modes_ = { supportedScreenModes };
2313     session->activeIdx_ = 0;
2314 
2315     orientation = Orientation::UNSPECIFIED;
2316     res = session->CalcRotation(orientation, foldDisplayMode);
2317     EXPECT_EQ(Rotation::ROTATION_0, res);
2318 
2319     orientation = Orientation::VERTICAL;
2320     res = session->CalcRotation(orientation, foldDisplayMode);
2321     EXPECT_EQ(Rotation::ROTATION_90, res);
2322 
2323     orientation = Orientation::HORIZONTAL;
2324     res = session->CalcRotation(orientation, foldDisplayMode);
2325     EXPECT_EQ(Rotation::ROTATION_0, res);
2326 
2327     orientation = Orientation::REVERSE_VERTICAL;
2328     res = session->CalcRotation(orientation, foldDisplayMode);
2329     EXPECT_EQ(Rotation::ROTATION_270, res);
2330 
2331     orientation = Orientation::REVERSE_HORIZONTAL;
2332     res = session->CalcRotation(orientation, foldDisplayMode);
2333     EXPECT_EQ(Rotation::ROTATION_180, res);
2334 
2335     orientation = Orientation::LOCKED;
2336     res = session->CalcRotation(orientation, foldDisplayMode);
2337     EXPECT_EQ(Rotation::ROTATION_0, res);
2338 
2339     GTEST_LOG_(INFO) << "ScreenSessionTest: CalcRotation end";
2340 }
2341 
2342 /**
2343  * @tc.name: CalcDisplayOrientation01
2344  * @tc.desc: normal function
2345  * @tc.type: FUNC
2346  */
2347 HWTEST_F(ScreenSessionTest, CalcDisplayOrientation01, TestSize.Level1)
2348 {
2349     GTEST_LOG_(INFO) << "ScreenSessionTest: CalcDisplayOrientation start";
2350     Rotation rotation { Rotation::ROTATION_0 };
2351     FoldDisplayMode foldDisplayMode { FoldDisplayMode::COORDINATION };
2352     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
2353     session->activeIdx_ = -1;
2354     auto res = session->CalcDisplayOrientation(rotation, foldDisplayMode);
2355     EXPECT_EQ(DisplayOrientation::LANDSCAPE, res);
2356 
2357     sptr<SupportedScreenModes> supportedScreenModes = new SupportedScreenModes;
2358     supportedScreenModes->width_ = 40;
2359     supportedScreenModes->height_ = 20;
2360     session->modes_ = { supportedScreenModes };
2361     session->activeIdx_ = 0;
2362 
2363     rotation = Rotation::ROTATION_0;
2364     res = session->CalcDisplayOrientation(rotation, foldDisplayMode);
2365     EXPECT_EQ(DisplayOrientation::LANDSCAPE, res);
2366 
2367     rotation = Rotation::ROTATION_90;
2368     res = session->CalcDisplayOrientation(rotation, foldDisplayMode);
2369     EXPECT_EQ(DisplayOrientation::PORTRAIT, res);
2370 
2371     rotation = Rotation::ROTATION_180;
2372     res = session->CalcDisplayOrientation(rotation, foldDisplayMode);
2373     EXPECT_EQ(DisplayOrientation::LANDSCAPE_INVERTED, res);
2374 
2375     rotation = Rotation::ROTATION_270;
2376     res = session->CalcDisplayOrientation(rotation, foldDisplayMode);
2377     EXPECT_EQ(DisplayOrientation::PORTRAIT_INVERTED, res);
2378 
2379     GTEST_LOG_(INFO) << "ScreenSessionTest: CalcDisplayOrientation end";
2380 }
2381 
2382 /**
2383  * @tc.name: CalcDisplayOrientation02
2384  * @tc.desc: normal function
2385  * @tc.type: FUNC
2386  */
2387 HWTEST_F(ScreenSessionTest, CalcDisplayOrientation02, TestSize.Level1)
2388 {
2389     GTEST_LOG_(INFO) << "ScreenSessionTest: CalcDisplayOrientation start";
2390     Rotation rotation { Rotation::ROTATION_0 };
2391     FoldDisplayMode foldDisplayMode { FoldDisplayMode::UNKNOWN };
2392     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
2393     session->activeIdx_ = -1;
2394     auto res = session->CalcDisplayOrientation(rotation, foldDisplayMode);
2395     EXPECT_EQ(DisplayOrientation::LANDSCAPE, res);
2396 
2397     sptr<SupportedScreenModes> supportedScreenModes = new SupportedScreenModes;
2398     supportedScreenModes->width_ = 40;
2399     supportedScreenModes->height_ = 20;
2400     session->modes_ = { supportedScreenModes };
2401     session->activeIdx_ = 0;
2402 
2403     rotation = Rotation::ROTATION_0;
2404     res = session->CalcDisplayOrientation(rotation, foldDisplayMode);
2405     EXPECT_EQ(DisplayOrientation::LANDSCAPE, res);
2406 
2407     rotation = Rotation::ROTATION_90;
2408     res = session->CalcDisplayOrientation(rotation, foldDisplayMode);
2409     EXPECT_EQ(DisplayOrientation::PORTRAIT, res);
2410 
2411     rotation = Rotation::ROTATION_180;
2412     res = session->CalcDisplayOrientation(rotation, foldDisplayMode);
2413     EXPECT_EQ(DisplayOrientation::LANDSCAPE_INVERTED, res);
2414 
2415     rotation = Rotation::ROTATION_270;
2416     res = session->CalcDisplayOrientation(rotation, foldDisplayMode);
2417     EXPECT_EQ(DisplayOrientation::PORTRAIT_INVERTED, res);
2418 
2419     GTEST_LOG_(INFO) << "ScreenSessionTest: CalcDisplayOrientation end";
2420 }
2421 
2422 /**
2423  * @tc.name: FillScreenInfo
2424  * @tc.desc: normal function
2425  * @tc.type: FUNC
2426  */
2427 HWTEST_F(ScreenSessionTest, FillScreenInfo, TestSize.Level1)
2428 {
2429     GTEST_LOG_(INFO) << "ScreenSessionTest: FillScreenInfo start";
2430     ScreenProperty property;
2431     property.SetVirtualPixelRatio(3.1415927);
2432     sptr<ScreenSession> session = new(std::nothrow) ScreenSession(2024, property, 0);
2433     sptr<ScreenInfo> info = nullptr;
2434     session->FillScreenInfo(info);
2435 
2436     sptr<SupportedScreenModes> supportedScreenModes = new SupportedScreenModes;
2437     session->modes_ = { supportedScreenModes };
2438     supportedScreenModes->width_ = 40;
2439     supportedScreenModes->height_ = 20;
2440     info = new ScreenInfo;
2441     session->FillScreenInfo(info);
2442     EXPECT_NE(nullptr, info);
2443     GTEST_LOG_(INFO) << "ScreenSessionTest: FillScreenInfo end";
2444 }
2445 
2446 /**
2447  * @tc.name: PropertyChange
2448  * @tc.desc: normal function
2449  * @tc.type: FUNC
2450  */
2451 HWTEST_F(ScreenSessionTest, PropertyChange, TestSize.Level1)
2452 {
2453     GTEST_LOG_(INFO) << "ScreenSessionTest: PropertyChange start";
2454     int res = 0;
2455     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
2456     ScreenProperty newProperty;
2457     ScreenPropertyChangeReason reason = ScreenPropertyChangeReason::CHANGE_MODE;
2458     session->PropertyChange(newProperty, reason);
2459     ASSERT_EQ(res, 0);
2460     GTEST_LOG_(INFO) << "ScreenSessionTest: PropertyChange end";
2461 }
2462 
2463 /**
2464  * @tc.name: PowerStatusChange
2465  * @tc.desc: normal function
2466  * @tc.type: FUNC
2467  */
2468 HWTEST_F(ScreenSessionTest, PowerStatusChange, TestSize.Level1)
2469 {
2470     GTEST_LOG_(INFO) << "ScreenSessionTest: PowerStatusChange start";
2471     int res = 0;
2472     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
2473     DisplayPowerEvent event = DisplayPowerEvent::DISPLAY_ON;
2474     EventStatus status = EventStatus::BEGIN;
2475     PowerStateChangeReason reason = PowerStateChangeReason::POWER_BUTTON;
2476     session->PowerStatusChange(event, status, reason);
2477     ASSERT_EQ(res, 0);
2478     GTEST_LOG_(INFO) << "ScreenSessionTest: PowerStatusChange end";
2479 }
2480 
2481 /**
2482  * @tc.name: SetScreenScale
2483  * @tc.desc: SetScreenScale test
2484  * @tc.type: FUNC
2485  */
2486 HWTEST_F(ScreenSessionTest, SetScreenScale, TestSize.Level1)
2487 {
2488     ScreenSession session;
2489     float scaleX = 1.0f;
2490     float scaleY = 1.0f;
2491     float pivotX = 0.5f;
2492     float pivotY = 0.5f;
2493     float translateX = 0.0f;
2494     float translateY = 0.0f;
2495     session.SetScreenScale(scaleX, scaleY, pivotX, pivotY, translateX, translateY);
2496     EXPECT_EQ(session.property_.GetScaleX(), scaleX);
2497     EXPECT_EQ(session.property_.GetScaleY(), scaleY);
2498     EXPECT_EQ(session.property_.GetPivotX(), pivotX);
2499     EXPECT_EQ(session.property_.GetPivotY(), pivotY);
2500     EXPECT_EQ(session.property_.GetTranslateX(), translateX);
2501     EXPECT_EQ(session.property_.GetTranslateY(), translateY);
2502 }
2503 
2504 /**
2505  * @tc.name: HoverStatusChange01
2506  * @tc.desc: normal function
2507  * @tc.type: FUNC
2508  */
2509 HWTEST_F(ScreenSessionTest, HoverStatusChange01, TestSize.Level1)
2510 {
2511     GTEST_LOG_(INFO) << "HoverStatusChange start";
2512     ScreenSessionConfig config = {
2513         .screenId = 100,
2514         .rsId = 101,
2515         .name = "OpenHarmony",
2516     };
2517     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
2518         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
2519     EXPECT_NE(nullptr, screenSession);
2520     int32_t HoverStatus = 0;
2521     screenSession->HoverStatusChange(HoverStatus);
2522     GTEST_LOG_(INFO) << "HoverStatusChange end";
2523 }
2524 
2525 /**
2526  * @tc.name: HoverStatusChange02
2527  * @tc.desc: run in for
2528  * @tc.type: FUNC
2529  */
2530 HWTEST_F(ScreenSessionTest, HoverStatusChange02, TestSize.Level1)
2531 {
2532     IScreenChangeListener* screenChangeListener = new MockScreenChangeListener();
2533     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
2534     EXPECT_NE(nullptr, session);
2535     session->RegisterScreenChangeListener(screenChangeListener);
2536     int32_t hoverStatus = 0;
2537     session->HoverStatusChange(hoverStatus);
2538 }
2539 
2540 /**
2541  * @tc.name: HandleHoverStatusChange01
2542  * @tc.desc: run in for
2543  * @tc.type: FUNC
2544  */
2545 HWTEST_F(ScreenSessionTest, HandleHoverStatusChange01, TestSize.Level1)
2546 {
2547     IScreenChangeListener* screenChangeListener = new MockScreenChangeListener();
2548     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
2549     EXPECT_NE(nullptr, session);
2550     session->RegisterScreenChangeListener(screenChangeListener);
2551     int32_t hoverStatus = 0;
2552     session->HandleHoverStatusChange(hoverStatus);
2553 }
2554 
2555 /**
2556  * @tc.name: ScreenCaptureNotify
2557  * @tc.desc: ScreenCaptureNotify test
2558  * @tc.type: FUNC
2559  */
2560 HWTEST_F(ScreenSessionTest, ScreenCaptureNotify, TestSize.Level1)
2561 {
2562     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
2563     ASSERT_NE(session, nullptr);
2564     ScreenId screenId = 0;
2565     int32_t uid = 0;
2566     std::string clientName = "test";
2567     session->ScreenCaptureNotify(screenId, uid, clientName);
2568 }
2569 
2570 /**
2571  * @tc.name: GetIsInternal01
2572  * @tc.desc: Test when isInternal is true, GetIsInternal should return true
2573  * @tc.type: FUNC
2574  */
2575 HWTEST_F(ScreenSessionTest, GetIsInternal01, TestSize.Level1)
2576 {
2577     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
2578     ASSERT_NE(session, nullptr);
2579     session->SetIsInternal(true);
2580     ASSERT_EQ(session->GetIsInternal(), true);
2581 }
2582 
2583 /**
2584  * @tc.name: GetIsInternal02
2585  * @tc.desc: Test when isInternal is false, GetIsInternal should return false
2586  * @tc.type: FUNC
2587  */
2588 HWTEST_F(ScreenSessionTest, GetIsInternal02, TestSize.Level1)
2589 {
2590     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
2591     ASSERT_NE(session, nullptr);
2592     session->SetIsInternal(false);
2593     ASSERT_EQ(session->GetIsInternal(), false);
2594 }
2595 
2596 /**
2597  * @tc.name: GetIsFakeInUse01
2598  * @tc.desc: Test when isFakeInUse is true, GetIsFakeInUse should return true
2599  * @tc.type: FUNC
2600  */
2601 HWTEST_F(ScreenSessionTest, GetIsFakeInUse01, TestSize.Level1)
2602 {
2603     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
2604     ASSERT_NE(session, nullptr);
2605     session->SetIsFakeInUse(true);
2606     ASSERT_EQ(session->GetIsFakeInUse(), true);
2607 }
2608 
2609 /**
2610  * @tc.name: GetIsFakeInUse02
2611  * @tc.desc: Test when isFakeInUse is false, GetIsFakeInUse should return false
2612  * @tc.type: FUNC
2613  */
2614 HWTEST_F(ScreenSessionTest, GetIsFakeInUse02, TestSize.Level1)
2615 {
2616     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
2617     ASSERT_NE(session, nullptr);
2618     session->SetIsFakeInUse(false);
2619     ASSERT_EQ(session->GetIsFakeInUse(), false);
2620 }
2621 
2622 /**
2623  * @tc.name: GetIsRealScreen01
2624  * @tc.desc: Test when isReal is true, GetIsRealScreen should return true
2625  * @tc.type: FUNC
2626  */
2627 HWTEST_F(ScreenSessionTest, GetIsRealScreen01, TestSize.Level1)
2628 {
2629     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
2630     ASSERT_NE(session, nullptr);
2631     session->SetIsRealScreen(true);
2632     ASSERT_EQ(session->GetIsRealScreen(), true);
2633 }
2634 
2635 /**
2636  * @tc.name: GetIsRealScreen02
2637  * @tc.desc: Test when isReal is false, GetIsRealScreen should return false
2638  * @tc.type: FUNC
2639  */
2640 HWTEST_F(ScreenSessionTest, GetIsRealScreen02, TestSize.Level1)
2641 {
2642     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
2643     ASSERT_NE(session, nullptr);
2644     session->SetIsRealScreen(false);
2645     ASSERT_EQ(session->GetIsRealScreen(), false);
2646 }
2647 
2648 /**
2649  * @tc.name: GetIsPcUse01
2650  * @tc.desc: Test when isPcUse is true, GetIsPcUse should return true
2651  * @tc.type: FUNC
2652  */
2653 HWTEST_F(ScreenSessionTest, GetIsPcUse01, TestSize.Level1)
2654 {
2655     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
2656     ASSERT_NE(session, nullptr);
2657     session->SetIsPcUse(true);
2658     ASSERT_EQ(session->GetIsPcUse(), true);
2659 }
2660 
2661 /**
2662  * @tc.name: GetIsPcUse02
2663  * @tc.desc: Test when isPcUse is false, GetIsPcUse should return false
2664  * @tc.type: FUNC
2665  */
2666 HWTEST_F(ScreenSessionTest, GetIsPcUse02, TestSize.Level1)
2667 {
2668     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
2669     ASSERT_NE(session, nullptr);
2670     session->SetIsPcUse(false);
2671     ASSERT_EQ(session->GetIsPcUse(), false);
2672 }
2673 
2674 /**
2675  * @tc.name: SetIsExtendVirtual001
2676  * @tc.desc: Test when isPcUse is true, GetIsPcUse should return true
2677  * @tc.type: FUNC
2678  */
2679 HWTEST_F(ScreenSessionTest, SetIsExtendVirtual001, TestSize.Level1)
2680 {
2681     sptr<ScreenSession> session = new ScreenSession();
2682     ASSERT_NE(session, nullptr);
2683     session->SetIsExtendVirtual(true);
2684     EXPECT_EQ(session->GetIsExtendVirtual(), true);
2685 }
2686 
2687 /**
2688  * @tc.name: SetIsExtendVirtual002
2689  * @tc.desc: Test when isPcUse is false, GetIsPcUse should return false
2690  * @tc.type: FUNC
2691  */
2692 HWTEST_F(ScreenSessionTest, SetIsExtendVirtual002, TestSize.Level1)
2693 {
2694     sptr<ScreenSession> session = new ScreenSession();
2695     ASSERT_NE(session, nullptr);
2696     session->SetIsExtendVirtual(false);
2697     EXPECT_EQ(session->GetIsExtendVirtual(), false);
2698 }
2699 
2700 /**
2701  * @tc.name: GetIsBScreenHalf01
2702  * @tc.desc: Test when isBScreenHalf is true, GetIsBScreenHalf should return true
2703  * @tc.type: FUNC
2704  */
2705 HWTEST_F(ScreenSessionTest, GetIsBScreenHalf01, TestSize.Level1)
2706 {
2707     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
2708     ASSERT_NE(session, nullptr);
2709     session->SetIsBScreenHalf(true);
2710     ASSERT_EQ(session->GetIsBScreenHalf(), true);
2711 }
2712 
2713 /**
2714  * @tc.name: GetIsBScreenHalf02
2715  * @tc.desc: Test when isBScreenHalf is false, GetIsBScreenHalf should return false
2716  * @tc.type: FUNC
2717  */
2718 HWTEST_F(ScreenSessionTest, GetIsBScreenHalf02, TestSize.Level1)
2719 {
2720     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
2721     ASSERT_NE(session, nullptr);
2722     session->SetIsBScreenHalf(false);
2723     ASSERT_EQ(session->GetIsBScreenHalf(), false);
2724 }
2725 
2726 /**
2727  * @tc.name: CalcDeviceOrientation01
2728  * @tc.desc: Test when rotation is ROTATION_0 then CalcDeviceOrientation returns PORTRAIT
2729  * @tc.type: FUNC
2730  */
2731 HWTEST_F(ScreenSessionTest, CalcDeviceOrientation01, TestSize.Level1)
2732 {
2733     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
2734     ASSERT_NE(session, nullptr);
2735     DisplayOrientation result = session->CalcDeviceOrientation(Rotation::ROTATION_0, FoldDisplayMode::FULL);
2736     ASSERT_EQ(result, DisplayOrientation::PORTRAIT);
2737 }
2738 
2739 /**
2740  * @tc.name: CalcDeviceOrientation02
2741  * @tc.desc: Test when rotation is ROTATION_90 then CalcDeviceOrientation returns LANDSCAPE
2742  * @tc.type: FUNC
2743  */
2744 HWTEST_F(ScreenSessionTest, CalcDeviceOrientation02, TestSize.Level1)
2745 {
2746     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
2747     ASSERT_NE(session, nullptr);
2748     DisplayOrientation result = session->CalcDeviceOrientation(Rotation::ROTATION_90, FoldDisplayMode::FULL);
2749     ASSERT_EQ(result, DisplayOrientation::LANDSCAPE);
2750 }
2751 
2752 /**
2753  * @tc.name: CalcDeviceOrientation03
2754  * @tc.desc: Test when rotation is ROTATION_180 then CalcDeviceOrientation returns PORTRAIT_INVERTED
2755  * @tc.type: FUNC
2756  */
2757 HWTEST_F(ScreenSessionTest, CalcDeviceOrientation03, TestSize.Level1)
2758 {
2759     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
2760     ASSERT_NE(session, nullptr);
2761     DisplayOrientation result = session->CalcDeviceOrientation(Rotation::ROTATION_180, FoldDisplayMode::FULL);
2762     ASSERT_EQ(result, DisplayOrientation::PORTRAIT_INVERTED);
2763 }
2764 
2765 /**
2766  * @tc.name: CalcDeviceOrientation04
2767  * @tc.desc: Test when rotation is ROTATION_270 then CalcDeviceOrientation returns LANDSCAPE_INVERTED
2768  * @tc.type: FUNC
2769  */
2770 HWTEST_F(ScreenSessionTest, CalcDeviceOrientation04, TestSize.Level1)
2771 {
2772     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
2773     ASSERT_NE(session, nullptr);
2774     DisplayOrientation result = session->CalcDeviceOrientation(Rotation::ROTATION_270, FoldDisplayMode::FULL);
2775     ASSERT_EQ(result, DisplayOrientation::LANDSCAPE_INVERTED);
2776 }
2777 
2778 /**
2779  * @tc.name: CalcDeviceOrientation05
2780  * @tc.desc: Test when rotation is unknown then CalcDeviceOrientation returns UNKNOWN
2781  * @tc.type: FUNC
2782  */
2783 HWTEST_F(ScreenSessionTest, CalcDeviceOrientation05, TestSize.Level1)
2784 {
2785     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
2786     ASSERT_NE(session, nullptr);
2787     DisplayOrientation result = session->CalcDeviceOrientation(static_cast<Rotation>(100),
2788         FoldDisplayMode::FULL);
2789     ASSERT_EQ(result, DisplayOrientation::UNKNOWN);
2790 }
2791 
2792 /**
2793  * @tc.name: CalcDeviceOrientationWithBounds01
2794  * @tc.desc: Test when rotation is ROTATION_0 then CalcDeviceOrientationWithBounds returns PORTRAIT
2795  * @tc.type: FUNC
2796  */
2797 HWTEST_F(ScreenSessionTest, CalcDeviceOrientationWithBounds01, TestSize.Level1)
2798 {
2799     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
2800     ASSERT_NE(session, nullptr);
2801     RRect bounds;
2802     bounds.rect_.width_ = 1344;
2803     bounds.rect_.height_ = 2772;
2804     auto result = session->CalcDeviceOrientationWithBounds(Rotation::ROTATION_0, FoldDisplayMode::FULL, bounds);
2805     ASSERT_EQ(result, DisplayOrientation::PORTRAIT);
2806 }
2807 
2808 /**
2809  * @tc.name: CalcDeviceOrientationWithBounds02
2810  * @tc.desc: Test when rotation is ROTATION_90 then CalcDeviceOrientationWithBounds returns LANDSCAPE
2811  * @tc.type: FUNC
2812  */
2813 HWTEST_F(ScreenSessionTest, CalcDeviceOrientationWithBounds02, TestSize.Level1)
2814 {
2815     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
2816     ASSERT_NE(session, nullptr);
2817     RRect bounds;
2818     bounds.rect_.width_ = 1344;
2819     bounds.rect_.height_ = 2772;
2820     auto result = session->CalcDeviceOrientationWithBounds(Rotation::ROTATION_90, FoldDisplayMode::FULL, bounds);
2821     ASSERT_EQ(result, DisplayOrientation::LANDSCAPE);
2822 }
2823 
2824 /**
2825  * @tc.name: CalcDeviceOrientationWithBounds03
2826  * @tc.desc: Test when rotation is ROTATION_180 then CalcDeviceOrientationWithBounds returns PORTRAIT_INVERTED
2827  * @tc.type: FUNC
2828  */
2829 HWTEST_F(ScreenSessionTest, CalcDeviceOrientationWithBounds03, TestSize.Level1)
2830 {
2831     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
2832     ASSERT_NE(session, nullptr);
2833     RRect bounds;
2834     bounds.rect_.width_ = 1344;
2835     bounds.rect_.height_ = 2772;
2836     auto result = session->CalcDeviceOrientationWithBounds(Rotation::ROTATION_180, FoldDisplayMode::FULL, bounds);
2837     ASSERT_EQ(result, DisplayOrientation::PORTRAIT_INVERTED);
2838 }
2839 
2840 /**
2841  * @tc.name: CalcDeviceOrientationWithBounds04
2842  * @tc.desc: Test when rotation is ROTATION_270 then CalcDeviceOrientationWithBounds returns LANDSCAPE_INVERTED
2843  * @tc.type: FUNC
2844  */
2845 HWTEST_F(ScreenSessionTest, CalcDeviceOrientationWithBounds04, TestSize.Level1)
2846 {
2847     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
2848     ASSERT_NE(session, nullptr);
2849     RRect bounds;
2850     bounds.rect_.width_ = 1344;
2851     bounds.rect_.height_ = 2772;
2852     auto result = session->CalcDeviceOrientationWithBounds(Rotation::ROTATION_270, FoldDisplayMode::FULL, bounds);
2853     ASSERT_EQ(result, DisplayOrientation::LANDSCAPE_INVERTED);
2854 }
2855 
2856 /**
2857  * @tc.name: CalcDeviceOrientationWithBounds05
2858  * @tc.desc: Test when rotation is unknown then CalcDeviceOrientationWithBounds returns UNKNOWN
2859  * @tc.type: FUNC
2860  */
2861 HWTEST_F(ScreenSessionTest, CalcDeviceOrientationWithBounds05, TestSize.Level1)
2862 {
2863     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
2864     ASSERT_NE(session, nullptr);
2865     RRect bounds;
2866     bounds.rect_.width_ = 1344;
2867     bounds.rect_.height_ = 2772;
2868     auto result = session->CalcDeviceOrientationWithBounds(static_cast<Rotation>(100), FoldDisplayMode::FULL, bounds);
2869     ASSERT_EQ(result, DisplayOrientation::UNKNOWN);
2870 }
2871 
2872 /**
2873  * @tc.name: CalcDeviceOrientationWithBounds06
2874  * @tc.desc: Test when foldDisplayMode is GLOBAL_FULL
2875  * @tc.type: FUNC
2876  */
2877 HWTEST_F(ScreenSessionTest, CalcDeviceOrientationWithBounds06, TestSize.Level1)
2878 {
2879     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
2880     ASSERT_NE(session, nullptr);
2881     RRect bounds;
2882     bounds.rect_.width_ = 1344;
2883     bounds.rect_.height_ = 2772;
2884     auto result = session->CalcDeviceOrientationWithBounds(Rotation::ROTATION_0, FoldDisplayMode::GLOBAL_FULL, bounds);
2885     ASSERT_EQ(result, DisplayOrientation::LANDSCAPE_INVERTED);
2886 }
2887 
2888 /**
2889  * @tc.name: CalcDeviceOrientationWithBounds07
2890  * @tc.desc: Test CalcDeviceOrientationWithBounds
2891  * @tc.type: FUNC
2892  */
2893 HWTEST_F(ScreenSessionTest, CalcDeviceOrientationWithBounds07, TestSize.Level1)
2894 {
2895     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
2896     ASSERT_NE(session, nullptr);
2897     RRect bounds;
2898     bounds.rect_.width_ = 2772;
2899     bounds.rect_.height_ = 1344;
2900     auto result = session->CalcDeviceOrientationWithBounds(Rotation::ROTATION_0, FoldDisplayMode::UNKNOWN, bounds);
2901     EXPECT_EQ(result, DisplayOrientation::LANDSCAPE);
2902     bounds.rect_.width_ = 1344;
2903     bounds.rect_.height_ = 2772;
2904     result = session->CalcDeviceOrientationWithBounds(Rotation::ROTATION_90, FoldDisplayMode::UNKNOWN, bounds);
2905     EXPECT_EQ(result, DisplayOrientation::PORTRAIT_INVERTED);
2906 }
2907 
2908 /**
2909  * @tc.name: GetIsPhysicalMirrorSwitch01
2910  * @tc.desc: Test when isPhysicalMirrorSwitch is true, GetIsPhysicalMirrorSwitch should return true
2911  * @tc.type: FUNC
2912  */
2913 HWTEST_F(ScreenSessionTest, GetIsPhysicalMirrorSwitch01, TestSize.Level1)
2914 {
2915     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
2916     ASSERT_NE(session, nullptr);
2917     session->SetIsPhysicalMirrorSwitch(true);
2918     ASSERT_EQ(session->GetIsPhysicalMirrorSwitch(), true);
2919 }
2920 
2921 /**
2922  * @tc.name: GetIsPhysicalMirrorSwitch02
2923  * @tc.desc: Test when isPhysicalMirrorSwitch is false, GetIsPhysicalMirrorSwitch should return false
2924  * @tc.type: FUNC
2925  */
2926 HWTEST_F(ScreenSessionTest, GetIsPhysicalMirrorSwitch02, TestSize.Level1)
2927 {
2928     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
2929     ASSERT_NE(session, nullptr);
2930     session->SetIsPhysicalMirrorSwitch(false);
2931     ASSERT_EQ(session->GetIsPhysicalMirrorSwitch(), false);
2932 }
2933 /**
2934  * @tc.name: GetDisplaySourceMode01
2935  * @tc.desc: normal function
2936  * @tc.type: FUNC
2937  */
2938 HWTEST_F(ScreenSessionTest, GetDisplaySourceMode01, TestSize.Level1)
2939 {
2940     GTEST_LOG_(INFO) << "ScreenSessionTest: GetSourceMode start";
2941     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
2942     session->screenId_ = session->defaultScreenId_;
2943     DisplaySourceMode mode = session->GetDisplaySourceMode();
2944     ASSERT_EQ(mode, DisplaySourceMode::MAIN);
2945     ScreenSessionConfig config = {
2946         .screenId = 100,
2947         .rsId = 101,
2948         .name = "OpenHarmony",
2949     };
2950     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
2951         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
2952     mode = screenSession->GetDisplaySourceMode();
2953     ASSERT_EQ(mode, DisplaySourceMode::NONE);
2954     screenSession->SetScreenCombination(ScreenCombination::SCREEN_EXPAND);
2955     mode = screenSession->GetDisplaySourceMode();
2956     ASSERT_EQ(mode, DisplaySourceMode::EXTEND);
2957     screenSession->SetScreenCombination(ScreenCombination::SCREEN_MIRROR);
2958     mode = screenSession->GetDisplaySourceMode();
2959     ASSERT_EQ(mode, DisplaySourceMode::MIRROR);
2960     screenSession->SetScreenCombination(ScreenCombination::SCREEN_UNIQUE);
2961     mode = screenSession->GetDisplaySourceMode();
2962     ASSERT_EQ(mode, DisplaySourceMode::ALONE);
2963     GTEST_LOG_(INFO) << "ScreenSessionTest: GetDisplaySourceMode01 end";
2964 }
2965 
2966 /**
2967 * @tc.name: GetDisplaySourceMode02
2968 * @tc.desc: normal function
2969 * @tc.type: FUNC
2970 */
2971 HWTEST_F(ScreenSessionTest, GetDisplaySourceMode02, TestSize.Level1)
2972 {
2973     GTEST_LOG_(INFO) << "ScreenSessionTest: GetDisplaySourceMode02 start";
2974     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
2975     session->screenId_ = session->defaultScreenId_;
2976     DisplaySourceMode mode = session->GetDisplaySourceMode();
2977     ASSERT_EQ(mode, DisplaySourceMode::MAIN);
2978     ScreenSessionConfig config = {
2979         .screenId = 100,
2980         .rsId = 101,
2981         .name = "OpenHarmony",
2982     };
2983     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
2984         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
2985 
2986     screenSession->SetScreenCombination(ScreenCombination::SCREEN_MAIN);
2987     mode = screenSession->GetDisplaySourceMode();
2988     ASSERT_EQ(mode, DisplaySourceMode::MAIN);
2989     screenSession->SetScreenCombination(ScreenCombination::SCREEN_EXTEND);
2990     mode = screenSession->GetDisplaySourceMode();
2991     ASSERT_EQ(mode, DisplaySourceMode::EXTEND);
2992     GTEST_LOG_(INFO) << "ScreenSessionTest: GetDisplaySourceMode02 end";
2993 }
2994 
2995 /**
2996  * @tc.name: SetPointerActiveWidth
2997  * @tc.desc: normal function
2998  * @tc.type: FUNC
2999  */
3000 HWTEST_F(ScreenSessionTest, SetPointerActiveWidth, Function | SmallTest | Level2)
3001 {
3002     GTEST_LOG_(INFO) << "ScreenSessionTest: SetPointerActiveWidth start";
3003     uint32_t pointerActiveWidth = 123;
3004     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
3005     session->SetPointerActiveWidth(pointerActiveWidth);
3006     ASSERT_EQ(pointerActiveWidth, session->property_.GetPointerActiveWidth());
3007     GTEST_LOG_(INFO) << "ScreenSessionTest: SetPointerActiveWidth end";
3008 }
3009 
3010 /**
3011  * @tc.name: GetPointerActiveWidth
3012  * @tc.desc: normal function
3013  * @tc.type: FUNC
3014  */
3015 HWTEST_F(ScreenSessionTest, GetPointerActiveWidth, Function | SmallTest | Level2)
3016 {
3017     GTEST_LOG_(INFO) << "ScreenSessionTest: GetPointerActiveWidth start";
3018     uint32_t pointerActiveWidth = 123;
3019     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
3020     session->SetPointerActiveWidth(pointerActiveWidth);
3021     ASSERT_EQ(pointerActiveWidth, session->GetPointerActiveWidth());
3022     GTEST_LOG_(INFO) << "ScreenSessionTest: GetPointerActiveWidth end";
3023 }
3024 
3025 /**
3026  * @tc.name: SetPointerActiveHeight
3027  * @tc.desc: normal function
3028  * @tc.type: FUNC
3029  */
3030 HWTEST_F(ScreenSessionTest, SetPointerActiveHeight, Function | SmallTest | Level2)
3031 {
3032     GTEST_LOG_(INFO) << "ScreenSessionTest: SetPointerActiveHeight start";
3033     uint32_t pointerActiveHeight = 321;
3034     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
3035     session->SetPointerActiveHeight(pointerActiveHeight);
3036     ASSERT_EQ(pointerActiveHeight, session->property_.GetPointerActiveHeight());
3037     GTEST_LOG_(INFO) << "ScreenSessionTest: SetPointerActiveHeight end";
3038 }
3039 
3040 /**
3041  * @tc.name: GetPointerActiveHeight
3042  * @tc.desc: normal function
3043  * @tc.type: FUNC
3044  */
3045 HWTEST_F(ScreenSessionTest, GetPointerActiveHeight, Function | SmallTest | Level2)
3046 {
3047     GTEST_LOG_(INFO) << "ScreenSessionTest: GetPointerActiveHeight start";
3048     uint32_t pointerActiveHeight = 321;
3049     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
3050     session->SetPointerActiveHeight(pointerActiveHeight);
3051     ASSERT_EQ(pointerActiveHeight, session->GetPointerActiveHeight());
3052     GTEST_LOG_(INFO) << "ScreenSessionTest: GetPointerActiveHeight end";
3053 }
3054 
3055 /**
3056  * @tc.name: UpdateExpandAvailableArea
3057  * @tc.desc: UpdateExpandAvailableArea test
3058  * @tc.type: FUNC
3059  */
3060 HWTEST_F(ScreenSessionTest, UpdateExpandAvailableArea, Function | SmallTest | Level2)
3061 {
3062     GTEST_LOG_(INFO) << "ScreenSessionTest: UpdateExpandAvailableArea start";
3063     ScreenSessionConfig config = {
3064         .screenId = 100,
3065         .rsId = 101,
3066         .name = "OpenHarmony",
3067     };
3068     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
3069         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
3070     ASSERT_NE(screenSession, nullptr);
3071     DMRect area = screenSession->GetExpandAvailableArea();
3072     auto res = screenSession->UpdateExpandAvailableArea(area);
3073     ASSERT_EQ(res, false);
3074     area = {200, 200, 200, 200};
3075     res = screenSession->UpdateExpandAvailableArea(area);
3076     ASSERT_EQ(res, true);
3077     GTEST_LOG_(INFO) << "ScreenSessionTest: UpdateExpandAvailableArea end";
3078 }
3079 
3080 /**
3081  * @tc.name: UpdateDisplayNodeRotation
3082  * @tc.desc: UpdateDisplayNodeRotation test
3083  * @tc.type: FUNC
3084  */
3085 HWTEST_F(ScreenSessionTest, UpdateDisplayNodeRotation, Function | SmallTest | Level2)
3086 {
3087     GTEST_LOG_(INFO) << "ScreenSessionTest: UpdateDisplayNodeRotation start";
3088     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr();
3089     ASSERT_NE(screenSession, nullptr);
3090     screenSession->UpdateDisplayNodeRotation(1);
3091     ASSERT_EQ(screenSession->isExtended_, false);
3092 
3093     Rosen::RSDisplayNodeConfig rsConfig;
3094     rsConfig.isMirrored = true;
3095     rsConfig.screenId = 101;
3096     screenSession->CreateDisplayNode(rsConfig);
3097     screenSession->UpdateDisplayNodeRotation(1);
3098     ASSERT_EQ(screenSession->isExtended_, false);
3099     GTEST_LOG_(INFO) << "ScreenSessionTest: UpdateDisplayNodeRotation end";
3100 }
3101 
3102 /**
3103  * @tc.name: UpdateExpandAvailableArea01
3104  * @tc.desc: normal function
3105  * @tc.type: FUNC
3106  */
3107 HWTEST_F(ScreenSessionTest, UpdateExpandAvailableArea01, TestSize.Level1)
3108 {
3109     GTEST_LOG_(INFO) << "UpdateExpandAvailableArea start";
3110     ScreenSessionConfig config = {
3111         .screenId = 100,
3112         .rsId = 101,
3113         .name = "OpenHarmony",
3114     };
3115     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
3116         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
3117     EXPECT_NE(nullptr, screenSession);
3118     DMRect area = screenSession->GetAvailableArea();
3119     auto res = screenSession->UpdateExpandAvailableArea(area);
3120     ASSERT_EQ(res, false);
3121     area = {2, 2, 2, 2};
3122     res = screenSession->UpdateExpandAvailableArea(area);
3123     ASSERT_EQ(res, true);
3124     GTEST_LOG_(INFO) << "UpdateExpandAvailableArea end";
3125 }
3126 
3127 /**
3128  * @tc.name: ScreenExtendChange01
3129  * @tc.desc: normal function
3130  * @tc.type: FUNC
3131  */
3132 HWTEST_F(ScreenSessionTest, ScreenExtendChange01, TestSize.Level1)
3133 {
3134     GTEST_LOG_(INFO) << "ScreenExtendChange start";
3135     ScreenSessionConfig config = {
3136         .screenId = 100,
3137         .rsId = 101,
3138         .name = "OpenHarmony",
3139     };
3140     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
3141         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
3142     EXPECT_NE(nullptr, screenSession);
3143     ScreenId mainScreenId = 0;
3144     ScreenId extendScreenId = 1;
3145     screenSession->ScreenExtendChange(mainScreenId, extendScreenId);
3146     GTEST_LOG_(INFO) << "UpdateExpandAvailableArea end";
3147 }
3148 
3149 /**
3150  * @tc.name: ScreenExtendChange02
3151  * @tc.desc: run in for
3152  * @tc.type: FUNC
3153  */
3154 HWTEST_F(ScreenSessionTest, ScreenExtendChange02, TestSize.Level1)
3155 {
3156     LOG_SetCallback(MyLogCallback);
3157     IScreenChangeListener* screenChangeListener = new MockScreenChangeListener();
3158     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
3159     EXPECT_NE(nullptr, session);
3160     session->RegisterScreenChangeListener(screenChangeListener);
3161     ScreenId mainScreenId = 0;
3162     ScreenId extendScreenId = 1;
3163     session->ScreenExtendChange(mainScreenId, extendScreenId);
3164     EXPECT_FALSE(g_errLog.find("screenChangeListener is null.") != std::string::npos);
3165 }
3166 
3167 /**
3168  * @tc.name: SuperFoldStatusChange01
3169  * @tc.desc: run in for
3170  * @tc.type: FUNC
3171  */
3172 HWTEST_F(ScreenSessionTest, SuperFoldStatusChange01, TestSize.Level1)
3173 {
3174     LOG_SetCallback(MyLogCallback);
3175     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
3176     EXPECT_NE(nullptr, session);
3177     ScreenId mainScreenId = 0;
3178     SuperFoldStatus superFoldStatus = SuperFoldStatus::UNKNOWN;
3179     session->SuperFoldStatusChange(mainScreenId, superFoldStatus);
3180     EXPECT_EQ(true, session->screenChangeListenerList_.empty());
3181     EXPECT_TRUE(g_errLog.find("screenChangeListenerList is empty.") != std::string::npos);
3182 }
3183 
3184 /**
3185  * @tc.name: ExtendScreenConnectStatusChange
3186  * @tc.desc: run in for
3187  * @tc.type: FUNC
3188  */
3189 HWTEST_F(ScreenSessionTest, ExtendScreenConnectStatusChange, TestSize.Level1)
3190 {
3191     LOG_SetCallback(MyLogCallback);
3192     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
3193     EXPECT_NE(nullptr, session);
3194     ScreenId mainScreenId = 0;
3195     ExtendScreenConnectStatus extendScreenConnectStatus = ExtendScreenConnectStatus::UNKNOWN;
3196     session->ExtendScreenConnectStatusChange(mainScreenId, extendScreenConnectStatus);
3197     EXPECT_EQ(true, session->screenChangeListenerList_.empty());
3198     EXPECT_TRUE(g_errLog.find("screenChangeListenerList is empty.") != std::string::npos);
3199 }
3200 
3201 /**
3202  * @tc.name: SecondaryReflexionChange
3203  * @tc.desc: run in for
3204  * @tc.type: FUNC
3205  */
3206 HWTEST_F(ScreenSessionTest, SecondaryReflexionChange, TestSize.Level1)
3207 {
3208     LOG_SetCallback(MyLogCallback);
3209     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
3210     EXPECT_NE(nullptr, session);
3211     ScreenId mainScreenId = 0;
3212     bool isSecondaryReflexion = true;
3213     session->SecondaryReflexionChange(mainScreenId, isSecondaryReflexion);
3214     EXPECT_EQ(true, session->screenChangeListenerList_.empty());
3215     EXPECT_TRUE(g_errLog.find("screenChangeListenerList is empty.") != std::string::npos);
3216 }
3217 
3218 /**
3219  * @tc.name: UpdatePropertyOnly
3220  * @tc.desc: normal function
3221  * @tc.type: FUNC
3222  */
3223 HWTEST_F(ScreenSessionTest, UpdatePropertyOnly, TestSize.Level1)
3224 {
3225     GTEST_LOG_(INFO) << "UpdatePropertyOnly start";
3226     LOG_SetCallback(MyLogCallback);
3227     ScreenSessionConfig config = {
3228         .screenId = 100,
3229         .rsId = 101,
3230         .name = "OpenHarmony",
3231     };
3232     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
3233         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
3234     EXPECT_NE(nullptr, screenSession);
3235     RRect bounds;
3236     bounds.rect_.width_ = 1344;
3237     bounds.rect_.height_ = 2772;
3238     int rotation = 90;
3239     FoldDisplayMode foldDisplayMode = FoldDisplayMode::MAIN;
3240     screenSession->UpdatePropertyOnly(bounds, rotation, foldDisplayMode);
3241     EXPECT_FALSE(g_errLog.find("bounds:[%{public}f %{public}f %{public}f %{public}f],\
3242         rotation:%{public}d, displayOrientation:%{public}u") != std::string::npos);
3243     GTEST_LOG_(INFO) << "UpdatePropertyOnly end";
3244 }
3245 
3246 /**
3247  * @tc.name: ReuseDisplayNode
3248  * @tc.desc: ReuseDisplayNode test
3249  * @tc.type: FUNC
3250  */
3251 HWTEST_F(ScreenSessionTest, ReuseDisplayNode, TestSize.Level1)
3252 {
3253     GTEST_LOG_(INFO) << "ScreenSessionTest: ReuseDisplayNode start";
3254     Rosen::RSDisplayNodeConfig rsConfig;
3255     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr();
3256     screenSession->SetDisplayNode(nullptr);
3257     screenSession->ReuseDisplayNode(rsConfig);
3258 
3259     rsConfig.isMirrored = true;
3260     rsConfig.screenId = 101;
3261     std::shared_ptr<RSDisplayNode> displayNode = RSDisplayNode::Create(rsConfig);
3262     screenSession->SetDisplayNode(displayNode);
3263     screenSession->ReuseDisplayNode(rsConfig);
3264     GTEST_LOG_(INFO) << "ScreenSessionTest: ReuseDisplayNode end";
3265 }
3266 
3267 /**
3268  * @tc.name: GetScreenModes
3269  * @tc.desc: normal function
3270  * @tc.type: FUNC
3271  */
3272 HWTEST_F(ScreenSessionTest, GetScreenModes, TestSize.Level1)
3273 {
3274     GTEST_LOG_(INFO) << "ScreenSessionTest: GetScreenModes start";
3275     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
3276     auto modes_ = session->GetScreenModes();
3277     GTEST_LOG_(INFO) << "ScreenSessionTest: GetScreenModes end";
3278 }
3279 
3280 /**
3281  * @tc.name: SetScreenModes
3282  * @tc.desc: normal function
3283  * @tc.type: FUNC
3284  */
3285 HWTEST_F(ScreenSessionTest, SetScreenModes, TestSize.Level1)
3286 {
3287     GTEST_LOG_(INFO) << "ScreenSessionTest: SetScreenModes start";
3288     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
3289     sptr<SupportedScreenModes> supportedScreenModes = new SupportedScreenModes();
3290     session->SetScreenModes({supportedScreenModes});
3291     GTEST_LOG_(INFO) << "ScreenSessionTest: SetScreenModes end";
3292 }
3293 
3294 /**
3295  * @tc.name: ConvertToRealDisplayInfo
3296  * @tc.desc: ConvertToRealDisplayInfo test
3297  * @tc.type: FUNC
3298  */
3299 HWTEST_F(ScreenSessionTest, ConvertToRealDisplayInfo, TestSize.Level1)
3300 {
3301     GTEST_LOG_(INFO) << "ScreenSessionTest: ConvertToRealDisplayInfo start";
3302     sptr<DisplayInfo> displayInfo = sptr<DisplayInfo>::MakeSptr();
3303     ASSERT_NE(displayInfo, nullptr);
3304     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr();
3305     ASSERT_NE(screenSession->ConvertToRealDisplayInfo(), nullptr);
3306     GTEST_LOG_(INFO) << "ScreenSessionTest: ConvertToRealDisplayInfo end";
3307 }
3308 
3309 /**
3310  * @tc.name: UpdateVirtualPixelRatio
3311  * @tc.desc: UpdateVirtualPixelRatio test
3312  * @tc.type: FUNC
3313  */
3314 HWTEST_F(ScreenSessionTest, UpdateVirtualPixelRatio, TestSize.Level1)
3315 {
3316     GTEST_LOG_(INFO) << "ScreenSessionTest: UpdateVirtualPixelRatio start";
3317     ScreenSessionConfig config = {
3318         .screenId = 0,
3319         .rsId = 0,
3320         .name = "OpenHarmony",
3321     };
3322     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
3323         ScreenSessionReason::CREATE_SESSION_FOR_CLIENT);
3324     EXPECT_NE(nullptr, screenSession);
3325     RRect bounds;
3326     bounds.rect_.width_ = 1344;
3327     bounds.rect_.height_ = 2772;
3328     screenSession->UpdateVirtualPixelRatio(bounds);
3329     float curVirtualPixelRatio = screenSession->property_.GetVirtualPixelRatio();
3330     ASSERT_EQ(curVirtualPixelRatio, 3.5f);
3331     GTEST_LOG_(INFO) << "ScreenSessionTest: UpdateVirtualPixelRatio end";
3332 }
3333 
3334 /**
3335  * @tc.name: SetInnerName
3336  * @tc.desc: SetInnerName test
3337  * @tc.type: FUNC
3338  */
3339 HWTEST_F(ScreenSessionTest, SetInnerName, TestSize.Level1)
3340 {
3341     GTEST_LOG_(INFO) << "ScreenSessionTest: SetInnerName start";
3342     ScreenSessionConfig config = {
3343         .screenId = 0,
3344         .rsId = 0,
3345         .name = "OpenHarmony",
3346     };
3347     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
3348         ScreenSessionReason::CREATE_SESSION_FOR_CLIENT);
3349     EXPECT_NE(nullptr, screenSession);
3350     std::string innerName = "OpenHarmony";
3351     screenSession->SetInnerName(innerName);
3352     EXPECT_EQ(innerName, screenSession->GetInnerName());
3353     GTEST_LOG_(INFO) << "ScreenSessionTest: SetInnerName end";
3354 }
3355 
3356 /**
3357  * @tc.name: SetFakeScreenSession
3358  * @tc.desc: SetFakeScreenSession test
3359  * @tc.type: FUNC
3360  */
3361 HWTEST_F(ScreenSessionTest, SetFakeScreenSession, TestSize.Level1)
3362 {
3363     GTEST_LOG_(INFO) << "ScreenSessionTest: SetFakeScreenSession start";
3364     ScreenSessionConfig config = {
3365         .screenId = 0,
3366         .rsId = 0,
3367         .name = "OpenHarmony",
3368     };
3369     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
3370         ScreenSessionReason::CREATE_SESSION_FOR_CLIENT);
3371     ScreenSessionConfig fakeConfig = {
3372         .screenId = 100,
3373         .rsId = 101,
3374         .name = "OpenHarmony",
3375     };
3376     sptr<ScreenSession> fakeScreenSession = sptr<ScreenSession>::MakeSptr(config,
3377         ScreenSessionReason::CREATE_SESSION_FOR_CLIENT);
3378     screenSession->SetFakeScreenSession(fakeScreenSession);
3379     ASSERT_EQ(screenSession->GetFakeScreenSession(), fakeScreenSession);
3380     GTEST_LOG_(INFO) << "ScreenSessionTest: SetFakeScreenSession end";
3381 }
3382 
3383 /**
3384  * @tc.name: GetScreenShape
3385  * @tc.desc: GetScreenShape test
3386  * @tc.type: FUNC
3387  */
3388 HWTEST_F(ScreenSessionTest, GetScreenShape, TestSize.Level1)
3389 {
3390     GTEST_LOG_(INFO) << "ScreenSessionTest: GetScreenShape start";
3391     ScreenSessionConfig config = {
3392         .screenId = 0,
3393         .rsId = 0,
3394         .name = "OpenHarmony",
3395     };
3396     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
3397         ScreenSessionReason::CREATE_SESSION_FOR_CLIENT);
3398     screenSession->property_.SetScreenShape(ScreenShape::RECTANGLE);
3399     ASSERT_EQ(screenSession->GetScreenShape(), ScreenShape::RECTANGLE);
3400     screenSession->property_.SetScreenShape(ScreenShape::ROUND);
3401     ASSERT_EQ(screenSession->GetScreenShape(), ScreenShape::ROUND);
3402     GTEST_LOG_(INFO) << "ScreenSessionTest: GetScreenShape end";
3403 }
3404 
3405 /**
3406  * @tc.name: SetSerialNumber
3407  * @tc.desc: SetSerialNumber test
3408  * @tc.type: FUNC
3409  */
3410 HWTEST_F(ScreenSessionTest, SetSerialNumber, TestSize.Level1)
3411 {
3412     GTEST_LOG_(INFO) << "ScreenSessionTest: SetSerialNumber start";
3413     ScreenSessionConfig config = {
3414         .screenId = 0,
3415         .rsId = 0,
3416         .name = "OpenHarmony",
3417     };
3418     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
3419         ScreenSessionReason::CREATE_SESSION_FOR_CLIENT);
3420     std::string serialNumber = "OpenHarmony";
3421     screenSession->SetSerialNumber(serialNumber);
3422     ASSERT_EQ(screenSession->GetSerialNumber(), serialNumber);
3423     GTEST_LOG_(INFO) << "ScreenSessionTest: SetSerialNumber end";
3424 }
3425 
3426 /**
3427  * @tc.name: UpdatePropertyByFakeBounds
3428  * @tc.desc: UpdatePropertyByFakeBounds test
3429  * @tc.type: FUNC
3430  */
3431 HWTEST_F(ScreenSessionTest, UpdatePropertyByFakeBounds, TestSize.Level1)
3432 {
3433     GTEST_LOG_(INFO) << "ScreenSessionTest: UpdatePropertyByFakeBounds start";
3434     ScreenSessionConfig config = {
3435         .screenId = 0,
3436         .rsId = 0,
3437         .name = "OpenHarmony",
3438     };
3439     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
3440         ScreenSessionReason::CREATE_SESSION_FOR_CLIENT);
3441     EXPECT_NE(nullptr, screenSession);
3442     uint32_t width = 1000;
3443     uint32_t height = 1500;
3444     screenSession->UpdatePropertyByFakeBounds(width, height);
3445     auto screenFakeBounds = screenSession->property_.GetFakeBounds();
3446     ASSERT_EQ(screenFakeBounds.rect_.width_, width);
3447     ASSERT_EQ(screenFakeBounds.rect_.height_, height);
3448     GTEST_LOG_(INFO) << "ScreenSessionTest: UpdatePropertyByFakeBounds end";
3449 }
3450 
3451 /**
3452  * @tc.name: GetValidSensorRotation
3453  * @tc.desc: GetValidSensorRotation test
3454  * @tc.type: FUNC
3455  */
3456 HWTEST_F(ScreenSessionTest, GetValidSensorRotation, TestSize.Level1)
3457 {
3458     GTEST_LOG_(INFO) << "ScreenSessionTest: GetValidSensorRotation start";
3459     ScreenSessionConfig config = {
3460         .screenId = 0,
3461         .rsId = 0,
3462         .name = "OpenHarmony",
3463     };
3464     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
3465         ScreenSessionReason::CREATE_SESSION_FOR_CLIENT);
3466     EXPECT_NE(nullptr, screenSession);
3467     Rotation sensorRotation = Rotation::ROTATION_0;
3468     screenSession->SensorRotationChange(sensorRotation);
3469     ASSERT_EQ(0, screenSession->GetValidSensorRotation());
3470     GTEST_LOG_(INFO) << "ScreenSessionTest: GetValidSensorRotation end";
3471 }
3472 
3473 /**
3474  * @tc.name: EnableMirrorScreenRegion
3475  * @tc.desc: EnableMirrorScreenRegion test
3476  * @tc.type: FUNC
3477  */
3478 HWTEST_F(ScreenSessionTest, EnableMirrorScreenRegion, TestSize.Level1)
3479 {
3480     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr();
3481     ASSERT_NE(nullptr, screenSession);
3482     screenSession->SetIsEnableRegionRotation(true);
3483     screenSession->EnableMirrorScreenRegion();
3484     EXPECT_EQ(screenSession->GetIsEnableRegionRotation(), true);
3485     screenSession->SetIsPhysicalMirrorSwitch(true);
3486     screenSession->EnableMirrorScreenRegion();
3487     EXPECT_EQ(screenSession->GetIsPhysicalMirrorSwitch(), true);
3488 }
3489 
3490 /**
3491  * @tc.name: SetIsExtend
3492  * @tc.desc: SetIsExtend
3493  * @tc.type: FUNC
3494  */
3495 HWTEST_F(ScreenSessionTest, SetIsExtend01, TestSize.Level1)
3496 {
3497     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
3498     ASSERT_NE(session, nullptr);
3499     session->SetIsExtend(true);
3500     EXPECT_EQ(session->GetIsExtend(), true);
3501 }
3502 
3503 /**
3504  * @tc.name: SetIsExtend
3505  * @tc.desc: SetIsExtend
3506  * @tc.type: FUNC
3507  */
3508 HWTEST_F(ScreenSessionTest, SetIsExtend02, TestSize.Level1)
3509 {
3510     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
3511     ASSERT_NE(session, nullptr);
3512     session->SetIsExtend(false);
3513     EXPECT_EQ(session->GetIsExtend(), false);
3514 }
3515 
3516 /**
3517  * @tc.name: SetIsCurrentInUse
3518  * @tc.desc: SetIsCurrentInUse
3519  * @tc.type: FUNC
3520  */
3521 HWTEST_F(ScreenSessionTest, SetIsCurrentInUse01, TestSize.Level1)
3522 {
3523     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
3524     ASSERT_NE(session, nullptr);
3525     session->SetIsCurrentInUse(true);
3526     EXPECT_EQ(session->GetIsCurrentInUse(), true);
3527 }
3528 
3529 /**
3530  * @tc.name: SetIsCurrentInUse
3531  * @tc.desc: SetIsCurrentInUse
3532  * @tc.type: FUNC
3533  */
3534 HWTEST_F(ScreenSessionTest, SetIsCurrentInUse02, TestSize.Level1)
3535 {
3536     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
3537     ASSERT_NE(session, nullptr);
3538     session->SetIsCurrentInUse(false);
3539     EXPECT_EQ(session->GetIsCurrentInUse(), false);
3540 }
3541 
3542 /**
3543  * @tc.name: SetValidHeight
3544  * @tc.desc: SetValidHeight
3545  * @tc.type: FUNC
3546  */
3547 HWTEST_F(ScreenSessionTest, SetValidHeight, TestSize.Level1)
3548 {
3549     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
3550     ASSERT_NE(session, nullptr);
3551     uint32_t validHeight = 100;
3552     session->SetValidHeight(validHeight);
3553     EXPECT_EQ(session->GetValidHeight(), validHeight);
3554 }
3555 
3556 /**
3557  * @tc.name: SetValidWidth
3558  * @tc.desc: SetValidWidth
3559  * @tc.type: FUNC
3560  */
3561 HWTEST_F(ScreenSessionTest, SetValidWidth, TestSize.Level1)
3562 {
3563     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
3564     ASSERT_NE(session, nullptr);
3565     uint32_t validWidth = 100;
3566     session->SetValidWidth(validWidth);
3567     EXPECT_EQ(session->GetValidWidth(), validWidth);
3568 }
3569 
3570 /**
3571  * @tc.name: UpdateRotationOrientation
3572  * @tc.desc: normal function
3573  * @tc.type: FUNC
3574  */
3575 HWTEST_F(ScreenSessionTest, UpdateRotationOrientation, TestSize.Level1)
3576 {
3577     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
3578     ASSERT_NE(session, nullptr);
3579     int rotation = 0;
3580     FoldDisplayMode foldDisplayMode = FoldDisplayMode::MAIN;
3581     RRect bounds;
3582     bounds.rect_.width_ = 1344;
3583     bounds.rect_.height_ = 2772;
3584     session->UpdateRotationOrientation(rotation, foldDisplayMode, bounds);
3585     ScreenProperty screenProperty = session->GetScreenProperty();
3586     EXPECT_EQ(screenProperty.deviceRotation_, Rotation::ROTATION_0);
3587 }
3588 
3589 /**
3590  * @tc.name: UpdatePropertyByFakeInUse
3591  * @tc.desc: normal function
3592  * @tc.type: FUNC
3593  */
3594 HWTEST_F(ScreenSessionTest, UpdatePropertyByFakeInUse01, TestSize.Level1)
3595 {
3596     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
3597     ASSERT_NE(session, nullptr);
3598     session->UpdatePropertyByFakeInUse(false);
3599     EXPECT_EQ(session->property_.GetIsFakeInUse(), false);
3600 }
3601 
3602 /**
3603  * @tc.name: UpdatePropertyByFakeInUse
3604  * @tc.desc: normal function
3605  * @tc.type: FUNC
3606  */
3607 HWTEST_F(ScreenSessionTest, UpdatePropertyByFakeInUse02, TestSize.Level1)
3608 {
3609     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
3610     ASSERT_NE(session, nullptr);
3611     session->UpdatePropertyByFakeInUse(true);
3612     EXPECT_EQ(session->property_.GetIsFakeInUse(), true);
3613 }
3614 
3615 /**
3616  * @tc.name: SetRotationAndScreenRotationOnly
3617  * @tc.desc: normal function
3618  * @tc.type: FUNC
3619  */
3620 HWTEST_F(ScreenSessionTest, SetRotationAndScreenRotationOnly, TestSize.Level1)
3621 {
3622     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
3623     ASSERT_NE(session, nullptr);
3624     bool enableRotation = (system::GetParameter("persist.window.rotation.enabled", "1") == "1");
3625     if (enableRotation) {
3626         session->SetRotationAndScreenRotationOnly(Rotation::ROTATION_0);
3627         EXPECT_EQ(session->property_.GetRotation(), 0.0f);
3628         session->SetRotationAndScreenRotationOnly(Rotation::ROTATION_90);
3629         EXPECT_EQ(session->property_.GetRotation(), 90.0f);
3630         session->SetRotationAndScreenRotationOnly(Rotation::ROTATION_180);
3631         EXPECT_EQ(session->property_.GetRotation(), 180.0f);
3632         session->SetRotationAndScreenRotationOnly(Rotation::ROTATION_270);
3633         EXPECT_EQ(session->property_.GetRotation(), 270.0f);
3634     }
3635 }
3636 
3637 /**
3638  * @tc.name: SetTouchEnabledFromJs
3639  * @tc.desc: normal function
3640  * @tc.type: FUNC
3641  */
3642 HWTEST_F(ScreenSessionTest, SetTouchEnabledFromJs01, TestSize.Level1)
3643 {
3644     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
3645     ASSERT_NE(session, nullptr);
3646     session->SetTouchEnabledFromJs(false);
3647     EXPECT_EQ(session->IsTouchEnabled(), false);
3648 }
3649 
3650 /**
3651  * @tc.name: SetTouchEnabledFromJs
3652  * @tc.desc: normal function
3653  * @tc.type: FUNC
3654  */
3655 HWTEST_F(ScreenSessionTest, SetTouchEnabledFromJs02, TestSize.Level1)
3656 {
3657     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
3658     ASSERT_NE(session, nullptr);
3659     session->SetTouchEnabledFromJs(true);
3660     EXPECT_EQ(session->IsTouchEnabled(), true);
3661 }
3662 
3663 /**
3664  * @tc.name: SetIsEnableCanvasRotation
3665  * @tc.desc: normal function
3666  * @tc.type: FUNC
3667  */
3668 HWTEST_F(ScreenSessionTest, SetIsEnableCanvasRotation, TestSize.Level1)
3669 {
3670     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
3671     ASSERT_NE(session, nullptr);
3672     session->SetIsEnableCanvasRotation(false);
3673     EXPECT_EQ(session->GetIsEnableCanvasRotation(), false);
3674 }
3675 
3676 /**
3677  * @tc.name: GetIsEnableCanvasRotation
3678  * @tc.desc: normal function
3679  * @tc.type: FUNC
3680  */
3681 HWTEST_F(ScreenSessionTest, GetIsEnableCanvasRotation, TestSize.Level1)
3682 {
3683     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
3684     ASSERT_NE(session, nullptr);
3685     session->SetIsEnableCanvasRotation(true);
3686     EXPECT_EQ(session->GetIsEnableCanvasRotation(), true);
3687 }
3688 
3689 /**
3690  * @tc.name: GetIsExtend
3691  * @tc.desc: normal function
3692  * @tc.type: FUNC
3693  */
3694 HWTEST_F(ScreenSessionTest, GetIsExtend, TestSize.Level0)
3695 {
3696     GTEST_LOG_(INFO) << "GetIsExtend start";
3697     ScreenSessionConfig config = {
3698         .screenId = 100,
3699         .rsId = 101,
3700         .name = "OpenHarmony",
3701     };
3702     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
3703         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
3704     ASSERT_NE(screenSession, nullptr);
3705 
3706     screenSession->SetIsExtend(true);
3707     EXPECT_EQ(screenSession->GetIsExtend(), true);
3708     GTEST_LOG_(INFO) << "GetIsExtend end";
3709 }
3710 
3711 /**
3712  * @tc.name: SetIsInternal
3713  * @tc.desc: Test when isInternal is true, GetIsInternal should return true
3714  * @tc.type: FUNC
3715  */
3716 HWTEST_F(ScreenSessionTest, SetIsInternal, TestSize.Level1)
3717 {
3718     GTEST_LOG_(INFO) << "SetIsInternal start";
3719     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
3720     ASSERT_NE(session, nullptr);
3721 
3722     session->SetIsInternal(true);
3723     EXPECT_EQ(session->GetIsInternal(), true);
3724     GTEST_LOG_(INFO) << "SetIsInternal end";
3725 }
3726 
3727 /**
3728  * @tc.name: GetIsCurrentInUse
3729  * @tc.desc: GetIsCurrentInUse
3730  * @tc.type: FUNC
3731  */
3732 HWTEST_F(ScreenSessionTest, GetIsCurrentInUse, TestSize.Level1)
3733 {
3734     GTEST_LOG_(INFO) << "GetIsCurrentInUse start";
3735     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
3736     ASSERT_NE(session, nullptr);
3737 
3738     session->SetIsCurrentInUse(true);
3739     EXPECT_EQ(session->GetIsCurrentInUse(), true);
3740     GTEST_LOG_(INFO) << "GetIsCurrentInUse end";
3741 }
3742 
3743 /**
3744  * @tc.name: SetIsFakeInUse
3745  * @tc.desc: Test when isFakeInUse is true, GetIsFakeInUse should return true
3746  * @tc.type: FUNC
3747  */
3748 HWTEST_F(ScreenSessionTest, SetIsFakeInUse, TestSize.Level1)
3749 {
3750     GTEST_LOG_(INFO) << "SetIsFakeInUse start";
3751     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
3752     ASSERT_NE(session, nullptr);
3753 
3754     session->SetIsFakeInUse(true);
3755     EXPECT_EQ(session->GetIsFakeInUse(), true);
3756     GTEST_LOG_(INFO) << "SetIsFakeInUse end";
3757 }
3758 
3759 /**
3760  * @tc.name: SetIsRealScreen
3761  * @tc.desc: Test when isReal is true, GetIsRealScreen should return true
3762  * @tc.type: FUNC
3763  */
3764 HWTEST_F(ScreenSessionTest, SetIsRealScreen, TestSize.Level1)
3765 {
3766     GTEST_LOG_(INFO) << "SetIsRealScreen start";
3767     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
3768     ASSERT_NE(session, nullptr);
3769 
3770     session->SetIsRealScreen(true);
3771     EXPECT_EQ(session->GetIsRealScreen(), true);
3772     GTEST_LOG_(INFO) << "SetIsRealScreen end";
3773 }
3774 
3775 /**
3776  * @tc.name: SetIsPcUse
3777  * @tc.desc: Test when isPcUse is true, GetIsPcUse should return true
3778  * @tc.type: FUNC
3779  */
3780 HWTEST_F(ScreenSessionTest, SetIsPcUse, TestSize.Level1)
3781 {
3782     GTEST_LOG_(INFO) << "SetIsRealScreen start";
3783     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
3784     ASSERT_NE(session, nullptr);
3785 
3786     session->SetIsPcUse(true);
3787     EXPECT_EQ(session->GetIsPcUse(), true);
3788     GTEST_LOG_(INFO) << "SetIsRealScreen end";
3789 }
3790 
3791 /**
3792  * @tc.name: GetValidHeight
3793  * @tc.desc: GetValidHeight
3794  * @tc.type: FUNC
3795  */
3796 HWTEST_F(ScreenSessionTest, GetValidHeight, TestSize.Level1)
3797 {
3798     GTEST_LOG_(INFO) << "GetValidHeight start";
3799     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
3800     ASSERT_NE(session, nullptr);
3801 
3802     uint32_t validHeight = 100;
3803     session->SetValidHeight(validHeight);
3804     EXPECT_EQ(session->GetValidHeight(), validHeight);
3805     GTEST_LOG_(INFO) << "GetValidHeight end";
3806 }
3807 
3808 /**
3809  * @tc.name: GetValidWidth
3810  * @tc.desc: GetValidWidth
3811  * @tc.type: FUNC
3812  */
3813 HWTEST_F(ScreenSessionTest, GetValidWidth, TestSize.Level1)
3814 {
3815     GTEST_LOG_(INFO) << "GetValidWidth start";
3816     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
3817     ASSERT_NE(session, nullptr);
3818 
3819     uint32_t validWidth = 100;
3820     session->SetValidWidth(validWidth);
3821     EXPECT_EQ(session->GetValidWidth(), validWidth);
3822     GTEST_LOG_(INFO) << "GetValidWidth end";
3823 }
3824 
3825 /**
3826  * @tc.name: GetInnerName
3827  * @tc.desc: GetInnerName test
3828  * @tc.type: FUNC
3829  */
3830 HWTEST_F(ScreenSessionTest, GetInnerName, TestSize.Level1)
3831 {
3832     GTEST_LOG_(INFO) << "ScreenSessionTest: GetInnerName start";
3833     ScreenSessionConfig config = {
3834         .screenId = 0,
3835         .rsId = 0,
3836         .name = "OpenHarmony",
3837     };
3838     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
3839         ScreenSessionReason::CREATE_SESSION_FOR_CLIENT);
3840     ASSERT_NE(nullptr, screenSession);
3841 
3842     std::string innerName = "OpenHarmony";
3843     screenSession->SetInnerName(innerName);
3844     EXPECT_EQ(innerName, screenSession->GetInnerName());
3845     GTEST_LOG_(INFO) << "ScreenSessionTest: GetInnerName end";
3846 }
3847 
3848 
3849 /**
3850  * @tc.name: screen_session_test002
3851  * @tc.desc: normal function
3852  * @tc.type: FUNC
3853  */
3854 HWTEST_F(ScreenSessionTest, GetScreenId, TestSize.Level1)
3855 {
3856     GTEST_LOG_(INFO) << "ScreenSessionTest: GetScreenId start";
3857     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
3858     ASSERT_NE(session, nullptr);
3859 
3860     ScreenId res = session->GetScreenId();
3861     EXPECT_EQ(res, session->screenId_);
3862     GTEST_LOG_(INFO) << "ScreenSessionTest: GetScreenId end";
3863 }
3864 
3865 /**
3866  * @tc.name: SetUpdateScreenPivotCallback
3867  * @tc.desc: normal function
3868  * @tc.type: FUNC
3869  */
3870 HWTEST_F(ScreenSessionTest, SetUpdateScreenPivotCallback, TestSize.Level1)
3871 {
3872     GTEST_LOG_(INFO) << "ScreenSessionTest: SetUpdateScreenPivotCallback start";
3873     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
3874     ASSERT_NE(session, nullptr);
3875 
__anon9ac455210602(float x, float y) 3876     auto func = [session](float x, float y) {
3877         session->GetScreenSnapshot(x, y);
3878     };
3879 
3880     session->SetUpdateScreenPivotCallback(func);
3881     EXPECT_NE(nullptr, session->updateScreenPivotCallback_);
3882     GTEST_LOG_(INFO) << "ScreenSessionTest: SetUpdateScreenPivotCallback end";
3883 }
3884 
3885 
3886 /**
3887  * @tc.name: UpdateTouchBoundsAndOffset
3888  * @tc.desc: UpdateTouchBoundsAndOffset test
3889  * @tc.type: FUNC
3890  */
3891 HWTEST_F(ScreenSessionTest, UpdateTouchBoundsAndOffset, TestSize.Level1)
3892 {
3893     GTEST_LOG_(INFO) << "ScreenSessionTest: UpdateTouchBoundsAndOffset start";
3894     ScreenSessionConfig config = {
3895         .screenId = 100,
3896         .rsId = 101,
3897         .name = "OpenHarmony",
3898     };
3899     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
3900         ScreenSessionReason::CREATE_SESSION_FOR_CLIENT);
3901     ASSERT_NE(screenSession, nullptr);
3902 
3903     screenSession->UpdateTouchBoundsAndOffset();
3904     EXPECT_EQ(0, screenSession->property_.GetInputOffsetY());
3905     GTEST_LOG_(INFO) << "ScreenSessionTest: UpdateTouchBoundsAndOffset end";
3906 }
3907 
3908 /**
3909  * @tc.name: GetOrientation
3910  * @tc.desc: normal function
3911  * @tc.type: FUNC
3912  */
3913 HWTEST_F(ScreenSessionTest, GetOrientation, TestSize.Level1)
3914 {
3915     GTEST_LOG_(INFO) << "ScreenSessionTest: GetOrientation start";
3916     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
3917     ASSERT_NE(session, nullptr);
3918 
3919     Orientation orientation = Orientation::UNSPECIFIED;
3920     session->SetOrientation(orientation);
3921     Orientation res = session->GetOrientation();
3922     ASSERT_EQ(res, orientation);
3923     GTEST_LOG_(INFO) << "ScreenSessionTest: GetOrientation end";
3924 }
3925 
3926 /**
3927  * @tc.name: GetOrientation
3928  * @tc.desc: normal function
3929  * @tc.type: FUNC
3930  */
3931 HWTEST_F(ScreenSessionTest, GetDensityInCurResolution, TestSize.Level1)
3932 {
3933     GTEST_LOG_(INFO) << "ScreenSessionTest: GetDensityInCurResolution start";
3934     ScreenSessionConfig config = {
3935         .screenId = 100,
3936         .rsId = 101,
3937         .name = "OpenHarmony",
3938     };
3939     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
3940         ScreenSessionReason::CREATE_SESSION_FOR_CLIENT);
3941     ASSERT_NE(screenSession, nullptr);
3942 
3943     float density = 1.5f;
3944     screenSession->SetDensityInCurResolution(density);
3945     float res = screenSession->GetDensityInCurResolution();
3946     EXPECT_EQ(1.5f, res);
3947     GTEST_LOG_(INFO) << "ScreenSessionTest: GetDensityInCurResolution end";
3948 }
3949 
3950 /**
3951  * @tc.name: SetDefaultDensity
3952  * @tc.desc: normal function
3953  * @tc.type: FUNC
3954  */
3955 HWTEST_F(ScreenSessionTest, SetDefaultDensity, TestSize.Level1)
3956 {
3957     GTEST_LOG_(INFO) << "ScreenSessionTest: SetDefaultDensity start";
3958     ScreenSessionConfig config = {
3959         .screenId = 100,
3960         .rsId = 101,
3961         .name = "OpenHarmony",
3962     };
3963     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
3964         ScreenSessionReason::CREATE_SESSION_FOR_CLIENT);
3965     ASSERT_NE(screenSession, nullptr);
3966 
3967     float density = 1.5f;
3968     screenSession->SetDefaultDensity(density);
3969     float res = screenSession->property_.GetDefaultDensity();
3970     EXPECT_EQ(1.5f, res);
3971     GTEST_LOG_(INFO) << "ScreenSessionTest: SetDefaultDensity end";
3972 }
3973 
3974 /**
3975  * @tc.name: GetChildrenPosition
3976  * @tc.desc: normal function
3977  * @tc.type: FUNC
3978  */
3979 HWTEST_F(ScreenSessionTest, GetChildrenPosition, TestSize.Level1)
3980 {
3981     GTEST_LOG_(INFO) << "ScreenSessionTest: GetChildrenPosition start";
3982     ScreenSessionGroup sessionGroup(1, 1, "create", ScreenCombination::SCREEN_ALONE);
3983     sptr<ScreenSession> session0 = nullptr;
3984     Point startPoint(0, 0);
3985     sptr<ScreenSession> defaultScreenSession;
3986     bool res = sessionGroup.AddChild(session0, startPoint, defaultScreenSession);
3987     EXPECT_EQ(res, false);
3988 
3989     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
3990     ASSERT_NE(session, nullptr);
3991 
3992     res = sessionGroup.AddChild(session, startPoint, defaultScreenSession);
3993     EXPECT_EQ(res, true);
3994     EXPECT_NE(0, sessionGroup.GetChildrenPosition().size());
3995     GTEST_LOG_(INFO) << "ScreenSessionTest: GetChildrenPosition end";
3996 }
3997 
3998 /**
3999  * @tc.name: GetChildCount
4000  * @tc.desc: normal function
4001  * @tc.type: FUNC
4002  */
4003 HWTEST_F(ScreenSessionTest, GetChildCount, TestSize.Level1)
4004 {
4005     GTEST_LOG_(INFO) << "ScreenSessionTest: GetChildCount start";
4006     ScreenSessionGroup sessionGroup(1, 1, "create", ScreenCombination::SCREEN_ALONE);
4007     sptr<ScreenSession> session0 = nullptr;
4008     Point startPoint(0, 0);
4009     sptr<ScreenSession> defaultScreenSession;
4010     bool res = sessionGroup.AddChild(session0, startPoint, defaultScreenSession);
4011     EXPECT_EQ(res, false);
4012 
4013     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
4014     ASSERT_NE(session, nullptr);
4015 
4016     res = sessionGroup.AddChild(session, startPoint, defaultScreenSession);
4017     EXPECT_EQ(res, true);
4018     EXPECT_NE(0, sessionGroup.GetChildCount());
4019     GTEST_LOG_(INFO) << "ScreenSessionTest: GetChildCount end";
4020 }
4021 
4022 /**
4023  * @tc.name: SetForceCloseHdr
4024  * @tc.desc: normal function
4025  * @tc.type: FUNC
4026  */
4027 HWTEST_F(ScreenSessionTest, SetForceCloseHdr, TestSize.Level1)
4028 {
4029     GTEST_LOG_(INFO) << "ScreenSessionTest: SetForceCloseHdr start";
4030     LOG_SetCallback(MyLogCallback);
4031     ScreenProperty newScreenProperty;
4032     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr(0, newScreenProperty, 0);
4033     ASSERT_NE(session, nullptr);
4034     session->SetForceCloseHdr(true);
4035     session->SetForceCloseHdr(false);
4036     EXPECT_FALSE(g_errLog.find("Start get screen status.") != std::string::npos);
4037     GTEST_LOG_(INFO) << "ScreenSessionTest: SetForceCloseHdr end";
4038 }
4039 
4040 /**
4041  * @tc.name: SetForceCloseHdr01
4042  * @tc.desc: normal function
4043  * @tc.type: FUNC
4044  */
4045 HWTEST_F(ScreenSessionTest, SetForceCloseHdr01, TestSize.Level1)
4046 {
4047     GTEST_LOG_(INFO) << "ScreenSessionTest: SetForceCloseHdr start";
4048     LOG_SetCallback(MyLogCallback);
4049     ScreenProperty newScreenProperty;
4050     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr(0, newScreenProperty, 0);
4051     ASSERT_NE(session, nullptr);
4052     session->SetForceCloseHdr(false);
4053     session->SetForceCloseHdr(false);
4054     EXPECT_TRUE(g_errLog.find("lastCloseHdrStatus_ and isForceCloseHdr are the same.") != std::string::npos);
4055     GTEST_LOG_(INFO) << "ScreenSessionTest: SetForceCloseHdr end";
4056 }
4057 
4058 /**
4059  * @tc.name: IsWidthHeightMatch01
4060  * @tc.desc: normal function
4061  * @tc.type: FUNC
4062  */
4063 HWTEST_F(ScreenSessionTest, IsWidthHeightMatch01, TestSize.Level1)
4064 {
4065     GTEST_LOG_(INFO) << "ScreenSessionTest: IsWidthHeightMatch01 start";
4066     ScreenSessionConfig config = {
4067         .screenId = 100,
4068         .rsId = 101,
4069         .name = "OpenHarmony",
4070     };
4071     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
4072         ScreenSessionReason::CREATE_SESSION_FOR_CLIENT);
4073     ASSERT_NE(screenSession, nullptr);
4074 
4075     float width = 1.5f;
4076     float height = 1.5f;
4077     float targetWidth = 1.5f;
4078     float targetHeight = 1.5f;
4079     EXPECT_EQ(true, screenSession->IsWidthHeightMatch(width, height, targetWidth, targetHeight));
4080     GTEST_LOG_(INFO) << "ScreenSessionTest: IsWidthHeightMatch01 end";
4081 }
4082 
4083 /**
4084  * @tc.name: IsWidthHeightMatch02
4085  * @tc.desc: normal function
4086  * @tc.type: FUNC
4087  */
4088 HWTEST_F(ScreenSessionTest, IsWidthHeightMatch02, TestSize.Level1)
4089 {
4090     GTEST_LOG_(INFO) << "ScreenSessionTest: IsWidthHeightMatch02 start";
4091     ScreenSessionConfig config = {
4092         .screenId = 100,
4093         .rsId = 101,
4094         .name = "OpenHarmony",
4095     };
4096     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
4097         ScreenSessionReason::CREATE_SESSION_FOR_CLIENT);
4098     ASSERT_NE(screenSession, nullptr);
4099 
4100     float width = 1.0f;
4101     float height = 2.0f;
4102     float targetWidth = 3.0f;
4103     float targetHeight = 4.0f;
4104     EXPECT_EQ(false, screenSession->IsWidthHeightMatch(width, height, targetWidth, targetHeight));
4105     GTEST_LOG_(INFO) << "ScreenSessionTest: IsWidthHeightMatch02 end";
4106 }
4107 
4108 /**
4109  * @tc.name: SetScreenSnapshotRect
4110  * @tc.desc: normal function
4111  * @tc.type: FUNC
4112  */
4113 HWTEST_F(ScreenSessionTest, SetScreenSnapshotRect, TestSize.Level1)
4114 {
4115     LOG_SetCallback(MyLogCallback);
4116     GTEST_LOG_(INFO) << "ScreenSessionTest: SetScreenSnapshotRect start";
4117     ScreenSessionConfig config = {
4118         .screenId = 100,
4119         .rsId = 101,
4120         .name = "OpenHarmony",
4121     };
4122     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
4123         ScreenSessionReason::CREATE_SESSION_FOR_CLIENT);
4124     ASSERT_NE(screenSession, nullptr);
4125 
4126     float scaleX = 1.0f;
4127     float scaleY = 1.0f;
4128     RSSurfaceCaptureConfig config1 = {
4129         .scaleX = scaleX,
4130         .scaleY = scaleY,
4131         .useDma = true,
4132     };
4133     screenSession->SetScreenSnapshotRect(config1);
4134     EXPECT_TRUE(g_errLog.find("no need to set screen snapshot rect") != std::string::npos);
4135     GTEST_LOG_(INFO) << "ScreenSessionTest: SetScreenSnapshotRect end";
4136 }
4137 
4138 /**
4139  * @tc.name: SetStartPosition
4140  * @tc.desc: normal function
4141  * @tc.type: FUNC
4142  */
4143 HWTEST_F(ScreenSessionTest, SetStartPosition, TestSize.Level1)
4144 {
4145     GTEST_LOG_(INFO) << "ScreenSessionTest: SetStartPosition start";
4146     ScreenSessionConfig config = {
4147         .screenId = 100,
4148         .rsId = 101,
4149         .name = "OpenHarmony",
4150     };
4151     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
4152         ScreenSessionReason::CREATE_SESSION_FOR_CLIENT);
4153     ASSERT_NE(screenSession, nullptr);
4154 
4155     float scaleX = 1.0f;
4156     float scaleY = 1.0f;
4157     screenSession->SetStartPosition(scaleX, scaleY);
4158     EXPECT_EQ(scaleX, screenSession->property_.scaleX_);
4159     GTEST_LOG_(INFO) << "ScreenSessionTest: SetStartPosition end";
4160 }
4161 
4162 /**
4163  * @tc.name: ScreenModeChange
4164  * @tc.desc: normal function
4165  * @tc.type: FUNC
4166  */
4167 HWTEST_F(ScreenSessionTest, ScreenModeChange, TestSize.Level1)
4168 {
4169     GTEST_LOG_(INFO) << "ScreenSessionTest: ScreenModeChange start";
4170     LOG_SetCallback(MyLogCallback);
4171     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
4172     EXPECT_NE(nullptr, session);
4173 
4174     session->screenChangeListenerList_.clear();
4175     session->ScreenModeChange(ScreenModeChangeEvent::UNKNOWN);
4176     EXPECT_TRUE(g_errLog.find("screenChangeListenerList is empty.") != std::string::npos);
4177     GTEST_LOG_(INFO) << "ScreenSessionTest: ScreenModeChange end";
4178 }
4179 
4180 /**
4181  * @tc.name: GetSensorRotation
4182  * @tc.desc: normal function
4183  * @tc.type: FUNC
4184  */
4185 HWTEST_F(ScreenSessionTest, GetSensorRotation, TestSize.Level1)
4186 {
4187     GTEST_LOG_(INFO) << "ScreenSessionTest: GetSensorRotation start";
4188     ScreenSessionConfig config = {
4189         .screenId = 100,
4190         .rsId = 101,
4191         .name = "OpenHarmony",
4192     };
4193     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
4194         ScreenSessionReason::CREATE_SESSION_FOR_CLIENT);
4195     ASSERT_NE(screenSession, nullptr);
4196 
4197     Rotation sensorRotation = Rotation::ROTATION_0;
4198     screenSession->SensorRotationChange(sensorRotation);
4199     EXPECT_EQ(0, screenSession->GetSensorRotation());
4200     GTEST_LOG_(INFO) << "ScreenSessionTest: GetSensorRotation end";
4201 }
4202 
4203 /**
4204  * @tc.name: GetDisplayId
4205  * @tc.desc: normal function
4206  * @tc.type: FUNC
4207  */
4208 HWTEST_F(ScreenSessionTest, GetDisplayId, TestSize.Level1)
4209 {
4210     GTEST_LOG_(INFO) << "ScreenSessionTest: GetDisplayId start";
4211     ScreenSessionConfig config = {
4212         .screenId = 100,
4213         .rsId = 101,
4214         .name = "OpenHarmony",
4215     };
4216     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
4217         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
4218     ASSERT_NE(screenSession, nullptr);
4219 
4220     screenSession->SetScreenId(1);
4221     EXPECT_EQ(1, screenSession->GetDisplayId());
4222     GTEST_LOG_(INFO) << "ScreenSessionTest: GetDisplayId end";
4223 }
4224 
4225 /**
4226  * @tc.name: SetDisplayNode
4227  * @tc.desc: normal function
4228  * @tc.type: FUNC
4229  */
4230 HWTEST_F(ScreenSessionTest, SetDisplayNode, TestSize.Level1)
4231 {
4232     GTEST_LOG_(INFO) << "ScreenSessionTest: SetDisplayNode start";
4233     ScreenSessionConfig config = {
4234         .screenId = 100,
4235         .rsId = 101,
4236         .name = "OpenHarmony",
4237     };
4238     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
4239         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
4240     ASSERT_NE(screenSession, nullptr);
4241 
4242     RSDisplayNodeConfig displayNodeConfig;
4243     std::shared_ptr<RSDisplayNode> displayNode = RSDisplayNode::Create(displayNodeConfig);
4244     EXPECT_NE(nullptr, displayNode);
4245 
4246     screenSession->SetDisplayNode(displayNode);
4247     EXPECT_NE(nullptr, screenSession->GetDisplayNode());
4248     GTEST_LOG_(INFO) << "ScreenSessionTest: SetDisplayNode end";
4249 }
4250 
4251 /**
4252  * @tc.name: SetRSScreenId
4253  * @tc.desc: normal function
4254  * @tc.type: FUNC
4255  */
4256 HWTEST_F(ScreenSessionTest, SetRSScreenId, TestSize.Level1)
4257 {
4258     GTEST_LOG_(INFO) << "ScreenSessionTest: SetRSScreenId start";
4259     ScreenSessionConfig config = {
4260         .screenId = 100,
4261         .rsId = 101,
4262         .name = "OpenHarmony",
4263     };
4264     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
4265         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
4266     ASSERT_NE(screenSession, nullptr);
4267 
4268     screenSession->SetRSScreenId(1);
4269     EXPECT_EQ(1, screenSession->GetRSScreenId());
4270     GTEST_LOG_(INFO) << "ScreenSessionTest: SetRSScreenId end";
4271 }
4272 
4273 /**
4274  * @tc.name: SetActiveId
4275  * @tc.desc: normal function
4276  * @tc.type: FUNC
4277  */
4278 HWTEST_F(ScreenSessionTest, SetActiveId, TestSize.Level1)
4279 {
4280     GTEST_LOG_(INFO) << "ScreenSessionTest: SetActiveId start";
4281     ScreenSessionConfig config = {
4282         .screenId = 100,
4283         .rsId = 101,
4284         .name = "OpenHarmony",
4285     };
4286     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
4287         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
4288     ASSERT_NE(screenSession, nullptr);
4289 
4290     screenSession->SetActiveId(1);
4291     EXPECT_EQ(1, screenSession->GetActiveId());
4292     GTEST_LOG_(INFO) << "ScreenSessionTest: SetActiveId end";
4293 }
4294 
4295 /**
4296  * @tc.name: SetIsAvailableAreaNeedNotify01
4297  * @tc.desc: normal function
4298  * @tc.type: FUNC
4299  */
4300 HWTEST_F(ScreenSessionTest, SetIsAvailableAreaNeedNotify01, TestSize.Level1)
4301 {
4302     GTEST_LOG_(INFO) << "ScreenSessionTest: SetIsAvailableAreaNeedNotify01 start";
4303     ScreenSessionConfig config = {
4304         .screenId = 100,
4305         .rsId = 101,
4306         .name = "OpenHarmony",
4307     };
4308     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
4309         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
4310     ASSERT_NE(screenSession, nullptr);
4311 
4312     screenSession->SetIsAvailableAreaNeedNotify(false);
4313     EXPECT_EQ(false, screenSession->GetIsAvailableAreaNeedNotify());
4314     GTEST_LOG_(INFO) << "ScreenSessionTest: SetIsAvailableAreaNeedNotify01 end";
4315 }
4316 
4317 
4318 /**
4319  * @tc.name: SetIsAvailableAreaNeedNotify02
4320  * @tc.desc: normal function
4321  * @tc.type: FUNC
4322  */
4323 HWTEST_F(ScreenSessionTest, SetIsAvailableAreaNeedNotify02, TestSize.Level1)
4324 {
4325     GTEST_LOG_(INFO) << "ScreenSessionTest: SetIsAvailableAreaNeedNotify02 start";
4326     ScreenSessionConfig config = {
4327         .screenId = 100,
4328         .rsId = 101,
4329         .name = "OpenHarmony",
4330     };
4331     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
4332         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
4333     ASSERT_NE(screenSession, nullptr);
4334 
4335     screenSession->SetIsAvailableAreaNeedNotify(true);
4336     EXPECT_EQ(true, screenSession->GetIsAvailableAreaNeedNotify());
4337     GTEST_LOG_(INFO) << "ScreenSessionTest: SetIsAvailableAreaNeedNotify02 end";
4338 }
4339 
4340 /**
4341  * @tc.name: SetIsEnableCanvasRotation01
4342  * @tc.desc: normal function
4343  * @tc.type: FUNC
4344  */
4345 HWTEST_F(ScreenSessionTest, SetIsEnableCanvasRotation01, TestSize.Level1)
4346 {
4347     GTEST_LOG_(INFO) << "ScreenSessionTest: SetIsEnableCanvasRotation01 start";
4348     ScreenSessionConfig config = {
4349         .screenId = 100,
4350         .rsId = 101,
4351         .name = "OpenHarmony",
4352     };
4353     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
4354         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
4355     ASSERT_NE(screenSession, nullptr);
4356 
4357     screenSession->SetIsEnableCanvasRotation(false);
4358     EXPECT_EQ(false, screenSession->GetIsEnableCanvasRotation());
4359     GTEST_LOG_(INFO) << "ScreenSessionTest: SetIsEnableCanvasRotation01 end";
4360 }
4361 
4362 /**
4363  * @tc.name: SetIsEnableCanvasRotation01
4364  * @tc.desc: normal function
4365  * @tc.type: FUNC
4366  */
4367 HWTEST_F(ScreenSessionTest, SetIsEnableCanvasRotation02, TestSize.Level1)
4368 {
4369     GTEST_LOG_(INFO) << "ScreenSessionTest: SetIsEnableCanvasRotation02 start";
4370     ScreenSessionConfig config = {
4371         .screenId = 100,
4372         .rsId = 101,
4373         .name = "OpenHarmony",
4374     };
4375     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
4376         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
4377     ASSERT_NE(screenSession, nullptr);
4378 
4379     screenSession->SetIsEnableCanvasRotation(true);
4380     EXPECT_EQ(true, screenSession->GetIsEnableCanvasRotation());
4381     GTEST_LOG_(INFO) << "ScreenSessionTest: SetIsEnableCanvasRotation02 end";
4382 }
4383 
4384 /**
4385  * @tc.name: SetSecurity01
4386  * @tc.desc: normal function
4387  * @tc.type: FUNC
4388  */
4389 HWTEST_F(ScreenSessionTest, SetSecurity01, TestSize.Level1)
4390 {
4391     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
4392     ASSERT_NE(session, nullptr);
4393     session->SetSecurity(true);
4394     EXPECT_EQ(session->isSecurity_, true);
4395 }
4396 
4397 /**
4398  * @tc.name: SetSecurity02
4399  * @tc.desc: normal function
4400  * @tc.type: FUNC
4401  */
4402 HWTEST_F(ScreenSessionTest, SetSecurity02, TestSize.Level1)
4403 {
4404     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
4405     ASSERT_NE(session, nullptr);
4406     session->SetSecurity(false);
4407     EXPECT_EQ(session->isSecurity_, false);
4408 }
4409 
4410 /**
4411  * @tc.name: SetHorizontalRotation01
4412  * @tc.desc: SetHorizontalRotation01
4413  * @tc.type: FUNC
4414  */
4415 HWTEST_F(ScreenSessionTest, SetHorizontalRotation01, TestSize.Level1)
4416 {
4417     LOG_SetCallback(MyLogCallback);
4418     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
4419     EXPECT_NE(nullptr, session);
4420 
4421     session->displayNode_ = nullptr;
4422     session->SetHorizontalRotation();
4423     EXPECT_EQ(session->property_.GetDeviceRotation(), Rotation::ROTATION_270);
4424     EXPECT_TRUE(g_errLog.find("displayNode is null, no need to set displayNode.") != std::string::npos);
4425 }
4426 
4427 /**
4428  * @tc.name: SetHorizontalRotation02
4429  * @tc.desc: SetHorizontalRotation02
4430  * @tc.type: FUNC
4431  */
4432 HWTEST_F(ScreenSessionTest, SetHorizontalRotation02, TestSize.Level1)
4433 {
4434     sptr<ScreenSession> session = sptr<ScreenSession>::MakeSptr();
4435     ASSERT_NE(session, nullptr);
4436 
4437     RSDisplayNodeConfig displayNodeConfig;
4438     std::shared_ptr<RSDisplayNode> displayNode = RSDisplayNode::Create(displayNodeConfig);
4439     EXPECT_NE(nullptr, displayNode);
4440 
4441     session->SetDisplayNode(displayNode);
4442     session->SetHorizontalRotation();
4443     EXPECT_EQ(session->property_.GetDeviceRotation(), Rotation::ROTATION_270);
4444     EXPECT_FALSE(g_errLog.find("displayNode is null, no need to set displayNode.") != std::string::npos);
4445 }
4446 
4447 /**
4448  * @tc.name: SetDisplayGroupId
4449  * @tc.desc: normal function
4450  * @tc.type: FUNC
4451  */
4452 HWTEST_F(ScreenSessionTest, SetDisplayGroupId, TestSize.Level1)
4453 {
4454     ScreenSessionConfig config = {
4455         .screenId = 100,
4456         .rsId = 101,
4457         .name = "OpenHarmony",
4458     };
4459     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
4460         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
4461     ASSERT_NE(screenSession, nullptr);
4462 
4463     screenSession->SetDisplayGroupId(0);
4464     EXPECT_EQ(0, screenSession->GetDisplayGroupId());
4465     screenSession->SetMainDisplayIdOfGroup(0);
4466     EXPECT_EQ(0, screenSession->GetMainDisplayIdOfGroup());
4467 }
4468 
4469 /**
4470  * @tc.name: SetScreenArea
4471  * @tc.desc: normal function
4472  * @tc.type: FUNC
4473  */
4474 HWTEST_F(ScreenSessionTest, SetScreenArea, TestSize.Level1)
4475 {
4476     ScreenSessionConfig config = {
4477         .screenId = 100,
4478         .rsId = 101,
4479         .name = "OpenHarmony",
4480     };
4481     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(config,
4482         ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
4483     ASSERT_NE(screenSession, nullptr);
4484 
4485     screenSession->SetScreenAreaOffsetX(100);
4486     screenSession->SetScreenAreaOffsetY(200);
4487     screenSession->SetScreenAreaWidth(300);
4488     screenSession->SetScreenAreaHeight(400);
4489     EXPECT_EQ(100, screenSession->GetScreenAreaOffsetX());
4490     EXPECT_EQ(200, screenSession->GetScreenAreaOffsetY());
4491     EXPECT_EQ(300, screenSession->GetScreenAreaWidth());
4492     EXPECT_EQ(400, screenSession->GetScreenAreaHeight());
4493 }
4494 
4495 /**
4496  * @tc.name: FreezeScreen
4497  * @tc.desc: FreezeScreen Test
4498  * @tc.type: FUNC
4499  */
4500 HWTEST_F(ScreenSessionTest, FreezeScreen, TestSize.Level2)
4501 {
4502     LOG_SetCallback(MyLogCallback);
4503     g_errLog.clear();
4504     ScreenId screenId = 0;
4505     ScreenProperty screenProperty;
4506     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(screenId, screenProperty, screenId);
4507     screenSession->displayNode_ = nullptr;
4508     bool isFreeze = false;
4509     screenSession->FreezeScreen(isFreeze);
4510     EXPECT_TRUE(g_errLog.find("displayNode is null") != std::string::npos);
4511 
4512     RSDisplayNodeConfig config;
4513     std::shared_ptr<RSDisplayNode> displayNode = std::make_shared<RSDisplayNode>(config);
4514     screenSession->SetDisplayNode(displayNode);
4515     screenSession->FreezeScreen(isFreeze);
4516     g_errLog.clear();
4517 }
4518 
4519 /**
4520  * @tc.name: GetScreenSnapshotWithAllWindows01
4521  * @tc.desc: GetScreenSnapshotWithAllWindows01 Test
4522  * @tc.type: FUNC
4523  */
4524 HWTEST_F(ScreenSessionTest, GetScreenSnapshotWithAllWindows01, TestSize.Level2)
4525 {
4526     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr();
4527     screenSession->displayNode_ = nullptr;
4528     float scaleX = 1.0;
4529     float scaleY = 1.0;
4530     bool isNeedCheckDrmAndSurfaceLock = true;
4531     std::shared_ptr<Media::PixelMap> pixelMap = nullptr;
4532     pixelMap = screenSession->GetScreenSnapshotWithAllWindows(scaleX, scaleY, isNeedCheckDrmAndSurfaceLock);
4533     EXPECT_EQ(pixelMap, nullptr);
4534 }
4535 
4536 /**
4537  * @tc.name: GetScreenSnapshotWithAllWindows02
4538  * @tc.desc: GetScreenSnapshotWithAllWindows02 Test
4539  * @tc.type: FUNC
4540  */
4541 HWTEST_F(ScreenSessionTest, GetScreenSnapshotWithAllWindows02, TestSize.Level2)
4542 {
4543     ScreenId screenId = 100;
4544     ScreenProperty screenProperty;
4545     sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(screenId, screenProperty, screenId);
4546     Rosen::RSDisplayNodeConfig config = { .screenId = 100 };
4547     std::shared_ptr<RSDisplayNode> displayNode = Rosen::RSDisplayNode::Create(config);
4548     screenSession->SetDisplayNode(displayNode);
4549     float scaleX = 1.0;
4550     float scaleY = 1.0;
4551     bool isNeedCheckDrmAndSurfaceLock = true;
4552     std::shared_ptr<Media::PixelMap> pixelMap = nullptr;
4553     pixelMap = screenSession->GetScreenSnapshotWithAllWindows(scaleX, scaleY, isNeedCheckDrmAndSurfaceLock);
4554     EXPECT_EQ(pixelMap, nullptr);
4555 }
4556 } // namespace
4557 } // namespace Rosen
4558 } // namespace OHOS
4559