• 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 <gtest/gtest.h>
17 
18 #include "scene_board_judgement.h"
19 #include "screen_session_manager/include/fold_screen_controller/fold_screen_controller.h"
20 #include "screen_session_manager/include/screen_session_manager.h"
21 #include "fold_screen_state_internel.h"
22 
23 using namespace testing;
24 using namespace testing::ext;
25 
26 namespace OHOS {
27 namespace Rosen {
28 namespace {
29     constexpr uint32_t SLEEP_TIME_IN_US = 100000; // 100ms
30     std::string g_errLog;
MyLogCallback(const LogType type,const LogLevel level,const unsigned int domain,const char * tag,const char * msg)31     void MyLogCallback(const LogType type, const LogLevel level, const unsigned int domain, const char *tag,
32         const char *msg)
33     {
34         g_errLog = msg;
35     }
36 }
37 class FoldScreenControllerTest : public testing::Test {
38 public:
39     static void SetUpTestCase();
40     static void TearDownTestCase();
41     void SetUp() override;
42     void TearDown() override;
43 
44     static ScreenSessionManager& ssm_;
45 };
46 
47 ScreenSessionManager& FoldScreenControllerTest::ssm_ = ScreenSessionManager::GetInstance();
48 
SetUpTestCase()49 void FoldScreenControllerTest::SetUpTestCase()
50 {
51 }
52 
TearDownTestCase()53 void FoldScreenControllerTest::TearDownTestCase()
54 {
55     usleep(SLEEP_TIME_IN_US);
56 }
57 
SetUp()58 void FoldScreenControllerTest::SetUp()
59 {
60 }
61 
TearDown()62 void FoldScreenControllerTest::TearDown()
63 {
64 }
65 
66 namespace {
67 
68     /**
69      * @tc.name: GetFoldScreenPolicy
70      * @tc.desc: test function :GetFoldScreenPolicy
71      * @tc.type: FUNC
72      */
73     HWTEST_F(FoldScreenControllerTest, GetFoldScreenPolicy, TestSize.Level1)
74     {
75         std::recursive_mutex mutex;
76         FoldScreenController fsc_(mutex, std::shared_ptr<TaskScheduler>());
77 
78         DisplayDeviceType productType = DisplayDeviceType::SINGLE_DISPLAY_DEVICE;
79         auto ret = fsc_.GetFoldScreenPolicy(productType);
80         ASSERT_NE(ret, nullptr);
81 
82         productType = DisplayDeviceType::DOUBLE_DISPLAY_DEVICE;
83         ret = fsc_.GetFoldScreenPolicy(productType);
84         ASSERT_NE(ret, nullptr);
85 
86         productType = DisplayDeviceType::SINGLE_DISPLAY_POCKET_DEVICE;
87         ret = fsc_.GetFoldScreenPolicy(productType);
88         ASSERT_NE(ret, nullptr);
89 
90         productType = DisplayDeviceType::DISPLAY_DEVICE_UNKNOWN;
91         ret = fsc_.GetFoldScreenPolicy(productType);
92         ASSERT_EQ(ret, nullptr);
93     }
94 
95     /**
96      * @tc.name: SetDisplayMode01
97      * @tc.desc: test function :SetDisplayMode
98      * @tc.type: FUNC
99      */
100     HWTEST_F(FoldScreenControllerTest, SetDisplayMode01, TestSize.Level1)
101     {
102         std::recursive_mutex mutex;
103         FoldScreenController fsc_(mutex, std::shared_ptr<TaskScheduler>());
104 
105         fsc_.foldScreenPolicy_ = nullptr;
106         FoldDisplayMode displayMode = FoldDisplayMode::FULL;
107         fsc_.SetDisplayMode(displayMode);
108         ASSERT_EQ(fsc_.GetDisplayMode(), FoldDisplayMode::UNKNOWN);
109     }
110 
111     /**
112      * @tc.name: SetDisplayMode02
113      * @tc.desc: test function :SetDisplayMode
114      * @tc.type: FUNC
115      */
116     HWTEST_F(FoldScreenControllerTest, SetDisplayMode02, TestSize.Level1)
117     {
118         if (FoldScreenStateInternel::IsSuperFoldDisplayDevice()) {
119             GTEST_SKIP();
120         }
121         std::recursive_mutex mutex;
122         FoldScreenController fsc_(mutex, std::shared_ptr<TaskScheduler>());
123 
124         ASSERT_NE(fsc_.foldScreenPolicy_, nullptr);
125         auto mode = fsc_.GetDisplayMode();
126         FoldDisplayMode displayMode = FoldDisplayMode::UNKNOWN;
127         fsc_.SetDisplayMode(displayMode);
128         if (ssm_.IsFoldable()) {
129             ASSERT_EQ(fsc_.GetDisplayMode(), displayMode);
130             fsc_.SetDisplayMode(mode);
131         } else {
132             ASSERT_EQ(fsc_.GetDisplayMode(), FoldDisplayMode::UNKNOWN);
133         }
134     }
135 
136     /**
137      * @tc.name: LockDisplayStatus01
138      * @tc.desc: test function :LockDisplayStatus
139      * @tc.type: FUNC
140      */
141     HWTEST_F(FoldScreenControllerTest, LockDisplayStatus01, TestSize.Level1)
142     {
143         std::recursive_mutex mutex;
144         FoldScreenController fsc_(mutex, std::shared_ptr<TaskScheduler>());
145 
146         fsc_.foldScreenPolicy_ = nullptr;
147         bool locked = false;
148         fsc_.LockDisplayStatus(locked);
149         ASSERT_EQ(fsc_.foldScreenPolicy_, nullptr);
150     }
151 
152     /**
153      * @tc.name: LockDisplayStatus02
154      * @tc.desc: test function :LockDisplayStatus
155      * @tc.type: FUNC
156      */
157     HWTEST_F(FoldScreenControllerTest, LockDisplayStatus02, TestSize.Level1)
158     {
159         std::recursive_mutex mutex;
160         FoldScreenController fsc_(mutex, std::shared_ptr<TaskScheduler>());
161 
162         fsc_.foldScreenPolicy_ = new FoldScreenPolicy();
163         bool locked = false;
164         fsc_.LockDisplayStatus(locked);
165         ASSERT_EQ((fsc_.foldScreenPolicy_)->lockDisplayStatus_, locked);
166     }
167 
168     /**
169      * @tc.name: GetDisplayMode
170      * @tc.desc: test function :GetDisplayMode
171      * @tc.type: FUNC
172      */
173     HWTEST_F(FoldScreenControllerTest, GetDisplayMode01, TestSize.Level1)
174     {
175         std::recursive_mutex mutex;
176         FoldScreenController fsc_(mutex, std::shared_ptr<TaskScheduler>());
177 
178         fsc_.foldScreenPolicy_ = nullptr;
179         auto ret = fsc_.GetDisplayMode();
180         ASSERT_EQ(ret, FoldDisplayMode::UNKNOWN);
181     }
182 
183     /**
184      * @tc.name: GetDisplayMode
185      * @tc.desc: foldScreenPolicy_ is not nullptr
186      * @tc.type: FUNC
187      */
188     HWTEST_F(FoldScreenControllerTest, GetDisplayMode02, TestSize.Level1)
189     {
190         std::recursive_mutex mutex;
191         FoldScreenController fsc_(mutex, std::shared_ptr<TaskScheduler>());
192 
193         fsc_.foldScreenPolicy_ = new FoldScreenPolicy();
194         auto ret = fsc_.GetDisplayMode();
195         ASSERT_EQ(ret, FoldDisplayMode::UNKNOWN);
196     }
197 
198     /**
199      * @tc.name: GetFoldStatus
200      * @tc.desc: test function :GetFoldStatus
201      * @tc.type: FUNC
202      */
203     HWTEST_F(FoldScreenControllerTest, GetFoldStatus, TestSize.Level1)
204     {
205         std::recursive_mutex mutex;
206         FoldScreenController fsc_(mutex, std::shared_ptr<TaskScheduler>());
207 
208         fsc_.foldScreenPolicy_ = nullptr;
209         auto ret = fsc_.GetFoldStatus();
210         ASSERT_EQ(ret, FoldStatus::UNKNOWN);
211     }
212 
213     /**
214      * @tc.name: SetFoldStatus01
215      * @tc.desc: test function :SetFoldStatus
216      * @tc.type: FUNC
217      */
218     HWTEST_F(FoldScreenControllerTest, SetFoldStatus01, TestSize.Level1)
219     {
220         std::recursive_mutex mutex;
221         FoldScreenController fsc_(mutex, std::shared_ptr<TaskScheduler>());
222 
223         FoldStatus foldStatus = FoldStatus::HALF_FOLD;
224         fsc_.foldScreenPolicy_ = nullptr;
225         fsc_.SetFoldStatus(foldStatus);
226         ASSERT_EQ(fsc_.foldScreenPolicy_, nullptr);
227         ASSERT_EQ(fsc_.GetFoldStatus(), FoldStatus::UNKNOWN);
228     }
229 
230     /**
231      * @tc.name: SetFoldStatus02
232      * @tc.desc: test function :SetFoldStatus
233      * @tc.type: FUNC
234      */
235     HWTEST_F(FoldScreenControllerTest, SetFoldStatus02, TestSize.Level1)
236     {
237         std::recursive_mutex mutex;
238         FoldScreenController fsc_(mutex, std::shared_ptr<TaskScheduler>());
239 
240         FoldStatus foldStatus = FoldStatus::HALF_FOLD;
241         fsc_.foldScreenPolicy_ = new FoldScreenPolicy();
242         fsc_.SetFoldStatus(foldStatus);
243         ASSERT_EQ(fsc_.GetFoldStatus(), foldStatus);
244     }
245 
246     /**
247      * @tc.name: GetCurrentFoldCreaseRegion
248      * @tc.desc: test function :GetCurrentFoldCreaseRegion
249      * @tc.type: FUNC
250      */
251     HWTEST_F(FoldScreenControllerTest, GetCurrentFoldCreaseRegion01, TestSize.Level1)
252     {
253         std::recursive_mutex mutex;
254         FoldScreenController fsc_(mutex, std::shared_ptr<TaskScheduler>());
255 
256         fsc_.foldScreenPolicy_ = nullptr;
257         auto ret = fsc_.GetCurrentFoldCreaseRegion();
258         ASSERT_EQ(ret, nullptr);
259     }
260 
261     /**
262      * @tc.name: GetCurrentFoldCreaseRegion
263      * @tc.desc: test function :GetCurrentFoldCreaseRegion
264      * @tc.type: FUNC
265      */
266     HWTEST_F(FoldScreenControllerTest, GetCurrentFoldCreaseRegion02, TestSize.Level1)
267     {
268         std::recursive_mutex mutex;
269         FoldScreenController fsc_(mutex, std::shared_ptr<TaskScheduler>());
270 
271         fsc_.foldScreenPolicy_ = new FoldScreenPolicy();
272         auto ret = fsc_.GetCurrentFoldCreaseRegion();
273         ASSERT_EQ(ret, fsc_.foldScreenPolicy_->GetCurrentFoldCreaseRegion());
274     }
275 
276     /**
277      * @tc.name: GetCurrentScreenId01
278      * @tc.desc: test function :GetCurrentScreenId
279      * @tc.type: FUNC
280      */
281     HWTEST_F(FoldScreenControllerTest, GetCurrentScreenId01, TestSize.Level1)
282     {
283         std::recursive_mutex mutex;
284         FoldScreenController fsc_(mutex, std::shared_ptr<TaskScheduler>());
285 
286         fsc_.foldScreenPolicy_ = nullptr;
287         auto ret = fsc_.GetCurrentScreenId();
288         ASSERT_EQ(ret, 0);
289     }
290 
291     /**
292      * @tc.name: GetCurrentScreenId02
293      * @tc.desc: test function :GetCurrentScreenId
294      * @tc.type: FUNC
295      */
296     HWTEST_F(FoldScreenControllerTest, GetCurrentScreenId02, TestSize.Level1)
297     {
298         std::recursive_mutex mutex;
299         FoldScreenController fsc_(mutex, std::shared_ptr<TaskScheduler>());
300 
301         fsc_.foldScreenPolicy_ = new FoldScreenPolicy();
302         auto ret = fsc_.GetCurrentScreenId();
303         ASSERT_NE(ret, 0);
304     }
305 
306     /**
307      * @tc.name: GetCurrentScreenId03
308      * @tc.desc: test function :GetCurrentScreenId
309      * @tc.type: FUNC
310      */
311     HWTEST_F(FoldScreenControllerTest, GetCurrentScreenId03, TestSize.Level1)
312     {
313         std::recursive_mutex mutex;
314         FoldScreenController fsc_(mutex, std::shared_ptr<TaskScheduler>());
315 
316         fsc_.foldScreenPolicy_ = nullptr;
317         auto ret = fsc_.GetCurrentScreenId();
318         ASSERT_EQ(ret, 0);
319 
320         fsc_.foldScreenPolicy_ = new FoldScreenPolicy();
321         ret = fsc_.GetCurrentScreenId();
322         ASSERT_NE(ret, 0);
323     }
324 
325     /**
326      * @tc.name: SetOnBootAnimation01
327      * @tc.desc: test function :SetOnBootAnimation
328      * @tc.type: FUNC
329      */
330     HWTEST_F(FoldScreenControllerTest, SetOnBootAnimation01, TestSize.Level1)
331     {
332         std::recursive_mutex mutex;
333         FoldScreenController fsc_(mutex, std::shared_ptr<TaskScheduler>());
334 
335         bool onBootAnimation = false;
336         fsc_.foldScreenPolicy_ = nullptr;
337         fsc_.SetOnBootAnimation(onBootAnimation);
338         ASSERT_EQ(onBootAnimation, false);
339     }
340 
341     /**
342      * @tc.name: SetOnBootAnimation02
343      * @tc.desc: test function :SetOnBootAnimation
344      * @tc.type: FUNC
345      */
346     HWTEST_F(FoldScreenControllerTest, SetOnBootAnimation02, TestSize.Level1)
347     {
348         std::recursive_mutex mutex;
349         FoldScreenController fsc_(mutex, std::shared_ptr<TaskScheduler>());
350 
351         bool onBootAnimation = true;
352         fsc_.foldScreenPolicy_ = new FoldScreenPolicy();
353         fsc_.SetOnBootAnimation(onBootAnimation);
354         ASSERT_EQ(onBootAnimation, true);
355     }
356 
357     /**
358      * @tc.name: SetOnBootAnimation03
359      * @tc.desc: test function :SetOnBootAnimation
360      * @tc.type: FUNC
361      */
362     HWTEST_F(FoldScreenControllerTest, SetOnBootAnimation03, TestSize.Level1)
363     {
364         std::recursive_mutex mutex;
365         FoldScreenController fsc_(mutex, std::shared_ptr<TaskScheduler>());
366 
367         bool onBootAnimation = true;
368         fsc_.foldScreenPolicy_ = new FoldScreenPolicy();
369         fsc_.SetOnBootAnimation(onBootAnimation);
370         ASSERT_EQ(onBootAnimation, true);
371         fsc_.foldScreenPolicy_ = nullptr;
372         bool onBootAnimation01 = false;
373         fsc_.SetOnBootAnimation(onBootAnimation01);
374         ASSERT_EQ(onBootAnimation, true);
375     }
376 
377     /**
378      * @tc.name: UpdateForPhyScreenPropertyChange01
379      * @tc.desc: test function :UpdateForPhyScreenPropertyChange
380      * @tc.type: FUNC
381      */
382     HWTEST_F(FoldScreenControllerTest, UpdateForPhyScreenPropertyChange01, TestSize.Level1)
383     {
384         std::recursive_mutex mutex;
385         FoldScreenController fsc_(mutex, std::shared_ptr<TaskScheduler>());
386 
387         fsc_.foldScreenPolicy_ = nullptr;
388         fsc_.UpdateForPhyScreenPropertyChange();
389         ASSERT_EQ(fsc_.foldScreenPolicy_, nullptr);
390     }
391 
392     /**
393      * @tc.name: UpdateForPhyScreenPropertyChange02
394      * @tc.desc: test function :UpdateForPhyScreenPropertyChange
395      * @tc.type: FUNC
396      */
397     HWTEST_F(FoldScreenControllerTest, UpdateForPhyScreenPropertyChange02, TestSize.Level1)
398     {
399         std::recursive_mutex mutex;
400         FoldScreenController fsc_(mutex, std::shared_ptr<TaskScheduler>());
401 
402         fsc_.foldScreenPolicy_ = new FoldScreenPolicy();
403         fsc_.UpdateForPhyScreenPropertyChange();
404         ASSERT_NE(fsc_.foldScreenPolicy_, nullptr);
405     }
406 
407     /**
408      * @tc.name: AddOrRemoveDisplayNodeToTree01
409      * @tc.desc: test function :AddOrRemoveDisplayNodeToTree
410      * @tc.type: FUNC
411      */
412     HWTEST_F(FoldScreenControllerTest, AddOrRemoveDisplayNodeToTree01, TestSize.Level1)
413     {
414         std::recursive_mutex mutex;
415         FoldScreenController fsc_(mutex, std::shared_ptr<TaskScheduler>());
416 
417         ScreenId screenId = 1;
418         int32_t command = 0;
419 
420         fsc_.foldScreenPolicy_ = new FoldScreenPolicy();
421         fsc_.AddOrRemoveDisplayNodeToTree(screenId, command);
422         ASSERT_NE(fsc_.foldScreenPolicy_, nullptr);
423     }
424 
425     /**
426      * @tc.name: AddOrRemoveDisplayNodeToTree02
427      * @tc.desc: test function :AddOrRemoveDisplayNodeToTree
428      * @tc.type: FUNC
429      */
430     HWTEST_F(FoldScreenControllerTest, AddOrRemoveDisplayNodeToTree02, TestSize.Level1)
431     {
432         std::recursive_mutex mutex;
433         FoldScreenController fsc_(mutex, std::shared_ptr<TaskScheduler>());
434 
435         ScreenId screenId = 0;
436         int32_t command = 1;
437 
438         fsc_.foldScreenPolicy_ = new FoldScreenPolicy();
439         fsc_.AddOrRemoveDisplayNodeToTree(screenId, command);
440         ASSERT_NE(fsc_.foldScreenPolicy_, nullptr);
441     }
442 
443     /**
444      * @tc.name: GetdisplayModeRunningStatus&SetdisplayModeChangeStatus01
445      * @tc.desc: test function :GetdisplayModeRunningStatus&SetdisplayModeChangeStatus
446      * @tc.type: FUNC
447      */
448     HWTEST_F(FoldScreenControllerTest, ModeChangeStatusTest01, TestSize.Level1)
449     {
450         std::recursive_mutex mutex;
451         FoldScreenController fsc_(mutex, std::shared_ptr<TaskScheduler>());
452 
453         bool status = false;
454 
455         fsc_.SetdisplayModeChangeStatus(status);
456         auto ret = fsc_.GetdisplayModeRunningStatus();
457 
458         ASSERT_EQ(ret, false);
459     }
460 
461     /**
462      * @tc.name: GetdisplayModeRunningStatus&SetdisplayModeChangeStatus02
463      * @tc.desc: test function :GetdisplayModeRunningStatus&SetdisplayModeChangeStatus
464      * @tc.type: FUNC
465      */
466     HWTEST_F(FoldScreenControllerTest, ModeChangeStatusTest02, TestSize.Level1)
467     {
468         std::recursive_mutex mutex;
469         FoldScreenController fsc_(mutex, std::shared_ptr<TaskScheduler>());
470 
471         bool status = true;
472 
473         fsc_.SetdisplayModeChangeStatus(status);
474         auto ret = fsc_.GetdisplayModeRunningStatus();
475 
476         ASSERT_EQ(ret, true);
477     }
478 
479     /**
480      * @tc.name: GetLastCacheDisplayMode01
481      * @tc.desc: test function :GetLastCacheDisplayMode
482      * @tc.type: FUNC
483      */
484     HWTEST_F(FoldScreenControllerTest, GetLastCacheDisplayMode01, TestSize.Level1)
485     {
486         std::recursive_mutex mutex;
487         FoldScreenController fsc_(mutex, std::shared_ptr<TaskScheduler>());
488 
489         FoldDisplayMode displayMode = FoldDisplayMode::UNKNOWN;
490         fsc_.SetDisplayMode(displayMode);
491         auto ret = fsc_.GetLastCacheDisplayMode();
492 
493         ASSERT_EQ(ret, FoldDisplayMode::UNKNOWN);
494     }
495 
496     /**
497      * @tc.name: GetLastCacheDisplayMode02
498      * @tc.desc: test function :GetLastCacheDisplayMode
499      * @tc.type: FUNC
500      */
501     HWTEST_F(FoldScreenControllerTest, GetLastCacheDisplayMode02, TestSize.Level1)
502     {
503         std::recursive_mutex mutex;
504         FoldScreenController fsc_(mutex, std::shared_ptr<TaskScheduler>());
505 
506         FoldDisplayMode displayMode = FoldDisplayMode::FULL;
507         fsc_.SetDisplayMode(displayMode);
508         auto ret = fsc_.GetLastCacheDisplayMode();
509 
510         ASSERT_EQ(ret, FoldDisplayMode::FULL);
511     }
512 
513     /**
514      * @tc.name: GetModeChangeRunningStatus
515      * @tc.desc: test function :GetModeChangeRunningStatus
516      * @tc.type: FUNC
517      */
518     HWTEST_F(FoldScreenControllerTest, GetModeChangeRunningStatus, TestSize.Level1)
519     {
520         std::recursive_mutex mutex;
521         FoldScreenController fsc_(mutex, std::shared_ptr<TaskScheduler>());
522 
523         auto ret = fsc_.GetModeChangeRunningStatus();
524 
525         ASSERT_EQ(ret, false);
526     }
527 
528     /**
529      * @tc.name: ExitCoordination01
530      * @tc.desc: test function :ExitCoordination
531      * @tc.type: FUNC
532      */
533     HWTEST_F(FoldScreenControllerTest, ExitCoordination01, TestSize.Level1)
534     {
535         std::recursive_mutex mutex;
536         FoldScreenController fsc_(mutex, std::shared_ptr<TaskScheduler>());
537 
538         fsc_.foldScreenPolicy_ = new FoldScreenPolicy();
539         fsc_.ExitCoordination();
540 
541         ASSERT_NE(fsc_.foldScreenPolicy_, nullptr);
542     }
543 
544     /**
545      * @tc.name: ExitCoordination02
546      * @tc.desc: test function :ExitCoordination
547      * @tc.type: FUNC
548      */
549     HWTEST_F(FoldScreenControllerTest, ExitCoordination02, TestSize.Level1)
550     {
551         std::recursive_mutex mutex;
552         FoldScreenController fsc_(mutex, std::shared_ptr<TaskScheduler>());
553 
554         fsc_.foldScreenPolicy_ = nullptr;
555         fsc_.ExitCoordination();
556 
557         ASSERT_EQ(fsc_.foldScreenPolicy_, nullptr);
558     }
559 
560     /**
561      * @tc.name: GetTentMode
562      * @tc.desc: test function :GetTentMode
563      * @tc.type: FUNC
564      */
565     HWTEST_F(FoldScreenControllerTest, GetTentMode, TestSize.Level1)
566     {
567         if (!ssm_.IsFoldable() || FoldScreenStateInternel::IsSuperFoldDisplayDevice()) {
568             GTEST_SKIP();
569         }
570         ASSERT_NE(ssm_.foldScreenController_, nullptr);
571             auto tentMode = ssm_.foldScreenController_->GetTentMode();
572             ASSERT_EQ(tentMode, false);
573     }
574 
575     /**
576      * @tc.name: OnTentModeChanged01
577      * @tc.desc: test function :OnTentModeChanged
578      * @tc.type: FUNC
579      */
580     HWTEST_F(FoldScreenControllerTest, OnTentModeChanged01, TestSize.Level1)
581     {
582         if (!FoldScreenStateInternel::IsSingleDisplayPocketFoldDevice()||
583             !FoldScreenStateInternel::IsDualDisplayFoldDevice()) {
584             GTEST_SKIP();
585         }
586         bool isTentMode = false;
587         ssm_.foldScreenController_->OnTentModeChanged(isTentMode);
588         ASSERT_EQ(ssm_.foldScreenController_->GetTentMode(), false);
589     }
590 
591     /**
592      * @tc.name: OnTentModeChanged02
593      * @tc.desc: test function :OnTentModeChanged
594      * @tc.type: FUNC
595      */
596     HWTEST_F(FoldScreenControllerTest, OnTentModeChanged02, TestSize.Level1)
597     {
598         if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
599             return;
600         }
601         if (ssm_.IsFoldable()) {
602             bool isTentMode = true;
603             ssm_.foldScreenController_->OnTentModeChanged(isTentMode);
604             ASSERT_EQ(ssm_.foldScreenController_->GetTentMode(), true);
605         }
606     }
607 
608     /**
609      * @tc.name: GetModeMatchStatus_ShouldReturnUnknow_WhenFoldScreenPolicyNull
610      * @tc.desc: Test GetModeMatchStatu method when foldScreenPolicy_ is null
611      * @tc.type: FUNC
612      */
613     HWTEST_F(FoldScreenControllerTest, GetModeMatchStatus_ShouldReturnUnknow_WhenFoldScreenPolicyNull,
614         TestSize.Level1)
615     {
616         //Arrange
617         std::recursive_mutex displayInfoMutex;
618         auto screenPowerTaskScheduler = std::shared_ptr<TaskScheduler>();
619         FoldScreenController foldScreenController(displayInfoMutex, screenPowerTaskScheduler);
620         foldScreenController.foldScreenPolicy_ = nullptr;
621 
622         //Act
623         auto result = foldScreenController.GetModeMatchStatus();
624 
625         //Assert
626         EXPECT_EQ(result, FoldDisplayMode::UNKNOWN);
627     }
628 
629     /**
630      * @tc.name: GetModeMatchStatus_ShouldReturnMode_WhenFoldScreenPolicyIsNoNull
631      * @tc.desc: Test GetModeMatchStatu method when foldScreenPolicy_ is not null
632      * @tc.type: FUNC
633      */
634     HWTEST_F(FoldScreenControllerTest, GetModeMatchStatus_ShouldReturnUnknow_WhenFoldScreenPolicyIsNotNull,
635         TestSize.Level1)
636     {
637         //Arrange
638         std::recursive_mutex displayInfoMutex;
639         auto screenPowerTaskScheduler = std::shared_ptr<TaskScheduler>();
640         FoldScreenController foldScreenController(displayInfoMutex, screenPowerTaskScheduler);
641 
642         //Set a mock foldScreenPolicy_
643         auto foldScreenPolicy = sptr<FoldScreenPolicy>::MakeSptr();
644         foldScreenController.foldScreenPolicy_ = foldScreenPolicy;
645 
646         //Act
647         auto result = foldScreenController.GetModeMatchStatus();
648 
649         //Assert
650         EXPECT_EQ(result, foldScreenPolicy->GetModeMatchStatus());
651     }
652 
653     /**
654      * @tc.name: GetScreenSnapshotRect_NullPolicy
655      * @tc.desc: test function :GetScreenSnapshotRect
656      * @tc.type: FUNC
657      */
658     HWTEST_F(FoldScreenControllerTest, GetScreenSnapshotRect_NullPolicy, TestSize.Level1)
659     {
660         std::recursive_mutex mutex;
661         auto screenPowerTaskScheduler = std::shared_ptr<TaskScheduler>();
662         FoldScreenController controller(mutex, screenPowerTaskScheduler);
663         controller.foldScreenPolicy_ = nullptr;
664 
665         Drawing::Rect expectedRect = {0, 0, 0, 0};
666         Drawing::Rect actualRect = controller.GetScreenSnapshotRect();
667 
668         EXPECT_EQ(expectedRect.left_, actualRect.left_);
669         EXPECT_EQ(expectedRect.top_, actualRect.top_);
670         EXPECT_EQ(expectedRect.right_, actualRect.right_);
671         EXPECT_EQ(expectedRect.bottom_, actualRect.bottom_);
672     }
673 
674     /**
675      * @tc.name: GetScreenSnapshotRect_ValidPolicy
676      * @tc.desc: test function :GetScreenSnapshotRect
677      * @tc.type: FUNC
678      */
679     HWTEST_F(FoldScreenControllerTest, GetScreenSnapshotRect_ValidPolicy, TestSize.Level1)
680     {
681         std::recursive_mutex mutex;
682         auto screenPowerTaskScheduler = std::shared_ptr<TaskScheduler>();
683         FoldScreenController controller(mutex, screenPowerTaskScheduler);
684         auto mockPolicy = sptr<FoldScreenPolicy>::MakeSptr();
685         controller.foldScreenPolicy_ = mockPolicy;
686         Drawing::Rect expectedRect = {0, 0, 0, 0};
687         Drawing::Rect actualRect = controller.GetScreenSnapshotRect();
688         EXPECT_EQ(expectedRect.left_, actualRect.left_);
689         EXPECT_EQ(expectedRect.top_, actualRect.top_);
690         EXPECT_EQ(expectedRect.right_, actualRect.right_);
691         EXPECT_EQ(expectedRect.bottom_, actualRect.bottom_);
692     }
693 
694     /**
695      * @tc.name: SetMainScreenRegion_ShouldSetMainScreenRegion_WhenFoldScreenPolicyIsNotNull
696      * @tc.desc: Test SetMainScreenRegion method when foldScreenPolicy_ is not null
697      * @tc.type: FUNC
698      */
699     HWTEST_F(FoldScreenControllerTest, SetMainScreenRegion_ShouldSetMainScreenRegion_WhenFoldScreenPolicyIsNotNull,
700         TestSize.Level1)
701     {
702         //Arrange
703         LOG_SetCallback(MyLogCallback);
704         std::recursive_mutex displayInfoMutex;
705         std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = std::shared_ptr<TaskScheduler>();
706         FoldScreenController foldScreenController(displayInfoMutex, screenPowerTaskScheduler);
707         DMRect mainScreenRegion = {0, 0, 1920, 1080};
708         foldScreenController.foldScreenPolicy_ = nullptr;
709 
710         //Act
711         foldScreenController.SetMainScreenRegion(mainScreenRegion);
712 
713         //Assert
714         EXPECT_TRUE(g_errLog.find("foldScreenPolicy_ is null") != std::string::npos);
715     }
716 
717     /**
718      * @tc.name: SetMainScreenRegion_ShouldSetMainScreenRegion_WhenFoldScreenPolicyIsNotNull
719      * @tc.desc: Test SetMainScreenRegion method when foldScreenPolicy_ is null
720      * @tc.type: FUNC
721      */
722     HWTEST_F(FoldScreenControllerTest, SetMainScreenRegion_ShouldSetMainScreenRegion_WhenFoldScreenPolicyIsNull,
723         TestSize.Level1)
724     {
725         //Arrange
726         LOG_SetCallback(MyLogCallback);
727         std::recursive_mutex displayInfoMutex;
728         std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = std::shared_ptr<TaskScheduler>();
729         FoldScreenController foldScreenController(displayInfoMutex, screenPowerTaskScheduler);
730         DMRect mainScreenRegion = {0, 0, 1920, 1080};
731         auto mockPolicy = sptr<FoldScreenPolicy>::MakeSptr();
732         foldScreenController.foldScreenPolicy_ = mockPolicy;
733 
734         //Act
735         foldScreenController.SetMainScreenRegion(mainScreenRegion);
736 
737         //Assert
738         EXPECT_TRUE(g_errLog.find("foldScreenPolicy_ is null") == std::string::npos);
739     }
740 
741     /**
742      * @tc.name: GetTentMode_ShouldReturnFalse_WhenSensorFoldStateManagerIsNull
743      * @tc.desc: Test GetTentMode function when sensorFoldStateManager_ is null
744      * @tc.type: FUNC
745      */
746     HWTEST_F(FoldScreenControllerTest, GetTentMode_ShouldReturnFalse_WhenSensorFoldStateManagerIsNull,
747         TestSize.Level1)
748     {
749         std::recursive_mutex displayInfoMutex;
750         std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = std::shared_ptr<TaskScheduler>();
751         FoldScreenController foldScreenController(displayInfoMutex, screenPowerTaskScheduler);
752         foldScreenController.sensorFoldStateManager_ = nullptr;
753         EXPECT_FALSE(foldScreenController.GetTentMode());
754     }
755 
756     /**
757      * @tc.name: GetTentMode_ShouldReturnFalse_WhenSensorFoldStateManagerIsNotNull
758      * @tc.desc: Test GetTentMode function when sensorFoldStateManager_ is not null
759      * @tc.type: FUNC
760      */
761     HWTEST_F(FoldScreenControllerTest, GetTentMode_ShouldReturnFalse_WhenSensorFoldStateManagerIsNotNull,
762         TestSize.Level1)
763     {
764         std::recursive_mutex displayInfoMutex;
765         std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = std::shared_ptr<TaskScheduler>();
766         FoldScreenController foldScreenController(displayInfoMutex, screenPowerTaskScheduler);
767         foldScreenController.sensorFoldStateManager_ = new SensorFoldStateManager();
768         foldScreenController.sensorFoldStateManager_->SetTentMode(1);
769         EXPECT_TRUE(foldScreenController.GetTentMode());
770     }
771 
772     /**
773      * @tc.name: SetIsClearingBootAnimation
774      * @tc.desc: test function :SetIsClearingBootAnimation
775      * @tc.type: FUNC
776      */
777     HWTEST_F(FoldScreenControllerTest, SetIsClearingBootAnimation, TestSize.Level1)
778     {
779         std::recursive_mutex mutex;
780         auto fsc_ = sptr<FoldScreenController>::MakeSptr(mutex, std::shared_ptr<TaskScheduler>());
781         fsc_->foldScreenPolicy_ = nullptr;
782         fsc_->SetIsClearingBootAnimation(false);
783         fsc_->foldScreenPolicy_ = fsc_->GetFoldScreenPolicy(DisplayDeviceType::SINGLE_DISPLAY_DEVICE);
784         fsc_->SetIsClearingBootAnimation(false);
785         EXPECT_FALSE(fsc_->foldScreenPolicy_->isClearingBootAnimation_);
786         fsc_->SetIsClearingBootAnimation(true);
787         EXPECT_TRUE(fsc_->foldScreenPolicy_->isClearingBootAnimation_);
788     }
789 }
790 } // namespace Rosen
791 } // namespace OHOS
792 
793