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 <regex>
18 #include <bundle_mgr_interface.h>
19 #include <bundlemgr/launcher_service.h>
20 #include "interfaces/include/ws_common.h"
21 #include "screen_fold_data.h"
22 #include "session_manager/include/scene_session_manager.h"
23 #include "session_info.h"
24 #include "session/host/include/scene_session.h"
25 #include "session/host/include/main_session.h"
26 #include "window_manager_agent.h"
27 #include "session_manager.h"
28 #include "zidl/window_manager_agent_interface.h"
29 #include "mock/mock_session_stage.h"
30 #include "mock/mock_window_event_channel.h"
31 #include "application_info.h"
32 #include "context.h"
33 
34 using namespace testing;
35 using namespace testing::ext;
36 
37 namespace OHOS {
38 namespace Rosen {
39 namespace {
40 const std::string EMPTY_DEVICE_ID = "";
41 }
42 class SceneSessionManagerTest : public testing::Test {
43 public:
44     static void SetUpTestCase();
45     static void TearDownTestCase();
46     void SetUp() override;
47     void TearDown() override;
48     static void SetVisibleForAccessibility(sptr<SceneSession>& sceneSession);
49     int32_t GetTaskCount(sptr<SceneSession>& session);
50     static bool gestureNavigationEnabled_;
51     static ProcessGestureNavigationEnabledChangeFunc callbackFunc_;
52     static sptr<SceneSessionManager> ssm_;
53 private:
54     static constexpr uint32_t WAIT_SYNC_IN_NS = 200000;
55 };
56 
57 sptr<SceneSessionManager> SceneSessionManagerTest::ssm_ = nullptr;
58 
59 bool SceneSessionManagerTest::gestureNavigationEnabled_ = true;
60 ProcessGestureNavigationEnabledChangeFunc SceneSessionManagerTest::callbackFunc_ = [](bool enable,
__anon7624743c0202(bool enable, const std::string& bundleName, GestureBackType type) 61     const std::string& bundleName, GestureBackType type) {
62     gestureNavigationEnabled_ = enable;
63 };
64 
WindowChangedFuncTest(int32_t persistentId,WindowUpdateType type)65 void WindowChangedFuncTest(int32_t persistentId, WindowUpdateType type)
66 {
67 }
68 
ProcessStatusBarEnabledChangeFuncTest(bool enable)69 void ProcessStatusBarEnabledChangeFuncTest(bool enable)
70 {
71 }
72 
DumpRootSceneElementInfoFuncTest(const std::vector<std::string> & params,std::vector<std::string> & infos)73 void DumpRootSceneElementInfoFuncTest(const std::vector<std::string>& params, std::vector<std::string>& infos)
74 {
75 }
76 
SetUpTestCase()77 void SceneSessionManagerTest::SetUpTestCase()
78 {
79     ssm_ = &SceneSessionManager::GetInstance();
80 }
81 
TearDownTestCase()82 void SceneSessionManagerTest::TearDownTestCase()
83 {
84     ssm_ = nullptr;
85 }
86 
SetUp()87 void SceneSessionManagerTest::SetUp()
88 {
89     ssm_->sceneSessionMap_.clear();
90 }
91 
TearDown()92 void SceneSessionManagerTest::TearDown()
93 {
94     usleep(WAIT_SYNC_IN_NS);
95     ssm_->sceneSessionMap_.clear();
96 }
97 
SetVisibleForAccessibility(sptr<SceneSession> & sceneSession)98 void SceneSessionManagerTest::SetVisibleForAccessibility(sptr<SceneSession>& sceneSession)
99 {
100     sceneSession->SetTouchable(true);
101     sceneSession->forceTouchable_ = true;
102     sceneSession->systemTouchable_ = true;
103     sceneSession->state_ = SessionState::STATE_FOREGROUND;
104     sceneSession->foregroundInteractiveStatus_.store(true);
105     sceneSession->isVisible_ = true;
106 }
107 
GetTaskCount(sptr<SceneSession> & session)108 int32_t SceneSessionManagerTest::GetTaskCount(sptr<SceneSession>& session)
109 {
110     std::string dumpInfo = session->handler_->GetEventRunner()->GetEventQueue()->DumpCurrentQueueSize();
111     std::regex pattern("\\d+");
112     std::smatch matches;
113     int32_t taskNum = 0;
114     while (std::regex_search(dumpInfo, matches, pattern)) {
115         taskNum += std::stoi(matches.str());
116         dumpInfo = matches.suffix();
117     }
118     return taskNum;
119 }
120 
121 namespace {
122 /**
123  * @tc.name: SetBrightness
124  * @tc.desc: ScreenSesionManager set session brightness
125  * @tc.type: FUNC
126  */
127 HWTEST_F(SceneSessionManagerTest, SetBrightness, Function | SmallTest | Level3)
128 {
129     SessionInfo info;
130     info.abilityName_ = "SetBrightness";
131     info.bundleName_ = "SetBrightness1";
132     sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
133     ASSERT_NE(nullptr, sceneSession);
134     WSError result = ssm_->SetBrightness(sceneSession, 0.5);
135     ASSERT_EQ(result, WSError::WS_OK);
136 }
137 
138 /**
139  * @tc.name: GerPrivacyBundleListTwoWindow
140  * @tc.desc: get privacy bundle list when two windows exist.
141  * @tc.type: FUNC
142 */
143 HWTEST_F(SceneSessionManagerTest, GerPrivacyBundleListTwoWindow, Function | SmallTest | Level3)
144 {
145     SessionInfo sessionInfoFirst;
146     sessionInfoFirst.bundleName_ = "privacy.test.first";
147     sessionInfoFirst.abilityName_ = "privacyAbilityName";
148     sptr<SceneSession> sceneSessionFirst = ssm_->CreateSceneSession(sessionInfoFirst, nullptr);
149     ASSERT_NE(sceneSessionFirst, nullptr);
150     ssm_->sceneSessionMap_.insert({sceneSessionFirst->GetPersistentId(), sceneSessionFirst});
151 
152     SessionInfo sessionInfoSecond;
153     sessionInfoSecond.bundleName_ = "privacy.test.second";
154     sessionInfoSecond.abilityName_ = "privacyAbilityName";
155     sptr<SceneSession> sceneSessionSecond = ssm_->CreateSceneSession(sessionInfoSecond, nullptr);
156     ASSERT_NE(sceneSessionSecond, nullptr);
157     ssm_->sceneSessionMap_.insert({sceneSessionSecond->GetPersistentId(), sceneSessionSecond});
158 
159     sceneSessionFirst->GetSessionProperty()->displayId_ = 0;
160     sceneSessionFirst->GetSessionProperty()->isPrivacyMode_ = true;
161     sceneSessionFirst->state_ = SessionState::STATE_FOREGROUND;
162 
163     sceneSessionSecond->GetSessionProperty()->displayId_ = 0;
164     sceneSessionSecond->GetSessionProperty()->isPrivacyMode_ = true;
165     sceneSessionSecond->state_ = SessionState::STATE_FOREGROUND;
166 
167     std::unordered_set<std::string> privacyBundleList;
168     ssm_->GetSceneSessionPrivacyModeBundles(0, privacyBundleList);
169     EXPECT_EQ(privacyBundleList.size(), 2);
170 
171     sceneSessionSecond->GetSessionProperty()->displayId_ = 1;
172     privacyBundleList.clear();
173     ssm_->GetSceneSessionPrivacyModeBundles(0, privacyBundleList);
174     EXPECT_EQ(privacyBundleList.size(), 1);
175 
176     privacyBundleList.clear();
177     ssm_->GetSceneSessionPrivacyModeBundles(1, privacyBundleList);
178     EXPECT_EQ(privacyBundleList.size(), 1);
179 }
180 
181 /**
182  * @tc.name: SetWindowFlags
183  * @tc.desc: SceneSesionManager set window flags
184  * @tc.type: FUNC
185 */
186 HWTEST_F(SceneSessionManagerTest, SetWindowFlags, Function | SmallTest | Level3)
187 {
188     SessionInfo info;
189     info.bundleName_ = "bundleName";
190     sptr<WindowSessionProperty> property = new WindowSessionProperty();
191     uint32_t flags = static_cast<uint32_t>(WindowFlag::WINDOW_FLAG_SHOW_WHEN_LOCKED);
192     property->SetWindowFlags(flags);
193     sptr<SceneSession> scensession = nullptr;
194     WSError result01 = ssm_->SetWindowFlags(scensession, property);
195     EXPECT_EQ(result01, WSError::WS_ERROR_NULLPTR);
196     scensession = new (std::nothrow) SceneSession(info, nullptr);
197     WSError result02 = ssm_->SetWindowFlags(scensession, property);
198     EXPECT_EQ(result02, WSError::WS_ERROR_NOT_SYSTEM_APP);
199     property->SetSystemCalling(true);
200     WSError result03 = ssm_->SetWindowFlags(scensession, property);
201     ASSERT_EQ(result03, WSError::WS_OK);
202     scensession = nullptr;
203     delete scensession;
204 }
205 
206 /**
207  * @tc.name: NotifyWaterMarkFlagChangedResult
208  * @tc.desc: SceneSesionManager notify water mark flag changed result
209  * @tc.type: FUNC
210 */
211 HWTEST_F(SceneSessionManagerTest, NotifyWaterMarkFlagChangedResult, Function | SmallTest | Level3)
212 {
213     int32_t persistentId = 10086;
214     ssm_->NotifyCompleteFirstFrameDrawing(persistentId);
215     bool hasWaterMark = true;
216     AppExecFwk::AbilityInfo abilityInfo;
217     WSError result01 = ssm_->NotifyWaterMarkFlagChangedResult(hasWaterMark);
218     EXPECT_EQ(result01, WSError::WS_OK);
219     ssm_->CheckAndNotifyWaterMarkChangedResult();
220     ssm_->ProcessPreload(abilityInfo);
221 }
222 
223 /**
224  * @tc.name: IsValidSessionIds
225  * @tc.desc: SceneSesionManager is valid session id
226  * @tc.type: FUNC
227 */
228 HWTEST_F(SceneSessionManagerTest, IsValidSessionIds, Function | SmallTest | Level3)
229 {
230     std::vector<int32_t> sessionIds = {0, 1, 2, 3, 4, 5, 24, 10086};
231     std::vector<bool> results = {};
232     WSError result = ssm_->IsValidSessionIds(sessionIds, results);
233     EXPECT_EQ(result, WSError::WS_OK);
234 }
235 
236 /**
237  * @tc.name: UnRegisterSessionListener
238  * @tc.desc: SceneSesionManager un register session listener
239  * @tc.type: FUNC
240 */
241 HWTEST_F(SceneSessionManagerTest, UnRegisterSessionListener, Function | SmallTest | Level3)
242 {
243     OHOS::MessageParcel data;
244     sptr<ISessionListener> listener = iface_cast<ISessionListener>(data.ReadRemoteObject());
245     WSError result = ssm_->UnRegisterSessionListener(listener);
246     EXPECT_EQ(result, WSError::WS_ERROR_INVALID_PERMISSION);
247 }
248 
249 /**
250  * @tc.name: GetSessionInfos
251  * @tc.desc: SceneSesionManager get session infos
252  * @tc.type: FUNC
253 */
254 HWTEST_F(SceneSessionManagerTest, GetSessionInfos, Function | SmallTest | Level3)
255 {
256     std::string deviceId = "1245";
257     int32_t numMax = 1024;
258     AAFwk::MissionInfo infoFrist;
259     infoFrist.label = "fristBundleName";
260     AAFwk::MissionInfo infoSecond;
261     infoSecond.label = "secondBundleName";
262     std::vector<SessionInfoBean> sessionInfos = {infoFrist, infoSecond};
263     WSError result = ssm_->GetSessionInfos(deviceId, numMax, sessionInfos);
264     EXPECT_EQ(result, WSError::WS_ERROR_INVALID_PERMISSION);
265     int32_t persistentId = 24;
266     SessionInfoBean sessionInfo;
267     int result01 = ssm_->GetRemoteSessionInfo(deviceId, persistentId, sessionInfo);
268     ASSERT_NE(result01, ERR_OK);
269 }
270 
271 /**
272  * @tc.name: GetUnreliableWindowInfo
273  * @tc.desc: SceneSesionManager get unreliable window info
274  * @tc.type: FUNC
275 */
276 HWTEST_F(SceneSessionManagerTest, GetUnreliableWindowInfo, Function | SmallTest | Level3)
277 {
278     int32_t windowId = 0;
279     std::vector<sptr<UnreliableWindowInfo>> infos;
280     WMError result = ssm_->GetUnreliableWindowInfo(windowId, infos);
281     EXPECT_EQ(WMError::WM_OK, result);
282 }
283 
284 /**
285  * @tc.name: GetMainWindowStatesByPid
286  * @tc.desc: SceneSesionManager get main window states
287  * @tc.type: FUNC
288  */
289 HWTEST_F(SceneSessionManagerTest, GetMainWindowStatesByPid, Function | SmallTest | Level3)
290 {
291     int32_t pid = 100;
292     std::vector<MainWindowState> windowStates;
293     WSError result = ssm_->GetMainWindowStatesByPid(pid, windowStates);
294     EXPECT_EQ(result, WSError::WS_OK);
295 }
296 
297 /**
298  * @tc.name: CheckIsRemote
299  * @tc.desc: SceneSesionManager check is remote
300  * @tc.type: FUNC
301 */
302 HWTEST_F(SceneSessionManagerTest, CheckIsRemote, Function | SmallTest | Level3)
303 {
304     std::string deviceId;
305     bool result = ssm_->CheckIsRemote(deviceId);
306     EXPECT_FALSE(result);
307     deviceId.assign("deviceId");
308     result = ssm_->CheckIsRemote(deviceId);
309     EXPECT_FALSE(result);
310 }
311 
312 /**
313  * @tc.name: AnonymizeDeviceId
314  * @tc.desc: SceneSesionManager anonymize deviceId
315  * @tc.type: FUNC
316 */
317 HWTEST_F(SceneSessionManagerTest, AnonymizeDeviceId, Function | SmallTest | Level3)
318 {
319     std::string deviceId;
320     std::string result(ssm_->AnonymizeDeviceId(deviceId));
321     EXPECT_EQ(result, EMPTY_DEVICE_ID);
322     deviceId.assign("100964857");
323     std::string result01 = "100964******";
324     ASSERT_EQ(ssm_->AnonymizeDeviceId(deviceId), result01);
325 }
326 
327 /**
328  * @tc.name: TerminateSessionNew
329  * @tc.desc: SceneSesionManager terminate session new
330  * @tc.type: FUNC
331 */
332 HWTEST_F(SceneSessionManagerTest, TerminateSessionNew, Function | SmallTest | Level3)
333 {
334     sptr<AAFwk::SessionInfo> info = nullptr;
335     bool needStartCaller = true;
336     WSError result01 = ssm_->TerminateSessionNew(info, needStartCaller);
337     EXPECT_EQ(WSError::WS_ERROR_INVALID_PARAM, result01);
338     info = new (std::nothrow) AAFwk::SessionInfo();
339     WSError result02 = ssm_->TerminateSessionNew(info, needStartCaller);
340     EXPECT_EQ(WSError::WS_ERROR_INVALID_PARAM, result02);
341 }
342 
343 /**
344  * @tc.name: RegisterSessionListener01
345  * @tc.desc: SceneSesionManager register session listener
346  * @tc.type: FUNC
347 */
348 HWTEST_F(SceneSessionManagerTest, RegisterSessionListener01, Function | SmallTest | Level3)
349 {
350     OHOS::MessageParcel data;
351     sptr<ISessionListener> listener = iface_cast<ISessionListener>(data.ReadRemoteObject());
352     WSError result = ssm_->RegisterSessionListener(listener);
353     EXPECT_EQ(result, WSError::WS_ERROR_INVALID_PERMISSION);
354 }
355 
356 /**
357  * @tc.name: ClearDisplayStatusBarTemporarilyFlags
358  * @tc.desc: check ClearDisplayStatusBarTemporarilyFlags
359  * @tc.type: FUNC
360 */
361 HWTEST_F(SceneSessionManagerTest, ClearDisplayStatusBarTemporarilyFlags, Function | SmallTest | Level3)
362 {
363     SessionInfo sessionInfo;
364     sessionInfo.bundleName_ = "ClearDisplayStatusBarTemporarilyFlags";
365     sessionInfo.abilityName_ = "ClearDisplayStatusBarTemporarilyFlags";
366     sessionInfo.windowType_ = static_cast<uint32_t>(WindowType::APP_MAIN_WINDOW_BASE);
367     sptr<SceneSession> sceneSession = ssm_->RequestSceneSession(sessionInfo, nullptr);
368     ASSERT_NE(nullptr, sceneSession);
369     sceneSession->SetIsDisplayStatusBarTemporarily(true);
370     ASSERT_EQ(true, sceneSession->GetIsDisplayStatusBarTemporarily());
371     ssm_->ClearDisplayStatusBarTemporarilyFlags();
372     ASSERT_EQ(true, sceneSession->GetIsDisplayStatusBarTemporarily());
373 }
374 
375 /**
376  * @tc.name: RequestSceneSessionByCall
377  * @tc.desc: SceneSesionManager request scene session by call
378  * @tc.type: FUNC
379 */
380 HWTEST_F(SceneSessionManagerTest, RequestSceneSessionByCall, Function | SmallTest | Level3)
381 {
382     sptr<SceneSession> scensession = nullptr;
383     WSError result01 = ssm_->RequestSceneSessionByCall(nullptr);
384     EXPECT_EQ(result01, WSError::WS_OK);
385     SessionInfo info;
386     info.bundleName_ = "bundleName";
387     scensession = new (std::nothrow) SceneSession(info, nullptr);
388     WSError result02 = ssm_->RequestSceneSessionByCall(scensession);
389     ASSERT_EQ(result02, WSError::WS_OK);
390     scensession = nullptr;
391     delete scensession;
392 }
393 
394 /**
395  * @tc.name: StartAbilityBySpecified
396  * @tc.desc: SceneSesionManager start ability by specified
397  * @tc.type: FUNC
398 */
399 HWTEST_F(SceneSessionManagerTest, StartAbilityBySpecified, Function | SmallTest | Level3)
400 {
401     int ret = 0;
402     SessionInfo info;
403     ssm_->StartAbilityBySpecified(info);
404 
405     std::shared_ptr<AAFwk::Want> want = std::make_shared<AAFwk::Want>();
406     AAFwk::WantParams wantParams;
407     want->SetParams(wantParams);
408     info.want = want;
409     ssm_->StartAbilityBySpecified(info);
410     ASSERT_EQ(ret, 0);
411 }
412 
413 /**
414  * @tc.name: FindMainWindowWithToken
415  * @tc.desc: SceneSesionManager find main window with token
416  * @tc.type: FUNC
417 */
418 HWTEST_F(SceneSessionManagerTest, FindMainWindowWithToken, Function | SmallTest | Level3)
419 {
420     sptr<IRemoteObject> targetToken = nullptr;
421     sptr<SceneSession> result = ssm_->FindMainWindowWithToken(targetToken);
422     EXPECT_EQ(result, nullptr);
423     uint64_t persistentId = 1423;
424     WSError result01 = ssm_->BindDialogSessionTarget(persistentId, targetToken);
425     EXPECT_EQ(result01, WSError::WS_ERROR_NULLPTR);
426 }
427 
428 /**
429  * @tc.name: UpdateParentSessionForDialog001
430  * @tc.desc: SceneSesionManager update parent session for dialog
431  * @tc.type: FUNC
432 */
433 HWTEST_F(SceneSessionManagerTest, UpdateParentSessionForDialog001, Function | SmallTest | Level3)
434 {
435     SessionInfo dialogInfo;
436     dialogInfo.abilityName_ = "DialogWindows";
437     dialogInfo.bundleName_ = "DialogWindows";
438     SessionInfo parentInfo;
439     parentInfo.abilityName_ = "ParentWindows";
440     parentInfo.bundleName_ = "ParentWindows";
441 
442     int32_t persistentId = 1005;
443     sptr<SceneSession> parentSession = new (std::nothrow) SceneSession(parentInfo, nullptr);
444     EXPECT_NE(parentSession, nullptr);
445     ssm_->sceneSessionMap_.insert({ persistentId, parentSession });
446 
447     sptr<SceneSession> dialogSession = new (std::nothrow) SceneSession(dialogInfo, nullptr);
448     EXPECT_NE(dialogSession, nullptr);
449 
450     sptr<WindowSessionProperty> property = new WindowSessionProperty();
451     property->SetParentPersistentId(persistentId);
452     property->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
453 
454     WSError result = ssm_->UpdateParentSessionForDialog(dialogSession, property);
455     EXPECT_EQ(dialogSession->GetParentPersistentId(), persistentId);
456     EXPECT_NE(dialogSession->GetParentSession(), nullptr);
457     EXPECT_EQ(result, WSError::WS_OK);
458 }
459 
460 /**
461  * @tc.name: MoveSessionsToBackground
462  * @tc.desc: SceneSesionManager move sessions to background
463  * @tc.type: FUNC
464 */
465 HWTEST_F(SceneSessionManagerTest, MoveSessionsToBackground, Function | SmallTest | Level3)
466 {
467     int32_t type = CollaboratorType::RESERVE_TYPE;
468     WSError result01 = ssm_->UnregisterIAbilityManagerCollaborator(type);
469     EXPECT_EQ(result01, WSError::WS_ERROR_INVALID_PERMISSION);
470     std::vector<std::int32_t> sessionIds = {1, 2, 3, 15, 1423};
471     std::vector<int32_t> res = {1, 2, 3, 15, 1423};
472     WSError result03 = ssm_->MoveSessionsToBackground(sessionIds, res);
473     ASSERT_EQ(result03, WSError::WS_ERROR_INVALID_PERMISSION);
474 }
475 
476 /**
477  * @tc.name: MoveSessionsToForeground
478  * @tc.desc: SceneSesionManager move sessions to foreground
479  * @tc.type: FUNC
480 */
481 HWTEST_F(SceneSessionManagerTest, MoveSessionsToForeground, Function | SmallTest | Level3)
482 {
483     std::vector<std::int32_t> sessionIds = {1, 2, 3, 15, 1423};
484     int32_t topSessionId = 1;
485     WSError result = ssm_->MoveSessionsToForeground(sessionIds, topSessionId);
486     ASSERT_EQ(result, WSError::WS_ERROR_INVALID_PERMISSION);
487 }
488 
489 /**
490  * @tc.name: UnlockSession
491  * @tc.desc: SceneSesionManager unlock session
492  * @tc.type: FUNC
493 */
494 HWTEST_F(SceneSessionManagerTest, UnlockSession, Function | SmallTest | Level3)
495 {
496     int32_t sessionId = 1;
497     WSError result = ssm_->UnlockSession(sessionId);
498     EXPECT_EQ(result, WSError::WS_ERROR_INVALID_PERMISSION);
499     result = ssm_->LockSession(sessionId);
500     EXPECT_EQ(result, WSError::WS_ERROR_INVALID_PERMISSION);
501 }
502 
503 /**
504  * @tc.name: GetImmersiveState
505  * @tc.desc: test GetImmersiveState
506  * @tc.type: FUNC
507 */
508 HWTEST_F(SceneSessionManagerTest, GetImmersiveState, Function | SmallTest | Level3)
509 {
510     int ret = 0;
511     ssm_->GetImmersiveState();
512     ASSERT_EQ(ret, 0);
513 }
514 
515 /**
516  * @tc.name: NotifyAINavigationBarShowStatus
517  * @tc.desc: test NotifyAINavigationBarShowStatus
518  * @tc.type: FUNC
519 */
520 HWTEST_F(SceneSessionManagerTest, NotifyAINavigationBarShowStatus, Function | SmallTest | Level3)
521 {
522     bool isVisible = false;
523     WSRect barArea = { 0, 0, 320, 240}; // width: 320, height: 240
524     uint64_t displayId = 0;
525     WSError result = ssm_->NotifyAINavigationBarShowStatus(isVisible, barArea, displayId);
526     ASSERT_EQ(result, WSError::WS_OK);
527 }
528 
529 /**
530  * @tc.name: NotifyWindowExtensionVisibilityChange
531  * @tc.desc: test NotifyWindowExtensionVisibilityChange
532  * @tc.type: FUNC
533 */
534 HWTEST_F(SceneSessionManagerTest, NotifyWindowExtensionVisibilityChange, Function | SmallTest | Level3)
535 {
536     int32_t pid = getprocpid();
537     int32_t uid = getuid();
538     bool isVisible = false;
539     WSError result = ssm_->NotifyWindowExtensionVisibilityChange(pid, uid, isVisible);
540     ASSERT_EQ(result, WSError::WS_OK);
541 
542     pid = INVALID_PID;
543     uid = INVALID_USER_ID;
544     result = ssm_->NotifyWindowExtensionVisibilityChange(pid, uid, isVisible);
545     ASSERT_EQ(result, WSError::WS_ERROR_INVALID_PERMISSION);
546 }
547 
548 /**
549  * @tc.name: UpdateTopmostProperty
550  * @tc.desc: test UpdateTopmostProperty
551  * @tc.type: FUNC
552 */
553 HWTEST_F(SceneSessionManagerTest, UpdateTopmostProperty, Function | SmallTest | Level3)
554 {
555     SessionInfo info;
556     info.abilityName_ = "UpdateTopmostProperty";
557     info.bundleName_ = "UpdateTopmostProperty";
558     sptr<WindowSessionProperty> property = new WindowSessionProperty();
559     property->SetTopmost(true);
560     property->SetSystemCalling(true);
561     sptr<SceneSession> scenesession = new (std::nothrow) MainSession(info, nullptr);
562     scenesession->SetSessionProperty(property);
563     WMError result = ssm_->UpdateTopmostProperty(property, scenesession);
564     ASSERT_EQ(WMError::WM_OK, result);
565 }
566 
567 /**
568  * @tc.name: UpdateSessionWindowVisibilityListener
569  * @tc.desc: SceneSesionManager update window visibility listener
570  * @tc.type: FUNC
571 */
572 HWTEST_F(SceneSessionManagerTest, UpdateSessionWindowVisibilityListener, Function | SmallTest | Level3)
573 {
574     int32_t persistentId = 10086;
575     bool haveListener = true;
576     WSError result = ssm_->UpdateSessionWindowVisibilityListener(persistentId, haveListener);
577     ASSERT_EQ(result, WSError::WS_DO_NOTHING);
578 }
579 
580 /**
581  * @tc.name: GetSessionSnapshotPixelMap
582  * @tc.desc: SceneSesionManager get session snapshot pixelmap
583  * @tc.type: FUNC
584 */
585 HWTEST_F(SceneSessionManagerTest, GetSessionSnapshotPixelMap, Function | SmallTest | Level3)
586 {
587     SessionInfo info;
588     info.abilityName_ = "GetPixelMap";
589     info.bundleName_ = "GetPixelMap1";
590     sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
591     sceneSession->SetSessionState(SessionState::STATE_ACTIVE);
592 
593     int32_t persistentId = 65535;
594     float scaleValue = 0.5f;
595     auto pixelMap = ssm_->GetSessionSnapshotPixelMap(persistentId, scaleValue);
596     EXPECT_EQ(pixelMap, nullptr);
597 
598     persistentId = 1;
599     pixelMap = ssm_->GetSessionSnapshotPixelMap(persistentId, scaleValue);
600     EXPECT_EQ(pixelMap, nullptr);
601 }
602 
603 /**
604  * @tc.name: GetSessionSnapshotById
605  * @tc.desc: test GetSessionSnapshotById
606  * @tc.type: FUNC
607 */
608 HWTEST_F(SceneSessionManagerTest, GetSessionSnapshotById, Function | SmallTest | Level3)
609 {
610     int32_t persistentId = -1;
611     SessionSnapshot snapshot;
612     WMError ret = ssm_->GetSessionSnapshotById(persistentId, snapshot);
613     EXPECT_EQ(WMError::WM_ERROR_INVALID_PARAM, ret);
614 }
615 
616 /**
617  * @tc.name: GetUIContentRemoteObj
618  * @tc.desc: SceneSesionManager GetUIContentRemoteObj
619  * @tc.type: FUNC
620 */
621 HWTEST_F(SceneSessionManagerTest, GetUIContentRemoteObj, Function | SmallTest | Level3)
622 {
623     sptr<IRemoteObject> remoteObj;
624     EXPECT_EQ(ssm_->GetUIContentRemoteObj(65535, remoteObj), WSError::WS_ERROR_INVALID_PERMISSION);
625     SessionInfo info;
626     info.abilityName_ = "GetUIContentRemoteObj";
627     info.bundleName_ = "GetUIContentRemoteObj";
628     sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
629     ASSERT_NE(sceneSession, nullptr);
630     ssm_->sceneSessionMap_.insert({65535, sceneSession});
631     EXPECT_EQ(ssm_->GetUIContentRemoteObj(65535, remoteObj), WSError::WS_ERROR_INVALID_PERMISSION);
632 }
633 
634 /**
635  * @tc.name: CalculateCombinedExtWindowFlags
636  * @tc.desc: SceneSesionManager calculate combined extension window flags
637  * @tc.type: FUNC
638 */
639 HWTEST_F(SceneSessionManagerTest, CalculateCombinedExtWindowFlags, Function | SmallTest | Level3)
640 {
641     EXPECT_EQ(ssm_->combinedExtWindowFlags_.bitData, 0);
642     ssm_->UpdateSpecialExtWindowFlags(1234, ExtensionWindowFlags(3), ExtensionWindowFlags(3));
643     ssm_->UpdateSpecialExtWindowFlags(5678, ExtensionWindowFlags(4), ExtensionWindowFlags(4));
644     ssm_->CalculateCombinedExtWindowFlags();
645     EXPECT_EQ(ssm_->combinedExtWindowFlags_.bitData, 7);
646     ssm_->extWindowFlagsMap_.clear();
647 }
648 
649 /**
650  * @tc.name: UpdateSpecialExtWindowFlags
651  * @tc.desc: SceneSesionManager update special extension window flags
652  * @tc.type: FUNC
653 */
654 HWTEST_F(SceneSessionManagerTest, UpdateSpecialExtWindowFlags, Function | SmallTest | Level3)
655 {
656     int32_t persistentId = 12345;
657     EXPECT_TRUE(ssm_->extWindowFlagsMap_.empty());
658     ssm_->UpdateSpecialExtWindowFlags(persistentId, 3, 3);
659     EXPECT_EQ(ssm_->extWindowFlagsMap_.size(), 1);
660     EXPECT_EQ(ssm_->extWindowFlagsMap_.begin()->first, persistentId);
661     EXPECT_EQ(ssm_->extWindowFlagsMap_.begin()->second.bitData, 3);
662     ssm_->UpdateSpecialExtWindowFlags(persistentId, 0, 3);
663     EXPECT_TRUE(ssm_->extWindowFlagsMap_.empty());
664     ssm_->extWindowFlagsMap_.clear();
665 }
666 
667 /**
668  * @tc.name: HideNonSecureFloatingWindows
669  * @tc.desc: SceneSesionManager hide non-secure floating windows
670  * @tc.type: FUNC
671 */
672 HWTEST_F(SceneSessionManagerTest, HideNonSecureFloatingWindows, Function | SmallTest | Level3)
673 {
674     SessionInfo info;
675     info.abilityName_ = "HideNonSecureFloatingWindows";
676     info.bundleName_ = "HideNonSecureFloatingWindows";
677 
678     sptr<SceneSession> sceneSession;
679     sceneSession = new (std::nothrow) SceneSession(info, nullptr);
680     EXPECT_NE(sceneSession, nullptr);
681     sceneSession->state_ = SessionState::STATE_FOREGROUND;
682     ssm_->sceneSessionMap_.insert(std::make_pair(sceneSession->GetPersistentId(), sceneSession));
683 
684     sptr<SceneSession> floatSession;
685     floatSession = new (std::nothrow) SceneSession(info, nullptr);
686     EXPECT_NE(floatSession, nullptr);
687     floatSession->GetSessionProperty()->SetWindowType(WindowType::WINDOW_TYPE_FLOAT);
688     ssm_->nonSystemFloatSceneSessionMap_.insert(std::make_pair(floatSession->GetPersistentId(), floatSession));
689 
690     EXPECT_FALSE(ssm_->shouldHideNonSecureFloatingWindows_.load());
691     EXPECT_FALSE(floatSession->GetSessionProperty()->GetForceHide());
692     sceneSession->combinedExtWindowFlags_.hideNonSecureWindowsFlag = true;
693     ssm_->HideNonSecureFloatingWindows();
694     EXPECT_TRUE(floatSession->GetSessionProperty()->GetForceHide());
695     sceneSession->combinedExtWindowFlags_.hideNonSecureWindowsFlag = false;
696     ssm_->combinedExtWindowFlags_.hideNonSecureWindowsFlag = true;
697     ssm_->HideNonSecureFloatingWindows();
698     EXPECT_TRUE(floatSession->GetSessionProperty()->GetForceHide());
699 
700     ssm_->combinedExtWindowFlags_.hideNonSecureWindowsFlag = false;
701     ssm_->HideNonSecureFloatingWindows();
702     ssm_->combinedExtWindowFlags_.hideNonSecureWindowsFlag = true;
703     ssm_->systemConfig_.uiType_ = UI_TYPE_PC;
704     ssm_->HideNonSecureFloatingWindows();
705     EXPECT_FALSE(floatSession->GetSessionProperty()->GetForceHide());
706     ssm_->systemConfig_.uiType_ = UI_TYPE_PHONE;
707 
708     ssm_->shouldHideNonSecureFloatingWindows_.store(false);
709     ssm_->sceneSessionMap_.clear();
710     ssm_->nonSystemFloatSceneSessionMap_.clear();
711 }
712 
713 /**
714  * @tc.name: HideNonSecureSubWindows
715  * @tc.desc: SceneSesionManager hide non-secure sub windows
716  * @tc.type: FUNC
717 */
718 HWTEST_F(SceneSessionManagerTest, HideNonSecureSubWindows, Function | SmallTest | Level3)
719 {
720     SessionInfo info;
721     info.abilityName_ = "HideNonSecureSubWindows";
722     info.bundleName_ = "HideNonSecureSubWindows";
723 
724     sptr<SceneSession> sceneSession;
725     sceneSession = new (std::nothrow) SceneSession(info, nullptr);
726     ASSERT_NE(sceneSession, nullptr);
727     sceneSession->state_ = SessionState::STATE_FOREGROUND;
728     sceneSession->combinedExtWindowFlags_.hideNonSecureWindowsFlag = true;
729 
730     sptr<SceneSession> subSession;
731     subSession = new (std::nothrow) SceneSession(info, nullptr);
732     ASSERT_NE(subSession, nullptr);
733     ASSERT_NE(subSession->GetSessionProperty(), nullptr);
734     sceneSession->AddSubSession(subSession);
735     subSession->GetSessionProperty()->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
736     subSession->GetSessionProperty()->SetParentPersistentId(sceneSession->GetPersistentId());
737     ssm_->sceneSessionMap_.insert(std::make_pair(subSession->GetPersistentId(), subSession));
738 
739     EXPECT_FALSE(subSession->GetSessionProperty()->GetForceHide());
740     sceneSession->combinedExtWindowFlags_.hideNonSecureWindowsFlag = true;
741     ssm_->HideNonSecureSubWindows(sceneSession);
742     EXPECT_TRUE(subSession->GetSessionProperty()->GetForceHide());
743     ssm_->sceneSessionMap_.clear();
744 }
745 
746 /**
747  * @tc.name: HandleSecureSessionShouldHide
748  * @tc.desc: SceneSesionManager handle secure session should hide
749  * @tc.type: FUNC
750 */
751 HWTEST_F(SceneSessionManagerTest, HandleSecureSessionShouldHide, Function | SmallTest | Level3)
752 {
753     SessionInfo info;
754     info.abilityName_ = "HandleSecureSessionShouldHide";
755     info.bundleName_ = "HandleSecureSessionShouldHide";
756 
757     sptr<SceneSession> sceneSession;
758     sceneSession = new (std::nothrow) SceneSession(info, nullptr);
759     ASSERT_NE(sceneSession, nullptr);
760     sceneSession->state_ = SessionState::STATE_FOREGROUND;
761     sceneSession->combinedExtWindowFlags_.hideNonSecureWindowsFlag = true;
762 
763     sptr<SceneSession> subSession;
764     subSession = new (std::nothrow) SceneSession(info, nullptr);
765     ASSERT_NE(subSession, nullptr);
766     ASSERT_NE(subSession->GetSessionProperty(), nullptr);
767     sceneSession->AddSubSession(subSession);
768     subSession->GetSessionProperty()->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
769     subSession->GetSessionProperty()->SetParentPersistentId(sceneSession->GetPersistentId());
770     ssm_->sceneSessionMap_.insert(std::make_pair(subSession->GetPersistentId(), subSession));
771 
772     sptr<SceneSession> floatSession;
773     floatSession = new (std::nothrow) SceneSession(info, nullptr);
774     ASSERT_NE(floatSession, nullptr);
775     ASSERT_NE(floatSession->GetSessionProperty(), nullptr);
776     floatSession->GetSessionProperty()->SetWindowType(WindowType::WINDOW_TYPE_FLOAT);
777     ssm_->nonSystemFloatSceneSessionMap_.insert(std::make_pair(floatSession->GetPersistentId(), floatSession));
778 
779     sceneSession->SetShouldHideNonSecureWindows(true);
780     auto ret = ssm_->HandleSecureSessionShouldHide(sceneSession);
781     EXPECT_EQ(ret, WSError::WS_OK);
782     EXPECT_TRUE(subSession->GetSessionProperty()->GetForceHide());
783     EXPECT_TRUE(floatSession->GetSessionProperty()->GetForceHide());
784     EXPECT_TRUE(ssm_->shouldHideNonSecureFloatingWindows_.load());
785     ssm_->sceneSessionMap_.clear();
786     ssm_->nonSystemFloatSceneSessionMap_.clear();
787 }
788 
789 /**
790  * @tc.name: HandleSpecialExtWindowFlagsChange
791  * @tc.desc: SceneSesionManager handle special uiextension window flags change
792  * @tc.type: FUNC
793 */
794 HWTEST_F(SceneSessionManagerTest, HandleSpecialExtWindowFlagsChange, Function | SmallTest | Level3)
795 {
796     int32_t persistentId = 12345;
797     EXPECT_TRUE(ssm_->extWindowFlagsMap_.empty());
798     ssm_->HandleSpecialExtWindowFlagsChange(persistentId, 3, 3);
799     EXPECT_EQ(ssm_->extWindowFlagsMap_.size(), 1);
800     EXPECT_EQ(ssm_->extWindowFlagsMap_.begin()->first, persistentId);
801     EXPECT_EQ(ssm_->extWindowFlagsMap_.begin()->second.bitData, 3);
802     ssm_->HandleSpecialExtWindowFlagsChange(persistentId, 0, 3);
803     EXPECT_TRUE(ssm_->extWindowFlagsMap_.empty());
804     ssm_->extWindowFlagsMap_.clear();
805 }
806 
807 /**
808  * @tc.name: UpdateModalExtensionRect
809  * @tc.desc: SceneSesionManager update modal extension rect
810  * @tc.type: FUNC
811 */
812 HWTEST_F(SceneSessionManagerTest, UpdateModalExtensionRect, Function | SmallTest | Level3)
813 {
814     SessionInfo info;
815     info.abilityName_ = "UpdateModalExtensionRect";
816     info.bundleName_ = "UpdateModalExtensionRect";
817     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
818     ASSERT_NE(sceneSession, nullptr);
819     Rect rect { 1, 2, 3, 4 };
820     ssm_->UpdateModalExtensionRect(nullptr, rect);
821     EXPECT_FALSE(sceneSession->GetLastModalUIExtensionEventInfo());
822 }
823 
824 /**
825  * @tc.name: ProcessModalExtensionPointDown
826  * @tc.desc: SceneSesionManager process modal extension point down
827  * @tc.type: FUNC
828 */
829 HWTEST_F(SceneSessionManagerTest, ProcessModalExtensionPointDown, Function | SmallTest | Level3)
830 {
831     SessionInfo info;
832     info.abilityName_ = "ProcessModalExtensionPointDown";
833     info.bundleName_ = "ProcessModalExtensionPointDown";
834     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
835     ASSERT_NE(sceneSession, nullptr);
836 
837     ssm_->ProcessModalExtensionPointDown(nullptr, 0, 0);
838     EXPECT_FALSE(sceneSession->GetLastModalUIExtensionEventInfo());
839 }
840 
841 /**
842  * @tc.name: GetExtensionWindowIds
843  * @tc.desc: SceneSesionManager get extension window ids
844  * @tc.type: FUNC
845 */
846 HWTEST_F(SceneSessionManagerTest, GetExtensionWindowIds, Function | SmallTest | Level3)
847 {
848     SessionInfo info;
849     info.abilityName_ = "GetExtensionWindowIds";
850     info.bundleName_ = "GetExtensionWindowIds";
851     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
852     ASSERT_NE(sceneSession, nullptr);
853 
854     int32_t persistentId = 0;
855     int32_t parentId = 0;
856     EXPECT_FALSE(ssm_->GetExtensionWindowIds(nullptr, persistentId, parentId));
857 }
858 
859 /**
860  * @tc.name: AddOrRemoveSecureSession
861  * @tc.desc: SceneSesionManager hide non-secure windows by scene session
862  * @tc.type: FUNC
863 */
864 HWTEST_F(SceneSessionManagerTest, AddOrRemoveSecureSession, Function | SmallTest | Level3)
865 {
866     SessionInfo info;
867     info.abilityName_ = "AddOrRemoveSecureSession";
868     info.bundleName_ = "AddOrRemoveSecureSession1";
869 
870     int32_t persistentId = 12345;
871     auto ret = ssm_->AddOrRemoveSecureSession(persistentId, true);
872     EXPECT_EQ(ret, WSError::WS_OK);
873 }
874 
875 /**
876  * @tc.name: UpdateExtWindowFlags
877  * @tc.desc: SceneSesionManager update uiextension window flags
878  * @tc.type: FUNC
879 */
880 HWTEST_F(SceneSessionManagerTest, UpdateExtWindowFlags, Function | SmallTest | Level3)
881 {
882     SessionInfo info;
883     info.abilityName_ = "UpdateExtWindowFlags";
884     info.bundleName_ = "UpdateExtWindowFlags";
885 
886     auto ret = ssm_->UpdateExtWindowFlags(nullptr, 7, 7);
887     EXPECT_EQ(ret, WSError::WS_ERROR_INVALID_PERMISSION);
888 }
889 
890 /**
891  * @tc.name: SetScreenLocked001
892  * @tc.desc: SetScreenLocked001
893  * @tc.type: FUNC
894 */
895 HWTEST_F(SceneSessionManagerTest, SetScreenLocked001, Function | SmallTest | Level3)
896 {
897     sptr<SceneSession> sceneSession = nullptr;
898     SessionInfo info;
899     info.bundleName_ = "bundleName";
900     sceneSession = new (std::nothrow) SceneSession(info, nullptr);
901     ASSERT_NE(nullptr, sceneSession);
902     sceneSession->SetEventHandler(ssm_->taskScheduler_->GetEventHandler(), ssm_->eventHandler_);
903     ssm_->sceneSessionMap_.insert(std::make_pair(sceneSession->GetPersistentId(), sceneSession));
904     DetectTaskInfo detectTaskInfo;
905     detectTaskInfo.taskState = DetectTaskState::ATTACH_TASK;
906     detectTaskInfo.taskWindowMode = WindowMode::WINDOW_MODE_UNDEFINED;
907     sceneSession->SetDetectTaskInfo(detectTaskInfo);
908     std::string taskName = "wms:WindowStateDetect" + std::to_string(sceneSession->persistentId_);
__anon7624743c0402()909     auto task = [](){};
910     int64_t delayTime = 3000;
911     sceneSession->handler_->PostTask(task, taskName, delayTime);
912     int32_t beforeTaskNum = GetTaskCount(sceneSession);
913     ssm_->SetScreenLocked(true);
914     ASSERT_EQ(beforeTaskNum - 1, GetTaskCount(sceneSession));
915     ASSERT_EQ(DetectTaskState::NO_TASK, sceneSession->detectTaskInfo_.taskState);
916     ASSERT_EQ(WindowMode::WINDOW_MODE_UNDEFINED, sceneSession->detectTaskInfo_.taskWindowMode);
917 }
918 
919 /**
920  * @tc.name: AccessibilityFillEmptySceneSessionListToNotifyList
921  * @tc.desc: SceneSesionManager fill empty scene session list to accessibilityList;
922  * @tc.type: FUNC
923 */
924 HWTEST_F(SceneSessionManagerTest, AccessibilityFillEmptySceneSessionListToNotifyList, Function | SmallTest | Level3)
925 {
926     std::vector<sptr<SceneSession>> sceneSessionList;
927     std::vector<sptr<AccessibilityWindowInfo>> accessibilityInfo;
928 
929     ssm_->FillAccessibilityInfo(sceneSessionList, accessibilityInfo);
930     EXPECT_EQ(accessibilityInfo.size(), 0);
931 }
932 
933 /**
934  * @tc.name: AccessibilityFillOneSceneSessionListToNotifyList
935  * @tc.desc: SceneSesionManager fill one sceneSession to accessibilityList;
936  * @tc.type: FUNC
937 */
938 HWTEST_F(SceneSessionManagerTest, AccessibilityFillOneSceneSessionListToNotifyList, Function | SmallTest | Level3)
939 {
940     SessionInfo sessionInfo;
941     sessionInfo.bundleName_ = "accessibilityNotifyTesterBundleName";
942     sessionInfo.abilityName_ = "accessibilityNotifyTesterAbilityName";
943 
944     sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(sessionInfo, nullptr);
945     ASSERT_NE(sceneSession, nullptr);
946     SetVisibleForAccessibility(sceneSession);
947     ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
948 
949     std::vector<sptr<SceneSession>> sceneSessionList;
950     ssm_->GetAllSceneSessionForAccessibility(sceneSessionList);
951     ASSERT_EQ(sceneSessionList.size(), 1);
952 
953     std::vector<sptr<AccessibilityWindowInfo>> accessibilityInfo;
954     ssm_->FillAccessibilityInfo(sceneSessionList, accessibilityInfo);
955     ASSERT_EQ(accessibilityInfo.size(), 1);
956 }
957 
958 /**
959  * @tc.name: AccessibilityFillTwoSceneSessionListToNotifyList
960  * @tc.desc: SceneSesionManager fill two sceneSessions to accessibilityList;
961  * @tc.type: FUNC
962 */
963 HWTEST_F(SceneSessionManagerTest, AccessibilityFillTwoSceneSessionListToNotifyList, Function | SmallTest | Level3)
964 {
965     SessionInfo sessionInfo;
966     sessionInfo.bundleName_ = "accessibilityNotifyTesterBundleName";
967     sessionInfo.abilityName_ = "accessibilityNotifyTesterAbilityName";
968 
969     sptr<SceneSession> sceneSessionFirst = ssm_->CreateSceneSession(sessionInfo, nullptr);
970     ASSERT_NE(sceneSessionFirst, nullptr);
971     SetVisibleForAccessibility(sceneSessionFirst);
972 
973     sptr<SceneSession> sceneSessionSecond = ssm_->CreateSceneSession(sessionInfo, nullptr);
974     ASSERT_NE(sceneSessionSecond, nullptr);
975     SetVisibleForAccessibility(sceneSessionSecond);
976 
977     ssm_->sceneSessionMap_.insert({sceneSessionFirst->GetPersistentId(), sceneSessionFirst});
978     ssm_->sceneSessionMap_.insert({sceneSessionSecond->GetPersistentId(), sceneSessionSecond});
979 
980     std::vector<sptr<SceneSession>> sceneSessionList;
981     ssm_->GetAllSceneSessionForAccessibility(sceneSessionList);
982     ASSERT_EQ(sceneSessionList.size(), 2);
983 
984     std::vector<sptr<AccessibilityWindowInfo>> accessibilityInfo;
985     ssm_->FillAccessibilityInfo(sceneSessionList, accessibilityInfo);
986     ASSERT_EQ(accessibilityInfo.size(), 2);
987 }
988 
989 /**
990  * @tc.name: AccessibilityFillEmptyBundleName
991  * @tc.desc: SceneSesionManager fill empty bundle name to accessibilityInfo;
992  * @tc.type: FUNC
993 */
994 HWTEST_F(SceneSessionManagerTest, AccessibilityFillEmptyBundleName, Function | SmallTest | Level3)
995 {
996     SessionInfo sessionInfo;
997     sessionInfo.abilityName_ = "accessibilityNotifyTesterAbilityName";
998 
999     sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(sessionInfo, nullptr);
1000     ASSERT_NE(sceneSession, nullptr);
1001     SetVisibleForAccessibility(sceneSession);
1002     ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
1003 
1004     std::vector<sptr<SceneSession>> sceneSessionList;
1005     ssm_->GetAllSceneSessionForAccessibility(sceneSessionList);
1006     ASSERT_EQ(sceneSessionList.size(), 1);
1007 
1008     std::vector<sptr<AccessibilityWindowInfo>> accessibilityInfo;
1009     ssm_->FillAccessibilityInfo(sceneSessionList, accessibilityInfo);
1010     ASSERT_EQ(accessibilityInfo.size(), 1);
1011 
1012     ASSERT_EQ(accessibilityInfo.at(0)->bundleName_, "");
1013     ASSERT_EQ(sceneSessionList.at(0)->GetSessionInfo().bundleName_, "");
1014     ASSERT_EQ(accessibilityInfo.at(0)->bundleName_, sceneSessionList.at(0)->GetSessionInfo().bundleName_);
1015 }
1016 
1017 /**
1018  * @tc.name: AccessibilityFillBundleName
1019  * @tc.desc: SceneSesionManager fill bundle name to accessibilityInfo;
1020  * @tc.type: FUNC
1021 */
1022 HWTEST_F(SceneSessionManagerTest, AccessibilityFillBundleName, Function | SmallTest | Level3)
1023 {
1024     SessionInfo sessionInfo;
1025     sessionInfo.bundleName_ = "accessibilityNotifyTesterBundleName";
1026     sessionInfo.abilityName_ = "accessibilityNotifyTesterAbilityName";
1027 
1028     sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(sessionInfo, nullptr);
1029     ASSERT_NE(sceneSession, nullptr);
1030     SetVisibleForAccessibility(sceneSession);
1031     ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
1032 
1033     std::vector<sptr<SceneSession>> sceneSessionList;
1034     ssm_->GetAllSceneSessionForAccessibility(sceneSessionList);
1035     ASSERT_EQ(sceneSessionList.size(), 1);
1036 
1037     std::vector<sptr<AccessibilityWindowInfo>> accessibilityInfo;
1038     ssm_->FillAccessibilityInfo(sceneSessionList, accessibilityInfo);
1039     ASSERT_EQ(accessibilityInfo.size(), 1);
1040 
1041     ASSERT_EQ(accessibilityInfo.at(0)->bundleName_, "accessibilityNotifyTesterBundleName");
1042     ASSERT_EQ(sceneSessionList.at(0)->GetSessionInfo().bundleName_, "accessibilityNotifyTesterBundleName");
1043     ASSERT_EQ(accessibilityInfo.at(0)->bundleName_, sceneSessionList.at(0)->GetSessionInfo().bundleName_);
1044 }
1045 
1046 /**
1047  * @tc.name: AccessibilityFillFilterBundleName
1048  * @tc.desc: SceneSesionManager fill filter bundle name to accessibilityInfo;
1049  * @tc.type: FUNC
1050 */
1051 HWTEST_F(SceneSessionManagerTest, AccessibilityFillFilterBundleName, Function | SmallTest | Level3)
1052 {
1053     SessionInfo sessionInfo;
1054     sessionInfo.bundleName_ = "SCBGestureTopBar";
1055     sessionInfo.abilityName_ = "accessibilityNotifyTesterAbilityName";
1056 
1057     sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(sessionInfo, nullptr);
1058     ASSERT_NE(sceneSession, nullptr);
1059     SetVisibleForAccessibility(sceneSession);
1060     ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
1061 
1062     std::vector<sptr<SceneSession>> sceneSessionList;
1063     ssm_->GetAllSceneSessionForAccessibility(sceneSessionList);
1064     ASSERT_EQ(sceneSessionList.size(), 0);
1065 
1066     std::vector<sptr<AccessibilityWindowInfo>> accessibilityInfo;
1067     ssm_->FillAccessibilityInfo(sceneSessionList, accessibilityInfo);
1068     ASSERT_EQ(accessibilityInfo.size(), 0);
1069 }
1070 
1071 /**
1072  * @tc.name: AccessibilityFillEmptyHotAreas
1073  * @tc.desc: SceneSesionManager fill empty hot areas to accessibilityInfo;
1074  * @tc.type: FUNC
1075 */
1076 HWTEST_F(SceneSessionManagerTest, AccessibilityFillEmptyHotAreas, Function | SmallTest | Level3)
1077 {
1078     SessionInfo sessionInfo;
1079     sessionInfo.bundleName_ = "accessibilityNotifyTesterBundleName";
1080     sessionInfo.abilityName_ = "accessibilityNotifyTesterAbilityName";
1081 
1082     sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(sessionInfo, nullptr);
1083     ASSERT_NE(sceneSession, nullptr);
1084     SetVisibleForAccessibility(sceneSession);
1085     ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
1086 
1087     std::vector<sptr<SceneSession>> sceneSessionList;
1088     std::vector<sptr<AccessibilityWindowInfo>> accessibilityInfo;
1089 
1090     ssm_->GetAllSceneSessionForAccessibility(sceneSessionList);
1091     ssm_->FillAccessibilityInfo(sceneSessionList, accessibilityInfo);
1092     ASSERT_EQ(accessibilityInfo.size(), 1);
1093 
1094     ASSERT_EQ(accessibilityInfo.at(0)->touchHotAreas_.size(), sceneSessionList.at(0)->GetTouchHotAreas().size());
1095     ASSERT_EQ(accessibilityInfo.at(0)->touchHotAreas_.size(), 0);
1096 }
1097 
1098 /**
1099  * @tc.name: AccessibilityFillOneHotAreas
1100  * @tc.desc: SceneSesionManager fill one hot areas to accessibilityInfo;
1101  * @tc.type: FUNC
1102 */
1103 HWTEST_F(SceneSessionManagerTest, AccessibilityFillOneHotAreas, Function | SmallTest | Level3)
1104 {
1105     SessionInfo sessionInfo;
1106     sessionInfo.bundleName_ = "accessibilityNotifyTesterBundleName";
1107     sessionInfo.abilityName_ = "accessibilityNotifyTesterAbilityName";
1108 
1109     Rect rect = {100, 200, 100, 200};
1110     std::vector<Rect> hotAreas;
1111     hotAreas.push_back(rect);
1112     sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(sessionInfo, nullptr);
1113     ASSERT_NE(sceneSession, nullptr);
1114     sceneSession->SetTouchHotAreas(hotAreas);
1115     SetVisibleForAccessibility(sceneSession);
1116     ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
1117 
1118     std::vector<sptr<SceneSession>> sceneSessionList;
1119     std::vector<sptr<AccessibilityWindowInfo>> accessibilityInfo;
1120 
1121     ssm_->GetAllSceneSessionForAccessibility(sceneSessionList);
1122     ssm_->FillAccessibilityInfo(sceneSessionList, accessibilityInfo);
1123     ASSERT_EQ(accessibilityInfo.size(), 1);
1124 
1125     ASSERT_EQ(accessibilityInfo.at(0)->touchHotAreas_.size(), sceneSessionList.at(0)->GetTouchHotAreas().size());
1126     ASSERT_EQ(accessibilityInfo.at(0)->touchHotAreas_.size(), 1);
1127 
1128     ASSERT_EQ(rect.posX_, sceneSessionList.at(0)->GetTouchHotAreas().at(0).posX_);
1129     ASSERT_EQ(rect.posY_, sceneSessionList.at(0)->GetTouchHotAreas().at(0).posY_);
1130     ASSERT_EQ(rect.width_, sceneSessionList.at(0)->GetTouchHotAreas().at(0).width_);
1131     ASSERT_EQ(rect.height_, sceneSessionList.at(0)->GetTouchHotAreas().at(0).height_);
1132 
1133     ASSERT_EQ(accessibilityInfo.at(0)->touchHotAreas_.at(0).posX_, rect.posX_);
1134     ASSERT_EQ(accessibilityInfo.at(0)->touchHotAreas_.at(0).posY_, rect.posY_);
1135     ASSERT_EQ(accessibilityInfo.at(0)->touchHotAreas_.at(0).width_, rect.width_);
1136     ASSERT_EQ(accessibilityInfo.at(0)->touchHotAreas_.at(0).height_, rect.height_);
1137 }
1138 
1139 /**
1140  * @tc.name: AccessibilityFillTwoHotAreas
1141  * @tc.desc: SceneSesionManager fill two hot areas to accessibilityInfo;
1142  * @tc.type: FUNC
1143 */
1144 HWTEST_F(SceneSessionManagerTest, AccessibilityFillTwoHotAreas, Function | SmallTest | Level3)
1145 {
1146     SessionInfo sessionInfo;
1147     sessionInfo.bundleName_ = "accessibilityNotifyTesterBundleName";
1148     sessionInfo.abilityName_ = "accessibilityNotifyTesterAbilityName";
1149 
1150     sptr<WindowSessionProperty> property = new WindowSessionProperty();
1151     std::vector<Rect> hotAreas;
1152     Rect rectFitst = {100, 200, 100, 200};
1153     Rect rectSecond = {50, 50, 20, 30};
1154     hotAreas.push_back(rectFitst);
1155     hotAreas.push_back(rectSecond);
1156     sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(sessionInfo, nullptr);
1157     ASSERT_NE(sceneSession, nullptr);
1158     sceneSession->SetTouchHotAreas(hotAreas);
1159     SetVisibleForAccessibility(sceneSession);
1160     ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
1161 
1162     std::vector<sptr<SceneSession>> sceneSessionList;
1163     std::vector<sptr<AccessibilityWindowInfo>> accessibilityInfo;
1164 
1165     ssm_->GetAllSceneSessionForAccessibility(sceneSessionList);
1166     ssm_->FillAccessibilityInfo(sceneSessionList, accessibilityInfo);
1167     ASSERT_EQ(accessibilityInfo.size(), 1);
1168 
1169     ASSERT_EQ(accessibilityInfo.at(0)->touchHotAreas_.size(), sceneSessionList.at(0)->GetTouchHotAreas().size());
1170     ASSERT_EQ(accessibilityInfo.at(0)->touchHotAreas_.size(), 2);
1171 
1172     ASSERT_EQ(accessibilityInfo.at(0)->touchHotAreas_.at(0).posX_, rectFitst.posX_);
1173     ASSERT_EQ(accessibilityInfo.at(0)->touchHotAreas_.at(0).posY_, rectFitst.posY_);
1174     ASSERT_EQ(accessibilityInfo.at(0)->touchHotAreas_.at(0).width_, rectFitst.width_);
1175     ASSERT_EQ(accessibilityInfo.at(0)->touchHotAreas_.at(0).height_, rectFitst.height_);
1176 
1177     ASSERT_EQ(accessibilityInfo.at(0)->touchHotAreas_.at(1).posX_, rectSecond.posX_);
1178     ASSERT_EQ(accessibilityInfo.at(0)->touchHotAreas_.at(1).posY_, rectSecond.posY_);
1179     ASSERT_EQ(accessibilityInfo.at(0)->touchHotAreas_.at(1).width_, rectSecond.width_);
1180     ASSERT_EQ(accessibilityInfo.at(0)->touchHotAreas_.at(1).height_, rectSecond.height_);
1181 }
1182 
1183 /**
1184  * @tc.name: AccessibilityFilterEmptySceneSessionList
1185  * @tc.desc: SceneSesionManager filter empty scene session list;
1186  * @tc.type: FUNC
1187 */
1188 HWTEST_F(SceneSessionManagerTest, AccessibilityFilterEmptySceneSessionList, Function | SmallTest | Level3)
1189 {
1190     std::vector<sptr<SceneSession>> sceneSessionList;
1191 
1192     ssm_->FilterSceneSessionCovered(sceneSessionList);
1193     ASSERT_EQ(sceneSessionList.size(), 0);
1194 }
1195 
1196 /**
1197  * @tc.name: AccessibilityFilterOneWindow
1198  * @tc.desc: SceneSesionManager filter one window;
1199  * @tc.type: FUNC
1200 */
1201 HWTEST_F(SceneSessionManagerTest, AccessibilityFilterOneWindow, Function | SmallTest | Level3)
1202 {
1203     SessionInfo sessionInfo;
1204     sessionInfo.bundleName_ = "accessibilityNotifyTesterBundleName";
1205     sessionInfo.abilityName_ = "accessibilityNotifyTesterAbilityName";
1206 
1207     sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(sessionInfo, nullptr);
1208     ASSERT_NE(sceneSession, nullptr);
1209     sceneSession->SetSessionRect({100, 100, 200, 200});
1210     SetVisibleForAccessibility(sceneSession);
1211     ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
1212 
1213     std::vector<sptr<SceneSession>> sceneSessionList;
1214     std::vector<sptr<AccessibilityWindowInfo>> accessibilityInfo;
1215     ssm_->GetAllSceneSessionForAccessibility(sceneSessionList);
1216     ssm_->FilterSceneSessionCovered(sceneSessionList);
1217     ssm_->FillAccessibilityInfo(sceneSessionList, accessibilityInfo);
1218     ASSERT_EQ(accessibilityInfo.size(), 1);
1219 }
1220 
1221 /**
1222  * @tc.name: AccessibilityFilterTwoWindowNotCovered
1223  * @tc.desc: SceneSesionManager filter two windows that not covered each other;
1224  * @tc.type: FUNC
1225 */
1226 HWTEST_F(SceneSessionManagerTest, AccessibilityFilterTwoWindowNotCovered, Function | SmallTest | Level3)
1227 {
1228     SessionInfo sessionInfo;
1229     sessionInfo.bundleName_ = "accessibilityNotifyTesterBundleName";
1230     sessionInfo.abilityName_ = "accessibilityNotifyTesterAbilityName";
1231 
1232     sptr<SceneSession> sceneSessionFirst = ssm_->CreateSceneSession(sessionInfo, nullptr);
1233     ASSERT_NE(sceneSessionFirst, nullptr);
1234     sceneSessionFirst->SetSessionRect({0, 0, 200, 200});
1235     SetVisibleForAccessibility(sceneSessionFirst);
1236     ssm_->sceneSessionMap_.insert({sceneSessionFirst->GetPersistentId(), sceneSessionFirst});
1237 
1238     sptr<SceneSession> sceneSessionSecond = ssm_->CreateSceneSession(sessionInfo, nullptr);
1239     ASSERT_NE(sceneSessionSecond, nullptr);
1240     sceneSessionSecond->SetSessionRect({300, 300, 200, 200});
1241     SetVisibleForAccessibility(sceneSessionSecond);
1242     ssm_->sceneSessionMap_.insert({sceneSessionSecond->GetPersistentId(), sceneSessionSecond});
1243 
1244     std::vector<sptr<SceneSession>> sceneSessionList;
1245     std::vector<sptr<AccessibilityWindowInfo>> accessibilityInfo;
1246     ssm_->GetAllSceneSessionForAccessibility(sceneSessionList);
1247     ssm_->FilterSceneSessionCovered(sceneSessionList);
1248     ssm_->FillAccessibilityInfo(sceneSessionList, accessibilityInfo);
1249     ASSERT_EQ(accessibilityInfo.size(), 2);
1250 }
1251 
1252 /**
1253  * @tc.name: AccessibilityFilterTwoWindowCovered
1254  * @tc.desc: SceneSesionManager filter two windows that covered each other;
1255  * @tc.type: FUNC
1256 */
1257 HWTEST_F(SceneSessionManagerTest, AccessibilityFilterTwoWindowCovered, Function | SmallTest | Level3)
1258 {
1259     SessionInfo sessionInfo;
1260     sessionInfo.bundleName_ = "accessibilityNotifyTesterBundleName";
1261     sessionInfo.abilityName_ = "accessibilityNotifyTesterAbilityName";
1262 
1263     sptr<SceneSession> sceneSessionFirst = ssm_->CreateSceneSession(sessionInfo, nullptr);
1264     ASSERT_NE(sceneSessionFirst, nullptr);
1265     sceneSessionFirst->SetSessionRect({0, 0, 200, 200});
1266     SetVisibleForAccessibility(sceneSessionFirst);
1267     sceneSessionFirst->SetZOrder(20);
1268     ssm_->sceneSessionMap_.insert({sceneSessionFirst->GetPersistentId(), sceneSessionFirst});
1269 
1270     sptr<SceneSession> sceneSessionSecond = ssm_->CreateSceneSession(sessionInfo, nullptr);
1271     ASSERT_NE(sceneSessionSecond, nullptr);
1272     sceneSessionSecond->SetSessionRect({50, 50, 50, 50});
1273     SetVisibleForAccessibility(sceneSessionSecond);
1274     sceneSessionSecond->SetZOrder(10);
1275     ssm_->sceneSessionMap_.insert({sceneSessionSecond->GetPersistentId(), sceneSessionSecond});
1276 
1277     std::vector<sptr<SceneSession>> sceneSessionList;
1278     std::vector<sptr<AccessibilityWindowInfo>> accessibilityInfo;
1279     ssm_->GetAllSceneSessionForAccessibility(sceneSessionList);
1280     ssm_->FilterSceneSessionCovered(sceneSessionList);
1281     ssm_->FillAccessibilityInfo(sceneSessionList, accessibilityInfo);
1282     ASSERT_EQ(accessibilityInfo.size(), 1);
1283 }
1284 
1285 /**
1286  * @tc.name: TestNotifyEnterRecentTask
1287  * @tc.desc: Test whether the enterRecent_ is set correctly;
1288  * @tc.type: FUNC
1289 */
1290 HWTEST_F(SceneSessionManagerTest, TestNotifyEnterRecentTask, Function | SmallTest | Level3)
1291 {
1292     GTEST_LOG_(INFO) << "SceneSessionManagerTest: TestNotifyEnterRecentTask start";
1293     sptr<SceneSessionManager> sceneSessionManager = new SceneSessionManager();
1294     ASSERT_NE(nullptr, sceneSessionManager);
1295 
1296     ASSERT_EQ(sceneSessionManager->NotifyEnterRecentTask(true), WSError::WS_OK);
1297     ASSERT_EQ(sceneSessionManager->enterRecent_.load(), true);
1298 }
1299 
1300 /**
1301  * @tc.name: GetAllWindowVisibilityInfos
1302  * @tc.desc: SceneSesionManager get all window visibility infos;
1303  * @tc.type: FUNC
1304 */
1305 HWTEST_F(SceneSessionManagerTest, GetAllWindowVisibilityInfos, Function | SmallTest | Level3)
1306 {
1307     ASSERT_NE(ssm_, nullptr);
1308     ssm_->sceneSessionMap_.clear();
1309     SessionInfo info;
1310     sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(info, nullptr);
1311     ASSERT_NE(nullptr, sceneSession);
1312     ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
1313     std::vector<std::pair<int32_t, uint32_t>> windowVisibilityInfos;
1314     ssm_->GetAllWindowVisibilityInfos(windowVisibilityInfos);
1315     EXPECT_NE(windowVisibilityInfos.size(), 0);
1316 }
1317 
1318 /**
1319  * @tc.name: TestNotifyEnterRecentTask
1320  * @tc.desc: Test whether the enterRecent_ is set correctly;
1321  * @tc.type: FUNC
1322 */
1323 HWTEST_F(SceneSessionManagerTest, TestNotifyEnterRecentTask01, Function | SmallTest | Level3)
1324 {
1325     GTEST_LOG_(INFO) << "SceneSessionManagerTest: TestNotifyEnterRecentTask start";
1326     sptr<SceneSessionManager> sceneSessionManager = new SceneSessionManager();
1327     ASSERT_NE(nullptr, sceneSessionManager);
1328 
1329     ASSERT_EQ(sceneSessionManager->NotifyEnterRecentTask(true), WSError::WS_OK);
1330     ASSERT_EQ(sceneSessionManager->enterRecent_.load(), true);
1331 }
1332 
1333 /**
1334  * @tc.name: TestIsEnablePiPCreate
1335  * @tc.desc: Test if pip window can be created;
1336  * @tc.type: FUNC
1337 */
1338 HWTEST_F(SceneSessionManagerTest, TestIsEnablePiPCreate, Function | SmallTest | Level3)
1339 {
1340     GTEST_LOG_(INFO) << "SceneSessionManagerTest: TestIsEnablePiPCreate start";
1341     ssm_->isScreenLocked_ = true;
1342     sptr<WindowSessionProperty> property = new (std::nothrow) WindowSessionProperty();
1343     ASSERT_TRUE(!ssm_->isEnablePiPCreate(property));
1344 
1345     ssm_->isScreenLocked_ = false;
1346     Rect reqRect = { 0, 0, 0, 0 };
1347     property->SetRequestRect(reqRect);
1348     ASSERT_TRUE(!ssm_->isEnablePiPCreate(property));
1349 
1350     reqRect = { 0, 0, 10, 0 };
1351     property->SetRequestRect(reqRect);
1352     ASSERT_TRUE(!ssm_->isEnablePiPCreate(property));
1353 
1354     reqRect = { 0, 0, 10, 10 };
1355     property->SetRequestRect(reqRect);
1356     PiPTemplateInfo info = {0, 0, {}};
1357     property->SetPiPTemplateInfo(info);
1358     SessionInfo info1;
1359     info1.abilityName_ = "test1";
1360     info1.bundleName_ = "test2";
1361     sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info1, nullptr);
1362     ASSERT_NE(nullptr, sceneSession);
1363     property->SetWindowMode(WindowMode::WINDOW_MODE_PIP);
1364     sceneSession->pipTemplateInfo_ = {0, 100, {}};
1365     ssm_->sceneSessionMap_.insert({0, sceneSession});
1366     ASSERT_TRUE(!ssm_->isEnablePiPCreate(property));
1367     ssm_->sceneSessionMap_.clear();
1368     ASSERT_TRUE(!ssm_->isEnablePiPCreate(property));
1369 
1370     property->SetParentPersistentId(100);
1371     ASSERT_TRUE(!ssm_->isEnablePiPCreate(property));
1372 
1373     ssm_->sceneSessionMap_.insert({100, sceneSession});
1374     ASSERT_TRUE(!ssm_->isEnablePiPCreate(property));
1375 
1376     ssm_->sceneSessionMap_.clear();
1377     sceneSession->SetSessionState(SessionState::STATE_FOREGROUND);
1378     ssm_->sceneSessionMap_.insert({100, sceneSession});
1379     ASSERT_TRUE(ssm_->isEnablePiPCreate(property));
1380 }
1381 
1382 /**
1383  * @tc.name: GetUnreliableWindowInfo01
1384  * @tc.desc: SceneSesionManager get unreliable window info, windowId correct
1385  * @tc.type: FUNC
1386 */
1387 HWTEST_F(SceneSessionManagerTest, GetUnreliableWindowInfo01, Function | SmallTest | Level3)
1388 {
1389     ssm_->sceneSessionMap_.clear();
1390     SessionInfo info;
1391     sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(info, nullptr);
1392     ASSERT_NE(nullptr, sceneSession);
1393     ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
1394 
1395     int32_t windowId = sceneSession->GetPersistentId();
1396     std::vector<sptr<UnreliableWindowInfo>> infos;
1397     WMError result = ssm_->GetUnreliableWindowInfo(windowId, infos);
1398     EXPECT_EQ(WMError::WM_OK, result);
1399     EXPECT_EQ(1, infos.size());
1400 }
1401 
1402 /**
1403  * @tc.name: GetUnreliableWindowInfo02
1404  * @tc.desc: SceneSesionManager get unreliable window info, toast window
1405  * @tc.type: FUNC
1406 */
1407 HWTEST_F(SceneSessionManagerTest, GetUnreliableWindowInfo02, Function | SmallTest | Level3)
1408 {
1409     ssm_->sceneSessionMap_.clear();
1410     SessionInfo info;
1411     info.windowType_ = 2107;
1412     sptr<WindowSessionProperty> property = new (std::nothrow) WindowSessionProperty();
1413     ASSERT_NE(nullptr, property);
1414     property->SetWindowType(WindowType::WINDOW_TYPE_TOAST);
1415     sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(info, property);
1416     ASSERT_NE(nullptr, sceneSession);
1417     sceneSession->SetRSVisible(true);
1418     ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
1419 
1420     int32_t windowId = 0;
1421     std::vector<sptr<UnreliableWindowInfo>> infos;
1422     WMError result = ssm_->GetUnreliableWindowInfo(windowId, infos);
1423     EXPECT_EQ(WMError::WM_OK, result);
1424     EXPECT_EQ(1, infos.size());
1425 }
1426 
1427 /**
1428  * @tc.name: GetUnreliableWindowInfo03
1429  * @tc.desc: SceneSesionManager get unreliable window info, app sub window
1430  * @tc.type: FUNC
1431 */
1432 HWTEST_F(SceneSessionManagerTest, GetUnreliableWindowInfo03, Function | SmallTest | Level3)
1433 {
1434     ssm_->sceneSessionMap_.clear();
1435     SessionInfo info;
1436     info.windowType_ = 1000;
1437     sptr<WindowSessionProperty> property = new (std::nothrow) WindowSessionProperty();
1438     ASSERT_NE(nullptr, property);
1439     property->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
1440     sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(info, property);
1441     ASSERT_NE(nullptr, sceneSession);
1442     ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
1443 
1444     SessionInfo info2;
1445     info2.windowType_ = 1001;
1446     sptr<WindowSessionProperty> property2 = new (std::nothrow) WindowSessionProperty();
1447     ASSERT_NE(nullptr, property2);
1448     property2->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
1449     property2->SetParentId(sceneSession->GetPersistentId());
1450     sptr<SceneSession> sceneSession2 = ssm_->CreateSceneSession(info2, property2);
1451     ASSERT_NE(nullptr, sceneSession2);
1452     sceneSession2->SetRSVisible(true);
1453     ssm_->sceneSessionMap_.insert({sceneSession2->GetPersistentId(), sceneSession2});
1454 
1455     int32_t windowId = 0;
1456     std::vector<sptr<UnreliableWindowInfo>> infos;
1457     WMError result = ssm_->GetUnreliableWindowInfo(windowId, infos);
1458     EXPECT_EQ(WMError::WM_OK, result);
1459     EXPECT_EQ(1, infos.size());
1460 }
1461 
1462 /**
1463  * @tc.name: GetUnreliableWindowInfo04
1464  * @tc.desc: SceneSesionManager get unreliable window info, input method window
1465  * @tc.type: FUNC
1466 */
1467 HWTEST_F(SceneSessionManagerTest, GetUnreliableWindowInfo04, Function | SmallTest | Level3)
1468 {
1469     ssm_->sceneSessionMap_.clear();
1470     SessionInfo info;
1471     info.windowType_ = 2105;
1472     sptr<WindowSessionProperty> property = new (std::nothrow) WindowSessionProperty();
1473     ASSERT_NE(nullptr, property);
1474     property->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
1475     sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(info, property);
1476     ASSERT_NE(nullptr, sceneSession);
1477     sceneSession->SetRSVisible(true);
1478     ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
1479 
1480     int32_t windowId = 0;
1481     std::vector<sptr<UnreliableWindowInfo>> infos;
1482     WMError result = ssm_->GetUnreliableWindowInfo(windowId, infos);
1483     EXPECT_EQ(WMError::WM_OK, result);
1484     EXPECT_EQ(1, infos.size());
1485 }
1486 
1487 /**
1488  * @tc.name: GetUnreliableWindowInfo05
1489  * @tc.desc: SceneSesionManager get unreliable window info, not correct window type, not visible
1490  * @tc.type: FUNC
1491 */
1492 HWTEST_F(SceneSessionManagerTest, GetUnreliableWindowInfo05, Function | SmallTest | Level3)
1493 {
1494     ssm_->sceneSessionMap_.clear();
1495     SessionInfo info;
1496     info.windowType_ = 2122;
1497     sptr<WindowSessionProperty> property = new (std::nothrow) WindowSessionProperty();
1498     ASSERT_NE(nullptr, property);
1499     property->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
1500     sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(info, property);
1501     ASSERT_NE(nullptr, sceneSession);
1502     sceneSession->SetRSVisible(true);
1503     ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
1504     ssm_->sceneSessionMap_.insert({0, nullptr});
1505 
1506     int32_t windowId = 0;
1507     std::vector<sptr<UnreliableWindowInfo>> infos;
1508     WMError result = ssm_->GetUnreliableWindowInfo(windowId, infos);
1509     EXPECT_EQ(WMError::WM_OK, result);
1510     sceneSession->SetRSVisible(false);
1511     result = ssm_->GetUnreliableWindowInfo(windowId, infos);
1512     EXPECT_EQ(WMError::WM_OK, result);
1513     EXPECT_EQ(0, infos.size());
1514 }
1515 
1516 /**
1517  * @tc.name: GetUnreliableWindowInfo06
1518  * @tc.desc: SceneSesionManager satisfy FillUnreliableWindowInfo branches coverage
1519  * @tc.type: FUNC
1520 */
1521 HWTEST_F(SceneSessionManagerTest, GetUnreliableWindowInfo06, Function | SmallTest | Level3)
1522 {
1523     ssm_->sceneSessionMap_.clear();
1524     SessionInfo info1;
1525     info1.bundleName_ = "SCBGestureBack";
1526     sptr<SceneSession> sceneSession1 = ssm_->CreateSceneSession(info1, nullptr);
1527     ASSERT_NE(nullptr, sceneSession1);
1528     ssm_->sceneSessionMap_.insert({sceneSession1->GetPersistentId(), sceneSession1});
1529 
1530     SessionInfo info2;
1531     info2.bundleName_ = "SCBGestureNavBar";
1532     sptr<SceneSession> sceneSession2 = ssm_->CreateSceneSession(info2, nullptr);
1533     ASSERT_NE(nullptr, sceneSession2);
1534     ssm_->sceneSessionMap_.insert({sceneSession2->GetPersistentId(), sceneSession2});
1535 
1536     SessionInfo info3;
1537     info3.bundleName_ = "SCBGestureTopBar";
1538     sptr<SceneSession> sceneSession3 = ssm_->CreateSceneSession(info3, nullptr);
1539     ASSERT_NE(nullptr, sceneSession3);
1540     ssm_->sceneSessionMap_.insert({sceneSession3->GetPersistentId(), sceneSession3});
1541 
1542     std::vector<sptr<UnreliableWindowInfo>> infos;
1543     ssm_->GetUnreliableWindowInfo(sceneSession1->GetPersistentId(), infos);
1544     ssm_->GetUnreliableWindowInfo(sceneSession2->GetPersistentId(), infos);
1545     ssm_->GetUnreliableWindowInfo(sceneSession3->GetPersistentId(), infos);
1546     EXPECT_EQ(0, infos.size());
1547 }
1548 
1549 /**
1550  * @tc.name: GetAllMainWindowInfos001
1551  * @tc.desc: SceneSessionManager get all main window infos.
1552  * @tc.type: FUNC
1553 */
1554 HWTEST_F(SceneSessionManagerTest, GetAllMainWindowInfos001, Function | SmallTest | Level3)
1555 {
1556     SessionInfo info;
1557     info.abilityName_ = "test1";
1558     info.bundleName_ = "test1";
1559     info.windowType_ = static_cast<uint32_t>(WindowType::APP_WINDOW_BASE);
1560     info.persistentId_ = 1;
1561     std::shared_ptr<AppExecFwk::AbilityInfo> abilityInfo = std::make_shared<AppExecFwk::AbilityInfo>();
1562     AppExecFwk::ApplicationInfo applicationInfo;
1563     applicationInfo.bundleType = AppExecFwk::BundleType::ATOMIC_SERVICE;
1564     abilityInfo->applicationInfo = applicationInfo;
1565     info.abilityInfo = abilityInfo;
1566     sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
1567     if (sceneSession == nullptr) {
1568         return;
1569     }
1570     ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
1571     std::vector<MainWindowInfo> infos;
1572     WMError result = ssm_->GetAllMainWindowInfos(infos);
1573     EXPECT_EQ(result, WMError::WM_OK);
1574     ssm_->sceneSessionMap_.erase(sceneSession->GetPersistentId());
1575 }
1576 
1577 /**
1578  * @tc.name: GetAllMainWindowInfos002
1579  * @tc.desc: SceneSessionManager get all main window infos, input params are not empty.
1580  * @tc.type: FUNC
1581 */
1582 HWTEST_F(SceneSessionManagerTest, GetAllMainWindowInfos002, Function | SmallTest | Level3)
1583 {
1584     std::vector<MainWindowInfo> infos;
1585     MainWindowInfo info;
1586     info.pid_ = 1000;
1587     info.bundleName_ = "test";
1588     infos.push_back(info);
1589     WMError result = ssm_->GetAllMainWindowInfos(infos);
1590     EXPECT_EQ(result, WMError::WM_ERROR_INVALID_PARAM);
1591 }
1592 
1593 /**
1594  * @tc.name: TestReportCorrectScreenFoldStatusChangeEvent
1595  * @tc.desc: Test whether report the correct screen fold status events
1596  * @tc.type: FUNC
1597 */
1598 HWTEST_F(SceneSessionManagerTest, TestReportCorrectScreenFoldStatusChangeEvent, Function | SmallTest | Level3)
1599 {
1600     GTEST_LOG_(INFO) << "SceneSessionManagerTest: TestReportCorrectScreenFoldStatusChangeEvent start";
1601     ScreenFoldData screenFoldData1;
1602     screenFoldData1.currentScreenFoldStatus_ = 1; // 1: current screen fold status
1603     screenFoldData1.nextScreenFoldStatus_ = 3; // 3: next screen fold status
1604     screenFoldData1.currentScreenFoldStatusDuration_ = 18; // 18: current duration
1605     screenFoldData1.postureAngle_ = 47.1f; // 47.1: posture angle (type: float)
1606     screenFoldData1.screenRotation_ = 1; // 1: screen rotation
1607     screenFoldData1.typeCThermal_ = 3000; // 3000: typec port thermal
1608     screenFoldData1.focusedPackageName_ = "Developer Test: (1, 3, 18, 47.1, 1, 3000)";
1609     WMError result = ssm_->CheckAndReportScreenFoldStatus(screenFoldData1);
1610     ASSERT_EQ(result, WMError::WM_DO_NOTHING); // not report half-fold event until next change
1611 
1612     ScreenFoldData screenFoldData2;
1613     screenFoldData2.currentScreenFoldStatus_ = 3; // 3: current screen fold status
1614     screenFoldData2.nextScreenFoldStatus_ = 2; // 2: next screen fold status
1615     screenFoldData2.currentScreenFoldStatusDuration_ = 20; // 20: current duration
1616     screenFoldData2.postureAngle_ = 143.7f; // 143.7: posture angle (type: float)
1617     screenFoldData2.screenRotation_ = 2; // 2: screen rotation
1618     screenFoldData2.typeCThermal_ = 3005; // 3005: typec port thermal
1619     screenFoldData2.focusedPackageName_ = "Developer Test: (3, 2, 20, 143.7, 2, 3005)";
1620     result = ssm_->CheckAndReportScreenFoldStatus(screenFoldData2);
1621     ASSERT_EQ(result, WMError::WM_OK);
1622 }
1623 
1624 /**
1625  * @tc.name: TestReportIncompleteScreenFoldStatusChangeEvent
1626  * @tc.desc: Test whether block the incomplete screen fold status events
1627  * @tc.type: FUNC
1628 */
1629 HWTEST_F(SceneSessionManagerTest, TestReportIncompleteScreenFoldStatusChangeEvent, Function | SmallTest | Level3)
1630 {
1631     GTEST_LOG_(INFO) << "SceneSessionManagerTest: TestReportIncompleteScreenFoldStatusChangeEvent start";
1632     // screen fold status changes from -1: invalid to 3: half_fold, duration = 0, angle = 67.0, rotation = 0
1633     std::vector<std::string> screenFoldInfo {"-1", "3", "0", "67.0", "0"};
1634     WMError result = ssm_->ReportScreenFoldStatusChange(screenFoldInfo);
1635     ASSERT_EQ(result, WMError::WM_DO_NOTHING);
1636 
1637     screenFoldInfo.clear();
1638     result = ssm_->ReportScreenFoldStatusChange(screenFoldInfo);
1639     ASSERT_EQ(result, WMError::WM_DO_NOTHING);
1640 
1641     // screen fold status changes from 2: folded to 3: half_fold, duration = 0, angle = 67.0, rotation = 0
1642     screenFoldInfo = {"2", "3", "0", "67.0", "0"};
1643     result = ssm_->ReportScreenFoldStatusChange(screenFoldInfo);
1644     ASSERT_EQ(result, WMError::WM_DO_NOTHING);
1645 
1646     // screen fold status changes from 3: half_fold to 1: expand, duration = 18, angle = 147.3, rotation = 2
1647     screenFoldInfo = {"3", "1", "18", "147.3", "2"};
1648     result = ssm_->ReportScreenFoldStatusChange(screenFoldInfo);
1649     ASSERT_EQ(result, WMError::WM_DO_NOTHING);
1650 }
1651 
1652 /**
1653  * @tc.name: ReleaseForegroundSessionScreenLock
1654  * @tc.desc: release screen lock of foreground session
1655  * @tc.type: FUNC
1656  */
1657 HWTEST_F(SceneSessionManagerTest, ReleaseForegroundSessionScreenLock, Function | SmallTest | Level3)
1658 {
1659     auto result = ssm_->ReleaseForegroundSessionScreenLock();
1660     ASSERT_EQ(result, WMError::WM_OK);
1661 }
1662 
1663 /**
1664  * @tc.name: SetAppForceLandscapeConfig
1665  * @tc.desc: SceneSesionManager SetAppForceLandscapeConfig
1666  * @tc.type: FUNC
1667  */
1668 HWTEST_F(SceneSessionManagerTest, SetAppForceLandscapeConfig, Function | SmallTest | Level3)
1669 {
1670     std::string bundleName = "SetAppForceLandscapeConfig";
1671     AppForceLandscapeConfig config = { 0, "MainPage" };
1672     WSError result = ssm_->SetAppForceLandscapeConfig(bundleName, config);
1673     ASSERT_EQ(result, WSError::WS_OK);
1674 }
1675 
1676 /**
1677  * @tc.name: GetAppForceLandscapeConfig
1678  * @tc.desc: SceneSesionManager GetAppForceLandscapeConfig
1679  * @tc.type: FUNC
1680  */
1681 HWTEST_F(SceneSessionManagerTest, GetAppForceLandscapeConfig, Function | SmallTest | Level3)
1682 {
1683     std::string bundleName = "GetAppForceLandscapeConfig";
1684     AppForceLandscapeConfig config = ssm_->GetAppForceLandscapeConfig(bundleName);
1685     ASSERT_EQ(config.mode_, 0);
1686     ASSERT_EQ(config.homePage_, "");
1687 }
1688 
1689 /**
1690  * @tc.name: CloseTargetFloatWindow
1691  * @tc.desc: SceneSesionManager CloseTargetFloatWindow
1692  * @tc.type: FUNC
1693  */
1694 HWTEST_F(SceneSessionManagerTest, CloseTargetFloatWindow, Function | SmallTest | Level3)
1695 {
1696     std::string bundleName = "testClose";
1697     auto result = ssm_->CloseTargetFloatWindow(bundleName);
1698     ASSERT_EQ(result, WMError::WM_OK);
1699 }
1700 
1701 /**
1702  * @tc.name: CloseTargetPiPWindow
1703  * @tc.desc: SceneSesionManager CloseTargetPiPWindow
1704  * @tc.type: FUNC
1705  */
1706 HWTEST_F(SceneSessionManagerTest, CloseTargetPiPWindow, Function | SmallTest | Level3)
1707 {
1708     std::string bundleName = "CloseTargetPiPWindow";
1709     auto result = ssm_->CloseTargetPiPWindow(bundleName);
1710     ASSERT_EQ(result, WMError::WM_OK);
1711 }
1712 
1713 /**
1714  * @tc.name: GetCurrentPiPWindowInfo01
1715  * @tc.desc: SceneSesionManager GetCurrentPiPWindowInfo
1716  * @tc.type: FUNC
1717  */
1718 HWTEST_F(SceneSessionManagerTest, GetCurrentPiPWindowInfo01, Function | SmallTest | Level3)
1719 {
1720     std::string bundleName;
1721     auto result = ssm_->GetCurrentPiPWindowInfo(bundleName);
1722     ASSERT_EQ(result, WMError::WM_OK);
1723     ASSERT_EQ("", bundleName);
1724 }
1725 
1726 /**
1727  * @tc.name: GetCurrentPiPWindowInfo02
1728  * @tc.desc: SceneSesionManager GetCurrentPiPWindowInfo
1729  * @tc.type: FUNC
1730  */
1731 HWTEST_F(SceneSessionManagerTest, GetCurrentPiPWindowInfo02, Function | SmallTest | Level3)
1732 {
1733     SessionInfo info1;
1734     info1.abilityName_ = "test1";
1735     info1.bundleName_ = "test1";
1736     info1.windowType_ = static_cast<uint32_t>(WindowType::WINDOW_TYPE_PIP);
1737     sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(info1, nullptr);
1738     ASSERT_NE(nullptr, sceneSession1);
1739     SessionInfo info2;
1740     info2.abilityName_ = "test2";
1741     info2.bundleName_ = "test2";
1742     info2.windowType_ = static_cast<uint32_t>(WindowType::WINDOW_TYPE_DIALOG);
1743     sptr<SceneSession> sceneSession2 = sptr<SceneSession>::MakeSptr(info2, nullptr);
1744     ASSERT_NE(nullptr, sceneSession2);
1745 
1746     ssm_->sceneSessionMap_.insert({sceneSession1->GetPersistentId(), sceneSession1});
1747     ssm_->sceneSessionMap_.insert({sceneSession2->GetPersistentId(), sceneSession2});
1748     std::string bundleName;
1749     auto result = ssm_->GetCurrentPiPWindowInfo(bundleName);
1750     ASSERT_EQ(result, WMError::WM_OK);
1751     ASSERT_EQ(info1.abilityName_, bundleName);
1752 }
1753 
1754 /**
1755  * @tc.name: IsWindowRectAutoSave
1756  * @tc.desc: IsWindowRectAutoSave
1757  * @tc.type: FUNC
1758  */
1759 HWTEST_F(SceneSessionManagerTest, IsWindowRectAutoSave, Function | SmallTest | Level3)
1760 {
1761     std::string key = "com.example.recposentryEntryAbilityabc";
1762     bool enabled = false;
1763     auto result = ssm_->IsWindowRectAutoSave(key, enabled);
1764     ASSERT_EQ(result, WMError::WM_OK);
1765 }
1766 
1767 /**
1768  * @tc.name: SetIsWindowRectAutoSave
1769  * @tc.desc: SetIsWindowRectAutoSave
1770  * @tc.type: FUNC
1771  */
1772 HWTEST_F(SceneSessionManagerTest, SetIsWindowRectAutoSave, Function | SmallTest | Level3)
1773 {
1774     std::string key = "com.example.recposentryEntryAbility";
1775     bool enabled = true;
1776     ssm_->SetIsWindowRectAutoSave(key, enabled);
1777     ASSERT_EQ(ssm_->isWindowRectAutoSaveMap_.at(key), true);
1778 }
1779 
1780 /**
1781  * @tc.name: GetDisplayIdByWindowId
1782  * @tc.desc: test function : GetDisplayIdByWindowId
1783  * @tc.type: FUNC
1784  */
1785 HWTEST_F(SceneSessionManagerTest, GetDisplayIdByWindowId, Function | SmallTest | Level3)
1786 {
1787     SessionInfo info;
1788     info.abilityName_ = "test";
1789     info.bundleName_ = "test";
1790     sptr<SceneSession> sceneSession1 = new (std::nothrow) SceneSession(info, nullptr);
1791     ASSERT_NE(nullptr, sceneSession1);
1792     ssm_->sceneSessionMap_.insert({sceneSession1->GetPersistentId(), sceneSession1});
1793     sptr<SceneSession> sceneSession2 = new (std::nothrow) SceneSession(info, nullptr);
1794     ASSERT_NE(nullptr, sceneSession2);
1795     ssm_->sceneSessionMap_.insert({sceneSession2->GetPersistentId(), sceneSession2});
1796 
1797     sptr<WindowSessionProperty> property = new WindowSessionProperty();
1798     DisplayId displayId = 0;
1799     property->SetDisplayId(displayId);
1800     sceneSession1->SetSessionProperty(property);
1801 
1802     const std::vector<uint64_t> windowIds = {1001, sceneSession1->GetPersistentId(), sceneSession2->GetPersistentId()};
1803     std::unordered_map<uint64_t, DisplayId> windowDisplayIdMap;
1804     ASSERT_EQ(ssm_->GetDisplayIdByWindowId(windowIds, windowDisplayIdMap), WMError::WM_OK);
1805 }
1806 
1807 /**
1808  * @tc.name: IsPcWindow
1809  * @tc.desc: IsPcWindow
1810  * @tc.type: FUNC
1811  */
1812 HWTEST_F(SceneSessionManagerTest, IsPcWindow, Function | SmallTest | Level3)
1813 {
1814     bool isPcWindow = false;
1815     auto result = ssm_->IsPcWindow(isPcWindow);
1816     ASSERT_EQ(result, WMError::WM_OK);
1817 }
1818 
1819 /**
1820  * @tc.name: IsPcOrPadFreeMultiWindowMode
1821  * @tc.desc: IsPcOrPadFreeMultiWindowMode
1822  * @tc.type: FUNC
1823  */
1824 HWTEST_F(SceneSessionManagerTest, IsPcOrPadFreeMultiWindowMode, Function | SmallTest | Level3)
1825 {
1826     bool isPcOrPadFreeMultiWindowMode = false;
1827     auto result = ssm_->IsPcOrPadFreeMultiWindowMode(isPcOrPadFreeMultiWindowMode);
1828     ASSERT_EQ(result, WMError::WM_OK);
1829 }
1830 
1831 /**
1832  * @tc.name: SetGlobalDragResizeType
1833  * @tc.desc: test function : SetGlobalDragResizeType
1834  * @tc.type: FUNC
1835  */
1836 HWTEST_F(SceneSessionManagerTest, SetGlobalDragResizeType, Function | SmallTest | Level3)
1837 {
1838     DragResizeType dragResizeType = DragResizeType::RESIZE_EACH_FRAME;
1839     ASSERT_EQ(ssm_->SetGlobalDragResizeType(dragResizeType), WMError::WM_OK);
1840 }
1841 
1842 /**
1843  * @tc.name: GetGlobalDragResizeType
1844  * @tc.desc: test function : GetGlobalDragResizeType
1845  * @tc.type: FUNC
1846  */
1847 HWTEST_F(SceneSessionManagerTest, GetGlobalDragResizeType, Function | SmallTest | Level3)
1848 {
1849     DragResizeType dragResizeType = DragResizeType::RESIZE_TYPE_UNDEFINED;
1850     ASSERT_EQ(ssm_->GetGlobalDragResizeType(dragResizeType), WMError::WM_OK);
1851 }
1852 
1853 /**
1854  * @tc.name: SetAppDragResizeType
1855  * @tc.desc: test function : SetAppDragResizeType
1856  * @tc.type: FUNC
1857  */
1858 HWTEST_F(SceneSessionManagerTest, SetAppDragResizeType, Function | SmallTest | Level3)
1859 {
1860     SessionInfo info;
1861     info.abilityName_ = "test1";
1862     info.bundleName_ = "test1";
1863     info.windowType_ = static_cast<uint32_t>(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
1864     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1865     ASSERT_NE(nullptr, sceneSession);
1866     ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
1867     DragResizeType dragResizeType = DragResizeType::RESIZE_EACH_FRAME;
1868     ASSERT_EQ(ssm_->SetAppDragResizeType(info.bundleName_, dragResizeType), WMError::WM_OK);
1869 }
1870 
1871 /**
1872  * @tc.name: GetAppDragResizeType
1873  * @tc.desc: test function : GetAppDragResizeType
1874  * @tc.type: FUNC
1875  */
1876 HWTEST_F(SceneSessionManagerTest, GetAppDragResizeType, Function | SmallTest | Level3)
1877 {
1878     SessionInfo info;
1879     info.abilityName_ = "test1";
1880     info.bundleName_ = "test1";
1881     info.windowType_ = static_cast<uint32_t>(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
1882     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1883     ASSERT_NE(nullptr, sceneSession);
1884     ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
1885     DragResizeType dragResizeType = DragResizeType::RESIZE_TYPE_UNDEFINED;
1886     ASSERT_EQ(ssm_->GetAppDragResizeType(info.bundleName_, dragResizeType), WMError::WM_OK);
1887 }
1888 
1889 /**
1890  * @tc.name: GetRootMainWindowId
1891  * @tc.desc: SceneSesionManager GetRootMainWindowId
1892  * @tc.type: FUNC
1893  */
1894 HWTEST_F(SceneSessionManagerTest, GetRootMainWindowId, Function | SmallTest | Level3)
1895 {
1896     SessionInfo info1;
1897     info1.abilityName_ = "test1";
1898     info1.bundleName_ = "test1";
1899     info1.windowType_ = static_cast<uint32_t>(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
1900     sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(info1, nullptr);
1901     ASSERT_NE(nullptr, sceneSession1);
1902     SessionInfo info2;
1903     info2.abilityName_ = "test2";
1904     info2.bundleName_ = "test2";
1905     info2.windowType_ = static_cast<uint32_t>(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
1906     sptr<SceneSession> sceneSession2 = sptr<SceneSession>::MakeSptr(info2, nullptr);
1907     ASSERT_NE(nullptr, sceneSession2);
1908     sceneSession2->SetParentSession(sceneSession1);
1909 
1910     ssm_->sceneSessionMap_.insert({sceneSession1->GetPersistentId(), sceneSession1});
1911     ssm_->sceneSessionMap_.insert({sceneSession2->GetPersistentId(), sceneSession2});
1912     int32_t hostWindowId = -1;
1913     auto result = ssm_->GetRootMainWindowId(sceneSession2->GetPersistentId(), hostWindowId);
1914     ASSERT_EQ(result, WMError::WM_OK);
1915     ASSERT_EQ(hostWindowId, sceneSession1->GetPersistentId());
1916 }
1917 }
1918 } // namespace Rosen
1919 } // namespace OHOS