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 <bundle_mgr_interface.h>
19 #include <bundle_mgr_proxy.h>
20 #include <bundlemgr/launcher_service.h>
21 #include "iremote_object_mocker.h"
22 #include "interfaces/include/ws_common.h"
23 #include "iremote_object_mocker.h"
24 #include "session_manager/include/scene_session_manager.h"
25 #include "session_manager/include/screen_session_manager.h"
26 #include "session_info.h"
27 #include "session/host/include/scene_session.h"
28 #include "session/host/include/main_session.h"
29 #include "window_manager_agent.h"
30 #include "session_manager.h"
31 #include "zidl/window_manager_agent_interface.h"
32 #include "mock/mock_session_stage.h"
33 #include "mock/mock_window_event_channel.h"
34 #include "context.h"
35 
36 using namespace testing;
37 using namespace testing::ext;
38 
39 namespace OHOS {
40 namespace Rosen {
41 
42 class SceneSessionManagerTest5 : public testing::Test {
43 public:
44     static void SetUpTestCase();
45 
46     static void TearDownTestCase();
47 
48     void SetUp() override;
49 
50     void TearDown() override;
51 
52     static bool gestureNavigationEnabled_;
53 
54     static ProcessGestureNavigationEnabledChangeFunc callbackFunc_;
55     static sptr<SceneSessionManager> ssm_;
56 
57 private:
58     static constexpr uint32_t WAIT_SYNC_IN_NS = 200000;
59 };
60 
61 sptr<SceneSessionManager> SceneSessionManagerTest5::ssm_ = nullptr;
62 bool SceneSessionManagerTest5::gestureNavigationEnabled_ = true;
63 
64 ProcessGestureNavigationEnabledChangeFunc SceneSessionManagerTest5::callbackFunc_ = [](bool enable,
__anon3b1460510102(bool enable, const std::string& bundleName, GestureBackType type) 65     const std::string& bundleName, GestureBackType type) {
66     gestureNavigationEnabled_ = enable;
67 };
68 
69 
WindowChangedFuncTest(int32_t persistentId,WindowUpdateType type)70 void WindowChangedFuncTest(int32_t persistentId, WindowUpdateType type)
71 {
72 }
73 
ProcessStatusBarEnabledChangeFuncTest(bool enable)74 void ProcessStatusBarEnabledChangeFuncTest(bool enable)
75 {
76 }
77 
DumpRootSceneElementInfoFuncTest(const std::vector<std::string> & params,std::vector<std::string> & infos)78 void DumpRootSceneElementInfoFuncTest(const std::vector<std::string>& params, std::vector<std::string>& infos)
79 {
80 }
81 
SetUpTestCase()82 void SceneSessionManagerTest5::SetUpTestCase()
83 {
84     ssm_ = &SceneSessionManager::GetInstance();
85 }
86 
TearDownTestCase()87 void SceneSessionManagerTest5::TearDownTestCase()
88 {
89     ssm_->sceneSessionMap_.clear();
90     ssm_ = nullptr;
91 }
92 
SetUp()93 void SceneSessionManagerTest5::SetUp()
94 {
95     ssm_->sceneSessionMap_.clear();
96 }
97 
TearDown()98 void SceneSessionManagerTest5::TearDown()
99 {
100     ssm_->sceneSessionMap_.clear();
101     usleep(WAIT_SYNC_IN_NS);
102 }
103 
104 namespace {
105 /**
106  * @tc.name: NotifySessionTouchOutside
107  * @tc.desc: SceneSesionManager notify session touch outside
108  * @tc.type: FUNC
109  */
110 HWTEST_F(SceneSessionManagerTest5, NotifySessionTouchOutside01, Function | SmallTest | Level3)
111 {
112     sptr<WindowSessionProperty> property = new (std::nothrow) WindowSessionProperty();
113     ASSERT_NE(ssm_, nullptr);
114     ssm_->recoveringFinished_ = false;
115     SessionInfo info;
116     info.abilityName_ = "test1";
117     info.bundleName_ = "test2";
118     sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(info, property);
119     property->SetWindowType(WindowType::APP_WINDOW_BASE);
120     ssm_->NotifySessionTouchOutside(0);
121     property->SetPersistentId(1);
122     ssm_->NotifySessionTouchOutside(1);
123 }
124 
125 /**
126  * @tc.name: DestroyAndDisconnectSpecificSessionInner
127  * @tc.desc: check func DestroyAndDisconnectSpecificSessionInner
128  * @tc.type: FUNC
129  */
130 HWTEST_F(SceneSessionManagerTest5, DestroyAndDisconnectSpecificSessionInner, Function | SmallTest | Level2)
131 {
132     sptr<ISession> session;
133     sptr<WindowSessionProperty> property = new (std::nothrow) WindowSessionProperty();
134     ASSERT_NE(nullptr, property);
135     std::vector<int32_t> recoveredPersistentIds = {0, 1, 2};
136     ssm_->SetAlivePersistentIds(recoveredPersistentIds);
137     ProcessShiftFocusFunc shiftFocusFunc_;
138     property->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
139     ssm_->DestroyAndDisconnectSpecificSessionInner(1);
140     property->SetPersistentId(1);
141     ssm_->DestroyAndDisconnectSpecificSessionInner(1);
142 
143     property->SetWindowType(WindowType::WINDOW_TYPE_TOAST);
144     ssm_->DestroyAndDisconnectSpecificSessionInner(1);
145 }
146 
147 
148 /**
149  * @tc.name: DestroyAndDisconnectSpecificSessionWithDetachCallback
150  * @tc.desc: SceneSesionManager destroy and disconnect specific session with detach callback
151  * @tc.type: FUNC
152  */
153 HWTEST_F(SceneSessionManagerTest5, DestroyAndDetachCallback, Function | SmallTest | Level3)
154 {
155     int32_t persistentId = 0;
156     ASSERT_NE(ssm_, nullptr);
157     sptr<IRemoteObject> callback = new (std::nothrow) IRemoteObjectMocker();
158     ASSERT_NE(callback, nullptr);
159     ssm_->DestroyAndDisconnectSpecificSessionWithDetachCallback(persistentId, callback);
160     sptr<WindowSessionProperty> property;
161     ssm_->recoveringFinished_ = false;
162     SessionInfo info;
163     info.abilityName_ = "test1";
164     info.bundleName_ = "test2";
165     sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(info, property);
166     ssm_->DestroyAndDisconnectSpecificSessionWithDetachCallback(persistentId, callback);
167 }
168 
169 /**
170  * @tc.name: GetStartupPageFromResource
171  * @tc.desc: GetStartupPageFromResource
172  * @tc.type: FUNC
173  */
174 HWTEST_F(SceneSessionManagerTest5, GetStartupPageFromResource, Function | SmallTest | Level3)
175 {
176     ASSERT_NE(ssm_, nullptr);
177     AppExecFwk::AbilityInfo info;
178     info.startWindowBackgroundId = 1;
179     std::string path = "path";
180     uint32_t bgColor = 1;
181     ASSERT_EQ(false, ssm_->GetStartupPageFromResource(info, path, bgColor));
182     info.startWindowIconId = 0;
183     ASSERT_EQ(false, ssm_->GetStartupPageFromResource(info, path, bgColor));
184     info.hapPath = "hapPath";
185     ASSERT_EQ(false, ssm_->GetStartupPageFromResource(info, path, bgColor));
186 }
187 
188 /**
189  * @tc.name: GetStartupPage
190  * @tc.desc: GetStartupPage
191  * @tc.type: FUNC
192  */
193 HWTEST_F(SceneSessionManagerTest5, GetStartupPage, Function | SmallTest | Level3)
194 {
195     ASSERT_NE(ssm_, nullptr);
196     SessionInfo info;
197     info.abilityName_ = "test1";
198     info.bundleName_ = "test2";
199     sptr<AppExecFwk::IBundleMgr> bundleMgr_ = nullptr;
200     std::string path = "path";
201     uint32_t bgColor = 1;
202     ssm_->GetStartupPage(info, path, bgColor);
203 }
204 
205 /**
206  * @tc.name: OnSCBSystemSessionBufferAvailable
207  * @tc.desc: OnSCBSystemSessionBufferAvailable
208  * @tc.type: FUNC
209  */
210 HWTEST_F(SceneSessionManagerTest5, OnSCBSystemSessionBufferAvailable02, Function | SmallTest | Level3)
211 {
212     SceneSessionManager* sceneSessionManager = new SceneSessionManager();
213     ASSERT_NE(sceneSessionManager, nullptr);
214     sceneSessionManager->OnSCBSystemSessionBufferAvailable(WindowType::WINDOW_TYPE_FLOAT);
215     delete sceneSessionManager;
216 }
217 
218 /**
219  * @tc.name: CreateKeyboardPanelSession
220  * @tc.desc: CreateKeyboardPanelSession
221  * @tc.type: FUNC
222  */
223 HWTEST_F(SceneSessionManagerTest5, CreateKeyboardPanelSession, Function | SmallTest | Level3)
224 {
225     SceneSessionManager* sceneSessionManager = new SceneSessionManager();
226     ASSERT_NE(sceneSessionManager, nullptr);
227     SessionInfo info;
228     info.abilityName_ = "test1";
229     info.bundleName_ = "test2";
230     sptr<WindowSessionProperty> property = new (std::nothrow) WindowSessionProperty();
231     ASSERT_NE(property, nullptr);
232     property->SetWindowType(WindowType::SYSTEM_SUB_WINDOW_BASE);
233     sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
234     sceneSessionManager->CreateKeyboardPanelSession(sceneSession);
235     delete sceneSessionManager;
236 }
237 
238 /**
239  * @tc.name: PrepareTerminate
240  * @tc.desc: SceneSesionManager prepare terminate
241  * @tc.type: FUNC
242  */
243 HWTEST_F(SceneSessionManagerTest5, PrepareTerminate, Function | SmallTest | Level3)
244 {
245     int32_t persistentId = 1;
246     bool isPrepareTerminate = true;
247     SceneSessionManager* sceneSessionManager = new SceneSessionManager();
248     ASSERT_NE(sceneSessionManager, nullptr);
249     ASSERT_EQ(WSError::WS_OK, sceneSessionManager->PrepareTerminate(persistentId, isPrepareTerminate));
250     delete sceneSessionManager;
251 }
252 
253 /**
254  * @tc.name: IsKeyboardForeground
255  * @tc.desc: IsKeyboardForeground
256  * @tc.type: FUNC
257  */
258 HWTEST_F(SceneSessionManagerTest5, IsKeyboardForeground, Function | SmallTest | Level3)
259 {
260     SceneSessionManager* sceneSessionManager = new SceneSessionManager();
261     ASSERT_NE(sceneSessionManager, nullptr);
262     SessionInfo info;
263     info.abilityName_ = "test1";
264     info.bundleName_ = "test2";
265     sptr<WindowSessionProperty> property = new (std::nothrow) WindowSessionProperty();
266     ASSERT_NE(property, nullptr);
267     property->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
268     sceneSessionManager->IsKeyboardForeground();
269     property->SetWindowType(WindowType::WINDOW_TYPE_SYSTEM_ALARM_WINDOW);
270     sceneSessionManager->IsKeyboardForeground();
271     delete sceneSessionManager;
272 }
273 
274 /**
275  * @tc.name: RequestInputMethodCloseKeyboard
276  * @tc.desc: RequestInputMethodCloseKeyboard
277  * @tc.type: FUNC
278  */
279 HWTEST_F(SceneSessionManagerTest5, RequestInputMethodCloseKeyboard02, Function | SmallTest | Level3)
280 {
281     int32_t persistentId = -1;
282     bool isPrepareTerminate = true;
283     SceneSessionManager* sceneSessionManager = new SceneSessionManager();
284     ASSERT_NE(sceneSessionManager, nullptr);
285     sceneSessionManager->PrepareTerminate(persistentId, isPrepareTerminate);
286     delete sceneSessionManager;
287 }
288 
289 /**
290  * @tc.name: HandleSpecificSystemBarProperty
291  * @tc.desc: HandleSpecificSystemBarProperty
292  * @tc.type: FUNC
293  */
294 HWTEST_F(SceneSessionManagerTest5, HandleSpecificSystemBarProperty, Function | SmallTest | Level3)
295 {
296     ASSERT_NE(ssm_, nullptr);
297     SessionInfo info;
298     info.abilityName_ = "test1";
299     info.bundleName_ = "test2";
300     sptr<WindowSessionProperty> property = new (std::nothrow) WindowSessionProperty();
301     ASSERT_NE(property, nullptr);
302     sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
303     WindowType type = WindowType::WINDOW_TYPE_STATUS_BAR;
304     ssm_->HandleSpecificSystemBarProperty(type, property, sceneSession);
305 }
306 
307 /**
308  * @tc.name: UpdateBrightness
309  * @tc.desc: UpdateBrightness
310  * @tc.type: FUNC
311  */
312 HWTEST_F(SceneSessionManagerTest5, UpdateBrightness, Function | SmallTest | Level3)
313 {
314     ASSERT_NE(ssm_, nullptr);
315     SessionInfo info;
316     info.abilityName_ = "test1";
317     info.bundleName_ = "test2";
318     info.isSystem_ = false;
319     sptr<WindowSessionProperty> property = new (std::nothrow) WindowSessionProperty();
320     sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(info, property);
321     ASSERT_NE(property, nullptr);
322     ssm_->UpdateBrightness(1);
323     FocusChangeInfo focusInfo;
324     ssm_->GetCurrentUserId();
325     ssm_->GetFocusWindowInfo(focusInfo);
326 }
327 
328 /**
329  * @tc.name: RegisterSessionSnapshotFunc
330  * @tc.desc: RegisterSessionSnapshotFunc
331  * @tc.type: FUNC
332  */
333 HWTEST_F(SceneSessionManagerTest5, RegisterSessionSnapshotFunc, Function | SmallTest | Level3)
334 {
335     SessionInfo info;
336     info.abilityName_ = "test1";
337     info.bundleName_ = "test2";
338     sptr<SceneSession> scensession = nullptr;
339     ssm_->RegisterSessionSnapshotFunc(scensession);
340     sptr<WindowSessionProperty> property = new (std::nothrow) WindowSessionProperty();
341     ASSERT_NE(property, nullptr);
342     sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
343     ASSERT_NE(sceneSession, nullptr);
344     ssm_->RegisterSessionSnapshotFunc(scensession);
345     info.isSystem_ = false;
346     ssm_->RegisterSessionSnapshotFunc(scensession);
347     std::shared_ptr<AppExecFwk::AbilityInfo> abilityInfo;
348     ssm_->RegisterSessionSnapshotFunc(scensession);
349 }
350 
351 /**
352  * @tc.name: RequestAllAppSessionUnfocus
353  * @tc.desc: RequestAllAppSessionUnfocus
354  * @tc.type: FUNC
355  */
356 HWTEST_F(SceneSessionManagerTest5, RequestAllAppSessionUnfocus, Function | SmallTest | Level3)
357 {
358     SessionInfo info;
359     info.abilityName_ = "test1";
360     info.bundleName_ = "test2";
361     sptr<SceneSession> scensession = nullptr;
362     sptr<WindowSessionProperty> property = new (std::nothrow) WindowSessionProperty();
363     ASSERT_NE(property, nullptr);
364     scensession = new (std::nothrow) SceneSession(info, nullptr);
365     ASSERT_NE(scensession, nullptr);
366     ssm_->HandleHideNonSystemFloatingWindows(property, scensession);
367     ssm_->RequestAllAppSessionUnfocus();
368 }
369 
370 /**
371  * @tc.name: RequestSessionFocus
372  * @tc.desc: RequestSessionFocus
373  * @tc.type: FUNC
374  */
375 HWTEST_F(SceneSessionManagerTest5, RequestSessionFocus, Function | SmallTest | Level3)
376 {
377     SessionInfo info;
378     info.abilityName_ = "test1";
379     info.bundleName_ = "test2";
380     sptr<SceneSession> scensession = nullptr;
381     sptr<WindowSessionProperty> property = new (std::nothrow) WindowSessionProperty();
382     ASSERT_NE(property, nullptr);
383     property->SetFocusable(false);
384     sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
385     ASSERT_NE(sceneSession, nullptr);
386     FocusChangeReason reason = FocusChangeReason::DEFAULT;
387     ssm_->RequestSessionFocus(0, true, reason);
388     ssm_->RequestSessionFocus(100, true, reason);
389 }
390 
391 /**
392  * @tc.name: SetShiftFocusListener
393  * @tc.desc: SetShiftFocusListener
394  * @tc.type: FUNC
395  */
396 HWTEST_F(SceneSessionManagerTest5, SetShiftFocusListener, Function | SmallTest | Level3)
397 {
398     ASSERT_NE(ssm_, nullptr);
399     SessionInfo info;
400     info.abilityName_ = "test1";
401     info.bundleName_ = "test2";
402     FocusChangeReason reason = FocusChangeReason::SPLIT_SCREEN;
403     sptr<SceneSession> scensession = nullptr;
404     ssm_->ShiftFocus(scensession, reason);
405     info.isSystem_ = true;
406     sptr<WindowSessionProperty> property = new (std::nothrow) WindowSessionProperty();
407     ASSERT_NE(property, nullptr);
408     sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
409     ASSERT_NE(sceneSession, nullptr);
410     ProcessShiftFocusFunc fun;
411     NotifySCBAfterUpdateFocusFunc func;
412     ssm_->SetShiftFocusListener(fun);
413     ssm_->SetSCBFocusedListener(func);
414     ssm_->SetSCBUnfocusedListener(func);
415     ProcessCallingSessionIdChangeFunc func1;
416     ssm_->SetCallingSessionIdSessionListenser(func1);
417     ProcessStartUIAbilityErrorFunc func2;
418     ssm_->SetStartUIAbilityErrorListener(func2);
419     ssm_->ShiftFocus(sceneSession, reason);
420 }
421 
422 /**
423  * @tc.name: UpdateFocusStatus
424  * @tc.desc: UpdateFocusStatus
425  * @tc.type: FUNC
426  */
427 HWTEST_F(SceneSessionManagerTest5, UpdateFocusStatus, Function | SmallTest | Level3)
428 {
429     ASSERT_NE(ssm_, nullptr);
430     SessionInfo info;
431     info.abilityName_ = "test1";
432     info.bundleName_ = "test2";
433     sptr<SceneSession> scensession = nullptr;
434     ssm_->UpdateFocusStatus(scensession, false);
435     ssm_->UpdateFocusStatus(scensession, true);
436 
437     sptr<WindowSessionProperty> property = new (std::nothrow) WindowSessionProperty();
438     ASSERT_NE(property, nullptr);
439     sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
440     ASSERT_NE(sceneSession, nullptr);
441     ssm_->UpdateFocusStatus(sceneSession, true);
442     ssm_->UpdateFocusStatus(sceneSession, false);
443 }
444 
445 /**
446  * @tc.name: RequestSessionUnfocus
447  * @tc.desc: RequestSessionUnfocus
448  * @tc.type: FUNC
449  */
450 HWTEST_F(SceneSessionManagerTest5, RequestSessionUnfocus, Function | SmallTest | Level3)
451 {
452     SessionInfo info;
453     info.abilityName_ = "test1";
454     info.bundleName_ = "test2";
455     sptr<SceneSession> scensession = nullptr;
456     sptr<WindowSessionProperty> property = new (std::nothrow) WindowSessionProperty();
457     ASSERT_NE(property, nullptr);
458     sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
459     ASSERT_NE(sceneSession, nullptr);
460     FocusChangeReason reason = FocusChangeReason::MOVE_UP;
461     ssm_->RequestSessionUnfocus(0, reason);
462 }
463 
464 /**
465  * @tc.name: RequestFocusSpecificCheck
466  * @tc.desc: RequestFocusSpecificCheck
467  * @tc.type: FUNC
468  */
469 HWTEST_F(SceneSessionManagerTest5, RequestFocusSpecificCheck, Function | SmallTest | Level3)
470 {
471     SessionInfo info;
472     info.abilityName_ = "test1";
473     info.bundleName_ = "test2";
474     sptr<SceneSession> scensession = nullptr;
475     sptr<WindowSessionProperty> property = new (std::nothrow) WindowSessionProperty();
476     ASSERT_NE(property, nullptr);
477     sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
478     ASSERT_NE(sceneSession, nullptr);
479     FocusChangeReason reason = FocusChangeReason::MOVE_UP;
480     property->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
481     ssm_->RequestFocusSpecificCheck(sceneSession, true, reason);
482 
483     FocusChangeReason reason1 = FocusChangeReason::SPLIT_SCREEN;
484     property->SetWindowType(WindowType::APP_WINDOW_BASE);
485     ssm_->RequestFocusSpecificCheck(sceneSession, true, reason1);
486 }
487 
488 /**
489  * @tc.name: NotifyFocusStatus
490  * @tc.desc: NotifyFocusStatus
491  * @tc.type: FUNC
492  */
493 HWTEST_F(SceneSessionManagerTest5, NotifyFocusStatus, Function | SmallTest | Level3)
494 {
495     SessionInfo info;
496     info.abilityName_ = "test1";
497     info.bundleName_ = "test2";
498     sptr<SceneSession> scensession = nullptr;
499     ssm_->NotifyFocusStatus(scensession, true);
500     sptr<WindowSessionProperty> property = new (std::nothrow) WindowSessionProperty();
501     ASSERT_NE(property, nullptr);
502     sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
503     ASSERT_NE(sceneSession, nullptr);
504     ssm_->NotifyFocusStatus(sceneSession, false);
505     info.isSystem_ = true;
506     ssm_->NotifyFocusStatus(sceneSession, true);
507 }
508 
509 /**
510  * @tc.name: NotifyFocusStatusByMission
511  * @tc.desc: NotifyFocusStatusByMission
512  * @tc.type: FUNC
513  */
514 HWTEST_F(SceneSessionManagerTest5, NotifyFocusStatusByMission, Function | SmallTest | Level3)
515 {
516     SessionInfo info;
517     info.abilityName_ = "test1";
518     info.bundleName_ = "test2";
519     sptr<SceneSession> scensession = nullptr;
520     sptr<SceneSession> currSession = nullptr;
521     ssm_->NotifyFocusStatusByMission(scensession, currSession);
522     ASSERT_EQ(false, ssm_->MissionChanged(scensession, currSession));
523     std::shared_ptr<SessionListenerController> listenerController =
524         std::make_shared<SessionListenerController>();
525     ssm_->listenerController_ = listenerController;
526     scensession = new (std::nothrow) SceneSession(info, nullptr);
527     ASSERT_NE(scensession, nullptr);
528     ssm_->NotifyFocusStatusByMission(scensession, currSession);
529     ssm_->MissionChanged(scensession, currSession);
530     currSession = new (std::nothrow) SceneSession(info, nullptr);
531     ASSERT_NE(currSession, nullptr);
532     ssm_->NotifyFocusStatusByMission(scensession, currSession);
533     ssm_->MissionChanged(scensession, currSession);
534     info.isSystem_ = true;
535     ssm_->NotifyFocusStatusByMission(scensession, currSession);
536     ssm_->MissionChanged(scensession, currSession);
537 }
538 
539 /**
540  * @tc.name: UpdateFocus
541  * @tc.desc: UpdateFocus
542  * @tc.type: FUNC
543  */
544 HWTEST_F(SceneSessionManagerTest5, UpdateFocus, Function | SmallTest | Level3)
545 {
546     SessionInfo info;
547     info.abilityName_ = "test1";
548     info.bundleName_ = "test2";
549     sptr<SceneSession> scensession = nullptr;
550     sptr<WindowSessionProperty> property = new (std::nothrow) WindowSessionProperty();
551     ASSERT_NE(property, nullptr);
552     sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
553     ASSERT_NE(sceneSession, nullptr);
554     ssm_->UpdateFocus(1, true);
555     ssm_->UpdateFocus(0, false);
556 }
557 
558 /**
559  * @tc.name: RequestSessionFocusImmediately
560  * @tc.desc: RequestSessionFocusImmediately
561  * @tc.type: FUNC
562  */
563 HWTEST_F(SceneSessionManagerTest5, RequestSessionFocusImmediately, Function | SmallTest | Level3)
564 {
565     SessionInfo info;
566     info.abilityName_ = "test1";
567     info.bundleName_ = "test2";
568     sptr<SceneSession> scensession = nullptr;
569     ssm_->RequestSessionFocusImmediately(0);
570     ssm_->RequestFocusBasicCheck(0);
571     sptr<WindowSessionProperty> property = new (std::nothrow) WindowSessionProperty();
572     ASSERT_NE(property, nullptr);
573     sptr<Session> session = new (std::nothrow) Session(info);
574     session->SetSessionProperty(property);
575     sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
576     ASSERT_NE(sceneSession, nullptr);
577     ssm_->RequestSessionFocusImmediately(1);
578     ssm_->RequestFocusBasicCheck(1);
579 }
580 /**
581  * @tc.name: CheckFocusIsDownThroughBlockingType
582  * @tc.desc: CheckFocusIsDownThroughBlockingType
583  * @tc.type: FUNC
584  */
585 HWTEST_F(SceneSessionManagerTest5, CheckFocusIsDownThroughBlockingType, Function | SmallTest | Level3)
586 {
587     SessionInfo info;
588     info.abilityName_ = "test1";
589     info.bundleName_ = "test1";
590     SessionInfo info2;
591     info2.abilityName_ = "test2";
592     info2.bundleName_ = "test2";
593     sptr<SceneSession> scensession = nullptr;
594     sptr<WindowSessionProperty> property = new (std::nothrow) WindowSessionProperty();
595     ASSERT_NE(property, nullptr);
596     sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info2, nullptr);
597     ASSERT_NE(sceneSession, nullptr);
598     sptr<SceneSession> sceneSession2 = new (std::nothrow) SceneSession(info2, nullptr);
599     ASSERT_NE(sceneSession2, nullptr);
600     ssm_->CheckFocusIsDownThroughBlockingType(sceneSession, sceneSession2, true);
601 }
602 
603 
604 /**
605  * @tc.name: CheckFocusIsDownThroughBlockingType
606  * @tc.desc: CheckFocusIsDownThroughBlockingType
607  * @tc.type: FUNC
608  */
609 HWTEST_F(SceneSessionManagerTest5, CheckFocusIsDownThroughBlockingType01, Function | SmallTest | Level3)
610 {
611     ASSERT_NE(ssm_, nullptr);
612     SessionInfo info;
613     info.abilityName_ = "test1";
614     info.bundleName_ = "test2";
615     sptr<SceneSession> requestSceneSession = new (std::nothrow) SceneSession(info, nullptr);
616     ASSERT_NE(requestSceneSession, nullptr);
617     sptr<SceneSession> focusedSession = new (std::nothrow) SceneSession(info, nullptr);
618     ASSERT_NE(focusedSession, nullptr);
619     bool includingAppSession = true;
620     ssm_->CheckFocusIsDownThroughBlockingType(requestSceneSession, focusedSession, includingAppSession);
621 
622     requestSceneSession->SetZOrder(0);
623     focusedSession->SetZOrder(1);
624     sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
625     ASSERT_NE(sceneSession, nullptr);
626     Session session = Session(info);
627     session.property_ = nullptr;
628     session.SetZOrder(2);
629 
630     session.property_ = new WindowSessionProperty();
631     session.isVisible_ = true;
632     ssm_->CheckFocusIsDownThroughBlockingType(requestSceneSession, focusedSession, includingAppSession);
633 }
634 
635 /**
636  * @tc.name: CheckTopmostWindowFocus
637  * @tc.desc: CheckTopmostWindowFocus
638  * @tc.type: FUNC
639  */
640 HWTEST_F(SceneSessionManagerTest5, CheckTopmostWindowFocus, Function | SmallTest | Level3)
641 {
642     ASSERT_NE(ssm_, nullptr);
643     SessionInfo info;
644     info.abilityName_ = "test1";
645     info.bundleName_ = "test2";
646 
647     sptr<SceneSession> focusedSession = new (std::nothrow) SceneSession(info, nullptr);
648     ASSERT_NE(focusedSession, nullptr);
649     sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
650     ASSERT_NE(sceneSession, nullptr);
651     Session session = Session(info);
652     session.property_ = nullptr;
653 
654     session.persistentId_ = 1;
655     focusedSession->GetMissionId();
656     ssm_->CheckTopmostWindowFocus(focusedSession, sceneSession);
657 }
658 
659 /**
660  * @tc.name: CheckRequestFocusImmdediately
661  * @tc.desc: CheckRequestFocusImmdediately
662  * @tc.type: FUNC
663  */
664 HWTEST_F(SceneSessionManagerTest5, CheckRequestFocusImmdediately, Function | SmallTest | Level3)
665 {
666     ASSERT_NE(ssm_, nullptr);
667     SessionInfo info;
668     info.abilityName_ = "test1";
669     info.bundleName_ = "test2";
670 
671     sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
672     ASSERT_NE(sceneSession, nullptr);
673     Session session = Session(info);
674     session.property_ = nullptr;
675     ssm_->CheckRequestFocusImmdediately(sceneSession);
676 }
677 
678 /**
679  * @tc.name: GetNextFocusableSession
680  * @tc.desc: GetNextFocusableSession
681  * @tc.type: FUNC
682  */
683 HWTEST_F(SceneSessionManagerTest5, GetNextFocusableSession, Function | SmallTest | Level3)
684 {
685     int32_t persistentId = 0;
686     ASSERT_NE(ssm_, nullptr);
687     SessionInfo info;
688     info.abilityName_ = "test1";
689     info.bundleName_ = "test2";
690 
691     sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
692     ASSERT_NE(sceneSession, nullptr);
693     ssm_->GetNextFocusableSession(persistentId);
694     sceneSession->GetForceHideState();
695     Session session = Session(info);
696     session.property_ = new WindowSessionProperty();
697     sptr<WindowSessionProperty> windowSessionProperty = new WindowSessionProperty();
698     ASSERT_NE(windowSessionProperty, nullptr);
699     ssm_->GetNextFocusableSession(persistentId);
700 }
701 
702 /**
703  * @tc.name: GetTopNearestBlockingFocusSession
704  * @tc.desc: GetTopNearestBlockingFocusSession
705  * @tc.type: FUNC
706  */
707 HWTEST_F(SceneSessionManagerTest5, GetTopNearestBlockingFocusSession, Function | SmallTest | Level3)
708 {
709     ASSERT_NE(ssm_, nullptr);
710     SessionInfo info;
711     info.abilityName_ = "test1";
712     info.bundleName_ = "test2";
713 
714     ssm_->GetTopNearestBlockingFocusSession(2, true);
715     sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
716     ASSERT_NE(sceneSession, nullptr);
717     ssm_->GetTopNearestBlockingFocusSession(0, true);
718 
719     Session session = Session(info);
720     session.property_ = nullptr;
721     ssm_->GetTopNearestBlockingFocusSession(0, true);
722     sptr<SceneSession> session_ = nullptr;
723     ssm_->GetTopNearestBlockingFocusSession(0, true);
724     session_ = new (std::nothrow) SceneSession(info, nullptr);
725     ASSERT_NE(session_, nullptr);
726     ssm_->GetTopNearestBlockingFocusSession(0, true);
727 }
728 
729 /**
730  * @tc.name: PreloadInLakeApp、UpdateSessionAvoidAreaListener
731  * @tc.desc: PreloadInLakeApp、UpdateSessionAvoidAreaListener
732  * @tc.type: FUNC
733  */
734 HWTEST_F(SceneSessionManagerTest5, PreloadInLakeApp, Function | SmallTest | Level3)
735 {
736     ASSERT_NE(ssm_, nullptr);
737     SessionInfo info;
738     info.abilityName_ = "test1";
739     info.bundleName_ = "test2";
740     int32_t persistentId = 0;
741 
742     ssm_->PreloadInLakeApp("");
743     sptr<SceneSession> sceneSession = nullptr;
744 
745     ssm_->UpdateSessionAvoidAreaListener(persistentId, true);
746     sceneSession = ssm_->CreateSceneSession(info, nullptr);
747     ASSERT_NE(nullptr, sceneSession);
748     ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
749     ssm_->UpdateSessionAvoidAreaListener(persistentId, true);
750 }
751 
752 /**
753  * @tc.name: NotifyMMIWindowPidChange
754  * @tc.desc: NotifyMMIWindowPidChange
755  * @tc.type: FUNC
756  */
757 HWTEST_F(SceneSessionManagerTest5, NotifyMMIWindowPidChange, Function | SmallTest | Level3)
758 {
759     ASSERT_NE(ssm_, nullptr);
760     SessionInfo info;
761     info.abilityName_ = "test1";
762     info.bundleName_ = "test2";
763     sptr<SceneSession> sceneSession = nullptr;
764     ssm_->NotifyMMIWindowPidChange(0, true);
765     sceneSession = ssm_->CreateSceneSession(info, nullptr);
766     ASSERT_NE(nullptr, sceneSession);
767     ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
768 }
769 
770 /**
771  * @tc.name: CheckModalSubWindowPermission
772  * @tc.desc: CheckModalSubWindowPermission
773  * @tc.type: FUNC
774  */
775 HWTEST_F(SceneSessionManagerTest5, CheckModalSubWindowPermission, Function | SmallTest | Level3)
776 {
777     ASSERT_NE(ssm_, nullptr);
778     SessionInfo info;
779     info.abilityName_ = "test1";
780     info.bundleName_ = "test2";
781     sptr<WindowSessionProperty> property = new (std::nothrow) WindowSessionProperty();
782     ASSERT_NE(property, nullptr);
783     property->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
784     property->SetWindowFlags(123);
785     ssm_->CheckModalSubWindowPermission(property);
786     property->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
787     ssm_->CheckModalSubWindowPermission(property);
788 }
789 
790 /**
791  * @tc.name: CheckSessionPropertyOnRecovery
792  * @tc.desc: CheckSessionPropertyOnRecovery
793  * @tc.type: FUNC
794  */
795 HWTEST_F(SceneSessionManagerTest5, CheckSessionPropertyOnRecovery, Function | SmallTest | Level3)
796 {
797     ASSERT_NE(ssm_, nullptr);
798     SessionInfo info;
799     info.abilityName_ = "test1";
800     info.bundleName_ = "test2";
801     sptr<WindowSessionProperty> property = new (std::nothrow) WindowSessionProperty();
802     ASSERT_NE(property, nullptr);
803     property->SetWindowType(WindowType::WINDOW_TYPE_UI_EXTENSION);
804     property->SetWindowFlags(123);
805     ssm_->CheckSessionPropertyOnRecovery(property, false);
806     property->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
807     property->SetParentPersistentId(111);
808     ssm_->CheckSessionPropertyOnRecovery(property, true);
809 }
810 
811 /**
812  * @tc.name: SetCreateKeyboardSessionListener
813  * @tc.desc: SetCreateKeyboardSessionListener
814  * @tc.type: FUNC
815  */
816 HWTEST_F(SceneSessionManagerTest5, SetCreateKeyboardSessionListener, Function | SmallTest | Level3)
817 {
818     ASSERT_NE(ssm_, nullptr);
819     ssm_->SetCreateSystemSessionListener(nullptr);
820     SessionInfo sessionInfo;
821     sessionInfo.bundleName_ = "test1";
822     sessionInfo.abilityName_ = "test2";
823     sessionInfo.abilityInfo = nullptr;
824     sessionInfo.isAtomicService_ = true;
825     sessionInfo.screenId_ = SCREEN_ID_INVALID;
826     ssm_->NotifySessionTouchOutside(123);
827 }
828 
829 /**
830  * @tc.name: DestroyAndDisconnectSpecificSessionInner
831  * @tc.desc: check func DestroyAndDisconnectSpecificSessionInner
832  * @tc.type: FUNC
833  */
834 HWTEST_F(SceneSessionManagerTest5, DestroyAndDisconnectSpecificSessionInner02, Function | SmallTest | Level2)
835 {
836     ASSERT_NE(ssm_, nullptr);
837     SessionInfo info;
838     info.abilityName_ = "test1";
839     info.bundleName_ = "test2";
840     sptr<WindowSessionProperty> property = new (std::nothrow) WindowSessionProperty();
841     ASSERT_NE(nullptr, property);
842     std::vector<int32_t> recoveredPersistentIds = {0, 1, 2};
843     ssm_->SetAlivePersistentIds(recoveredPersistentIds);
844     property->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
845     ssm_->DestroyAndDisconnectSpecificSessionInner(1);
846 }
847 
848 /**
849  * @tc.name: DestroyToastSession
850  * @tc.desc: DestroyToastSession
851  * @tc.type: FUNC
852  */
853 HWTEST_F(SceneSessionManagerTest5, DestroyToastSession, Function | SmallTest | Level3)
854 {
855     ASSERT_NE(ssm_, nullptr);
856     SessionInfo info;
857     info.abilityName_ = "test1";
858     info.bundleName_ = "test2";
859     info.screenId_ = SCREEN_ID_INVALID;
860     sptr<WindowSessionProperty> property = new (std::nothrow) WindowSessionProperty();
861     ASSERT_NE(property, nullptr);
862     property->SetWindowType(WindowType::WINDOW_TYPE_KEYBOARD_PANEL);
863     sptr<SceneSession> sceneSession = nullptr;
864     ssm_->DestroyToastSession(sceneSession);
865     sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
866     ssm_->DestroyToastSession(sceneSession);
867     ssm_->StartUIAbilityBySCB(sceneSession);
868     ssm_->ChangeUIAbilityVisibilityBySCB(sceneSession, true);
869 }
870 
871 /**
872  * @tc.name: RequestSceneSessionBackground
873  * @tc.desc: RequestSceneSessionBackground
874  * @tc.type: FUNC
875  */
876 HWTEST_F(SceneSessionManagerTest5, RequestSceneSessionBackground, Function | SmallTest | Level3)
877 {
878     ASSERT_NE(ssm_, nullptr);
879     SessionInfo info;
880     info.abilityName_ = "test1";
881     info.bundleName_ = "test2";
882     info.ancoSceneState = 0;
883     sptr<WindowSessionProperty> property = new (std::nothrow) WindowSessionProperty();
884     ASSERT_NE(property, nullptr);
885     property->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
886     sptr<SceneSession> sceneSession = nullptr;
887     std::shared_ptr<std::promise<int32_t>> promise = std::make_shared<std::promise<int32_t>>();
888     ssm_->RequestSceneSessionBackground(sceneSession, true, true, true);
889     sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
890     ssm_->RequestSceneSessionBackground(sceneSession, false, false, false);
891     ssm_->RequestSceneSessionBackground(sceneSession, true, false, true);
892     ssm_->RequestSceneSessionBackground(sceneSession, true, true, true);
893 }
894 
895 /**
896  * @tc.name: RequestSceneSessionBackground
897  * @tc.desc: RequestSceneSessionBackground
898  * @tc.type: FUNC
899  */
900 HWTEST_F(SceneSessionManagerTest5, RequestSceneSessionBackground02, Function | SmallTest | Level3)
901 {
902     ASSERT_NE(ssm_, nullptr);
903     SessionInfo info;
904     info.abilityName_ = "test1";
905     info.bundleName_ = "test2";
906     info.ancoSceneState = 0;
907     sptr<WindowSessionProperty> property = new (std::nothrow) WindowSessionProperty();
908     ASSERT_NE(property, nullptr);
909     property->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
910     sptr<Session> session = new (std::nothrow) Session(info);
911     ASSERT_NE(session, nullptr);
912     sptr<SceneSession> sceneSession = nullptr;
913     std::shared_ptr<std::promise<int32_t>> promise = std::make_shared<std::promise<int32_t>>();
914     sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
915     session->SetSessionInfoPersistentId(123);
916     ssm_->RequestSceneSessionBackground(sceneSession, false, false, false);
917     session->SetSessionInfoPersistentId(0);
918     ssm_->RequestSceneSessionBackground(sceneSession, false, false, true);
919 }
920 
921 /**
922  * @tc.name: ConfigAppWindowShadow
923  * @tc.desc: SceneSesionManager config app window shadow
924  * @tc.type: FUNC
925  */
926 HWTEST_F(SceneSessionManagerTest5, ConfigAppWindowShadow03, Function | SmallTest | Level3)
927 {
928     ASSERT_NE(ssm_, nullptr);
929     WindowSceneConfig::ConfigItem item;
930     WindowSceneConfig::ConfigItem shadowConfig;
931     WindowShadowConfig outShadow;
932     std::vector<float> floatTest = {0.0f, 0.1f, 0.2f, 0.3f};
933     bool result = ssm_->ConfigAppWindowShadow(shadowConfig, outShadow);
934     ASSERT_EQ(result, true);
935 
936     item.SetValue(floatTest);
937     shadowConfig.SetValue({{"offsetX", item}});
938     ssm_->ConfigAppWindowShadow(shadowConfig, outShadow);
939 
940     shadowConfig.SetValue({{"offsetY", item}});
941     ssm_->ConfigAppWindowShadow(shadowConfig, outShadow);
942 
943     item.SetValue(new std::string(""));
944     shadowConfig.SetValue({{"color", item}});
945     ssm_->ConfigAppWindowShadow(shadowConfig, outShadow);
946 }
947 
948 /**
949  * @tc.name: CreateAndConnectSpecificSession
950  * @tc.desc: CreateAndConnectSpecificSession
951  * @tc.type: FUNC
952  */
953 HWTEST_F(SceneSessionManagerTest5, CreateAndConnectSpecificSession02, Function | SmallTest | Level3)
954 {
955     ASSERT_NE(ssm_, nullptr);
956     sptr<ISessionStage> sessionStage;
957     sptr<IWindowEventChannel> eventChannel;
958     std::shared_ptr<RSSurfaceNode> node = nullptr;
959     sptr<ISession> session;
960     SystemSessionConfig systemConfig;
961     sptr<IRemoteObject> token;
962     int32_t id = 0;
963     SessionInfo info;
964     info.abilityName_ = "test1";
965     info.bundleName_ = "test2";
966     sptr<WindowSessionProperty> property = new (std::nothrow) WindowSessionProperty();
967     ASSERT_NE(property, nullptr);
968     property->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
969     property->SetWindowFlags(123);
970     ssm_->CreateAndConnectSpecificSession(sessionStage, eventChannel, node, property, id, session,
971         systemConfig, token);
972     property->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
973     ssm_->CreateAndConnectSpecificSession(sessionStage, eventChannel, node, property, id, session,
974         systemConfig, token);
975     property->SetWindowType(WindowType::WINDOW_TYPE_FLOAT);
976     ssm_->CreateAndConnectSpecificSession(sessionStage, eventChannel, node, property, id, session,
977         systemConfig, token);
978     property->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
979     ssm_->CreateAndConnectSpecificSession(sessionStage, eventChannel, node, property, id, session,
980         systemConfig, token);
981 
982     property->SetWindowType(WindowType::WINDOW_TYPE_FLOAT);
983     property->SetFloatingWindowAppType(true);
984     ssm_->shouldHideNonSecureFloatingWindows_.store(true);
985     ssm_->systemConfig_.uiType_ = UI_TYPE_PC;
986     auto res = ssm_->CreateAndConnectSpecificSession(sessionStage, eventChannel, node, property, id, session,
987         systemConfig, token);
988     ASSERT_NE(WSError::WS_ERROR_INVALID_OPERATION, res);
989     ssm_->shouldHideNonSecureFloatingWindows_.store(false);
990     ssm_->systemConfig_.uiType_ = UI_TYPE_PHONE;
991 }
992 
993 /**
994  * @tc.name: ProcessDialogRequestFocusImmdediately
995  * @tc.desc: ProcessDialogRequestFocusImmdediately
996  * @tc.type: FUNC
997  */
998 HWTEST_F(SceneSessionManagerTest5, ProcessDialogRequestFocusImmdediately02, Function | SmallTest | Level3)
999 {
1000     ASSERT_NE(ssm_, nullptr);
1001     SessionInfo info;
1002     info.abilityName_ = "test1";
1003     info.bundleName_ = "test2";
1004     info.persistentId_ = 123;
1005     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1006     ASSERT_NE(sceneSession, nullptr);
1007     sptr<WindowSessionProperty> property = new (std::nothrow) WindowSessionProperty();
1008     ASSERT_NE(property, nullptr);
1009     property->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
1010     auto ret = ssm_->ProcessDialogRequestFocusImmdediately(sceneSession);
1011     EXPECT_EQ(WSError::WS_DO_NOTHING, ret);
1012     ret = ssm_->ProcessDialogRequestFocusImmdediately(sceneSession);
1013 }
1014 
1015 /**
1016  * @tc.name: RequestSceneSessionByCall
1017  * @tc.desc: SceneSesionManager request scene session by call
1018  * @tc.type: FUNC
1019  */
1020 HWTEST_F(SceneSessionManagerTest5, RequestSceneSessionByCall02, Function | SmallTest | Level3)
1021 {
1022     ASSERT_NE(ssm_, nullptr);
1023     sptr<SceneSession> scensession = nullptr;
1024     ssm_->RequestSceneSessionByCall(nullptr);
1025     SessionInfo info;
1026     info.abilityName_ = "test1";
1027     info.bundleName_ = "test2";
1028     scensession = sptr<SceneSession>::MakeSptr(info, nullptr);
1029     ssm_->RequestSceneSessionByCall(scensession);
1030 }
1031 
1032 /**
1033  * @tc.name: GetAllAbilityInfos
1034  * @tc.desc: Test if pip window can be created;
1035  * @tc.type: FUNC
1036  */
1037 HWTEST_F(SceneSessionManagerTest5, GetAllAbilityInfos02, Function | SmallTest | Level3)
1038 {
1039     ASSERT_NE(ssm_, nullptr);
1040     AAFwk::Want want;
1041     AppExecFwk::ElementName elementName = want.GetElement();
1042     int32_t userId = 1;
1043     std::vector<SCBAbilityInfo> scbAbilityInfos;
1044     ssm_->GetAllAbilityInfos(want, userId, scbAbilityInfos);
1045 
1046     elementName.bundleName_ = "test";
1047     ssm_->GetAllAbilityInfos(want, userId, scbAbilityInfos);
1048 
1049     elementName.abilityName_ = "test";
1050     ssm_->GetAllAbilityInfos(want, userId, scbAbilityInfos);
1051 
1052     elementName.bundleName_ = "";
1053     ssm_->GetAllAbilityInfos(want, userId, scbAbilityInfos);
1054 }
1055 
1056 /**
1057  * @tc.name: GetBatchAbilityInfos01
1058  * @tc.desc: GetBatchAbilityInfos01
1059  * @tc.type: FUNC
1060  */
1061 HWTEST_F(SceneSessionManagerTest5, GetBatchAbilityInfos01, Function | SmallTest | Level3)
1062 {
1063     ASSERT_NE(ssm_, nullptr);
1064     auto bundleMgr = ssm_->bundleMgr_;
1065     ssm_->bundleMgr_ = nullptr;
1066     int32_t userId = 100;
1067     std::vector<std::string> bundleNames = { "test1", "test2" };
1068     auto scbAbilityInfos = std::make_shared<std::vector<SCBAbilityInfo>>();
1069     WSError ret = ssm_->GetBatchAbilityInfos(bundleNames, userId, *scbAbilityInfos);
1070     ASSERT_EQ(ret, WSError::WS_ERROR_NULLPTR);
1071 }
1072 
1073 /**
1074  * @tc.name: GetBatchAbilityInfos02
1075  * @tc.desc: GetBatchAbilityInfos02
1076  * @tc.type: FUNC
1077  */
1078 HWTEST_F(SceneSessionManagerTest5, GetBatchAbilityInfos02, Function | SmallTest | Level3)
1079 {
1080     ASSERT_NE(ssm_, nullptr);
1081     sptr<IRemoteObject> iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr();
1082     ssm_->bundleMgr_ = sptr<AppExecFwk::BundleMgrProxy>::MakeSptr(iRemoteObjectMocker);
1083     int32_t userId = 100;
1084     std::vector<std::string> bundleNames = {};
1085     auto scbAbilityInfos = std::make_shared<std::vector<SCBAbilityInfo>>();
1086     WSError ret = ssm_->GetBatchAbilityInfos(bundleNames, userId, *scbAbilityInfos);
1087     ASSERT_EQ(ret, WSError::WS_ERROR_INVALID_PARAM);
1088 }
1089 
1090 /**
1091  * @tc.name: GetBatchAbilityInfos03
1092  * @tc.desc: GetBatchAbilityInfos03
1093  * @tc.type: FUNC
1094  */
1095 HWTEST_F(SceneSessionManagerTest5, GetBatchAbilityInfos03, Function | SmallTest | Level3)
1096 {
1097     ASSERT_NE(ssm_, nullptr);
1098     sptr<IRemoteObject> iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr();
1099     ssm_->bundleMgr_ = sptr<AppExecFwk::BundleMgrProxy>::MakeSptr(iRemoteObjectMocker);
1100     int32_t userId = 100;
1101     std::vector<std::string> bundleNames = { "" };
1102     auto scbAbilityInfos = std::make_shared<std::vector<SCBAbilityInfo>>();
1103     WSError ret = ssm_->GetBatchAbilityInfos(bundleNames, userId, *scbAbilityInfos);
1104     ASSERT_EQ(ret, WSError::WS_ERROR_INVALID_PARAM);
1105 }
1106 
1107 /**
1108  * @tc.name: GetBatchAbilityInfos04
1109  * @tc.desc: GetBatchAbilityInfos04
1110  * @tc.type: FUNC
1111  */
1112 HWTEST_F(SceneSessionManagerTest5, GetBatchAbilityInfos04, Function | SmallTest | Level3)
1113 {
1114     ASSERT_NE(ssm_, nullptr);
1115     sptr<IRemoteObject> iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr();
1116     ssm_->bundleMgr_ = sptr<AppExecFwk::BundleMgrProxy>::MakeSptr(iRemoteObjectMocker);
1117     int32_t userId = 100;
1118     std::vector<std::string> bundleNames = { "test1", "test2" };
1119     auto scbAbilityInfos = std::make_shared<std::vector<SCBAbilityInfo>>();
1120     WSError ret = ssm_->GetBatchAbilityInfos(bundleNames, userId, *scbAbilityInfos);
1121     ASSERT_EQ(ret, WSError::WS_ERROR_INVALID_PARAM);
1122 }
1123 
1124 /**
1125  * @tc.name: FindMainWindowWithToken
1126  * @tc.desc: SceneSesionManager find main window with token
1127  * @tc.type: FUNC
1128  */
1129 HWTEST_F(SceneSessionManagerTest5, FindMainWindowWithToken02, Function | SmallTest | Level3)
1130 {
1131     ASSERT_NE(ssm_, nullptr);
1132     SessionInfo info;
1133     info.abilityName_ = "test1";
1134     info.bundleName_ = "test2";
1135     info.persistentId_ = 123;
1136     sptr<IRemoteObject> targetToken = nullptr;
1137     ssm_->FindMainWindowWithToken(targetToken);
1138     targetToken = new (std::nothrow) IRemoteObjectMocker();
1139     ASSERT_NE(targetToken, nullptr);
1140     ssm_->FindMainWindowWithToken(targetToken);
1141     sptr<SceneSession> scensession = sptr<SceneSession>::MakeSptr(info, nullptr);
1142     ssm_->FindMainWindowWithToken(targetToken);
1143 }
1144 
1145 /**
1146  * @tc.name: RequestSceneSessionBackground
1147  * @tc.desc: RequestSceneSessionBackground
1148  * @tc.type: FUNC
1149  */
1150 HWTEST_F(SceneSessionManagerTest5, RequestSceneSessionBackground03, Function | SmallTest | Level3)
1151 {
1152     ASSERT_NE(ssm_, nullptr);
1153     SessionInfo info;
1154     info.abilityName_ = "test1";
1155     info.bundleName_ = "test2";
1156     info.persistentId_ = 0;
1157     sptr<WindowSessionProperty> property = new (std::nothrow) WindowSessionProperty();
1158     ASSERT_NE(property, nullptr);
1159     property->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
1160     sptr<Session> session = new (std::nothrow) Session(info);
1161     ASSERT_NE(session, nullptr);
1162     std::shared_ptr<std::promise<int32_t>> promise = std::make_shared<std::promise<int32_t>>();
1163     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1164     session->SetSessionInfoPersistentId(0);
1165     ssm_->RequestSceneSessionBackground(sceneSession, false, false, true);
1166 }
1167 
1168 /**
1169  * @tc.name: DestroyToastSession
1170  * @tc.desc: DestroyToastSession
1171  * @tc.type: FUNC
1172  */
1173 HWTEST_F(SceneSessionManagerTest5, DestroyToastSession02, Function | SmallTest | Level3)
1174 {
1175     ASSERT_NE(ssm_, nullptr);
1176     SessionInfo info;
1177     info.abilityName_ = "test1";
1178     info.bundleName_ = "test2";
1179     info.screenId_ = SCREEN_ID_INVALID;
1180     sptr<WindowSessionProperty> property = new (std::nothrow) WindowSessionProperty();
1181     ASSERT_NE(property, nullptr);
1182     property->SetWindowType(WindowType::WINDOW_TYPE_KEYBOARD_PANEL);
1183     sptr<SceneSession> sceneSession = nullptr;
1184     ssm_->DestroyToastSession(sceneSession);
1185     sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1186     sceneSession->state_ = SessionState::STATE_FOREGROUND;
1187     ssm_->DestroyToastSession(sceneSession);
1188 }
1189 
1190 /**
1191  * @tc.name: CheckModalSubWindowPermission
1192  * @tc.desc: CheckModalSubWindowPermission
1193  * @tc.type: FUNC
1194  */
1195 HWTEST_F(SceneSessionManagerTest5, CheckModalSubWindowPermission02, Function | SmallTest | Level3)
1196 {
1197     ASSERT_NE(ssm_, nullptr);
1198     SessionInfo info;
1199     info.abilityName_ = "test1";
1200     info.bundleName_ = "test2";
1201     sptr<WindowSessionProperty> property = new (std::nothrow) WindowSessionProperty();
1202     ASSERT_NE(property, nullptr);
1203     property->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
1204     property->SetWindowFlags(123);
1205     property->SetTopmost(true);
1206     ssm_->CheckModalSubWindowPermission(property);
1207     property->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
1208     ssm_->CheckModalSubWindowPermission(property);
1209 }
1210 
1211 /**
1212  * @tc.name: ConfigDecor
1213  * @tc.desc: SceneSesionManager config decor
1214  * @tc.type: FUNC
1215  */
1216 HWTEST_F(SceneSessionManagerTest5, ConfigDecor02, Function | SmallTest | Level3)
1217 {
1218     ASSERT_NE(ssm_, nullptr);
1219     WindowSceneConfig::ConfigItem* item = new WindowSceneConfig::ConfigItem;
1220     ASSERT_NE(item, nullptr);
1221     ssm_->ConfigDecor(*item, false);
1222     delete item;
1223 }
1224 
1225 /**
1226  * @tc.name: SetSkipSelfWhenShowOnVirtualScreen
1227  * @tc.desc: SetSkipSelfWhenShowOnVirtualScreen
1228  * @tc.type: FUNC
1229  */
1230 HWTEST_F(SceneSessionManagerTest5, SetSkipSelfWhenShowOnVirtualScreen, Function | SmallTest | Level3)
1231 {
1232     ASSERT_NE(ssm_, nullptr);
1233     SessionInfo info;
1234     info.abilityName_ = "test1";
1235     info.bundleName_ = "test2";
1236     sptr<WindowSessionProperty> property = new (std::nothrow) WindowSessionProperty();
1237     ASSERT_NE(property, nullptr);
1238     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1239     uint64_t surfaceNodeId = 1234;
1240     ssm_->SetSkipSelfWhenShowOnVirtualScreen(surfaceNodeId, false);
1241     ssm_->SetSkipSelfWhenShowOnVirtualScreen(surfaceNodeId, true);
1242 }
1243 
1244 /**
1245  * @tc.name: CreateKeyboardPanelSession
1246  * @tc.desc: CreateKeyboardPanelSession
1247  * @tc.type: FUNC
1248  */
1249 HWTEST_F(SceneSessionManagerTest5, CreateKeyboardPanelSession02, Function | SmallTest | Level3)
1250 {
1251     ASSERT_NE(ssm_, nullptr);
1252     SessionInfo info;
1253     info.abilityName_ = "test1";
1254     info.bundleName_ = "test2";
1255     info.screenId_ = SCREEN_ID_INVALID;
1256     sptr<WindowSessionProperty> property = new (std::nothrow) WindowSessionProperty();
1257     ASSERT_NE(property, nullptr);
1258     property->SetWindowType(WindowType::WINDOW_TYPE_KEYBOARD_PANEL);
1259     sptr<SceneSession> sceneSession = nullptr;
1260     ssm_->CreateKeyboardPanelSession(sceneSession);
1261     sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1262     ssm_->CreateKeyboardPanelSession(sceneSession);
1263 }
1264 
1265 /**
1266  * @tc.name: InitSceneSession02
1267  * @tc.desc: InitSceneSession02
1268  * @tc.type: FUNC
1269  */
1270 HWTEST_F(SceneSessionManagerTest5, InitSceneSession02, Function | SmallTest | Level3)
1271 {
1272     ASSERT_NE(nullptr, ssm_);
1273     SessionInfo sessionInfo;
1274     sessionInfo.bundleName_ = "test1";
1275     sessionInfo.abilityName_ = "test2";
1276     sessionInfo.abilityInfo = nullptr;
1277     sessionInfo.isAtomicService_ = true;
1278     sessionInfo.screenId_ = SCREEN_ID_INVALID;
1279     unsigned int flags = 1111;
1280     sessionInfo.want = std::make_shared<AAFwk::Want>();
1281     ASSERT_NE(nullptr, sessionInfo.want);
1282     sessionInfo.want->SetFlags(flags);
1283     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1284     ASSERT_NE(nullptr, sceneSession);
1285     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
1286     ssm_->InitSceneSession(sceneSession, sessionInfo, nullptr);
1287     ASSERT_EQ(nullptr, sessionInfo.abilityInfo);
1288 }
1289 
1290 /**
1291  * @tc.name: PrepareTerminate
1292  * @tc.desc: SceneSesionManager prepare terminate
1293  * @tc.type: FUNC
1294  */
1295 HWTEST_F(SceneSessionManagerTest5, PrepareTerminate03, Function | SmallTest | Level3)
1296 {
1297     ASSERT_NE(nullptr, ssm_);
1298     SessionInfo sessionInfo;
1299     sessionInfo.bundleName_ = "PrepareTerminate";
1300     sessionInfo.abilityName_ = "PrepareTerminate";
1301     sessionInfo.abilityInfo = nullptr;
1302     int32_t persistentId = 1;
1303     bool isPrepareTerminate = true;
1304     ASSERT_EQ(WSError::WS_OK, ssm_->PrepareTerminate(persistentId, isPrepareTerminate));
1305 }
1306 
1307 /**
1308  * @tc.name: AddClientDeathRecipient
1309  * @tc.desc: SceneSesionManager add client death recipient
1310  * @tc.type: FUNC
1311  */
1312 HWTEST_F(SceneSessionManagerTest5, AddClientDeathRecipient02, Function | SmallTest | Level3)
1313 {
1314     ASSERT_NE(ssm_, nullptr);
1315     SessionInfo info;
1316     info.abilityName_ = "AddClientDeathRecipient";
1317     info.bundleName_ = "AddClientDeathRecipient";
1318     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1319     ASSERT_NE(nullptr, sceneSession);
1320     ssm_->AddClientDeathRecipient(nullptr, sceneSession);
1321     sptr<ISessionStage> sessionStage = new (std::nothrow) SessionStageMocker();
1322     ssm_->AddClientDeathRecipient(sessionStage, sceneSession);
1323 }
1324 }
1325 } // namespace Rosen
1326 } // namespace OHOS
1327