• 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 
22 // using namespace FRAME_TRACE;
23 using namespace testing;
24 using namespace testing::ext;
25 namespace OHOS {
26 namespace Rosen {
27 class MockScreenChangeListener : public IScreenChangeListener {
28 public:
OnConnect(ScreenId screenId)29     void OnConnect(ScreenId screenId) override {}
OnDisconnect(ScreenId screenId)30     void OnDisconnect(ScreenId screenId) override {}
OnPropertyChange(const ScreenProperty & newProperty,ScreenPropertyChangeReason reason,ScreenId screenId)31     void OnPropertyChange(const ScreenProperty& newProperty, ScreenPropertyChangeReason reason,
32         ScreenId screenId) override {}
OnPowerStatusChange(DisplayPowerEvent event,EventStatus status,PowerStateChangeReason reason)33     void OnPowerStatusChange(DisplayPowerEvent event, EventStatus status,
34         PowerStateChangeReason reason) override {}
OnSensorRotationChange(float sensorRotation,ScreenId screenId)35     void OnSensorRotationChange(float sensorRotation, ScreenId screenId) override {}
OnScreenOrientationChange(float screenOrientation,ScreenId screenId)36     void OnScreenOrientationChange(float screenOrientation, ScreenId screenId) override {}
OnScreenRotationLockedChange(bool isLocked,ScreenId screenId)37     void OnScreenRotationLockedChange(bool isLocked, ScreenId screenId) override {}
OnScreenExtendChange(ScreenId mainScreenId,ScreenId extendScreenId)38     void OnScreenExtendChange(ScreenId mainScreenId, ScreenId extendScreenId) override {}
OnHoverStatusChange(int32_t hoverStatus,bool needRotate,ScreenId screenId)39     void OnHoverStatusChange(int32_t hoverStatus, bool needRotate, ScreenId screenId) override {}
OnScreenCaptureNotify(ScreenId mainScreenId,int32_t uid,const std::string & clientName)40     void OnScreenCaptureNotify(ScreenId mainScreenId, int32_t uid, const std::string& clientName) override {}
OnCameraBackSelfieChange(bool isCameraBackSelfie,ScreenId screenId)41     void OnCameraBackSelfieChange(bool isCameraBackSelfie, ScreenId screenId) override {}
OnSuperFoldStatusChange(ScreenId screenId,SuperFoldStatus superFoldStatus)42     void OnSuperFoldStatusChange(ScreenId screenId, SuperFoldStatus superFoldStatus) override {}
OnSecondaryReflexionChange(ScreenId screenId,bool isSecondaryReflexion)43     void OnSecondaryReflexionChange(ScreenId screenId, bool isSecondaryReflexion) override {}
OnExtendScreenConnectStatusChange(ScreenId screenId,ExtendScreenConnectStatus extendScreenConnectStatus)44     void OnExtendScreenConnectStatusChange(ScreenId screenId,
45         ExtendScreenConnectStatus extendScreenConnectStatus) override {}
46 };
47 class ScreenSessionTest : public testing::Test {
48   public:
ScreenSessionTest()49     ScreenSessionTest() {}
~ScreenSessionTest()50     ~ScreenSessionTest() {}
51 };
52 
53 namespace {
54 
55 /**
56  * @tc.name: create ScreenSession
57  * @tc.desc: normal function
58  * @tc.type: FUNC
59  */
60 HWTEST_F(ScreenSessionTest, ScreenSession, Function | SmallTest | Level2)
61 {
62     ScreenSessionConfig config = {
63         .screenId = 0,
64         .rsId = 0,
65         .name = "OpenHarmony",
66     };
67     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_CLIENT);
68     EXPECT_NE(nullptr, screenSession);
69 }
70 
71 /**
72  * @tc.name: create ScreenSession02
73  * @tc.desc: normal function
74  * @tc.type: FUNC
75  */
76 HWTEST_F(ScreenSessionTest, ScreenSession02, Function | SmallTest | Level2)
77 {
78     ScreenSessionConfig config = {
79         .screenId = 0,
80         .rsId = 0,
81         .name = "OpenHarmony",
82     };
83     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
84     EXPECT_NE(nullptr, screenSession);
85 }
86 
87 /**
88  * @tc.name: create ScreenSession03
89  * @tc.desc: normal function
90  * @tc.type: FUNC
91  */
92 HWTEST_F(ScreenSessionTest, ScreenSession03, Function | SmallTest | Level2)
93 {
94     ScreenSessionConfig config = {
95         .screenId = 0,
96         .rsId = 0,
97         .name = "OpenHarmony",
98     };
99     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_MIRROR);
100     EXPECT_NE(nullptr, screenSession);
101 }
102 
103 /**
104  * @tc.name: create ScreenSession03
105  * @tc.desc: normal function
106  * @tc.type: FUNC
107  */
108 HWTEST_F(ScreenSessionTest, ScreenSession04, Function | SmallTest | Level2)
109 {
110     ScreenSessionConfig config = {
111         .screenId = 0,
112         .rsId = 0,
113         .name = "OpenHarmony",
114     };
115     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_REAL);
116     EXPECT_NE(nullptr, screenSession);
117 }
118 
119 /**
120  * @tc.name: create ScreenSession05
121  * @tc.desc: normal function
122  * @tc.type: FUNC
123  */
124 HWTEST_F(ScreenSessionTest, ScreenSession05, Function | SmallTest | Level2)
125 {
126     ScreenSessionConfig config = {
127         .screenId = 0,
128         .rsId = 0,
129         .name = "OpenHarmony",
130     };
131     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::INVALID);
132     EXPECT_NE(nullptr, screenSession);
133 }
134 
135 /**
136  * @tc.name: CreateDisplayNode
137  * @tc.desc: normal function
138  * @tc.type: FUNC
139  */
140 HWTEST_F(ScreenSessionTest, CreateDisplayNode, Function | SmallTest | Level2)
141 {
142     GTEST_LOG_(INFO) << "ScreenSessionTest: CreateDisplayNode start";
143     Rosen::RSDisplayNodeConfig rsConfig;
144     ScreenSessionConfig config = {
145         .screenId = 100,
146         .rsId = 101,
147         .name = "OpenHarmony",
148     };
149     rsConfig.isMirrored = true;
150     rsConfig.screenId = 101;
151     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
152     EXPECT_NE(nullptr, screenSession);
153     screenSession->CreateDisplayNode(rsConfig);
154     GTEST_LOG_(INFO) << "ScreenSessionTest: CreateDisplayNode end";
155 }
156 
157 /**
158  * @tc.name: SetMirrorScreenType
159  * @tc.desc: normal function
160  * @tc.type: FUNC
161  */
162 HWTEST_F(ScreenSessionTest, SetMirrorScreenType, Function | SmallTest | Level2)
163 {
164     GTEST_LOG_(INFO) << "SetMirrorScreenType start";
165     ScreenSessionConfig config = {
166         .screenId = 100,
167         .rsId = 101,
168         .name = "OpenHarmony",
169     };
170     Rosen::RSDisplayNodeConfig rsConfig;
171     rsConfig.isMirrored = true;
172     rsConfig.screenId = 101;
173     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
174     EXPECT_NE(nullptr, screenSession);
175     MirrorScreenType mirrorType = MirrorScreenType::VIRTUAL_MIRROR;
176     screenSession->SetMirrorScreenType(mirrorType);
177     GTEST_LOG_(INFO) << "SetMirrorScreenType end";
178 }
179 
180 /**
181  * @tc.name: GetMirrorScreenType
182  * @tc.desc: normal function
183  * @tc.type: FUNC
184  */
185 HWTEST_F(ScreenSessionTest, GetMirrorScreenType, Function | SmallTest | Level2)
186 {
187     GTEST_LOG_(INFO) << "GetMirrorScreenType start";
188     ScreenSessionConfig config = {
189         .screenId = 100,
190         .rsId = 101,
191         .name = "OpenHarmony",
192     };
193     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
194     EXPECT_NE(nullptr, screenSession);
195     MirrorScreenType mirrorType = MirrorScreenType::VIRTUAL_MIRROR;
196     screenSession->SetMirrorScreenType(mirrorType);
197     MirrorScreenType res = screenSession->GetMirrorScreenType();
198     ASSERT_EQ(mirrorType, res);
199     GTEST_LOG_(INFO) << "GetMirrorScreenType end";
200 }
201 
202 /**
203  * @tc.name: SetDefaultDeviceRotationOffset
204  * @tc.desc: normal function
205  * @tc.type: FUNC
206  */
207 HWTEST_F(ScreenSessionTest, SetDefaultDeviceRotationOffset, Function | SmallTest | Level2)
208 {
209     GTEST_LOG_(INFO) << "SetDefaultDeviceRotationOffset start";
210     ScreenSessionConfig config = {
211         .screenId = 100,
212         .rsId = 101,
213         .name = "OpenHarmony",
214     };
215     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
216     EXPECT_NE(nullptr, screenSession);
217     uint32_t defaultRotationOffset = 0;
218     screenSession->SetDefaultDeviceRotationOffset(defaultRotationOffset);
219     GTEST_LOG_(INFO) << "SetDefaultDeviceRotationOffset end";
220 }
221 
222 /**
223  * @tc.name: UpdateDisplayState
224  * @tc.desc: normal function
225  * @tc.type: FUNC
226  */
227 HWTEST_F(ScreenSessionTest, UpdateDisplayState, Function | SmallTest | Level2)
228 {
229     GTEST_LOG_(INFO) << "UpdateDisplayState start";
230     ScreenSessionConfig config = {
231         .screenId = 100,
232         .rsId = 101,
233         .name = "OpenHarmony",
234     };
235     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
236     EXPECT_NE(nullptr, screenSession);
237     DisplayState displayState = DisplayState::OFF;
238     screenSession->UpdateDisplayState(displayState);
239     GTEST_LOG_(INFO) << "UpdateDisplayState end";
240 }
241 
242 /**
243  * @tc.name: UpdateRefreshRate
244  * @tc.desc: normal function
245  * @tc.type: FUNC
246  */
247 HWTEST_F(ScreenSessionTest, UpdateRefreshRate, Function | SmallTest | Level2)
248 {
249     GTEST_LOG_(INFO) << "UpdateRefreshRate start";
250     ScreenSessionConfig config = {
251         .screenId = 100,
252         .rsId = 101,
253         .name = "OpenHarmony",
254     };
255     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
256     EXPECT_NE(nullptr, screenSession);
257     uint32_t refreshRate = 2;
258     screenSession->UpdateRefreshRate(refreshRate);
259     GTEST_LOG_(INFO) << "UpdateRefreshRate end";
260 }
261 
262 /**
263  * @tc.name: GetRefreshRate
264  * @tc.desc: normal function
265  * @tc.type: FUNC
266  */
267 HWTEST_F(ScreenSessionTest, GetRefreshRate, Function | SmallTest | Level2)
268 {
269     GTEST_LOG_(INFO) << "GetRefreshRate start";
270     ScreenSessionConfig config = {
271         .screenId = 100,
272         .rsId = 101,
273         .name = "OpenHarmony",
274     };
275     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
276     EXPECT_NE(nullptr, screenSession);
277     uint32_t refreshRate = 2;
278     screenSession->UpdateRefreshRate(refreshRate);
279     auto res = screenSession->GetRefreshRate();
280     ASSERT_EQ(refreshRate, res);
281     GTEST_LOG_(INFO) << "GetRefreshRate end";
282 }
283 
284 /**
285  * @tc.name: UpdatePropertyByResolution
286  * @tc.desc: normal function
287  * @tc.type: FUNC
288  */
289 HWTEST_F(ScreenSessionTest, UpdatePropertyByResolution, Function | SmallTest | Level2)
290 {
291     GTEST_LOG_(INFO) << "UpdatePropertyByResolution start";
292     ScreenSessionConfig config = {
293         .screenId = 100,
294         .rsId = 101,
295         .name = "OpenHarmony",
296     };
297     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
298     EXPECT_NE(nullptr, screenSession);
299     uint32_t width = 1000;
300     uint32_t height = 1500;
301     screenSession->UpdatePropertyByResolution(width, height);
302     GTEST_LOG_(INFO) << "UpdatePropertyByResolution end";
303 }
304 
305 /**
306  * @tc.name: HandleSensorRotation
307  * @tc.desc: normal function
308  * @tc.type: FUNC
309  */
310 HWTEST_F(ScreenSessionTest, HandleSensorRotation, Function | SmallTest | Level2)
311 {
312     GTEST_LOG_(INFO) << "HandleSensorRotation start";
313     ScreenSessionConfig config = {
314         .screenId = 100,
315         .rsId = 101,
316         .name = "OpenHarmony",
317     };
318     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
319     EXPECT_NE(nullptr, screenSession);
320     float sensorRotation = 0.0f;
321     screenSession->HandleSensorRotation(sensorRotation);
322     GTEST_LOG_(INFO) << "HandleSensorRotation end";
323 }
324 
325 /**
326  * @tc.name: ConvertIntToRotation
327  * @tc.desc: normal function
328  * @tc.type: FUNC
329  */
330 HWTEST_F(ScreenSessionTest, ConvertIntToRotation, Function | SmallTest | Level2)
331 {
332     GTEST_LOG_(INFO) << "ScreenSessionTest: ConvertIntToRotation start";
333     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
334     int rotation = 0;
335     auto res = session->ConvertIntToRotation(rotation);
336     ASSERT_EQ(res, Rotation::ROTATION_0);
337     rotation = 90;
338     res = session->ConvertIntToRotation(rotation);
339     ASSERT_EQ(res, Rotation::ROTATION_90);
340     rotation = 180;
341     res = session->ConvertIntToRotation(rotation);
342     ASSERT_EQ(res, Rotation::ROTATION_180);
343     rotation = 270;
344     res = session->ConvertIntToRotation(rotation);
345     ASSERT_EQ(res, Rotation::ROTATION_270);
346     GTEST_LOG_(INFO) << "ScreenSessionTest: ConvertIntToRotation end";
347 }
348 
349 /**
350  * @tc.name: SetVirtualScreenFlag
351  * @tc.desc: normal function
352  * @tc.type: FUNC
353  */
354 HWTEST_F(ScreenSessionTest, SetVirtualScreenFlag, Function | SmallTest | Level2)
355 {
356     GTEST_LOG_(INFO) << "SetVirtualScreenFlag start";
357     ScreenSessionConfig config = {
358         .screenId = 100,
359         .rsId = 101,
360         .name = "OpenHarmony",
361     };
362     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
363     EXPECT_NE(nullptr, screenSession);
364     VirtualScreenFlag screenFlag = VirtualScreenFlag::CAST;
365     screenSession->SetVirtualScreenFlag(screenFlag);
366     GTEST_LOG_(INFO) << "SetVirtualScreenFlag end";
367 }
368 
369 /**
370  * @tc.name: GetVirtualScreenFlag
371  * @tc.desc: normal function
372  * @tc.type: FUNC
373  */
374 HWTEST_F(ScreenSessionTest, GetVirtualScreenFlag, Function | SmallTest | Level2)
375 {
376     GTEST_LOG_(INFO) << "GetVirtualScreenFlag start";
377     ScreenSessionConfig config = {
378         .screenId = 100,
379         .rsId = 101,
380         .name = "OpenHarmony",
381     };
382     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
383     EXPECT_NE(nullptr, screenSession);
384     VirtualScreenFlag screenFlag = VirtualScreenFlag::CAST;
385     screenSession->SetVirtualScreenFlag(screenFlag);
386     auto res = screenSession->GetVirtualScreenFlag();
387     ASSERT_EQ(screenFlag, res);
388     GTEST_LOG_(INFO) << "GetVirtualScreenFlag end";
389 }
390 
391 /**
392  * @tc.name: SetPhysicalRotation
393  * @tc.desc: normal function
394  * @tc.type: FUNC
395  */
396 HWTEST_F(ScreenSessionTest, SetPhysicalRotation, Function | SmallTest | Level2)
397 {
398     GTEST_LOG_(INFO) << "SetPhysicalRotation start";
399     ScreenSessionConfig config = {
400         .screenId = 100,
401         .rsId = 101,
402         .name = "OpenHarmony",
403     };
404     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
405     EXPECT_NE(nullptr, screenSession);
406     int rotation = 0;
407     screenSession->SetPhysicalRotation(rotation);
408     GTEST_LOG_(INFO) << "SetPhysicalRotation end";
409 }
410 
411 /**
412  * @tc.name: SetScreenComponentRotation
413  * @tc.desc: normal function
414  * @tc.type: FUNC
415  */
416 HWTEST_F(ScreenSessionTest, SetScreenComponentRotation, Function | SmallTest | Level2)
417 {
418     GTEST_LOG_(INFO) << "SetScreenComponentRotation start";
419     ScreenSessionConfig config = {
420         .screenId = 100,
421         .rsId = 101,
422         .name = "OpenHarmony",
423     };
424     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
425     EXPECT_NE(nullptr, screenSession);
426     int rotation = 0;
427     screenSession->SetScreenComponentRotation(rotation);
428     GTEST_LOG_(INFO) << "SetScreenComponentRotation end";
429 }
430 
431 /**
432  * @tc.name: UpdateToInputManager
433  * @tc.desc: normal function
434  * @tc.type: FUNC
435  */
436 HWTEST_F(ScreenSessionTest, UpdateToInputManager, Function | SmallTest | Level2)
437 {
438     GTEST_LOG_(INFO) << "UpdateToInputManager start";
439     ScreenSessionConfig config = {
440         .screenId = 100,
441         .rsId = 101,
442         .name = "OpenHarmony",
443     };
444     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
445     EXPECT_NE(nullptr, screenSession);
446     RRect bounds;
447     int rotation = 90;
448     int deviceRotation = 90;
449     FoldDisplayMode foldDisplayMode = FoldDisplayMode::FULL;
450     screenSession->UpdateToInputManager(bounds, rotation, deviceRotation, foldDisplayMode, false);
451     bounds.rect_.width_ = 1344;
452     bounds.rect_.height_ = 2772;
453     rotation = 0;
454     foldDisplayMode = FoldDisplayMode::MAIN;
455     screenSession->UpdateToInputManager(bounds, rotation, deviceRotation, foldDisplayMode, false);
456     GTEST_LOG_(INFO) << "UpdateToInputManager end";
457 }
458 
459 /**
460  * @tc.name: OptimizeSecondaryDisplayMode
461  * @tc.desc: normal function
462  * @tc.type: FUNC
463  */
464 HWTEST_F(ScreenSessionTest, OptimizeSecondaryDisplayMode01, Function | SmallTest | Level2)
465 {
466     if (!FoldScreenStateInternel::IsSecondaryDisplayFoldDevice()) {
467         GTEST_SKIP();
468     }
469     GTEST_LOG_(INFO) << "OptimizeSecondaryDisplayMode start";
470     ScreenSessionConfig config = {
471         .screenId = 100,
472         .rsId = 101,
473         .name = "OpenHarmony",
474     };
475     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
476     ASSERT_NE(screenSession, nullptr);
477     FoldDisplayMode foldDisplayMode = FoldDisplayMode::UNKNOWN;
478     RRect bounds;
479     bounds.rect_.width_ = 1008;
480     bounds.rect_.height_ = 2232;
481     screenSession->OptimizeSecondaryDisplayMode(bounds, foldDisplayMode);
482     EXPECT_EQ(foldDisplayMode, FoldDisplayMode::MAIN);
483 
484     bounds.rect_.width_ = 2048;
485     screenSession->OptimizeSecondaryDisplayMode(bounds, foldDisplayMode);
486     EXPECT_EQ(foldDisplayMode, FoldDisplayMode::FULL);
487 
488     bounds.rect_.width_ = 3184;
489     screenSession->OptimizeSecondaryDisplayMode(bounds, foldDisplayMode);
490     EXPECT_EQ(foldDisplayMode, FoldDisplayMode::GLOBAL_FULL);
491 
492     GTEST_LOG_(INFO) << "OptimizeSecondaryDisplayMode end";
493 }
494 
495 /**
496  * @tc.name: UpdatePropertyAfterRotation
497  * @tc.desc: normal function
498  * @tc.type: FUNC
499  */
500 HWTEST_F(ScreenSessionTest, UpdatePropertyAfterRotation, Function | SmallTest | Level2)
501 {
502     GTEST_LOG_(INFO) << "UpdatePropertyAfterRotation start";
503     ScreenSessionConfig config = {
504         .screenId = 100,
505         .rsId = 101,
506         .name = "OpenHarmony",
507     };
508     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
509     EXPECT_NE(nullptr, screenSession);
510     RRect bounds;
511     bounds.rect_.width_ = 1344;
512     bounds.rect_.height_ = 2772;
513     int rotation = 90;
514     FoldDisplayMode foldDisplayMode = FoldDisplayMode::MAIN;
515     screenSession->UpdatePropertyAfterRotation(bounds, rotation, foldDisplayMode, false);
516     GTEST_LOG_(INFO) << "UpdatePropertyAfterRotation end";
517 }
518 
519 /**
520  * @tc.name: ReportNotifyModeChange
521  * @tc.desc: normal function
522  * @tc.type: FUNC
523  */
524 HWTEST_F(ScreenSessionTest, ReportNotifyModeChange, Function | SmallTest | Level2)
525 {
526     GTEST_LOG_(INFO) << "ReportNotifyModeChange start";
527     ScreenSessionConfig config = {
528         .screenId = 100,
529         .rsId = 101,
530         .name = "OpenHarmony",
531     };
532     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
533     EXPECT_NE(nullptr, screenSession);
534     DisplayOrientation displayOrientation = DisplayOrientation::LANDSCAPE;
535     screenSession->ReportNotifyModeChange(displayOrientation);
536     displayOrientation = DisplayOrientation::PORTRAIT;
537     screenSession->ReportNotifyModeChange(displayOrientation);
538     displayOrientation = DisplayOrientation::PORTRAIT_INVERTED;
539     screenSession->ReportNotifyModeChange(displayOrientation);
540     GTEST_LOG_(INFO) << "ReportNotifyModeChange end";
541 }
542 
543 /**
544  * @tc.name: SuperFoldStatusChange
545  * @tc.desc: normal function
546  * @tc.type: FUNC
547  */
548 HWTEST_F(ScreenSessionTest, SuperFoldStatusChange, Function | SmallTest | Level2)
549 {
550     GTEST_LOG_(INFO) << "SuperFoldStatusChange start";
551     ScreenSessionConfig config = {
552         .screenId = 100,
553         .rsId = 101,
554         .name = "OpenHarmony",
555     };
556     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
557     EXPECT_NE(nullptr, screenSession);
558     ScreenId screenId = 0;
559     SuperFoldStatus superFoldStatus = SuperFoldStatus::UNKNOWN;
560     screenSession->SuperFoldStatusChange(screenId, superFoldStatus);
561     superFoldStatus = SuperFoldStatus::EXPANDED;
562     screenSession->SuperFoldStatusChange(screenId, superFoldStatus);
563     superFoldStatus = SuperFoldStatus::FOLDED;
564     screenSession->SuperFoldStatusChange(screenId, superFoldStatus);
565     superFoldStatus = SuperFoldStatus::KEYBOARD;
566     screenSession->SuperFoldStatusChange(screenId, superFoldStatus);
567     superFoldStatus = SuperFoldStatus::HALF_FOLDED;
568     screenSession->SuperFoldStatusChange(screenId, superFoldStatus);
569     GTEST_LOG_(INFO) << "SuperFoldStatusChange end";
570 }
571 
572 /**
573  * @tc.name: UpdateRotationAfterBoot01
574  * @tc.desc: normal function
575  * @tc.type: FUNC
576  */
577 HWTEST_F(ScreenSessionTest, UpdateRotationAfterBoot01, Function | SmallTest | Level2)
578 {
579     GTEST_LOG_(INFO) << "UpdateRotationAfterBoot start";
580     ScreenSessionConfig config = {
581         .screenId = 100,
582         .rsId = 101,
583         .name = "OpenHarmony",
584     };
585     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
586     EXPECT_NE(nullptr, screenSession);
587     bool foldToExpand = true;
588     screenSession->UpdateRotationAfterBoot(foldToExpand);
589     GTEST_LOG_(INFO) << "UpdateRotationAfterBoot end";
590 }
591 
592 /**
593  * @tc.name: UpdateRotationAfterBoot02
594  * @tc.desc: normal function
595  * @tc.type: FUNC
596  */
597 HWTEST_F(ScreenSessionTest, UpdateRotationAfterBoot02, Function | SmallTest | Level2)
598 {
599     GTEST_LOG_(INFO) << "UpdateRotationAfterBoot start";
600     ScreenSessionConfig config = {
601         .screenId = 100,
602         .rsId = 101,
603         .name = "OpenHarmony",
604     };
605     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
606     EXPECT_NE(nullptr, screenSession);
607     bool foldToExpand = false;
608     screenSession->UpdateRotationAfterBoot(foldToExpand);
609     GTEST_LOG_(INFO) << "UpdateRotationAfterBoot end";
610 }
611 
612 /**
613  * @tc.name: UpdateValidRotationToScb
614  * @tc.desc: normal function
615  * @tc.type: FUNC
616  */
617 HWTEST_F(ScreenSessionTest, UpdateValidRotationToScb, Function | SmallTest | Level2)
618 {
619     GTEST_LOG_(INFO) << "UpdateValidRotationToScb start";
620     ScreenSessionConfig config = {
621         .screenId = 100,
622         .rsId = 101,
623         .name = "OpenHarmony",
624     };
625     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
626     EXPECT_NE(nullptr, screenSession);
627     screenSession->UpdateValidRotationToScb();
628     GTEST_LOG_(INFO) << "UpdateValidRotationToScb end";
629 }
630 
631 /**
632  * @tc.name: SetScreenSceneDpiChangeListener
633  * @tc.desc: normal function
634  * @tc.type: FUNC
635  */
636 HWTEST_F(ScreenSessionTest, SetScreenSceneDpiChangeListener, Function | SmallTest | Level2)
637 {
638     GTEST_LOG_(INFO) << "SetScreenSceneDpiChangeListener start";
639     ScreenSessionConfig config = {
640         .screenId = 100,
641         .rsId = 101,
642         .name = "OpenHarmony",
643     };
644     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
645     EXPECT_NE(nullptr, screenSession);
646     SetScreenSceneDpiFunc func = nullptr;
647     screenSession->SetScreenSceneDpiChangeListener(func);
648     GTEST_LOG_(INFO) << "SetScreenSceneDpiChangeListener end";
649 }
650 
651 /**
652  * @tc.name: SetScreenSceneDestroyListener
653  * @tc.desc: normal function
654  * @tc.type: FUNC
655  */
656 HWTEST_F(ScreenSessionTest, SetScreenSceneDestroyListener, Function | SmallTest | Level2)
657 {
658     GTEST_LOG_(INFO) << "SetScreenSceneDestroyListener start";
659     ScreenSessionConfig config = {
660         .screenId = 100,
661         .rsId = 101,
662         .name = "OpenHarmony",
663     };
664     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
665     EXPECT_NE(nullptr, screenSession);
666     DestroyScreenSceneFunc func = nullptr;
667     screenSession->SetScreenSceneDestroyListener(func);
668     GTEST_LOG_(INFO) << "SetScreenSceneDestroyListener end";
669 }
670 
671 /**
672  * @tc.name: SetScreenSceneDpi
673  * @tc.desc: normal function
674  * @tc.type: FUNC
675  */
676 HWTEST_F(ScreenSessionTest, SetScreenSceneDpi, Function | SmallTest | Level2)
677 {
678     GTEST_LOG_(INFO) << "SetScreenSceneDpi start";
679     ScreenSessionConfig config = {
680         .screenId = 100,
681         .rsId = 101,
682         .name = "OpenHarmony",
683     };
684     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
685     EXPECT_NE(nullptr, screenSession);
686     float density = 1.5f;
687     SetScreenSceneDpiFunc func = nullptr;
688     screenSession->SetScreenSceneDpiChangeListener(func);
689     screenSession->SetScreenSceneDpi(density);
__anon0ae6727f0202(float density) 690     SetScreenSceneDpiFunc func2 = [](float density) {
691             EXPECT_TRUE(true);
692         };
693     screenSession->SetScreenSceneDpiChangeListener(func2);
694     screenSession->SetScreenSceneDpi(density);
695     GTEST_LOG_(INFO) << "SetScreenSceneDpi end";
696 }
697 
698 /**
699  * @tc.name: DestroyScreenScene
700  * @tc.desc: normal function
701  * @tc.type: FUNC
702  */
703 HWTEST_F(ScreenSessionTest, DestroyScreenScene, Function | SmallTest | Level2)
704 {
705     GTEST_LOG_(INFO) << "DestroyScreenScene start";
706     ScreenSessionConfig config = {
707         .screenId = 100,
708         .rsId = 101,
709         .name = "OpenHarmony",
710     };
711     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
712     EXPECT_NE(nullptr, screenSession);
713     DestroyScreenSceneFunc func = nullptr;
714     screenSession->SetScreenSceneDestroyListener(func);
715     screenSession->DestroyScreenScene();
__anon0ae6727f0302() 716     DestroyScreenSceneFunc func2 = []() {
717             EXPECT_TRUE(true);
718         };
719     screenSession->SetScreenSceneDestroyListener(func2);
720     screenSession->DestroyScreenScene();
721     GTEST_LOG_(INFO) << "DestroyScreenScene end";
722 }
723 
724 /**
725  * @tc.name: SetDensityInCurResolution
726  * @tc.desc: normal function
727  * @tc.type: FUNC
728  */
729 HWTEST_F(ScreenSessionTest, SetDensityInCurResolution, Function | SmallTest | Level2)
730 {
731     GTEST_LOG_(INFO) << "SetDensityInCurResolution start";
732     ScreenSessionConfig config = {
733         .screenId = 100,
734         .rsId = 101,
735         .name = "OpenHarmony",
736     };
737     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
738     EXPECT_NE(nullptr, screenSession);
739     float densityInCurResolution = 1.5f;
740     screenSession->SetDensityInCurResolution(densityInCurResolution);
741     GTEST_LOG_(INFO) << "SetDensityInCurResolution end";
742 }
743 
744 /**
745  * @tc.name: GetSourceMode
746  * @tc.desc: normal function
747  * @tc.type: FUNC
748  */
749 HWTEST_F(ScreenSessionTest, GetSourceMode, Function | SmallTest | Level2)
750 {
751     GTEST_LOG_(INFO) << "ScreenSessionTest: GetSourceMode start";
752     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
753     session->screenId_ = session->defaultScreenId_;
754     ScreenSourceMode mode = session->GetSourceMode();
755     ASSERT_EQ(mode, ScreenSourceMode::SCREEN_MAIN);
756     ScreenSessionConfig config = {
757         .screenId = 100,
758         .rsId = 101,
759         .name = "OpenHarmony",
760     };
761     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
762     mode = screenSession->GetSourceMode();
763     ASSERT_EQ(mode, ScreenSourceMode::SCREEN_ALONE);
764     screenSession->SetScreenCombination(ScreenCombination::SCREEN_EXPAND);
765     mode = screenSession->GetSourceMode();
766     ASSERT_EQ(mode, ScreenSourceMode::SCREEN_EXTEND);
767     screenSession->SetScreenCombination(ScreenCombination::SCREEN_MIRROR);
768     mode = screenSession->GetSourceMode();
769     ASSERT_EQ(mode, ScreenSourceMode::SCREEN_MIRROR);
770     screenSession->SetScreenCombination(ScreenCombination::SCREEN_UNIQUE);
771     mode = screenSession->GetSourceMode();
772     ASSERT_EQ(mode, ScreenSourceMode::SCREEN_UNIQUE);
773     GTEST_LOG_(INFO) << "ScreenSessionTest: GetSourceMode end";
774 }
775 
776 /**
777  * @tc.name: GetSourceMode02
778  * @tc.desc: normal function
779  * @tc.type: FUNC
780  */
781 HWTEST_F(ScreenSessionTest, GetSourceMode02, Function | SmallTest | Level2)
782 {
783     GTEST_LOG_(INFO) << "ScreenSessionTest: GetSourceMode02 start";
784     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
785     session->screenId_ = session->defaultScreenId_;
786     ScreenSourceMode mode = session->GetSourceMode();
787     ASSERT_EQ(mode, ScreenSourceMode::SCREEN_MAIN);
788     ScreenSessionConfig config = {
789         .screenId = 100,
790         .rsId = 101,
791         .name = "OpenHarmony",
792     };
793     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
794 
795     screenSession->SetScreenCombination(ScreenCombination::SCREEN_MAIN);
796     mode = screenSession->GetSourceMode();
797     ASSERT_EQ(mode, ScreenSourceMode::SCREEN_MAIN);
798     screenSession->SetScreenCombination(ScreenCombination::SCREEN_EXTEND);
799     mode = screenSession->GetSourceMode();
800     ASSERT_EQ(mode, ScreenSourceMode::SCREEN_EXTEND);
801     GTEST_LOG_(INFO) << "ScreenSessionTest: GetSourceMode02 end";
802 }
803 
804 /**
805  * @tc.name: GetPixelFormat
806  * @tc.desc: normal function
807  * @tc.type: FUNC
808  */
809 HWTEST_F(ScreenSessionTest, GetPixelFormat, Function | SmallTest | Level2)
810 {
811     GTEST_LOG_(INFO) << "GetPixelFormat start";
812     ScreenSessionConfig config = {
813         .screenId = 100,
814         .rsId = 0,
815         .name = "OpenHarmony",
816     };
817     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
818     EXPECT_NE(nullptr, screenSession);
819     GraphicPixelFormat pixelFormat;
820     auto res = screenSession->GetPixelFormat(pixelFormat);
821     ASSERT_EQ(res, DMError::DM_OK);
822     GTEST_LOG_(INFO) << "GetPixelFormat end";
823 }
824 
825 /**
826  * @tc.name: SetPixelFormat
827  * @tc.desc: normal function
828  * @tc.type: FUNC
829  */
830 HWTEST_F(ScreenSessionTest, SetPixelFormat, Function | SmallTest | Level2)
831 {
832     GTEST_LOG_(INFO) << "SetPixelFormat start";
833     ScreenSessionConfig config = {
834         .screenId = 100,
835         .rsId = 0,
836         .name = "OpenHarmony",
837     };
838     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
839     EXPECT_NE(nullptr, screenSession);
840     GraphicPixelFormat pixelFormat = GraphicPixelFormat{GRAPHIC_PIXEL_FMT_CLUT8};
841     auto res = screenSession->SetPixelFormat(pixelFormat);
842     ASSERT_EQ(res, DMError::DM_OK);
843     GTEST_LOG_(INFO) << "SetPixelFormat end";
844 }
845 
846 /**
847  * @tc.name: GetSupportedHDRFormats
848  * @tc.desc: normal function
849  * @tc.type: FUNC
850  */
851 HWTEST_F(ScreenSessionTest, GetSupportedHDRFormats, Function | SmallTest | Level2)
852 {
853 #ifdef WM_SCREEN_HDR_FORMAT_ENABLE
854     GTEST_LOG_(INFO) << "GetSupportedHDRFormats start";
855     ScreenSessionConfig config = {
856         .screenId = 100,
857         .rsId = 0,
858         .name = "OpenHarmony",
859     };
860     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
861     EXPECT_NE(nullptr, screenSession);
862     std::vector<ScreenHDRFormat> hdrFormats;
863     auto res = screenSession->GetSupportedHDRFormats(hdrFormats);
864     if (SceneBoardJudgement::IsSceneBoardEnabled()) {
865         ASSERT_EQ(res, DMError::DM_OK);
866     } else {
867         ASSERT_NE(res, DMError::DM_OK);
868     }
869     GTEST_LOG_(INFO) << "GetSupportedHDRFormats end";
870 #endif
871 }
872 
873 /**
874  * @tc.name: GetScreenHDRFormat
875  * @tc.desc: normal function
876  * @tc.type: FUNC
877  */
878 HWTEST_F(ScreenSessionTest, GetScreenHDRFormat, Function | SmallTest | Level2)
879 {
880     GTEST_LOG_(INFO) << "GetScreenHDRFormat start";
881     ScreenSessionConfig config = {
882         .screenId = 100,
883         .rsId = 0,
884         .name = "OpenHarmony",
885     };
886     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
887     EXPECT_NE(nullptr, screenSession);
888     ScreenHDRFormat hdrFormat;
889     auto res = screenSession->GetScreenHDRFormat(hdrFormat);
890     if (SceneBoardJudgement::IsSceneBoardEnabled()) {
891         ASSERT_EQ(res, DMError::DM_OK);
892     } else {
893         ASSERT_NE(res, DMError::DM_OK);
894     }
895     GTEST_LOG_(INFO) << "GetScreenHDRFormat end";
896 }
897 
898 /**
899  * @tc.name: SetScreenHDRFormat
900  * @tc.desc: normal function
901  * @tc.type: FUNC
902  */
903 HWTEST_F(ScreenSessionTest, SetScreenHDRFormat, Function | SmallTest | Level2)
904 {
905 #ifdef WM_SCREEN_HDR_FORMAT_ENABLE
906     GTEST_LOG_(INFO) << "SetScreenHDRFormat start";
907     ScreenSessionConfig config = {
908         .screenId = 100,
909         .rsId = 0,
910         .name = "OpenHarmony",
911     };
912     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
913     EXPECT_NE(nullptr, screenSession);
914     int32_t modeIdx = 0;
915     auto res = screenSession->SetScreenHDRFormat(modeIdx);
916     if (SceneBoardJudgement::IsSceneBoardEnabled()) {
917         ASSERT_EQ(res, DMError::DM_OK);
918         modeIdx = -1;
919         res = screenSession->SetScreenHDRFormat(modeIdx);
920         ASSERT_EQ(res, DMError::DM_ERROR_INVALID_PARAM);
921     } else {
922         ASSERT_NE(res, DMError::DM_OK);
923     }
924     GTEST_LOG_(INFO) << "SetScreenHDRFormat end";
925 #endif
926 }
927 
928 /**
929  * @tc.name: GetSupportedColorSpaces
930  * @tc.desc: normal function
931  * @tc.type: FUNC
932  */
933 HWTEST_F(ScreenSessionTest, GetSupportedColorSpaces, Function | SmallTest | Level2)
934 {
935     GTEST_LOG_(INFO) << "GetSupportedColorSpaces start";
936     ScreenSessionConfig config = {
937         .screenId = 100,
938         .rsId = 0,
939         .name = "OpenHarmony",
940     };
941     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
942     EXPECT_NE(nullptr, screenSession);
943     std::vector<GraphicCM_ColorSpaceType> colorSpaces;
944     auto res = screenSession->GetSupportedColorSpaces(colorSpaces);
945     if (SceneBoardJudgement::IsSceneBoardEnabled()) {
946         ASSERT_EQ(res, DMError::DM_OK);
947     } else {
948         ASSERT_NE(res, DMError::DM_OK);
949     }
950     GTEST_LOG_(INFO) << "GetSupportedColorSpaces end";
951 }
952 
953 /**
954  * @tc.name: GetScreenColorSpace
955  * @tc.desc: normal function
956  * @tc.type: FUNC
957  */
958 HWTEST_F(ScreenSessionTest, GetScreenColorSpace, Function | SmallTest | Level2)
959 {
960     GTEST_LOG_(INFO) << "GetScreenColorSpace start";
961     ScreenSessionConfig config = {
962         .screenId = 100,
963         .rsId = 0,
964         .name = "OpenHarmony",
965     };
966     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
967     EXPECT_NE(nullptr, screenSession);
968     GraphicCM_ColorSpaceType colorSpace;
969     auto res = screenSession->GetScreenColorSpace(colorSpace);
970     if (SceneBoardJudgement::IsSceneBoardEnabled()) {
971         ASSERT_EQ(res, DMError::DM_OK);
972     } else {
973         ASSERT_NE(res, DMError::DM_OK);
974     }
975     GTEST_LOG_(INFO) << "GetScreenColorSpace end";
976 }
977 
978 /**
979  * @tc.name: SetScreenColorSpace
980  * @tc.desc: normal function
981  * @tc.type: FUNC
982  */
983 HWTEST_F(ScreenSessionTest, SetScreenColorSpace, Function | SmallTest | Level2)
984 {
985     GTEST_LOG_(INFO) << "SetScreenColorSpace start";
986     ScreenSessionConfig config = {
987         .screenId = 100,
988         .rsId = 101,
989         .name = "OpenHarmony",
990     };
991     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
992     EXPECT_NE(nullptr, screenSession);
993     GraphicCM_ColorSpaceType colorSpace = GraphicCM_ColorSpaceType{GRAPHIC_CM_COLORSPACE_NONE};
994     screenSession->SetScreenColorSpace(colorSpace);
995     EXPECT_TRUE(true);
996     GTEST_LOG_(INFO) << "SetScreenColorSpace end";
997 }
998 
999 /**
1000  * @tc.name: SetPrivateSessionForeground
1001  * @tc.desc: normal function
1002  * @tc.type: FUNC
1003  */
1004 HWTEST_F(ScreenSessionTest, SetPrivateSessionForeground, Function | SmallTest | Level2)
1005 {
1006     GTEST_LOG_(INFO) << "SetPrivateSessionForeground start";
1007     ScreenSessionConfig config = {
1008         .screenId = 100,
1009         .rsId = 101,
1010         .name = "OpenHarmony",
1011     };
1012     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
1013     EXPECT_NE(nullptr, screenSession);
1014     bool hasPrivate = true;
1015     screenSession->SetPrivateSessionForeground(hasPrivate);
1016     auto res = screenSession->HasPrivateSessionForeground();
1017     ASSERT_EQ(res, hasPrivate);
1018     GTEST_LOG_(INFO) << "SetPrivateSessionForeground end";
1019 }
1020 
1021 /**
1022  * @tc.name: GetScreenCombination
1023  * @tc.desc: normal function
1024  * @tc.type: FUNC
1025  */
1026 HWTEST_F(ScreenSessionTest, GetScreenCombination, Function | SmallTest | Level2)
1027 {
1028     GTEST_LOG_(INFO) << "GetScreenCombination start";
1029     ScreenSessionConfig config = {
1030         .screenId = 100,
1031         .rsId = 101,
1032         .name = "OpenHarmony",
1033     };
1034     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
1035     EXPECT_NE(nullptr, screenSession);
1036     ScreenCombination combination { ScreenCombination::SCREEN_ALONE };
1037     screenSession->SetScreenCombination(combination);
1038     auto res = screenSession->GetScreenCombination();
1039     ASSERT_EQ(res, combination);
1040     GTEST_LOG_(INFO) << "GetScreenCombination end";
1041 }
1042 
1043 /**
1044  * @tc.name: Resize
1045  * @tc.desc: normal function
1046  * @tc.type: FUNC
1047  */
1048 HWTEST_F(ScreenSessionTest, Resize, Function | SmallTest | Level2)
1049 {
1050     GTEST_LOG_(INFO) << "Resize start";
1051     ScreenSessionConfig config = {
1052         .screenId = 100,
1053         .rsId = 101,
1054         .name = "OpenHarmony",
1055     };
1056     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
1057     EXPECT_NE(nullptr, screenSession);
1058     uint32_t width = 1000;
1059     uint32_t height = 1000;
1060     screenSession->Resize(width, height);
1061     GTEST_LOG_(INFO) << "Resize end";
1062 }
1063 
1064 /**
1065  * @tc.name: UpdateAvailableArea
1066  * @tc.desc: normal function
1067  * @tc.type: FUNC
1068  */
1069 HWTEST_F(ScreenSessionTest, UpdateAvailableArea, Function | SmallTest | Level2)
1070 {
1071     GTEST_LOG_(INFO) << "UpdateAvailableArea start";
1072     ScreenSessionConfig config = {
1073         .screenId = 100,
1074         .rsId = 101,
1075         .name = "OpenHarmony",
1076     };
1077     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
1078     EXPECT_NE(nullptr, screenSession);
1079     DMRect area = screenSession->GetAvailableArea();
1080     auto res = screenSession->UpdateAvailableArea(area);
1081     ASSERT_EQ(res, false);
1082     area = {2, 2, 2, 2};
1083     res = screenSession->UpdateAvailableArea(area);
1084     ASSERT_EQ(res, true);
1085     GTEST_LOG_(INFO) << "UpdateAvailableArea end";
1086 }
1087 
1088 /**
1089  * @tc.name: SetAvailableArea
1090  * @tc.desc: normal function
1091  * @tc.type: FUNC
1092  */
1093 HWTEST_F(ScreenSessionTest, SetAvailableArea, Function | SmallTest | Level2)
1094 {
1095     GTEST_LOG_(INFO) << "SetAvailableArea start";
1096     ScreenSessionConfig config = {
1097         .screenId = 100,
1098         .rsId = 101,
1099         .name = "OpenHarmony",
1100     };
1101     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
1102     EXPECT_NE(nullptr, screenSession);
1103     DMRect area = {2, 2, 2, 2};
1104     screenSession->SetAvailableArea(area);
1105     GTEST_LOG_(INFO) << "SetAvailableArea end";
1106 }
1107 
1108 /**
1109  * @tc.name: GetAvailableArea
1110  * @tc.desc: normal function
1111  * @tc.type: FUNC
1112  */
1113 HWTEST_F(ScreenSessionTest, GetAvailableArea, Function | SmallTest | Level2)
1114 {
1115     GTEST_LOG_(INFO) << "GetAvailableArea start";
1116     ScreenSessionConfig config = {
1117         .screenId = 100,
1118         .rsId = 101,
1119         .name = "OpenHarmony",
1120     };
1121     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
1122     EXPECT_NE(nullptr, screenSession);
1123     DMRect area = {2, 2, 2, 2};
1124     screenSession->SetAvailableArea(area);
1125     auto res = screenSession->GetAvailableArea();
1126     ASSERT_EQ(res, area);
1127     GTEST_LOG_(INFO) << "GetAvailableArea end";
1128 }
1129 
1130 /**
1131  * @tc.name: SetFoldScreen
1132  * @tc.desc: normal function
1133  * @tc.type: FUNC
1134  */
1135 HWTEST_F(ScreenSessionTest, SetFoldScreen, Function | SmallTest | Level2)
1136 {
1137     GTEST_LOG_(INFO) << "SetFoldScreen start";
1138     ScreenSessionConfig config = {
1139         .screenId = 100,
1140         .rsId = 101,
1141         .name = "OpenHarmony",
1142     };
1143     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
1144     EXPECT_NE(nullptr, screenSession);
1145     bool isFold = false;
1146     screenSession->SetFoldScreen(isFold);
1147     GTEST_LOG_(INFO) << "SetFoldScreen end";
1148 }
1149 
1150 /**
1151  * @tc.name: SetHdrFormats
1152  * @tc.desc: normal function
1153  * @tc.type: FUNC
1154  */
1155 HWTEST_F(ScreenSessionTest, SetHdrFormats, Function | SmallTest | Level2)
1156 {
1157     GTEST_LOG_(INFO) << "SetHdrFormats start";
1158     ScreenSessionConfig config = {
1159         .screenId = 100,
1160         .rsId = 101,
1161         .name = "OpenHarmony",
1162     };
1163     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
1164     EXPECT_NE(nullptr, screenSession);
1165     std::vector<uint32_t> hdrFormats = { 0, 0, 0, 0 };
1166     screenSession->SetHdrFormats(std::move(hdrFormats));
1167     GTEST_LOG_(INFO) << "SetHdrFormats end";
1168 }
1169 
1170 /**
1171  * @tc.name: SetColorSpaces
1172  * @tc.desc: normal function
1173  * @tc.type: FUNC
1174  */
1175 HWTEST_F(ScreenSessionTest, SetColorSpaces, Function | SmallTest | Level2)
1176 {
1177     GTEST_LOG_(INFO) << "SetColorSpaces start";
1178     ScreenSessionConfig config = {
1179         .screenId = 100,
1180         .rsId = 101,
1181         .name = "OpenHarmony",
1182     };
1183     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
1184     EXPECT_NE(nullptr, screenSession);
1185     std::vector<uint32_t> colorSpaces = { 0, 0, 0, 0 };
1186     screenSession->SetColorSpaces(std::move(colorSpaces));
1187     GTEST_LOG_(INFO) << "SetColorSpaces end";
1188 }
1189 
1190 /**
1191  * @tc.name: SetDisplayNodeScreenId
1192  * @tc.desc: normal function
1193  * @tc.type: FUNC
1194  */
1195 HWTEST_F(ScreenSessionTest, SetDisplayNodeScreenId, Function | SmallTest | Level2)
1196 {
1197     GTEST_LOG_(INFO) << "ScreenSessionTest: SetDisplayNodeScreenId start";
1198     ScreenId screenId = 0;
1199     ScreenId rsId = 1;
1200     std::string name = "OpenHarmony";
1201     ScreenProperty property;
1202     RSDisplayNodeConfig displayNodeConfig;
1203     std::shared_ptr<RSDisplayNode> displayNode = RSDisplayNode::Create(displayNodeConfig);
1204     EXPECT_NE(nullptr, displayNode);
1205     sptr<ScreenSession> session = new(std::nothrow) ScreenSession(screenId, rsId, name, property, displayNode);
1206     session->SetDisplayNodeScreenId(screenId);
1207     GTEST_LOG_(INFO) << "ScreenSessionTest: SetDisplayNodeScreenId end";
1208 }
1209 
1210 /**
1211  * @tc.name: UnregisterScreenChangeListener
1212  * @tc.desc: normal function
1213  * @tc.type: FUNC
1214  */
1215 HWTEST_F(ScreenSessionTest, UnregisterScreenChangeListener, Function | SmallTest | Level2)
1216 {
1217     GTEST_LOG_(INFO) << "ScreenSessionTest: UnregisterScreenChangeListener start";
1218     IScreenChangeListener* screenChangeListener = nullptr;
1219     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1220     int64_t ret = 0;
1221     session->UnregisterScreenChangeListener(screenChangeListener);
1222     ASSERT_EQ(ret, 0);
1223     GTEST_LOG_(INFO) << "ScreenSessionTest: UnregisterScreenChangeListener end";
1224 }
1225 
1226 /**
1227  * @tc.name: UnregisterScreenChangeListener02
1228  * @tc.desc: normal function
1229  * @tc.type: FUNC
1230  */
1231 HWTEST_F(ScreenSessionTest, UnregisterScreenChangeListener02, Function | SmallTest | Level2)
1232 {
1233     GTEST_LOG_(INFO) << "ScreenSessionTest: UnregisterScreenChangeListener02 start";
1234     IScreenChangeListener* screenChangeListener = new ScreenSessionManager();
1235     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1236     int64_t ret = 0;
1237     session->UnregisterScreenChangeListener(screenChangeListener);
1238     ASSERT_EQ(ret, 0);
1239     GTEST_LOG_(INFO) << "ScreenSessionTest: UnregisterScreenChangeListener02 end";
1240 }
1241 
1242 /**
1243  * @tc.name: ConvertToDisplayInfo
1244  * @tc.desc: normal function
1245  * @tc.type: FUNC
1246  */
1247 HWTEST_F(ScreenSessionTest, ConvertToDisplayInfo, Function | SmallTest | Level2)
1248 {
1249     GTEST_LOG_(INFO) << "ScreenSessionTest: ConvertToDisplayInfo start";
1250     sptr<DisplayInfo> displayInfo = new(std::nothrow) DisplayInfo();
1251     EXPECT_NE(displayInfo, nullptr);
1252     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1253     EXPECT_NE(nullptr, session->ConvertToDisplayInfo());
1254 
1255     sptr<ScreenInfo> info = new(std::nothrow) ScreenInfo();
1256     EXPECT_NE(info, nullptr);
1257     EXPECT_NE(nullptr, session->ConvertToScreenInfo());
1258     GTEST_LOG_(INFO) << "ScreenSessionTest: ConvertToDisplayInfo end";
1259 }
1260 
1261 /**
1262  * @tc.name: GetScreenSupportedColorGamuts
1263  * @tc.desc: normal function
1264  * @tc.type: FUNC
1265  */
1266 HWTEST_F(ScreenSessionTest, GetScreenSupportedColorGamuts, Function | SmallTest | Level2)
1267 {
1268     GTEST_LOG_(INFO) << "ScreenSessionTest: GetScreenSupportedColorGamuts start";
1269     std::vector<ScreenColorGamut> colorGamuts;
1270     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1271     DMError ret = session->GetScreenSupportedColorGamuts(colorGamuts);
1272     if (SceneBoardJudgement::IsSceneBoardEnabled()) {
1273         ASSERT_EQ(ret, DMError::DM_OK);
1274     } else {
1275         ASSERT_NE(ret, DMError::DM_OK);
1276     }
1277     GTEST_LOG_(INFO) << "ScreenSessionTest: GetScreenSupportedColorGamuts end";
1278 }
1279 
1280 /**
1281  * @tc.name: GetActiveScreenMode
1282  * @tc.desc: normal function
1283  * @tc.type: FUNC
1284  */
1285 HWTEST_F(ScreenSessionTest, GetActiveScreenMode, Function | SmallTest | Level2)
1286 {
1287     GTEST_LOG_(INFO) << "ScreenSessionTest: GetActiveScreenMode start";
1288     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1289     session->activeIdx_ = -1;
1290     sptr<SupportedScreenModes> mode1 = session->GetActiveScreenMode();
1291     session->GetActiveScreenMode();
1292     ASSERT_EQ(mode1, nullptr);
1293 
1294     session->activeIdx_ = 100;
1295     sptr<SupportedScreenModes> mode2 = session->GetActiveScreenMode();
1296     session->GetActiveScreenMode();
1297     ASSERT_EQ(mode2, nullptr);
1298 
1299     GTEST_LOG_(INFO) << "ScreenSessionTest: GetActiveScreenMode end";
1300 }
1301 
1302 /**
1303  * @tc.name: SetScreenCombination
1304  * @tc.desc: normal function
1305  * @tc.type: FUNC
1306  */
1307 HWTEST_F(ScreenSessionTest, SetScreenCombination, Function | SmallTest | Level2)
1308 {
1309     GTEST_LOG_(INFO) << "ScreenSessionTest: SetScreenCombination start";
1310     ScreenId screenId = 2024;
1311     ScreenProperty property;
1312     NodeId nodeId = 0;
1313     ScreenId defaultScreenId = 0;
1314     ScreenCombination combination { ScreenCombination::SCREEN_ALONE };
1315     sptr<ScreenSession> session = new(std::nothrow) ScreenSession(screenId, property, nodeId, defaultScreenId);
1316     session->SetScreenCombination(combination);
1317     EXPECT_NE(session, nullptr);
1318     EXPECT_EQ(combination, session->GetScreenCombination());
1319     GTEST_LOG_(INFO) << "ScreenSessionTest: SetScreenCombination end";
1320 }
1321 
1322 /**
1323  * @tc.name: GetScreenColorGamut
1324  * @tc.desc: normal function
1325  * @tc.type: FUNC
1326  */
1327 HWTEST_F(ScreenSessionTest, GetScreenColorGamut, Function | SmallTest | Level2)
1328 {
1329     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
1330         GTEST_SKIP() << "SceneBoard is not enabled, skipping test.";
1331     }
1332 #ifdef WM_SCREEN_COLOR_GAMUT_ENABLE
1333     GTEST_LOG_(INFO) << "ScreenSessionTest: GetScreenColorGamut start";
1334     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1335     ASSERT_NE(session, nullptr);
1336 
1337     ScreenColorGamut colorGamut;
1338     DMError res = session->GetScreenColorGamut(colorGamut);
1339     if (SceneBoardJudgement::IsSceneBoardEnabled()) {
1340         ASSERT_EQ(res, DMError::DM_OK);
1341     } else {
1342         ASSERT_NE(res, DMError::DM_OK);
1343     }
1344     GTEST_LOG_(INFO) << "ScreenSessionTest: GetScreenColorGamut end";
1345 #endif
1346 }
1347 
1348 /**
1349  * @tc.name: SetScreenColorGamut01
1350  * @tc.desc: normal function
1351  * @tc.type: FUNC
1352  */
1353 HWTEST_F(ScreenSessionTest, SetScreenColorGamut01, Function | SmallTest | Level2)
1354 {
1355     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
1356         GTEST_SKIP() << "SceneBoard is not enabled, skipping test.";
1357     }
1358 #ifdef WM_SCREEN_COLOR_GAMUT_ENABLE
1359     GTEST_LOG_(INFO) << "ScreenSessionTest: SetScreenColorGamut start";
1360     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1361     ASSERT_NE(session, nullptr);
1362 
1363     int32_t colorGamut = 1;
1364     DMError res = session->SetScreenColorGamut(colorGamut);
1365     ASSERT_EQ(res, DMError::DM_ERROR_RENDER_SERVICE_FAILED);
1366     GTEST_LOG_(INFO) << "ScreenSessionTest: SetScreenColorGamut end";
1367 #endif
1368 }
1369 
1370 /**
1371  * @tc.name: SetScreenColorGamut02
1372  * @tc.desc: normal function
1373  * @tc.type: FUNC
1374  */
1375 HWTEST_F(ScreenSessionTest, SetScreenColorGamut02, Function | SmallTest | Level2)
1376 {
1377     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
1378         GTEST_SKIP() << "SceneBoard is not enabled, skipping test.";
1379     }
1380 #ifdef WM_SCREEN_COLOR_GAMUT_ENABLE
1381     GTEST_LOG_(INFO) << "ScreenSessionTest: SetScreenColorGamut start";
1382     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1383     ASSERT_NE(session, nullptr);
1384 
1385     int32_t colorGamut = -1;
1386     DMError res = session->SetScreenColorGamut(colorGamut);
1387     ASSERT_EQ(res, DMError::DM_ERROR_INVALID_PARAM);
1388     GTEST_LOG_(INFO) << "ScreenSessionTest: SetScreenColorGamut end";
1389 #endif
1390 }
1391 
1392 /**
1393  * @tc.name: GetScreenGamutMap
1394  * @tc.desc: normal function
1395  * @tc.type: FUNC
1396  */
1397 HWTEST_F(ScreenSessionTest, GetScreenGamutMap, Function | SmallTest | Level2)
1398 {
1399 #ifdef WM_SCREEN_COLOR_GAMUT_ENABLE
1400     GTEST_LOG_(INFO) << "ScreenSessionTest: GetScreenGamutMap start";
1401     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1402     ASSERT_NE(session, nullptr);
1403 
1404     ScreenGamutMap gamutMap;
1405     DMError res = session->GetScreenGamutMap(gamutMap);
1406     ASSERT_EQ(res, DMError::DM_ERROR_RENDER_SERVICE_FAILED);
1407     GTEST_LOG_(INFO) << "ScreenSessionTest: GetScreenGamutMap end";
1408 #endif
1409 }
1410 
1411 /**
1412  * @tc.name: SetScreenGamutMap
1413  * @tc.desc: normal function
1414  * @tc.type: FUNC
1415  */
1416 HWTEST_F(ScreenSessionTest, SetScreenGamutMap, Function | SmallTest | Level2)
1417 {
1418 #ifdef WM_SCREEN_COLOR_GAMUT_ENABLE
1419     GTEST_LOG_(INFO) << "ScreenSessionTest: SetScreenGamutMap start";
1420     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1421     ASSERT_NE(session, nullptr);
1422     ScreenGamutMap gamutMap = GAMUT_MAP_CONSTANT;
1423     DMError res = session->SetScreenGamutMap(gamutMap);
1424     ASSERT_EQ(res, DMError::DM_ERROR_RENDER_SERVICE_FAILED);
1425 
1426     gamutMap = GAMUT_MAP_HDR_EXTENSION;
1427     res = session->SetScreenGamutMap(gamutMap);
1428     ASSERT_EQ(res, DMError::DM_ERROR_RENDER_SERVICE_FAILED);
1429     GTEST_LOG_(INFO) << "ScreenSessionTest: SetScreenGamutMap end";
1430 #endif
1431 }
1432 
1433 /**
1434  * @tc.name: InitRSDisplayNode
1435  * @tc.desc: normal function
1436  * @tc.type: FUNC
1437  */
1438 HWTEST_F(ScreenSessionTest, InitRSDisplayNode, Function | SmallTest | Level2)
1439 {
1440     GTEST_LOG_(INFO) << "ScreenSessionTest: InitRSDisplayNode start";
1441     ScreenSessionGroup sessionGroup(1, 1, "create", ScreenCombination::SCREEN_ALONE);
1442     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1443     ASSERT_NE(session, nullptr);
1444     RSDisplayNodeConfig config;
1445     Point startPoint;
1446     int res = 0;
1447     sessionGroup.InitRSDisplayNode(config, startPoint);
1448     ASSERT_EQ(res, 0);
1449     GTEST_LOG_(INFO) << "ScreenSessionTest: InitRSDisplayNode end";
1450 }
1451 
1452 /**
1453  * @tc.name: GetRSDisplayNodeConfig
1454  * @tc.desc: normal function
1455  * @tc.type: FUNC
1456  */
1457 HWTEST_F(ScreenSessionTest, GetRSDisplayNodeConfig, Function | SmallTest | Level2)
1458 {
1459     GTEST_LOG_(INFO) << "ScreenSessionTest: GetRSDisplayNodeConfig start";
1460     ScreenSessionGroup sessionGroup(1, 1, "create", ScreenCombination::SCREEN_ALONE);
1461     sptr<ScreenSession> session0 = nullptr;
1462     RSDisplayNodeConfig config = {1};
1463     sptr<ScreenSession> defaultScreenSession;
1464     bool res = sessionGroup.GetRSDisplayNodeConfig(session0, config, defaultScreenSession);
1465     ASSERT_EQ(res, false);
1466 
1467     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1468     sessionGroup.combination_ = ScreenCombination::SCREEN_ALONE;
1469     res = sessionGroup.GetRSDisplayNodeConfig(session, config, defaultScreenSession);
1470     ASSERT_EQ(res, true);
1471 
1472     sessionGroup.combination_ = ScreenCombination::SCREEN_EXPAND;
1473     res = sessionGroup.GetRSDisplayNodeConfig(session, config, defaultScreenSession);
1474     ASSERT_EQ(res, true);
1475 
1476     sessionGroup.combination_ = ScreenCombination::SCREEN_MIRROR;
1477     res = sessionGroup.GetRSDisplayNodeConfig(session, config, defaultScreenSession);
1478     ASSERT_EQ(res, true);
1479     GTEST_LOG_(INFO) << "ScreenSessionTest: GetRSDisplayNodeConfig end";
1480 }
1481 
1482 /**
1483  * @tc.name: AddChild
1484  * @tc.desc: normal function
1485  * @tc.type: FUNC
1486  */
1487 HWTEST_F(ScreenSessionTest, AddChild, Function | SmallTest | Level2)
1488 {
1489     GTEST_LOG_(INFO) << "ScreenSessionTest: AddChild start";
1490     ScreenSessionGroup sessionGroup(1, 1, "create", ScreenCombination::SCREEN_ALONE);
1491     sptr<ScreenSession> session0 = nullptr;
1492     Point startPoint(0, 0);
1493     sptr<ScreenSession> defaultScreenSession;
1494     bool res = sessionGroup.AddChild(session0, startPoint, defaultScreenSession);
1495     ASSERT_EQ(res, false);
1496 
1497     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1498     res = sessionGroup.AddChild(session, startPoint, defaultScreenSession);
1499     ASSERT_EQ(res, true);
1500     GTEST_LOG_(INFO) << "ScreenSessionTest: AddChild end";
1501 }
1502 
1503 /**
1504  * @tc.name: AddChildren01
1505  * @tc.desc: normal function
1506  * @tc.type: FUNC
1507  */
1508 HWTEST_F(ScreenSessionTest, AddChildren01, Function | SmallTest | Level2)
1509 {
1510     GTEST_LOG_(INFO) << "ScreenSessionTest: AddChildren start";
1511     ScreenSessionGroup sessionGroup(1, 1, "create", ScreenCombination::SCREEN_ALONE);
1512     std::vector<sptr<ScreenSession>> smsScreens;
1513     std::vector<Point> startPoints;
1514     bool res = sessionGroup.AddChildren(smsScreens, startPoints);
1515     ASSERT_EQ(res, true);
1516     GTEST_LOG_(INFO) << "ScreenSessionTest: AddChildren end";
1517 }
1518 
1519 /**
1520  * @tc.name: AddChildren02
1521  * @tc.desc: normal function
1522  * @tc.type: FUNC
1523  */
1524 HWTEST_F(ScreenSessionTest, AddChildren02, Function | SmallTest | Level2)
1525 {
1526     GTEST_LOG_(INFO) << "ScreenSessionTest: AddChildren start";
1527     ScreenSessionGroup sessionGroup(1, 1, "create", ScreenCombination::SCREEN_ALONE);
1528     std::vector<sptr<ScreenSession>> smsScreens(2);
1529     std::vector<Point> startPoints(1);
1530     bool res = sessionGroup.AddChildren(smsScreens, startPoints);
1531     ASSERT_EQ(res, false);
1532     GTEST_LOG_(INFO) << "ScreenSessionTest: AddChildren end";
1533 }
1534 
1535 /**
1536  * @tc.name: RemoveChild
1537  * @tc.desc: normal function
1538  * @tc.type: FUNC
1539  */
1540 HWTEST_F(ScreenSessionTest, RemoveChild, Function | SmallTest | Level2)
1541 {
1542     GTEST_LOG_(INFO) << "ScreenSessionTest: RemoveChild start";
1543     ScreenSessionGroup sessionGroup(1, 1, "create", ScreenCombination::SCREEN_ALONE);
1544     sptr<ScreenSession> session0 = nullptr;
1545     bool res = sessionGroup.RemoveChild(session0);
1546     ASSERT_EQ(res, false);
1547 
1548     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1549     res = sessionGroup.RemoveChild(session);
1550     ASSERT_EQ(res, false);
1551     GTEST_LOG_(INFO) << "ScreenSessionTest: GetRSDisplayNodeConfig end";
1552 }
1553 
1554 /**
1555  * @tc.name: GetChildPosition
1556  * @tc.desc: normal function
1557  * @tc.type: FUNC
1558  */
1559 HWTEST_F(ScreenSessionTest, GetChildPosition, Function | SmallTest | Level2)
1560 {
1561     GTEST_LOG_(INFO) << "ScreenSessionTest: GetChildPosition start";
1562     ScreenSessionGroup sessionGroup(1, 1, "create", ScreenCombination::SCREEN_ALONE);
1563     ScreenId screenId = 1;
1564     Point res = sessionGroup.GetChildPosition(screenId);
1565     ASSERT_EQ(res.posX_, 0);
1566     GTEST_LOG_(INFO) << "ScreenSessionTest: GetChildPosition end";
1567 }
1568 
1569 /**
1570  * @tc.name: ConvertToScreenGroupInfo
1571  * @tc.desc: normal function
1572  * @tc.type: FUNC
1573  */
1574 HWTEST_F(ScreenSessionTest, ConvertToScreenGroupInfo, Function | SmallTest | Level2)
1575 {
1576     GTEST_LOG_(INFO) << "ScreenSessionTest: ConvertToScreenGroupInfo start";
1577     ScreenSessionGroup sessionGroup(1, 1, "create", ScreenCombination::SCREEN_ALONE);
1578     sptr<ScreenGroupInfo> res = sessionGroup.ConvertToScreenGroupInfo();
1579     ASSERT_NE(res, nullptr);
1580     GTEST_LOG_(INFO) << "ScreenSessionTest: ConvertToScreenGroupInfo end";
1581 }
1582 
1583 /**
1584  * @tc.name: RegisterScreenChangeListener
1585  * @tc.desc: normal function
1586  * @tc.type: FUNC
1587  */
1588 HWTEST_F(ScreenSessionTest, RegisterScreenChangeListener01, Function | SmallTest | Level2)
1589 {
1590     GTEST_LOG_(INFO) << "ScreenSessionTest: RegisterScreenChangeListener start";
1591     int res = 0;
1592     IScreenChangeListener* screenChangeListener = nullptr;
1593     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1594     session->RegisterScreenChangeListener(screenChangeListener);
1595     ASSERT_EQ(res, 0);
1596     GTEST_LOG_(INFO) << "ScreenSessionTest: RegisterScreenChangeListener end";
1597 }
1598 
1599 /**
1600  * @tc.name: RegisterScreenChangeListener
1601  * @tc.desc: Repeat to register
1602  * @tc.type: FUNC
1603  */
1604 HWTEST_F(ScreenSessionTest, RegisterScreenChangeListener02, Function | SmallTest | Level2)
1605 {
1606     GTEST_LOG_(INFO) << "ScreenSessionTest: RegisterScreenChangeListener start";
1607     IScreenChangeListener* screenChangeListener = new MockScreenChangeListener();
1608     IScreenChangeListener* screenChangeListener1 = new MockScreenChangeListener();
1609     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1610     session->RegisterScreenChangeListener(screenChangeListener);
1611     session->RegisterScreenChangeListener(screenChangeListener1);
1612     ASSERT_FALSE(session->isFold_);
1613 }
1614 
1615 /**
1616  * @tc.name: RegisterScreenChangeListener
1617  * @tc.desc: screenState_ == ScreenState::CONNECTION
1618  * @tc.type: FUNC
1619  */
1620 HWTEST_F(ScreenSessionTest, RegisterScreenChangeListener03, Function | SmallTest | Level2)
1621 {
1622     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1623     ASSERT_EQ(session->screenState_, ScreenState::INIT);
1624     session->screenState_ = ScreenState::CONNECTION;
1625     IScreenChangeListener* screenChangeListener = new MockScreenChangeListener();
1626     session->RegisterScreenChangeListener(screenChangeListener);
1627     ASSERT_FALSE(session->isFold_);
1628     session->screenState_ = ScreenState::INIT;
1629 }
1630 
1631 /**
1632  * @tc.name: Connect
1633  * @tc.desc: Connect
1634  * @tc.type: FUNC
1635  */
1636 HWTEST_F(ScreenSessionTest, Connect, Function | SmallTest | Level2)
1637 {
1638     IScreenChangeListener* screenChangeListener = new MockScreenChangeListener();
1639     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1640     session->RegisterScreenChangeListener(screenChangeListener);
1641     session->Connect();
1642     ASSERT_FALSE(session->isFold_);
1643 }
1644 
1645 /**
1646  * @tc.name: UpdatePropertyByActiveMode
1647  * @tc.desc: normal function
1648  * @tc.type: FUNC
1649  */
1650 HWTEST_F(ScreenSessionTest, UpdatePropertyByActiveMode, Function | SmallTest | Level2)
1651 {
1652     GTEST_LOG_(INFO) << "ScreenSessionTest: UpdatePropertyByActiveMode start";
1653     int res = 0;
1654     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1655     session->UpdatePropertyByActiveMode();
1656     ASSERT_EQ(res, 0);
1657     GTEST_LOG_(INFO) << "ScreenSessionTest: UpdatePropertyByActiveMode end";
1658 }
1659 
1660 /**
1661  * @tc.name: Disconnect
1662  * @tc.desc: normal function
1663  * @tc.type: FUNC
1664  */
1665 HWTEST_F(ScreenSessionTest, Disconnect, Function | SmallTest | Level2)
1666 {
1667     GTEST_LOG_(INFO) << "ScreenSessionTest: Disconnect start";
1668     int res = 0;
1669     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1670     session->Disconnect();
1671     ASSERT_EQ(res, 0);
1672     GTEST_LOG_(INFO) << "ScreenSessionTest: Disconnect end";
1673 }
1674 
1675 /**
1676  * @tc.name: Disconnect
1677  * @tc.desc: !listener
1678  * @tc.type: FUNC
1679  */
1680 HWTEST_F(ScreenSessionTest, Disconnect02, Function | SmallTest | Level2)
1681 {
1682     IScreenChangeListener* screenChangeListener = new MockScreenChangeListener();
1683     IScreenChangeListener* screenChangeListener1 = new MockScreenChangeListener();
1684     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1685     sptr<ScreenSession> session1 = new(std::nothrow) ScreenSession();
1686     session->RegisterScreenChangeListener(screenChangeListener);
1687     session1->RegisterScreenChangeListener(screenChangeListener1);
1688     session1->Connect();
1689     session1->Disconnect();
1690     ASSERT_FALSE(session->isFold_);
1691 }
1692 
1693 /**
1694  * @tc.name: SensorRotationChange
1695  * @tc.desc: normal function
1696  * @tc.type: FUNC
1697  */
1698 HWTEST_F(ScreenSessionTest, SensorRotationChange01, Function | SmallTest | Level2)
1699 {
1700     GTEST_LOG_(INFO) << "ScreenSessionTest: SensorRotationChange start";
1701     int res = 0;
1702     Rotation sensorRotation = Rotation::ROTATION_0;
1703     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1704     session->SensorRotationChange(sensorRotation);
1705     ASSERT_EQ(res, 0);
1706     GTEST_LOG_(INFO) << "ScreenSessionTest: SensorRotationChange end";
1707 }
1708 
1709 /**
1710  * @tc.name: SensorRotationChange
1711  * @tc.desc: run in for
1712  * @tc.type: FUNC
1713  */
1714 HWTEST_F(ScreenSessionTest, SensorRotationChange02, Function | SmallTest | Level2)
1715 {
1716     IScreenChangeListener* screenChangeListener = new MockScreenChangeListener();
1717     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1718     session->RegisterScreenChangeListener(screenChangeListener);
1719     Rotation sensorRotation = Rotation::ROTATION_90;
1720     session->SensorRotationChange(sensorRotation);
1721     ASSERT_FALSE(session->isFold_);
1722 }
1723 
1724 /**
1725  * @tc.name: SetOrientation
1726  * @tc.desc: normal function
1727  * @tc.type: FUNC
1728  */
1729 HWTEST_F(ScreenSessionTest, SetOrientation, Function | SmallTest | Level2)
1730 {
1731     GTEST_LOG_(INFO) << "ScreenSessionTest: SetOrientation start";
1732     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1733     Orientation orientation = Orientation::UNSPECIFIED;
1734     session->SetOrientation(orientation);
1735     Orientation res = session->GetOrientation();
1736     ASSERT_EQ(res, orientation);
1737     GTEST_LOG_(INFO) << "ScreenSessionTest: SetOrientation end";
1738 }
1739 
1740 /**
1741  * @tc.name: SetScreenRequestedOrientation
1742  * @tc.desc: normal function
1743  * @tc.type: FUNC
1744  */
1745 HWTEST_F(ScreenSessionTest, SetScreenRequestedOrientation, Function | SmallTest | Level2)
1746 {
1747     GTEST_LOG_(INFO) << "ScreenSessionTest: SetScreenRequestedOrientation start";
1748     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1749     Orientation orientation = Orientation::UNSPECIFIED;
1750     session->SetScreenRequestedOrientation(orientation);
1751     Orientation res = session->GetScreenRequestedOrientation();
1752     ASSERT_EQ(res, orientation);
1753     GTEST_LOG_(INFO) << "ScreenSessionTest: SetScreenRequestedOrientation end";
1754 }
1755 
1756 /**
1757  * @tc.name: SetUpdateToInputManagerCallback
1758  * @tc.desc: normal function
1759  * @tc.type: FUNC
1760  */
1761 HWTEST_F(ScreenSessionTest, SetUpdateToInputManagerCallback, Function | SmallTest | Level2)
1762 {
1763     GTEST_LOG_(INFO) << "ScreenSessionTest: SetUpdateToInputManagerCallback start";
1764     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
__anon0ae6727f0402(float x) 1765     auto func = [session](float x) {
1766         session->SetVirtualPixelRatio(x);
1767     };
1768     session->SetUpdateToInputManagerCallback(func);
1769     EXPECT_NE(nullptr, &func);
1770 
1771     ScreenProperty screenPropert = session->GetScreenProperty();
1772     EXPECT_NE(nullptr, &screenPropert);
1773     session->SetVirtualPixelRatio(3.14);
1774 
1775     ScreenType screenType { ScreenType::REAL };
1776     session->SetScreenType(screenType);
1777 
1778     GTEST_LOG_(INFO) << "ScreenSessionTest: SetUpdateToInputManagerCallbackend";
1779 }
1780 
1781 /**
1782  * @tc.name: SetScreenRotationLocked
1783  * @tc.desc: normal function
1784  * @tc.type: FUNC
1785  */
1786 HWTEST_F(ScreenSessionTest, SetScreenRotationLocked, Function | SmallTest | Level2)
1787 {
1788     GTEST_LOG_(INFO) << "ScreenSessionTest: SetScreenRotationLocked start";
1789     bool isLocked = true;
1790     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1791     session->SetScreenRotationLocked(isLocked);
1792     bool res = session->IsScreenRotationLocked();
1793     ASSERT_EQ(res, isLocked);
1794     GTEST_LOG_(INFO) << "ScreenSessionTest: SetScreenRotationLocked end";
1795 }
1796 
1797 /**
1798  * @tc.name: SetScreenRotationLockedFromJs
1799  * @tc.desc: normal function
1800  * @tc.type: FUNC
1801  */
1802 HWTEST_F(ScreenSessionTest, SetScreenRotationLockedFromJs, Function | SmallTest | Level2)
1803 {
1804     GTEST_LOG_(INFO) << "ScreenSessionTest: SetScreenRotationLockedFromJs start";
1805     bool isLocked = true;
1806     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1807     session->SetScreenRotationLockedFromJs(isLocked);
1808     bool res = session->IsScreenRotationLocked();
1809     ASSERT_EQ(res, isLocked);
1810     GTEST_LOG_(INFO) << "ScreenSessionTest: SetScreenRotationLockedFromJs end";
1811 }
1812 
1813 /**
1814  * @tc.name: IsScreenRotationLocked
1815  * @tc.desc: normal function
1816  * @tc.type: FUNC
1817  */
1818 HWTEST_F(ScreenSessionTest, IsScreenRotationLocked, Function | SmallTest | Level2)
1819 {
1820     GTEST_LOG_(INFO) << "ScreenSessionTest: IsScreenRotationLocked start";
1821     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1822     bool res = session->IsScreenRotationLocked();
1823     ASSERT_EQ(res, session->isScreenLocked_);
1824     GTEST_LOG_(INFO) << "ScreenSessionTest: IsScreenRotationLocked end";
1825 }
1826 
1827 /**
1828  * @tc.name: GetScreenRequestedOrientation
1829  * @tc.desc: normal function
1830  * @tc.type: FUNC
1831  */
1832 HWTEST_F(ScreenSessionTest, GetScreenRequestedOrientation, Function | SmallTest | Level2)
1833 {
1834     GTEST_LOG_(INFO) << "ScreenSessionTest: GetScreenRequestedOrientation start";
1835     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1836     Orientation res = session->GetScreenRequestedOrientation();
1837     ASSERT_EQ(res, session->property_.GetScreenRequestedOrientation());
1838     GTEST_LOG_(INFO) << "ScreenSessionTest: GetScreenRequestedOrientation end";
1839 }
1840 
1841 /**
1842  * @tc.name: SetVirtualPixelRatio
1843  * @tc.desc: normal function
1844  * @tc.type: FUNC
1845  */
1846 HWTEST_F(ScreenSessionTest, SetVirtualPixelRatio, Function | SmallTest | Level2)
1847 {
1848     GTEST_LOG_(INFO) << "ScreenSessionTest: SetVirtualPixelRatio start";
1849     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1850     float virtualPixelRatio = 1;
1851     session->SetVirtualPixelRatio(virtualPixelRatio);
1852     float res = session->property_.GetVirtualPixelRatio();
1853     ASSERT_EQ(res, virtualPixelRatio);
1854     GTEST_LOG_(INFO) << "ScreenSessionTest: SetVirtualPixelRatio end";
1855 }
1856 
1857 /**
1858  * @tc.name: screen_session_test001
1859  * @tc.desc: normal function
1860  * @tc.type: FUNC
1861  */
1862 HWTEST_F(ScreenSessionTest, screen_session_test001, Function | SmallTest | Level2)
1863 {
1864     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test001 start";
1865     IScreenChangeListener* screenChangeListener = nullptr;
1866     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1867     session->screenState_ = ScreenState::CONNECTION;
1868     int res = 0;
1869     session->RegisterScreenChangeListener(screenChangeListener);
1870     ASSERT_EQ(res, 0);
1871     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test001 end";
1872 }
1873 
1874 /**
1875  * @tc.name: screen_session_test002
1876  * @tc.desc: normal function
1877  * @tc.type: FUNC
1878  */
1879 HWTEST_F(ScreenSessionTest, screen_session_test002, Function | SmallTest | Level2)
1880 {
1881     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test002 start";
1882     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1883     ScreenId res = session->GetScreenId();
1884     ASSERT_EQ(res, session->screenId_);
1885     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test002 end";
1886 }
1887 
1888 /**
1889  * @tc.name: screen_session_test003
1890  * @tc.desc: normal function
1891  * @tc.type: FUNC
1892  */
1893 HWTEST_F(ScreenSessionTest, screen_session_test003, Function | SmallTest | Level2)
1894 {
1895     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test003 start";
1896     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1897     DMError res = session->SetScreenColorTransform();
1898     ASSERT_EQ(res, DMError::DM_OK);
1899     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test003 end";
1900 }
1901 
1902 /**
1903  * @tc.name: screen_session_test004
1904  * @tc.desc: normal function
1905  * @tc.type: FUNC
1906  */
1907 HWTEST_F(ScreenSessionTest, screen_session_test004, Function | SmallTest | Level2)
1908 {
1909     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test004 start";
1910     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1911     ScreenProperty newProperty;
1912     int res = 0;
1913     session->UpdatePropertyByFoldControl(newProperty);
1914     ASSERT_EQ(res, 0);
1915     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test004 end";
1916 }
1917 
1918 /**
1919  * @tc.name: screen_session_test005
1920  * @tc.desc: normal function
1921  * @tc.type: FUNC
1922  */
1923 HWTEST_F(ScreenSessionTest, screen_session_test005, Function | SmallTest | Level2)
1924 {
1925     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test005 start";
1926     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1927     ScreenProperty newProperty;
1928     ScreenPropertyChangeReason reason = ScreenPropertyChangeReason::CHANGE_MODE;
1929     int res = 0;
1930     session->PropertyChange(newProperty, reason);
1931     ASSERT_EQ(res, 0);
1932     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test005 end";
1933 }
1934 
1935 /**
1936  * @tc.name: screen_session_test006
1937  * @tc.desc: normal function
1938  * @tc.type: FUNC
1939  */
1940 HWTEST_F(ScreenSessionTest, screen_session_test006, Function | SmallTest | Level2)
1941 {
1942     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test006 start";
1943     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1944     Rotation sensorRotation = Rotation::ROTATION_90;
1945     float res = session->ConvertRotationToFloat(sensorRotation);
1946     ASSERT_EQ(res, 90.f);
1947     sensorRotation = Rotation::ROTATION_180;
1948     res = session->ConvertRotationToFloat(sensorRotation);
1949     ASSERT_EQ(res, 180.f);
1950     sensorRotation = Rotation::ROTATION_270;
1951     res = session->ConvertRotationToFloat(sensorRotation);
1952     ASSERT_EQ(res, 270.f);
1953     sensorRotation = Rotation::ROTATION_0;
1954     res = session->ConvertRotationToFloat(sensorRotation);
1955     ASSERT_EQ(res, 0.f);
1956     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test006 end";
1957 }
1958 
1959 /**
1960  * @tc.name: screen_session_test007
1961  * @tc.desc: normal function
1962  * @tc.type: FUNC
1963  */
1964 HWTEST_F(ScreenSessionTest, screen_session_test007, Function | SmallTest | Level2)
1965 {
1966     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test007 start";
1967     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1968     Orientation orientation = Orientation::UNSPECIFIED;
1969     int res = 0;
1970     session->ScreenOrientationChange(orientation, FoldDisplayMode::UNKNOWN);
1971     ASSERT_EQ(res, 0);
1972     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test007 end";
1973 }
1974 
1975 /**
1976  * @tc.name: screen_session_test008
1977  * @tc.desc: normal function
1978  * @tc.type: FUNC
1979  */
1980 HWTEST_F(ScreenSessionTest, screen_session_test008, Function | SmallTest | Level2)
1981 {
1982     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test008 start";
1983     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1984     bool res = session->HasPrivateSessionForeground();
1985     ASSERT_EQ(res, false);
1986     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test008 end";
1987 }
1988 
1989 /**
1990  * @tc.name: screen_session_test009
1991  * @tc.desc: normal function
1992  * @tc.type: FUNC
1993  */
1994 HWTEST_F(ScreenSessionTest, screen_session_test009, Function | SmallTest | Level2)
1995 {
1996     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test009 start";
1997     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
1998     Rotation rotation = Rotation::ROTATION_90;
1999     session->SetRotation(rotation);
2000     Rotation res = session->GetRotation();
2001     ASSERT_EQ(res, rotation);
2002     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test009 end";
2003 }
2004 
2005 /**
2006  * @tc.name: screen_session_test010
2007  * @tc.desc: normal function
2008  * @tc.type: FUNC
2009  */
2010 HWTEST_F(ScreenSessionTest, screen_session_test010, Function | SmallTest | Level2)
2011 {
2012     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test010 start";
2013     ScreenSessionGroup sessionGroup(1, 1, "create", ScreenCombination::SCREEN_ALONE);
2014     ScreenId childScreen = 1;
2015     bool res = sessionGroup.HasChild(childScreen);
2016     ASSERT_EQ(res, false);
2017     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test010 end";
2018 }
2019 
2020 /**
2021  * @tc.name: screen_session_test011
2022  * @tc.desc: normal function
2023  * @tc.type: FUNC
2024  */
2025 HWTEST_F(ScreenSessionTest, screen_session_test011, Function | SmallTest | Level2)
2026 {
2027     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test011 start";
2028     ScreenSessionGroup sessionGroup(1, 1, "create", ScreenCombination::SCREEN_ALONE);
2029     std::vector<sptr<ScreenSession>> res = sessionGroup.GetChildren();
2030     ASSERT_EQ(res.empty(), true);
2031     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test011 end";
2032 }
2033 
2034 /**
2035  * @tc.name: screen_session_test012
2036  * @tc.desc: normal function
2037  * @tc.type: FUNC
2038  */
2039 HWTEST_F(ScreenSessionTest, screen_session_test012, Function | SmallTest | Level2)
2040 {
2041     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test012 start";
2042     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
2043     int res = 0;
2044     RectF rect = RectF(0, 0, 0, 0);
2045     uint32_t offsetY = 0;
2046     session->SetDisplayBoundary(rect, offsetY);
2047     ASSERT_EQ(res, 0);
2048     GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test012 end";
2049 }
2050 
2051 /**
2052  * @tc.name: GetName
2053  * @tc.desc: normal function
2054  * @tc.type: FUNC
2055  */
2056 HWTEST_F(ScreenSessionTest, GetName, Function | SmallTest | Level2)
2057 {
2058     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
2059         GTEST_SKIP() << "SceneBoard is not enabled, skipping test.";
2060     }
2061     GTEST_LOG_(INFO) << "ScreenSessionTest: GetName start";
2062     std::string name { "UNKNOW" };
2063     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
2064     ASSERT_EQ(name, session->GetName());
2065     GTEST_LOG_(INFO) << "ScreenSessionTest: GetName end";
2066 }
2067 
2068 /**
2069  * @tc.name: SetName
2070  * @tc.desc: normal function
2071  * @tc.type: FUNC
2072  */
2073 HWTEST_F(ScreenSessionTest, SetName, Function | SmallTest | Level2)
2074 {
2075     GTEST_LOG_(INFO) << "ScreenSessionTest: SetName start";
2076     std::string name { "UNKNOWN" };
2077     int ret = 0;
2078     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
2079     session->SetName(name);
2080     ASSERT_EQ(ret, 0);
2081     GTEST_LOG_(INFO) << "ScreenSessionTest: SetName end";
2082 }
2083 
2084 /**
2085  * @tc.name: GetScreenSnapshot
2086  * @tc.desc: normal function
2087  * @tc.type: FUNC
2088  */
2089 HWTEST_F(ScreenSessionTest, GetScreenSnapshot, Function | SmallTest | Level2)
2090 {
2091     GTEST_LOG_(INFO) << "ScreenSessionTest: GetScreenSnapshot start";
2092     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
2093     session->displayNode_ = nullptr;
2094     auto pixelmap = session->GetScreenSnapshot(1.0, 1.0);
2095     EXPECT_EQ(pixelmap, nullptr);
2096 
2097     ScreenProperty newScreenProperty;
2098     session = new(std::nothrow) ScreenSession(0, newScreenProperty, 0);
2099     pixelmap = session->GetScreenSnapshot(1.0, 1.0);
2100     int ret = 0;
2101     ASSERT_EQ(ret, 0);
2102     GTEST_LOG_(INFO) << "ScreenSessionTest: GetScreenSnapshot end";
2103 }
2104 
2105 /**
2106  * @tc.name: GetRSScreenId
2107  * @tc.desc: normal function
2108  * @tc.type: FUNC
2109  */
2110 HWTEST_F(ScreenSessionTest, GetRSScreenId, Function | SmallTest | Level2)
2111 {
2112     GTEST_LOG_(INFO) << "ScreenSessionTest: GetRSScreenId start";
2113     ScreenProperty property;
2114     sptr<ScreenSession> session = new(std::nothrow)
2115         ScreenSession("OpenHarmony", 1, 100, 0);
2116     EXPECT_EQ(100, session->GetRSScreenId());
2117 
2118     RSDisplayNodeConfig displayNodeConfig;
2119     std::shared_ptr<RSDisplayNode> displayNode = RSDisplayNode::Create(displayNodeConfig);
2120     session = new ScreenSession(1, 100, "OpenHarmony",
2121         property, displayNode);
2122     EXPECT_NE(nullptr, session->GetDisplayNode());
2123     session->ReleaseDisplayNode();
2124     EXPECT_EQ(nullptr, session->GetDisplayNode());
2125     GTEST_LOG_(INFO) << "ScreenSessionTest: GetRSScreenId end";
2126 }
2127 
2128 /**
2129  * @tc.name: CalcRotation01
2130  * @tc.desc: normal function
2131  * @tc.type: FUNC
2132  */
2133 HWTEST_F(ScreenSessionTest, CalcRotation01, Function | SmallTest | Level2)
2134 {
2135     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
2136         GTEST_SKIP() << "SceneBoard is not enabled, skipping test.";
2137     }
2138     Orientation orientation { Orientation::BEGIN };
2139     FoldDisplayMode foldDisplayMode { FoldDisplayMode::COORDINATION };
2140     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
2141     session->activeIdx_ = -1;
2142     auto res = session->CalcRotation(orientation, foldDisplayMode);
2143     EXPECT_EQ(Rotation::ROTATION_0, res);
2144     sptr<SupportedScreenModes> supportedScreenModes = new SupportedScreenModes;
2145     supportedScreenModes->width_ = 40;
2146     supportedScreenModes->height_ = 20;
2147     session->modes_ = { supportedScreenModes };
2148     session->activeIdx_ = 0;
2149     orientation = Orientation::UNSPECIFIED;
2150     res = session->CalcRotation(orientation, foldDisplayMode);
2151     EXPECT_EQ(Rotation::ROTATION_0, res);
2152 
2153     orientation = Orientation::VERTICAL;
2154     res = session->CalcRotation(orientation, foldDisplayMode);
2155     if (ScreenSessionManager::GetInstance().IsFoldable()) {
2156         EXPECT_EQ(Rotation::ROTATION_0, res);
2157     } else {
2158         EXPECT_EQ(Rotation::ROTATION_90, res);
2159     }
2160 
2161     orientation = Orientation::HORIZONTAL;
2162     res = session->CalcRotation(orientation, foldDisplayMode);
2163     if (ScreenSessionManager::GetInstance().IsFoldable()) {
2164         EXPECT_EQ(Rotation::ROTATION_90, res);
2165     } else {
2166         EXPECT_EQ(Rotation::ROTATION_0, res);
2167     }
2168 
2169     orientation = Orientation::REVERSE_VERTICAL;
2170     res = session->CalcRotation(orientation, foldDisplayMode);
2171     if (ScreenSessionManager::GetInstance().IsFoldable()) {
2172         EXPECT_EQ(Rotation::ROTATION_180, res);
2173     } else {
2174         EXPECT_EQ(Rotation::ROTATION_270, res);
2175     }
2176     orientation = Orientation::REVERSE_HORIZONTAL;
2177     res = session->CalcRotation(orientation, foldDisplayMode);
2178     if (ScreenSessionManager::GetInstance().IsFoldable()) {
2179         EXPECT_EQ(Rotation::ROTATION_270, res);
2180     } else {
2181         EXPECT_EQ(Rotation::ROTATION_180, res);
2182     }
2183     orientation = Orientation::LOCKED;
2184     res = session->CalcRotation(orientation, foldDisplayMode);
2185     EXPECT_EQ(Rotation::ROTATION_0, res);
2186 }
2187 
2188 /**
2189  * @tc.name: CalcRotation02
2190  * @tc.desc: normal function
2191  * @tc.type: FUNC
2192  */
2193 HWTEST_F(ScreenSessionTest, CalcRotation02, Function | SmallTest | Level2)
2194 {
2195     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
2196         GTEST_SKIP() << "SceneBoard is not enabled, skipping test.";
2197     }
2198     GTEST_LOG_(INFO) << "ScreenSessionTest: CalcRotation start";
2199     Orientation orientation { Orientation::BEGIN };
2200     FoldDisplayMode foldDisplayMode { FoldDisplayMode::UNKNOWN };
2201     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
2202     session->activeIdx_ = -1;
2203     auto res = session->CalcRotation(orientation, foldDisplayMode);
2204     EXPECT_EQ(Rotation::ROTATION_0, res);
2205 
2206     sptr<SupportedScreenModes> supportedScreenModes = new SupportedScreenModes;
2207     supportedScreenModes->width_ = 40;
2208     supportedScreenModes->height_ = 20;
2209     session->modes_ = { supportedScreenModes };
2210     session->activeIdx_ = 0;
2211     orientation = Orientation::UNSPECIFIED;
2212     res = session->CalcRotation(orientation, foldDisplayMode);
2213     EXPECT_EQ(Rotation::ROTATION_0, res);
2214     orientation = Orientation::VERTICAL;
2215     res = session->CalcRotation(orientation, foldDisplayMode);
2216     EXPECT_EQ(Rotation::ROTATION_90, res);
2217     orientation = Orientation::HORIZONTAL;
2218     res = session->CalcRotation(orientation, foldDisplayMode);
2219     EXPECT_EQ(Rotation::ROTATION_0, res);
2220     orientation = Orientation::REVERSE_VERTICAL;
2221     res = session->CalcRotation(orientation, foldDisplayMode);
2222     EXPECT_EQ(Rotation::ROTATION_270, res);
2223     orientation = Orientation::REVERSE_HORIZONTAL;
2224     res = session->CalcRotation(orientation, foldDisplayMode);
2225     EXPECT_EQ(Rotation::ROTATION_180, res);
2226     orientation = Orientation::LOCKED;
2227     res = session->CalcRotation(orientation, foldDisplayMode);
2228     EXPECT_EQ(Rotation::ROTATION_0, res);
2229     GTEST_LOG_(INFO) << "ScreenSessionTest: CalcRotation end";
2230 }
2231 
2232 /**
2233  * @tc.name: CalcDisplayOrientation01
2234  * @tc.desc: normal function
2235  * @tc.type: FUNC
2236  */
2237 HWTEST_F(ScreenSessionTest, CalcDisplayOrientation01, Function | SmallTest | Level2)
2238 {
2239     GTEST_LOG_(INFO) << "ScreenSessionTest: CalcDisplayOrientation start";
2240     Rotation rotation { Rotation::ROTATION_0 };
2241     FoldDisplayMode foldDisplayMode { FoldDisplayMode::COORDINATION };
2242     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
2243     session->activeIdx_ = -1;
2244     auto res = session->CalcDisplayOrientation(rotation, foldDisplayMode, false);
2245     EXPECT_EQ(DisplayOrientation::LANDSCAPE, res);
2246 
2247     sptr<SupportedScreenModes> supportedScreenModes = new SupportedScreenModes;
2248     supportedScreenModes->width_ = 40;
2249     supportedScreenModes->height_ = 20;
2250     session->modes_ = { supportedScreenModes };
2251     session->activeIdx_ = 0;
2252 
2253     rotation = Rotation::ROTATION_0;
2254     res = session->CalcDisplayOrientation(rotation, foldDisplayMode, false);
2255     EXPECT_EQ(DisplayOrientation::LANDSCAPE, res);
2256 
2257     rotation = Rotation::ROTATION_90;
2258     res = session->CalcDisplayOrientation(rotation, foldDisplayMode, false);
2259     EXPECT_EQ(DisplayOrientation::PORTRAIT, res);
2260 
2261     rotation = Rotation::ROTATION_180;
2262     res = session->CalcDisplayOrientation(rotation, foldDisplayMode, false);
2263     EXPECT_EQ(DisplayOrientation::LANDSCAPE_INVERTED, res);
2264 
2265     rotation = Rotation::ROTATION_270;
2266     res = session->CalcDisplayOrientation(rotation, foldDisplayMode, false);
2267     EXPECT_EQ(DisplayOrientation::PORTRAIT_INVERTED, res);
2268 
2269     GTEST_LOG_(INFO) << "ScreenSessionTest: CalcDisplayOrientation end";
2270 }
2271 
2272 /**
2273  * @tc.name: CalcDisplayOrientation02
2274  * @tc.desc: normal function
2275  * @tc.type: FUNC
2276  */
2277 HWTEST_F(ScreenSessionTest, CalcDisplayOrientation02, Function | SmallTest | Level2)
2278 {
2279     GTEST_LOG_(INFO) << "ScreenSessionTest: CalcDisplayOrientation start";
2280     Rotation rotation { Rotation::ROTATION_0 };
2281     FoldDisplayMode foldDisplayMode { FoldDisplayMode::UNKNOWN };
2282     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
2283     session->activeIdx_ = -1;
2284     auto res = session->CalcDisplayOrientation(rotation, foldDisplayMode, false);
2285     EXPECT_EQ(DisplayOrientation::LANDSCAPE, res);
2286 
2287     sptr<SupportedScreenModes> supportedScreenModes = new SupportedScreenModes;
2288     supportedScreenModes->width_ = 40;
2289     supportedScreenModes->height_ = 20;
2290     session->modes_ = { supportedScreenModes };
2291     session->activeIdx_ = 0;
2292 
2293     rotation = Rotation::ROTATION_0;
2294     res = session->CalcDisplayOrientation(rotation, foldDisplayMode, false);
2295     EXPECT_EQ(DisplayOrientation::LANDSCAPE, res);
2296 
2297     rotation = Rotation::ROTATION_90;
2298     res = session->CalcDisplayOrientation(rotation, foldDisplayMode, false);
2299     EXPECT_EQ(DisplayOrientation::PORTRAIT, res);
2300 
2301     rotation = Rotation::ROTATION_180;
2302     res = session->CalcDisplayOrientation(rotation, foldDisplayMode, false);
2303     EXPECT_EQ(DisplayOrientation::LANDSCAPE_INVERTED, res);
2304 
2305     rotation = Rotation::ROTATION_270;
2306     res = session->CalcDisplayOrientation(rotation, foldDisplayMode, false);
2307     EXPECT_EQ(DisplayOrientation::PORTRAIT_INVERTED, res);
2308 
2309     GTEST_LOG_(INFO) << "ScreenSessionTest: CalcDisplayOrientation end";
2310 }
2311 
2312 /**
2313  * @tc.name: FillScreenInfo
2314  * @tc.desc: normal function
2315  * @tc.type: FUNC
2316  */
2317 HWTEST_F(ScreenSessionTest, FillScreenInfo, Function | SmallTest | Level2)
2318 {
2319     GTEST_LOG_(INFO) << "ScreenSessionTest: FillScreenInfo start";
2320     ScreenProperty property;
2321     property.SetVirtualPixelRatio(3.1415927);
2322     sptr<ScreenSession> session = new(std::nothrow) ScreenSession(2024, property, 0);
2323     sptr<ScreenInfo> info = nullptr;
2324     session->FillScreenInfo(info);
2325 
2326     sptr<SupportedScreenModes> supportedScreenModes = new SupportedScreenModes;
2327     session->modes_ = { supportedScreenModes };
2328     supportedScreenModes->width_ = 40;
2329     supportedScreenModes->height_ = 20;
2330     info = new ScreenInfo;
2331     session->FillScreenInfo(info);
2332     EXPECT_NE(nullptr, info);
2333     GTEST_LOG_(INFO) << "ScreenSessionTest: FillScreenInfo end";
2334 }
2335 
2336 /**
2337  * @tc.name: PropertyChange
2338  * @tc.desc: normal function
2339  * @tc.type: FUNC
2340  */
2341 HWTEST_F(ScreenSessionTest, PropertyChange, Function | SmallTest | Level2)
2342 {
2343     GTEST_LOG_(INFO) << "ScreenSessionTest: PropertyChange start";
2344     int res = 0;
2345     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
2346     ScreenProperty newProperty;
2347     ScreenPropertyChangeReason reason = ScreenPropertyChangeReason::CHANGE_MODE;
2348     session->PropertyChange(newProperty, reason);
2349     ASSERT_EQ(res, 0);
2350     GTEST_LOG_(INFO) << "ScreenSessionTest: PropertyChange end";
2351 }
2352 
2353 /**
2354  * @tc.name: PowerStatusChange
2355  * @tc.desc: normal function
2356  * @tc.type: FUNC
2357  */
2358 HWTEST_F(ScreenSessionTest, PowerStatusChange, Function | SmallTest | Level2)
2359 {
2360     GTEST_LOG_(INFO) << "ScreenSessionTest: PowerStatusChange start";
2361     int res = 0;
2362     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
2363     DisplayPowerEvent event = DisplayPowerEvent::DISPLAY_ON;
2364     EventStatus status = EventStatus::BEGIN;
2365     PowerStateChangeReason reason = PowerStateChangeReason::POWER_BUTTON;
2366     session->PowerStatusChange(event, status, reason);
2367     ASSERT_EQ(res, 0);
2368     GTEST_LOG_(INFO) << "ScreenSessionTest: PowerStatusChange end";
2369 }
2370 
2371 /**
2372  * @tc.name: SetScreenScale
2373  * @tc.desc: SetScreenScale test
2374  * @tc.type: FUNC
2375  */
2376 HWTEST_F(ScreenSessionTest, SetScreenScale, Function | SmallTest | Level2)
2377 {
2378     ScreenSession session;
2379     float scaleX = 1.0f;
2380     float scaleY = 1.0f;
2381     float pivotX = 0.5f;
2382     float pivotY = 0.5f;
2383     float translateX = 0.0f;
2384     float translateY = 0.0f;
2385     session.SetScreenScale(scaleX, scaleY, pivotX, pivotY, translateX, translateY);
2386     EXPECT_EQ(session.property_.GetScaleX(), scaleX);
2387     EXPECT_EQ(session.property_.GetScaleY(), scaleY);
2388     EXPECT_EQ(session.property_.GetPivotX(), pivotX);
2389     EXPECT_EQ(session.property_.GetPivotY(), pivotY);
2390     EXPECT_EQ(session.property_.GetTranslateX(), translateX);
2391     EXPECT_EQ(session.property_.GetTranslateY(), translateY);
2392 }
2393 
2394 /**
2395  * @tc.name: HoverStatusChange01
2396  * @tc.desc: normal function
2397  * @tc.type: FUNC
2398  */
2399 HWTEST_F(ScreenSessionTest, HoverStatusChange01, Function | SmallTest | Level2)
2400 {
2401     GTEST_LOG_(INFO) << "HoverStatusChange start";
2402     ScreenSessionConfig config = {
2403         .screenId = 100,
2404         .rsId = 101,
2405         .name = "OpenHarmony",
2406     };
2407     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
2408     EXPECT_NE(nullptr, screenSession);
2409     int32_t HoverStatus = 0;
2410     screenSession->HoverStatusChange(HoverStatus);
2411     GTEST_LOG_(INFO) << "HoverStatusChange end";
2412 }
2413 
2414 /**
2415  * @tc.name: HoverStatusChange02
2416  * @tc.desc: run in for
2417  * @tc.type: FUNC
2418  */
2419 HWTEST_F(ScreenSessionTest, HoverStatusChange02, Function | SmallTest | Level2)
2420 {
2421     IScreenChangeListener* screenChangeListener = new MockScreenChangeListener();
2422     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
2423     EXPECT_NE(nullptr, session);
2424     session->RegisterScreenChangeListener(screenChangeListener);
2425     int32_t hoverStatus = 0;
2426     session->HoverStatusChange(hoverStatus);
2427 }
2428 
2429 /**
2430  * @tc.name: HandleHoverStatusChange01
2431  * @tc.desc: run in for
2432  * @tc.type: FUNC
2433  */
2434 HWTEST_F(ScreenSessionTest, HandleHoverStatusChange01, Function | SmallTest | Level2)
2435 {
2436     IScreenChangeListener* screenChangeListener = new MockScreenChangeListener();
2437     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
2438     EXPECT_NE(nullptr, session);
2439     session->RegisterScreenChangeListener(screenChangeListener);
2440     int32_t hoverStatus = 0;
2441     session->HandleHoverStatusChange(hoverStatus);
2442 }
2443 
2444 /**
2445  * @tc.name: ScreenCaptureNotify
2446  * @tc.desc: ScreenCaptureNotify test
2447  * @tc.type: FUNC
2448  */
2449 HWTEST_F(ScreenSessionTest, ScreenCaptureNotify, Function | SmallTest | Level2)
2450 {
2451     sptr<ScreenSession> session = new ScreenSession();
2452     ASSERT_NE(session, nullptr);
2453     ScreenId screenId = 0;
2454     int32_t uid = 0;
2455     std::string clientName = "test";
2456     session->ScreenCaptureNotify(screenId, uid, clientName);
2457 }
2458 
2459 /**
2460  * @tc.name: GetIsInternal01
2461  * @tc.desc: Test when isInternal is true, GetIsInternal should return true
2462  * @tc.type: FUNC
2463  */
2464 HWTEST_F(ScreenSessionTest, GetIsInternal01, Function | SmallTest | Level2)
2465 {
2466     sptr<ScreenSession> session = new ScreenSession();
2467     ASSERT_NE(session, nullptr);
2468     session->SetIsInternal(true);
2469     ASSERT_EQ(session->GetIsInternal(), true);
2470 }
2471 
2472 /**
2473  * @tc.name: GetIsInternal02
2474  * @tc.desc: Test when isInternal is false, GetIsInternal should return false
2475  * @tc.type: FUNC
2476  */
2477 HWTEST_F(ScreenSessionTest, GetIsInternal02, Function | SmallTest | Level2)
2478 {
2479     sptr<ScreenSession> session = new ScreenSession();
2480     ASSERT_NE(session, nullptr);
2481     session->SetIsInternal(false);
2482     ASSERT_EQ(session->GetIsInternal(), false);
2483 }
2484 
2485 /**
2486  * @tc.name: GetIsFakeInUse01
2487  * @tc.desc: Test when isFakeInUse is true, GetIsFakeInUse should return true
2488  * @tc.type: FUNC
2489  */
2490 HWTEST_F(ScreenSessionTest, GetIsFakeInUse01, Function | SmallTest | Level2)
2491 {
2492     sptr<ScreenSession> session = new ScreenSession();
2493     ASSERT_NE(session, nullptr);
2494     session->SetIsFakeInUse(true);
2495     ASSERT_EQ(session->GetIsFakeInUse(), true);
2496 }
2497 
2498 /**
2499  * @tc.name: GetIsFakeInUse02
2500  * @tc.desc: Test when isFakeInUse is false, GetIsFakeInUse should return false
2501  * @tc.type: FUNC
2502  */
2503 HWTEST_F(ScreenSessionTest, GetIsFakeInUse02, Function | SmallTest | Level2)
2504 {
2505     sptr<ScreenSession> session = new ScreenSession();
2506     ASSERT_NE(session, nullptr);
2507     session->SetIsFakeInUse(false);
2508     ASSERT_EQ(session->GetIsFakeInUse(), false);
2509 }
2510 
2511 /**
2512  * @tc.name: GetIsRealScreen01
2513  * @tc.desc: Test when isReal is true, GetIsRealScreen should return true
2514  * @tc.type: FUNC
2515  */
2516 HWTEST_F(ScreenSessionTest, GetIsRealScreen01, Function | SmallTest | Level2)
2517 {
2518     sptr<ScreenSession> session = new ScreenSession();
2519     ASSERT_NE(session, nullptr);
2520     session->SetIsRealScreen(true);
2521     ASSERT_EQ(session->GetIsRealScreen(), true);
2522 }
2523 
2524 /**
2525  * @tc.name: GetIsRealScreen02
2526  * @tc.desc: Test when isReal is false, GetIsRealScreen should return false
2527  * @tc.type: FUNC
2528  */
2529 HWTEST_F(ScreenSessionTest, GetIsRealScreen02, Function | SmallTest | Level2)
2530 {
2531     sptr<ScreenSession> session = new ScreenSession();
2532     ASSERT_NE(session, nullptr);
2533     session->SetIsRealScreen(false);
2534     ASSERT_EQ(session->GetIsRealScreen(), false);
2535 }
2536 
2537 /**
2538  * @tc.name: GetIsPcUse01
2539  * @tc.desc: Test when isPcUse is true, GetIsPcUse should return true
2540  * @tc.type: FUNC
2541  */
2542 HWTEST_F(ScreenSessionTest, GetIsPcUse01, Function | SmallTest | Level2)
2543 {
2544     sptr<ScreenSession> session = new ScreenSession();
2545     ASSERT_NE(session, nullptr);
2546     session->SetIsPcUse(true);
2547     ASSERT_EQ(session->GetIsPcUse(), true);
2548 }
2549 
2550 /**
2551  * @tc.name: GetIsPcUse02
2552  * @tc.desc: Test when isPcUse is false, GetIsPcUse should return false
2553  * @tc.type: FUNC
2554  */
2555 HWTEST_F(ScreenSessionTest, GetIsPcUse02, Function | SmallTest | Level2)
2556 {
2557     sptr<ScreenSession> session = new ScreenSession();
2558     ASSERT_NE(session, nullptr);
2559     session->SetIsPcUse(false);
2560     ASSERT_EQ(session->GetIsPcUse(), false);
2561 }
2562 
2563 /**
2564  * @tc.name: GetIsBScreenHalf01
2565  * @tc.desc: Test when isBScreenHalf is true, GetIsBScreenHalf should return true
2566  * @tc.type: FUNC
2567  */
2568 HWTEST_F(ScreenSessionTest, GetIsBScreenHalf01, Function | SmallTest | Level2)
2569 {
2570     sptr<ScreenSession> session = new ScreenSession();
2571     ASSERT_NE(session, nullptr);
2572     session->SetIsBScreenHalf(true);
2573     ASSERT_EQ(session->GetIsBScreenHalf(), true);
2574 }
2575 
2576 /**
2577  * @tc.name: GetIsBScreenHalf02
2578  * @tc.desc: Test when isBScreenHalf is false, GetIsBScreenHalf should return false
2579  * @tc.type: FUNC
2580  */
2581 HWTEST_F(ScreenSessionTest, GetIsBScreenHalf02, Function | SmallTest | Level2)
2582 {
2583     sptr<ScreenSession> session = new ScreenSession();
2584     ASSERT_NE(session, nullptr);
2585     session->SetIsBScreenHalf(false);
2586     ASSERT_EQ(session->GetIsBScreenHalf(), false);
2587 }
2588 
2589 /**
2590  * @tc.name: CalcDeviceOrientation01
2591  * @tc.desc: Test when rotation is ROTATION_0 then CalcDeviceOrientation returns PORTRAIT
2592  * @tc.type: FUNC
2593  */
2594 HWTEST_F(ScreenSessionTest, CalcDeviceOrientation01, Function | SmallTest | Level2)
2595 {
2596     sptr<ScreenSession> session = new ScreenSession();
2597     ASSERT_NE(session, nullptr);
2598     DisplayOrientation result = session->CalcDeviceOrientation(Rotation::ROTATION_0, FoldDisplayMode::FULL, false);
2599     ASSERT_EQ(result, DisplayOrientation::PORTRAIT);
2600 }
2601 
2602 /**
2603  * @tc.name: CalcDeviceOrientation02
2604  * @tc.desc: Test when rotation is ROTATION_90 then CalcDeviceOrientation returns LANDSCAPE
2605  * @tc.type: FUNC
2606  */
2607 HWTEST_F(ScreenSessionTest, CalcDeviceOrientation02, Function | SmallTest | Level2)
2608 {
2609     sptr<ScreenSession> session = new ScreenSession();
2610     ASSERT_NE(session, nullptr);
2611     DisplayOrientation result = session->CalcDeviceOrientation(Rotation::ROTATION_90, FoldDisplayMode::FULL, false);
2612     ASSERT_EQ(result, DisplayOrientation::LANDSCAPE);
2613 }
2614 
2615 /**
2616  * @tc.name: CalcDeviceOrientation03
2617  * @tc.desc: Test when rotation is ROTATION_180 then CalcDeviceOrientation returns PORTRAIT_INVERTED
2618  * @tc.type: FUNC
2619  */
2620 HWTEST_F(ScreenSessionTest, CalcDeviceOrientation03, Function | SmallTest | Level2)
2621 {
2622     sptr<ScreenSession> session = new ScreenSession();
2623     ASSERT_NE(session, nullptr);
2624     DisplayOrientation result = session->CalcDeviceOrientation(Rotation::ROTATION_180, FoldDisplayMode::FULL, false);
2625     ASSERT_EQ(result, DisplayOrientation::PORTRAIT_INVERTED);
2626 }
2627 
2628 /**
2629  * @tc.name: CalcDeviceOrientation04
2630  * @tc.desc: Test when rotation is ROTATION_270 then CalcDeviceOrientation returns LANDSCAPE_INVERTED
2631  * @tc.type: FUNC
2632  */
2633 HWTEST_F(ScreenSessionTest, CalcDeviceOrientation04, Function | SmallTest | Level2)
2634 {
2635     sptr<ScreenSession> session = new ScreenSession();
2636     ASSERT_NE(session, nullptr);
2637     DisplayOrientation result = session->CalcDeviceOrientation(Rotation::ROTATION_270, FoldDisplayMode::FULL, false);
2638     ASSERT_EQ(result, DisplayOrientation::LANDSCAPE_INVERTED);
2639 }
2640 
2641 /**
2642  * @tc.name: CalcDeviceOrientation05
2643  * @tc.desc: Test when rotation is unknown then CalcDeviceOrientation returns UNKNOWN
2644  * @tc.type: FUNC
2645  */
2646 HWTEST_F(ScreenSessionTest, CalcDeviceOrientation05, Function | SmallTest | Level2)
2647 {
2648     sptr<ScreenSession> session = new ScreenSession();
2649     ASSERT_NE(session, nullptr);
2650     DisplayOrientation result = session->CalcDeviceOrientation(static_cast<Rotation>(100),
2651         FoldDisplayMode::FULL, false);
2652     ASSERT_EQ(result, DisplayOrientation::UNKNOWN);
2653 }
2654 
2655 /**
2656  * @tc.name: GetIsPhysicalMirrorSwitch01
2657  * @tc.desc: Test when isPhysicalMirrorSwitch is true, GetIsPhysicalMirrorSwitch should return true
2658  * @tc.type: FUNC
2659  */
2660 HWTEST_F(ScreenSessionTest, GetIsPhysicalMirrorSwitch01, Function | SmallTest | Level2)
2661 {
2662     sptr<ScreenSession> session = new ScreenSession();
2663     ASSERT_NE(session, nullptr);
2664     session->SetIsPhysicalMirrorSwitch(true);
2665     ASSERT_EQ(session->GetIsPhysicalMirrorSwitch(), true);
2666 }
2667 
2668 /**
2669  * @tc.name: GetIsPhysicalMirrorSwitch02
2670  * @tc.desc: Test when isPhysicalMirrorSwitch is false, GetIsPhysicalMirrorSwitch should return false
2671  * @tc.type: FUNC
2672  */
2673 HWTEST_F(ScreenSessionTest, GetIsPhysicalMirrorSwitch02, Function | SmallTest | Level2)
2674 {
2675     sptr<ScreenSession> session = new ScreenSession();
2676     ASSERT_NE(session, nullptr);
2677     session->SetIsPhysicalMirrorSwitch(false);
2678     ASSERT_EQ(session->GetIsPhysicalMirrorSwitch(), false);
2679 }
2680 /**
2681  * @tc.name: GetDisplaySourceMode01
2682  * @tc.desc: normal function
2683  * @tc.type: FUNC
2684  */
2685 HWTEST_F(ScreenSessionTest, GetDisplaySourceMode01, Function | SmallTest | Level2)
2686 {
2687     GTEST_LOG_(INFO) << "ScreenSessionTest: GetSourceMode start";
2688     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
2689     session->screenId_ = session->defaultScreenId_;
2690     DisplaySourceMode mode = session->GetDisplaySourceMode();
2691     ASSERT_EQ(mode, DisplaySourceMode::MAIN);
2692     ScreenSessionConfig config = {
2693         .screenId = 100,
2694         .rsId = 101,
2695         .name = "OpenHarmony",
2696     };
2697     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
2698     mode = screenSession->GetDisplaySourceMode();
2699     ASSERT_EQ(mode, DisplaySourceMode::NONE);
2700     screenSession->SetScreenCombination(ScreenCombination::SCREEN_EXPAND);
2701     mode = screenSession->GetDisplaySourceMode();
2702     ASSERT_EQ(mode, DisplaySourceMode::EXTEND);
2703     screenSession->SetScreenCombination(ScreenCombination::SCREEN_MIRROR);
2704     mode = screenSession->GetDisplaySourceMode();
2705     ASSERT_EQ(mode, DisplaySourceMode::MIRROR);
2706     screenSession->SetScreenCombination(ScreenCombination::SCREEN_UNIQUE);
2707     mode = screenSession->GetDisplaySourceMode();
2708     ASSERT_EQ(mode, DisplaySourceMode::ALONE);
2709     GTEST_LOG_(INFO) << "ScreenSessionTest: GetDisplaySourceMode01 end";
2710 }
2711 
2712 /**
2713 * @tc.name: GetDisplaySourceMode02
2714 * @tc.desc: normal function
2715 * @tc.type: FUNC
2716 */
2717 HWTEST_F(ScreenSessionTest, GetDisplaySourceMode02, Function | SmallTest | Level2)
2718 {
2719     GTEST_LOG_(INFO) << "ScreenSessionTest: GetDisplaySourceMode02 start";
2720     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
2721     session->screenId_ = session->defaultScreenId_;
2722     DisplaySourceMode mode = session->GetDisplaySourceMode();
2723     ASSERT_EQ(mode, DisplaySourceMode::MAIN);
2724     ScreenSessionConfig config = {
2725         .screenId = 100,
2726         .rsId = 101,
2727         .name = "OpenHarmony",
2728     };
2729     sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
2730 
2731     screenSession->SetScreenCombination(ScreenCombination::SCREEN_MAIN);
2732     mode = screenSession->GetDisplaySourceMode();
2733     ASSERT_EQ(mode, DisplaySourceMode::MAIN);
2734     screenSession->SetScreenCombination(ScreenCombination::SCREEN_EXTEND);
2735     mode = screenSession->GetDisplaySourceMode();
2736     ASSERT_EQ(mode, DisplaySourceMode::EXTEND);
2737     GTEST_LOG_(INFO) << "ScreenSessionTest: GetDisplaySourceMode02 end";
2738 }
2739 
2740 /**
2741  * @tc.name: SetPointerActiveWidth
2742  * @tc.desc: normal function
2743  * @tc.type: FUNC
2744  */
2745 HWTEST_F(ScreenSessionTest, SetPointerActiveWidth, Function | SmallTest | Level2)
2746 {
2747     GTEST_LOG_(INFO) << "ScreenSessionTest: SetPointerActiveWidth start";
2748     uint32_t pointerActiveWidth = 123;
2749     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
2750     session->SetPointerActiveWidth(pointerActiveWidth);
2751     ASSERT_EQ(pointerActiveWidth, session->property_.GetPointerActiveWidth());
2752     GTEST_LOG_(INFO) << "ScreenSessionTest: SetPointerActiveWidth end";
2753 }
2754 
2755 /**
2756  * @tc.name: GetPointerActiveWidth
2757  * @tc.desc: normal function
2758  * @tc.type: FUNC
2759  */
2760 HWTEST_F(ScreenSessionTest, GetPointerActiveWidth, Function | SmallTest | Level2)
2761 {
2762     GTEST_LOG_(INFO) << "ScreenSessionTest: GetPointerActiveWidth start";
2763     uint32_t pointerActiveWidth = 123;
2764     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
2765     session->SetPointerActiveWidth(pointerActiveWidth);
2766     ASSERT_EQ(pointerActiveWidth, session->GetPointerActiveWidth());
2767     GTEST_LOG_(INFO) << "ScreenSessionTest: GetPointerActiveWidth end";
2768 }
2769 
2770 /**
2771  * @tc.name: SetPointerActiveHeight
2772  * @tc.desc: normal function
2773  * @tc.type: FUNC
2774  */
2775 HWTEST_F(ScreenSessionTest, SetPointerActiveHeight, Function | SmallTest | Level2)
2776 {
2777     GTEST_LOG_(INFO) << "ScreenSessionTest: SetPointerActiveHeight start";
2778     uint32_t pointerActiveHeight = 321;
2779     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
2780     session->SetPointerActiveHeight(pointerActiveHeight);
2781     ASSERT_EQ(pointerActiveHeight, session->property_.GetPointerActiveHeight());
2782     GTEST_LOG_(INFO) << "ScreenSessionTest: SetPointerActiveHeight end";
2783 }
2784 
2785 /**
2786  * @tc.name: GetPointerActiveHeighth
2787  * @tc.desc: normal function
2788  * @tc.type: FUNC
2789  */
2790 HWTEST_F(ScreenSessionTest, GetPointerActiveHeight, Function | SmallTest | Level2)
2791 {
2792     GTEST_LOG_(INFO) << "ScreenSessionTest: GetPointerActiveHeight start";
2793     uint32_t pointerActiveHeight = 321;
2794     sptr<ScreenSession> session = new(std::nothrow) ScreenSession();
2795     session->SetPointerActiveHeight(pointerActiveHeight);
2796     ASSERT_EQ(pointerActiveHeight, session->GetPointerActiveHeight());
2797     GTEST_LOG_(INFO) << "ScreenSessionTest: GetPointerActiveHeight end";
2798 }
2799 } // namespace
2800 } // namespace Rosen
2801 } // namespace OHOS
2802