1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <gtest/gtest.h>
17 #include <regex>
18 #include <bundle_mgr_interface.h>
19 #include <bundlemgr/launcher_service.h>
20 
21 #include "context.h"
22 #include "interfaces/include/ws_common.h"
23 #include "iremote_object_mocker.h"
24 #include "mock/mock_session_stage.h"
25 #include "mock/mock_window_event_channel.h"
26 #include "session_info.h"
27 #include "session_manager.h"
28 #include "session_manager/include/scene_session_manager.h"
29 #include "session/host/include/scene_session.h"
30 #include "session/host/include/main_session.h"
31 #include "window_manager_agent.h"
32 #include "zidl/window_manager_agent_interface.h"
33 
34 using namespace testing;
35 using namespace testing::ext;
36 
37 namespace OHOS {
38 namespace Rosen {
39 class SceneSessionManagerTest4 : public testing::Test {
40 public:
41     static void SetUpTestCase();
42 
43     static void TearDownTestCase();
44 
45     void SetUp() override;
46 
47     void TearDown() override;
48 
49     static bool gestureNavigationEnabled_;
50 
51     static ProcessGestureNavigationEnabledChangeFunc callbackFunc_;
52     static sptr<SceneSessionManager> ssm_;
53 
54 private:
55     static constexpr uint32_t WAIT_SYNC_IN_NS = 200000;
56 };
57 
58 sptr<SceneSessionManager> SceneSessionManagerTest4::ssm_ = nullptr;
59 bool SceneSessionManagerTest4::gestureNavigationEnabled_ = true;
60 
61 ProcessGestureNavigationEnabledChangeFunc SceneSessionManagerTest4::callbackFunc_ = [](bool enable,
62     const std::string& bundleName, GestureBackType type) {
63     gestureNavigationEnabled_ = enable;
64 };
65 
66 
WindowChangedFuncTest(int32_t persistentId, WindowUpdateType type)67 void WindowChangedFuncTest(int32_t persistentId, WindowUpdateType type)
68 {
69 }
70 
ProcessStatusBarEnabledChangeFuncTest(bool enable)71 void ProcessStatusBarEnabledChangeFuncTest(bool enable)
72 {
73 }
74 
DumpRootSceneElementInfoFuncTest(const std::vector<std::string>& params, std::vector<std::string>& infos)75 void DumpRootSceneElementInfoFuncTest(const std::vector<std::string>& params, std::vector<std::string>& infos)
76 {
77 }
78 
SetUpTestCase()79 void SceneSessionManagerTest4::SetUpTestCase()
80 {
81     ssm_ = &SceneSessionManager::GetInstance();
82 }
83 
TearDownTestCase()84 void SceneSessionManagerTest4::TearDownTestCase()
85 {
86     ssm_ = nullptr;
87 }
88 
SetUp()89 void SceneSessionManagerTest4::SetUp()
90 {
91     ssm_->sceneSessionMap_.clear();
92 }
93 
TearDown()94 void SceneSessionManagerTest4::TearDown()
95 {
96     ssm_->sceneSessionMap_.clear();
97     usleep(WAIT_SYNC_IN_NS);
98 }
99 
100 
101 namespace {
102 /**
103  * @tc.name: UpdateSceneSessionWant01
104  * @tc.desc: SceneSesionManager test UpdateSceneSessionWant
105  * @tc.type: FUNC
106  */
HWTEST_F(SceneSessionManagerTest4, UpdateSceneSessionWant01, Function | SmallTest | Level3)107 HWTEST_F(SceneSessionManagerTest4, UpdateSceneSessionWant01, Function | SmallTest | Level3)
108 {
109     SessionInfo info;
110     info.persistentId_ = 0;
111     ssm_->UpdateSceneSessionWant(info);
112     ASSERT_NE(ssm_, nullptr);
113 }
114 
115 /**
116  * @tc.name: UpdateSceneSessionWant02
117  * @tc.desc: SceneSesionManager test UpdateSceneSessionWant
118  * @tc.type: FUNC
119  */
HWTEST_F(SceneSessionManagerTest4, UpdateSceneSessionWant02, Function | SmallTest | Level3)120 HWTEST_F(SceneSessionManagerTest4, UpdateSceneSessionWant02, Function | SmallTest | Level3)
121 {
122     SessionInfo info;
123     info.persistentId_ = 1;
124     ssm_->UpdateSceneSessionWant(info);
125     ASSERT_NE(ssm_, nullptr);
126 }
127 
128 /**
129  * @tc.name: UpdateSceneSessionWant03
130  * @tc.desc: SceneSesionManager test UpdateSceneSessionWant
131  * @tc.type: FUNC
132  */
HWTEST_F(SceneSessionManagerTest4, UpdateSceneSessionWant03, Function | SmallTest | Level3)133 HWTEST_F(SceneSessionManagerTest4, UpdateSceneSessionWant03, Function | SmallTest | Level3)
134 {
135     SessionInfo info;
136     info.persistentId_ = 1;
137     auto sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
138     ASSERT_NE(sceneSession, nullptr);
139     ssm_->sceneSessionMap_.insert({1, sceneSession});
140     ssm_->UpdateSceneSessionWant(info);
141     ASSERT_NE(ssm_, nullptr);
142 }
143 
144 /**
145  * @tc.name: UpdateSceneSessionWant04
146  * @tc.desc: SceneSesionManager test UpdateSceneSessionWant
147  * @tc.type: FUNC
148  */
HWTEST_F(SceneSessionManagerTest4, UpdateSceneSessionWant04, Function | SmallTest | Level3)149 HWTEST_F(SceneSessionManagerTest4, UpdateSceneSessionWant04, Function | SmallTest | Level3)
150 {
151     SessionInfo info;
152     info.persistentId_ = 1;
153     std::shared_ptr<AAFwk::Want> want = std::make_shared<AAFwk::Want>();
154     info.want = want;
155     auto sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
156     ASSERT_NE(sceneSession, nullptr);
157     ssm_->sceneSessionMap_.insert({1, sceneSession});
158     ssm_->UpdateSceneSessionWant(info);
159     ASSERT_NE(ssm_, nullptr);
160 }
161 
162 /**
163  * @tc.name: UpdateSceneSessionWant05
164  * @tc.desc: SceneSesionManager test UpdateSceneSessionWant
165  * @tc.type: FUNC
166  */
HWTEST_F(SceneSessionManagerTest4, UpdateSceneSessionWant05, Function | SmallTest | Level3)167 HWTEST_F(SceneSessionManagerTest4, UpdateSceneSessionWant05, Function | SmallTest | Level3)
168 {
169     SessionInfo info;
170     info.persistentId_ = 1;
171     std::shared_ptr<AAFwk::Want> want = std::make_shared<AAFwk::Want>();
172     info.want = want;
173     auto sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
174     ASSERT_NE(sceneSession, nullptr);
175     int32_t collaboratorType = CollaboratorType::RESERVE_TYPE;
176     sceneSession->SetCollaboratorType(collaboratorType);
177     ssm_->sceneSessionMap_.insert({1, sceneSession});
178     ssm_->UpdateSceneSessionWant(info);
179     ASSERT_NE(ssm_, nullptr);
180 }
181 
182 /**
183  * @tc.name: UpdateSceneSessionWant06
184  * @tc.desc: SceneSesionManager test UpdateSceneSessionWant
185  * @tc.type: FUNC
186  */
HWTEST_F(SceneSessionManagerTest4, UpdateSceneSessionWant06, Function | SmallTest | Level3)187 HWTEST_F(SceneSessionManagerTest4, UpdateSceneSessionWant06, Function | SmallTest | Level3)
188 {
189     SessionInfo info;
190     info.persistentId_ = 1;
191     std::shared_ptr<AAFwk::Want> want = std::make_shared<AAFwk::Want>();
192     info.want = want;
193     auto sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
194     ASSERT_NE(sceneSession, nullptr);
195     int32_t collaboratorType = -1;
196     sceneSession->SetCollaboratorType(collaboratorType);
197     ssm_->sceneSessionMap_.insert({1, sceneSession});
198     ssm_->UpdateSceneSessionWant(info);
199     ASSERT_NE(ssm_, nullptr);
200 }
201 
202 /**
203  * @tc.name: GetSceneSessionByIdentityInfo01
204  * @tc.desc: SceneSesionManager test GetSceneSessionByIdentityInfo
205  * @tc.type: FUNC
206  */
HWTEST_F(SceneSessionManagerTest4, GetSceneSessionByIdentityInfo01, Function | SmallTest | Level3)207 HWTEST_F(SceneSessionManagerTest4, GetSceneSessionByIdentityInfo01, Function | SmallTest | Level3)
208 {
209     std::string abilityName = "test1";
210     std::string bundleName = "test2";
211     std::string moduleName = "test3";
212     int32_t appIndex = 10;
213     SessionInfo info;
214     info.abilityName_ = abilityName;
215     info.bundleName_ = bundleName;
216     info.moduleName_ = moduleName;
217     info.appIndex_ = appIndex;
218     info.persistentId_ = 1;
219     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
220     ASSERT_NE(sceneSession, nullptr);
221     ssm_->sceneSessionMap_.insert({1, sceneSession});
222     SessionIdentityInfo identityInfo = { bundleName, moduleName, abilityName, appIndex };
223     ASSERT_NE(ssm_->GetSceneSessionByIdentityInfo(identityInfo), nullptr);
224 }
225 
226 /**
227  * @tc.name: DestroyAndDisconnectSpecificSession01
228  * @tc.desc: SceneSesionManager test DestroyAndDisconnectSpecificSession
229  * @tc.type: FUNC
230  */
HWTEST_F(SceneSessionManagerTest4, DestroyAndDisconnectSpecificSession01, Function | SmallTest | Level3)231 HWTEST_F(SceneSessionManagerTest4, DestroyAndDisconnectSpecificSession01, Function | SmallTest | Level3)
232 {
233     SessionInfo info;
234     info.abilityName_ = "DestroyAndDisconnectSpecificSession";
235     info.bundleName_ = "DestroyAndDisconnectSpecificSession";
236     info.persistentId_ = 1;
237     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
238     ASSERT_NE(sceneSession, nullptr);
239     ssm_->sceneSessionMap_.insert({1, sceneSession});
240     ASSERT_NE(ssm_->DestroyAndDisconnectSpecificSession(1), WSError::WS_ERROR_NULLPTR);
241 }
242 
243 /**
244  * @tc.name: GetAllSessionDumpInfo
245  * @tc.desc: SceneSesionManager test GetAllSessionDumpInfo
246  * @tc.type: FUNC
247  */
HWTEST_F(SceneSessionManagerTest4, GetAllSessionDumpInfo, Function | SmallTest | Level3)248 HWTEST_F(SceneSessionManagerTest4, GetAllSessionDumpInfo, Function | SmallTest | Level3)
249 {
250     SessionInfo info1;
251     info1.abilityName_ = "GetAllSessionDumpInfo1";
252     info1.bundleName_ = "GetAllSessionDumpInfo1";
253     info1.persistentId_ = 1;
254     sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(info1, nullptr);
255     ASSERT_NE(sceneSession1, nullptr);
256     sceneSession1->UpdateNativeVisibility(true);
257 
258     SessionInfo info2;
259     info2.abilityName_ = "GetAllSessionDumpInfo2";
260     info2.bundleName_ = "GetAllSessionDumpInfo2";
261     info2.persistentId_ = 2;
262     sptr<SceneSession> sceneSession2 = sptr<SceneSession>::MakeSptr(info2, nullptr);
263     ASSERT_NE(sceneSession2, nullptr);
264     sceneSession2->UpdateNativeVisibility(false);
265 
266     ssm_->sceneSessionMap_.insert({1, sceneSession1});
267     ssm_->sceneSessionMap_.insert({2, sceneSession2});
268     std::string dumpInfo;
269     ASSERT_EQ(ssm_->GetAllSessionDumpInfo(dumpInfo), WSError::WS_OK);
270 }
271 
272 /**
273  * @tc.name: GetSpecifiedSessionDumpInfo
274  * @tc.desc: SceneSesionManager test GetSpecifiedSessionDumpInfo
275  * @tc.type: FUNC
276  */
HWTEST_F(SceneSessionManagerTest4, GetSpecifiedSessionDumpInfo, Function | SmallTest | Level3)277 HWTEST_F(SceneSessionManagerTest4, GetSpecifiedSessionDumpInfo, Function | SmallTest | Level3)
278 {
279     SessionInfo info;
280     info.abilityName_ = "GetSpecifiedSessionDumpInfo";
281     info.bundleName_ = "GetSpecifiedSessionDumpInfo";
282     info.persistentId_ = 1234;
283     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
284     ASSERT_NE(sceneSession, nullptr);
285     ssm_->sceneSessionMap_.insert({1234, sceneSession});
286     std::string dumpInfo;
287     std::string strId = "1234";
288     std::vector<std::string> params_(5, "");
289     ASSERT_EQ(ssm_->GetSpecifiedSessionDumpInfo(dumpInfo, params_, strId), WSError::WS_OK);
290 }
291 
292 /**
293  * @tc.name: NotifyEnterRecentTask02
294  * @tc.desc: NotifyEnterRecentTask
295  * @tc.type: FUNC
296  */
HWTEST_F(SceneSessionManagerTest4, NotifyEnterRecentTask02, Function | SmallTest | Level3)297 HWTEST_F(SceneSessionManagerTest4, NotifyEnterRecentTask02, Function | SmallTest | Level3)
298 {
299     ASSERT_NE(nullptr, ssm_);
300     EXPECT_EQ(ssm_->NotifyEnterRecentTask(false), WSError::WS_OK);
301 }
302 
303 /**
304  * @tc.name: GetWindowStatus
305  * @tc.desc: GetWindowStatus
306  * @tc.type: FUNC
307  */
HWTEST_F(SceneSessionManagerTest4, GetWindowStatus, Function | SmallTest | Level3)308 HWTEST_F(SceneSessionManagerTest4, GetWindowStatus, Function | SmallTest | Level3)
309 {
310     ASSERT_NE(nullptr, ssm_);
311     WindowMode mode = WindowMode::WINDOW_MODE_FLOATING;
312     SessionState sessionState = SessionState::STATE_FOREGROUND;
313     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
314     ASSERT_NE(property, nullptr);
315     auto result = ssm_->GetWindowStatus(mode, sessionState, nullptr);
316     EXPECT_EQ(result, WindowStatus::WINDOW_STATUS_UNDEFINED);
317 
318     property->SetMaximizeMode(MaximizeMode::MODE_AVOID_SYSTEM_BAR);
319     result = ssm_->GetWindowStatus(mode, sessionState, property);
320     EXPECT_EQ(result, WindowStatus::WINDOW_STATUS_MAXIMIZE);
321 
322     property->SetMaximizeMode(MaximizeMode::MODE_FULL_FILL);
323     result = ssm_->GetWindowStatus(mode, sessionState, property);
324     EXPECT_EQ(result, WindowStatus::WINDOW_STATUS_FLOATING);
325 
326     mode = WindowMode::WINDOW_MODE_SPLIT_PRIMARY;
327     result = ssm_->GetWindowStatus(mode, sessionState, property);
328     EXPECT_EQ(result, WindowStatus::WINDOW_STATUS_SPLITSCREEN);
329 }
330 
331 /**
332  * @tc.name: UpdateDisplayRegion
333  * @tc.desc: UpdateDisplayRegion
334  * @tc.type: FUNC
335  */
HWTEST_F(SceneSessionManagerTest4, UpdateDisplayRegion, Function | SmallTest | Level3)336 HWTEST_F(SceneSessionManagerTest4, UpdateDisplayRegion, Function | SmallTest | Level3)
337 {
338     ASSERT_NE(nullptr, ssm_);
339     ssm_->UpdateDisplayRegion(nullptr);
340     sptr<DisplayInfo> displayInfo = sptr<DisplayInfo>::MakeSptr();
341     ASSERT_NE(displayInfo, nullptr);
342     displayInfo->SetWidth(0);
343     ssm_->UpdateDisplayRegion(displayInfo);
344 
345     displayInfo->SetWidth(1);
346     displayInfo->SetHeight(0);
347     ssm_->UpdateDisplayRegion(displayInfo);
348 
349     displayInfo->SetHeight(1);
350     ssm_->UpdateDisplayRegion(displayInfo);
351     EXPECT_EQ(WSError::WS_ERROR_INVALID_SESSION, ssm_->HandleSecureSessionShouldHide(nullptr));
352 }
353 
354 /**
355  * @tc.name: GetCustomDecorHeight
356  * @tc.desc: GetCustomDecorHeight
357  * @tc.type: FUNC
358  */
HWTEST_F(SceneSessionManagerTest4, GetCustomDecorHeight, Function | SmallTest | Level3)359 HWTEST_F(SceneSessionManagerTest4, GetCustomDecorHeight, Function | SmallTest | Level3)
360 {
361     ASSERT_NE(nullptr, ssm_);
362     SessionInfo info;
363     info.abilityName_ = "SetBrightness";
364     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
365     ASSERT_NE(sceneSession, nullptr);
366     sceneSession->SetCustomDecorHeight(50);
367     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
368     ssm_->sceneSessionMap_.insert(std::make_pair(2, nullptr));
369     EXPECT_EQ(0, ssm_->GetCustomDecorHeight(2));
370     EXPECT_EQ(50, ssm_->GetCustomDecorHeight(1));
371 }
372 
373 /**
374  * @tc.name: IsVectorSame
375  * @tc.desc: IsVectorSame
376  * @tc.type: FUNC
377  */
HWTEST_F(SceneSessionManagerTest4, IsVectorSame, Function | SmallTest | Level3)378 HWTEST_F(SceneSessionManagerTest4, IsVectorSame, Function | SmallTest | Level3)
379 {
380     ASSERT_NE(nullptr, ssm_);
381     std::vector<VisibleWindowNumInfo> lastInfo;
382     std::vector<VisibleWindowNumInfo> currentInfo;
383     VisibleWindowNumInfo num;
384     lastInfo.push_back(num);
385     EXPECT_EQ(false, ssm_->IsVectorSame(lastInfo, currentInfo));
386     lastInfo.clear();
387 
388     lastInfo.reserve(2);
389     VisibleWindowNumInfo oneNum;
390     oneNum.displayId = 0;
391     oneNum.visibleWindowNum = 3;
392     lastInfo.push_back(oneNum);
393     currentInfo.push_back(oneNum);
394     EXPECT_EQ(true, ssm_->IsVectorSame(lastInfo, currentInfo));
395 
396     currentInfo.clear();
397     VisibleWindowNumInfo twoNum;
398     twoNum.displayId = 0;
399     twoNum.visibleWindowNum = 2;
400     currentInfo.push_back(twoNum);
401     EXPECT_EQ(false, ssm_->IsVectorSame(lastInfo, currentInfo));
402 
403     currentInfo.clear();
404     twoNum.displayId = 1;
405     twoNum.visibleWindowNum = 3;
406     currentInfo.push_back(twoNum);
407     EXPECT_EQ(false, ssm_->IsVectorSame(lastInfo, currentInfo));
408 }
409 
410 /**
411  * @tc.name: ReportWindowProfileInfos
412  * @tc.desc: ReportWindowProfileInfos
413  * @tc.type: FUNC
414  */
HWTEST_F(SceneSessionManagerTest4, ReportWindowProfileInfos, Function | SmallTest | Level3)415 HWTEST_F(SceneSessionManagerTest4, ReportWindowProfileInfos, Function | SmallTest | Level3)
416 {
417     ASSERT_NE(nullptr, ssm_);
418     SessionInfo info;
419     info.abilityName_ = "SetBrightness";
420     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
421     ASSERT_NE(sceneSession, nullptr);
422     sceneSession->sessionInfo_.isSystem_ = false;
423     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
424     ssm_->ReportWindowProfileInfos();
425 
426     ssm_->focusedSessionId_ = 123;
427     ssm_->ReportWindowProfileInfos();
428     EXPECT_EQ(WSError::WS_ERROR_INVALID_SESSION, ssm_->HandleSecureSessionShouldHide(nullptr));
429 }
430 
431 /**
432  * @tc.name: ReportWindowProfileInfos02
433  * @tc.desc: ReportWindowProfileInfos
434  * @tc.type: FUNC
435  */
HWTEST_F(SceneSessionManagerTest4, ReportWindowProfileInfos02, Function | SmallTest | Level3)436 HWTEST_F(SceneSessionManagerTest4, ReportWindowProfileInfos02, Function | SmallTest | Level3)
437 {
438     ASSERT_NE(nullptr, ssm_);
439     SessionInfo info;
440     info.abilityName_ = "SetBrightness";
441     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
442     ASSERT_NE(sceneSession, nullptr);
443     sceneSession->sessionInfo_.isSystem_ = false;
444     sptr<Session> session = sptr<Session>::MakeSptr(info);
445     ASSERT_NE(session, nullptr);
446     ASSERT_NE(sceneSession->property_, nullptr);
447     sceneSession->property_->type_ = WindowType::WINDOW_TYPE_MEDIA;
448     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
449     ssm_->ReportWindowProfileInfos();
450     EXPECT_EQ(WSError::WS_ERROR_INVALID_SESSION, ssm_->HandleSecureSessionShouldHide(nullptr));
451 }
452 
453 /**
454  * @tc.name: ReportWindowProfileInfos03
455  * @tc.desc: ReportWindowProfileInfos
456  * @tc.type: FUNC
457  */
HWTEST_F(SceneSessionManagerTest4, ReportWindowProfileInfos03, Function | SmallTest | Level3)458 HWTEST_F(SceneSessionManagerTest4, ReportWindowProfileInfos03, Function | SmallTest | Level3)
459 {
460     ASSERT_NE(nullptr, ssm_);
461     SessionInfo info;
462     info.abilityName_ = "SetBrightness";
463     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
464     ASSERT_NE(sceneSession, nullptr);
465     sceneSession->sessionInfo_.isSystem_ = true;
466     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
467     ssm_->ReportWindowProfileInfos();
468     EXPECT_EQ(WSError::WS_ERROR_INVALID_SESSION, ssm_->HandleSecureSessionShouldHide(nullptr));
469 }
470 
471 /**
472  * @tc.name: ReportWindowProfileInfos04
473  * @tc.desc: ReportWindowProfileInfos
474  * @tc.type: FUNC
475  */
HWTEST_F(SceneSessionManagerTest4, ReportWindowProfileInfos04, Function | SmallTest | Level3)476 HWTEST_F(SceneSessionManagerTest4, ReportWindowProfileInfos04, Function | SmallTest | Level3)
477 {
478     ASSERT_NE(nullptr, ssm_);
479     ssm_->sceneSessionMap_.insert(std::make_pair(1, nullptr));
480     ssm_->ReportWindowProfileInfos();
481     EXPECT_EQ(WSError::WS_ERROR_INVALID_SESSION, ssm_->HandleSecureSessionShouldHide(nullptr));
482 }
483 
484 /**
485  * @tc.name: CacVisibleWindowNum
486  * @tc.desc: CacVisibleWindowNum
487  * @tc.type: FUNC
488  */
HWTEST_F(SceneSessionManagerTest4, CacVisibleWindowNum, Function | SmallTest | Level3)489 HWTEST_F(SceneSessionManagerTest4, CacVisibleWindowNum, Function | SmallTest | Level3)
490 {
491     ASSERT_NE(nullptr, ssm_);
492     SessionInfo info;
493     info.abilityName_ = "SetBrightness";
494     sptr<SceneSession> sceneSession01 = sptr<SceneSession>::MakeSptr(info, nullptr);
495     sptr<SceneSession> sceneSession02 = sptr<SceneSession>::MakeSptr(info, nullptr);
496     sptr<SceneSession> sceneSession03 = sptr<SceneSession>::MakeSptr(info, nullptr);
497     sptr<SceneSession> sceneSession04 = sptr<SceneSession>::MakeSptr(info, nullptr);
498     ASSERT_NE(sceneSession01, nullptr);
499     ASSERT_NE(sceneSession02, nullptr);
500     ASSERT_NE(sceneSession03, nullptr);
501     ASSERT_NE(sceneSession04, nullptr);
502     ASSERT_NE(sceneSession01->property_, nullptr);
503     sceneSession01->property_->type_ = WindowType::WINDOW_TYPE_WALLPAPER;
504     sceneSession01->SetRSVisible(true);
505     sceneSession02->state_ = SessionState::STATE_BACKGROUND;
506     ASSERT_NE(sceneSession03->property_, nullptr);
507     sceneSession03->property_->type_ = WindowType::APP_MAIN_WINDOW_END;
508     ASSERT_NE(sceneSession04->property_, nullptr);
509     sceneSession04->property_->type_ = WindowType::WINDOW_TYPE_WALLPAPER;
510     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession01));
511     ssm_->sceneSessionMap_.insert(std::make_pair(2, sceneSession02));
512     ssm_->sceneSessionMap_.insert(std::make_pair(3, sceneSession03));
513     ssm_->sceneSessionMap_.insert(std::make_pair(4, sceneSession04));
514     ssm_->sceneSessionMap_.insert(std::make_pair(5, nullptr));
515 
516     ssm_->CacVisibleWindowNum();
517     EXPECT_EQ(WSError::WS_ERROR_INVALID_SESSION, ssm_->HandleSecureSessionShouldHide(nullptr));
518 }
519 
520 /**
521  * @tc.name: GetAppMainSceneSession
522  * @tc.desc: GetAppMainSceneSession
523  * @tc.type: FUNC
524  */
HWTEST_F(SceneSessionManagerTest4, GetAppMainSceneSession, Function | SmallTest | Level3)525 HWTEST_F(SceneSessionManagerTest4, GetAppMainSceneSession, Function | SmallTest | Level3)
526 {
527     ASSERT_NE(nullptr, ssm_);
528     SessionInfo info;
529     info.abilityName_ = "SetBrightness";
530     sptr<SceneSession> sceneSession;
531     sptr<SceneSession> sceneSession01 = sptr<SceneSession>::MakeSptr(info, nullptr);
532     sptr<SceneSession> sceneSession02 = sptr<SceneSession>::MakeSptr(info, nullptr);
533     ASSERT_NE(sceneSession01, nullptr);
534     ASSERT_NE(sceneSession02, nullptr);
535     ssm_->sceneSessionMap_.insert(std::make_pair(0, sceneSession));
536     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession01));
537     ssm_->sceneSessionMap_.insert(std::make_pair(2, sceneSession02));
538     EXPECT_EQ(ssm_->GetAppMainSceneSession(sceneSession, 0), WSError::WS_ERROR_INVALID_SESSION);
539 
540     EXPECT_EQ(ssm_->GetAppMainSceneSession(sceneSession01, 1), WSError::WS_OK);
541 
542     ASSERT_NE(sceneSession01->property_, nullptr);
543     sceneSession01->property_->type_ = WindowType::WINDOW_TYPE_MEDIA;
544     EXPECT_EQ(ssm_->GetAppMainSceneSession(sceneSession01, 1), WSError::WS_ERROR_INVALID_CALLING);
545 
546     sceneSession01->property_->type_ = WindowType::WINDOW_TYPE_APP_SUB_WINDOW;
547     sceneSession01->property_->SetParentPersistentId(2);
548     EXPECT_EQ(ssm_->GetAppMainSceneSession(sceneSession01, 1), WSError::WS_OK);
549 }
550 
551 /**
552  * @tc.name: GetImmersiveState02
553  * @tc.desc: GetImmersiveState
554  * @tc.type: FUNC
555  */
HWTEST_F(SceneSessionManagerTest4, GetImmersiveState02, Function | SmallTest | Level3)556 HWTEST_F(SceneSessionManagerTest4, GetImmersiveState02, Function | SmallTest | Level3)
557 {
558     ASSERT_NE(nullptr, ssm_);
559 
560     SessionInfo info;
561     info.abilityName_ = "SetBrightness";
562     sptr<SceneSession> sceneSession01;
563     sptr<SceneSession> sceneSession02 = sptr<SceneSession>::MakeSptr(info, nullptr);
564     ASSERT_EQ(sceneSession01, nullptr);
565     ASSERT_NE(sceneSession02, nullptr);
566     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession01));
567     ssm_->sceneSessionMap_.insert(std::make_pair(2, sceneSession02));
568 
569     sceneSession02->property_ = nullptr;
570     EXPECT_EQ(false, ssm_->GetImmersiveState(0u));
571     sceneSession02->property_ = sptr<WindowSessionProperty>::MakeSptr();
572     ASSERT_NE(sceneSession02->property_, nullptr);
573     sceneSession02->property_->type_ = WindowType::APP_MAIN_WINDOW_END;
574     EXPECT_EQ(false, ssm_->GetImmersiveState(0u));
575     sceneSession02->property_->type_ = WindowType::APP_MAIN_WINDOW_BASE;
576     EXPECT_EQ(false, ssm_->GetImmersiveState(0u));
577     sceneSession02->state_ = SessionState::STATE_ACTIVE;
578     EXPECT_EQ(false, ssm_->GetImmersiveState(0u));
579     sceneSession02->state_ = SessionState::STATE_FOREGROUND;
580     EXPECT_EQ(false, ssm_->GetImmersiveState(0u));
581     sceneSession02->property_->SetWindowMode(WindowMode::WINDOW_MODE_UNDEFINED);
582     EXPECT_EQ(false, ssm_->GetImmersiveState(0u));
583     sceneSession02->property_->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
584     sceneSession02->property_->sysBarPropMap_[WindowType::WINDOW_TYPE_STATUS_BAR].enable_ = false;
585     EXPECT_EQ(true, ssm_->GetImmersiveState(0u));
586     sceneSession02->property_->sysBarPropMap_[WindowType::WINDOW_TYPE_STATUS_BAR].enable_ = true;
587     EXPECT_EQ(false, ssm_->GetImmersiveState(0u));
588 }
589 
590 /**
591  * @tc.name: UpdateSessionDisplayId
592  * @tc.desc: UpdateSessionDisplayId
593  * @tc.type: FUNC
594  */
HWTEST_F(SceneSessionManagerTest4, UpdateSessionDisplayId, Function | SmallTest | Level3)595 HWTEST_F(SceneSessionManagerTest4, UpdateSessionDisplayId, Function | SmallTest | Level3)
596 {
597     ASSERT_NE(nullptr, ssm_);
598     auto result = ssm_->UpdateSessionDisplayId(0, 0);
599     EXPECT_EQ(result, WSError::WS_ERROR_INVALID_WINDOW);
600 
601     SessionInfo info;
602     info.abilityName_ = "SetBrightness";
603     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
604     ASSERT_NE(sceneSession, nullptr);
605     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
606     sceneSession->sessionInfo_.screenId_ = 6;
607     result = ssm_->UpdateSessionDisplayId(1, 2);
608     EXPECT_EQ(result, WSError::WS_OK);
609 
610     sceneSession->property_ = nullptr;
611     result = ssm_->UpdateSessionDisplayId(1, 2);
612     EXPECT_EQ(result, WSError::WS_ERROR_NULLPTR);
613 }
614 
615 /**
616  * @tc.name: UpdateSessionWindowVisibilityListener02
617  * @tc.desc: UpdateSessionWindowVisibilityListener
618  * @tc.type: FUNC
619  */
HWTEST_F(SceneSessionManagerTest4, UpdateSessionWindowVisibilityListener02, Function | SmallTest | Level3)620 HWTEST_F(SceneSessionManagerTest4, UpdateSessionWindowVisibilityListener02, Function | SmallTest | Level3)
621 {
622     ASSERT_NE(nullptr, ssm_);
623     SessionInfo info;
624     info.abilityName_ = "SetBrightness";
625     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
626     ASSERT_NE(sceneSession, nullptr);
627     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
628     int32_t persistentId = 1;
629     auto result = ssm_->UpdateSessionWindowVisibilityListener(persistentId, true);
630     EXPECT_EQ(result, WSError::WS_ERROR_INVALID_PERMISSION);
631 }
632 
633 /**
634  * @tc.name: NotifySessionAINavigationBarChange
635  * @tc.desc: NotifySessionAINavigationBarChange
636  * @tc.type: FUNC
637  */
HWTEST_F(SceneSessionManagerTest4, NotifySessionAINavigationBarChange, Function | SmallTest | Level3)638 HWTEST_F(SceneSessionManagerTest4, NotifySessionAINavigationBarChange, Function | SmallTest | Level3)
639 {
640     ASSERT_NE(nullptr, ssm_);
641     SessionInfo info;
642     info.abilityName_ = "SetBrightness";
643     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
644     ASSERT_NE(sceneSession, nullptr);
645     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
646     ssm_->NotifySessionAINavigationBarChange(0);
647     ssm_->NotifySessionAINavigationBarChange(1);
648 
649     ASSERT_NE(sceneSession->property_, nullptr);
650     sceneSession->property_->type_ = WindowType::APP_SUB_WINDOW_END;
651     sceneSession->state_ = SessionState::STATE_ACTIVE;
652     ssm_->NotifySessionAINavigationBarChange(1);
653     EXPECT_EQ(WSError::WS_ERROR_INVALID_SESSION, ssm_->HandleSecureSessionShouldHide(nullptr));
654 }
655 
656 /**
657  * @tc.name: UpdateNormalSessionAvoidArea
658  * @tc.desc: UpdateNormalSessionAvoidArea
659  * @tc.type: FUNC
660  */
HWTEST_F(SceneSessionManagerTest4, UpdateNormalSessionAvoidArea, Function | SmallTest | Level3)661 HWTEST_F(SceneSessionManagerTest4, UpdateNormalSessionAvoidArea, Function | SmallTest | Level3)
662 {
663     ASSERT_NE(nullptr, ssm_);
664     int32_t persistentId = 1;
665     sptr<SceneSession> sceneSession = nullptr;
666     bool needUpdate = true;
667     ssm_->UpdateNormalSessionAvoidArea(persistentId, sceneSession, needUpdate);
668     EXPECT_EQ(needUpdate, false);
669 
670     SessionInfo info;
671     info.abilityName_ = "SetBrightness";
672     sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
673     ASSERT_NE(sceneSession, nullptr);
674     ASSERT_NE(sceneSession->property_, nullptr);
675     sceneSession->property_->type_ = WindowType::APP_SUB_WINDOW_BASE;
676     needUpdate = true;
677     ssm_->UpdateNormalSessionAvoidArea(persistentId, sceneSession, needUpdate);
678     EXPECT_EQ(needUpdate, false);
679 
680     sceneSession->property_->type_ = WindowType::APP_SUB_WINDOW_END;
681     sceneSession->isVisible_ = true;
682     needUpdate = true;
683     ssm_->UpdateNormalSessionAvoidArea(persistentId, sceneSession, needUpdate);
684     EXPECT_EQ(needUpdate, false);
685 
686     ssm_->avoidAreaListenerSessionSet_.insert(1);
687     ssm_->UpdateNormalSessionAvoidArea(persistentId, sceneSession, needUpdate);
688     EXPECT_EQ(WSError::WS_ERROR_INVALID_SESSION, ssm_->HandleSecureSessionShouldHide(nullptr));
689 }
690 
691 /**
692  * @tc.name: UpdateAvoidSessionAvoidArea
693  * @tc.desc: UpdateAvoidSessionAvoidArea
694  * @tc.type: FUNC
695  */
HWTEST_F(SceneSessionManagerTest4, UpdateAvoidSessionAvoidArea, Function | SmallTest | Level3)696 HWTEST_F(SceneSessionManagerTest4, UpdateAvoidSessionAvoidArea, Function | SmallTest | Level3)
697 {
698     ASSERT_NE(nullptr, ssm_);
699     ssm_->avoidAreaListenerSessionSet_.insert(0);
700     ssm_->avoidAreaListenerSessionSet_.insert(1);
701     SessionInfo info;
702     info.abilityName_ = "SetBrightness";
703     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
704     ASSERT_NE(sceneSession, nullptr);
705     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
706     WindowType type = WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT;
707     bool needUpdate = true;
708     ssm_->UpdateAvoidSessionAvoidArea(type, needUpdate);
709 
710     ASSERT_NE(sceneSession->property_, nullptr);
711     sceneSession->property_->type_ = WindowType::APP_MAIN_WINDOW_END;
712     sceneSession->isVisible_ = true;
713     ssm_->UpdateAvoidSessionAvoidArea(type, needUpdate);
714     EXPECT_EQ(WSError::WS_ERROR_INVALID_SESSION, ssm_->HandleSecureSessionShouldHide(nullptr));
715 }
716 
717 /**
718  * @tc.name: FindSessionByAffinity
719  * @tc.desc: FindSessionByAffinity
720  * @tc.type: FUNC
721  */
HWTEST_F(SceneSessionManagerTest4, FindSessionByAffinity, Function | SmallTest | Level3)722 HWTEST_F(SceneSessionManagerTest4, FindSessionByAffinity, Function | SmallTest | Level3)
723 {
724     ASSERT_NE(nullptr, ssm_);
725     std::string affinity = "";
726     sptr<SceneSession> sceneSession = ssm_->FindSessionByAffinity(affinity);
727     EXPECT_EQ(sceneSession, nullptr);
728 }
729 
730 /**
731  * @tc.name: SetSystemAnimatedScenes
732  * @tc.desc: SetSystemAnimatedScenes
733  * @tc.type: FUNC
734  */
HWTEST_F(SceneSessionManagerTest4, SetSystemAnimatedScenes, Function | SmallTest | Level3)735 HWTEST_F(SceneSessionManagerTest4, SetSystemAnimatedScenes, Function | SmallTest | Level3)
736 {
737     ASSERT_NE(nullptr, ssm_);
738     SystemAnimatedSceneType sceneType = SystemAnimatedSceneType::SCENE_ENTER_MISSION_CENTER;
739     auto result = ssm_->SetSystemAnimatedScenes(sceneType);
740     EXPECT_EQ(result, WMError::WM_OK);
741 }
742 
743 /**
744  * @tc.name: GetProcessDrawingState
745  * @tc.desc: GetProcessDrawingState
746  * @tc.type: FUNC
747  */
HWTEST_F(SceneSessionManagerTest4, GetProcessDrawingState, Function | SmallTest | Level3)748 HWTEST_F(SceneSessionManagerTest4, GetProcessDrawingState, Function | SmallTest | Level3)
749 {
750     ASSERT_NE(nullptr, ssm_);
751     uint64_t windowId = 10;
752     int32_t pid = 1;
753     bool currentDrawingContentState = true;
754     SessionInfo info;
755     info.abilityName_ = "SetBrightness";
756     sptr<SceneSession> sceneSession01 = nullptr;
757     sptr<SceneSession> sceneSession02 = sptr<SceneSession>::MakeSptr(info, nullptr);
758     sptr<SceneSession> sceneSession03 = sptr<SceneSession>::MakeSptr(info, nullptr);
759     sptr<SceneSession> sceneSession04 = sptr<SceneSession>::MakeSptr(info, nullptr);
760     ASSERT_NE(sceneSession02, nullptr);
761     ASSERT_NE(sceneSession03, nullptr);
762     ASSERT_NE(sceneSession04, nullptr);
763     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession01));
764     ssm_->sceneSessionMap_.insert(std::make_pair(2, sceneSession02));
765     ssm_->sceneSessionMap_.insert(std::make_pair(3, sceneSession03));
766     ssm_->sceneSessionMap_.insert(std::make_pair(4, sceneSession04));
767     sceneSession02->SetCallingPid(pid);
768     struct RSSurfaceNodeConfig config;
769     sceneSession02->surfaceNode_ = RSSurfaceNode::Create(config);
770     ASSERT_NE(sceneSession02->surfaceNode_, nullptr);
771     sceneSession03->SetCallingPid(pid);
772     sceneSession03->surfaceNode_ = nullptr;
773     sceneSession04->SetCallingPid(6);
774     auto result = ssm_->GetProcessDrawingState(windowId, pid, currentDrawingContentState);
775     EXPECT_EQ(result, true);
776 }
777 
778 /**
779  * @tc.name: GetPreWindowDrawingState
780  * @tc.desc: GetPreWindowDrawingState
781  * @tc.type: FUNC
782  */
HWTEST_F(SceneSessionManagerTest4, GetPreWindowDrawingState, Function | SmallTest | Level3)783 HWTEST_F(SceneSessionManagerTest4, GetPreWindowDrawingState, Function | SmallTest | Level3)
784 {
785     ASSERT_NE(nullptr, ssm_);
786     uint64_t surfaceId = 0;
787     int32_t pid = 10;
788     bool result = ssm_->GetPreWindowDrawingState(surfaceId, pid, true);
789     EXPECT_EQ(result, false);
790 
791     SessionInfo info;
792     info.abilityName_ = "SetBrightness";
793     sptr<SceneSession> sceneSession01 = sptr<SceneSession>::MakeSptr(info, nullptr);
794     ASSERT_NE(sceneSession01, nullptr);
795     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession01));
796     struct RSSurfaceNodeConfig config;
797     sceneSession01->surfaceNode_ = RSSurfaceNode::Create(config);
798     ASSERT_NE(sceneSession01->surfaceNode_, nullptr);
799     sceneSession01->surfaceNode_->id_ = 10;
800     surfaceId = 10;
801     result = ssm_->GetPreWindowDrawingState(surfaceId, pid, true);
802     EXPECT_EQ(result, false);
803 }
804 
805 /**
806  * @tc.name: GetWindowDrawingContentChangeInfo
807  * @tc.desc: GetWindowDrawingContentChangeInfo
808  * @tc.type: FUNC
809  */
HWTEST_F(SceneSessionManagerTest4, GetWindowDrawingContentChangeInfo, Function | SmallTest | Level3)810 HWTEST_F(SceneSessionManagerTest4, GetWindowDrawingContentChangeInfo, Function | SmallTest | Level3)
811 {
812     ASSERT_NE(nullptr, ssm_);
813     SessionInfo info;
814     info.abilityName_ = "SetBrightness";
815     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
816     ASSERT_NE(sceneSession, nullptr);
817     ssm_->sceneSessionMap_.insert(std::make_pair(0, nullptr));
818     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
819 
820     std::vector<std::pair<uint64_t, bool>> currDrawingContentData;
821     currDrawingContentData.push_back(std::make_pair(0, false));
822     currDrawingContentData.push_back(std::make_pair(1, true));
823 
824     struct RSSurfaceNodeConfig config;
825     sceneSession->surfaceNode_ = RSSurfaceNode::Create(config);
826     ASSERT_NE(sceneSession->surfaceNode_, nullptr);
827     sceneSession->surfaceNode_->id_ = 0;
828     sceneSession->SetCallingPid(0);
829     sceneSession->SetDrawingContentState(true);
830 
831     auto result = ssm_->GetWindowDrawingContentChangeInfo(currDrawingContentData);
832     EXPECT_EQ(result, currDrawingContentData);
833 
834     sceneSession->SetCallingPid(2);
835     result = ssm_->GetWindowDrawingContentChangeInfo(currDrawingContentData);
836     EXPECT_NE(result, currDrawingContentData);
837 }
838 
839 /**
840  * @tc.name: DealwithDrawingContentChange
841  * @tc.desc: DealwithDrawingContentChange
842  * @tc.type: FUNC
843  */
HWTEST_F(SceneSessionManagerTest4, DealwithDrawingContentChange, Function | SmallTest | Level3)844 HWTEST_F(SceneSessionManagerTest4, DealwithDrawingContentChange, Function | SmallTest | Level3)
845 {
846     ASSERT_NE(nullptr, ssm_);
847     SessionInfo info;
848     info.abilityName_ = "SetBrightness";
849     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
850     ASSERT_NE(sceneSession, nullptr);
851     ssm_->sceneSessionMap_.insert(std::make_pair(0, nullptr));
852 
853     std::vector<std::pair<uint64_t, bool>> drawingContentChangeInfo;
854     drawingContentChangeInfo.push_back(std::make_pair(0, true));
855     drawingContentChangeInfo.push_back(std::make_pair(1, true));
856     ssm_->DealwithDrawingContentChange(drawingContentChangeInfo);
857 
858     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
859     struct RSSurfaceNodeConfig config;
860     sceneSession->surfaceNode_ = RSSurfaceNode::Create(config);
861     ASSERT_NE(sceneSession->surfaceNode_, nullptr);
862     sceneSession->surfaceNode_->id_ = 1;
863     ssm_->DealwithDrawingContentChange(drawingContentChangeInfo);
864 
865     ssm_->openDebugTrace_ = true;
866     ssm_->DealwithDrawingContentChange(drawingContentChangeInfo);
867     EXPECT_EQ(WSError::WS_ERROR_INVALID_SESSION, ssm_->HandleSecureSessionShouldHide(nullptr));
868 }
869 
870 /**
871  * @tc.name: GetSubSceneSession
872  * @tc.desc: GetSubSceneSession
873  * @tc.type: FUNC
874  */
HWTEST_F(SceneSessionManagerTest4, GetSubSceneSession, Function | SmallTest | Level3)875 HWTEST_F(SceneSessionManagerTest4, GetSubSceneSession, Function | SmallTest | Level3)
876 {
877     ASSERT_NE(nullptr, ssm_);
878     SessionInfo info;
879     info.abilityName_ = "SetBrightness";
880     sptr<SceneSession> sceneSession01 = sptr<SceneSession>::MakeSptr(info, nullptr);
881     sptr<SceneSession> sceneSession02 = sptr<SceneSession>::MakeSptr(info, nullptr);
882     sptr<SceneSession> sceneSession03 = sptr<SceneSession>::MakeSptr(info, nullptr);
883     sptr<Session> session04 = sptr<Session>::MakeSptr(info);
884     sptr<Session> session05 = sptr<Session>::MakeSptr(info);
885     ASSERT_NE(sceneSession01, nullptr);
886     ASSERT_NE(sceneSession02, nullptr);
887     ASSERT_NE(sceneSession03, nullptr);
888     ASSERT_NE(session04, nullptr);
889     ASSERT_NE(session05, nullptr);
890     ssm_->sceneSessionMap_.insert(std::make_pair(0, nullptr));
891     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession01));
892     ssm_->sceneSessionMap_.insert(std::make_pair(2, sceneSession02));
893     ssm_->sceneSessionMap_.insert(std::make_pair(3, sceneSession03));
894     int32_t parentWindowId = INVALID_SESSION_ID;
895     sceneSession01->parentSession_ = session04;
896     sceneSession02->parentSession_ = session05;
897     session05->persistentId_ = 5;
898     std::vector<sptr<SceneSession>> subSessions = ssm_->GetSubSceneSession(parentWindowId);
899     EXPECT_EQ(subSessions.size(), 1);
900 }
901 
902 /**
903  * @tc.name: RemoveDuplicateSubSession
904  * @tc.desc: RemoveDuplicateSubSession
905  * @tc.type: FUNC
906  */
HWTEST_F(SceneSessionManagerTest4, RemoveDuplicateSubSession, Function | SmallTest | Level3)907 HWTEST_F(SceneSessionManagerTest4, RemoveDuplicateSubSession, Function | SmallTest | Level3)
908 {
909     ASSERT_NE(nullptr, ssm_);
910     std::vector<std::pair<uint64_t, WindowVisibilityState>> visibilityChangeInfo;
911     std::vector<sptr<SceneSession>> subSessions;
912     visibilityChangeInfo.push_back(std::make_pair(0, WINDOW_VISIBILITY_STATE_NO_OCCLUSION));
913     visibilityChangeInfo.push_back(std::make_pair(1, WINDOW_VISIBILITY_STATE_PARTICALLY_OCCLUSION));
914 
915     SessionInfo info;
916     info.abilityName_ = "SetBrightness";
917     sptr<SceneSession> sceneSession01 = sptr<SceneSession>::MakeSptr(info, nullptr);
918     sptr<SceneSession> sceneSession02 = sptr<SceneSession>::MakeSptr(info, nullptr);
919     sptr<SceneSession> sceneSession03 = nullptr;
920     ASSERT_NE(sceneSession01, nullptr);
921     ASSERT_NE(sceneSession02, nullptr);
922     struct RSSurfaceNodeConfig config;
923     sceneSession01->surfaceNode_ = RSSurfaceNode::Create(config);
924     ASSERT_NE(sceneSession01->surfaceNode_, nullptr);
925     sceneSession01->surfaceNode_->id_ = 0;
926 
927     ssm_->sceneSessionMap_.insert(std::make_pair(0, nullptr));
928     ssm_->RemoveDuplicateSubSession(visibilityChangeInfo, subSessions);
929 
930     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession01));
931     sceneSession02->persistentId_ = 2;
932     subSessions.push_back(sceneSession01);
933     subSessions.push_back(sceneSession02);
934     subSessions.push_back(sceneSession03);
935     ssm_->RemoveDuplicateSubSession(visibilityChangeInfo, subSessions);
936     EXPECT_EQ(WSError::WS_ERROR_INVALID_SESSION, ssm_->HandleSecureSessionShouldHide(nullptr));
937 }
938 
939 /**
940  * @tc.name: UpdateSubWindowVisibility
941  * @tc.desc: UpdateSubWindowVisibility
942  * @tc.type: FUNC
943  */
HWTEST_F(SceneSessionManagerTest4, UpdateSubWindowVisibility, Function | SmallTest | Level3)944 HWTEST_F(SceneSessionManagerTest4, UpdateSubWindowVisibility, Function | SmallTest | Level3)
945 {
946     ASSERT_NE(nullptr, ssm_);
947     SessionInfo info;
948     info.abilityName_ = "SetBrightness";
949     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
950     ASSERT_NE(sceneSession, nullptr);
951     WindowVisibilityState visibleState = WINDOW_VISIBILITY_STATE_TOTALLY_OCCUSION;
952     std::vector<std::pair<uint64_t, WindowVisibilityState>> visibilityChangeInfo;
953     std::vector<sptr<WindowVisibilityInfo>> windowVisibilityInfos;
954     std::string visibilityInfo = "";
955     std::vector<std::pair<uint64_t, WindowVisibilityState>> currVisibleData;
956     ssm_->UpdateSubWindowVisibility(sceneSession, visibleState, visibilityChangeInfo,
957                                     windowVisibilityInfos, visibilityInfo, currVisibleData);
958 
959     ASSERT_NE(sceneSession->property_, nullptr);
960     sceneSession->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_END);
961     ssm_->UpdateSubWindowVisibility(sceneSession, visibleState, visibilityChangeInfo,
962                                     windowVisibilityInfos, visibilityInfo, currVisibleData);
963 
964     sceneSession->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
965     visibleState = WINDOW_VISIBILITY_STATE_PARTICALLY_OCCLUSION;
966     ssm_->sceneSessionMap_.insert(std::make_pair(0, nullptr));
967     ssm_->UpdateSubWindowVisibility(sceneSession, visibleState, visibilityChangeInfo,
968                                     windowVisibilityInfos, visibilityInfo, currVisibleData);
969 
970     sptr<SceneSession> sceneSession01 = sptr<SceneSession>::MakeSptr(info, nullptr);
971     sptr<SceneSession> sceneSession02 = sptr<SceneSession>::MakeSptr(info, nullptr);
972     sptr<SceneSession> sceneSession03 = sptr<SceneSession>::MakeSptr(info, nullptr);
973     sptr<Session> session03 = sptr<Session>::MakeSptr(info);
974     ASSERT_NE(sceneSession01, nullptr);
975     ASSERT_NE(sceneSession02, nullptr);
976     ASSERT_NE(sceneSession03, nullptr);
977     ASSERT_NE(session03, nullptr);
978     sceneSession01->SetParentSession(session03);
979     sceneSession02->SetParentSession(session03);
980     sceneSession03->SetParentSession(session03);
981     sceneSession02->SetCallingPid(2);
982     sceneSession03->SetCallingPid(3);
983     sceneSession03->state_ = SessionState::STATE_FOREGROUND;
984     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession01));
985     ssm_->sceneSessionMap_.insert(std::make_pair(2, sceneSession02));
986     ssm_->sceneSessionMap_.insert(std::make_pair(3, sceneSession03));
987     ssm_->UpdateSubWindowVisibility(sceneSession, visibleState, visibilityChangeInfo,
988                                     windowVisibilityInfos, visibilityInfo, currVisibleData);
989     EXPECT_EQ(WSError::WS_ERROR_INVALID_SESSION, ssm_->HandleSecureSessionShouldHide(nullptr));
990 }
991 
992 /**
993  * @tc.name: SelectSesssionFromMap
994  * @tc.desc: SelectSesssionFromMap
995  * @tc.type: FUNC
996  */
HWTEST_F(SceneSessionManagerTest4, SelectSesssionFromMap, Function | SmallTest | Level3)997 HWTEST_F(SceneSessionManagerTest4, SelectSesssionFromMap, Function | SmallTest | Level3)
998 {
999     ASSERT_NE(nullptr, ssm_);
1000     uint64_t surfaceId = 6;
1001     uint64_t surfaceId02 = 7;
1002     SessionInfo info;
1003     info.abilityName_ = "SetBrightness";
1004     sptr<SceneSession> sceneSession;
1005     sptr<SceneSession> sceneSession01 = sptr<SceneSession>::MakeSptr(info, nullptr);
1006     sptr<SceneSession> sceneSession02 = sptr<SceneSession>::MakeSptr(info, nullptr);
1007     ASSERT_NE(sceneSession01, nullptr);
1008     ASSERT_NE(sceneSession02, nullptr);
1009     ssm_->sceneSessionMap_.insert(std::make_pair(0, sceneSession));
1010     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession01));
1011     ssm_->sceneSessionMap_.insert(std::make_pair(2, sceneSession02));
1012     sceneSession01->surfaceNode_ = nullptr;
1013     struct RSSurfaceNodeConfig config;
1014     sceneSession02->surfaceNode_ = RSSurfaceNode::Create(config);
1015     ASSERT_NE(sceneSession02->surfaceNode_, nullptr);
1016     NodeId id = 6;
1017     sceneSession02->surfaceNode_->SetId(id);
1018     EXPECT_EQ(sceneSession02->surfaceNode_->id_, 6);
1019 
1020     sptr<SceneSession> result = ssm_->SelectSesssionFromMap(surfaceId);
1021     EXPECT_EQ(result, sceneSession02);
1022     result = ssm_->SelectSesssionFromMap(surfaceId02);
1023     EXPECT_EQ(result, nullptr);
1024 }
1025 
1026 /**
1027  * @tc.name: GetAccessibilityWindowInfo
1028  * @tc.desc: GetAccessibilityWindowInfo
1029  * @tc.type: FUNC
1030  */
HWTEST_F(SceneSessionManagerTest4, GetAccessibilityWindowInfo, Function | SmallTest | Level3)1031 HWTEST_F(SceneSessionManagerTest4, GetAccessibilityWindowInfo, Function | SmallTest | Level3)
1032 {
1033     ASSERT_NE(nullptr, ssm_);
1034     SessionInfo info;
1035     info.abilityName_ = "SetBrightness";
1036     sptr<SceneSession> sceneSession;
1037     sptr<SceneSession> sceneSession01 = sptr<SceneSession>::MakeSptr(info, nullptr);
1038     sptr<SceneSession> sceneSession02 = sptr<SceneSession>::MakeSptr(info, nullptr);
1039     sptr<SceneSession> sceneSession03 = sptr<SceneSession>::MakeSptr(info, nullptr);
1040     sptr<SceneSession> sceneSession04 = sptr<SceneSession>::MakeSptr(info, nullptr);
1041     ASSERT_NE(sceneSession01, nullptr);
1042     ASSERT_NE(sceneSession02, nullptr);
1043     ASSERT_NE(sceneSession03, nullptr);
1044     ASSERT_NE(sceneSession04, nullptr);
1045     sceneSession01->SetForceTouchable(true);
1046     sceneSession01->isVisible_ = true;
1047     ASSERT_NE(sceneSession01->property_, nullptr);
1048     sceneSession01->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
1049     sceneSession01->property_->SetParentPersistentId(4);
1050     sceneSession02->SetForceTouchable(false);
1051     sceneSession03->SetForceTouchable(true);
1052     sceneSession03->isVisible_ = true;
1053     ASSERT_NE(sceneSession03->property_, nullptr);
1054     sceneSession03->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
1055     sceneSession03->property_->SetParentPersistentId(6);
1056     ssm_->sceneSessionMap_.insert(std::make_pair(0, sceneSession));
1057     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession01));
1058     ssm_->sceneSessionMap_.insert(std::make_pair(2, sceneSession02));
1059     ssm_->sceneSessionMap_.insert(std::make_pair(3, sceneSession03));
1060     ssm_->sceneSessionMap_.insert(std::make_pair(4, sceneSession04));
1061     std::vector<sptr<AccessibilityWindowInfo>> accessibilityInfo;
1062     auto result = ssm_->GetAccessibilityWindowInfo(accessibilityInfo);
1063     EXPECT_EQ(result, WMError::WM_OK);
1064 }
1065 
1066 /**
1067  * @tc.name: ShiftAppWindowFocus02
1068  * @tc.desc: ShiftAppWindowFocus
1069  * @tc.type: FUNC
1070  */
HWTEST_F(SceneSessionManagerTest4, ShiftAppWindowFocus02, Function | SmallTest | Level3)1071 HWTEST_F(SceneSessionManagerTest4, ShiftAppWindowFocus02, Function | SmallTest | Level3)
1072 {
1073     ASSERT_NE(ssm_, nullptr);
1074     ssm_->SetFocusedSessionId(INVALID_SESSION_ID);
1075     int32_t sourcePersistentId = INVALID_SESSION_ID;
1076     int32_t targetPersistentId = INVALID_SESSION_ID;
1077     auto result = ssm_->ShiftAppWindowFocus(sourcePersistentId, targetPersistentId);
1078     EXPECT_EQ(result, WSError::WS_DO_NOTHING);
1079 
1080     targetPersistentId = 1;
1081     result = ssm_->ShiftAppWindowFocus(sourcePersistentId, targetPersistentId);
1082     EXPECT_EQ(result, WSError::WS_ERROR_INVALID_SESSION);
1083 
1084     SessionInfo info;
1085     info.abilityName_ = "abilityName";
1086     info.bundleName_ = "bundleName";
1087     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1088     ASSERT_NE(sceneSession, nullptr);
1089     ssm_->sceneSessionMap_.insert(std::make_pair(INVALID_SESSION_ID, sceneSession));
1090     ASSERT_NE(sceneSession->property_, nullptr);
1091     sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
1092     result = ssm_->ShiftAppWindowFocus(sourcePersistentId, targetPersistentId);
1093     EXPECT_EQ(result, WSError::WS_ERROR_INVALID_SESSION);
1094 
1095     SessionInfo info01;
1096     info01.abilityName_ = "abilityName01";
1097     info01.bundleName_ = "bundleName01";
1098     sptr<SceneSession> sceneSession01 = sptr<SceneSession>::MakeSptr(info01, nullptr);
1099     ASSERT_NE(sceneSession01, nullptr);
1100     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession01));
1101     ASSERT_NE(sceneSession01->property_, nullptr);
1102     sceneSession01->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
1103     result = ssm_->ShiftAppWindowFocus(sourcePersistentId, targetPersistentId);
1104     EXPECT_EQ(result, WSError::WS_ERROR_INVALID_CALLING);
1105 }
1106 
1107 /**
1108  * @tc.name: UpdateTitleInTargetPos
1109  * @tc.desc: UpdateTitleInTargetPos
1110  * @tc.type: FUNC
1111  */
HWTEST_F(SceneSessionManagerTest4, UpdateTitleInTargetPos, Function | SmallTest | Level3)1112 HWTEST_F(SceneSessionManagerTest4, UpdateTitleInTargetPos, Function | SmallTest | Level3)
1113 {
1114     ASSERT_NE(ssm_, nullptr);
1115     SessionInfo info;
1116     info.abilityName_ = "abilityName";
1117     info.bundleName_ = "bundleName";
1118     info.isSystem_ = true;
1119     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1120     ASSERT_NE(sceneSession, nullptr);
1121     ssm_->sceneSessionMap_.insert(std::make_pair(0, sceneSession));
1122     auto result = ssm_->UpdateTitleInTargetPos(1, true, 1);
1123     ASSERT_EQ(result, WSError::WS_ERROR_INVALID_WINDOW);
1124 
1125     result = ssm_->UpdateTitleInTargetPos(0, true, 1);
1126     EXPECT_EQ(result, WSError::WS_ERROR_INVALID_SESSION);
1127 }
1128 
1129 /**
1130  * @tc.name: GetIsLayoutFullScreen
1131  * @tc.desc: GetIsLayoutFullScreen
1132  * @tc.type: FUNC
1133  */
HWTEST_F(SceneSessionManagerTest4, GetIsLayoutFullScreen, Function | SmallTest | Level3)1134 HWTEST_F(SceneSessionManagerTest4, GetIsLayoutFullScreen, Function | SmallTest | Level3)
1135 {
1136     ASSERT_NE(ssm_, nullptr);
1137     SessionInfo info;
1138     info.abilityName_ = "abilityName";
1139     info.bundleName_ = "bundleName";
1140     sptr<SceneSession> sceneSession01 = sptr<SceneSession>::MakeSptr(info, nullptr);
1141     sptr<SceneSession> sceneSession02 = sptr<SceneSession>::MakeSptr(info, nullptr);
1142     sptr<SceneSession> sceneSession03 = sptr<SceneSession>::MakeSptr(info, nullptr);
1143     sptr<SceneSession> sceneSession04 = sptr<SceneSession>::MakeSptr(info, nullptr);
1144     ASSERT_NE(sceneSession01, nullptr);
1145     ASSERT_NE(sceneSession02, nullptr);
1146     ASSERT_NE(sceneSession03, nullptr);
1147     ASSERT_NE(sceneSession04, nullptr);
1148     ASSERT_NE(sceneSession01->property_, nullptr);
1149     sceneSession01->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_END);
1150 
1151     ASSERT_NE(sceneSession02->property_, nullptr);
1152     sceneSession02->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
1153     sceneSession02->SetSessionState(SessionState::STATE_DISCONNECT);
1154 
1155     ASSERT_NE(sceneSession03->property_, nullptr);
1156     sceneSession03->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
1157     sceneSession03->SetSessionState(SessionState::STATE_ACTIVE);
1158     sceneSession03->property_->SetWindowMode(WindowMode::WINDOW_MODE_UNDEFINED);
1159 
1160     ASSERT_NE(sceneSession04->property_, nullptr);
1161     sceneSession04->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
1162     sceneSession04->SetSessionState(SessionState::STATE_FOREGROUND);
1163     sceneSession04->property_->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
1164     sceneSession04->property_->SetIsLayoutFullScreen(true);
1165 
1166     ASSERT_NE(sceneSession04->property_, nullptr);
1167     sceneSession04->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
1168     sceneSession04->SetSessionState(SessionState::STATE_FOREGROUND);
1169     sceneSession04->property_->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
1170     sceneSession04->property_->SetIsLayoutFullScreen(false);
1171 
1172     ssm_->sceneSessionMap_.insert(std::make_pair(0, nullptr));
1173     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession01));
1174     ssm_->sceneSessionMap_.insert(std::make_pair(2, sceneSession02));
1175     ssm_->sceneSessionMap_.insert(std::make_pair(3, sceneSession03));
1176     bool isLayoutFullScreen = true;
1177     auto result = ssm_->GetIsLayoutFullScreen(isLayoutFullScreen);
1178     EXPECT_EQ(result, WSError::WS_OK);
1179 }
1180 
1181 /**
1182  * @tc.name: UpdateExtWindowFlags
1183  * @tc.desc: UpdateExtWindowFlags
1184  * @tc.type: FUNC
1185  */
HWTEST_F(SceneSessionManagerTest4, UpdateExtWindowFlags, Function | SmallTest | Level3)1186 HWTEST_F(SceneSessionManagerTest4, UpdateExtWindowFlags, Function | SmallTest | Level3)
1187 {
1188     ASSERT_NE(ssm_, nullptr);
1189     uint32_t extWindowFlags = 0;
1190     uint32_t extWindowActions = 0;
1191     auto ret = ssm_->UpdateExtWindowFlags(nullptr, extWindowFlags, extWindowActions);
1192     EXPECT_EQ(ret, WSError::WS_OK);
1193 }
1194 
1195 /**
1196  * @tc.name: AddOrRemoveSecureSession02
1197  * @tc.desc: AddOrRemoveSecureSession
1198  * @tc.type: FUNC
1199  */
HWTEST_F(SceneSessionManagerTest4, AddOrRemoveSecureSession02, Function | SmallTest | Level3)1200 HWTEST_F(SceneSessionManagerTest4, AddOrRemoveSecureSession02, Function | SmallTest | Level3)
1201 {
1202     ASSERT_NE(ssm_, nullptr);
1203     int32_t persistentId = 1;
1204     bool shouldHide = true;
1205     SessionInfo info;
1206     info.abilityName_ = "secureSession";
1207     info.bundleName_ = "secureSession";
1208     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1209     ASSERT_NE(sceneSession, nullptr);
1210     ssm_->sceneSessionMap_.insert(std::make_pair(0, nullptr));
1211     ssm_->sceneSessionMap_.insert(std::make_pair(persistentId, sceneSession));
1212     auto result = ssm_->AddOrRemoveSecureSession(0, shouldHide);
1213     EXPECT_EQ(result, WSError::WS_OK);
1214     result = ssm_->AddOrRemoveSecureSession(persistentId, shouldHide);
1215     EXPECT_EQ(result, WSError::WS_OK);
1216     static constexpr uint32_t WAIT_SYNC_IN_NS = 500000;
1217     usleep(WAIT_SYNC_IN_NS);
1218 }
1219 
1220 /**
1221  * @tc.name: GetSessionSnapshotPixelMap
1222  * @tc.desc: GetSessionSnapshotPixelMap
1223  * @tc.type: FUNC
1224  */
HWTEST_F(SceneSessionManagerTest4, GetSessionSnapshotPixelMap, Function | SmallTest | Level3)1225 HWTEST_F(SceneSessionManagerTest4, GetSessionSnapshotPixelMap, Function | SmallTest | Level3)
1226 {
1227     ASSERT_NE(ssm_, nullptr);
1228     SessionInfo info;
1229     info.abilityName_ = "GetPixelMap";
1230     info.bundleName_ = "GetPixelMap1";
1231     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1232     ASSERT_NE(sceneSession, nullptr);
1233     sceneSession->SetSessionState(SessionState::STATE_ACTIVE);
1234     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
1235     int32_t persistentId = 1;
1236     float scaleParam = 0.5f;
1237     auto result = ssm_->GetSessionSnapshotPixelMap(persistentId, scaleParam);
1238     EXPECT_EQ(result, nullptr);
1239 
1240     sceneSession->SetSessionState(SessionState::STATE_FOREGROUND);
1241     std::string bundleName = "testBundleName";
1242     int32_t testpersistentId = 1;
1243     sceneSession->scenePersistence_ = sptr<ScenePersistence>::MakeSptr(bundleName, testpersistentId);
1244     ASSERT_NE(sceneSession->scenePersistence_, nullptr);
1245     struct RSSurfaceNodeConfig config;
1246     sceneSession->surfaceNode_ = RSSurfaceNode::Create(config);
1247     ASSERT_NE(sceneSession->surfaceNode_, nullptr);
1248     sceneSession->bufferAvailable_ = true;
1249     result = ssm_->GetSessionSnapshotPixelMap(persistentId, scaleParam);
1250     EXPECT_EQ(result, nullptr);
1251 }
1252 
1253 /**
1254  * @tc.name: GetStartupPageFromResource
1255  * @tc.desc: GetStartupPageFromResource
1256  * @tc.type: FUNC
1257  */
HWTEST_F(SceneSessionManagerTest4, GetStartupPageFromResource, Function | SmallTest | Level3)1258 HWTEST_F(SceneSessionManagerTest4, GetStartupPageFromResource, Function | SmallTest | Level3)
1259 {
1260     ASSERT_NE(ssm_, nullptr);
1261     AppExecFwk::AbilityInfo abilityInfo;
1262     EXPECT_EQ(ssm_->GetResourceManager(abilityInfo), nullptr);
1263     std::string path = "testPath";
1264     uint32_t bgColor = 0;
1265     bool result = ssm_->GetStartupPageFromResource(abilityInfo, path, bgColor);
1266     EXPECT_EQ(result, false);
1267 }
1268 
1269 /**
1270  * @tc.name: HandleHideNonSystemFloatingWindows
1271  * @tc.desc: HandleHideNonSystemFloatingWindows
1272  * @tc.type: FUNC
1273  */
HWTEST_F(SceneSessionManagerTest4, HandleHideNonSystemFloatingWindows, Function | SmallTest | Level3)1274 HWTEST_F(SceneSessionManagerTest4, HandleHideNonSystemFloatingWindows, Function | SmallTest | Level3)
1275 {
1276     ASSERT_NE(ssm_, nullptr);
1277     SessionInfo info;
1278     info.abilityName_ = "abilityName";
1279     info.bundleName_ = "bundleName";
1280     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1281     ASSERT_NE(property, nullptr);
1282     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1283     ASSERT_NE(sceneSession, nullptr);
1284 
1285     sceneSession->property_->hideNonSystemFloatingWindows_ = true;
1286     property->SetHideNonSystemFloatingWindows(false);
1287     sceneSession->isVisible_ = true;
1288     sceneSession->state_ = SessionState::STATE_FOREGROUND;
1289     ssm_->HandleHideNonSystemFloatingWindows(property, sceneSession);
1290 
1291     sceneSession->property_->hideNonSystemFloatingWindows_ = false;
1292     property->SetHideNonSystemFloatingWindows(true);
1293     ssm_->HandleHideNonSystemFloatingWindows(property, sceneSession);
1294 
1295     sceneSession->isVisible_ = false;
1296     ssm_->HandleHideNonSystemFloatingWindows(property, sceneSession);
1297     EXPECT_EQ(Session::IsScbCoreEnabled(), true);
1298 }
1299 
1300 /**
1301  * @tc.name: GetAllClearableSessions
1302  * @tc.desc: GetAllClearableSessions
1303  * @tc.type: FUNC
1304  */
HWTEST_F(SceneSessionManagerTest4, GetAllClearableSessions, Function | SmallTest | Level3)1305 HWTEST_F(SceneSessionManagerTest4, GetAllClearableSessions, Function | SmallTest | Level3)
1306 {
1307     SessionInfo sessionInfo;
1308     sessionInfo.bundleName_ = "bundleName";
1309     sessionInfo.abilityName_ = "abilityName";
1310     sessionInfo.abilityInfo = nullptr;
1311     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1312     ASSERT_NE(nullptr, ssm_);
1313     ASSERT_NE(nullptr, sceneSession);
1314     ssm_->sceneSessionMap_.insert(std::make_pair(2, sceneSession));
1315     SessionInfo sessionInfo1;
1316     sessionInfo1.bundleName_ = "bundleName";
1317     sessionInfo1.abilityName_ = "abilityName";
1318     sessionInfo1.abilityInfo = std::make_shared<AppExecFwk::AbilityInfo>();
1319     ASSERT_NE(nullptr, sessionInfo1.abilityInfo);
1320     sessionInfo1.abilityInfo->excludeFromMissions = false;
1321     sessionInfo1.abilityInfo->unclearableMission = false;
1322     sessionInfo1.isSystem_ = false;
1323     sessionInfo1.lockedState = false;
1324     sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(sessionInfo1, nullptr);
1325     ssm_->sceneSessionMap_.insert(std::make_pair(3, sceneSession1));
1326     std::vector<sptr<SceneSession>> sessionVector;
1327     sessionVector.clear();
1328     ssm_->GetAllClearableSessions(sessionVector);
1329     EXPECT_FALSE(sessionVector.empty());
1330 }
1331 
1332 /**
1333  * @tc.name: UpdateBrightness
1334  * @tc.desc: UpdateBrightness
1335  * @tc.type: FUNC
1336  */
HWTEST_F(SceneSessionManagerTest4, UpdateBrightness, Function | SmallTest | Level3)1337 HWTEST_F(SceneSessionManagerTest4, UpdateBrightness, Function | SmallTest | Level3)
1338 {
1339     ASSERT_NE(ssm_, nullptr);
1340     SessionInfo sessionInfo;
1341     sessionInfo.isSystem_ = false;
1342     sessionInfo.bundleName_ = "bundleName";
1343     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1344     ASSERT_NE(sceneSession, nullptr);
1345     ASSERT_NE(sceneSession->property_, nullptr);
1346     sceneSession->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_END);
1347     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
1348     WSError result = ssm_->UpdateBrightness(1);
1349     EXPECT_EQ(result, WSError::WS_DO_NOTHING);
1350 
1351     SessionInfo sessionInfo02;
1352     sessionInfo02.isSystem_ = true;
1353     sessionInfo02.bundleName_ = "bundleName";
1354     sptr<SceneSession> sceneSession02 = sptr<SceneSession>::MakeSptr(sessionInfo02, nullptr);
1355     ASSERT_NE(sceneSession02, nullptr);
1356     ASSERT_NE(sceneSession02->property_, nullptr);
1357     ssm_->sceneSessionMap_.insert(std::make_pair(2, sceneSession02));
1358     sceneSession02->property_->SetBrightness(50.f);
1359     ssm_->SetDisplayBrightness(40.f);
1360     result = ssm_->UpdateBrightness(2);
1361     EXPECT_EQ(ssm_->displayBrightness_, 50);
1362     EXPECT_EQ(result, WSError::WS_OK);
1363 }
1364 
1365 /**
1366  * @tc.name: RegisterSessionExceptionFunc
1367  * @tc.desc: RegisterSessionExceptionFunc
1368  * @tc.type: FUNC
1369  */
HWTEST_F(SceneSessionManagerTest4, RegisterSessionExceptionFunc, Function | SmallTest | Level3)1370 HWTEST_F(SceneSessionManagerTest4, RegisterSessionExceptionFunc, Function | SmallTest | Level3)
1371 {
1372     ASSERT_NE(ssm_, nullptr);
1373     SessionInfo sessionInfo;
1374     sessionInfo.bundleName_ = "bundleName";
1375     sessionInfo.persistentId_ = 1;
1376     sessionInfo.isSystem_ = true;
1377     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1378     ASSERT_NE(sceneSession, nullptr);
1379     ssm_->sceneSessionMap_.insert(std::make_pair(sessionInfo.persistentId_, sceneSession));
1380     ssm_->RegisterSessionExceptionFunc(sceneSession);
1381 
1382     sptr<AAFwk::SessionInfo> abilitySessionInfo = sptr<AAFwk::SessionInfo>::MakeSptr();
1383     ASSERT_NE(abilitySessionInfo, nullptr);
1384     WSError result = sceneSession->NotifySessionExceptionInner(abilitySessionInfo, false, false);
1385     EXPECT_EQ(result, WSError::WS_OK);
1386 
1387     abilitySessionInfo->errorCode = 1;
1388     result = sceneSession->NotifySessionExceptionInner(abilitySessionInfo, false, false);
1389     EXPECT_EQ(result, WSError::WS_OK);
1390 
1391     abilitySessionInfo->errorCode = 0;
1392     result = sceneSession->NotifySessionExceptionInner(abilitySessionInfo, false, false);
1393     EXPECT_EQ(result, WSError::WS_OK);
1394 
1395     sessionInfo.isSystem_ = false;
1396     result = sceneSession->NotifySessionExceptionInner(abilitySessionInfo, false, false);
1397     EXPECT_EQ(result, WSError::WS_OK);
1398 
1399     sessionInfo.persistentId_ = 2;
1400     result = sceneSession->NotifySessionExceptionInner(abilitySessionInfo, false, false);
1401     EXPECT_EQ(result, WSError::WS_OK);
1402     usleep(WAIT_SYNC_IN_NS);
1403 }
1404 
1405 /**
1406  * @tc.name: RegisterSessionSnapshotFunc
1407  * @tc.desc: RegisterSessionSnapshotFunc
1408  * @tc.type: FUNC
1409  */
HWTEST_F(SceneSessionManagerTest4, RegisterSessionSnapshotFunc, Function | SmallTest | Level3)1410 HWTEST_F(SceneSessionManagerTest4, RegisterSessionSnapshotFunc, Function | SmallTest | Level3)
1411 {
1412     ASSERT_NE(ssm_, nullptr);
1413     SessionInfo sessionInfo;
1414     sessionInfo.bundleName_ = "bundleName";
1415     sessionInfo.persistentId_ = 1;
1416     sessionInfo.isSystem_ = false;
1417     sessionInfo.abilityInfo = std::make_shared<AppExecFwk::AbilityInfo>();
1418     ASSERT_NE(sessionInfo.abilityInfo, nullptr);
1419     sessionInfo.abilityInfo->excludeFromMissions = true;
1420     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1421     ASSERT_NE(sceneSession, nullptr);
1422     sceneSession->scenePersistence_ = sptr<ScenePersistence>::MakeSptr("bundleName", 1);
1423     ASSERT_NE(sceneSession->scenePersistence_, nullptr);
1424     struct RSSurfaceNodeConfig rsSurfaceNodeConfig;
1425     sceneSession->surfaceNode_ = std::make_shared<RSSurfaceNode>(rsSurfaceNodeConfig, true, 0);
1426     ASSERT_NE(sceneSession->surfaceNode_, nullptr);
1427     sceneSession->surfaceNode_->bufferAvailable_ = true;
1428     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
1429     ssm_->RegisterSessionSnapshotFunc(sceneSession);
1430     EXPECT_EQ(sceneSession->Snapshot(1.f), nullptr);
1431 
1432     sessionInfo.abilityInfo->excludeFromMissions = false;
1433     EXPECT_EQ(sceneSession->Snapshot(1.f), nullptr);
1434 
1435     sessionInfo.abilityInfo = nullptr;
1436     EXPECT_EQ(sceneSession->Snapshot(1.f), nullptr);
1437 
1438     sessionInfo.isSystem_ = true;
1439     EXPECT_EQ(sceneSession->Snapshot(1.f), nullptr);
1440 
1441     sessionInfo.persistentId_ = 2;
1442     EXPECT_EQ(sceneSession->Snapshot(1.f), nullptr);
1443     usleep(WAIT_SYNC_IN_NS);
1444 }
1445 
1446 /**
1447  * @tc.name: GetSessionDumpInfo
1448  * @tc.desc: GetSessionDumpInfo
1449  * @tc.type: FUNC
1450  */
HWTEST_F(SceneSessionManagerTest4, GetSessionDumpInfo, Function | SmallTest | Level3)1451 HWTEST_F(SceneSessionManagerTest4, GetSessionDumpInfo, Function | SmallTest | Level3)
1452 {
1453     ASSERT_NE(ssm_, nullptr);
1454     std::string dumpInfo = "testDumpInfo";
1455     std::vector<std::string> params = {"testDumpInfo"};
1456     WSError result = ssm_->GetSessionDumpInfo(params, dumpInfo);
1457     EXPECT_EQ(result, WSError::WS_ERROR_INVALID_OPERATION);
1458 
1459     params.clear();
1460     params.push_back("-w");
1461     params.push_back("a");
1462     result = ssm_->GetSessionDumpInfo(params, dumpInfo);
1463     EXPECT_EQ(result, WSError::WS_ERROR_INVALID_OPERATION);
1464 
1465     params.clear();
1466     params.push_back("-b");
1467     params.push_back("a");
1468     result = ssm_->GetSessionDumpInfo(params, dumpInfo);
1469     EXPECT_EQ(result, WSError::WS_OK);
1470 
1471     params.clear();
1472     params.push_back("-p");
1473     params.push_back("1");
1474     result = ssm_->GetSessionDumpInfo(params, dumpInfo);
1475     EXPECT_EQ(result, WSError::WS_OK);
1476 
1477     params.clear();
1478     params.push_back("-b");
1479     params.push_back("a");
1480     result = ssm_->GetSessionDumpInfo(params, dumpInfo);
1481     EXPECT_EQ(result, WSError::WS_OK);
1482 
1483     params.clear();
1484     params.push_back("testDumpInfo");
1485     params.push_back("a");
1486     result = ssm_->GetSessionDumpInfo(params, dumpInfo);
1487     EXPECT_EQ(result, WSError::WS_ERROR_INVALID_OPERATION);
1488 }
1489 
1490 /**
1491  * @tc.name: IsParentSessionVisible
1492  * @tc.desc: IsParentSessionVisible
1493  * @tc.type: FUNC
1494  */
HWTEST_F(SceneSessionManagerTest4, IsParentSessionVisible, Function | SmallTest | Level3)1495 HWTEST_F(SceneSessionManagerTest4, IsParentSessionVisible, Function | SmallTest | Level3)
1496 {
1497     ASSERT_NE(ssm_, nullptr);
1498     SessionInfo sessionInfo;
1499     sessionInfo.bundleName_ = "bundleName";
1500     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1501     ASSERT_NE(sceneSession, nullptr);
1502     ASSERT_NE(sceneSession->property_, nullptr);
1503     sceneSession->property_->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
1504     sceneSession->property_->SetParentPersistentId(1);
1505     sceneSession->isVisible_ = false;
1506     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
1507     bool result = ssm_->IsParentSessionVisible(sceneSession);
1508     EXPECT_EQ(result, false);
1509 
1510     bool testRet = sceneSession->IsScbCoreEnabled();
1511     EXPECT_EQ(testRet, true);
1512 
1513     sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
1514     sceneSession->isVisible_ = true;
1515     sceneSession->SetSessionState(SessionState::STATE_FOREGROUND);
1516     result = ssm_->IsParentSessionVisible(sceneSession);
1517     EXPECT_EQ(result, true);
1518 
1519     sceneSession->property_->SetParentPersistentId(2);
1520     sceneSession->SetSessionState(SessionState::STATE_DISCONNECT);
1521     result = ssm_->IsParentSessionVisible(sceneSession);
1522     EXPECT_EQ(result, true);
1523 
1524     sceneSession->property_->SetWindowType(WindowType::SYSTEM_WINDOW_BASE);
1525     result = ssm_->IsParentSessionVisible(sceneSession);
1526     EXPECT_EQ(result, true);
1527 }
1528 
1529 /**
1530  * @tc.name: GetTopFocusableNonAppSession
1531  * @tc.desc: GetTopFocusableNonAppSession
1532  * @tc.type: FUNC
1533  */
HWTEST_F(SceneSessionManagerTest4, GetTopFocusableNonAppSession, Function | SmallTest | Level3)1534 HWTEST_F(SceneSessionManagerTest4, GetTopFocusableNonAppSession, Function | SmallTest | Level3)
1535 {
1536     ASSERT_NE(ssm_, nullptr);
1537     SessionInfo sessionInfo;
1538     sessionInfo.bundleName_ = "bundleName";
1539     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1540     ASSERT_NE(sceneSession, nullptr);
1541     ASSERT_NE(sceneSession->property_, nullptr);
1542 
1543     sceneSession->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_END);
1544     sceneSession->property_->SetFocusable(true);
1545     sceneSession->isVisible_ = true;
1546     sceneSession->state_ = SessionState::STATE_FOREGROUND;
1547     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
1548     sptr<SceneSession> result = ssm_->GetTopFocusableNonAppSession();
1549     EXPECT_EQ(result, sceneSession);
1550 
1551     sceneSession->isVisible_ = false;
1552     result = ssm_->GetTopFocusableNonAppSession();
1553     EXPECT_EQ(result, nullptr);
1554 
1555     sceneSession->property_->SetFocusable(false);
1556     result = ssm_->GetTopFocusableNonAppSession();
1557     EXPECT_EQ(result, nullptr);
1558 
1559     sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
1560     result = ssm_->GetTopFocusableNonAppSession();
1561     EXPECT_EQ(result, nullptr);
1562 }
1563 
1564 /**
1565  * @tc.name: GetNextFocusableSession
1566  * @tc.desc: GetNextFocusableSession
1567  * @tc.type: FUNC
1568  */
HWTEST_F(SceneSessionManagerTest4, GetNextFocusableSession, Function | SmallTest | Level3)1569 HWTEST_F(SceneSessionManagerTest4, GetNextFocusableSession, Function | SmallTest | Level3)
1570 {
1571     ASSERT_NE(ssm_, nullptr);
1572     SessionInfo sessionInfo;
1573     sessionInfo.bundleName_ = "bundleName";
1574     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1575     sptr<SceneSession> sceneSession02 = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1576     sptr<SceneSession> sceneSession03 = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1577     sptr<SceneSession> sceneSession04 = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1578     sptr<SceneSession> sceneSession05 = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1579     ASSERT_NE(sceneSession, nullptr);
1580     ASSERT_NE(sceneSession02, nullptr);
1581     ASSERT_NE(sceneSession03, nullptr);
1582     ASSERT_NE(sceneSession04, nullptr);
1583     ASSERT_NE(sceneSession05, nullptr);
1584     ASSERT_NE(sceneSession->property_, nullptr);
1585 
1586     sceneSession->SetForceHideState(ForceHideState::NOT_HIDDEN);
1587     sceneSession->property_->SetFocusable(true);
1588     sceneSession->property_->SetWindowType(WindowType::SYSTEM_WINDOW_BASE);
1589     sceneSession->isVisible_ = true;
1590     sceneSession->state_ = SessionState::STATE_FOREGROUND;
1591     sceneSession->SetZOrder(1);
1592 
1593     sceneSession02->SetFocusable(false);
1594     sceneSession02->SetZOrder(2);
1595 
1596     sceneSession03->SetZOrder(3);
1597 
1598     sceneSession04->SetForceHideState(ForceHideState::HIDDEN_WHEN_FOCUSED);
1599     sceneSession04->SetZOrder(4);
1600 
1601     sceneSession05->persistentId_ = 1;
1602     sceneSession05->SetZOrder(5);
1603 
1604     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
1605     ssm_->sceneSessionMap_.insert(std::make_pair(2, sceneSession02));
1606     ssm_->sceneSessionMap_.insert(std::make_pair(3, sceneSession03));
1607     ssm_->sceneSessionMap_.insert(std::make_pair(4, sceneSession04));
1608     ssm_->sceneSessionMap_.insert(std::make_pair(5, sceneSession05));
1609     sptr<SceneSession> result = ssm_->GetNextFocusableSession(1);
1610     EXPECT_EQ(result, sceneSession);
1611 }
1612 
1613 /**
1614  * @tc.name: GetTopNearestBlockingFocusSession
1615  * @tc.desc: GetTopNearestBlockingFocusSession
1616  * @tc.type: FUNC
1617  */
HWTEST_F(SceneSessionManagerTest4, GetTopNearestBlockingFocusSession, Function | SmallTest | Level3)1618 HWTEST_F(SceneSessionManagerTest4, GetTopNearestBlockingFocusSession, Function | SmallTest | Level3)
1619 {
1620     ASSERT_NE(ssm_, nullptr);
1621     SessionInfo sessionInfo;
1622     sessionInfo.bundleName_ = "bundleName";
1623     sessionInfo.isSystem_ = true;
1624     sptr<SceneSession> sceneSession01 = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1625     sptr<SceneSession> sceneSession02 = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1626     sptr<SceneSession> sceneSession03 = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1627     sptr<SceneSession> sceneSession04 = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1628     sptr<SceneSession> parentSceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1629     ASSERT_NE(sceneSession01, nullptr);
1630     ASSERT_NE(sceneSession02, nullptr);
1631     ASSERT_NE(sceneSession03, nullptr);
1632     ASSERT_NE(sceneSession04, nullptr);
1633     ASSERT_NE(parentSceneSession, nullptr);
1634 
1635     sceneSession01->SetZOrder(1);
1636     sceneSession01->isVisible_ = true;
1637     sceneSession01->SetSessionState(SessionState::STATE_FOREGROUND);
1638 
1639     sceneSession02->SetZOrder(2);
1640     sceneSession02->isVisible_ = true;
1641     sceneSession02->SetSessionState(SessionState::STATE_FOREGROUND);
1642     sceneSession02->property_->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
1643     sceneSession02->blockingFocus_ = false;
1644 
1645     sceneSession03->SetZOrder(3);
1646     sceneSession03->property_->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
1647     parentSceneSession->property_->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
1648     sceneSession03->property_->SetParentPersistentId(8);
1649 
1650     sceneSession04->SetZOrder(4);
1651     sceneSession04->property_->SetParentPersistentId(1);
1652 
1653     ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession01));
1654     ssm_->sceneSessionMap_.insert(std::make_pair(2, sceneSession02));
1655     ssm_->sceneSessionMap_.insert(std::make_pair(3, sceneSession03));
1656     ssm_->sceneSessionMap_.insert(std::make_pair(4, sceneSession04));
1657     ssm_->sceneSessionMap_.insert(std::make_pair(8, parentSceneSession));
1658 
1659     sptr<SceneSession> ret = ssm_->GetTopNearestBlockingFocusSession(0, true);
1660     EXPECT_EQ(ret, sceneSession01);
1661 
1662     ret = ssm_->GetTopNearestBlockingFocusSession(10, true);
1663     EXPECT_EQ(ret, nullptr);
1664 }
1665 
1666 /**
1667  * @tc.name: RequestFocusSpecificCheck
1668  * @tc.desc: RequestFocusSpecificCheck
1669  * @tc.type: FUNC
1670  */
HWTEST_F(SceneSessionManagerTest4, RequestFocusSpecificCheck, Function | SmallTest | Level3)1671 HWTEST_F(SceneSessionManagerTest4, RequestFocusSpecificCheck, Function | SmallTest | Level3)
1672 {
1673     ASSERT_NE(ssm_, nullptr);
1674     SessionInfo sessionInfo;
1675     sessionInfo.bundleName_ = "bundleName";
1676     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1677     ASSERT_NE(sceneSession, nullptr);
1678     bool byForeground = true;
1679     FocusChangeReason reason = FocusChangeReason::CLIENT_REQUEST;
1680     sceneSession->SetForceHideState(ForceHideState::HIDDEN_WHEN_FOCUSED);
1681     WSError result = ssm_->RequestFocusSpecificCheck(sceneSession, byForeground, reason);
1682     EXPECT_EQ(result, WSError::WS_ERROR_INVALID_OPERATION);
1683 
1684     sceneSession->SetForceHideState(ForceHideState::NOT_HIDDEN);
1685     sptr<SceneSession> sceneSession01 = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1686     ASSERT_NE(sceneSession01, nullptr);
1687     ssm_->sceneSessionMap_.insert(std::make_pair(0, sceneSession01));
1688     sceneSession01->parentSession_ = sceneSession;
1689     result = ssm_->RequestFocusSpecificCheck(sceneSession, byForeground, reason);
1690     EXPECT_EQ(result, WSError::WS_OK);
1691 }
1692 
1693 /**
1694  * @tc.name: ProcessModalExtensionPointDown
1695  * @tc.desc: ProcessModalExtensionPointDown
1696  * @tc.type: FUNC
1697  */
HWTEST_F(SceneSessionManagerTest4, ProcessModalExtensionPointDown, Function | SmallTest | Level3)1698 HWTEST_F(SceneSessionManagerTest4, ProcessModalExtensionPointDown, Function | SmallTest | Level3)
1699 {
1700     ASSERT_NE(ssm_, nullptr);
1701     sptr<IRemoteObject> token = sptr<IRemoteObjectMocker>::MakeSptr();
1702     ASSERT_NE(token, nullptr);
1703     int32_t posX = 1;
1704     int32_t posY = 1;
1705     ExtensionWindowAbilityInfo extensionWindowAbilityInfo;
1706     extensionWindowAbilityInfo.persistentId = 1;
1707     extensionWindowAbilityInfo.parentId = 2;
1708     ssm_->extSessionInfoMap_.insert(std::make_pair(token, extensionWindowAbilityInfo));
1709 
1710     SessionInfo sessionInfo;
1711     sessionInfo.bundleName_ = "bundleName";
1712     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1713     ASSERT_NE(sceneSession, nullptr);
1714     ssm_->sceneSessionMap_.insert(std::make_pair(2, sceneSession));
1715     ssm_->ProcessModalExtensionPointDown(token, posX, posY);
1716 
1717     ExtensionWindowEventInfo eventInfo;
1718     eventInfo.pid = 0;
1719     eventInfo.persistentId = 1;
1720     sceneSession->modalUIExtensionInfoList_.push_back(eventInfo);
1721     ssm_->ProcessModalExtensionPointDown(token, posX, posY);
1722 
1723     eventInfo.persistentId = 4;
1724     ssm_->ProcessModalExtensionPointDown(token, posX, posY);
1725 
1726     eventInfo.pid = 4;
1727     ssm_->ProcessModalExtensionPointDown(token, posX, posY);
1728 
1729     sceneSession->modalUIExtensionInfoList_.clear();
1730     ssm_->ProcessModalExtensionPointDown(token, posX, posY);
1731     bool result = true;
1732     EXPECT_EQ(WSError::WS_OK, ssm_->GetFreeMultiWindowEnableState(result));
1733     usleep(WAIT_SYNC_IN_NS);
1734 }
1735 }
1736 } // namespace Rosen
1737 } // namespace OHOS
1738