1 /*
2 * Copyright (c) 2024 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 <hisysevent.h>
19 #include "fold_screen_controller/single_display_pocket_fold_policy.h"
20 #include "session/screen/include/screen_session.h"
21 #include "screen_session_manager.h"
22 #include "fold_screen_state_internel.h"
23
24 #include "window_manager_hilog.h"
25
26 using namespace testing;
27 using namespace testing::ext;
28
29 namespace OHOS {
30 namespace Rosen {
31 namespace {
32 constexpr uint32_t SLEEP_TIME_US = 100000;
33 }
34
35 class SingleDisplayPocketFoldPolicyTest : public testing::Test {
36 public:
37 static void SetUpTestCase();
38 static void TearDownTestCase();
39 void SetUp() override;
40 void TearDown() override;
41 };
42
SetUpTestCase()43 void SingleDisplayPocketFoldPolicyTest::SetUpTestCase()
44 {
45 }
46
TearDownTestCase()47 void SingleDisplayPocketFoldPolicyTest::TearDownTestCase()
48 {
49 }
50
SetUp()51 void SingleDisplayPocketFoldPolicyTest::SetUp()
52 {
53 }
54
TearDown()55 void SingleDisplayPocketFoldPolicyTest::TearDown()
56 {
57 usleep(SLEEP_TIME_US);
58 }
59
60 namespace {
61 /**
62 * @tc.name: ChangeScreenDisplayMode
63 * @tc.desc: test function : ChangeScreenDisplayMode
64 * @tc.type: FUNC
65 */
66 HWTEST_F(SingleDisplayPocketFoldPolicyTest, ChangeScreenDisplayMode, Function | SmallTest | Level3)
67 {
68 std::recursive_mutex displayInfoMutex;
69 std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = nullptr;
70 SingleDisplayPocketFoldPolicy policy(displayInfoMutex, screenPowerTaskScheduler);
71
72 FoldDisplayMode displayMode = FoldDisplayMode::UNKNOWN;
73 policy.ChangeScreenDisplayMode(displayMode);
74 EXPECT_FALSE(policy.onBootAnimation_);
75
76 displayMode = FoldDisplayMode::MAIN;
77 policy.ChangeScreenDisplayMode(displayMode);
78 EXPECT_FALSE(policy.onBootAnimation_);
79
80 displayMode = FoldDisplayMode::FULL;
81 policy.ChangeScreenDisplayMode(displayMode);
82 EXPECT_FALSE(policy.onBootAnimation_);
83
84 displayMode = FoldDisplayMode::SUB;
85 policy.ChangeScreenDisplayMode(displayMode);
86 EXPECT_FALSE(policy.onBootAnimation_);
87 }
88
89 /**
90 * @tc.name: SendSensorResult
91 * @tc.desc: test function : SendSensorResult
92 * @tc.type: FUNC
93 */
94 HWTEST_F(SingleDisplayPocketFoldPolicyTest, SendSensorResult, Function | SmallTest | Level3)
95 {
96 std::recursive_mutex displayInfoMutex;
97 std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = nullptr;
98 SingleDisplayPocketFoldPolicy policy(displayInfoMutex, screenPowerTaskScheduler);
99
100 FoldStatus foldStatus = FoldStatus::UNKNOWN;
101 policy.SendSensorResult(foldStatus);
102 EXPECT_FALSE(policy.onBootAnimation_);
103 }
104
105 /**
106 * @tc.name: GetCurrentFoldCreaseRegion
107 * @tc.desc: test function : GetCurrentFoldCreaseRegion
108 * @tc.type: FUNC
109 */
110 HWTEST_F(SingleDisplayPocketFoldPolicyTest, GetCurrentFoldCreaseRegion, Function | SmallTest | Level3)
111 {
112 std::recursive_mutex displayInfoMutex;
113 std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = nullptr;
114 SingleDisplayPocketFoldPolicy policy(displayInfoMutex, screenPowerTaskScheduler);
115
116 sptr<FoldCreaseRegion> foldCreaseRegion;
117 foldCreaseRegion = policy.GetCurrentFoldCreaseRegion();
118 EXPECT_EQ(policy.currentFoldCreaseRegion_, foldCreaseRegion);
119 }
120
121 /**
122 * @tc.name: LockDisplayStatus
123 * @tc.desc: test function : LockDisplayStatus
124 * @tc.type: FUNC
125 */
126 HWTEST_F(SingleDisplayPocketFoldPolicyTest, LockDisplayStatus, Function | SmallTest | Level3)
127 {
128 std::recursive_mutex displayInfoMutex;
129 std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = nullptr;
130 SingleDisplayPocketFoldPolicy policy(displayInfoMutex, screenPowerTaskScheduler);
131
132 policy.LockDisplayStatus(false);
133 EXPECT_EQ(policy.lockDisplayStatus_, false);
134 }
135
136 /**
137 * @tc.name: SetOnBootAnimation
138 * @tc.desc: test function : SetOnBootAnimation
139 * @tc.type: FUNC
140 */
141 HWTEST_F(SingleDisplayPocketFoldPolicyTest, SetOnBootAnimation, Function | SmallTest | Level3)
142 {
143 std::recursive_mutex displayInfoMutex;
144 std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = nullptr;
145 SingleDisplayPocketFoldPolicy policy(displayInfoMutex, screenPowerTaskScheduler);
146
147 policy.SetOnBootAnimation(false);
148 EXPECT_FALSE(policy.onBootAnimation_);
149
150 policy.SetOnBootAnimation(true);
151 EXPECT_TRUE(policy.onBootAnimation_);
152 }
153
154 /**
155 * @tc.name: RecoverWhenBootAnimationExit
156 * @tc.desc: test function : RecoverWhenBootAnimationExit
157 * @tc.type: FUNC
158 */
159 HWTEST_F(SingleDisplayPocketFoldPolicyTest, RecoverWhenBootAnimationExit, Function | SmallTest | Level3)
160 {
161 std::recursive_mutex displayInfoMutex;
162 std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = nullptr;
163 SingleDisplayPocketFoldPolicy policy(displayInfoMutex, screenPowerTaskScheduler);
164
165 policy.currentDisplayMode_ = FoldDisplayMode::UNKNOWN;
166 policy.RecoverWhenBootAnimationExit();
167 EXPECT_FALSE(policy.onBootAnimation_);
168
169 policy.currentDisplayMode_ = FoldDisplayMode::SUB;
170 policy.RecoverWhenBootAnimationExit();
171 EXPECT_FALSE(policy.onBootAnimation_);
172
173 policy.currentDisplayMode_ = FoldDisplayMode::FULL;
174 policy.RecoverWhenBootAnimationExit();
175 EXPECT_FALSE(policy.onBootAnimation_);
176
177 policy.currentDisplayMode_ = FoldDisplayMode::MAIN;
178 policy.RecoverWhenBootAnimationExit();
179 EXPECT_FALSE(policy.onBootAnimation_);
180
181 policy.currentDisplayMode_ = FoldDisplayMode::COORDINATION;
182 policy.RecoverWhenBootAnimationExit();
183 EXPECT_FALSE(policy.onBootAnimation_);
184 }
185
186 /**
187 * @tc.name: UpdateForPhyScreenPropertyChange
188 * @tc.desc: test function : UpdateForPhyScreenPropertyChange
189 * @tc.type: FUNC
190 */
191 HWTEST_F(SingleDisplayPocketFoldPolicyTest, UpdateForPhyScreenPropertyChange, Function | SmallTest | Level3)
192 {
193 std::recursive_mutex displayInfoMutex;
194 std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = nullptr;
195 SingleDisplayPocketFoldPolicy policy(displayInfoMutex, screenPowerTaskScheduler);
196
197 policy.currentDisplayMode_ = FoldDisplayMode::UNKNOWN;
198 policy.UpdateForPhyScreenPropertyChange();
199 EXPECT_FALSE(policy.onBootAnimation_);
200
201 policy.currentDisplayMode_ = FoldDisplayMode::SUB;
202 policy.UpdateForPhyScreenPropertyChange();
203 EXPECT_FALSE(policy.onBootAnimation_);
204
205 policy.currentDisplayMode_ = FoldDisplayMode::FULL;
206 policy.UpdateForPhyScreenPropertyChange();
207 EXPECT_FALSE(policy.onBootAnimation_);
208
209 policy.currentDisplayMode_ = FoldDisplayMode::MAIN;
210 policy.UpdateForPhyScreenPropertyChange();
211 EXPECT_FALSE(policy.onBootAnimation_);
212
213 policy.currentDisplayMode_ = FoldDisplayMode::COORDINATION;
214 policy.UpdateForPhyScreenPropertyChange();
215 EXPECT_FALSE(policy.onBootAnimation_);
216 }
217
218 /**
219 * @tc.name: GetModeMatchStatus
220 * @tc.desc: test function : GetModeMatchStatus
221 * @tc.type: FUNC
222 */
223 HWTEST_F(SingleDisplayPocketFoldPolicyTest, GetModeMatchStatus, Function | SmallTest | Level3)
224 {
225 std::recursive_mutex displayInfoMutex;
226 std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = nullptr;
227 SingleDisplayPocketFoldPolicy policy(displayInfoMutex, screenPowerTaskScheduler);
228 FoldDisplayMode displayMode = FoldDisplayMode::UNKNOWN;
229
230 policy.currentFoldStatus_ = FoldStatus::EXPAND;
231 displayMode = policy.GetModeMatchStatus();
232 EXPECT_EQ(FoldDisplayMode::FULL, displayMode);
233
234 policy.currentFoldStatus_ = FoldStatus::FOLDED;
235 displayMode = policy.GetModeMatchStatus();
236 EXPECT_EQ(FoldDisplayMode::MAIN, displayMode);
237
238 policy.currentFoldStatus_ = FoldStatus::HALF_FOLD;
239 displayMode = policy.GetModeMatchStatus();
240 EXPECT_EQ(FoldDisplayMode::FULL, displayMode);
241
242 policy.currentFoldStatus_ = FoldStatus::UNKNOWN;
243 displayMode = policy.GetModeMatchStatus();
244 EXPECT_EQ(FoldDisplayMode::UNKNOWN, displayMode);
245 }
246
247 /**
248 * @tc.name: ReportFoldDisplayModeChange
249 * @tc.desc: test function : ReportFoldDisplayModeChange
250 * @tc.type: FUNC
251 */
252 HWTEST_F(SingleDisplayPocketFoldPolicyTest, ReportFoldDisplayModeChange, Function | SmallTest | Level3)
253 {
254 std::recursive_mutex displayInfoMutex;
255 std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = nullptr;
256 SingleDisplayPocketFoldPolicy policy(displayInfoMutex, screenPowerTaskScheduler);
257
258 FoldDisplayMode displayMode = FoldDisplayMode::UNKNOWN;
259 policy.ReportFoldDisplayModeChange(displayMode);
260 EXPECT_EQ(FoldDisplayMode::UNKNOWN, displayMode);
261
262 displayMode = FoldDisplayMode::FULL;
263 policy.ReportFoldDisplayModeChange(displayMode);
264 EXPECT_NE(FoldDisplayMode::UNKNOWN, displayMode);
265 }
266
267 /**
268 * @tc.name: ReportFoldStatusChangeBegin
269 * @tc.desc: test function : ReportFoldStatusChangeBegin
270 * @tc.type: FUNC
271 */
272 HWTEST_F(SingleDisplayPocketFoldPolicyTest, ReportFoldStatusChangeBegin, Function | SmallTest | Level3)
273 {
274 std::recursive_mutex displayInfoMutex;
275 std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = nullptr;
276 SingleDisplayPocketFoldPolicy policy(displayInfoMutex, screenPowerTaskScheduler);
277
278 int32_t offScreen = 0;
279 int32_t onScreen = 1;
280 policy.ReportFoldStatusChangeBegin(offScreen, onScreen);
281 EXPECT_TRUE(onScreen);
282
283 policy.ReportFoldStatusChangeBegin(offScreen, onScreen);
284 EXPECT_TRUE(onScreen);
285 }
286
287 /**
288 * @tc.name: ChangeScreenDisplayModeToMain
289 * @tc.desc: test function : ChangeScreenDisplayModeToMain
290 * @tc.type: FUNC
291 */
292 HWTEST_F(SingleDisplayPocketFoldPolicyTest, ChangeScreenDisplayModeToMain, Function | SmallTest | Level3)
293 {
294 std::recursive_mutex displayInfoMutex;
295 std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = nullptr;
296 SingleDisplayPocketFoldPolicy policy(displayInfoMutex, screenPowerTaskScheduler);
297 sptr<ScreenSession> screenSession = new ScreenSession;
298
299 policy.onBootAnimation_ = true;
300 policy.ChangeScreenDisplayModeToMain(screenSession);
301 EXPECT_TRUE(policy.onBootAnimation_);
302
303 policy.ChangeScreenDisplayModeToMain(screenSession);
304 EXPECT_TRUE(policy.onBootAnimation_);
305 }
306
307 /**
308 * @tc.name: ChangeScreenDisplayModeToFull
309 * @tc.desc: test function : ChangeScreenDisplayModeToFull
310 * @tc.type: FUNC
311 */
312 HWTEST_F(SingleDisplayPocketFoldPolicyTest, ChangeScreenDisplayModeToFull, Function | SmallTest | Level3)
313 {
314 std::recursive_mutex displayInfoMutex;
315 std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = nullptr;
316 SingleDisplayPocketFoldPolicy policy(displayInfoMutex, screenPowerTaskScheduler);
317 sptr<ScreenSession> screenSession = new ScreenSession;
318
319 policy.onBootAnimation_ = true;
320 policy.ChangeScreenDisplayModeToFull(screenSession);
321 EXPECT_TRUE(policy.onBootAnimation_);
322
323 policy.ChangeScreenDisplayModeToFull(screenSession);
324 EXPECT_TRUE(policy.onBootAnimation_);
325 }
326
327 /**
328 * @tc.name: ChangeScreenDisplayModePower
329 * @tc.desc: test function : ChangeScreenDisplayModePower
330 * @tc.type: FUNC
331 */
332 HWTEST_F(SingleDisplayPocketFoldPolicyTest, ChangeScreenDisplayModePower, Function | SmallTest | Level3)
333 {
334 std::recursive_mutex displayInfoMutex;
335 std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = nullptr;
336 SingleDisplayPocketFoldPolicy policy(displayInfoMutex, screenPowerTaskScheduler);
337 EXPECT_TRUE(1);
338 }
339
340 /**
341 * @tc.name: SendPropertyChangeResult
342 * @tc.desc: test function : SendPropertyChangeResult
343 * @tc.type: FUNC
344 */
345 HWTEST_F(SingleDisplayPocketFoldPolicyTest, SendPropertyChangeResult, Function | SmallTest | Level3)
346 {
347 std::recursive_mutex displayInfoMutex;
348 std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = nullptr;
349 SingleDisplayPocketFoldPolicy policy(displayInfoMutex, screenPowerTaskScheduler);
350 sptr<ScreenSession> screenSession = new ScreenSession;
351 ScreenId screenId = 0;
352 ScreenPropertyChangeReason reason = ScreenPropertyChangeReason::UNDEFINED;
353
354 policy.SendPropertyChangeResult(screenSession, screenId, reason);
355 EXPECT_FALSE(policy.onBootAnimation_);
356 }
357
358 /**
359 * @tc.name: ChangeScreenDisplayModeToMainOnBootAnimation
360 * @tc.desc: test function : ChangeScreenDisplayModeToMainOnBootAnimation
361 * @tc.type: FUNC
362 */
363 HWTEST_F(SingleDisplayPocketFoldPolicyTest, ChangeScreenDisplayModeToMainOnBootAnimation, Function | SmallTest | Level3)
364 {
365 std::recursive_mutex displayInfoMutex;
366 std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = nullptr;
367 SingleDisplayPocketFoldPolicy policy(displayInfoMutex, screenPowerTaskScheduler);
368 sptr<ScreenSession> screenSession = new ScreenSession;
369
370 policy.ChangeScreenDisplayModeToMainOnBootAnimation(screenSession);
371 EXPECT_FALSE(policy.onBootAnimation_);
372 }
373
374 /**
375 * @tc.name: ChangeScreenDisplayModeToFullOnBootAnimation
376 * @tc.desc: test function : ChangeScreenDisplayModeToFullOnBootAnimation
377 * @tc.type: FUNC
378 */
379 HWTEST_F(SingleDisplayPocketFoldPolicyTest, ChangeScreenDisplayModeToFullOnBootAnimation, Function | SmallTest | Level3)
380 {
381 std::recursive_mutex displayInfoMutex;
382 std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = nullptr;
383 SingleDisplayPocketFoldPolicy policy(displayInfoMutex, screenPowerTaskScheduler);
384 sptr<ScreenSession> screenSession = new ScreenSession;
385
386 policy.ChangeScreenDisplayModeToFullOnBootAnimation(screenSession);
387 EXPECT_FALSE(policy.onBootAnimation_);
388 }
389
390 /**
391 * @tc.name: SetdisplayModeChangeStatus01
392 * @tc.desc: test function : SetdisplayModeChangeStatus
393 * @tc.type: FUNC
394 */
395 HWTEST_F(SingleDisplayPocketFoldPolicyTest, SetdisplayModeChangeStatus01, Function | SmallTest | Level3)
396 {
397 std::recursive_mutex displayInfoMutex;
398 std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = nullptr;
399 SingleDisplayPocketFoldPolicy policy(displayInfoMutex, screenPowerTaskScheduler);
400
401 bool status = true;
402 policy.SetdisplayModeChangeStatus(status);
403 EXPECT_EQ(policy.pengdingTask_, 3);
404 }
405
406 /**
407 * @tc.name: SetdisplayModeChangeStatus02
408 * @tc.desc: test function : SetdisplayModeChangeStatus
409 * @tc.type: FUNC
410 */
411 HWTEST_F(SingleDisplayPocketFoldPolicyTest, SetdisplayModeChangeStatus02, Function | SmallTest | Level3)
412 {
413 std::recursive_mutex displayInfoMutex;
414 std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = nullptr;
415 SingleDisplayPocketFoldPolicy policy(displayInfoMutex, screenPowerTaskScheduler);
416
417 bool status = false;
418 policy.SetdisplayModeChangeStatus(status);
419 EXPECT_NE(policy.pengdingTask_, 3);
420 }
421
422 /**
423 * @tc.name: ChangeScreenDisplayMode02
424 * @tc.desc: test function : ChangeScreenDisplayMode02
425 * @tc.type: FUNC
426 */
427 HWTEST_F(SingleDisplayPocketFoldPolicyTest, ChangeScreenDisplayMode02, Function | SmallTest | Level3)
428 {
429 std::recursive_mutex displayInfoMutex;
430 std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = nullptr;
431 SingleDisplayPocketFoldPolicy policy(displayInfoMutex, screenPowerTaskScheduler);
432 sptr<ScreenSession> screenSession = new ScreenSession;
433
434 FoldDisplayMode displayMode = FoldDisplayMode::UNKNOWN;
435 policy.ChangeScreenDisplayMode(displayMode);
436 EXPECT_FALSE(policy.onBootAnimation_);
437
438 displayMode = FoldDisplayMode::MAIN;
439 policy.ChangeScreenDisplayMode(displayMode);
440 EXPECT_FALSE(policy.onBootAnimation_);
441
442 displayMode = FoldDisplayMode::FULL;
443 policy.ChangeScreenDisplayMode(displayMode);
444 EXPECT_FALSE(policy.onBootAnimation_);
445
446 displayMode = FoldDisplayMode::SUB;
447 policy.ChangeScreenDisplayMode(displayMode);
448 EXPECT_FALSE(policy.onBootAnimation_);
449
450 displayMode = FoldDisplayMode::COORDINATION;
451 policy.ChangeScreenDisplayMode(displayMode);
452 EXPECT_FALSE(policy.onBootAnimation_);
453 }
454
455 /**
456 * @tc.name: ChangeScreenDisplayModeToCoordination
457 * @tc.desc: test function : ChangeScreenDisplayModeToCoordination
458 * @tc.type: FUNC
459 */
460 HWTEST_F(SingleDisplayPocketFoldPolicyTest, ChangeScreenDisplayModeToCoordination, Function | SmallTest | Level3)
461 {
462 std::recursive_mutex displayInfoMutex;
463 std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = nullptr;
464 SingleDisplayPocketFoldPolicy policy(displayInfoMutex, screenPowerTaskScheduler);
465
466 policy.screenPowerTaskScheduler_ = std::make_shared<TaskScheduler>("Test");
467 policy.ChangeScreenDisplayModeToCoordination();
468 EXPECT_EQ(ScreenSessionManager::GetInstance().isCoordinationFlag_, true);
469 }
470
471 /**
472 * @tc.name: CloseCoordinationScreen
473 * @tc.desc: test function : CloseCoordinationScreen
474 * @tc.type: FUNC
475 */
476 HWTEST_F(SingleDisplayPocketFoldPolicyTest, CloseCoordinationScreen, Function | SmallTest | Level3)
477 {
478 if (FoldScreenStateInternel::IsSingleDisplayPocketFoldDevice()) {
479 std::recursive_mutex displayInfoMutex;
480 std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = nullptr;
481 SingleDisplayPocketFoldPolicy policy(displayInfoMutex, screenPowerTaskScheduler);
482
483 policy.screenPowerTaskScheduler_ = std::make_shared<TaskScheduler>("Test");
484 policy.CloseCoordinationScreen();
485 EXPECT_EQ(ScreenSessionManager::GetInstance().isCoordinationFlag_, false);
486 }
487 }
488
489 /**
490 * @tc.name: ExitCoordination
491 * @tc.desc: test function : ExitCoordination
492 * @tc.type: FUNC
493 */
494 HWTEST_F(SingleDisplayPocketFoldPolicyTest, ExitCoordination, Function | SmallTest | Level3)
495 {
496 if (FoldScreenStateInternel::IsSingleDisplayPocketFoldDevice()) {
497 std::recursive_mutex displayInfoMutex;
498 std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = nullptr;
499 SingleDisplayPocketFoldPolicy policy(displayInfoMutex, screenPowerTaskScheduler);
500
501 policy.currentFoldStatus_ = FoldStatus::EXPAND;
502 policy.ExitCoordination();
503 EXPECT_EQ(policy.currentDisplayMode_, FoldDisplayMode::FULL);
504 EXPECT_EQ(policy.lastDisplayMode_, FoldDisplayMode::FULL);
505 }
506 }
507
508 /**
509 * @tc.name: ChangeOnTentMode
510 * @tc.desc: test function : ChangeOnTentMode
511 * @tc.type: FUNC
512 */
513 HWTEST_F(SingleDisplayPocketFoldPolicyTest, ChangeOnTentMode, Function | SmallTest | Level3)
514 {
515 std::recursive_mutex displayInfoMutex;
516 std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = nullptr;
517 SingleDisplayPocketFoldPolicy policy(displayInfoMutex, screenPowerTaskScheduler);
518
519 FoldStatus currentState = FoldStatus::EXPAND;
520 policy.ChangeOnTentMode(currentState);
521 EXPECT_EQ(policy.lastCachedisplayMode_, FoldDisplayMode::MAIN);
522
523 currentState = FoldStatus::HALF_FOLD;
524 policy.ChangeOnTentMode(currentState);
525 EXPECT_EQ(policy.lastCachedisplayMode_, FoldDisplayMode::MAIN);
526
527 currentState = FoldStatus::FOLDED;
528 policy.ChangeOnTentMode(currentState);
529 EXPECT_EQ(policy.lastCachedisplayMode_, FoldDisplayMode::MAIN);
530
531 currentState = FoldStatus::UNKNOWN;
532 policy.ChangeOnTentMode(currentState);
533 EXPECT_EQ(policy.lastCachedisplayMode_, FoldDisplayMode::MAIN);
534 }
535
536 /**
537 * @tc.name: ChangeOffTentMode
538 * @tc.desc: test function : ChangeOffTentMode
539 * @tc.type: FUNC
540 */
541 HWTEST_F(SingleDisplayPocketFoldPolicyTest, ChangeOffTentMode, Function | SmallTest | Level3)
542 {
543 std::recursive_mutex displayInfoMutex;
544 std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = nullptr;
545 SingleDisplayPocketFoldPolicy policy(displayInfoMutex, screenPowerTaskScheduler);
546
547 policy.ChangeOffTentMode();
548 FoldDisplayMode displayMode = policy.GetModeMatchStatus();
549 EXPECT_EQ(policy.lastCachedisplayMode_, displayMode);
550 }
551 }
552 } // namespace Rosen
553 } // namespace OHOS