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 #include "screen_session_manager/include/screen_session_manager_client.h"
25 
26 using namespace testing;
27 using namespace testing::ext;
28 
29 namespace OHOS {
30 namespace Rosen {
31 
32 class SceneSessionManagerTest10 : public testing::Test {
33 public:
34     static void SetUpTestCase();
35     static void TearDownTestCase();
36     void SetUp() override;
37     void TearDown() override;
38     void InitTestSceneSession(DisplayId displayId, int32_t windowId, int32_t zOrder, bool visible, WSRect rect);
39 
40     static sptr<SceneSessionManager> ssm_;
41 private:
42     static constexpr uint32_t WAIT_SYNC_IN_NS = 200000;
43 };
44 
45 sptr<SceneSessionManager> SceneSessionManagerTest10::ssm_ = nullptr;
46 
NotifyRecoverSceneSessionFuncTest(const sptr<SceneSession> & session,const SessionInfo & sessionInfo)47 void NotifyRecoverSceneSessionFuncTest(const sptr<SceneSession>& session, const SessionInfo& sessionInfo)
48 {
49 }
50 
TraverseFuncTest(const sptr<SceneSession> & session)51 bool TraverseFuncTest(const sptr<SceneSession>& session)
52 {
53     return true;
54 }
55 
WindowChangedFuncTest(int32_t persistentId,WindowUpdateType type)56 void WindowChangedFuncTest(int32_t persistentId, WindowUpdateType type)
57 {
58 }
59 
ProcessStatusBarEnabledChangeFuncTest(bool enable)60 void ProcessStatusBarEnabledChangeFuncTest(bool enable)
61 {
62 }
63 
DumpRootSceneElementInfoFuncTest(const std::vector<std::string> & params,std::vector<std::string> & infos)64 void DumpRootSceneElementInfoFuncTest(const std::vector<std::string>& params, std::vector<std::string>& infos)
65 {
66 }
67 
SetUpTestCase()68 void SceneSessionManagerTest10::SetUpTestCase()
69 {
70     ssm_ = &SceneSessionManager::GetInstance();
71 }
72 
TearDownTestCase()73 void SceneSessionManagerTest10::TearDownTestCase()
74 {
75     ssm_ = nullptr;
76 }
77 
SetUp()78 void SceneSessionManagerTest10::SetUp()
79 {
80 }
81 
TearDown()82 void SceneSessionManagerTest10::TearDown()
83 {
84     usleep(WAIT_SYNC_IN_NS);
85 }
86 
InitTestSceneSession(DisplayId displayId,int32_t windowId,int32_t zOrder,bool visible,WSRect rect)87 void SceneSessionManagerTest10::InitTestSceneSession(DisplayId displayId,
88     int32_t windowId, int32_t zOrder, bool visible, WSRect rect)
89 {
90     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
91     property->SetDisplayId(displayId);
92     SessionInfo info;
93     info.bundleName_ = "root";
94     info.persistentId_ = windowId;
95     sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(info, nullptr);
96     ASSERT_NE(nullptr, sceneSession);
97     sceneSession->SetZOrder(zOrder);
98     sceneSession->SetRSVisible(visible);
99     sceneSession->SetSessionRect(rect);
100     sceneSession->SetSessionProperty(property);
101     ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
102     EXPECT_EQ(windowId, sceneSession->GetPersistentId());
103 }
104 
105 namespace {
106 /**
107  * @tc.name: RequestSceneSessionDestructionInner
108  * @tc.desc: RequestSceneSessionDestructionInner
109  * @tc.type: FUNC
110  */
111 HWTEST_F(SceneSessionManagerTest10, RequestSceneSessionDestructionInner, Function | SmallTest | Level3)
112 {
113     ASSERT_NE(ssm_, nullptr);
114 
115     SessionInfo info;
116     sptr<SceneSession::SpecificSessionCallback> specificCallback = nullptr;
117     sptr<SceneSession> scnSession = new (std::nothrow) SceneSession(info, specificCallback);
118     sptr<AAFwk::SessionInfo> scnSessionInfo = new AAFwk::SessionInfo();
119     bool needRemoveSession = true;
120     bool isForceClean = true;
121 
122     SessionInfo sessionInfo;
123     sessionInfo.collaboratorType_ = CollaboratorType::RESERVE_TYPE;
124     ssm_->RequestSceneSessionDestructionInner(scnSession, scnSessionInfo, needRemoveSession, isForceClean);
125 
126     needRemoveSession = false;
127     isForceClean = false;
128     sessionInfo.collaboratorType_ = CollaboratorType::DEFAULT_TYPE;
129     sessionInfo.want = std::make_shared<AAFwk::Want>();
130     ssm_->listenerController_ = std::make_shared<SessionListenerController>();
131     ssm_->RequestSceneSessionDestructionInner(scnSession, scnSessionInfo, needRemoveSession, isForceClean);
132 }
133 
134 /**
135  * @tc.name: RegisterWindowManagerAgent
136  * @tc.desc: RegisterWindowManagerAgent
137  * @tc.type: FUNC
138  */
139 HWTEST_F(SceneSessionManagerTest10, RegisterWindowManagerAgent01, Function | SmallTest | Level3)
140 {
141     WindowManagerAgentType type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_SYSTEM_BAR;
142     sptr<IWindowManagerAgent> windowManagerAgent;
143     ssm_->RegisterWindowManagerAgent(type, windowManagerAgent);
144 
145     type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_GESTURE_NAVIGATION_ENABLED;
146     ssm_->RegisterWindowManagerAgent(type, windowManagerAgent);
147 
148     type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WATER_MARK_FLAG;
149     ssm_->RegisterWindowManagerAgent(type, windowManagerAgent);
150 
151     type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WINDOW_UPDATE;
152     ssm_->RegisterWindowManagerAgent(type, windowManagerAgent);
153 
154     type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WINDOW_VISIBILITY;
155     ssm_->RegisterWindowManagerAgent(type, windowManagerAgent);
156 
157     type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WINDOW_DRAWING_STATE;
158     ssm_->RegisterWindowManagerAgent(type, windowManagerAgent);
159 
160     type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_VISIBLE_WINDOW_NUM;
161     ssm_->RegisterWindowManagerAgent(type, windowManagerAgent);
162 
163     type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_FOCUS;
164     ssm_->RegisterWindowManagerAgent(type, windowManagerAgent);
165 
166     type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WINDOW_MODE;
167     ssm_->RegisterWindowManagerAgent(type, windowManagerAgent);
168 
169     type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_CAMERA_FLOAT;
170     ASSERT_EQ(windowManagerAgent, nullptr);
171     ssm_->RegisterWindowManagerAgent(type, windowManagerAgent);
172 }
173 
174 /**
175  * @tc.name: UpdateRotateAnimationConfig
176  * @tc.desc: UpdateRotateAnimationConfig
177  * @tc.type: FUNC
178  */
179 HWTEST_F(SceneSessionManagerTest10, UpdateRotateAnimationConfig, Function | SmallTest | Level3)
180 {
181     ASSERT_NE(ssm_, nullptr);
182     RotateAnimationConfig config = { 400 };
183     ssm_->UpdateRotateAnimationConfig(config);
184     usleep(WAIT_SYNC_IN_NS);
185     ASSERT_EQ(ssm_->rotateAnimationConfig_.duration_, 400);
186 
187     config.duration_ = 600;
188     ssm_->UpdateRotateAnimationConfig(config);
189     usleep(WAIT_SYNC_IN_NS);
190     ASSERT_EQ(ssm_->rotateAnimationConfig_.duration_, 600);
191 }
192 
193 /**
194  * @tc.name: RegisterAcquireRotateAnimationConfigFunc
195  * @tc.desc: RegisterAcquireRotateAnimationConfigFunc
196  * @tc.type: FUNC
197  */
198 HWTEST_F(SceneSessionManagerTest10, RegisterAcquireRotateAnimationConfigFunc, Function | SmallTest | Level3)
199 {
200     ASSERT_NE(ssm_, nullptr);
201     SessionInfo sessionInfo;
202     sessionInfo.bundleName_ = "bundleName";
203     sessionInfo.persistentId_ = 1;
204     sessionInfo.isSystem_ = false;
205     sessionInfo.abilityInfo = std::make_shared<AppExecFwk::AbilityInfo>();
206     ASSERT_NE(sessionInfo.abilityInfo, nullptr);
207     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
208     ASSERT_NE(sceneSession, nullptr);
209     sceneSession->scenePersistence_ = sptr<ScenePersistence>::MakeSptr("bundleName", 1);
210     ASSERT_NE(sceneSession->scenePersistence_, nullptr);
211     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
212     ssm_->RegisterAcquireRotateAnimationConfigFunc(sceneSession);
213     WSRect rect({1, 1, 1, 1});
214     SizeChangeReason reason = SizeChangeReason::ROTATION;
215     WSError result = sceneSession->UpdateRect(rect, reason, "SceneSessionManagerTest10");
216     ASSERT_EQ(result, WSError::WS_OK);
217 }
218 
219 /**
220  * @tc.name: CheckLastFocusedAppSessionFocus
221  * @tc.desc: CheckLastFocusedAppSessionFocus
222  * @tc.type: FUNC
223  */
224 HWTEST_F(SceneSessionManagerTest10, CheckLastFocusedAppSessionFocus, Function | SmallTest | Level3)
225 {
226     ASSERT_NE(ssm_, nullptr);
227 
228     SessionInfo info1;
229     info1.abilityName_ = "focusedSession";
230     info1.bundleName_ = "focusedSession";
231     info1.windowType_ = 1;
232     sptr<SceneSession> focusedSession = new (std::nothrow) SceneSession(info1, nullptr);
233     ASSERT_NE(focusedSession, nullptr);
234 
235     SessionInfo info2;
236     info2.abilityName_ = "nextSession";
237     info2.bundleName_ = "nextSession";
238     info2.windowType_ = 1;
239     sptr<SceneSession> nextSession = new (std::nothrow) SceneSession(info2, nullptr);
240     ASSERT_NE(nextSession, nullptr);
241 
242     ssm_->lastFocusedAppSessionId_ = nextSession->GetPersistentId();
243     ASSERT_EQ(false, ssm_->CheckLastFocusedAppSessionFocus(focusedSession, nextSession));
244 
245     ssm_->lastFocusedAppSessionId_ = 124;
246     focusedSession->property_->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
247     ASSERT_EQ(false, ssm_->CheckLastFocusedAppSessionFocus(focusedSession, nextSession));
248 
249     nextSession->property_->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_PRIMARY);
250     ssm_->CheckLastFocusedAppSessionFocus(focusedSession, nextSession);
251     ASSERT_EQ(0, ssm_->lastFocusedAppSessionId_);
252 }
253 
254 /**
255  * @tc.name: GetWindowIdsByCoordinate01
256  * @tc.desc: GetWindowIdsByCoordinate, displayId invalid
257  * @tc.type: FUNC
258  */
259 HWTEST_F(SceneSessionManagerTest10, GetWindowIdsByCoordinate01, Function | SmallTest | Level3)
260 {
261     std::vector<int32_t> windowIds;
262     WMError result = ssm_->GetWindowIdsByCoordinate(DISPLAY_ID_INVALID, 0, 0, 0, windowIds);
263     EXPECT_EQ(result, WMError::WM_ERROR_INVALID_PARAM);
264 }
265 
266 /**
267  * @tc.name: GetWindowIdsByCoordinate02
268  * @tc.desc: GetWindowIdsByCoordinate, windowNumber 0, x y invalid
269  * @tc.type: FUNC
270  */
271 HWTEST_F(SceneSessionManagerTest10, GetWindowIdsByCoordinate02, Function | SmallTest | Level3)
272 {
273     ssm_->sceneSessionMap_.clear();
274     InitTestSceneSession(1, 101, 11, true, {100, 100, 200, 200});
275     ssm_->sceneSessionMap_.insert({102, nullptr});
276     InitTestSceneSession(1, 103, 14, true, {120, 120, 220, 220});
277     InitTestSceneSession(1, 104, 12, true, {100, 100, 200, 200});
278     auto it1 = ssm_->sceneSessionMap_.find(104);
279     if (it1 != ssm_->sceneSessionMap_.end()) {
280         it1->second->SetSessionProperty(nullptr);
281     }
282     InitTestSceneSession(1, 105, 12, true, {100, 100, 200, 200});
283     auto it2 = ssm_->sceneSessionMap_.find(105);
284     if (it2 != ssm_->sceneSessionMap_.end()) {
285         it2->second->sessionInfo_.bundleName_ = "other";
286     }
287     InitTestSceneSession(1, 106, 15, true, {140, 140, 240, 240});
288     InitTestSceneSession(2, 107, 15, true, {150, 150, 250, 250});
289     InitTestSceneSession(1, 108, 13, false, {150, 150, 250, 250});
290     InitTestSceneSession(1, 109, 13, true, {160, 160, 260, 260});
291     InitTestSceneSession(1, 110, 12, true, {500, 500, 600, 600});
292 
293     std::vector<int32_t> windowIds;
294     WMError result = ssm_->GetWindowIdsByCoordinate(1, 0, -1, -1, windowIds);
295     EXPECT_EQ(result, WMError::WM_OK);
296     EXPECT_EQ(5, windowIds.size());
297     EXPECT_EQ(106, windowIds[0]);
298     EXPECT_EQ(103, windowIds[1]);
299     EXPECT_EQ(109, windowIds[2]);
300     EXPECT_EQ(110, windowIds[3]);
301     EXPECT_EQ(101, windowIds[4]);
302     ssm_->sceneSessionMap_.clear();
303 }
304 
305 /**
306  * @tc.name: GetWindowIdsByCoordinate03
307  * @tc.desc: GetWindowIdsByCoordinate, windowNumber 3, x y invalid
308  * @tc.type: FUNC
309  */
310 HWTEST_F(SceneSessionManagerTest10, GetWindowIdsByCoordinate03, Function | SmallTest | Level3)
311 {
312     ssm_->sceneSessionMap_.clear();
313     InitTestSceneSession(1, 111, 11, true, {100, 100, 200, 200});
314     ssm_->sceneSessionMap_.insert({102, nullptr});
315     InitTestSceneSession(1, 113, 14, true, {120, 120, 220, 220});
316     InitTestSceneSession(1, 114, 12, true, {100, 100, 200, 200});
317     auto it1 = ssm_->sceneSessionMap_.find(114);
318     if (it1 != ssm_->sceneSessionMap_.end()) {
319         it1->second->SetSessionProperty(nullptr);
320     }
321     InitTestSceneSession(1, 115, 12, true, {100, 100, 200, 200});
322     auto it2 = ssm_->sceneSessionMap_.find(115);
323     if (it2 != ssm_->sceneSessionMap_.end()) {
324         it2->second->sessionInfo_.bundleName_ = "other";
325     }
326     InitTestSceneSession(1, 116, 15, true, {140, 140, 240, 240});
327     InitTestSceneSession(2, 117, 15, true, {150, 150, 250, 250});
328     InitTestSceneSession(1, 118, 13, false, {150, 150, 250, 250});
329     InitTestSceneSession(1, 119, 13, true, {160, 160, 260, 260});
330     InitTestSceneSession(1, 120, 12, true, {500, 500, 600, 600});
331 
332     std::vector<int32_t> windowIds;
333     WMError result = ssm_->GetWindowIdsByCoordinate(1, 3, -1, -1, windowIds);
334     EXPECT_EQ(result, WMError::WM_OK);
335     EXPECT_EQ(3, windowIds.size());
336     EXPECT_EQ(116, windowIds[0]);
337     EXPECT_EQ(113, windowIds[1]);
338     EXPECT_EQ(119, windowIds[2]);
339     ssm_->sceneSessionMap_.clear();
340 }
341 
342 /**
343  * @tc.name: GetWindowIdsByCoordinate04
344  * @tc.desc: GetWindowIdsByCoordinate, windowNumber 0, x y effictive value
345  * @tc.type: FUNC
346  */
347 HWTEST_F(SceneSessionManagerTest10, GetWindowIdsByCoordinate04, Function | SmallTest | Level3)
348 {
349     ssm_->sceneSessionMap_.clear();
350     InitTestSceneSession(1, 121, 11, true, {100, 100, 200, 200});
351     ssm_->sceneSessionMap_.insert({102, nullptr});
352     InitTestSceneSession(1, 123, 14, true, {120, 120, 220, 220});
353     InitTestSceneSession(1, 124, 12, true, {100, 100, 200, 200});
354     auto it1 = ssm_->sceneSessionMap_.find(124);
355     if (it1 != ssm_->sceneSessionMap_.end()) {
356         it1->second->SetSessionProperty(nullptr);
357     }
358     InitTestSceneSession(1, 125, 12, true, {100, 100, 200, 200});
359     auto it2 = ssm_->sceneSessionMap_.find(125);
360     if (it2 != ssm_->sceneSessionMap_.end()) {
361         it2->second->sessionInfo_.bundleName_ = "other";
362     }
363     InitTestSceneSession(1, 126, 15, true, {140, 140, 240, 240});
364     InitTestSceneSession(2, 127, 15, true, {150, 150, 250, 250});
365     InitTestSceneSession(1, 128, 13, false, {150, 150, 250, 250});
366     InitTestSceneSession(1, 129, 13, true, {160, 160, 260, 260});
367     InitTestSceneSession(1, 130, 12, true, {500, 500, 600, 600});
368 
369     std::vector<int32_t> windowIds;
370     WMError result = ssm_->GetWindowIdsByCoordinate(1, 0, 180, 180, windowIds);
371     EXPECT_EQ(result, WMError::WM_OK);
372     EXPECT_EQ(4, windowIds.size());
373     EXPECT_EQ(126, windowIds[0]);
374     EXPECT_EQ(123, windowIds[1]);
375     EXPECT_EQ(129, windowIds[2]);
376     EXPECT_EQ(121, windowIds[3]);
377     ssm_->sceneSessionMap_.clear();
378 }
379 
380 /**
381  * @tc.name: GetWindowIdsByCoordinate05
382  * @tc.desc: GetWindowIdsByCoordinate, windowNumber 3, x y effictive value
383  * @tc.type: FUNC
384  */
385 HWTEST_F(SceneSessionManagerTest10, GetWindowIdsByCoordinate05, Function | SmallTest | Level3)
386 {
387     ssm_->sceneSessionMap_.clear();
388     InitTestSceneSession(1, 131, 11, true, {100, 100, 200, 200});
389     ssm_->sceneSessionMap_.insert({102, nullptr});
390     InitTestSceneSession(1, 133, 14, true, {120, 120, 220, 220});
391     InitTestSceneSession(1, 134, 12, true, {100, 100, 200, 200});
392     auto it1 = ssm_->sceneSessionMap_.find(134);
393     if (it1 != ssm_->sceneSessionMap_.end()) {
394         it1->second->SetSessionProperty(nullptr);
395     }
396     InitTestSceneSession(1, 135, 12, true, {100, 100, 200, 200});
397     auto it2 = ssm_->sceneSessionMap_.find(135);
398     if (it2 != ssm_->sceneSessionMap_.end()) {
399         it2->second->sessionInfo_.bundleName_ = "other";
400     }
401     InitTestSceneSession(1, 136, 15, true, {140, 140, 240, 240});
402     InitTestSceneSession(2, 137, 15, true, {150, 150, 250, 250});
403     InitTestSceneSession(1, 138, 13, false, {150, 150, 250, 250});
404     InitTestSceneSession(1, 139, 13, true, {160, 160, 260, 260});
405     InitTestSceneSession(1, 140, 12, true, {500, 500, 600, 600});
406 
407     std::vector<int32_t> windowIds;
408     WMError result = ssm_->GetWindowIdsByCoordinate(1, 3, 180, 180, windowIds);
409     EXPECT_EQ(result, WMError::WM_OK);
410     EXPECT_EQ(3, windowIds.size());
411     EXPECT_EQ(136, windowIds[0]);
412     EXPECT_EQ(133, windowIds[1]);
413     EXPECT_EQ(139, windowIds[2]);
414     ssm_->sceneSessionMap_.clear();
415 }
416 
417 /**
418  * @tc.name: ProcessFocusZOrderChange
419  * @tc.desc: ProcessFocusZOrderChange
420  * @tc.type: FUNC
421  */
422 HWTEST_F(SceneSessionManagerTest10, ProcessFocusZOrderChange, Function | SmallTest | Level3)
423 {
424     ssm_->sceneSessionMap_.clear();
425     ssm_->ProcessFocusZOrderChange(10);
426     ssm_->systemConfig_.uiType_ = "pc";
427     ssm_->ProcessFocusZOrderChange(97);
428 
429     ssm_->systemConfig_.uiType_ = "phone";
430     ssm_->ProcessFocusZOrderChange(97);
431 
432     SessionInfo sessionInfo;
433     sessionInfo.bundleName_ = "focusedSession";
434     sessionInfo.abilityName_ = "focusedSession";
435     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
436     ASSERT_NE(nullptr, sceneSession);
437     ssm_->sceneSessionMap_.emplace(1, sceneSession);
438     ssm_->focusedSessionId_ = 1;
439     ssm_->ProcessFocusZOrderChange(97);
440 
441     sceneSession->lastZOrder_ = 2203;
442     sceneSession->zOrder_ = 101;
443     ssm_->ProcessFocusZOrderChange(97);
444 
445     SessionInfo sessionInfo1;
446     sessionInfo1.bundleName_ = "voiceInteractionSession";
447     sessionInfo1.abilityName_ = "voiceInteractionSession";
448     sessionInfo1.windowType_ = static_cast<uint32_t>(WindowType::WINDOW_TYPE_VOICE_INTERACTION);
449     sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(sessionInfo1, nullptr);
450     ASSERT_NE(nullptr, sceneSession1);
451     sceneSession1->zOrder_ = 2109;
452     ssm_->sceneSessionMap_.emplace(2, sceneSession1);
453 
454     sceneSession->lastZOrder_ = 103;
455     sceneSession->zOrder_ = 101;
456     ssm_->ProcessFocusZOrderChange(97);
457 
458     sceneSession->lastZOrder_ = 2203;
459     sceneSession->zOrder_ = 101;
460     ssm_->ProcessFocusZOrderChange(97);
461 }
462 
463 /**
464  * @tc.name: NotifyVisibleChange
465  * @tc.desc: test NotifyVisibleChange
466  * @tc.type: FUNC
467  */
468 HWTEST_F(SceneSessionManagerTest10, NotifyVisibleChange, Function | SmallTest | Level3)
469 {
470     SessionInfo info;
471     info.abilityName_ = "test";
472     info.bundleName_ = "test";
473     sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
474     ASSERT_NE(nullptr, sceneSession);
475 
476     ASSERT_FALSE(ssm_->NotifyVisibleChange(sceneSession->GetPersistentId()));
477     ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
478     ASSERT_TRUE(ssm_->NotifyVisibleChange(sceneSession->GetPersistentId()));
479 
480     ssm_->sceneSessionMap_.erase(sceneSession->GetPersistentId());
481 }
482 
483 /**
484  * @tc.name: IsInSecondaryScreen
485  * @tc.desc: test IsInSecondaryScreen
486  * @tc.type: FUNC
487  */
488 HWTEST_F(SceneSessionManagerTest10, IsInSecondaryScreen, Function | SmallTest | Level3)
489 {
490     SessionInfo info;
491     info.abilityName_ = "test";
492     info.bundleName_ = "test";
493     sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
494     ASSERT_NE(nullptr, sceneSession);
495     sptr<WindowSessionProperty> property = new (std::nothrow) WindowSessionProperty();
496     ASSERT_NE(nullptr, property);
497     DisplayId displayId = ScreenSessionManagerClient::GetInstance().GetDefaultScreenId();
498     property->SetDisplayId(displayId);
499     sceneSession->SetSessionProperty(property);
500     ASSERT_EQ(ssm_->IsInSecondaryScreen(sceneSession), false);
501 
502     displayId = 5;
503     property->SetDisplayId(displayId);
504     sceneSession->SetSessionProperty(property);
505     ASSERT_EQ(ssm_->IsInSecondaryScreen(sceneSession), true);
506 }
507 
508 /**
509  * @tc.name: ProcessUpdateLastFocusedAppId
510  * @tc.desc: test ProcessUpdateLastFocusedAppId
511  * @tc.type: FUNC
512  */
513 HWTEST_F(SceneSessionManagerTest10, ProcessUpdateLastFocusedAppId, Function | SmallTest | Level1)
514 {
515     ssm_->sceneSessionMap_.clear();
516     std::vector<uint32_t> zOrderList;
517     ssm_->lastFocusedAppSessionId_ = INVALID_SESSION_ID;
518     ssm_->ProcessUpdateLastFocusedAppId(zOrderList);
519 
520     SessionInfo sessionInfo;
521     sessionInfo.bundleName_ = "lastFocusedAppSession";
522     sessionInfo.abilityName_ = "lastFocusedAppSession";
523     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
524     ssm_->sceneSessionMap_.emplace(1, sceneSession);
525     ssm_->lastFocusedAppSessionId_ = 1;
526     sceneSession->zOrder_ = 101;
527 
528     ssm_->ProcessUpdateLastFocusedAppId(zOrderList);
529     ASSERT_EQ(1, ssm_->lastFocusedAppSessionId_);
530 
531     zOrderList.push_back(103);
532     ssm_->ProcessUpdateLastFocusedAppId(zOrderList);
533     ASSERT_EQ(INVALID_SESSION_ID, ssm_->lastFocusedAppSessionId_);
534 }
535 
536 /**
537  * @tc.name: NotifyAppUseControlList
538  * @tc.desc: NotifyAppUseControlList
539  * @tc.type: FUNC
540  */
541 HWTEST_F(SceneSessionManagerTest10, NotifyAppUseControlList, Function | SmallTest | Level3)
542 {
543     ASSERT_NE(ssm_, nullptr);
544     std::vector<AppUseControlInfo> controlList;
545     controlList.emplace_back();
546     EXPECT_EQ(WSError::WS_ERROR_INVALID_PERMISSION,
547         ssm_->NotifyAppUseControlList(ControlAppType::APP_LOCK, -1, controlList));
548 
549     AppUseControlInfo appUseControlInfo;
550     appUseControlInfo.bundleName_ = "bundleName";
551     appUseControlInfo.appIndex_ = 1;
552     appUseControlInfo.isNeedControl_ = true;
553     EXPECT_EQ(WSError::WS_ERROR_INVALID_PERMISSION,
554         ssm_->NotifyAppUseControlList(ControlAppType::APP_LOCK, -1, controlList));
555 }
556 }  // namespace
557 }
558 }