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: ChangeScreenDisplayModeToCoordination
392 * @tc.desc: test function : ChangeScreenDisplayModeToCoordination
393 * @tc.type: FUNC
394 */
395 HWTEST_F(SingleDisplayPocketFoldPolicyTest, ChangeScreenDisplayModeToCoordination, Function | SmallTest | Level3)
396 {
397 std::recursive_mutex displayInfoMutex;
398 std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = nullptr;
399 SingleDisplayPocketFoldPolicy policy(displayInfoMutex, screenPowerTaskScheduler);
400
401 policy.screenPowerTaskScheduler_ = std::make_shared<TaskScheduler>("Test");
402 policy.ChangeScreenDisplayModeToCoordination();
403 EXPECT_EQ(ScreenSessionManager::GetInstance().isCoordinationFlag_, true);
404 }
405
406 /**
407 * @tc.name: CloseCoordinationScreen
408 * @tc.desc: test function : CloseCoordinationScreen
409 * @tc.type: FUNC
410 */
411 HWTEST_F(SingleDisplayPocketFoldPolicyTest, CloseCoordinationScreen, Function | SmallTest | Level3)
412 {
413 if (FoldScreenStateInternel::IsSingleDisplayPocketFoldDevice()) {
414 std::recursive_mutex displayInfoMutex;
415 std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = nullptr;
416 SingleDisplayPocketFoldPolicy policy(displayInfoMutex, screenPowerTaskScheduler);
417
418 policy.screenPowerTaskScheduler_ = std::make_shared<TaskScheduler>("Test");
419 policy.CloseCoordinationScreen();
420 EXPECT_EQ(ScreenSessionManager::GetInstance().isCoordinationFlag_, false);
421 }
422 }
423
424 /**
425 * @tc.name: ExitCoordination
426 * @tc.desc: test function : ExitCoordination
427 * @tc.type: FUNC
428 */
429 HWTEST_F(SingleDisplayPocketFoldPolicyTest, ExitCoordination, Function | SmallTest | Level3)
430 {
431 if (FoldScreenStateInternel::IsSingleDisplayPocketFoldDevice()) {
432 std::recursive_mutex displayInfoMutex;
433 std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = nullptr;
434 SingleDisplayPocketFoldPolicy policy(displayInfoMutex, screenPowerTaskScheduler);
435
436 policy.currentFoldStatus_ = FoldStatus::EXPAND;
437 policy.ExitCoordination();
438 EXPECT_EQ(policy.currentDisplayMode_, FoldDisplayMode::FULL);
439 EXPECT_EQ(policy.lastDisplayMode_, FoldDisplayMode::FULL);
440 }
441 }
442
443 /**
444 * @tc.name: SetdisplayModeChangeStatus01
445 * @tc.desc: test function : SetdisplayModeChangeStatus
446 * @tc.type: FUNC
447 */
448 HWTEST_F(SingleDisplayPocketFoldPolicyTest, SetdisplayModeChangeStatus01, Function | SmallTest | Level3)
449 {
450 std::recursive_mutex displayInfoMutex;
451 std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = nullptr;
452 SingleDisplayPocketFoldPolicy policy(displayInfoMutex, screenPowerTaskScheduler);
453
454 bool status = true;
455 policy.SetdisplayModeChangeStatus(status);
456 EXPECT_EQ(policy.pengdingTask_, 3);
457 }
458
459 /**
460 * @tc.name: SetdisplayModeChangeStatus02
461 * @tc.desc: test function : SetdisplayModeChangeStatus
462 * @tc.type: FUNC
463 */
464 HWTEST_F(SingleDisplayPocketFoldPolicyTest, SetdisplayModeChangeStatus02, Function | SmallTest | Level3)
465 {
466 std::recursive_mutex displayInfoMutex;
467 std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = nullptr;
468 SingleDisplayPocketFoldPolicy policy(displayInfoMutex, screenPowerTaskScheduler);
469
470 bool status = false;
471 policy.SetdisplayModeChangeStatus(status);
472 EXPECT_NE(policy.pengdingTask_, 3);
473 }
474
475 /**
476 * @tc.name: ChangeScreenDisplayMode02
477 * @tc.desc: test function : ChangeScreenDisplayMode02
478 * @tc.type: FUNC
479 */
480 HWTEST_F(SingleDisplayPocketFoldPolicyTest, ChangeScreenDisplayMode02, Function | SmallTest | Level3)
481 {
482 std::recursive_mutex displayInfoMutex;
483 std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = nullptr;
484 SingleDisplayPocketFoldPolicy policy(displayInfoMutex, screenPowerTaskScheduler);
485 sptr<ScreenSession> screenSession = new ScreenSession;
486
487 FoldDisplayMode displayMode = FoldDisplayMode::UNKNOWN;
488 policy.ChangeScreenDisplayMode(displayMode);
489 EXPECT_FALSE(policy.onBootAnimation_);
490
491 displayMode = FoldDisplayMode::MAIN;
492 policy.ChangeScreenDisplayMode(displayMode);
493 EXPECT_FALSE(policy.onBootAnimation_);
494
495 displayMode = FoldDisplayMode::FULL;
496 policy.ChangeScreenDisplayMode(displayMode);
497 EXPECT_FALSE(policy.onBootAnimation_);
498
499 displayMode = FoldDisplayMode::SUB;
500 policy.ChangeScreenDisplayMode(displayMode);
501 EXPECT_FALSE(policy.onBootAnimation_);
502 }
503
504 /**
505 * @tc.name: ChangeOnTentMode
506 * @tc.desc: test function : ChangeOnTentMode
507 * @tc.type: FUNC
508 */
509 HWTEST_F(SingleDisplayPocketFoldPolicyTest, ChangeOnTentMode, Function | SmallTest | Level3)
510 {
511 std::recursive_mutex displayInfoMutex;
512 std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = nullptr;
513 SingleDisplayPocketFoldPolicy policy(displayInfoMutex, screenPowerTaskScheduler);
514
515 FoldStatus currentState = FoldStatus::EXPAND;
516 policy.ChangeOnTentMode(currentState);
517 EXPECT_EQ(policy.lastCachedisplayMode_, FoldDisplayMode::MAIN);
518
519 currentState = FoldStatus::HALF_FOLD;
520 policy.ChangeOnTentMode(currentState);
521 EXPECT_EQ(policy.lastCachedisplayMode_, FoldDisplayMode::MAIN);
522
523 currentState = FoldStatus::FOLDED;
524 policy.ChangeOnTentMode(currentState);
525 EXPECT_EQ(policy.lastCachedisplayMode_, FoldDisplayMode::MAIN);
526
527 currentState = FoldStatus::UNKNOWN;
528 policy.ChangeOnTentMode(currentState);
529 EXPECT_EQ(policy.lastCachedisplayMode_, FoldDisplayMode::MAIN);
530 }
531
532 /**
533 * @tc.name: ChangeOffTentMode
534 * @tc.desc: test function : ChangeOffTentMode
535 * @tc.type: FUNC
536 */
537 HWTEST_F(SingleDisplayPocketFoldPolicyTest, ChangeOffTentMode, Function | SmallTest | Level3)
538 {
539 std::recursive_mutex displayInfoMutex;
540 std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = nullptr;
541 SingleDisplayPocketFoldPolicy policy(displayInfoMutex, screenPowerTaskScheduler);
542
543 policy.ChangeOffTentMode();
544 FoldDisplayMode displayMode = policy.GetModeMatchStatus();
545 EXPECT_EQ(policy.lastCachedisplayMode_, displayMode);
546 }
547 }
548 } // namespace Rosen
549 } // namespace OHOS