• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "interfaces/include/ws_common.h"
19 #include "iremote_object_mocker.h"
20 #include "mock/mock_accesstoken_kit.h"
21 #include "session_manager/include/scene_session_manager.h"
22 #include "session_info.h"
23 #include "session/host/include/scene_session.h"
24 #include "session_manager.h"
25 #define private public
26 #include "session/host/include/keyboard_session.h"
27 #undef private
28 
29 using namespace testing;
30 using namespace testing::ext;
31 
32 namespace OHOS {
33 namespace Rosen {
34 namespace {
35 const std::string EMPTY_DEVICE_ID = "";
36 using ConfigItem = WindowSceneConfig::ConfigItem;
37 } // namespace
38 class SceneSessionManagerTest7 : public testing::Test {
39 public:
40     static void SetUpTestCase();
41     static void TearDownTestCase();
42     void SetUp() override;
43     void TearDown() override;
44 
45     static bool gestureNavigationEnabled_;
46     static ProcessGestureNavigationEnabledChangeFunc callbackFunc_;
47     static sptr<SceneSessionManager> ssm_;
48 
49     static constexpr uint32_t WAIT_SYNC_IN_NS = 200000;
50     static constexpr uint32_t WAIT_SYNC_FOR_SNAPSHOT_SKIP_IN_NS = 500000;
51     static constexpr uint32_t WAIT_SYNC_FOR_TEST_END_IN_NS = 1000000;
52 };
53 
54 sptr<SceneSessionManager> SceneSessionManagerTest7::ssm_ = nullptr;
55 
56 bool SceneSessionManagerTest7::gestureNavigationEnabled_ = true;
57 ProcessGestureNavigationEnabledChangeFunc SceneSessionManagerTest7::callbackFunc_ =
__anonfcc6fbfd0202(bool enable, const std::string& bundleName, GestureBackType type) 58     [](bool enable, const std::string& bundleName, GestureBackType type) { gestureNavigationEnabled_ = enable; };
59 
SetUpTestCase()60 void SceneSessionManagerTest7::SetUpTestCase()
61 {
62     ssm_ = &SceneSessionManager::GetInstance();
63 }
64 
TearDownTestCase()65 void SceneSessionManagerTest7::TearDownTestCase()
66 {
67     ssm_ = nullptr;
68 }
69 
SetUp()70 void SceneSessionManagerTest7::SetUp()
71 {
72     ssm_->sceneSessionMap_.clear();
73 }
74 
TearDown()75 void SceneSessionManagerTest7::TearDown()
76 {
77     MockAccesstokenKit::ChangeMockStateToInit();
78     usleep(WAIT_SYNC_IN_NS);
79     ssm_->sceneSessionMap_.clear();
80 }
81 
82 namespace {
83 /**
84  * @tc.name: UpdateSessionWindowVisibilityListener
85  * @tc.desc: UpdateSessionWindowVisibilityListener
86  * @tc.type: FUNC
87  */
88 HWTEST_F(SceneSessionManagerTest7, UpdateSessionWindowVisibilityListener, TestSize.Level1)
89 {
90     int32_t persistentId = 1;
91     bool haveListener = true;
92     ASSERT_NE(nullptr, ssm_);
93     ssm_->sceneSessionMap_.clear();
94     auto ret = ssm_->UpdateSessionWindowVisibilityListener(persistentId, haveListener);
95     EXPECT_EQ(ret, WSError::WS_DO_NOTHING);
96     SessionInfo sessionInfo;
97     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
98     sessionInfo.abilityName_ = "UpdateSessionWindowVisibilityListener";
99     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
100     ASSERT_NE(nullptr, sceneSession);
101     sceneSession->callingPid_ = 65535;
102     ssm_->sceneSessionMap_.insert(std::make_pair(persistentId, sceneSession));
103     ret = ssm_->UpdateSessionWindowVisibilityListener(persistentId, haveListener);
104     EXPECT_EQ(ret, WSError::WS_ERROR_INVALID_PERMISSION);
105 }
106 
107 /**
108  * @tc.name: ProcessVirtualPixelRatioChange
109  * @tc.desc: ProcessVirtualPixelRatioChange
110  * @tc.type: FUNC
111  */
112 HWTEST_F(SceneSessionManagerTest7, ProcessVirtualPixelRatioChange, TestSize.Level1)
113 {
114     DisplayId defaultDisplayId = 0;
115     sptr<DisplayInfo> displayInfo = nullptr;
116     std::map<DisplayId, sptr<DisplayInfo>> displayInfoMap;
117     DisplayStateChangeType type = DisplayStateChangeType::BEFORE_SUSPEND;
118     ASSERT_NE(nullptr, ssm_);
119     ssm_->ProcessVirtualPixelRatioChange(defaultDisplayId, displayInfo, displayInfoMap, type);
120     displayInfo = sptr<DisplayInfo>::MakeSptr();
121     ASSERT_NE(nullptr, displayInfo);
122     ssm_->sceneSessionMap_.clear();
123     ssm_->ProcessVirtualPixelRatioChange(defaultDisplayId, displayInfo, displayInfoMap, type);
124     SessionInfo sessionInfo;
125     sessionInfo.bundleName_ = "SceneSessionManagerTest6";
126     sessionInfo.abilityName_ = "UpdateAvoidArea";
127     sessionInfo.isSystem_ = true;
128     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
129     ASSERT_NE(nullptr, sceneSession);
130     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
131     ssm_->ProcessVirtualPixelRatioChange(defaultDisplayId, displayInfo, displayInfoMap, type);
132     sessionInfo.isSystem_ = false;
133     ssm_->ProcessVirtualPixelRatioChange(defaultDisplayId, displayInfo, displayInfoMap, type);
134     sceneSession->SetSessionState(SessionState::STATE_FOREGROUND);
135     ssm_->ProcessVirtualPixelRatioChange(defaultDisplayId, displayInfo, displayInfoMap, type);
136     sceneSession->SetSessionState(SessionState::STATE_ACTIVE);
137     ssm_->ProcessVirtualPixelRatioChange(defaultDisplayId, displayInfo, displayInfoMap, type);
138     sceneSession->SetSessionState(SessionState::STATE_INACTIVE);
139     ssm_->ProcessVirtualPixelRatioChange(defaultDisplayId, displayInfo, displayInfoMap, type);
140     sceneSession = nullptr;
141     ssm_->ProcessVirtualPixelRatioChange(defaultDisplayId, displayInfo, displayInfoMap, type);
142 }
143 
144 /**
145  * @tc.name: ProcessVirtualPixelRatioChange01
146  * @tc.desc: ProcessVirtualPixelRatioChange
147  * @tc.type: FUNC
148  */
149 HWTEST_F(SceneSessionManagerTest7, ProcessVirtualPixelRatioChange01, TestSize.Level1)
150 {
151     DisplayId defaultDisplayId = 0;
152     sptr<DisplayInfo> displayInfo = sptr<DisplayInfo>::MakeSptr();
153     std::map<DisplayId, sptr<DisplayInfo>> displayInfoMap;
154     DisplayStateChangeType type = DisplayStateChangeType::BEFORE_SUSPEND;
155     ASSERT_NE(nullptr, displayInfo);
156     ASSERT_NE(nullptr, ssm_);
157     ssm_->processVirtualPixelRatioChangeFunc_ = nullptr;
158     displayInfo->SetVirtualPixelRatio(0.1f);
159     displayInfo->SetDensityInCurResolution(0.1f);
160     ssm_->ProcessVirtualPixelRatioChange(defaultDisplayId, displayInfo, displayInfoMap, type);
__anonfcc6fbfd0402(float ratio, const OHOS::Rosen::Rect& rect) 161     ProcessVirtualPixelRatioChangeFunc func = [](float ratio, const OHOS::Rosen::Rect& rect) {};
162     ssm_->SetVirtualPixelRatioChangeListener(func);
163     ASSERT_NE(nullptr, ssm_->processVirtualPixelRatioChangeFunc_);
164     ssm_->ProcessVirtualPixelRatioChange(defaultDisplayId, displayInfo, displayInfoMap, type);
165     displayInfo->SetDensityInCurResolution(0.2f);
166     ssm_->ProcessVirtualPixelRatioChange(defaultDisplayId, displayInfo, displayInfoMap, type);
167     ssm_->processVirtualPixelRatioChangeFunc_ = nullptr;
168     ssm_->ProcessVirtualPixelRatioChange(defaultDisplayId, displayInfo, displayInfoMap, type);
169 }
170 
171 /**
172  * @tc.name: ProcessUpdateRotationChange
173  * @tc.desc: ProcessUpdateRotationChange
174  * @tc.type: FUNC
175  */
176 HWTEST_F(SceneSessionManagerTest7, ProcessUpdateRotationChange, TestSize.Level1)
177 {
178     DisplayId defaultDisplayId = 0;
179     sptr<DisplayInfo> displayInfo = nullptr;
180     std::map<DisplayId, sptr<DisplayInfo>> displayInfoMap;
181     DisplayStateChangeType type = DisplayStateChangeType::BEFORE_SUSPEND;
182     ASSERT_NE(nullptr, ssm_);
183     ssm_->ProcessUpdateRotationChange(defaultDisplayId, displayInfo, displayInfoMap, type);
184     displayInfo = sptr<DisplayInfo>::MakeSptr();
185     ASSERT_NE(nullptr, displayInfo);
186     SessionInfo sessionInfo;
187     sessionInfo.bundleName_ = "SceneSessionManagerTest6";
188     sessionInfo.abilityName_ = "UpdateAvoidArea";
189     sessionInfo.isSystem_ = true;
190     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
191     ASSERT_NE(nullptr, sceneSession);
192     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
193     sceneSession->SetSessionState(SessionState::STATE_FOREGROUND);
194     ssm_->ProcessUpdateRotationChange(defaultDisplayId, displayInfo, displayInfoMap, type);
195     sceneSession->SetSessionState(SessionState::STATE_ACTIVE);
196     ssm_->ProcessUpdateRotationChange(defaultDisplayId, displayInfo, displayInfoMap, type);
197     sceneSession->SetSessionState(SessionState::STATE_INACTIVE);
198     ssm_->ProcessUpdateRotationChange(defaultDisplayId, displayInfo, displayInfoMap, type);
199     WSRectF bounds = { 0, 0, 0, 0 };
200     sceneSession->SetBounds(bounds);
201     displayInfo->width_ = 0;
202     displayInfo->height_ = 0;
203     Rotation rotation = Rotation::ROTATION_0;
204     sceneSession->SetRotation(rotation);
205     displayInfo->SetRotation(rotation);
206     ssm_->ProcessUpdateRotationChange(defaultDisplayId, displayInfo, displayInfoMap, type);
207 }
208 
209 /**
210  * @tc.name: FlushUIParams
211  * @tc.desc: FlushUIParams
212  * @tc.type: FUNC
213  */
214 HWTEST_F(SceneSessionManagerTest7, FlushUIParams, TestSize.Level1)
215 {
216     SessionInfo sessionInfo;
217     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
218     sessionInfo.abilityName_ = "FlushUIParams";
219     sessionInfo.screenId_ = 1;
220     ScreenId screenId = 2;
221     std::unordered_map<int32_t, SessionUIParam> uiParams;
222     uiParams.clear();
223     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
224     ASSERT_NE(nullptr, sceneSession);
225     ASSERT_NE(nullptr, sceneSession->property_);
226     sceneSession->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
227     ASSERT_NE(nullptr, ssm_);
228     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
229     ssm_->FlushUIParams(screenId, std::move(uiParams));
230     sceneSession->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_END);
231     ssm_->FlushUIParams(screenId, std::move(uiParams));
232 }
233 
234 /**
235  * @tc.name: FlushUIParams01
236  * @tc.desc: FlushUIParams
237  * @tc.type: FUNC
238  */
239 HWTEST_F(SceneSessionManagerTest7, FlushUIParams01, TestSize.Level1)
240 {
241     SessionInfo sessionInfo;
242     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
243     sessionInfo.abilityName_ = "FlushUIParams01";
244     sessionInfo.screenId_ = 2;
245     ScreenId screenId = 2;
246     std::unordered_map<int32_t, SessionUIParam> uiParams;
247     uiParams.clear();
248     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
249     ASSERT_NE(nullptr, sceneSession);
250     ASSERT_NE(nullptr, sceneSession->property_);
251     sceneSession->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
252     sceneSession->persistentId_ = 1;
253     ASSERT_NE(nullptr, ssm_);
254     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
255     SessionUIParam sessionUIParam;
256     uiParams.insert(std::make_pair(1, sessionUIParam));
257     ssm_->FlushUIParams(screenId, std::move(uiParams));
258     sessionInfo.screenId_ = -1ULL;
259     ssm_->FlushUIParams(screenId, std::move(uiParams));
260 }
261 
262 /**
263  * @tc.name: FlushUIParams02
264  * @tc.desc: FlushUIParams Multi-screen
265  * @tc.type: FUNC
266  */
267 HWTEST_F(SceneSessionManagerTest7, FlushUIParams02, Function | SmallTest | Level3)
268 {
269     SessionInfo sessionInfo;
270     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
271     sessionInfo.abilityName_ = "FlushUIParams02";
272     sessionInfo.screenId_ = 2;
273     ScreenId screenId = 2;
274     std::unordered_map<int32_t, SessionUIParam> uiParams;
275     uiParams.clear();
276     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
277     ASSERT_NE(nullptr, sceneSession);
278     sceneSession->persistentId_ = 1;
279     sceneSession->dirtyFlags_ |= static_cast<uint32_t>(SessionUIDirtyFlag::RECT);
280     ASSERT_NE(nullptr, ssm_);
281     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
282     SessionUIParam sessionUIParam;
283     uiParams.insert(std::make_pair(1, sessionUIParam));
284     ssm_->FlushUIParams(screenId, std::move(uiParams));
285     sessionInfo.screenId_ = -1ULL;
286     ssm_->FlushUIParams(screenId, std::move(uiParams));
287     ASSERT_NE(sceneSession->dirtyFlags_, 0);
288 }
289 
290 /**
291  * @tc.name: FlushUIParams03
292  * @tc.desc: FlushUIParams keyboard
293  * @tc.type: FUNC
294  */
295 HWTEST_F(SceneSessionManagerTest7, FlushUIParams03, Function | SmallTest | Level3)
296 {
297     SessionInfo callingSessionInfo;
298     callingSessionInfo.bundleName_ = "SceneSessionManagerTest7";
299     callingSessionInfo.abilityName_ = "FlushUIParams03";
300     callingSessionInfo.screenId_ = 2;
301     ScreenId screenId = 2;
302     std::unordered_map<int32_t, SessionUIParam> uiParams;
303     uiParams.clear();
304     sptr<SceneSession> callingSession = sptr<SceneSession>::MakeSptr(callingSessionInfo, nullptr);
305     callingSession->persistentId_ = 1;
306 
307     SessionInfo keyboardSessionInfo;
308     keyboardSessionInfo.abilityName_ = "keyboardSession";
309     keyboardSessionInfo.bundleName_ = "keyboardSession";
310     sptr<KeyboardSession> keyboardSession = sptr<KeyboardSession>::MakeSptr(keyboardSessionInfo, nullptr, nullptr);
311     keyboardSession->property_->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
312     keyboardSession->property_->SetCallingSessionId(1);
313     keyboardSession->persistentId_ = 3;
314     keyboardSession->SetIsSystemKeyboard(false);
315     keyboardSession->SetScreenId(2);
316 
317     ASSERT_NE(nullptr, ssm_);
318     ssm_->sceneSessionMap_.clear();
319     ssm_->sceneSessionMap_.insert({1, callingSession});
320     ssm_->sceneSessionMap_.insert({3, keyboardSession});
321     SessionUIParam callingSessionUIParam;
322     SessionUIParam keyboardSessionUIParam;
323     uiParams.insert(std::make_pair(1, callingSessionUIParam));
324     uiParams.insert(std::make_pair(3, keyboardSessionUIParam));
325     keyboardSession->stateChanged_ = true;
326     ssm_->FlushUIParams(screenId, std::move(uiParams));
327     usleep(WAIT_SYNC_IN_NS);
328     EXPECT_EQ(false, keyboardSession->stateChanged_);
329 
330     uiParams.clear();
331     uiParams.insert(std::make_pair(1, callingSessionUIParam));
332     uiParams.insert(std::make_pair(3, keyboardSessionUIParam));
333     keyboardSession->SetScreenId(999);
334     keyboardSession->stateChanged_ = true;
335     ssm_->FlushUIParams(screenId, std::move(uiParams));
336     usleep(WAIT_SYNC_IN_NS);
337     EXPECT_EQ(true, keyboardSession->stateChanged_);
338 }
339 
340 /**
341  * @tc.name: RegisterIAbilityManagerCollaborator
342  * @tc.desc: RegisterIAbilityManagerCollaborator
343  * @tc.type: FUNC
344  */
345 HWTEST_F(SceneSessionManagerTest7, RegisterIAbilityManagerCollaborator, TestSize.Level1)
346 {
347     int32_t type = 0;
348     sptr<AAFwk::IAbilityManagerCollaborator> impl = nullptr;
349     ASSERT_NE(nullptr, ssm_);
350     MockAccesstokenKit::MockAccessTokenKitRet(-1);
351     auto ret = ssm_->RegisterIAbilityManagerCollaborator(type, impl);
352     EXPECT_EQ(ret, WSError::WS_ERROR_INVALID_PERMISSION);
353 }
354 
355 /**
356  * @tc.name: ProcessBackEvent
357  * @tc.desc: ProcessBackEvent
358  * @tc.type: FUNC
359  */
360 HWTEST_F(SceneSessionManagerTest7, ProcessBackEvent, TestSize.Level1)
361 {
362     SessionInfo sessionInfo;
363     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
364     sessionInfo.abilityName_ = "FlushUIParams01";
365     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
366     ASSERT_NE(nullptr, sceneSession);
367     ASSERT_NE(nullptr, ssm_);
368     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
369     auto focusGroup = ssm_->windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID);
370     focusGroup->SetFocusedSessionId(1);
371     ssm_->needBlockNotifyFocusStatusUntilForeground_ = true;
372     auto ret = ssm_->ProcessBackEvent();
373     EXPECT_EQ(ret, WSError::WS_OK);
374     ssm_->needBlockNotifyFocusStatusUntilForeground_ = false;
375     sessionInfo.isSystem_ = true;
376     ssm_->rootSceneProcessBackEventFunc_ = nullptr;
377     ret = ssm_->ProcessBackEvent();
378     EXPECT_EQ(ret, WSError::WS_OK);
__anonfcc6fbfd0502() 379     RootSceneProcessBackEventFunc func = []() {};
380     ssm_->rootSceneProcessBackEventFunc_ = func;
381     ASSERT_NE(nullptr, ssm_->rootSceneProcessBackEventFunc_);
382     ret = ssm_->ProcessBackEvent();
383     EXPECT_EQ(ret, WSError::WS_OK);
384     sessionInfo.isSystem_ = false;
385     ret = ssm_->ProcessBackEvent();
386     EXPECT_EQ(ret, WSError::WS_OK);
387     ssm_->rootSceneProcessBackEventFunc_ = nullptr;
388     ret = ssm_->ProcessBackEvent();
389     EXPECT_EQ(ret, WSError::WS_OK);
390 }
391 
392 /**
393  * @tc.name: DestroySpecificSession
394  * @tc.desc: DestroySpecificSession
395  * @tc.type: FUNC
396  */
397 HWTEST_F(SceneSessionManagerTest7, DestroySpecificSession, TestSize.Level1)
398 {
399     ASSERT_NE(nullptr, ssm_);
400     ssm_->remoteObjectMap_.clear();
401     sptr<IRemoteObject> remoteObject = sptr<IRemoteObjectMocker>::MakeSptr();
402     ASSERT_NE(nullptr, remoteObject);
403     ssm_->DestroySpecificSession(remoteObject);
404     ssm_->remoteObjectMap_.insert(std::make_pair(remoteObject, 1));
405     SessionInfo sessionInfo;
406     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
407     sessionInfo.abilityName_ = "DestroySpecificSession";
408     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
409     ASSERT_NE(nullptr, sceneSession);
410     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
411     ssm_->DestroySpecificSession(remoteObject);
412     sceneSession = nullptr;
413     ssm_->DestroySpecificSession(remoteObject);
414 }
415 
416 /**
417  * @tc.name: DestroyAndDisconnectSpecificSessionWithDetachCallback
418  * @tc.desc: DestroyAndDisconnectSpecificSessionWithDetachCallback
419  * @tc.type: FUNC
420  */
421 HWTEST_F(SceneSessionManagerTest7, DestroyAndDisconnectSpecificSessionWithDetachCallback, TestSize.Level0)
422 {
423     int32_t persistentId = 1;
424     sptr<IRemoteObject> callback = sptr<IRemoteObjectMocker>::MakeSptr();
425     ASSERT_NE(nullptr, callback);
426     SessionInfo sessionInfo;
427     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
428     sessionInfo.abilityName_ = "DestroyAndDisconnectSpecificSessionWithDetachCallback";
429     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
430     ASSERT_NE(nullptr, sceneSession);
431     sceneSession->SetCallingUid(1);
432     ASSERT_NE(nullptr, ssm_);
433     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
434     auto ret = ssm_->DestroyAndDisconnectSpecificSessionWithDetachCallback(persistentId, callback);
435     EXPECT_EQ(ret, WSError::WS_ERROR_INVALID_PERMISSION);
436 }
437 
438 /**
439  * @tc.name: DestroyAndDisconnectSpecificSessionInner
440  * @tc.desc: DestroyAndDisconnectSpecificSessionInner
441  * @tc.type: FUNC
442  */
443 HWTEST_F(SceneSessionManagerTest7, DestroyAndDisconnectSpecificSessionInner, TestSize.Level0)
444 {
445     SessionInfo sessionInfo;
446     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
447     sessionInfo.abilityName_ = "DestroyAndDisconnectSpecificSessionInner";
448     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
449     ASSERT_NE(nullptr, sceneSession);
450     ASSERT_NE(nullptr, sceneSession->property_);
451     sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
452     sceneSession->SetParentPersistentId(2);
453     SessionInfo sessionInfo1;
454     sessionInfo1.bundleName_ = "SceneSessionManagerTest7";
455     sessionInfo1.abilityName_ = "ParentSceneSession";
456     sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(sessionInfo1, nullptr);
457     ASSERT_NE(nullptr, sceneSession1);
458     ASSERT_NE(nullptr, ssm_);
459     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
460     ssm_->sceneSessionMap_.insert(std::make_pair(2, sceneSession1));
461     auto ret = ssm_->DestroyAndDisconnectSpecificSessionInner(1);
462     EXPECT_EQ(ret, WSError::WS_OK);
463     sceneSession1 = nullptr;
464     ret = ssm_->DestroyAndDisconnectSpecificSessionInner(2);
465     EXPECT_EQ(ret, WSError::WS_OK);
466 }
467 
468 /**
469  * @tc.name: DestroyAndDisconnectSpecificSessionInner01
470  * @tc.desc: DestroyAndDisconnectSpecificSessionInner
471  * @tc.type: FUNC
472  */
473 HWTEST_F(SceneSessionManagerTest7, DestroyAndDisconnectSpecificSessionInner01, TestSize.Level0)
474 {
475     SessionInfo sessionInfo;
476     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
477     sessionInfo.abilityName_ = "DestroyAndDisconnectSpecificSessionInner";
478     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
479     ASSERT_NE(nullptr, sceneSession);
480     ASSERT_NE(nullptr, sceneSession->property_);
481     sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_TOAST);
482     sceneSession->SetParentPersistentId(2);
483     SessionInfo sessionInfo1;
484     sessionInfo1.bundleName_ = "SceneSessionManagerTest7";
485     sessionInfo1.abilityName_ = "ParentSceneSession";
486     sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(sessionInfo1, nullptr);
487     ASSERT_NE(nullptr, sceneSession1);
488     ASSERT_NE(nullptr, ssm_);
489     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
490     ssm_->sceneSessionMap_.insert(std::make_pair(2, sceneSession1));
491     auto ret = ssm_->DestroyAndDisconnectSpecificSessionInner(1);
492     EXPECT_EQ(ret, WSError::WS_OK);
493     sceneSession1 = nullptr;
494     ret = ssm_->DestroyAndDisconnectSpecificSessionInner(2);
495     EXPECT_EQ(ret, WSError::WS_OK);
496 }
497 
498 /**
499  * @tc.name: DestroyAndDisconnectSpecificSessionInner02
500  * @tc.desc: DestroyAndDisconnectSpecificSessionInner
501  * @tc.type: FUNC
502  */
503 HWTEST_F(SceneSessionManagerTest7, DestroyAndDisconnectSpecificSessionInner02, TestSize.Level0)
504 {
505     SessionInfo sessionInfo;
506     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
507     sessionInfo.abilityName_ = "DestroyAndDisconnectSpecificSessionInner";
508     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
509     ASSERT_NE(nullptr, sceneSession);
510     ASSERT_NE(nullptr, sceneSession->property_);
511     sceneSession->property_->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
512     sceneSession->SetParentPersistentId(2);
513     SessionInfo sessionInfo1;
514     sessionInfo1.bundleName_ = "SceneSessionManagerTest7";
515     sessionInfo1.abilityName_ = "ParentSceneSession";
516     sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(sessionInfo1, nullptr);
517     ASSERT_NE(nullptr, sceneSession1);
518     ASSERT_NE(nullptr, ssm_);
519     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
520     ssm_->sceneSessionMap_.insert(std::make_pair(2, sceneSession1));
521     auto ret = ssm_->DestroyAndDisconnectSpecificSessionInner(1);
522     EXPECT_EQ(ret, WSError::WS_OK);
523     sceneSession1 = nullptr;
524     ret = ssm_->DestroyAndDisconnectSpecificSessionInner(2);
525     EXPECT_EQ(ret, WSError::WS_OK);
526 }
527 
528 /**
529  * @tc.name: DestroyAndDisconnectSpecificSessionInner03
530  * @tc.desc: DestroyAndDisconnectSpecificSessionInner
531  * @tc.type: FUNC
532  */
533 HWTEST_F(SceneSessionManagerTest7, DestroyAndDisconnectSpecificSessionInner03, TestSize.Level0)
534 {
535     SessionInfo sessionInfo;
536     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
537     sessionInfo.abilityName_ = "DestroyAndDisconnectSpecificSessionInner03";
538     sptr<SceneSession> floatSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
539     floatSession->property_->SetWindowType(WindowType::WINDOW_TYPE_FLOAT);
540     floatSession->persistentId_ = 1;
541     sptr<SceneSession> subSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
542     subSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
543     subSession->persistentId_ = 2;
544     subSession->SetParentSession(floatSession);
545     floatSession->subSession_.push_back(subSession);
546     ASSERT_NE(nullptr, ssm_);
547     ssm_->sceneSessionMap_.insert(std::make_pair(1, floatSession));
548     ssm_->sceneSessionMap_.insert(std::make_pair(2, subSession));
549     auto ret = ssm_->DestroyAndDisconnectSpecificSessionInner(1);
550     EXPECT_EQ(ret, WSError::WS_OK);
551     EXPECT_EQ(ssm_->sceneSessionMap_.find(2), ssm_->sceneSessionMap_.end());
552     ret = ssm_->DestroyAndDisconnectSpecificSessionInner(2);
553     EXPECT_EQ(ret, WSError::WS_ERROR_NULLPTR);
554 }
555 
556 /**
557  * @tc.name: CheckPiPPriority
558  * @tc.desc: CheckPiPPriority
559  * @tc.type: FUNC
560  */
561 HWTEST_F(SceneSessionManagerTest7, CheckPiPPriority, TestSize.Level1)
562 {
563     SessionInfo sessionInfo;
564     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
565     sessionInfo.abilityName_ = "CheckPiPPriority";
566     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
567     ASSERT_NE(nullptr, sceneSession);
568     ASSERT_NE(nullptr, sceneSession->property_);
569     sceneSession->property_->SetWindowMode(WindowMode::WINDOW_MODE_PIP);
570     PiPTemplateInfo pipTemplateInfo;
571     pipTemplateInfo.priority = 0;
572     sceneSession->pipTemplateInfo_.priority = 1;
573     sceneSession->state_ = SessionState::STATE_FOREGROUND;
574     ASSERT_NE(nullptr, ssm_);
575     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
576     auto ret = ssm_->CheckPiPPriority(pipTemplateInfo);
577     EXPECT_EQ(ret, false);
578     sceneSession->state_ = SessionState::STATE_ACTIVE;
579     ret = ssm_->CheckPiPPriority(pipTemplateInfo);
580     EXPECT_EQ(ret, false);
581     pipTemplateInfo.priority = 1;
582     ret = ssm_->CheckPiPPriority(pipTemplateInfo);
583     EXPECT_EQ(ret, true);
584     sceneSession->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
585     ret = ssm_->CheckPiPPriority(pipTemplateInfo);
586     EXPECT_EQ(ret, true);
587     sceneSession = nullptr;
588     ret = ssm_->CheckPiPPriority(pipTemplateInfo);
589     EXPECT_EQ(ret, true);
590 }
591 
592 /**
593  * @tc.name: IsSessionVisibleForeground
594  * @tc.desc: IsSessionVisibleForeground
595  * @tc.type: FUNC
596  */
597 HWTEST_F(SceneSessionManagerTest7, IsSessionVisibleForeground, TestSize.Level1)
598 {
599     sptr<SceneSession> session = nullptr;
600     ASSERT_NE(nullptr, ssm_);
601     auto ret = ssm_->IsSessionVisibleForeground(session);
602     EXPECT_EQ(ret, false);
603     SessionInfo sessionInfo;
604     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
605     sessionInfo.abilityName_ = "IsSessionVisibleForeground";
606     session = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
607     ASSERT_NE(nullptr, session);
608     session->isVisible_ = false;
609     ret = ssm_->IsSessionVisibleForeground(session);
610     EXPECT_EQ(ret, false);
611 }
612 
613 /**
614  * @tc.name: UpdateNormalSessionAvoidArea
615  * @tc.desc: UpdateNormalSessionAvoidArea
616  * @tc.type: FUNC
617  */
618 HWTEST_F(SceneSessionManagerTest7, UpdateNormalSessionAvoidArea, TestSize.Level1)
619 {
620     SessionInfo sessionInfo;
621     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
622     sessionInfo.abilityName_ = "UpdateNormalSessionAvoidArea";
623     sessionInfo.isSystem_ = true;
624     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
625     ASSERT_NE(nullptr, sceneSession);
626     sceneSession->isVisible_ = true;
627     sceneSession->state_ = SessionState::STATE_FOREGROUND;
628     int32_t persistentId = 1;
629     bool needUpdate = true;
630     ASSERT_NE(nullptr, ssm_);
631     ssm_->avoidAreaListenerSessionSet_.clear();
632     ssm_->UpdateNormalSessionAvoidArea(persistentId, sceneSession, needUpdate);
633     sceneSession->isVisible_ = false;
634     ssm_->UpdateNormalSessionAvoidArea(persistentId, sceneSession, needUpdate);
635 }
636 
637 /**
638  * @tc.name: UpdateNormalSessionAvoidArea01
639  * @tc.desc: UpdateNormalSessionAvoidArea
640  * @tc.type: FUNC
641  */
642 HWTEST_F(SceneSessionManagerTest7, UpdateNormalSessionAvoidArea01, TestSize.Level1)
643 {
644     SessionInfo sessionInfo;
645     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
646     sessionInfo.abilityName_ = "UpdateNormalSessionAvoidArea01";
647     sessionInfo.isSystem_ = true;
648     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
649     ASSERT_NE(nullptr, sceneSession);
650     sceneSession->isVisible_ = true;
651     sceneSession->state_ = SessionState::STATE_FOREGROUND;
652     int32_t persistentId = 1;
653     bool needUpdate = true;
654     ASSERT_NE(nullptr, ssm_);
655     ssm_->avoidAreaListenerSessionSet_.clear();
656     ssm_->avoidAreaListenerSessionSet_.insert(persistentId);
657     ssm_->UpdateNormalSessionAvoidArea(persistentId, sceneSession, needUpdate);
658     sceneSession = nullptr;
659     ssm_->UpdateNormalSessionAvoidArea(persistentId, sceneSession, needUpdate);
660 }
661 
662 /**
663  * @tc.name: UnregisterWindowManagerAgent
664  * @tc.desc: UnregisterWindowManagerAgent
665  * @tc.type: FUNC
666  */
667 HWTEST_F(SceneSessionManagerTest7, UnregisterWindowManagerAgent, TestSize.Level1)
668 {
669     WindowManagerAgentType type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_SYSTEM_BAR;
670     sptr<IWindowManagerAgent> windowManagerAgent = nullptr;
671     ASSERT_NE(nullptr, ssm_);
672     auto ret = ssm_->UnregisterWindowManagerAgent(type, windowManagerAgent);
673     EXPECT_EQ(ret, WMError::WM_ERROR_NULLPTR);
674     type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_GESTURE_NAVIGATION_ENABLED;
675     ret = ssm_->UnregisterWindowManagerAgent(type, windowManagerAgent);
676     EXPECT_EQ(ret, WMError::WM_ERROR_NULLPTR);
677     type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WATER_MARK_FLAG;
678     ret = ssm_->UnregisterWindowManagerAgent(type, windowManagerAgent);
679     EXPECT_EQ(ret, WMError::WM_ERROR_NULLPTR);
680     type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WINDOW_VISIBILITY;
681     ret = ssm_->UnregisterWindowManagerAgent(type, windowManagerAgent);
682     EXPECT_EQ(ret, WMError::WM_ERROR_INVALID_PERMISSION);
683     type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WINDOW_DRAWING_STATE;
684     ret = ssm_->UnregisterWindowManagerAgent(type, windowManagerAgent);
685     EXPECT_EQ(ret, WMError::WM_ERROR_INVALID_PERMISSION);
686     type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_VISIBLE_WINDOW_NUM;
687     ret = ssm_->UnregisterWindowManagerAgent(type, windowManagerAgent);
688     EXPECT_EQ(ret, WMError::WM_ERROR_INVALID_PERMISSION);
689     type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_FOCUS;
690     ret = ssm_->UnregisterWindowManagerAgent(type, windowManagerAgent);
691     EXPECT_EQ(ret, WMError::WM_ERROR_INVALID_PERMISSION);
692     type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WINDOW_MODE;
693     ret = ssm_->UnregisterWindowManagerAgent(type, windowManagerAgent);
694     EXPECT_EQ(ret, WMError::WM_ERROR_INVALID_PERMISSION);
695     type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WINDOW_UPDATE;
696     ret = ssm_->UnregisterWindowManagerAgent(type, windowManagerAgent);
697     EXPECT_EQ(ret, WMError::WM_ERROR_NULLPTR);
698 }
699 
700 /**
701  * @tc.name: FindSessionByAffinity
702  * @tc.desc: FindSessionByAffinity
703  * @tc.type: FUNC
704  */
705 HWTEST_F(SceneSessionManagerTest7, FindSessionByAffinity, TestSize.Level1)
706 {
707     std::string affinity = "";
708     ASSERT_NE(nullptr, ssm_);
709     auto ret = ssm_->FindSessionByAffinity(affinity);
710     EXPECT_EQ(ret, nullptr);
711     affinity = "Test";
712     SessionInfo sessionInfo;
713     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
714     sessionInfo.abilityName_ = "FindSessionByAffinity";
715     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
716     ASSERT_NE(nullptr, sceneSession);
717     sceneSession->SetCollaboratorType(CollaboratorType::DEFAULT_TYPE);
718     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
719     ret = ssm_->FindSessionByAffinity(affinity);
720     EXPECT_EQ(ret, nullptr);
721     sceneSession->SetCollaboratorType(CollaboratorType::OTHERS_TYPE);
722     sceneSession->sessionInfo_.sessionAffinity = "Test";
723     ret = ssm_->FindSessionByAffinity(affinity);
724     EXPECT_EQ(ret, sceneSession);
725 }
726 
727 /**
728  * @tc.name: FindSessionByAffinity01
729  * @tc.desc: FindSessionByAffinity
730  * @tc.type: FUNC
731  */
732 HWTEST_F(SceneSessionManagerTest7, FindSessionByAffinity01, TestSize.Level1)
733 {
734     std::string affinity = "Test";
735     sptr<SceneSession> sceneSession = nullptr;
736     ASSERT_NE(nullptr, ssm_);
737     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
738     auto ret = ssm_->FindSessionByAffinity(affinity);
739     EXPECT_EQ(ret, nullptr);
740 }
741 
742 /**
743  * @tc.name: ProcessUpdateRotationChange01
744  * @tc.desc: ProcessUpdateRotationChange
745  * @tc.type: FUNC
746  */
747 HWTEST_F(SceneSessionManagerTest7, ProcessUpdateRotationChange01, TestSize.Level1)
748 {
749     DisplayId defaultDisplayId = 0;
750     sptr<DisplayInfo> displayInfo = sptr<DisplayInfo>::MakeSptr();
751     ASSERT_NE(nullptr, displayInfo);
752     std::map<DisplayId, sptr<DisplayInfo>> displayInfoMap;
753     DisplayStateChangeType type = DisplayStateChangeType::BEFORE_SUSPEND;
754     sptr<SceneSession> sceneSession = nullptr;
755     ASSERT_NE(nullptr, ssm_);
756     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
757     ssm_->ProcessUpdateRotationChange(defaultDisplayId, displayInfo, displayInfoMap, type);
758 }
759 
760 /**
761  * @tc.name: ProcessUpdateRotationChange02
762  * @tc.desc: ProcessUpdateRotationChange
763  * @tc.type: FUNC
764  */
765 HWTEST_F(SceneSessionManagerTest7, ProcessUpdateRotationChange02, TestSize.Level1)
766 {
767     DisplayId defaultDisplayId = 0;
768     sptr<DisplayInfo> displayInfo = sptr<DisplayInfo>::MakeSptr();
769     ASSERT_NE(nullptr, displayInfo);
770     std::map<DisplayId, sptr<DisplayInfo>> displayInfoMap;
771     DisplayStateChangeType type = DisplayStateChangeType::BEFORE_SUSPEND;
772     SessionInfo sessionInfo;
773     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
774     sessionInfo.abilityName_ = "UpdateAvoidArea";
775     sessionInfo.isSystem_ = true;
776     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
777     ASSERT_NE(nullptr, sceneSession);
778     ASSERT_NE(nullptr, ssm_);
779     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
780     sceneSession->SetSessionState(SessionState::STATE_INACTIVE);
781     WSRectF bounds = { 0, 0, 0, 0 };
782     sceneSession->SetBounds(bounds);
783     displayInfo->width_ = 0;
784     displayInfo->height_ = 0;
785     sceneSession->SetRotation(Rotation::ROTATION_0);
786     displayInfo->SetRotation(Rotation::ROTATION_90);
787     ssm_->ProcessUpdateRotationChange(defaultDisplayId, displayInfo, displayInfoMap, type);
788     displayInfo->height_ = 1;
789     ssm_->ProcessUpdateRotationChange(defaultDisplayId, displayInfo, displayInfoMap, type);
790     displayInfo->width_ = 1;
791     ssm_->ProcessUpdateRotationChange(defaultDisplayId, displayInfo, displayInfoMap, type);
792 }
793 
794 /**
795  * @tc.name: SetSkipSelfWhenShowOnVirtualScreen
796  * @tc.desc: SetSkipSelfWhenShowOnVirtualScreen
797  * @tc.type: FUNC
798  */
799 HWTEST_F(SceneSessionManagerTest7, SetSkipSelfWhenShowOnVirtualScreen, TestSize.Level1)
800 {
801     uint64_t surfaceNodeId = 0;
802     bool isSkip = true;
803     ASSERT_NE(nullptr, ssm_);
804     ssm_->skipSurfaceNodeIds_.clear();
805     ssm_->SetSkipSelfWhenShowOnVirtualScreen(surfaceNodeId, isSkip);
806     ssm_->skipSurfaceNodeIds_.push_back(surfaceNodeId);
807     ssm_->SetSkipSelfWhenShowOnVirtualScreen(surfaceNodeId, isSkip);
808 }
809 
810 /**
811  * @tc.name: SetSkipSelfWhenShowOnVirtualScreen01
812  * @tc.desc: SetSkipSelfWhenShowOnVirtualScreen
813  * @tc.type: FUNC
814  */
815 HWTEST_F(SceneSessionManagerTest7, SetSkipSelfWhenShowOnVirtualScreen01, TestSize.Level1)
816 {
817     uint64_t surfaceNodeId = 0;
818     bool isSkip = false;
819     ASSERT_NE(nullptr, ssm_);
820     ssm_->skipSurfaceNodeIds_.clear();
821     ssm_->SetSkipSelfWhenShowOnVirtualScreen(surfaceNodeId, isSkip);
822     ssm_->skipSurfaceNodeIds_.push_back(surfaceNodeId);
823     ssm_->SetSkipSelfWhenShowOnVirtualScreen(surfaceNodeId, isSkip);
824 }
825 
826 /**
827  * @tc.name: GetMainWindowInfos
828  * @tc.desc: GetMainWindowInfos
829  * @tc.type: FUNC
830  */
831 HWTEST_F(SceneSessionManagerTest7, GetMainWindowInfos, TestSize.Level1)
832 {
833     int32_t topNum = 1;
834     std::vector<MainWindowInfo> topNInfo;
835     topNInfo.clear();
836     SessionInfo sessionInfo;
837     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
838     sessionInfo.abilityName_ = "GetMainWindowInfos";
839     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
840     ASSERT_NE(nullptr, sceneSession);
841     ASSERT_NE(nullptr, sceneSession->property_);
842     sceneSession->property_->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
843     sceneSession->isVisible_ = true;
844     sceneSession->state_ = SessionState::STATE_FOREGROUND;
845     ASSERT_NE(nullptr, ssm_);
846     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
847     auto ret = ssm_->GetMainWindowInfos(topNum, topNInfo);
848     EXPECT_EQ(ret, WMError::WM_OK);
849     sceneSession->isVisible_ = false;
850     ret = ssm_->GetMainWindowInfos(topNum, topNInfo);
851     EXPECT_EQ(ret, WMError::WM_OK);
852     sceneSession->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_END);
853     ret = ssm_->GetMainWindowInfos(topNum, topNInfo);
854     EXPECT_EQ(ret, WMError::WM_OK);
855     sceneSession->isVisible_ = true;
856     ret = ssm_->GetMainWindowInfos(topNum, topNInfo);
857     EXPECT_EQ(ret, WMError::WM_OK);
858 }
859 
860 /**
861  * @tc.name: WindowLayerInfoChangeCallback
862  * @tc.desc: WindowLayerInfoChangeCallback
863  * @tc.type: FUNC
864  */
865 HWTEST_F(SceneSessionManagerTest7, WindowLayerInfoChangeCallback, TestSize.Level1)
866 {
867     std::shared_ptr<RSOcclusionData> occlusiontionData = nullptr;
868     ASSERT_NE(nullptr, ssm_);
869     ssm_->WindowLayerInfoChangeCallback(occlusiontionData);
870     VisibleData visibleData;
871     visibleData.push_back(std::make_pair(0, WINDOW_LAYER_INFO_TYPE::ALL_VISIBLE));
872     visibleData.push_back(std::make_pair(1, WINDOW_LAYER_INFO_TYPE::SEMI_VISIBLE));
873     visibleData.push_back(std::make_pair(2, WINDOW_LAYER_INFO_TYPE::INVISIBLE));
874     visibleData.push_back(std::make_pair(3, WINDOW_LAYER_INFO_TYPE::WINDOW_LAYER_DYNAMIC_STATUS));
875     visibleData.push_back(std::make_pair(4, WINDOW_LAYER_INFO_TYPE::WINDOW_LAYER_STATIC_STATUS));
876     visibleData.push_back(std::make_pair(5, WINDOW_LAYER_INFO_TYPE::WINDOW_LAYER_UNKNOWN_TYPE));
877     occlusiontionData = std::make_shared<RSOcclusionData>(visibleData);
878     ASSERT_NE(nullptr, occlusiontionData);
879     ssm_->WindowLayerInfoChangeCallback(occlusiontionData);
880 }
881 
882 /**
883  * @tc.name: NotifySessionMovedToFront
884  * @tc.desc: NotifySessionMovedToFront
885  * @tc.type: FUNC
886  */
887 HWTEST_F(SceneSessionManagerTest7, NotifySessionMovedToFront, TestSize.Level1)
888 {
889     int32_t persistentId = 1;
890     SessionInfo sessionInfo;
891     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
892     sessionInfo.abilityName_ = "GetMainWindowInfos";
893     sessionInfo.isSystem_ = false;
894     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
895     ASSERT_NE(nullptr, sceneSession);
896     ASSERT_NE(nullptr, ssm_);
897     ssm_->listenerController_ = std::make_shared<SessionListenerController>();
898     ASSERT_NE(nullptr, ssm_->listenerController_);
899     sceneSession->sessionInfo_.abilityInfo = std::make_shared<AppExecFwk::AbilityInfo>();
900     ASSERT_NE(nullptr, sceneSession->sessionInfo_.abilityInfo);
901     sceneSession->sessionInfo_.abilityInfo->excludeFromMissions = false;
902     ssm_->sceneSessionMap_.insert(std::make_pair(persistentId, sceneSession));
903     ssm_->NotifySessionMovedToFront(persistentId);
904     sceneSession->sessionInfo_.abilityInfo->excludeFromMissions = true;
905     ssm_->NotifySessionMovedToFront(persistentId);
906     sceneSession->sessionInfo_.abilityInfo = nullptr;
907     ssm_->NotifySessionMovedToFront(persistentId);
908     sceneSession->sessionInfo_.isSystem_ = true;
909     ssm_->NotifySessionMovedToFront(persistentId);
910     ssm_->listenerController_ = nullptr;
911     ssm_->NotifySessionMovedToFront(persistentId);
912 }
913 
914 /**
915  * @tc.name: ProcessVirtualPixelRatioChange02
916  * @tc.desc: ProcessVirtualPixelRatioChange
917  * @tc.type: FUNC
918  */
919 HWTEST_F(SceneSessionManagerTest7, ProcessVirtualPixelRatioChange02, TestSize.Level1)
920 {
921     DisplayId defaultDisplayId = 0;
922     sptr<DisplayInfo> displayInfo = sptr<DisplayInfo>::MakeSptr();
923     std::map<DisplayId, sptr<DisplayInfo>> displayInfoMap;
924     DisplayStateChangeType type = DisplayStateChangeType::BEFORE_SUSPEND;
925     ASSERT_NE(nullptr, displayInfo);
926     SessionInfo sessionInfo;
927     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
928     sessionInfo.abilityName_ = "ProcessVirtualPixelRatioChange02";
929     sessionInfo.isSystem_ = true;
930     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
931     ASSERT_NE(nullptr, sceneSession);
932     ASSERT_NE(nullptr, ssm_);
933     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
934     sptr<SceneSession> sceneSession1 = nullptr;
935     ssm_->sceneSessionMap_.insert(std::make_pair(2, sceneSession1));
936     ssm_->ProcessVirtualPixelRatioChange(defaultDisplayId, displayInfo, displayInfoMap, type);
937 }
938 
939 /**
940  * @tc.name: ProcessVirtualPixelRatioChange03
941  * @tc.desc: ProcessVirtualPixelRatioChange
942  * @tc.type: FUNC
943  */
944 HWTEST_F(SceneSessionManagerTest7, ProcessVirtualPixelRatioChange03, TestSize.Level1)
945 {
946     DisplayId defaultDisplayId = 0;
947     sptr<DisplayInfo> displayInfo = sptr<DisplayInfo>::MakeSptr();
948     std::map<DisplayId, sptr<DisplayInfo>> displayInfoMap;
949     DisplayStateChangeType type = DisplayStateChangeType::BEFORE_SUSPEND;
950     ASSERT_NE(nullptr, displayInfo);
951     SessionInfo sessionInfo;
952     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
953     sessionInfo.abilityName_ = "ProcessVirtualPixelRatioChange03";
954     sessionInfo.isSystem_ = false;
955     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
956     ASSERT_NE(nullptr, sceneSession);
957     sceneSession->SetSessionState(SessionState::STATE_FOREGROUND);
958     ASSERT_NE(nullptr, ssm_);
959     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
960     sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
961     ASSERT_NE(nullptr, sceneSession1);
962     sceneSession1->SetSessionState(SessionState::STATE_ACTIVE);
963     ssm_->sceneSessionMap_.insert(std::make_pair(2, sceneSession1));
964     sptr<SceneSession> sceneSession2 = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
965     ASSERT_NE(nullptr, sceneSession2);
966     sceneSession2->SetSessionState(SessionState::STATE_INACTIVE);
967     ssm_->sceneSessionMap_.insert(std::make_pair(3, sceneSession2));
968     ssm_->ProcessVirtualPixelRatioChange(defaultDisplayId, displayInfo, displayInfoMap, type);
969 }
970 
971 /**
972  * @tc.name: ProcessBackEvent01
973  * @tc.desc: ProcessBackEvent
974  * @tc.type: FUNC
975  */
976 HWTEST_F(SceneSessionManagerTest7, ProcessBackEvent01, TestSize.Level1)
977 {
978     SessionInfo sessionInfo;
979     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
980     sessionInfo.abilityName_ = "ProcessBackEvent01";
981     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
982     ASSERT_NE(nullptr, sceneSession);
983     ASSERT_NE(nullptr, ssm_);
984     auto focusGroup = ssm_->windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID);
985     focusGroup->SetFocusedSessionId(1);
986     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
987     ssm_->needBlockNotifyFocusStatusUntilForeground_ = true;
988     auto ret = ssm_->ProcessBackEvent();
989     EXPECT_EQ(ret, WSError::WS_OK);
990 }
991 
992 /**
993  * @tc.name: ProcessBackEvent02
994  * @tc.desc: ProcessBackEvent
995  * @tc.type: FUNC
996  */
997 HWTEST_F(SceneSessionManagerTest7, ProcessBackEvent02, TestSize.Level1)
998 {
999     SessionInfo sessionInfo;
1000     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
1001     sessionInfo.abilityName_ = "ProcessBackEvent02";
1002     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1003     ASSERT_NE(nullptr, sceneSession);
1004     sceneSession->sessionInfo_.isSystem_ = true;
1005     ASSERT_NE(nullptr, ssm_);
1006     auto focusGroup = ssm_->windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID);
1007     focusGroup->SetFocusedSessionId(1);
1008     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
1009     ssm_->needBlockNotifyFocusStatusUntilForeground_ = false;
1010     ssm_->rootSceneProcessBackEventFunc_ = nullptr;
1011     auto ret = ssm_->ProcessBackEvent();
1012     EXPECT_EQ(ret, WSError::WS_OK);
1013 }
1014 
1015 /**
1016  * @tc.name: ProcessBackEvent03
1017  * @tc.desc: ProcessBackEvent
1018  * @tc.type: FUNC
1019  */
1020 HWTEST_F(SceneSessionManagerTest7, ProcessBackEvent03, TestSize.Level1)
1021 {
1022     SessionInfo sessionInfo;
1023     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
1024     sessionInfo.abilityName_ = "ProcessBackEvent03";
1025     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1026     ASSERT_NE(nullptr, sceneSession);
1027     sceneSession->sessionInfo_.isSystem_ = true;
1028     ASSERT_NE(nullptr, ssm_);
1029     auto focusGroup = ssm_->windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID);
1030     focusGroup->SetFocusedSessionId(1);
1031     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
1032     ssm_->needBlockNotifyFocusStatusUntilForeground_ = false;
__anonfcc6fbfd0602() 1033     RootSceneProcessBackEventFunc func = []() {};
1034     ssm_->rootSceneProcessBackEventFunc_ = func;
1035     ASSERT_NE(nullptr, ssm_->rootSceneProcessBackEventFunc_);
1036     auto ret = ssm_->ProcessBackEvent();
1037     EXPECT_EQ(ret, WSError::WS_OK);
1038 }
1039 
1040 /**
1041  * @tc.name: ProcessBackEvent02
1042  * @tc.desc: ProcessBackEvent
1043  * @tc.type: FUNC
1044  */
1045 HWTEST_F(SceneSessionManagerTest7, ProcessBackEvent04, TestSize.Level1)
1046 {
1047     SessionInfo sessionInfo;
1048     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
1049     sessionInfo.abilityName_ = "ProcessBackEvent04";
1050     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1051     ASSERT_NE(nullptr, sceneSession);
1052     sceneSession->sessionInfo_.isSystem_ = false;
1053     ASSERT_NE(nullptr, ssm_);
1054     auto focusGroup = ssm_->windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID);
1055     focusGroup->SetFocusedSessionId(1);
1056     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
1057     ssm_->needBlockNotifyFocusStatusUntilForeground_ = false;
1058     ssm_->rootSceneProcessBackEventFunc_ = nullptr;
1059     auto ret = ssm_->ProcessBackEvent();
1060     EXPECT_EQ(ret, WSError::WS_OK);
1061 }
1062 
1063 /**
1064  * @tc.name: ProcessBackEvent05
1065  * @tc.desc: ProcessBackEvent
1066  * @tc.type: FUNC
1067  */
1068 HWTEST_F(SceneSessionManagerTest7, ProcessBackEvent05, TestSize.Level1)
1069 {
1070     SessionInfo sessionInfo;
1071     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
1072     sessionInfo.abilityName_ = "ProcessBackEvent03";
1073     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1074     ASSERT_NE(nullptr, sceneSession);
1075     sceneSession->sessionInfo_.isSystem_ = false;
1076     ASSERT_NE(nullptr, ssm_);
1077     auto focusGroup = ssm_->windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID);
1078     focusGroup->SetFocusedSessionId(1);
1079     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
1080     ssm_->needBlockNotifyFocusStatusUntilForeground_ = false;
__anonfcc6fbfd0702() 1081     RootSceneProcessBackEventFunc func = []() {};
1082     ssm_->rootSceneProcessBackEventFunc_ = func;
1083     ASSERT_NE(nullptr, ssm_->rootSceneProcessBackEventFunc_);
1084     auto ret = ssm_->ProcessBackEvent();
1085     EXPECT_EQ(ret, WSError::WS_OK);
1086 }
1087 
1088 /**
1089  * @tc.name: GetWindowVisibilityChangeInfo
1090  * @tc.desc: GetWindowVisibilityChangeInfo
1091  * @tc.type: FUNC
1092  */
1093 HWTEST_F(SceneSessionManagerTest7, GetWindowVisibilityChangeInfo, TestSize.Level1)
1094 {
1095     std::vector<std::pair<uint64_t, WindowVisibilityState>> currVisibleData;
1096     std::vector<std::pair<uint64_t, WindowVisibilityState>> visibilitychangeInfos;
1097     currVisibleData.emplace_back(2, WindowVisibilityState::WINDOW_VISIBILITY_STATE_NO_OCCLUSION);
1098     currVisibleData.emplace_back(4, WindowVisibilityState::WINDOW_LAYER_STATE_MAX);
1099     currVisibleData.emplace_back(5, WindowVisibilityState::WINDOW_VISIBILITY_STATE_TOTALLY_OCCUSION);
1100     currVisibleData.emplace_back(7, WindowVisibilityState::WINDOW_LAYER_STATE_MAX);
1101     currVisibleData.emplace_back(9, WindowVisibilityState::WINDOW_VISIBILITY_STATE_TOTALLY_OCCUSION);
1102     ASSERT_NE(nullptr, ssm_);
1103     ssm_->lastVisibleData_.emplace_back(1, WindowVisibilityState::WINDOW_VISIBILITY_STATE_NO_OCCLUSION);
1104     ssm_->lastVisibleData_.emplace_back(4, WindowVisibilityState::WINDOW_VISIBILITY_STATE_PARTICALLY_OCCLUSION);
1105     ssm_->lastVisibleData_.emplace_back(5, WindowVisibilityState::WINDOW_VISIBILITY_STATE_TOTALLY_OCCUSION);
1106     ssm_->lastVisibleData_.emplace_back(6, WindowVisibilityState::WINDOW_LAYER_STATE_MAX);
1107     visibilitychangeInfos = ssm_->GetWindowVisibilityChangeInfo(currVisibleData);
1108     ASSERT_EQ(visibilitychangeInfos.size(), 7);
1109 }
1110 
1111 /**
1112  * @tc.name: UpdateAvoidArea
1113  * @tc.desc: UpdateAvoidArea
1114  * @tc.type: FUNC
1115  */
1116 HWTEST_F(SceneSessionManagerTest7, UpdateAvoidArea, TestSize.Level1)
1117 {
1118     int32_t persistentId = 0;
1119     ASSERT_NE(nullptr, ssm_);
1120     ssm_->sceneSessionMap_.clear();
1121     ssm_->rootSceneSession_ = sptr<RootSceneSession>::MakeSptr();
1122     ssm_->UpdateAvoidArea(persistentId);
1123 }
1124 
1125 /**
1126  * @tc.name: UpdateAvoidArea01
1127  * @tc.desc: UpdateAvoidArea
1128  * @tc.type: FUNC
1129  */
1130 HWTEST_F(SceneSessionManagerTest7, UpdateAvoidArea01, TestSize.Level1)
1131 {
1132     int32_t persistentId = 0;
1133     ASSERT_NE(nullptr, ssm_);
1134     ssm_->sceneSessionMap_.clear();
1135     ssm_->rootSceneSession_ = sptr<RootSceneSession>::MakeSptr();
1136     ssm_->UpdateAvoidArea(persistentId);
1137     SessionInfo sessionInfo;
1138     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
1139     sessionInfo.abilityName_ = "UpdateAvoidArea01";
1140     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1141     ASSERT_NE(nullptr, sceneSession);
1142     ASSERT_NE(nullptr, sceneSession->property_);
1143     sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_STATUS_BAR);
1144     ssm_->sceneSessionMap_.insert(std::make_pair(persistentId, sceneSession));
1145     ssm_->UpdateAvoidArea(persistentId);
1146 }
1147 
1148 /**
1149  * @tc.name: UpdateAvoidArea02
1150  * @tc.desc: UpdateAvoidArea
1151  * @tc.type: FUNC
1152  */
1153 HWTEST_F(SceneSessionManagerTest7, UpdateAvoidArea02, TestSize.Level1)
1154 {
1155     int32_t persistentId = 0;
1156     ASSERT_NE(nullptr, ssm_);
1157     ssm_->sceneSessionMap_.clear();
1158     ssm_->rootSceneSession_ = sptr<RootSceneSession>::MakeSptr();
1159     ssm_->UpdateAvoidArea(persistentId);
1160     SessionInfo sessionInfo;
1161     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
1162     sessionInfo.abilityName_ = "UpdateAvoidArea02";
1163     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1164     ASSERT_NE(nullptr, sceneSession);
1165     ASSERT_NE(nullptr, sceneSession->property_);
1166     sceneSession->property_->SetWindowType(WindowType::APP_WINDOW_BASE);
1167     ssm_->sceneSessionMap_.insert(std::make_pair(persistentId, sceneSession));
1168     ssm_->UpdateAvoidArea(persistentId);
1169 }
1170 
1171 /**
1172  * @tc.name: NotifySessionMovedToFront01
1173  * @tc.desc: NotifySessionMovedToFront
1174  * @tc.type: FUNC
1175  */
1176 HWTEST_F(SceneSessionManagerTest7, NotifySessionMovedToFront01, TestSize.Level1)
1177 {
1178     int32_t persistentId = 1;
1179     SessionInfo sessionInfo;
1180     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
1181     sessionInfo.abilityName_ = "NotifySessionMovedToFront01";
1182     sessionInfo.isSystem_ = false;
1183     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1184     ASSERT_NE(nullptr, sceneSession);
1185     ASSERT_NE(nullptr, ssm_);
1186     ssm_->listenerController_ = std::make_shared<SessionListenerController>();
1187     ASSERT_NE(nullptr, ssm_->listenerController_);
1188     sceneSession->sessionInfo_.abilityInfo = std::make_shared<AppExecFwk::AbilityInfo>();
1189     ASSERT_NE(nullptr, sceneSession->sessionInfo_.abilityInfo);
1190     sceneSession->sessionInfo_.abilityInfo->excludeFromMissions = true;
1191     ssm_->sceneSessionMap_.insert(std::make_pair(persistentId, sceneSession));
1192     ssm_->NotifySessionMovedToFront(persistentId);
1193 }
1194 
1195 /**
1196  * @tc.name: NotifySessionMovedToFront02
1197  * @tc.desc: NotifySessionMovedToFront
1198  * @tc.type: FUNC
1199  */
1200 HWTEST_F(SceneSessionManagerTest7, NotifySessionMovedToFront02, TestSize.Level1)
1201 {
1202     int32_t persistentId = 1;
1203     SessionInfo sessionInfo;
1204     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
1205     sessionInfo.abilityName_ = "NotifySessionMovedToFront02";
1206     sessionInfo.isSystem_ = false;
1207     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1208     ASSERT_NE(nullptr, sceneSession);
1209     ASSERT_NE(nullptr, ssm_);
1210     ssm_->listenerController_ = std::make_shared<SessionListenerController>();
1211     ASSERT_NE(nullptr, ssm_->listenerController_);
1212     sceneSession->sessionInfo_.abilityInfo = std::make_shared<AppExecFwk::AbilityInfo>();
1213     ASSERT_NE(nullptr, sceneSession->sessionInfo_.abilityInfo);
1214     sceneSession->sessionInfo_.abilityInfo->excludeFromMissions = false;
1215     ssm_->sceneSessionMap_.insert(std::make_pair(persistentId, sceneSession));
1216     ssm_->NotifySessionMovedToFront(persistentId);
1217 }
1218 
1219 /**
1220  * @tc.name: NotifySessionMovedToFront03
1221  * @tc.desc: NotifySessionMovedToFront
1222  * @tc.type: FUNC
1223  */
1224 HWTEST_F(SceneSessionManagerTest7, NotifySessionMovedToFront03, TestSize.Level1)
1225 {
1226     int32_t persistentId = 1;
1227     SessionInfo sessionInfo;
1228     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
1229     sessionInfo.abilityName_ = "NotifySessionMovedToFront03";
1230     sessionInfo.isSystem_ = false;
1231     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1232     ASSERT_NE(nullptr, sceneSession);
1233     ASSERT_NE(nullptr, ssm_);
1234     ssm_->listenerController_ = std::make_shared<SessionListenerController>();
1235     ASSERT_NE(nullptr, ssm_->listenerController_);
1236     sceneSession->sessionInfo_.abilityInfo = nullptr;
1237     ssm_->NotifySessionMovedToFront(persistentId);
1238 }
1239 
1240 /**
1241  * @tc.name: NotifySessionMovedToFront04
1242  * @tc.desc: NotifySessionMovedToFront
1243  * @tc.type: FUNC
1244  */
1245 HWTEST_F(SceneSessionManagerTest7, NotifySessionMovedToFront04, TestSize.Level1)
1246 {
1247     int32_t persistentId = 1;
1248     SessionInfo sessionInfo;
1249     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
1250     sessionInfo.abilityName_ = "NotifySessionMovedToFront04";
1251     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1252     ASSERT_NE(nullptr, sceneSession);
1253     ASSERT_NE(nullptr, ssm_);
1254     ssm_->listenerController_ = std::make_shared<SessionListenerController>();
1255     ASSERT_NE(nullptr, ssm_->listenerController_);
1256     sceneSession->sessionInfo_.isSystem_ = true;
1257     ssm_->NotifySessionMovedToFront(persistentId);
1258 }
1259 
1260 /**
1261  * @tc.name: NotifySessionMovedToFront05
1262  * @tc.desc: NotifySessionMovedToFront
1263  * @tc.type: FUNC
1264  */
1265 HWTEST_F(SceneSessionManagerTest7, NotifySessionMovedToFront05, TestSize.Level1)
1266 {
1267     int32_t persistentId = 1;
1268     SessionInfo sessionInfo;
1269     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
1270     sessionInfo.abilityName_ = "NotifySessionMovedToFront05";
1271     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1272     ASSERT_NE(nullptr, sceneSession);
1273     ASSERT_NE(nullptr, ssm_);
1274     ssm_->listenerController_ = nullptr;
1275     ssm_->NotifySessionMovedToFront(persistentId);
1276 }
1277 
1278 /**
1279  * @tc.name: UpdateNormalSessionAvoidArea02
1280  * @tc.desc: UpdateNormalSessionAvoidArea
1281  * @tc.type: FUNC
1282  */
1283 HWTEST_F(SceneSessionManagerTest7, UpdateNormalSessionAvoidArea02, TestSize.Level1)
1284 {
1285     SessionInfo sessionInfo;
1286     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
1287     sessionInfo.abilityName_ = "UpdateNormalSessionAvoidArea02";
1288     sessionInfo.isSystem_ = true;
1289     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1290     ASSERT_NE(nullptr, sceneSession);
1291     sceneSession->isVisible_ = true;
1292     sceneSession->state_ = SessionState::STATE_FOREGROUND;
1293     sceneSession->GetLayoutController()->SetSessionRect({ 1, 1, 1, 1 });
1294     int32_t persistentId = 1;
1295     bool needUpdate = true;
1296     ASSERT_NE(nullptr, ssm_);
1297     ssm_->avoidAreaListenerSessionSet_.clear();
1298     ssm_->avoidAreaListenerSessionSet_.insert(persistentId);
1299     ssm_->UpdateNormalSessionAvoidArea(persistentId, sceneSession, needUpdate);
1300 }
1301 
1302 /**
1303  * @tc.name: RemoveProcessSnapshotSkip
1304  * @tc.desc: SceneSesionManager RemoveProcessSnapshotSkip
1305  * @tc.type: FUNC
1306  */
1307 HWTEST_F(SceneSessionManagerTest7, RemoveProcessSnapshotSkip, TestSize.Level1)
1308 {
1309     ssm_->snapshotSkipPidSet_.insert(1);
1310     ssm_->RemoveProcessSnapshotSkip(1);
1311     ASSERT_EQ(ssm_->snapshotSkipPidSet_.find(1), ssm_->snapshotSkipPidSet_.end());
1312 }
1313 
1314 /**
1315  * @tc.name: SetSessionSnapshotSkipForAppProcess
1316  * @tc.desc: SceneSesionManager SetSessionSnapshotSkipForAppProcess
1317  * @tc.type: FUNC
1318  */
1319 HWTEST_F(SceneSessionManagerTest7, SetSessionSnapshotSkipForAppProcess, TestSize.Level1)
1320 {
1321     SessionInfo info;
1322     sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(info, nullptr);
1323     sceneSession->SetCallingPid(1000);
1324     struct RSSurfaceNodeConfig config;
1325     std::shared_ptr<RSSurfaceNode> surfaceNode = RSSurfaceNode::Create(config);
1326     sceneSession->surfaceNode_ = surfaceNode;
1327     ssm_->SetSessionSnapshotSkipForAppProcess(sceneSession);
1328     ASSERT_EQ(sceneSession->GetSessionProperty()->GetSnapshotSkip(), false);
1329 
1330     ssm_->snapshotSkipPidSet_.insert(1000);
1331     ssm_->SetSessionSnapshotSkipForAppProcess(sceneSession);
1332     ASSERT_EQ(sceneSession->GetSessionProperty()->GetSnapshotSkip(), true);
1333     ssm_->snapshotSkipPidSet_.erase(1000);
1334 }
1335 
1336 /**
1337  * @tc.name: TestReportCorrectScreenFoldStatusChangeEvent
1338  * @tc.desc: Test whether report the correct screen fold status events
1339  * @tc.type: FUNC
1340  */
1341 HWTEST_F(SceneSessionManagerTest7, TestReportCorrectScreenFoldStatusChangeEvent, TestSize.Level1)
1342 {
1343     GTEST_LOG_(INFO) << "SceneSessionManagerTest: TestReportCorrectScreenFoldStatusChangeEvent start";
1344     ScreenFoldData screenFoldData1;
1345     screenFoldData1.currentScreenFoldStatus_ = 1;          // 1: current screen fold status
1346     screenFoldData1.nextScreenFoldStatus_ = 3;             // 3: next screen fold status
1347     screenFoldData1.currentScreenFoldStatusDuration_ = 18; // 18: current duration
1348     screenFoldData1.postureAngle_ = 47.1f;                 // 47.1: posture angle (type: float)
1349     screenFoldData1.screenRotation_ = 1;                   // 1: screen rotation
1350     screenFoldData1.typeCThermal_ = 3000;                  // 3000: typec port thermal
1351     screenFoldData1.focusedPackageName_ = "Developer Test: (1, 3, 18, 47.1, 1, 3000)";
1352     WMError result = ssm_->CheckAndReportScreenFoldStatus(screenFoldData1);
1353     ASSERT_EQ(result, WMError::WM_DO_NOTHING); // not report half-fold event until next change
1354 
1355     ScreenFoldData screenFoldData2;
1356     screenFoldData2.currentScreenFoldStatus_ = 3;          // 3: current screen fold status
1357     screenFoldData2.nextScreenFoldStatus_ = 2;             // 2: next screen fold status
1358     screenFoldData2.currentScreenFoldStatusDuration_ = 20; // 20: current duration
1359     screenFoldData2.postureAngle_ = 143.7f;                // 143.7: posture angle (type: float)
1360     screenFoldData2.screenRotation_ = 2;                   // 2: screen rotation
1361     screenFoldData2.typeCThermal_ = 3005;                  // 3005: typec port thermal
1362     screenFoldData2.focusedPackageName_ = "Developer Test: (3, 2, 20, 143.7, 2, 3005)";
1363     result = ssm_->CheckAndReportScreenFoldStatus(screenFoldData2);
1364     ASSERT_EQ(result, WMError::WM_OK);
1365 }
1366 
1367 /**
1368  * @tc.name: TestReportIncompleteScreenFoldStatusChangeEvent
1369  * @tc.desc: Test whether block the incomplete screen fold status events
1370  * @tc.type: FUNC
1371  */
1372 HWTEST_F(SceneSessionManagerTest7, TestReportIncompleteScreenFoldStatusChangeEvent, TestSize.Level1)
1373 {
1374     GTEST_LOG_(INFO) << "SceneSessionManagerTest: TestReportIncompleteScreenFoldStatusChangeEvent start";
1375     // screen fold status changes from -1: invalid to 3: half_fold, duration = 0, angle = 67.0, rotation = 0
1376     std::vector<std::string> screenFoldInfo{ "-1", "3", "0", "67.0", "0" };
1377     WMError result = ssm_->ReportScreenFoldStatusChange(screenFoldInfo);
1378     ASSERT_EQ(result, WMError::WM_DO_NOTHING);
1379 
1380     screenFoldInfo.clear();
1381     result = ssm_->ReportScreenFoldStatusChange(screenFoldInfo);
1382     ASSERT_EQ(result, WMError::WM_DO_NOTHING);
1383 
1384     // screen fold status changes from 2: folded to 3: half_fold, duration = 0, angle = 67.0, rotation = 0
1385     screenFoldInfo = { "2", "3", "0", "67.0", "0" };
1386     result = ssm_->ReportScreenFoldStatusChange(screenFoldInfo);
1387     ASSERT_EQ(result, WMError::WM_DO_NOTHING);
1388 
1389     // screen fold status changes from 3: half_fold to 1: expand, duration = 18, angle = 147.3, rotation = 2
1390     screenFoldInfo = { "3", "1", "18", "147.3", "2" };
1391     result = ssm_->ReportScreenFoldStatusChange(screenFoldInfo);
1392     ASSERT_EQ(result, WMError::WM_DO_NOTHING);
1393 }
1394 
1395 /**
1396  * @tc.name: SetAppForceLandscapeConfig
1397  * @tc.desc: SceneSesionManager SetAppForceLandscapeConfig
1398  * @tc.type: FUNC
1399  */
1400 HWTEST_F(SceneSessionManagerTest7, SetAppForceLandscapeConfig, TestSize.Level1)
1401 {
1402     std::string bundleName = "SetAppForceLandscapeConfig";
1403     AppForceLandscapeConfig config = { 0, "MainPage", false, "ArkuiOptions" };
1404     WSError result = ssm_->SetAppForceLandscapeConfig(bundleName, config);
1405     ASSERT_EQ(result, WSError::WS_OK);
1406 }
1407 
1408 /**
1409  * @tc.name: SetAppForceLandscapeConfig01
1410  * @tc.desc: SetAppForceLandscapeConfig_ShouldReturnNullptrError_WhenBundleNameIsEmpty
1411  * @tc.type: FUNC
1412  */
1413 HWTEST_F(SceneSessionManagerTest7, SetAppForceLandscapeConfig01, TestSize.Level1)
1414 {
1415     std::string bundleName = "";
1416     AppForceLandscapeConfig config;
1417     WSError result = ssm_->SetAppForceLandscapeConfig(bundleName, config);
1418     EXPECT_EQ(result, WSError::WS_ERROR_NULLPTR);
1419 }
1420 
1421 /**
1422  * @tc.name: SetAppForceLandscapeConfig02
1423  * @tc.desc: SetAppForceLandscapeConfig_ShouldUpdateConfig_WhenBundleNameIsValid
1424  * @tc.type: FUNC
1425  */
1426 HWTEST_F(SceneSessionManagerTest7, SetAppForceLandscapeConfig02, TestSize.Level1)
1427 {
1428     std::string bundleName = "com.example.app";
1429     AppForceLandscapeConfig config;
1430     config.mode_ = 5; // 5: FORCE_SPLIT_MODE
1431     config.homePage_ = "homePage";
1432     config.supportSplit_ = 5;
1433     config.arkUIOptions_ = "arkUIOptions";
1434 
1435     WSError result = ssm_->SetAppForceLandscapeConfig(bundleName, config);
1436     EXPECT_EQ(result, WSError::WS_OK);
1437     EXPECT_EQ(ssm_->appForceLandscapeMap_[bundleName].mode_, 5);
1438     EXPECT_EQ(ssm_->appForceLandscapeMap_[bundleName].homePage_, "homePage");
1439     EXPECT_EQ(ssm_->appForceLandscapeMap_[bundleName].supportSplit_, 5);
1440     EXPECT_EQ(ssm_->appForceLandscapeMap_[bundleName].arkUIOptions_, "arkUIOptions");
1441 }
1442 
1443 /**
1444  * @tc.name: SetAppForceLandscapeConfig03
1445  * @tc.desc: SetAppForceLandscapeConfig_ShouldUpdateConfig_WhenBundleNameIsValid
1446  * @tc.type: FUNC
1447  */
1448 HWTEST_F(SceneSessionManagerTest7, SetAppForceLandscapeConfig03, TestSize.Level1)
1449 {
1450     std::string bundleName = "com.example.app";
1451     AppForceLandscapeConfig preConfig;
1452     preConfig.mode_ = 0;
1453     preConfig.homePage_ = "homePage";
1454     preConfig.supportSplit_ = -1;
1455     preConfig.arkUIOptions_ = "arkUIOptions";
1456     ssm_->appForceLandscapeMap_[bundleName] = preConfig;
1457 
1458     AppForceLandscapeConfig config;
1459     config.mode_ = 5; // 5: FORCE_SPLIT_MODE
1460     config.homePage_ = "newHomePage";
1461     config.supportSplit_ = 5;
1462     config.arkUIOptions_ = "newArkUIOptions";
1463 
1464     WSError result = ssm_->SetAppForceLandscapeConfig(bundleName, config);
1465     EXPECT_EQ(result, WSError::WS_OK);
1466     EXPECT_EQ(ssm_->appForceLandscapeMap_[bundleName].mode_, 5);
1467     EXPECT_EQ(ssm_->appForceLandscapeMap_[bundleName].homePage_, "newHomePage");
1468     EXPECT_EQ(ssm_->appForceLandscapeMap_[bundleName].supportSplit_, 5);
1469     EXPECT_EQ(ssm_->appForceLandscapeMap_[bundleName].arkUIOptions_, "newArkUIOptions");
1470 }
1471 
1472 /**
1473  * @tc.name: GetAppForceLandscapeConfig
1474  * @tc.desc: SceneSesionManager GetAppForceLandscapeConfig
1475  * @tc.type: FUNC
1476  */
1477 HWTEST_F(SceneSessionManagerTest7, GetAppForceLandscapeConfig, TestSize.Level1)
1478 {
1479     std::string bundleName = "GetAppForceLandscapeConfig";
1480     AppForceLandscapeConfig config = ssm_->GetAppForceLandscapeConfig(bundleName);
1481     EXPECT_EQ(config.mode_, 0);
1482     EXPECT_EQ(config.homePage_, "");
1483     EXPECT_EQ(config.supportSplit_, -1);
1484     EXPECT_EQ(config.arkUIOptions_, "");
1485 }
1486 
1487 /**
1488  * @tc.name: RemoveProcessWatermarkPid
1489  * @tc.desc: SceneSesionManager RemoveProcessWatermarkPid
1490  * @tc.type: FUNC
1491  */
1492 HWTEST_F(SceneSessionManagerTest7, RemoveProcessWatermarkPid, TestSize.Level1)
1493 {
1494     ssm_->processWatermarkPidMap_.insert({ 1, "test" });
1495     ssm_->RemoveProcessWatermarkPid(1);
1496     ASSERT_EQ(ssm_->processWatermarkPidMap_.find(1), ssm_->processWatermarkPidMap_.end());
1497 }
1498 
1499 /**
1500  * @tc.name: SetSessionWatermarkForAppProcess
1501  * @tc.desc: SceneSesionManager SetSessionWatermarkForAppProcess
1502  * @tc.type: FUNC
1503  */
1504 HWTEST_F(SceneSessionManagerTest7, SetSessionWatermarkForAppProcess, TestSize.Level0)
1505 {
1506     SessionInfo info;
1507     sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(info, nullptr);
1508     sceneSession->SetCallingPid(1);
1509     ASSERT_FALSE(ssm_->SetSessionWatermarkForAppProcess(sceneSession));
1510     ssm_->processWatermarkPidMap_.insert({ 1, "test" });
1511     ASSERT_TRUE(ssm_->SetSessionWatermarkForAppProcess(sceneSession));
1512     ssm_->processWatermarkPidMap_.erase(1);
1513 }
1514 
1515 /**
1516  * @tc.name: CloseTargetFloatWindow
1517  * @tc.desc: SceneSesionManager CloseTargetFloatWindow
1518  * @tc.type: FUNC
1519  */
1520 HWTEST_F(SceneSessionManagerTest7, CloseTargetFloatWindow, TestSize.Level1)
1521 {
1522     std::string bundleName = "testClose";
1523     auto result = ssm_->CloseTargetFloatWindow(bundleName);
1524     ASSERT_EQ(result, WMError::WM_OK);
1525 }
1526 
1527 /**
1528  * @tc.name: CloseTargetPiPWindow
1529  * @tc.desc: SceneSesionManager CloseTargetPiPWindow
1530  * @tc.type: FUNC
1531  */
1532 HWTEST_F(SceneSessionManagerTest7, CloseTargetPiPWindow, TestSize.Level1)
1533 {
1534     std::string bundleName = "CloseTargetPiPWindow";
1535     auto result = ssm_->CloseTargetPiPWindow(bundleName);
1536     ASSERT_EQ(result, WMError::WM_OK);
1537 }
1538 
1539 /**
1540  * @tc.name: GetCurrentPiPWindowInfo01
1541  * @tc.desc: SceneSesionManager GetCurrentPiPWindowInfo
1542  * @tc.type: FUNC
1543  */
1544 HWTEST_F(SceneSessionManagerTest7, GetCurrentPiPWindowInfo01, TestSize.Level1)
1545 {
1546     std::string bundleName;
1547     auto result = ssm_->GetCurrentPiPWindowInfo(bundleName);
1548     ASSERT_EQ(result, WMError::WM_OK);
1549     ASSERT_EQ("", bundleName);
1550 }
1551 
1552 /**
1553  * @tc.name: GetCurrentPiPWindowInfo02
1554  * @tc.desc: SceneSesionManager GetCurrentPiPWindowInfo
1555  * @tc.type: FUNC
1556  */
1557 HWTEST_F(SceneSessionManagerTest7, GetCurrentPiPWindowInfo02, TestSize.Level1)
1558 {
1559     SessionInfo info1;
1560     info1.abilityName_ = "test1";
1561     info1.bundleName_ = "test1";
1562     info1.windowType_ = static_cast<uint32_t>(WindowType::WINDOW_TYPE_PIP);
1563     sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(info1, nullptr);
1564     ASSERT_NE(nullptr, sceneSession1);
1565     SessionInfo info2;
1566     info2.abilityName_ = "test2";
1567     info2.bundleName_ = "test2";
1568     info2.windowType_ = static_cast<uint32_t>(WindowType::WINDOW_TYPE_DIALOG);
1569     sptr<SceneSession> sceneSession2 = sptr<SceneSession>::MakeSptr(info2, nullptr);
1570     ASSERT_NE(nullptr, sceneSession2);
1571 
1572     ssm_->sceneSessionMap_.insert({ sceneSession1->GetPersistentId(), sceneSession1 });
1573     ssm_->sceneSessionMap_.insert({ sceneSession2->GetPersistentId(), sceneSession2 });
1574     std::string bundleName;
1575     auto result = ssm_->GetCurrentPiPWindowInfo(bundleName);
1576     ASSERT_EQ(result, WMError::WM_OK);
1577     ASSERT_EQ(info1.abilityName_, bundleName);
1578 }
1579 
1580 /**
1581  * @tc.name: SkipSnapshotByUserIdAndBundleNames
1582  * @tc.desc: SkipSnapshotByUserIdAndBundleNames
1583  * @tc.type: FUNC
1584  */
1585 HWTEST_F(SceneSessionManagerTest7, SkipSnapshotByUserIdAndBundleNames, TestSize.Level1)
1586 {
1587     ASSERT_NE(nullptr, ssm_);
1588     auto result = ssm_->SkipSnapshotByUserIdAndBundleNames(100, { "TestName" });
1589     ASSERT_EQ(result, WMError::WM_OK);
1590     usleep(WAIT_SYNC_FOR_SNAPSHOT_SKIP_IN_NS);
1591     ASSERT_NE(ssm_->snapshotSkipBundleNameSet_.find("TestName"), ssm_->snapshotSkipBundleNameSet_.end());
1592 
1593     result = ssm_->SkipSnapshotByUserIdAndBundleNames(100, {});
1594     ASSERT_EQ(result, WMError::WM_OK);
1595     usleep(WAIT_SYNC_FOR_SNAPSHOT_SKIP_IN_NS);
1596     ASSERT_EQ(ssm_->snapshotSkipBundleNameSet_.find("TestName"), ssm_->snapshotSkipBundleNameSet_.end());
1597 
1598     SessionInfo info1;
1599     info1.bundleName_ = "TestName1";
1600     sptr<SceneSession> sceneSession1 = ssm_->CreateSceneSession(info1, nullptr);
1601     SessionInfo info2;
1602     info1.bundleName_ = "TestName2";
1603     sptr<SceneSession> sceneSession2 = ssm_->CreateSceneSession(info2, nullptr);
1604     ASSERT_NE(nullptr, sceneSession1);
1605     ASSERT_NE(nullptr, sceneSession2);
1606     sceneSession1->SetCallingPid(1000);
1607     sceneSession2->SetCallingPid(1001);
1608     ssm_->sceneSessionMap_.insert({ sceneSession1->GetPersistentId(), sceneSession1 });
1609     ssm_->sceneSessionMap_.insert({ sceneSession2->GetPersistentId(), sceneSession2 });
1610     ssm_->sceneSessionMap_.insert({ -1, nullptr });
1611     result = ssm_->SkipSnapshotByUserIdAndBundleNames(100, { "TestName1" });
1612     ASSERT_EQ(result, WMError::WM_OK);
1613     ssm_->sceneSessionMap_.erase(sceneSession1->GetPersistentId());
1614     ssm_->sceneSessionMap_.erase(sceneSession2->GetPersistentId());
1615     ssm_->sceneSessionMap_.erase(-1);
1616     usleep(WAIT_SYNC_FOR_TEST_END_IN_NS);
1617 }
1618 
1619 /**
1620  * @tc.name: SetSessionSnapshotSkipForAppBundleName
1621  * @tc.desc: SceneSesionManager SetSessionSnapshotSkipForAppBundleName
1622  * @tc.type: FUNC
1623  */
1624 HWTEST_F(SceneSessionManagerTest7, SetSessionSnapshotSkipForAppBundleName, TestSize.Level1)
1625 {
1626     SessionInfo info;
1627     info.bundleName_ = "TestName";
1628     sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(info, nullptr);
1629     struct RSSurfaceNodeConfig config;
1630     std::shared_ptr<RSSurfaceNode> surfaceNode = RSSurfaceNode::Create(config);
1631     sceneSession->surfaceNode_ = surfaceNode;
1632     ssm_->SetSessionSnapshotSkipForAppBundleName(sceneSession);
1633     ASSERT_EQ(sceneSession->GetSessionProperty()->GetSnapshotSkip(), false);
1634 
1635     ssm_->snapshotSkipBundleNameSet_.insert("TestName");
1636     ssm_->SetSessionSnapshotSkipForAppBundleName(sceneSession);
1637     ASSERT_EQ(sceneSession->GetSessionProperty()->GetSnapshotSkip(), true);
1638     ssm_->snapshotSkipBundleNameSet_.erase("TestName");
1639 }
1640 
1641 /**
1642  * @tc.name: GetRootMainWindowId
1643  * @tc.desc: SceneSesionManager GetRootMainWindowId
1644  * @tc.type: FUNC
1645  */
1646 HWTEST_F(SceneSessionManagerTest7, GetRootMainWindowId, TestSize.Level1)
1647 {
1648     SessionInfo info1;
1649     info1.abilityName_ = "test1";
1650     info1.bundleName_ = "test1";
1651     info1.windowType_ = static_cast<uint32_t>(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
1652     sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(info1, nullptr);
1653     ASSERT_NE(nullptr, sceneSession1);
1654     SessionInfo info2;
1655     info2.abilityName_ = "test2";
1656     info2.bundleName_ = "test2";
1657     info2.windowType_ = static_cast<uint32_t>(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
1658     sptr<SceneSession> sceneSession2 = sptr<SceneSession>::MakeSptr(info2, nullptr);
1659     ASSERT_NE(nullptr, sceneSession2);
1660     sceneSession2->SetParentSession(sceneSession1);
1661 
1662     ssm_->sceneSessionMap_.insert({ sceneSession1->GetPersistentId(), sceneSession1 });
1663     ssm_->sceneSessionMap_.insert({ sceneSession2->GetPersistentId(), sceneSession2 });
1664     int32_t hostWindowId = -1;
1665     auto result = ssm_->GetRootMainWindowId(sceneSession2->GetPersistentId(), hostWindowId);
1666     ASSERT_EQ(result, WMError::WM_OK);
1667     ASSERT_EQ(hostWindowId, sceneSession1->GetPersistentId());
1668 }
1669 
1670 /**
1671  * @tc.name: UpdateScreenLockStatusForApp
1672  * @tc.desc: SceneSesionManager UpdateScreenLockStatusForApp
1673  * @tc.type: FUNC
1674  */
1675 HWTEST_F(SceneSessionManagerTest7, UpdateScreenLockStatusForApp, TestSize.Level1)
1676 {
1677     auto result = ssm_->UpdateScreenLockStatusForApp("", true);
1678     ASSERT_EQ(result, WMError::WM_OK);
1679 }
1680 
1681 /**
1682  * @tc.name: UpdateAppHookDisplayInfo001
1683  * @tc.desc: Test delete HookDisplayInfo
1684  * @tc.type: FUNC
1685  */
1686 HWTEST_F(SceneSessionManagerTest7, UpdateAppHookDisplayInfo001, TestSize.Level1)
1687 {
1688     int32_t uid = 0;
1689     bool enable = false;
1690     HookInfo hookInfo;
1691     hookInfo.width_ = 100;
1692     hookInfo.height_ = 100;
1693     hookInfo.density_ = 2.25;
1694     hookInfo.rotation_ = 0;
1695     hookInfo.enableHookRotation_ = false;
1696     auto result = ssm_->UpdateAppHookDisplayInfo(uid, hookInfo, enable);
1697     ASSERT_EQ(result, WMError::WM_OK);
1698 
1699     uid = 20221524;
1700     hookInfo.width_ = 0;
1701     result = ssm_->UpdateAppHookDisplayInfo(uid, hookInfo, enable);
1702     ASSERT_EQ(result, WMError::WM_OK);
1703 
1704     hookInfo.width_ = 100;
1705     hookInfo.height_ = 0;
1706     result = ssm_->UpdateAppHookDisplayInfo(uid, hookInfo, enable);
1707     ASSERT_EQ(result, WMError::WM_OK);
1708 
1709     hookInfo.height_ = 100;
1710     hookInfo.density_ = 0;
1711     result = ssm_->UpdateAppHookDisplayInfo(uid, hookInfo, enable);
1712     ASSERT_EQ(result, WMError::WM_OK);
1713 
1714     hookInfo.density_ = 2.25;
1715     result = ssm_->UpdateAppHookDisplayInfo(uid, hookInfo, enable);
1716     ASSERT_EQ(result, WMError::WM_OK);
1717 }
1718 
1719 /**
1720  * @tc.name: UpdateAppHookDisplayInfo002
1721  * @tc.desc: Test add HookDisplayInfo
1722  * @tc.type: FUNC
1723  */
1724 HWTEST_F(SceneSessionManagerTest7, UpdateAppHookDisplayInfo002, TestSize.Level1)
1725 {
1726     int32_t uid = 0;
1727     bool enable = true;
1728     HookInfo hookInfo;
1729     hookInfo.width_ = 100;
1730     hookInfo.height_ = 100;
1731     hookInfo.density_ = 2.25;
1732     hookInfo.rotation_ = 0;
1733     hookInfo.enableHookRotation_ = false;
1734     auto result = ssm_->UpdateAppHookDisplayInfo(uid, hookInfo, enable);
1735     ASSERT_EQ(result, WMError::WM_ERROR_INVALID_PARAM);
1736 
1737     uid = 20221524;
1738     hookInfo.width_ = 0;
1739     result = ssm_->UpdateAppHookDisplayInfo(uid, hookInfo, enable);
1740     ASSERT_EQ(result, WMError::WM_ERROR_INVALID_PARAM);
1741 
1742     hookInfo.width_ = 100;
1743     hookInfo.height_ = 0;
1744     result = ssm_->UpdateAppHookDisplayInfo(uid, hookInfo, enable);
1745     ASSERT_EQ(result, WMError::WM_ERROR_INVALID_PARAM);
1746 
1747     hookInfo.height_ = 100;
1748     hookInfo.density_ = 0;
1749     result = ssm_->UpdateAppHookDisplayInfo(uid, hookInfo, enable);
1750     ASSERT_EQ(result, WMError::WM_ERROR_INVALID_PARAM);
1751 
1752     hookInfo.density_ = 2.25;
1753     result = ssm_->UpdateAppHookDisplayInfo(uid, hookInfo, enable);
1754     ASSERT_EQ(result, WMError::WM_OK);
1755 }
1756 
1757 /**
1758  * @tc.name: IsPcWindow
1759  * @tc.desc: IsPcWindow
1760  * @tc.type: FUNC
1761  */
1762 HWTEST_F(SceneSessionManagerTest7, IsPcWindow, TestSize.Level1)
1763 {
1764     bool isPcWindow = false;
1765     auto result = ssm_->IsPcWindow(isPcWindow);
1766     ASSERT_EQ(result, WMError::WM_OK);
1767 }
1768 
1769 /**
1770  * @tc.name: IsPcOrPadFreeMultiWindowMode
1771  * @tc.desc: IsPcOrPadFreeMultiWindowMode
1772  * @tc.type: FUNC
1773  */
1774 HWTEST_F(SceneSessionManagerTest7, IsPcOrPadFreeMultiWindowMode, TestSize.Level1)
1775 {
1776     bool isPcOrPadFreeMultiWindowMode = false;
1777     auto result = ssm_->IsPcOrPadFreeMultiWindowMode(isPcOrPadFreeMultiWindowMode);
1778     ASSERT_EQ(result, WMError::WM_OK);
1779 }
1780 
1781 /**
1782  * @tc.name: SetImageForRecent001
1783  * @tc.desc: SetImageForRecent001
1784  * @tc.type: FUNC
1785  */
1786 HWTEST_F(SceneSessionManagerTest7, SetImageForRecent001, TestSize.Level1)
1787 {
1788     ssm_->sceneSessionMap_.clear();
1789     SessionInfo info;
1790     info.abilityName_ = "test";
1791     info.bundleName_ = "test";
1792     info.persistentId_ = 1999;
1793     info.windowType_ = static_cast<uint32_t>(WindowType::APP_WINDOW_BASE);
1794     auto result = ssm_->SetImageForRecent(1, ImageFit::FILL, 1);
1795     ASSERT_EQ(result, WMError::WM_ERROR_NULLPTR);
1796 
1797     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1798     ASSERT_NE(sceneSession, nullptr);
1799     ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession });
1800 
1801     std::shared_ptr<AppExecFwk::AbilityInfo> abilityInfo = std::make_shared<AppExecFwk::AbilityInfo>();
1802     AppExecFwk::ApplicationInfo applicationInfo;
1803     sceneSession->state_ = SessionState::STATE_FOREGROUND;
1804     result = ssm_->SetImageForRecent(1, ImageFit::FILL, sceneSession->GetPersistentId());
1805     ASSERT_EQ(result, WMError::WM_ERROR_NULLPTR);
1806 
1807     sceneSession->state_ = SessionState::STATE_ACTIVE;
1808     applicationInfo.isSystemApp = false;
1809     abilityInfo->applicationInfo = applicationInfo;
1810     sceneSession->SetAbilitySessionInfo(abilityInfo);
1811     result = ssm_->SetImageForRecent(1, ImageFit::FILL, sceneSession->GetPersistentId());
1812     ASSERT_EQ(result, WMError::WM_ERROR_NOT_SYSTEM_APP);
1813 
1814     applicationInfo.isSystemApp = true;
1815     abilityInfo->applicationInfo = applicationInfo;
1816     sceneSession->SetAbilitySessionInfo(abilityInfo);
1817     result = ssm_->SetImageForRecent(1, ImageFit::FILL, sceneSession->GetPersistentId());
1818     ASSERT_EQ(result, WMError::WM_ERROR_NULLPTR);
1819     ssm_->sceneSessionMap_.erase(sceneSession->GetPersistentId());
1820 }
1821 
1822 /**
1823  * @tc.name: IsWindowRectAutoSave
1824  * @tc.desc: IsWindowRectAutoSave
1825  * @tc.type: FUNC
1826  */
1827 HWTEST_F(SceneSessionManagerTest7, IsWindowRectAutoSave, TestSize.Level1)
1828 {
1829     std::string key = "com.example.recposentryEntryAbilityabc";
1830     bool enabled = false;
1831     int persistentId = 1;
1832     auto result = ssm_->IsWindowRectAutoSave(key, enabled, persistentId);
1833     ASSERT_EQ(result, WMError::WM_ERROR_INVALID_SESSION);
1834 }
1835 
1836 /**
1837  * @tc.name: SetImageForRecent
1838  * @tc.desc: SetImageForRecent
1839  * @tc.type: FUNC
1840  */
1841 HWTEST_F(SceneSessionManagerTest7, SetImageForRecent, TestSize.Level1)
1842 {
1843     uint32_t imgResourceId = 1;
1844     ImageFit imageFit = ImageFit::FILL;
1845     int32_t persistentId = 1;
1846     auto result = ssm_->SetImageForRecent(imgResourceId, imageFit, persistentId);
1847     ASSERT_EQ(result, WMError::WM_ERROR_NULLPTR);
1848 }
1849 
1850 /**
1851  * @tc.name: SetIsWindowRectAutoSave
1852  * @tc.desc: SetIsWindowRectAutoSave
1853  * @tc.type: FUNC
1854  */
1855 HWTEST_F(SceneSessionManagerTest7, SetIsWindowRectAutoSave, TestSize.Level1)
1856 {
1857     std::string key = "com.example.recposentryEntryAbilityTest";
1858     bool enabled = true;
1859     std::string abilityKey = "com.example.recposentryEntryAbility";
1860     bool isSaveSpecifiedFlag = true;
1861     ssm_->SetIsWindowRectAutoSave(key, enabled, abilityKey, isSaveSpecifiedFlag);
1862     ASSERT_EQ(ssm_->isWindowRectAutoSaveMap_.at(key), true);
1863     ASSERT_EQ(ssm_->isSaveBySpecifiedFlagMap_.at(abilityKey), true);
1864 }
1865 
1866 /**
1867  * @tc.name: GetDisplayIdByWindowId01
1868  * @tc.desc: test function : GetDisplayIdByWindowId
1869  * @tc.type: FUNC
1870  */
1871 HWTEST_F(SceneSessionManagerTest7, GetDisplayIdByWindowId01, TestSize.Level1)
1872 {
1873     SessionInfo info;
1874     info.abilityName_ = "test";
1875     info.bundleName_ = "test";
1876     sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(info, nullptr);
1877     ASSERT_NE(nullptr, sceneSession1);
1878     ssm_->sceneSessionMap_.insert({ sceneSession1->GetPersistentId(), sceneSession1 });
1879     sptr<SceneSession> sceneSession2 = sptr<SceneSession>::MakeSptr(info, nullptr);
1880     ASSERT_NE(nullptr, sceneSession2);
1881     ssm_->sceneSessionMap_.insert({ sceneSession2->GetPersistentId(), sceneSession2 });
1882 
1883     DisplayId displayId = 0;
1884     sceneSession1->property_->SetDisplayId(displayId);
1885 
1886     const std::vector<uint64_t> windowIds = { 1001,
1887                                               sceneSession1->GetPersistentId(),
1888                                               sceneSession2->GetPersistentId() };
1889     std::unordered_map<uint64_t, DisplayId> windowDisplayIdMap;
1890     ASSERT_EQ(ssm_->GetDisplayIdByWindowId(windowIds, windowDisplayIdMap), WMError::WM_OK);
1891 }
1892 
1893 /**
1894  * @tc.name: GetDisplayIdByWindowId02
1895  * @tc.desc: Half fold
1896  * @tc.type: FUNC
1897  */
1898 HWTEST_F(SceneSessionManagerTest7, GetDisplayIdByWindowId02, TestSize.Level1)
1899 {
1900     PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus(
1901         0, SuperFoldStatus::HALF_FOLDED, { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1624, 2472, 1648 });
1902     SessionInfo sessionInfo;
1903     sessionInfo.isSystem_ = false;
1904 
1905     sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1906     sceneSession1->SetVisibilityState(WINDOW_VISIBILITY_STATE_NO_OCCLUSION);
1907     WSRect rect = { 0, 4000, 120, 1000 };
1908     sceneSession1->SetSessionRect(rect);
1909     sceneSession1->SetSessionGlobalRect(rect);
1910     sceneSession1->property_->SetDisplayId(0);
1911     sceneSession1->SetClientDisplayId(999);
1912     int32_t zOrder = 100;
1913     sceneSession1->SetZOrder(zOrder);
1914     ssm_->sceneSessionMap_.insert({ sceneSession1->GetPersistentId(), sceneSession1 });
1915 
1916     std::vector<uint64_t> windowIds;
1917     windowIds.emplace_back(sceneSession1->GetPersistentId());
1918     std::unordered_map<uint64_t, DisplayId> windowDisplayIdMap;
1919     ssm_->GetDisplayIdByWindowId(windowIds, windowDisplayIdMap);
1920     ssm_->sceneSessionMap_.clear();
1921     ASSERT_EQ(windowDisplayIdMap[sceneSession1->GetPersistentId()], 999);
1922 }
1923 
1924 /**
1925  * @tc.name: SetGlobalDragResizeType01
1926  * @tc.desc: test function : SetGlobalDragResizeType valid session
1927  * @tc.type: FUNC
1928  */
1929 HWTEST_F(SceneSessionManagerTest7, SetGlobalDragResizeType01, TestSize.Level1)
1930 {
1931     DragResizeType dragResizeType = DragResizeType::RESIZE_EACH_FRAME;
1932     ASSERT_EQ(ssm_->SetGlobalDragResizeType(dragResizeType), WMError::WM_OK);
1933 
1934     SessionInfo info;
1935     info.abilityName_ = "test1";
1936     info.bundleName_ = "test1";
1937     info.windowType_ = static_cast<uint32_t>(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
1938     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1939     ASSERT_NE(nullptr, sceneSession);
1940     ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession });
1941 
1942     ASSERT_EQ(ssm_->SetGlobalDragResizeType(DragResizeType::RESIZE_TYPE_UNDEFINED), WMError::WM_OK);
1943     usleep(WAIT_SYNC_IN_NS);
1944     ASSERT_EQ(ssm_->SetGlobalDragResizeType(dragResizeType), WMError::WM_OK);
1945     usleep(WAIT_SYNC_IN_NS);
1946 }
1947 
1948 /**
1949  * @tc.name: SetGlobalDragResizeType02
1950  * @tc.desc: test function : SetGlobalDragResizeType invalid session
1951  * @tc.type: FUNC
1952  */
1953 HWTEST_F(SceneSessionManagerTest7, SetGlobalDragResizeType02, TestSize.Level1)
1954 {
1955     DragResizeType dragResizeType = DragResizeType::RESIZE_EACH_FRAME;
1956     ASSERT_EQ(ssm_->SetGlobalDragResizeType(dragResizeType), WMError::WM_OK);
1957     SessionInfo info;
1958     info.abilityName_ = "test1";
1959     info.bundleName_ = "test1";
1960     info.windowType_ = static_cast<uint32_t>(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
1961     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1962     ASSERT_NE(nullptr, sceneSession);
1963     ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession });
1964     ASSERT_EQ(ssm_->SetGlobalDragResizeType(dragResizeType), WMError::WM_OK);
1965     usleep(WAIT_SYNC_IN_NS);
1966     ssm_->sceneSessionMap_.insert({ 0, nullptr });
1967     ASSERT_EQ(ssm_->SetGlobalDragResizeType(dragResizeType), WMError::WM_OK);
1968     usleep(WAIT_SYNC_IN_NS);
1969     ssm_->sceneSessionMap_.clear();
1970     ssm_->sceneSessionMap_.insert({ 0, nullptr });
1971     ASSERT_EQ(ssm_->SetGlobalDragResizeType(dragResizeType), WMError::WM_OK);
1972     usleep(WAIT_SYNC_IN_NS);
1973 }
1974 
1975 /**
1976  * @tc.name: GetGlobalDragResizeType
1977  * @tc.desc: test function : GetGlobalDragResizeType
1978  * @tc.type: FUNC
1979  */
1980 HWTEST_F(SceneSessionManagerTest7, GetGlobalDragResizeType, TestSize.Level1)
1981 {
1982     DragResizeType dragResizeType = DragResizeType::RESIZE_TYPE_UNDEFINED;
1983     ASSERT_EQ(ssm_->GetGlobalDragResizeType(dragResizeType), WMError::WM_OK);
1984 }
1985 
1986 /**
1987  * @tc.name: SetAppDragResizeType
1988  * @tc.desc: test function : SetAppDragResizeType
1989  * @tc.type: FUNC
1990  */
1991 HWTEST_F(SceneSessionManagerTest7, SetAppDragResizeType, TestSize.Level1)
1992 {
1993     SessionInfo info;
1994     info.abilityName_ = "test1";
1995     info.bundleName_ = "test1";
1996     info.windowType_ = static_cast<uint32_t>(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
1997     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1998     ASSERT_NE(nullptr, sceneSession);
1999     ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession });
2000     DragResizeType dragResizeType = DragResizeType::RESIZE_EACH_FRAME;
2001     ASSERT_EQ(ssm_->SetAppDragResizeType("", dragResizeType), WMError::WM_ERROR_INVALID_PARAM);
2002     ASSERT_EQ(ssm_->SetAppDragResizeType(info.bundleName_, dragResizeType), WMError::WM_OK);
2003 }
2004 
2005 /**
2006  * @tc.name: GetDefaultDragResizeType
2007  * @tc.desc: test function : GetDefaultDragResizeType
2008  * @tc.type: FUNC
2009  */
2010 HWTEST_F(SceneSessionManagerTest7, GetDefaultDragResizeType, TestSize.Level1)
2011 {
2012     DragResizeType originalDragResizeType = ssm_->systemConfig_.freeMultiWindowConfig_.defaultDragResizeType_;
2013     bool originalFreeMultiWindowSupport = ssm_->systemConfig_.freeMultiWindowSupport_;
2014     ASSERT_EQ(ssm_->SetGlobalDragResizeType(DragResizeType::RESIZE_TYPE_UNDEFINED), WMError::WM_OK);
2015     // not support
2016     ssm_->systemConfig_.freeMultiWindowSupport_ = false;
2017     ssm_->systemConfig_.freeMultiWindowConfig_.defaultDragResizeType_ = DragResizeType::RESIZE_TYPE_UNDEFINED;
2018     DragResizeType dragResizeType = DragResizeType::RESIZE_TYPE_UNDEFINED;
2019     ssm_->GetEffectiveDragResizeType(dragResizeType);
2020     ASSERT_EQ(dragResizeType, DragResizeType::RESIZE_EACH_FRAME);
2021     // support and default
2022     ssm_->systemConfig_.freeMultiWindowSupport_ = true;
2023     ssm_->systemConfig_.freeMultiWindowConfig_.defaultDragResizeType_ = DragResizeType::RESIZE_TYPE_UNDEFINED;
2024     dragResizeType = DragResizeType::RESIZE_TYPE_UNDEFINED;
2025     ssm_->GetEffectiveDragResizeType(dragResizeType);
2026     ASSERT_EQ(dragResizeType, DragResizeType::RESIZE_WHEN_DRAG_END);
2027     // support and set
2028     ssm_->systemConfig_.freeMultiWindowConfig_.defaultDragResizeType_ = DragResizeType::RESIZE_WHEN_DRAG_END;
2029     dragResizeType = DragResizeType::RESIZE_TYPE_UNDEFINED;
2030     ssm_->GetEffectiveDragResizeType(dragResizeType);
2031     ASSERT_EQ(dragResizeType, ssm_->systemConfig_.freeMultiWindowConfig_.defaultDragResizeType_);
2032 
2033     ssm_->systemConfig_.freeMultiWindowConfig_.defaultDragResizeType_ = originalDragResizeType;
2034     ssm_->systemConfig_.freeMultiWindowSupport_ = originalFreeMultiWindowSupport;
2035 }
2036 
2037 /**
2038  * @tc.name: GetAppDragResizeType
2039  * @tc.desc: test function : GetAppDragResizeType
2040  * @tc.type: FUNC
2041  */
2042 HWTEST_F(SceneSessionManagerTest7, GetAppDragResizeType, TestSize.Level1)
2043 {
2044     SessionInfo info;
2045     info.abilityName_ = "test1";
2046     info.bundleName_ = "test1";
2047     info.windowType_ = static_cast<uint32_t>(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
2048     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
2049     ASSERT_NE(nullptr, sceneSession);
2050     ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession });
2051     DragResizeType dragResizeType = DragResizeType::RESIZE_TYPE_UNDEFINED;
2052     ASSERT_EQ(ssm_->GetAppDragResizeType(info.bundleName_, dragResizeType), WMError::WM_OK);
2053 }
2054 
2055 /**
2056  * @tc.name: SetAppKeyFramePolicy
2057  * @tc.desc: test function : SetAppKeyFramePolicy
2058  * @tc.type: FUNC
2059  */
2060 HWTEST_F(SceneSessionManagerTest7, SetAppKeyFramePolicy, TestSize.Level1)
2061 {
2062     SessionInfo info;
2063     info.abilityName_ = "test1";
2064     info.bundleName_ = "test1";
2065     info.windowType_ = static_cast<uint32_t>(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
2066     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
2067     ASSERT_NE(nullptr, sceneSession);
2068     KeyFramePolicy keyFramePolicy;
2069     // empty map
2070     ASSERT_EQ(ssm_->SetAppKeyFramePolicy(info.bundleName_, keyFramePolicy), WMError::WM_OK);
2071     auto getKeyFramePolicy = ssm_->GetAppKeyFramePolicy(info.bundleName_);
2072     ASSERT_EQ(getKeyFramePolicy.dragResizeType_, keyFramePolicy.dragResizeType_);
2073     keyFramePolicy.dragResizeType_ = DragResizeType::RESIZE_KEY_FRAME;
2074     ASSERT_EQ(ssm_->SetAppKeyFramePolicy(info.bundleName_, keyFramePolicy), WMError::WM_OK);
2075     getKeyFramePolicy = ssm_->GetAppKeyFramePolicy(info.bundleName_);
2076     ASSERT_EQ(getKeyFramePolicy.dragResizeType_, keyFramePolicy.dragResizeType_);
2077     // valid
2078     ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession });
2079     ASSERT_EQ(ssm_->SetAppKeyFramePolicy(info.bundleName_, keyFramePolicy), WMError::WM_OK);
2080     getKeyFramePolicy = ssm_->GetAppKeyFramePolicy(info.bundleName_);
2081     ASSERT_EQ(getKeyFramePolicy.dragResizeType_, keyFramePolicy.dragResizeType_);
2082     // nullptr
2083     ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), nullptr });
2084     ASSERT_EQ(ssm_->SetAppKeyFramePolicy(info.bundleName_, keyFramePolicy), WMError::WM_OK);
2085     getKeyFramePolicy = ssm_->GetAppKeyFramePolicy(info.bundleName_);
2086     ASSERT_EQ(getKeyFramePolicy.dragResizeType_, keyFramePolicy.dragResizeType_);
2087     // empty name
2088     ASSERT_EQ(ssm_->SetAppKeyFramePolicy("", keyFramePolicy), WMError::WM_ERROR_INVALID_PARAM);
2089     // sub window
2090     info.windowType_ = static_cast<uint32_t>(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
2091     sptr<SceneSession> sceneSession2 = sptr<SceneSession>::MakeSptr(info, nullptr);
2092     ASSERT_NE(nullptr, sceneSession2);
2093     ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession2 });
2094     ASSERT_EQ(ssm_->SetAppKeyFramePolicy(info.bundleName_, keyFramePolicy), WMError::WM_OK);
2095 }
2096 
2097 /**
2098  * @tc.name: BuildCancelPointerEvent
2099  * @tc.desc: test function : BuildCancelPointerEvent
2100  * @tc.type: FUNC
2101  */
2102 HWTEST_F(SceneSessionManagerTest7, BuildCancelPointerEvent, TestSize.Level1)
2103 {
2104     auto pointerEvent = MMI::PointerEvent::Create();
2105     ssm_->BuildCancelPointerEvent(pointerEvent, 0, MMI::PointerEvent::POINTER_ACTION_DOWN, 2);
2106     int32_t pointerId = 99999999;
2107     ASSERT_EQ(pointerEvent->GetId(), pointerId);
2108     ASSERT_EQ(pointerEvent->GetTargetWindowId(), 2);
2109     ASSERT_EQ(pointerEvent->GetPointerId(), 0);
2110     ASSERT_EQ(pointerEvent->GetPointerAction(), MMI::PointerEvent::POINTER_ACTION_CANCEL);
2111     ASSERT_EQ(pointerEvent->GetSourceType(), MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
2112 }
2113 
2114 /**
2115  * @tc.name: MinimizeByWindowId
2116  * @tc.desc: test function : MinimizeByWindowId
2117  * @tc.type: FUNC
2118  */
2119 HWTEST_F(SceneSessionManagerTest7, MinimizeByWindowId, TestSize.Level1)
2120 {
2121     std::vector<int32_t> windowIds;
2122     WMError res = ssm_->MinimizeByWindowId(windowIds);
2123     EXPECT_EQ(WMError::WM_ERROR_INVALID_PARAM, res);
2124 }
2125 
2126 /**
2127  * @tc.name: SetForegroundWindowNum
2128  * @tc.desc: test function : SetForegroundWindowNum
2129  * @tc.type: FUNC
2130  */
2131 HWTEST_F(SceneSessionManagerTest7, SetForegroundWindowNum, TestSize.Level1)
2132 {
2133     uint32_t windowNum = 0;
2134     WMError res = ssm_->SetForegroundWindowNum(windowNum);
2135     if (!ssm_->systemConfig_.freeMultiWindowSupport_) {
2136         EXPECT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, res);
2137     } else {
2138         EXPECT_EQ(WMError::WM_OK, res);
2139         windowNum = 1;
2140         res = ssm_->SetForegroundWindowNum(windowNum);
2141         EXPECT_EQ(WMError::WM_OK, res);
2142     }
2143 }
2144 
2145 /**
2146  * @tc.name: CloneWindow
2147  * @tc.desc: test function : CloneWindow
2148  * @tc.type: FUNC
2149  */
2150 HWTEST_F(SceneSessionManagerTest7, CloneWindow, TestSize.Level1)
2151 {
2152     int32_t fromPersistentId = 8;
2153     int32_t toPersistentId = 11;
2154     bool needOffScreen = true;
2155     WSError res = ssm_->CloneWindow(fromPersistentId, toPersistentId, needOffScreen);
2156     EXPECT_EQ(WSError::WS_ERROR_NULLPTR, res);
2157 }
2158 
2159 /**
2160  * @tc.name: ConfigSupportFunctionType
2161  * @tc.desc: test function : ConfigSupportFunctionType
2162  * @tc.type: FUNC
2163  */
2164 HWTEST_F(SceneSessionManagerTest7, ConfigSupportFunctionType, Function | SmallTest | Level3)
2165 {
2166     ssm_->ConfigSupportFunctionType(SupportFunctionType::ALLOW_KEYBOARD_WILL_ANIMATION_NOTIFICATION);
2167     EXPECT_EQ(SupportFunctionType::ALLOW_KEYBOARD_WILL_ANIMATION_NOTIFICATION,
2168         (ssm_->systemConfig_.supportFunctionType_ & SupportFunctionType::ALLOW_KEYBOARD_WILL_ANIMATION_NOTIFICATION));
2169 }
2170 } // namespace
2171 } // namespace Rosen
2172 } // namespace OHOS