1 /*
2 * Copyright (c) 2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include <gtest/gtest.h>
17
18 #include "interfaces/include/ws_common.h"
19 #include "iremote_object_mocker.h"
20 #include "session_manager/include/scene_session_manager.h"
21 #include "session_info.h"
22 #include "session/host/include/scene_session.h"
23 #include "session_manager.h"
24
25 using namespace testing;
26 using namespace testing::ext;
27
28 namespace OHOS {
29 namespace Rosen {
30 namespace {
31 const std::string EMPTY_DEVICE_ID = "";
32 using ConfigItem = WindowSceneConfig::ConfigItem;
33 }
34 class SceneSessionManagerTest7 : public testing::Test {
35 public:
36 static void SetUpTestCase();
37 static void TearDownTestCase();
38 void SetUp() override;
39 void TearDown() override;
40
41 static bool gestureNavigationEnabled_;
42 static ProcessGestureNavigationEnabledChangeFunc callbackFunc_;
43 static sptr<SceneSessionManager> ssm_;
44 private:
45 static constexpr uint32_t WAIT_SYNC_IN_NS = 200000;
46 };
47
48 sptr<SceneSessionManager> SceneSessionManagerTest7::ssm_ = nullptr;
49
50 bool SceneSessionManagerTest7::gestureNavigationEnabled_ = true;
51 ProcessGestureNavigationEnabledChangeFunc SceneSessionManagerTest7::callbackFunc_ = [](bool enable,
__anonc154985b0202(bool enable, const std::string& bundleName, GestureBackType type) 52 const std::string& bundleName, GestureBackType type) {
53 gestureNavigationEnabled_ = enable;
54 };
55
WindowChangedFuncTest(int32_t persistentId,WindowUpdateType type)56 void WindowChangedFuncTest(int32_t persistentId, WindowUpdateType type)
57 {
58 }
59
ProcessStatusBarEnabledChangeFuncTest(bool enable)60 void ProcessStatusBarEnabledChangeFuncTest(bool enable)
61 {
62 }
63
DumpRootSceneElementInfoFuncTest(const std::vector<std::string> & params,std::vector<std::string> & infos)64 void DumpRootSceneElementInfoFuncTest(const std::vector<std::string>& params, std::vector<std::string>& infos)
65 {
66 }
67
SetUpTestCase()68 void SceneSessionManagerTest7::SetUpTestCase()
69 {
70 ssm_ = &SceneSessionManager::GetInstance();
71 }
72
TearDownTestCase()73 void SceneSessionManagerTest7::TearDownTestCase()
74 {
75 ssm_ = nullptr;
76 }
77
SetUp()78 void SceneSessionManagerTest7::SetUp()
79 {
80 ssm_->sceneSessionMap_.clear();
81 }
82
TearDown()83 void SceneSessionManagerTest7::TearDown()
84 {
85 usleep(WAIT_SYNC_IN_NS);
86 ssm_->sceneSessionMap_.clear();
87 }
88
89 namespace {
90 /**
91 * @tc.name: UpdateSessionWindowVisibilityListener
92 * @tc.desc: UpdateSessionWindowVisibilityListener
93 * @tc.type: FUNC
94 */
95 HWTEST_F(SceneSessionManagerTest7, UpdateSessionWindowVisibilityListener, Function | SmallTest | Level3)
96 {
97 int32_t persistentId = 1;
98 bool haveListener = true;
99 ASSERT_NE(nullptr, ssm_);
100 ssm_->sceneSessionMap_.clear();
101 auto ret = ssm_->UpdateSessionWindowVisibilityListener(persistentId, haveListener);
102 EXPECT_EQ(ret, WSError::WS_DO_NOTHING);
103 SessionInfo sessionInfo;
104 sessionInfo.bundleName_ = "SceneSessionManagerTest7";
105 sessionInfo.abilityName_ = "UpdateSessionWindowVisibilityListener";
106 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
107 ASSERT_NE(nullptr, sceneSession);
108 sceneSession->callingPid_ = 65535;
109 ssm_->sceneSessionMap_.insert(std::make_pair(persistentId, sceneSession));
110 ret = ssm_->UpdateSessionWindowVisibilityListener(persistentId, haveListener);
111 EXPECT_EQ(ret, WSError::WS_ERROR_INVALID_PERMISSION);
112 }
113
114 /**
115 * @tc.name: ProcessVirtualPixelRatioChange
116 * @tc.desc: ProcessVirtualPixelRatioChange
117 * @tc.type: FUNC
118 */
119 HWTEST_F(SceneSessionManagerTest7, ProcessVirtualPixelRatioChange, Function | SmallTest | Level3)
120 {
121 DisplayId defaultDisplayId = 0;
122 sptr<DisplayInfo> displayInfo = nullptr;
123 std::map<DisplayId, sptr<DisplayInfo>> displayInfoMap;
124 DisplayStateChangeType type = DisplayStateChangeType::BEFORE_SUSPEND;
125 ASSERT_NE(nullptr, ssm_);
126 ssm_->ProcessVirtualPixelRatioChange(defaultDisplayId, displayInfo, displayInfoMap, type);
127 displayInfo = sptr<DisplayInfo>::MakeSptr();
128 ASSERT_NE(nullptr, displayInfo);
129 ssm_->sceneSessionMap_.clear();
130 ssm_->ProcessVirtualPixelRatioChange(defaultDisplayId, displayInfo, displayInfoMap, type);
131 SessionInfo sessionInfo;
132 sessionInfo.bundleName_ = "SceneSessionManagerTest6";
133 sessionInfo.abilityName_ = "UpdateAvoidArea";
134 sessionInfo.isSystem_ = true;
135 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
136 ASSERT_NE(nullptr, sceneSession);
137 ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
138 ssm_->ProcessVirtualPixelRatioChange(defaultDisplayId, displayInfo, displayInfoMap, type);
139 sessionInfo.isSystem_ = false;
140 ssm_->ProcessVirtualPixelRatioChange(defaultDisplayId, displayInfo, displayInfoMap, type);
141 sceneSession->SetSessionState(SessionState::STATE_FOREGROUND);
142 ssm_->ProcessVirtualPixelRatioChange(defaultDisplayId, displayInfo, displayInfoMap, type);
143 sceneSession->SetSessionState(SessionState::STATE_ACTIVE);
144 ssm_->ProcessVirtualPixelRatioChange(defaultDisplayId, displayInfo, displayInfoMap, type);
145 sceneSession->SetSessionState(SessionState::STATE_INACTIVE);
146 ssm_->ProcessVirtualPixelRatioChange(defaultDisplayId, displayInfo, displayInfoMap, type);
147 sceneSession = nullptr;
148 ssm_->ProcessVirtualPixelRatioChange(defaultDisplayId, displayInfo, displayInfoMap, type);
149 }
150
151 /**
152 * @tc.name: ProcessVirtualPixelRatioChange01
153 * @tc.desc: ProcessVirtualPixelRatioChange
154 * @tc.type: FUNC
155 */
156 HWTEST_F(SceneSessionManagerTest7, ProcessVirtualPixelRatioChange01, Function | SmallTest | Level3)
157 {
158 DisplayId defaultDisplayId = 0;
159 sptr<DisplayInfo> displayInfo = sptr<DisplayInfo>::MakeSptr();
160 std::map<DisplayId, sptr<DisplayInfo>> displayInfoMap;
161 DisplayStateChangeType type = DisplayStateChangeType::BEFORE_SUSPEND;
162 ASSERT_NE(nullptr, displayInfo);
163 ASSERT_NE(nullptr, ssm_);
164 ssm_->processVirtualPixelRatioChangeFunc_ = nullptr;
165 displayInfo->SetVirtualPixelRatio(0.1f);
166 displayInfo->SetDensityInCurResolution(0.1f);
167 ssm_->ProcessVirtualPixelRatioChange(defaultDisplayId, displayInfo, displayInfoMap, type);
__anonc154985b0402(float ratio, const OHOS::Rosen::Rect& rect) 168 ProcessVirtualPixelRatioChangeFunc func = [](float ratio, const OHOS::Rosen::Rect& rect) {};
169 ssm_->SetVirtualPixelRatioChangeListener(func);
170 ASSERT_NE(nullptr, ssm_->processVirtualPixelRatioChangeFunc_);
171 ssm_->ProcessVirtualPixelRatioChange(defaultDisplayId, displayInfo, displayInfoMap, type);
172 displayInfo->SetDensityInCurResolution(0.2f);
173 ssm_->ProcessVirtualPixelRatioChange(defaultDisplayId, displayInfo, displayInfoMap, type);
174 ssm_->processVirtualPixelRatioChangeFunc_ = nullptr;
175 ssm_->ProcessVirtualPixelRatioChange(defaultDisplayId, displayInfo, displayInfoMap, type);
176 }
177
178 /**
179 * @tc.name: ProcessUpdateRotationChange
180 * @tc.desc: ProcessUpdateRotationChange
181 * @tc.type: FUNC
182 */
183 HWTEST_F(SceneSessionManagerTest7, ProcessUpdateRotationChange, Function | SmallTest | Level3)
184 {
185 DisplayId defaultDisplayId = 0;
186 sptr<DisplayInfo> displayInfo = nullptr;
187 std::map<DisplayId, sptr<DisplayInfo>> displayInfoMap;
188 DisplayStateChangeType type = DisplayStateChangeType::BEFORE_SUSPEND;
189 ASSERT_NE(nullptr, ssm_);
190 ssm_->ProcessUpdateRotationChange(defaultDisplayId, displayInfo, displayInfoMap, type);
191 displayInfo = sptr<DisplayInfo>::MakeSptr();
192 ASSERT_NE(nullptr, displayInfo);
193 SessionInfo sessionInfo;
194 sessionInfo.bundleName_ = "SceneSessionManagerTest6";
195 sessionInfo.abilityName_ = "UpdateAvoidArea";
196 sessionInfo.isSystem_ = true;
197 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
198 ASSERT_NE(nullptr, sceneSession);
199 ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
200 sceneSession->SetSessionState(SessionState::STATE_FOREGROUND);
201 ssm_->ProcessUpdateRotationChange(defaultDisplayId, displayInfo, displayInfoMap, type);
202 sceneSession->SetSessionState(SessionState::STATE_ACTIVE);
203 ssm_->ProcessUpdateRotationChange(defaultDisplayId, displayInfo, displayInfoMap, type);
204 sceneSession->SetSessionState(SessionState::STATE_INACTIVE);
205 ssm_->ProcessUpdateRotationChange(defaultDisplayId, displayInfo, displayInfoMap, type);
206 WSRectF bounds = { 0, 0, 0, 0 };
207 sceneSession->SetBounds(bounds);
208 displayInfo->width_ = 0;
209 displayInfo->height_ = 0;
210 Rotation rotation = Rotation::ROTATION_0;
211 sceneSession->SetRotation(rotation);
212 displayInfo->SetRotation(rotation);
213 ssm_->ProcessUpdateRotationChange(defaultDisplayId, displayInfo, displayInfoMap, type);
214 }
215
216 /**
217 * @tc.name: FlushUIParams
218 * @tc.desc: FlushUIParams
219 * @tc.type: FUNC
220 */
221 HWTEST_F(SceneSessionManagerTest7, FlushUIParams, Function | SmallTest | Level3)
222 {
223 SessionInfo sessionInfo;
224 sessionInfo.bundleName_ = "SceneSessionManagerTest7";
225 sessionInfo.abilityName_ = "FlushUIParams";
226 sessionInfo.screenId_ = 1;
227 ScreenId screenId = 2;
228 std::unordered_map<int32_t, SessionUIParam> uiParams;
229 uiParams.clear();
230 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
231 ASSERT_NE(nullptr, sceneSession);
232 ASSERT_NE(nullptr, sceneSession->property_);
233 sceneSession->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
234 ASSERT_NE(nullptr, ssm_);
235 ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
236 ssm_->FlushUIParams(screenId, std::move(uiParams));
237 sceneSession->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_END);
238 ssm_->FlushUIParams(screenId, std::move(uiParams));
239 }
240
241 /**
242 * @tc.name: FlushUIParams01
243 * @tc.desc: FlushUIParams
244 * @tc.type: FUNC
245 */
246 HWTEST_F(SceneSessionManagerTest7, FlushUIParams01, Function | SmallTest | Level3)
247 {
248 SessionInfo sessionInfo;
249 sessionInfo.bundleName_ = "SceneSessionManagerTest7";
250 sessionInfo.abilityName_ = "FlushUIParams01";
251 sessionInfo.screenId_ = 2;
252 ScreenId screenId = 2;
253 std::unordered_map<int32_t, SessionUIParam> uiParams;
254 uiParams.clear();
255 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
256 ASSERT_NE(nullptr, sceneSession);
257 ASSERT_NE(nullptr, sceneSession->property_);
258 sceneSession->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
259 sceneSession->persistentId_ = 1;
260 ASSERT_NE(nullptr, ssm_);
261 ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
262 SessionUIParam sessionUIParam;
263 uiParams.insert(std::make_pair(1, sessionUIParam));
264 ssm_->FlushUIParams(screenId, std::move(uiParams));
265 sessionInfo.screenId_ = -1ULL;
266 ssm_->FlushUIParams(screenId, std::move(uiParams));
267 }
268
269 /**
270 * @tc.name: RegisterIAbilityManagerCollaborator
271 * @tc.desc: RegisterIAbilityManagerCollaborator
272 * @tc.type: FUNC
273 */
274 HWTEST_F(SceneSessionManagerTest7, RegisterIAbilityManagerCollaborator, Function | SmallTest | Level3)
275 {
276 int32_t type = 0;
277 sptr<AAFwk::IAbilityManagerCollaborator> impl = nullptr;
278 ASSERT_NE(nullptr, ssm_);
279 auto ret = ssm_->RegisterIAbilityManagerCollaborator(type, impl);
280 EXPECT_EQ(ret, WSError::WS_ERROR_INVALID_PERMISSION);
281 }
282
283 /**
284 * @tc.name: ProcessBackEvent
285 * @tc.desc: ProcessBackEvent
286 * @tc.type: FUNC
287 */
288 HWTEST_F(SceneSessionManagerTest7, ProcessBackEvent, Function | SmallTest | Level3)
289 {
290 SessionInfo sessionInfo;
291 sessionInfo.bundleName_ = "SceneSessionManagerTest7";
292 sessionInfo.abilityName_ = "FlushUIParams01";
293 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
294 ASSERT_NE(nullptr, sceneSession);
295 ASSERT_NE(nullptr, ssm_);
296 ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
297 auto focusGroup = ssm_->windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID);
298 focusGroup->SetFocusedSessionId(1);
299 ssm_->needBlockNotifyFocusStatusUntilForeground_ = true;
300 auto ret = ssm_->ProcessBackEvent();
301 EXPECT_EQ(ret, WSError::WS_OK);
302 ssm_->needBlockNotifyFocusStatusUntilForeground_ = false;
303 sessionInfo.isSystem_ = true;
304 ssm_->rootSceneProcessBackEventFunc_ = nullptr;
305 ret = ssm_->ProcessBackEvent();
306 EXPECT_EQ(ret, WSError::WS_OK);
__anonc154985b0502()307 RootSceneProcessBackEventFunc func = [](){};
308 ssm_->rootSceneProcessBackEventFunc_ = func;
309 ASSERT_NE(nullptr, ssm_->rootSceneProcessBackEventFunc_);
310 ret = ssm_->ProcessBackEvent();
311 EXPECT_EQ(ret, WSError::WS_OK);
312 sessionInfo.isSystem_ = false;
313 ret = ssm_->ProcessBackEvent();
314 EXPECT_EQ(ret, WSError::WS_OK);
315 ssm_->rootSceneProcessBackEventFunc_ = nullptr;
316 ret = ssm_->ProcessBackEvent();
317 EXPECT_EQ(ret, WSError::WS_OK);
318 }
319
320 /**
321 * @tc.name: DestroySpecificSession
322 * @tc.desc: DestroySpecificSession
323 * @tc.type: FUNC
324 */
325 HWTEST_F(SceneSessionManagerTest7, DestroySpecificSession, Function | SmallTest | Level3)
326 {
327 ASSERT_NE(nullptr, ssm_);
328 ssm_->remoteObjectMap_.clear();
329 sptr<IRemoteObject> remoteObject = sptr<IRemoteObjectMocker>::MakeSptr();
330 ASSERT_NE(nullptr, remoteObject);
331 ssm_->DestroySpecificSession(remoteObject);
332 ssm_->remoteObjectMap_.insert(std::make_pair(remoteObject, 1));
333 SessionInfo sessionInfo;
334 sessionInfo.bundleName_ = "SceneSessionManagerTest7";
335 sessionInfo.abilityName_ = "DestroySpecificSession";
336 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
337 ASSERT_NE(nullptr, sceneSession);
338 ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
339 ssm_->DestroySpecificSession(remoteObject);
340 sceneSession = nullptr;
341 ssm_->DestroySpecificSession(remoteObject);
342 }
343
344 /**
345 * @tc.name: DestroyAndDisconnectSpecificSessionWithDetachCallback
346 * @tc.desc: DestroyAndDisconnectSpecificSessionWithDetachCallback
347 * @tc.type: FUNC
348 */
349 HWTEST_F(SceneSessionManagerTest7, DestroyAndDisconnectSpecificSessionWithDetachCallback,
350 Function | SmallTest | Level3)
351 {
352 int32_t persistentId = 1;
353 sptr<IRemoteObject> callback = sptr<IRemoteObjectMocker>::MakeSptr();
354 ASSERT_NE(nullptr, callback);
355 SessionInfo sessionInfo;
356 sessionInfo.bundleName_ = "SceneSessionManagerTest7";
357 sessionInfo.abilityName_ = "DestroyAndDisconnectSpecificSessionWithDetachCallback";
358 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
359 ASSERT_NE(nullptr, sceneSession);
360 sceneSession->SetCallingUid(1);
361 ASSERT_NE(nullptr, ssm_);
362 ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
363 auto ret = ssm_->DestroyAndDisconnectSpecificSessionWithDetachCallback(persistentId, callback);
364 EXPECT_EQ(ret, WSError::WS_ERROR_INVALID_PERMISSION);
365 }
366
367 /**
368 * @tc.name: DestroyAndDisconnectSpecificSessionInner
369 * @tc.desc: DestroyAndDisconnectSpecificSessionInner
370 * @tc.type: FUNC
371 */
372 HWTEST_F(SceneSessionManagerTest7, DestroyAndDisconnectSpecificSessionInner, Function | SmallTest | Level3)
373 {
374 SessionInfo sessionInfo;
375 sessionInfo.bundleName_ = "SceneSessionManagerTest7";
376 sessionInfo.abilityName_ = "DestroyAndDisconnectSpecificSessionInner";
377 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
378 ASSERT_NE(nullptr, sceneSession);
379 ASSERT_NE(nullptr, sceneSession->property_);
380 sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
381 sceneSession->SetParentPersistentId(2);
382 SessionInfo sessionInfo1;
383 sessionInfo1.bundleName_ = "SceneSessionManagerTest7";
384 sessionInfo1.abilityName_ = "ParentSceneSession";
385 sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(sessionInfo1, nullptr);
386 ASSERT_NE(nullptr, sceneSession1);
387 ASSERT_NE(nullptr, ssm_);
388 ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
389 ssm_->sceneSessionMap_.insert(std::make_pair(2, sceneSession1));
390 auto ret = ssm_->DestroyAndDisconnectSpecificSessionInner(1);
391 EXPECT_EQ(ret, WSError::WS_OK);
392 sceneSession1 = nullptr;
393 ret = ssm_->DestroyAndDisconnectSpecificSessionInner(2);
394 EXPECT_EQ(ret, WSError::WS_OK);
395 }
396
397 /**
398 * @tc.name: DestroyAndDisconnectSpecificSessionInner01
399 * @tc.desc: DestroyAndDisconnectSpecificSessionInner
400 * @tc.type: FUNC
401 */
402 HWTEST_F(SceneSessionManagerTest7, DestroyAndDisconnectSpecificSessionInner01, Function | SmallTest | Level3)
403 {
404 SessionInfo sessionInfo;
405 sessionInfo.bundleName_ = "SceneSessionManagerTest7";
406 sessionInfo.abilityName_ = "DestroyAndDisconnectSpecificSessionInner";
407 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
408 ASSERT_NE(nullptr, sceneSession);
409 ASSERT_NE(nullptr, sceneSession->property_);
410 sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_TOAST);
411 sceneSession->SetParentPersistentId(2);
412 SessionInfo sessionInfo1;
413 sessionInfo1.bundleName_ = "SceneSessionManagerTest7";
414 sessionInfo1.abilityName_ = "ParentSceneSession";
415 sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(sessionInfo1, nullptr);
416 ASSERT_NE(nullptr, sceneSession1);
417 ASSERT_NE(nullptr, ssm_);
418 ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
419 ssm_->sceneSessionMap_.insert(std::make_pair(2, sceneSession1));
420 auto ret = ssm_->DestroyAndDisconnectSpecificSessionInner(1);
421 EXPECT_EQ(ret, WSError::WS_OK);
422 sceneSession1 = nullptr;
423 ret = ssm_->DestroyAndDisconnectSpecificSessionInner(2);
424 EXPECT_EQ(ret, WSError::WS_OK);
425 }
426
427 /**
428 * @tc.name: DestroyAndDisconnectSpecificSessionInner02
429 * @tc.desc: DestroyAndDisconnectSpecificSessionInner
430 * @tc.type: FUNC
431 */
432 HWTEST_F(SceneSessionManagerTest7, DestroyAndDisconnectSpecificSessionInner02, Function | SmallTest | Level3)
433 {
434 SessionInfo sessionInfo;
435 sessionInfo.bundleName_ = "SceneSessionManagerTest7";
436 sessionInfo.abilityName_ = "DestroyAndDisconnectSpecificSessionInner";
437 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
438 ASSERT_NE(nullptr, sceneSession);
439 ASSERT_NE(nullptr, sceneSession->property_);
440 sceneSession->property_->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
441 sceneSession->SetParentPersistentId(2);
442 SessionInfo sessionInfo1;
443 sessionInfo1.bundleName_ = "SceneSessionManagerTest7";
444 sessionInfo1.abilityName_ = "ParentSceneSession";
445 sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(sessionInfo1, nullptr);
446 ASSERT_NE(nullptr, sceneSession1);
447 ASSERT_NE(nullptr, ssm_);
448 ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
449 ssm_->sceneSessionMap_.insert(std::make_pair(2, sceneSession1));
450 auto ret = ssm_->DestroyAndDisconnectSpecificSessionInner(1);
451 EXPECT_EQ(ret, WSError::WS_OK);
452 sceneSession1 = nullptr;
453 ret = ssm_->DestroyAndDisconnectSpecificSessionInner(2);
454 EXPECT_EQ(ret, WSError::WS_OK);
455 }
456
457 /**
458 * @tc.name: DestroyAndDisconnectSpecificSessionInner03
459 * @tc.desc: DestroyAndDisconnectSpecificSessionInner
460 * @tc.type: FUNC
461 */
462 HWTEST_F(SceneSessionManagerTest7, DestroyAndDisconnectSpecificSessionInner03, Function | SmallTest | Level3)
463 {
464 SessionInfo sessionInfo;
465 sessionInfo.bundleName_ = "SceneSessionManagerTest7";
466 sessionInfo.abilityName_ = "DestroyAndDisconnectSpecificSessionInner03";
467 sptr<SceneSession> floatSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
468 floatSession->property_->SetWindowType(WindowType::WINDOW_TYPE_FLOAT);
469 floatSession->persistentId_ = 1;
470 sptr<SceneSession> subSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
471 subSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
472 subSession->persistentId_ = 2;
473 subSession->SetParentSession(floatSession);
474 floatSession->subSession_.push_back(subSession);
475 ASSERT_NE(nullptr, ssm_);
476 ssm_->sceneSessionMap_.insert(std::make_pair(1, floatSession));
477 ssm_->sceneSessionMap_.insert(std::make_pair(2, subSession));
478 auto ret = ssm_->DestroyAndDisconnectSpecificSessionInner(1);
479 EXPECT_EQ(ret, WSError::WS_OK);
480 EXPECT_EQ(ssm_->sceneSessionMap_.find(2), ssm_->sceneSessionMap_.end());
481 ret = ssm_->DestroyAndDisconnectSpecificSessionInner(2);
482 EXPECT_EQ(ret, WSError::WS_ERROR_NULLPTR);
483 }
484
485 /**
486 * @tc.name: CheckPiPPriority
487 * @tc.desc: CheckPiPPriority
488 * @tc.type: FUNC
489 */
490 HWTEST_F(SceneSessionManagerTest7, CheckPiPPriority, Function | SmallTest | Level3)
491 {
492 SessionInfo sessionInfo;
493 sessionInfo.bundleName_ = "SceneSessionManagerTest7";
494 sessionInfo.abilityName_ = "CheckPiPPriority";
495 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
496 ASSERT_NE(nullptr, sceneSession);
497 ASSERT_NE(nullptr, sceneSession->property_);
498 sceneSession->property_->SetWindowMode(WindowMode::WINDOW_MODE_PIP);
499 PiPTemplateInfo pipTemplateInfo;
500 pipTemplateInfo.priority = 0;
501 sceneSession->pipTemplateInfo_.priority = 1;
502 sceneSession->state_ = SessionState::STATE_FOREGROUND;
503 ASSERT_NE(nullptr, ssm_);
504 ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
505 auto ret = ssm_->CheckPiPPriority(pipTemplateInfo);
506 EXPECT_EQ(ret, false);
507 sceneSession->state_ = SessionState::STATE_ACTIVE;
508 ret = ssm_->CheckPiPPriority(pipTemplateInfo);
509 EXPECT_EQ(ret, false);
510 pipTemplateInfo.priority = 1;
511 ret = ssm_->CheckPiPPriority(pipTemplateInfo);
512 EXPECT_EQ(ret, true);
513 sceneSession->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
514 ret = ssm_->CheckPiPPriority(pipTemplateInfo);
515 EXPECT_EQ(ret, true);
516 sceneSession = nullptr;
517 ret = ssm_->CheckPiPPriority(pipTemplateInfo);
518 EXPECT_EQ(ret, true);
519 }
520
521 /**
522 * @tc.name: IsSessionVisibleForeground
523 * @tc.desc: IsSessionVisibleForeground
524 * @tc.type: FUNC
525 */
526 HWTEST_F(SceneSessionManagerTest7, IsSessionVisibleForeground, Function | SmallTest | Level3)
527 {
528 sptr<SceneSession> session = nullptr;
529 ASSERT_NE(nullptr, ssm_);
530 auto ret = ssm_->IsSessionVisibleForeground(session);
531 EXPECT_EQ(ret, false);
532 SessionInfo sessionInfo;
533 sessionInfo.bundleName_ = "SceneSessionManagerTest7";
534 sessionInfo.abilityName_ = "IsSessionVisibleForeground";
535 session = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
536 ASSERT_NE(nullptr, session);
537 session->isVisible_ = false;
538 ret = ssm_->IsSessionVisibleForeground(session);
539 EXPECT_EQ(ret, false);
540 }
541
542 /**
543 * @tc.name: GetAllSessionDumpInfo
544 * @tc.desc: GetAllSessionDumpInfo
545 * @tc.type: FUNC
546 */
547 HWTEST_F(SceneSessionManagerTest7, GetAllSessionDumpInfo, Function | SmallTest | Level3)
548 {
549 SessionInfo sessionInfo;
550 sessionInfo.bundleName_ = "SceneSessionManagerTest7";
551 sessionInfo.abilityName_ = "GetAllSessionDumpInfo";
552 sessionInfo.isSystem_ = false;
553 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
554 ASSERT_NE(nullptr, sceneSession);
555 sceneSession->state_ = SessionState::STATE_DISCONNECT;
556 ASSERT_NE(nullptr, ssm_);
557 ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
558 std::string dumpInfo = "";
559 auto ret = ssm_->GetAllSessionDumpInfo(dumpInfo);
560 EXPECT_EQ(ret, WSError::WS_OK);
561 sceneSession->state_ = SessionState::STATE_END;
562 ret = ssm_->GetAllSessionDumpInfo(dumpInfo);
563 EXPECT_EQ(ret, WSError::WS_OK);
564 sceneSession->state_ = SessionState::STATE_ACTIVE;
565 ret = ssm_->GetAllSessionDumpInfo(dumpInfo);
566 EXPECT_EQ(ret, WSError::WS_OK);
567 sessionInfo.isSystem_ = true;
568 ret = ssm_->GetAllSessionDumpInfo(dumpInfo);
569 EXPECT_EQ(ret, WSError::WS_OK);
570 sceneSession = nullptr;
571 ret = ssm_->GetAllSessionDumpInfo(dumpInfo);
572 EXPECT_EQ(ret, WSError::WS_OK);
573 }
574
575 /**
576 * @tc.name: GetAllSessionDumpInfo01
577 * @tc.desc: GetAllSessionDumpInfo
578 * @tc.type: FUNC
579 */
580 HWTEST_F(SceneSessionManagerTest7, GetAllSessionDumpInfo01, Function | SmallTest | Level3)
581 {
582 SessionInfo sessionInfo;
583 sessionInfo.bundleName_ = "SceneSessionManagerTest7";
584 sessionInfo.abilityName_ = "GetAllSessionDumpInfo01";
585 sessionInfo.isSystem_ = true;
586 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
587 ASSERT_NE(nullptr, sceneSession);
588 sceneSession->isVisible_ = true;
589 ASSERT_NE(nullptr, ssm_);
590 ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
591 std::string dumpInfo = "";
592 auto ret = ssm_->GetAllSessionDumpInfo(dumpInfo);
593 EXPECT_EQ(ret, WSError::WS_OK);
594 sceneSession->isVisible_ = false;
595 ret = ssm_->GetAllSessionDumpInfo(dumpInfo);
596 EXPECT_EQ(ret, WSError::WS_OK);
597 }
598
599 /**
600 * @tc.name: UpdateNormalSessionAvoidArea
601 * @tc.desc: UpdateNormalSessionAvoidArea
602 * @tc.type: FUNC
603 */
604 HWTEST_F(SceneSessionManagerTest7, UpdateNormalSessionAvoidArea, Function | SmallTest | Level3)
605 {
606 SessionInfo sessionInfo;
607 sessionInfo.bundleName_ = "SceneSessionManagerTest7";
608 sessionInfo.abilityName_ = "UpdateNormalSessionAvoidArea";
609 sessionInfo.isSystem_ = true;
610 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
611 ASSERT_NE(nullptr, sceneSession);
612 sceneSession->isVisible_ = true;
613 sceneSession->state_ = SessionState::STATE_FOREGROUND;
614 int32_t persistentId = 1;
615 bool needUpdate = true;
616 ASSERT_NE(nullptr, ssm_);
617 ssm_->avoidAreaListenerSessionSet_.clear();
618 ssm_->UpdateNormalSessionAvoidArea(persistentId, sceneSession, needUpdate);
619 sceneSession->isVisible_ = false;
620 ssm_->UpdateNormalSessionAvoidArea(persistentId, sceneSession, needUpdate);
621 }
622
623 /**
624 * @tc.name: UpdateNormalSessionAvoidArea01
625 * @tc.desc: UpdateNormalSessionAvoidArea
626 * @tc.type: FUNC
627 */
628 HWTEST_F(SceneSessionManagerTest7, UpdateNormalSessionAvoidArea01, Function | SmallTest | Level3)
629 {
630 SessionInfo sessionInfo;
631 sessionInfo.bundleName_ = "SceneSessionManagerTest7";
632 sessionInfo.abilityName_ = "UpdateNormalSessionAvoidArea01";
633 sessionInfo.isSystem_ = true;
634 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
635 ASSERT_NE(nullptr, sceneSession);
636 sceneSession->isVisible_ = true;
637 sceneSession->state_ = SessionState::STATE_FOREGROUND;
638 int32_t persistentId = 1;
639 bool needUpdate = true;
640 ASSERT_NE(nullptr, ssm_);
641 ssm_->avoidAreaListenerSessionSet_.clear();
642 ssm_->avoidAreaListenerSessionSet_.insert(persistentId);
643 ssm_->UpdateNormalSessionAvoidArea(persistentId, sceneSession, needUpdate);
644 sceneSession = nullptr;
645 ssm_->UpdateNormalSessionAvoidArea(persistentId, sceneSession, needUpdate);
646 }
647
648 /**
649 * @tc.name: UnregisterWindowManagerAgent
650 * @tc.desc: UnregisterWindowManagerAgent
651 * @tc.type: FUNC
652 */
653 HWTEST_F(SceneSessionManagerTest7, UnregisterWindowManagerAgent, Function | SmallTest | Level3)
654 {
655 WindowManagerAgentType type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_SYSTEM_BAR;
656 sptr<IWindowManagerAgent> windowManagerAgent = nullptr;
657 ASSERT_NE(nullptr, ssm_);
658 auto ret = ssm_->UnregisterWindowManagerAgent(type, windowManagerAgent);
659 EXPECT_EQ(ret, WMError::WM_ERROR_NULLPTR);
660 type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_GESTURE_NAVIGATION_ENABLED;
661 ret = ssm_->UnregisterWindowManagerAgent(type, windowManagerAgent);
662 EXPECT_EQ(ret, WMError::WM_ERROR_NULLPTR);
663 type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WATER_MARK_FLAG;
664 ret = ssm_->UnregisterWindowManagerAgent(type, windowManagerAgent);
665 EXPECT_EQ(ret, WMError::WM_ERROR_NULLPTR);
666 type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WINDOW_VISIBILITY;
667 ret = ssm_->UnregisterWindowManagerAgent(type, windowManagerAgent);
668 EXPECT_EQ(ret, WMError::WM_ERROR_INVALID_PERMISSION);
669 type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WINDOW_DRAWING_STATE;
670 ret = ssm_->UnregisterWindowManagerAgent(type, windowManagerAgent);
671 EXPECT_EQ(ret, WMError::WM_ERROR_INVALID_PERMISSION);
672 type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_VISIBLE_WINDOW_NUM;
673 ret = ssm_->UnregisterWindowManagerAgent(type, windowManagerAgent);
674 EXPECT_EQ(ret, WMError::WM_ERROR_INVALID_PERMISSION);
675 type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_FOCUS;
676 ret = ssm_->UnregisterWindowManagerAgent(type, windowManagerAgent);
677 EXPECT_EQ(ret, WMError::WM_ERROR_INVALID_PERMISSION);
678 type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WINDOW_MODE;
679 ret = ssm_->UnregisterWindowManagerAgent(type, windowManagerAgent);
680 EXPECT_EQ(ret, WMError::WM_ERROR_INVALID_PERMISSION);
681 type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WINDOW_UPDATE;
682 ret = ssm_->UnregisterWindowManagerAgent(type, windowManagerAgent);
683 EXPECT_EQ(ret, WMError::WM_ERROR_NULLPTR);
684 }
685
686 /**
687 * @tc.name: FindSessionByAffinity
688 * @tc.desc: FindSessionByAffinity
689 * @tc.type: FUNC
690 */
691 HWTEST_F(SceneSessionManagerTest7, FindSessionByAffinity, Function | SmallTest | Level3)
692 {
693 std::string affinity = "";
694 ASSERT_NE(nullptr, ssm_);
695 auto ret = ssm_->FindSessionByAffinity(affinity);
696 EXPECT_EQ(ret, nullptr);
697 affinity = "Test";
698 SessionInfo sessionInfo;
699 sessionInfo.bundleName_ = "SceneSessionManagerTest7";
700 sessionInfo.abilityName_ = "FindSessionByAffinity";
701 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
702 ASSERT_NE(nullptr, sceneSession);
703 sceneSession->SetCollaboratorType(CollaboratorType::DEFAULT_TYPE);
704 ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
705 ret = ssm_->FindSessionByAffinity(affinity);
706 EXPECT_EQ(ret, nullptr);
707 sceneSession->SetCollaboratorType(CollaboratorType::OTHERS_TYPE);
708 sceneSession->sessionInfo_.sessionAffinity = "Test";
709 ret = ssm_->FindSessionByAffinity(affinity);
710 EXPECT_EQ(ret, sceneSession);
711 }
712
713 /**
714 * @tc.name: FindSessionByAffinity01
715 * @tc.desc: FindSessionByAffinity
716 * @tc.type: FUNC
717 */
718 HWTEST_F(SceneSessionManagerTest7, FindSessionByAffinity01, Function | SmallTest | Level3)
719 {
720 std::string affinity = "Test";
721 sptr<SceneSession> sceneSession = nullptr;
722 ASSERT_NE(nullptr, ssm_);
723 ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
724 auto ret = ssm_->FindSessionByAffinity(affinity);
725 EXPECT_EQ(ret, nullptr);
726 }
727
728 /**
729 * @tc.name: ProcessUpdateRotationChange01
730 * @tc.desc: ProcessUpdateRotationChange
731 * @tc.type: FUNC
732 */
733 HWTEST_F(SceneSessionManagerTest7, ProcessUpdateRotationChange01, Function | SmallTest | Level3)
734 {
735 DisplayId defaultDisplayId = 0;
736 sptr<DisplayInfo> displayInfo = sptr<DisplayInfo>::MakeSptr();
737 ASSERT_NE(nullptr, displayInfo);
738 std::map<DisplayId, sptr<DisplayInfo>> displayInfoMap;
739 DisplayStateChangeType type = DisplayStateChangeType::BEFORE_SUSPEND;
740 sptr<SceneSession> sceneSession = nullptr;
741 ASSERT_NE(nullptr, ssm_);
742 ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
743 ssm_->ProcessUpdateRotationChange(defaultDisplayId, displayInfo, displayInfoMap, type);
744 }
745
746 /**
747 * @tc.name: ProcessUpdateRotationChange02
748 * @tc.desc: ProcessUpdateRotationChange
749 * @tc.type: FUNC
750 */
751 HWTEST_F(SceneSessionManagerTest7, ProcessUpdateRotationChange02, Function | SmallTest | Level3)
752 {
753 DisplayId defaultDisplayId = 0;
754 sptr<DisplayInfo> displayInfo = sptr<DisplayInfo>::MakeSptr();
755 ASSERT_NE(nullptr, displayInfo);
756 std::map<DisplayId, sptr<DisplayInfo>> displayInfoMap;
757 DisplayStateChangeType type = DisplayStateChangeType::BEFORE_SUSPEND;
758 SessionInfo sessionInfo;
759 sessionInfo.bundleName_ = "SceneSessionManagerTest7";
760 sessionInfo.abilityName_ = "UpdateAvoidArea";
761 sessionInfo.isSystem_ = true;
762 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
763 ASSERT_NE(nullptr, sceneSession);
764 ASSERT_NE(nullptr, ssm_);
765 ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
766 sceneSession->SetSessionState(SessionState::STATE_INACTIVE);
767 WSRectF bounds = { 0, 0, 0, 0 };
768 sceneSession->SetBounds(bounds);
769 displayInfo->width_ = 0;
770 displayInfo->height_ = 0;
771 sceneSession->SetRotation(Rotation::ROTATION_0);
772 displayInfo->SetRotation(Rotation::ROTATION_90);
773 ssm_->ProcessUpdateRotationChange(defaultDisplayId, displayInfo, displayInfoMap, type);
774 displayInfo->height_ = 1;
775 ssm_->ProcessUpdateRotationChange(defaultDisplayId, displayInfo, displayInfoMap, type);
776 displayInfo->width_ = 1;
777 ssm_->ProcessUpdateRotationChange(defaultDisplayId, displayInfo, displayInfoMap, type);
778 }
779
780 /**
781 * @tc.name: SetSkipSelfWhenShowOnVirtualScreen
782 * @tc.desc: SetSkipSelfWhenShowOnVirtualScreen
783 * @tc.type: FUNC
784 */
785 HWTEST_F(SceneSessionManagerTest7, SetSkipSelfWhenShowOnVirtualScreen, Function | SmallTest | Level3)
786 {
787 uint64_t surfaceNodeId = 0;
788 bool isSkip = true;
789 ASSERT_NE(nullptr, ssm_);
790 ssm_->skipSurfaceNodeIds_.clear();
791 ssm_->SetSkipSelfWhenShowOnVirtualScreen(surfaceNodeId, isSkip);
792 ssm_->skipSurfaceNodeIds_.push_back(surfaceNodeId);
793 ssm_->SetSkipSelfWhenShowOnVirtualScreen(surfaceNodeId, isSkip);
794 }
795
796 /**
797 * @tc.name: SetSkipSelfWhenShowOnVirtualScreen01
798 * @tc.desc: SetSkipSelfWhenShowOnVirtualScreen
799 * @tc.type: FUNC
800 */
801 HWTEST_F(SceneSessionManagerTest7, SetSkipSelfWhenShowOnVirtualScreen01, Function | SmallTest | Level3)
802 {
803 uint64_t surfaceNodeId = 0;
804 bool isSkip = false;
805 ASSERT_NE(nullptr, ssm_);
806 ssm_->skipSurfaceNodeIds_.clear();
807 ssm_->SetSkipSelfWhenShowOnVirtualScreen(surfaceNodeId, isSkip);
808 ssm_->skipSurfaceNodeIds_.push_back(surfaceNodeId);
809 ssm_->SetSkipSelfWhenShowOnVirtualScreen(surfaceNodeId, isSkip);
810 }
811
812 /**
813 * @tc.name: GetMainWindowInfos
814 * @tc.desc: GetMainWindowInfos
815 * @tc.type: FUNC
816 */
817 HWTEST_F(SceneSessionManagerTest7, GetMainWindowInfos, Function | SmallTest | Level3)
818 {
819 int32_t topNum = 1;
820 std::vector<MainWindowInfo> topNInfo;
821 topNInfo.clear();
822 SessionInfo sessionInfo;
823 sessionInfo.bundleName_ = "SceneSessionManagerTest7";
824 sessionInfo.abilityName_ = "GetMainWindowInfos";
825 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
826 ASSERT_NE(nullptr, sceneSession);
827 ASSERT_NE(nullptr, sceneSession->property_);
828 sceneSession->property_->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
829 sceneSession->isVisible_ = true;
830 sceneSession->state_ = SessionState::STATE_FOREGROUND;
831 ASSERT_NE(nullptr, ssm_);
832 ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
833 auto ret = ssm_->GetMainWindowInfos(topNum, topNInfo);
834 EXPECT_EQ(ret, WMError::WM_OK);
835 sceneSession->isVisible_ = false;
836 ret = ssm_->GetMainWindowInfos(topNum, topNInfo);
837 EXPECT_EQ(ret, WMError::WM_OK);
838 sceneSession->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_END);
839 ret = ssm_->GetMainWindowInfos(topNum, topNInfo);
840 EXPECT_EQ(ret, WMError::WM_OK);
841 sceneSession->isVisible_ = true;
842 ret = ssm_->GetMainWindowInfos(topNum, topNInfo);
843 EXPECT_EQ(ret, WMError::WM_OK);
844 }
845
846 /**
847 * @tc.name: WindowLayerInfoChangeCallback
848 * @tc.desc: WindowLayerInfoChangeCallback
849 * @tc.type: FUNC
850 */
851 HWTEST_F(SceneSessionManagerTest7, WindowLayerInfoChangeCallback, Function | SmallTest | Level3)
852 {
853 std::shared_ptr<RSOcclusionData> occlusiontionData = nullptr;
854 ASSERT_NE(nullptr, ssm_);
855 ssm_->WindowLayerInfoChangeCallback(occlusiontionData);
856 VisibleData visibleData;
857 visibleData.push_back(std::make_pair(0, WINDOW_LAYER_INFO_TYPE::ALL_VISIBLE));
858 visibleData.push_back(std::make_pair(1, WINDOW_LAYER_INFO_TYPE::SEMI_VISIBLE));
859 visibleData.push_back(std::make_pair(2, WINDOW_LAYER_INFO_TYPE::INVISIBLE));
860 visibleData.push_back(std::make_pair(3, WINDOW_LAYER_INFO_TYPE::WINDOW_LAYER_DYNAMIC_STATUS));
861 visibleData.push_back(std::make_pair(4, WINDOW_LAYER_INFO_TYPE::WINDOW_LAYER_STATIC_STATUS));
862 visibleData.push_back(std::make_pair(5, WINDOW_LAYER_INFO_TYPE::WINDOW_LAYER_UNKNOWN_TYPE));
863 occlusiontionData = std::make_shared<RSOcclusionData>(visibleData);
864 ASSERT_NE(nullptr, occlusiontionData);
865 ssm_->WindowLayerInfoChangeCallback(occlusiontionData);
866 }
867
868 /**
869 * @tc.name: NotifySessionMovedToFront
870 * @tc.desc: NotifySessionMovedToFront
871 * @tc.type: FUNC
872 */
873 HWTEST_F(SceneSessionManagerTest7, NotifySessionMovedToFront, Function | SmallTest | Level3)
874 {
875 int32_t persistentId = 1;
876 SessionInfo sessionInfo;
877 sessionInfo.bundleName_ = "SceneSessionManagerTest7";
878 sessionInfo.abilityName_ = "GetMainWindowInfos";
879 sessionInfo.isSystem_ = false;
880 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
881 ASSERT_NE(nullptr, sceneSession);
882 ASSERT_NE(nullptr, ssm_);
883 ssm_->listenerController_ = std::make_shared<SessionListenerController>();
884 ASSERT_NE(nullptr, ssm_->listenerController_);
885 sceneSession->sessionInfo_.abilityInfo = std::make_shared<AppExecFwk::AbilityInfo>();
886 ASSERT_NE(nullptr, sceneSession->sessionInfo_.abilityInfo);
887 sceneSession->sessionInfo_.abilityInfo->excludeFromMissions = false;
888 ssm_->sceneSessionMap_.insert(std::make_pair(persistentId, sceneSession));
889 ssm_->NotifySessionMovedToFront(persistentId);
890 sceneSession->sessionInfo_.abilityInfo->excludeFromMissions = true;
891 ssm_->NotifySessionMovedToFront(persistentId);
892 sceneSession->sessionInfo_.abilityInfo = nullptr;
893 ssm_->NotifySessionMovedToFront(persistentId);
894 sceneSession->sessionInfo_.isSystem_ = true;
895 ssm_->NotifySessionMovedToFront(persistentId);
896 ssm_->listenerController_ = nullptr;
897 ssm_->NotifySessionMovedToFront(persistentId);
898 }
899
900 /**
901 * @tc.name: ProcessVirtualPixelRatioChange02
902 * @tc.desc: ProcessVirtualPixelRatioChange
903 * @tc.type: FUNC
904 */
905 HWTEST_F(SceneSessionManagerTest7, ProcessVirtualPixelRatioChange02, Function | SmallTest | Level3)
906 {
907 DisplayId defaultDisplayId = 0;
908 sptr<DisplayInfo> displayInfo = sptr<DisplayInfo>::MakeSptr();
909 std::map<DisplayId, sptr<DisplayInfo>> displayInfoMap;
910 DisplayStateChangeType type = DisplayStateChangeType::BEFORE_SUSPEND;
911 ASSERT_NE(nullptr, displayInfo);
912 SessionInfo sessionInfo;
913 sessionInfo.bundleName_ = "SceneSessionManagerTest7";
914 sessionInfo.abilityName_ = "ProcessVirtualPixelRatioChange02";
915 sessionInfo.isSystem_ = true;
916 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
917 ASSERT_NE(nullptr, sceneSession);
918 ASSERT_NE(nullptr, ssm_);
919 ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
920 sptr<SceneSession> sceneSession1 = nullptr;
921 ssm_->sceneSessionMap_.insert(std::make_pair(2, sceneSession1));
922 ssm_->ProcessVirtualPixelRatioChange(defaultDisplayId, displayInfo, displayInfoMap, type);
923 }
924
925 /**
926 * @tc.name: ProcessVirtualPixelRatioChange03
927 * @tc.desc: ProcessVirtualPixelRatioChange
928 * @tc.type: FUNC
929 */
930 HWTEST_F(SceneSessionManagerTest7, ProcessVirtualPixelRatioChange03, Function | SmallTest | Level3)
931 {
932 DisplayId defaultDisplayId = 0;
933 sptr<DisplayInfo> displayInfo = sptr<DisplayInfo>::MakeSptr();
934 std::map<DisplayId, sptr<DisplayInfo>> displayInfoMap;
935 DisplayStateChangeType type = DisplayStateChangeType::BEFORE_SUSPEND;
936 ASSERT_NE(nullptr, displayInfo);
937 SessionInfo sessionInfo;
938 sessionInfo.bundleName_ = "SceneSessionManagerTest7";
939 sessionInfo.abilityName_ = "ProcessVirtualPixelRatioChange03";
940 sessionInfo.isSystem_ = false;
941 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
942 ASSERT_NE(nullptr, sceneSession);
943 sceneSession->SetSessionState(SessionState::STATE_FOREGROUND);
944 ASSERT_NE(nullptr, ssm_);
945 ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
946 sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
947 ASSERT_NE(nullptr, sceneSession1);
948 sceneSession1->SetSessionState(SessionState::STATE_ACTIVE);
949 ssm_->sceneSessionMap_.insert(std::make_pair(2, sceneSession1));
950 sptr<SceneSession> sceneSession2 = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
951 ASSERT_NE(nullptr, sceneSession2);
952 sceneSession2->SetSessionState(SessionState::STATE_INACTIVE);
953 ssm_->sceneSessionMap_.insert(std::make_pair(3, sceneSession2));
954 ssm_->ProcessVirtualPixelRatioChange(defaultDisplayId, displayInfo, displayInfoMap, type);
955 }
956
957 /**
958 * @tc.name: ProcessBackEvent01
959 * @tc.desc: ProcessBackEvent
960 * @tc.type: FUNC
961 */
962 HWTEST_F(SceneSessionManagerTest7, ProcessBackEvent01, Function | SmallTest | Level3)
963 {
964 SessionInfo sessionInfo;
965 sessionInfo.bundleName_ = "SceneSessionManagerTest7";
966 sessionInfo.abilityName_ = "ProcessBackEvent01";
967 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
968 ASSERT_NE(nullptr, sceneSession);
969 ASSERT_NE(nullptr, ssm_);
970 auto focusGroup = ssm_->windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID);
971 focusGroup->SetFocusedSessionId(1);
972 ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
973 ssm_->needBlockNotifyFocusStatusUntilForeground_ = true;
974 auto ret = ssm_->ProcessBackEvent();
975 EXPECT_EQ(ret, WSError::WS_OK);
976 }
977
978 /**
979 * @tc.name: ProcessBackEvent02
980 * @tc.desc: ProcessBackEvent
981 * @tc.type: FUNC
982 */
983 HWTEST_F(SceneSessionManagerTest7, ProcessBackEvent02, Function | SmallTest | Level3)
984 {
985 SessionInfo sessionInfo;
986 sessionInfo.bundleName_ = "SceneSessionManagerTest7";
987 sessionInfo.abilityName_ = "ProcessBackEvent02";
988 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
989 ASSERT_NE(nullptr, sceneSession);
990 sceneSession->sessionInfo_.isSystem_ = true;
991 ASSERT_NE(nullptr, ssm_);
992 auto focusGroup = ssm_->windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID);
993 focusGroup->SetFocusedSessionId(1);
994 ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
995 ssm_->needBlockNotifyFocusStatusUntilForeground_ = false;
996 ssm_->rootSceneProcessBackEventFunc_ = nullptr;
997 auto ret = ssm_->ProcessBackEvent();
998 EXPECT_EQ(ret, WSError::WS_OK);
999 }
1000
1001 /**
1002 * @tc.name: ProcessBackEvent03
1003 * @tc.desc: ProcessBackEvent
1004 * @tc.type: FUNC
1005 */
1006 HWTEST_F(SceneSessionManagerTest7, ProcessBackEvent03, Function | SmallTest | Level3)
1007 {
1008 SessionInfo sessionInfo;
1009 sessionInfo.bundleName_ = "SceneSessionManagerTest7";
1010 sessionInfo.abilityName_ = "ProcessBackEvent03";
1011 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1012 ASSERT_NE(nullptr, sceneSession);
1013 sceneSession->sessionInfo_.isSystem_ = true;
1014 ASSERT_NE(nullptr, ssm_);
1015 auto focusGroup = ssm_->windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID);
1016 focusGroup->SetFocusedSessionId(1);
1017 ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
1018 ssm_->needBlockNotifyFocusStatusUntilForeground_ = false;
__anonc154985b0602()1019 RootSceneProcessBackEventFunc func = [](){};
1020 ssm_->rootSceneProcessBackEventFunc_ = func;
1021 ASSERT_NE(nullptr, ssm_->rootSceneProcessBackEventFunc_);
1022 auto ret = ssm_->ProcessBackEvent();
1023 EXPECT_EQ(ret, WSError::WS_OK);
1024 }
1025
1026 /**
1027 * @tc.name: ProcessBackEvent02
1028 * @tc.desc: ProcessBackEvent
1029 * @tc.type: FUNC
1030 */
1031 HWTEST_F(SceneSessionManagerTest7, ProcessBackEvent04, Function | SmallTest | Level3)
1032 {
1033 SessionInfo sessionInfo;
1034 sessionInfo.bundleName_ = "SceneSessionManagerTest7";
1035 sessionInfo.abilityName_ = "ProcessBackEvent04";
1036 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1037 ASSERT_NE(nullptr, sceneSession);
1038 sceneSession->sessionInfo_.isSystem_ = false;
1039 ASSERT_NE(nullptr, ssm_);
1040 auto focusGroup = ssm_->windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID);
1041 focusGroup->SetFocusedSessionId(1);
1042 ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
1043 ssm_->needBlockNotifyFocusStatusUntilForeground_ = false;
1044 ssm_->rootSceneProcessBackEventFunc_ = nullptr;
1045 auto ret = ssm_->ProcessBackEvent();
1046 EXPECT_EQ(ret, WSError::WS_OK);
1047 }
1048
1049 /**
1050 * @tc.name: ProcessBackEvent05
1051 * @tc.desc: ProcessBackEvent
1052 * @tc.type: FUNC
1053 */
1054 HWTEST_F(SceneSessionManagerTest7, ProcessBackEvent05, Function | SmallTest | Level3)
1055 {
1056 SessionInfo sessionInfo;
1057 sessionInfo.bundleName_ = "SceneSessionManagerTest7";
1058 sessionInfo.abilityName_ = "ProcessBackEvent03";
1059 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1060 ASSERT_NE(nullptr, sceneSession);
1061 sceneSession->sessionInfo_.isSystem_ = false;
1062 ASSERT_NE(nullptr, ssm_);
1063 auto focusGroup = ssm_->windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID);
1064 focusGroup->SetFocusedSessionId(1);
1065 ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession));
1066 ssm_->needBlockNotifyFocusStatusUntilForeground_ = false;
__anonc154985b0702()1067 RootSceneProcessBackEventFunc func = [](){};
1068 ssm_->rootSceneProcessBackEventFunc_ = func;
1069 ASSERT_NE(nullptr, ssm_->rootSceneProcessBackEventFunc_);
1070 auto ret = ssm_->ProcessBackEvent();
1071 EXPECT_EQ(ret, WSError::WS_OK);
1072 }
1073
1074 /**
1075 * @tc.name: GetWindowVisibilityChangeInfo
1076 * @tc.desc: GetWindowVisibilityChangeInfo
1077 * @tc.type: FUNC
1078 */
1079 HWTEST_F(SceneSessionManagerTest7, GetWindowVisibilityChangeInfo, Function | SmallTest | Level3)
1080 {
1081 std::vector<std::pair<uint64_t, WindowVisibilityState>> currVisibleData;
1082 std::vector<std::pair<uint64_t, WindowVisibilityState>> visibilitychangeInfos;
1083 currVisibleData.emplace_back(2, WindowVisibilityState::WINDOW_VISIBILITY_STATE_NO_OCCLUSION);
1084 currVisibleData.emplace_back(4, WindowVisibilityState::WINDOW_LAYER_STATE_MAX);
1085 currVisibleData.emplace_back(5, WindowVisibilityState::WINDOW_VISIBILITY_STATE_TOTALLY_OCCUSION);
1086 currVisibleData.emplace_back(7, WindowVisibilityState::WINDOW_LAYER_STATE_MAX);
1087 currVisibleData.emplace_back(9, WindowVisibilityState::WINDOW_VISIBILITY_STATE_TOTALLY_OCCUSION);
1088 ASSERT_NE(nullptr, ssm_);
1089 ssm_->lastVisibleData_.emplace_back(1, WindowVisibilityState::WINDOW_VISIBILITY_STATE_NO_OCCLUSION);
1090 ssm_->lastVisibleData_.emplace_back(4, WindowVisibilityState::WINDOW_VISIBILITY_STATE_PARTICALLY_OCCLUSION);
1091 ssm_->lastVisibleData_.emplace_back(5, WindowVisibilityState::WINDOW_VISIBILITY_STATE_TOTALLY_OCCUSION);
1092 ssm_->lastVisibleData_.emplace_back(6, WindowVisibilityState::WINDOW_LAYER_STATE_MAX);
1093 visibilitychangeInfos = ssm_->GetWindowVisibilityChangeInfo(currVisibleData);
1094 ASSERT_EQ(visibilitychangeInfos.size(), 7);
1095 }
1096
1097 /**
1098 * @tc.name: UpdateAvoidArea
1099 * @tc.desc: UpdateAvoidArea
1100 * @tc.type: FUNC
1101 */
1102 HWTEST_F(SceneSessionManagerTest7, UpdateAvoidArea, Function | SmallTest | Level3)
1103 {
1104 int32_t persistentId = 0;
1105 ASSERT_NE(nullptr, ssm_);
1106 ssm_->sceneSessionMap_.clear();
1107 ssm_->rootSceneSession_ = sptr<RootSceneSession>::MakeSptr();
1108 ssm_->UpdateAvoidArea(persistentId);
1109 }
1110
1111 /**
1112 * @tc.name: UpdateAvoidArea01
1113 * @tc.desc: UpdateAvoidArea
1114 * @tc.type: FUNC
1115 */
1116 HWTEST_F(SceneSessionManagerTest7, UpdateAvoidArea01, Function | SmallTest | Level3)
1117 {
1118 int32_t persistentId = 0;
1119 ASSERT_NE(nullptr, ssm_);
1120 ssm_->sceneSessionMap_.clear();
1121 ssm_->rootSceneSession_ = sptr<RootSceneSession>::MakeSptr();
1122 ssm_->UpdateAvoidArea(persistentId);
1123 SessionInfo sessionInfo;
1124 sessionInfo.bundleName_ = "SceneSessionManagerTest7";
1125 sessionInfo.abilityName_ = "UpdateAvoidArea01";
1126 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1127 ASSERT_NE(nullptr, sceneSession);
1128 ASSERT_NE(nullptr, sceneSession->property_);
1129 sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_STATUS_BAR);
1130 ssm_->sceneSessionMap_.insert(std::make_pair(persistentId, sceneSession));
1131 ssm_->UpdateAvoidArea(persistentId);
1132 }
1133
1134 /**
1135 * @tc.name: UpdateAvoidArea02
1136 * @tc.desc: UpdateAvoidArea
1137 * @tc.type: FUNC
1138 */
1139 HWTEST_F(SceneSessionManagerTest7, UpdateAvoidArea02, Function | SmallTest | Level3)
1140 {
1141 int32_t persistentId = 0;
1142 ASSERT_NE(nullptr, ssm_);
1143 ssm_->sceneSessionMap_.clear();
1144 ssm_->rootSceneSession_ = sptr<RootSceneSession>::MakeSptr();
1145 ssm_->UpdateAvoidArea(persistentId);
1146 SessionInfo sessionInfo;
1147 sessionInfo.bundleName_ = "SceneSessionManagerTest7";
1148 sessionInfo.abilityName_ = "UpdateAvoidArea02";
1149 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1150 ASSERT_NE(nullptr, sceneSession);
1151 ASSERT_NE(nullptr, sceneSession->property_);
1152 sceneSession->property_->SetWindowType(WindowType::APP_WINDOW_BASE);
1153 ssm_->sceneSessionMap_.insert(std::make_pair(persistentId, sceneSession));
1154 ssm_->UpdateAvoidArea(persistentId);
1155 }
1156
1157 /**
1158 * @tc.name: NotifySessionMovedToFront01
1159 * @tc.desc: NotifySessionMovedToFront
1160 * @tc.type: FUNC
1161 */
1162 HWTEST_F(SceneSessionManagerTest7, NotifySessionMovedToFront01, Function | SmallTest | Level3)
1163 {
1164 int32_t persistentId = 1;
1165 SessionInfo sessionInfo;
1166 sessionInfo.bundleName_ = "SceneSessionManagerTest7";
1167 sessionInfo.abilityName_ = "NotifySessionMovedToFront01";
1168 sessionInfo.isSystem_ = false;
1169 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1170 ASSERT_NE(nullptr, sceneSession);
1171 ASSERT_NE(nullptr, ssm_);
1172 ssm_->listenerController_ = std::make_shared<SessionListenerController>();
1173 ASSERT_NE(nullptr, ssm_->listenerController_);
1174 sceneSession->sessionInfo_.abilityInfo = std::make_shared<AppExecFwk::AbilityInfo>();
1175 ASSERT_NE(nullptr, sceneSession->sessionInfo_.abilityInfo);
1176 sceneSession->sessionInfo_.abilityInfo->excludeFromMissions = true;
1177 ssm_->sceneSessionMap_.insert(std::make_pair(persistentId, sceneSession));
1178 ssm_->NotifySessionMovedToFront(persistentId);
1179 }
1180
1181 /**
1182 * @tc.name: NotifySessionMovedToFront02
1183 * @tc.desc: NotifySessionMovedToFront
1184 * @tc.type: FUNC
1185 */
1186 HWTEST_F(SceneSessionManagerTest7, NotifySessionMovedToFront02, Function | SmallTest | Level3)
1187 {
1188 int32_t persistentId = 1;
1189 SessionInfo sessionInfo;
1190 sessionInfo.bundleName_ = "SceneSessionManagerTest7";
1191 sessionInfo.abilityName_ = "NotifySessionMovedToFront02";
1192 sessionInfo.isSystem_ = false;
1193 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1194 ASSERT_NE(nullptr, sceneSession);
1195 ASSERT_NE(nullptr, ssm_);
1196 ssm_->listenerController_ = std::make_shared<SessionListenerController>();
1197 ASSERT_NE(nullptr, ssm_->listenerController_);
1198 sceneSession->sessionInfo_.abilityInfo = std::make_shared<AppExecFwk::AbilityInfo>();
1199 ASSERT_NE(nullptr, sceneSession->sessionInfo_.abilityInfo);
1200 sceneSession->sessionInfo_.abilityInfo->excludeFromMissions = false;
1201 ssm_->sceneSessionMap_.insert(std::make_pair(persistentId, sceneSession));
1202 ssm_->NotifySessionMovedToFront(persistentId);
1203 }
1204
1205 /**
1206 * @tc.name: NotifySessionMovedToFront03
1207 * @tc.desc: NotifySessionMovedToFront
1208 * @tc.type: FUNC
1209 */
1210 HWTEST_F(SceneSessionManagerTest7, NotifySessionMovedToFront03, Function | SmallTest | Level3)
1211 {
1212 int32_t persistentId = 1;
1213 SessionInfo sessionInfo;
1214 sessionInfo.bundleName_ = "SceneSessionManagerTest7";
1215 sessionInfo.abilityName_ = "NotifySessionMovedToFront03";
1216 sessionInfo.isSystem_ = false;
1217 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1218 ASSERT_NE(nullptr, sceneSession);
1219 ASSERT_NE(nullptr, ssm_);
1220 ssm_->listenerController_ = std::make_shared<SessionListenerController>();
1221 ASSERT_NE(nullptr, ssm_->listenerController_);
1222 sceneSession->sessionInfo_.abilityInfo = nullptr;
1223 ssm_->NotifySessionMovedToFront(persistentId);
1224 }
1225
1226 /**
1227 * @tc.name: NotifySessionMovedToFront04
1228 * @tc.desc: NotifySessionMovedToFront
1229 * @tc.type: FUNC
1230 */
1231 HWTEST_F(SceneSessionManagerTest7, NotifySessionMovedToFront04, Function | SmallTest | Level3)
1232 {
1233 int32_t persistentId = 1;
1234 SessionInfo sessionInfo;
1235 sessionInfo.bundleName_ = "SceneSessionManagerTest7";
1236 sessionInfo.abilityName_ = "NotifySessionMovedToFront04";
1237 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1238 ASSERT_NE(nullptr, sceneSession);
1239 ASSERT_NE(nullptr, ssm_);
1240 ssm_->listenerController_ = std::make_shared<SessionListenerController>();
1241 ASSERT_NE(nullptr, ssm_->listenerController_);
1242 sceneSession->sessionInfo_.isSystem_ = true;
1243 ssm_->NotifySessionMovedToFront(persistentId);
1244 }
1245
1246 /**
1247 * @tc.name: NotifySessionMovedToFront05
1248 * @tc.desc: NotifySessionMovedToFront
1249 * @tc.type: FUNC
1250 */
1251 HWTEST_F(SceneSessionManagerTest7, NotifySessionMovedToFront05, Function | SmallTest | Level3)
1252 {
1253 int32_t persistentId = 1;
1254 SessionInfo sessionInfo;
1255 sessionInfo.bundleName_ = "SceneSessionManagerTest7";
1256 sessionInfo.abilityName_ = "NotifySessionMovedToFront05";
1257 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1258 ASSERT_NE(nullptr, sceneSession);
1259 ASSERT_NE(nullptr, ssm_);
1260 ssm_->listenerController_ = nullptr;
1261 ssm_->NotifySessionMovedToFront(persistentId);
1262 }
1263
1264 /**
1265 * @tc.name: UpdateNormalSessionAvoidArea02
1266 * @tc.desc: UpdateNormalSessionAvoidArea
1267 * @tc.type: FUNC
1268 */
1269 HWTEST_F(SceneSessionManagerTest7, UpdateNormalSessionAvoidArea02, Function | SmallTest | Level3)
1270 {
1271 SessionInfo sessionInfo;
1272 sessionInfo.bundleName_ = "SceneSessionManagerTest7";
1273 sessionInfo.abilityName_ = "UpdateNormalSessionAvoidArea02";
1274 sessionInfo.isSystem_ = true;
1275 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1276 ASSERT_NE(nullptr, sceneSession);
1277 sceneSession->isVisible_ = true;
1278 sceneSession->state_ = SessionState::STATE_FOREGROUND;
1279 sceneSession->winRect_ = { 1, 1, 1, 1 };
1280 int32_t persistentId = 1;
1281 bool needUpdate = true;
1282 ASSERT_NE(nullptr, ssm_);
1283 ssm_->avoidAreaListenerSessionSet_.clear();
1284 ssm_->avoidAreaListenerSessionSet_.insert(persistentId);
1285 ssm_->UpdateNormalSessionAvoidArea(persistentId, sceneSession, needUpdate);
1286 }
1287 }
1288 } // namespace Rosen
1289 } // namespace OHOS