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