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