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