• 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 <application_context.h>
17 #include <bundle_mgr_interface.h>
18 #include <bundlemgr/launcher_service.h>
19 #include <gtest/gtest.h>
20 #include <regex>
21 
22 #include "context.h"
23 #include "interfaces/include/ws_common.h"
24 #include "iremote_object_mocker.h"
25 #include "mock/mock_session_stage.h"
26 #include "mock/mock_window_event_channel.h"
27 #include "session_info.h"
28 #include "session_manager.h"
29 #include "session_manager/include/scene_session_manager.h"
30 #include "session/host/include/main_session.h"
31 #include "session/host/include/pc_fold_screen_controller.h"
32 #include "session/host/include/scene_session.h"
33 #include "window_manager_agent.h"
34 #include "zidl/window_manager_agent_interface.h"
35 
36 using namespace testing;
37 using namespace testing::ext;
38 
39 namespace OHOS {
40 namespace Rosen {
41 class SceneSessionManagerTest4 : public testing::Test {
42 public:
43     static void SetUpTestCase();
44 
45     static void TearDownTestCase();
46 
47     void SetUp() override;
48 
49     void TearDown() override;
50 
51     static bool gestureNavigationEnabled_;
52 
53     static ProcessGestureNavigationEnabledChangeFunc callbackFunc_;
54     static sptr<SceneSessionManager> ssm_;
55 
56 private:
57     static constexpr uint32_t WAIT_SYNC_IN_NS = 200000;
58 };
59 
60 sptr<SceneSessionManager> SceneSessionManagerTest4::ssm_ = nullptr;
61 bool SceneSessionManagerTest4::gestureNavigationEnabled_ = true;
62 
63 ProcessGestureNavigationEnabledChangeFunc SceneSessionManagerTest4::callbackFunc_ = [](bool enable,
__anonc11e4ed80102(bool enable, const std::string& bundleName, GestureBackType type) 64     const std::string& bundleName, GestureBackType type) {
65     gestureNavigationEnabled_ = enable;
66 };
67 
68 
WindowChangedFuncTest(int32_t persistentId,WindowUpdateType type)69 void WindowChangedFuncTest(int32_t persistentId, WindowUpdateType type)
70 {
71 }
72 
ProcessStatusBarEnabledChangeFuncTest(bool enable)73 void ProcessStatusBarEnabledChangeFuncTest(bool enable)
74 {
75 }
76 
DumpRootSceneElementInfoFuncTest(const std::vector<std::string> & params,std::vector<std::string> & infos)77 void DumpRootSceneElementInfoFuncTest(const std::vector<std::string>& params, std::vector<std::string>& infos)
78 {
79 }
80 
SetUpTestCase()81 void SceneSessionManagerTest4::SetUpTestCase()
82 {
83     ssm_ = &SceneSessionManager::GetInstance();
84 }
85 
TearDownTestCase()86 void SceneSessionManagerTest4::TearDownTestCase()
87 {
88     ssm_ = nullptr;
89 }
90 
SetUp()91 void SceneSessionManagerTest4::SetUp()
92 {
93     ssm_->sceneSessionMap_.clear();
94 }
95 
TearDown()96 void SceneSessionManagerTest4::TearDown()
97 {
98     ssm_->sceneSessionMap_.clear();
99     usleep(WAIT_SYNC_IN_NS);
100 }
101 
102 
103 namespace {
104 /**
105  * @tc.name: UpdateSceneSessionWant01
106  * @tc.desc: SceneSesionManager test UpdateSceneSessionWant
107  * @tc.type: FUNC
108  */
109 HWTEST_F(SceneSessionManagerTest4, UpdateSceneSessionWant01, Function | SmallTest | Level3)
110 {
111     SessionInfo info;
112     info.persistentId_ = 0;
113     ssm_->UpdateSceneSessionWant(info);
114     ASSERT_NE(ssm_, nullptr);
115 }
116 
117 /**
118  * @tc.name: UpdateSceneSessionWant02
119  * @tc.desc: SceneSesionManager test UpdateSceneSessionWant
120  * @tc.type: FUNC
121  */
122 HWTEST_F(SceneSessionManagerTest4, UpdateSceneSessionWant02, Function | SmallTest | Level3)
123 {
124     SessionInfo info;
125     info.persistentId_ = 1;
126     ssm_->UpdateSceneSessionWant(info);
127     ASSERT_NE(ssm_, nullptr);
128 }
129 
130 /**
131  * @tc.name: UpdateSceneSessionWant03
132  * @tc.desc: SceneSesionManager test UpdateSceneSessionWant
133  * @tc.type: FUNC
134  */
135 HWTEST_F(SceneSessionManagerTest4, UpdateSceneSessionWant03, Function | SmallTest | Level3)
136 {
137     SessionInfo info;
138     info.persistentId_ = 1;
139     auto sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
140     ASSERT_NE(sceneSession, nullptr);
141     ssm_->sceneSessionMap_.insert({1, sceneSession});
142     ssm_->UpdateSceneSessionWant(info);
143     ASSERT_NE(ssm_, nullptr);
144 }
145 
146 /**
147  * @tc.name: UpdateSceneSessionWant04
148  * @tc.desc: SceneSesionManager test UpdateSceneSessionWant
149  * @tc.type: FUNC
150  */
151 HWTEST_F(SceneSessionManagerTest4, UpdateSceneSessionWant04, Function | SmallTest | Level3)
152 {
153     SessionInfo info;
154     info.persistentId_ = 1;
155     std::shared_ptr<AAFwk::Want> want = std::make_shared<AAFwk::Want>();
156     info.want = want;
157     auto sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
158     ASSERT_NE(sceneSession, nullptr);
159     ssm_->sceneSessionMap_.insert({1, sceneSession});
160     ssm_->UpdateSceneSessionWant(info);
161     ASSERT_NE(ssm_, nullptr);
162 }
163 
164 /**
165  * @tc.name: UpdateSceneSessionWant05
166  * @tc.desc: SceneSesionManager test UpdateSceneSessionWant
167  * @tc.type: FUNC
168  */
169 HWTEST_F(SceneSessionManagerTest4, UpdateSceneSessionWant05, Function | SmallTest | Level3)
170 {
171     SessionInfo info;
172     info.persistentId_ = 1;
173     std::shared_ptr<AAFwk::Want> want = std::make_shared<AAFwk::Want>();
174     info.want = want;
175     auto sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
176     ASSERT_NE(sceneSession, nullptr);
177     int32_t collaboratorType = CollaboratorType::RESERVE_TYPE;
178     sceneSession->SetCollaboratorType(collaboratorType);
179     ssm_->sceneSessionMap_.insert({1, sceneSession});
180     ssm_->UpdateSceneSessionWant(info);
181     ASSERT_NE(ssm_, nullptr);
182 }
183 
184 /**
185  * @tc.name: UpdateSceneSessionWant06
186  * @tc.desc: SceneSesionManager test UpdateSceneSessionWant
187  * @tc.type: FUNC
188  */
189 HWTEST_F(SceneSessionManagerTest4, UpdateSceneSessionWant06, Function | SmallTest | Level3)
190 {
191     SessionInfo info;
192     info.persistentId_ = 1;
193     std::shared_ptr<AAFwk::Want> want = std::make_shared<AAFwk::Want>();
194     info.want = want;
195     auto sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
196     ASSERT_NE(sceneSession, nullptr);
197     int32_t collaboratorType = -1;
198     sceneSession->SetCollaboratorType(collaboratorType);
199     ssm_->sceneSessionMap_.insert({1, sceneSession});
200     ssm_->UpdateSceneSessionWant(info);
201     ASSERT_NE(ssm_, nullptr);
202 }
203 
204 /**
205  * @tc.name: GetSceneSessionByIdentityInfo01
206  * @tc.desc: SceneSesionManager test GetSceneSessionByIdentityInfo
207  * @tc.type: FUNC
208  */
209 HWTEST_F(SceneSessionManagerTest4, GetSceneSessionByIdentityInfo01, Function | SmallTest | Level3)
210 {
211     std::string abilityName = "test1";
212     std::string bundleName = "test2";
213     std::string moduleName = "test3";
214     int32_t appIndex = 10;
215     SessionInfo info;
216     info.abilityName_ = abilityName;
217     info.bundleName_ = bundleName;
218     info.moduleName_ = moduleName;
219     info.appIndex_ = appIndex;
220     info.persistentId_ = 1;
221     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
222     ASSERT_NE(sceneSession, nullptr);
223     ssm_->sceneSessionMap_.insert({1, sceneSession});
224     SessionIdentityInfo identityInfo = { bundleName, moduleName, abilityName, appIndex };
225     ASSERT_NE(ssm_->GetSceneSessionByIdentityInfo(identityInfo), nullptr);
226 }
227 
228 /**
229  * @tc.name: DestroyAndDisconnectSpecificSession01
230  * @tc.desc: SceneSesionManager test DestroyAndDisconnectSpecificSession
231  * @tc.type: FUNC
232  */
233 HWTEST_F(SceneSessionManagerTest4, DestroyAndDisconnectSpecificSession01, Function | SmallTest | Level3)
234 {
235     SessionInfo info;
236     info.abilityName_ = "DestroyAndDisconnectSpecificSession";
237     info.bundleName_ = "DestroyAndDisconnectSpecificSession";
238     info.persistentId_ = 1;
239     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
240     ASSERT_NE(sceneSession, nullptr);
241     ssm_->sceneSessionMap_.insert({1, sceneSession});
242     ASSERT_NE(ssm_->DestroyAndDisconnectSpecificSession(1), WSError::WS_ERROR_NULLPTR);
243 }
244 
245 /**
246  * @tc.name: GetAllSessionDumpInfo
247  * @tc.desc: SceneSesionManager test GetAllSessionDumpInfo
248  * @tc.type: FUNC
249  */
250 HWTEST_F(SceneSessionManagerTest4, GetAllSessionDumpInfo, Function | SmallTest | Level3)
251 {
252     SessionInfo info1;
253     info1.abilityName_ = "GetAllSessionDumpInfo1";
254     info1.bundleName_ = "GetAllSessionDumpInfo1";
255     info1.persistentId_ = 1;
256     sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(info1, nullptr);
257     ASSERT_NE(sceneSession1, nullptr);
258     sceneSession1->UpdateNativeVisibility(true);
259 
260     SessionInfo info2;
261     info2.abilityName_ = "GetAllSessionDumpInfo2";
262     info2.bundleName_ = "GetAllSessionDumpInfo2";
263     info2.persistentId_ = 2;
264     sptr<SceneSession> sceneSession2 = sptr<SceneSession>::MakeSptr(info2, nullptr);
265     ASSERT_NE(sceneSession2, nullptr);
266     sceneSession2->UpdateNativeVisibility(false);
267 
268     ssm_->sceneSessionMap_.insert({1, sceneSession1});
269     ssm_->sceneSessionMap_.insert({2, sceneSession2});
270     std::string dumpInfo;
271     ASSERT_EQ(ssm_->GetAllSessionDumpInfo(dumpInfo), WSError::WS_OK);
272 }
273 
274 /**
275  * @tc.name: GetSpecifiedSessionDumpInfo
276  * @tc.desc: SceneSesionManager test GetSpecifiedSessionDumpInfo
277  * @tc.type: FUNC
278  */
279 HWTEST_F(SceneSessionManagerTest4, GetSpecifiedSessionDumpInfo, Function | SmallTest | Level3)
280 {
281     SessionInfo info;
282     info.abilityName_ = "GetSpecifiedSessionDumpInfo";
283     info.bundleName_ = "GetSpecifiedSessionDumpInfo";
284     info.persistentId_ = 1234;
285     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
286     ASSERT_NE(sceneSession, nullptr);
287     ssm_->sceneSessionMap_.insert({1234, sceneSession});
288     std::string dumpInfo;
289     std::string strId = "1234";
290     std::vector<std::string> params_(5, "");
291     ASSERT_EQ(ssm_->GetSpecifiedSessionDumpInfo(dumpInfo, params_, strId), WSError::WS_OK);
292 }
293 
294 /**
295  * @tc.name: NotifyEnterRecentTask02
296  * @tc.desc: NotifyEnterRecentTask
297  * @tc.type: FUNC
298  */
299 HWTEST_F(SceneSessionManagerTest4, NotifyEnterRecentTask02, Function | SmallTest | Level3)
300 {
301     ASSERT_NE(nullptr, ssm_);
302     EXPECT_EQ(ssm_->NotifyEnterRecentTask(false), WSError::WS_OK);
303 }
304 
305 /**
306  * @tc.name: GetWindowStatus
307  * @tc.desc: GetWindowStatus
308  * @tc.type: FUNC
309  */
310 HWTEST_F(SceneSessionManagerTest4, GetWindowStatus, Function | SmallTest | Level3)
311 {
312     ASSERT_NE(nullptr, ssm_);
313     WindowMode mode = WindowMode::WINDOW_MODE_FLOATING;
314     SessionState sessionState = SessionState::STATE_FOREGROUND;
315     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
316     ASSERT_NE(property, nullptr);
317     auto result = ssm_->GetWindowStatus(mode, sessionState, nullptr);
318     EXPECT_EQ(result, WindowStatus::WINDOW_STATUS_UNDEFINED);
319 }
320 
321 /**
322  * @tc.name: GetWindowStatus02
323  * @tc.desc: GetWindowStatus
324  * @tc.type: FUNC
325  */
326 HWTEST_F(SceneSessionManagerTest4, GetWindowStatus02, Function | SmallTest | Level3)
327 {
328     ASSERT_NE(nullptr, ssm_);
329     WindowMode mode = WindowMode::WINDOW_MODE_FLOATING;
330     SessionState sessionState = SessionState::STATE_FOREGROUND;
331     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
332     ASSERT_NE(property, nullptr);
333     auto result = ssm_->GetWindowStatus(mode, sessionState, nullptr);
334     property->SetMaximizeMode(MaximizeMode::MODE_AVOID_SYSTEM_BAR);
335     result = ssm_->GetWindowStatus(mode, sessionState, property);
336     EXPECT_EQ(result, WindowStatus::WINDOW_STATUS_MAXIMIZE);
337 }
338 
339 /**
340  * @tc.name: GetWindowStatus03
341  * @tc.desc: GetWindowStatus
342  * @tc.type: FUNC
343  */
344 HWTEST_F(SceneSessionManagerTest4, GetWindowStatus03, Function | SmallTest | Level3)
345 {
346     ASSERT_NE(nullptr, ssm_);
347     WindowMode mode = WindowMode::WINDOW_MODE_FLOATING;
348     SessionState sessionState = SessionState::STATE_FOREGROUND;
349     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
350     ASSERT_NE(property, nullptr);
351     auto result = ssm_->GetWindowStatus(mode, sessionState, nullptr);
352     property->SetMaximizeMode(MaximizeMode::MODE_FULL_FILL);
353     result = ssm_->GetWindowStatus(mode, sessionState, property);
354     EXPECT_EQ(result, WindowStatus::WINDOW_STATUS_FLOATING);
355 }
356 
357 /**
358  * @tc.name: GetWindowStatus04
359  * @tc.desc: GetWindowStatus
360  * @tc.type: FUNC
361  */
362 HWTEST_F(SceneSessionManagerTest4, GetWindowStatus04, Function | SmallTest | Level3)
363 {
364     ASSERT_NE(nullptr, ssm_);
365     WindowMode mode = WindowMode::WINDOW_MODE_FLOATING;
366     SessionState sessionState = SessionState::STATE_FOREGROUND;
367     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
368     ASSERT_NE(property, nullptr);
369     mode = WindowMode::WINDOW_MODE_SPLIT_PRIMARY;
370     auto result = ssm_->GetWindowStatus(mode, sessionState, property);
371     EXPECT_EQ(result, WindowStatus::WINDOW_STATUS_SPLITSCREEN);
372 }
373 
374 /**
375  * @tc.name: UpdateDisplayRegion
376  * @tc.desc: UpdateDisplayRegion
377  * @tc.type: FUNC
378  */
379 HWTEST_F(SceneSessionManagerTest4, UpdateDisplayRegion, Function | SmallTest | Level3)
380 {
381     ASSERT_NE(nullptr, ssm_);
382     ssm_->UpdateDisplayRegion(nullptr);
383     sptr<DisplayInfo> displayInfo = sptr<DisplayInfo>::MakeSptr();
384     ASSERT_NE(displayInfo, nullptr);
385 
386     constexpr DisplayId displayId = 0;
387     constexpr int32_t width = 100;
388     displayInfo->SetDisplayId(displayId);
389     displayInfo->SetWidth(width);
390     ssm_->UpdateDisplayRegion(displayInfo);
391 
392     constexpr int32_t height = 200;
393     displayInfo->SetWidth(width);
394     displayInfo->SetHeight(height);
395     ssm_->UpdateDisplayRegion(displayInfo);
396 
397     displayInfo->SetHeight(height);
398     PcFoldScreenManager::GetInstance().SetDisplayInfo(displayId, SuperFoldStatus::HALF_FOLDED);
399     PcFoldScreenManager::GetInstance().SetDisplayRects(
400         WSRect::EMPTY_RECT, { 0, 0, width, height }, WSRect::EMPTY_RECT);
401     ssm_->UpdateDisplayRegion(displayInfo);
402     ASSERT_NE(ssm_->displayRegionMap_.count(displayId), 0);
403     auto region = ssm_->displayRegionMap_[displayId];
404     ASSERT_NE(region, nullptr);
405     const SkIRect& rect = region->getBounds();
406     EXPECT_EQ(rect.fLeft, 0);
407     EXPECT_EQ(rect.fTop, 0);
408     EXPECT_EQ(rect.fRight, width);
409     EXPECT_EQ(rect.fBottom, height);
410 }
411 
412 /**
413  * @tc.name: GetDisplayRegion
414  * @tc.desc: GetDisplayRegion
415  * @tc.type: FUNC
416  */
417 HWTEST_F(SceneSessionManagerTest4, GetDisplayRegion, Function | SmallTest | Level3)
418 {
419     ASSERT_NE(nullptr, ssm_);
420     constexpr DisplayId displayId = 0;
421     auto region = ssm_->GetDisplayRegion(displayId);
422     EXPECT_NE(region, nullptr);
423 
424     constexpr int32_t left = 0;
425     constexpr int32_t top = 0;
426     constexpr int32_t right = 100;
427     constexpr int32_t bottom = 200;
428     SkIRect rect { .fLeft = left, .fTop = top, .fRight = right, .fBottom = bottom };
429     ssm_->displayRegionMap_[displayId] = std::make_shared<SkRegion>(rect);
430     auto region1 = ssm_->GetDisplayRegion(displayId);
431     ASSERT_NE(region1, nullptr);
432     const SkIRect& rect1 = region1->getBounds();
433     EXPECT_EQ(rect1.fLeft, 0);
434     EXPECT_EQ(rect1.fTop, 0);
435     EXPECT_EQ(rect1.fRight, right);
436     EXPECT_EQ(rect1.fBottom, bottom);
437 }
438 
439 /**
440  * @tc.name: GetCustomDecorHeight
441  * @tc.desc: GetCustomDecorHeight
442  * @tc.type: FUNC
443  */
444 HWTEST_F(SceneSessionManagerTest4, GetCustomDecorHeight, Function | SmallTest | Level3)
445 {
446     ASSERT_NE(nullptr, ssm_);
447     SessionInfo info;
448     info.abilityName_ = "SetBrightness";
449     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
450     ASSERT_NE(sceneSession, nullptr);
451     sceneSession->SetCustomDecorHeight(50);
452     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
453     ssm_->sceneSessionMap_.insert(std::make_pair(2, nullptr));
454     EXPECT_EQ(0, ssm_->GetCustomDecorHeight(2));
455     EXPECT_EQ(50, ssm_->GetCustomDecorHeight(1));
456 }
457 
458 /**
459  * @tc.name: IsVectorSame
460  * @tc.desc: IsVectorSame
461  * @tc.type: FUNC
462  */
463 HWTEST_F(SceneSessionManagerTest4, IsVectorSame, Function | SmallTest | Level3)
464 {
465     ASSERT_NE(nullptr, ssm_);
466     std::vector<VisibleWindowNumInfo> lastInfo;
467     std::vector<VisibleWindowNumInfo> currentInfo;
468     VisibleWindowNumInfo num;
469     lastInfo.push_back(num);
470     EXPECT_EQ(false, ssm_->IsVectorSame(lastInfo, currentInfo));
471     lastInfo.clear();
472 }
473 
474 /**
475  * @tc.name: IsVectorSame01
476  * @tc.desc: IsVectorSame
477  * @tc.type: FUNC
478  */
479 HWTEST_F(SceneSessionManagerTest4, IsVectorSame01, Function | SmallTest | Level3)
480 {
481     ASSERT_NE(nullptr, ssm_);
482     std::vector<VisibleWindowNumInfo> lastInfo;
483     std::vector<VisibleWindowNumInfo> currentInfo;
484     lastInfo.reserve(2);
485     VisibleWindowNumInfo oneNum;
486     oneNum.displayId = 0;
487     oneNum.visibleWindowNum = 3;
488     lastInfo.push_back(oneNum);
489     currentInfo.push_back(oneNum);
490     EXPECT_EQ(true, ssm_->IsVectorSame(lastInfo, currentInfo));
491 }
492 
493 /**
494  * @tc.name: IsVectorSame03
495  * @tc.desc: IsVectorSame
496  * @tc.type: FUNC
497  */
498 HWTEST_F(SceneSessionManagerTest4, IsVectorSame03, Function | SmallTest | Level3)
499 {
500     ASSERT_NE(nullptr, ssm_);
501     std::vector<VisibleWindowNumInfo> lastInfo;
502     std::vector<VisibleWindowNumInfo> currentInfo;
503     lastInfo.clear();
504     currentInfo.clear();
505     VisibleWindowNumInfo twoNum;
506     twoNum.displayId = 0;
507     twoNum.visibleWindowNum = 2;
508     currentInfo.push_back(twoNum);
509     EXPECT_EQ(false, ssm_->IsVectorSame(lastInfo, currentInfo));
510 }
511 
512 /**
513  * @tc.name: IsVectorSame04
514  * @tc.desc: IsVectorSame
515  * @tc.type: FUNC
516  */
517 HWTEST_F(SceneSessionManagerTest4, IsVectorSame04, Function | SmallTest | Level3)
518 {
519     ASSERT_NE(nullptr, ssm_);
520     std::vector<VisibleWindowNumInfo> lastInfo;
521     std::vector<VisibleWindowNumInfo> currentInfo;
522     VisibleWindowNumInfo twoNum;
523     currentInfo.clear();
524     twoNum.displayId = 1;
525     twoNum.visibleWindowNum = 3;
526     currentInfo.push_back(twoNum);
527     EXPECT_EQ(false, ssm_->IsVectorSame(lastInfo, currentInfo));
528 }
529 
530 /**
531  * @tc.name: ReportWindowProfileInfos
532  * @tc.desc: ReportWindowProfileInfos
533  * @tc.type: FUNC
534  */
535 HWTEST_F(SceneSessionManagerTest4, ReportWindowProfileInfos, Function | SmallTest | Level3)
536 {
537     ASSERT_NE(nullptr, ssm_);
538     SessionInfo info;
539     info.abilityName_ = "SetBrightness";
540     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
541     ASSERT_NE(sceneSession, nullptr);
542     sceneSession->sessionInfo_.isSystem_ = false;
543     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
544     ssm_->ReportWindowProfileInfos();
545     auto focusGroup = ssm_->windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID);
546     focusGroup->SetFocusedSessionId(123);
547     ssm_->ReportWindowProfileInfos();
548     EXPECT_EQ(WSError::WS_ERROR_INVALID_SESSION, ssm_->HandleSecureSessionShouldHide(nullptr));
549 }
550 
551 /**
552  * @tc.name: ReportWindowProfileInfos02
553  * @tc.desc: ReportWindowProfileInfos
554  * @tc.type: FUNC
555  */
556 HWTEST_F(SceneSessionManagerTest4, ReportWindowProfileInfos02, Function | SmallTest | Level3)
557 {
558     ASSERT_NE(nullptr, ssm_);
559     SessionInfo info;
560     info.abilityName_ = "SetBrightness";
561     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
562     ASSERT_NE(sceneSession, nullptr);
563     sceneSession->sessionInfo_.isSystem_ = false;
564     sptr<Session> session = sptr<Session>::MakeSptr(info);
565     ASSERT_NE(session, nullptr);
566     ASSERT_NE(sceneSession->property_, nullptr);
567     sceneSession->property_->type_ = WindowType::WINDOW_TYPE_MEDIA;
568     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
569     ssm_->ReportWindowProfileInfos();
570     EXPECT_EQ(WSError::WS_ERROR_INVALID_SESSION, ssm_->HandleSecureSessionShouldHide(nullptr));
571 }
572 
573 /**
574  * @tc.name: ReportWindowProfileInfos03
575  * @tc.desc: ReportWindowProfileInfos
576  * @tc.type: FUNC
577  */
578 HWTEST_F(SceneSessionManagerTest4, ReportWindowProfileInfos03, Function | SmallTest | Level3)
579 {
580     ASSERT_NE(nullptr, ssm_);
581     SessionInfo info;
582     info.abilityName_ = "SetBrightness";
583     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
584     ASSERT_NE(sceneSession, nullptr);
585     sceneSession->sessionInfo_.isSystem_ = true;
586     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
587     ssm_->ReportWindowProfileInfos();
588     EXPECT_EQ(WSError::WS_ERROR_INVALID_SESSION, ssm_->HandleSecureSessionShouldHide(nullptr));
589 }
590 
591 /**
592  * @tc.name: ReportWindowProfileInfos04
593  * @tc.desc: ReportWindowProfileInfos
594  * @tc.type: FUNC
595  */
596 HWTEST_F(SceneSessionManagerTest4, ReportWindowProfileInfos04, Function | SmallTest | Level3)
597 {
598     ASSERT_NE(nullptr, ssm_);
599     ssm_->sceneSessionMap_.insert(std::make_pair(1, nullptr));
600     ssm_->ReportWindowProfileInfos();
601     EXPECT_EQ(WSError::WS_ERROR_INVALID_SESSION, ssm_->HandleSecureSessionShouldHide(nullptr));
602 }
603 
604 /**
605  * @tc.name: CacVisibleWindowNum
606  * @tc.desc: CacVisibleWindowNum
607  * @tc.type: FUNC
608  */
609 HWTEST_F(SceneSessionManagerTest4, CacVisibleWindowNum, Function | SmallTest | Level3)
610 {
611     ASSERT_NE(nullptr, ssm_);
612     SessionInfo info;
613     info.abilityName_ = "SetBrightness";
614     sptr<SceneSession> sceneSession01 = sptr<SceneSession>::MakeSptr(info, nullptr);
615     sptr<SceneSession> sceneSession02 = sptr<SceneSession>::MakeSptr(info, nullptr);
616     sptr<SceneSession> sceneSession03 = sptr<SceneSession>::MakeSptr(info, nullptr);
617     sptr<SceneSession> sceneSession04 = sptr<SceneSession>::MakeSptr(info, nullptr);
618     ASSERT_NE(sceneSession01, nullptr);
619     ASSERT_NE(sceneSession02, nullptr);
620     ASSERT_NE(sceneSession03, nullptr);
621     ASSERT_NE(sceneSession04, nullptr);
622     ASSERT_NE(sceneSession01->property_, nullptr);
623     sceneSession01->property_->type_ = WindowType::WINDOW_TYPE_WALLPAPER;
624     sceneSession01->SetRSVisible(true);
625     sceneSession02->state_ = SessionState::STATE_BACKGROUND;
626     ASSERT_NE(sceneSession03->property_, nullptr);
627     sceneSession03->property_->type_ = WindowType::APP_MAIN_WINDOW_END;
628     ASSERT_NE(sceneSession04->property_, nullptr);
629     sceneSession04->property_->type_ = WindowType::WINDOW_TYPE_WALLPAPER;
630     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession01));
631     ssm_->sceneSessionMap_.insert(std::make_pair(2, sceneSession02));
632     ssm_->sceneSessionMap_.insert(std::make_pair(3, sceneSession03));
633     ssm_->sceneSessionMap_.insert(std::make_pair(4, sceneSession04));
634     ssm_->sceneSessionMap_.insert(std::make_pair(5, nullptr));
635 
636     ssm_->CacVisibleWindowNum();
637     EXPECT_EQ(WSError::WS_ERROR_INVALID_SESSION, ssm_->HandleSecureSessionShouldHide(nullptr));
638 }
639 
640 /**
641  * @tc.name: GetAppMainSceneSession
642  * @tc.desc: GetAppMainSceneSession
643  * @tc.type: FUNC
644  */
645 HWTEST_F(SceneSessionManagerTest4, GetAppMainSceneSession, Function | SmallTest | Level3)
646 {
647     ASSERT_NE(nullptr, ssm_);
648     SessionInfo info;
649     info.abilityName_ = "SetBrightness";
650     sptr<SceneSession> sceneSession;
651     sptr<SceneSession> sceneSession01 = sptr<SceneSession>::MakeSptr(info, nullptr);
652     sptr<SceneSession> sceneSession02 = sptr<SceneSession>::MakeSptr(info, nullptr);
653     ASSERT_NE(sceneSession01, nullptr);
654     ASSERT_NE(sceneSession02, nullptr);
655     ssm_->sceneSessionMap_.insert(std::make_pair(0, sceneSession));
656     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession01));
657     ssm_->sceneSessionMap_.insert(std::make_pair(2, sceneSession02));
658     EXPECT_EQ(ssm_->GetAppMainSceneSession(0, sceneSession), WSError::WS_ERROR_INVALID_SESSION);
659 
660     EXPECT_EQ(ssm_->GetAppMainSceneSession(1, sceneSession01), WSError::WS_OK);
661 
662     ASSERT_NE(sceneSession01->property_, nullptr);
663     sceneSession01->property_->type_ = WindowType::WINDOW_TYPE_MEDIA;
664     EXPECT_EQ(ssm_->GetAppMainSceneSession(1, sceneSession01), WSError::WS_ERROR_INVALID_CALLING);
665 
666     sceneSession01->property_->type_ = WindowType::WINDOW_TYPE_APP_SUB_WINDOW;
667     sceneSession01->property_->SetParentPersistentId(2);
668     EXPECT_EQ(ssm_->GetAppMainSceneSession(1, sceneSession01), WSError::WS_OK);
669 }
670 
671 /**
672  * @tc.name: GetImmersiveState01
673  * @tc.desc: GetImmersiveState
674  * @tc.type: FUNC
675  */
676 HWTEST_F(SceneSessionManagerTest4, GetImmersiveState01, Function | SmallTest | Level3)
677 {
678     ASSERT_NE(nullptr, ssm_);
679     ssm_->systemConfig_.windowUIType_ = WindowUIType::PC_WINDOW;
680 
681     SessionInfo info;
682     info.abilityName_ = "GetImmersiveState01";
683     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
684     ASSERT_NE(sceneSession, nullptr);
685     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
686 
687     sceneSession->property_->type_ = WindowType::APP_MAIN_WINDOW_BASE;
688     sceneSession->state_ = SessionState::STATE_ACTIVE;
689     sceneSession->state_ = SessionState::STATE_FOREGROUND;
690     sceneSession->property_->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
691     EXPECT_EQ(false, ssm_->GetImmersiveState(0u));
692     sceneSession->SetIsLayoutFullScreen(true);
693     EXPECT_EQ(true, ssm_->GetImmersiveState(0u));
694 }
695 
696 /**
697  * @tc.name: GetImmersiveState02
698  * @tc.desc: GetImmersiveState
699  * @tc.type: FUNC
700  */
701 HWTEST_F(SceneSessionManagerTest4, GetImmersiveState02, Function | SmallTest | Level3)
702 {
703     ASSERT_NE(nullptr, ssm_);
704     ssm_->systemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW;
705 
706     SessionInfo info;
707     info.abilityName_ = "GetImmersiveState02";
708     sptr<SceneSession> sceneSession01;
709     sptr<SceneSession> sceneSession02 = sptr<SceneSession>::MakeSptr(info, nullptr);
710     ASSERT_EQ(sceneSession01, nullptr);
711     ASSERT_NE(sceneSession02, nullptr);
712     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession01));
713     ssm_->sceneSessionMap_.insert(std::make_pair(2, sceneSession02));
714 
715     EXPECT_EQ(false, ssm_->GetImmersiveState(0u));
716     sceneSession02->property_->type_ = WindowType::APP_MAIN_WINDOW_END;
717     EXPECT_EQ(false, ssm_->GetImmersiveState(0u));
718     sceneSession02->property_->type_ = WindowType::APP_MAIN_WINDOW_BASE;
719     EXPECT_EQ(false, ssm_->GetImmersiveState(0u));
720     sceneSession02->state_ = SessionState::STATE_ACTIVE;
721     EXPECT_EQ(false, ssm_->GetImmersiveState(0u));
722     sceneSession02->state_ = SessionState::STATE_FOREGROUND;
723     EXPECT_EQ(false, ssm_->GetImmersiveState(0u));
724     sceneSession02->property_->SetWindowMode(WindowMode::WINDOW_MODE_UNDEFINED);
725     EXPECT_EQ(false, ssm_->GetImmersiveState(0u));
726     sceneSession02->property_->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
727     sceneSession02->property_->sysBarPropMap_[WindowType::WINDOW_TYPE_STATUS_BAR].enable_ = false;
728     EXPECT_EQ(true, ssm_->GetImmersiveState(0u));
729     sceneSession02->property_->sysBarPropMap_[WindowType::WINDOW_TYPE_STATUS_BAR].enable_ = true;
730     EXPECT_EQ(false, ssm_->GetImmersiveState(0u));
731 }
732 
733 /**
734  * @tc.name: UpdateSessionDisplayId
735  * @tc.desc: UpdateSessionDisplayId
736  * @tc.type: FUNC
737  */
738 HWTEST_F(SceneSessionManagerTest4, UpdateSessionDisplayId, Function | SmallTest | Level3)
739 {
740     ASSERT_NE(nullptr, ssm_);
741     auto result = ssm_->UpdateSessionDisplayId(0, 0);
742     EXPECT_EQ(result, WSError::WS_ERROR_INVALID_WINDOW);
743 
744     SessionInfo info;
745     info.abilityName_ = "SetBrightness";
746     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
747     ASSERT_NE(sceneSession, nullptr);
748     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
749     sceneSession->sessionInfo_.screenId_ = 6;
750     result = ssm_->UpdateSessionDisplayId(1, 2);
751     EXPECT_EQ(result, WSError::WS_OK);
752 }
753 
754 /**
755  * @tc.name: UpdateSessionWindowVisibilityListener02
756  * @tc.desc: UpdateSessionWindowVisibilityListener
757  * @tc.type: FUNC
758  */
759 HWTEST_F(SceneSessionManagerTest4, UpdateSessionWindowVisibilityListener02, Function | SmallTest | Level3)
760 {
761     ASSERT_NE(nullptr, ssm_);
762     SessionInfo info;
763     info.abilityName_ = "SetBrightness";
764     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
765     ASSERT_NE(sceneSession, nullptr);
766     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
767     int32_t persistentId = 1;
768     auto result = ssm_->UpdateSessionWindowVisibilityListener(persistentId, true);
769     EXPECT_EQ(result, WSError::WS_ERROR_INVALID_PERMISSION);
770 }
771 
772 /**
773  * @tc.name: UpdateDarkColorModeToRS
774  * @tc.desc: UpdateDarkColorModeToRS
775  * @tc.type: FUNC
776  * @tc.require: issueIB1N43
777  */
778 HWTEST_F(SceneSessionManagerTest4, UpdateDarkColorModeToRS, Function | SmallTest | Level3)
779 {
780     ASSERT_NE(nullptr, ssm_);
781     AbilityRuntime::ApplicationContext::applicationContext_ =
782         std::make_shared<AbilityRuntime::ApplicationContext>();
783     ASSERT_NE(nullptr, AbilityRuntime::ApplicationContext::applicationContext_);
784     AbilityRuntime::ApplicationContext::applicationContext_->contextImpl_ =
785         std::make_shared<AbilityRuntime::ContextImpl>();
786     ASSERT_NE(nullptr, AbilityRuntime::ApplicationContext::applicationContext_->contextImpl_);
787     AbilityRuntime::ApplicationContext::applicationContext_->contextImpl_->config_ =
788         std::make_shared<AppExecFwk::Configuration>();
789     ASSERT_NE(nullptr, AbilityRuntime::ApplicationContext::applicationContext_->GetConfiguration());
790     ssm_->UpdateDarkColorModeToRS();
791 }
792 
793 /**
794  * @tc.name: NotifySessionAINavigationBarChange
795  * @tc.desc: NotifySessionAINavigationBarChange
796  * @tc.type: FUNC
797  */
798 HWTEST_F(SceneSessionManagerTest4, NotifySessionAINavigationBarChange, Function | SmallTest | Level3)
799 {
800     ASSERT_NE(nullptr, ssm_);
801     SessionInfo info;
802     info.abilityName_ = "SetBrightness";
803     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
804     ASSERT_NE(sceneSession, nullptr);
805     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
806     ssm_->NotifySessionAINavigationBarChange(0);
807     ssm_->NotifySessionAINavigationBarChange(1);
808 
809     ASSERT_NE(sceneSession->property_, nullptr);
810     sceneSession->property_->type_ = WindowType::APP_SUB_WINDOW_END;
811     sceneSession->state_ = SessionState::STATE_ACTIVE;
812     ssm_->NotifySessionAINavigationBarChange(1);
813     EXPECT_EQ(WSError::WS_ERROR_INVALID_SESSION, ssm_->HandleSecureSessionShouldHide(nullptr));
814 }
815 
816 /**
817  * @tc.name: UpdateNormalSessionAvoidArea
818  * @tc.desc: UpdateNormalSessionAvoidArea
819  * @tc.type: FUNC
820  */
821 HWTEST_F(SceneSessionManagerTest4, UpdateNormalSessionAvoidArea, Function | SmallTest | Level3)
822 {
823     ASSERT_NE(nullptr, ssm_);
824     int32_t persistentId = 1;
825     sptr<SceneSession> sceneSession = nullptr;
826     bool needUpdate = true;
827     ssm_->UpdateNormalSessionAvoidArea(persistentId, sceneSession, needUpdate);
828     EXPECT_EQ(needUpdate, false);
829 
830     SessionInfo info;
831     info.abilityName_ = "SetBrightness";
832     sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
833     ASSERT_NE(sceneSession, nullptr);
834     ASSERT_NE(sceneSession->property_, nullptr);
835     sceneSession->property_->type_ = WindowType::APP_SUB_WINDOW_BASE;
836     needUpdate = true;
837     ssm_->UpdateNormalSessionAvoidArea(persistentId, sceneSession, needUpdate);
838     EXPECT_EQ(needUpdate, false);
839 
840     sceneSession->property_->type_ = WindowType::APP_SUB_WINDOW_END;
841     sceneSession->isVisible_ = true;
842     needUpdate = true;
843     ssm_->UpdateNormalSessionAvoidArea(persistentId, sceneSession, needUpdate);
844     EXPECT_EQ(needUpdate, false);
845 
846     ssm_->avoidAreaListenerSessionSet_.insert(1);
847     ssm_->UpdateNormalSessionAvoidArea(persistentId, sceneSession, needUpdate);
848     EXPECT_EQ(WSError::WS_ERROR_INVALID_SESSION, ssm_->HandleSecureSessionShouldHide(nullptr));
849 }
850 
851 /**
852  * @tc.name: UpdateRootSceneSessionAvoidArea
853  * @tc.desc: UpdateRootSceneSessionAvoidArea
854  * @tc.type: FUNC
855  */
856 HWTEST_F(SceneSessionManagerTest4, UpdateRootSceneSessionAvoidArea, Function | SmallTest | Level3)
857 {
858     ASSERT_NE(nullptr, ssm_);
859     int32_t persistentId = 1;
860     ssm_->rootSceneSession_ = sptr<RootSceneSession>::MakeSptr();
861     ASSERT_NE(nullptr, ssm_->rootSceneSession_);
862     bool needUpdate = false;
863     ssm_->UpdateRootSceneSessionAvoidArea(persistentId, needUpdate);
864 }
865 
866 /**
867  * @tc.name: UpdateAvoidSessionAvoidArea
868  * @tc.desc: UpdateAvoidSessionAvoidArea
869  * @tc.type: FUNC
870  */
871 HWTEST_F(SceneSessionManagerTest4, UpdateAvoidSessionAvoidArea, Function | SmallTest | Level3)
872 {
873     ASSERT_NE(nullptr, ssm_);
874     ssm_->avoidAreaListenerSessionSet_.insert(0);
875     ssm_->avoidAreaListenerSessionSet_.insert(1);
876     SessionInfo info;
877     info.abilityName_ = "SetBrightness";
878     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
879     ASSERT_NE(sceneSession, nullptr);
880     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
881     WindowType type = WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT;
882     ssm_->UpdateAvoidSessionAvoidArea(type);
883 
884     ASSERT_NE(sceneSession->property_, nullptr);
885     sceneSession->property_->type_ = WindowType::APP_MAIN_WINDOW_END;
886     sceneSession->isVisible_ = true;
887     ssm_->UpdateAvoidSessionAvoidArea(type);
888     EXPECT_EQ(WSError::WS_ERROR_INVALID_SESSION, ssm_->HandleSecureSessionShouldHide(nullptr));
889 }
890 
891 /**
892  * @tc.name: FindSessionByAffinity
893  * @tc.desc: FindSessionByAffinity
894  * @tc.type: FUNC
895  */
896 HWTEST_F(SceneSessionManagerTest4, FindSessionByAffinity, Function | SmallTest | Level3)
897 {
898     ASSERT_NE(nullptr, ssm_);
899     std::string affinity = "";
900     sptr<SceneSession> sceneSession = ssm_->FindSessionByAffinity(affinity);
901     EXPECT_EQ(sceneSession, nullptr);
902 }
903 
904 /**
905  * @tc.name: SetSystemAnimatedScenes
906  * @tc.desc: SetSystemAnimatedScenes
907  * @tc.type: FUNC
908  */
909 HWTEST_F(SceneSessionManagerTest4, SetSystemAnimatedScenes, Function | SmallTest | Level3)
910 {
911     ASSERT_NE(nullptr, ssm_);
912     SystemAnimatedSceneType sceneType = SystemAnimatedSceneType::SCENE_ENTER_MISSION_CENTER;
913     auto result = ssm_->SetSystemAnimatedScenes(sceneType);
914     EXPECT_EQ(result, WMError::WM_OK);
915 }
916 
917 /**
918  * @tc.name: GetProcessDrawingState
919  * @tc.desc: GetProcessDrawingState
920  * @tc.type: FUNC
921  */
922 HWTEST_F(SceneSessionManagerTest4, GetProcessDrawingState, Function | SmallTest | Level3)
923 {
924     ASSERT_NE(nullptr, ssm_);
925     uint64_t windowId = 10;
926     int32_t pid = 1;
927     SessionInfo info;
928     info.abilityName_ = "SetBrightness";
929     sptr<SceneSession> sceneSession01 = nullptr;
930     sptr<SceneSession> sceneSession02 = sptr<SceneSession>::MakeSptr(info, nullptr);
931     sptr<SceneSession> sceneSession03 = sptr<SceneSession>::MakeSptr(info, nullptr);
932     sptr<SceneSession> sceneSession04 = sptr<SceneSession>::MakeSptr(info, nullptr);
933     ASSERT_NE(sceneSession02, nullptr);
934     ASSERT_NE(sceneSession03, nullptr);
935     ASSERT_NE(sceneSession04, nullptr);
936     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession01));
937     ssm_->sceneSessionMap_.insert(std::make_pair(2, sceneSession02));
938     ssm_->sceneSessionMap_.insert(std::make_pair(3, sceneSession03));
939     ssm_->sceneSessionMap_.insert(std::make_pair(4, sceneSession04));
940     sceneSession02->SetCallingPid(pid);
941     struct RSSurfaceNodeConfig config;
942     sceneSession02->surfaceNode_ = RSSurfaceNode::Create(config);
943     ASSERT_NE(sceneSession02->surfaceNode_, nullptr);
944     sceneSession03->SetCallingPid(pid);
945     sceneSession03->surfaceNode_ = nullptr;
946     sceneSession04->SetCallingPid(6);
947     auto result = ssm_->GetProcessDrawingState(windowId, pid);
948     EXPECT_EQ(result, true);
949 }
950 
951 /**
952  * @tc.name: GetPreWindowDrawingState
953  * @tc.desc: GetPreWindowDrawingState
954  * @tc.type: FUNC
955  */
956 HWTEST_F(SceneSessionManagerTest4, GetPreWindowDrawingState, Function | SmallTest | Level3)
957 {
958     ASSERT_NE(nullptr, ssm_);
959     uint64_t surfaceId = 0;
960     int32_t pid = 10;
961     bool result = ssm_->GetPreWindowDrawingState(surfaceId, true, pid);
962     EXPECT_EQ(result, false);
963 
964     SessionInfo info;
965     info.abilityName_ = "SetBrightness";
966     sptr<SceneSession> sceneSession01 = sptr<SceneSession>::MakeSptr(info, nullptr);
967     ASSERT_NE(sceneSession01, nullptr);
968     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession01));
969     struct RSSurfaceNodeConfig config;
970     sceneSession01->surfaceNode_ = RSSurfaceNode::Create(config);
971     ASSERT_NE(sceneSession01->surfaceNode_, nullptr);
972     sceneSession01->surfaceNode_->id_ = 10;
973     surfaceId = 10;
974     result = ssm_->GetPreWindowDrawingState(surfaceId, true, pid);
975     EXPECT_EQ(result, false);
976 }
977 
978 /**
979  * @tc.name: GetWindowDrawingContentChangeInfo
980  * @tc.desc: GetWindowDrawingContentChangeInfo
981  * @tc.type: FUNC
982  */
983 HWTEST_F(SceneSessionManagerTest4, GetWindowDrawingContentChangeInfo, Function | SmallTest | Level3)
984 {
985     ASSERT_NE(nullptr, ssm_);
986     SessionInfo info;
987     info.abilityName_ = "SetBrightness";
988     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
989     ASSERT_NE(sceneSession, nullptr);
990     ssm_->sceneSessionMap_.insert(std::make_pair(0, nullptr));
991     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
992 
993     std::vector<std::pair<uint64_t, bool>> currDrawingContentData;
994     currDrawingContentData.push_back(std::make_pair(0, false));
995     currDrawingContentData.push_back(std::make_pair(1, true));
996 
997     struct RSSurfaceNodeConfig config;
998     sceneSession->surfaceNode_ = RSSurfaceNode::Create(config);
999     ASSERT_NE(sceneSession->surfaceNode_, nullptr);
1000     sceneSession->surfaceNode_->id_ = 0;
1001     sceneSession->SetCallingPid(0);
1002     sceneSession->SetDrawingContentState(true);
1003 
1004     auto result = ssm_->GetWindowDrawingContentChangeInfo(currDrawingContentData);
1005     EXPECT_EQ(result, currDrawingContentData);
1006 
1007     sceneSession->SetCallingPid(2);
1008     result = ssm_->GetWindowDrawingContentChangeInfo(currDrawingContentData);
1009     EXPECT_NE(result, currDrawingContentData);
1010 }
1011 
1012 /**
1013  * @tc.name: GetWindowDrawingContentChangeInfo02
1014  * @tc.desc: GetWindowDrawingContentChangeInfo02
1015  * @tc.type: FUNC
1016  */
1017 HWTEST_F(SceneSessionManagerTest4, GetWindowDrawingContentChangeInfo02, Function | SmallTest | Level3)
1018 {
1019     ASSERT_NE(nullptr, ssm_);
1020     SessionInfo info;
1021     info.abilityName_ = "GetWindowDrawingContentChangeInfo02";
1022     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1023     ASSERT_NE(sceneSession, nullptr);
1024     ssm_->sceneSessionMap_.insert(std::make_pair(0, nullptr));
1025 
1026     std::vector<std::pair<uint64_t, bool>> currDrawingContentData;
1027     currDrawingContentData.push_back(std::make_pair(0, false));
1028     currDrawingContentData.push_back(std::make_pair(1, true));
1029 
1030     auto result = ssm_->GetWindowDrawingContentChangeInfo(currDrawingContentData);
1031     EXPECT_EQ(result, currDrawingContentData);
1032 }
1033 
1034 /**
1035  * @tc.name: DealwithDrawingContentChange
1036  * @tc.desc: DealwithDrawingContentChange
1037  * @tc.type: FUNC
1038  */
1039 HWTEST_F(SceneSessionManagerTest4, DealwithDrawingContentChange, Function | SmallTest | Level3)
1040 {
1041     ASSERT_NE(nullptr, ssm_);
1042     SessionInfo info;
1043     info.abilityName_ = "SetBrightness";
1044     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1045     ASSERT_NE(sceneSession, nullptr);
1046     ssm_->sceneSessionMap_.insert(std::make_pair(0, nullptr));
1047 
1048     std::vector<std::pair<uint64_t, bool>> drawingContentChangeInfo;
1049     drawingContentChangeInfo.push_back(std::make_pair(0, true));
1050     drawingContentChangeInfo.push_back(std::make_pair(1, true));
1051     ssm_->DealwithDrawingContentChange(drawingContentChangeInfo);
1052 
1053     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
1054     struct RSSurfaceNodeConfig config;
1055     sceneSession->surfaceNode_ = RSSurfaceNode::Create(config);
1056     ASSERT_NE(sceneSession->surfaceNode_, nullptr);
1057     sceneSession->surfaceNode_->id_ = 1;
1058     ssm_->DealwithDrawingContentChange(drawingContentChangeInfo);
1059 
1060     ssm_->openDebugTrace_ = true;
1061     ssm_->DealwithDrawingContentChange(drawingContentChangeInfo);
1062     EXPECT_EQ(WSError::WS_ERROR_INVALID_SESSION, ssm_->HandleSecureSessionShouldHide(nullptr));
1063 }
1064 
1065 /**
1066  * @tc.name: GetSubSceneSession
1067  * @tc.desc: GetSubSceneSession
1068  * @tc.type: FUNC
1069  */
1070 HWTEST_F(SceneSessionManagerTest4, GetSubSceneSession, Function | SmallTest | Level3)
1071 {
1072     ASSERT_NE(nullptr, ssm_);
1073     SessionInfo info;
1074     info.abilityName_ = "GetSubSceneSession";
1075     sptr<SceneSession> sceneSession01 = sptr<SceneSession>::MakeSptr(info, nullptr);
1076     sptr<SceneSession> sceneSession02 = sptr<SceneSession>::MakeSptr(info, nullptr);
1077     sptr<SceneSession> sceneSession03 = sptr<SceneSession>::MakeSptr(info, nullptr);
1078     sptr<Session> session04 = sptr<Session>::MakeSptr(info);
1079     sptr<Session> session05 = sptr<Session>::MakeSptr(info);
1080     ASSERT_NE(sceneSession01, nullptr);
1081     ASSERT_NE(sceneSession02, nullptr);
1082     ASSERT_NE(sceneSession03, nullptr);
1083     ASSERT_NE(session04, nullptr);
1084     ASSERT_NE(session05, nullptr);
1085     sceneSession01->persistentId_ = 1;
1086     sceneSession02->persistentId_ = 2;
1087     sceneSession03->persistentId_ = 3;
1088     session04->persistentId_ = 4;
1089     session05->persistentId_ = 5;
1090     ssm_->sceneSessionMap_.insert(std::make_pair(0, nullptr));
1091     ssm_->sceneSessionMap_.insert(std::make_pair(sceneSession01->GetPersistentId(), sceneSession01));
1092     ssm_->sceneSessionMap_.insert(std::make_pair(sceneSession02->GetPersistentId(), sceneSession02));
1093     ssm_->sceneSessionMap_.insert(std::make_pair(sceneSession03->GetPersistentId(), sceneSession03));
1094     session04->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
1095     sceneSession01->property_->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
1096     sceneSession01->parentSession_ = session04;
1097     session05->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
1098     sceneSession02->property_->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
1099     sceneSession02->parentSession_ = session05;
1100     sceneSession03->property_->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
1101     sceneSession03->parentSession_ = sceneSession01;
1102     std::vector<sptr<SceneSession>> subSessions = ssm_->GetSubSceneSession(session04->GetPersistentId());
1103     EXPECT_EQ(subSessions.size(), 2);
1104 }
1105 
1106 /**
1107  * @tc.name: RemoveDuplicateSubSession
1108  * @tc.desc: RemoveDuplicateSubSession
1109  * @tc.type: FUNC
1110  */
1111 HWTEST_F(SceneSessionManagerTest4, RemoveDuplicateSubSession, Function | SmallTest | Level3)
1112 {
1113     ASSERT_NE(nullptr, ssm_);
1114     std::vector<std::pair<uint64_t, WindowVisibilityState>> visibilityChangeInfo;
1115     std::vector<sptr<SceneSession>> subSessions;
1116     visibilityChangeInfo.push_back(std::make_pair(0, WINDOW_VISIBILITY_STATE_NO_OCCLUSION));
1117     visibilityChangeInfo.push_back(std::make_pair(1, WINDOW_VISIBILITY_STATE_PARTICALLY_OCCLUSION));
1118 
1119     SessionInfo info;
1120     info.abilityName_ = "SetBrightness";
1121     sptr<SceneSession> sceneSession01 = sptr<SceneSession>::MakeSptr(info, nullptr);
1122     sptr<SceneSession> sceneSession02 = sptr<SceneSession>::MakeSptr(info, nullptr);
1123     sptr<SceneSession> sceneSession03 = nullptr;
1124     ASSERT_NE(sceneSession01, nullptr);
1125     ASSERT_NE(sceneSession02, nullptr);
1126     struct RSSurfaceNodeConfig config;
1127     sceneSession01->surfaceNode_ = RSSurfaceNode::Create(config);
1128     ASSERT_NE(sceneSession01->surfaceNode_, nullptr);
1129     sceneSession01->surfaceNode_->id_ = 0;
1130 
1131     ssm_->sceneSessionMap_.insert(std::make_pair(0, nullptr));
1132     ssm_->RemoveDuplicateSubSession(visibilityChangeInfo, subSessions);
1133 
1134     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession01));
1135     sceneSession02->persistentId_ = 2;
1136     subSessions.push_back(sceneSession01);
1137     subSessions.push_back(sceneSession02);
1138     subSessions.push_back(sceneSession03);
1139     ssm_->RemoveDuplicateSubSession(visibilityChangeInfo, subSessions);
1140     EXPECT_EQ(WSError::WS_ERROR_INVALID_SESSION, ssm_->HandleSecureSessionShouldHide(nullptr));
1141 }
1142 
1143 /**
1144  * @tc.name: UpdateSubWindowVisibility
1145  * @tc.desc: UpdateSubWindowVisibility
1146  * @tc.type: FUNC
1147  */
1148 HWTEST_F(SceneSessionManagerTest4, UpdateSubWindowVisibility, Function | SmallTest | Level3)
1149 {
1150     ASSERT_NE(nullptr, ssm_);
1151     SessionInfo info;
1152     info.abilityName_ = "SetBrightness";
1153     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1154     ASSERT_NE(sceneSession, nullptr);
1155     WindowVisibilityState visibleState = WINDOW_VISIBILITY_STATE_TOTALLY_OCCUSION;
1156     std::vector<std::pair<uint64_t, WindowVisibilityState>> visibilityChangeInfo;
1157     std::vector<sptr<WindowVisibilityInfo>> windowVisibilityInfos;
1158     std::string visibilityInfo = "";
1159     std::vector<std::pair<uint64_t, WindowVisibilityState>> currVisibleData;
1160     ssm_->UpdateSubWindowVisibility(sceneSession, visibleState, visibilityChangeInfo,
1161                                     windowVisibilityInfos, visibilityInfo, currVisibleData);
1162 
1163     ASSERT_NE(sceneSession->property_, nullptr);
1164     sceneSession->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_END);
1165     ssm_->UpdateSubWindowVisibility(sceneSession, visibleState, visibilityChangeInfo,
1166                                     windowVisibilityInfos, visibilityInfo, currVisibleData);
1167 
1168     sceneSession->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
1169     visibleState = WINDOW_VISIBILITY_STATE_PARTICALLY_OCCLUSION;
1170     ssm_->sceneSessionMap_.insert(std::make_pair(0, nullptr));
1171     ssm_->UpdateSubWindowVisibility(sceneSession, visibleState, visibilityChangeInfo,
1172                                     windowVisibilityInfos, visibilityInfo, currVisibleData);
1173 
1174     sptr<SceneSession> sceneSession01 = sptr<SceneSession>::MakeSptr(info, nullptr);
1175     sptr<SceneSession> sceneSession02 = sptr<SceneSession>::MakeSptr(info, nullptr);
1176     sptr<SceneSession> sceneSession03 = sptr<SceneSession>::MakeSptr(info, nullptr);
1177     sptr<Session> session03 = sptr<Session>::MakeSptr(info);
1178     ASSERT_NE(sceneSession01, nullptr);
1179     ASSERT_NE(sceneSession02, nullptr);
1180     ASSERT_NE(sceneSession03, nullptr);
1181     ASSERT_NE(session03, nullptr);
1182     sceneSession01->SetParentSession(session03);
1183     sceneSession02->SetParentSession(session03);
1184     sceneSession03->SetParentSession(session03);
1185     sceneSession02->SetCallingPid(2);
1186     sceneSession03->SetCallingPid(3);
1187     sceneSession03->state_ = SessionState::STATE_FOREGROUND;
1188     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession01));
1189     ssm_->sceneSessionMap_.insert(std::make_pair(2, sceneSession02));
1190     ssm_->sceneSessionMap_.insert(std::make_pair(3, sceneSession03));
1191     ssm_->UpdateSubWindowVisibility(sceneSession, visibleState, visibilityChangeInfo,
1192                                     windowVisibilityInfos, visibilityInfo, currVisibleData);
1193     EXPECT_EQ(WSError::WS_ERROR_INVALID_SESSION, ssm_->HandleSecureSessionShouldHide(nullptr));
1194 }
1195 
1196 /**
1197  * @tc.name: SelectSesssionFromMap
1198  * @tc.desc: SelectSesssionFromMap
1199  * @tc.type: FUNC
1200  */
1201 HWTEST_F(SceneSessionManagerTest4, SelectSesssionFromMap, Function | SmallTest | Level3)
1202 {
1203     ASSERT_NE(nullptr, ssm_);
1204     uint64_t surfaceId = 6;
1205     uint64_t surfaceId02 = 7;
1206     SessionInfo info;
1207     info.abilityName_ = "SetBrightness";
1208     sptr<SceneSession> sceneSession;
1209     sptr<SceneSession> sceneSession01 = sptr<SceneSession>::MakeSptr(info, nullptr);
1210     sptr<SceneSession> sceneSession02 = sptr<SceneSession>::MakeSptr(info, nullptr);
1211     ASSERT_NE(sceneSession01, nullptr);
1212     ASSERT_NE(sceneSession02, nullptr);
1213     ssm_->sceneSessionMap_.insert(std::make_pair(0, sceneSession));
1214     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession01));
1215     ssm_->sceneSessionMap_.insert(std::make_pair(2, sceneSession02));
1216     sceneSession01->surfaceNode_ = nullptr;
1217     struct RSSurfaceNodeConfig config;
1218     sceneSession02->surfaceNode_ = RSSurfaceNode::Create(config);
1219     ASSERT_NE(sceneSession02->surfaceNode_, nullptr);
1220     NodeId id = 6;
1221     sceneSession02->surfaceNode_->SetId(id);
1222     EXPECT_EQ(sceneSession02->surfaceNode_->id_, 6);
1223 
1224     sptr<SceneSession> result = ssm_->SelectSesssionFromMap(surfaceId);
1225     EXPECT_EQ(result, sceneSession02);
1226     result = ssm_->SelectSesssionFromMap(surfaceId02);
1227     EXPECT_EQ(result, nullptr);
1228 }
1229 
1230 /**
1231  * @tc.name: GetAccessibilityWindowInfo
1232  * @tc.desc: GetAccessibilityWindowInfo
1233  * @tc.type: FUNC
1234  */
1235 HWTEST_F(SceneSessionManagerTest4, GetAccessibilityWindowInfo, Function | SmallTest | Level3)
1236 {
1237     ASSERT_NE(nullptr, ssm_);
1238     SessionInfo info;
1239     info.abilityName_ = "SetBrightness";
1240     sptr<SceneSession> sceneSession;
1241     sptr<SceneSession> sceneSession01 = sptr<SceneSession>::MakeSptr(info, nullptr);
1242     sptr<SceneSession> sceneSession02 = sptr<SceneSession>::MakeSptr(info, nullptr);
1243     sptr<SceneSession> sceneSession03 = sptr<SceneSession>::MakeSptr(info, nullptr);
1244     sptr<SceneSession> sceneSession04 = sptr<SceneSession>::MakeSptr(info, nullptr);
1245     ASSERT_NE(sceneSession01, nullptr);
1246     ASSERT_NE(sceneSession02, nullptr);
1247     ASSERT_NE(sceneSession03, nullptr);
1248     ASSERT_NE(sceneSession04, nullptr);
1249     sceneSession01->SetForceTouchable(true);
1250     sceneSession01->isVisible_ = true;
1251     ASSERT_NE(sceneSession01->property_, nullptr);
1252     sceneSession01->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
1253     sceneSession01->property_->SetParentPersistentId(4);
1254     sceneSession02->SetForceTouchable(false);
1255     sceneSession03->SetForceTouchable(true);
1256     sceneSession03->isVisible_ = true;
1257     ASSERT_NE(sceneSession03->property_, nullptr);
1258     sceneSession03->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
1259     sceneSession03->property_->SetParentPersistentId(6);
1260     ssm_->sceneSessionMap_.insert(std::make_pair(0, sceneSession));
1261     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession01));
1262     ssm_->sceneSessionMap_.insert(std::make_pair(2, sceneSession02));
1263     ssm_->sceneSessionMap_.insert(std::make_pair(3, sceneSession03));
1264     ssm_->sceneSessionMap_.insert(std::make_pair(4, sceneSession04));
1265     std::vector<sptr<AccessibilityWindowInfo>> accessibilityInfo;
1266     auto result = ssm_->GetAccessibilityWindowInfo(accessibilityInfo);
1267     EXPECT_EQ(result, WMError::WM_OK);
1268 }
1269 
1270 /**
1271  * @tc.name: ShiftAppWindowFocus02
1272  * @tc.desc: ShiftAppWindowFocus
1273  * @tc.type: FUNC
1274  */
1275 HWTEST_F(SceneSessionManagerTest4, ShiftAppWindowFocus02, Function | SmallTest | Level3)
1276 {
1277     ASSERT_NE(ssm_, nullptr);
1278     ssm_->SetFocusedSessionId(INVALID_SESSION_ID, DEFAULT_DISPLAY_ID);
1279     int32_t sourcePersistentId = INVALID_SESSION_ID;
1280     int32_t targetPersistentId = 1;
1281 
1282     auto result = ssm_->ShiftAppWindowFocus(sourcePersistentId, targetPersistentId);
1283     EXPECT_EQ(result, WSError::WS_ERROR_INVALID_SESSION);
1284 
1285     SessionInfo info;
1286     info.abilityName_ = "abilityName";
1287     info.bundleName_ = "bundleName";
1288     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1289     ssm_->sceneSessionMap_.insert(std::make_pair(INVALID_SESSION_ID, sceneSession));
1290     sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
1291     result = ssm_->ShiftAppWindowFocus(sourcePersistentId, targetPersistentId);
1292     EXPECT_EQ(result, WSError::WS_ERROR_INVALID_SESSION);
1293 
1294     SessionInfo info01;
1295     info01.abilityName_ = "abilityName01";
1296     info01.bundleName_ = "bundleName01";
1297     sptr<SceneSession> sceneSession01 = sptr<SceneSession>::MakeSptr(info01, nullptr);
1298     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession01));
1299     sceneSession01->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
1300     result = ssm_->ShiftAppWindowFocus(sourcePersistentId, targetPersistentId);
1301     EXPECT_EQ(result, WSError::WS_ERROR_INVALID_CALLING);
1302 }
1303 
1304 /**
1305  * @tc.name: UpdateTitleInTargetPos
1306  * @tc.desc: UpdateTitleInTargetPos
1307  * @tc.type: FUNC
1308  */
1309 HWTEST_F(SceneSessionManagerTest4, UpdateTitleInTargetPos, Function | SmallTest | Level3)
1310 {
1311     ASSERT_NE(ssm_, nullptr);
1312     SessionInfo info;
1313     info.abilityName_ = "abilityName";
1314     info.bundleName_ = "bundleName";
1315     info.isSystem_ = true;
1316     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1317     ASSERT_NE(sceneSession, nullptr);
1318     ssm_->sceneSessionMap_.insert(std::make_pair(0, sceneSession));
1319     auto result = ssm_->UpdateTitleInTargetPos(1, true, 1);
1320     ASSERT_EQ(result, WSError::WS_ERROR_INVALID_WINDOW);
1321 
1322     result = ssm_->UpdateTitleInTargetPos(0, true, 1);
1323     EXPECT_EQ(result, WSError::WS_ERROR_INVALID_SESSION);
1324 }
1325 
1326 /**
1327  * @tc.name: GetIsLayoutFullScreen
1328  * @tc.desc: GetIsLayoutFullScreen
1329  * @tc.type: FUNC
1330  */
1331 HWTEST_F(SceneSessionManagerTest4, GetIsLayoutFullScreen, Function | SmallTest | Level3)
1332 {
1333     ASSERT_NE(ssm_, nullptr);
1334     SessionInfo info;
1335     info.abilityName_ = "abilityName";
1336     info.bundleName_ = "bundleName";
1337     sptr<SceneSession> sceneSession01 = sptr<SceneSession>::MakeSptr(info, nullptr);
1338     sptr<SceneSession> sceneSession02 = sptr<SceneSession>::MakeSptr(info, nullptr);
1339     sptr<SceneSession> sceneSession03 = sptr<SceneSession>::MakeSptr(info, nullptr);
1340     sptr<SceneSession> sceneSession04 = sptr<SceneSession>::MakeSptr(info, nullptr);
1341     ASSERT_NE(sceneSession01, nullptr);
1342     ASSERT_NE(sceneSession02, nullptr);
1343     ASSERT_NE(sceneSession03, nullptr);
1344     ASSERT_NE(sceneSession04, nullptr);
1345     ASSERT_NE(sceneSession01->property_, nullptr);
1346     sceneSession01->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_END);
1347 
1348     ASSERT_NE(sceneSession02->property_, nullptr);
1349     sceneSession02->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
1350     sceneSession02->SetSessionState(SessionState::STATE_DISCONNECT);
1351 
1352     ASSERT_NE(sceneSession03->property_, nullptr);
1353     sceneSession03->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
1354     sceneSession03->SetSessionState(SessionState::STATE_ACTIVE);
1355     sceneSession03->property_->SetWindowMode(WindowMode::WINDOW_MODE_UNDEFINED);
1356 
1357     ASSERT_NE(sceneSession04->property_, nullptr);
1358     sceneSession04->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
1359     sceneSession04->SetSessionState(SessionState::STATE_FOREGROUND);
1360     sceneSession04->property_->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
1361     sceneSession04->property_->SetIsLayoutFullScreen(true);
1362 
1363     ASSERT_NE(sceneSession04->property_, nullptr);
1364     sceneSession04->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
1365     sceneSession04->SetSessionState(SessionState::STATE_FOREGROUND);
1366     sceneSession04->property_->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
1367     sceneSession04->property_->SetIsLayoutFullScreen(false);
1368 
1369     ssm_->sceneSessionMap_.insert(std::make_pair(0, nullptr));
1370     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession01));
1371     ssm_->sceneSessionMap_.insert(std::make_pair(2, sceneSession02));
1372     ssm_->sceneSessionMap_.insert(std::make_pair(3, sceneSession03));
1373     bool isLayoutFullScreen = true;
1374     auto result = ssm_->GetIsLayoutFullScreen(isLayoutFullScreen);
1375     EXPECT_EQ(result, WSError::WS_OK);
1376 }
1377 
1378 /**
1379  * @tc.name: UpdateExtWindowFlags
1380  * @tc.desc: UpdateExtWindowFlags
1381  * @tc.type: FUNC
1382  */
1383 HWTEST_F(SceneSessionManagerTest4, UpdateExtWindowFlags, Function | SmallTest | Level3)
1384 {
1385     ASSERT_NE(ssm_, nullptr);
1386     uint32_t extWindowFlags = 0;
1387     uint32_t extWindowActions = 0;
1388     auto ret = ssm_->UpdateExtWindowFlags(nullptr, extWindowFlags, extWindowActions);
1389     EXPECT_EQ(ret, WSError::WS_OK);
1390 }
1391 
1392 /**
1393  * @tc.name: AddOrRemoveSecureSession02
1394  * @tc.desc: AddOrRemoveSecureSession
1395  * @tc.type: FUNC
1396  */
1397 HWTEST_F(SceneSessionManagerTest4, AddOrRemoveSecureSession02, Function | SmallTest | Level3)
1398 {
1399     ASSERT_NE(ssm_, nullptr);
1400     int32_t persistentId = 1;
1401     bool shouldHide = true;
1402     SessionInfo info;
1403     info.abilityName_ = "secureSession";
1404     info.bundleName_ = "secureSession";
1405     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1406     ASSERT_NE(sceneSession, nullptr);
1407     ssm_->sceneSessionMap_.insert(std::make_pair(0, nullptr));
1408     ssm_->sceneSessionMap_.insert(std::make_pair(persistentId, sceneSession));
1409     auto result = ssm_->AddOrRemoveSecureSession(0, shouldHide);
1410     EXPECT_EQ(result, WSError::WS_OK);
1411     result = ssm_->AddOrRemoveSecureSession(persistentId, shouldHide);
1412     EXPECT_EQ(result, WSError::WS_OK);
1413     static constexpr uint32_t WAIT_SYNC_IN_NS = 500000;
1414     usleep(WAIT_SYNC_IN_NS);
1415 }
1416 
1417 /**
1418  * @tc.name: GetSessionSnapshotPixelMap
1419  * @tc.desc: GetSessionSnapshotPixelMap
1420  * @tc.type: FUNC
1421  */
1422 HWTEST_F(SceneSessionManagerTest4, GetSessionSnapshotPixelMap, Function | SmallTest | Level3)
1423 {
1424     ASSERT_NE(ssm_, nullptr);
1425     SessionInfo info;
1426     info.abilityName_ = "GetPixelMap";
1427     info.bundleName_ = "GetPixelMap1";
1428     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1429     ASSERT_NE(sceneSession, nullptr);
1430     sceneSession->SetSessionState(SessionState::STATE_ACTIVE);
1431     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
1432     int32_t persistentId = 1;
1433     float scaleParam = 0.5f;
1434     auto result = ssm_->GetSessionSnapshotPixelMap(persistentId, scaleParam);
1435     EXPECT_EQ(result, nullptr);
1436 
1437     sceneSession->SetSessionState(SessionState::STATE_FOREGROUND);
1438     std::string bundleName = "testBundleName";
1439     int32_t testpersistentId = 1;
1440     sceneSession->scenePersistence_ = sptr<ScenePersistence>::MakeSptr(bundleName, testpersistentId);
1441     ASSERT_NE(sceneSession->scenePersistence_, nullptr);
1442     struct RSSurfaceNodeConfig config;
1443     sceneSession->surfaceNode_ = RSSurfaceNode::Create(config);
1444     ASSERT_NE(sceneSession->surfaceNode_, nullptr);
1445     sceneSession->bufferAvailable_ = true;
1446     result = ssm_->GetSessionSnapshotPixelMap(persistentId, scaleParam);
1447     EXPECT_EQ(result, nullptr);
1448 }
1449 
1450 /**
1451  * @tc.name: HandleHideNonSystemFloatingWindows
1452  * @tc.desc: HandleHideNonSystemFloatingWindows
1453  * @tc.type: FUNC
1454  */
1455 HWTEST_F(SceneSessionManagerTest4, HandleHideNonSystemFloatingWindows, Function | SmallTest | Level3)
1456 {
1457     ASSERT_NE(ssm_, nullptr);
1458     SessionInfo info;
1459     info.abilityName_ = "abilityName";
1460     info.bundleName_ = "bundleName";
1461     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1462     ASSERT_NE(property, nullptr);
1463     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1464     ASSERT_NE(sceneSession, nullptr);
1465 
1466     sceneSession->property_->hideNonSystemFloatingWindows_ = true;
1467     property->SetHideNonSystemFloatingWindows(false);
1468     sceneSession->isVisible_ = true;
1469     sceneSession->state_ = SessionState::STATE_FOREGROUND;
1470     ssm_->HandleHideNonSystemFloatingWindows(property, sceneSession);
1471 
1472     sceneSession->property_->hideNonSystemFloatingWindows_ = false;
1473     property->SetHideNonSystemFloatingWindows(true);
1474     ssm_->HandleHideNonSystemFloatingWindows(property, sceneSession);
1475 
1476     sceneSession->isVisible_ = false;
1477     ssm_->HandleHideNonSystemFloatingWindows(property, sceneSession);
1478     EXPECT_EQ(Session::IsScbCoreEnabled(), true);
1479 }
1480 
1481 /**
1482  * @tc.name: GetAllClearableSessions
1483  * @tc.desc: GetAllClearableSessions
1484  * @tc.type: FUNC
1485  */
1486 HWTEST_F(SceneSessionManagerTest4, GetAllClearableSessions, Function | SmallTest | Level3)
1487 {
1488     SessionInfo sessionInfo;
1489     sessionInfo.bundleName_ = "bundleName";
1490     sessionInfo.abilityName_ = "abilityName";
1491     sessionInfo.abilityInfo = nullptr;
1492     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1493     ASSERT_NE(nullptr, ssm_);
1494     ASSERT_NE(nullptr, sceneSession);
1495     ssm_->sceneSessionMap_.insert(std::make_pair(2, sceneSession));
1496     SessionInfo sessionInfo1;
1497     sessionInfo1.bundleName_ = "bundleName";
1498     sessionInfo1.abilityName_ = "abilityName";
1499     sessionInfo1.abilityInfo = std::make_shared<AppExecFwk::AbilityInfo>();
1500     ASSERT_NE(nullptr, sessionInfo1.abilityInfo);
1501     sessionInfo1.abilityInfo->excludeFromMissions = false;
1502     sessionInfo1.abilityInfo->unclearableMission = false;
1503     sessionInfo1.isSystem_ = false;
1504     sessionInfo1.lockedState = false;
1505     sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(sessionInfo1, nullptr);
1506     ssm_->sceneSessionMap_.insert(std::make_pair(3, sceneSession1));
1507     std::vector<sptr<SceneSession>> sessionVector;
1508     sessionVector.clear();
1509     ssm_->GetAllClearableSessions(sessionVector);
1510     EXPECT_FALSE(sessionVector.empty());
1511 }
1512 
1513 /**
1514  * @tc.name: UpdateBrightness
1515  * @tc.desc: UpdateBrightness
1516  * @tc.type: FUNC
1517  */
1518 HWTEST_F(SceneSessionManagerTest4, UpdateBrightness, Function | SmallTest | Level3)
1519 {
1520     ASSERT_NE(ssm_, nullptr);
1521     SessionInfo sessionInfo;
1522     sessionInfo.isSystem_ = false;
1523     sessionInfo.bundleName_ = "bundleName";
1524     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1525     ASSERT_NE(sceneSession, nullptr);
1526     ASSERT_NE(sceneSession->property_, nullptr);
1527     sceneSession->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_END);
1528     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
1529     ssm_->systemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW;
1530     WSError result = ssm_->UpdateBrightness(1);
1531     EXPECT_EQ(result, WSError::WS_DO_NOTHING);
1532 
1533     SessionInfo sessionInfo02;
1534     sessionInfo02.isSystem_ = true;
1535     sessionInfo02.bundleName_ = "bundleName";
1536     sptr<SceneSession> sceneSession02 = sptr<SceneSession>::MakeSptr(sessionInfo02, nullptr);
1537     ASSERT_NE(sceneSession02, nullptr);
1538     ASSERT_NE(sceneSession02->property_, nullptr);
1539     ssm_->sceneSessionMap_.insert(std::make_pair(2, sceneSession02));
1540     sceneSession02->property_->SetBrightness(50.f);
1541     ssm_->SetDisplayBrightness(40.f);
1542     result = ssm_->UpdateBrightness(2);
1543     EXPECT_EQ(ssm_->displayBrightness_, 50);
1544     EXPECT_EQ(result, WSError::WS_OK);
1545 }
1546 
1547 /**
1548  * @tc.name: RegisterSessionExceptionFunc
1549  * @tc.desc: RegisterSessionExceptionFunc
1550  * @tc.type: FUNC
1551  */
1552 HWTEST_F(SceneSessionManagerTest4, RegisterSessionExceptionFunc, Function | SmallTest | Level3)
1553 {
1554     ASSERT_NE(ssm_, nullptr);
1555     SessionInfo sessionInfo;
1556     sessionInfo.bundleName_ = "bundleName";
1557     sessionInfo.persistentId_ = 1;
1558     sessionInfo.isSystem_ = true;
1559     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1560     ASSERT_NE(sceneSession, nullptr);
1561     ssm_->sceneSessionMap_.insert(std::make_pair(sessionInfo.persistentId_, sceneSession));
1562     std::shared_ptr<SessionListenerController> listenerController =
1563         std::make_shared<SessionListenerController>();
1564     ssm_->listenerController_ = listenerController;
1565     ASSERT_NE(ssm_->listenerController_, nullptr);
1566     ExceptionInfo exceptionInfo;
1567     ssm_->RegisterSessionExceptionFunc(sceneSession);
1568 
1569     sptr<AAFwk::SessionInfo> abilitySessionInfo = sptr<AAFwk::SessionInfo>::MakeSptr();
1570     ASSERT_NE(abilitySessionInfo, nullptr);
1571     WSError result = sceneSession->NotifySessionExceptionInner(abilitySessionInfo, exceptionInfo, false);
1572     EXPECT_EQ(result, WSError::WS_OK);
1573 
1574     abilitySessionInfo->errorCode = 1;
1575     result = sceneSession->NotifySessionExceptionInner(abilitySessionInfo, exceptionInfo, false);
1576     EXPECT_EQ(result, WSError::WS_OK);
1577 
1578     abilitySessionInfo->errorCode = 0;
1579     result = sceneSession->NotifySessionExceptionInner(abilitySessionInfo, exceptionInfo, false);
1580     EXPECT_EQ(result, WSError::WS_OK);
1581 
1582     sessionInfo.isSystem_ = false;
1583     result = sceneSession->NotifySessionExceptionInner(abilitySessionInfo, exceptionInfo, false);
1584     EXPECT_EQ(result, WSError::WS_OK);
1585 
1586     ssm_->listenerController_ = nullptr;
1587     result = sceneSession->NotifySessionExceptionInner(abilitySessionInfo, exceptionInfo, false);
1588     EXPECT_EQ(result, WSError::WS_OK);
1589 
1590     sessionInfo.persistentId_ = 2;
1591     result = sceneSession->NotifySessionExceptionInner(abilitySessionInfo, exceptionInfo, false);
1592     EXPECT_EQ(result, WSError::WS_OK);
1593     usleep(WAIT_SYNC_IN_NS);
1594 }
1595 
1596 /**
1597  * @tc.name: RegisterSessionSnapshotFunc
1598  * @tc.desc: RegisterSessionSnapshotFunc
1599  * @tc.type: FUNC
1600  */
1601 HWTEST_F(SceneSessionManagerTest4, RegisterSessionSnapshotFunc, Function | SmallTest | Level3)
1602 {
1603     ASSERT_NE(ssm_, nullptr);
1604     SessionInfo sessionInfo;
1605     sessionInfo.bundleName_ = "bundleName";
1606     sessionInfo.persistentId_ = 1;
1607     sessionInfo.isSystem_ = false;
1608     sessionInfo.abilityInfo = std::make_shared<AppExecFwk::AbilityInfo>();
1609     ASSERT_NE(sessionInfo.abilityInfo, nullptr);
1610     sessionInfo.abilityInfo->excludeFromMissions = true;
1611     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1612     ASSERT_NE(sceneSession, nullptr);
1613     sceneSession->scenePersistence_ = sptr<ScenePersistence>::MakeSptr("bundleName", 1);
1614     ASSERT_NE(sceneSession->scenePersistence_, nullptr);
1615     struct RSSurfaceNodeConfig rsSurfaceNodeConfig;
1616     sceneSession->surfaceNode_ = std::make_shared<RSSurfaceNode>(rsSurfaceNodeConfig, true, 0);
1617     ASSERT_NE(sceneSession->surfaceNode_, nullptr);
1618     sceneSession->surfaceNode_->bufferAvailable_ = true;
1619     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
1620     ssm_->listenerController_ = std::make_shared<SessionListenerController>();
1621     ASSERT_NE(ssm_->listenerController_, nullptr);
1622     ssm_->RegisterSessionSnapshotFunc(sceneSession);
1623     EXPECT_EQ(sceneSession->Snapshot(1.f), nullptr);
1624 
1625     sessionInfo.abilityInfo->excludeFromMissions = false;
1626     EXPECT_EQ(sceneSession->Snapshot(1.f), nullptr);
1627 
1628     ssm_->listenerController_ = nullptr;
1629     EXPECT_EQ(sceneSession->Snapshot(1.f), nullptr);
1630 
1631     sessionInfo.abilityInfo = nullptr;
1632     EXPECT_EQ(sceneSession->Snapshot(1.f), nullptr);
1633 
1634     sessionInfo.isSystem_ = true;
1635     EXPECT_EQ(sceneSession->Snapshot(1.f), nullptr);
1636 
1637     sessionInfo.persistentId_ = 2;
1638     EXPECT_EQ(sceneSession->Snapshot(1.f), nullptr);
1639     usleep(WAIT_SYNC_IN_NS);
1640 }
1641 
1642 /**
1643  * @tc.name: GetSessionDumpInfo
1644  * @tc.desc: GetSessionDumpInfo
1645  * @tc.type: FUNC
1646  */
1647 HWTEST_F(SceneSessionManagerTest4, GetSessionDumpInfo, Function | SmallTest | Level3)
1648 {
1649     ASSERT_NE(ssm_, nullptr);
1650     std::string dumpInfo = "testDumpInfo";
1651     std::vector<std::string> params = {"testDumpInfo"};
1652     WSError result = ssm_->GetSessionDumpInfo(params, dumpInfo);
1653     EXPECT_EQ(result, WSError::WS_ERROR_INVALID_OPERATION);
1654 
1655     params.clear();
1656     params.push_back("-w");
1657     params.push_back("a");
1658     result = ssm_->GetSessionDumpInfo(params, dumpInfo);
1659     EXPECT_EQ(result, WSError::WS_ERROR_INVALID_OPERATION);
1660 
1661     params.clear();
1662     params.push_back("-b");
1663     params.push_back("a");
1664     result = ssm_->GetSessionDumpInfo(params, dumpInfo);
1665     EXPECT_EQ(result, WSError::WS_OK);
1666 
1667     params.clear();
1668     params.push_back("-p");
1669     params.push_back("1");
1670     result = ssm_->GetSessionDumpInfo(params, dumpInfo);
1671     EXPECT_EQ(result, WSError::WS_OK);
1672 
1673     params.clear();
1674     params.push_back("-b");
1675     params.push_back("a");
1676     result = ssm_->GetSessionDumpInfo(params, dumpInfo);
1677     EXPECT_EQ(result, WSError::WS_OK);
1678 
1679     params.clear();
1680     params.push_back("testDumpInfo");
1681     params.push_back("a");
1682     result = ssm_->GetSessionDumpInfo(params, dumpInfo);
1683     EXPECT_EQ(result, WSError::WS_ERROR_INVALID_OPERATION);
1684 }
1685 
1686 /**
1687  * @tc.name: IsParentSessionVisible
1688  * @tc.desc: IsParentSessionVisible
1689  * @tc.type: FUNC
1690  */
1691 HWTEST_F(SceneSessionManagerTest4, IsParentSessionVisible, Function | SmallTest | Level3)
1692 {
1693     ASSERT_NE(ssm_, nullptr);
1694     SessionInfo sessionInfo;
1695     sessionInfo.bundleName_ = "bundleName";
1696     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1697     ASSERT_NE(sceneSession, nullptr);
1698     ASSERT_NE(sceneSession->property_, nullptr);
1699     sceneSession->property_->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
1700     sceneSession->property_->SetParentPersistentId(1);
1701     sceneSession->isVisible_ = false;
1702     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
1703     bool result = ssm_->IsParentSessionVisible(sceneSession);
1704     EXPECT_EQ(result, false);
1705 
1706     bool testRet = sceneSession->IsScbCoreEnabled();
1707     EXPECT_EQ(testRet, true);
1708 
1709     sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
1710     sceneSession->isVisible_ = true;
1711     sceneSession->SetSessionState(SessionState::STATE_FOREGROUND);
1712     result = ssm_->IsParentSessionVisible(sceneSession);
1713     EXPECT_EQ(result, true);
1714 
1715     sceneSession->property_->SetParentPersistentId(2);
1716     sceneSession->SetSessionState(SessionState::STATE_DISCONNECT);
1717     result = ssm_->IsParentSessionVisible(sceneSession);
1718     EXPECT_EQ(result, true);
1719 
1720     sceneSession->property_->SetWindowType(WindowType::SYSTEM_WINDOW_BASE);
1721     result = ssm_->IsParentSessionVisible(sceneSession);
1722     EXPECT_EQ(result, true);
1723 }
1724 
1725 /**
1726  * @tc.name: GetTopFocusableNonAppSession
1727  * @tc.desc: GetTopFocusableNonAppSession
1728  * @tc.type: FUNC
1729  */
1730 HWTEST_F(SceneSessionManagerTest4, GetTopFocusableNonAppSession, Function | SmallTest | Level3)
1731 {
1732     ASSERT_NE(ssm_, nullptr);
1733     SessionInfo sessionInfo;
1734     sessionInfo.bundleName_ = "bundleName";
1735     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1736     ASSERT_NE(sceneSession, nullptr);
1737     ASSERT_NE(sceneSession->property_, nullptr);
1738 
1739     sceneSession->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_END);
1740     sceneSession->property_->SetFocusable(true);
1741     sceneSession->isVisible_ = true;
1742     sceneSession->state_ = SessionState::STATE_FOREGROUND;
1743     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
1744     sptr<SceneSession> result = ssm_->GetTopFocusableNonAppSession();
1745     EXPECT_EQ(result, sceneSession);
1746 
1747     sceneSession->isVisible_ = false;
1748     result = ssm_->GetTopFocusableNonAppSession();
1749     EXPECT_EQ(result, nullptr);
1750 
1751     sceneSession->property_->SetFocusable(false);
1752     result = ssm_->GetTopFocusableNonAppSession();
1753     EXPECT_EQ(result, nullptr);
1754 
1755     sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
1756     result = ssm_->GetTopFocusableNonAppSession();
1757     EXPECT_EQ(result, nullptr);
1758 }
1759 
1760 /**
1761  * @tc.name: GetNextFocusableSession
1762  * @tc.desc: GetNextFocusableSession
1763  * @tc.type: FUNC
1764  */
1765 HWTEST_F(SceneSessionManagerTest4, GetNextFocusableSession, Function | SmallTest | Level3)
1766 {
1767     ASSERT_NE(ssm_, nullptr);
1768     SessionInfo sessionInfo;
1769     sessionInfo.bundleName_ = "bundleName";
1770     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1771     sptr<SceneSession> sceneSession02 = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1772     sptr<SceneSession> sceneSession03 = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1773     sptr<SceneSession> sceneSession04 = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1774     sptr<SceneSession> sceneSession05 = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1775     ASSERT_NE(sceneSession, nullptr);
1776     ASSERT_NE(sceneSession02, nullptr);
1777     ASSERT_NE(sceneSession03, nullptr);
1778     ASSERT_NE(sceneSession04, nullptr);
1779     ASSERT_NE(sceneSession05, nullptr);
1780     ASSERT_NE(sceneSession->property_, nullptr);
1781 
1782     sceneSession->SetForceHideState(ForceHideState::NOT_HIDDEN);
1783     sceneSession->property_->SetFocusable(true);
1784     sceneSession->property_->SetWindowType(WindowType::SYSTEM_WINDOW_BASE);
1785     sceneSession->isVisible_ = true;
1786     sceneSession->state_ = SessionState::STATE_FOREGROUND;
1787     sceneSession->SetZOrder(1);
1788 
1789     sceneSession02->SetFocusable(false);
1790     sceneSession02->SetZOrder(2);
1791 
1792     sceneSession03->SetZOrder(3);
1793 
1794     sceneSession04->SetForceHideState(ForceHideState::HIDDEN_WHEN_FOCUSED);
1795     sceneSession04->SetZOrder(4);
1796 
1797     sceneSession05->persistentId_ = 1;
1798     sceneSession05->SetZOrder(5);
1799 
1800     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
1801     ssm_->sceneSessionMap_.insert(std::make_pair(2, sceneSession02));
1802     ssm_->sceneSessionMap_.insert(std::make_pair(3, sceneSession03));
1803     ssm_->sceneSessionMap_.insert(std::make_pair(4, sceneSession04));
1804     ssm_->sceneSessionMap_.insert(std::make_pair(5, sceneSession05));
1805     sptr<SceneSession> result = ssm_->GetNextFocusableSession(DEFAULT_DISPLAY_ID, 1);
1806     EXPECT_EQ(result, sceneSession);
1807 }
1808 
1809 /**
1810  * @tc.name: GetTopNearestBlockingFocusSession
1811  * @tc.desc: GetTopNearestBlockingFocusSession
1812  * @tc.type: FUNC
1813  */
1814 HWTEST_F(SceneSessionManagerTest4, GetTopNearestBlockingFocusSession, Function | SmallTest | Level3)
1815 {
1816     ASSERT_NE(ssm_, nullptr);
1817     SessionInfo sessionInfo;
1818     sessionInfo.bundleName_ = "bundleName";
1819     sessionInfo.isSystem_ = true;
1820     sptr<SceneSession> sceneSession01 = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1821     sptr<SceneSession> sceneSession02 = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1822     sptr<SceneSession> sceneSession03 = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1823     sptr<SceneSession> sceneSession04 = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1824     sptr<SceneSession> parentSceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1825     ASSERT_NE(sceneSession01, nullptr);
1826     ASSERT_NE(sceneSession02, nullptr);
1827     ASSERT_NE(sceneSession03, nullptr);
1828     ASSERT_NE(sceneSession04, nullptr);
1829     ASSERT_NE(parentSceneSession, nullptr);
1830 
1831     sceneSession01->SetZOrder(1);
1832     sceneSession01->isVisible_ = true;
1833     sceneSession01->SetSessionState(SessionState::STATE_FOREGROUND);
1834 
1835     sceneSession02->SetZOrder(2);
1836     sceneSession02->isVisible_ = true;
1837     sceneSession02->SetSessionState(SessionState::STATE_FOREGROUND);
1838     sceneSession02->property_->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
1839     sceneSession02->blockingFocus_ = false;
1840 
1841     sceneSession03->SetZOrder(3);
1842     sceneSession03->property_->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
1843     parentSceneSession->property_->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
1844     sceneSession03->property_->SetParentPersistentId(8);
1845 
1846     sceneSession04->SetZOrder(4);
1847     sceneSession04->property_->SetParentPersistentId(1);
1848 
1849     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession01));
1850     ssm_->sceneSessionMap_.insert(std::make_pair(2, sceneSession02));
1851     ssm_->sceneSessionMap_.insert(std::make_pair(3, sceneSession03));
1852     ssm_->sceneSessionMap_.insert(std::make_pair(4, sceneSession04));
1853     ssm_->sceneSessionMap_.insert(std::make_pair(8, parentSceneSession));
1854 
1855     sptr<SceneSession> ret = ssm_->GetTopNearestBlockingFocusSession(DEFAULT_DISPLAY_ID, 0, true);
1856     EXPECT_EQ(ret, sceneSession01);
1857 
1858     ret = ssm_->GetTopNearestBlockingFocusSession(DEFAULT_DISPLAY_ID, 10, true);
1859     EXPECT_EQ(ret, nullptr);
1860 }
1861 
1862 /**
1863  * @tc.name: RequestFocusSpecificCheck
1864  * @tc.desc: RequestFocusSpecificCheck
1865  * @tc.type: FUNC
1866  */
1867 HWTEST_F(SceneSessionManagerTest4, RequestFocusSpecificCheck, Function | SmallTest | Level3)
1868 {
1869     ASSERT_NE(ssm_, nullptr);
1870     SessionInfo sessionInfo;
1871     sessionInfo.bundleName_ = "bundleName";
1872     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1873     ASSERT_NE(sceneSession, nullptr);
1874     bool byForeground = true;
1875     FocusChangeReason reason = FocusChangeReason::CLIENT_REQUEST;
1876     sceneSession->SetForceHideState(ForceHideState::HIDDEN_WHEN_FOCUSED);
1877     WSError result = ssm_->RequestFocusSpecificCheck(DEFAULT_DISPLAY_ID, sceneSession, byForeground, reason);
1878     EXPECT_EQ(result, WSError::WS_ERROR_INVALID_OPERATION);
1879 
1880     sceneSession->SetForceHideState(ForceHideState::NOT_HIDDEN);
1881     sptr<SceneSession> sceneSession01 = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1882     ASSERT_NE(sceneSession01, nullptr);
1883     ssm_->sceneSessionMap_.insert(std::make_pair(0, sceneSession01));
1884     sceneSession01->parentSession_ = sceneSession;
1885     result = ssm_->RequestFocusSpecificCheck(DEFAULT_DISPLAY_ID, sceneSession, byForeground, reason);
1886     EXPECT_EQ(result, WSError::WS_OK);
1887 }
1888 
1889 /**
1890  * @tc.name: ProcessModalExtensionPointDown
1891  * @tc.desc: ProcessModalExtensionPointDown
1892  * @tc.type: FUNC
1893  */
1894 HWTEST_F(SceneSessionManagerTest4, ProcessModalExtensionPointDown, Function | SmallTest | Level3)
1895 {
1896     ASSERT_NE(ssm_, nullptr);
1897     sptr<IRemoteObject> token = sptr<IRemoteObjectMocker>::MakeSptr();
1898     ASSERT_NE(token, nullptr);
1899     int32_t posX = 1;
1900     int32_t posY = 1;
1901     ExtensionWindowAbilityInfo extensionWindowAbilityInfo;
1902     extensionWindowAbilityInfo.persistentId = 1;
1903     extensionWindowAbilityInfo.parentId = 2;
1904     ssm_->extSessionInfoMap_.insert(std::make_pair(token, extensionWindowAbilityInfo));
1905 
1906     SessionInfo sessionInfo;
1907     sessionInfo.bundleName_ = "bundleName";
1908     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1909     ASSERT_NE(sceneSession, nullptr);
1910     ssm_->sceneSessionMap_.insert(std::make_pair(2, sceneSession));
1911     ssm_->ProcessModalExtensionPointDown(token, posX, posY);
1912 
1913     ExtensionWindowEventInfo eventInfo;
1914     eventInfo.pid = 0;
1915     eventInfo.persistentId = 1;
1916     sceneSession->modalUIExtensionInfoList_.push_back(eventInfo);
1917     ssm_->ProcessModalExtensionPointDown(token, posX, posY);
1918 
1919     eventInfo.persistentId = 4;
1920     ssm_->ProcessModalExtensionPointDown(token, posX, posY);
1921 
1922     eventInfo.pid = 4;
1923     ssm_->ProcessModalExtensionPointDown(token, posX, posY);
1924 
1925     sceneSession->modalUIExtensionInfoList_.clear();
1926     ssm_->ProcessModalExtensionPointDown(token, posX, posY);
1927     bool result = true;
1928     EXPECT_EQ(WSError::WS_OK, ssm_->GetFreeMultiWindowEnableState(result));
1929     usleep(WAIT_SYNC_IN_NS);
1930 }
1931 }
1932 } // namespace Rosen
1933 } // namespace OHOS
1934 
1935