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 "session_manager/include/scene_session_manager.h"
21 #include "session_info.h"
22 #include "session/host/include/scene_session.h"
23 #include "session_manager.h"
24 
25 using namespace testing;
26 using namespace testing::ext;
27 
28 namespace OHOS {
29 namespace Rosen {
30 namespace {
31 const std::string EMPTY_DEVICE_ID = "";
32 using ConfigItem = WindowSceneConfig::ConfigItem;
33 }
34 class SceneSessionManagerTest7 : public testing::Test {
35 public:
36     static void SetUpTestCase();
37     static void TearDownTestCase();
38     void SetUp() override;
39     void TearDown() override;
40 
41     static bool gestureNavigationEnabled_;
42     static ProcessGestureNavigationEnabledChangeFunc callbackFunc_;
43     static sptr<SceneSessionManager> ssm_;
44 private:
45     static constexpr uint32_t WAIT_SYNC_IN_NS = 200000;
46 };
47 
48 sptr<SceneSessionManager> SceneSessionManagerTest7::ssm_ = nullptr;
49 
50 bool SceneSessionManagerTest7::gestureNavigationEnabled_ = true;
51 ProcessGestureNavigationEnabledChangeFunc SceneSessionManagerTest7::callbackFunc_ = [](bool enable,
52     const std::string& bundleName, GestureBackType type) {
53     gestureNavigationEnabled_ = enable;
54 };
55 
WindowChangedFuncTest(int32_t persistentId, WindowUpdateType type)56 void WindowChangedFuncTest(int32_t persistentId, WindowUpdateType type)
57 {
58 }
59 
ProcessStatusBarEnabledChangeFuncTest(bool enable)60 void ProcessStatusBarEnabledChangeFuncTest(bool enable)
61 {
62 }
63 
DumpRootSceneElementInfoFuncTest(const std::vector<std::string>& params, std::vector<std::string>& infos)64 void DumpRootSceneElementInfoFuncTest(const std::vector<std::string>& params, std::vector<std::string>& infos)
65 {
66 }
67 
SetUpTestCase()68 void SceneSessionManagerTest7::SetUpTestCase()
69 {
70     ssm_ = &SceneSessionManager::GetInstance();
71 }
72 
TearDownTestCase()73 void SceneSessionManagerTest7::TearDownTestCase()
74 {
75     ssm_ = nullptr;
76 }
77 
SetUp()78 void SceneSessionManagerTest7::SetUp()
79 {
80     ssm_->sceneSessionMap_.clear();
81 }
82 
TearDown()83 void SceneSessionManagerTest7::TearDown()
84 {
85     usleep(WAIT_SYNC_IN_NS);
86     ssm_->sceneSessionMap_.clear();
87 }
88 
89 namespace {
90 /**
91  * @tc.name: UpdateSessionWindowVisibilityListener
92  * @tc.desc: UpdateSessionWindowVisibilityListener
93  * @tc.type: FUNC
94  */
HWTEST_F(SceneSessionManagerTest7, UpdateSessionWindowVisibilityListener, Function | SmallTest | Level3)95 HWTEST_F(SceneSessionManagerTest7, UpdateSessionWindowVisibilityListener, Function | SmallTest | Level3)
96 {
97     int32_t persistentId = 1;
98     bool haveListener = true;
99     ASSERT_NE(nullptr, ssm_);
100     ssm_->sceneSessionMap_.clear();
101     auto ret = ssm_->UpdateSessionWindowVisibilityListener(persistentId, haveListener);
102     EXPECT_EQ(ret, WSError::WS_DO_NOTHING);
103     SessionInfo sessionInfo;
104     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
105     sessionInfo.abilityName_ = "UpdateSessionWindowVisibilityListener";
106     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
107     ASSERT_NE(nullptr, sceneSession);
108     sceneSession->callingPid_ = 65535;
109     ssm_->sceneSessionMap_.insert(std::make_pair(persistentId, sceneSession));
110     ret = ssm_->UpdateSessionWindowVisibilityListener(persistentId, haveListener);
111     EXPECT_EQ(ret, WSError::WS_ERROR_INVALID_PERMISSION);
112 }
113 
114 /**
115  * @tc.name: ProcessVirtualPixelRatioChange
116  * @tc.desc: ProcessVirtualPixelRatioChange
117  * @tc.type: FUNC
118  */
HWTEST_F(SceneSessionManagerTest7, ProcessVirtualPixelRatioChange, Function | SmallTest | Level3)119 HWTEST_F(SceneSessionManagerTest7, ProcessVirtualPixelRatioChange, Function | SmallTest | Level3)
120 {
121     DisplayId defaultDisplayId = 0;
122     sptr<DisplayInfo> displayInfo = nullptr;
123     std::map<DisplayId, sptr<DisplayInfo>> displayInfoMap;
124     DisplayStateChangeType type = DisplayStateChangeType::BEFORE_SUSPEND;
125     ASSERT_NE(nullptr, ssm_);
126     ssm_->ProcessVirtualPixelRatioChange(defaultDisplayId, displayInfo, displayInfoMap, type);
127     displayInfo = sptr<DisplayInfo>::MakeSptr();
128     ASSERT_NE(nullptr, displayInfo);
129     ssm_->sceneSessionMap_.clear();
130     ssm_->ProcessVirtualPixelRatioChange(defaultDisplayId, displayInfo, displayInfoMap, type);
131     SessionInfo sessionInfo;
132     sessionInfo.bundleName_ = "SceneSessionManagerTest6";
133     sessionInfo.abilityName_ = "UpdateAvoidArea";
134     sessionInfo.isSystem_ = true;
135     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
136     ASSERT_NE(nullptr, sceneSession);
137     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
138     ssm_->ProcessVirtualPixelRatioChange(defaultDisplayId, displayInfo, displayInfoMap, type);
139     sessionInfo.isSystem_ = false;
140     ssm_->ProcessVirtualPixelRatioChange(defaultDisplayId, displayInfo, displayInfoMap, type);
141     sceneSession->SetSessionState(SessionState::STATE_FOREGROUND);
142     ssm_->ProcessVirtualPixelRatioChange(defaultDisplayId, displayInfo, displayInfoMap, type);
143     sceneSession->SetSessionState(SessionState::STATE_ACTIVE);
144     ssm_->ProcessVirtualPixelRatioChange(defaultDisplayId, displayInfo, displayInfoMap, type);
145     sceneSession->SetSessionState(SessionState::STATE_INACTIVE);
146     ssm_->ProcessVirtualPixelRatioChange(defaultDisplayId, displayInfo, displayInfoMap, type);
147     sceneSession = nullptr;
148     ssm_->ProcessVirtualPixelRatioChange(defaultDisplayId, displayInfo, displayInfoMap, type);
149 }
150 
151 /**
152  * @tc.name: ProcessVirtualPixelRatioChange01
153  * @tc.desc: ProcessVirtualPixelRatioChange
154  * @tc.type: FUNC
155  */
HWTEST_F(SceneSessionManagerTest7, ProcessVirtualPixelRatioChange01, Function | SmallTest | Level3)156 HWTEST_F(SceneSessionManagerTest7, ProcessVirtualPixelRatioChange01, Function | SmallTest | Level3)
157 {
158     DisplayId defaultDisplayId = 0;
159     sptr<DisplayInfo> displayInfo = sptr<DisplayInfo>::MakeSptr();
160     std::map<DisplayId, sptr<DisplayInfo>> displayInfoMap;
161     DisplayStateChangeType type = DisplayStateChangeType::BEFORE_SUSPEND;
162     ASSERT_NE(nullptr, displayInfo);
163     ASSERT_NE(nullptr, ssm_);
164     ssm_->processVirtualPixelRatioChangeFunc_ = nullptr;
165     displayInfo->SetVirtualPixelRatio(0.1f);
166     displayInfo->SetDensityInCurResolution(0.1f);
167     ssm_->ProcessVirtualPixelRatioChange(defaultDisplayId, displayInfo, displayInfoMap, type);
168     ProcessVirtualPixelRatioChangeFunc func = [](float ratio, const OHOS::Rosen::Rect& rect) {};
169     ssm_->SetVirtualPixelRatioChangeListener(func);
170     ASSERT_NE(nullptr, ssm_->processVirtualPixelRatioChangeFunc_);
171     ssm_->ProcessVirtualPixelRatioChange(defaultDisplayId, displayInfo, displayInfoMap, type);
172     displayInfo->SetDensityInCurResolution(0.2f);
173     ssm_->ProcessVirtualPixelRatioChange(defaultDisplayId, displayInfo, displayInfoMap, type);
174     ssm_->processVirtualPixelRatioChangeFunc_ = nullptr;
175     ssm_->ProcessVirtualPixelRatioChange(defaultDisplayId, displayInfo, displayInfoMap, type);
176 }
177 
178 /**
179  * @tc.name: ProcessUpdateRotationChange
180  * @tc.desc: ProcessUpdateRotationChange
181  * @tc.type: FUNC
182  */
HWTEST_F(SceneSessionManagerTest7, ProcessUpdateRotationChange, Function | SmallTest | Level3)183 HWTEST_F(SceneSessionManagerTest7, ProcessUpdateRotationChange, Function | SmallTest | Level3)
184 {
185     DisplayId defaultDisplayId = 0;
186     sptr<DisplayInfo> displayInfo = nullptr;
187     std::map<DisplayId, sptr<DisplayInfo>> displayInfoMap;
188     DisplayStateChangeType type = DisplayStateChangeType::BEFORE_SUSPEND;
189     ASSERT_NE(nullptr, ssm_);
190     ssm_->ProcessUpdateRotationChange(defaultDisplayId, displayInfo, displayInfoMap, type);
191     displayInfo = sptr<DisplayInfo>::MakeSptr();
192     ASSERT_NE(nullptr, displayInfo);
193     SessionInfo sessionInfo;
194     sessionInfo.bundleName_ = "SceneSessionManagerTest6";
195     sessionInfo.abilityName_ = "UpdateAvoidArea";
196     sessionInfo.isSystem_ = true;
197     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
198     ASSERT_NE(nullptr, sceneSession);
199     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
200     sceneSession->SetSessionState(SessionState::STATE_FOREGROUND);
201     ssm_->ProcessUpdateRotationChange(defaultDisplayId, displayInfo, displayInfoMap, type);
202     sceneSession->SetSessionState(SessionState::STATE_ACTIVE);
203     ssm_->ProcessUpdateRotationChange(defaultDisplayId, displayInfo, displayInfoMap, type);
204     sceneSession->SetSessionState(SessionState::STATE_INACTIVE);
205     ssm_->ProcessUpdateRotationChange(defaultDisplayId, displayInfo, displayInfoMap, type);
206     WSRectF bounds = { 0, 0, 0, 0 };
207     sceneSession->SetBounds(bounds);
208     displayInfo->width_ = 0;
209     displayInfo->height_ = 0;
210     Rotation rotation = Rotation::ROTATION_0;
211     sceneSession->SetRotation(rotation);
212     displayInfo->SetRotation(rotation);
213     ssm_->ProcessUpdateRotationChange(defaultDisplayId, displayInfo, displayInfoMap, type);
214 }
215 
216 /**
217  * @tc.name: FlushUIParams
218  * @tc.desc: FlushUIParams
219  * @tc.type: FUNC
220  */
HWTEST_F(SceneSessionManagerTest7, FlushUIParams, Function | SmallTest | Level3)221 HWTEST_F(SceneSessionManagerTest7, FlushUIParams, Function | SmallTest | Level3)
222 {
223     SessionInfo sessionInfo;
224     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
225     sessionInfo.abilityName_ = "FlushUIParams";
226     sessionInfo.screenId_ = 1;
227     ScreenId screenId = 2;
228     std::unordered_map<int32_t, SessionUIParam> uiParams;
229     uiParams.clear();
230     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
231     ASSERT_NE(nullptr, sceneSession);
232     ASSERT_NE(nullptr, sceneSession->property_);
233     sceneSession->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
234     ASSERT_NE(nullptr, ssm_);
235     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
236     ssm_->FlushUIParams(screenId, std::move(uiParams));
237     sceneSession->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_END);
238     ssm_->FlushUIParams(screenId, std::move(uiParams));
239 }
240 
241 /**
242  * @tc.name: FlushUIParams01
243  * @tc.desc: FlushUIParams
244  * @tc.type: FUNC
245  */
HWTEST_F(SceneSessionManagerTest7, FlushUIParams01, Function | SmallTest | Level3)246 HWTEST_F(SceneSessionManagerTest7, FlushUIParams01, Function | SmallTest | Level3)
247 {
248     SessionInfo sessionInfo;
249     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
250     sessionInfo.abilityName_ = "FlushUIParams01";
251     sessionInfo.screenId_ = 2;
252     ScreenId screenId = 2;
253     std::unordered_map<int32_t, SessionUIParam> uiParams;
254     uiParams.clear();
255     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
256     ASSERT_NE(nullptr, sceneSession);
257     ASSERT_NE(nullptr, sceneSession->property_);
258     sceneSession->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
259     sceneSession->persistentId_ = 1;
260     ASSERT_NE(nullptr, ssm_);
261     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
262     SessionUIParam sessionUIParam;
263     uiParams.insert(std::make_pair(1, sessionUIParam));
264     ssm_->FlushUIParams(screenId, std::move(uiParams));
265     sessionInfo.screenId_ = -1ULL;
266     ssm_->FlushUIParams(screenId, std::move(uiParams));
267 }
268 
269 /**
270  * @tc.name: RegisterIAbilityManagerCollaborator
271  * @tc.desc: RegisterIAbilityManagerCollaborator
272  * @tc.type: FUNC
273  */
HWTEST_F(SceneSessionManagerTest7, RegisterIAbilityManagerCollaborator, Function | SmallTest | Level3)274 HWTEST_F(SceneSessionManagerTest7, RegisterIAbilityManagerCollaborator, Function | SmallTest | Level3)
275 {
276     int32_t type = 0;
277     sptr<AAFwk::IAbilityManagerCollaborator> impl = nullptr;
278     ASSERT_NE(nullptr, ssm_);
279     auto ret = ssm_->RegisterIAbilityManagerCollaborator(type, impl);
280     EXPECT_EQ(ret, WSError::WS_ERROR_INVALID_PERMISSION);
281 }
282 
283 /**
284  * @tc.name: ProcessBackEvent
285  * @tc.desc: ProcessBackEvent
286  * @tc.type: FUNC
287  */
HWTEST_F(SceneSessionManagerTest7, ProcessBackEvent, Function | SmallTest | Level3)288 HWTEST_F(SceneSessionManagerTest7, ProcessBackEvent, Function | SmallTest | Level3)
289 {
290     SessionInfo sessionInfo;
291     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
292     sessionInfo.abilityName_ = "FlushUIParams01";
293     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
294     ASSERT_NE(nullptr, sceneSession);
295     ASSERT_NE(nullptr, ssm_);
296     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
297     ssm_->focusedSessionId_ = 1;
298     ssm_->needBlockNotifyFocusStatusUntilForeground_ = true;
299     auto ret = ssm_->ProcessBackEvent();
300     EXPECT_EQ(ret, WSError::WS_OK);
301     ssm_->needBlockNotifyFocusStatusUntilForeground_ = false;
302     sessionInfo.isSystem_ = true;
303     ssm_->rootSceneProcessBackEventFunc_ = nullptr;
304     ret = ssm_->ProcessBackEvent();
305     EXPECT_EQ(ret, WSError::WS_OK);
306     RootSceneProcessBackEventFunc func = [](){};
307     ssm_->rootSceneProcessBackEventFunc_ = func;
308     ASSERT_NE(nullptr, ssm_->rootSceneProcessBackEventFunc_);
309     ret = ssm_->ProcessBackEvent();
310     EXPECT_EQ(ret, WSError::WS_OK);
311     sessionInfo.isSystem_ = false;
312     ret = ssm_->ProcessBackEvent();
313     EXPECT_EQ(ret, WSError::WS_OK);
314     ssm_->rootSceneProcessBackEventFunc_ = nullptr;
315     ret = ssm_->ProcessBackEvent();
316     EXPECT_EQ(ret, WSError::WS_OK);
317 }
318 
319 /**
320  * @tc.name: DestroySpecificSession
321  * @tc.desc: DestroySpecificSession
322  * @tc.type: FUNC
323  */
HWTEST_F(SceneSessionManagerTest7, DestroySpecificSession, Function | SmallTest | Level3)324 HWTEST_F(SceneSessionManagerTest7, DestroySpecificSession, Function | SmallTest | Level3)
325 {
326     ASSERT_NE(nullptr, ssm_);
327     ssm_->remoteObjectMap_.clear();
328     sptr<IRemoteObject> remoteObject = sptr<IRemoteObjectMocker>::MakeSptr();
329     ASSERT_NE(nullptr, remoteObject);
330     ssm_->DestroySpecificSession(remoteObject);
331     ssm_->remoteObjectMap_.insert(std::make_pair(remoteObject, 1));
332     SessionInfo sessionInfo;
333     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
334     sessionInfo.abilityName_ = "DestroySpecificSession";
335     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
336     ASSERT_NE(nullptr, sceneSession);
337     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
338     ssm_->DestroySpecificSession(remoteObject);
339     sceneSession = nullptr;
340     ssm_->DestroySpecificSession(remoteObject);
341 }
342 
343 /**
344  * @tc.name: DestroyAndDisconnectSpecificSessionWithDetachCallback
345  * @tc.desc: DestroyAndDisconnectSpecificSessionWithDetachCallback
346  * @tc.type: FUNC
347  */
HWTEST_F(SceneSessionManagerTest7, DestroyAndDisconnectSpecificSessionWithDetachCallback, Function | SmallTest | Level3)348 HWTEST_F(SceneSessionManagerTest7, DestroyAndDisconnectSpecificSessionWithDetachCallback,
349     Function | SmallTest | Level3)
350 {
351     int32_t persistentId = 1;
352     sptr<IRemoteObject> callback = sptr<IRemoteObjectMocker>::MakeSptr();
353     ASSERT_NE(nullptr, callback);
354     SessionInfo sessionInfo;
355     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
356     sessionInfo.abilityName_ = "DestroyAndDisconnectSpecificSessionWithDetachCallback";
357     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
358     ASSERT_NE(nullptr, sceneSession);
359     sceneSession->SetCallingUid(1);
360     ASSERT_NE(nullptr, ssm_);
361     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
362     auto ret = ssm_->DestroyAndDisconnectSpecificSessionWithDetachCallback(persistentId, callback);
363     EXPECT_EQ(ret, WSError::WS_ERROR_INVALID_PERMISSION);
364 }
365 
366 /**
367  * @tc.name: DestroyAndDisconnectSpecificSessionInner
368  * @tc.desc: DestroyAndDisconnectSpecificSessionInner
369  * @tc.type: FUNC
370  */
HWTEST_F(SceneSessionManagerTest7, DestroyAndDisconnectSpecificSessionInner, Function | SmallTest | Level3)371 HWTEST_F(SceneSessionManagerTest7, DestroyAndDisconnectSpecificSessionInner, Function | SmallTest | Level3)
372 {
373     SessionInfo sessionInfo;
374     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
375     sessionInfo.abilityName_ = "DestroyAndDisconnectSpecificSessionInner";
376     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
377     ASSERT_NE(nullptr, sceneSession);
378     ASSERT_NE(nullptr, sceneSession->property_);
379     sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
380     sceneSession->SetParentPersistentId(2);
381     SessionInfo sessionInfo1;
382     sessionInfo1.bundleName_ = "SceneSessionManagerTest7";
383     sessionInfo1.abilityName_ = "ParentSceneSession";
384     sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(sessionInfo1, nullptr);
385     ASSERT_NE(nullptr, sceneSession1);
386     ASSERT_NE(nullptr, ssm_);
387     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
388     ssm_->sceneSessionMap_.insert(std::make_pair(2, sceneSession1));
389     auto ret = ssm_->DestroyAndDisconnectSpecificSessionInner(1);
390     EXPECT_EQ(ret, WSError::WS_OK);
391     sceneSession1 = nullptr;
392     ret = ssm_->DestroyAndDisconnectSpecificSessionInner(2);
393     EXPECT_EQ(ret, WSError::WS_OK);
394 }
395 
396 /**
397  * @tc.name: DestroyAndDisconnectSpecificSessionInner01
398  * @tc.desc: DestroyAndDisconnectSpecificSessionInner
399  * @tc.type: FUNC
400  */
HWTEST_F(SceneSessionManagerTest7, DestroyAndDisconnectSpecificSessionInner01, Function | SmallTest | Level3)401 HWTEST_F(SceneSessionManagerTest7, DestroyAndDisconnectSpecificSessionInner01, Function | SmallTest | Level3)
402 {
403     SessionInfo sessionInfo;
404     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
405     sessionInfo.abilityName_ = "DestroyAndDisconnectSpecificSessionInner";
406     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
407     ASSERT_NE(nullptr, sceneSession);
408     ASSERT_NE(nullptr, sceneSession->property_);
409     sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_TOAST);
410     sceneSession->SetParentPersistentId(2);
411     SessionInfo sessionInfo1;
412     sessionInfo1.bundleName_ = "SceneSessionManagerTest7";
413     sessionInfo1.abilityName_ = "ParentSceneSession";
414     sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(sessionInfo1, nullptr);
415     ASSERT_NE(nullptr, sceneSession1);
416     ASSERT_NE(nullptr, ssm_);
417     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
418     ssm_->sceneSessionMap_.insert(std::make_pair(2, sceneSession1));
419     auto ret = ssm_->DestroyAndDisconnectSpecificSessionInner(1);
420     EXPECT_EQ(ret, WSError::WS_OK);
421     sceneSession1 = nullptr;
422     ret = ssm_->DestroyAndDisconnectSpecificSessionInner(2);
423     EXPECT_EQ(ret, WSError::WS_OK);
424 }
425 
426 /**
427  * @tc.name: DestroyAndDisconnectSpecificSessionInner02
428  * @tc.desc: DestroyAndDisconnectSpecificSessionInner
429  * @tc.type: FUNC
430  */
HWTEST_F(SceneSessionManagerTest7, DestroyAndDisconnectSpecificSessionInner02, Function | SmallTest | Level3)431 HWTEST_F(SceneSessionManagerTest7, DestroyAndDisconnectSpecificSessionInner02, Function | SmallTest | Level3)
432 {
433     SessionInfo sessionInfo;
434     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
435     sessionInfo.abilityName_ = "DestroyAndDisconnectSpecificSessionInner";
436     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
437     ASSERT_NE(nullptr, sceneSession);
438     ASSERT_NE(nullptr, sceneSession->property_);
439     sceneSession->property_->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
440     sceneSession->SetParentPersistentId(2);
441     SessionInfo sessionInfo1;
442     sessionInfo1.bundleName_ = "SceneSessionManagerTest7";
443     sessionInfo1.abilityName_ = "ParentSceneSession";
444     sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(sessionInfo1, nullptr);
445     ASSERT_NE(nullptr, sceneSession1);
446     ASSERT_NE(nullptr, ssm_);
447     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
448     ssm_->sceneSessionMap_.insert(std::make_pair(2, sceneSession1));
449     auto ret = ssm_->DestroyAndDisconnectSpecificSessionInner(1);
450     EXPECT_EQ(ret, WSError::WS_OK);
451     sceneSession1 = nullptr;
452     ret = ssm_->DestroyAndDisconnectSpecificSessionInner(2);
453     EXPECT_EQ(ret, WSError::WS_OK);
454 }
455 
456 /**
457  * @tc.name: CheckPiPPriority
458  * @tc.desc: CheckPiPPriority
459  * @tc.type: FUNC
460  */
HWTEST_F(SceneSessionManagerTest7, CheckPiPPriority, Function | SmallTest | Level3)461 HWTEST_F(SceneSessionManagerTest7, CheckPiPPriority, Function | SmallTest | Level3)
462 {
463     SessionInfo sessionInfo;
464     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
465     sessionInfo.abilityName_ = "CheckPiPPriority";
466     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
467     ASSERT_NE(nullptr, sceneSession);
468     ASSERT_NE(nullptr, sceneSession->property_);
469     sceneSession->property_->SetWindowMode(WindowMode::WINDOW_MODE_PIP);
470     PiPTemplateInfo pipTemplateInfo;
471     pipTemplateInfo.priority = 0;
472     sceneSession->pipTemplateInfo_.priority = 1;
473     sceneSession->isVisible_ = true;
474     sceneSession->state_ = SessionState::STATE_FOREGROUND;
475     ASSERT_NE(nullptr, ssm_);
476     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
477     auto ret = ssm_->CheckPiPPriority(pipTemplateInfo);
478     EXPECT_EQ(ret, false);
479     sceneSession->isVisible_ = false;
480     ret = ssm_->CheckPiPPriority(pipTemplateInfo);
481     EXPECT_EQ(ret, true);
482     pipTemplateInfo.priority = 1;
483     ret = ssm_->CheckPiPPriority(pipTemplateInfo);
484     EXPECT_EQ(ret, true);
485     sceneSession->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
486     ret = ssm_->CheckPiPPriority(pipTemplateInfo);
487     EXPECT_EQ(ret, true);
488     sceneSession = nullptr;
489     ret = ssm_->CheckPiPPriority(pipTemplateInfo);
490     EXPECT_EQ(ret, true);
491 }
492 
493 /**
494  * @tc.name: IsSessionVisibleForeground
495  * @tc.desc: IsSessionVisibleForeground
496  * @tc.type: FUNC
497  */
HWTEST_F(SceneSessionManagerTest7, IsSessionVisibleForeground, Function | SmallTest | Level3)498 HWTEST_F(SceneSessionManagerTest7, IsSessionVisibleForeground, Function | SmallTest | Level3)
499 {
500     sptr<SceneSession> session = nullptr;
501     ASSERT_NE(nullptr, ssm_);
502     auto ret = ssm_->IsSessionVisibleForeground(session);
503     EXPECT_EQ(ret, false);
504     SessionInfo sessionInfo;
505     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
506     sessionInfo.abilityName_ = "IsSessionVisibleForeground";
507     session = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
508     ASSERT_NE(nullptr, session);
509     session->isVisible_ = false;
510     ret = ssm_->IsSessionVisibleForeground(session);
511     EXPECT_EQ(ret, false);
512 }
513 
514 /**
515  * @tc.name: GetAllSessionDumpInfo
516  * @tc.desc: GetAllSessionDumpInfo
517  * @tc.type: FUNC
518  */
HWTEST_F(SceneSessionManagerTest7, GetAllSessionDumpInfo, Function | SmallTest | Level3)519 HWTEST_F(SceneSessionManagerTest7, GetAllSessionDumpInfo, Function | SmallTest | Level3)
520 {
521     SessionInfo sessionInfo;
522     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
523     sessionInfo.abilityName_ = "GetAllSessionDumpInfo";
524     sessionInfo.isSystem_ = false;
525     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
526     ASSERT_NE(nullptr, sceneSession);
527     sceneSession->state_ = SessionState::STATE_DISCONNECT;
528     ASSERT_NE(nullptr, ssm_);
529     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
530     std::string dumpInfo = "";
531     auto ret = ssm_->GetAllSessionDumpInfo(dumpInfo);
532     EXPECT_EQ(ret, WSError::WS_OK);
533     sceneSession->state_ = SessionState::STATE_END;
534     ret = ssm_->GetAllSessionDumpInfo(dumpInfo);
535     EXPECT_EQ(ret, WSError::WS_OK);
536     sceneSession->state_ = SessionState::STATE_ACTIVE;
537     ret = ssm_->GetAllSessionDumpInfo(dumpInfo);
538     EXPECT_EQ(ret, WSError::WS_OK);
539     sessionInfo.isSystem_ = true;
540     ret = ssm_->GetAllSessionDumpInfo(dumpInfo);
541     EXPECT_EQ(ret, WSError::WS_OK);
542     sceneSession = nullptr;
543     ret = ssm_->GetAllSessionDumpInfo(dumpInfo);
544     EXPECT_EQ(ret, WSError::WS_OK);
545 }
546 
547 /**
548  * @tc.name: GetAllSessionDumpInfo01
549  * @tc.desc: GetAllSessionDumpInfo
550  * @tc.type: FUNC
551  */
HWTEST_F(SceneSessionManagerTest7, GetAllSessionDumpInfo01, Function | SmallTest | Level3)552 HWTEST_F(SceneSessionManagerTest7, GetAllSessionDumpInfo01, Function | SmallTest | Level3)
553 {
554     SessionInfo sessionInfo;
555     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
556     sessionInfo.abilityName_ = "GetAllSessionDumpInfo01";
557     sessionInfo.isSystem_ = true;
558     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
559     ASSERT_NE(nullptr, sceneSession);
560     sceneSession->isVisible_ = true;
561     ASSERT_NE(nullptr, ssm_);
562     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
563     std::string dumpInfo = "";
564     auto ret = ssm_->GetAllSessionDumpInfo(dumpInfo);
565     EXPECT_EQ(ret, WSError::WS_OK);
566     sceneSession->isVisible_ = false;
567     ret = ssm_->GetAllSessionDumpInfo(dumpInfo);
568     EXPECT_EQ(ret, WSError::WS_OK);
569 }
570 
571 /**
572  * @tc.name: UpdateNormalSessionAvoidArea
573  * @tc.desc: UpdateNormalSessionAvoidArea
574  * @tc.type: FUNC
575  */
HWTEST_F(SceneSessionManagerTest7, UpdateNormalSessionAvoidArea, Function | SmallTest | Level3)576 HWTEST_F(SceneSessionManagerTest7, UpdateNormalSessionAvoidArea, Function | SmallTest | Level3)
577 {
578     SessionInfo sessionInfo;
579     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
580     sessionInfo.abilityName_ = "UpdateNormalSessionAvoidArea";
581     sessionInfo.isSystem_ = true;
582     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
583     ASSERT_NE(nullptr, sceneSession);
584     sceneSession->isVisible_ = true;
585     sceneSession->state_ = SessionState::STATE_FOREGROUND;
586     int32_t persistentId = 1;
587     bool needUpdate = true;
588     ASSERT_NE(nullptr, ssm_);
589     ssm_->avoidAreaListenerSessionSet_.clear();
590     ssm_->UpdateNormalSessionAvoidArea(persistentId, sceneSession, needUpdate);
591     sceneSession->isVisible_ = false;
592     ssm_->UpdateNormalSessionAvoidArea(persistentId, sceneSession, needUpdate);
593 }
594 
595 /**
596  * @tc.name: UpdateNormalSessionAvoidArea01
597  * @tc.desc: UpdateNormalSessionAvoidArea
598  * @tc.type: FUNC
599  */
HWTEST_F(SceneSessionManagerTest7, UpdateNormalSessionAvoidArea01, Function | SmallTest | Level3)600 HWTEST_F(SceneSessionManagerTest7, UpdateNormalSessionAvoidArea01, Function | SmallTest | Level3)
601 {
602     SessionInfo sessionInfo;
603     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
604     sessionInfo.abilityName_ = "UpdateNormalSessionAvoidArea01";
605     sessionInfo.isSystem_ = true;
606     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
607     ASSERT_NE(nullptr, sceneSession);
608     sceneSession->isVisible_ = true;
609     sceneSession->state_ = SessionState::STATE_FOREGROUND;
610     int32_t persistentId = 1;
611     bool needUpdate = true;
612     ASSERT_NE(nullptr, ssm_);
613     ssm_->avoidAreaListenerSessionSet_.clear();
614     ssm_->avoidAreaListenerSessionSet_.insert(persistentId);
615     ssm_->UpdateNormalSessionAvoidArea(persistentId, sceneSession, needUpdate);
616     sceneSession = nullptr;
617     ssm_->UpdateNormalSessionAvoidArea(persistentId, sceneSession, needUpdate);
618 }
619 
620 /**
621  * @tc.name: UnregisterWindowManagerAgent
622  * @tc.desc: UnregisterWindowManagerAgent
623  * @tc.type: FUNC
624  */
HWTEST_F(SceneSessionManagerTest7, UnregisterWindowManagerAgent, Function | SmallTest | Level3)625 HWTEST_F(SceneSessionManagerTest7, UnregisterWindowManagerAgent, Function | SmallTest | Level3)
626 {
627     WindowManagerAgentType type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_SYSTEM_BAR;
628     sptr<IWindowManagerAgent> windowManagerAgent = nullptr;
629     ASSERT_NE(nullptr, ssm_);
630     auto ret = ssm_->UnregisterWindowManagerAgent(type, windowManagerAgent);
631     EXPECT_EQ(ret, WMError::WM_ERROR_NULLPTR);
632     type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_GESTURE_NAVIGATION_ENABLED;
633     ret = ssm_->UnregisterWindowManagerAgent(type, windowManagerAgent);
634     EXPECT_EQ(ret, WMError::WM_ERROR_NULLPTR);
635     type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WATER_MARK_FLAG;
636     ret = ssm_->UnregisterWindowManagerAgent(type, windowManagerAgent);
637     EXPECT_EQ(ret, WMError::WM_ERROR_NULLPTR);
638     type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WINDOW_VISIBILITY;
639     ret = ssm_->UnregisterWindowManagerAgent(type, windowManagerAgent);
640     EXPECT_EQ(ret, WMError::WM_ERROR_INVALID_PERMISSION);
641     type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WINDOW_DRAWING_STATE;
642     ret = ssm_->UnregisterWindowManagerAgent(type, windowManagerAgent);
643     EXPECT_EQ(ret, WMError::WM_ERROR_INVALID_PERMISSION);
644     type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_VISIBLE_WINDOW_NUM;
645     ret = ssm_->UnregisterWindowManagerAgent(type, windowManagerAgent);
646     EXPECT_EQ(ret, WMError::WM_ERROR_INVALID_PERMISSION);
647     type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_FOCUS;
648     ret = ssm_->UnregisterWindowManagerAgent(type, windowManagerAgent);
649     EXPECT_EQ(ret, WMError::WM_ERROR_INVALID_PERMISSION);
650     type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WINDOW_MODE;
651     ret = ssm_->UnregisterWindowManagerAgent(type, windowManagerAgent);
652     EXPECT_EQ(ret, WMError::WM_ERROR_INVALID_PERMISSION);
653     type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WINDOW_UPDATE;
654     ret = ssm_->UnregisterWindowManagerAgent(type, windowManagerAgent);
655     EXPECT_EQ(ret, WMError::WM_ERROR_NULLPTR);
656 }
657 
658 /**
659  * @tc.name: FindSessionByAffinity
660  * @tc.desc: FindSessionByAffinity
661  * @tc.type: FUNC
662  */
HWTEST_F(SceneSessionManagerTest7, FindSessionByAffinity, Function | SmallTest | Level3)663 HWTEST_F(SceneSessionManagerTest7, FindSessionByAffinity, Function | SmallTest | Level3)
664 {
665     std::string affinity = "";
666     ASSERT_NE(nullptr, ssm_);
667     auto ret = ssm_->FindSessionByAffinity(affinity);
668     EXPECT_EQ(ret, nullptr);
669     affinity = "Test";
670     SessionInfo sessionInfo;
671     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
672     sessionInfo.abilityName_ = "FindSessionByAffinity";
673     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
674     ASSERT_NE(nullptr, sceneSession);
675     sceneSession->SetCollaboratorType(CollaboratorType::DEFAULT_TYPE);
676     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
677     ret = ssm_->FindSessionByAffinity(affinity);
678     EXPECT_EQ(ret, nullptr);
679     sceneSession->SetCollaboratorType(CollaboratorType::OTHERS_TYPE);
680     sceneSession->sessionInfo_.sessionAffinity = "Test";
681     ret = ssm_->FindSessionByAffinity(affinity);
682     EXPECT_EQ(ret, sceneSession);
683 }
684 
685 /**
686  * @tc.name: FindSessionByAffinity01
687  * @tc.desc: FindSessionByAffinity
688  * @tc.type: FUNC
689  */
HWTEST_F(SceneSessionManagerTest7, FindSessionByAffinity01, Function | SmallTest | Level3)690 HWTEST_F(SceneSessionManagerTest7, FindSessionByAffinity01, Function | SmallTest | Level3)
691 {
692     std::string affinity = "Test";
693     sptr<SceneSession> sceneSession = nullptr;
694     ASSERT_NE(nullptr, ssm_);
695     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
696     auto ret = ssm_->FindSessionByAffinity(affinity);
697     EXPECT_EQ(ret, nullptr);
698 }
699 
700 /**
701  * @tc.name: ProcessUpdateRotationChange01
702  * @tc.desc: ProcessUpdateRotationChange
703  * @tc.type: FUNC
704  */
HWTEST_F(SceneSessionManagerTest7, ProcessUpdateRotationChange01, Function | SmallTest | Level3)705 HWTEST_F(SceneSessionManagerTest7, ProcessUpdateRotationChange01, Function | SmallTest | Level3)
706 {
707     DisplayId defaultDisplayId = 0;
708     sptr<DisplayInfo> displayInfo = sptr<DisplayInfo>::MakeSptr();
709     ASSERT_NE(nullptr, displayInfo);
710     std::map<DisplayId, sptr<DisplayInfo>> displayInfoMap;
711     DisplayStateChangeType type = DisplayStateChangeType::BEFORE_SUSPEND;
712     sptr<SceneSession> sceneSession = nullptr;
713     ASSERT_NE(nullptr, ssm_);
714     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
715     ssm_->ProcessUpdateRotationChange(defaultDisplayId, displayInfo, displayInfoMap, type);
716 }
717 
718 /**
719  * @tc.name: ProcessUpdateRotationChange02
720  * @tc.desc: ProcessUpdateRotationChange
721  * @tc.type: FUNC
722  */
HWTEST_F(SceneSessionManagerTest7, ProcessUpdateRotationChange02, Function | SmallTest | Level3)723 HWTEST_F(SceneSessionManagerTest7, ProcessUpdateRotationChange02, Function | SmallTest | Level3)
724 {
725     DisplayId defaultDisplayId = 0;
726     sptr<DisplayInfo> displayInfo = sptr<DisplayInfo>::MakeSptr();
727     ASSERT_NE(nullptr, displayInfo);
728     std::map<DisplayId, sptr<DisplayInfo>> displayInfoMap;
729     DisplayStateChangeType type = DisplayStateChangeType::BEFORE_SUSPEND;
730     SessionInfo sessionInfo;
731     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
732     sessionInfo.abilityName_ = "UpdateAvoidArea";
733     sessionInfo.isSystem_ = true;
734     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
735     ASSERT_NE(nullptr, sceneSession);
736     ASSERT_NE(nullptr, ssm_);
737     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
738     sceneSession->SetSessionState(SessionState::STATE_INACTIVE);
739     WSRectF bounds = { 0, 0, 0, 0 };
740     sceneSession->SetBounds(bounds);
741     displayInfo->width_ = 0;
742     displayInfo->height_ = 0;
743     sceneSession->SetRotation(Rotation::ROTATION_0);
744     displayInfo->SetRotation(Rotation::ROTATION_90);
745     ssm_->ProcessUpdateRotationChange(defaultDisplayId, displayInfo, displayInfoMap, type);
746     displayInfo->height_ = 1;
747     ssm_->ProcessUpdateRotationChange(defaultDisplayId, displayInfo, displayInfoMap, type);
748     displayInfo->width_ = 1;
749     ssm_->ProcessUpdateRotationChange(defaultDisplayId, displayInfo, displayInfoMap, type);
750 }
751 
752 /**
753  * @tc.name: SetSkipSelfWhenShowOnVirtualScreen
754  * @tc.desc: SetSkipSelfWhenShowOnVirtualScreen
755  * @tc.type: FUNC
756  */
HWTEST_F(SceneSessionManagerTest7, SetSkipSelfWhenShowOnVirtualScreen, Function | SmallTest | Level3)757 HWTEST_F(SceneSessionManagerTest7, SetSkipSelfWhenShowOnVirtualScreen, Function | SmallTest | Level3)
758 {
759     uint64_t surfaceNodeId = 0;
760     bool isSkip = true;
761     ASSERT_NE(nullptr, ssm_);
762     ssm_->skipSurfaceNodeIds_.clear();
763     ssm_->SetSkipSelfWhenShowOnVirtualScreen(surfaceNodeId, isSkip);
764     ssm_->skipSurfaceNodeIds_.push_back(surfaceNodeId);
765     ssm_->SetSkipSelfWhenShowOnVirtualScreen(surfaceNodeId, isSkip);
766 }
767 
768 /**
769  * @tc.name: SetSkipSelfWhenShowOnVirtualScreen01
770  * @tc.desc: SetSkipSelfWhenShowOnVirtualScreen
771  * @tc.type: FUNC
772  */
HWTEST_F(SceneSessionManagerTest7, SetSkipSelfWhenShowOnVirtualScreen01, Function | SmallTest | Level3)773 HWTEST_F(SceneSessionManagerTest7, SetSkipSelfWhenShowOnVirtualScreen01, Function | SmallTest | Level3)
774 {
775     uint64_t surfaceNodeId = 0;
776     bool isSkip = false;
777     ASSERT_NE(nullptr, ssm_);
778     ssm_->skipSurfaceNodeIds_.clear();
779     ssm_->SetSkipSelfWhenShowOnVirtualScreen(surfaceNodeId, isSkip);
780     ssm_->skipSurfaceNodeIds_.push_back(surfaceNodeId);
781     ssm_->SetSkipSelfWhenShowOnVirtualScreen(surfaceNodeId, isSkip);
782 }
783 
784 /**
785  * @tc.name: GetMainWindowInfos
786  * @tc.desc: GetMainWindowInfos
787  * @tc.type: FUNC
788  */
HWTEST_F(SceneSessionManagerTest7, GetMainWindowInfos, Function | SmallTest | Level3)789 HWTEST_F(SceneSessionManagerTest7, GetMainWindowInfos, Function | SmallTest | Level3)
790 {
791     int32_t topNum = 1;
792     std::vector<MainWindowInfo> topNInfo;
793     topNInfo.clear();
794     SessionInfo sessionInfo;
795     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
796     sessionInfo.abilityName_ = "GetMainWindowInfos";
797     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
798     ASSERT_NE(nullptr, sceneSession);
799     ASSERT_NE(nullptr, sceneSession->property_);
800     sceneSession->property_->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
801     sceneSession->isVisible_ = true;
802     sceneSession->state_ = SessionState::STATE_FOREGROUND;
803     ASSERT_NE(nullptr, ssm_);
804     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
805     auto ret = ssm_->GetMainWindowInfos(topNum, topNInfo);
806     EXPECT_EQ(ret, WMError::WM_OK);
807     sceneSession->isVisible_ = false;
808     ret = ssm_->GetMainWindowInfos(topNum, topNInfo);
809     EXPECT_EQ(ret, WMError::WM_OK);
810     sceneSession->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_END);
811     ret = ssm_->GetMainWindowInfos(topNum, topNInfo);
812     EXPECT_EQ(ret, WMError::WM_OK);
813     sceneSession->isVisible_ = true;
814     ret = ssm_->GetMainWindowInfos(topNum, topNInfo);
815     EXPECT_EQ(ret, WMError::WM_OK);
816 }
817 
818 /**
819  * @tc.name: WindowLayerInfoChangeCallback
820  * @tc.desc: WindowLayerInfoChangeCallback
821  * @tc.type: FUNC
822  */
HWTEST_F(SceneSessionManagerTest7, WindowLayerInfoChangeCallback, Function | SmallTest | Level3)823 HWTEST_F(SceneSessionManagerTest7, WindowLayerInfoChangeCallback, Function | SmallTest | Level3)
824 {
825     std::shared_ptr<RSOcclusionData> occlusiontionData = nullptr;
826     ASSERT_NE(nullptr, ssm_);
827     ssm_->WindowLayerInfoChangeCallback(occlusiontionData);
828     VisibleData visibleData;
829     visibleData.push_back(std::make_pair(0, WINDOW_LAYER_INFO_TYPE::ALL_VISIBLE));
830     visibleData.push_back(std::make_pair(1, WINDOW_LAYER_INFO_TYPE::SEMI_VISIBLE));
831     visibleData.push_back(std::make_pair(2, WINDOW_LAYER_INFO_TYPE::INVISIBLE));
832     visibleData.push_back(std::make_pair(3, WINDOW_LAYER_INFO_TYPE::WINDOW_LAYER_DYNAMIC_STATUS));
833     visibleData.push_back(std::make_pair(4, WINDOW_LAYER_INFO_TYPE::WINDOW_LAYER_STATIC_STATUS));
834     visibleData.push_back(std::make_pair(5, WINDOW_LAYER_INFO_TYPE::WINDOW_LAYER_UNKNOWN_TYPE));
835     occlusiontionData = std::make_shared<RSOcclusionData>(visibleData);
836     ASSERT_NE(nullptr, occlusiontionData);
837     ssm_->WindowLayerInfoChangeCallback(occlusiontionData);
838 }
839 
840 /**
841  * @tc.name: NotifySessionMovedToFront
842  * @tc.desc: NotifySessionMovedToFront
843  * @tc.type: FUNC
844  */
HWTEST_F(SceneSessionManagerTest7, NotifySessionMovedToFront, Function | SmallTest | Level3)845 HWTEST_F(SceneSessionManagerTest7, NotifySessionMovedToFront, Function | SmallTest | Level3)
846 {
847     int32_t persistentId = 1;
848     SessionInfo sessionInfo;
849     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
850     sessionInfo.abilityName_ = "GetMainWindowInfos";
851     sessionInfo.isSystem_ = false;
852     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
853     ASSERT_NE(nullptr, sceneSession);
854     ASSERT_NE(nullptr, ssm_);
855     sceneSession->sessionInfo_.abilityInfo = std::make_shared<AppExecFwk::AbilityInfo>();
856     ASSERT_NE(nullptr, sceneSession->sessionInfo_.abilityInfo);
857     sceneSession->sessionInfo_.abilityInfo->excludeFromMissions = false;
858     ssm_->sceneSessionMap_.insert(std::make_pair(persistentId, sceneSession));
859     ssm_->NotifySessionMovedToFront(persistentId);
860     sceneSession->sessionInfo_.abilityInfo->excludeFromMissions = true;
861     ssm_->NotifySessionMovedToFront(persistentId);
862     sceneSession->sessionInfo_.abilityInfo = nullptr;
863     ssm_->NotifySessionMovedToFront(persistentId);
864     sceneSession->sessionInfo_.isSystem_ = true;
865     ssm_->NotifySessionMovedToFront(persistentId);
866 }
867 
868 /**
869  * @tc.name: ProcessVirtualPixelRatioChange02
870  * @tc.desc: ProcessVirtualPixelRatioChange
871  * @tc.type: FUNC
872  */
HWTEST_F(SceneSessionManagerTest7, ProcessVirtualPixelRatioChange02, Function | SmallTest | Level3)873 HWTEST_F(SceneSessionManagerTest7, ProcessVirtualPixelRatioChange02, Function | SmallTest | Level3)
874 {
875     DisplayId defaultDisplayId = 0;
876     sptr<DisplayInfo> displayInfo = sptr<DisplayInfo>::MakeSptr();
877     std::map<DisplayId, sptr<DisplayInfo>> displayInfoMap;
878     DisplayStateChangeType type = DisplayStateChangeType::BEFORE_SUSPEND;
879     ASSERT_NE(nullptr, displayInfo);
880     SessionInfo sessionInfo;
881     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
882     sessionInfo.abilityName_ = "ProcessVirtualPixelRatioChange02";
883     sessionInfo.isSystem_ = true;
884     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
885     ASSERT_NE(nullptr, sceneSession);
886     ASSERT_NE(nullptr, ssm_);
887     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
888     sptr<SceneSession> sceneSession1 = nullptr;
889     ssm_->sceneSessionMap_.insert(std::make_pair(2, sceneSession1));
890     ssm_->ProcessVirtualPixelRatioChange(defaultDisplayId, displayInfo, displayInfoMap, type);
891 }
892 
893 /**
894  * @tc.name: ProcessVirtualPixelRatioChange03
895  * @tc.desc: ProcessVirtualPixelRatioChange
896  * @tc.type: FUNC
897  */
HWTEST_F(SceneSessionManagerTest7, ProcessVirtualPixelRatioChange03, Function | SmallTest | Level3)898 HWTEST_F(SceneSessionManagerTest7, ProcessVirtualPixelRatioChange03, Function | SmallTest | Level3)
899 {
900     DisplayId defaultDisplayId = 0;
901     sptr<DisplayInfo> displayInfo = sptr<DisplayInfo>::MakeSptr();
902     std::map<DisplayId, sptr<DisplayInfo>> displayInfoMap;
903     DisplayStateChangeType type = DisplayStateChangeType::BEFORE_SUSPEND;
904     ASSERT_NE(nullptr, displayInfo);
905     SessionInfo sessionInfo;
906     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
907     sessionInfo.abilityName_ = "ProcessVirtualPixelRatioChange03";
908     sessionInfo.isSystem_ = false;
909     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
910     ASSERT_NE(nullptr, sceneSession);
911     sceneSession->SetSessionState(SessionState::STATE_FOREGROUND);
912     ASSERT_NE(nullptr, ssm_);
913     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
914     sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
915     ASSERT_NE(nullptr, sceneSession1);
916     sceneSession1->SetSessionState(SessionState::STATE_ACTIVE);
917     ssm_->sceneSessionMap_.insert(std::make_pair(2, sceneSession1));
918     sptr<SceneSession> sceneSession2 = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
919     ASSERT_NE(nullptr, sceneSession2);
920     sceneSession2->SetSessionState(SessionState::STATE_INACTIVE);
921     ssm_->sceneSessionMap_.insert(std::make_pair(3, sceneSession2));
922     ssm_->ProcessVirtualPixelRatioChange(defaultDisplayId, displayInfo, displayInfoMap, type);
923 }
924 
925 /**
926  * @tc.name: ProcessBackEvent01
927  * @tc.desc: ProcessBackEvent
928  * @tc.type: FUNC
929  */
HWTEST_F(SceneSessionManagerTest7, ProcessBackEvent01, Function | SmallTest | Level3)930 HWTEST_F(SceneSessionManagerTest7, ProcessBackEvent01, Function | SmallTest | Level3)
931 {
932     SessionInfo sessionInfo;
933     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
934     sessionInfo.abilityName_ = "ProcessBackEvent01";
935     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
936     ASSERT_NE(nullptr, sceneSession);
937     ASSERT_NE(nullptr, ssm_);
938     ssm_->focusedSessionId_ = 1;
939     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
940     ssm_->needBlockNotifyFocusStatusUntilForeground_ = true;
941     auto ret = ssm_->ProcessBackEvent();
942     EXPECT_EQ(ret, WSError::WS_OK);
943 }
944 
945 /**
946  * @tc.name: ProcessBackEvent02
947  * @tc.desc: ProcessBackEvent
948  * @tc.type: FUNC
949  */
HWTEST_F(SceneSessionManagerTest7, ProcessBackEvent02, Function | SmallTest | Level3)950 HWTEST_F(SceneSessionManagerTest7, ProcessBackEvent02, Function | SmallTest | Level3)
951 {
952     SessionInfo sessionInfo;
953     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
954     sessionInfo.abilityName_ = "ProcessBackEvent02";
955     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
956     ASSERT_NE(nullptr, sceneSession);
957     sceneSession->sessionInfo_.isSystem_ = true;
958     ASSERT_NE(nullptr, ssm_);
959     ssm_->focusedSessionId_ = 1;
960     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
961     ssm_->needBlockNotifyFocusStatusUntilForeground_ = false;
962     ssm_->rootSceneProcessBackEventFunc_ = nullptr;
963     auto ret = ssm_->ProcessBackEvent();
964     EXPECT_EQ(ret, WSError::WS_OK);
965 }
966 
967 /**
968  * @tc.name: ProcessBackEvent03
969  * @tc.desc: ProcessBackEvent
970  * @tc.type: FUNC
971  */
HWTEST_F(SceneSessionManagerTest7, ProcessBackEvent03, Function | SmallTest | Level3)972 HWTEST_F(SceneSessionManagerTest7, ProcessBackEvent03, Function | SmallTest | Level3)
973 {
974     SessionInfo sessionInfo;
975     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
976     sessionInfo.abilityName_ = "ProcessBackEvent03";
977     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
978     ASSERT_NE(nullptr, sceneSession);
979     sceneSession->sessionInfo_.isSystem_ = true;
980     ASSERT_NE(nullptr, ssm_);
981     ssm_->focusedSessionId_ = 1;
982     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
983     ssm_->needBlockNotifyFocusStatusUntilForeground_ = false;
984     RootSceneProcessBackEventFunc func = [](){};
985     ssm_->rootSceneProcessBackEventFunc_ = func;
986     ASSERT_NE(nullptr, ssm_->rootSceneProcessBackEventFunc_);
987     auto ret = ssm_->ProcessBackEvent();
988     EXPECT_EQ(ret, WSError::WS_OK);
989 }
990 
991 /**
992  * @tc.name: ProcessBackEvent02
993  * @tc.desc: ProcessBackEvent
994  * @tc.type: FUNC
995  */
HWTEST_F(SceneSessionManagerTest7, ProcessBackEvent04, Function | SmallTest | Level3)996 HWTEST_F(SceneSessionManagerTest7, ProcessBackEvent04, Function | SmallTest | Level3)
997 {
998     SessionInfo sessionInfo;
999     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
1000     sessionInfo.abilityName_ = "ProcessBackEvent04";
1001     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1002     ASSERT_NE(nullptr, sceneSession);
1003     sceneSession->sessionInfo_.isSystem_ = false;
1004     ASSERT_NE(nullptr, ssm_);
1005     ssm_->focusedSessionId_ = 1;
1006     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
1007     ssm_->needBlockNotifyFocusStatusUntilForeground_ = false;
1008     ssm_->rootSceneProcessBackEventFunc_ = nullptr;
1009     auto ret = ssm_->ProcessBackEvent();
1010     EXPECT_EQ(ret, WSError::WS_OK);
1011 }
1012 
1013 /**
1014  * @tc.name: ProcessBackEvent05
1015  * @tc.desc: ProcessBackEvent
1016  * @tc.type: FUNC
1017  */
HWTEST_F(SceneSessionManagerTest7, ProcessBackEvent05, Function | SmallTest | Level3)1018 HWTEST_F(SceneSessionManagerTest7, ProcessBackEvent05, Function | SmallTest | Level3)
1019 {
1020     SessionInfo sessionInfo;
1021     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
1022     sessionInfo.abilityName_ = "ProcessBackEvent03";
1023     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1024     ASSERT_NE(nullptr, sceneSession);
1025     sceneSession->sessionInfo_.isSystem_ = false;
1026     ASSERT_NE(nullptr, ssm_);
1027     ssm_->focusedSessionId_ = 1;
1028     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
1029     ssm_->needBlockNotifyFocusStatusUntilForeground_ = false;
1030     RootSceneProcessBackEventFunc func = [](){};
1031     ssm_->rootSceneProcessBackEventFunc_ = func;
1032     ASSERT_NE(nullptr, ssm_->rootSceneProcessBackEventFunc_);
1033     auto ret = ssm_->ProcessBackEvent();
1034     EXPECT_EQ(ret, WSError::WS_OK);
1035 }
1036 
1037 /**
1038  * @tc.name: GetWindowVisibilityChangeInfo
1039  * @tc.desc: GetWindowVisibilityChangeInfo
1040  * @tc.type: FUNC
1041  */
HWTEST_F(SceneSessionManagerTest7, GetWindowVisibilityChangeInfo, Function | SmallTest | Level3)1042 HWTEST_F(SceneSessionManagerTest7, GetWindowVisibilityChangeInfo, Function | SmallTest | Level3)
1043 {
1044     std::vector<std::pair<uint64_t, WindowVisibilityState>> currVisibleData;
1045     std::vector<std::pair<uint64_t, WindowVisibilityState>> visibilitychangeInfos;
1046     currVisibleData.emplace_back(2, WindowVisibilityState::WINDOW_VISIBILITY_STATE_NO_OCCLUSION);
1047     currVisibleData.emplace_back(4, WindowVisibilityState::WINDOW_LAYER_STATE_MAX);
1048     currVisibleData.emplace_back(5, WindowVisibilityState::WINDOW_VISIBILITY_STATE_TOTALLY_OCCUSION);
1049     currVisibleData.emplace_back(7, WindowVisibilityState::WINDOW_LAYER_STATE_MAX);
1050     currVisibleData.emplace_back(9, WindowVisibilityState::WINDOW_VISIBILITY_STATE_TOTALLY_OCCUSION);
1051     ASSERT_NE(nullptr, ssm_);
1052     ssm_->lastVisibleData_.emplace_back(1, WindowVisibilityState::WINDOW_VISIBILITY_STATE_NO_OCCLUSION);
1053     ssm_->lastVisibleData_.emplace_back(4, WindowVisibilityState::WINDOW_VISIBILITY_STATE_PARTICALLY_OCCLUSION);
1054     ssm_->lastVisibleData_.emplace_back(5, WindowVisibilityState::WINDOW_VISIBILITY_STATE_TOTALLY_OCCUSION);
1055     ssm_->lastVisibleData_.emplace_back(6, WindowVisibilityState::WINDOW_LAYER_STATE_MAX);
1056     visibilitychangeInfos = ssm_->GetWindowVisibilityChangeInfo(currVisibleData);
1057     ASSERT_EQ(visibilitychangeInfos.size(), 7);
1058 }
1059 
1060 /**
1061  * @tc.name: UpdateAvoidArea
1062  * @tc.desc: UpdateAvoidArea
1063  * @tc.type: FUNC
1064  */
HWTEST_F(SceneSessionManagerTest7, UpdateAvoidArea, Function | SmallTest | Level3)1065 HWTEST_F(SceneSessionManagerTest7, UpdateAvoidArea, Function | SmallTest | Level3)
1066 {
1067     int32_t persistentId = 0;
1068     ASSERT_NE(nullptr, ssm_);
1069     ssm_->sceneSessionMap_.clear();
1070     ssm_->UpdateAvoidArea(persistentId);
1071 }
1072 
1073 /**
1074  * @tc.name: UpdateAvoidArea01
1075  * @tc.desc: UpdateAvoidArea
1076  * @tc.type: FUNC
1077  */
HWTEST_F(SceneSessionManagerTest7, UpdateAvoidArea01, Function | SmallTest | Level3)1078 HWTEST_F(SceneSessionManagerTest7, UpdateAvoidArea01, Function | SmallTest | Level3)
1079 {
1080     int32_t persistentId = 0;
1081     ASSERT_NE(nullptr, ssm_);
1082     ssm_->sceneSessionMap_.clear();
1083     ssm_->UpdateAvoidArea(persistentId);
1084     SessionInfo sessionInfo;
1085     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
1086     sessionInfo.abilityName_ = "UpdateAvoidArea01";
1087     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1088     ASSERT_NE(nullptr, sceneSession);
1089     ASSERT_NE(nullptr, sceneSession->property_);
1090     sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_STATUS_BAR);
1091     ssm_->sceneSessionMap_.insert(std::make_pair(persistentId, sceneSession));
1092     ssm_->UpdateAvoidArea(persistentId);
1093 }
1094 
1095 /**
1096  * @tc.name: UpdateAvoidArea02
1097  * @tc.desc: UpdateAvoidArea
1098  * @tc.type: FUNC
1099  */
HWTEST_F(SceneSessionManagerTest7, UpdateAvoidArea02, Function | SmallTest | Level3)1100 HWTEST_F(SceneSessionManagerTest7, UpdateAvoidArea02, Function | SmallTest | Level3)
1101 {
1102     int32_t persistentId = 0;
1103     ASSERT_NE(nullptr, ssm_);
1104     ssm_->sceneSessionMap_.clear();
1105     ssm_->UpdateAvoidArea(persistentId);
1106     SessionInfo sessionInfo;
1107     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
1108     sessionInfo.abilityName_ = "UpdateAvoidArea02";
1109     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1110     ASSERT_NE(nullptr, sceneSession);
1111     ASSERT_NE(nullptr, sceneSession->property_);
1112     sceneSession->property_->SetWindowType(WindowType::APP_WINDOW_BASE);
1113     ssm_->sceneSessionMap_.insert(std::make_pair(persistentId, sceneSession));
1114     ssm_->UpdateAvoidArea(persistentId);
1115 }
1116 
1117 /**
1118  * @tc.name: NotifySessionMovedToFront01
1119  * @tc.desc: NotifySessionMovedToFront
1120  * @tc.type: FUNC
1121  */
HWTEST_F(SceneSessionManagerTest7, NotifySessionMovedToFront01, Function | SmallTest | Level3)1122 HWTEST_F(SceneSessionManagerTest7, NotifySessionMovedToFront01, Function | SmallTest | Level3)
1123 {
1124     int32_t persistentId = 1;
1125     SessionInfo sessionInfo;
1126     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
1127     sessionInfo.abilityName_ = "NotifySessionMovedToFront01";
1128     sessionInfo.isSystem_ = false;
1129     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1130     ASSERT_NE(nullptr, sceneSession);
1131     ASSERT_NE(nullptr, ssm_);
1132     sceneSession->sessionInfo_.abilityInfo = std::make_shared<AppExecFwk::AbilityInfo>();
1133     ASSERT_NE(nullptr, sceneSession->sessionInfo_.abilityInfo);
1134     sceneSession->sessionInfo_.abilityInfo->excludeFromMissions = true;
1135     ssm_->sceneSessionMap_.insert(std::make_pair(persistentId, sceneSession));
1136     ssm_->NotifySessionMovedToFront(persistentId);
1137 }
1138 
1139 /**
1140  * @tc.name: NotifySessionMovedToFront02
1141  * @tc.desc: NotifySessionMovedToFront
1142  * @tc.type: FUNC
1143  */
HWTEST_F(SceneSessionManagerTest7, NotifySessionMovedToFront02, Function | SmallTest | Level3)1144 HWTEST_F(SceneSessionManagerTest7, NotifySessionMovedToFront02, Function | SmallTest | Level3)
1145 {
1146     int32_t persistentId = 1;
1147     SessionInfo sessionInfo;
1148     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
1149     sessionInfo.abilityName_ = "NotifySessionMovedToFront02";
1150     sessionInfo.isSystem_ = false;
1151     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1152     ASSERT_NE(nullptr, sceneSession);
1153     ASSERT_NE(nullptr, ssm_);
1154     sceneSession->sessionInfo_.abilityInfo = std::make_shared<AppExecFwk::AbilityInfo>();
1155     ASSERT_NE(nullptr, sceneSession->sessionInfo_.abilityInfo);
1156     sceneSession->sessionInfo_.abilityInfo->excludeFromMissions = false;
1157     ssm_->sceneSessionMap_.insert(std::make_pair(persistentId, sceneSession));
1158     ssm_->NotifySessionMovedToFront(persistentId);
1159 }
1160 
1161 /**
1162  * @tc.name: NotifySessionMovedToFront03
1163  * @tc.desc: NotifySessionMovedToFront
1164  * @tc.type: FUNC
1165  */
HWTEST_F(SceneSessionManagerTest7, NotifySessionMovedToFront03, Function | SmallTest | Level3)1166 HWTEST_F(SceneSessionManagerTest7, NotifySessionMovedToFront03, Function | SmallTest | Level3)
1167 {
1168     int32_t persistentId = 1;
1169     SessionInfo sessionInfo;
1170     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
1171     sessionInfo.abilityName_ = "NotifySessionMovedToFront03";
1172     sessionInfo.isSystem_ = false;
1173     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1174     ASSERT_NE(nullptr, sceneSession);
1175     ASSERT_NE(nullptr, ssm_);
1176     sceneSession->sessionInfo_.abilityInfo = nullptr;
1177     ssm_->NotifySessionMovedToFront(persistentId);
1178 }
1179 
1180 /**
1181  * @tc.name: NotifySessionMovedToFront04
1182  * @tc.desc: NotifySessionMovedToFront
1183  * @tc.type: FUNC
1184  */
HWTEST_F(SceneSessionManagerTest7, NotifySessionMovedToFront04, Function | SmallTest | Level3)1185 HWTEST_F(SceneSessionManagerTest7, NotifySessionMovedToFront04, Function | SmallTest | Level3)
1186 {
1187     int32_t persistentId = 1;
1188     SessionInfo sessionInfo;
1189     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
1190     sessionInfo.abilityName_ = "NotifySessionMovedToFront04";
1191     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1192     ASSERT_NE(nullptr, sceneSession);
1193     ASSERT_NE(nullptr, ssm_);
1194     sceneSession->sessionInfo_.isSystem_ = true;
1195     ssm_->NotifySessionMovedToFront(persistentId);
1196 }
1197 
1198 /**
1199  * @tc.name: NotifySessionMovedToFront05
1200  * @tc.desc: NotifySessionMovedToFront
1201  * @tc.type: FUNC
1202  */
HWTEST_F(SceneSessionManagerTest7, NotifySessionMovedToFront05, Function | SmallTest | Level3)1203 HWTEST_F(SceneSessionManagerTest7, NotifySessionMovedToFront05, Function | SmallTest | Level3)
1204 {
1205     int32_t persistentId = 1;
1206     SessionInfo sessionInfo;
1207     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
1208     sessionInfo.abilityName_ = "NotifySessionMovedToFront05";
1209     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1210     ASSERT_NE(nullptr, sceneSession);
1211     ASSERT_NE(nullptr, ssm_);
1212     ssm_->NotifySessionMovedToFront(persistentId);
1213 }
1214 
1215 /**
1216  * @tc.name: UpdateNormalSessionAvoidArea02
1217  * @tc.desc: UpdateNormalSessionAvoidArea
1218  * @tc.type: FUNC
1219  */
HWTEST_F(SceneSessionManagerTest7, UpdateNormalSessionAvoidArea02, Function | SmallTest | Level3)1220 HWTEST_F(SceneSessionManagerTest7, UpdateNormalSessionAvoidArea02, Function | SmallTest | Level3)
1221 {
1222     SessionInfo sessionInfo;
1223     sessionInfo.bundleName_ = "SceneSessionManagerTest7";
1224     sessionInfo.abilityName_ = "UpdateNormalSessionAvoidArea02";
1225     sessionInfo.isSystem_ = true;
1226     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1227     ASSERT_NE(nullptr, sceneSession);
1228     sceneSession->isVisible_ = true;
1229     sceneSession->state_ = SessionState::STATE_FOREGROUND;
1230     sceneSession->winRect_ = { 1, 1, 1, 1 };
1231     int32_t persistentId = 1;
1232     bool needUpdate = true;
1233     ASSERT_NE(nullptr, ssm_);
1234     ssm_->avoidAreaListenerSessionSet_.clear();
1235     ssm_->avoidAreaListenerSessionSet_.insert(persistentId);
1236     ssm_->UpdateNormalSessionAvoidArea(persistentId, sceneSession, needUpdate);
1237 }
1238 }
1239 } // namespace Rosen
1240 } // namespace OHOS