• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 <bundle_mgr_interface.h>
18 #include <bundlemgr/launcher_service.h>
19 
20 #include "interfaces/include/ws_common.h"
21 #include "session_manager/include/scene_session_manager.h"
22 #include "session_info.h"
23 #include "session/host/include/scene_session.h"
24 #include "session/host/include/main_session.h"
25 #include "scene_board_judgement.h"
26 #include "screen_session_manager/include/screen_session_manager.h"
27 #include "window_manager_agent.h"
28 #include "session_manager.h"
29 #include "zidl/window_manager_agent_interface.h"
30 #include "mock/mock_session_stage.h"
31 #include "mock/mock_window_event_channel.h"
32 #include "context.h"
33 
34 using namespace testing;
35 using namespace testing::ext;
36 
37 namespace OHOS {
38 namespace Rosen {
39 class SceneSessionManagerSupplementTest : public testing::Test {
40 public:
41     static void SetUpTestCase();
42     static void TearDownTestCase();
43     void SetUp() override;
44     void TearDown() override;
45 
46     static sptr<SceneSessionManager> ssm_;
47     static constexpr uint32_t WAIT_SYNC_IN_NS = 200000;
48 };
49 
50 sptr<SceneSessionManager> SceneSessionManagerSupplementTest::ssm_ = nullptr;
51 
SetUpTestCase()52 void SceneSessionManagerSupplementTest::SetUpTestCase()
53 {
54     ssm_ = &SceneSessionManager::GetInstance();
55 }
56 
TearDownTestCase()57 void SceneSessionManagerSupplementTest::TearDownTestCase()
58 {
59     ssm_ = nullptr;
60 }
61 
SetUp()62 void SceneSessionManagerSupplementTest::SetUp()
63 {
64     ssm_->sceneSessionMap_.clear();
65 }
66 
TearDown()67 void SceneSessionManagerSupplementTest::TearDown()
68 {
69     ssm_->sceneSessionMap_.clear();
70     usleep(WAIT_SYNC_IN_NS);
71 }
72 
73 namespace {
74 /**
75  * @tc.name: LoadFreeMultiWindowConfigWithTrue
76  * @tc.desc: Test LoadFreeMultiWindowConfig for input true
77  * @tc.type: FUNC
78  */
79 HWTEST_F(SceneSessionManagerSupplementTest, LoadFreeMultiWindowConfigWithTrue, TestSize.Level1)
80 {
81     ssm_->systemConfig_.freeMultiWindowEnable_ = false;
82     ssm_->LoadFreeMultiWindowConfig(true);
83     auto config = ssm_->GetSystemSessionConfig();
84     ASSERT_EQ(config.freeMultiWindowEnable_, true);
85 }
86 
87 /**
88  * @tc.name: LoadFreeMultiWindowConfigWithFalse
89  * @tc.desc: Test LoadFreeMultiWindowConfig for input false
90  * @tc.type: FUNC
91  */
92 HWTEST_F(SceneSessionManagerSupplementTest, LoadFreeMultiWindowConfigWithFalse, TestSize.Level1)
93 {
94     ssm_->systemConfig_.freeMultiWindowEnable_ = true;
95     ssm_->LoadFreeMultiWindowConfig(false);
96     auto config = ssm_->GetSystemSessionConfig();
97     ASSERT_EQ(config.freeMultiWindowEnable_, false);
98 }
99 
100 /**
101  * @tc.name: SwitchFreeMultiWindowWithTrue
102  * @tc.desc: Test LoadFreeMultiWindowConfig for input false
103  * @tc.type: FUNC
104  */
105 HWTEST_F(SceneSessionManagerSupplementTest, SwitchFreeMultiWindowWithTrue, TestSize.Level1)
106 {
107     ssm_->systemConfig_.freeMultiWindowSupport_ = false;
108     auto res = ssm_->SwitchFreeMultiWindow(true);
109     ASSERT_EQ(res, WSError::WS_ERROR_DEVICE_NOT_SUPPORT);
110 }
111 
112 /**
113  * @tc.name: SwitchFreeMultiWindowWithFalse
114  * @tc.desc: Test LoadFreeMultiWindowConfig for input false
115  * @tc.type: FUNC
116  */
117 HWTEST_F(SceneSessionManagerSupplementTest, SwitchFreeMultiWindowWithFalse, TestSize.Level1)
118 {
119     ssm_->systemConfig_.freeMultiWindowSupport_ = true;
120 
121     auto res = ssm_->SwitchFreeMultiWindow(true);
122     ASSERT_EQ(res, WSError::WS_OK);
123     auto config = ssm_->GetSystemSessionConfig();
124     ASSERT_EQ(config.freeMultiWindowEnable_, true);
125 }
126 
127 /**
128  * @tc.name: TestSwitchWindowWithNullSceneSession
129  * @tc.desc: Test LoadFreeMultiWindowConfig with sceneSession is nullptr
130  * @tc.type: FUNC
131  */
132 HWTEST_F(SceneSessionManagerSupplementTest, TestSwitchWindowWithNullSceneSession, TestSize.Level1)
133 {
134     ssm_->systemConfig_.freeMultiWindowSupport_ = true;
135     sptr<SceneSession> sceneSession;
136     ssm_->sceneSessionMap_.insert({ 1, sceneSession });
137 
138     auto res = ssm_->SwitchFreeMultiWindow(false);
139     ASSERT_EQ(res, WSError::WS_OK);
140     auto config = ssm_->GetSystemSessionConfig();
141     ASSERT_EQ(config.freeMultiWindowEnable_, false);
142 }
143 
144 /**
145  * @tc.name: TestSwitchWindowWithSceneSession
146  * @tc.desc: Test LoadFreeMultiWindowConfig with sceneSession is not nullptr
147  * @tc.type: FUNC
148  */
149 HWTEST_F(SceneSessionManagerSupplementTest, TestSwitchWindowWithSceneSession, TestSize.Level1)
150 {
151     ssm_->systemConfig_.freeMultiWindowSupport_ = true;
152     SessionInfo sessionInfo;
153     sessionInfo.bundleName_ = "accessibilityNotifyTesterBundleName";
154     sessionInfo.abilityName_ = "accessibilityNotifyTesterAbilityName";
155     sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(sessionInfo, nullptr);
156     ssm_->sceneSessionMap_.insert({ 1, sceneSession });
157 
158     auto res = ssm_->SwitchFreeMultiWindow(false);
159     ASSERT_EQ(res, WSError::WS_OK);
160     auto config = ssm_->GetSystemSessionConfig();
161     ASSERT_EQ(config.freeMultiWindowEnable_, false);
162 }
163 
164 /**
165  * @tc.name: TestSwitchWindowWithProperty
166  * @tc.desc: Test LoadFreeMultiWindowConfig with property is not nullptr
167  * @tc.type: FUNC
168  */
169 HWTEST_F(SceneSessionManagerSupplementTest, TestSwitchWindowWithProperty, TestSize.Level1)
170 {
171     ssm_->systemConfig_.freeMultiWindowSupport_ = true;
172     SessionInfo sessionInfo;
173     sessionInfo.bundleName_ = "accessibilityNotifyTesterBundleName";
174     sessionInfo.abilityName_ = "accessibilityNotifyTesterAbilityName";
175     sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(sessionInfo, nullptr);
176     ssm_->sceneSessionMap_.insert({ 1, sceneSession });
177     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
178     ASSERT_NE(property, nullptr);
179     property->SetWindowType(WindowType::WINDOW_TYPE_SYSTEM_SUB_WINDOW);
180     sceneSession->SetSessionProperty(property);
181 
182     auto res = ssm_->SwitchFreeMultiWindow(false);
183     ASSERT_EQ(res, WSError::WS_OK);
184     auto config = ssm_->GetSystemSessionConfig();
185     ASSERT_EQ(config.freeMultiWindowEnable_, false);
186 }
187 
188 /**
189  * @tc.name: TestSwitchWindowWithPropertyInputTrue
190  * @tc.desc: Test LoadFreeMultiWindowConfig with property is not nullptr
191  * @tc.type: FUNC
192  */
193 HWTEST_F(SceneSessionManagerSupplementTest, TestSwitchWindowWithPropertyInputTrue, TestSize.Level1)
194 {
195     ssm_->systemConfig_.freeMultiWindowSupport_ = true;
196     SessionInfo sessionInfo;
197     sessionInfo.bundleName_ = "accessibilityNotifyTesterBundleName";
198     sessionInfo.abilityName_ = "accessibilityNotifyTesterAbilityName";
199     sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(sessionInfo, nullptr);
200     ssm_->sceneSessionMap_.insert({ 1, sceneSession });
201     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
202     ASSERT_NE(property, nullptr);
203     property->SetWindowType(WindowType::WINDOW_TYPE_SYSTEM_SUB_WINDOW);
204     sceneSession->SetSessionProperty(property);
205 
206     auto res = ssm_->SwitchFreeMultiWindow(true);
207     ASSERT_EQ(res, WSError::WS_OK);
208     auto config = ssm_->GetSystemSessionConfig();
209     ASSERT_EQ(config.freeMultiWindowEnable_, true);
210 }
211 
212 /**
213  * @tc.name: TestSetEnableInputEventWithInputTrue
214  * @tc.desc: Test LoadFreeMultiWindowConfig for input true
215  * @tc.type: FUNC
216  */
217 HWTEST_F(SceneSessionManagerSupplementTest, TestSetEnableInputEventWithInputTrue, TestSize.Level1)
218 {
219     ssm_->enableInputEvent_ = false;
220     ssm_->SetEnableInputEvent(true);
221     ASSERT_EQ(ssm_->enableInputEvent_, true);
222     auto res = ssm_->IsInputEventEnabled();
223     ASSERT_EQ(res, true);
224 }
225 
226 /**
227  * @tc.name: RequestSceneSessionActivationInner
228  * @tc.desc: SceneSessionManagerSupplementTest RequestSceneSessionActivationInner
229  * @tc.type: FUNC
230  */
231 HWTEST_F(SceneSessionManagerSupplementTest, RequestSceneSessionActivationInner, TestSize.Level1)
232 {
233     SessionInfo sessionInfo;
234     sessionInfo.bundleName_ = "accessibilityNotifyTesterBundleName";
235     sessionInfo.abilityName_ = "accessibilityNotifyTesterAbilityName";
236     sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(sessionInfo, nullptr);
237     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
238     ASSERT_NE(property, nullptr);
239     property->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
240     sceneSession->SetSessionProperty(property);
241     sceneSession->SetCollaboratorType(0);
242     auto ret = ssm_->RequestSceneSessionActivationInner(sceneSession, true);
243     ASSERT_EQ(ret, WSError::WS_OK);
244     ret = ssm_->RequestSceneSessionActivationInner(sceneSession, false);
245     ASSERT_EQ(ret, WSError::WS_OK);
246 }
247 
248 /**
249  * @tc.name: RequestSceneSessionActivationInnerTest01
250  * @tc.desc: SceneSessionManagerSupplementTest RequestSceneSessionActivationInner
251  * @tc.type: FUNC
252  */
253 HWTEST_F(SceneSessionManagerSupplementTest, RequestSceneSessionActivationInnerTest_01, TestSize.Level1)
254 {
255     SessionInfo sessionInfo;
256     sessionInfo.bundleName_ = "accessibilityNotifyTesterBundleName";
257     sessionInfo.abilityName_ = "accessibilityNotifyTesterAbilityName";
258     sessionInfo.ancoSceneState = AncoSceneState::NOTIFY_FOREGROUND;
259     sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(sessionInfo, nullptr);
260     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
261     ASSERT_NE(property, nullptr);
262     property->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
263     sceneSession->SetSessionProperty(property);
264     sceneSession->SetScbCoreEnabled(true);
265     auto ret = ssm_->RequestSceneSessionActivationInner(sceneSession, true);
266     ASSERT_EQ(ret, WSError::WS_OK);
267     ret = ssm_->RequestSceneSessionActivationInner(sceneSession, false);
268     ASSERT_EQ(ret, WSError::WS_OK);
269 }
270 
271 /**
272  * @tc.name: NotifyCollaboratorAfterStart
273  * @tc.desc: SceneSessionManagerSupplementTest NotifyCollaboratorAfterStart
274  * @tc.type: FUNC
275  */
276 HWTEST_F(SceneSessionManagerSupplementTest, NotifyCollaboratorAfterStart, TestSize.Level1)
277 {
278     sptr<SceneSession> sceneSession;
279     sptr<AAFwk::SessionInfo> sceneSessionInfo;
280     ssm_->NotifyCollaboratorAfterStart(sceneSession, sceneSessionInfo);
281     SessionInfo info;
282     info.bundleName_ = "test1";
283     info.abilityName_ = "test2";
284     auto ret = ssm_->RequestSceneSessionBackground(sceneSession, true, true);
285     ASSERT_EQ(ret, WSError::WS_OK);
286     sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
287     ASSERT_NE(sceneSession, nullptr);
288     ssm_->NotifyCollaboratorAfterStart(sceneSession, sceneSessionInfo);
289     sceneSessionInfo = sptr<AAFwk::SessionInfo>::MakeSptr();
290     ssm_->NotifyCollaboratorAfterStart(sceneSession, sceneSessionInfo);
291     ssm_->NotifyCollaboratorAfterStart(sceneSession, sceneSessionInfo);
292     ret = ssm_->RequestSceneSessionBackground(sceneSession, true, true);
293     ASSERT_EQ(ret, WSError::WS_OK);
294     ret = ssm_->RequestSceneSessionBackground(sceneSession, true, false);
295     ASSERT_EQ(ret, WSError::WS_OK);
296     ssm_->brightnessSessionId_ = sceneSession->GetPersistentId();
297     ret = ssm_->RequestSceneSessionBackground(sceneSession, false, true);
298     ASSERT_EQ(ret, WSError::WS_OK);
299     ret = ssm_->RequestSceneSessionBackground(sceneSession, false, false);
300     ASSERT_EQ(ret, WSError::WS_OK);
301     ssm_->brightnessSessionId_ = 0;
302     ssm_->systemConfig_.backgroundswitch = true;
303     ret = ssm_->RequestSceneSessionBackground(sceneSession, true, true);
304     ASSERT_EQ(ret, WSError::WS_OK);
305     ret = ssm_->RequestSceneSessionBackground(sceneSession, true, false);
306     ASSERT_EQ(ret, WSError::WS_OK);
307     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
308     ASSERT_NE(property, nullptr);
309     property->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
310     sceneSession->SetSessionProperty(property);
311     ret = ssm_->RequestSceneSessionBackground(sceneSession, false, true);
312     ASSERT_EQ(ret, WSError::WS_OK);
313     ret = ssm_->RequestSceneSessionBackground(sceneSession, false, false);
314     ASSERT_EQ(ret, WSError::WS_OK);
315     ssm_->NotifyForegroundInteractiveStatus(sceneSession, true);
316     ssm_->NotifyForegroundInteractiveStatus(sceneSession, false);
317     ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession });
318     ssm_->NotifyForegroundInteractiveStatus(sceneSession, true);
319 }
320 
321 /**
322  * @tc.name: TestDestroyDialogWithMainWindow_01
323  * @tc.desc: Test DestroyDialogWithMainWindow with sceneSession is null
324  * @tc.type: FUNC
325  */
326 HWTEST_F(SceneSessionManagerSupplementTest, TestDestroyDialogWithMainWindow_01, TestSize.Level1)
327 {
328     SessionInfo info;
329     info.bundleName_ = "test1";
330     info.abilityName_ = "test2";
331     sptr<SceneSession> sceneSession;
332     auto res = ssm_->DestroyDialogWithMainWindow(sceneSession);
333     ASSERT_EQ(res, WSError::WS_ERROR_NULLPTR);
334 }
335 
336 /**
337  * @tc.name: TestDestroyDialogWithMainWindow_02
338  * @tc.desc: Test DestroyDialogWithMainWindow with window type is WINDOW_TYPE_APP_COMPONENT
339  * @tc.type: FUNC
340  */
341 HWTEST_F(SceneSessionManagerSupplementTest, TestDestroyDialogWithMainWindow_02, TestSize.Level1)
342 {
343     SessionInfo info;
344     info.bundleName_ = "test1";
345     info.abilityName_ = "test2";
346     sptr<SceneSession> sceneSession;
347     ASSERT_NE(ssm_, nullptr);
348     ssm_->DestroySubSession(sceneSession);
349     ssm_->RequestSceneSessionDestruction(sceneSession, true);
350     ssm_->RequestSceneSessionDestruction(sceneSession, false);
351     sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
352     ASSERT_NE(sceneSession, nullptr);
353     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
354     ASSERT_NE(property, nullptr);
355     property->SetWindowType(WindowType::WINDOW_TYPE_APP_COMPONENT);
356     sceneSession->SetSessionProperty(property);
357     auto res = ssm_->DestroyDialogWithMainWindow(sceneSession);
358     ASSERT_EQ(res, WSError::WS_ERROR_INVALID_SESSION);
359 }
360 
361 /**
362  * @tc.name: TestDestroyDialogWithMainWindow_03
363  * @tc.desc: Test DestroyDialogWithMainWindow with subSession is null
364  * @tc.type: FUNC
365  */
366 HWTEST_F(SceneSessionManagerSupplementTest, TestDestroyDialogWithMainWindow_03, TestSize.Level1)
367 {
368     SessionInfo info;
369     info.bundleName_ = "test1";
370     info.abilityName_ = "test2";
371     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
372     ASSERT_NE(sceneSession, nullptr);
373     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
374     ASSERT_NE(property, nullptr);
375     property->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
376     sceneSession->SetSessionProperty(property);
377     sptr<SceneSession> sceneSession2;
378     sceneSession->dialogVec_.push_back(sceneSession2);
379     sceneSession->subSession_.push_back(sceneSession2);
380     auto res = ssm_->DestroyDialogWithMainWindow(sceneSession);
381     ASSERT_EQ(res, WSError::WS_OK);
382 }
383 
384 /**
385  * @tc.name: TestDestroyDialogWithMainWindow_04
386  * @tc.desc: Test DestroyDialogWithMainWindow with subSession is not null
387  * @tc.type: FUNC
388  */
389 HWTEST_F(SceneSessionManagerSupplementTest, TestDestroyDialogWithMainWindow_04, TestSize.Level1)
390 {
391     SessionInfo info;
392     info.bundleName_ = "test1";
393     info.abilityName_ = "test2";
394     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
395     ASSERT_NE(sceneSession, nullptr);
396     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
397     ASSERT_NE(property, nullptr);
398     property->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
399     sceneSession->SetSessionProperty(property);
400     sptr<SceneSession> sceneSession2;
401     sceneSession->dialogVec_.push_back(sceneSession2);
402     sceneSession->subSession_.push_back(sceneSession2);
403     sceneSession2 = sptr<SceneSession>::MakeSptr(info, nullptr);
404     ASSERT_NE(sceneSession2, nullptr);
405     ssm_->DestroySubSession(sceneSession);
406     auto res = ssm_->DestroyDialogWithMainWindow(sceneSession);
407     ASSERT_EQ(res, WSError::WS_OK);
408 }
409 
410 /**
411  * @tc.name: TestDestroyDialogWithMainWindow_05
412  * @tc.desc: Test DestroyDialogWithMainWindow with insert sceneSession2 in sceneSessionMap_
413  * @tc.type: FUNC
414  */
415 HWTEST_F(SceneSessionManagerSupplementTest, TestDestroyDialogWithMainWindow_05, TestSize.Level1)
416 {
417     SessionInfo info;
418     info.bundleName_ = "test1";
419     info.abilityName_ = "test2";
420     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
421     ASSERT_NE(sceneSession, nullptr);
422     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
423     ASSERT_NE(property, nullptr);
424     property->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
425     sceneSession->SetSessionProperty(property);
426     sptr<SceneSession> sceneSession2;
427     sceneSession->dialogVec_.push_back(sceneSession2);
428     sceneSession->subSession_.push_back(sceneSession2);
429     sceneSession2 = sptr<SceneSession>::MakeSptr(info, nullptr);
430     ASSERT_NE(sceneSession2, nullptr);
431     ssm_->DestroySubSession(sceneSession);
432     ssm_->RequestSceneSessionDestruction(sceneSession, true);
433     ssm_->RequestSceneSessionDestruction(sceneSession, false);
434     ssm_->sceneSessionMap_.insert({ sceneSession2->GetPersistentId(), sceneSession2 });
435     auto res = ssm_->DestroyDialogWithMainWindow(sceneSession);
436     ASSERT_EQ(res, WSError::WS_OK);
437 }
438 
439 /**
440  * @tc.name: DestroyDialogWithSessionIsNull
441  * @tc.desc: DestroyDialogWithMainWindow with with session is nullptr
442  * @tc.type: FUNC
443  */
444 HWTEST_F(SceneSessionManagerSupplementTest, DestroyDialogWithSessionIsNull, TestSize.Level1)
445 {
446     sptr<SceneSession> sceneSession;
447     auto res = ssm_->DestroyDialogWithMainWindow(sceneSession);
448     ASSERT_EQ(res, WSError::WS_ERROR_NULLPTR);
449 }
450 
451 /**
452  * @tc.name: DestroyDialogWithFalseType
453  * @tc.desc: DestroyDialogWithMainWindow with type is WINDOW_TYPE_APP_COMPONENT
454  * @tc.type: FUNC
455  */
456 HWTEST_F(SceneSessionManagerSupplementTest, DestroyDialogWithFalseType, TestSize.Level1)
457 {
458     SessionInfo info;
459     info.bundleName_ = "test1";
460     info.abilityName_ = "test2";
461     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
462     ASSERT_NE(sceneSession, nullptr);
463     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
464     ASSERT_NE(property, nullptr);
465     property->SetWindowType(WindowType::WINDOW_TYPE_APP_COMPONENT);
466     sceneSession->SetSessionProperty(property);
467     auto res = ssm_->DestroyDialogWithMainWindow(sceneSession);
468     ASSERT_EQ(res, WSError::WS_ERROR_INVALID_SESSION);
469 }
470 
471 /**
472  * @tc.name: DestroyDialogWithTrueType
473  * @tc.desc: DestroyDialogWithMainWindow with type is WINDOW_TYPE_APP_MAIN_WINDOW
474  * @tc.type: FUNC
475  */
476 HWTEST_F(SceneSessionManagerSupplementTest, DestroyDialogWithTrueType, TestSize.Level1)
477 {
478     SessionInfo info;
479     info.bundleName_ = "test1";
480     info.abilityName_ = "test2";
481     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
482     ASSERT_NE(sceneSession, nullptr);
483     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
484     ASSERT_NE(property, nullptr);
485     property->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
486     sceneSession->SetSessionProperty(property);
487     sptr<SceneSession> sceneSession2;
488     sceneSession->dialogVec_.push_back(sceneSession2);
489     sceneSession->subSession_.push_back(sceneSession2);
490     auto res = ssm_->DestroyDialogWithMainWindow(sceneSession);
491     ASSERT_EQ(res, WSError::WS_OK);
492 }
493 
494 /**
495  * @tc.name: DestroyDialogWithTrueType_01
496  * @tc.desc: DestroyDialogWithMainWindow with type is WINDOW_TYPE_APP_MAIN_WINDOW
497  * @tc.type: FUNC
498  */
499 HWTEST_F(SceneSessionManagerSupplementTest, DestroyDialogWithTrueType_01, TestSize.Level1)
500 {
501     SessionInfo info;
502     info.bundleName_ = "test1";
503     info.abilityName_ = "test2";
504     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
505     ASSERT_NE(sceneSession, nullptr);
506     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
507     ASSERT_NE(property, nullptr);
508     property->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
509     sceneSession->SetSessionProperty(property);
510     sptr<SceneSession> sceneSession2;
511     sceneSession->dialogVec_.push_back(sceneSession2);
512     sceneSession->subSession_.push_back(sceneSession2);
513     sceneSession2 = sptr<SceneSession>::MakeSptr(info, nullptr);
514     ASSERT_NE(sceneSession2, nullptr);
515     ssm_->sceneSessionMap_.insert({ sceneSession2->GetPersistentId(), sceneSession2 });
516     auto res = ssm_->DestroyDialogWithMainWindow(sceneSession);
517     ASSERT_EQ(res, WSError::WS_OK);
518 }
519 
520 /**
521  * @tc.name: TestCreateAndConnectSession_01
522  * @tc.desc: Test for CreateAndConnectSpecificSession with property is nullptr
523  * @tc.type: FUNC
524  */
525 HWTEST_F(SceneSessionManagerSupplementTest, TestCreateAndConnectSession_01, TestSize.Level1)
526 {
527     sptr<ISessionStage> sessionStage;
528     sptr<IWindowEventChannel> eventChannel;
529     std::shared_ptr<RSSurfaceNode> node = nullptr;
530     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
531     sptr<ISession> session;
532     SystemSessionConfig systemConfig;
533     sptr<IRemoteObject> token;
534     int32_t id = 0;
535 
536     auto res = ssm_->CreateAndConnectSpecificSession(
537         sessionStage, eventChannel, node, property, id, session, systemConfig, token);
538     ASSERT_EQ(res, WSError::WS_ERROR_NULLPTR);
539 }
540 
541 /**
542  * @tc.name: TestCreateAndConnectSession_02
543  * @tc.desc: Test for CreateAndConnectSpecificSession with WindowType is WINDOW_TYPE_UI_EXTENSION
544  * @tc.type: FUNC
545  */
546 HWTEST_F(SceneSessionManagerSupplementTest, TestCreateAndConnectSession_02, TestSize.Level1)
547 {
548     sptr<ISessionStage> sessionStage;
549     sptr<IWindowEventChannel> eventChannel;
550     std::shared_ptr<RSSurfaceNode> node = nullptr;
551     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
552     ASSERT_NE(property, nullptr);
553     sptr<ISession> session;
554     SystemSessionConfig systemConfig;
555     sptr<IRemoteObject> token;
556     int32_t id = 0;
557     property->SetWindowType(WindowType::WINDOW_TYPE_UI_EXTENSION);
558 
559     auto res = ssm_->CreateAndConnectSpecificSession(
560         sessionStage, eventChannel, node, property, id, session, systemConfig, token);
561     ASSERT_EQ(res, WSError::WS_ERROR_NOT_SYSTEM_APP);
562 }
563 
564 /**
565  * @tc.name: TestCreateAndConnectSession_03
566  * @tc.desc: Test for CreateAndConnectSpecificSession with WindowType is WINDOW_TYPE_INPUT_METHOD_FLOAT
567  * @tc.type: FUNC
568  */
569 HWTEST_F(SceneSessionManagerSupplementTest, TestCreateAndConnectSession_03, TestSize.Level1)
570 {
571     sptr<ISessionStage> sessionStage;
572     sptr<IWindowEventChannel> eventChannel;
573     std::shared_ptr<RSSurfaceNode> node = nullptr;
574     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
575     ASSERT_NE(property, nullptr);
576     sptr<ISession> session;
577     SystemSessionConfig systemConfig;
578     sptr<IRemoteObject> token;
579     int32_t id = 0;
580     property->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
581 
582     auto res = ssm_->CreateAndConnectSpecificSession(
583         sessionStage, eventChannel, node, property, id, session, systemConfig, token);
584     ASSERT_EQ(res, WSError::WS_ERROR_NULLPTR);
585 }
586 
587 /**
588  * @tc.name: TestCreateAndConnectSession_04
589  * @tc.desc: Test for CreateAndConnectSpecificSession with WindowType is WINDOW_TYPE_FLOAT
590  * @tc.type: FUNC
591  */
592 HWTEST_F(SceneSessionManagerSupplementTest, TestCreateAndConnectSession_04, TestSize.Level1)
593 {
594     sptr<ISessionStage> sessionStage;
595     sptr<IWindowEventChannel> eventChannel;
596     std::shared_ptr<RSSurfaceNode> node = nullptr;
597     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
598     ASSERT_NE(property, nullptr);
599     sptr<ISession> session;
600     SystemSessionConfig systemConfig;
601     sptr<IRemoteObject> token;
602     int32_t id = 0;
603     property->SetWindowType(WindowType::WINDOW_TYPE_FLOAT);
604     property->SetFloatingWindowAppType(true);
605 
606     auto res = ssm_->CreateAndConnectSpecificSession(
607         sessionStage, eventChannel, node, property, id, session, systemConfig, token);
608     ASSERT_EQ(res, WSError::WS_ERROR_NOT_SYSTEM_APP);
609 }
610 
611 /**
612  * @tc.name: TestCreateAndConnectSession_05
613  * @tc.desc: Test for CreateAndConnectSpecificSession with WindowType is WINDOW_TYPE_APP_SUB_WINDOW
614  * @tc.type: FUNC
615  */
616 HWTEST_F(SceneSessionManagerSupplementTest, TestCreateAndConnectSession_05, TestSize.Level1)
617 {
618     sptr<ISessionStage> sessionStage;
619     sptr<IWindowEventChannel> eventChannel;
620     std::shared_ptr<RSSurfaceNode> node = nullptr;
621     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
622     ASSERT_NE(property, nullptr);
623     sptr<ISession> session;
624     SystemSessionConfig systemConfig;
625     sptr<IRemoteObject> token;
626     int32_t id = 0;
627     property->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
628     property->SetFloatingWindowAppType(true);
629     property->SetIsUIExtFirstSubWindow(true);
630 
631     auto res = ssm_->CreateAndConnectSpecificSession(
632         sessionStage, eventChannel, node, property, id, session, systemConfig, token);
633     ASSERT_EQ(res, WSError::WS_ERROR_NULLPTR);
634 }
635 
636 /**
637  * @tc.name: TestCreateAndConnectSession_06
638  * @tc.desc: Test for CreateAndConnectSpecificSession with WindowType is WINDOW_TYPE_SYSTEM_ALARM_WINDOW
639  * @tc.type: FUNC
640  */
641 HWTEST_F(SceneSessionManagerSupplementTest, TestCreateAndConnectSession_06, TestSize.Level1)
642 {
643     sptr<ISessionStage> sessionStage;
644     sptr<IWindowEventChannel> eventChannel;
645     std::shared_ptr<RSSurfaceNode> node = nullptr;
646     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
647     ASSERT_NE(property, nullptr);
648     sptr<ISession> session;
649     SystemSessionConfig systemConfig;
650     sptr<IRemoteObject> token;
651     int32_t id = 0;
652     property->SetWindowType(WindowType::WINDOW_TYPE_SYSTEM_ALARM_WINDOW);
653     property->SetFloatingWindowAppType(true);
654     property->SetIsUIExtFirstSubWindow(true);
655 
656     auto res = ssm_->CreateAndConnectSpecificSession(
657         sessionStage, eventChannel, node, property, id, session, systemConfig, token);
658     ASSERT_EQ(res, WSError::WS_ERROR_INVALID_WINDOW);
659 }
660 
661 /**
662  * @tc.name: TestCreateAndConnectSession_07
663  * @tc.desc: Test for CreateAndConnectSpecificSession with WindowType is WINDOW_TYPE_PIP
664  * @tc.type: FUNC
665  */
666 HWTEST_F(SceneSessionManagerSupplementTest, TestCreateAndConnectSession_07, TestSize.Level1)
667 {
668     sptr<ISessionStage> sessionStage;
669     sptr<IWindowEventChannel> eventChannel;
670     std::shared_ptr<RSSurfaceNode> node = nullptr;
671     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
672     ASSERT_NE(property, nullptr);
673     sptr<ISession> session;
674     SystemSessionConfig systemConfig;
675     sptr<IRemoteObject> token;
676     int32_t id = 0;
677     property->SetWindowType(WindowType::WINDOW_TYPE_PIP);
678     property->SetFloatingWindowAppType(true);
679     property->SetIsUIExtFirstSubWindow(true);
680 
681     auto res = ssm_->CreateAndConnectSpecificSession(
682         sessionStage, eventChannel, node, property, id, session, systemConfig, token);
683     ASSERT_EQ(res, WSError::WS_DO_NOTHING);
684 }
685 
686 /**
687  * @tc.name: TestCreateAndConnectSession_08
688  * @tc.desc: Test for CreateAndConnectSpecificSession with WindowType is WINDOW_TYPE_MUTISCREEN_COLLABORATION
689  * @tc.type: FUNC
690  */
691 HWTEST_F(SceneSessionManagerSupplementTest, TestCreateAndConnectSession_08, Function | SmallTest | Level3)
692 {
693     sptr<ISessionStage> sessionStage;
694     sptr<IWindowEventChannel> eventChannel;
695     std::shared_ptr<RSSurfaceNode> node = nullptr;
696     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
697     ASSERT_NE(property, nullptr);
698     sptr<ISession> session;
699     SystemSessionConfig systemConfig;
700     sptr<IRemoteObject> token;
701     int32_t id = 0;
702     property->SetWindowType(WindowType::WINDOW_TYPE_MUTISCREEN_COLLABORATION);
703     ssm_->systemConfig_.windowUIType_ = WindowUIType::PC_WINDOW;
704     auto res = ssm_->CreateAndConnectSpecificSession(sessionStage, eventChannel, node, property, id, session,
705         systemConfig, token);
706     ASSERT_EQ(res, WSError::WS_ERROR_INVALID_OPERATION);
707 }
708 
709 /**
710  * @tc.name: ClosePipWindowIfExist
711  * @tc.desc: ClosePipWindowIfExist
712  * @tc.type: FUNC
713  */
714 HWTEST_F(SceneSessionManagerSupplementTest, ClosePipWindowIfExist, TestSize.Level1)
715 {
716     ssm_->ClosePipWindowIfExist(WindowType::WINDOW_TYPE_SYSTEM_ALARM_WINDOW);
717     ssm_->ClosePipWindowIfExist(WindowType::WINDOW_TYPE_PIP);
718     SessionInfo info;
719     info.bundleName_ = "test1";
720     info.abilityName_ = "test2";
721     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
722     ASSERT_NE(sceneSession, nullptr);
723     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
724     ASSERT_NE(property, nullptr);
725     property->SetWindowType(WindowType::WINDOW_TYPE_APP_COMPONENT);
726     sceneSession->SetSessionProperty(property);
727     PiPTemplateInfo pipInfo;
728     pipInfo.priority = 0;
729     auto res = ssm_->CheckPiPPriority(pipInfo);
730     ASSERT_EQ(res, true);
731     ssm_->sceneSessionMap_.insert({ 0, sceneSession });
732     ssm_->ClosePipWindowIfExist(WindowType::WINDOW_TYPE_PIP);
733     res = ssm_->CheckPiPPriority(pipInfo);
734     ASSERT_EQ(res, true);
735     property->SetWindowType(WindowType::WINDOW_TYPE_PIP);
736     PiPTemplateInfo pipInfo1;
737     pipInfo1.priority = 0;
738     sceneSession->SetPiPTemplateInfo(pipInfo1);
739     res = ssm_->CheckPiPPriority(pipInfo);
740     ASSERT_EQ(res, true);
741     sceneSession->isVisible_ = true;
742     res = ssm_->CheckPiPPriority(pipInfo);
743     ASSERT_EQ(res, true);
744 }
745 
746 /**
747  * @tc.name: CheckSysWinPermissionWithUIExtTypeThenFalse
748  * @tc.desc: Check system window permission while type is WINDOW_TYPE_UI_EXTENSION return false
749  * @tc.type: FUNC
750  */
751 HWTEST_F(SceneSessionManagerSupplementTest, CheckSysWinPermissionWithUIExtTypeThenFalse, TestSize.Level1)
752 {
753     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
754     ASSERT_NE(property, nullptr);
755     property->SetWindowType(WindowType::WINDOW_TYPE_UI_EXTENSION);
756 
757     ASSERT_NE(ssm_, nullptr);
758     bool res = ssm_->CheckSystemWindowPermission(property);
759     ASSERT_EQ(res, false);
760 }
761 
762 /**
763  * @tc.name: CheckSysWinPermissionWithInputTypeThenFalse
764  * @tc.desc: Check system window permission while type is WINDOW_TYPE_INPUT_METHOD_FLOAT return false
765  * @tc.type: FUNC
766  */
767 HWTEST_F(SceneSessionManagerSupplementTest, CheckSysWinPermissionWithInputTypeThenFalse, TestSize.Level1)
768 {
769     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
770     ASSERT_NE(property, nullptr);
771     property->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
772 
773     ASSERT_NE(ssm_, nullptr);
774     bool res = ssm_->CheckSystemWindowPermission(property);
775     ASSERT_EQ(res, true);
776 }
777 
778 /**
779  * @tc.name: CheckSysWinPermWithInputStatusTypeThenFalse
780  * @tc.desc: Check system window permission while type is WINDOW_TYPE_INPUT_METHOD_STATUS_BAR return false
781  * @tc.type: FUNC
782  */
783 HWTEST_F(SceneSessionManagerSupplementTest, CheckSysWinPermWithInputStatusTypeThenFalse, TestSize.Level1)
784 {
785     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
786     ASSERT_NE(property, nullptr);
787     property->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_STATUS_BAR);
788 
789     ASSERT_NE(ssm_, nullptr);
790     bool res = ssm_->CheckSystemWindowPermission(property);
791     ASSERT_EQ(res, true);
792 }
793 
794 /**
795  * @tc.name: CheckSysWinPermWithDraggingTypeThenTrue
796  * @tc.desc: Check system window permission while type is WINDOW_TYPE_DRAGGING_EFFECT return false
797  * @tc.type: FUNC
798  */
799 HWTEST_F(SceneSessionManagerSupplementTest, CheckSysWinPermWithDraggingTypeThenTrue, TestSize.Level1)
800 {
801     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
802     ASSERT_NE(property, nullptr);
803     property->SetWindowType(WindowType::WINDOW_TYPE_DRAGGING_EFFECT);
804 
805     ASSERT_NE(ssm_, nullptr);
806     bool res = ssm_->CheckSystemWindowPermission(property);
807     ASSERT_EQ(res, true);
808 }
809 
810 /**
811  * @tc.name: CheckSysWinPermWithToastTypeThenTrue
812  * @tc.desc: Check system window permission while type is WINDOW_TYPE_TOAST return false
813  * @tc.type: FUNC
814  */
815 HWTEST_F(SceneSessionManagerSupplementTest, CheckSysWinPermWithToastTypeThenTrue, TestSize.Level1)
816 {
817     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
818     ASSERT_NE(property, nullptr);
819     property->SetWindowType(WindowType::WINDOW_TYPE_TOAST);
820 
821     ASSERT_NE(ssm_, nullptr);
822     bool res = ssm_->CheckSystemWindowPermission(property);
823     ASSERT_EQ(res, true);
824 }
825 
826 /**
827  * @tc.name: CheckSysWinPermWithDialgTypeThenTrue
828  * @tc.desc: Check system window permission while type is WINDOW_TYPE_DIALOG return true
829  * @tc.type: FUNC
830  */
831 HWTEST_F(SceneSessionManagerSupplementTest, CheckSysWinPermWithDialgTypeThenTrue, TestSize.Level1)
832 {
833     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
834     ASSERT_NE(property, nullptr);
835     property->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
836 
837     ASSERT_NE(ssm_, nullptr);
838     bool res = ssm_->CheckSystemWindowPermission(property);
839     ASSERT_EQ(res, true);
840 }
841 
842 /**
843  * @tc.name: CheckSysWinPermWithPipTypeThenTrue
844  * @tc.desc: Check system window permission while type is WINDOW_TYPE_DIALOG return true
845  * @tc.type: FUNC
846  */
847 HWTEST_F(SceneSessionManagerSupplementTest, CheckSysWinPermWithPipTypeThenTrue, TestSize.Level1)
848 {
849     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
850     ASSERT_NE(property, nullptr);
851     property->SetWindowType(WindowType::WINDOW_TYPE_PIP);
852 
853     ASSERT_NE(ssm_, nullptr);
854     bool res = ssm_->CheckSystemWindowPermission(property);
855     ASSERT_EQ(res, true);
856 }
857 
858 /**
859  * @tc.name: CheckSysWinPermWithFloatTypeThenFalse
860  * @tc.desc: Check system window permission while type is WINDOW_TYPE_FLOAT return false
861  * @tc.type: FUNC
862  */
863 HWTEST_F(SceneSessionManagerSupplementTest, CheckSysWinPermWithFloatTypeThenFalse, TestSize.Level1)
864 {
865     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
866     ASSERT_NE(property, nullptr);
867     property->SetWindowType(WindowType::WINDOW_TYPE_FLOAT);
868 
869     ASSERT_NE(ssm_, nullptr);
870     bool res = ssm_->CheckSystemWindowPermission(property);
871     ASSERT_EQ(res, false);
872 }
873 
874 /**
875  * @tc.name: SetAlivePersistentIdsWithNoId
876  * @tc.desc: Set Alive Persistent Ids With no persistentId then IsNeedRecover check return false
877  * @tc.type: FUNC
878  */
879 HWTEST_F(SceneSessionManagerSupplementTest, SetAlivePersistentIdsWithNoId, TestSize.Level1)
880 {
881     std::vector<int32_t> alivePersistentIds;
882     ASSERT_NE(ssm_, nullptr);
883     ssm_->SetAlivePersistentIds(alivePersistentIds);
884 
885     int persistentId = 1;
886     bool res = ssm_->IsNeedRecover(persistentId);
887     ASSERT_EQ(res, false);
888 }
889 
890 /**
891  * @tc.name: SetAlivePersistentIdsWithIds
892  * @tc.desc: Set Alive Persistent Ids With persistentIds then IsNeedRecover check return true
893  * @tc.type: FUNC
894  */
895 HWTEST_F(SceneSessionManagerSupplementTest, SetAlivePersistentIdsWithIds, TestSize.Level1)
896 {
897     std::vector<int32_t> alivePersistentIds = { 0, 1, 2 };
898     ASSERT_NE(ssm_, nullptr);
899     ssm_->SetAlivePersistentIds(alivePersistentIds);
900     ASSERT_EQ(ssm_->alivePersistentIds_, alivePersistentIds);
901 
902     bool res = ssm_->IsNeedRecover(0);
903     ASSERT_EQ(res, true);
904     res = ssm_->IsNeedRecover(1);
905     ASSERT_EQ(res, true);
906     res = ssm_->IsNeedRecover(2);
907     ASSERT_EQ(res, true);
908 }
909 
910 /**
911  * @tc.name: RecoverAndConnectSpecificSession
912  * @tc.desc: RecoverAndConnectSpecificSession
913  * @tc.type: FUNC
914  */
915 HWTEST_F(SceneSessionManagerSupplementTest, RecoverAndConnectSpecificSession, TestSize.Level1)
916 {
917     sptr<ISessionStage> sessionStage;
918     sptr<IWindowEventChannel> eventChannel;
919     std::shared_ptr<RSSurfaceNode> node = nullptr;
920     sptr<WindowSessionProperty> property;
921     sptr<ISession> session;
922     sptr<IRemoteObject> token;
923     auto ret = ssm_->RecoverAndConnectSpecificSession(sessionStage, eventChannel, node, property, session, token);
924     ASSERT_EQ(ret, WSError::WS_ERROR_NULLPTR);
925     property = sptr<WindowSessionProperty>::MakeSptr();
926     ASSERT_NE(property, nullptr);
927     ret = ssm_->RecoverAndConnectSpecificSession(sessionStage, eventChannel, node, property, session, token);
928     ASSERT_EQ(ret, WSError::WS_ERROR_NULLPTR);
929     ssm_->NotifyRecoveringFinished();
930     usleep(WAIT_SYNC_IN_NS);
931     ASSERT_EQ(ssm_->recoveringFinished_, true);
932 }
933 
934 /**
935  * @tc.name: TestCacheSpecificSessionForRecovering_01
936  * @tc.desc: Test CacheSpecificSessionForRecovering with recoveringFinished_ is false
937  * @tc.type: FUNC
938  */
939 HWTEST_F(SceneSessionManagerSupplementTest, TestCacheSpecificSessionForRecovering_01, TestSize.Level1)
940 {
941     sptr<SceneSession> sceneSession;
942     SessionInfo info;
943     info.bundleName_ = "test1";
944     info.abilityName_ = "test2";
945     sptr<WindowSessionProperty> property;
946     ssm_->recoveringFinished_ = true;
947     ssm_->recoverSubSessionCacheMap_.clear();
948     ssm_->CacheSpecificSessionForRecovering(sceneSession, property);
949     ASSERT_EQ(ssm_->recoverSubSessionCacheMap_.size(), 0);
950 }
951 
952 /**
953  * @tc.name: TestCacheSpecificSessionForRecovering_02
954  * @tc.desc: Test CacheSpecificSessionForRecovering with property is null
955  * @tc.type: FUNC
956  */
957 HWTEST_F(SceneSessionManagerSupplementTest, TestCacheSpecificSessionForRecovering_02, TestSize.Level1)
958 {
959     SessionInfo info;
960     info.bundleName_ = "test1";
961     info.abilityName_ = "test2";
962     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
963     sptr<WindowSessionProperty> property;
964     ssm_->recoveringFinished_ = false;
965     ssm_->recoverSubSessionCacheMap_.clear();
966     ssm_->CacheSpecificSessionForRecovering(sceneSession, property);
967     ASSERT_EQ(ssm_->recoverSubSessionCacheMap_.size(), 0);
968 }
969 
970 /**
971  * @tc.name: TestCacheSpecificSessionForRecovering_03
972  * @tc.desc: Test CacheSpecificSessionForRecovering with sceneSession is null
973  * @tc.type: FUNC
974  */
975 HWTEST_F(SceneSessionManagerSupplementTest, TestCacheSpecificSessionForRecovering_03, TestSize.Level1)
976 {
977     SessionInfo info;
978     info.bundleName_ = "test1";
979     info.abilityName_ = "test2";
980     sptr<SceneSession> sceneSession;
981     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
982     ssm_->recoveringFinished_ = false;
983     ssm_->recoverSubSessionCacheMap_.clear();
984     ssm_->CacheSpecificSessionForRecovering(sceneSession, property);
985     ASSERT_EQ(ssm_->recoverSubSessionCacheMap_.size(), 0);
986 }
987 
988 /**
989  * @tc.name: TestCacheSpecificSessionForRecovering_04
990  * @tc.desc: Test CacheSpecificSessionForRecovering with windowType is WINDOW_TYPE_APP_MAIN_WINDOW
991  * @tc.type: FUNC
992  */
993 HWTEST_F(SceneSessionManagerSupplementTest, TestCacheSpecificSessionForRecovering_04, TestSize.Level1)
994 {
995     SessionInfo info;
996     info.bundleName_ = "test1";
997     info.abilityName_ = "test2";
998     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
999     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1000     ssm_->recoveringFinished_ = false;
1001     ssm_->recoverSubSessionCacheMap_.clear();
1002     property->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
1003     ssm_->CacheSpecificSessionForRecovering(sceneSession, property);
1004     ASSERT_EQ(ssm_->recoverSubSessionCacheMap_.size(), 0);
1005 }
1006 
1007 /**
1008  * @tc.name: TestCacheSpecificSessionForRecovering_05
1009  * @tc.desc: Test CacheSpecificSessionForRecovering with windowType is APP_SUB_WINDOW_END and no parentId in map
1010  * @tc.type: FUNC
1011  */
1012 HWTEST_F(SceneSessionManagerSupplementTest, TestCacheSpecificSessionForRecovering_05, TestSize.Level1)
1013 {
1014     SessionInfo info;
1015     info.bundleName_ = "test1";
1016     info.abilityName_ = "test2";
1017     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1018     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1019     ssm_->recoveringFinished_ = false;
1020     ssm_->recoverSubSessionCacheMap_.clear();
1021     property->SetWindowType(WindowType::APP_SUB_WINDOW_END);
1022     ssm_->CacheSpecificSessionForRecovering(sceneSession, property);
1023     ASSERT_EQ(ssm_->recoverSubSessionCacheMap_.size(), 0);
1024 }
1025 
1026 /**
1027  * @tc.name: TestCacheSpecificSessionForRecovering_06
1028  * @tc.desc: Test CacheSpecificSessionForRecovering with windowType is WINDOW_TYPE_APP_SUB_WINDOW
1029  * @tc.type: FUNC
1030  */
1031 HWTEST_F(SceneSessionManagerSupplementTest, TestCacheSpecificSessionForRecovering_06, TestSize.Level1)
1032 {
1033     SessionInfo info;
1034     info.bundleName_ = "test1";
1035     info.abilityName_ = "test2";
1036     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1037     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1038     ssm_->recoveringFinished_ = false;
1039     ssm_->recoverSubSessionCacheMap_.clear();
1040     property->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
1041     property->SetParentPersistentId(1);
1042     NotifyCreateSubSessionFunc func;
1043     ssm_->createSubSessionFuncMap_.clear();
1044     ssm_->createSubSessionFuncMap_.insert({ 1, func });
1045     ssm_->CacheSpecificSessionForRecovering(sceneSession, property);
1046     ASSERT_EQ(ssm_->recoverSubSessionCacheMap_.size(), 0);
1047     ssm_->createSubSessionFuncMap_.clear();
1048 }
1049 
1050 /**
1051  * @tc.name: TestCacheSpecificSessionForRecovering_07
1052  * @tc.desc: Test CacheSpecificSessionForRecovering with windowType is WINDOW_TYPE_DIALOG
1053  * @tc.type: FUNC
1054  */
1055 HWTEST_F(SceneSessionManagerSupplementTest, TestCacheSpecificSessionForRecovering_07, TestSize.Level1)
1056 {
1057     SessionInfo info;
1058     info.bundleName_ = "test1";
1059     info.abilityName_ = "test2";
1060     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1061     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1062     ssm_->recoveringFinished_ = false;
1063     ssm_->recoverDialogSessionCacheMap_.clear();
1064     property->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
1065     property->SetParentPersistentId(1);
1066     NotifyCreateSubSessionFunc func;
1067     ssm_->bindDialogTargetFuncMap_.clear();
1068     ssm_->bindDialogTargetFuncMap_.insert({ 1, func });
1069     ssm_->CacheSpecificSessionForRecovering(sceneSession, property);
1070     ASSERT_EQ(ssm_->recoverDialogSessionCacheMap_.size(), 0);
1071 }
1072 
1073 /**
1074  * @tc.name: TestCacheSpecificSessionForRecovering_08
1075  * @tc.desc: Test CacheSpecificSessionForRecovering with windowType is WINDOW_TYPE_DIALOG and no parentId in map
1076  * @tc.type: FUNC
1077  */
1078 HWTEST_F(SceneSessionManagerSupplementTest, TestCacheSpecificSessionForRecovering_08, TestSize.Level1)
1079 {
1080     SessionInfo info;
1081     info.bundleName_ = "test1";
1082     info.abilityName_ = "test2";
1083     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1084     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1085     ssm_->recoveringFinished_ = false;
1086     ssm_->recoverDialogSessionCacheMap_.clear();
1087     property->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
1088     NotifyCreateSubSessionFunc func;
1089     ssm_->CacheSpecificSessionForRecovering(sceneSession, property);
1090     ASSERT_EQ(ssm_->recoverDialogSessionCacheMap_.size(), 1);
1091 }
1092 
1093 /**
1094  * @tc.name: TestRecoverAndReconnectSceneSession_01
1095  * @tc.desc: Test RecoverAndReconnectSceneSession with property is null
1096  * @tc.type: FUNC
1097  */
1098 HWTEST_F(SceneSessionManagerSupplementTest, TestRecoverAndReconnectSceneSession_01, TestSize.Level1)
1099 {
1100     sptr<ISessionStage> sessionStage;
1101     sptr<IWindowEventChannel> eventChannel;
1102     std::shared_ptr<RSSurfaceNode> node = nullptr;
1103     sptr<WindowSessionProperty> property;
1104     sptr<ISession> session;
1105     sptr<IRemoteObject> token;
1106 
1107     auto ret = ssm_->RecoverAndReconnectSceneSession(sessionStage, eventChannel, node, session, property, token);
1108     ASSERT_EQ(ret, WSError::WS_ERROR_NULLPTR);
1109 }
1110 
1111 /**
1112  * @tc.name: TestRecoverAndReconnectSceneSession_02
1113  * @tc.desc: Test RecoverAndReconnectSceneSession with recoveringFinished_ is true
1114  * @tc.type: FUNC
1115  */
1116 HWTEST_F(SceneSessionManagerSupplementTest, TestRecoverAndReconnectSceneSession_02, TestSize.Level1)
1117 {
1118     sptr<ISessionStage> sessionStage;
1119     sptr<IWindowEventChannel> eventChannel;
1120     std::shared_ptr<RSSurfaceNode> node = nullptr;
1121     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1122     sptr<ISession> session;
1123     sptr<IRemoteObject> token;
1124 
1125     property->SetPersistentId(1);
1126     ssm_->alivePersistentIds_.push_back(1);
1127     ssm_->recoveringFinished_ = true;
1128     auto ret = ssm_->RecoverAndReconnectSceneSession(sessionStage, eventChannel, node, session, property, token);
1129     ASSERT_EQ(ret, WSError::WS_ERROR_INVALID_OPERATION);
1130     ssm_->alivePersistentIds_.clear();
1131 }
1132 
1133 /**
1134  * @tc.name: TestRecoverAndReconnectSceneSession_03
1135  * @tc.desc: Test RecoverAndReconnectSceneSession with recoveringFinished_ is false
1136  * @tc.type: FUNC
1137  */
1138 HWTEST_F(SceneSessionManagerSupplementTest, TestRecoverAndReconnectSceneSession_03, TestSize.Level1)
1139 {
1140     sptr<ISessionStage> sessionStage;
1141     sptr<IWindowEventChannel> eventChannel;
1142     std::shared_ptr<RSSurfaceNode> node = nullptr;
1143     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1144     sptr<ISession> session;
1145     sptr<IRemoteObject> token;
1146 
1147     property->SetPersistentId(1);
1148     ssm_->alivePersistentIds_.push_back(1);
1149     ssm_->recoveringFinished_ = false;
1150     auto ret = ssm_->RecoverAndReconnectSceneSession(sessionStage, eventChannel, node, session, property, token);
1151     ASSERT_EQ(ret, WSError::WS_ERROR_NULLPTR);
1152     ssm_->alivePersistentIds_.clear();
1153 }
1154 
1155 /**
1156  * @tc.name: TestRecoverAndReconnectSceneSession_04
1157  * @tc.desc: Test RecoverAndReconnectSceneSession with windowType is APP_SUB_WINDOW_END
1158  * @tc.type: FUNC
1159  */
1160 HWTEST_F(SceneSessionManagerSupplementTest, TestRecoverAndReconnectSceneSession_04, TestSize.Level1)
1161 {
1162     sptr<ISessionStage> sessionStage;
1163     sptr<IWindowEventChannel> eventChannel;
1164     std::shared_ptr<RSSurfaceNode> node = nullptr;
1165     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1166     sptr<ISession> session;
1167     sptr<IRemoteObject> token;
1168 
1169     property->SetPersistentId(1);
1170     ssm_->alivePersistentIds_.push_back(1);
1171     ssm_->recoveringFinished_ = false;
1172     property->SetWindowType(WindowType::APP_SUB_WINDOW_END);
1173     auto ret = ssm_->RecoverAndReconnectSceneSession(sessionStage, eventChannel, node, session, property, token);
1174     ASSERT_EQ(ret, WSError::WS_ERROR_NULLPTR);
1175     ssm_->alivePersistentIds_.clear();
1176 }
1177 
1178 /**
1179  * @tc.name: NotifyCreateSpecificSession
1180  * @tc.desc: NotifyCreateSpecificSession
1181  * @tc.type: FUNC
1182  */
1183 HWTEST_F(SceneSessionManagerSupplementTest, NotifyCreateSpecificSession, TestSize.Level1)
1184 {
1185     sptr<SceneSession> sceneSession;
1186     sptr<WindowSessionProperty> property;
1187     ASSERT_NE(ssm_, nullptr);
1188     ssm_->NotifyCreateSpecificSession(sceneSession, property, WindowType::APP_MAIN_WINDOW_BASE);
1189     SessionInfo info;
1190     info.bundleName_ = "test1";
1191     info.abilityName_ = "test2";
1192     sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1193     ASSERT_NE(sceneSession, nullptr);
1194     ssm_->NotifyCreateSpecificSession(sceneSession, property, WindowType::APP_MAIN_WINDOW_BASE);
1195     property = sptr<WindowSessionProperty>::MakeSptr();
1196     ASSERT_NE(property, nullptr);
1197     ssm_->NotifyCreateSpecificSession(sceneSession, property, WindowType::APP_MAIN_WINDOW_BASE);
1198     ssm_->NotifyCreateSpecificSession(sceneSession, property, WindowType::SYSTEM_SUB_WINDOW_BASE);
1199     ssm_->NotifyCreateSpecificSession(sceneSession, property, WindowType::APP_SUB_WINDOW_BASE);
1200     ssm_->NotifyCreateSpecificSession(sceneSession, property, WindowType::WINDOW_TYPE_SCENE_BOARD);
1201     ssm_->NotifyCreateSpecificSession(sceneSession, property, WindowType::WINDOW_TYPE_TOAST);
1202     ssm_->NotifyCreateSpecificSession(sceneSession, property, WindowType::WINDOW_TYPE_FLOAT);
1203     property->SetParentPersistentId(1);
1204     ASSERT_EQ(property->GetParentPersistentId(), 1);
1205     SessionInfo info1;
1206     info1.bundleName_ = "test3";
1207     info1.abilityName_ = "test3";
1208     sptr<SceneSession> sceneSession2 = sptr<SceneSession>::MakeSptr(info1, nullptr);
1209     ssm_->sceneSessionMap_.insert({ 1, sceneSession2 });
1210     ASSERT_TRUE(ssm_->sceneSessionMap_.find(1) != ssm_->sceneSessionMap_.end());
1211     ssm_->NotifyCreateSpecificSession(sceneSession, property, WindowType::WINDOW_TYPE_FLOAT);
1212     ssm_->NotifyCreateSpecificSession(sceneSession, property, WindowType::WINDOW_TYPE_DIALOG);
1213     ssm_->NotifyCreateSpecificSession(sceneSession, property, WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
1214     ssm_->NotifyCreateSpecificSession(sceneSession, property, WindowType::BELOW_APP_SYSTEM_WINDOW_BASE);
1215 }
1216 
1217 /**
1218  * @tc.name: NotifyCreateSubSession
1219  * @tc.desc: NotifyCreateSubSession
1220  * @tc.type: FUNC
1221  */
1222 HWTEST_F(SceneSessionManagerSupplementTest, NotifyCreateSubSession, TestSize.Level1)
1223 {
1224     sptr<SceneSession> sceneSession;
1225     ssm_->NotifyCreateSubSession(1, sceneSession);
1226     SessionInfo info;
1227     info.bundleName_ = "test1";
1228     info.abilityName_ = "test2";
1229     sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1230     ASSERT_NE(sceneSession, nullptr);
1231     ssm_->NotifyCreateSubSession(1, sceneSession);
1232     ssm_->UnregisterSpecificSessionCreateListener(1);
1233     ASSERT_TRUE(ssm_->createSubSessionFuncMap_.find(1) == ssm_->createSubSessionFuncMap_.end());
1234     SessionInfo info1;
1235     info1.bundleName_ = "test1";
1236     info1.abilityName_ = "test2";
1237     sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(info1, nullptr);
1238     ASSERT_NE(sceneSession1, nullptr);
1239     NotifyCreateSubSessionFunc func;
1240     ssm_->createSubSessionFuncMap_.insert({ 1, func });
1241     ssm_->NotifyCreateSubSession(1, sceneSession);
1242     ssm_->UnregisterSpecificSessionCreateListener(1);
1243     ssm_->createSubSessionFuncMap_.clear();
1244     ASSERT_TRUE(ssm_->createSubSessionFuncMap_.find(1) == ssm_->createSubSessionFuncMap_.end());
1245     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1246     ASSERT_NE(property, nullptr);
1247     property->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
1248     sceneSession->SetSessionProperty(property);
1249     ssm_->sceneSessionMap_.insert({ 1, sceneSession });
1250     ASSERT_TRUE(ssm_->sceneSessionMap_.find(1) != ssm_->sceneSessionMap_.end());
1251     ssm_->NotifySessionTouchOutside(1, 0);
1252     sceneSession->state_ = SessionState::STATE_FOREGROUND;
1253     ssm_->NotifySessionTouchOutside(1, 0);
1254     sceneSession->persistentId_ = property->callingSessionId_;
1255     ssm_->NotifySessionTouchOutside(1, 0);
1256     sceneSession->persistentId_ = property->callingSessionId_ + 1;
1257     ssm_->NotifySessionTouchOutside(1, 0);
1258     static constexpr uint32_t WAIT_SYNC_IN_NS = 200000;
1259     usleep(WAIT_SYNC_IN_NS);
1260 }
1261 
1262 /**
1263  * @tc.name: TestDestroyAndDisconSpecSessionInner_01
1264  * @tc.desc: Test DestroyAndDisconnectSpecificSessionInner with invaild persistentId
1265  * @tc.type: FUNC
1266  */
1267 HWTEST_F(SceneSessionManagerSupplementTest, TestDestroyAndDisconSpecSessionInner_01, TestSize.Level1)
1268 {
1269     ssm_->sceneSessionMap_.clear();
1270     int invaildPersistentId = -1;
1271     auto ret = ssm_->DestroyAndDisconnectSpecificSessionInner(invaildPersistentId);
1272     ASSERT_EQ(ret, WSError::WS_ERROR_NULLPTR);
1273 }
1274 
1275 /**
1276  * @tc.name: TestDestroyAndDisconSpecSessionInner_02
1277  * @tc.desc: Test DestroyAndDisconnectSpecificSessionInner with true persistentId
1278  * @tc.type: FUNC
1279  */
1280 HWTEST_F(SceneSessionManagerSupplementTest, TestDestroyAndDisconSpecSessionInner_02, TestSize.Level1)
1281 {
1282     ssm_->sceneSessionMap_.clear();
1283     SessionInfo info;
1284     info.bundleName_ = "test1";
1285     info.abilityName_ = "test2";
1286     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1287     uint32_t uid = 0;
1288     ssm_->GetTopWindowId(1, uid);
1289     ssm_->sceneSessionMap_.insert({ 1, sceneSession });
1290     ssm_->GetTopWindowId(1, uid);
1291     auto ret = ssm_->DestroyAndDisconnectSpecificSessionInner(1);
1292     ASSERT_EQ(ret, WSError::WS_OK);
1293 }
1294 
1295 /**
1296  * @tc.name: TestDestroyAndDisconSpecSessionInner_03
1297  * @tc.desc: Test DestroyAndDisconnectSpecificSessionInner with WindowType APP_SUB_WINDOW_BASE
1298  * @tc.type: FUNC
1299  */
1300 HWTEST_F(SceneSessionManagerSupplementTest, TestDestroyAndDisconSpecSessionInner_03, TestSize.Level1)
1301 {
1302     ssm_->sceneSessionMap_.clear();
1303     SessionInfo info;
1304     info.bundleName_ = "test1";
1305     info.abilityName_ = "test2";
1306     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1307     uint32_t uid = 0;
1308     ssm_->GetTopWindowId(1, uid);
1309     ssm_->sceneSessionMap_.insert({ 1, sceneSession });
1310     ssm_->GetTopWindowId(1, uid);
1311     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1312     property->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
1313     property->SetParentPersistentId(100);
1314     ASSERT_EQ(property->GetParentPersistentId(), 100);
1315     sceneSession->SetSessionProperty(property);
1316     auto ret = ssm_->DestroyAndDisconnectSpecificSessionInner(1);
1317     ASSERT_EQ(ret, WSError::WS_OK);
1318 }
1319 
1320 /**
1321  * @tc.name: TestDestroyAndDisconSpecSessionInner_04
1322  * @tc.desc: Test DestroyAndDisconnectSpecificSessionInner with WindowType WINDOW_TYPE_DIALOG
1323  * @tc.type: FUNC
1324  */
1325 HWTEST_F(SceneSessionManagerSupplementTest, TestDestroyAndDisconSpecSessionInner_04, TestSize.Level1)
1326 {
1327     ssm_->sceneSessionMap_.clear();
1328     SessionInfo info;
1329     info.bundleName_ = "test1";
1330     info.abilityName_ = "test2";
1331     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1332     uint32_t uid = 0;
1333     ssm_->GetTopWindowId(1, uid);
1334     ssm_->sceneSessionMap_.insert({ 1, sceneSession });
1335     ssm_->GetTopWindowId(1, uid);
1336     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1337     property->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
1338     property->SetParentPersistentId(100);
1339     ASSERT_EQ(property->GetParentPersistentId(), 100);
1340     sceneSession->SetSessionProperty(property);
1341     auto ret = ssm_->DestroyAndDisconnectSpecificSessionInner(1);
1342     ASSERT_EQ(ret, WSError::WS_OK);
1343 }
1344 
1345 /**
1346  * @tc.name: GetFocusWindowInfo
1347  * @tc.desc: GetFocusWindowInfo
1348  * @tc.type: FUNC
1349  */
1350 HWTEST_F(SceneSessionManagerSupplementTest, GetFocusWindowInfo, TestSize.Level1)
1351 {
1352     sptr<WindowSessionProperty> property;
1353     sptr<SceneSession> sceneSession;
1354     ssm_->NotifySessionForCallback(sceneSession, true);
1355     SessionInfo info;
1356     info.bundleName_ = "test1";
1357     info.abilityName_ = "test2";
1358     info.isSystem_ = true;
1359     sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1360     ASSERT_NE(sceneSession, nullptr);
1361     ssm_->NotifySessionForCallback(sceneSession, true);
1362     info.isSystem_ = false;
1363     ssm_->NotifySessionForCallback(sceneSession, true);
1364     property = sptr<WindowSessionProperty>::MakeSptr();
1365     ASSERT_NE(property, nullptr);
1366     property->SetBrightness(1.f);
1367     auto ret = ssm_->SetBrightness(sceneSession, 1.f);
1368     ASSERT_EQ(ret, WSError::WS_OK);
1369     ret = ssm_->SetBrightness(sceneSession, 2.f);
1370     ASSERT_EQ(ret, WSError::WS_OK);
1371     ssm_->displayBrightness_ = 2.f;
1372     ret = ssm_->SetBrightness(sceneSession, 2.f);
1373     ASSERT_EQ(ret, WSError::WS_OK);
1374     ssm_->displayBrightness_ = 3.f;
1375     ret = ssm_->SetBrightness(sceneSession, 2.f);
1376     ASSERT_EQ(ret, WSError::WS_OK);
1377     ssm_->systemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW;
1378     ret = ssm_->UpdateBrightness(1);
1379     ASSERT_EQ(ret, WSError::WS_ERROR_NULLPTR);
1380     ssm_->sceneSessionMap_.insert({ 1, sceneSession });
1381     property->SetBrightness(-1.f);
1382     property->SetWindowType(WindowType::APP_WINDOW_BASE);
1383     sceneSession->SetSessionProperty(property);
1384     ret = ssm_->UpdateBrightness(1);
1385     ASSERT_EQ(ret, WSError::WS_OK);
1386     property->SetBrightness(3.f);
1387     property->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
1388     sceneSession->SetSessionProperty(property);
1389     ret = ssm_->UpdateBrightness(1);
1390     ASSERT_EQ(ret, WSError::WS_OK);
1391     FocusChangeInfo changeInfo;
1392     ssm_->GetFocusWindowInfo(changeInfo);
1393 }
1394 
1395 /**
1396  * @tc.name: TestIsSessionVisible_01
1397  * @tc.desc: Test IsSessionVisible with session is null then false
1398  * @tc.type: FUNC
1399  */
1400 HWTEST_F(SceneSessionManagerSupplementTest, TestIsSessionVisible_01, TestSize.Level1)
1401 {
1402     sptr<SceneSession> sceneSession;
1403     bool ret = ssm_->IsSessionVisible(sceneSession);
1404     ASSERT_EQ(ret, false);
1405 }
1406 
1407 /**
1408  * @tc.name: TestIsSessionVisible_02
1409  * @tc.desc: Test IsSessionVisible with isScbCoreEnabled_ is true then false
1410  * @tc.type: FUNC
1411  */
1412 HWTEST_F(SceneSessionManagerSupplementTest, TestIsSessionVisible_02, TestSize.Level1)
1413 {
1414     SessionInfo info;
1415     info.bundleName_ = "test1";
1416     info.abilityName_ = "test2";
1417     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1418     sceneSession->SetScbCoreEnabled(true);
1419     sceneSession->isVisible_ = false;
1420 
1421     bool ret = ssm_->IsSessionVisible(sceneSession);
1422     ASSERT_EQ(ret, false);
1423 }
1424 
1425 /**
1426  * @tc.name: TestIsSessionVisible_03
1427  * @tc.desc: Test IsSessionVisible with WindowType is APP_SUB_WINDOW_BASE then false
1428  * @tc.type: FUNC
1429  */
1430 HWTEST_F(SceneSessionManagerSupplementTest, TestIsSessionVisible_03, TestSize.Level1)
1431 {
1432     SessionInfo info;
1433     info.bundleName_ = "test1";
1434     info.abilityName_ = "test2";
1435     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1436     sceneSession->SetScbCoreEnabled(false);
1437     sceneSession->isVisible_ = true;
1438     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1439     property->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
1440     sceneSession->SetSessionProperty(property);
1441 
1442     bool ret = ssm_->IsSessionVisible(sceneSession);
1443     ASSERT_EQ(ret, false);
1444 }
1445 
1446 /**
1447  * @tc.name: TestIsSessionVisible_04
1448  * @tc.desc: Test IsSessionVisible with mainSession is not null then true
1449  * @tc.type: FUNC
1450  */
1451 HWTEST_F(SceneSessionManagerSupplementTest, TestIsSessionVisible_04, TestSize.Level1)
1452 {
1453     ssm_->sceneSessionMap_.clear();
1454     SessionInfo info;
1455     info.bundleName_ = "test1";
1456     info.abilityName_ = "test2";
1457     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1458     sceneSession->SetScbCoreEnabled(false);
1459     sceneSession->isVisible_ = true;
1460     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1461     property->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
1462     SessionInfo info1;
1463     info1.bundleName_ = "test3";
1464     sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(info1, nullptr);
1465     ssm_->sceneSessionMap_.insert({ 100, sceneSession1 });
1466     property->SetParentPersistentId(100);
1467     sceneSession->SetSessionProperty(property);
1468     sceneSession->SetParentSession(sceneSession1);
1469 
1470     bool ret = ssm_->IsSessionVisible(sceneSession);
1471     ASSERT_EQ(ret, true);
1472 }
1473 
1474 /**
1475  * @tc.name: TestIsSessionVisible_05
1476  * @tc.desc: Test IsSessionVisible with session and mainSession state is STATE_ACTIVE then true
1477  * @tc.type: FUNC
1478  */
1479 HWTEST_F(SceneSessionManagerSupplementTest, TestIsSessionVisible_05, TestSize.Level1)
1480 {
1481     ssm_->sceneSessionMap_.clear();
1482     SessionInfo info;
1483     info.bundleName_ = "test1";
1484     info.abilityName_ = "test2";
1485     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1486     sceneSession->SetScbCoreEnabled(false);
1487     sceneSession->isVisible_ = true;
1488     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1489     property->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
1490     SessionInfo info1;
1491     info1.bundleName_ = "test3";
1492     sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(info1, nullptr);
1493     ssm_->sceneSessionMap_.insert({ 1, sceneSession1 });
1494     property->SetParentPersistentId(1);
1495     sceneSession->SetSessionProperty(property);
1496     sceneSession->SetParentSession(sceneSession1);
1497     sceneSession1->state_ = SessionState::STATE_ACTIVE;
1498     sceneSession->state_ = SessionState::STATE_ACTIVE;
1499 
1500     bool ret = ssm_->IsSessionVisible(sceneSession);
1501     ASSERT_EQ(ret, true);
1502 }
1503 
1504 /**
1505  * @tc.name: TestIsSessionVisible_06
1506  * @tc.desc: Test IsSessionVisible with session state is STATE_ACTIVE and mainSession state is STATE_INACTIVE then false
1507  * @tc.type: FUNC
1508  */
1509 HWTEST_F(SceneSessionManagerSupplementTest, TestIsSessionVisible_06, TestSize.Level1)
1510 {
1511     ssm_->sceneSessionMap_.clear();
1512     SessionInfo info;
1513     info.bundleName_ = "test1";
1514     info.abilityName_ = "test2";
1515     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1516     sceneSession->SetScbCoreEnabled(false);
1517     sceneSession->isVisible_ = true;
1518     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1519     property->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
1520     SessionInfo info1;
1521     info1.bundleName_ = "test3";
1522     sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(info1, nullptr);
1523     ssm_->sceneSessionMap_.insert({ 1, sceneSession1 });
1524     property->SetParentPersistentId(1);
1525     sceneSession->SetSessionProperty(property);
1526     sceneSession->SetParentSession(sceneSession1);
1527     sceneSession1->state_ = SessionState::STATE_INACTIVE;
1528     sceneSession->state_ = SessionState::STATE_ACTIVE;
1529 
1530     bool ret = ssm_->IsSessionVisible(sceneSession);
1531     ASSERT_EQ(ret, false);
1532 }
1533 
1534 /**
1535  * @tc.name: TestIsSessionVisible_07
1536  * @tc.desc: Test IsSessionVisible with session state is STATE_INACTIVE and isVisible_ is false then false
1537  * @tc.type: FUNC
1538  */
1539 HWTEST_F(SceneSessionManagerSupplementTest, TestIsSessionVisible_07, TestSize.Level1)
1540 {
1541     ssm_->sceneSessionMap_.clear();
1542     SessionInfo info;
1543     info.bundleName_ = "test1";
1544     info.abilityName_ = "test2";
1545     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1546     sceneSession->SetScbCoreEnabled(false);
1547     sceneSession->isVisible_ = false;
1548     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1549     property->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
1550     SessionInfo info1;
1551     info1.bundleName_ = "test3";
1552     sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(info1, nullptr);
1553     ssm_->sceneSessionMap_.insert({ 1, sceneSession1 });
1554     property->SetParentPersistentId(1);
1555     sceneSession->SetSessionProperty(property);
1556     sceneSession->SetParentSession(sceneSession1);
1557     sceneSession->state_ = SessionState::STATE_INACTIVE;
1558 
1559     bool ret = ssm_->IsSessionVisible(sceneSession);
1560     ASSERT_EQ(ret, false);
1561 }
1562 
1563 /**
1564  * @tc.name: TestIsSessionVisible_08
1565  * @tc.desc: Test IsSessionVisible with window type is WINDOW_TYPE_APP_MAIN_WINDOW and isVisible_ is true then true
1566  * @tc.type: FUNC
1567  */
1568 HWTEST_F(SceneSessionManagerSupplementTest, TestIsSessionVisible_08, TestSize.Level1)
1569 {
1570     ssm_->sceneSessionMap_.clear();
1571     SessionInfo info;
1572     info.bundleName_ = "test1";
1573     info.abilityName_ = "test2";
1574     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1575     sceneSession->SetScbCoreEnabled(false);
1576     sceneSession->isVisible_ = true;
1577     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1578     property->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
1579     sceneSession->SetSessionProperty(property);
1580     sceneSession->state_ = SessionState::STATE_INACTIVE;
1581 
1582     bool ret = ssm_->IsSessionVisible(sceneSession);
1583     ASSERT_EQ(ret, true);
1584 }
1585 
1586 /**
1587  * @tc.name: TestIsSessionVisible_09
1588  * @tc.desc: Test IsSessionVisible with window type is WINDOW_TYPE_APP_MAIN_WINDOW and isVisible_ is false then true
1589  * @tc.type: FUNC
1590  */
1591 HWTEST_F(SceneSessionManagerSupplementTest, TestIsSessionVisible_09, TestSize.Level1)
1592 {
1593     ssm_->sceneSessionMap_.clear();
1594     SessionInfo info;
1595     info.bundleName_ = "test1";
1596     info.abilityName_ = "test2";
1597     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1598     sceneSession->SetScbCoreEnabled(false);
1599     sceneSession->isVisible_ = false;
1600     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1601     property->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
1602     sceneSession->SetSessionProperty(property);
1603     sceneSession->state_ = SessionState::STATE_ACTIVE;
1604 
1605     bool ret = ssm_->IsSessionVisible(sceneSession);
1606     ASSERT_EQ(ret, true);
1607 }
1608 
1609 /**
1610  * @tc.name: RegisterBindDialogTargetListener
1611  * @tc.desc: RegisterBindDialogTargetListener
1612  * @tc.type: FUNC
1613  */
1614 HWTEST_F(SceneSessionManagerSupplementTest, RegisterBindDialogTargetListener, TestSize.Level1)
1615 {
1616     SessionInfo info;
1617     info.bundleName_ = "test1";
1618     info.abilityName_ = "test2";
1619     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1620     ASSERT_NE(sceneSession, nullptr);
1621 
1622     int32_t persistentId = 1;
1623     ssm_->UnregisterSpecificSessionCreateListener(persistentId);
1624     NotifyBindDialogSessionFunc func1;
1625     ssm_->RegisterBindDialogTargetListener(sceneSession, std::move(func1));
1626     ssm_->UnregisterSpecificSessionCreateListener(persistentId);
1627 
1628     NotifyBindDialogSessionFunc func2;
1629     ssm_->bindDialogTargetFuncMap_.insert({ persistentId, func2 });
1630     ASSERT_NE(ssm_->bindDialogTargetFuncMap_.find(persistentId), ssm_->bindDialogTargetFuncMap_.end());
1631     ssm_->bindDialogTargetFuncMap_.erase(persistentId);
1632     ASSERT_EQ(ssm_->bindDialogTargetFuncMap_.find(persistentId), ssm_->bindDialogTargetFuncMap_.end());
1633     ssm_->bindDialogTargetFuncMap_.insert({ persistentId, func2 });
1634     ASSERT_NE(ssm_->bindDialogTargetFuncMap_.find(persistentId), ssm_->bindDialogTargetFuncMap_.end());
1635     ssm_->bindDialogTargetFuncMap_.clear();
1636     ASSERT_EQ(ssm_->bindDialogTargetFuncMap_.find(persistentId), ssm_->bindDialogTargetFuncMap_.end());
1637 }
1638 } // namespace
1639 } // namespace Rosen
1640 } // namespace OHOS