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 <bundle_mgr_interface.h>
17 #include <bundlemgr/launcher_service.h>
18 #include <gtest/gtest.h>
19 #include <regex>
20 #include "context.h"
21 #include "interfaces/include/ws_common.h"
22 #include "mock/mock_session_stage.h"
23 #include "mock/mock_window_event_channel.h"
24 #include "session/host/include/scene_session.h"
25 #include "session/host/include/main_session.h"
26 #include "session_info.h"
27 #include "session_manager.h"
28 #include "session_manager/include/scene_session_manager.h"
29 #include "window_manager_agent.h"
30 #include "zidl/window_manager_agent_interface.h"
31 #include "screen_session_manager/include/screen_session_manager_client.h"
32 
33 using namespace testing;
34 using namespace testing::ext;
35 
36 namespace OHOS {
37 namespace Rosen {
38 namespace {
39 const std::string EMPTY_DEVICE_ID = "";
40 using ConfigItem = WindowSceneConfig::ConfigItem;
41 }
42 class SceneSessionManagerTest6 : public testing::Test {
43 public:
44     static void SetUpTestCase();
45     static void TearDownTestCase();
46     void SetUp() override;
47     void TearDown() override;
48 
49     static bool gestureNavigationEnabled_;
50     static ProcessGestureNavigationEnabledChangeFunc callbackFunc_;
51     static sptr<SceneSessionManager> ssm_;
52 private:
53     static constexpr uint32_t WAIT_SYNC_IN_NS = 200000;
54 };
55 
56 sptr<SceneSessionManager> SceneSessionManagerTest6::ssm_ = nullptr;
57 
58 bool SceneSessionManagerTest6::gestureNavigationEnabled_ = true;
59 ProcessGestureNavigationEnabledChangeFunc SceneSessionManagerTest6::callbackFunc_ = [](bool enable,
__anon3b2678d20202(bool enable, const std::string& bundleName, GestureBackType type) 60     const std::string& bundleName, GestureBackType type) {
61     gestureNavigationEnabled_ = enable;
62 };
63 
WindowChangedFuncTest(int32_t persistentId,WindowUpdateType type)64 void WindowChangedFuncTest(int32_t persistentId, WindowUpdateType type)
65 {
66 }
67 
ProcessStatusBarEnabledChangeFuncTest(bool enable)68 void ProcessStatusBarEnabledChangeFuncTest(bool enable)
69 {
70 }
71 
DumpRootSceneElementInfoFuncTest(const std::vector<std::string> & params,std::vector<std::string> & infos)72 void DumpRootSceneElementInfoFuncTest(const std::vector<std::string>& params, std::vector<std::string>& infos)
73 {
74 }
75 
SetUpTestCase()76 void SceneSessionManagerTest6::SetUpTestCase()
77 {
78     ssm_ = &SceneSessionManager::GetInstance();
79 }
80 
TearDownTestCase()81 void SceneSessionManagerTest6::TearDownTestCase()
82 {
83     ssm_ = nullptr;
84 }
85 
SetUp()86 void SceneSessionManagerTest6::SetUp()
87 {
88     ssm_->sceneSessionMap_.clear();
89 }
90 
TearDown()91 void SceneSessionManagerTest6::TearDown()
92 {
93     usleep(WAIT_SYNC_IN_NS);
94     ssm_->sceneSessionMap_.clear();
95 }
96 
97 namespace {
98 /**
99  * @tc.name: MissionChanged
100  * @tc.desc: MissionChanged
101  * @tc.type: FUNC
102  */
103 HWTEST_F(SceneSessionManagerTest6, MissionChanged, Function | SmallTest | Level3)
104 {
105     sptr<SceneSession> prevSession = nullptr;
106     sptr<SceneSession> currSession = nullptr;
107     ASSERT_NE(nullptr, ssm_);
108     auto ret = ssm_->MissionChanged(prevSession, currSession);
109     EXPECT_EQ(false, ret);
110     SessionInfo sessionInfoFirst;
111     sessionInfoFirst.bundleName_ = "privacy.test.first";
112     sessionInfoFirst.abilityName_ = "privacyAbilityName";
113     prevSession = sptr<SceneSession>::MakeSptr(sessionInfoFirst, nullptr);
114     ASSERT_NE(nullptr, prevSession);
115     ASSERT_NE(nullptr, ssm_);
116     ret = ssm_->MissionChanged(prevSession, currSession);
117     EXPECT_EQ(true, ret);
118     SessionInfo sessionInfoSecond;
119     sessionInfoSecond.bundleName_ = "privacy.test.second";
120     sessionInfoSecond.abilityName_ = "privacyAbilityName";
121     currSession= sptr<SceneSession>::MakeSptr(sessionInfoSecond, nullptr);
122     ASSERT_NE(nullptr, currSession);
123     prevSession->persistentId_ = 0;
124     currSession->persistentId_ = 0;
125     ASSERT_NE(nullptr, ssm_);
126     ret = ssm_->MissionChanged(prevSession, currSession);
127     EXPECT_EQ(false, ret);
128     prevSession = nullptr;
129     ASSERT_NE(nullptr, ssm_);
130     ret = ssm_->MissionChanged(prevSession, currSession);
131     EXPECT_EQ(true, ret);
132 }
133 
134 /**
135  * @tc.name: UpdateSecSurfaceInfo
136  * @tc.desc: UpdateSecSurfaceInfo
137  * @tc.type: FUNC
138  */
139 HWTEST_F(SceneSessionManagerTest6, UpdateSecSurfaceInfo, Function | SmallTest | Level3)
140 {
141     ASSERT_NE(ssm_, nullptr);
142     std::map<NodeId, std::vector<SecSurfaceInfo>> callbackData;
143     std::shared_ptr<RSUIExtensionData> secExtData = std::make_shared<RSUIExtensionData>(callbackData);
144     ssm_->currentUserId_ = 101;
145     ssm_->UpdateSecSurfaceInfo(secExtData, 100);
146 
147     ssm_->currentUserId_ = 100;
148     ssm_->UpdateSecSurfaceInfo(secExtData, 100);
149 }
150 
151 /**
152  * @tc.name: GetWindowLayerChangeInfo
153  * @tc.desc: GetWindowLayerChangeInfo
154  * @tc.type: FUNC
155  */
156 HWTEST_F(SceneSessionManagerTest6, GetWindowLayerChangeInfo, Function | SmallTest | Level3)
157 {
158     std::vector<std::pair<uint64_t, WindowVisibilityState>> currVisibleData;
159     currVisibleData.push_back(std::make_pair(0, WindowVisibilityState::WINDOW_VISIBILITY_STATE_NO_OCCLUSION));
160     currVisibleData.push_back(std::make_pair(1, WindowVisibilityState::WINDOW_VISIBILITY_STATE_PARTICALLY_OCCLUSION));
161     currVisibleData.push_back(std::make_pair(2, WindowVisibilityState::WINDOW_VISIBILITY_STATE_TOTALLY_OCCUSION));
162     currVisibleData.push_back(std::make_pair(3, WindowVisibilityState::WINDOW_LAYER_STATE_MAX));
163     std::vector<std::pair<uint64_t, bool>> currDrawingContentData;
164     currDrawingContentData.push_back(std::make_pair(0, true));
165     currDrawingContentData.push_back(std::make_pair(1, false));
166     VisibleData visibleData;
167     visibleData.push_back(std::make_pair(0, WINDOW_LAYER_INFO_TYPE::ALL_VISIBLE));
168     visibleData.push_back(std::make_pair(1, WINDOW_LAYER_INFO_TYPE::SEMI_VISIBLE));
169     visibleData.push_back(std::make_pair(2, WINDOW_LAYER_INFO_TYPE::INVISIBLE));
170     visibleData.push_back(std::make_pair(3, WINDOW_LAYER_INFO_TYPE::WINDOW_LAYER_DYNAMIC_STATUS));
171     visibleData.push_back(std::make_pair(4, WINDOW_LAYER_INFO_TYPE::WINDOW_LAYER_STATIC_STATUS));
172     visibleData.push_back(std::make_pair(5, WINDOW_LAYER_INFO_TYPE::WINDOW_LAYER_UNKNOWN_TYPE));
173     std::shared_ptr<RSOcclusionData> occlusionDataPtr = std::make_shared<RSOcclusionData>(visibleData);
174     ASSERT_NE(nullptr, occlusionDataPtr);
175     ASSERT_NE(nullptr, ssm_);
176     ssm_->GetWindowLayerChangeInfo(occlusionDataPtr, currVisibleData, currDrawingContentData);
177 }
178 
179 /**
180  * @tc.name: GetWindowVisibilityChangeInfo01
181  * @tc.desc: GetWindowVisibilityChangeInfo01
182  * @tc.type: FUNC
183  */
184 HWTEST_F(SceneSessionManagerTest6, GetWindowVisibilityChangeInfo01, Function | SmallTest | Level3)
185 {
186     ASSERT_NE(nullptr, ssm_);
187     ssm_->lastVisibleData_.clear();
188     std::vector<std::pair<uint64_t, WindowVisibilityState>> currVisibleData;
189     std::vector<std::pair<uint64_t, WindowVisibilityState>> visibilityChangeInfos;
190     currVisibleData.push_back(std::make_pair(1, WindowVisibilityState::WINDOW_VISIBILITY_STATE_PARTICALLY_OCCLUSION));
191     currVisibleData.push_back(std::make_pair(2, WindowVisibilityState::WINDOW_VISIBILITY_STATE_TOTALLY_OCCUSION));
192     currVisibleData.push_back(std::make_pair(3, WindowVisibilityState::WINDOW_LAYER_STATE_MAX));
193     ssm_->lastVisibleData_.push_back(std::make_pair(0, WindowVisibilityState::WINDOW_VISIBILITY_STATE_NO_OCCLUSION));
194     visibilityChangeInfos = ssm_->GetWindowVisibilityChangeInfo(currVisibleData);
195     ASSERT_EQ(visibilityChangeInfos.size(), 3);
196 }
197 
198 /**
199  * @tc.name: GetWindowVisibilityChangeInfo02
200  * @tc.desc: GetWindowVisibilityChangeInfo02
201  * @tc.type: FUNC
202  */
203 HWTEST_F(SceneSessionManagerTest6, GetWindowVisibilityChangeInfo02, Function | SmallTest | Level3)
204 {
205     ASSERT_NE(nullptr, ssm_);
206     ssm_->lastVisibleData_.clear();
207     std::vector<std::pair<uint64_t, WindowVisibilityState>> currVisibleData;
208     std::vector<std::pair<uint64_t, WindowVisibilityState>> visibilityChangeInfos;
209     currVisibleData.push_back(std::make_pair(0, WindowVisibilityState::WINDOW_VISIBILITY_STATE_PARTICALLY_OCCLUSION));
210     ssm_->lastVisibleData_.push_back(std::make_pair(1, WindowVisibilityState::WINDOW_VISIBILITY_STATE_NO_OCCLUSION));
211     visibilityChangeInfos = ssm_->GetWindowVisibilityChangeInfo(currVisibleData);
212     ASSERT_EQ(visibilityChangeInfos.size(), 2);
213 }
214 
215 /**
216  * @tc.name: GetWindowVisibilityChangeInfo03
217  * @tc.desc: GetWindowVisibilityChangeInfo03
218  * @tc.type: FUNC
219  */
220 HWTEST_F(SceneSessionManagerTest6, GetWindowVisibilityChangeInfo03, Function | SmallTest | Level3)
221 {
222     ASSERT_NE(nullptr, ssm_);
223     ssm_->lastVisibleData_.clear();
224     std::vector<std::pair<uint64_t, WindowVisibilityState>> currVisibleData;
225     std::vector<std::pair<uint64_t, WindowVisibilityState>> visibilityChangeInfos;
226     currVisibleData.push_back(std::make_pair(1, WindowVisibilityState::WINDOW_VISIBILITY_STATE_PARTICALLY_OCCLUSION));
227     currVisibleData.push_back(std::make_pair(2, WindowVisibilityState::WINDOW_VISIBILITY_STATE_TOTALLY_OCCUSION));
228     ssm_->lastVisibleData_.push_back(
229         std::make_pair(1, WindowVisibilityState::WINDOW_VISIBILITY_STATE_PARTICALLY_OCCLUSION));
230     ssm_->lastVisibleData_.push_back(
231         std::make_pair(2, WindowVisibilityState::WINDOW_VISIBILITY_STATE_PARTICALLY_OCCLUSION));
232     visibilityChangeInfos = ssm_->GetWindowVisibilityChangeInfo(currVisibleData);
233     ASSERT_EQ(visibilityChangeInfos.size(), 1);
234     currVisibleData.clear();
235     ssm_->lastVisibleData_.clear();
236     currVisibleData.push_back(std::make_pair(1, WindowVisibilityState::WINDOW_VISIBILITY_STATE_TOTALLY_OCCUSION));
237     ssm_->lastVisibleData_.push_back(
238         std::make_pair(2, WindowVisibilityState::WINDOW_VISIBILITY_STATE_NO_OCCLUSION));
239     visibilityChangeInfos = ssm_->GetWindowVisibilityChangeInfo(currVisibleData);
240     ASSERT_EQ(visibilityChangeInfos.size(), 1);
241     ASSERT_EQ(visibilityChangeInfos[0].first, 2);
242 }
243 
244 /**
245  * @tc.name: GetWindowVisibilityChangeInfo04
246  * @tc.desc: GetWindowVisibilityChangeInfo04
247  * @tc.type: FUNC
248  */
249 HWTEST_F(SceneSessionManagerTest6, GetWindowVisibilityChangeInfo04, Function | SmallTest | Level3)
250 {
251     ASSERT_NE(nullptr, ssm_);
252     ssm_->lastVisibleData_.clear();
253     std::vector<std::pair<uint64_t, WindowVisibilityState>> currVisibleData;
254     std::vector<std::pair<uint64_t, WindowVisibilityState>> visibilityChangeInfos;
255     ssm_->lastVisibleData_.push_back(std::make_pair(0, WindowVisibilityState::WINDOW_VISIBILITY_STATE_NO_OCCLUSION));
256     currVisibleData.push_back(std::make_pair(0, WindowVisibilityState::WINDOW_VISIBILITY_STATE_TOTALLY_OCCUSION));
257     currVisibleData.push_back(std::make_pair(1, WindowVisibilityState::WINDOW_VISIBILITY_STATE_TOTALLY_OCCUSION));
258     visibilityChangeInfos = ssm_->GetWindowVisibilityChangeInfo(currVisibleData);
259     ASSERT_EQ(visibilityChangeInfos.size(), 1);
260 
261     currVisibleData.clear();
262     currVisibleData.push_back(std::make_pair(1, WindowVisibilityState::WINDOW_VISIBILITY_STATE_TOTALLY_OCCUSION));
263     visibilityChangeInfos = ssm_->GetWindowVisibilityChangeInfo(currVisibleData);
264     ASSERT_EQ(visibilityChangeInfos.size(), 0);
265 }
266 
267 /**
268  * @tc.name: DealwithVisibilityChange01
269  * @tc.desc: DealwithVisibilityChange01
270  * @tc.type: FUNC
271  */
272 HWTEST_F(SceneSessionManagerTest6, DealwithVisibilityChange01, Function | SmallTest | Level3)
273 {
274     ASSERT_NE(nullptr, ssm_);
275     ssm_->sceneSessionMap_.clear();
276     SessionInfo sessionInfo;
277     sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
278     sptr<SceneSession> sceneSession2 = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
279     ssm_->sceneSessionMap_.insert(std::make_pair(sceneSession1->GetPersistentId(), sceneSession1));
280     ssm_->sceneSessionMap_.insert(std::make_pair(sceneSession2->GetPersistentId(), sceneSession2));
281     struct RSSurfaceNodeConfig config;
282     std::shared_ptr<RSSurfaceNode> surfaceNode1 = RSSurfaceNode::Create(config);
283     std::shared_ptr<RSSurfaceNode> surfaceNode2 = RSSurfaceNode::Create(config);
284     ASSERT_NE(nullptr, surfaceNode1);
285     ASSERT_NE(nullptr, surfaceNode2);
286     surfaceNode1->SetId(1);
287     surfaceNode2->SetId(2);
288     ASSERT_NE(nullptr, sceneSession1);
289     ASSERT_NE(nullptr, sceneSession2);
290     sceneSession1->SetSessionState(SessionState::STATE_FOREGROUND);
291     sceneSession1->surfaceNode_ = surfaceNode1;
292     sceneSession1->SetCallingPid(1);
293     sceneSession2->SetSessionState(SessionState::STATE_FOREGROUND);
294     sceneSession2->SetParentSession(sceneSession1);
295     sceneSession2->surfaceNode_ = surfaceNode2;
296     sceneSession2->SetCallingPid(2);
297     ASSERT_NE(nullptr, sceneSession1->property_);
298     ASSERT_NE(nullptr, sceneSession2->property_);
299     sceneSession1->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
300     sceneSession2->property_->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
301     sceneSession1->property_->SetWindowName("visibility1");
302     sceneSession2->property_->SetWindowName("visibility2");
303     std::vector<std::pair<uint64_t, WindowVisibilityState>> visibilityChangeInfos;
304     visibilityChangeInfos.push_back(std::make_pair(1, WindowVisibilityState::WINDOW_VISIBILITY_STATE_NO_OCCLUSION));
305     std::vector<std::pair<uint64_t, WindowVisibilityState>> currVisibleData;
306     currVisibleData.push_back(std::make_pair(1, WindowVisibilityState::WINDOW_VISIBILITY_STATE_NO_OCCLUSION));
307     ssm_->DealwithVisibilityChange(visibilityChangeInfos, currVisibleData);
308     ASSERT_EQ(sceneSession1->GetRSVisible(), true);
309     ASSERT_EQ(sceneSession2->GetRSVisible(), true);
310     sceneSession2->SetSessionState(SessionState::STATE_BACKGROUND);
311     sceneSession1->SetRSVisible(false);
312     sceneSession2->SetRSVisible(false);
313     ssm_->DealwithVisibilityChange(visibilityChangeInfos, currVisibleData);
314     ASSERT_EQ(sceneSession1->GetRSVisible(), true);
315     ASSERT_EQ(sceneSession2->GetRSVisible(), false);
316 }
317 
318 /**
319  * @tc.name: DealwithVisibilityChange02
320  * @tc.desc: DealwithVisibilityChange02
321  * @tc.type: FUNC
322  */
323 HWTEST_F(SceneSessionManagerTest6, DealwithVisibilityChange02, Function | SmallTest | Level3)
324 {
325     ASSERT_NE(nullptr, ssm_);
326     ssm_->sceneSessionMap_.clear();
327     SessionInfo sessionInfo;
328     sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
329     sptr<SceneSession> sceneSession2 = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
330     ssm_->sceneSessionMap_.insert(std::make_pair(sceneSession1->GetPersistentId(), sceneSession1));
331     ssm_->sceneSessionMap_.insert(std::make_pair(sceneSession2->GetPersistentId(), sceneSession2));
332     struct RSSurfaceNodeConfig config;
333     std::shared_ptr<RSSurfaceNode> surfaceNode1 = RSSurfaceNode::Create(config);
334     std::shared_ptr<RSSurfaceNode> surfaceNode2 = RSSurfaceNode::Create(config);
335     ASSERT_NE(nullptr, surfaceNode1);
336     ASSERT_NE(nullptr, surfaceNode2);
337     surfaceNode1->SetId(1);
338     surfaceNode2->SetId(2);
339     ASSERT_NE(nullptr, sceneSession1);
340     ASSERT_NE(nullptr, sceneSession2);
341     sceneSession1->SetSessionState(SessionState::STATE_FOREGROUND);
342     sceneSession1->surfaceNode_ = surfaceNode1;
343     sceneSession2->SetSessionState(SessionState::STATE_FOREGROUND);
344     sceneSession2->SetParentSession(sceneSession1);
345     sceneSession2->surfaceNode_ = surfaceNode2;
346     ASSERT_NE(nullptr, sceneSession1->property_);
347     ASSERT_NE(nullptr, sceneSession2->property_);
348     sceneSession1->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
349     sceneSession2->property_->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
350     sceneSession1->property_->SetWindowName("visibility1");
351     sceneSession2->property_->SetWindowName("visibility2");
352     std::vector<std::pair<uint64_t, WindowVisibilityState>> visibilityChangeInfos;
353     visibilityChangeInfos.push_back(std::make_pair(2, WindowVisibilityState::WINDOW_VISIBILITY_STATE_NO_OCCLUSION));
354     std::vector<std::pair<uint64_t, WindowVisibilityState>> currVisibleData;
355     currVisibleData.push_back(std::make_pair(3, WindowVisibilityState::WINDOW_VISIBILITY_STATE_NO_OCCLUSION));
356     sceneSession1->SetRSVisible(true);
357     ssm_->DealwithVisibilityChange(visibilityChangeInfos, currVisibleData);
358     ASSERT_EQ(sceneSession2->GetRSVisible(), true);
359     sceneSession2->SetSessionState(SessionState::STATE_BACKGROUND);
360     sceneSession1->SetRSVisible(false);
361     sceneSession2->SetRSVisible(false);
362     sceneSession1->SetSessionState(SessionState::STATE_BACKGROUND);
363     ssm_->DealwithVisibilityChange(visibilityChangeInfos, currVisibleData);
364     ASSERT_EQ(sceneSession2->GetRSVisible(), false);
365 }
366 
367 /**
368  * @tc.name: UpdateWindowMode
369  * @tc.desc: UpdateWindowMode
370  * @tc.type: FUNC
371  */
372 HWTEST_F(SceneSessionManagerTest6, UpdateWindowMode, Function | SmallTest | Level3)
373 {
374     SessionInfo sessionInfo;
375     sessionInfo.bundleName_ = "SceneSessionManagerTest2";
376     sessionInfo.abilityName_ = "DumpSessionWithId";
377     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
378     ASSERT_NE(nullptr, ssm_);
379     ssm_->sceneSessionMap_.insert(std::make_pair(2, sceneSession));
380     ASSERT_NE(nullptr, ssm_);
381     auto ret = ssm_->UpdateWindowMode(0, 0);
382     EXPECT_EQ(WSError::WS_ERROR_INVALID_WINDOW, ret);
383     ASSERT_NE(nullptr, ssm_);
384     ret = ssm_->UpdateWindowMode(2, 0);
385     EXPECT_EQ(WSError::WS_OK, ret);
386 }
387 
388 /**
389  * @tc.name: SetScreenLocked && IsScreenLocked
390  * @tc.desc: SceneSesionManager update screen locked state
391  * @tc.type: FUNC
392  */
393 HWTEST_F(SceneSessionManagerTest6, IsScreenLocked, Function | SmallTest | Level3)
394 {
395     ASSERT_NE(nullptr, ssm_);
396     ssm_->SetScreenLocked(true);
397     ASSERT_NE(nullptr, ssm_);
398     EXPECT_TRUE(ssm_->IsScreenLocked());
399     ASSERT_NE(nullptr, ssm_);
400     ssm_->ProcessWindowModeType();
401     ASSERT_NE(nullptr, ssm_);
402     ssm_->SetScreenLocked(false);
403     ASSERT_NE(nullptr, ssm_);
404     EXPECT_FALSE(ssm_->IsScreenLocked());
405     ASSERT_NE(nullptr, ssm_);
406     ssm_->ProcessWindowModeType();
407 }
408 
409 /**
410  * @tc.name: CheckWindowModeType
411  * @tc.desc: CheckWindowModeType
412  * @tc.type: FUNC
413  */
414 HWTEST_F(SceneSessionManagerTest6, CheckWindowModeType, Function | SmallTest | Level3)
415 {
416     ASSERT_NE(nullptr, ssm_);
417     ssm_->sceneSessionMap_.clear();
418     auto ret = ssm_->CheckWindowModeType();
419     EXPECT_EQ(WindowModeType::WINDOW_MODE_OTHER, ret);
420     SessionInfo sessionInfo;
421     sessionInfo.bundleName_ = "privacy.test.first";
422     sessionInfo.abilityName_ = "privacyAbilityName";
423     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
424     ASSERT_NE(nullptr, sceneSession);
425     ASSERT_NE(nullptr, sceneSession->property_);
426     sceneSession->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_END);
427     DisplayId displayId = ScreenSessionManagerClient::GetInstance().GetDefaultScreenId();
428     sceneSession->property_->SetDisplayId(displayId);
429     ASSERT_NE(nullptr, ssm_);
430     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
431     ASSERT_NE(nullptr, ssm_);
432     ret = ssm_->CheckWindowModeType();
433     EXPECT_EQ(WindowModeType::WINDOW_MODE_OTHER, ret);
434     ASSERT_NE(nullptr, sceneSession->property_);
435     sceneSession->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
436     sceneSession->isVisible_ = false;
437     sceneSession->state_ = SessionState::STATE_DISCONNECT;
438     ASSERT_NE(nullptr, ssm_);
439     ret = ssm_->CheckWindowModeType();
440     EXPECT_EQ(WindowModeType::WINDOW_MODE_OTHER, ret);
441 }
442 
443 /**
444  * @tc.name: CheckWindowModeType01
445  * @tc.desc: CheckWindowModeType
446  * @tc.type: FUNC
447  */
448 HWTEST_F(SceneSessionManagerTest6, CheckWindowModeType01, Function | SmallTest | Level3)
449 {
450     DisplayId displayId = ScreenSessionManagerClient::GetInstance().GetDefaultScreenId();
451     SessionInfo sessionInfo;
452     sessionInfo.bundleName_ = "privacy.test.first";
453     sessionInfo.abilityName_ = "privacyAbilityName";
454     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
455     ASSERT_NE(nullptr, sceneSession);
456     ASSERT_NE(nullptr, sceneSession->property_);
457     sceneSession->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
458     ASSERT_NE(nullptr, sceneSession->property_);
459     sceneSession->property_->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_PRIMARY);
460     sceneSession->property_->SetDisplayId(displayId);
461     sceneSession->isVisible_ = true;
462     sceneSession->state_ = SessionState::STATE_ACTIVE;
463     ASSERT_NE(nullptr, ssm_);
464     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
465     SessionInfo sessionInfo1;
466     sessionInfo1.bundleName_ = "privacy.test.first";
467     sessionInfo1.abilityName_ = "privacyAbilityName";
468     sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(sessionInfo1, nullptr);
469     ASSERT_NE(nullptr, sceneSession1);
470     ASSERT_NE(nullptr, sceneSession1->property_);
471     sceneSession1->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
472     ASSERT_NE(nullptr, sceneSession1->property_);
473     sceneSession1->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
474     sceneSession1->property_->SetDisplayId(displayId);
475     sceneSession1->isVisible_ = true;
476     sceneSession1->state_ = SessionState::STATE_ACTIVE;
477     ASSERT_NE(nullptr, ssm_);
478     ssm_->sceneSessionMap_.insert(std::make_pair(2, sceneSession1));
479     ASSERT_NE(nullptr, ssm_);
480     auto ret = ssm_->CheckWindowModeType();
481     EXPECT_EQ(WindowModeType::WINDOW_MODE_SPLIT_FLOATING, ret);
482     ASSERT_NE(nullptr, sceneSession);
483     ASSERT_NE(nullptr, sceneSession->property_);
484     sceneSession->property_->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
485     ASSERT_NE(nullptr, ssm_);
486     ret = ssm_->CheckWindowModeType();
487     EXPECT_EQ(WindowModeType::WINDOW_MODE_FULLSCREEN_FLOATING, ret);
488 }
489 
490 /**
491  * @tc.name: CheckWindowModeType02
492  * @tc.desc: CheckWindowModeType
493  * @tc.type: FUNC
494  */
495 HWTEST_F(SceneSessionManagerTest6, CheckWindowModeType02, Function | SmallTest | Level3)
496 {
497     DisplayId displayId = ScreenSessionManagerClient::GetInstance().GetDefaultScreenId();
498     SessionInfo sessionInfo;
499     sessionInfo.bundleName_ = "privacy.test.first";
500     sessionInfo.abilityName_ = "privacyAbilityName";
501     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
502     ASSERT_NE(nullptr, sceneSession);
503     ASSERT_NE(nullptr, sceneSession->property_);
504     sceneSession->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
505     ASSERT_NE(nullptr, sceneSession->property_);
506     sceneSession->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
507     sceneSession->property_->SetDisplayId(displayId);
508     sceneSession->isVisible_ = true;
509     sceneSession->state_ = SessionState::STATE_ACTIVE;
510     ASSERT_NE(nullptr, ssm_);
511     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
512     ASSERT_NE(nullptr, ssm_);
513     ssm_->lastWindowModeType_ = WindowModeType::WINDOW_MODE_FULLSCREEN;
514     auto ret = ssm_->CheckWindowModeType();
515     EXPECT_EQ(WindowModeType::WINDOW_MODE_FLOATING, ret);
516     ASSERT_NE(nullptr, ssm_);
517     ssm_->NotifyRSSWindowModeTypeUpdate();
518     ASSERT_NE(nullptr, sceneSession->property_);
519     sceneSession->property_->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
520     ASSERT_NE(nullptr, ssm_);
521     ret = ssm_->CheckWindowModeType();
522     EXPECT_EQ(WindowModeType::WINDOW_MODE_FULLSCREEN, ret);
523     ASSERT_NE(nullptr, ssm_);
524     ssm_->NotifyRSSWindowModeTypeUpdate();
525 }
526 
527 /**
528  * @tc.name: CheckWindowModeType03
529  * @tc.desc: CheckWindowModeType
530  * @tc.type: FUNC
531  */
532 HWTEST_F(SceneSessionManagerTest6, CheckWindowModeType03, Function | SmallTest | Level3)
533 {
534     DisplayId displayId = ScreenSessionManagerClient::GetInstance().GetDefaultScreenId();
535     SessionInfo sessionInfo;
536     sessionInfo.bundleName_ = "privacy.test.first";
537     sessionInfo.abilityName_ = "privacyAbilityName";
538     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
539     ASSERT_NE(nullptr, sceneSession);
540     ASSERT_NE(nullptr, sceneSession->property_);
541     sceneSession->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
542     sceneSession->property_->SetDisplayId(displayId);
543     sceneSession->isVisible_ = true;
544     sceneSession->state_ = SessionState::STATE_ACTIVE;
545     ASSERT_NE(nullptr, ssm_);
546     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
547     ASSERT_NE(nullptr, sceneSession);
548     ASSERT_NE(nullptr, sceneSession->property_);
549     sceneSession->property_->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_PRIMARY);
550     sceneSession->isVisible_ = true;
551     sceneSession->state_ = SessionState::STATE_ACTIVE;
552     ASSERT_NE(nullptr, ssm_);
553     auto ret = ssm_->CheckWindowModeType();
554     EXPECT_EQ(WindowModeType::WINDOW_MODE_SPLIT, ret);
555     ASSERT_NE(nullptr, sceneSession);
556     ASSERT_NE(nullptr, sceneSession->property_);
557     sceneSession->property_->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_SECONDARY);
558     ASSERT_NE(nullptr, ssm_);
559     ret = ssm_->CheckWindowModeType();
560     EXPECT_EQ(WindowModeType::WINDOW_MODE_SPLIT, ret);
561 }
562 
563 /**
564  * @tc.name: GetSceneSessionPrivacyModeBundles
565  * @tc.desc: GetSceneSessionPrivacyModeBundles
566  * @tc.type: FUNC
567  */
568 HWTEST_F(SceneSessionManagerTest6, GetSceneSessionPrivacyModeBundles, Function | SmallTest | Level3)
569 {
570     ASSERT_NE(nullptr, ssm_);
571     ssm_->sceneSessionMap_.clear();
572     DisplayId displayId = 0;
573     std::unordered_set<std::string> privacyBundles;
574     ssm_->GetSceneSessionPrivacyModeBundles(displayId, privacyBundles);
575     SessionInfo sessionInfoFirst;
576     sessionInfoFirst.bundleName_ = "";
577     sessionInfoFirst.abilityName_ = "privacyAbilityName";
578     sptr<SceneSession> sceneSessionFirst = sptr<SceneSession>::MakeSptr(sessionInfoFirst, nullptr);
579     ASSERT_NE(sceneSessionFirst, nullptr);
580     sceneSessionFirst->property_ = nullptr;
581     ASSERT_NE(nullptr, ssm_);
582     ssm_->GetSceneSessionPrivacyModeBundles(displayId, privacyBundles);
583     sceneSessionFirst->property_ = sptr<WindowSessionProperty>::MakeSptr();
584     ASSERT_NE(nullptr, sceneSessionFirst->property_);
585     sceneSessionFirst->property_->SetDisplayId(0);
586     ASSERT_NE(nullptr, ssm_);
587     ssm_->GetSceneSessionPrivacyModeBundles(displayId, privacyBundles);
588     sessionInfoFirst.bundleName_ = "privacy.test.first";
589     sceneSessionFirst->state_ = SessionState::STATE_FOREGROUND;
590     ASSERT_NE(nullptr, ssm_);
591     ssm_->GetSceneSessionPrivacyModeBundles(displayId, privacyBundles);
592     sceneSessionFirst->state_ = SessionState::STATE_CONNECT;
593     ASSERT_NE(nullptr, ssm_);
594     ssm_->GetSceneSessionPrivacyModeBundles(displayId, privacyBundles);
595 }
596 
597 /**
598  * @tc.name: GetSceneSessionPrivacyModeBundles01
599  * @tc.desc: GetSceneSessionPrivacyModeBundles
600  * @tc.type: FUNC
601  */
602 HWTEST_F(SceneSessionManagerTest6, GetSceneSessionPrivacyModeBundles01, Function | SmallTest | Level3)
603 {
604     DisplayId displayId = 0;
605     std::unordered_set<std::string> privacyBundles;
606     ssm_->GetSceneSessionPrivacyModeBundles(displayId, privacyBundles);
607     SessionInfo sessionInfoFirst;
608     sessionInfoFirst.bundleName_ = "privacy.test.first";
609     sessionInfoFirst.abilityName_ = "privacyAbilityName";
610     sptr<SceneSession> sceneSessionFirst = sptr<SceneSession>::MakeSptr(sessionInfoFirst, nullptr);
611     ASSERT_NE(sceneSessionFirst, nullptr);
612     sceneSessionFirst->property_ = sptr<WindowSessionProperty>::MakeSptr();
613     ASSERT_NE(nullptr, sceneSessionFirst->property_);
614     sceneSessionFirst->property_->SetDisplayId(0);
615     sceneSessionFirst->state_ = SessionState::STATE_ACTIVE;
616     ASSERT_NE(nullptr, ssm_);
617     SessionInfo sessionInfoSecond;
618     sessionInfoSecond.bundleName_ = "privacy.test.second";
619     sessionInfoSecond.abilityName_ = "privacyAbilityName";
620     sptr<SceneSession> sceneSessionSecond = sptr<SceneSession>::MakeSptr(sessionInfoSecond, nullptr);
621     ASSERT_NE(nullptr, sceneSessionSecond);
622     ssm_->sceneSessionMap_.insert({sceneSessionSecond->GetPersistentId(), sceneSessionSecond});
623     ASSERT_NE(nullptr, sceneSessionSecond->property_);
624     sceneSessionSecond->property_->displayId_ = 1;
625     sceneSessionSecond->state_ = SessionState::STATE_ACTIVE;
626     sceneSessionSecond->parentSession_ = sceneSessionFirst;
627     ASSERT_NE(nullptr, ssm_);
628     ssm_->GetSceneSessionPrivacyModeBundles(displayId, privacyBundles);
629     sceneSessionSecond->state_ = SessionState::STATE_FOREGROUND;
630     sceneSessionSecond->state_ = SessionState::STATE_CONNECT;
631     ASSERT_NE(nullptr, ssm_);
632     ssm_->GetSceneSessionPrivacyModeBundles(displayId, privacyBundles);
633 }
634 
635 /**
636  * @tc.name: GetSceneSessionPrivacyModeBundles02
637  * @tc.desc: GetSceneSessionPrivacyModeBundles
638  * @tc.type: FUNC
639  */
640 HWTEST_F(SceneSessionManagerTest6, GetSceneSessionPrivacyModeBundles02, Function | SmallTest | Level3)
641 {
642     DisplayId displayId = 0;
643     std::unordered_set<std::string> privacyBundles;
644     ASSERT_NE(nullptr, ssm_);
645     ssm_->GetSceneSessionPrivacyModeBundles(displayId, privacyBundles);
646     SessionInfo sessionInfoFirst;
647     sessionInfoFirst.bundleName_ = "privacy.test.first";
648     sessionInfoFirst.abilityName_ = "privacyAbilityName";
649     sptr<SceneSession> sceneSessionFirst = sptr<SceneSession>::MakeSptr(sessionInfoFirst, nullptr);
650     ASSERT_NE(sceneSessionFirst, nullptr);
651     sceneSessionFirst->property_ = sptr<WindowSessionProperty>::MakeSptr();
652     ASSERT_NE(nullptr, sceneSessionFirst->property_);
653     sceneSessionFirst->property_->SetDisplayId(0);
654     sceneSessionFirst->state_ = SessionState::STATE_ACTIVE;
655     sceneSessionFirst->property_->isPrivacyMode_ = false;
656     ASSERT_NE(nullptr, ssm_);
657     ssm_->GetSceneSessionPrivacyModeBundles(displayId, privacyBundles);
658 }
659 
660 /**
661  * @tc.name: RegisterWindowManagerAgent
662  * @tc.desc: RegisterWindowManagerAgent
663  * @tc.type: FUNC
664  */
665 HWTEST_F(SceneSessionManagerTest6, RegisterWindowManagerAgent, Function | SmallTest | Level3)
666 {
667     WindowManagerAgentType type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_SYSTEM_BAR;
668     sptr<IWindowManagerAgent> windowManagerAgent = nullptr;
669     ASSERT_NE(nullptr, ssm_);
670     auto ret = ssm_->RegisterWindowManagerAgent(type, windowManagerAgent);
671     EXPECT_EQ(WMError::WM_ERROR_NULLPTR, ret);
672     type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_GESTURE_NAVIGATION_ENABLED;
673     ASSERT_NE(nullptr, ssm_);
674     ret = ssm_->RegisterWindowManagerAgent(type, windowManagerAgent);
675     EXPECT_EQ(WMError::WM_ERROR_NULLPTR, ret);
676     type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WATER_MARK_FLAG;
677     ASSERT_NE(nullptr, ssm_);
678     ret = ssm_->RegisterWindowManagerAgent(type, windowManagerAgent);
679     EXPECT_EQ(WMError::WM_ERROR_NULLPTR, ret);
680     type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WINDOW_VISIBILITY;
681     ASSERT_NE(nullptr, ssm_);
682     ret = ssm_->RegisterWindowManagerAgent(type, windowManagerAgent);
683     EXPECT_EQ(WMError::WM_ERROR_INVALID_PERMISSION, ret);
684     type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WINDOW_DRAWING_STATE;
685     ASSERT_NE(nullptr, ssm_);
686     ret = ssm_->RegisterWindowManagerAgent(type, windowManagerAgent);
687     EXPECT_EQ(WMError::WM_ERROR_INVALID_PERMISSION, ret);
688     type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_VISIBLE_WINDOW_NUM;
689     ASSERT_NE(nullptr, ssm_);
690     ret = ssm_->RegisterWindowManagerAgent(type, windowManagerAgent);
691     EXPECT_EQ(WMError::WM_ERROR_INVALID_PERMISSION, ret);
692     type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_CAMERA_FLOAT;
693     ASSERT_NE(nullptr, ssm_);
694     ret = ssm_->RegisterWindowManagerAgent(type, windowManagerAgent);
695     EXPECT_EQ(WMError::WM_ERROR_NULLPTR, ret);
696 }
697 
698 /**
699  * @tc.name: OnSessionStateChange
700  * @tc.desc: OnSessionStateChange
701  * @tc.type: FUNC
702  */
703 HWTEST_F(SceneSessionManagerTest6, OnSessionStateChange, Function | SmallTest | Level3)
704 {
705     SessionState state = SessionState::STATE_FOREGROUND;
706     ASSERT_NE(nullptr, ssm_);
707     ssm_->sceneSessionMap_.clear();
708     ssm_->OnSessionStateChange(1, state);
709     SessionInfo sessionInfo;
710     sessionInfo.bundleName_ = "SceneSessionManagerTest2";
711     sessionInfo.abilityName_ = "DumpSessionWithId";
712     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
713     ASSERT_NE(nullptr, ssm_);
714     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
715     ASSERT_NE(nullptr, sceneSession);
716     ASSERT_NE(nullptr, sceneSession->property_);
717     sceneSession->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_END);
718     ASSERT_NE(nullptr, ssm_);
719     ssm_->OnSessionStateChange(1, state);
720     ssm_->focusedSessionId_ = 1;
721     ssm_->OnSessionStateChange(1, state);
722     sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
723     ASSERT_NE(nullptr, ssm_);
724     ssm_->needBlockNotifyFocusStatusUntilForeground_ = true;
725     ssm_->OnSessionStateChange(1, state);
726     ASSERT_NE(nullptr, ssm_);
727     ssm_->needBlockNotifyFocusStatusUntilForeground_ = false;
728     ssm_->OnSessionStateChange(1, state);
729     ssm_->focusedSessionId_ = 0;
730     ASSERT_NE(nullptr, ssm_);
731     ssm_->OnSessionStateChange(1, state);
732 }
733 
734 /**
735  * @tc.name: OnSessionStateChange01
736  * @tc.desc: OnSessionStateChange01
737  * @tc.type: FUNC
738  */
739 HWTEST_F(SceneSessionManagerTest6, OnSessionStateChange01, Function | SmallTest | Level3)
740 {
741     SessionState state = SessionState::STATE_BACKGROUND;
742     ASSERT_NE(nullptr, ssm_);
743     ssm_->sceneSessionMap_.clear();
744     SessionInfo sessionInfo;
745     sessionInfo.bundleName_ = "SceneSessionManagerTest2";
746     sessionInfo.abilityName_ = "DumpSessionWithId";
747     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
748     ASSERT_NE(nullptr, ssm_);
749     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
750     ASSERT_NE(nullptr, sceneSession);
751     ASSERT_NE(nullptr, sceneSession->property_);
752     sceneSession->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_END);
753     ASSERT_NE(nullptr, ssm_);
754     ssm_->OnSessionStateChange(1, state);
755     sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
756     ASSERT_NE(nullptr, ssm_);
757     ssm_->OnSessionStateChange(1, state);
758     state = SessionState::STATE_END;
759     ASSERT_NE(nullptr, ssm_);
760     ssm_->OnSessionStateChange(1, state);
761 }
762 
763 /**
764  * @tc.name: OnSessionStateChange02
765  * @tc.desc: OnSessionStateChange02
766  * @tc.type: FUNC
767  */
768 HWTEST_F(SceneSessionManagerTest6, OnSessionStateChange02, Function | SmallTest | Level3)
769 {
770     SessionState state = SessionState::STATE_FOREGROUND;
771     ASSERT_NE(nullptr, ssm_);
772     ssm_->sceneSessionMap_.clear();
773     SessionInfo sessionInfo;
774     sessionInfo.bundleName_ = "SceneSessionManagerTest2";
775     sessionInfo.abilityName_ = "DumpSessionWithId";
776     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
777     ASSERT_NE(nullptr, ssm_);
778     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
779     ASSERT_NE(nullptr, sceneSession);
780     ASSERT_NE(nullptr, sceneSession->property_);
781     sceneSession->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_END);
782     sceneSession->SetFocusedOnShow(true);
783     ASSERT_NE(nullptr, ssm_);
784     ssm_->OnSessionStateChange(1, state);
785     sceneSession->SetFocusedOnShow(false);
786     ASSERT_NE(nullptr, ssm_);
787     ssm_->OnSessionStateChange(1, state);
788 }
789 
790 /**
791  * @tc.name: SetWindowFlags
792  * @tc.desc: SetWindowFlags
793  * @tc.type: FUNC
794  */
795 HWTEST_F(SceneSessionManagerTest6, SetWindowFlags, Function | SmallTest | Level3)
796 {
797     SessionInfo sessionInfo;
798     sessionInfo.bundleName_ = "SceneSessionManagerTest2";
799     sessionInfo.abilityName_ = "DumpSessionWithId";
800     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
801     sptr<WindowSessionProperty> property = nullptr;
802     sceneSession->property_ = nullptr;
803     ASSERT_NE(nullptr, ssm_);
804     auto ret = ssm_->SetWindowFlags(sceneSession, property);
805     EXPECT_EQ(WSError::WS_ERROR_NULLPTR, ret);
806 }
807 
808 /**
809  * @tc.name: ProcessSubSessionForeground
810  * @tc.desc: ProcessSubSessionForeground
811  * @tc.type: FUNC
812  */
813 HWTEST_F(SceneSessionManagerTest6, ProcessSubSessionForeground, Function | SmallTest | Level3)
814 {
815     sptr<SceneSession> sceneSession = nullptr;
816     ASSERT_NE(nullptr, ssm_);
817     ssm_->ProcessSubSessionForeground(sceneSession);
818     SessionInfo sessionInfo;
819     sessionInfo.bundleName_ = "SceneSessionManagerTest2";
820     sessionInfo.abilityName_ = "DumpSessionWithId";
821     sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
822     ASSERT_NE(nullptr, sceneSession);
823     ASSERT_NE(nullptr, ssm_);
824     ssm_->ProcessSubSessionForeground(sceneSession);
825     sptr<SceneSession> subSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
826     ASSERT_NE(nullptr, sceneSession);
827     ASSERT_NE(nullptr, subSession);
828     sceneSession->AddSubSession(subSession);
829     ASSERT_NE(nullptr, ssm_);
830     ssm_->ProcessSubSessionForeground(sceneSession);
831     ASSERT_NE(nullptr, subSession);
832     subSession->SetSessionState(SessionState::STATE_FOREGROUND);
833     ASSERT_NE(nullptr, ssm_);
834     ssm_->ProcessSubSessionForeground(sceneSession);
835     ASSERT_NE(nullptr, subSession);
836     subSession->SetSessionState(SessionState::STATE_ACTIVE);
837     ASSERT_NE(nullptr, ssm_);
838     ssm_->ProcessSubSessionForeground(sceneSession);
839     ASSERT_NE(nullptr, subSession);
840     subSession->SetSessionState(SessionState::STATE_INACTIVE);
841     ASSERT_NE(nullptr, ssm_);
842     ssm_->ProcessSubSessionForeground(sceneSession);
843 }
844 
845 /**
846  * @tc.name: ProcessModalTopmostRequestFocusImmdediately
847  * @tc.desc: ProcessModalTopmostRequestFocusImmdediately
848  * @tc.type: FUNC
849  */
850 HWTEST_F(SceneSessionManagerTest6, ProcessModalTopmostRequestFocusImmdediately, Function | SmallTest | Level3)
851 {
852     SessionInfo sessionInfo;
853     sessionInfo.bundleName_ = "SceneSessionManagerTest2";
854     sessionInfo.abilityName_ = "DumpSessionWithId";
855     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
856     ASSERT_NE(nullptr, sceneSession->property_);
857     sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
858     ASSERT_NE(nullptr, ssm_);
859     auto ret = ssm_->ProcessModalTopmostRequestFocusImmdediately(sceneSession);
860     EXPECT_EQ(WSError::WS_DO_NOTHING, ret);
861     ASSERT_NE(nullptr, sceneSession->property_);
862     sceneSession->property_->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
863     ASSERT_NE(nullptr, ssm_);
864     ret = ssm_->ProcessModalTopmostRequestFocusImmdediately(sceneSession);
865     EXPECT_EQ(WSError::WS_DO_NOTHING, ret);
866     ASSERT_NE(nullptr, sceneSession->property_);
867     sceneSession->property_->SetWindowType(WindowType::APP_SUB_WINDOW_END);
868     ASSERT_NE(nullptr, ssm_);
869     ret = ssm_->ProcessModalTopmostRequestFocusImmdediately(sceneSession);
870     EXPECT_EQ(WSError::WS_DO_NOTHING, ret);
871 }
872 
873 /**
874  * @tc.name: GetAbilityInfosFromBundleInfo
875  * @tc.desc: GetAbilityInfosFromBundleInfo
876  * @tc.type: FUNC
877  */
878 HWTEST_F(SceneSessionManagerTest6, GetAbilityInfosFromBundleInfo, Function | SmallTest | Level3)
879 {
880     std::vector<AppExecFwk::BundleInfo> bundleInfos;
881     std::vector<SCBAbilityInfo> scbAbilityInfos;
882     ASSERT_NE(nullptr, ssm_);
883     auto ret = ssm_->GetAbilityInfosFromBundleInfo(bundleInfos, scbAbilityInfos);
884     EXPECT_EQ(WSError::WS_ERROR_INVALID_PARAM, ret);
885     OHOS::AppExecFwk::BundleInfo bundleInfo;
886     bundleInfo.name = "com.ix.residentservcie";
887     bundleInfo.isKeepAlive = true;
888     bundleInfo.applicationInfo.process = "com.ix.residentservcie";
889     OHOS::AppExecFwk::HapModuleInfo hapModuleInfo;
890     hapModuleInfo.isModuleJson = true;
891     hapModuleInfo.mainElementName = "residentServiceAbility";
892     hapModuleInfo.process = "com.ix.residentservcie";
893     bundleInfo.hapModuleInfos.emplace_back(hapModuleInfo);
894     bundleInfos.emplace_back(bundleInfo);
895     ASSERT_NE(nullptr, ssm_);
896     ret = ssm_->GetAbilityInfosFromBundleInfo(bundleInfos, scbAbilityInfos);
897     EXPECT_EQ(WSError::WS_OK, ret);
898 }
899 
900 /**
901  * @tc.name: GetOrientationFromResourceManager
902  * @tc.desc: GetOrientationFromResourceManager
903  * @tc.type: FUNC
904  */
905 HWTEST_F(SceneSessionManagerTest6, GetOrientationFromResourceManager, Function | SmallTest | Level3)
906 {
907     ASSERT_NE(nullptr, ssm_);
908     OHOS::AppExecFwk::AbilityInfo abilityInfo;
909     abilityInfo.bundleName = "testBundleName";
910     abilityInfo.moduleName = "testModuleName";
911     abilityInfo.orientationId = 123456;
912     ssm_->GetOrientationFromResourceManager(abilityInfo);
913     EXPECT_EQ(OHOS::AppExecFwk::DisplayOrientation::UNSPECIFIED, abilityInfo.orientation);
914 }
915 
916 /**
917  * @tc.name: NotifyCompleteFirstFrameDrawing
918  * @tc.desc: NotifyCompleteFirstFrameDrawing
919  * @tc.type: FUNC
920  */
921 HWTEST_F(SceneSessionManagerTest6, NotifyCompleteFirstFrameDrawing, Function | SmallTest | Level3)
922 {
923     ASSERT_NE(nullptr, ssm_);
924     ssm_->sceneSessionMap_.clear();
925     SessionInfo sessionInfo;
926     sessionInfo.bundleName_ = "SceneSessionManagerTest2";
927     sessionInfo.abilityName_ = "DumpSessionWithId";
928     sessionInfo.abilityInfo = nullptr;
929     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
930     ASSERT_NE(nullptr, ssm_);
931     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
932     ASSERT_NE(nullptr, ssm_);
933     ssm_->NotifyCompleteFirstFrameDrawing(1);
934     sessionInfo.abilityInfo = std::make_shared<AppExecFwk::AbilityInfo>();
935     ASSERT_NE(nullptr, sessionInfo.abilityInfo);
936     ASSERT_NE(nullptr, ssm_);
937     ssm_->eventHandler_ = nullptr;
938     ssm_->NotifyCompleteFirstFrameDrawing(1);
939     ssm_->eventHandler_ = std::make_shared<AppExecFwk::EventHandler>();
940     ASSERT_NE(nullptr, ssm_->eventHandler_);
941     ASSERT_NE(nullptr, ssm_);
942     ssm_->NotifyCompleteFirstFrameDrawing(1);
943     ASSERT_NE(nullptr, ssm_);
944     ssm_->taskScheduler_ = nullptr;
945     ssm_->NotifyCompleteFirstFrameDrawing(1);
946     ssm_->taskScheduler_ = std::make_shared<TaskScheduler>("OS_SceneSessionManager");
947     ASSERT_NE(nullptr, ssm_->taskScheduler_);
948     ASSERT_NE(nullptr, ssm_);
949     ssm_->NotifyCompleteFirstFrameDrawing(1);
950 }
951 
952 /**
953  * @tc.name: NotifyCompleteFirstFrameDrawing02
954  * @tc.desc: NotifyCompleteFirstFrameDrawing02:AtomicService free-install start.
955  * @tc.type: FUNC
956  */
957 HWTEST_F(SceneSessionManagerTest6, NotifyCompleteFirstFrameDrawing02, Function | SmallTest | Level3)
958 {
959     ASSERT_NE(nullptr, ssm_);
960     ssm_->sceneSessionMap_.clear();
961     SessionInfo sessionInfo;
962     sessionInfo.bundleName_ = "SceneSessionManagerTest2";
963     sessionInfo.abilityName_ = "DumpSessionWithId";
964     sessionInfo.abilityInfo = nullptr;
965     sessionInfo.isAtomicService_ = true;
966     sessionInfo.isBackTransition_ = false;
967     unsigned int flags = 11111111;
968     sessionInfo.want = std::make_shared<AAFwk::Want>();
969     ASSERT_NE(nullptr, sessionInfo.want);
970     sessionInfo.want->SetFlags(flags);
971     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
972     ASSERT_NE(nullptr, sceneSession);
973     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
974     ssm_->NotifyCompleteFirstFrameDrawing(1);
975     ASSERT_EQ(nullptr, sessionInfo.abilityInfo);
976 }
977 
978 /**
979  * @tc.name: InitSceneSession01
980  * @tc.desc: InitSceneSession01:AtomicService free-install start.
981  * @tc.type: FUNC
982  */
983 HWTEST_F(SceneSessionManagerTest6, InitSceneSession01, Function | SmallTest | Level3)
984 {
985     ASSERT_NE(nullptr, ssm_);
986     ssm_->sceneSessionMap_.clear();
987     SessionInfo sessionInfo;
988     sessionInfo.bundleName_ = "SceneSessionManagerTest2";
989     sessionInfo.abilityName_ = "DumpSessionWithId";
990     sessionInfo.abilityInfo = nullptr;
991     sessionInfo.isAtomicService_ = true;
992     sessionInfo.isBackTransition_ = false;
993     unsigned int flags = 11111111;
994     sessionInfo.want = std::make_shared<AAFwk::Want>();
995     ASSERT_NE(nullptr, sessionInfo.want);
996     sessionInfo.want->SetFlags(flags);
997     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
998     ASSERT_NE(nullptr, sceneSession);
999     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
1000     ssm_->InitSceneSession(sceneSession, sessionInfo, nullptr);
1001     ASSERT_EQ(nullptr, sessionInfo.abilityInfo);
1002 }
1003 
1004 /**
1005  * @tc.name: CheckAndNotifyWaterMarkChangedResult
1006  * @tc.desc: CheckAndNotifyWaterMarkChangedResult
1007  * @tc.type: FUNC
1008  */
1009 HWTEST_F(SceneSessionManagerTest6, CheckAndNotifyWaterMarkChangedResult, Function | SmallTest | Level3)
1010 {
1011     ASSERT_NE(nullptr, ssm_);
1012     ssm_->sceneSessionMap_.clear();
1013     ssm_->CheckAndNotifyWaterMarkChangedResult();
1014     SessionInfo sessionInfo;
1015     sessionInfo.bundleName_ = "SceneSessionManagerTest2";
1016     sessionInfo.abilityName_ = "DumpSessionWithId";
1017     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1018     ASSERT_NE(nullptr, sceneSession);
1019     sceneSession->property_ = nullptr;
1020     ASSERT_NE(nullptr, ssm_);
1021     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
1022     sceneSession->property_ = sptr<WindowSessionProperty>::MakeSptr();
1023     ASSERT_NE(nullptr, sceneSession->property_);
1024     sceneSession->property_->flags_ = 1 << 4;
1025     sceneSession->isRSVisible_ = true;
1026     sceneSession->combinedExtWindowFlags_.waterMarkFlag = true;
1027     ASSERT_NE(nullptr, ssm_);
1028     ssm_->CheckAndNotifyWaterMarkChangedResult();
1029     sceneSession->isRSVisible_ = false;
1030     ASSERT_NE(nullptr, ssm_);
1031     ssm_->CheckAndNotifyWaterMarkChangedResult();
1032     sceneSession->property_->flags_ = 0;
1033     sceneSession->isRSVisible_ = false;
1034     ASSERT_NE(nullptr, ssm_);
1035     ssm_->CheckAndNotifyWaterMarkChangedResult();
1036     sceneSession->isRSVisible_ = true;
1037     ASSERT_NE(nullptr, ssm_);
1038     ssm_->CheckAndNotifyWaterMarkChangedResult();
1039 }
1040 
1041 /**
1042  * @tc.name: CheckAndNotifyWaterMarkChangedResult01
1043  * @tc.desc: CheckAndNotifyWaterMarkChangedResult01
1044  * @tc.type: FUNC
1045  */
1046 HWTEST_F(SceneSessionManagerTest6, CheckAndNotifyWaterMarkChangedResult01, Function | SmallTest | Level3)
1047 {
1048     ASSERT_NE(nullptr, ssm_);
1049     ssm_->sceneSessionMap_.clear();
1050     SessionInfo sessionInfo;
1051     sessionInfo.bundleName_ = "SceneSessionManagerTest2";
1052     sessionInfo.abilityName_ = "DumpSessionWithId";
1053     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1054     ASSERT_NE(nullptr, sceneSession);
1055     ASSERT_NE(nullptr, ssm_);
1056     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
1057     sceneSession->property_ = sptr<WindowSessionProperty>::MakeSptr();
1058     ASSERT_NE(nullptr, sceneSession->property_);
1059     sceneSession->property_->flags_ = 1 << 4;
1060     sceneSession->isRSVisible_ = true;
1061     sceneSession->combinedExtWindowFlags_.waterMarkFlag = false;
1062     ASSERT_NE(nullptr, ssm_);
1063     ssm_->CheckAndNotifyWaterMarkChangedResult();
1064     sceneSession->isRSVisible_ = false;
1065     ASSERT_NE(nullptr, ssm_);
1066     ssm_->CheckAndNotifyWaterMarkChangedResult();
1067     sceneSession->property_->flags_ = 0;
1068     sceneSession->isRSVisible_ = false;
1069     ASSERT_NE(nullptr, ssm_);
1070     ssm_->CheckAndNotifyWaterMarkChangedResult();
1071     sceneSession->isRSVisible_ = true;
1072     ASSERT_NE(nullptr, ssm_);
1073     ssm_->CheckAndNotifyWaterMarkChangedResult();
1074 }
1075 
1076 /**
1077  * @tc.name: CheckAndNotifyWaterMarkChangedResult02
1078  * @tc.desc: CheckAndNotifyWaterMarkChangedResult02
1079  * @tc.type: FUNC
1080  */
1081 HWTEST_F(SceneSessionManagerTest6, CheckAndNotifyWaterMarkChangedResult02, Function | SmallTest | Level3)
1082 {
1083     ASSERT_NE(nullptr, ssm_);
1084     ssm_->sceneSessionMap_.clear();
1085     ssm_->lastWaterMarkShowState_ = true;
1086     ssm_->CheckAndNotifyWaterMarkChangedResult();
1087     ASSERT_NE(nullptr, ssm_);
1088     ssm_->lastWaterMarkShowState_ = false;
1089     ssm_->CheckAndNotifyWaterMarkChangedResult();
1090 }
1091 
1092 /**
1093  * @tc.name: FillWindowInfo
1094  * @tc.desc: FillWindowInfo
1095  * @tc.type: FUNC
1096  */
1097 HWTEST_F(SceneSessionManagerTest6, FillWindowInfo, Function | SmallTest | Level3)
1098 {
1099     std::vector<sptr<AccessibilityWindowInfo>> infos;
1100     sptr<SceneSession> sceneSession = nullptr;
1101     ASSERT_NE(nullptr, ssm_);
1102     auto ret = ssm_->FillWindowInfo(infos, sceneSession);
1103     EXPECT_EQ(false, ret);
1104     SessionInfo sessionInfo;
1105     sessionInfo.bundleName_ = "SceneSessionManagerTest2";
1106     sessionInfo.abilityName_ = "DumpSessionWithId";
1107     sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1108     ASSERT_NE(nullptr, ssm_);
1109     ASSERT_NE(nullptr, sceneSession);
1110     ret = ssm_->FillWindowInfo(infos, sceneSession);
1111     EXPECT_EQ(true, ret);
1112     sessionInfo.bundleName_ = "SCBGestureBack";
1113     sessionInfo.isSystem_ = true;
1114     ASSERT_NE(nullptr, ssm_);
1115     ret = ssm_->FillWindowInfo(infos, sceneSession);
1116     EXPECT_EQ(true, ret);
1117     sessionInfo.isSystem_ = false;
1118     ASSERT_NE(nullptr, ssm_);
1119     ret = ssm_->FillWindowInfo(infos, sceneSession);
1120     EXPECT_EQ(true, ret);
1121     sceneSession->property_ = nullptr;
1122     ASSERT_NE(nullptr, ssm_);
1123     ret = ssm_->FillWindowInfo(infos, sceneSession);
1124     EXPECT_EQ(true, ret);
1125     sceneSession->property_ = sptr<WindowSessionProperty>::MakeSptr();
1126     ASSERT_NE(nullptr, sceneSession->property_);
1127     ASSERT_NE(nullptr, ssm_);
1128     ret = ssm_->FillWindowInfo(infos, sceneSession);
1129     EXPECT_EQ(true, ret);
1130 }
1131 
1132 /**
1133  * @tc.name: SetSessionVisibilityInfo
1134  * @tc.desc: SetSessionVisibilityInfo
1135  * @tc.type: FUNC
1136  */
1137 HWTEST_F(SceneSessionManagerTest6, SetSessionVisibilityInfo, Function | SmallTest | Level3)
1138 {
1139     sptr<SceneSession> session = nullptr;
1140     WindowVisibilityState visibleState = WindowVisibilityState::WINDOW_VISIBILITY_STATE_NO_OCCLUSION;
1141     std::vector<sptr<WindowVisibilityInfo>> windowVisibilityInfos;
1142     std::string visibilityInfo = "";
1143     ASSERT_NE(nullptr, ssm_);
1144     ssm_->SetSessionVisibilityInfo(session, visibleState, windowVisibilityInfos, visibilityInfo);
1145     SessionInfo sessionInfo;
1146     sessionInfo.bundleName_ = "SceneSessionManagerTest2";
1147     sessionInfo.abilityName_ = "DumpSessionWithId";
1148     session = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1149     ASSERT_NE(nullptr, ssm_);
1150     ASSERT_NE(nullptr, session);
1151     session->persistentId_ = 1;
1152     ssm_->windowVisibilityListenerSessionSet_.clear();
1153     ssm_->SetSessionVisibilityInfo(session, visibleState, windowVisibilityInfos, visibilityInfo);
1154     ssm_->windowVisibilityListenerSessionSet_.insert(1);
1155     ssm_->SetSessionVisibilityInfo(session, visibleState, windowVisibilityInfos, visibilityInfo);
1156 }
1157 
1158 /**
1159  * @tc.name: SendTouchEvent
1160  * @tc.desc: SendTouchEvent
1161  * @tc.type: FUNC
1162  */
1163 HWTEST_F(SceneSessionManagerTest6, SendTouchEvent, Function | SmallTest | Level3)
1164 {
1165     std::shared_ptr<MMI::PointerEvent> pointerEvent = nullptr;
1166     ASSERT_NE(nullptr, ssm_);
1167     auto ret = ssm_->SendTouchEvent(pointerEvent, 0);
1168     EXPECT_EQ(WSError::WS_ERROR_NULLPTR, ret);
1169     MMI::PointerEvent::PointerItem pointerItem;
1170     pointerItem.pointerId_ = 0;
1171     pointerEvent = MMI::PointerEvent::Create();
1172     ASSERT_NE(nullptr, pointerEvent);
1173     pointerEvent->pointerId_ = 0;
1174     pointerEvent->AddPointerItem(pointerItem);
1175     ASSERT_NE(nullptr, ssm_);
1176     ret = ssm_->SendTouchEvent(pointerEvent, 0);
1177     EXPECT_EQ(WSError::WS_OK, ret);
1178     pointerEvent->pointerId_ = 1;
1179     ASSERT_NE(nullptr, ssm_);
1180     ret = ssm_->SendTouchEvent(pointerEvent, 0);
1181     EXPECT_EQ(WSError::WS_ERROR_INVALID_PARAM, ret);
1182     ASSERT_NE(nullptr, ssm_);
1183     ssm_->RegisterWindowChanged(WindowChangedFuncTest);
1184 }
1185 
1186 /**
1187  * @tc.name: JudgeNeedNotifyPrivacyInfo
1188  * @tc.desc: JudgeNeedNotifyPrivacyInfo
1189  * @tc.type: FUNC
1190  */
1191 HWTEST_F(SceneSessionManagerTest6, JudgeNeedNotifyPrivacyInfo, Function | SmallTest | Level3)
1192 {
1193     DisplayId displayId = 1;
1194     std::unordered_set<std::string> privacyBundles;
1195     ASSERT_NE(nullptr, ssm_);
1196     auto ret = ssm_->JudgeNeedNotifyPrivacyInfo(displayId, privacyBundles);
1197     EXPECT_EQ(true, ret);
1198     privacyBundles.insert("bundle1");
1199     ASSERT_NE(nullptr, ssm_);
1200     ret = ssm_->JudgeNeedNotifyPrivacyInfo(displayId, privacyBundles);
1201     EXPECT_EQ(true, ret);
1202     std::unordered_set<std::string> privacyBundles1;
1203     privacyBundles1.insert("bundle2");
1204     ASSERT_NE(nullptr, ssm_);
1205     ssm_->privacyBundleMap_.insert({displayId, privacyBundles1});
1206     ret = ssm_->JudgeNeedNotifyPrivacyInfo(displayId, privacyBundles);
1207     EXPECT_EQ(true, ret);
1208     privacyBundles.insert("bundle2");
1209     ASSERT_NE(nullptr, ssm_);
1210     ret = ssm_->JudgeNeedNotifyPrivacyInfo(displayId, privacyBundles);
1211     EXPECT_EQ(true, ret);
1212     ASSERT_NE(nullptr, ssm_);
1213     ssm_->InitPersistentStorage();
1214     ASSERT_NE(nullptr, ssm_);
1215     ssm_->UpdateCameraFloatWindowStatus(0, true);
1216     ASSERT_NE(nullptr, ssm_);
1217     ssm_->UpdateCameraWindowStatus(0, true);
1218 }
1219 
1220 /**
1221  * @tc.name: UpdatePrivateStateAndNotify
1222  * @tc.desc: UpdatePrivateStateAndNotify
1223  * @tc.type: FUNC
1224  */
1225 HWTEST_F(SceneSessionManagerTest6, UpdatePrivateStateAndNotify, Function | SmallTest | Level3)
1226 {
1227     ASSERT_NE(nullptr, ssm_);
1228     ssm_->sceneSessionMap_.clear();
1229     ssm_->UpdatePrivateStateAndNotify(0);
1230     SessionInfo sessionInfo;
1231     sessionInfo.bundleName_ = "SceneSessionManagerTest2";
1232     sessionInfo.abilityName_ = "DumpSessionWithId";
1233     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1234     ASSERT_NE(nullptr, sceneSession);
1235     ASSERT_NE(nullptr, ssm_);
1236     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
1237     sceneSession->property_ = nullptr;
1238     ASSERT_NE(nullptr, ssm_);
1239     ssm_->UpdatePrivateStateAndNotify(1);
1240     ASSERT_NE(nullptr, ssm_);
1241     ssm_->UpdatePrivateStateAndNotifyForAllScreens();
1242 }
1243 
1244 /**
1245  * @tc.name: GetCollaboratorByType
1246  * @tc.desc: GetCollaboratorByType
1247  * @tc.type: FUNC
1248  */
1249 HWTEST_F(SceneSessionManagerTest6, GetCollaboratorByType, Function | SmallTest | Level3)
1250 {
1251     ASSERT_NE(nullptr, ssm_);
1252     ssm_->collaboratorMap_.clear();
1253     auto ret = ssm_->GetCollaboratorByType(0);
1254     EXPECT_EQ(nullptr, ret);
1255     sptr<AAFwk::IAbilityManagerCollaborator> collaborator = nullptr;
1256     ASSERT_NE(nullptr, ssm_);
1257     ssm_->collaboratorMap_.insert(std::make_pair(1, collaborator));
1258     ret = ssm_->GetCollaboratorByType(1);
1259     EXPECT_EQ(nullptr, ret);
1260 }
1261 
1262 /**
1263  * @tc.name: RegisterGetStateFromManagerFunc
1264  * @tc.desc: RegisterGetStateFromManagerFunc
1265  * @tc.type: FUNC
1266  */
1267 HWTEST_F(SceneSessionManagerTest6, RegisterGetStateFromManagerFunc, Function | SmallTest | Level3)
1268 {
1269     SessionInfo sessionInfo;
1270     sessionInfo.bundleName_ = "SceneSessionManagerTest2";
1271     sessionInfo.abilityName_ = "DumpSessionWithId";
1272     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1273     ASSERT_NE(nullptr, ssm_);
1274     ASSERT_NE(nullptr, sceneSession);
1275     ssm_->RegisterGetStateFromManagerFunc(sceneSession);
1276     sceneSession = nullptr;
1277     ASSERT_NE(nullptr, ssm_);
1278     ssm_->RegisterGetStateFromManagerFunc(sceneSession);
1279 }
1280 
1281 /**
1282  * @tc.name: ProcessDialogRequestFocusImmdediately
1283  * @tc.desc: ProcessDialogRequestFocusImmdediately
1284  * @tc.type: FUNC
1285  */
1286 HWTEST_F(SceneSessionManagerTest6, ProcessDialogRequestFocusImmdediately, Function | SmallTest | Level3)
1287 {
1288     SessionInfo sessionInfo;
1289     sessionInfo.bundleName_ = "SceneSessionManagerTest2";
1290     sessionInfo.abilityName_ = "DumpSessionWithId";
1291     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1292     ASSERT_NE(nullptr, sceneSession->property_);
1293     sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
1294     ASSERT_NE(nullptr, ssm_);
1295     auto ret = ssm_->ProcessDialogRequestFocusImmdediately(sceneSession);
1296     EXPECT_EQ(WSError::WS_DO_NOTHING, ret);
1297     ASSERT_NE(nullptr, sceneSession->property_);
1298     sceneSession->property_->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
1299     ASSERT_NE(nullptr, ssm_);
1300     ret = ssm_->ProcessDialogRequestFocusImmdediately(sceneSession);
1301     EXPECT_EQ(WSError::WS_DO_NOTHING, ret);
1302     ASSERT_NE(nullptr, sceneSession->property_);
1303     sceneSession->property_->SetWindowType(WindowType::APP_SUB_WINDOW_END);
1304     ASSERT_NE(nullptr, ssm_);
1305     ret = ssm_->ProcessDialogRequestFocusImmdediately(sceneSession);
1306     EXPECT_EQ(WSError::WS_DO_NOTHING, ret);
1307 }
1308 
1309 /**
1310  * @tc.name: ProcessSubSessionBackground
1311  * @tc.desc: ProcessSubSessionBackground
1312  * @tc.type: FUNC
1313  */
1314 HWTEST_F(SceneSessionManagerTest6, ProcessSubSessionBackground, Function | SmallTest | Level3)
1315 {
1316     sptr<SceneSession> sceneSession = nullptr;
1317     ASSERT_NE(nullptr, ssm_);
1318     ssm_->ProcessSubSessionBackground(sceneSession);
1319     SessionInfo sessionInfo;
1320     sessionInfo.bundleName_ = "SceneSessionManagerTest2";
1321     sessionInfo.abilityName_ = "DumpSessionWithId";
1322     sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1323     ASSERT_NE(nullptr, sceneSession);
1324     ASSERT_NE(nullptr, ssm_);
1325     ssm_->ProcessSubSessionBackground(sceneSession);
1326     sptr<SceneSession> subSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1327     ASSERT_NE(nullptr, sceneSession);
1328     ASSERT_NE(nullptr, subSession);
1329     sceneSession->AddSubSession(subSession);
1330     subSession->state_ = SessionState::STATE_FOREGROUND;
1331     ASSERT_NE(nullptr, ssm_);
1332     ssm_->ProcessSubSessionBackground(sceneSession);
1333     ASSERT_NE(nullptr, subSession);
1334     subSession->state_ = SessionState::STATE_ACTIVE;
1335     ASSERT_NE(nullptr, ssm_);
1336     ssm_->ProcessSubSessionBackground(sceneSession);
1337     ASSERT_NE(nullptr, subSession);
1338     subSession->state_ = SessionState::STATE_INACTIVE;
1339     ASSERT_NE(nullptr, ssm_);
1340     ssm_->ProcessSubSessionBackground(sceneSession);
1341 }
1342 
1343 /**
1344  * @tc.name: ProcessSubSessionBackground01
1345  * @tc.desc: ProcessSubSessionBackground01
1346  * @tc.type: FUNC
1347  */
1348 HWTEST_F(SceneSessionManagerTest6, ProcessSubSessionBackground01, Function | SmallTest | Level3)
1349 {
1350     SessionInfo sessionInfo;
1351     sessionInfo.bundleName_ = "SceneSessionManagerTest2";
1352     sessionInfo.abilityName_ = "DumpSessionWithId";
1353     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1354     ASSERT_NE(nullptr, sceneSession);
1355     sceneSession->dialogVec_.clear();
1356     ASSERT_NE(nullptr, ssm_);
1357     ssm_->ProcessSubSessionBackground(sceneSession);
1358     sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1359     ASSERT_NE(nullptr, sceneSession1);
1360     ASSERT_NE(nullptr, sceneSession);
1361     sceneSession->dialogVec_.push_back(sceneSession1);
1362     ASSERT_NE(nullptr, ssm_);
1363     ssm_->sceneSessionMap_.clear();
1364     sceneSession1->persistentId_ = 1;
1365     ssm_->sceneSessionMap_.insert(std::make_pair(0, sceneSession));
1366     ssm_->ProcessSubSessionBackground(sceneSession);
1367     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
1368     ssm_->ProcessSubSessionBackground(sceneSession);
1369     sptr<SceneSession> toastSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1370     ASSERT_NE(nullptr, toastSession);
1371     ASSERT_NE(nullptr, sceneSession);
1372     sceneSession->AddToastSession(toastSession);
1373     toastSession->state_ = SessionState::STATE_FOREGROUND;
1374     ASSERT_NE(nullptr, ssm_);
1375     ssm_->ProcessSubSessionBackground(sceneSession);
1376     toastSession->state_ = SessionState::STATE_ACTIVE;
1377     ssm_->ProcessSubSessionBackground(sceneSession);
1378     toastSession->state_ = SessionState::STATE_INACTIVE;
1379     ssm_->ProcessSubSessionBackground(sceneSession);
1380 }
1381 
1382 /**
1383  * @tc.name: IsValidSessionIds
1384  * @tc.desc: IsValidSessionIds
1385  * @tc.type: FUNC
1386  */
1387 HWTEST_F(SceneSessionManagerTest6, IsValidSessionIds, Function | SmallTest | Level3)
1388 {
1389     std::vector<int32_t> sessionIds = {1, 2, 3, 4};
1390     std::vector<bool> results;
1391     results.clear();
1392     SessionInfo sessionInfo;
1393     sessionInfo.bundleName_ = "SceneSessionManagerTest2";
1394     sessionInfo.abilityName_ = "DumpSessionWithId";
1395     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1396     ASSERT_NE(nullptr, sceneSession);
1397     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
1398     sptr<SceneSession> sceneSession1 = nullptr;
1399     ASSERT_NE(nullptr, ssm_);
1400     ssm_->sceneSessionMap_.insert(std::make_pair(2, sceneSession1));
1401     ssm_->IsValidSessionIds(sessionIds, results);
1402     EXPECT_FALSE(results.empty());
1403     DisplayChangeListener listener;
1404     std::vector<uint64_t> missionIds;
1405     std::vector<uint64_t> surfaceNodeIds;
1406     listener.OnGetSurfaceNodeIdsFromMissionIds(missionIds, surfaceNodeIds);
1407 }
1408 
1409 /**
1410  * @tc.name: DeleteStateDetectTask
1411  * @tc.desc: DeleteStateDetectTask
1412  * @tc.type: FUNC
1413  */
1414 HWTEST_F(SceneSessionManagerTest6, DeleteStateDetectTask, Function | SmallTest | Level3)
1415 {
1416     ASSERT_NE(nullptr, ssm_);
1417     ssm_->SetScreenLocked(true);
1418     EXPECT_EQ(true, ssm_->isScreenLocked_);
1419     ssm_->sceneSessionMap_.clear();
1420     ASSERT_NE(nullptr, ssm_);
1421     ssm_->DeleteStateDetectTask();
1422     SessionInfo sessionInfo;
1423     sessionInfo.bundleName_ = "SceneSessionManagerTest2";
1424     sessionInfo.abilityName_ = "DumpSessionWithId";
1425     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1426     ASSERT_NE(nullptr, sceneSession);
1427     sceneSession->detectTaskInfo_.taskState = DetectTaskState::NO_TASK;
1428     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
1429     ASSERT_NE(nullptr, ssm_);
1430     ssm_->DeleteStateDetectTask();
1431     sceneSession->detectTaskInfo_.taskState = DetectTaskState::ATTACH_TASK;
1432     ASSERT_NE(nullptr, ssm_);
1433     ssm_->DeleteStateDetectTask();
1434 }
1435 
1436 /**
1437  * @tc.name: GetWindowStyleType
1438  * @tc.desc: GetWindowStyleType
1439  * @tc.type: FUNC
1440  */
1441 HWTEST_F(SceneSessionManagerTest6, GetWindowStyleType, Function | SmallTest | Level3)
1442 {
1443     ASSERT_NE(nullptr, ssm_);
1444     WindowStyleType windowModeType = Rosen::WindowStyleType::WINDOW_STYLE_DEFAULT;
1445     ssm_->GetWindowStyleType(windowModeType);
1446     ASSERT_EQ(windowModeType, Rosen::WindowStyleType::WINDOW_STYLE_DEFAULT);
1447 }
1448 
1449 /**
1450  * @tc.name: TerminateSessionByPersistentId
1451  * @tc.desc: Success to terminate session by persistentId.
1452  * @tc.type: FUNC
1453  */
1454 HWTEST_F(SceneSessionManagerTest6, TerminateSessionByPersistentId001, Function | SmallTest | Level3)
1455 {
1456     SessionInfo info;
1457     info.abilityName_ = "test1";
1458     info.bundleName_ = "test1";
1459     info.windowType_ = static_cast<uint32_t>(WindowType::APP_WINDOW_BASE);
1460     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1461     ASSERT_NE(nullptr, sceneSession);
1462     ASSERT_NE(nullptr, ssm_);
1463     ssm_->sceneSessionMap_.insert(std::make_pair(sceneSession->GetPersistentId(), sceneSession));
1464     auto result = ssm_->TerminateSessionByPersistentId(sceneSession->GetPersistentId());
1465     EXPECT_EQ(result, WMError::WM_ERROR_INVALID_PERMISSION);
1466 }
1467 
1468 /**
1469  * @tc.name: TerminateSessionByPersistentId
1470  * @tc.desc: Fail to terminate session by persistentId, invalid persistentId.
1471  * @tc.type: FUNC
1472  */
1473 HWTEST_F(SceneSessionManagerTest6, TerminateSessionByPersistentId002, Function | SmallTest | Level3)
1474 {
1475     SessionInfo info;
1476     info.abilityName_ = "test1";
1477     info.bundleName_ = "test1";
1478     info.windowType_ = static_cast<uint32_t>(WindowType::APP_WINDOW_BASE);
1479     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1480     ASSERT_NE(nullptr, sceneSession);
1481     ASSERT_NE(nullptr, ssm_);
1482     ssm_->sceneSessionMap_.insert(std::make_pair(sceneSession->GetPersistentId(), sceneSession));
1483     auto result = ssm_->TerminateSessionByPersistentId(INVALID_SESSION_ID);
1484     EXPECT_EQ(result, WMError::WM_ERROR_INVALID_PERMISSION);
1485 }
1486 
1487 /**
1488  * @tc.name: SetRootSceneProcessBackEventFunc
1489  * @tc.desc: test function : SetRootSceneProcessBackEventFunc
1490  * @tc.type: FUNC
1491  */
1492 HWTEST_F(SceneSessionManagerTest6, SetRootSceneProcessBackEventFunc, Function | SmallTest | Level3)
1493 {
1494     SessionInfo sessionInfo;
1495     sessionInfo.bundleName_ = "SceneSessionManagerTest6";
1496     sessionInfo.abilityName_ = "SetRootSceneProcessBackEventFunc";
1497     sessionInfo.windowType_ = static_cast<uint32_t>(WindowType::APP_WINDOW_BASE);
1498     sessionInfo.isSystem_ = true;
1499     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1500     ASSERT_NE(nullptr, sceneSession);
1501     ASSERT_NE(nullptr, ssm_);
1502     ssm_->sceneSessionMap_.insert(std::make_pair(sceneSession->GetPersistentId(), sceneSession));
1503     ssm_->focusedSessionId_ = sceneSession->GetPersistentId();
1504     ssm_->needBlockNotifyFocusStatusUntilForeground_ = false;
1505     ssm_->ProcessBackEvent();
1506 
__anon3b2678d20402() 1507     RootSceneProcessBackEventFunc func = []() {};
1508     ssm_->SetRootSceneProcessBackEventFunc(func);
1509     ssm_->ProcessBackEvent();
1510 }
1511 
1512 /**
1513  * @tc.name: RequestInputMethodCloseKeyboard
1514  * @tc.desc: RequestInputMethodCloseKeyboard
1515  * @tc.type: FUNC
1516  */
1517 HWTEST_F(SceneSessionManagerTest6, RequestInputMethodCloseKeyboard, Function | SmallTest | Level3)
1518 {
1519     ASSERT_NE(nullptr, ssm_);
1520     SessionInfo info;
1521     sptr<SceneSession::SpecificSessionCallback> specificCallback = nullptr;
1522     sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, specificCallback);
1523     ssm_->sceneSessionMap_.insert({0, sceneSession});
1524     int32_t persistentId = 10;
1525     ssm_->RequestInputMethodCloseKeyboard(persistentId);
1526 
1527     persistentId = 0;
1528     sptr<Session> session = new Session(info);
1529     session->property_ = nullptr;
1530     ssm_->RequestInputMethodCloseKeyboard(persistentId);
1531 
1532     bool enable = true;
1533     auto result = ssm_->GetFreeMultiWindowEnableState(enable);
1534     ASSERT_EQ(result, WSError::WS_OK);
1535 }
1536 
1537 /**
1538  * @tc.name: RequestSceneSession
1539  * @tc.desc: RequestSceneSession
1540  * @tc.type: FUNC
1541  */
1542 HWTEST_F(SceneSessionManagerTest6, RequestSceneSession, Function | SmallTest | Level3)
1543 {
1544     SessionInfo sessionInfo;
1545     sptr<WindowSessionProperty> property = nullptr;
1546     ssm_->RequestSceneSession(sessionInfo, property);
1547 
1548     sessionInfo.persistentId_ = 1;
1549     sptr<SceneSession::SpecificSessionCallback> specificCallback = nullptr;
1550     sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(sessionInfo, specificCallback);
1551     ASSERT_NE(sceneSession, nullptr);
1552     ssm_->sceneSessionMap_.insert({1, sceneSession});
1553     ssm_->RequestSceneSession(sessionInfo, property);
1554 
1555     ssm_->sceneSessionMap_.clear();
1556     ssm_->sceneSessionMap_.insert({0, sceneSession});
1557     ssm_->RequestSceneSession(sessionInfo, property);
1558 
1559     sessionInfo.persistentId_ = 0;
1560     ssm_->RequestSceneSession(sessionInfo, property);
1561 }
1562 
1563 /**
1564  * @tc.name: GetSceneSessionBySessionInfo
1565  * @tc.desc: GetSceneSessionBySessionInfo
1566  * @tc.type: FUNC
1567  */
1568 HWTEST_F(SceneSessionManagerTest6, GetSceneSessionBySessionInfo, Function | SmallTest | Level3)
1569 {
1570     SessionInfo info1;
1571     info1.persistentId_ = 1;
1572     info1.isPersistentRecover_ = false;
1573     info1.windowType_ = 1000;
1574     ASSERT_EQ(ssm_->GetSceneSessionBySessionInfo(info1), nullptr);
1575 
1576     SessionInfo info2;
1577     info2.persistentId_ = 1;
1578     info2.isPersistentRecover_ = false;
1579     info2.windowType_ = 1;
1580     info2.bundleName_ = "GetSceneSessionBySessionInfoBundle";
1581     info2.abilityName_ = "GetSceneSessionBySessionInfoAbility";
1582     info2.abilityInfo = std::make_shared<AppExecFwk::AbilityInfo>();
1583     ASSERT_NE(nullptr, info2.abilityInfo);
1584     info2.abilityInfo->launchMode = AppExecFwk::LaunchMode::SINGLETON;
1585     sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info2, nullptr);
1586     ASSERT_NE(sceneSession, nullptr);
1587     ssm_->sceneSessionMap_.insert({1, sceneSession});
1588     sptr<SceneSession> getSceneSession = ssm_->GetSceneSessionBySessionInfo(info2);
1589     ASSERT_EQ(sceneSession, getSceneSession);
1590 
1591     SessionInfo info3;
1592     info3.persistentId_ = 2;
1593     info3.isPersistentRecover_ = false;
1594     info3.windowType_ = 1;
1595     info3.bundleName_ = "GetSceneSessionBySessionInfoBundle2";
1596     info3.abilityName_ = "GetSceneSessionBySessionInfoAbility2";
1597     info3.abilityInfo = std::make_shared<AppExecFwk::AbilityInfo>();
1598     info3.abilityInfo->launchMode = AppExecFwk::LaunchMode::SPECIFIED;
1599     sptr<SceneSession> sceneSession2 = new (std::nothrow) SceneSession(info3, nullptr);
1600     ASSERT_NE(sceneSession2, nullptr);
1601     ssm_->sceneSessionMap_.insert({2, sceneSession2});
1602     info3.persistentId_ = 1000;
1603     ASSERT_EQ(ssm_->GetSceneSessionBySessionInfo(info3), nullptr);
1604 
1605     SessionInfo info4;
1606     info4.persistentId_ = 0;
1607     info4.isPersistentRecover_ = false;
1608     ASSERT_EQ(ssm_->GetSceneSessionBySessionInfo(info4), nullptr);
1609 
1610     SessionInfo info5;
1611     info5.persistentId_ = 5;
1612     info5.isPersistentRecover_ = true;
1613     ASSERT_EQ(ssm_->GetSceneSessionBySessionInfo(info5), nullptr);
1614 }
1615 
1616 /**
1617  * @tc.name: IsKeyboardForeground
1618  * @tc.desc: IsKeyboardForeground
1619  * @tc.type: FUNC
1620  */
1621 HWTEST_F(SceneSessionManagerTest6, IsKeyboardForeground, Function | SmallTest | Level3)
1622 {
1623     ASSERT_NE(nullptr, ssm_);
1624     SessionInfo info;
1625     sptr<SceneSession::SpecificSessionCallback> specificCallback = nullptr;
1626     sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, specificCallback);
1627     ASSERT_NE(sceneSession, nullptr);
1628     sptr<Session> session = new Session(info);
1629     ASSERT_NE(session, nullptr);
1630     session->property_ = nullptr;
1631     auto result = ssm_->IsKeyboardForeground();
1632     ASSERT_EQ(result, false);
1633 
1634     ssm_->sceneSessionMap_.insert({0, sceneSession});
1635     session->property_ = new WindowSessionProperty();
1636     ASSERT_NE(session->property_, nullptr);
1637 
1638     if (session->property_) {
1639         auto result1 = session->GetWindowType();
1640         result1 = WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT;
1641         ASSERT_EQ(result1, WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
1642     }
1643     result = ssm_->IsKeyboardForeground();
1644     ASSERT_EQ(result, false);
1645 }
1646 
1647 /**
1648  * @tc.name: DestroyDialogWithMainWindow
1649  * @tc.desc: DestroyDialogWithMainWindow
1650  * @tc.type: FUNC
1651  */
1652 HWTEST_F(SceneSessionManagerTest6, DestroyDialogWithMainWindow, Function | SmallTest | Level3)
1653 {
1654     sptr<SceneSession> scnSession = nullptr;
1655     auto result = ssm_->DestroyDialogWithMainWindow(scnSession);
1656     ASSERT_EQ(result, WSError::WS_ERROR_NULLPTR);
1657 
1658     SessionInfo info;
1659     sptr<SceneSession::SpecificSessionCallback> specificCallback = nullptr;
1660     scnSession = new (std::nothrow) SceneSession(info, specificCallback);
1661     ASSERT_NE(scnSession, nullptr);
1662 
1663     sptr<Session> session = new Session(info);
1664     ASSERT_NE(session, nullptr);
1665     session->GetDialogVector().clear();
1666     ssm_->DestroyDialogWithMainWindow(scnSession);
1667 
1668     sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, specificCallback);
1669     ASSERT_NE(sceneSession, nullptr);
1670     ssm_->sceneSessionMap_.insert({0, sceneSession});
1671     ssm_->GetSceneSession(1);
1672     result = ssm_->DestroyDialogWithMainWindow(scnSession);
1673     ASSERT_EQ(result, WSError::WS_OK);
1674 
1675     WindowVisibilityInfo windowVisibilityInfo;
1676     windowVisibilityInfo.windowType_ = WindowType::APP_WINDOW_BASE;
1677     ssm_->DestroyDialogWithMainWindow(scnSession);
1678 }
1679 
1680 /**
1681  * @tc.name: RequestSceneSessionDestruction
1682  * @tc.desc: RequestSceneSessionDestruction
1683  * @tc.type: FUNC
1684  */
1685 HWTEST_F(SceneSessionManagerTest6, RequestSceneSessionDestruction, Function | SmallTest | Level3)
1686 {
1687     sptr<SceneSession> sceneSession;
1688     ASSERT_EQ(sceneSession, nullptr);
1689     bool needRemoveSession = true;
1690     bool isSaveSnapshot = true;
1691     bool isForceClean = true;
1692     ssm_->RequestSceneSessionDestruction(sceneSession, needRemoveSession, isSaveSnapshot, isForceClean);
1693 
1694     SessionInfo info;
1695     sptr<SceneSession::SpecificSessionCallback> specificCallback = nullptr;
1696     sceneSession = new (std::nothrow) SceneSession(info, specificCallback);
1697     sptr<WindowSessionProperty> property = new (std::nothrow) WindowSessionProperty();
1698     ASSERT_NE(property, nullptr);
1699     property->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
1700     ssm_->RequestSceneSessionDestruction(sceneSession, needRemoveSession, isSaveSnapshot, isForceClean);
1701 }
1702 
1703 /**
1704  * @tc.name: NotifySessionAINavigationBarChange
1705  * @tc.desc: NotifySessionAINavigationBarChange
1706  * @tc.type: FUNC
1707  */
1708 HWTEST_F(SceneSessionManagerTest6, NotifySessionAINavigationBarChange, Function | SmallTest | Level3)
1709 {
1710     ASSERT_NE(nullptr, ssm_);
1711     int32_t persistentId = 1;
1712     SessionInfo info;
1713     sptr<SceneSession::SpecificSessionCallback> specificCallback = nullptr;
1714     sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, specificCallback);
1715     ssm_->sceneSessionMap_.insert({0, sceneSession});
1716     ssm_->NotifySessionAINavigationBarChange(persistentId);
1717 
1718     persistentId = 0;
1719     Session session(info);
1720     session.isVisible_ = true;
1721     session.state_ = SessionState::STATE_FOREGROUND;
1722     ssm_->NotifySessionAINavigationBarChange(persistentId);
1723 }
1724 
1725 /**
1726  * @tc.name: GetProcessSurfaceNodeIdByPersistentId
1727  * @tc.desc: GetProcessSurfaceNodeIdByPersistentId
1728  * @tc.type: FUNC
1729  */
1730 HWTEST_F(SceneSessionManagerTest6, GetProcessSurfaceNodeIdByPersistentId, Function | SmallTest | Level3)
1731 {
1732     ASSERT_NE(nullptr, ssm_);
1733     SessionInfo info;
1734     sptr<SceneSession::SpecificSessionCallback> specificCallback = nullptr;
1735     sptr<SceneSession> sceneSession1 = new (std::nothrow) SceneSession(info, specificCallback);
1736     sptr<SceneSession> sceneSession2 = new (std::nothrow) SceneSession(info, specificCallback);
1737     sptr<SceneSession> sceneSession3 = new (std::nothrow) SceneSession(info, specificCallback);
1738     sceneSession1->SetCallingPid(123);
1739     sceneSession2->SetCallingPid(123);
1740     sceneSession3->SetCallingPid(111);
1741 
1742     int32_t pid = 123;
1743     std::vector<int32_t> persistentIds;
1744     std::vector<uint64_t> surfaceNodeIds;
1745     persistentIds.push_back(sceneSession1->GetPersistentId());
1746     persistentIds.push_back(sceneSession2->GetPersistentId());
1747     persistentIds.push_back(sceneSession3->GetPersistentId());
1748     ssm_->sceneSessionMap_.insert({sceneSession1->GetPersistentId(), sceneSession1});
1749     ssm_->sceneSessionMap_.insert({sceneSession2->GetPersistentId(), sceneSession2});
1750     ssm_->sceneSessionMap_.insert({sceneSession3->GetPersistentId(), sceneSession3});
1751 
1752     ASSERT_EQ(WMError::WM_OK, ssm_->GetProcessSurfaceNodeIdByPersistentId(pid, persistentIds, surfaceNodeIds));
1753     ASSERT_EQ(0, surfaceNodeIds.size());
1754 }
1755 
1756 /**
1757  * @tc.name: OnScreenFoldStatusChanged
1758  * @tc.desc: OnScreenFoldStatusChanged
1759  * @tc.type: FUNC
1760  */
1761 HWTEST_F(SceneSessionManagerTest6, OnScreenFoldStatusChanged, Function | SmallTest | Level3)
1762 {
1763     std::vector<std::string> screenFoldInfo;
1764     sptr<IDisplayChangeListener> listener = sptr<DisplayChangeListener>::MakeSptr();
1765     ASSERT_NE(nullptr, listener);
1766     listener->OnScreenFoldStatusChanged(screenFoldInfo);
1767     ASSERT_NE(nullptr, ssm_);
1768     auto ret = ssm_->UpdateDisplayHookInfo(0, 50, 50, 0.0f, true);
1769     EXPECT_EQ(ret, WMError::WM_OK);
1770     ssm_->CheckSceneZOrder();
1771 }
1772 
1773 /**
1774  * @tc.name: NotifySessionForeground
1775  * @tc.desc: NotifySessionForeground
1776  * @tc.type: FUNC
1777  */
1778 HWTEST_F(SceneSessionManagerTest6, NotifySessionForeground, Function | SmallTest | Level3)
1779 {
1780     SessionInfo sessionInfo;
1781     sessionInfo.bundleName_ = "SceneSessionManagerTest6";
1782     sessionInfo.abilityName_ = "NotifySessionForeground";
1783     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1784     uint32_t reason = 0;
1785     bool withAnimation = false;
1786     ASSERT_NE(nullptr, ssm_);
1787     ssm_->NotifySessionForeground(sceneSession, reason, withAnimation);
1788     WSRect area = { 0, 0, 0, 0 };
1789     uint32_t type = 0;
1790     ssm_->AddWindowDragHotArea(type, area);
1791     uint64_t displayId = 0;
1792     ssm_->currAINavigationBarAreaMap_.clear();
1793     ssm_->currAINavigationBarAreaMap_.insert(std::make_pair(displayId, area));
1794     auto ret = ssm_->GetAINavigationBarArea(1);
1795     EXPECT_TRUE(ret.IsEmpty());
1796     ret = ssm_->GetAINavigationBarArea(displayId);
1797     EXPECT_EQ(ret, area);
1798 }
1799 
1800 /**
1801  * @tc.name: OnDisplayStateChange
1802  * @tc.desc: OnDisplayStateChange
1803  * @tc.type: FUNC
1804  */
1805 HWTEST_F(SceneSessionManagerTest6, OnDisplayStateChange, Function | SmallTest | Level3)
1806 {
1807     DisplayChangeListener listener;
1808     DisplayId displayId = 0;
1809     sptr<DisplayInfo> displayInfo = sptr<DisplayInfo>::MakeSptr();
1810     ASSERT_NE(nullptr, displayInfo);
1811     std::map<DisplayId, sptr<DisplayInfo>> displayInfoMap;
1812     displayInfoMap.insert(std::make_pair(displayId, displayInfo));
1813     DisplayStateChangeType type = DisplayStateChangeType::VIRTUAL_PIXEL_RATIO_CHANGE;
1814     listener.OnDisplayStateChange(displayId, displayInfo, displayInfoMap, type);
1815     type = DisplayStateChangeType::UPDATE_ROTATION;
1816     listener.OnDisplayStateChange(displayId, displayInfo, displayInfoMap, type);
1817     type = DisplayStateChangeType::UPDATE_SCALE;
1818     listener.OnDisplayStateChange(displayId, displayInfo, displayInfoMap, type);
1819     type = DisplayStateChangeType::UNKNOWN;
1820     listener.OnDisplayStateChange(displayId, displayInfo, displayInfoMap, type);
1821 }
1822 
1823 /**
1824  * @tc.name: UpdateSessionAvoidAreaIfNeed
1825  * @tc.desc: UpdateSessionAvoidAreaIfNeed
1826  * @tc.type: FUNC
1827  */
1828 HWTEST_F(SceneSessionManagerTest6, UpdateSessionAvoidAreaIfNeed, Function | SmallTest | Level3)
1829 {
1830     int32_t persistentId = 0;
1831     sptr<SceneSession> sceneSession = nullptr;
1832     AvoidArea avoidArea;
1833     AvoidAreaType avoidAreaType = AvoidAreaType::TYPE_KEYBOARD;
1834     ASSERT_NE(nullptr, ssm_);
1835     ssm_->enterRecent_ = false;
1836     auto ret = ssm_->UpdateSessionAvoidAreaIfNeed(persistentId, sceneSession, avoidArea, avoidAreaType);
1837     EXPECT_EQ(ret, false);
1838     ssm_->enterRecent_ = true;
1839     ret = ssm_->UpdateSessionAvoidAreaIfNeed(persistentId, sceneSession, avoidArea, avoidAreaType);
1840     EXPECT_EQ(ret, false);
1841     SessionInfo sessionInfo;
1842     sessionInfo.bundleName_ = "SceneSessionManagerTest6";
1843     sessionInfo.abilityName_ = "UpdateSessionAvoidAreaIfNeed";
1844     sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1845     ASSERT_NE(nullptr, sceneSession);
1846     ret = ssm_->UpdateSessionAvoidAreaIfNeed(persistentId, sceneSession, avoidArea, avoidAreaType);
1847     EXPECT_EQ(ret, false);
1848     ssm_->enterRecent_ = false;
1849     ret = ssm_->UpdateSessionAvoidAreaIfNeed(persistentId, sceneSession, avoidArea, avoidAreaType);
1850     EXPECT_EQ(ret, false);
1851     ssm_->lastUpdatedAvoidArea_.clear();
1852     ret = ssm_->UpdateSessionAvoidAreaIfNeed(persistentId, sceneSession, avoidArea, avoidAreaType);
1853     EXPECT_EQ(ret, false);
1854 }
1855 
1856 /**
1857  * @tc.name: UpdateSessionAvoidAreaIfNeed01
1858  * @tc.desc: UpdateSessionAvoidAreaIfNeed
1859  * @tc.type: FUNC
1860  */
1861 HWTEST_F(SceneSessionManagerTest6, UpdateSessionAvoidAreaIfNeed01, Function | SmallTest | Level3)
1862 {
1863     int32_t persistentId = 0;
1864     AvoidArea avoidArea;
1865     AvoidAreaType avoidAreaType = AvoidAreaType::TYPE_KEYBOARD;
1866     SessionInfo sessionInfo;
1867     sessionInfo.bundleName_ = "SceneSessionManagerTest6";
1868     sessionInfo.abilityName_ = "UpdateSessionAvoidAreaIfNeed";
1869     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1870     ASSERT_NE(nullptr, sceneSession);
1871     ASSERT_NE(nullptr, ssm_);
1872     ssm_->enterRecent_ = false;
1873     std::map<AvoidAreaType, AvoidArea> mapAvoidAreaType;
1874     mapAvoidAreaType.insert(std::make_pair(avoidAreaType, avoidArea));
1875     ssm_->lastUpdatedAvoidArea_.insert(std::make_pair(persistentId, mapAvoidAreaType));
1876     auto ret = ssm_->UpdateSessionAvoidAreaIfNeed(persistentId, sceneSession, avoidArea, avoidAreaType);
1877     EXPECT_EQ(ret, false);
1878     avoidAreaType = AvoidAreaType::TYPE_SYSTEM;
1879     ret = ssm_->UpdateSessionAvoidAreaIfNeed(persistentId, sceneSession, avoidArea, avoidAreaType);
1880     EXPECT_EQ(ret, false);
1881     avoidArea.topRect_.posX_ = 1;
1882     ret = ssm_->UpdateSessionAvoidAreaIfNeed(persistentId, sceneSession, avoidArea, avoidAreaType);
1883     EXPECT_EQ(ret, true);
1884 }
1885 
1886 /**
1887  * @tc.name: CheckIfReuseSession
1888  * @tc.desc: CheckIfReuseSession
1889  * @tc.type: FUNC
1890  */
1891 HWTEST_F(SceneSessionManagerTest6, CheckIfReuseSession, Function | SmallTest | Level3)
1892 {
1893     SessionInfo sessionInfo;
1894     sessionInfo.bundleName_ = "SceneSessionManagerTest6";
1895     sessionInfo.abilityName_ = "CheckIfReuseSession";
1896     ASSERT_NE(nullptr, ssm_);
1897     auto ret = ssm_->CheckIfReuseSession(sessionInfo);
1898     EXPECT_EQ(ret, BrokerStates::BROKER_UNKOWN);
1899     ScreenId screenId = 0;
1900     std::unordered_map<int32_t, SessionUIParam> uiParams;
1901     ssm_->FlushUIParams(screenId, std::move(uiParams));
1902 }
1903 
1904 /**
1905  * @tc.name: UpdateAvoidArea
1906  * @tc.desc: UpdateAvoidArea
1907  * @tc.type: FUNC
1908  */
1909 HWTEST_F(SceneSessionManagerTest6, UpdateAvoidArea, Function | SmallTest | Level3)
1910 {
1911     int32_t persistentId = 0;
1912     ASSERT_NE(nullptr, ssm_);
1913     ssm_->sceneSessionMap_.clear();
1914     ssm_->UpdateAvoidArea(persistentId);
1915     SessionInfo sessionInfo;
1916     sessionInfo.bundleName_ = "SceneSessionManagerTest6";
1917     sessionInfo.abilityName_ = "UpdateAvoidArea";
1918     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1919     ASSERT_NE(nullptr, sceneSession);
1920     ssm_->sceneSessionMap_.insert(std::make_pair(persistentId, sceneSession));
1921     ASSERT_NE(nullptr, sceneSession->property_);
1922     sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_STATUS_BAR);
1923     ssm_->UpdateAvoidArea(persistentId);
1924     sceneSession->property_->SetWindowType(WindowType::APP_WINDOW_BASE);
1925     ssm_->UpdateAvoidArea(persistentId);
1926 }
1927 
1928 /**
1929  * @tc.name: UpdateMaximizeMode
1930  * @tc.desc: UpdateMaximizeMode
1931  * @tc.type: FUNC
1932  */
1933 HWTEST_F(SceneSessionManagerTest6, UpdateMaximizeMode, Function | SmallTest | Level3)
1934 {
1935     int32_t persistentId = 0;
1936     bool isMaximize = true;
1937     ASSERT_NE(nullptr, ssm_);
1938     ssm_->sceneSessionMap_.clear();
1939     auto ret = ssm_->UpdateMaximizeMode(persistentId, isMaximize);
1940     EXPECT_EQ(ret, WSError::WS_OK);
1941     SessionInfo sessionInfo;
1942     sessionInfo.bundleName_ = "SceneSessionManagerTest6";
1943     sessionInfo.abilityName_ = "UpdateMaximizeMode";
1944     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1945     ASSERT_NE(nullptr, sceneSession);
1946     ssm_->sceneSessionMap_.insert(std::make_pair(persistentId, sceneSession));
1947     EXPECT_EQ(ret, WSError::WS_OK);
1948     sptr<DisplayInfo> displayInfo = nullptr;
1949     ssm_->ProcessDisplayScale(displayInfo);
1950     displayInfo = sptr<DisplayInfo>::MakeSptr();
1951     ASSERT_NE(nullptr, displayInfo);
1952     ssm_->ProcessDisplayScale(displayInfo);
1953     ProcessVirtualPixelRatioChangeFunc func = nullptr;
1954     ssm_->SetVirtualPixelRatioChangeListener(func);
1955 }
1956 
1957 /**
1958  * @tc.name: WindowDestroyNotifyVisibility
1959  * @tc.desc: WindowDestroyNotifyVisibility
1960  * @tc.type: FUNC
1961  */
1962 HWTEST_F(SceneSessionManagerTest6, WindowDestroyNotifyVisibility, Function | SmallTest | Level3)
1963 {
1964     SessionInfo sessionInfo;
1965     sessionInfo.bundleName_ = "SceneSessionManagerTest6";
1966     sessionInfo.abilityName_ = "WindowDestroyNotifyVisibility";
1967     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1968     ASSERT_NE(nullptr, sceneSession);
1969     sceneSession->SetRSVisible(true);
1970     ASSERT_NE(nullptr, ssm_);
1971     ssm_->WindowDestroyNotifyVisibility(sceneSession);
1972     sceneSession->SetRSVisible(false);
1973     ssm_->WindowDestroyNotifyVisibility(sceneSession);
1974     sceneSession = nullptr;
1975     ssm_->WindowDestroyNotifyVisibility(sceneSession);
1976 }
1977 }
1978 } // namespace Rosen
1979 } // namespace OHOS