• 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 "iremote_object_mocker.h"
19 #include "interfaces/include/ws_common.h"
20 #include "mock/mock_session_stage.h"
21 #include "mock/mock_accesstoken_kit.h"
22 #include "session_manager/include/scene_session_manager.h"
23 #include "session_info.h"
24 #include "session/host/include/scene_session.h"
25 #include "session_manager.h"
26 
27 using namespace testing;
28 using namespace testing::ext;
29 
30 namespace OHOS {
31 namespace Rosen {
32 
33 class SceneSessionManagerTest8 : public testing::Test {
34 public:
35     static void SetUpTestCase();
36     static void TearDownTestCase();
37     void SetUp();
38     void TearDown();
39 
40 private:
41     sptr<SceneSessionManager> ssm_;
42     static constexpr uint32_t WAIT_SYNC_IN_NS = 500000;
43     sptr<SceneSession> CreateSceneSession(const std::string& bundleName, WindowType windowType);
44 };
45 
SetUpTestCase()46 void SceneSessionManagerTest8::SetUpTestCase() {}
47 
TearDownTestCase()48 void SceneSessionManagerTest8::TearDownTestCase() {}
49 
SetUp()50 void SceneSessionManagerTest8::SetUp()
51 {
52     ssm_ = &SceneSessionManager::GetInstance();
53     EXPECT_NE(nullptr, ssm_);
54     ssm_->sceneSessionMap_.clear();
55 }
56 
TearDown()57 void SceneSessionManagerTest8::TearDown()
58 {
59     ssm_->sceneSessionMap_.clear();
60     usleep(WAIT_SYNC_IN_NS);
61     ssm_ = nullptr;
62 }
63 
CreateSceneSession(const std::string & bundleName,WindowType windowType)64 sptr<SceneSession> SceneSessionManagerTest8::CreateSceneSession(const std::string& bundleName, WindowType windowType)
65 {
66     SessionInfo sessionInfo;
67     sessionInfo.bundleName_ = bundleName;
68 
69     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
70     property->SetWindowType(windowType);
71     property->SetWindowName(bundleName);
72 
73     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
74     sceneSession->property_ = property;
75     return sceneSession;
76 }
77 
78 namespace {
79 
80 /**
81  * @tc.name: GetRemoteSessionSnapshotInfo
82  * @tc.desc: GetRemoteSessionSnapshotInfo set gesture navigation enabled
83  * @tc.type: FUNC
84  */
85 HWTEST_F(SceneSessionManagerTest8, GetRemoteSessionSnapshotInfo, TestSize.Level1)
86 {
87     AAFwk::MissionSnapshot sessionSnapshot;
88     std::string deviceId = "";
89     int res = ssm_->GetRemoteSessionSnapshotInfo(deviceId, 8, sessionSnapshot);
90     EXPECT_EQ(ERR_NULL_OBJECT, res);
91 }
92 
93 /**
94  * @tc.name: WindowLayerInfoChangeCallback
95  * @tc.desc: test function : WindowLayerInfoChangeCallback
96  * @tc.type: FUNC
97  */
98 HWTEST_F(SceneSessionManagerTest8, WindowLayerInfoChangeCallback, TestSize.Level1)
99 {
100     std::shared_ptr<RSOcclusionData> rsData = nullptr;
101     ssm_->WindowLayerInfoChangeCallback(rsData);
102 
103     rsData = std::make_shared<RSOcclusionData>();
104     ASSERT_NE(nullptr, rsData);
105     ssm_->WindowLayerInfoChangeCallback(rsData);
106 
107     VisibleData visibleData;
108     visibleData.push_back(std::make_pair(0, WINDOW_LAYER_INFO_TYPE::ALL_VISIBLE));
109     visibleData.push_back(std::make_pair(1, WINDOW_LAYER_INFO_TYPE::SEMI_VISIBLE));
110     visibleData.push_back(std::make_pair(2, WINDOW_LAYER_INFO_TYPE::INVISIBLE));
111     visibleData.push_back(std::make_pair(3, WINDOW_LAYER_INFO_TYPE::WINDOW_LAYER_DYNAMIC_STATUS));
112     visibleData.push_back(std::make_pair(4, WINDOW_LAYER_INFO_TYPE::WINDOW_LAYER_STATIC_STATUS));
113     visibleData.push_back(std::make_pair(5, WINDOW_LAYER_INFO_TYPE::WINDOW_LAYER_UNKNOWN_TYPE));
114     rsData = std::make_shared<RSOcclusionData>(visibleData);
115     ASSERT_NE(nullptr, rsData);
116     ssm_->WindowLayerInfoChangeCallback(rsData);
117 }
118 
119 /**
120  * @tc.name: PostProcessFocus
121  * @tc.desc: test function : PostProcessFocus
122  * @tc.type: FUNC
123  */
124 HWTEST_F(SceneSessionManagerTest8, PostProcessFocus, TestSize.Level1)
125 {
126     ssm_->sceneSessionMap_.emplace(0, nullptr);
127     ssm_->PostProcessFocus();
128     ssm_->sceneSessionMap_.clear();
129 
130     SessionInfo sessionInfo;
131     sessionInfo.bundleName_ = "PostProcessFocus";
132     sessionInfo.abilityName_ = "PostProcessFocus";
133     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
134     ASSERT_NE(nullptr, sceneSession);
135     PostProcessFocusState state;
136     EXPECT_EQ(false, state.enabled_);
137     sceneSession->SetPostProcessFocusState(state);
138     ssm_->sceneSessionMap_.emplace(0, sceneSession);
139     ssm_->PostProcessFocus();
140 
141     state.enabled_ = true;
142     state.isFocused_ = false;
143     sceneSession->SetPostProcessFocusState(state);
144     ssm_->PostProcessFocus();
145 
146     state.isFocused_ = true;
147     state.reason_ = FocusChangeReason::SCB_START_APP;
148     sceneSession->SetPostProcessFocusState(state);
149     ssm_->PostProcessFocus();
150 
151     sceneSession->SetPostProcessFocusState(state);
152     state.reason_ = FocusChangeReason::DEFAULT;
153     ssm_->PostProcessFocus();
154 }
155 
156 /**
157  * @tc.name: PostProcessFocus01
158  * @tc.desc: test function : PostProcessFocus with focusableOnShow
159  * @tc.type: FUNC
160  */
161 HWTEST_F(SceneSessionManagerTest8, PostProcessFocus01, TestSize.Level1)
162 {
163     ssm_->sceneSessionMap_.clear();
164     auto focusGroup = ssm_->windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID);
165     focusGroup->SetFocusedSessionId(0);
166 
167     SessionInfo sessionInfo;
168     sessionInfo.bundleName_ = "PostProcessFocus01";
169     sessionInfo.abilityName_ = "PostProcessFocus01";
170     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
171     sceneSession->persistentId_ = 1;
172     sceneSession->state_ = SessionState::STATE_FOREGROUND;
173     sceneSession->isVisible_ = true;
174 
175     PostProcessFocusState state = { true, true, true, FocusChangeReason::FOREGROUND };
176     sceneSession->SetPostProcessFocusState(state);
177     sceneSession->SetFocusableOnShow(false);
178     ssm_->sceneSessionMap_.emplace(1, sceneSession);
179     ssm_->PostProcessFocus();
180 
181     EXPECT_NE(1, focusGroup->GetFocusedSessionId());
182 }
183 
184 /**
185  * @tc.name: PostProcessFocus03
186  * @tc.desc: test function : PostProcessFocus
187  * @tc.type: FUNC
188  */
189 HWTEST_F(SceneSessionManagerTest8, PostProcessFocus03, TestSize.Level1)
190 {
191     ssm_->sceneSessionMap_.clear();
192 
193     SessionInfo sessionInfo;
194     sessionInfo.bundleName_ = "PostProcessFocus03";
195     sessionInfo.abilityName_ = "PostProcessFocus03";
196     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
197     sceneSession->persistentId_ = 1;
198 
199     sceneSession->SetFocusedOnShow(false);
200     PostProcessFocusState state = { true, true, true, FocusChangeReason::FOREGROUND };
201     sceneSession->SetPostProcessFocusState(state);
202     ssm_->sceneSessionMap_.emplace(1, sceneSession);
203     ssm_->PostProcessFocus();
204     EXPECT_EQ(sceneSession->IsFocusedOnShow(), false);
205 
206     sceneSession->state_ = SessionState::STATE_FOREGROUND;
207     sceneSession->isVisible_ = true;
208     state = { true, true, true, FocusChangeReason::FOREGROUND };
209     sceneSession->SetPostProcessFocusState(state);
210     ssm_->sceneSessionMap_.emplace(1, sceneSession);
211     ssm_->PostProcessFocus();
212     EXPECT_EQ(sceneSession->IsFocusedOnShow(), true);
213 }
214 
215 /**
216  * @tc.name: PostProcessProperty
217  * @tc.desc: test function : PostProcessProperty
218  * @tc.type: FUNC
219  */
220 HWTEST_F(SceneSessionManagerTest8, PostProcessProperty, TestSize.Level1)
221 {
222     ssm_->sceneSessionMap_.emplace(0, nullptr);
223     ssm_->PostProcessProperty(static_cast<uint32_t>(SessionUIDirtyFlag::AVOID_AREA));
224     ssm_->PostProcessProperty(~static_cast<uint32_t>(SessionUIDirtyFlag::AVOID_AREA));
225     ssm_->sceneSessionMap_.clear();
226 
227     SessionInfo sessionInfo;
228     sessionInfo.bundleName_ = "PostProcessProperty";
229     sessionInfo.abilityName_ = "PostProcessProperty";
230     sessionInfo.windowType_ = static_cast<uint32_t>(WindowType::WINDOW_TYPE_DIALOG);
231     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
232     ASSERT_NE(nullptr, sceneSession);
233     PostProcessFocusState state;
234     EXPECT_EQ(false, state.enabled_);
235     sceneSession->SetPostProcessFocusState(state);
236     ssm_->sceneSessionMap_.emplace(0, sceneSession);
237     ssm_->PostProcessFocus();
238 
239     state.enabled_ = true;
240     sceneSession->SetPostProcessFocusState(state);
241     ssm_->PostProcessFocus();
242 
243     sessionInfo.windowType_ = static_cast<uint32_t>(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
244     ssm_->PostProcessFocus();
245 }
246 
247 /**
248  * @tc.name: NotifyUpdateRectAfterLayout
249  * @tc.desc: test function : NotifyUpdateRectAfterLayout
250  * @tc.type: FUNC
251  */
252 HWTEST_F(SceneSessionManagerTest8, NotifyUpdateRectAfterLayout, TestSize.Level1)
253 {
254     ssm_->sceneSessionMap_.emplace(0, nullptr);
255     ssm_->NotifyUpdateRectAfterLayout();
256     ssm_->sceneSessionMap_.clear();
257 
258     SessionInfo sessionInfo;
259     sessionInfo.bundleName_ = "NotifyUpdateRectAfterLayout";
260     sessionInfo.abilityName_ = "NotifyUpdateRectAfterLayout";
261     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
262     ASSERT_NE(nullptr, sceneSession);
263     ssm_->sceneSessionMap_.emplace(0, sceneSession);
264     ssm_->NotifyUpdateRectAfterLayout();
265     constexpr uint32_t NOT_WAIT_SYNC_IN_NS = 500000;
266     usleep(NOT_WAIT_SYNC_IN_NS);
267 }
268 
269 /**
270  * @tc.name: DestroyExtensionSession
271  * @tc.desc: test function : DestroyExtensionSession
272  * @tc.type: FUNC
273  */
274 HWTEST_F(SceneSessionManagerTest8, DestroyExtensionSession, TestSize.Level1)
275 {
276     ssm_->remoteExtSessionMap_.clear();
277     sptr<IRemoteObject> iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr();
278     sptr<IRemoteObject> token = sptr<IRemoteObjectMocker>::MakeSptr();
279     EXPECT_NE(nullptr, iRemoteObjectMocker);
280     ssm_->DestroyExtensionSession(iRemoteObjectMocker);
281     ssm_->remoteExtSessionMap_.emplace(iRemoteObjectMocker, token);
282 
283     ssm_->extSessionInfoMap_.clear();
284     ssm_->DestroyExtensionSession(iRemoteObjectMocker);
285 
286     ExtensionWindowAbilityInfo extensionWindowAbilituInfo;
287     ssm_->extSessionInfoMap_.emplace(token, extensionWindowAbilituInfo);
288 
289     ssm_->sceneSessionMap_.emplace(0, nullptr);
290     ssm_->DestroyExtensionSession(iRemoteObjectMocker);
291     ssm_->sceneSessionMap_.clear();
292 
293     SessionInfo sessionInfo;
294     sessionInfo.bundleName_ = "DestroyExtensionSession";
295     sessionInfo.abilityName_ = "DestroyExtensionSession";
296     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
297     ASSERT_NE(nullptr, sceneSession);
298     ssm_->sceneSessionMap_.emplace(0, sceneSession);
299 
300     ExtensionWindowFlags extensionWindowFlags;
301     sceneSession->combinedExtWindowFlags_ = extensionWindowFlags;
302     ssm_->DestroyExtensionSession(iRemoteObjectMocker);
303 
304     extensionWindowFlags.waterMarkFlag = false;
305     extensionWindowFlags.privacyModeFlag = false;
306     sceneSession->combinedExtWindowFlags_ = extensionWindowFlags;
307     EXPECT_EQ(false, sceneSession->combinedExtWindowFlags_.privacyModeFlag);
308     int len = sceneSession->modalUIExtensionInfoList_.size();
309     ssm_->DestroyExtensionSession(iRemoteObjectMocker, true);
310     constexpr uint32_t DES_WAIT_SYNC_IN_NS = 500000;
311     usleep(DES_WAIT_SYNC_IN_NS);
312     EXPECT_EQ(len, sceneSession->modalUIExtensionInfoList_.size());
313     ssm_->DestroyExtensionSession(iRemoteObjectMocker, false);
314     usleep(DES_WAIT_SYNC_IN_NS);
315     EXPECT_EQ(len, sceneSession->modalUIExtensionInfoList_.size());
316 }
317 
318 /**
319  * @tc.name: FilterSceneSessionCovered
320  * @tc.desc: test function : FilterSceneSessionCovered
321  * @tc.type: FUNC
322  */
323 HWTEST_F(SceneSessionManagerTest8, FilterSceneSessionCovered, TestSize.Level1)
324 {
325     std::vector<sptr<SceneSession>> sceneSessionList;
326     sptr<SceneSession> sceneSession = nullptr;
327     sceneSessionList.emplace_back(sceneSession);
328     EXPECT_EQ(1, sceneSessionList.size());
329     ssm_->FilterSceneSessionCovered(sceneSessionList);
330 
331     SessionInfo sessionInfo;
332     sceneSessionList.clear();
333     sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
334     EXPECT_NE(nullptr, sceneSession);
335     sceneSessionList.emplace_back(sceneSession);
336     ssm_->FilterSceneSessionCovered(sceneSessionList);
337 }
338 
339 /**
340  * @tc.name: SubtractIntersectArea
341  * @tc.desc: test function : SubtractIntersectArea
342  * @tc.type: FUNC
343  */
344 HWTEST_F(SceneSessionManagerTest8, SubtractIntersectArea, TestSize.Level1)
345 {
346     SkIRect rect{ .fLeft = 0, .fTop = 0, .fRight = 2880, .fBottom = 1920 };
347     auto unaccountedSpace = std::make_shared<SkRegion>(rect);
348     EXPECT_NE(unaccountedSpace, nullptr);
349 
350     sptr<SceneSession> sceneSession = nullptr;
351     EXPECT_EQ(ssm_->SubtractIntersectArea(unaccountedSpace, sceneSession), false);
352 
353     SessionInfo sessionInfo;
354     sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
355     EXPECT_NE(sceneSession, nullptr);
356     WSRect wsRect{ .posX_ = 0, .posY_ = 0, .width_ = 100, .height_ = 100 };
357     sceneSession->GetLayoutController()->SetSessionRect(wsRect);
358     EXPECT_EQ(ssm_->SubtractIntersectArea(unaccountedSpace, sceneSession), true);
359 
360     SessionInfo sessionInfo2;
361     sptr<SceneSession> sceneSession2 = sptr<SceneSession>::MakeSptr(sessionInfo2, nullptr);
362     ASSERT_NE(sceneSession2, nullptr);
363     WSRect wsRect2 { .posX_ = 100, .posY_ = 150, .width_ = 100, .height_ = 100 };
364     sceneSession2->GetLayoutController()->SetSessionRect(wsRect2);
365     std::vector<Rect> hotAreas;
366     hotAreas.push_back(Rect::EMPTY_RECT);
367     hotAreas.push_back({.posX_ = 0, .posY_ = 0, .width_ = 10, .height_ = 10});
368     sceneSession2->GetSessionProperty()->SetTouchHotAreas(hotAreas);
369     EXPECT_EQ(ssm_->SubtractIntersectArea(unaccountedSpace, sceneSession2), true);
370 }
371 
372 /**
373  * @tc.name: UpdateSubWindowVisibility
374  * @tc.desc: test function : UpdateSubWindowVisibility
375  * @tc.type: FUNC
376  */
377 HWTEST_F(SceneSessionManagerTest8, UpdateSubWindowVisibility, TestSize.Level1)
378 {
379     SessionInfo sessionInfo;
380     sessionInfo.bundleName_ = "UpdateSubWindowVisibility";
381     sessionInfo.abilityName_ = "UpdateSubWindowVisibility";
382     sessionInfo.windowType_ = static_cast<uint32_t>(WindowType::APP_SUB_WINDOW_BASE);
383     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
384     EXPECT_NE(nullptr, sceneSession);
385     WindowVisibilityState visibleState = WindowVisibilityState::WINDOW_VISIBILITY_STATE_NO_OCCLUSION;
386     std::vector<std::pair<uint64_t, WindowVisibilityState>> visibilityChangeInfo;
387     std::vector<sptr<WindowVisibilityInfo>> windowVisibilityInfos;
388     std::string visibilityInfo = "";
389     std::vector<std::pair<uint64_t, WindowVisibilityState>> currVisibleData;
390     sceneSession->persistentId_ = 1998;
391     sceneSession->SetCallingUid(1998);
392     SessionState state = SessionState::STATE_CONNECT;
393     sceneSession->SetSessionState(state);
394     sceneSession->SetParentSession(sceneSession);
395     EXPECT_EQ(1998, sceneSession->GetParentSession()->GetWindowId());
396     ssm_->sceneSessionMap_.emplace(0, sceneSession);
397 
398     sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
399     EXPECT_NE(nullptr, sceneSession1);
400     sceneSession1->persistentId_ = 1998;
401     sceneSession1->SetCallingUid(1024);
402     SessionState state1 = SessionState::STATE_CONNECT;
403     sceneSession1->SetSessionState(state1);
404     sceneSession1->SetParentSession(sceneSession1);
405     EXPECT_EQ(1998, sceneSession1->GetParentSession()->GetWindowId());
406     ssm_->sceneSessionMap_.emplace(0, sceneSession1);
407 
408     sptr<SceneSession> sceneSession2 = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
409     EXPECT_NE(nullptr, sceneSession2);
410     sceneSession2->persistentId_ = 1998;
411     sceneSession2->SetCallingUid(1998);
412     SessionState state2 = SessionState::STATE_FOREGROUND;
413     sceneSession2->SetSessionState(state2);
414     sceneSession2->SetParentSession(sceneSession2);
415     EXPECT_EQ(1998, sceneSession2->GetParentSession()->GetWindowId());
416     ssm_->sceneSessionMap_.emplace(0, sceneSession2);
417     ssm_->UpdateSubWindowVisibility(
418         sceneSession, visibleState, visibilityChangeInfo, windowVisibilityInfos, visibilityInfo, currVisibleData);
419 }
420 
421 /**
422  * @tc.name: RegisterSessionChangeByActionNotifyManagerFunc
423  * @tc.desc: test function : RegisterSessionChangeByActionNotifyManagerFunc
424  * @tc.type: FUNC
425  */
426 HWTEST_F(SceneSessionManagerTest8, RegisterSessionChangeByActionNotifyManagerFunc, TestSize.Level1)
427 {
428     sptr<SceneSession> sceneSession = nullptr;
429     ssm_->RegisterSessionChangeByActionNotifyManagerFunc(sceneSession);
430     SessionInfo sessionInfo;
431     sessionInfo.bundleName_ = "RegisterSessionChangeByActionNotifyManagerFunc";
432     sessionInfo.abilityName_ = "RegisterSessionChangeByActionNotifyManagerFunc";
433     sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
434     EXPECT_NE(nullptr, sceneSession);
435     ssm_->RegisterSessionChangeByActionNotifyManagerFunc(sceneSession);
436     EXPECT_NE(nullptr, sceneSession->sessionChangeByActionNotifyManagerFunc_);
437 
438     sptr<WindowSessionProperty> property = nullptr;
439     sceneSession->NotifySessionChangeByActionNotifyManager(property,
440                                                            WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON);
441 
442     property = sptr<WindowSessionProperty>::MakeSptr();
443     EXPECT_NE(nullptr, property);
444 
445     sceneSession->NotifySessionChangeByActionNotifyManager(property,
446                                                            WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON);
447 }
448 
449 /**
450  * @tc.name: RegisterSessionChangeByActionNotifyManagerFunc1
451  * @tc.desc: test function : RegisterSessionChangeByActionNotifyManagerFunc1
452  * @tc.type: FUNC
453  */
454 HWTEST_F(SceneSessionManagerTest8, RegisterSessionChangeByActionNotifyManagerFunc1, TestSize.Level1)
455 {
456     SessionInfo sessionInfo;
457     sessionInfo.bundleName_ = "RegisterSessionChangeByActionNotifyManagerFunc1";
458     sessionInfo.abilityName_ = "RegisterSessionChangeByActionNotifyManagerFunc1";
459     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
460     EXPECT_NE(nullptr, sceneSession);
461 
462     ssm_->RegisterSessionChangeByActionNotifyManagerFunc(sceneSession);
463     EXPECT_NE(nullptr, sceneSession->sessionChangeByActionNotifyManagerFunc_);
464 
465     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
466     EXPECT_NE(nullptr, property);
467 
468     sceneSession->NotifySessionChangeByActionNotifyManager(property,
469                                                            WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON);
470 
471     sceneSession->NotifySessionChangeByActionNotifyManager(
472         property, WSPropertyChangeAction::ACTION_UPDATE_NAVIGATION_INDICATOR_PROPS);
473 
474     sceneSession->NotifySessionChangeByActionNotifyManager(property,
475                                                            WSPropertyChangeAction::ACTION_UPDATE_SET_BRIGHTNESS);
476 
477     sceneSession->NotifySessionChangeByActionNotifyManager(property,
478                                                            WSPropertyChangeAction::ACTION_UPDATE_SYSTEM_PRIVACY_MODE);
479 
480     sceneSession->NotifySessionChangeByActionNotifyManager(property, WSPropertyChangeAction::ACTION_UPDATE_FLAGS);
481 
482     sceneSession->NotifySessionChangeByActionNotifyManager(property, WSPropertyChangeAction::ACTION_UPDATE_MODE);
483 
484     sceneSession->NotifySessionChangeByActionNotifyManager(
485         property, WSPropertyChangeAction::ACTION_UPDATE_HIDE_NON_SYSTEM_FLOATING_WINDOWS);
486 
487     sceneSession->NotifySessionChangeByActionNotifyManager(property, WSPropertyChangeAction::ACTION_UPDATE_WINDOW_MASK);
488 
489     sceneSession->NotifySessionChangeByActionNotifyManager(property, WSPropertyChangeAction::ACTION_UPDATE_TOPMOST);
490 }
491 
492 /**
493  * @tc.name: RegisterRequestFocusStatusNotifyManagerFunc
494  * @tc.desc: test function : RegisterRequestFocusStatusNotifyManagerFunc
495  * @tc.type: FUNC
496  */
497 HWTEST_F(SceneSessionManagerTest8, RegisterRequestFocusStatusNotifyManagerFunc, TestSize.Level1)
498 {
499     sptr<SceneSession> sceneSession = nullptr;
500     ssm_->RegisterRequestFocusStatusNotifyManagerFunc(sceneSession);
501     EXPECT_EQ(nullptr, sceneSession);
502 }
503 
504 /**
505  * @tc.name: HandleTurnScreenOn
506  * @tc.desc: test function : HandleTurnScreenOn
507  * @tc.type: FUNC
508  */
509 HWTEST_F(SceneSessionManagerTest8, HandleTurnScreenOn, TestSize.Level1)
510 {
511     sptr<SceneSession> sceneSession = nullptr;
512     ssm_->HandleTurnScreenOn(sceneSession);
513     SessionInfo sessionInfo;
514     sessionInfo.bundleName_ = "HandleTurnScreenOn";
515     sessionInfo.abilityName_ = "HandleTurnScreenOn";
516     sessionInfo.windowType_ = static_cast<uint32_t>(WindowType::APP_SUB_WINDOW_BASE);
517     sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
518     EXPECT_NE(nullptr, sceneSession);
519     sceneSession->GetSessionProperty()->SetTurnScreenOn(false);
520     ssm_->HandleTurnScreenOn(sceneSession);
521     EXPECT_EQ(false, sceneSession->GetSessionProperty()->IsTurnScreenOn());
522     sceneSession->GetSessionProperty()->SetTurnScreenOn(true);
523     ssm_->HandleTurnScreenOn(sceneSession);
524     constexpr uint32_t NOT_WAIT_SYNC_IN_NS = 500000;
525     usleep(NOT_WAIT_SYNC_IN_NS);
526 }
527 
528 /**
529  * @tc.name: HandleKeepScreenOn
530  * @tc.desc: test function : HandleKeepScreenOn
531  * @tc.type: FUNC
532  */
533 HWTEST_F(SceneSessionManagerTest8, HandleKeepScreenOn, TestSize.Level1)
534 {
535     SessionInfo sessionInfo;
536     sessionInfo.bundleName_ = "HandleTurnScreenOn";
537     sessionInfo.abilityName_ = "HandleTurnScreenOn";
538     sessionInfo.windowType_ = static_cast<uint32_t>(WindowType::APP_SUB_WINDOW_BASE);
539     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
540     EXPECT_NE(nullptr, sceneSession);
541 
542     std::string lockName = "windowLock";
543     ssm_->HandleKeepScreenOn(sceneSession, false, lockName, sceneSession->keepScreenLock_);
544     sceneSession->keepScreenLock_ = nullptr;
545     ssm_->HandleKeepScreenOn(sceneSession, true, lockName, sceneSession->keepScreenLock_);
546     bool enable = true;
547     EXPECT_EQ(WSError::WS_OK, ssm_->GetFreeMultiWindowEnableState(enable));
548 }
549 
550 /**
551  * @tc.name: SetBrightness
552  * @tc.desc: test function : SetBrightness
553  * @tc.type: FUNC
554  */
555 HWTEST_F(SceneSessionManagerTest8, SetBrightness, TestSize.Level1)
556 {
557     SessionInfo sessionInfo;
558     sessionInfo.bundleName_ = "SetBrightness";
559     sessionInfo.abilityName_ = "SetBrightness";
560     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
561     EXPECT_NE(nullptr, sceneSession);
562     sceneSession->persistentId_ = 2024;
563 
564     ssm_->SetDisplayBrightness(3.14f);
565     std::shared_ptr<AppExecFwk::EventHandler> pipeEventHandler = nullptr;
566     ssm_->eventHandler_ = pipeEventHandler;
567     ASSERT_EQ(nullptr, ssm_->eventHandler_);
568     auto ret = ssm_->SetBrightness(sceneSession, 3.15f);
569     EXPECT_EQ(WSError::WS_OK, ret);
570 
571     ssm_->Init();
572     ASSERT_NE(nullptr, ssm_->eventHandler_);
573 
574     ssm_->SetFocusedSessionId(2024, DEFAULT_DISPLAY_ID);
575     EXPECT_EQ(2024, ssm_->GetFocusedSessionId());
576 
577     ret = ssm_->SetBrightness(sceneSession, 3.15f);
578     EXPECT_EQ(WSError::WS_OK, ret);
579     EXPECT_EQ(3.15f, ssm_->GetDisplayBrightness());
580 
581     ret = ssm_->SetBrightness(sceneSession, UNDEFINED_BRIGHTNESS);
582     EXPECT_EQ(WSError::WS_OK, ret);
583     EXPECT_EQ(UNDEFINED_BRIGHTNESS, ssm_->GetDisplayBrightness());
584 }
585 
586 /**
587  * @tc.name: TerminateSessionNew
588  * @tc.desc: test function : TerminateSessionNew
589  * @tc.type: FUNC
590  */
591 HWTEST_F(SceneSessionManagerTest8, TerminateSessionNew, TestSize.Level1)
592 {
593     sptr<AAFwk::SessionInfo> sessionInfo = sptr<AAFwk::SessionInfo>::MakeSptr();
594     EXPECT_NE(nullptr, sessionInfo);
595     sptr<IRemoteObject> iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr();
596     EXPECT_NE(nullptr, iRemoteObjectMocker);
597     sessionInfo->sessionToken = iRemoteObjectMocker;
598 
599     SessionInfo info;
600     info.bundleName_ = "TerminateSessionNew";
601     info.abilityName_ = "TerminateSessionNew";
602     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
603     EXPECT_NE(nullptr, sceneSession);
604     sceneSession->SetAbilityToken(iRemoteObjectMocker);
605     ssm_->sceneSessionMap_.emplace(0, sceneSession);
606     ssm_->TerminateSessionNew(sessionInfo, true, true);
607 }
608 
609 /**
610  * @tc.name: IsLastFrameLayoutFinished
611  * @tc.desc: test function : IsLastFrameLayoutFinished
612  * @tc.type: FUNC
613  */
614 HWTEST_F(SceneSessionManagerTest8, IsLastFrameLayoutFinished, TestSize.Level1)
615 {
616     ssm_->closeTargetFloatWindowFunc_ = nullptr;
617     std::string bundleName = "SetCloseTargetFloatWindowFunc";
__anonfcd9147e0202(const std::string& bundleName1) 618     ProcessCloseTargetFloatWindowFunc func = [](const std::string& bundleName1) { return; };
619     ssm_->SetCloseTargetFloatWindowFunc(func);
620 
__anonfcd9147e0302() 621     IsRootSceneLastFrameLayoutFinishedFunc func1 = []() { return true; };
622     ssm_->isRootSceneLastFrameLayoutFinishedFunc_ = func1;
623     ASSERT_NE(ssm_->isRootSceneLastFrameLayoutFinishedFunc_, nullptr);
624     bool isLayoutFinished = false;
625     auto ret = ssm_->IsLastFrameLayoutFinished(isLayoutFinished);
626     EXPECT_EQ(true, isLayoutFinished);
627     EXPECT_EQ(WSError::WS_OK, ret);
628 }
629 
630 /**
631  * @tc.name: ReportScreenFoldStatus
632  * @tc.desc: test function : ReportScreenFoldStatus
633  * @tc.type: FUNC
634  */
635 HWTEST_F(SceneSessionManagerTest8, ReportScreenFoldStatus, TestSize.Level1)
636 {
637     sptr<SceneSession> sceneSession = nullptr;
638     ssm_->sceneSessionMap_.insert(std::make_pair(0, sceneSession));
639     SessionInfo info;
640     info.bundleName_ = "ReportScreenFoldStatus";
641     info.abilityName_ = "ReportScreenFoldStatus";
642     sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(info, nullptr);
643     ASSERT_NE(sceneSession1, nullptr);
644     sceneSession1->SetSessionState(SessionState::STATE_FOREGROUND);
645     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession1));
646     SessionInfo info1;
647     info1.bundleName_ = "ReportScreenFoldStatus1";
648     info1.abilityName_ = "ReportScreenFoldStatus1";
649     sptr<SceneSession> sceneSession2 = sptr<SceneSession>::MakeSptr(info1, nullptr);
650     ASSERT_NE(sceneSession2, nullptr);
651     sceneSession2->SetSessionState(SessionState::STATE_ACTIVE);
652     ssm_->sceneSessionMap_.insert(std::make_pair(2, sceneSession2));
653     SessionInfo info2;
654     info2.bundleName_ = "ReportScreenFoldStatus2";
655     info2.abilityName_ = "ReportScreenFoldStatus2";
656     sptr<SceneSession> sceneSession3 = sptr<SceneSession>::MakeSptr(info2, nullptr);
657     ASSERT_NE(sceneSession3, nullptr);
658     sceneSession3->SetSessionState(SessionState::STATE_BACKGROUND);
659     ssm_->sceneSessionMap_.insert(std::make_pair(3, sceneSession3));
660     ssm_->OnScreenshot(1);
661     constexpr uint32_t NOT_WAIT_SYNC_IN_NS = 500000;
662     usleep(NOT_WAIT_SYNC_IN_NS);
663 
664     ScreenFoldData data;
665     data.currentScreenFoldStatus_ = ScreenFoldData::INVALID_VALUE;
666     auto ret = ssm_->ReportScreenFoldStatus(data);
667     EXPECT_EQ(WMError::WM_DO_NOTHING, ret);
668 }
669 
670 /**
671  * @tc.name: GetWindowModeType
672  * @tc.desc: test function : GetWindowModeType
673  * @tc.type: FUNC
674  */
675 
676 HWTEST_F(SceneSessionManagerTest8, GetWindowModeType, TestSize.Level1)
677 {
678     MockAccesstokenKit::MockIsSACalling(false);
679     SessionInfo info;
680     info.bundleName_ = "GetWindowModeType";
681     info.abilityName_ = "GetWindowModeType";
682     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
683     ASSERT_NE(sceneSession, nullptr);
684     ssm_->NotifySessionBackground(sceneSession, 1, true, true);
685     WindowModeType windowModeType = WindowModeType::WINDOW_MODE_SPLIT_FLOATING;
686     auto ret = ssm_->GetWindowModeType(windowModeType);
687     EXPECT_EQ(WMError::WM_ERROR_INVALID_PERMISSION, ret);
688 }
689 
690 /**
691  * @tc.name: GetHostWindowRect
692  * @tc.desc: test function : GetHostWindowRect
693  * @tc.type: FUNC
694  */
695 HWTEST_F(SceneSessionManagerTest8, GetHostWindowRect, TestSize.Level1)
696 {
697     sptr<IDisplayChangeListener> listener = sptr<DisplayChangeListener>::MakeSptr();
698     ASSERT_NE(nullptr, listener);
699     DisplayId displayId = 1;
700     listener->OnScreenshot(displayId);
701     constexpr uint32_t NOT_WAIT_SYNC_IN_NS = 500000;
702     usleep(NOT_WAIT_SYNC_IN_NS);
703 
704     int32_t hostWindowId = 0;
705     Rect rect = { 0, 0, 0, 0 };
706     SessionInfo info;
707     info.bundleName_ = "GetHostWindowRect";
708     info.abilityName_ = "GetHostWindowRect";
709     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
710     ASSERT_NE(sceneSession, nullptr);
711     sceneSession->sessionInfo_.screenId_ = 0;
712     EXPECT_EQ(sceneSession->GetScreenId(), 0);
713     ssm_->sceneSessionMap_.insert(std::make_pair(hostWindowId, sceneSession));
714     PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus(
715         0, SuperFoldStatus::EXPANDED, { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1624, 2472, 1648 });
716     auto ret = ssm_->GetHostWindowRect(hostWindowId, rect);
717     EXPECT_EQ(WSError::WS_OK, ret);
718     EXPECT_EQ(rect.posY_, 0);
719     PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus(
720         0, SuperFoldStatus::KEYBOARD, { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1624, 2472, 1648 });
721     sceneSession->GetLayoutController()->SetSessionRect({ 0, 100, 0, 0 });
722     ret = ssm_->GetHostWindowRect(hostWindowId, rect);
723     EXPECT_EQ(WSError::WS_OK, ret);
724     EXPECT_EQ(rect.posY_, 100);
725 
726     PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus(
727         0, SuperFoldStatus::HALF_FOLDED, { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1649, 2472, 40 });
728     sceneSession->GetLayoutController()->SetSessionRect({ 0, 1000, 100, 100 });
729     ret = ssm_->GetHostWindowRect(hostWindowId, rect);
730     EXPECT_EQ(WSError::WS_OK, ret);
731     EXPECT_EQ(rect.posY_, 1000);
732     sceneSession->GetLayoutController()->SetSessionRect({ 0, 2000, 100, 100 });
733     ret = ssm_->GetHostWindowRect(hostWindowId, rect);
734     WSRect hostRect = { 0, 2000, 100, 100 };
735     sceneSession->TransformGlobalRectToRelativeRect(hostRect);
736     EXPECT_EQ(WSError::WS_OK, ret);
737     EXPECT_EQ(rect.posY_, hostRect.posY_);
738 
739     sceneSession->GetSessionProperty()->SetIsSystemKeyboard(false);
740     PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus(
741         0, SuperFoldStatus::UNKNOWN, { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1624, 2472, 1648 });
742     sceneSession->GetLayoutController()->SetSessionRect({ 0, 0, 0, 0 });
743     ret = ssm_->GetHostWindowRect(hostWindowId, rect);
744     EXPECT_EQ(WSError::WS_OK, ret);
745     EXPECT_EQ(rect.posY_, 0);
746     PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus(
747         0, SuperFoldStatus::FOLDED, { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1624, 2472, 1648 });
748     sceneSession->GetLayoutController()->SetSessionRect({ 0, 100, 0, 0 });
749     ret = ssm_->GetHostWindowRect(hostWindowId, rect);
750     EXPECT_EQ(WSError::WS_OK, ret);
751     EXPECT_EQ(rect.posY_, 100);
752 
753     sceneSession->GetSessionProperty()->SetIsSystemKeyboard(true);
754     PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus(
755         0, SuperFoldStatus::HALF_FOLDED, { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1649, 2472, 40 });
756     sceneSession->GetLayoutController()->SetSessionRect({ 0, 1000, 100, 100 });
757     ret = ssm_->GetHostWindowRect(hostWindowId, rect);
758     EXPECT_EQ(WSError::WS_OK, ret);
759     EXPECT_EQ(rect.posY_, 1000);
760 }
761 
762 /**
763  * @tc.name: GetHostGlobalScaledRect
764  * @tc.desc: test function : GetHostGlobalScaledRect
765  * @tc.type: FUNC
766  */
767 HWTEST_F(SceneSessionManagerTest8, GetHostGlobalScaledRect, TestSize.Level1)
768 {
769     sptr<IDisplayChangeListener> listener = sptr<DisplayChangeListener>::MakeSptr();
770     ASSERT_NE(nullptr, listener);
771     DisplayId displayId = 1;
772     listener->OnScreenshot(displayId);
773     constexpr uint32_t NOT_WAIT_SYNC_IN_NS = 500000;
774     usleep(NOT_WAIT_SYNC_IN_NS);
775 
776     int32_t hostWindowId = 0;
777     Rect rect = { 0, 0, 0, 0 };
778     SessionInfo info;
779     info.bundleName_ = "GetHostGlobalScaledRect";
780     info.abilityName_ = "GetHostGlobalScaledRect";
781     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
782     ASSERT_NE(sceneSession, nullptr);
783     sceneSession->sessionInfo_.screenId_ = 0;
784     EXPECT_EQ(sceneSession->GetScreenId(), 0);
785     ssm_->sceneSessionMap_.insert(std::make_pair(hostWindowId, sceneSession));
786     auto ret = ssm_->GetHostGlobalScaledRect(hostWindowId, rect);
787     EXPECT_EQ(WSError::WS_OK, ret);
788 }
789 
790 /**
791  * @tc.name: NotifyStackEmpty
792  * @tc.desc: test function : NotifyStackEmpty
793  * @tc.type: FUNC
794  */
795 HWTEST_F(SceneSessionManagerTest8, NotifyStackEmpty, TestSize.Level1)
796 {
797     SessionInfo info;
798     info.bundleName_ = "NotifyStackEmpty";
799     info.abilityName_ = "NotifyStackEmpty";
800     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
801     ASSERT_NE(sceneSession, nullptr);
802     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
803     auto ret = ssm_->NotifyStackEmpty(0);
804     EXPECT_EQ(ret, WSError::WS_OK);
805     constexpr uint32_t NOT_WAIT_SYNC_IN_NS = 500000;
806     usleep(NOT_WAIT_SYNC_IN_NS);
807     ret = ssm_->NotifyStackEmpty(1);
808     EXPECT_EQ(WSError::WS_OK, ret);
809     usleep(NOT_WAIT_SYNC_IN_NS);
810 }
811 
812 /**
813  * @tc.name: GetAppMainSceneSession
814  * @tc.desc: test function : GetAppMainSceneSession
815  * @tc.type: FUNC
816  */
817 HWTEST_F(SceneSessionManagerTest8, GetAppMainSceneSession, TestSize.Level1)
818 {
819     ssm_->isUserBackground_ = true;
820     ssm_->FlushWindowInfoToMMI(true);
821 
822     SessionInfo info;
823     info.bundleName_ = "GetAppMainSceneSession";
824     info.abilityName_ = "GetAppMainSceneSession";
825     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
826     ASSERT_NE(sceneSession, nullptr);
827     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
828     ASSERT_NE(property, nullptr);
829     property->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
830     property->SetParentPersistentId(2);
831     sceneSession->property_ = property;
832     ssm_->sceneSessionMap_.clear();
833     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
834     auto ret = ssm_->GetAppMainSceneSession(1, sceneSession);
835     EXPECT_EQ(WSError::WS_ERROR_INVALID_SESSION, ret);
836 }
837 
838 /**
839  * @tc.name: PostProcessProperty01
840  * @tc.desc: test function : PostProcessProperty
841  * @tc.type: FUNC
842  */
843 HWTEST_F(SceneSessionManagerTest8, PostProcessProperty01, TestSize.Level1)
844 {
845     SessionInfo info;
846     info.bundleName_ = "PostProcessProperty";
847     info.abilityName_ = "PostProcessProperty";
848     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
849     ASSERT_NE(sceneSession, nullptr);
850     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
851     ASSERT_NE(property, nullptr);
852     property->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
853     sceneSession->property_ = property;
854     sceneSession->postProcessProperty_ = true;
855     ssm_->sceneSessionMap_.clear();
856     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
857     uint32_t dirty = static_cast<uint32_t>(SessionUIDirtyFlag::AVOID_AREA);
858     ssm_->PostProcessProperty(dirty);
859 
860     dirty = static_cast<uint32_t>(SessionUIDirtyFlag::VISIBLE);
861     ssm_->PostProcessProperty(dirty);
862 
863     property->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
864     ssm_->PostProcessProperty(dirty);
865     EXPECT_EQ(false, sceneSession->postProcessProperty_);
866 }
867 
868 /**
869  * @tc.name: SetVmaCacheStatus
870  * @tc.desc: test function : SetVmaCacheStatus
871  * @tc.type: FUNC
872  */
873 HWTEST_F(SceneSessionManagerTest8, SetVmaCacheStatus, TestSize.Level1)
874 {
875     AppExecFwk::AbilityInfo abilityInfo;
876     ssm_->ProcessPreload(abilityInfo);
877 
878     auto ret = ssm_->SetVmaCacheStatus(true);
879     EXPECT_EQ(WSError::WS_OK, ret);
880 }
881 
882 /**
883  * @tc.name: IsInDefaultScreen
884  * @tc.desc: test function : IsInDefaultScreen
885  * @tc.type: FUNC
886  */
887 HWTEST_F(SceneSessionManagerTest8, IsInDefaultScreen, TestSize.Level1)
888 {
889     sptr<SceneSession> sceneSession = nullptr;
890     ssm_->ProcessFocusWhenForegroundScbCore(sceneSession);
891 
892     SessionInfo info;
893     info.bundleName_ = "IsInDefaultScreen";
894     info.abilityName_ = "IsInDefaultScreen";
895     sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
896     ASSERT_NE(sceneSession, nullptr);
897     auto ret = ssm_->IsInDefaultScreen(sceneSession);
898     EXPECT_EQ(false, ret);
899 }
900 
901 /**
902  * @tc.name: OnSessionStateChange
903  * @tc.desc: test function : OnSessionStateChange
904  * @tc.type: FUNC
905  */
906 HWTEST_F(SceneSessionManagerTest8, OnSessionStateChange, TestSize.Level1)
907 {
908     SessionInfo info;
909     info.bundleName_ = "OnSessionStateChange";
910     info.abilityName_ = "OnSessionStateChange";
911     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
912     ASSERT_NE(sceneSession, nullptr);
913     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
914     ASSERT_NE(property, nullptr);
915     property->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
916     sceneSession->property_ = property;
917     SessionState state = SessionState::STATE_DISCONNECT;
918     ssm_->sceneSessionMap_.clear();
919     ssm_->sceneSessionMap_.insert(std::make_pair(100, sceneSession));
920     ssm_->OnSessionStateChange(100, state);
921     property->SetWindowType(WindowType::APP_MAIN_WINDOW_END);
922     ssm_->OnSessionStateChange(100, state);
923 
924     ssm_->isRootSceneLastFrameLayoutFinishedFunc_ = nullptr;
925     bool isLayoutFinished = false;
926     auto ret = ssm_->IsLastFrameLayoutFinished(isLayoutFinished);
927     EXPECT_EQ(WSError::WS_ERROR_NULLPTR, ret);
928 }
929 
930 /**
931  * @tc.name: OnSessionStateChange01
932  * @tc.desc: test function : OnSessionStateChange
933  * @tc.type: FUNC
934  */
935 HWTEST_F(SceneSessionManagerTest8, OnSessionStateChange01, TestSize.Level1)
936 {
937     SessionInfo info;
938     info.bundleName_ = "OnSessionStateChange01";
939     info.abilityName_ = "OnSessionStateChange01";
940     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
941     ASSERT_NE(sceneSession, nullptr);
942     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
943     ASSERT_NE(property, nullptr);
944     property->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
945     sceneSession->property_ = property;
946     sceneSession->isScbCoreEnabled_ = true;
947     sceneSession->isVisible_ = true;
948     sceneSession->state_ = SessionState::STATE_FOREGROUND;
949     SessionState state = SessionState::STATE_FOREGROUND;
950     ssm_->sceneSessionMap_.clear();
951     ssm_->sceneSessionMap_.insert(std::make_pair(100, sceneSession));
952     ssm_->OnSessionStateChange(100, state);
953 
954     property->SetWindowType(WindowType::APP_MAIN_WINDOW_END);
955     ssm_->OnSessionStateChange(100, state);
956     auto ret = ssm_->UpdateMaximizeMode(1, true);
957     EXPECT_EQ(WSError::WS_OK, ret);
958     constexpr uint32_t NOT_WAIT_SYNC_IN_NS = 500000;
959     usleep(NOT_WAIT_SYNC_IN_NS);
960 }
961 
962 /**
963  * @tc.name: UnregisterSpecificSessionCreateListener
964  * @tc.desc: test function : UnregisterSpecificSessionCreateListener
965  * @tc.type: FUNC
966  */
967 HWTEST_F(SceneSessionManagerTest8, UnregisterSpecificSessionCreateListener, TestSize.Level1)
968 {
969     sptr<SceneSession> sceneSession = nullptr;
970     ssm_->DestroyUIServiceExtensionSubWindow(sceneSession);
971     ssm_->RegisterSessionInfoChangeNotifyManagerFunc(sceneSession);
972 
973     SessionInfo info;
974     info.bundleName_ = "UnregisterSpecificSessionCreateListener";
975     info.abilityName_ = "UnregisterSpecificSessionCreateListener";
976     sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
977     ASSERT_NE(sceneSession, nullptr);
978     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
979     ASSERT_NE(property, nullptr);
980     ssm_->HandleHideNonSystemFloatingWindows(property, sceneSession);
981 
982     NotifyCreateKeyboardSessionFunc func = [](const sptr<SceneSession>& keyboardSession,
__anonfcd9147e0402(const sptr<SceneSession>& keyboardSession, const sptr<SceneSession>& panelSession) 983                                               const sptr<SceneSession>& panelSession) {};
984     ssm_->SetCreateKeyboardSessionListener(func);
985 
__anonfcd9147e0502(int32_t x, int32_t y) 986     ProcessOutsideDownEventFunc func1 = [](int32_t x, int32_t y) {};
987     ssm_->outsideDownEventFunc_ = func1;
988     ssm_->OnOutsideDownEvent(0, 0);
989 
990     ssm_->createSubSessionFuncMap_.clear();
991     ssm_->bindDialogTargetFuncMap_.clear();
__anonfcd9147e0602(const sptr<SceneSession>& sceneSession) 992     NotifyBindDialogSessionFunc func2 = [](const sptr<SceneSession>& sceneSession) {};
993     ssm_->bindDialogTargetFuncMap_.insert(std::make_pair(1, func2));
994     ssm_->UnregisterSpecificSessionCreateListener(1);
995     EXPECT_EQ(true, ssm_->bindDialogTargetFuncMap_.empty());
996 }
997 
998 /**
999  * @tc.name: GetIsLayoutFullScreen
1000  * @tc.desc: test function : GetIsLayoutFullScreen
1001  * @tc.type: FUNC
1002  */
1003 HWTEST_F(SceneSessionManagerTest8, GetIsLayoutFullScreen, TestSize.Level1)
1004 {
1005     std::ostringstream oss;
1006     SessionInfo info;
1007     info.bundleName_ = "GetIsLayoutFullScreen";
1008     info.abilityName_ = "GetIsLayoutFullScreen";
1009     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1010     ASSERT_NE(sceneSession, nullptr);
1011     ssm_->DumpSessionInfo(sceneSession, oss);
1012 
1013     ssm_->listenerController_ = std::make_shared<SessionListenerController>();
1014     ASSERT_NE(ssm_->listenerController_, nullptr);
1015     info.isSystem_ = true;
1016     ssm_->NotifyUnFocusedByMission(sceneSession);
1017     info.isSystem_ = false;
1018     ssm_->NotifyUnFocusedByMission(sceneSession);
1019 
1020     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1021     ASSERT_NE(property, nullptr);
1022     property->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
1023     property->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
1024     property->SetIsLayoutFullScreen(true);
1025     sceneSession->property_ = property;
1026     sceneSession->state_ = SessionState::STATE_FOREGROUND;
1027     bool isLayoutFullScreen = true;
1028     auto ret = ssm_->GetIsLayoutFullScreen(isLayoutFullScreen);
1029     EXPECT_EQ(WSError::WS_OK, ret);
1030     property->SetIsLayoutFullScreen(false);
1031     ret = ssm_->GetIsLayoutFullScreen(isLayoutFullScreen);
1032     EXPECT_EQ(WSError::WS_OK, ret);
1033 }
1034 
1035 /**
1036  * @tc.name: RegisterWindowPropertyChangeAgent01
1037  * @tc.desc: test function : RegisterWindowPropertyChangeAgent
1038  * @tc.type: FUNC
1039  */
1040 HWTEST_F(SceneSessionManagerTest8, RegisterWindowPropertyChangeAgent01, TestSize.Level1)
1041 {
1042     MockAccesstokenKit::MockIsSACalling(false);
1043     uint32_t interestInfo = 0;
1044     interestInfo |= static_cast<uint32_t>(WindowInfoKey::WINDOW_ID);
1045     sptr<IWindowManagerAgent> windowManagerAgent = nullptr;
1046     auto ret = ssm_->RegisterWindowPropertyChangeAgent(WindowInfoKey::DISPLAY_ID, interestInfo, windowManagerAgent);
1047     EXPECT_EQ(static_cast<uint32_t>(WindowInfoKey::DISPLAY_ID), ssm_->observedFlags_);
1048     EXPECT_EQ(static_cast<uint32_t>(WindowInfoKey::WINDOW_ID), ssm_->interestedFlags_);
1049     EXPECT_EQ(WMError::WM_ERROR_INVALID_PERMISSION, ret);
1050     ssm_->observedFlags_ = 0;
1051     ssm_->interestedFlags_ = 0;
1052 }
1053 
1054 /**
1055  * @tc.name: UnregisterWindowPropertyChangeAgent01
1056  * @tc.desc: test function : UnregisterWindowPropertyChangeAgent
1057  * @tc.type: FUNC
1058  */
1059 HWTEST_F(SceneSessionManagerTest8, UnregisterWindowPropertyChangeAgent01, TestSize.Level1)
1060 {
1061     MockAccesstokenKit::MockIsSACalling(false);
1062     uint32_t interestInfo = 0;
1063     interestInfo |= static_cast<uint32_t>(WindowInfoKey::WINDOW_ID);
1064     sptr<IWindowManagerAgent> windowManagerAgent = nullptr;
1065     auto ret = ssm_->RegisterWindowPropertyChangeAgent(WindowInfoKey::DISPLAY_ID, interestInfo, windowManagerAgent);
1066     ret = ssm_->UnregisterWindowPropertyChangeAgent(WindowInfoKey::DISPLAY_ID, interestInfo, windowManagerAgent);
1067     EXPECT_EQ(0, ssm_->observedFlags_);
1068     EXPECT_EQ(0, ssm_->interestedFlags_);
1069     EXPECT_EQ(WMError::WM_ERROR_INVALID_PERMISSION, ret);
1070     ssm_->observedFlags_ = 0;
1071     ssm_->interestedFlags_ = 0;
1072 }
1073 
1074 /**
1075  * @tc.name: PackWindowPropertyChangeInfo01
1076  * @tc.desc: test function : PackWindowPropertyChangeInfo
1077  * @tc.type: FUNC
1078  */
1079 HWTEST_F(SceneSessionManagerTest8, PackWindowPropertyChangeInfo01, TestSize.Level1)
1080 {
1081     ssm_->interestedFlags_ = -1;
1082     SessionInfo sessionInfo1;
1083     sessionInfo1.isSystem_ = false;
1084     sessionInfo1.bundleName_ = "PackWindowPropertyChangeInfo";
1085     sessionInfo1.abilityName_ = "PackWindowPropertyChangeInfo";
1086     sessionInfo1.appIndex_ = 10;
1087     sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(sessionInfo1, nullptr);
1088     sceneSession1->SetVisibilityState(WINDOW_VISIBILITY_STATE_TOTALLY_OCCUSION);
1089     WSRect rect = { 0, 0, 100, 100 };
1090     sceneSession1->SetSessionRect(rect);
1091     sceneSession1->SetSessionGlobalRect(rect);
1092     sceneSession1->SetSessionState(SessionState::STATE_FOREGROUND);
1093     sceneSession1->GetSessionProperty()->SetDisplayId(0);
1094     sceneSession1->GetSessionProperty()->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
1095     sceneSession1->SetFloatingScale(1.0f);
1096 
1097     std::unordered_map<WindowInfoKey, WindowChangeInfoType> windowPropertyChangeInfo;
1098     ssm_->PackWindowPropertyChangeInfo(sceneSession1, windowPropertyChangeInfo);
1099     EXPECT_EQ(windowPropertyChangeInfo.size(), 9);
1100 }
1101 
1102 /**
1103  * @tc.name: TestCheckSystemWindowPermission_Fb
1104  * @tc.desc: Test CheckSystemWindowPermission with windowType WINDOW_TYPE_FB then true
1105  * @tc.type: FUNC
1106  */
1107 HWTEST_F(SceneSessionManagerTest8, TestCheckSystemWindowPermission_Fb, TestSize.Level1)
1108 {
1109     ASSERT_NE(nullptr, ssm_);
1110     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1111 
1112     property->SetWindowType(WindowType::WINDOW_TYPE_FB);
1113     ASSERT_EQ(true, ssm_->CheckSystemWindowPermission(property));
1114 }
1115 
1116 /**
1117  * @tc.name: InitFbWindow
1118  * @tc.desc: test function : InitFbWindow
1119  * @tc.type: FUNC
1120  */
1121 HWTEST_F(SceneSessionManagerTest8, InitFbWindow, TestSize.Level1)
1122 {
1123     ASSERT_NE(nullptr, ssm_);
1124     SessionInfo sessionInfo;
1125     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1126     ASSERT_NE(nullptr, sceneSession);
1127 
1128     ssm_->InitFbWindow(sceneSession, nullptr);
1129 
1130     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1131     ASSERT_NE(nullptr, property);
1132     property->SetWindowType(WindowType::WINDOW_TYPE_PIP);
1133     ssm_->InitFbWindow(sceneSession, property);
1134 
1135     property->SetWindowType(WindowType::WINDOW_TYPE_FB);
1136     ssm_->InitFbWindow(sceneSession, property);
1137     EXPECT_EQ(0, sceneSession->GetFbTemplateInfo().template_);
1138 }
1139 
1140 /**
1141 @tc.name: GetFbPanelWindowId
1142 @tc.desc: test function : GetFbPanelWindowId
1143 @tc.type: FUNC
1144 */
1145 HWTEST_F(SceneSessionManagerTest8, GetFbPanelWindowId, TestSize.Level1)
1146 {
1147     ASSERT_NE(nullptr, ssm_);
1148     uint32_t windowId = 0;
1149     EXPECT_EQ(WMError::WM_ERROR_FB_INTERNAL_ERROR, ssm_->GetFbPanelWindowId(windowId));
1150     ssm_->sceneSessionMap_.insert({0, nullptr});
1151     ssm_->sceneSessionMap_.insert({1, CreateSceneSession("", WindowType::WINDOW_TYPE_PIP)});
1152     ssm_->sceneSessionMap_.insert({2, CreateSceneSession("SCBGlobalSearch7", WindowType::WINDOW_TYPE_FB)});
1153     sptr<SceneSession> sceneSession = CreateSceneSession("Fb_panel8", WindowType::WINDOW_TYPE_FB);
1154     ssm_->sceneSessionMap_.insert({3, sceneSession});
1155 
1156     MockAccesstokenKit::MockAccessTokenKitRet(0);
1157     EXPECT_EQ(WMError::WM_OK, ssm_->GetFbPanelWindowId(windowId));
1158     EXPECT_EQ(sceneSession->GetWindowId(), windowId);
1159     MockAccesstokenKit::MockAccessTokenKitRet(-1);
1160 }
1161 
1162 /**
1163  * @tc.name: SetScreenPrivacyWindowTagSwitch01
1164  * @tc.desc: test function : SetScreenPrivacyWindowTagSwitch
1165  * @tc.type: FUNC
1166  */
1167 HWTEST_F(SceneSessionManagerTest8, SetScreenPrivacyWindowTagSwitch01, TestSize.Level1)
1168 {
1169     ASSERT_NE(nullptr, ssm_);
1170     MockAccesstokenKit::MockIsSACalling(false);
1171     uint64_t screenId = 0;
1172     std::vector<std::string> privacyWindowTags;
1173     bool enable = false;
1174     auto ret = ssm_->SetScreenPrivacyWindowTagSwitch(screenId, privacyWindowTags, enable);
1175     EXPECT_EQ(WMError::WM_ERROR_INVALID_PERMISSION, ret);
1176 
1177     MockAccesstokenKit::MockIsSACalling(true);
1178     ret = ssm_->SetScreenPrivacyWindowTagSwitch(screenId, privacyWindowTags, enable);
1179     EXPECT_EQ(WMError::WM_OK, ret);
1180 
1181     enable = true;
1182     ret = ssm_->SetScreenPrivacyWindowTagSwitch(screenId, privacyWindowTags, enable);
1183     EXPECT_EQ(WMError::WM_OK, ret);
1184 }
1185 
1186 /**
1187  * @tc.name: AddSessionBlackList01
1188  * @tc.desc: test function : AddSessionBlackList
1189  * @tc.type: FUNC
1190  */
1191 HWTEST_F(SceneSessionManagerTest8, AddSessionBlackList01, TestSize.Level1)
1192 {
1193     ASSERT_NE(nullptr, ssm_);
1194     ssm_->sceneSessionMap_.clear();
1195     MockAccesstokenKit::MockIsSACalling(false);
1196     std::unordered_set<std::string> bundleNames = { "test" };
1197     std::unordered_set<std::string> privacyWindowTags;
1198     auto ret = ssm_->AddSessionBlackList(bundleNames, privacyWindowTags);
1199     EXPECT_EQ(WMError::WM_ERROR_INVALID_PERMISSION, ret);
1200 
1201     MockAccesstokenKit::MockIsSACalling(true);
1202     ret = ssm_->AddSessionBlackList(bundleNames, privacyWindowTags);
1203     EXPECT_EQ(WMError::WM_OK, ret);
1204 
1205     SessionInfo sessionInfo1;
1206     sessionInfo1.bundleName_ = "test";
1207     sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(sessionInfo1, nullptr);
1208     ssm_->sceneSessionMap_.insert({1, sceneSession1});
1209     ret = ssm_->AddSessionBlackList(bundleNames, privacyWindowTags);
1210     EXPECT_EQ(WMError::WM_OK, ret);
1211 
1212     ssm_->sceneSessionMap_.clear();
1213 }
1214 
1215 /**
1216  * @tc.name: AddSessionBlackList02
1217  * @tc.desc: test function : AddSessionBlackList(sceneSession)
1218  * @tc.type: FUNC
1219  */
1220 HWTEST_F(SceneSessionManagerTest8, AddSessionBlackList02, TestSize.Level1)
1221 {
1222     ASSERT_NE(nullptr, ssm_);
1223     ssm_->sceneSessionMap_.clear();
1224 
1225     SessionInfo sessionInfo1;
1226     sessionInfo1.bundleName_ = "test";
1227     sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(sessionInfo1, nullptr);
1228     std::vector<sptr<SceneSession>> sceneSessionList;
1229     sceneSessionList.emplace_back(sceneSession1);
1230     std::unordered_set<std::string> privacyWindowTags;
1231     auto ret = ssm_->AddSessionBlackList(sceneSessionList, privacyWindowTags);
1232 
1233     ssm_->sceneSessionMap_.clear();
1234 }
1235 
1236 /**
1237  * @tc.name: RemoveSessionBlackList01
1238  * @tc.desc: test function : RemoveSessionBlackList
1239  * @tc.type: FUNC
1240  */
1241 HWTEST_F(SceneSessionManagerTest8, RemoveSessionBlackList01, TestSize.Level1)
1242 {
1243     ASSERT_NE(nullptr, ssm_);
1244     ssm_->sceneSessionMap_.clear();
1245     MockAccesstokenKit::MockIsSACalling(false);
1246     std::unordered_set<std::string> bundleNames = { "test" };
1247     std::unordered_set<std::string> privacyWindowTags;
1248     auto ret = ssm_->RemoveSessionBlackList(bundleNames, privacyWindowTags);
1249     EXPECT_EQ(WMError::WM_ERROR_INVALID_PERMISSION, ret);
1250 
1251     MockAccesstokenKit::MockIsSACalling(true);
1252     ret = ssm_->RemoveSessionBlackList(bundleNames, privacyWindowTags);
1253     EXPECT_EQ(WMError::WM_OK, ret);
1254 
1255     SessionInfo sessionInfo1;
1256     sessionInfo1.bundleName_ = "test";
1257     sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(sessionInfo1, nullptr);
1258     ssm_->sceneSessionMap_.insert({1, sceneSession1});
1259     ret = ssm_->RemoveSessionBlackList(bundleNames, privacyWindowTags);
1260     EXPECT_EQ(WMError::WM_OK, ret);
1261 
1262     ssm_->sceneSessionMap_.clear();
1263 }
1264 
1265 /**
1266  * @tc.name: RemoveSessionBlackList02
1267  * @tc.desc: test function : RemoveSessionBlackList(sceneSession)
1268  * @tc.type: FUNC
1269  */
1270 HWTEST_F(SceneSessionManagerTest8, RemoveSessionBlackList02, TestSize.Level1)
1271 {
1272     ASSERT_NE(nullptr, ssm_);
1273     ssm_->sceneSessionMap_.clear();
1274 
1275     SessionInfo sessionInfo1;
1276     sessionInfo1.bundleName_ = "test";
1277     sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(sessionInfo1, nullptr);
1278     std::vector<sptr<SceneSession>> sceneSessionList;
1279     sceneSessionList.emplace_back(sceneSession1);
1280     std::unordered_set<std::string> privacyWindowTags;
1281     auto ret = ssm_->RemoveSessionBlackList(sceneSessionList, privacyWindowTags);
1282     EXPECT_EQ(WMError::WM_OK, ret);
1283 
1284     ssm_->sceneSessionMap_.clear();
1285 }
1286 
1287 /**
1288  * @tc.name: FlushSessionBlackListInfoMapWhenAdd01
1289  * @tc.desc: test function : FlushSessionBlackListInfoMapWhenAdd()
1290  * @tc.type: FUNC
1291  */
1292 HWTEST_F(SceneSessionManagerTest8, FlushSessionBlackListInfoMapWhenAdd01, TestSize.Level1)
1293 {
1294     ASSERT_NE(nullptr, ssm_);
1295     ssm_->screenRSBlackListConfigMap_.clear();
1296     ssm_->sessionRSBlackListConfigSet_.clear();
1297     ssm_->sessionBlackListInfoMap_.clear();
1298 
1299     SceneSessionManager::ScreenBlackListInfoSet info;
1300     info.insert({ .privacyWindowTag = "test" });
1301     ssm_->screenRSBlackListConfigMap_[0].insert(*info.begin());
1302     ssm_->sessionRSBlackListConfigSet_.insert({ .windowId = 0, .privacyWindowTag = "test" });
1303 
1304     auto ret = ssm_->FlushSessionBlackListInfoMapWhenAdd();
1305     EXPECT_EQ(WMError::WM_OK, ret);
1306 
1307     ssm_->screenRSBlackListConfigMap_.clear();
1308     ssm_->sessionRSBlackListConfigSet_.clear();
1309     ssm_->sessionBlackListInfoMap_.clear();
1310 }
1311 
1312 /**
1313  * @tc.name: FlushSessionBlackListInfoMapWhenAdd02
1314  * @tc.desc: test function : FlushSessionBlackListInfoMapWhenAdd(screenId)
1315  * @tc.type: FUNC
1316  */
1317 HWTEST_F(SceneSessionManagerTest8, FlushSessionBlackListInfoMapWhenAdd02, TestSize.Level1)
1318 {
1319     ASSERT_NE(nullptr, ssm_);
1320     ssm_->screenRSBlackListConfigMap_.clear();
1321     ssm_->sessionRSBlackListConfigSet_.clear();
1322     ssm_->sessionBlackListInfoMap_.clear();
1323 
1324     SceneSessionManager::ScreenBlackListInfoSet info;
1325     info.insert({ .privacyWindowTag = "test" });
1326     ssm_->screenRSBlackListConfigMap_[0].insert(*info.begin());
1327     ssm_->sessionRSBlackListConfigSet_.insert({ .windowId = 0, .privacyWindowTag = "test" });
1328 
1329     auto ret = ssm_->FlushSessionBlackListInfoMapWhenAdd();
1330     EXPECT_EQ(WMError::WM_OK, ret);
1331 
1332     ssm_->screenRSBlackListConfigMap_.clear();
1333     ssm_->sessionRSBlackListConfigSet_.clear();
1334     ssm_->sessionBlackListInfoMap_.clear();
1335 }
1336 
1337 /**
1338  * @tc.name: FlushSessionBlackListInfoMapWhenRemove01
1339  * @tc.desc: test function : FlushSessionBlackListInfoMapWhenRemove()
1340  * @tc.type: FUNC
1341  */
1342 HWTEST_F(SceneSessionManagerTest8, FlushSessionBlackListInfoMapWhenRemove01, TestSize.Level1)
1343 {
1344     ASSERT_NE(nullptr, ssm_);
1345     ssm_->screenRSBlackListConfigMap_.clear();
1346     ssm_->sessionRSBlackListConfigSet_.clear();
1347     ssm_->sessionBlackListInfoMap_.clear();
1348 
1349     SceneSessionManager::ScreenBlackListInfoSet info;
1350     info.insert({ .privacyWindowTag = "test" });
1351     ssm_->screenRSBlackListConfigMap_[0].insert(*info.begin());
1352     ssm_->sessionRSBlackListConfigSet_.insert({ .windowId = 0, .privacyWindowTag = "test" });
1353     ssm_->sessionBlackListInfoMap_[0].insert({ .windowId = 0, .privacyWindowTag = "test1" });
1354     ssm_->sessionBlackListInfoMap_[0].insert({ .windowId = 1, .privacyWindowTag = "WMS_DEFAULT" });
1355 
1356     auto ret = ssm_->FlushSessionBlackListInfoMapWhenRemove();
1357     EXPECT_EQ(WMError::WM_OK, ret);
1358 
1359     ssm_->screenRSBlackListConfigMap_.clear();
1360     ssm_->sessionRSBlackListConfigSet_.clear();
1361     ssm_->sessionBlackListInfoMap_.clear();
1362 }
1363 
1364 /**
1365  * @tc.name: FlushSessionBlackListInfoMapWhenRemove02
1366  * @tc.desc: test function : FlushSessionBlackListInfoMapWhenRemove(screenId)
1367  * @tc.type: FUNC
1368  */
1369 HWTEST_F(SceneSessionManagerTest8, FlushSessionBlackListInfoMapWhenRemove02, TestSize.Level1)
1370 {
1371     ASSERT_NE(nullptr, ssm_);
1372     ssm_->screenRSBlackListConfigMap_.clear();
1373     ssm_->sessionRSBlackListConfigSet_.clear();
1374     ssm_->sessionBlackListInfoMap_.clear();
1375 
1376     SceneSessionManager::ScreenBlackListInfoSet info;
1377     info.insert({ .privacyWindowTag = "test" });
1378     ssm_->screenRSBlackListConfigMap_[0].insert(*info.begin());
1379     ssm_->sessionRSBlackListConfigSet_.insert({ .windowId = 0, .privacyWindowTag = "test" });
1380     ssm_->sessionBlackListInfoMap_[0].insert({ .windowId = 0, .privacyWindowTag = "test1" });
1381     ssm_->sessionBlackListInfoMap_[0].insert({ .windowId = 1, .privacyWindowTag = "WMS_DEFAULT" });
1382 
1383     auto ret = ssm_->FlushSessionBlackListInfoMapWhenRemove(0);
1384     EXPECT_EQ(WMError::WM_OK, ret);
1385 
1386     ssm_->screenRSBlackListConfigMap_.clear();
1387     ssm_->sessionRSBlackListConfigSet_.clear();
1388     ssm_->sessionBlackListInfoMap_.clear();
1389 }
1390 
1391 /**
1392  * @tc.name: AddskipSurfaceNodeIdSet
1393  * @tc.desc: test function : AddskipSurfaceNodeIdSet
1394  * @tc.type: FUNC
1395  */
1396 HWTEST_F(SceneSessionManagerTest8, AddskipSurfaceNodeIdSet01, TestSize.Level1)
1397 {
1398     ASSERT_NE(nullptr, ssm_);
1399     ssm_->sceneSessionMap_.clear();
1400     std::unordered_set<uint64_t> skipSurfaceNodeIdSet;
1401 
1402     ssm_->sceneSessionMap_.insert({1, nullptr });
1403     ssm_->AddskipSurfaceNodeIdSet(1, skipSurfaceNodeIdSet);
1404     EXPECT_EQ(skipSurfaceNodeIdSet.size(), 0);
1405     skipSurfaceNodeIdSet.clear();
1406 
1407     SessionInfo sessionInfo1;
1408     sessionInfo1.bundleName_ = "test";
1409     sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(sessionInfo1, nullptr);
1410     sceneSession1->GetSessionProperty()->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
1411     struct RSSurfaceNodeConfig config;
1412     std::shared_ptr<RSSurfaceNode> surfaceNode = RSSurfaceNode::Create(config);
1413     ASSERT_NE(nullptr, surfaceNode);
1414     sceneSession1->SetSurfaceNode(surfaceNode);
1415     sceneSession1->GetSurfaceNode()->SetId(1001);
1416     sceneSession1->SetLeashWinSurfaceNode(surfaceNode);
1417     ssm_->sceneSessionMap_.insert({2, sceneSession1 });
1418     ssm_->AddskipSurfaceNodeIdSet(2, skipSurfaceNodeIdSet);
1419     EXPECT_EQ(skipSurfaceNodeIdSet.size(), 2);
1420     skipSurfaceNodeIdSet.clear();
1421 
1422     ssm_->sceneSessionMap_.clear();
1423 }
1424 
1425 /**
1426  * @tc.name: NotifyOnAttachToFrameNode01
1427  * @tc.desc: test function : NotifyOnAttachToFrameNode
1428  * @tc.type: FUNC
1429  */
1430 HWTEST_F(SceneSessionManagerTest8, NotifyOnAttachToFrameNode01, TestSize.Level1)
1431 {
1432     ASSERT_NE(nullptr, ssm_);
1433     ssm_->screenRSBlackListConfigMap_.clear();
1434     ssm_->sessionRSBlackListConfigSet_.clear();
1435     ssm_->sessionBlackListInfoMap_.clear();
1436     ssm_->bundleRSBlackListConfigMap_.clear();
1437 
1438     sptr<Session> session = nullptr;
1439     ssm_->NotifyOnAttachToFrameNode(session);
1440     EXPECT_EQ(ssm_->sessionBlackListInfoMap_.size(), 0);
1441     EXPECT_EQ(ssm_->sessionRSBlackListConfigSet_.size(), 0);
1442 
1443     SessionInfo info;
1444     session = sptr<Session>::MakeSptr(info);
1445     session->GetSessionProperty()->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
1446     ssm_->NotifyOnAttachToFrameNode(session);
1447     EXPECT_EQ(ssm_->sessionBlackListInfoMap_.size(), 0);
1448     EXPECT_EQ(ssm_->sessionRSBlackListConfigSet_.size(), 0);
1449 
1450     session->GetSessionProperty()->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
1451     session->SetSurfaceNode(nullptr);
1452     ssm_->NotifyOnAttachToFrameNode(session);
1453     EXPECT_EQ(ssm_->sessionBlackListInfoMap_.size(), 0);
1454     EXPECT_EQ(ssm_->sessionRSBlackListConfigSet_.size(), 0);
1455 
1456     session->GetSessionProperty()->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
1457     struct RSSurfaceNodeConfig config;
1458     std::shared_ptr<RSSurfaceNode> surfaceNode = RSSurfaceNode::Create(config);
1459     ASSERT_NE(nullptr, surfaceNode);
1460     session->SetSurfaceNode(surfaceNode);
1461     ssm_->NotifyOnAttachToFrameNode(session);
1462     EXPECT_EQ(ssm_->sessionBlackListInfoMap_.size(), 0);
1463     EXPECT_EQ(ssm_->sessionRSBlackListConfigSet_.size(), 0);
1464 
1465     ssm_->screenRSBlackListConfigMap_.clear();
1466     ssm_->sessionRSBlackListConfigSet_.clear();
1467     ssm_->sessionBlackListInfoMap_.clear();
1468     ssm_->bundleRSBlackListConfigMap_.clear();
1469 }
1470 
1471 /**
1472  * @tc.name: SetSurfaceNodeIds01
1473  * @tc.desc: test function : SetSurfaceNodeIds
1474  * @tc.type: FUNC
1475  */
1476 HWTEST_F(SceneSessionManagerTest8, SetSurfaceNodeIds01, TestSize.Level1)
1477 {
1478     ssm_->sessionBlackListInfoMap_.clear();
1479     ssm_->sceneSessionMap_.clear();
1480     std::vector<uint64_t> surfaceNodeIds;
1481     ssm_->sessionBlackListInfoMap_[0].insert({ .windowId = 0 });
1482     ssm_->sessionBlackListInfoMap_[0].insert({ .windowId = 0, .privacyWindowTag = "test" });
1483     ssm_->SetSurfaceNodeIds(0, surfaceNodeIds);
1484     EXPECT_EQ(ssm_->sessionBlackListInfoMap_[0].size(), 1);
1485 
1486     surfaceNodeIds.push_back(1);
1487     ssm_->SetSurfaceNodeIds(0, surfaceNodeIds);
1488     EXPECT_EQ(ssm_->sessionBlackListInfoMap_[0].size(), 1);
1489 
1490     SessionInfo sessionInfo1;
1491     sessionInfo1.bundleName_ = "test";
1492     sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(sessionInfo1, nullptr);
1493     ssm_->sceneSessionMap_.insert({1, sceneSession1});
1494     struct RSSurfaceNodeConfig config;
1495     std::shared_ptr<RSSurfaceNode> surfaceNode = RSSurfaceNode::Create(config);
1496     ASSERT_NE(nullptr, surfaceNode);
1497     surfaceNode->SetId(1);
1498     sceneSession1->SetSurfaceNode(surfaceNode);
1499     ssm_->SetSurfaceNodeIds(0, surfaceNodeIds);
1500     EXPECT_EQ(ssm_->sessionBlackListInfoMap_[0].size(), 2);
1501 }
1502 
1503 /**
1504  * @tc.name: AddSkipSurfaceNodeWhenAttach01
1505  * @tc.desc: test function : AddSkipSurfaceNodeWhenAttach
1506  * @tc.type: FUNC
1507  */
1508 HWTEST_F(SceneSessionManagerTest8, AddSkipSurfaceNodeWhenAttach01, TestSize.Level1)
1509 {
1510     ASSERT_NE(nullptr, ssm_);
1511     ssm_->screenRSBlackListConfigMap_.clear();
1512     ssm_->sessionRSBlackListConfigSet_.clear();
1513     ssm_->sessionBlackListInfoMap_.clear();
1514     ssm_->bundleRSBlackListConfigMap_.clear();
1515 
1516     int32_t persistentId = 1;
1517     ssm_->bundleRSBlackListConfigMap_["test"].insert({ "test" });
1518     ssm_->screenRSBlackListConfigMap_[0].insert({ .privacyWindowTag = "test" });
1519 
1520     ssm_->AddSkipSurfaceNodeWhenAttach(persistentId, "test", static_cast<uint64_t>(persistentId));
1521     EXPECT_EQ(ssm_->sessionBlackListInfoMap_.size(), 1);
1522     EXPECT_EQ(ssm_->sessionRSBlackListConfigSet_.size(), 1);
1523 
1524     ssm_->screenRSBlackListConfigMap_.clear();
1525     ssm_->sessionRSBlackListConfigSet_.clear();
1526     ssm_->sessionBlackListInfoMap_.clear();
1527     ssm_->bundleRSBlackListConfigMap_.clear();
1528 }
1529 
1530 /**
1531  * @tc.name: RemoveSessionFromBlackListInfoSet
1532  * @tc.desc: test function : RemoveSessionFromBlackListInfoSet
1533  * @tc.type: FUNC
1534  */
1535 HWTEST_F(SceneSessionManagerTest8, RemoveSessionFromBlackListInfoSet01, TestSize.Level1)
1536 {
1537     ASSERT_NE(nullptr, ssm_);
1538     ssm_->screenRSBlackListConfigMap_.clear();
1539     ssm_->sessionRSBlackListConfigSet_.clear();
1540     ssm_->sessionBlackListInfoMap_.clear();
1541 
1542     SessionInfo sessionInfo1;
1543     sessionInfo1.bundleName_ = "test";
1544     sessionInfo1.persistentId_ = 1;
1545     sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(sessionInfo1, nullptr);
1546     SceneSessionManager::SessionBlackListInfoSet sessionBlackListInfoSet;
1547     sessionBlackListInfoSet.insert({ .windowId = 0, .privacyWindowTag = "test" });
1548 
1549     ssm_->RemoveSessionFromBlackListInfoSet(sceneSession1, sessionBlackListInfoSet);
1550     EXPECT_EQ(sessionBlackListInfoSet.size(), 1);
1551 
1552     ssm_->screenRSBlackListConfigMap_.clear();
1553     ssm_->sessionRSBlackListConfigSet_.clear();
1554     ssm_->sessionBlackListInfoMap_.clear();
1555 }
1556 } // namespace
1557 } // namespace Rosen
1558 } // namespace OHOS