• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <gtest/gtest.h>
17 
18 #include "interfaces/include/ws_common.h"
19 #include "iremote_object_mocker.h"
20 #include "session_manager/include/scene_session_manager.h"
21 #include "session_info.h"
22 #include "session/host/include/scene_session.h"
23 #include "session_manager.h"
24 
25 using namespace testing;
26 using namespace testing::ext;
27 
28 namespace OHOS {
29 namespace Rosen {
30 
31 class SceneSessionManagerTest9 : public testing::Test {
32 public:
33     static void SetUpTestCase();
34     static void TearDownTestCase();
35     void SetUp() override;
36     void TearDown() override;
37 
38     static sptr<SceneSessionManager> ssm_;
39 private:
40     static constexpr uint32_t WAIT_SYNC_IN_NS = 200000;
41 };
42 
43 sptr<SceneSessionManager> SceneSessionManagerTest9::ssm_ = nullptr;
44 
NotifyRecoverSceneSessionFuncTest(const sptr<SceneSession> & session,const SessionInfo & sessionInfo)45 void NotifyRecoverSceneSessionFuncTest(const sptr<SceneSession>& session, const SessionInfo& sessionInfo)
46 {
47 }
48 
TraverseFuncTest(const sptr<SceneSession> & session)49 bool TraverseFuncTest(const sptr<SceneSession>& session)
50 {
51     return true;
52 }
53 
WindowChangedFuncTest(int32_t persistentId,WindowUpdateType type)54 void WindowChangedFuncTest(int32_t persistentId, WindowUpdateType type)
55 {
56 }
57 
ProcessStatusBarEnabledChangeFuncTest(bool enable)58 void ProcessStatusBarEnabledChangeFuncTest(bool enable)
59 {
60 }
61 
DumpRootSceneElementInfoFuncTest(const std::vector<std::string> & params,std::vector<std::string> & infos)62 void DumpRootSceneElementInfoFuncTest(const std::vector<std::string>& params, std::vector<std::string>& infos)
63 {
64 }
65 
SetUpTestCase()66 void SceneSessionManagerTest9::SetUpTestCase()
67 {
68     ssm_ = &SceneSessionManager::GetInstance();
69 }
70 
TearDownTestCase()71 void SceneSessionManagerTest9::TearDownTestCase()
72 {
73     ssm_ = nullptr;
74 }
75 
SetUp()76 void SceneSessionManagerTest9::SetUp()
77 {
78 }
79 
TearDown()80 void SceneSessionManagerTest9::TearDown()
81 {
82     usleep(WAIT_SYNC_IN_NS);
83 }
84 
85 namespace {
86 /**
87  * @tc.name: TraverseSessionTreeFromTopToBottom
88  * @tc.desc: TraverseSessionTreeFromTopToBottom
89  * @tc.type: FUNC
90  */
91 HWTEST_F(SceneSessionManagerTest9, TraverseSessionTreeFromTopToBottom, Function | SmallTest | Level3)
92 {
93     ASSERT_NE(nullptr, ssm_);
94     ssm_->TraverseSessionTreeFromTopToBottom(TraverseFuncTest);
95 
96     SessionInfo sessionInfo;
97     sessionInfo.bundleName_ = "SceneSessionManagerTest9";
98     sessionInfo.abilityName_ = "TraverseSessionTreeFromTopToBottom";
99     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
100     ASSERT_NE(nullptr, sceneSession);
101     ssm_->sceneSessionMap_.insert(std::make_pair(1, nullptr));
102     ssm_->sceneSessionMap_.insert(std::make_pair(2, sceneSession));
103     ssm_->TraverseSessionTreeFromTopToBottom(TraverseFuncTest);
104 }
105 
106 /**
107  * @tc.name: RequestFocusStatus02
108  * @tc.desc: RequestFocusStatus
109  * @tc.type: FUNC
110  */
111 HWTEST_F(SceneSessionManagerTest9, RequestFocusStatus02, Function | SmallTest | Level3)
112 {
113     ASSERT_NE(nullptr, ssm_);
114     EXPECT_EQ(ssm_->RequestFocusStatus(1, false, false, FocusChangeReason::FLOATING_SCENE), WMError::WM_ERROR_NULLPTR);
115 
116     SessionInfo sessionInfo;
117     sessionInfo.bundleName_ = "SceneSessionManagerTest9";
118     sessionInfo.abilityName_ = "RequestFocusStatus02";
119     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
120     ASSERT_NE(nullptr, sceneSession);
121     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
122     ssm_->RequestFocusStatus(1, false, false, FocusChangeReason::FLOATING_SCENE);
123 }
124 
125 /**
126  * @tc.name: RequestSessionFocusImmediately02
127  * @tc.desc: RequestSessionFocusImmediately
128  * @tc.type: FUNC
129  */
130 HWTEST_F(SceneSessionManagerTest9, RequestSessionFocusImmediately02, Function | SmallTest | Level3)
131 {
132     ASSERT_NE(nullptr, ssm_);
133     EXPECT_NE(ssm_->RequestSessionFocusImmediately(0), WSError::WS_OK);
134 
135     ssm_->RequestSessionFocusImmediately(2);
136 
137     SessionInfo sessionInfo;
138     sessionInfo.bundleName_ = "SceneSessionManagerTest9";
139     sessionInfo.abilityName_ = "RequestSessionFocusImmediately02";
140     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
141 
142     ASSERT_NE(nullptr, sceneSession);
143     sceneSession->SetFocusable(false);
144     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
145     ssm_->RequestSessionFocusImmediately(1);
146 
147     sceneSession->SetFocusable(true);
148     sceneSession->SetFocusedOnShow(false);
149     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
150     ssm_->RequestSessionFocusImmediately(1);
151 
152     sceneSession->SetFocusedOnShow(true);
153     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
154     ssm_->RequestSessionFocusImmediately(1);
155 }
156 
157 /**
158  * @tc.name: RequestSessionFocus02
159  * @tc.desc: RequestSessionFocus
160  * @tc.type: FUNC
161  */
162 HWTEST_F(SceneSessionManagerTest9, RequestSessionFocus02, Function | SmallTest | Level3)
163 {
164     ASSERT_NE(nullptr, ssm_);
165     SessionInfo sessionInfo;
166     sessionInfo.bundleName_ = "SceneSessionManagerTest9";
167     sessionInfo.abilityName_ = "RequestSessionFocus02";
168     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
169     ASSERT_NE(nullptr, sceneSession);
170     sceneSession->SetFocusable(true);
171     sceneSession->UpdateVisibilityInner(true);
172     sceneSession->SetSessionState(SessionState::STATE_ACTIVE);
173     sceneSession->SetFocusedOnShow(false);
174     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
175     ssm_->RequestSessionFocus(1, false, FocusChangeReason::DEFAULT);
176 
177     sceneSession->SetFocusedOnShow(true);
178     sceneSession->SetFocusableOnShow(false);
179     sceneSession->GetSessionProperty()->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
180     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
181     WSError ret = ssm_->RequestSessionFocus(1, false, FocusChangeReason::FOREGROUND);
182     ASSERT_EQ(ret, WSError::WS_DO_NOTHING);
183 
184     sceneSession->SetFocusableOnShow(false);
185     sceneSession->GetSessionProperty()->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
186     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
187     ssm_->RequestSessionFocus(1, false, FocusChangeReason::DEFAULT);
188 
189     sceneSession->GetSessionProperty()->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
190     sceneSession->SetForceHideState(ForceHideState::HIDDEN_WHEN_FOCUSED);
191     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
192     ssm_->RequestSessionFocus(1, false, FocusChangeReason::DEFAULT);
193 
194     sceneSession->SetForceHideState(ForceHideState::NOT_HIDDEN);
195     sceneSession->SetTopmost(true);
196     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
197     ssm_->RequestSessionFocus(1, false, FocusChangeReason::DEFAULT);
198 }
199 
200 /**
201  * @tc.name: ProcessFocusWhenForegroundScbCore
202  * @tc.desc: ProcessFocusWhenForegroundScbCore
203  * @tc.type: FUNC
204  */
205 HWTEST_F(SceneSessionManagerTest9, ProcessFocusWhenForegroundScbCore, Function | SmallTest | Level3)
206 {
207     ASSERT_NE(nullptr, ssm_);
208     ssm_->focusedSessionId_ = 0;
209     SessionInfo sessionInfo;
210     sessionInfo.bundleName_ = "SceneSessionManagerTest9";
211     sessionInfo.abilityName_ = "ProcessFocusWhenForegroundScbCore";
212     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
213     sceneSession->persistentId_ = 1;
214     ASSERT_NE(nullptr, sceneSession->property_);
215     sceneSession->SetFocusableOnShow(false);
216     sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
217     ssm_->ProcessFocusWhenForegroundScbCore(sceneSession);
218     ASSERT_EQ(sceneSession->GetPostProcessFocusState().isFocused_, false);
219     ASSERT_EQ(ssm_->focusedSessionId_, 0);
220 
221     sceneSession->SetFocusableOnShow(true);
222     ssm_->ProcessFocusWhenForegroundScbCore(sceneSession); // SetPostProcessFocusState
223     ASSERT_EQ(sceneSession->GetPostProcessFocusState().isFocused_, true);
224 
225     sceneSession->isVisible_ = true;
226     sceneSession->SetSessionState(SessionState::STATE_FOREGROUND);
227     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
228     ssm_->ProcessFocusWhenForegroundScbCore(sceneSession); // RequestSessionFocus
229     ASSERT_EQ(ssm_->focusedSessionId_, 1);
230 }
231 
232 /**
233  * @tc.name: RequestSessionUnfocus02
234  * @tc.desc: RequestSessionUnfocus
235  * @tc.type: FUNC
236  */
237 HWTEST_F(SceneSessionManagerTest9, RequestSessionUnfocus02, Function | SmallTest | Level3)
238 {
239     ASSERT_NE(nullptr, ssm_);
240     ssm_->RequestSessionUnfocus(1, FocusChangeReason::DEFAULT);
241 
242     SessionInfo sessionInfo;
243     sessionInfo.bundleName_ = "SceneSessionManagerTest9";
244     sessionInfo.abilityName_ = "RequestSessionUnfocus02";
245     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
246     ASSERT_NE(nullptr, sceneSession);
247     ssm_->focusedSessionId_ = 2;
248     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
249 
250     SessionInfo sessionInfo1;
251     sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(sessionInfo1, nullptr);
252     ASSERT_NE(nullptr, sceneSession1);
253     sceneSession1->GetSessionProperty()->SetParentPersistentId(3);
254     sceneSession1->GetSessionProperty()->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
255     ssm_->sceneSessionMap_.insert(std::make_pair(2, sceneSession1));
256     ssm_->RequestSessionUnfocus(1, FocusChangeReason::DEFAULT);
257 
258     ssm_->lastFocusedSessionId_ = 4;
259     sceneSession1->GetSessionProperty()->SetWindowType(WindowType::WINDOW_TYPE_SYSTEM_FLOAT);
260     ssm_->RequestSessionUnfocus(1, FocusChangeReason::DEFAULT);
261 
262     SessionInfo sessionInfo2;
263     sptr<SceneSession> sceneSession2 = sptr<SceneSession>::MakeSptr(sessionInfo2, nullptr);
264     ASSERT_NE(nullptr, sceneSession2);
265     sceneSession2->GetSessionProperty()->SetWindowType(WindowType::WINDOW_TYPE_SYSTEM_FLOAT);
266     ssm_->sceneSessionMap_.insert(std::make_pair(4, sceneSession1));
267     ssm_->RequestSessionUnfocus(1, FocusChangeReason::DEFAULT);
268 
269     sceneSession2->GetSessionProperty()->SetWindowType(WindowType::WINDOW_TYPE_DESKTOP);
270     ssm_->RequestSessionUnfocus(1, FocusChangeReason::DEFAULT);
271 
272     ssm_->focusedSessionId_ = 5;
273     ssm_->RequestSessionUnfocus(1, FocusChangeReason::DEFAULT);
274 }
275 
276 /**
277  * @tc.name: RequestAllAppSessionUnfocusInner
278  * @tc.desc: RequestAllAppSessionUnfocusInner
279  * @tc.type: FUNC
280  */
281 HWTEST_F(SceneSessionManagerTest9, RequestAllAppSessionUnfocusInner, Function | SmallTest | Level3)
282 {
283     ASSERT_NE(nullptr, ssm_);
284     ssm_->RequestAllAppSessionUnfocusInner();
285 
286     SessionInfo sessionInfo;
287     sessionInfo.bundleName_ = "SceneSessionManagerTest9";
288     sessionInfo.abilityName_ = "RequestAllAppSessionUnfocusInner";
289     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
290     ASSERT_NE(nullptr, sceneSession);
291     sceneSession->GetSessionProperty()->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
292     ssm_->focusedSessionId_ = 1;
293     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
294     ssm_->RequestAllAppSessionUnfocusInner();
295 
296     sceneSession->GetSessionProperty()->SetWindowType(WindowType::WINDOW_TYPE_SYSTEM_FLOAT);
297     ssm_->RequestAllAppSessionUnfocusInner();
298 }
299 
300 /**
301  * @tc.name: UpdateFocus04
302  * @tc.desc: UpdateFocus
303  * @tc.type: FUNC
304  */
305 HWTEST_F(SceneSessionManagerTest9, UpdateFocus04, Function | SmallTest | Level3)
306 {
307     ASSERT_NE(nullptr, ssm_);
308     SessionInfo sessionInfo;
309     sessionInfo.bundleName_ = "SceneSessionManagerTest9";
310     sessionInfo.abilityName_ = "UpdateFocus04";
311     sessionInfo.isSystem_ = true;
312     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
313     ASSERT_NE(nullptr, sceneSession);
314     sceneSession->GetSessionProperty()->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
315     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
316     ssm_->focusedSessionId_ = 0;
317     sceneSession->UpdateFocus(false);
318     ssm_->UpdateFocus(1, false);
319 
320     ssm_->listenerController_ = nullptr;
321     ssm_->UpdateFocus(1, true);
322 
323     std::shared_ptr<SessionListenerController> listenerController = std::make_shared<SessionListenerController>();
324     ssm_->listenerController_ = listenerController;
325     ssm_->UpdateFocus(1, true);
326 
327     sessionInfo.isSystem_ = false;
328     ssm_->focusedSessionId_ = 1;
329     sceneSession->UpdateFocus(true);
330     ssm_->UpdateFocus(1, false);
331 
332     sceneSession->UpdateFocus(false);
333     ssm_->UpdateFocus(1, true);
334 }
335 
336 /**
337  * @tc.name: ProcessFocusWhenForeground
338  * @tc.desc: ProcessFocusWhenForeground
339  * @tc.type: FUNC
340  */
341 HWTEST_F(SceneSessionManagerTest9, ProcessFocusWhenForeground, Function | SmallTest | Level3)
342 {
343     ASSERT_NE(nullptr, ssm_);
344     SessionInfo sessionInfo;
345     sessionInfo.bundleName_ = "SceneSessionManagerTest9";
346     sessionInfo.abilityName_ = "ProcessFocusWhenForeground";
347     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
348     ASSERT_NE(nullptr, sceneSession);
349     sceneSession->persistentId_ = 1;
350     ASSERT_NE(nullptr, sceneSession->property_);
351     sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
352     ssm_->focusedSessionId_ = 1;
353     ssm_->needBlockNotifyFocusStatusUntilForeground_ = false;
354     ssm_->ProcessFocusWhenForeground(sceneSession);
355 
356     sceneSession->isVisible_ = true;
357     sceneSession->SetSessionState(SessionState::STATE_FOREGROUND);
358     ssm_->ProcessFocusWhenForeground(sceneSession);
359 }
360 
361 /**
362  * @tc.name: ProcessSubSessionForeground03
363  * @tc.desc: ProcessSubSessionForeground
364  * @tc.type: FUNC
365  */
366 HWTEST_F(SceneSessionManagerTest9, ProcessSubSessionForeground03, Function | SmallTest | Level3)
367 {
368     ASSERT_NE(nullptr, ssm_);
369     SessionInfo sessionInfo;
370     sessionInfo.bundleName_ = "SceneSessionManagerTest9";
371     sessionInfo.abilityName_ = "ProcessSubSessionForeground03";
372     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
373     ASSERT_NE(nullptr, sceneSession);
374 
375     SessionInfo subSessionInfo;
376     sptr<SceneSession> subSceneSession = sptr<SceneSession>::MakeSptr(subSessionInfo, nullptr);
377     ASSERT_NE(nullptr, subSceneSession);
378     subSceneSession->SetTopmost(true);
379     subSceneSession->SetSessionState(SessionState::STATE_FOREGROUND);
380     subSceneSession->persistentId_ = 1;
381     sceneSession->GetSubSession().push_back(subSceneSession);
382     ssm_->sceneSessionMap_.insert(std::make_pair(1, subSceneSession));
383 
384     ssm_->focusedSessionId_ = 1;
385     ssm_->needBlockNotifyFocusStatusUntilForeground_ = true;
386 
387     SessionInfo subSessionInfo1;
388     sptr<SceneSession> subSceneSession1 = sptr<SceneSession>::MakeSptr(subSessionInfo1, nullptr);
389     ASSERT_NE(nullptr, subSceneSession1);
390     subSceneSession1->SetTopmost(true);
391     subSceneSession1->SetSessionState(SessionState::STATE_ACTIVE);
392     subSceneSession1->persistentId_ = 0;
393     sceneSession->GetSubSession().push_back(subSceneSession1);
394 
395     SessionInfo subSessionInfo2;
396     sptr<SceneSession> subSceneSession2 = sptr<SceneSession>::MakeSptr(subSessionInfo2, nullptr);
397     ASSERT_NE(nullptr, subSceneSession2);
398     subSceneSession2->SetTopmost(true);
399     subSceneSession2->SetSessionState(SessionState::STATE_CONNECT);
400     sceneSession->GetSubSession().push_back(subSceneSession2);
401 
402     SessionInfo subSessionInfo3;
403     sptr<SceneSession> subSceneSession3 = sptr<SceneSession>::MakeSptr(subSessionInfo3, nullptr);
404     ASSERT_NE(nullptr, subSceneSession3);
405     subSceneSession3->SetTopmost(false);
406     subSceneSession3->SetSessionState(SessionState::STATE_ACTIVE);
407     sceneSession->GetSubSession().push_back(subSceneSession3);
408 
409     sceneSession->GetSubSession().push_back(nullptr);
410 
411     ssm_->ProcessSubSessionForeground(sceneSession);
412 
413     ssm_->needBlockNotifyFocusStatusUntilForeground_ = false;
414     ssm_->ProcessSubSessionForeground(sceneSession);
415 
416     ssm_->focusedSessionId_ = 2;
417     ssm_->ProcessSubSessionForeground(sceneSession);
418 }
419 
420 /**
421  * @tc.name: ProcessModalTopmostRequestFocusImmdediately02
422  * @tc.desc: ProcessModalTopmostRequestFocusImmdediately
423  * @tc.type: FUNC
424  */
425 HWTEST_F(SceneSessionManagerTest9, ProcessModalTopmostRequestFocusImmdediately02, Function | SmallTest | Level3)
426 {
427     ASSERT_NE(nullptr, ssm_);
428     SessionInfo sessionInfo;
429     sessionInfo.bundleName_ = "SceneSessionManagerTest9";
430     sessionInfo.abilityName_ = "ProcessModalTopmostRequestFocusImmdediately02";
431     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
432     ASSERT_NE(nullptr, sceneSession);
433 
434     SessionInfo subSessionInfo;
435     sptr<SceneSession> subSceneSession = sptr<SceneSession>::MakeSptr(subSessionInfo, nullptr);
436     ASSERT_NE(nullptr, subSceneSession);
437     subSceneSession->SetTopmost(true);
438     subSceneSession->SetSessionState(SessionState::STATE_FOREGROUND);
439     subSceneSession->persistentId_ = 1;
440     subSceneSession->SetFocusable(true);
441     subSceneSession->SetFocusedOnShow(true);
442     sceneSession->GetSubSession().push_back(subSceneSession);
443 
444     ssm_->sceneSessionMap_.insert(std::make_pair(1, subSceneSession));
445     ssm_->focusedSessionId_ = 1;
446     ssm_->needBlockNotifyFocusStatusUntilForeground_ = true;
447 
448     SessionInfo subSessionInfo1;
449     sptr<SceneSession> subSceneSession1 = sptr<SceneSession>::MakeSptr(subSessionInfo1, nullptr);
450     ASSERT_NE(nullptr, subSceneSession1);
451     subSceneSession1->SetTopmost(true);
452     subSceneSession1->SetSessionState(SessionState::STATE_ACTIVE);
453     subSceneSession1->persistentId_ = 0;
454     sceneSession->GetSubSession().push_back(subSceneSession1);
455 
456     SessionInfo subSessionInfo2;
457     sptr<SceneSession> subSceneSession2 = sptr<SceneSession>::MakeSptr(subSessionInfo2, nullptr);
458     ASSERT_NE(nullptr, subSceneSession2);
459     subSceneSession2->SetTopmost(true);
460     subSceneSession2->SetSessionState(SessionState::STATE_CONNECT);
461     sceneSession->GetSubSession().push_back(subSceneSession2);
462 
463     SessionInfo subSessionInfo3;
464     sptr<SceneSession> subSceneSession3 = sptr<SceneSession>::MakeSptr(subSessionInfo3, nullptr);
465     ASSERT_NE(nullptr, subSceneSession3);
466     subSceneSession3->SetTopmost(false);
467     subSceneSession3->SetSessionState(SessionState::STATE_ACTIVE);
468     sceneSession->GetSubSession().push_back(subSceneSession3);
469 
470     sceneSession->GetSubSession().push_back(nullptr);
471 
472     ssm_->ProcessModalTopmostRequestFocusImmdediately(sceneSession);
473 
474     ssm_->needBlockNotifyFocusStatusUntilForeground_ = false;
475     ssm_->ProcessSubSessionForeground(sceneSession);
476 
477     subSceneSession->persistentId_ = 0;
478     ssm_->ProcessModalTopmostRequestFocusImmdediately(sceneSession);
479 }
480 
481 /**
482  * @tc.name: ProcessDialogRequestFocusImmdediately02
483  * @tc.desc: ProcessDialogRequestFocusImmdediately
484  * @tc.type: FUNC
485  */
486 HWTEST_F(SceneSessionManagerTest9, ProcessDialogRequestFocusImmdediately02, Function | SmallTest | Level3)
487 {
488     ASSERT_NE(nullptr, ssm_);
489     SessionInfo sessionInfo;
490     sessionInfo.bundleName_ = "SceneSessionManagerTest9";
491     sessionInfo.abilityName_ = "ProcessDialogRequestFocusImmdediately02";
492     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
493     ASSERT_NE(nullptr, sceneSession);
494     sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
495 
496     SessionInfo dialogSessionInfo;
497     sptr<SceneSession> dialogSceneSession = sptr<SceneSession>::MakeSptr(dialogSessionInfo, nullptr);
498     ASSERT_NE(nullptr, dialogSceneSession);
499     dialogSceneSession->SetTopmost(true);
500     dialogSceneSession->SetSessionState(SessionState::STATE_FOREGROUND);
501     dialogSceneSession->persistentId_ = 1;
502     dialogSceneSession->SetFocusable(true);
503     dialogSceneSession->SetFocusedOnShow(true);
504     sceneSession->GetDialogVector().push_back(dialogSceneSession);
505 
506     ssm_->sceneSessionMap_.insert(std::make_pair(1, dialogSceneSession));
507     ssm_->focusedSessionId_ = 1;
508     ssm_->needBlockNotifyFocusStatusUntilForeground_ = true;
509 
510     SessionInfo dialogSessionInfo1;
511     sptr<SceneSession> dialogSceneSession1 = sptr<SceneSession>::MakeSptr(dialogSessionInfo1, nullptr);
512     ASSERT_NE(nullptr, dialogSceneSession1);
513     dialogSceneSession1->SetTopmost(true);
514     dialogSceneSession1->SetSessionState(SessionState::STATE_ACTIVE);
515     dialogSceneSession1->persistentId_ = 0;
516     sceneSession->GetDialogVector().push_back(dialogSceneSession1);
517 
518     SessionInfo dialogSessionInfo2;
519     sptr<SceneSession> dialogSceneSession2 = sptr<SceneSession>::MakeSptr(dialogSessionInfo2, nullptr);
520     ASSERT_NE(nullptr, dialogSceneSession2);
521     dialogSceneSession2->SetTopmost(true);
522     dialogSceneSession2->SetSessionState(SessionState::STATE_CONNECT);
523     sceneSession->GetDialogVector().push_back(dialogSceneSession2);
524 
525     sceneSession->GetDialogVector().push_back(nullptr);
526 
527     ssm_->ProcessDialogRequestFocusImmdediately(sceneSession);
528 
529     dialogSceneSession->persistentId_ = 0;
530     ssm_->ProcessDialogRequestFocusImmdediately(sceneSession);
531 }
532 
533 /**
534  * @tc.name: NotifyCompleteFirstFrameDrawing03
535  * @tc.desc: NotifyCompleteFirstFrameDrawing
536  * @tc.type: FUNC
537  */
538 HWTEST_F(SceneSessionManagerTest9, NotifyCompleteFirstFrameDrawing03, Function | SmallTest | Level3)
539 {
540     ASSERT_NE(nullptr, ssm_);
541     SessionInfo sessionInfo;
542     sessionInfo.bundleName_ = "SceneSessionManagerTest9";
543     sessionInfo.abilityName_ = "NotifyCompleteFirstFrameDrawing03";
544     std::shared_ptr<AppExecFwk::AbilityInfo> abilityInfo = std::make_shared<AppExecFwk::AbilityInfo>();
545     abilityInfo->excludeFromMissions = true;
546     sessionInfo.abilityInfo = abilityInfo;
547     sessionInfo.isSystem_ = true;
548     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
549     ASSERT_NE(nullptr, sceneSession);
550     sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
551     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
552     ssm_->listenerController_ = nullptr;
553     ssm_->NotifyCompleteFirstFrameDrawing(1);
554 
555     std::shared_ptr<SessionListenerController> listenerController = std::make_shared<SessionListenerController>();
556     ssm_->listenerController_ = listenerController;
557     sessionInfo.isSystem_ = false;
558     ssm_->eventHandler_ = nullptr;
559     ssm_->NotifyCompleteFirstFrameDrawing(1);
560 
561     std::shared_ptr<AppExecFwk::EventHandler> eventHandler = std::make_shared<AppExecFwk::EventHandler>();
562     ssm_->eventHandler_ = eventHandler;
563     abilityInfo->excludeFromMissions = false;
564     ssm_->NotifyCompleteFirstFrameDrawing(1);
565 }
566 
567 /**
568  * @tc.name: SetSessionLabel02
569  * @tc.desc: SetSessionLabel
570  * @tc.type: FUNC
571  */
572 HWTEST_F(SceneSessionManagerTest9, SetSessionLabel02, Function | SmallTest | Level3)
573 {
574     ASSERT_NE(nullptr, ssm_);
575     SessionInfo sessionInfo;
576     sessionInfo.bundleName_ = "SceneSessionManagerTest9";
577     sessionInfo.abilityName_ = "SetSessionLabel02";
578     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
579     ASSERT_NE(nullptr, sceneSession);
580     sptr<IRemoteObject> token = new (std::nothrow) MockIRemoteObject();
581     ASSERT_NE(nullptr, token);
582     sceneSession->SetAbilityToken(token);
583     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
584     ssm_->listenerController_ = nullptr;
585 
586     std::string label = "testLabel";
587     ssm_->SetSessionLabel(token, label);
588 
589     std::shared_ptr<SessionListenerController> listenerController = std::make_shared<SessionListenerController>();
590     ssm_->listenerController_ = listenerController;
591     sessionInfo.isSystem_ = false;
592     ssm_->SetSessionLabel(token, label);
593 
594     sessionInfo.isSystem_ = true;
595     ssm_->SetSessionLabel(token, label);
596 }
597 
598 /**
599  * @tc.name: RecoverAndReconnectSceneSession02
600  * @tc.desc: RecoverAndReconnectSceneSession
601  * @tc.type: FUNC
602  */
603 HWTEST_F(SceneSessionManagerTest9, RecoverAndReconnectSceneSession02, Function | SmallTest | Level3)
604 {
605     ASSERT_NE(nullptr, ssm_);
606     SessionInfo sessionInfo;
607     sessionInfo.bundleName_ = "SceneSessionManagerTest9";
608     sessionInfo.abilityName_ = "RecoverAndReconnectSceneSession02";
609     sessionInfo.moduleName_ = "moduleTest";
610     sessionInfo.appIndex_ = 10;
611     sessionInfo.persistentId_ = 1;
612     std::shared_ptr<AppExecFwk::AbilityInfo> abilityInfo = std::make_shared<AppExecFwk::AbilityInfo>();
613     abilityInfo->excludeFromMissions = true;
614     sessionInfo.abilityInfo = abilityInfo;
615     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
616     ASSERT_NE(nullptr, sceneSession);
617 
618     sptr<WindowSessionProperty> property = sceneSession->GetSessionProperty();
619     property->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
620     property->SetPersistentId(1);
621     property->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
622     property->SetWindowState(WindowState::STATE_SHOWN);
623     property->SetRequestedOrientation(Orientation::UNSPECIFIED);
624     ssm_->alivePersistentIds_.push_back(1);
625     ssm_->recoveringFinished_ = false;
626     ssm_->recoverSceneSessionFunc_ = NotifyRecoverSceneSessionFuncTest;
627 
628     sptr<ISession> session;
629     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
630     ssm_->RecoverAndReconnectSceneSession(nullptr, nullptr, nullptr, session, property, nullptr);
631 
632     property->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
633     property->SetPersistentId(0);
634     ssm_->RecoverAndReconnectSceneSession(nullptr, nullptr, nullptr, session, property, nullptr);
635 }
636 
637 /**
638  * @tc.name: GetSessionRSVisible
639  * @tc.desc: GetSessionRSVisible
640  * @tc.type: FUNC
641  */
642 HWTEST_F(SceneSessionManagerTest9, GetSessionRSVisible, Function | SmallTest | Level3)
643 {
644     ASSERT_NE(nullptr, ssm_);
645     SessionInfo sessionInfo;
646     sessionInfo.bundleName_ = "SceneSessionManagerTest9";
647     sessionInfo.abilityName_ = "GetSessionRSVisible";
648     sessionInfo.moduleName_ = "moduleTest";
649     uint64_t windowId = 10;
650     sptr<SceneSession> sceneSession01 = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
651     sceneSession01->persistentId_ = windowId;
652     sptr<SceneSession> sceneSession02 = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
653     std::vector<std::pair<uint64_t, WindowVisibilityState>> currVisibleData;
654     currVisibleData.push_back(std::make_pair(0, WindowVisibilityState::WINDOW_VISIBILITY_STATE_NO_OCCLUSION));
655     currVisibleData.push_back(std::make_pair(1, WindowVisibilityState::WINDOW_VISIBILITY_STATE_PARTICALLY_OCCLUSION));
656     struct RSSurfaceNodeConfig config;
657     sceneSession02->surfaceNode_ = RSSurfaceNode::Create(config);
658     ASSERT_NE(nullptr, sceneSession02->surfaceNode_);
659     sceneSession02->surfaceNode_->id_ = 0;
660     sceneSession02->persistentId_ = windowId;
661     ssm_->sceneSessionMap_.insert(std::make_pair(0, sceneSession02));
662 
663     bool actual = ssm_->GetSessionRSVisible(sceneSession01, currVisibleData);
664     EXPECT_EQ(actual, true);
665 }
666 }
667 } // namespace Rosen
668 } // namespace OHOS