• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <gtest/gtest.h>
17 #include <regex>
18 #include <bundle_mgr_interface.h>
19 #include <bundlemgr/launcher_service.h>
20 #include "interfaces/include/ws_common.h"
21 #include "iremote_object_mocker.h"
22 #include "screen_fold_data.h"
23 #include "screen_session_manager_client/include/screen_session_manager_client.h"
24 #include "session_manager/include/scene_session_manager.h"
25 #include "session_info.h"
26 #include "session/host/include/scene_session.h"
27 #include "session/host/include/main_session.h"
28 #include "window_manager_agent.h"
29 #include "session_manager.h"
30 #include "zidl/window_manager_agent_interface.h"
31 #include "mock/mock_session_stage.h"
32 #include "mock/mock_window_event_channel.h"
33 #include "application_info.h"
34 #include "context.h"
35 
36 using namespace testing;
37 using namespace testing::ext;
38 
39 namespace OHOS {
40 namespace Rosen {
41 namespace {
42 const std::string EMPTY_DEVICE_ID = "";
43 }
44 class SceneSessionManagerTest : public testing::Test {
45 public:
46     static void SetUpTestCase();
47     static void TearDownTestCase();
48     void SetUp() override;
49     void TearDown() override;
50     static void SetVisibleForAccessibility(sptr<SceneSession>& sceneSession);
51     int32_t GetTaskCount(sptr<SceneSession>& session);
52     static bool gestureNavigationEnabled_;
53     static ProcessGestureNavigationEnabledChangeFunc callbackFunc_;
54     static sptr<SceneSessionManager> ssm_;
55 private:
56     static constexpr uint32_t WAIT_SYNC_IN_NS = 200000;
57     static constexpr uint32_t WAIT_SYNC_FOR_SNAPSHOT_SKIP_IN_NS = 500000;
58     static constexpr uint32_t WAIT_SYNC_FOR_TEST_END_IN_NS = 1000000;
59 };
60 
61 sptr<SceneSessionManager> SceneSessionManagerTest::ssm_ = nullptr;
62 
63 bool SceneSessionManagerTest::gestureNavigationEnabled_ = true;
64 ProcessGestureNavigationEnabledChangeFunc SceneSessionManagerTest::callbackFunc_ = [](bool enable,
__anon05d7ba440202(bool enable, const std::string& bundleName, GestureBackType type) 65     const std::string& bundleName, GestureBackType type) {
66     gestureNavigationEnabled_ = enable;
67 };
68 
WindowChangedFuncTest(int32_t persistentId,WindowUpdateType type)69 void WindowChangedFuncTest(int32_t persistentId, WindowUpdateType type)
70 {
71 }
72 
ProcessStatusBarEnabledChangeFuncTest(bool enable)73 void ProcessStatusBarEnabledChangeFuncTest(bool enable)
74 {
75 }
76 
DumpRootSceneElementInfoFuncTest(const std::vector<std::string> & params,std::vector<std::string> & infos)77 void DumpRootSceneElementInfoFuncTest(const std::vector<std::string>& params, std::vector<std::string>& infos)
78 {
79 }
80 
SetUpTestCase()81 void SceneSessionManagerTest::SetUpTestCase()
82 {
83     ssm_ = &SceneSessionManager::GetInstance();
84 }
85 
TearDownTestCase()86 void SceneSessionManagerTest::TearDownTestCase()
87 {
88     ssm_ = nullptr;
89 }
90 
SetUp()91 void SceneSessionManagerTest::SetUp()
92 {
93     ssm_->sceneSessionMap_.clear();
94 }
95 
TearDown()96 void SceneSessionManagerTest::TearDown()
97 {
98     usleep(WAIT_SYNC_IN_NS);
99     ssm_->sceneSessionMap_.clear();
100 }
101 
SetVisibleForAccessibility(sptr<SceneSession> & sceneSession)102 void SceneSessionManagerTest::SetVisibleForAccessibility(sptr<SceneSession>& sceneSession)
103 {
104     sceneSession->SetTouchable(true);
105     sceneSession->forceTouchable_ = true;
106     sceneSession->systemTouchable_ = true;
107     sceneSession->state_ = SessionState::STATE_FOREGROUND;
108     sceneSession->foregroundInteractiveStatus_.store(true);
109     sceneSession->isVisible_ = true;
110 }
111 
GetTaskCount(sptr<SceneSession> & session)112 int32_t SceneSessionManagerTest::GetTaskCount(sptr<SceneSession>& session)
113 {
114     std::string dumpInfo = session->handler_->GetEventRunner()->GetEventQueue()->DumpCurrentQueueSize();
115     std::regex pattern("\\d+");
116     std::smatch matches;
117     int32_t taskNum = 0;
118     while (std::regex_search(dumpInfo, matches, pattern)) {
119         taskNum += std::stoi(matches.str());
120         dumpInfo = matches.suffix();
121     }
122     return taskNum;
123 }
124 
125 namespace {
126 /**
127  * @tc.name: SetBrightness
128  * @tc.desc: ScreenSesionManager set session brightness
129  * @tc.type: FUNC
130  */
131 HWTEST_F(SceneSessionManagerTest, SetBrightness, Function | SmallTest | Level3)
132 {
133     SessionInfo info;
134     info.abilityName_ = "SetBrightness";
135     info.bundleName_ = "SetBrightness1";
136     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
137     ASSERT_NE(nullptr, sceneSession);
138     float brightness = 0.5;
139     WSError result = ssm_->SetBrightness(sceneSession, brightness);
140     ASSERT_EQ(result, WSError::WS_OK);
141     ASSERT_NE(brightness, ssm_->GetDisplayBrightness());
142 }
143 
144 /**
145  * @tc.name: GerPrivacyBundleListTwoWindow
146  * @tc.desc: get privacy bundle list when two windows exist.
147  * @tc.type: FUNC
148  */
149 HWTEST_F(SceneSessionManagerTest, GerPrivacyBundleListTwoWindow, Function | SmallTest | Level3)
150 {
151     SessionInfo sessionInfoFirst;
152     sessionInfoFirst.bundleName_ = "privacy.test.first";
153     sessionInfoFirst.abilityName_ = "privacyAbilityName";
154     sptr<SceneSession> sceneSessionFirst = ssm_->CreateSceneSession(sessionInfoFirst, nullptr);
155     ASSERT_NE(sceneSessionFirst, nullptr);
156     ssm_->sceneSessionMap_.insert({sceneSessionFirst->GetPersistentId(), sceneSessionFirst});
157 
158     SessionInfo sessionInfoSecond;
159     sessionInfoSecond.bundleName_ = "privacy.test.second";
160     sessionInfoSecond.abilityName_ = "privacyAbilityName";
161     sptr<SceneSession> sceneSessionSecond = ssm_->CreateSceneSession(sessionInfoSecond, nullptr);
162     ASSERT_NE(sceneSessionSecond, nullptr);
163     ssm_->sceneSessionMap_.insert({sceneSessionSecond->GetPersistentId(), sceneSessionSecond});
164 
165     sceneSessionFirst->GetSessionProperty()->displayId_ = 0;
166     sceneSessionFirst->GetSessionProperty()->isPrivacyMode_ = true;
167     sceneSessionFirst->state_ = SessionState::STATE_FOREGROUND;
168 
169     sceneSessionSecond->GetSessionProperty()->displayId_ = 0;
170     sceneSessionSecond->GetSessionProperty()->isPrivacyMode_ = true;
171     sceneSessionSecond->state_ = SessionState::STATE_FOREGROUND;
172 
173     std::unordered_set<std::string> privacyBundleList;
174     ssm_->GetSceneSessionPrivacyModeBundles(0, privacyBundleList);
175     EXPECT_EQ(privacyBundleList.size(), 2);
176 
177     sceneSessionSecond->GetSessionProperty()->displayId_ = 1;
178     privacyBundleList.clear();
179     ssm_->GetSceneSessionPrivacyModeBundles(0, privacyBundleList);
180     EXPECT_EQ(privacyBundleList.size(), 1);
181 
182     privacyBundleList.clear();
183     ssm_->GetSceneSessionPrivacyModeBundles(1, privacyBundleList);
184     EXPECT_EQ(privacyBundleList.size(), 1);
185 }
186 
187 /**
188  * @tc.name: SetWindowFlags01
189  * @tc.desc: SceneSesionManager set window flags
190  * @tc.type: FUNC
191  */
192 HWTEST_F(SceneSessionManagerTest, SetWindowFlags01, Function | SmallTest | Level3)
193 {
194     SessionInfo info;
195     info.bundleName_ = "bundleName";
196     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
197     uint32_t flags = static_cast<uint32_t>(WindowFlag::WINDOW_FLAG_SHOW_WHEN_LOCKED);
198     property->SetWindowFlags(flags);
199     sptr<SceneSession> sceneSession = nullptr;
200     WSError result01 = ssm_->SetWindowFlags(sceneSession, property);
201     EXPECT_EQ(result01, WSError::WS_ERROR_NULLPTR);
202 }
203 
204 /**
205  * @tc.name: SetWindowFlags02
206  * @tc.desc: SceneSesionManager set window flags
207  * @tc.type: FUNC
208  */
209 HWTEST_F(SceneSessionManagerTest, SetWindowFlags02, Function | SmallTest | Level3)
210 {
211     SessionInfo info;
212     info.bundleName_ = "bundleName";
213     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
214     uint32_t flags = static_cast<uint32_t>(WindowFlag::WINDOW_FLAG_SHOW_WHEN_LOCKED);
215     property->SetWindowFlags(flags);
216     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
217     WSError result02 = ssm_->SetWindowFlags(sceneSession, property);
218     EXPECT_EQ(result02, WSError::WS_ERROR_NOT_SYSTEM_APP);
219 }
220 
221 /**
222  * @tc.name: SetWindowFlags03
223  * @tc.desc: SceneSesionManager set window flags
224  * @tc.type: FUNC
225  */
226 HWTEST_F(SceneSessionManagerTest, SetWindowFlags03, Function | SmallTest | Level3)
227 {
228     SessionInfo info;
229     info.bundleName_ = "bundleName";
230     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
231     uint32_t flags = static_cast<uint32_t>(WindowFlag::WINDOW_FLAG_SHOW_WHEN_LOCKED);
232     property->SetWindowFlags(flags);
233     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
234     property->SetSystemCalling(true);
235     WSError result03 = ssm_->SetWindowFlags(sceneSession, property);
236     ASSERT_EQ(result03, WSError::WS_OK);
237 }
238 
239 /**
240  * @tc.name: NotifyWaterMarkFlagChangedResult
241  * @tc.desc: SceneSesionManager notify water mark flag changed result
242  * @tc.type: FUNC
243  */
244 HWTEST_F(SceneSessionManagerTest, NotifyWaterMarkFlagChangedResult, Function | SmallTest | Level3)
245 {
246     int32_t persistentId = 10086;
247     ssm_->NotifyCompleteFirstFrameDrawing(persistentId);
248     bool hasWaterMark = true;
249     AppExecFwk::AbilityInfo abilityInfo;
250     WSError result01 = ssm_->NotifyWaterMarkFlagChangedResult(hasWaterMark);
251     EXPECT_EQ(result01, WSError::WS_OK);
252     ssm_->CheckAndNotifyWaterMarkChangedResult();
253     ssm_->ProcessPreload(abilityInfo);
254 }
255 
256 /**
257  * @tc.name: IsValidSessionIds
258  * @tc.desc: SceneSesionManager is valid session id
259  * @tc.type: FUNC
260  */
261 HWTEST_F(SceneSessionManagerTest, IsValidSessionIds, Function | SmallTest | Level3)
262 {
263     std::vector<int32_t> sessionIds = {0, 1, 2, 3, 4, 5, 24, 10086};
264     std::vector<bool> results = {};
265     WSError result = ssm_->IsValidSessionIds(sessionIds, results);
266     EXPECT_EQ(result, WSError::WS_OK);
267 }
268 
269 /**
270  * @tc.name: UnRegisterSessionListener
271  * @tc.desc: SceneSesionManager un register session listener
272  * @tc.type: FUNC
273  */
274 HWTEST_F(SceneSessionManagerTest, UnRegisterSessionListener, Function | SmallTest | Level3)
275 {
276     OHOS::MessageParcel data;
277     sptr<ISessionListener> listener = iface_cast<ISessionListener>(data.ReadRemoteObject());
278     WSError result = ssm_->UnRegisterSessionListener(listener);
279     EXPECT_EQ(result, WSError::WS_ERROR_INVALID_PERMISSION);
280 }
281 
282 /**
283  * @tc.name: GetSessionInfos01
284  * @tc.desc: SceneSesionManager get session infos
285  * @tc.type: FUNC
286  */
287 HWTEST_F(SceneSessionManagerTest, GetSessionInfos01, Function | SmallTest | Level3)
288 {
289     std::string deviceId = "1245";
290     int32_t numMax = 1024;
291     AAFwk::MissionInfo infoFrist;
292     infoFrist.label = "fristBundleName";
293     AAFwk::MissionInfo infoSecond;
294     infoSecond.label = "secondBundleName";
295     std::vector<SessionInfoBean> sessionInfos = {infoFrist, infoSecond};
296     WSError result = ssm_->GetSessionInfos(deviceId, numMax, sessionInfos);
297     EXPECT_EQ(result, WSError::WS_ERROR_INVALID_PERMISSION);
298 }
299 
300 /**
301  * @tc.name: GetSessionInfos02
302  * @tc.desc: SceneSesionManager get session infos
303  * @tc.type: FUNC
304  */
305 HWTEST_F(SceneSessionManagerTest, GetSessionInfos02, Function | SmallTest | Level3)
306 {
307     std::string deviceId = "1245";
308     AAFwk::MissionInfo infoFrist;
309     infoFrist.label = "fristBundleName";
310     AAFwk::MissionInfo infoSecond;
311     infoSecond.label = "secondBundleName";
312     std::vector<SessionInfoBean> sessionInfos = {infoFrist, infoSecond};
313     int32_t persistentId = 24;
314     SessionInfoBean sessionInfo;
315     int result01 = ssm_->GetRemoteSessionInfo(deviceId, persistentId, sessionInfo);
316     ASSERT_NE(result01, ERR_OK);
317 }
318 
319 /**
320  * @tc.name: GetUnreliableWindowInfo
321  * @tc.desc: SceneSesionManager get unreliable window info
322  * @tc.type: FUNC
323 */
324 HWTEST_F(SceneSessionManagerTest, GetUnreliableWindowInfo, Function | SmallTest | Level3)
325 {
326     int32_t windowId = 0;
327     std::vector<sptr<UnreliableWindowInfo>> infos;
328     WMError result = ssm_->GetUnreliableWindowInfo(windowId, infos);
329     EXPECT_EQ(WMError::WM_OK, result);
330 }
331 
332 /**
333  * @tc.name: GetMainWindowStatesByPid
334  * @tc.desc: SceneSesionManager get main window states
335  * @tc.type: FUNC
336  */
337 HWTEST_F(SceneSessionManagerTest, GetMainWindowStatesByPid, Function | SmallTest | Level3)
338 {
339     int32_t pid = 100;
340     std::vector<MainWindowState> windowStates;
341     WSError result = ssm_->GetMainWindowStatesByPid(pid, windowStates);
342     EXPECT_EQ(result, WSError::WS_OK);
343 }
344 
345 /**
346  * @tc.name: CheckIsRemote01
347  * @tc.desc: DeviceId is empty
348  * @tc.type: FUNC
349  */
350 HWTEST_F(SceneSessionManagerTest, CheckIsRemote01, Function | SmallTest | Level3)
351 {
352     std::string deviceId;
353     EXPECT_EQ(deviceId.empty(), true);
354     bool result = ssm_->CheckIsRemote(deviceId);
355     EXPECT_FALSE(result);
356 }
357 
358 /**
359  * @tc.name: CheckIsRemote02
360  * @tc.desc: SceneSesionManager check is remote
361  * @tc.type: FUNC
362  */
363 HWTEST_F(SceneSessionManagerTest, CheckIsRemote02, Function | SmallTest | Level3)
364 {
365     std::string deviceId = "abc";
366     EXPECT_EQ(deviceId.empty(), false);
367     bool result = ssm_->CheckIsRemote(deviceId);
368     EXPECT_FALSE(result);
369 }
370 
371 /**
372  * @tc.name: AnonymizeDeviceId01
373  * @tc.desc: SceneSesionManager anonymize deviceId
374  * @tc.type: FUNC
375  */
376 HWTEST_F(SceneSessionManagerTest, AnonymizeDeviceId01, Function | SmallTest | Level3)
377 {
378     std::string deviceId;
379     std::string result(ssm_->AnonymizeDeviceId(deviceId));
380     EXPECT_EQ(result, EMPTY_DEVICE_ID);
381 }
382 
383 /**
384  * @tc.name: AnonymizeDeviceId02
385  * @tc.desc: SceneSesionManager anonymize deviceId
386  * @tc.type: FUNC
387  */
388 HWTEST_F(SceneSessionManagerTest, AnonymizeDeviceId02, Function | SmallTest | Level3)
389 {
390     std::string deviceId;
391     deviceId.assign("100964857");
392     std::string result01 = "100964******";
393     ASSERT_EQ(ssm_->AnonymizeDeviceId(deviceId), result01);
394 }
395 
396 /**
397  * @tc.name: TerminateSessionNew01
398  * @tc.desc: SceneSesionManager terminate session new
399  * @tc.type: FUNC
400  */
401 HWTEST_F(SceneSessionManagerTest, TerminateSessionNew01, Function | SmallTest | Level3)
402 {
403     sptr<AAFwk::SessionInfo> info = nullptr;
404     bool needStartCaller = true;
405     WSError result01 = ssm_->TerminateSessionNew(info, needStartCaller);
406     EXPECT_EQ(WSError::WS_ERROR_INVALID_PARAM, result01);
407 }
408 
409 /**
410  * @tc.name: TerminateSessionNew02
411  * @tc.desc: SceneSesionManager terminate session new
412  * @tc.type: FUNC
413  */
414 HWTEST_F(SceneSessionManagerTest, TerminateSessionNew, Function | SmallTest | Level3)
415 {
416     bool needStartCaller = true;
417     sptr<AAFwk::SessionInfo> info = sptr<AAFwk::SessionInfo>::MakeSptr();
418     WSError result02 = ssm_->TerminateSessionNew(info, needStartCaller);
419     EXPECT_EQ(WSError::WS_ERROR_INVALID_PARAM, result02);
420 }
421 
422 /**
423  * @tc.name: RegisterSessionListener01
424  * @tc.desc: SceneSesionManager register session listener
425  * @tc.type: FUNC
426  */
427 HWTEST_F(SceneSessionManagerTest, RegisterSessionListener01, Function | SmallTest | Level3)
428 {
429     OHOS::MessageParcel data;
430     sptr<ISessionListener> listener = iface_cast<ISessionListener>(data.ReadRemoteObject());
431     WSError result = ssm_->RegisterSessionListener(listener);
432     EXPECT_EQ(result, WSError::WS_ERROR_INVALID_PERMISSION);
433 }
434 
435 /**
436  * @tc.name: ClearDisplayStatusBarTemporarilyFlags01
437  * @tc.desc: check ClearDisplayStatusBarTemporarilyFlags
438  * @tc.type: FUNC
439  */
440 HWTEST_F(SceneSessionManagerTest, ClearDisplayStatusBarTemporarilyFlags01, Function | SmallTest | Level3)
441 {
442     SessionInfo sessionInfo;
443     sessionInfo.bundleName_ = "ClearDisplayStatusBarTemporarilyFlags";
444     sessionInfo.abilityName_ = "ClearDisplayStatusBarTemporarilyFlags";
445     sessionInfo.windowType_ = static_cast<uint32_t>(WindowType::APP_MAIN_WINDOW_BASE);
446     sptr<SceneSession> sceneSession = ssm_->RequestSceneSession(sessionInfo, nullptr);
447     ASSERT_NE(nullptr, sceneSession);
448 }
449 
450 /**
451  * @tc.name: ClearDisplayStatusBarTemporarilyFlags02
452  * @tc.desc: check ClearDisplayStatusBarTemporarilyFlags
453  * @tc.type: FUNC
454  */
455 HWTEST_F(SceneSessionManagerTest, ClearDisplayStatusBarTemporarilyFlags02, Function | SmallTest | Level3)
456 {
457     SessionInfo sessionInfo;
458     sessionInfo.bundleName_ = "ClearDisplayStatusBarTemporarilyFlags";
459     sessionInfo.abilityName_ = "ClearDisplayStatusBarTemporarilyFlags";
460     sessionInfo.windowType_ = static_cast<uint32_t>(WindowType::APP_MAIN_WINDOW_BASE);
461     sptr<SceneSession> sceneSession = ssm_->RequestSceneSession(sessionInfo, nullptr);
462     sceneSession->SetIsDisplayStatusBarTemporarily(true);
463     ASSERT_EQ(true, sceneSession->GetIsDisplayStatusBarTemporarily());
464 }
465 
466 /**
467  * @tc.name: ClearDisplayStatusBarTemporarilyFlags03
468  * @tc.desc: check ClearDisplayStatusBarTemporarilyFlags
469  * @tc.type: FUNC
470  */
471 HWTEST_F(SceneSessionManagerTest, ClearDisplayStatusBarTemporarilyFlags03, Function | SmallTest | Level3)
472 {
473     SessionInfo sessionInfo;
474     sessionInfo.bundleName_ = "ClearDisplayStatusBarTemporarilyFlags";
475     sessionInfo.abilityName_ = "ClearDisplayStatusBarTemporarilyFlags";
476     sessionInfo.windowType_ = static_cast<uint32_t>(WindowType::APP_MAIN_WINDOW_BASE);
477     sptr<SceneSession> sceneSession = ssm_->RequestSceneSession(sessionInfo, nullptr);
478     sceneSession->SetIsDisplayStatusBarTemporarily(true);
479     ssm_->ClearDisplayStatusBarTemporarilyFlags();
480     ASSERT_EQ(true, sceneSession->GetIsDisplayStatusBarTemporarily());
481 }
482 
483 /**
484  * @tc.name: RequestSceneSessionByCall01
485  * @tc.desc: SceneSesionManager request scene session by call
486  * @tc.type: FUNC
487  */
488 HWTEST_F(SceneSessionManagerTest, RequestSceneSessionByCall01, Function | SmallTest | Level3)
489 {
490     sptr<SceneSession> sceneSession = nullptr;
491     WSError result01 = ssm_->RequestSceneSessionByCall(nullptr);
492     EXPECT_EQ(result01, WSError::WS_OK);
493 }
494 
495 /**
496  * @tc.name: RequestSceneSessionByCall02
497  * @tc.desc: SceneSesionManager request scene session by call
498  * @tc.type: FUNC
499  */
500 HWTEST_F(SceneSessionManagerTest, RequestSceneSessionByCall02, Function | SmallTest | Level3)
501 {
502     sptr<SceneSession> sceneSession = nullptr;
503     SessionInfo info;
504     info.bundleName_ = "bundleName";
505     sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
506     WSError result02 = ssm_->RequestSceneSessionByCall(sceneSession);
507     ASSERT_EQ(result02, WSError::WS_OK);
508 }
509 
510 /**
511  * @tc.name: StartAbilityBySpecified
512  * @tc.desc: SceneSesionManager start ability by specified
513  * @tc.type: FUNC
514  */
515 HWTEST_F(SceneSessionManagerTest, StartAbilityBySpecified, Function | SmallTest | Level3)
516 {
517     int ret = 0;
518     SessionInfo info;
519     ssm_->StartAbilityBySpecified(info);
520 
521     std::shared_ptr<AAFwk::Want> want = std::make_shared<AAFwk::Want>();
522     AAFwk::WantParams wantParams;
523     want->SetParams(wantParams);
524     info.want = want;
525     ssm_->StartAbilityBySpecified(info);
526     ASSERT_EQ(ret, 0);
527 }
528 
529 /**
530  * @tc.name: FindMainWindowWithToken01
531  * @tc.desc: SceneSesionManager find main window with token
532  * @tc.type: FUNC
533  */
534 HWTEST_F(SceneSessionManagerTest, FindMainWindowWithToken01, Function | SmallTest | Level3)
535 {
536     sptr<IRemoteObject> targetToken = nullptr;
537     sptr<SceneSession> result = ssm_->FindMainWindowWithToken(targetToken);
538     EXPECT_EQ(result, nullptr);
539 
540     uint64_t persistentId = 1423;
541     WSError result01 = ssm_->BindDialogSessionTarget(persistentId, targetToken);
542     EXPECT_EQ(result01, WSError::WS_ERROR_NULLPTR);
543 }
544 
545 /**
546  * @tc.name: FindMainWindowWithToken02
547  * @tc.desc: SceneSesionManager find main window with token
548  * @tc.type: FUNC
549  */
550 HWTEST_F(SceneSessionManagerTest, FindMainWindowWithToken02, Function | SmallTest | Level3)
551 {
552     SessionInfo info;
553     info.abilityName_ = "test1";
554     info.bundleName_ = "test2";
555     info.moduleName_ = "test3";
556     info.persistentId_ = 1;
557     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
558     ASSERT_NE(nullptr, sceneSession);
559     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
560     ASSERT_NE(nullptr, property);
561 }
562 
563 /**
564  * @tc.name: FindMainWindowWithToken03
565  * @tc.desc: SceneSesionManager find main window with token
566  * @tc.type: FUNC
567  */
568 HWTEST_F(SceneSessionManagerTest, FindMainWindowWithToken03, Function | SmallTest | Level3)
569 {
570     sptr<IRemoteObject> targetToken = sptr<IRemoteObjectMocker>::MakeSptr();
571     uint64_t persistentId = 1423;
572     SessionInfo info;
573     info.abilityName_ = "test1";
574     info.bundleName_ = "test2";
575     info.moduleName_ = "test3";
576     info.persistentId_ = 1;
577     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
578     ssm_->sceneSessionMap_.insert({1, sceneSession});
579     persistentId = 1;
580     WSError result02 = ssm_->BindDialogSessionTarget(persistentId, targetToken);
581     EXPECT_EQ(result02, WSError::WS_OK);
582 
583     sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
584     WSError result03 = ssm_->BindDialogSessionTarget(persistentId, targetToken);
585     EXPECT_EQ(result03, WSError::WS_ERROR_INVALID_PARAM);
586 }
587 
588 /**
589  * @tc.name: UpdateParentSessionForDialog001
590  * @tc.desc: SceneSesionManager update parent session for dialog
591  * @tc.type: FUNC
592  */
593 HWTEST_F(SceneSessionManagerTest, UpdateParentSessionForDialog001, Function | SmallTest | Level3)
594 {
595     SessionInfo dialogInfo;
596     dialogInfo.abilityName_ = "DialogWindows";
597     dialogInfo.bundleName_ = "DialogWindows";
598     SessionInfo parentInfo;
599     parentInfo.abilityName_ = "ParentWindows";
600     parentInfo.bundleName_ = "ParentWindows";
601 
602     int32_t persistentId = 1005;
603     sptr<SceneSession> parentSession = sptr<SceneSession>::MakeSptr(parentInfo, nullptr);
604     EXPECT_NE(parentSession, nullptr);
605     ssm_->sceneSessionMap_.insert({ persistentId, parentSession });
606 
607     sptr<SceneSession> dialogSession = sptr<SceneSession>::MakeSptr(dialogInfo, nullptr);
608     EXPECT_NE(dialogSession, nullptr);
609 
610     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
611     property->SetParentPersistentId(persistentId);
612     property->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
613 
614     WSError result = ssm_->UpdateParentSessionForDialog(dialogSession, property);
615     EXPECT_EQ(dialogSession->GetParentPersistentId(), persistentId);
616     EXPECT_NE(dialogSession->GetParentSession(), nullptr);
617     EXPECT_EQ(result, WSError::WS_OK);
618 }
619 
620 /**
621  * @tc.name: MoveSessionsToBackground01
622  * @tc.desc: SceneSesionManager move sessions to background
623  * @tc.type: FUNC
624  */
625 HWTEST_F(SceneSessionManagerTest, MoveSessionsToBackground01, Function | SmallTest | Level3)
626 {
627     int32_t type = CollaboratorType::RESERVE_TYPE;
628     WSError result01 = ssm_->UnregisterIAbilityManagerCollaborator(type);
629     EXPECT_EQ(result01, WSError::WS_ERROR_INVALID_PERMISSION);
630 }
631 
632 /**
633  * @tc.name: MoveSessionsToBackground02
634  * @tc.desc: SceneSesionManager move sessions to background
635  * @tc.type: FUNC
636  */
637 HWTEST_F(SceneSessionManagerTest, MoveSessionsToBackground02, Function | SmallTest | Level3)
638 {
639     std::vector<std::int32_t> sessionIds = {1, 2, 3, 15, 1423};
640     std::vector<int32_t> res = {1, 2, 3, 15, 1423};
641     WSError result03 = ssm_->MoveSessionsToBackground(sessionIds, res);
642     ASSERT_EQ(result03, WSError::WS_ERROR_INVALID_PERMISSION);
643 }
644 
645 /**
646  * @tc.name: ClearAllCollaboratorSessions
647  * @tc.desc: SceneSesionManager clear all collaborator sessions
648  * @tc.type: FUNC
649  */
650 HWTEST_F(SceneSessionManagerTest, ClearAllCollaboratorSessions, Function | SmallTest | Level3)
651 {
652     std::string bundleName = "bundleName";
653     std::string abilityName = "abilityName";
654     int32_t persistentId = 1200;
655     SessionInfo info;
656     info.bundleName_ = bundleName;
657     info.abilityName_ = abilityName;
658     info.persistentId_ = persistentId;
659     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
660     ASSERT_NE(sceneSession, nullptr);
661     sceneSession->SetCollaboratorType(CollaboratorType::DEFAULT_TYPE);
__anon05d7ba440402(const SessionInfo& info, bool needStartCaller, bool isFromBroker) 662     sceneSession->SetTerminateSessionListenerNew([](const SessionInfo& info, bool needStartCaller, bool isFromBroker) {
663         ssm_->sceneSessionMap_.erase(info.persistentId_);
664     });
665     usleep(WAIT_SYNC_IN_NS);
666     ssm_->sceneSessionMap_.insert({persistentId, sceneSession});
667     ssm_->ClearAllCollaboratorSessions();
668     ASSERT_EQ(ssm_->sceneSessionMap_[persistentId], sceneSession);
669 }
670 
671 /**
672  * @tc.name: ClearAllCollaboratorSessions02
673  * @tc.desc: SceneSesionManager clear all collaborator sessions
674  * @tc.type: FUNC
675  */
676 HWTEST_F(SceneSessionManagerTest, ClearAllCollaboratorSessions02, Function | SmallTest | Level3)
677 {
678     std::string bundleName = "bundleName";
679     std::string abilityName = "abilityName";
680     int32_t persistentId = 1201;
681     SessionInfo info;
682     info.bundleName_ = bundleName;
683     info.abilityName_ = abilityName;
684     info.persistentId_ = persistentId;
685     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
686     ASSERT_NE(sceneSession, nullptr);
687     sceneSession->SetCollaboratorType(CollaboratorType::RESERVE_TYPE);
__anon05d7ba440502(const SessionInfo& info, bool needStartCaller, bool isFromBroker) 688     sceneSession->SetTerminateSessionListenerNew([](const SessionInfo& info, bool needStartCaller, bool isFromBroker) {
689         ssm_->sceneSessionMap_.erase(info.persistentId_);
690     });
691     usleep(WAIT_SYNC_IN_NS);
692     ssm_->sceneSessionMap_.insert({persistentId, sceneSession});
693     ssm_->ClearAllCollaboratorSessions();
694     ASSERT_EQ(ssm_->sceneSessionMap_[persistentId], nullptr);
695 }
696 
697 /**
698  * @tc.name: ClearAllCollaboratorSessions03
699  * @tc.desc: SceneSesionManager clear all collaborator sessions
700  * @tc.type: FUNC
701  */
702 HWTEST_F(SceneSessionManagerTest, ClearAllCollaboratorSessions03, Function | SmallTest | Level3)
703 {
704     std::string bundleName = "bundleName";
705     std::string abilityName = "abilityName";
706     int32_t persistentId = 1202;
707     SessionInfo info;
708     info.bundleName_ = bundleName;
709     info.abilityName_ = abilityName;
710     info.persistentId_ = persistentId;
711     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
712     ASSERT_NE(sceneSession, nullptr);
713     sceneSession->SetCollaboratorType(CollaboratorType::OTHERS_TYPE);
__anon05d7ba440602(const SessionInfo& info, bool needStartCaller, bool isFromBroker) 714     sceneSession->SetTerminateSessionListenerNew([](const SessionInfo& info, bool needStartCaller, bool isFromBroker) {
715         ssm_->sceneSessionMap_.erase(info.persistentId_);
716     });
717     usleep(WAIT_SYNC_IN_NS);
718     ssm_->sceneSessionMap_.insert({persistentId, sceneSession});
719     ssm_->ClearAllCollaboratorSessions();
720     ASSERT_EQ(ssm_->sceneSessionMap_[persistentId], nullptr);
721 }
722 
723 /**
724  * @tc.name: MoveSessionsToForeground
725  * @tc.desc: SceneSesionManager move sessions to foreground
726  * @tc.type: FUNC
727  */
728 HWTEST_F(SceneSessionManagerTest, MoveSessionsToForeground, Function | SmallTest | Level3)
729 {
730     std::vector<std::int32_t> sessionIds = {1, 2, 3, 15, 1423};
731     int32_t topSessionId = 1;
732     WSError result = ssm_->MoveSessionsToForeground(sessionIds, topSessionId);
733     ASSERT_EQ(result, WSError::WS_ERROR_INVALID_PERMISSION);
734 }
735 
736 /**
737  * @tc.name: UnlockSession
738  * @tc.desc: SceneSesionManager unlock session
739  * @tc.type: FUNC
740  */
741 HWTEST_F(SceneSessionManagerTest, UnlockSession, Function | SmallTest | Level3)
742 {
743     int32_t sessionId = 1;
744     WSError result = ssm_->UnlockSession(sessionId);
745     EXPECT_EQ(result, WSError::WS_ERROR_INVALID_PERMISSION);
746     result = ssm_->LockSession(sessionId);
747     EXPECT_EQ(result, WSError::WS_ERROR_INVALID_PERMISSION);
748 }
749 
750 /**
751  * @tc.name: GetImmersiveState
752  * @tc.desc: test GetImmersiveState
753  * @tc.type: FUNC
754  */
755 HWTEST_F(SceneSessionManagerTest, GetImmersiveState, Function | SmallTest | Level3)
756 {
757     int ret = 0;
758     ssm_->GetImmersiveState(0u);
759     ASSERT_EQ(ret, 0);
760 }
761 
762 /**
763  * @tc.name: NotifyAINavigationBarShowStatus
764  * @tc.desc: test NotifyAINavigationBarShowStatus
765  * @tc.type: FUNC
766  */
767 HWTEST_F(SceneSessionManagerTest, NotifyAINavigationBarShowStatus, Function | SmallTest | Level3)
768 {
769     bool isVisible = false;
770     WSRect barArea = { 0, 0, 320, 240}; // width: 320, height: 240
771     uint64_t displayId = 0;
772     WSError result = ssm_->NotifyAINavigationBarShowStatus(isVisible, barArea, displayId);
773     ASSERT_EQ(result, WSError::WS_OK);
774 }
775 
776 /**
777  * @tc.name: NotifyWindowExtensionVisibilityChange
778  * @tc.desc: test NotifyWindowExtensionVisibilityChange
779  * @tc.type: FUNC
780  */
781 HWTEST_F(SceneSessionManagerTest, NotifyWindowExtensionVisibilityChange, Function | SmallTest | Level3)
782 {
783     int32_t pid = getprocpid();
784     int32_t uid = getuid();
785     bool isVisible = false;
786     WSError result = ssm_->NotifyWindowExtensionVisibilityChange(pid, uid, isVisible);
787     ASSERT_EQ(result, WSError::WS_OK);
788 
789     pid = INVALID_PID;
790     uid = INVALID_USER_ID;
791     result = ssm_->NotifyWindowExtensionVisibilityChange(pid, uid, isVisible);
792     ASSERT_EQ(result, WSError::WS_ERROR_INVALID_PERMISSION);
793 }
794 
795 /**
796  * @tc.name: UpdateTopmostProperty
797  * @tc.desc: test UpdateTopmostProperty
798  * @tc.type: FUNC
799  */
800 HWTEST_F(SceneSessionManagerTest, UpdateTopmostProperty, Function | SmallTest | Level3)
801 {
802     SessionInfo info;
803     info.abilityName_ = "UpdateTopmostProperty";
804     info.bundleName_ = "UpdateTopmostProperty";
805     sptr<SceneSession> sceneSession = sptr<MainSession>::MakeSptr(info, nullptr);
806     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
807     property->SetTopmost(true);
808     property->SetSystemCalling(true);
809     WMError result = ssm_->UpdateTopmostProperty(property, sceneSession);
810     ASSERT_EQ(WMError::WM_OK, result);
811 }
812 
813 /**
814  * @tc.name: UpdateSessionWindowVisibilityListener
815  * @tc.desc: SceneSesionManager update window visibility listener
816  * @tc.type: FUNC
817  */
818 HWTEST_F(SceneSessionManagerTest, UpdateSessionWindowVisibilityListener, Function | SmallTest | Level3)
819 {
820     int32_t persistentId = 10086;
821     bool haveListener = true;
822     WSError result = ssm_->UpdateSessionWindowVisibilityListener(persistentId, haveListener);
823     ASSERT_EQ(result, WSError::WS_DO_NOTHING);
824 }
825 
826 /**
827  * @tc.name: GetSessionSnapshotPixelMap01
828  * @tc.desc: SceneSesionManager get session snapshot pixelmap
829  * @tc.type: FUNC
830  */
831 HWTEST_F(SceneSessionManagerTest, GetSessionSnapshotPixelMap01, Function | SmallTest | Level3)
832 {
833     SessionInfo info;
834     info.abilityName_ = "GetPixelMap";
835     info.bundleName_ = "GetPixelMap1";
836     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
837     sceneSession->SetSessionState(SessionState::STATE_ACTIVE);
838 
839     int32_t persistentId = 65535;
840     float scaleValue = 0.5f;
841     auto pixelMap = ssm_->GetSessionSnapshotPixelMap(persistentId, scaleValue);
842     EXPECT_EQ(pixelMap, nullptr);
843 }
844 
845 /**
846  * @tc.name: GetSessionSnapshotPixelMap02
847  * @tc.desc: SceneSesionManager get session snapshot pixelmap
848  * @tc.type: FUNC
849  */
850 HWTEST_F(SceneSessionManagerTest, GetSessionSnapshotPixelMap02, Function | SmallTest | Level3)
851 {
852     SessionInfo info;
853     info.abilityName_ = "GetPixelMap";
854     info.bundleName_ = "GetPixelMap1";
855     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
856     sceneSession->SetSessionState(SessionState::STATE_ACTIVE);
857 
858     float scaleValue = 0.5f;
859     int32_t persistentId = 1;
860     auto pixelMap = ssm_->GetSessionSnapshotPixelMap(persistentId, scaleValue);
861     EXPECT_EQ(pixelMap, nullptr);
862 }
863 
864 /**
865  * @tc.name: GetSessionSnapshotById
866  * @tc.desc: test GetSessionSnapshotById
867  * @tc.type: FUNC
868  */
869 HWTEST_F(SceneSessionManagerTest, GetSessionSnapshotById, Function | SmallTest | Level3)
870 {
871     int32_t persistentId = -1;
872     SessionSnapshot snapshot;
873     WMError ret = ssm_->GetSessionSnapshotById(persistentId, snapshot);
874     EXPECT_EQ(WMError::WM_ERROR_INVALID_PARAM, ret);
875 }
876 
877 /**
878  * @tc.name: GetUIContentRemoteObj
879  * @tc.desc: SceneSesionManager GetUIContentRemoteObj
880  * @tc.type: FUNC
881  */
882 HWTEST_F(SceneSessionManagerTest, GetUIContentRemoteObj, Function | SmallTest | Level3)
883 {
884     sptr<IRemoteObject> remoteObj;
885     EXPECT_EQ(ssm_->GetUIContentRemoteObj(65535, remoteObj), WSError::WS_ERROR_INVALID_PERMISSION);
886     SessionInfo info;
887     info.abilityName_ = "GetUIContentRemoteObj";
888     info.bundleName_ = "GetUIContentRemoteObj";
889     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
890     ASSERT_NE(sceneSession, nullptr);
891     ssm_->sceneSessionMap_.insert({65535, sceneSession});
892     EXPECT_EQ(ssm_->GetUIContentRemoteObj(65535, remoteObj), WSError::WS_ERROR_INVALID_PERMISSION);
893 }
894 
895 /**
896  * @tc.name: CalculateCombinedExtWindowFlags
897  * @tc.desc: SceneSesionManager calculate combined extension window flags
898  * @tc.type: FUNC
899  */
900 HWTEST_F(SceneSessionManagerTest, CalculateCombinedExtWindowFlags, Function | SmallTest | Level3)
901 {
902     EXPECT_EQ(ssm_->combinedExtWindowFlags_.bitData, 0);
903     ssm_->UpdateSpecialExtWindowFlags(1234, ExtensionWindowFlags(3), ExtensionWindowFlags(3));
904     ssm_->UpdateSpecialExtWindowFlags(5678, ExtensionWindowFlags(4), ExtensionWindowFlags(4));
905     ssm_->CalculateCombinedExtWindowFlags();
906     EXPECT_EQ(ssm_->combinedExtWindowFlags_.bitData, 7);
907     ssm_->extWindowFlagsMap_.clear();
908 }
909 
910 /**
911  * @tc.name: UpdateSpecialExtWindowFlags
912  * @tc.desc: SceneSesionManager update special extension window flags
913  * @tc.type: FUNC
914  */
915 HWTEST_F(SceneSessionManagerTest, UpdateSpecialExtWindowFlags, Function | SmallTest | Level3)
916 {
917     int32_t persistentId = 12345;
918     EXPECT_TRUE(ssm_->extWindowFlagsMap_.empty());
919     ssm_->UpdateSpecialExtWindowFlags(persistentId, 3, 3);
920     EXPECT_EQ(ssm_->extWindowFlagsMap_.size(), 1);
921     EXPECT_EQ(ssm_->extWindowFlagsMap_.begin()->first, persistentId);
922     EXPECT_EQ(ssm_->extWindowFlagsMap_.begin()->second.bitData, 3);
923     ssm_->UpdateSpecialExtWindowFlags(persistentId, 0, 3);
924     EXPECT_TRUE(ssm_->extWindowFlagsMap_.empty());
925     ssm_->extWindowFlagsMap_.clear();
926 }
927 
928 /**
929  * @tc.name: HideNonSecureFloatingWindows
930  * @tc.desc: SceneSesionManager hide non-secure floating windows
931  * @tc.type: FUNC
932  */
933 HWTEST_F(SceneSessionManagerTest, HideNonSecureFloatingWindows, Function | SmallTest | Level3)
934 {
935     SessionInfo info;
936     info.abilityName_ = "HideNonSecureFloatingWindows";
937     info.bundleName_ = "HideNonSecureFloatingWindows";
938 
939     sptr<SceneSession> sceneSession;
940     sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
941     EXPECT_NE(sceneSession, nullptr);
942     sceneSession->state_ = SessionState::STATE_FOREGROUND;
943     ssm_->sceneSessionMap_.insert(std::make_pair(sceneSession->GetPersistentId(), sceneSession));
944 
945     sptr<SceneSession> floatSession;
946     floatSession = sptr<SceneSession>::MakeSptr(info, nullptr);
947     EXPECT_NE(floatSession, nullptr);
948     floatSession->GetSessionProperty()->SetWindowType(WindowType::WINDOW_TYPE_FLOAT);
949     ssm_->nonSystemFloatSceneSessionMap_.insert(std::make_pair(floatSession->GetPersistentId(), floatSession));
950 
951     EXPECT_FALSE(ssm_->shouldHideNonSecureFloatingWindows_.load());
952     EXPECT_FALSE(floatSession->GetSessionProperty()->GetForceHide());
953     sceneSession->combinedExtWindowFlags_.hideNonSecureWindowsFlag = true;
954     ssm_->HideNonSecureFloatingWindows();
955     EXPECT_TRUE(floatSession->GetSessionProperty()->GetForceHide());
956     sceneSession->combinedExtWindowFlags_.hideNonSecureWindowsFlag = false;
957     ssm_->combinedExtWindowFlags_.hideNonSecureWindowsFlag = true;
958     ssm_->HideNonSecureFloatingWindows();
959     EXPECT_TRUE(floatSession->GetSessionProperty()->GetForceHide());
960 
961     ssm_->combinedExtWindowFlags_.hideNonSecureWindowsFlag = false;
962     ssm_->HideNonSecureFloatingWindows();
963     ssm_->combinedExtWindowFlags_.hideNonSecureWindowsFlag = true;
964     ssm_->systemConfig_.windowUIType_ = WindowUIType::PC_WINDOW;
965     ssm_->HideNonSecureFloatingWindows();
966     EXPECT_FALSE(floatSession->GetSessionProperty()->GetForceHide());
967     ssm_->systemConfig_.windowUIType_ = WindowUIType::INVALID_WINDOW;
968 
969     ssm_->shouldHideNonSecureFloatingWindows_.store(false);
970     ssm_->sceneSessionMap_.clear();
971     ssm_->nonSystemFloatSceneSessionMap_.clear();
972 }
973 
974 /**
975  * @tc.name: HideNonSecureSubWindows
976  * @tc.desc: SceneSesionManager hide non-secure sub windows
977  * @tc.type: FUNC
978  */
979 HWTEST_F(SceneSessionManagerTest, HideNonSecureSubWindows, Function | SmallTest | Level3)
980 {
981     SessionInfo info;
982     info.abilityName_ = "HideNonSecureSubWindows";
983     info.bundleName_ = "HideNonSecureSubWindows";
984 
985     sptr<SceneSession> sceneSession;
986     sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
987     ASSERT_NE(sceneSession, nullptr);
988     sceneSession->state_ = SessionState::STATE_FOREGROUND;
989     sceneSession->combinedExtWindowFlags_.hideNonSecureWindowsFlag = true;
990 
991     sptr<SceneSession> subSession;
992     subSession = sptr<SceneSession>::MakeSptr(info, nullptr);
993     ASSERT_NE(subSession, nullptr);
994     ASSERT_NE(subSession->GetSessionProperty(), nullptr);
995     sceneSession->AddSubSession(subSession);
996     subSession->GetSessionProperty()->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
997     subSession->GetSessionProperty()->SetParentPersistentId(sceneSession->GetPersistentId());
998     ssm_->sceneSessionMap_.insert(std::make_pair(subSession->GetPersistentId(), subSession));
999 
1000     EXPECT_FALSE(subSession->GetSessionProperty()->GetForceHide());
1001     sceneSession->combinedExtWindowFlags_.hideNonSecureWindowsFlag = true;
1002     ssm_->HideNonSecureSubWindows(sceneSession);
1003     EXPECT_TRUE(subSession->GetSessionProperty()->GetForceHide());
1004     ssm_->sceneSessionMap_.clear();
1005 }
1006 
1007 /**
1008  * @tc.name: HandleSecureSessionShouldHide
1009  * @tc.desc: SceneSesionManager handle secure session should hide
1010  * @tc.type: FUNC
1011  */
1012 HWTEST_F(SceneSessionManagerTest, HandleSecureSessionShouldHide, Function | SmallTest | Level3)
1013 {
1014     SessionInfo info;
1015     info.abilityName_ = "HandleSecureSessionShouldHide";
1016     info.bundleName_ = "HandleSecureSessionShouldHide";
1017 
1018     sptr<SceneSession> sceneSession;
1019     sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1020     ASSERT_NE(sceneSession, nullptr);
1021     sceneSession->state_ = SessionState::STATE_FOREGROUND;
1022     sceneSession->combinedExtWindowFlags_.hideNonSecureWindowsFlag = true;
1023 
1024     sptr<SceneSession> subSession;
1025     subSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1026     ASSERT_NE(subSession, nullptr);
1027     ASSERT_NE(subSession->GetSessionProperty(), nullptr);
1028     sceneSession->AddSubSession(subSession);
1029     subSession->GetSessionProperty()->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
1030     subSession->GetSessionProperty()->SetParentPersistentId(sceneSession->GetPersistentId());
1031     ssm_->sceneSessionMap_.insert(std::make_pair(subSession->GetPersistentId(), subSession));
1032 
1033     sptr<SceneSession> floatSession;
1034     floatSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1035     ASSERT_NE(floatSession, nullptr);
1036     ASSERT_NE(floatSession->GetSessionProperty(), nullptr);
1037     floatSession->GetSessionProperty()->SetWindowType(WindowType::WINDOW_TYPE_FLOAT);
1038     ssm_->nonSystemFloatSceneSessionMap_.insert(std::make_pair(floatSession->GetPersistentId(), floatSession));
1039 
1040     sceneSession->SetShouldHideNonSecureWindows(true);
1041     auto ret = ssm_->HandleSecureSessionShouldHide(sceneSession);
1042     EXPECT_EQ(ret, WSError::WS_OK);
1043     EXPECT_TRUE(subSession->GetSessionProperty()->GetForceHide());
1044     EXPECT_TRUE(floatSession->GetSessionProperty()->GetForceHide());
1045     EXPECT_TRUE(ssm_->shouldHideNonSecureFloatingWindows_.load());
1046     ssm_->sceneSessionMap_.clear();
1047     ssm_->nonSystemFloatSceneSessionMap_.clear();
1048 }
1049 
1050 /**
1051  * @tc.name: HandleSpecialExtWindowFlagsChange
1052  * @tc.desc: SceneSesionManager handle special uiextension window flags change
1053  * @tc.type: FUNC
1054  */
1055 HWTEST_F(SceneSessionManagerTest, HandleSpecialExtWindowFlagsChange, Function | SmallTest | Level3)
1056 {
1057     int32_t persistentId = 12345;
1058     EXPECT_TRUE(ssm_->extWindowFlagsMap_.empty());
1059     ssm_->HandleSpecialExtWindowFlagsChange(persistentId, 3, 3);
1060     EXPECT_EQ(ssm_->extWindowFlagsMap_.size(), 1);
1061     EXPECT_EQ(ssm_->extWindowFlagsMap_.begin()->first, persistentId);
1062     EXPECT_EQ(ssm_->extWindowFlagsMap_.begin()->second.bitData, 3);
1063     ssm_->HandleSpecialExtWindowFlagsChange(persistentId, 0, 3);
1064     EXPECT_TRUE(ssm_->extWindowFlagsMap_.empty());
1065     ssm_->extWindowFlagsMap_.clear();
1066 }
1067 
1068 /**
1069  * @tc.name: UpdateModalExtensionRect
1070  * @tc.desc: SceneSesionManager update modal extension rect
1071  * @tc.type: FUNC
1072  */
1073 HWTEST_F(SceneSessionManagerTest, UpdateModalExtensionRect, Function | SmallTest | Level3)
1074 {
1075     SessionInfo info;
1076     info.abilityName_ = "UpdateModalExtensionRect";
1077     info.bundleName_ = "UpdateModalExtensionRect";
1078     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1079     ASSERT_NE(sceneSession, nullptr);
1080     Rect rect { 1, 2, 3, 4 };
1081     ssm_->UpdateModalExtensionRect(nullptr, rect);
1082     EXPECT_FALSE(sceneSession->GetLastModalUIExtensionEventInfo());
1083 }
1084 
1085 /**
1086  * @tc.name: ProcessModalExtensionPointDown
1087  * @tc.desc: SceneSesionManager process modal extension point down
1088  * @tc.type: FUNC
1089  */
1090 HWTEST_F(SceneSessionManagerTest, ProcessModalExtensionPointDown, Function | SmallTest | Level3)
1091 {
1092     SessionInfo info;
1093     info.abilityName_ = "ProcessModalExtensionPointDown";
1094     info.bundleName_ = "ProcessModalExtensionPointDown";
1095     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1096     ASSERT_NE(sceneSession, nullptr);
1097 
1098     ssm_->ProcessModalExtensionPointDown(nullptr, 0, 0);
1099     EXPECT_FALSE(sceneSession->GetLastModalUIExtensionEventInfo());
1100 }
1101 
1102 /**
1103  * @tc.name: GetExtensionWindowIds
1104  * @tc.desc: SceneSesionManager get extension window ids
1105  * @tc.type: FUNC
1106  */
1107 HWTEST_F(SceneSessionManagerTest, GetExtensionWindowIds, Function | SmallTest | Level3)
1108 {
1109     SessionInfo info;
1110     info.abilityName_ = "GetExtensionWindowIds";
1111     info.bundleName_ = "GetExtensionWindowIds";
1112     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1113     ASSERT_NE(sceneSession, nullptr);
1114 
1115     int32_t persistentId = 0;
1116     int32_t parentId = 0;
1117     EXPECT_FALSE(ssm_->GetExtensionWindowIds(nullptr, persistentId, parentId));
1118 }
1119 
1120 /**
1121  * @tc.name: AddOrRemoveSecureSession
1122  * @tc.desc: SceneSesionManager hide non-secure windows by scene session
1123  * @tc.type: FUNC
1124  */
1125 HWTEST_F(SceneSessionManagerTest, AddOrRemoveSecureSession, Function | SmallTest | Level3)
1126 {
1127     SessionInfo info;
1128     info.abilityName_ = "AddOrRemoveSecureSession";
1129     info.bundleName_ = "AddOrRemoveSecureSession1";
1130 
1131     int32_t persistentId = 12345;
1132     auto ret = ssm_->AddOrRemoveSecureSession(persistentId, true);
1133     EXPECT_EQ(ret, WSError::WS_OK);
1134 }
1135 
1136 /**
1137  * @tc.name: UpdateExtWindowFlags
1138  * @tc.desc: SceneSesionManager update uiextension window flags
1139  * @tc.type: FUNC
1140  */
1141 HWTEST_F(SceneSessionManagerTest, UpdateExtWindowFlags, Function | SmallTest | Level3)
1142 {
1143     SessionInfo info;
1144     info.abilityName_ = "UpdateExtWindowFlags";
1145     info.bundleName_ = "UpdateExtWindowFlags";
1146 
1147     auto ret = ssm_->UpdateExtWindowFlags(nullptr, 7, 7);
1148     EXPECT_EQ(ret, WSError::WS_ERROR_INVALID_PERMISSION);
1149 }
1150 
1151 /**
1152  * @tc.name: SetScreenLocked001
1153  * @tc.desc: SetScreenLocked001
1154  * @tc.type: FUNC
1155  */
1156 HWTEST_F(SceneSessionManagerTest, SetScreenLocked001, Function | SmallTest | Level3)
1157 {
1158     sptr<SceneSession> sceneSession = nullptr;
1159     SessionInfo info;
1160     info.bundleName_ = "bundleName";
1161     sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1162     ASSERT_NE(nullptr, sceneSession);
1163     sceneSession->SetEventHandler(ssm_->taskScheduler_->GetEventHandler(), ssm_->eventHandler_);
1164     ssm_->sceneSessionMap_.insert(std::make_pair(sceneSession->GetPersistentId(), sceneSession));
1165     DetectTaskInfo detectTaskInfo;
1166     detectTaskInfo.taskState = DetectTaskState::ATTACH_TASK;
1167     detectTaskInfo.taskWindowMode = WindowMode::WINDOW_MODE_UNDEFINED;
1168     sceneSession->SetDetectTaskInfo(detectTaskInfo);
1169     std::string taskName = "wms:WindowStateDetect" + std::to_string(sceneSession->persistentId_);
__anon05d7ba440702()1170     auto task = [](){};
1171     int64_t delayTime = 3000;
1172     sceneSession->handler_->PostTask(task, taskName, delayTime);
1173     int32_t beforeTaskNum = GetTaskCount(sceneSession);
1174     ssm_->SetScreenLocked(true);
1175     sleep(1);
1176     ASSERT_EQ(beforeTaskNum - 1, GetTaskCount(sceneSession));
1177     ASSERT_EQ(DetectTaskState::NO_TASK, sceneSession->detectTaskInfo_.taskState);
1178     ASSERT_EQ(WindowMode::WINDOW_MODE_UNDEFINED, sceneSession->detectTaskInfo_.taskWindowMode);
1179 }
1180 
1181 /**
1182  * @tc.name: AccessibilityFillEmptySceneSessionListToNotifyList
1183  * @tc.desc: SceneSesionManager fill empty scene session list to accessibilityList;
1184  * @tc.type: FUNC
1185  */
1186 HWTEST_F(SceneSessionManagerTest, AccessibilityFillEmptySceneSessionListToNotifyList, Function | SmallTest | Level3)
1187 {
1188     std::vector<sptr<SceneSession>> sceneSessionList;
1189     std::vector<sptr<AccessibilityWindowInfo>> accessibilityInfo;
1190 
1191     ssm_->FillAccessibilityInfo(sceneSessionList, accessibilityInfo);
1192     EXPECT_EQ(accessibilityInfo.size(), 0);
1193 }
1194 
1195 /**
1196  * @tc.name: AccessibilityFillOneSceneSessionListToNotifyList
1197  * @tc.desc: SceneSesionManager fill one sceneSession to accessibilityList;
1198  * @tc.type: FUNC
1199  */
1200 HWTEST_F(SceneSessionManagerTest, AccessibilityFillOneSceneSessionListToNotifyList, Function | SmallTest | Level3)
1201 {
1202     SessionInfo sessionInfo;
1203     sessionInfo.bundleName_ = "accessibilityNotifyTesterBundleName";
1204     sessionInfo.abilityName_ = "accessibilityNotifyTesterAbilityName";
1205 
1206     sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(sessionInfo, nullptr);
1207     ASSERT_NE(sceneSession, nullptr);
1208     SetVisibleForAccessibility(sceneSession);
1209     ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
1210 
1211     std::vector<sptr<SceneSession>> sceneSessionList;
1212     ssm_->GetAllSceneSessionForAccessibility(sceneSessionList);
1213     ASSERT_EQ(sceneSessionList.size(), 1);
1214 
1215     std::vector<sptr<AccessibilityWindowInfo>> accessibilityInfo;
1216     ssm_->FillAccessibilityInfo(sceneSessionList, accessibilityInfo);
1217     ASSERT_EQ(accessibilityInfo.size(), 1);
1218 }
1219 
1220 /**
1221  * @tc.name: AccessibilityFillTwoSceneSessionListToNotifyList
1222  * @tc.desc: SceneSesionManager fill two sceneSessions to accessibilityList;
1223  * @tc.type: FUNC
1224  */
1225 HWTEST_F(SceneSessionManagerTest, AccessibilityFillTwoSceneSessionListToNotifyList, Function | SmallTest | Level3)
1226 {
1227     SessionInfo sessionInfo;
1228     sessionInfo.bundleName_ = "accessibilityNotifyTesterBundleName";
1229     sessionInfo.abilityName_ = "accessibilityNotifyTesterAbilityName";
1230 
1231     sptr<SceneSession> sceneSessionFirst = ssm_->CreateSceneSession(sessionInfo, nullptr);
1232     ASSERT_NE(sceneSessionFirst, nullptr);
1233     SetVisibleForAccessibility(sceneSessionFirst);
1234 
1235     sptr<SceneSession> sceneSessionSecond = ssm_->CreateSceneSession(sessionInfo, nullptr);
1236     ASSERT_NE(sceneSessionSecond, nullptr);
1237     SetVisibleForAccessibility(sceneSessionSecond);
1238 
1239     ssm_->sceneSessionMap_.insert({sceneSessionFirst->GetPersistentId(), sceneSessionFirst});
1240     ssm_->sceneSessionMap_.insert({sceneSessionSecond->GetPersistentId(), sceneSessionSecond});
1241 
1242     std::vector<sptr<SceneSession>> sceneSessionList;
1243     ssm_->GetAllSceneSessionForAccessibility(sceneSessionList);
1244     ASSERT_EQ(sceneSessionList.size(), 2);
1245 
1246     std::vector<sptr<AccessibilityWindowInfo>> accessibilityInfo;
1247     ssm_->FillAccessibilityInfo(sceneSessionList, accessibilityInfo);
1248     ASSERT_EQ(accessibilityInfo.size(), 2);
1249 }
1250 
1251 /**
1252  * @tc.name: AccessibilityFillEmptyBundleName
1253  * @tc.desc: SceneSesionManager fill empty bundle name to accessibilityInfo;
1254  * @tc.type: FUNC
1255  */
1256 HWTEST_F(SceneSessionManagerTest, AccessibilityFillEmptyBundleName, Function | SmallTest | Level3)
1257 {
1258     SessionInfo sessionInfo;
1259     sessionInfo.abilityName_ = "accessibilityNotifyTesterAbilityName";
1260 
1261     sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(sessionInfo, nullptr);
1262     ASSERT_NE(sceneSession, nullptr);
1263     SetVisibleForAccessibility(sceneSession);
1264     ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
1265 
1266     std::vector<sptr<SceneSession>> sceneSessionList;
1267     ssm_->GetAllSceneSessionForAccessibility(sceneSessionList);
1268     ASSERT_EQ(sceneSessionList.size(), 1);
1269 
1270     std::vector<sptr<AccessibilityWindowInfo>> accessibilityInfo;
1271     ssm_->FillAccessibilityInfo(sceneSessionList, accessibilityInfo);
1272     ASSERT_EQ(accessibilityInfo.size(), 1);
1273 
1274     ASSERT_EQ(accessibilityInfo.at(0)->bundleName_, "");
1275     ASSERT_EQ(sceneSessionList.at(0)->GetSessionInfo().bundleName_, "");
1276     ASSERT_EQ(accessibilityInfo.at(0)->bundleName_, sceneSessionList.at(0)->GetSessionInfo().bundleName_);
1277 }
1278 
1279 /**
1280  * @tc.name: AccessibilityFillBundleName
1281  * @tc.desc: SceneSesionManager fill bundle name to accessibilityInfo;
1282  * @tc.type: FUNC
1283  */
1284 HWTEST_F(SceneSessionManagerTest, AccessibilityFillBundleName, Function | SmallTest | Level3)
1285 {
1286     SessionInfo sessionInfo;
1287     sessionInfo.bundleName_ = "accessibilityNotifyTesterBundleName";
1288     sessionInfo.abilityName_ = "accessibilityNotifyTesterAbilityName";
1289 
1290     sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(sessionInfo, nullptr);
1291     ASSERT_NE(sceneSession, nullptr);
1292     SetVisibleForAccessibility(sceneSession);
1293     ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
1294 
1295     std::vector<sptr<SceneSession>> sceneSessionList;
1296     ssm_->GetAllSceneSessionForAccessibility(sceneSessionList);
1297     ASSERT_EQ(sceneSessionList.size(), 1);
1298 
1299     std::vector<sptr<AccessibilityWindowInfo>> accessibilityInfo;
1300     ssm_->FillAccessibilityInfo(sceneSessionList, accessibilityInfo);
1301     ASSERT_EQ(accessibilityInfo.size(), 1);
1302 
1303     ASSERT_EQ(accessibilityInfo.at(0)->bundleName_, "accessibilityNotifyTesterBundleName");
1304     ASSERT_EQ(sceneSessionList.at(0)->GetSessionInfo().bundleName_, "accessibilityNotifyTesterBundleName");
1305     ASSERT_EQ(accessibilityInfo.at(0)->bundleName_, sceneSessionList.at(0)->GetSessionInfo().bundleName_);
1306 }
1307 
1308 /**
1309  * @tc.name: AccessibilityFillFilterBundleName
1310  * @tc.desc: SceneSesionManager fill filter bundle name to accessibilityInfo;
1311  * @tc.type: FUNC
1312  */
1313 HWTEST_F(SceneSessionManagerTest, AccessibilityFillFilterBundleName, Function | SmallTest | Level3)
1314 {
1315     SessionInfo sessionInfo;
1316     sessionInfo.bundleName_ = "SCBGestureTopBar";
1317     sessionInfo.abilityName_ = "accessibilityNotifyTesterAbilityName";
1318 
1319     sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(sessionInfo, nullptr);
1320     ASSERT_NE(sceneSession, nullptr);
1321     SetVisibleForAccessibility(sceneSession);
1322     ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
1323 
1324     std::vector<sptr<SceneSession>> sceneSessionList;
1325     ssm_->GetAllSceneSessionForAccessibility(sceneSessionList);
1326     ASSERT_EQ(sceneSessionList.size(), 0);
1327 
1328     std::vector<sptr<AccessibilityWindowInfo>> accessibilityInfo;
1329     ssm_->FillAccessibilityInfo(sceneSessionList, accessibilityInfo);
1330     ASSERT_EQ(accessibilityInfo.size(), 0);
1331 }
1332 
1333 /**
1334  * @tc.name: AccessibilityFillEmptyHotAreas
1335  * @tc.desc: SceneSesionManager fill empty hot areas to accessibilityInfo;
1336  * @tc.type: FUNC
1337  */
1338 HWTEST_F(SceneSessionManagerTest, AccessibilityFillEmptyHotAreas, Function | SmallTest | Level3)
1339 {
1340     SessionInfo sessionInfo;
1341     sessionInfo.bundleName_ = "accessibilityNotifyTesterBundleName";
1342     sessionInfo.abilityName_ = "accessibilityNotifyTesterAbilityName";
1343 
1344     sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(sessionInfo, nullptr);
1345     ASSERT_NE(sceneSession, nullptr);
1346     SetVisibleForAccessibility(sceneSession);
1347     ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
1348 
1349     std::vector<sptr<SceneSession>> sceneSessionList;
1350     std::vector<sptr<AccessibilityWindowInfo>> accessibilityInfo;
1351 
1352     ssm_->GetAllSceneSessionForAccessibility(sceneSessionList);
1353     ssm_->FillAccessibilityInfo(sceneSessionList, accessibilityInfo);
1354     ASSERT_EQ(accessibilityInfo.size(), 1);
1355 
1356     ASSERT_EQ(accessibilityInfo.at(0)->touchHotAreas_.size(), sceneSessionList.at(0)->GetTouchHotAreas().size());
1357     ASSERT_EQ(accessibilityInfo.at(0)->touchHotAreas_.size(), 0);
1358 }
1359 
1360 /**
1361  * @tc.name: AccessibilityFillOneHotAreas
1362  * @tc.desc: SceneSesionManager fill one hot areas to accessibilityInfo;
1363  * @tc.type: FUNC
1364  */
1365 HWTEST_F(SceneSessionManagerTest, AccessibilityFillOneHotAreas, Function | SmallTest | Level3)
1366 {
1367     SessionInfo sessionInfo;
1368     sessionInfo.bundleName_ = "accessibilityNotifyTesterBundleName";
1369     sessionInfo.abilityName_ = "accessibilityNotifyTesterAbilityName";
1370 
1371     Rect rect = {100, 200, 100, 200};
1372     std::vector<Rect> hotAreas;
1373     hotAreas.push_back(rect);
1374     sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(sessionInfo, nullptr);
1375     ASSERT_NE(sceneSession, nullptr);
1376     sceneSession->SetTouchHotAreas(hotAreas);
1377     SetVisibleForAccessibility(sceneSession);
1378     ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
1379 
1380     std::vector<sptr<SceneSession>> sceneSessionList;
1381     std::vector<sptr<AccessibilityWindowInfo>> accessibilityInfo;
1382 
1383     ssm_->GetAllSceneSessionForAccessibility(sceneSessionList);
1384     ssm_->FillAccessibilityInfo(sceneSessionList, accessibilityInfo);
1385     ASSERT_EQ(accessibilityInfo.size(), 1);
1386 
1387     ASSERT_EQ(accessibilityInfo.at(0)->touchHotAreas_.size(), sceneSessionList.at(0)->GetTouchHotAreas().size());
1388     ASSERT_EQ(accessibilityInfo.at(0)->touchHotAreas_.size(), 1);
1389 
1390     ASSERT_EQ(rect.posX_, sceneSessionList.at(0)->GetTouchHotAreas().at(0).posX_);
1391     ASSERT_EQ(rect.posY_, sceneSessionList.at(0)->GetTouchHotAreas().at(0).posY_);
1392     ASSERT_EQ(rect.width_, sceneSessionList.at(0)->GetTouchHotAreas().at(0).width_);
1393     ASSERT_EQ(rect.height_, sceneSessionList.at(0)->GetTouchHotAreas().at(0).height_);
1394 
1395     ASSERT_EQ(accessibilityInfo.at(0)->touchHotAreas_.at(0).posX_, rect.posX_);
1396     ASSERT_EQ(accessibilityInfo.at(0)->touchHotAreas_.at(0).posY_, rect.posY_);
1397     ASSERT_EQ(accessibilityInfo.at(0)->touchHotAreas_.at(0).width_, rect.width_);
1398     ASSERT_EQ(accessibilityInfo.at(0)->touchHotAreas_.at(0).height_, rect.height_);
1399 }
1400 
1401 /**
1402  * @tc.name: AccessibilityFillTwoHotAreas
1403  * @tc.desc: SceneSesionManager fill two hot areas to accessibilityInfo;
1404  * @tc.type: FUNC
1405  */
1406 HWTEST_F(SceneSessionManagerTest, AccessibilityFillTwoHotAreas, Function | SmallTest | Level3)
1407 {
1408     SessionInfo sessionInfo;
1409     sessionInfo.bundleName_ = "accessibilityNotifyTesterBundleName";
1410     sessionInfo.abilityName_ = "accessibilityNotifyTesterAbilityName";
1411 
1412     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1413     std::vector<Rect> hotAreas;
1414     Rect rectFitst = {100, 200, 100, 200};
1415     Rect rectSecond = {50, 50, 20, 30};
1416     hotAreas.push_back(rectFitst);
1417     hotAreas.push_back(rectSecond);
1418     sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(sessionInfo, nullptr);
1419     ASSERT_NE(sceneSession, nullptr);
1420     sceneSession->SetTouchHotAreas(hotAreas);
1421     SetVisibleForAccessibility(sceneSession);
1422     ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
1423 
1424     std::vector<sptr<SceneSession>> sceneSessionList;
1425     std::vector<sptr<AccessibilityWindowInfo>> accessibilityInfo;
1426 
1427     ssm_->GetAllSceneSessionForAccessibility(sceneSessionList);
1428     ssm_->FillAccessibilityInfo(sceneSessionList, accessibilityInfo);
1429     ASSERT_EQ(accessibilityInfo.size(), 1);
1430 
1431     ASSERT_EQ(accessibilityInfo.at(0)->touchHotAreas_.size(), sceneSessionList.at(0)->GetTouchHotAreas().size());
1432     ASSERT_EQ(accessibilityInfo.at(0)->touchHotAreas_.size(), 2);
1433 
1434     ASSERT_EQ(accessibilityInfo.at(0)->touchHotAreas_.at(0).posX_, rectFitst.posX_);
1435     ASSERT_EQ(accessibilityInfo.at(0)->touchHotAreas_.at(0).posY_, rectFitst.posY_);
1436     ASSERT_EQ(accessibilityInfo.at(0)->touchHotAreas_.at(0).width_, rectFitst.width_);
1437     ASSERT_EQ(accessibilityInfo.at(0)->touchHotAreas_.at(0).height_, rectFitst.height_);
1438 
1439     ASSERT_EQ(accessibilityInfo.at(0)->touchHotAreas_.at(1).posX_, rectSecond.posX_);
1440     ASSERT_EQ(accessibilityInfo.at(0)->touchHotAreas_.at(1).posY_, rectSecond.posY_);
1441     ASSERT_EQ(accessibilityInfo.at(0)->touchHotAreas_.at(1).width_, rectSecond.width_);
1442     ASSERT_EQ(accessibilityInfo.at(0)->touchHotAreas_.at(1).height_, rectSecond.height_);
1443 }
1444 
1445 /**
1446  * @tc.name: AccessibilityFilterEmptySceneSessionList
1447  * @tc.desc: SceneSesionManager filter empty scene session list;
1448  * @tc.type: FUNC
1449  */
1450 HWTEST_F(SceneSessionManagerTest, AccessibilityFilterEmptySceneSessionList, Function | SmallTest | Level3)
1451 {
1452     std::vector<sptr<SceneSession>> sceneSessionList;
1453 
1454     ssm_->FilterSceneSessionCovered(sceneSessionList);
1455     ASSERT_EQ(sceneSessionList.size(), 0);
1456 }
1457 
1458 /**
1459  * @tc.name: AccessibilityFilterOneWindow
1460  * @tc.desc: SceneSesionManager filter one window;
1461  * @tc.type: FUNC
1462  */
1463 HWTEST_F(SceneSessionManagerTest, AccessibilityFilterOneWindow, Function | SmallTest | Level3)
1464 {
1465     SessionInfo sessionInfo;
1466     sessionInfo.bundleName_ = "accessibilityNotifyTesterBundleName";
1467     sessionInfo.abilityName_ = "accessibilityNotifyTesterAbilityName";
1468 
1469     sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(sessionInfo, nullptr);
1470     ASSERT_NE(sceneSession, nullptr);
1471     sceneSession->SetSessionRect({100, 100, 200, 200});
1472     SetVisibleForAccessibility(sceneSession);
1473     ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
1474 
1475     std::vector<sptr<SceneSession>> sceneSessionList;
1476     std::vector<sptr<AccessibilityWindowInfo>> accessibilityInfo;
1477     ssm_->GetAllSceneSessionForAccessibility(sceneSessionList);
1478     ssm_->FilterSceneSessionCovered(sceneSessionList);
1479     ssm_->FillAccessibilityInfo(sceneSessionList, accessibilityInfo);
1480     ASSERT_EQ(accessibilityInfo.size(), 1);
1481 }
1482 
1483 /**
1484  * @tc.name: AccessibilityFilterTwoWindowNotCovered
1485  * @tc.desc: SceneSesionManager filter two windows that not covered each other;
1486  * @tc.type: FUNC
1487  */
1488 HWTEST_F(SceneSessionManagerTest, AccessibilityFilterTwoWindowNotCovered, Function | SmallTest | Level3)
1489 {
1490     SessionInfo sessionInfo;
1491     sessionInfo.bundleName_ = "accessibilityNotifyTesterBundleName";
1492     sessionInfo.abilityName_ = "accessibilityNotifyTesterAbilityName";
1493 
1494     sptr<SceneSession> sceneSessionFirst = ssm_->CreateSceneSession(sessionInfo, nullptr);
1495     ASSERT_NE(sceneSessionFirst, nullptr);
1496     sceneSessionFirst->SetSessionRect({0, 0, 200, 200});
1497     SetVisibleForAccessibility(sceneSessionFirst);
1498     ssm_->sceneSessionMap_.insert({sceneSessionFirst->GetPersistentId(), sceneSessionFirst});
1499 
1500     sptr<SceneSession> sceneSessionSecond = ssm_->CreateSceneSession(sessionInfo, nullptr);
1501     ASSERT_NE(sceneSessionSecond, nullptr);
1502     sceneSessionSecond->SetSessionRect({300, 300, 200, 200});
1503     SetVisibleForAccessibility(sceneSessionSecond);
1504     ssm_->sceneSessionMap_.insert({sceneSessionSecond->GetPersistentId(), sceneSessionSecond});
1505 
1506     std::vector<sptr<SceneSession>> sceneSessionList;
1507     std::vector<sptr<AccessibilityWindowInfo>> accessibilityInfo;
1508     ssm_->GetAllSceneSessionForAccessibility(sceneSessionList);
1509     ssm_->FilterSceneSessionCovered(sceneSessionList);
1510     ssm_->FillAccessibilityInfo(sceneSessionList, accessibilityInfo);
1511     ASSERT_EQ(accessibilityInfo.size(), 2);
1512 }
1513 
1514 /**
1515  * @tc.name: AccessibilityFilterTwoWindowCovered
1516  * @tc.desc: SceneSesionManager filter two windows that covered each other;
1517  * @tc.type: FUNC
1518  */
1519 HWTEST_F(SceneSessionManagerTest, AccessibilityFilterTwoWindowCovered, Function | SmallTest | Level3)
1520 {
1521     SessionInfo sessionInfo;
1522     sessionInfo.bundleName_ = "accessibilityNotifyTesterBundleName";
1523     sessionInfo.abilityName_ = "accessibilityNotifyTesterAbilityName";
1524 
1525     sptr<SceneSession> sceneSessionFirst = ssm_->CreateSceneSession(sessionInfo, nullptr);
1526     ASSERT_NE(sceneSessionFirst, nullptr);
1527     sceneSessionFirst->SetSessionRect({0, 0, 200, 200});
1528     SetVisibleForAccessibility(sceneSessionFirst);
1529     sceneSessionFirst->SetZOrder(20);
1530     ssm_->sceneSessionMap_.insert({sceneSessionFirst->GetPersistentId(), sceneSessionFirst});
1531 
1532     sptr<SceneSession> sceneSessionSecond = ssm_->CreateSceneSession(sessionInfo, nullptr);
1533     ASSERT_NE(sceneSessionSecond, nullptr);
1534     sceneSessionSecond->SetSessionRect({50, 50, 50, 50});
1535     SetVisibleForAccessibility(sceneSessionSecond);
1536     sceneSessionSecond->SetZOrder(10);
1537     ssm_->sceneSessionMap_.insert({sceneSessionSecond->GetPersistentId(), sceneSessionSecond});
1538 
1539     std::vector<sptr<SceneSession>> sceneSessionList;
1540     std::vector<sptr<AccessibilityWindowInfo>> accessibilityInfo;
1541     ssm_->GetAllSceneSessionForAccessibility(sceneSessionList);
1542     ssm_->FilterSceneSessionCovered(sceneSessionList);
1543     ssm_->FillAccessibilityInfo(sceneSessionList, accessibilityInfo);
1544     ASSERT_EQ(accessibilityInfo.size(), 1);
1545 }
1546 
1547 /**
1548  * @tc.name: GetMainWindowInfos
1549  * @tc.desc: SceneSesionManager get topN main window infos;
1550  * @tc.type: FUNC
1551  */
1552 HWTEST_F(SceneSessionManagerTest, GetMainWindowInfos, Function | SmallTest | Level3)
1553 {
1554     int32_t topNum = 1024;
1555     std::vector<MainWindowInfo> topNInfos;
1556     auto result = ssm_->GetMainWindowInfos(topNum, topNInfos);
1557     EXPECT_EQ(result, WMError::WM_OK);
1558 
1559     topNum = 0;
1560     ssm_->GetMainWindowInfos(topNum, topNInfos);
1561 
1562     topNum = 1000;
1563     MainWindowInfo info;
1564     topNInfos.push_back(info);
1565     ssm_->GetMainWindowInfos(topNum, topNInfos);
1566 }
1567 
1568 /**
1569  * @tc.name: GetAllWindowVisibilityInfos
1570  * @tc.desc: SceneSesionManager get all window visibility infos;
1571  * @tc.type: FUNC
1572  */
1573 HWTEST_F(SceneSessionManagerTest, GetAllWindowVisibilityInfos, Function | SmallTest | Level3)
1574 {
1575     ASSERT_NE(ssm_, nullptr);
1576     ssm_->sceneSessionMap_.clear();
1577     SessionInfo info;
1578     sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(info, nullptr);
1579     ASSERT_NE(nullptr, sceneSession);
1580     ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
1581     std::vector<std::pair<int32_t, uint32_t>> windowVisibilityInfos;
1582     ssm_->GetAllWindowVisibilityInfos(windowVisibilityInfos);
1583     EXPECT_NE(windowVisibilityInfos.size(), 0);
1584 }
1585 
1586 /**
1587  * @tc.name: TestNotifyEnterRecentTask
1588  * @tc.desc: Test whether the enterRecent_ is set correctly;
1589  * @tc.type: FUNC
1590  */
1591 HWTEST_F(SceneSessionManagerTest, TestNotifyEnterRecentTask, Function | SmallTest | Level3)
1592 {
1593     GTEST_LOG_(INFO) << "SceneSessionManagerTest: TestNotifyEnterRecentTask start";
1594     sptr<SceneSessionManager> sceneSessionManager = sptr<SceneSessionManager>::MakeSptr();
1595     ASSERT_NE(nullptr, sceneSessionManager);
1596 
1597     ASSERT_EQ(sceneSessionManager->NotifyEnterRecentTask(true), WSError::WS_OK);
1598     ASSERT_EQ(sceneSessionManager->enterRecent_.load(), true);
1599 }
1600 
1601 /**
1602  * @tc.name: TestIsEnablePiPCreate
1603  * @tc.desc: Test if pip window can be created;
1604  * @tc.type: FUNC
1605  */
1606 HWTEST_F(SceneSessionManagerTest, TestIsEnablePiPCreate, Function | SmallTest | Level3)
1607 {
1608     GTEST_LOG_(INFO) << "SceneSessionManagerTest: TestIsEnablePiPCreate start";
1609     ssm_->isScreenLocked_ = true;
1610     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1611     ASSERT_TRUE(!ssm_->IsEnablePiPCreate(property));
1612 
1613     ssm_->isScreenLocked_ = false;
1614     Rect reqRect = { 0, 0, 0, 0 };
1615     property->SetRequestRect(reqRect);
1616     ASSERT_TRUE(!ssm_->IsEnablePiPCreate(property));
1617 
1618     reqRect = { 0, 0, 10, 0 };
1619     property->SetRequestRect(reqRect);
1620     ASSERT_TRUE(!ssm_->IsEnablePiPCreate(property));
1621 
1622     reqRect = { 0, 0, 10, 10 };
1623     property->SetRequestRect(reqRect);
1624     PiPTemplateInfo info = {0, 0, {}};
1625     property->SetPiPTemplateInfo(info);
1626     SessionInfo info1;
1627     info1.abilityName_ = "test1";
1628     info1.bundleName_ = "test2";
1629     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info1, nullptr);
1630     ASSERT_NE(nullptr, sceneSession);
1631     property->SetWindowMode(WindowMode::WINDOW_MODE_PIP);
1632     sceneSession->pipTemplateInfo_ = {0, 100, {}};
1633     ssm_->sceneSessionMap_.insert({0, sceneSession});
1634     ASSERT_TRUE(!ssm_->IsEnablePiPCreate(property));
1635     ssm_->sceneSessionMap_.clear();
1636     ASSERT_TRUE(!ssm_->IsEnablePiPCreate(property));
1637 
1638     property->SetParentPersistentId(100);
1639     ASSERT_TRUE(!ssm_->IsEnablePiPCreate(property));
1640 
1641     ssm_->sceneSessionMap_.insert({100, sceneSession});
1642     ASSERT_TRUE(!ssm_->IsEnablePiPCreate(property));
1643 
1644     ssm_->sceneSessionMap_.clear();
1645     sceneSession->SetSessionState(SessionState::STATE_FOREGROUND);
1646     ssm_->sceneSessionMap_.insert({100, sceneSession});
1647     ASSERT_TRUE(ssm_->IsEnablePiPCreate(property));
1648 }
1649 
1650 /**
1651  * @tc.name: TestIsPiPForbidden
1652  * @tc.desc: Test if pip window is forbidden to use;
1653  * @tc.type: FUNC
1654  */
1655 HWTEST_F(SceneSessionManagerTest, TestIsPiPForbidden, Function | SmallTest | Level3)
1656 {
1657     GTEST_LOG_(INFO) << "SceneSessionManagerTest: TestIsPiPForbidden start";
1658     int32_t persistentId = 1001;
1659     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1660     ASSERT_NE(nullptr, property);
1661     property->SetParentPersistentId(persistentId);
1662     ASSERT_TRUE(!ssm_->IsPiPForbidden(property, WindowType::WINDOW_TYPE_PIP));
1663 
1664     SessionInfo sessionInfo;
1665     sessionInfo.persistentId_ = persistentId;
1666     sessionInfo.bundleName_ = "test1";
1667     sessionInfo.abilityName_ = "test2";
1668     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1669     ASSERT_NE(nullptr, sceneSession);
1670     property->SetDisplayId(-1ULL);
1671     sceneSession->SetSessionProperty(property);
1672     ssm_->sceneSessionMap_.insert({persistentId, sceneSession});
1673     ASSERT_TRUE(!ssm_->IsPiPForbidden(property, WindowType::WINDOW_TYPE_PIP));
1674 
1675     uint64_t displayId = 1001;
1676     property->SetDisplayId(displayId);
1677     sceneSession->SetSessionProperty(property);
1678     ssm_->sceneSessionMap_[persistentId] = sceneSession;
1679     sptr<ScreenSession> screenSession = new ScreenSession();
1680     screenSession->SetName("HiCar");
1681     ScreenSessionManagerClient::GetInstance().screenSessionMap_.insert({displayId, screenSession});
1682     ASSERT_TRUE(ssm_->IsPiPForbidden(property, WindowType::WINDOW_TYPE_PIP));
1683     ASSERT_TRUE(!ssm_->IsPiPForbidden(property, WindowType::WINDOW_TYPE_FLOAT));
1684 }
1685 
1686 /**
1687  * @tc.name: GetAllMainWindowInfos
1688  * @tc.desc: GetAllMainWindowInfos
1689  * @tc.type: FUNC
1690  */
1691 HWTEST_F(SceneSessionManagerTest, GetAllMainWindowInfos, Function | SmallTest | Level3)
1692 {
1693     SessionInfo info;
1694     info.abilityName_ = "test";
1695     info.bundleName_ = "test";
1696     info.windowType_ = static_cast<uint32_t>(WindowType::APP_SUB_WINDOW_BASE);
1697     info.persistentId_ = 100;
1698     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1699     ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
1700     std::vector<MainWindowInfo> infos;
1701     WMError result = ssm_->GetAllMainWindowInfos(infos);
1702     ASSERT_EQ(result, WMError::WM_OK);
1703     ssm_->sceneSessionMap_.erase(sceneSession->GetPersistentId());
1704 }
1705 
1706 /**
1707  * @tc.name: GetAllMainWindowInfos001
1708  * @tc.desc: SceneSessionManager get all main window infos.
1709  * @tc.type: FUNC
1710  */
1711 HWTEST_F(SceneSessionManagerTest, GetAllMainWindowInfos001, Function | SmallTest | Level3)
1712 {
1713     SessionInfo info;
1714     info.abilityName_ = "test1";
1715     info.bundleName_ = "test1";
1716     info.windowType_ = static_cast<uint32_t>(WindowType::APP_WINDOW_BASE);
1717     info.persistentId_ = 1;
1718     std::shared_ptr<AppExecFwk::AbilityInfo> abilityInfo = std::make_shared<AppExecFwk::AbilityInfo>();
1719     AppExecFwk::ApplicationInfo applicationInfo;
1720     applicationInfo.bundleType = AppExecFwk::BundleType::ATOMIC_SERVICE;
1721     abilityInfo->applicationInfo = applicationInfo;
1722     info.abilityInfo = abilityInfo;
1723     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1724     if (sceneSession == nullptr) {
1725         return;
1726     }
1727     ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
1728     std::vector<MainWindowInfo> infos;
1729     WMError result = ssm_->GetAllMainWindowInfos(infos);
1730     EXPECT_EQ(result, WMError::WM_OK);
1731     ssm_->sceneSessionMap_.erase(sceneSession->GetPersistentId());
1732 }
1733 
1734 /**
1735  * @tc.name: GetAllMainWindowInfos002
1736  * @tc.desc: SceneSessionManager get all main window infos, input params are not empty.
1737  * @tc.type: FUNC
1738  */
1739 HWTEST_F(SceneSessionManagerTest, GetAllMainWindowInfos002, Function | SmallTest | Level3)
1740 {
1741     std::vector<MainWindowInfo> infos;
1742     MainWindowInfo info;
1743     info.pid_ = 1000;
1744     info.bundleName_ = "test";
1745     infos.push_back(info);
1746     WMError result = ssm_->GetAllMainWindowInfos(infos);
1747     EXPECT_EQ(result, WMError::WM_ERROR_INVALID_PARAM);
1748 }
1749 
1750 /**
1751  * @tc.name: GetUnreliableWindowInfo01
1752  * @tc.desc: SceneSesionManager get unreliable window info, windowId correct
1753  * @tc.type: FUNC
1754  */
1755 HWTEST_F(SceneSessionManagerTest, GetUnreliableWindowInfo01, Function | SmallTest | Level3)
1756 {
1757     ssm_->sceneSessionMap_.clear();
1758     SessionInfo info;
1759     sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(info, nullptr);
1760     ASSERT_NE(nullptr, sceneSession);
1761     ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
1762 
1763     int32_t windowId = sceneSession->GetPersistentId();
1764     std::vector<sptr<UnreliableWindowInfo>> infos;
1765     WMError result = ssm_->GetUnreliableWindowInfo(windowId, infos);
1766     EXPECT_EQ(WMError::WM_OK, result);
1767     EXPECT_EQ(1, infos.size());
1768 }
1769 
1770 /**
1771  * @tc.name: GetUnreliableWindowInfo02
1772  * @tc.desc: SceneSesionManager get unreliable window info, toast window
1773  * @tc.type: FUNC
1774  */
1775 HWTEST_F(SceneSessionManagerTest, GetUnreliableWindowInfo02, Function | SmallTest | Level3)
1776 {
1777     ssm_->sceneSessionMap_.clear();
1778     SessionInfo info;
1779     info.windowType_ = 2107;
1780     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1781     ASSERT_NE(nullptr, property);
1782     property->SetWindowType(WindowType::WINDOW_TYPE_TOAST);
1783     sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(info, property);
1784     ASSERT_NE(nullptr, sceneSession);
1785     sceneSession->SetRSVisible(true);
1786     ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
1787 
1788     int32_t windowId = 0;
1789     std::vector<sptr<UnreliableWindowInfo>> infos;
1790     WMError result = ssm_->GetUnreliableWindowInfo(windowId, infos);
1791     EXPECT_EQ(WMError::WM_OK, result);
1792     EXPECT_EQ(1, infos.size());
1793 }
1794 
1795 /**
1796  * @tc.name: GetUnreliableWindowInfo03
1797  * @tc.desc: SceneSesionManager get unreliable window info, app sub window
1798  * @tc.type: FUNC
1799  */
1800 HWTEST_F(SceneSessionManagerTest, GetUnreliableWindowInfo03, Function | SmallTest | Level3)
1801 {
1802     ssm_->sceneSessionMap_.clear();
1803     SessionInfo info;
1804     info.windowType_ = 1000;
1805     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1806     ASSERT_NE(nullptr, property);
1807     property->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
1808     sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(info, property);
1809     ASSERT_NE(nullptr, sceneSession);
1810     ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
1811 
1812     SessionInfo info2;
1813     info2.windowType_ = 1001;
1814     sptr<WindowSessionProperty> property2 = sptr<WindowSessionProperty>::MakeSptr();
1815     ASSERT_NE(nullptr, property2);
1816     property2->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
1817     property2->SetParentId(sceneSession->GetPersistentId());
1818     sptr<SceneSession> sceneSession2 = ssm_->CreateSceneSession(info2, property2);
1819     ASSERT_NE(nullptr, sceneSession2);
1820     sceneSession2->SetRSVisible(true);
1821     ssm_->sceneSessionMap_.insert({sceneSession2->GetPersistentId(), sceneSession2});
1822 
1823     int32_t windowId = 0;
1824     std::vector<sptr<UnreliableWindowInfo>> infos;
1825     WMError result = ssm_->GetUnreliableWindowInfo(windowId, infos);
1826     EXPECT_EQ(WMError::WM_OK, result);
1827     EXPECT_EQ(1, infos.size());
1828 }
1829 
1830 /**
1831  * @tc.name: GetUnreliableWindowInfo04
1832  * @tc.desc: SceneSesionManager get unreliable window info, input method window
1833  * @tc.type: FUNC
1834  */
1835 HWTEST_F(SceneSessionManagerTest, GetUnreliableWindowInfo04, Function | SmallTest | Level3)
1836 {
1837     ssm_->sceneSessionMap_.clear();
1838     SessionInfo info;
1839     info.windowType_ = 2105;
1840     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1841     ASSERT_NE(nullptr, property);
1842     property->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
1843     sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(info, property);
1844     ASSERT_NE(nullptr, sceneSession);
1845     sceneSession->SetRSVisible(true);
1846     ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
1847 
1848     int32_t windowId = 0;
1849     std::vector<sptr<UnreliableWindowInfo>> infos;
1850     WMError result = ssm_->GetUnreliableWindowInfo(windowId, infos);
1851     EXPECT_EQ(WMError::WM_OK, result);
1852     EXPECT_EQ(1, infos.size());
1853 }
1854 
1855 /**
1856  * @tc.name: GetUnreliableWindowInfo05
1857  * @tc.desc: SceneSesionManager get unreliable window info, not correct window type, not visible
1858  * @tc.type: FUNC
1859  */
1860 HWTEST_F(SceneSessionManagerTest, GetUnreliableWindowInfo05, Function | SmallTest | Level3)
1861 {
1862     ssm_->sceneSessionMap_.clear();
1863     SessionInfo info;
1864     info.windowType_ = 2122;
1865     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1866     ASSERT_NE(nullptr, property);
1867     property->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
1868     sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(info, property);
1869     ASSERT_NE(nullptr, sceneSession);
1870     sceneSession->SetRSVisible(true);
1871     ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
1872     ssm_->sceneSessionMap_.insert({0, nullptr});
1873 
1874     int32_t windowId = 0;
1875     std::vector<sptr<UnreliableWindowInfo>> infos;
1876     WMError result = ssm_->GetUnreliableWindowInfo(windowId, infos);
1877     EXPECT_EQ(WMError::WM_OK, result);
1878     sceneSession->SetRSVisible(false);
1879     result = ssm_->GetUnreliableWindowInfo(windowId, infos);
1880     EXPECT_EQ(WMError::WM_OK, result);
1881     EXPECT_EQ(0, infos.size());
1882 }
1883 
1884 /**
1885  * @tc.name: GetUnreliableWindowInfo06
1886  * @tc.desc: SceneSesionManager satisfy FillUnreliableWindowInfo branches coverage
1887  * @tc.type: FUNC
1888  */
1889 HWTEST_F(SceneSessionManagerTest, GetUnreliableWindowInfo06, Function | SmallTest | Level3)
1890 {
1891     ssm_->sceneSessionMap_.clear();
1892     SessionInfo info1;
1893     info1.bundleName_ = "SCBGestureBack";
1894     sptr<SceneSession> sceneSession1 = ssm_->CreateSceneSession(info1, nullptr);
1895     ASSERT_NE(nullptr, sceneSession1);
1896     ssm_->sceneSessionMap_.insert({sceneSession1->GetPersistentId(), sceneSession1});
1897 
1898     SessionInfo info2;
1899     info2.bundleName_ = "SCBGestureNavBar";
1900     sptr<SceneSession> sceneSession2 = ssm_->CreateSceneSession(info2, nullptr);
1901     ASSERT_NE(nullptr, sceneSession2);
1902     ssm_->sceneSessionMap_.insert({sceneSession2->GetPersistentId(), sceneSession2});
1903 
1904     SessionInfo info3;
1905     info3.bundleName_ = "SCBGestureTopBar";
1906     sptr<SceneSession> sceneSession3 = ssm_->CreateSceneSession(info3, nullptr);
1907     ASSERT_NE(nullptr, sceneSession3);
1908     ssm_->sceneSessionMap_.insert({sceneSession3->GetPersistentId(), sceneSession3});
1909 
1910     std::vector<sptr<UnreliableWindowInfo>> infos;
1911     ssm_->GetUnreliableWindowInfo(sceneSession1->GetPersistentId(), infos);
1912     ssm_->GetUnreliableWindowInfo(sceneSession2->GetPersistentId(), infos);
1913     ssm_->GetUnreliableWindowInfo(sceneSession3->GetPersistentId(), infos);
1914     EXPECT_EQ(0, infos.size());
1915 }
1916 
1917 /**
1918  * @tc.name: SkipSnapshotForAppProcess
1919  * @tc.desc: add or cancel snapshot skip for app process
1920  * @tc.type: FUNC
1921  */
1922 HWTEST_F(SceneSessionManagerTest, SkipSnapshotForAppProcess, Function | SmallTest | Level3)
1923 {
1924     int32_t pid = 1000;
1925     bool skip = true;
1926     auto result = ssm_->SkipSnapshotForAppProcess(pid, skip);
1927     ASSERT_EQ(result, WMError::WM_OK);
1928     usleep(WAIT_SYNC_FOR_SNAPSHOT_SKIP_IN_NS);
1929     ASSERT_NE(ssm_->snapshotSkipPidSet_.find(pid), ssm_->snapshotSkipPidSet_.end());
1930 
1931     skip = false;
1932     result = ssm_->SkipSnapshotForAppProcess(pid, skip);
1933     ASSERT_EQ(result, WMError::WM_OK);
1934     usleep(WAIT_SYNC_FOR_SNAPSHOT_SKIP_IN_NS);
1935     ASSERT_EQ(ssm_->snapshotSkipPidSet_.find(pid), ssm_->snapshotSkipPidSet_.end());
1936 
1937     SessionInfo info;
1938     sptr<SceneSession> sceneSession1 = ssm_->CreateSceneSession(info, nullptr);
1939     sptr<SceneSession> sceneSession2 = ssm_->CreateSceneSession(info, nullptr);
1940     ASSERT_NE(nullptr, sceneSession1);
1941     ASSERT_NE(nullptr, sceneSession2);
1942     sceneSession1->SetCallingPid(1000);
1943     sceneSession2->SetCallingPid(1001);
1944     ssm_->sceneSessionMap_.insert({sceneSession1->GetPersistentId(), sceneSession1});
1945     ssm_->sceneSessionMap_.insert({sceneSession2->GetPersistentId(), sceneSession2});
1946     ssm_->sceneSessionMap_.insert({-1, nullptr});
1947     skip = true;
1948     result = ssm_->SkipSnapshotForAppProcess(pid, skip);
1949     usleep(WAIT_SYNC_FOR_SNAPSHOT_SKIP_IN_NS);
1950     ASSERT_EQ(result, WMError::WM_OK);
1951     skip = false;
1952     result = ssm_->SkipSnapshotForAppProcess(pid, skip);
1953     ASSERT_EQ(result, WMError::WM_OK);
1954     ssm_->sceneSessionMap_.erase(sceneSession1->GetPersistentId());
1955     ssm_->sceneSessionMap_.erase(sceneSession2->GetPersistentId());
1956     ssm_->sceneSessionMap_.erase(-1);
1957     usleep(WAIT_SYNC_FOR_TEST_END_IN_NS);
1958 }
1959 
1960 /**
1961  * @tc.name: RemoveProcessSnapshotSkip
1962  * @tc.desc: SceneSesionManager RemoveProcessSnapshotSkip
1963  * @tc.type: FUNC
1964  */
1965 HWTEST_F(SceneSessionManagerTest, RemoveProcessSnapshotSkip, Function | SmallTest | Level3)
1966 {
1967     ssm_->snapshotSkipPidSet_.insert(1);
1968     ssm_->RemoveProcessSnapshotSkip(1);
1969     ASSERT_EQ(ssm_->snapshotSkipPidSet_.find(1), ssm_->snapshotSkipPidSet_.end());
1970 }
1971 
1972 /**
1973  * @tc.name: SetSessionSnapshotSkipForAppProcess
1974  * @tc.desc: SceneSesionManager SetSessionSnapshotSkipForAppProcess
1975  * @tc.type: FUNC
1976  */
1977 HWTEST_F(SceneSessionManagerTest, SetSessionSnapshotSkipForAppProcess, Function | SmallTest | Level3)
1978 {
1979     SessionInfo info;
1980     sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(info, nullptr);
1981     sceneSession->SetCallingPid(1000);
1982     struct RSSurfaceNodeConfig config;
1983     std::shared_ptr<RSSurfaceNode> surfaceNode = RSSurfaceNode::Create(config);
1984     sceneSession->surfaceNode_ = surfaceNode;
1985     ssm_->SetSessionSnapshotSkipForAppProcess(sceneSession);
1986     ASSERT_EQ(sceneSession->GetSessionProperty()->GetSnapshotSkip(), false);
1987 
1988     ssm_->snapshotSkipPidSet_.insert(1000);
1989     ssm_->SetSessionSnapshotSkipForAppProcess(sceneSession);
1990     ASSERT_EQ(sceneSession->GetSessionProperty()->GetSnapshotSkip(), true);
1991     ssm_->snapshotSkipPidSet_.erase(1000);
1992 }
1993 
1994 /**
1995  * @tc.name: TestReportCorrectScreenFoldStatusChangeEvent
1996  * @tc.desc: Test whether report the correct screen fold status events
1997  * @tc.type: FUNC
1998  */
1999 HWTEST_F(SceneSessionManagerTest, TestReportCorrectScreenFoldStatusChangeEvent, Function | SmallTest | Level3)
2000 {
2001     GTEST_LOG_(INFO) << "SceneSessionManagerTest: TestReportCorrectScreenFoldStatusChangeEvent start";
2002     ScreenFoldData screenFoldData1;
2003     screenFoldData1.currentScreenFoldStatus_ = 1; // 1: current screen fold status
2004     screenFoldData1.nextScreenFoldStatus_ = 3; // 3: next screen fold status
2005     screenFoldData1.currentScreenFoldStatusDuration_ = 18; // 18: current duration
2006     screenFoldData1.postureAngle_ = 47.1f; // 47.1: posture angle (type: float)
2007     screenFoldData1.screenRotation_ = 1; // 1: screen rotation
2008     screenFoldData1.typeCThermal_ = 3000; // 3000: typec port thermal
2009     screenFoldData1.focusedPackageName_ = "Developer Test: (1, 3, 18, 47.1, 1, 3000)";
2010     WMError result = ssm_->CheckAndReportScreenFoldStatus(screenFoldData1);
2011     ASSERT_EQ(result, WMError::WM_DO_NOTHING); // not report half-fold event until next change
2012 
2013     ScreenFoldData screenFoldData2;
2014     screenFoldData2.currentScreenFoldStatus_ = 3; // 3: current screen fold status
2015     screenFoldData2.nextScreenFoldStatus_ = 2; // 2: next screen fold status
2016     screenFoldData2.currentScreenFoldStatusDuration_ = 20; // 20: current duration
2017     screenFoldData2.postureAngle_ = 143.7f; // 143.7: posture angle (type: float)
2018     screenFoldData2.screenRotation_ = 2; // 2: screen rotation
2019     screenFoldData2.typeCThermal_ = 3005; // 3005: typec port thermal
2020     screenFoldData2.focusedPackageName_ = "Developer Test: (3, 2, 20, 143.7, 2, 3005)";
2021     result = ssm_->CheckAndReportScreenFoldStatus(screenFoldData2);
2022     ASSERT_EQ(result, WMError::WM_OK);
2023 }
2024 
2025 /**
2026  * @tc.name: TestReportIncompleteScreenFoldStatusChangeEvent
2027  * @tc.desc: Test whether block the incomplete screen fold status events
2028  * @tc.type: FUNC
2029  */
2030 HWTEST_F(SceneSessionManagerTest, TestReportIncompleteScreenFoldStatusChangeEvent, Function | SmallTest | Level3)
2031 {
2032     GTEST_LOG_(INFO) << "SceneSessionManagerTest: TestReportIncompleteScreenFoldStatusChangeEvent start";
2033     // screen fold status changes from -1: invalid to 3: half_fold, duration = 0, angle = 67.0, rotation = 0
2034     std::vector<std::string> screenFoldInfo {"-1", "3", "0", "67.0", "0"};
2035     WMError result = ssm_->ReportScreenFoldStatusChange(screenFoldInfo);
2036     ASSERT_EQ(result, WMError::WM_DO_NOTHING);
2037 
2038     screenFoldInfo.clear();
2039     result = ssm_->ReportScreenFoldStatusChange(screenFoldInfo);
2040     ASSERT_EQ(result, WMError::WM_DO_NOTHING);
2041 
2042     // screen fold status changes from 2: folded to 3: half_fold, duration = 0, angle = 67.0, rotation = 0
2043     screenFoldInfo = {"2", "3", "0", "67.0", "0"};
2044     result = ssm_->ReportScreenFoldStatusChange(screenFoldInfo);
2045     ASSERT_EQ(result, WMError::WM_DO_NOTHING);
2046 
2047     // screen fold status changes from 3: half_fold to 1: expand, duration = 18, angle = 147.3, rotation = 2
2048     screenFoldInfo = {"3", "1", "18", "147.3", "2"};
2049     result = ssm_->ReportScreenFoldStatusChange(screenFoldInfo);
2050     ASSERT_EQ(result, WMError::WM_DO_NOTHING);
2051 }
2052 
2053 /**
2054  * @tc.name: SetAppForceLandscapeConfig
2055  * @tc.desc: SceneSesionManager SetAppForceLandscapeConfig
2056  * @tc.type: FUNC
2057  */
2058 HWTEST_F(SceneSessionManagerTest, SetAppForceLandscapeConfig, Function | SmallTest | Level3)
2059 {
2060     std::string bundleName = "SetAppForceLandscapeConfig";
2061     AppForceLandscapeConfig config = { 0, "MainPage" };
2062     WSError result = ssm_->SetAppForceLandscapeConfig(bundleName, config);
2063     ASSERT_EQ(result, WSError::WS_OK);
2064 }
2065 
2066 /**
2067  * @tc.name: GetAppForceLandscapeConfig
2068  * @tc.desc: SceneSesionManager GetAppForceLandscapeConfig
2069  * @tc.type: FUNC
2070  */
2071 HWTEST_F(SceneSessionManagerTest, GetAppForceLandscapeConfig, Function | SmallTest | Level3)
2072 {
2073     std::string bundleName = "GetAppForceLandscapeConfig";
2074     AppForceLandscapeConfig config = ssm_->GetAppForceLandscapeConfig(bundleName);
2075     ASSERT_EQ(config.mode_, 0);
2076     ASSERT_EQ(config.homePage_, "");
2077 }
2078 
2079 /**
2080  * @tc.name: RemoveProcessWatermarkPid
2081  * @tc.desc: SceneSesionManager RemoveProcessWatermarkPid
2082  * @tc.type: FUNC
2083  */
2084 HWTEST_F(SceneSessionManagerTest, RemoveProcessWatermarkPid, Function | SmallTest | Level3)
2085 {
2086     ssm_->processWatermarkPidMap_.insert({1, "test"});
2087     ssm_->RemoveProcessWatermarkPid(1);
2088     ASSERT_EQ(ssm_->processWatermarkPidMap_.find(1), ssm_->processWatermarkPidMap_.end());
2089 }
2090 
2091 /**
2092  * @tc.name: SetSessionWatermarkForAppProcess
2093  * @tc.desc: SceneSesionManager SetSessionWatermarkForAppProcess
2094  * @tc.type: FUNC
2095  */
2096 HWTEST_F(SceneSessionManagerTest, SetSessionWatermarkForAppProcess, Function | SmallTest | Level3)
2097 {
2098     SessionInfo info;
2099     sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(info, nullptr);
2100     sceneSession->SetCallingPid(1);
2101     ASSERT_FALSE(ssm_->SetSessionWatermarkForAppProcess(sceneSession));
2102     ssm_->processWatermarkPidMap_.insert({1, "test"});
2103     ASSERT_TRUE(ssm_->SetSessionWatermarkForAppProcess(sceneSession));
2104     ssm_->processWatermarkPidMap_.erase(1);
2105 }
2106 
2107 /**
2108  * @tc.name: CloseTargetFloatWindow
2109  * @tc.desc: SceneSesionManager CloseTargetFloatWindow
2110  * @tc.type: FUNC
2111  */
2112 HWTEST_F(SceneSessionManagerTest, CloseTargetFloatWindow, Function | SmallTest | Level3)
2113 {
2114     std::string bundleName = "testClose";
2115     auto result = ssm_->CloseTargetFloatWindow(bundleName);
2116     ASSERT_EQ(result, WMError::WM_OK);
2117 }
2118 
2119 /**
2120  * @tc.name: CloseTargetPiPWindow
2121  * @tc.desc: SceneSesionManager CloseTargetPiPWindow
2122  * @tc.type: FUNC
2123  */
2124 HWTEST_F(SceneSessionManagerTest, CloseTargetPiPWindow, Function | SmallTest | Level3)
2125 {
2126     std::string bundleName = "CloseTargetPiPWindow";
2127     auto result = ssm_->CloseTargetPiPWindow(bundleName);
2128     ASSERT_EQ(result, WMError::WM_OK);
2129 }
2130 
2131 /**
2132  * @tc.name: GetCurrentPiPWindowInfo01
2133  * @tc.desc: SceneSesionManager GetCurrentPiPWindowInfo
2134  * @tc.type: FUNC
2135  */
2136 HWTEST_F(SceneSessionManagerTest, GetCurrentPiPWindowInfo01, Function | SmallTest | Level3)
2137 {
2138     std::string bundleName;
2139     auto result = ssm_->GetCurrentPiPWindowInfo(bundleName);
2140     ASSERT_EQ(result, WMError::WM_OK);
2141     ASSERT_EQ("", bundleName);
2142 }
2143 
2144 /**
2145  * @tc.name: GetCurrentPiPWindowInfo02
2146  * @tc.desc: SceneSesionManager GetCurrentPiPWindowInfo
2147  * @tc.type: FUNC
2148  */
2149 HWTEST_F(SceneSessionManagerTest, GetCurrentPiPWindowInfo02, Function | SmallTest | Level3)
2150 {
2151     SessionInfo info1;
2152     info1.abilityName_ = "test1";
2153     info1.bundleName_ = "test1";
2154     info1.windowType_ = static_cast<uint32_t>(WindowType::WINDOW_TYPE_PIP);
2155     sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(info1, nullptr);
2156     ASSERT_NE(nullptr, sceneSession1);
2157     SessionInfo info2;
2158     info2.abilityName_ = "test2";
2159     info2.bundleName_ = "test2";
2160     info2.windowType_ = static_cast<uint32_t>(WindowType::WINDOW_TYPE_DIALOG);
2161     sptr<SceneSession> sceneSession2 = sptr<SceneSession>::MakeSptr(info2, nullptr);
2162     ASSERT_NE(nullptr, sceneSession2);
2163 
2164     ssm_->sceneSessionMap_.insert({sceneSession1->GetPersistentId(), sceneSession1});
2165     ssm_->sceneSessionMap_.insert({sceneSession2->GetPersistentId(), sceneSession2});
2166     std::string bundleName;
2167     auto result = ssm_->GetCurrentPiPWindowInfo(bundleName);
2168     ASSERT_EQ(result, WMError::WM_OK);
2169     ASSERT_EQ(info1.abilityName_, bundleName);
2170 }
2171 
2172 /**
2173  * @tc.name: SkipSnapshotByUserIdAndBundleNames
2174  * @tc.desc: SkipSnapshotByUserIdAndBundleNames
2175  * @tc.type: FUNC
2176  */
2177 HWTEST_F(SceneSessionManagerTest, SkipSnapshotByUserIdAndBundleNames, Function | SmallTest | Level3)
2178 {
2179     ASSERT_NE(nullptr, ssm_);
2180     auto result = ssm_->SkipSnapshotByUserIdAndBundleNames(100, {"TestName"});
2181     ASSERT_EQ(result, WMError::WM_OK);
2182     usleep(WAIT_SYNC_FOR_SNAPSHOT_SKIP_IN_NS);
2183     ASSERT_NE(ssm_->snapshotSkipBundleNameSet_.find("TestName"), ssm_->snapshotSkipBundleNameSet_.end());
2184 
2185     result = ssm_->SkipSnapshotByUserIdAndBundleNames(100, {});
2186     ASSERT_EQ(result, WMError::WM_OK);
2187     usleep(WAIT_SYNC_FOR_SNAPSHOT_SKIP_IN_NS);
2188     ASSERT_EQ(ssm_->snapshotSkipBundleNameSet_.find("TestName"), ssm_->snapshotSkipBundleNameSet_.end());
2189 
2190     SessionInfo info1;
2191     info1.bundleName_ = "TestName1";
2192     sptr<SceneSession> sceneSession1 = ssm_->CreateSceneSession(info1, nullptr);
2193     SessionInfo info2;
2194     info1.bundleName_ = "TestName2";
2195     sptr<SceneSession> sceneSession2 = ssm_->CreateSceneSession(info2, nullptr);
2196     ASSERT_NE(nullptr, sceneSession1);
2197     ASSERT_NE(nullptr, sceneSession2);
2198     sceneSession1->SetCallingPid(1000);
2199     sceneSession2->SetCallingPid(1001);
2200     ssm_->sceneSessionMap_.insert({sceneSession1->GetPersistentId(), sceneSession1});
2201     ssm_->sceneSessionMap_.insert({sceneSession2->GetPersistentId(), sceneSession2});
2202     ssm_->sceneSessionMap_.insert({-1, nullptr});
2203     result = ssm_->SkipSnapshotByUserIdAndBundleNames(100, {"TestName1"});
2204     ASSERT_EQ(result, WMError::WM_OK);
2205     ssm_->sceneSessionMap_.erase(sceneSession1->GetPersistentId());
2206     ssm_->sceneSessionMap_.erase(sceneSession2->GetPersistentId());
2207     ssm_->sceneSessionMap_.erase(-1);
2208     usleep(WAIT_SYNC_FOR_TEST_END_IN_NS);
2209 }
2210 
2211 /**
2212  * @tc.name: SetSessionSnapshotSkipForAppBundleName
2213  * @tc.desc: SceneSesionManager SetSessionSnapshotSkipForAppBundleName
2214  * @tc.type: FUNC
2215  */
2216 HWTEST_F(SceneSessionManagerTest, SetSessionSnapshotSkipForAppBundleName, Function | SmallTest | Level3)
2217 {
2218     SessionInfo info;
2219     info.bundleName_ = "TestName";
2220     sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(info, nullptr);
2221     struct RSSurfaceNodeConfig config;
2222     std::shared_ptr<RSSurfaceNode> surfaceNode = RSSurfaceNode::Create(config);
2223     sceneSession->surfaceNode_ = surfaceNode;
2224     ssm_->SetSessionSnapshotSkipForAppBundleName(sceneSession);
2225     ASSERT_EQ(sceneSession->GetSessionProperty()->GetSnapshotSkip(), false);
2226 
2227     ssm_->snapshotSkipBundleNameSet_.insert("TestName");
2228     ssm_->SetSessionSnapshotSkipForAppBundleName(sceneSession);
2229     ASSERT_EQ(sceneSession->GetSessionProperty()->GetSnapshotSkip(), true);
2230     ssm_->snapshotSkipBundleNameSet_.erase("TestName");
2231 }
2232 
2233 /**
2234  * @tc.name: GetRootMainWindowId
2235  * @tc.desc: SceneSesionManager GetRootMainWindowId
2236  * @tc.type: FUNC
2237  */
2238 HWTEST_F(SceneSessionManagerTest, GetRootMainWindowId, Function | SmallTest | Level3)
2239 {
2240     SessionInfo info1;
2241     info1.abilityName_ = "test1";
2242     info1.bundleName_ = "test1";
2243     info1.windowType_ = static_cast<uint32_t>(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
2244     sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(info1, nullptr);
2245     ASSERT_NE(nullptr, sceneSession1);
2246     SessionInfo info2;
2247     info2.abilityName_ = "test2";
2248     info2.bundleName_ = "test2";
2249     info2.windowType_ = static_cast<uint32_t>(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
2250     sptr<SceneSession> sceneSession2 = sptr<SceneSession>::MakeSptr(info2, nullptr);
2251     ASSERT_NE(nullptr, sceneSession2);
2252     sceneSession2->SetParentSession(sceneSession1);
2253 
2254     ssm_->sceneSessionMap_.insert({sceneSession1->GetPersistentId(), sceneSession1});
2255     ssm_->sceneSessionMap_.insert({sceneSession2->GetPersistentId(), sceneSession2});
2256     int32_t hostWindowId = -1;
2257     auto result = ssm_->GetRootMainWindowId(sceneSession2->GetPersistentId(), hostWindowId);
2258     ASSERT_EQ(result, WMError::WM_OK);
2259     ASSERT_EQ(hostWindowId, sceneSession1->GetPersistentId());
2260 }
2261 
2262 /**
2263  * @tc.name: UpdateScreenLockStatusForApp
2264  * @tc.desc: SceneSesionManager UpdateScreenLockStatusForApp
2265  * @tc.type: FUNC
2266  */
2267 HWTEST_F(SceneSessionManagerTest, UpdateScreenLockStatusForApp, Function | SmallTest | Level3)
2268 {
2269     auto result = ssm_->UpdateScreenLockStatusForApp("", true);
2270     ASSERT_EQ(result, WMError::WM_OK);
2271 }
2272 
2273 /**
2274  * @tc.name: UpdateAppHookDisplayInfo001
2275  * @tc.desc: Test delete HookDisplayInfo
2276  * @tc.type: FUNC
2277  */
2278 HWTEST_F(SceneSessionManagerTest, UpdateAppHookDisplayInfo001, Function | SmallTest | Level3)
2279 {
2280     int32_t uid = 0;
2281     bool enable = false;
2282     HookInfo hookInfo;
2283     hookInfo.width_ = 100;
2284     hookInfo.height_ = 100;
2285     hookInfo.density_ = 2.25;
2286     hookInfo.rotation_ = 0;
2287     hookInfo.enableHookRotation_ = false;
2288     auto result = ssm_->UpdateAppHookDisplayInfo(uid, hookInfo, enable);
2289     ASSERT_EQ(result, WMError::WM_OK);
2290 
2291     uid = 20221524;
2292     hookInfo.width_ = 0;
2293     result = ssm_->UpdateAppHookDisplayInfo(uid, hookInfo, enable);
2294     ASSERT_EQ(result, WMError::WM_OK);
2295 
2296     hookInfo.width_ = 100;
2297     hookInfo.height_ = 0;
2298     result = ssm_->UpdateAppHookDisplayInfo(uid, hookInfo, enable);
2299     ASSERT_EQ(result, WMError::WM_OK);
2300 
2301     hookInfo.height_ = 100;
2302     hookInfo.density_ = 0;
2303     result = ssm_->UpdateAppHookDisplayInfo(uid, hookInfo, enable);
2304     ASSERT_EQ(result, WMError::WM_OK);
2305 
2306     hookInfo.density_ = 2.25;
2307     result = ssm_->UpdateAppHookDisplayInfo(uid, hookInfo, enable);
2308     ASSERT_EQ(result, WMError::WM_OK);
2309 }
2310 
2311 /**
2312  * @tc.name: UpdateAppHookDisplayInfo002
2313  * @tc.desc: Test add HookDisplayInfo
2314  * @tc.type: FUNC
2315  */
2316 HWTEST_F(SceneSessionManagerTest, UpdateAppHookDisplayInfo002, Function | SmallTest | Level3)
2317 {
2318     int32_t uid = 0;
2319     bool enable = true;
2320     HookInfo hookInfo;
2321     hookInfo.width_ = 100;
2322     hookInfo.height_ = 100;
2323     hookInfo.density_ = 2.25;
2324     hookInfo.rotation_ = 0;
2325     hookInfo.enableHookRotation_ = false;
2326     auto result = ssm_->UpdateAppHookDisplayInfo(uid, hookInfo, enable);
2327     ASSERT_EQ(result, WMError::WM_ERROR_INVALID_PARAM);
2328 
2329     uid = 20221524;
2330     hookInfo.width_ = 0;
2331     result = ssm_->UpdateAppHookDisplayInfo(uid, hookInfo, enable);
2332     ASSERT_EQ(result, WMError::WM_ERROR_INVALID_PARAM);
2333 
2334     hookInfo.width_ = 100;
2335     hookInfo.height_ = 0;
2336     result = ssm_->UpdateAppHookDisplayInfo(uid, hookInfo, enable);
2337     ASSERT_EQ(result, WMError::WM_ERROR_INVALID_PARAM);
2338 
2339     hookInfo.height_ = 100;
2340     hookInfo.density_ = 0;
2341     result = ssm_->UpdateAppHookDisplayInfo(uid, hookInfo, enable);
2342     ASSERT_EQ(result, WMError::WM_ERROR_INVALID_PARAM);
2343 
2344     hookInfo.density_ = 2.25;
2345     result = ssm_->UpdateAppHookDisplayInfo(uid, hookInfo, enable);
2346     ASSERT_EQ(result, WMError::WM_OK);
2347 }
2348 
2349 /**
2350  * @tc.name: IsPcWindow
2351  * @tc.desc: IsPcWindow
2352  * @tc.type: FUNC
2353  */
2354 HWTEST_F(SceneSessionManagerTest, IsPcWindow, Function | SmallTest | Level3)
2355 {
2356     bool isPcWindow = false;
2357     auto result = ssm_->IsPcWindow(isPcWindow);
2358     ASSERT_EQ(result, WMError::WM_OK);
2359 }
2360 
2361 /**
2362  * @tc.name: IsPcOrPadFreeMultiWindowMode
2363  * @tc.desc: IsPcOrPadFreeMultiWindowMode
2364  * @tc.type: FUNC
2365  */
2366 HWTEST_F(SceneSessionManagerTest, IsPcOrPadFreeMultiWindowMode, Function | SmallTest | Level3)
2367 {
2368     bool isPcOrPadFreeMultiWindowMode = false;
2369     auto result = ssm_->IsPcOrPadFreeMultiWindowMode(isPcOrPadFreeMultiWindowMode);
2370     ASSERT_EQ(result, WMError::WM_OK);
2371 }
2372 
2373 /**
2374  * @tc.name: IsWindowRectAutoSave
2375  * @tc.desc: IsWindowRectAutoSave
2376  * @tc.type: FUNC
2377  */
2378 HWTEST_F(SceneSessionManagerTest, IsWindowRectAutoSave, Function | SmallTest | Level3)
2379 {
2380     std::string key = "com.example.recposentryEntryAbilityabc";
2381     bool enabled = false;
2382     int persistentId = 1;
2383     auto result = ssm_->IsWindowRectAutoSave(key, enabled, persistentId);
2384     ASSERT_EQ(result, WMError::WM_ERROR_INVALID_SESSION);
2385 }
2386 
2387 /**
2388  * @tc.name: SetIsWindowRectAutoSave
2389  * @tc.desc: SetIsWindowRectAutoSave
2390  * @tc.type: FUNC
2391  */
2392 HWTEST_F(SceneSessionManagerTest, SetIsWindowRectAutoSave, Function | SmallTest | Level3)
2393 {
2394     std::string key = "com.example.recposentryEntryAbility";
2395     bool enabled = true;
2396     ssm_->SetIsWindowRectAutoSave(key, enabled);
2397     ASSERT_EQ(ssm_->isWindowRectAutoSaveMap_.at(key), true);
2398 }
2399 
2400 /**
2401  * @tc.name: GetDisplayIdByWindowId
2402  * @tc.desc: test function : GetDisplayIdByWindowId
2403  * @tc.type: FUNC
2404  */
2405 HWTEST_F(SceneSessionManagerTest, GetDisplayIdByWindowId, Function | SmallTest | Level3)
2406 {
2407     SessionInfo info;
2408     info.abilityName_ = "test";
2409     info.bundleName_ = "test";
2410     sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(info, nullptr);
2411     ASSERT_NE(nullptr, sceneSession1);
2412     ssm_->sceneSessionMap_.insert({sceneSession1->GetPersistentId(), sceneSession1});
2413     sptr<SceneSession> sceneSession2 = sptr<SceneSession>::MakeSptr(info, nullptr);
2414     ASSERT_NE(nullptr, sceneSession2);
2415     ssm_->sceneSessionMap_.insert({sceneSession2->GetPersistentId(), sceneSession2});
2416 
2417     DisplayId displayId = 0;
2418     sceneSession1->property_->SetDisplayId(displayId);
2419 
2420     const std::vector<uint64_t> windowIds = {1001, sceneSession1->GetPersistentId(), sceneSession2->GetPersistentId()};
2421     std::unordered_map<uint64_t, DisplayId> windowDisplayIdMap;
2422     ASSERT_EQ(ssm_->GetDisplayIdByWindowId(windowIds, windowDisplayIdMap), WMError::WM_OK);
2423 }
2424 
2425 /**
2426  * @tc.name: SetGlobalDragResizeType
2427  * @tc.desc: test function : SetGlobalDragResizeType
2428  * @tc.type: FUNC
2429  */
2430 HWTEST_F(SceneSessionManagerTest, SetGlobalDragResizeType, Function | SmallTest | Level3)
2431 {
2432     DragResizeType dragResizeType = DragResizeType::RESIZE_EACH_FRAME;
2433     ASSERT_EQ(ssm_->SetGlobalDragResizeType(dragResizeType), WMError::WM_OK);
2434 }
2435 
2436 /**
2437  * @tc.name: GetGlobalDragResizeType
2438  * @tc.desc: test function : GetGlobalDragResizeType
2439  * @tc.type: FUNC
2440  */
2441 HWTEST_F(SceneSessionManagerTest, GetGlobalDragResizeType, Function | SmallTest | Level3)
2442 {
2443     DragResizeType dragResizeType = DragResizeType::RESIZE_TYPE_UNDEFINED;
2444     ASSERT_EQ(ssm_->GetGlobalDragResizeType(dragResizeType), WMError::WM_OK);
2445 }
2446 
2447 /**
2448  * @tc.name: SetAppDragResizeType
2449  * @tc.desc: test function : SetAppDragResizeType
2450  * @tc.type: FUNC
2451  */
2452 HWTEST_F(SceneSessionManagerTest, SetAppDragResizeType, Function | SmallTest | Level3)
2453 {
2454     SessionInfo info;
2455     info.abilityName_ = "test1";
2456     info.bundleName_ = "test1";
2457     info.windowType_ = static_cast<uint32_t>(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
2458     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
2459     ASSERT_NE(nullptr, sceneSession);
2460     ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
2461     DragResizeType dragResizeType = DragResizeType::RESIZE_EACH_FRAME;
2462     ASSERT_EQ(ssm_->SetAppDragResizeType(info.bundleName_, dragResizeType), WMError::WM_OK);
2463 }
2464 
2465 /**
2466  * @tc.name: GetAppDragResizeType
2467  * @tc.desc: test function : GetAppDragResizeType
2468  * @tc.type: FUNC
2469  */
2470 HWTEST_F(SceneSessionManagerTest, GetAppDragResizeType, Function | SmallTest | Level3)
2471 {
2472     SessionInfo info;
2473     info.abilityName_ = "test1";
2474     info.bundleName_ = "test1";
2475     info.windowType_ = static_cast<uint32_t>(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
2476     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
2477     ASSERT_NE(nullptr, sceneSession);
2478     ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
2479     DragResizeType dragResizeType = DragResizeType::RESIZE_TYPE_UNDEFINED;
2480     ASSERT_EQ(ssm_->GetAppDragResizeType(info.bundleName_, dragResizeType), WMError::WM_OK);
2481 }
2482 
2483 /**
2484  * @tc.name: BuildCancelPointerEvent
2485  * @tc.desc: test function : BuildCancelPointerEvent
2486  * @tc.type: FUNC
2487  */
2488 HWTEST_F(SceneSessionManagerTest, BuildCancelPointerEvent, Function | SmallTest | Level3)
2489 {
2490     auto pointerEvent = MMI::PointerEvent::Create();
2491     ssm_->BuildCancelPointerEvent(pointerEvent, 0, MMI::PointerEvent::POINTER_ACTION_DOWN, 2);
2492     int32_t pointerId = 99999999;
2493     ASSERT_EQ(pointerEvent->GetId(), pointerId);
2494     ASSERT_EQ(pointerEvent->GetTargetWindowId(), 2);
2495     ASSERT_EQ(pointerEvent->GetPointerId(), 0);
2496     ASSERT_EQ(pointerEvent->GetPointerAction(), MMI::PointerEvent::POINTER_ACTION_CANCEL);
2497     ASSERT_EQ(pointerEvent->GetSourceType(), MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
2498 }
2499 
2500 /**
2501  * @tc.name: MinimizeByWindowId
2502  * @tc.desc: test function : MinimizeByWindowId
2503  * @tc.type: FUNC
2504  */
2505 HWTEST_F(SceneSessionManagerTest, MinimizeByWindowId, Function | SmallTest | Level3)
2506 {
2507     std::vector<int32_t> windowIds;
2508     WMError res = ssm_->MinimizeByWindowId(windowIds);
2509     EXPECT_EQ(WMError::WM_ERROR_INVALID_PARAM, res);
2510 }
2511 }
2512 } // namespace Rosen
2513 } // namespace OHOS
2514