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