1 /*
2 * Copyright (c) 2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include <gtest/gtest.h>
17 #include <regex>
18 #include <bundle_mgr_interface.h>
19 #include <bundlemgr/launcher_service.h>
20
21 #include "common_test_utils.h"
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_scene_session.h"
27 #include "mock/mock_window_event_channel.h"
28 #include "session_info.h"
29 #include "session_manager.h"
30 #include "session_manager/include/scene_session_manager.h"
31 #include "session/host/include/scene_session.h"
32 #include "session/host/include/main_session.h"
33 #include "window_manager_agent.h"
34 #include "zidl/window_manager_agent_interface.h"
35 #include "mock/mock_window_manager_agent_lite.h"
36 #include "session_manager/include/session_manager_agent_controller.h"
37
38 using namespace testing;
39 using namespace testing::ext;
40
41 namespace OHOS {
42 namespace Rosen {
43 class KeyboardTestData;
44 class SceneSessionManagerTest12 : public testing::Test {
45 public:
46 static void SetUpTestCase();
47 static void TearDownTestCase();
48 void SetUp() override;
49 void TearDown() override;
50
51 void ConstructKeyboardCallingWindowTestData(const KeyboardTestData& keyboardTestData);
52
53 static sptr<SceneSessionManager> ssm_;
54 private:
55 static constexpr uint32_t WAIT_SYNC_IN_NS = 200000;
56 };
57
58 sptr<SceneSessionManager> SceneSessionManagerTest12::ssm_ = nullptr;
59
SetUpTestCase()60 void SceneSessionManagerTest12::SetUpTestCase()
61 {
62 ssm_ = &SceneSessionManager::GetInstance();
63 }
64
TearDownTestCase()65 void SceneSessionManagerTest12::TearDownTestCase()
66 {
67 ssm_ = nullptr;
68 }
69
SetUp()70 void SceneSessionManagerTest12::SetUp()
71 {
72 }
73
TearDown()74 void SceneSessionManagerTest12::TearDown()
75 {
76 usleep(WAIT_SYNC_IN_NS);
77 }
78
79 class KeyboardTestData {
80 public:
KeyboardTestData(uint64_t cScreenId,int32_t cPid,int32_t kScreenId,WindowType keyboardWindowType,bool isSysKeyboard)81 KeyboardTestData(uint64_t cScreenId, int32_t cPid, int32_t kScreenId, WindowType keyboardWindowType,
82 bool isSysKeyboard) : cScreenId_(cScreenId), cPid_(cPid), kScreenId_(kScreenId),
83 keyboardWindowType_(keyboardWindowType), isSysKeyboard_(isSysKeyboard) {}
84
SetCallingSessionId(uint32_t callingSessionId)85 void SetCallingSessionId(uint32_t callingSessionId)
86 {
87 callingSessionId_ = callingSessionId;
88 }
89
90 private:
91 uint64_t cScreenId_; // screenId of callingWindow
92 int32_t cPid_; // callingPid of callingWindow
93 int32_t kScreenId_; // screenId of keyboard
94 WindowType keyboardWindowType_;
95 bool isSysKeyboard_;
96 uint32_t callingSessionId_;
97 };
98
ConstructKeyboardCallingWindowTestData(const KeyboardTestData & keyboardTestData)99 void SceneSessionManagerTest12::ConstructKeyboardCallingWindowTestData(const KeyboardTestData& keyboardTestData)
100 {
101 ssm_->sceneSessionMap_.clear();
102 SessionInfo callingSessionInfo;
103 callingSessionInfo.abilityName_ = "callingSession";
104 callingSessionInfo.bundleName_ = "callingSession";
105 callingSessionInfo.screenId_ = keyboardTestData.cScreenId_;
106 sptr<SceneSession> callingSession = sptr<SceneSession>::MakeSptr(callingSessionInfo, nullptr);
107 callingSession->callingPid_ = keyboardTestData.cPid_;
108 sptr<WindowSessionProperty> callingSessionProperties = sptr<WindowSessionProperty>::MakeSptr();
109 callingSessionProperties->SetDisplayId(keyboardTestData.cScreenId_);
110 callingSession->SetSessionProperty(callingSessionProperties);
111
112 SessionInfo keyboardSessionInfo;
113 keyboardSessionInfo.abilityName_ = "keyboardSession";
114 keyboardSessionInfo.bundleName_ = "keyboardSession";
115 sptr<SceneSession> keyboardSession = sptr<SceneSession>::MakeSptr(keyboardSessionInfo, nullptr);
116
117 keyboardSession->SetScreenId(keyboardTestData.kScreenId_);
118 sptr<WindowSessionProperty> keyboardProperties = sptr<WindowSessionProperty>::MakeSptr();
119 keyboardProperties->SetWindowType(keyboardTestData.keyboardWindowType_);
120 keyboardProperties->SetIsSystemKeyboard(keyboardTestData.isSysKeyboard_);
121 keyboardProperties->SetCallingSessionId(keyboardTestData.callingSessionId_);
122 keyboardSession->SetSessionProperty(keyboardProperties);
123
124 ssm_->sceneSessionMap_.insert({keyboardTestData.callingSessionId_, callingSession});
125 ssm_->sceneSessionMap_.insert({2, keyboardSession});
126 }
127
128 namespace {
129 /**
130 * @tc.name: GetResourceManager
131 * @tc.desc: GetResourceManager
132 * @tc.type: FUNC
133 */
134 HWTEST_F(SceneSessionManagerTest12, GetResourceManager, Function | SmallTest | Level3)
135 {
136 ASSERT_NE(ssm_, nullptr);
137 AppExecFwk::AbilityInfo abilityInfo;
138 auto result = ssm_->GetResourceManager(abilityInfo);
139 EXPECT_EQ(result, nullptr);
140 }
141
142 /**
143 * @tc.name: GetStartupPageFromResource
144 * @tc.desc: GetStartupPageFromResource
145 * @tc.type: FUNC
146 */
147 HWTEST_F(SceneSessionManagerTest12, GetStartupPageFromResource, Function | SmallTest | Level3)
148 {
149 ASSERT_NE(ssm_, nullptr);
150 AppExecFwk::AbilityInfo abilityInfo;
151 std::string path = "";
152 uint32_t bgColor = 0;
153 bool result = ssm_->GetStartupPageFromResource(abilityInfo, path, bgColor);
154 EXPECT_EQ(result, false);
155 }
156
157 /**
158 * @tc.name: RequestKeyboardPanelSession
159 * @tc.desc: test RequestKeyboardPanelSession
160 * @tc.type: FUNC
161 */
162 HWTEST_F(SceneSessionManagerTest12, RequestKeyboardPanelSession, Function | SmallTest | Level2)
163 {
164 sptr<SceneSessionManager> ssm = sptr<SceneSessionManager>::MakeSptr();
165 std::string panelName = "SystemKeyboardPanel";
166 ASSERT_NE(nullptr, ssm->RequestKeyboardPanelSession(panelName, 0)); // 0 is screenId
167 ssm->systemConfig_.windowUIType_ = WindowUIType::PC_WINDOW;
168 ASSERT_NE(nullptr, ssm->RequestKeyboardPanelSession(panelName, 0)); // 0 is screenId
169 }
170
171 /**
172 * @tc.name: CreateKeyboardPanelSession
173 * @tc.desc: CreateKeyboardPanelSession
174 * @tc.type: FUNC
175 */
176 HWTEST_F(SceneSessionManagerTest12, CreateKeyboardPanelSession02, Function | SmallTest | Level3)
177 {
178 ASSERT_NE(ssm_, nullptr);
179 SessionInfo info;
180 info.abilityName_ = "test1";
181 info.bundleName_ = "test2";
182 info.screenId_ = SCREEN_ID_INVALID;
183 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
184 ASSERT_NE(property, nullptr);
185 property->SetWindowType(WindowType::WINDOW_TYPE_KEYBOARD_PANEL);
186 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
187 ssm_->CreateKeyboardPanelSession(sceneSession);
188 }
189
190 /**
191 * @tc.name: CreateKeyboardPanelSession03
192 * @tc.desc: test CreateKeyboardPanelSession
193 * @tc.type: FUNC
194 */
195 HWTEST_F(SceneSessionManagerTest12, CreateKeyboardPanelSession03, Function | SmallTest | Level2)
196 {
197 SessionInfo keyboardInfo;
198 keyboardInfo.abilityName_ = "CreateKeyboardPanelSession03";
199 keyboardInfo.bundleName_ = "CreateKeyboardPanelSession03";
200 sptr<KeyboardSession> keyboardSession = sptr<KeyboardSession>::MakeSptr(keyboardInfo, nullptr, nullptr);
201 ASSERT_EQ(nullptr, keyboardSession->GetKeyboardPanelSession());
202 sptr<SceneSessionManager> ssm = sptr<SceneSessionManager>::MakeSptr();
203
204 // the keyboard panel enabled flag of ssm is false
205 ssm->CreateKeyboardPanelSession(keyboardSession);
206 ASSERT_EQ(nullptr, keyboardSession->GetKeyboardPanelSession());
207
208 // keyboard session is nullptr
209 ssm->isKeyboardPanelEnabled_ = true;
210 ssm->CreateKeyboardPanelSession(nullptr);
211 ASSERT_EQ(nullptr, keyboardSession->GetKeyboardPanelSession());
212
213 // the keyboard session is system keyboard
214 keyboardSession->property_->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
215 ASSERT_NE(nullptr, keyboardSession->GetSessionProperty());
216 keyboardSession->SetIsSystemKeyboard(true);
217 ASSERT_EQ(true, keyboardSession->IsSystemKeyboard());
218 ssm->CreateKeyboardPanelSession(keyboardSession);
219 ASSERT_NE(nullptr, keyboardSession->GetKeyboardPanelSession());
220 }
221
222 /**
223 * @tc.name: CreateKeyboardPanelSession04
224 * @tc.desc: test CreateKeyboardPanelSession
225 * @tc.type: FUNC
226 */
227 HWTEST_F(SceneSessionManagerTest12, CreateKeyboardPanelSession04, Function | SmallTest | Level2)
228 {
229 SessionInfo keyboardInfo;
230 keyboardInfo.abilityName_ = "CreateKeyboardPanelSession04";
231 keyboardInfo.bundleName_ = "CreateKeyboardPanelSession04";
232 sptr<KeyboardSession> keyboardSession = sptr<KeyboardSession>::MakeSptr(keyboardInfo, nullptr, nullptr);
233 ASSERT_EQ(nullptr, keyboardSession->GetKeyboardPanelSession());
234 sptr<SceneSessionManager> ssm = sptr<SceneSessionManager>::MakeSptr();
235
236 // the keyboard panel enabled flag of ssm is true
237 ssm->isKeyboardPanelEnabled_ = true;
238 ASSERT_NE(nullptr, keyboardSession->GetSessionProperty());
239 ASSERT_EQ(false, keyboardSession->IsSystemKeyboard());
240 ssm->CreateKeyboardPanelSession(keyboardSession);
241 ASSERT_NE(nullptr, keyboardSession->GetKeyboardPanelSession());
242
243 // keyboard panel session is already exists
244 ssm->CreateKeyboardPanelSession(keyboardSession);
245 ASSERT_NE(nullptr, keyboardSession->GetKeyboardPanelSession());
246 }
247
248 /**
249 * @tc.name: TestCheckSystemWindowPermission_01
250 * @tc.desc: Test CheckSystemWindowPermission with windowType WINDOW_TYPE_UI_EXTENSION then false
251 * @tc.type: FUNC
252 */
253 HWTEST_F(SceneSessionManagerTest12, TestCheckSystemWindowPermission_01, Function | SmallTest | Level2)
254 {
255 ASSERT_NE(nullptr, ssm_);
256 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
257
258 property->SetWindowType(WindowType::WINDOW_TYPE_UI_EXTENSION);
259 ASSERT_EQ(false, ssm_->CheckSystemWindowPermission(property));
260 }
261
262 /**
263 * @tc.name: TestCheckSystemWindowPermission_02
264 * @tc.desc: Test CheckSystemWindowPermission with windowType WINDOW_TYPE_APP_MAIN_WINDOW then true
265 * @tc.type: FUNC
266 */
267 HWTEST_F(SceneSessionManagerTest12, TestCheckSystemWindowPermission_02, Function | SmallTest | Level2)
268 {
269 ASSERT_NE(nullptr, ssm_);
270 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
271
272 property->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); // main window is not system window
273 ASSERT_EQ(true, ssm_->CheckSystemWindowPermission(property));
274 }
275
276 /**
277 * @tc.name: TestCheckSystemWindowPermission_03
278 * @tc.desc: Test CheckSystemWindowPermission with windowType WINDOW_TYPE_INPUT_METHOD_FLOAT then true
279 * @tc.type: FUNC
280 */
281 HWTEST_F(SceneSessionManagerTest12, TestCheckSystemWindowPermission_03, Function | SmallTest | Level2)
282 {
283 ASSERT_NE(nullptr, ssm_);
284 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
285
286 property->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
287 ASSERT_EQ(true, ssm_->CheckSystemWindowPermission(property));
288 }
289
290 /**
291 * @tc.name: TestCheckSystemWindowPermission_04
292 * @tc.desc: Test CheckSystemWindowPermission with windowType WINDOW_TYPE_INPUT_METHOD_STATUS_BAR then true
293 * @tc.type: FUNC
294 */
295 HWTEST_F(SceneSessionManagerTest12, TestCheckSystemWindowPermission_04, Function | SmallTest | Level2)
296 {
297 ASSERT_NE(nullptr, ssm_);
298 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
299
300 property->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_STATUS_BAR);
301 ASSERT_EQ(true, ssm_->CheckSystemWindowPermission(property));
302 }
303
304 /**
305 * @tc.name: TestCheckSystemWindowPermission_05
306 * @tc.desc: Test CheckSystemWindowPermission with windowType WINDOW_TYPE_INPUT_METHOD_FLOAT then false
307 * @tc.type: FUNC
308 */
309 HWTEST_F(SceneSessionManagerTest12, TestCheckSystemWindowPermission_05, Function | SmallTest | Level2)
310 {
311 ASSERT_NE(nullptr, ssm_);
312 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
313
314 property->SetIsSystemKeyboard(true);
315 property->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
316 ASSERT_EQ(false, ssm_->CheckSystemWindowPermission(property));
317 }
318
319 /**
320 * @tc.name: TestCheckSystemWindowPermission_06
321 * @tc.desc: Test CheckSystemWindowPermission with windowType WINDOW_TYPE_DIALOG then true
322 * @tc.type: FUNC
323 */
324 HWTEST_F(SceneSessionManagerTest12, TestCheckSystemWindowPermission_06, Function | SmallTest | Level2)
325 {
326 ASSERT_NE(nullptr, ssm_);
327 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
328
329 property->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
330 ASSERT_EQ(true, ssm_->CheckSystemWindowPermission(property));
331 }
332
333 /**
334 * @tc.name: TestCheckSystemWindowPermission_07
335 * @tc.desc: Test CheckSystemWindowPermission with windowType WINDOW_TYPE_PIP then true
336 * @tc.type: FUNC
337 */
338 HWTEST_F(SceneSessionManagerTest12, TestCheckSystemWindowPermission_07, Function | SmallTest | Level2)
339 {
340 ASSERT_NE(nullptr, ssm_);
341 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
342
343 property->SetWindowType(WindowType::WINDOW_TYPE_PIP);
344 ASSERT_EQ(true, ssm_->CheckSystemWindowPermission(property));
345 }
346
347 /**
348 * @tc.name: TestCheckSystemWindowPermission_08
349 * @tc.desc: Test CheckSystemWindowPermission with windowType WINDOW_TYPE_FLOAT then true
350 * @tc.type: FUNC
351 */
352 HWTEST_F(SceneSessionManagerTest12, TestCheckSystemWindowPermission_08, Function | SmallTest | Level2)
353 {
354 ASSERT_NE(nullptr, ssm_);
355 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
356
357 property->SetWindowType(WindowType::WINDOW_TYPE_FLOAT);
358 ASSERT_EQ(false, ssm_->CheckSystemWindowPermission(property));
359 }
360
361 /**
362 * @tc.name: TestCheckSystemWindowPermission_09
363 * @tc.desc: Test CheckSystemWindowPermission with windowType WINDOW_TYPE_TOAST then true
364 * @tc.type: FUNC
365 */
366 HWTEST_F(SceneSessionManagerTest12, TestCheckSystemWindowPermission_09, Function | SmallTest | Level2)
367 {
368 ASSERT_NE(nullptr, ssm_);
369 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
370
371 property->SetWindowType(WindowType::WINDOW_TYPE_TOAST);
372 ASSERT_EQ(true, ssm_->CheckSystemWindowPermission(property));
373 }
374
375 /**
376 * @tc.name: CreateAndConnectSpecificSession
377 * @tc.desc: CreateAndConnectSpecificSession
378 * @tc.type: FUNC
379 */
380 HWTEST_F(SceneSessionManagerTest12, CreateAndConnectSpecificSession03, Function | SmallTest | Level3)
381 {
382 sptr<ISessionStage> sessionStage;
383 sptr<IWindowEventChannel> eventChannel;
384 std::shared_ptr<RSSurfaceNode> node = nullptr;
385 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
386 sptr<ISession> session;
387 SystemSessionConfig systemConfig;
388 sptr<IRemoteObject> token;
389 int32_t id = 0;
390 ASSERT_NE(ssm_, nullptr);
391
392 property->SetWindowType(WindowType::WINDOW_TYPE_UI_EXTENSION);
393 auto res = ssm_->CreateAndConnectSpecificSession(sessionStage, eventChannel, node, property, id, session,
394 systemConfig, token);
395 ASSERT_EQ(WSError::WS_ERROR_NOT_SYSTEM_APP, res);
396
397 property->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
398 property->SetTopmost(true);
399 uint32_t flags = property->GetWindowFlags() & (~(static_cast<uint32_t>(WindowFlag::WINDOW_FLAG_IS_MODAL)));
400 property->SetWindowFlags(flags);
401 res = ssm_->CreateAndConnectSpecificSession(sessionStage, eventChannel, node, property, id, session,
402 systemConfig, token);
403 ASSERT_EQ(WSError::WS_ERROR_NOT_SYSTEM_APP, res);
404
405 property->SetWindowType(WindowType::WINDOW_TYPE_FLOAT);
406 property->SetFloatingWindowAppType(true);
407 ssm_->shouldHideNonSecureFloatingWindows_.store(true);
408 res = ssm_->CreateAndConnectSpecificSession(sessionStage, eventChannel, node, property, id, session,
409 systemConfig, token);
410 ASSERT_EQ(WSError::WS_ERROR_NOT_SYSTEM_APP, res);
411
412 property->SetWindowType(WindowType::WINDOW_TYPE_SYSTEM_ALARM_WINDOW);
413 res = ssm_->CreateAndConnectSpecificSession(sessionStage, eventChannel, node, property, id, session,
414 systemConfig, token);
415 ASSERT_EQ(WSError::WS_ERROR_INVALID_WINDOW, res);
416
417 property->SetWindowType(WindowType::WINDOW_TYPE_PIP);
418 ssm_->isScreenLocked_ = true;
419 res = ssm_->CreateAndConnectSpecificSession(sessionStage, eventChannel, node, property, id, session,
420 systemConfig, token);
421 ASSERT_EQ(WSError::WS_DO_NOTHING, res);
422 }
423
424 /**
425 * @tc.name: SetCreateKeyboardSessionListener
426 * @tc.desc: SetCreateKeyboardSessionListener
427 * @tc.type: FUNC
428 */
429 HWTEST_F(SceneSessionManagerTest12, SetCreateKeyboardSessionListener, Function | SmallTest | Level3)
430 {
431 ASSERT_NE(ssm_, nullptr);
432 ssm_->SetCreateSystemSessionListener(nullptr);
433 SessionInfo sessionInfo;
434 sessionInfo.bundleName_ = "test1";
435 sessionInfo.abilityName_ = "test2";
436 sessionInfo.abilityInfo = nullptr;
437 sessionInfo.isAtomicService_ = true;
438 sessionInfo.screenId_ = SCREEN_ID_INVALID;
439 ssm_->NotifySessionTouchOutside(123);
440 }
441
442 /**
443 * @tc.name: DestroyAndDisconnectSpecificSessionInner
444 * @tc.desc: check func DestroyAndDisconnectSpecificSessionInner
445 * @tc.type: FUNC
446 */
447 HWTEST_F(SceneSessionManagerTest12, DestroyAndDisconnectSpecificSessionInner02, Function | SmallTest | Level2)
448 {
449 ASSERT_NE(ssm_, nullptr);
450 SessionInfo info;
451 info.abilityName_ = "test1";
452 info.bundleName_ = "test2";
453 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
454 ASSERT_NE(nullptr, property);
455 std::vector<int32_t> recoveredPersistentIds = {0, 1, 2};
456 ssm_->SetAlivePersistentIds(recoveredPersistentIds);
457 property->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
458 auto ret = ssm_->DestroyAndDisconnectSpecificSessionInner(1);
459 EXPECT_EQ(ret, WSError::WS_ERROR_NULLPTR);
460 }
461
462 /**
463 * @tc.name: DestroyToastSession
464 * @tc.desc: DestroyToastSession
465 * @tc.type: FUNC
466 */
467 HWTEST_F(SceneSessionManagerTest12, DestroyToastSession, Function | SmallTest | Level3)
468 {
469 ASSERT_NE(ssm_, nullptr);
470 SessionInfo info;
471 info.abilityName_ = "test1";
472 info.bundleName_ = "test2";
473 info.screenId_ = SCREEN_ID_INVALID;
474 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
475 ASSERT_NE(property, nullptr);
476 property->SetWindowType(WindowType::WINDOW_TYPE_KEYBOARD_PANEL);
477 sptr<SceneSession> sceneSession = nullptr;
478 ssm_->DestroyToastSession(sceneSession);
479 sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
480 ssm_->DestroyToastSession(sceneSession);
481 ssm_->StartUIAbilityBySCB(sceneSession);
482 int32_t ret = ssm_->ChangeUIAbilityVisibilityBySCB(sceneSession, true);
483 EXPECT_NE(ret, ERR_OK);
484 }
485
486 /**
487 * @tc.name: DestroyToastSession
488 * @tc.desc: DestroyToastSession
489 * @tc.type: FUNC
490 */
491 HWTEST_F(SceneSessionManagerTest12, DestroyToastSession02, Function | SmallTest | Level3)
492 {
493 ASSERT_NE(ssm_, nullptr);
494 SessionInfo info;
495 info.abilityName_ = "test1";
496 info.bundleName_ = "test2";
497 info.screenId_ = SCREEN_ID_INVALID;
498 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
499 ASSERT_NE(property, nullptr);
500 property->SetWindowType(WindowType::WINDOW_TYPE_KEYBOARD_PANEL);
501 sptr<SceneSession> sceneSession = nullptr;
502 ssm_->DestroyToastSession(sceneSession);
503 sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
504 sceneSession->state_ = SessionState::STATE_FOREGROUND;
505 ssm_->DestroyToastSession(sceneSession);
506 }
507
508 /**
509 * @tc.name: CheckModalSubWindowPermission
510 * @tc.desc: CheckModalSubWindowPermission
511 * @tc.type: FUNC
512 */
513 HWTEST_F(SceneSessionManagerTest12, CheckModalSubWindowPermission, Function | SmallTest | Level3)
514 {
515 ASSERT_NE(ssm_, nullptr);
516 SessionInfo info;
517 info.abilityName_ = "test1";
518 info.bundleName_ = "test2";
519 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
520 ASSERT_NE(property, nullptr);
521 property->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
522 property->SetWindowFlags(123);
523 ssm_->CheckModalSubWindowPermission(property);
524 property->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
525 ssm_->CheckModalSubWindowPermission(property);
526 }
527
528 /**
529 * @tc.name: CheckModalSubWindowPermission
530 * @tc.desc: CheckModalSubWindowPermission
531 * @tc.type: FUNC
532 */
533 HWTEST_F(SceneSessionManagerTest12, CheckModalSubWindowPermission02, Function | SmallTest | Level3)
534 {
535 ASSERT_NE(ssm_, nullptr);
536 SessionInfo info;
537 info.abilityName_ = "test1";
538 info.bundleName_ = "test2";
539 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
540 ASSERT_NE(property, nullptr);
541 property->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
542 property->SetWindowFlags(123);
543 property->SetTopmost(true);
544 ssm_->CheckModalSubWindowPermission(property);
545 property->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
546 ssm_->CheckModalSubWindowPermission(property);
547 }
548
549 /**
550 * @tc.name: DestroyAndDisconnectSpecificSessionInner
551 * @tc.desc: check func DestroyAndDisconnectSpecificSessionInner
552 * @tc.type: FUNC
553 */
554 HWTEST_F(SceneSessionManagerTest12, DestroyAndDisconnectSpecificSessionInner, Function | SmallTest | Level2)
555 {
556 sptr<ISession> session;
557 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
558 ASSERT_NE(nullptr, property);
559 std::vector<int32_t> recoveredPersistentIds = {0, 1, 2};
560 ssm_->SetAlivePersistentIds(recoveredPersistentIds);
561 ProcessShiftFocusFunc shiftFocusFunc_;
562 property->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
563 auto ret = ssm_->DestroyAndDisconnectSpecificSessionInner(1);
564 EXPECT_EQ(ret, WSError::WS_ERROR_NULLPTR);
565 property->SetPersistentId(1);
566 ret = ssm_->DestroyAndDisconnectSpecificSessionInner(1);
567 EXPECT_EQ(ret, WSError::WS_ERROR_NULLPTR);
568
569 property->SetWindowType(WindowType::WINDOW_TYPE_TOAST);
570 ret = ssm_->DestroyAndDisconnectSpecificSessionInner(1);
571 EXPECT_EQ(ret, WSError::WS_ERROR_NULLPTR);
572 }
573
574 /**
575 * @tc.name: DestroyAndDisconnectSpecificSessionWithDetachCallback
576 * @tc.desc: SceneSesionManager destroy and disconnect specific session with detach callback
577 * @tc.type: FUNC
578 */
579 HWTEST_F(SceneSessionManagerTest12, DestroyAndDetachCallback, Function | SmallTest | Level3)
580 {
581 int32_t persistentId = 0;
582 ASSERT_NE(ssm_, nullptr);
583 sptr<IRemoteObject> callback = sptr<IRemoteObjectMocker>::MakeSptr();
584 ASSERT_NE(callback, nullptr);
585 ssm_->DestroyAndDisconnectSpecificSessionWithDetachCallback(persistentId, callback);
586 sptr<WindowSessionProperty> property;
587 ssm_->recoveringFinished_ = false;
588 SessionInfo info;
589 info.abilityName_ = "test1";
590 info.bundleName_ = "test2";
591 sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(info, property);
592 ssm_->DestroyAndDisconnectSpecificSessionWithDetachCallback(persistentId, callback);
593 }
594
595 /**
596 * @tc.name: IsKeyboardForeground
597 * @tc.desc: IsKeyboardForeground
598 * @tc.type: FUNC
599 */
600 HWTEST_F(SceneSessionManagerTest12, IsKeyboardForeground, Function | SmallTest | Level3)
601 {
602 auto sceneSessionManager = sptr<SceneSessionManager>::MakeSptr();
603 SessionInfo info;
604 info.abilityName_ = "test1";
605 info.bundleName_ = "test2";
606 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
607 sceneSession->property_ = sptr<WindowSessionProperty>::MakeSptr();
608 sceneSessionManager->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
609
610 sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
611 sceneSession->state_ = SessionState::STATE_FOREGROUND;
612 ASSERT_EQ(true, sceneSessionManager->IsKeyboardForeground());
613 sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_SYSTEM_ALARM_WINDOW);
614 ASSERT_EQ(false, sceneSessionManager->IsKeyboardForeground());
615 sceneSessionManager->sceneSessionMap_.clear();
616 ASSERT_EQ(false, sceneSessionManager->IsKeyboardForeground());
617 }
618
619 /**
620 * @tc.name: RegisterWatchGestureConsumeResultCallback
621 * @tc.desc: RegisterWatchGestureConsumeResultCallback
622 * @tc.type: FUNC
623 */
624 HWTEST_F(SceneSessionManagerTest12, RegisterWatchGestureConsumeResultCallback, Function | SmallTest | Level3)
625 {
__anonde13cb070202(int32_t keyCode, bool isConsumed) 626 NotifyWatchGestureConsumeResultFunc func = [](int32_t keyCode, bool isConsumed) {};
627 ssm_->RegisterWatchGestureConsumeResultCallback(std::move(func));
628 ASSERT_NE(ssm_->onWatchGestureConsumeResultFunc_, nullptr);
629 }
630
631 /**
632 * @tc.name: RegisterWatchFocusActiveChangeCallback
633 * @tc.desc: RegisterWatchFocusActiveChangeCallback
634 * @tc.type: FUNC
635 */
636 HWTEST_F(SceneSessionManagerTest12, RegisterWatchFocusActiveChangeCallback, Function | SmallTest | Level3)
637 {
__anonde13cb070302(bool isActive) 638 NotifyWatchFocusActiveChangeFunc func = [](bool isActive) {};
639 ssm_->RegisterWatchFocusActiveChangeCallback(std::move(func));
640 ASSERT_NE(ssm_->onWatchFocusActiveChangeFunc_, nullptr);
641 }
642
643 /**
644 * @tc.name: NotifyWatchGestureConsumeResult
645 * @tc.desc: NotifyWatchGestureConsumeResult
646 * @tc.type: FUNC
647 */
648 HWTEST_F(SceneSessionManagerTest12, NotifyWatchGestureConsumeResult, Function | SmallTest | Level3)
649 {
650 int32_t keyCode = 2049;
651 bool isConsumed = true;
__anonde13cb070402(int32_t keyCode, bool isConsumed) 652 ssm_->onWatchGestureConsumeResultFunc_ = [](int32_t keyCode, bool isConsumed) {};
653 auto ret = ssm_->NotifyWatchGestureConsumeResult(keyCode, isConsumed);
654 ASSERT_EQ(WMError::WM_OK, ret);
655 ssm_->onWatchGestureConsumeResultFunc_ = nullptr;
656 ret = ssm_->NotifyWatchGestureConsumeResult(keyCode, isConsumed);
657 ASSERT_EQ(ret, WMError::WM_ERROR_INVALID_PARAM);
658 }
659
660 /**
661 * @tc.name: NotifyWatchFocusActiveChange
662 * @tc.desc: NotifyWatchFocusActiveChange
663 * @tc.type: FUNC
664 */
665 HWTEST_F(SceneSessionManagerTest12, NotifyWatchFocusActiveChange, Function | SmallTest | Level3)
666 {
667 bool isActive = true;
__anonde13cb070502(bool isActive) 668 ssm_->onWatchFocusActiveChangeFunc_ = [](bool isActive) {};
669 auto ret = ssm_->NotifyWatchFocusActiveChange(isActive);
670 ASSERT_EQ(WMError::WM_OK, ret);
671 ssm_->onWatchFocusActiveChangeFunc_ = nullptr;
672 ret = ssm_->NotifyWatchFocusActiveChange(isActive);
673 ASSERT_EQ(ret, WMError::WM_ERROR_INVALID_PARAM);
674 }
675
676 /**
677 * @tc.name: ShiftAppWindowPointerEvent01
678 * @tc.desc: ShiftAppWindowPointerEvent,
679 * @tc.type: FUNC
680 */
681 HWTEST_F(SceneSessionManagerTest12, ShiftAppWindowPointerEvent_01, Function | SmallTest | Level3)
682 {
683 SessionInfo sourceInfo;
684 sourceInfo.windowType_ = 1;
685 sptr<SceneSession> sourceSceneSession = sptr<SceneSession>::MakeSptr(sourceInfo, nullptr);
686 ssm_->sceneSessionMap_.insert({sourceSceneSession->GetPersistentId(), sourceSceneSession});
687
688 SessionInfo targetInfo;
689 targetInfo.windowType_ = 1;
690 sptr<SceneSession> targetSceneSession = sptr<SceneSession>::MakeSptr(targetInfo, nullptr);
691 ssm_->sceneSessionMap_.insert({targetSceneSession->GetPersistentId(), targetSceneSession});
692
693 ssm_->systemConfig_.windowUIType_ = WindowUIType::PC_WINDOW;
694 WMError result = ssm_->ShiftAppWindowPointerEvent(INVALID_SESSION_ID, targetSceneSession->GetPersistentId());
695 EXPECT_EQ(result, WMError::WM_ERROR_INVALID_SESSION);
696 result = ssm_->ShiftAppWindowPointerEvent(sourceSceneSession->GetPersistentId(), INVALID_SESSION_ID);
697 EXPECT_EQ(result, WMError::WM_ERROR_INVALID_SESSION);
698 ssm_->sceneSessionMap_.erase(sourceSceneSession->GetPersistentId());
699 ssm_->sceneSessionMap_.erase(targetSceneSession->GetPersistentId());
700 }
701
702 /**
703 * @tc.name: ShiftAppWindowPointerEvent02
704 * @tc.desc: ShiftAppWindowPointerEvent,
705 * @tc.type: FUNC
706 */
707 HWTEST_F(SceneSessionManagerTest12, ShiftAppWindowPointerEvent_02, Function | SmallTest | Level3)
708 {
709 SessionInfo systemWindowInfo;
710 systemWindowInfo.windowType_ = 2000;
711 sptr<SceneSession> systemWindowSession = sptr<SceneSession>::MakeSptr(systemWindowInfo, nullptr);
712 ssm_->sceneSessionMap_.insert({systemWindowSession->GetPersistentId(), systemWindowSession});
713
714 SessionInfo mainWindowInfo;
715 mainWindowInfo.windowType_ = 1;
716 sptr<SceneSession> mainWindowSession = sptr<SceneSession>::MakeSptr(mainWindowInfo, nullptr);
717 ssm_->sceneSessionMap_.insert({mainWindowSession->GetPersistentId(), mainWindowSession});
718
719 int mainWindowPersistentId = mainWindowSession->GetPersistentId();
720 int systemWindowPersistentId = systemWindowSession->GetPersistentId();
721 ssm_->systemConfig_.windowUIType_ = WindowUIType::PC_WINDOW;
722 WMError result = ssm_->ShiftAppWindowPointerEvent(mainWindowPersistentId, systemWindowPersistentId);
723 EXPECT_EQ(result, WMError::WM_ERROR_INVALID_CALLING);
724 result = ssm_->ShiftAppWindowPointerEvent(systemWindowPersistentId, mainWindowPersistentId);
725 EXPECT_EQ(result, WMError::WM_ERROR_INVALID_CALLING);
726 ssm_->sceneSessionMap_.erase(systemWindowSession->GetPersistentId());
727 ssm_->sceneSessionMap_.erase(mainWindowSession->GetPersistentId());
728 }
729
730 /**
731 * @tc.name: ShiftAppWindowPointerEvent03
732 * @tc.desc: ShiftAppWindowPointerEvent,
733 * @tc.type: FUNC
734 */
735 HWTEST_F(SceneSessionManagerTest12, ShiftAppWindowPointerEvent_03, Function | SmallTest | Level3)
736 {
737 SessionInfo sourceInfo;
738 sourceInfo.windowType_ = 1;
739 sptr<SceneSession> sourceSceneSession = sptr<SceneSession>::MakeSptr(sourceInfo, nullptr);
740 ssm_->sceneSessionMap_.insert({sourceSceneSession->GetPersistentId(), sourceSceneSession});
741
742 int32_t sourcePersistentId = sourceSceneSession->GetPersistentId();
743 ssm_->systemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW;
744 WMError result = ssm_->ShiftAppWindowPointerEvent(sourcePersistentId, sourcePersistentId);
745 EXPECT_EQ(result, WMError::WM_ERROR_DEVICE_NOT_SUPPORT);
746
747 ssm_->systemConfig_.windowUIType_ = WindowUIType::PC_WINDOW;
748 result = ssm_->ShiftAppWindowPointerEvent(sourcePersistentId, sourcePersistentId);
749 EXPECT_EQ(result, WMError::WM_ERROR_INVALID_CALLING);
750 ssm_->sceneSessionMap_.erase(sourceSceneSession->GetPersistentId());
751 }
752
753 /**
754 * @tc.name: ShiftAppWindowPointerEvent04
755 * @tc.desc: ShiftAppWindowPointerEvent,
756 * @tc.type: FUNC
757 */
758 HWTEST_F(SceneSessionManagerTest12, ShiftAppWindowPointerEvent_04, Function | SmallTest | Level3)
759 {
760 SessionInfo sourceInfo;
761 sourceInfo.windowType_ = 1;
762 sptr<SceneSession> sourceSceneSession = sptr<SceneSession>::MakeSptr(sourceInfo, nullptr);
763 ssm_->sceneSessionMap_.insert({sourceSceneSession->GetPersistentId(), sourceSceneSession});
764
765 SessionInfo otherSourceInfo;
766 otherSourceInfo.bundleName_ = "other";
767 otherSourceInfo.windowType_ = 1;
768 sptr<SceneSession> otherSourceSession = sptr<SceneSession>::MakeSptr(otherSourceInfo, nullptr);
769 ssm_->sceneSessionMap_.insert({otherSourceSession->GetPersistentId(), otherSourceSession});
770
771 SessionInfo otherTargetInfo;
772 otherTargetInfo.bundleName_ = "other";
773 otherTargetInfo.windowType_ = 1;
774 sptr<SceneSession> otherTargetSession = sptr<SceneSession>::MakeSptr(otherTargetInfo, nullptr);
775 ssm_->sceneSessionMap_.insert({otherTargetSession->GetPersistentId(), otherTargetSession});
776
777 int32_t sourcePersistentId = sourceSceneSession->GetPersistentId();
778 int32_t otherSourcePersistentId = otherSourceSession->GetPersistentId();
779 int32_t otherTargetPersistentId = otherTargetSession->GetPersistentId();
780 ssm_->systemConfig_.windowUIType_ = WindowUIType::PC_WINDOW;
781 WMError result = ssm_->ShiftAppWindowPointerEvent(sourcePersistentId, otherTargetPersistentId);
782 EXPECT_EQ(result, WMError::WM_ERROR_INVALID_CALLING);
783 result = ssm_->ShiftAppWindowPointerEvent(otherSourcePersistentId, otherTargetPersistentId);
784 EXPECT_EQ(result, WMError::WM_ERROR_INVALID_CALLING);
785 ssm_->sceneSessionMap_.erase(sourceSceneSession->GetPersistentId());
786 ssm_->sceneSessionMap_.erase(otherSourceSession->GetPersistentId());
787 ssm_->sceneSessionMap_.erase(otherTargetSession->GetPersistentId());
788 }
789
790 /**
791 * @tc.name: GetKeyboardSession
792 * @tc.desc: test GetKeyboardSession
793 * @tc.type: FUNC
794 */
795 HWTEST_F(SceneSessionManagerTest12, GetKeyboardSession, Function | SmallTest | Level3)
796 {
797 sptr<SceneSessionManager> ssm = sptr<SceneSessionManager>::MakeSptr();
798 SessionInfo info;
799 info.abilityName_ = "GetKeyboardSession";
800 info.bundleName_ = "GetKeyboardSession";
801 info.windowType_ = 2105; // 2105 is WINDOW_TYPE_INPUT_METHOD_FLOAT
802 info.screenId_ = 1; // 1 is screenId
803 sptr<KeyboardSession> keyboardSession = sptr<KeyboardSession>::MakeSptr(info, nullptr, nullptr);
804 ASSERT_EQ(false, keyboardSession->IsSystemKeyboard());
805 ssm->sceneSessionMap_.insert({ keyboardSession->GetPersistentId(), keyboardSession });
806 sptr<KeyboardSession> systemKeyboardSession = sptr<KeyboardSession>::MakeSptr(info, nullptr, nullptr);
807 systemKeyboardSession->SetIsSystemKeyboard(true);
808 ASSERT_EQ(true, systemKeyboardSession->IsSystemKeyboard());
809 ssm->sceneSessionMap_.insert({ systemKeyboardSession->GetPersistentId(), systemKeyboardSession });
810
811 ASSERT_EQ(nullptr, ssm->GetKeyboardSession(DISPLAY_ID_INVALID, false));
812 ASSERT_NE(nullptr, ssm->GetKeyboardSession(keyboardSession->GetScreenId(), false));
813 ASSERT_NE(nullptr, ssm->GetKeyboardSession(systemKeyboardSession->GetScreenId(), true));
814 }
815
816 /**
817 * @tc.name: UpdateKeyboardAvoidAreaActive
818 * @tc.desc: test UpdateKeyboardAvoidAreaActive
819 * @tc.type: FUNC
820 */
821 HWTEST_F(SceneSessionManagerTest12, UpdateKeyboardAvoidAreaActive, Function | SmallTest | Level3)
822 {
823 sptr<SceneSessionManager> ssm = sptr<SceneSessionManager>::MakeSptr();
824 SessionInfo info;
825 info.abilityName_ = "UpdateKeyboardAvoidAreaActive";
826 info.bundleName_ = "UpdateKeyboardAvoidAreaActive";
827 info.windowType_ = 2105; // 2105 is WINDOW_TYPE_INPUT_METHOD_FLOAT
828 info.screenId_ = 1; // 1 is screenId
829 sptr<KeyboardSession> keyboardSession = sptr<KeyboardSession>::MakeSptr(info, nullptr, nullptr);
830 ASSERT_NE(nullptr, keyboardSession->GetSessionProperty());
831 keyboardSession->GetSessionProperty()->SetDisplayId(info.screenId_);
832 ASSERT_EQ(false, keyboardSession->IsSystemKeyboard());
833 ssm->sceneSessionMap_.insert({ keyboardSession->GetPersistentId(), keyboardSession });
834 sptr<KeyboardSession> systemKeyboardSession = sptr<KeyboardSession>::MakeSptr(info, nullptr, nullptr);
835 ASSERT_NE(nullptr, systemKeyboardSession->GetSessionProperty());
836 systemKeyboardSession->GetSessionProperty()->SetDisplayId(info.screenId_);
837 systemKeyboardSession->SetIsSystemKeyboard(true);
838 ASSERT_EQ(true, systemKeyboardSession->IsSystemKeyboard());
839 ssm->sceneSessionMap_.insert({ systemKeyboardSession->GetPersistentId(), systemKeyboardSession });
840
841 ssm->UpdateKeyboardAvoidAreaActive(false);
842 ASSERT_EQ(true, keyboardSession->keyboardAvoidAreaActive_);
843 ASSERT_EQ(false, systemKeyboardSession->keyboardAvoidAreaActive_);
844 ssm->UpdateKeyboardAvoidAreaActive(true);
845 ASSERT_EQ(false, keyboardSession->keyboardAvoidAreaActive_);
846 ASSERT_EQ(true, systemKeyboardSession->keyboardAvoidAreaActive_);
847 }
848
849 /**
850 * @tc.name: HandleKeyboardAvoidChange
851 * @tc.desc: test HandleKeyboardAvoidChange
852 * @tc.type: FUNC
853 */
854 HWTEST_F(SceneSessionManagerTest12, HandleKeyboardAvoidChange, Function | SmallTest | Level3)
855 {
856 sptr<SceneSessionManager> ssm = sptr<SceneSessionManager>::MakeSptr();
857 SessionInfo info;
858 info.abilityName_ = "HandleKeyboardAvoidChange";
859 info.bundleName_ = "HandleKeyboardAvoidChange";
860 info.windowType_ = 2105; // 2105 is WINDOW_TYPE_INPUT_METHOD_FLOAT
861 info.screenId_ = 1; // 1 is screenId
862 sptr<KeyboardSession> keyboardSession = sptr<KeyboardSession>::MakeSptr(info, nullptr, nullptr);
863 ASSERT_NE(nullptr, keyboardSession->GetSessionProperty());
864 keyboardSession->GetSessionProperty()->SetDisplayId(info.screenId_);
865 ASSERT_EQ(false, keyboardSession->IsSystemKeyboard());
866 ssm->sceneSessionMap_.insert({ keyboardSession->GetPersistentId(), keyboardSession });
867 sptr<KeyboardSession> systemKeyboardSession = sptr<KeyboardSession>::MakeSptr(info, nullptr, nullptr);
868 ASSERT_NE(nullptr, systemKeyboardSession->GetSessionProperty());
869 systemKeyboardSession->GetSessionProperty()->SetDisplayId(info.screenId_);
870 systemKeyboardSession->SetIsSystemKeyboard(true);
871 ASSERT_EQ(true, systemKeyboardSession->IsSystemKeyboard());
872 ssm->sceneSessionMap_.insert({ systemKeyboardSession->GetPersistentId(), systemKeyboardSession });
873
874 ssm->systemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW;
875 ssm->HandleKeyboardAvoidChange(keyboardSession, keyboardSession->GetScreenId(),
876 SystemKeyboardAvoidChangeReason::KEYBOARD_CREATED);
877 ASSERT_EQ(true, keyboardSession->keyboardAvoidAreaActive_);
878
879 ssm->systemConfig_.windowUIType_ = WindowUIType::PC_WINDOW;
880 ssm->HandleKeyboardAvoidChange(keyboardSession, keyboardSession->GetScreenId(),
881 SystemKeyboardAvoidChangeReason::KEYBOARD_CREATED);
882 ASSERT_EQ(true, keyboardSession->keyboardAvoidAreaActive_);
883
884 ssm->HandleKeyboardAvoidChange(systemKeyboardSession, systemKeyboardSession->GetScreenId(),
885 SystemKeyboardAvoidChangeReason::KEYBOARD_SHOW);
886 ASSERT_EQ(false, keyboardSession->keyboardAvoidAreaActive_);
887 ASSERT_EQ(true, systemKeyboardSession->keyboardAvoidAreaActive_);
888
889 ssm->HandleKeyboardAvoidChange(systemKeyboardSession, systemKeyboardSession->GetScreenId(),
890 SystemKeyboardAvoidChangeReason::KEYBOARD_GRAVITY_BOTTOM);
891 ASSERT_EQ(false, keyboardSession->keyboardAvoidAreaActive_);
892 ASSERT_EQ(true, systemKeyboardSession->keyboardAvoidAreaActive_);
893
894 ssm->HandleKeyboardAvoidChange(systemKeyboardSession, systemKeyboardSession->GetScreenId(),
895 SystemKeyboardAvoidChangeReason::KEYBOARD_HIDE);
896 ASSERT_EQ(true, keyboardSession->keyboardAvoidAreaActive_);
897 ASSERT_EQ(false, systemKeyboardSession->keyboardAvoidAreaActive_);
898
899 ssm->HandleKeyboardAvoidChange(systemKeyboardSession, systemKeyboardSession->GetScreenId(),
900 SystemKeyboardAvoidChangeReason::KEYBOARD_DISCONNECT);
901 ASSERT_EQ(true, keyboardSession->keyboardAvoidAreaActive_);
902 ASSERT_EQ(false, systemKeyboardSession->keyboardAvoidAreaActive_);
903
904 ssm->HandleKeyboardAvoidChange(systemKeyboardSession, systemKeyboardSession->GetScreenId(),
905 SystemKeyboardAvoidChangeReason::KEYBOARD_GRAVITY_FLOAT);
906 ASSERT_EQ(true, keyboardSession->keyboardAvoidAreaActive_);
907 ASSERT_EQ(false, systemKeyboardSession->keyboardAvoidAreaActive_);
908 }
909
910 /**
911 * @tc.name: GetAllWindowLayoutInfo01
912 * @tc.desc: HALF_FOLDED
913 * @tc.type: FUNC
914 */
915 HWTEST_F(SceneSessionManagerTest12, GetAllWindowLayoutInfo01, Function | SmallTest | Level3)
916 {
917 PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus(0, SuperFoldStatus::HALF_FOLDED,
918 { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1624, 2472, 1648 });
919 SessionInfo sessionInfo;
920 sessionInfo.isSystem_ = false;
921
922 sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
923 sceneSession1->SetVisibilityState(WINDOW_VISIBILITY_STATE_NO_OCCLUSION);
924 WSRect rect = { 0, 1500, 120, 1000 };
925 sceneSession1->SetSessionRect(rect);
926 sceneSession1->SetSessionGlobalRect(rect);
927 int32_t zOrder = 100;
928 sceneSession1->SetZOrder(zOrder);
929 ssm_->sceneSessionMap_.insert({ sceneSession1->GetPersistentId(), sceneSession1 });
930
931 constexpr DisplayId VIRTUAL_DISPLAY_ID = 999;
932 std::vector<sptr<WindowLayoutInfo>> info;
933 ssm_->GetAllWindowLayoutInfo(VIRTUAL_DISPLAY_ID, info);
934 ssm_->sceneSessionMap_.clear();
935 ASSERT_NE(info.size(), 0);
936 ASSERT_EQ(-972, info[0]->rect.posY_);
937 }
938
939 /**
940 * @tc.name: FilterForGetAllWindowLayoutInfo01
941 * @tc.desc: test return by zOrder
942 * @tc.type: FUNC
943 */
944 HWTEST_F(SceneSessionManagerTest12, FilterForGetAllWindowLayoutInfo01, Function | SmallTest | Level3)
945 {
946 SessionInfo sessionInfo;
947 sessionInfo.isSystem_ = false;
948
949 sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
950 sceneSession1->SetVisibilityState(WINDOW_VISIBILITY_STATE_NO_OCCLUSION);
951 WSRect rect = { 0, 0, 120, 120 };
952 sceneSession1->SetSessionRect(rect);
953 sceneSession1->SetSessionGlobalRect(rect);
954 int32_t zOrder = 100;
955 sceneSession1->SetZOrder(zOrder);
956 ssm_->sceneSessionMap_.insert({ sceneSession1->GetPersistentId(), sceneSession1 });
957
958 sptr<SceneSession> sceneSession2 = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
959 sceneSession2->SetVisibilityState(WINDOW_VISIBILITY_STATE_NO_OCCLUSION);
960 rect = { 0, 130, 120, 120 };
961 sceneSession2->SetSessionRect(rect);
962 sceneSession2->SetSessionGlobalRect(rect);
963 zOrder = 101;
964 sceneSession2->SetZOrder(zOrder);
965 ssm_->sceneSessionMap_.insert({ sceneSession2->GetPersistentId(), sceneSession2 });
966
967 constexpr DisplayId DEFAULT_DISPLAY_ID = 0;
968 std::vector<sptr<SceneSession>> filteredSessions;
969 ssm_->FilterForGetAllWindowLayoutInfo(DEFAULT_DISPLAY_ID, false, filteredSessions);
970 ssm_->sceneSessionMap_.clear();
971 ASSERT_NE(filteredSessions.size(), 0);
972 ASSERT_EQ(130, filteredSessions[0]->GetSessionRect().posY_);
973 }
974
975 /**
976 * @tc.name: FilterForGetAllWindowLayoutInfo02
977 * @tc.desc: test system window
978 * @tc.type: FUNC
979 */
980 HWTEST_F(SceneSessionManagerTest12, FilterForGetAllWindowLayoutInfo02, Function | SmallTest | Level3)
981 {
982 SessionInfo sessionInfo;
983 sessionInfo.isSystem_ = false;
984 sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
985 sceneSession1->SetVisibilityState(WINDOW_VISIBILITY_STATE_NO_OCCLUSION);
986 WSRect rect = { 0, 0, 120, 120 };
987 sceneSession1->SetSessionRect(rect);
988 sceneSession1->SetSessionGlobalRect(rect);
989 int32_t zOrder = 100;
990 sceneSession1->SetZOrder(zOrder);
991 ssm_->sceneSessionMap_.insert({sceneSession1->GetPersistentId(), sceneSession1});
992
993 sessionInfo.isSystem_ = true;
994 sessionInfo.abilityName_ = "SCBSmartDock";
995 sptr<SceneSession> sceneSession2 = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
996 sceneSession2->SetVisibilityState(WINDOW_VISIBILITY_STATE_NO_OCCLUSION);
997 rect = { 0, 130, 120, 120 };
998 sceneSession2->SetSessionRect(rect);
999 sceneSession2->SetSessionGlobalRect(rect);
1000 zOrder = 101;
1001 sceneSession2->SetZOrder(zOrder);
1002 ssm_->sceneSessionMap_.insert({ sceneSession2->GetPersistentId(), sceneSession2 });
1003
1004 sessionInfo.abilityName_ = "TestAbility";
1005 sptr<SceneSession> sceneSession3 = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1006 sceneSession3->SetVisibilityState(WINDOW_VISIBILITY_STATE_NO_OCCLUSION);
1007 rect = { 0, 250, 120, 120 };
1008 sceneSession3->SetSessionRect(rect);
1009 sceneSession3->SetSessionGlobalRect(rect);
1010 zOrder = 102;
1011 sceneSession3->SetZOrder(zOrder);
1012 ssm_->sceneSessionMap_.insert({ sceneSession3->GetPersistentId(), sceneSession3 });
1013
1014 constexpr DisplayId DEFAULT_DISPLAY_ID = 0;
1015 std::vector<sptr<SceneSession>> filteredSessions;
1016 ssm_->FilterForGetAllWindowLayoutInfo(DEFAULT_DISPLAY_ID, false, filteredSessions);
1017 ssm_->sceneSessionMap_.clear();
1018 ASSERT_EQ(2, filteredSessions.size());
1019 }
1020
1021 /**
1022 * @tc.name: FilterForGetAllWindowLayoutInfo03
1023 * @tc.desc: test VisibilityState
1024 * @tc.type: FUNC
1025 */
1026 HWTEST_F(SceneSessionManagerTest12, FilterForGetAllWindowLayoutInfo03, Function | SmallTest | Level3)
1027 {
1028 SessionInfo sessionInfo;
1029 sessionInfo.isSystem_ = false;
1030 sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1031 sceneSession1->SetVisibilityState(WINDOW_VISIBILITY_STATE_NO_OCCLUSION);
1032 WSRect rect = { 0, 0, 120, 120 };
1033 sceneSession1->SetSessionRect(rect);
1034 sceneSession1->SetSessionGlobalRect(rect);
1035 int32_t zOrder = 101;
1036 sceneSession1->SetZOrder(zOrder);
1037 ssm_->sceneSessionMap_.insert({ sceneSession1->GetPersistentId(), sceneSession1 });
1038
1039 sptr<SceneSession> sceneSession2 = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1040 sceneSession2->SetVisibilityState(WINDOW_VISIBILITY_STATE_PARTICALLY_OCCLUSION);
1041 rect = { 0, 0, 130, 120 };
1042 sceneSession2->SetSessionRect(rect);
1043 sceneSession2->SetSessionGlobalRect(rect);
1044 zOrder = 100;
1045 sceneSession2->SetZOrder(zOrder);
1046 ssm_->sceneSessionMap_.insert({ sceneSession2->GetPersistentId(), sceneSession2 });
1047
1048 sptr<SceneSession> sceneSession3 = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1049 sceneSession3->SetVisibilityState(WINDOW_VISIBILITY_STATE_TOTALLY_OCCUSION);
1050 rect = { 0, 0, 100, 100 };
1051 sceneSession3->SetSessionRect(rect);
1052 sceneSession3->SetSessionGlobalRect(rect);
1053 zOrder = 99;
1054 sceneSession3->SetZOrder(zOrder);
1055 ssm_->sceneSessionMap_.insert({ sceneSession3->GetPersistentId(), sceneSession3 });
1056
1057 constexpr DisplayId DEFAULT_DISPLAY_ID = 0;
1058 std::vector<sptr<SceneSession>> filteredSessions;
1059 ssm_->FilterForGetAllWindowLayoutInfo(DEFAULT_DISPLAY_ID, false, filteredSessions);
1060 ssm_->sceneSessionMap_.clear();
1061 ASSERT_EQ(2, filteredSessions.size());
1062 }
1063
1064 /**
1065 * @tc.name: FilterForGetAllWindowLayoutInfo04
1066 * @tc.desc: HALF_FOLDED
1067 * @tc.type: FUNC
1068 */
1069 HWTEST_F(SceneSessionManagerTest12, FilterForGetAllWindowLayoutInfo04, Function | SmallTest | Level3)
1070 {
1071 PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus(0, SuperFoldStatus::HALF_FOLDED,
1072 { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1624, 2472, 1648 });
1073 SessionInfo sessionInfo;
1074 sessionInfo.isSystem_ = false;
1075
1076 sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1077 sceneSession1->SetVisibilityState(WINDOW_VISIBILITY_STATE_NO_OCCLUSION);
1078 WSRect rect = { 0, 0, 120, 120 };
1079 sceneSession1->SetSessionRect(rect);
1080 sceneSession1->SetSessionGlobalRect(rect);
1081 int32_t zOrder = 100;
1082 sceneSession1->SetZOrder(zOrder);
1083 ssm_->sceneSessionMap_.insert({ sceneSession1->GetPersistentId(), sceneSession1 });
1084
1085 sptr<SceneSession> sceneSession2 = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1086 sceneSession2->SetVisibilityState(WINDOW_VISIBILITY_STATE_NO_OCCLUSION);
1087 rect = { 0, 4000, 120, 120 };
1088 sceneSession2->SetSessionRect(rect);
1089 sceneSession2->SetSessionGlobalRect(rect);
1090 zOrder = 101;
1091 sceneSession2->SetZOrder(zOrder);
1092 ssm_->sceneSessionMap_.insert({ sceneSession2->GetPersistentId(), sceneSession2 });
1093
1094 sptr<SceneSession> sceneSession3 = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1095 sceneSession3->SetVisibilityState(WINDOW_VISIBILITY_STATE_NO_OCCLUSION);
1096 rect = { 0, 1500, 120, 1000 };
1097 sceneSession3->SetSessionRect(rect);
1098 sceneSession3->SetSessionGlobalRect(rect);
1099 zOrder = 102;
1100 sceneSession3->SetZOrder(zOrder);
1101 ssm_->sceneSessionMap_.insert({ sceneSession3->GetPersistentId(), sceneSession3 });
1102
1103 constexpr DisplayId DEFAULT_DISPLAY_ID = 0;
1104 std::vector<sptr<SceneSession>> filteredSessions1;
1105 ssm_->FilterForGetAllWindowLayoutInfo(DEFAULT_DISPLAY_ID, false, filteredSessions1);
1106 EXPECT_EQ(2, filteredSessions1.size());
1107 std::vector<sptr<SceneSession>> filteredSessions2;
1108 ssm_->FilterForGetAllWindowLayoutInfo(DEFAULT_DISPLAY_ID, true, filteredSessions2);
1109 ssm_->sceneSessionMap_.clear();
1110 ASSERT_EQ(2, filteredSessions2.size());
1111 }
1112
1113 /**
1114 * @tc.name: FilterForGetAllWindowLayoutInfo05
1115 * @tc.desc: session is nullptr
1116 * @tc.type: FUNC
1117 */
1118 HWTEST_F(SceneSessionManagerTest12, FilterForGetAllWindowLayoutInfo05, Function | SmallTest | Level3)
1119 {
1120 sptr<SceneSession> sceneSession = nullptr;
1121 ssm_->sceneSessionMap_.insert({ 1, sceneSession });
1122 constexpr DisplayId DEFAULT_DISPLAY_ID = 0;
1123 std::vector<sptr<SceneSession>> filteredSessions;
1124 ssm_->FilterForGetAllWindowLayoutInfo(DEFAULT_DISPLAY_ID, false, filteredSessions);
1125 ssm_->sceneSessionMap_.clear();
1126 ASSERT_EQ(0, filteredSessions.size());
1127 }
1128
1129 /**
1130 * @tc.name: GetFoldLowerScreenPosY01
1131 * @tc.desc: test get fold lower screen posY
1132 * @tc.type: FUNC
1133 */
1134 HWTEST_F(SceneSessionManagerTest12, GetFoldLowerScreenPosY01, Function | SmallTest | Level3)
1135 {
1136 PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus(0, SuperFoldStatus::HALF_FOLDED,
1137 { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1624, 2472, 1648 });
1138 ASSERT_EQ(2472, ssm_->GetFoldLowerScreenPosY());
1139 }
1140
1141 /**
1142 * @tc.name: IsGetWindowLayoutInfoNeeded01
1143 * @tc.desc: not System
1144 * @tc.type: FUNC
1145 */
1146 HWTEST_F(SceneSessionManagerTest12, IsGetWindowLayoutInfoNeeded01, Function | SmallTest | Level3)
1147 {
1148 SessionInfo sessionInfo;
1149 sessionInfo.isSystem_ = false;
1150 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1151 ASSERT_EQ(true, ssm_->IsGetWindowLayoutInfoNeeded(sceneSession));
1152 }
1153
1154 /**
1155 * @tc.name: IsGetWindowLayoutInfoNeeded02
1156 * @tc.desc: is System, not in whitelist
1157 * @tc.type: FUNC
1158 */
1159 HWTEST_F(SceneSessionManagerTest12, IsGetWindowLayoutInfoNeeded02, Function | SmallTest | Level3)
1160 {
1161 SessionInfo sessionInfo;
1162 sessionInfo.isSystem_ = true;
1163 sessionInfo.abilityName_ = "TestAbility";
1164 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1165 ASSERT_EQ(false, ssm_->IsGetWindowLayoutInfoNeeded(sceneSession));
1166 }
1167
1168 /**
1169 * @tc.name: IsGetWindowLayoutInfoNeeded03
1170 * @tc.desc: is System, in whitelist
1171 * @tc.type: FUNC
1172 */
1173 HWTEST_F(SceneSessionManagerTest12, IsGetWindowLayoutInfoNeeded03, Function | SmallTest | Level3)
1174 {
1175 SessionInfo sessionInfo;
1176 sessionInfo.isSystem_ = true;
1177 sessionInfo.abilityName_ = "SCBSmartDock";
1178 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1179 ASSERT_EQ(true, ssm_->IsGetWindowLayoutInfoNeeded(sceneSession));
1180 }
1181
1182 /**
1183 * @tc.name: HasFloatingWindowForeground01
1184 * @tc.desc: test HasFloatingWindowForeground with null abilityToken
1185 * @tc.type: FUNC
1186 */
1187 HWTEST_F(SceneSessionManagerTest12, HasFloatingWindowForeground01, Function | SmallTest | Level3)
1188 {
1189 bool hasFloatWindowForeground = false;
1190 WMError result = ssm_->HasFloatingWindowForeground(nullptr, hasFloatWindowForeground);
1191 EXPECT_EQ(result, WMError::WM_ERROR_NULLPTR);
1192 EXPECT_EQ(hasFloatWindowForeground, false);
1193 }
1194
1195 /**
1196 * @tc.name: HasFloatingWindowForeground02
1197 * @tc.desc: test HasFloatingWindowForeground with not existed abilityToken
1198 * @tc.type: FUNC
1199 */
1200 HWTEST_F(SceneSessionManagerTest12, HasFloatingWindowForeground02, Function | SmallTest | Level3)
1201 {
1202 SessionInfo sessionInfo;
1203 sessionInfo.sessionState_ = SessionState::STATE_ACTIVE;
1204 sessionInfo.persistentId_ = 1;
1205 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1206
1207 sceneSession->GetSessionProperty()->SetWindowType(WindowType::WINDOW_TYPE_FLOAT);
1208 sptr<IRemoteObject> token1 = sptr<MockIRemoteObject>::MakeSptr();
1209 sceneSession->SetAbilityToken(token1);
1210 sceneSession->SetSessionState(SessionState::STATE_ACTIVE);
1211 ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession });
1212
1213 bool hasFloatWindowForeground = false;
1214 sptr<IRemoteObject> token2 = sptr<MockIRemoteObject>::MakeSptr();
1215 WMError result = ssm_->HasFloatingWindowForeground(token2, hasFloatWindowForeground);
1216 EXPECT_EQ(result, WMError::WM_OK);
1217 EXPECT_EQ(hasFloatWindowForeground, false);
1218 }
1219
1220 /**
1221 * @tc.name: HasFloatingWindowForeground03
1222 * @tc.desc: test HasFloatingWindowForeground with existed foreground float window
1223 * @tc.type: FUNC
1224 */
1225 HWTEST_F(SceneSessionManagerTest12, HasFloatingWindowForeground03, Function | SmallTest | Level3)
1226 {
1227 // create first test sceneSession
1228 SessionInfo sessionInfo1;
1229 sessionInfo1.sessionState_ = SessionState::STATE_ACTIVE;
1230 sessionInfo1.persistentId_ = 1;
1231
1232 sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(sessionInfo1, nullptr);
1233 sptr<IRemoteObject> token1 = sptr<MockIRemoteObject>::MakeSptr();
1234 sceneSession1->GetSessionProperty()->SetWindowType(WindowType::WINDOW_TYPE_FLOAT);
1235 sceneSession1->SetAbilityToken(token1);
1236 sceneSession1->SetSessionState(SessionState::STATE_ACTIVE);
1237
1238 // create second test sceneSession
1239 SessionInfo sessionInfo2;
1240 sessionInfo2.sessionState_ = SessionState::STATE_FOREGROUND;
1241 sessionInfo2.persistentId_ = 2;
1242
1243 sptr<SceneSession> sceneSession2 = sptr<SceneSession>::MakeSptr(sessionInfo2, nullptr);
1244 sptr<IRemoteObject> token2 = sptr<MockIRemoteObject>::MakeSptr();
1245 sceneSession2->GetSessionProperty()->SetWindowType(WindowType::WINDOW_TYPE_FLOAT);
1246 sceneSession2->SetAbilityToken(token2);
1247 sceneSession2->SetSessionState(SessionState::STATE_FOREGROUND);
1248
1249 ssm_->sceneSessionMap_.insert({ sceneSession1->GetPersistentId(), sceneSession1 });
1250 ssm_->sceneSessionMap_.insert({ sceneSession2->GetPersistentId(), sceneSession2 });
1251
1252 bool hasFloatWindowForeground = false;
1253 WMError result = ssm_->HasFloatingWindowForeground(token1, hasFloatWindowForeground);
1254 EXPECT_EQ(result, WMError::WM_OK);
1255 EXPECT_EQ(hasFloatWindowForeground, true);
1256
1257 hasFloatWindowForeground = false;
1258 result = ssm_->HasFloatingWindowForeground(token2, hasFloatWindowForeground);
1259 EXPECT_EQ(result, WMError::WM_OK);
1260 EXPECT_EQ(hasFloatWindowForeground, true);
1261 }
1262
1263 /**
1264 * @tc.name: HasFloatingWindowForeground04
1265 * @tc.desc: test HasFloatingWindowForeground with existed background float window
1266 * @tc.type: FUNC
1267 */
1268 HWTEST_F(SceneSessionManagerTest12, HasFloatingWindowForeground04, Function | SmallTest | Level3)
1269 {
1270 // create first test sceneSession
1271 SessionInfo sessionInfo1;
1272 sessionInfo1.sessionState_ = SessionState::STATE_INACTIVE;
1273 sessionInfo1.persistentId_ = 1;
1274
1275 sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(sessionInfo1, nullptr);
1276 sptr<IRemoteObject> token1 = sptr<MockIRemoteObject>::MakeSptr();
1277 sceneSession1->GetSessionProperty()->SetWindowType(WindowType::WINDOW_TYPE_FLOAT);
1278 sceneSession1->SetAbilityToken(token1);
1279 sceneSession1->SetSessionState(SessionState::STATE_INACTIVE);
1280
1281 // create second test sceneSession
1282 SessionInfo sessionInfo2;
1283 sessionInfo2.sessionState_ = SessionState::STATE_BACKGROUND;
1284 sessionInfo2.persistentId_ = 2;
1285
1286 sptr<SceneSession> sceneSession2 = sptr<SceneSession>::MakeSptr(sessionInfo2, nullptr);
1287 sptr<IRemoteObject> token2 = sptr<MockIRemoteObject>::MakeSptr();
1288 sceneSession2->GetSessionProperty()->SetWindowType(WindowType::WINDOW_TYPE_FLOAT);
1289 sceneSession2->SetAbilityToken(token2);
1290 sceneSession2->SetSessionState(SessionState::STATE_BACKGROUND);
1291
1292 ssm_->sceneSessionMap_.insert({ sceneSession1->GetPersistentId(), sceneSession1 });
1293 ssm_->sceneSessionMap_.insert({ sceneSession2->GetPersistentId(), sceneSession2 });
1294
1295 bool hasFloatWindowForeground = false;
1296 WMError result = ssm_->HasFloatingWindowForeground(token1, hasFloatWindowForeground);
1297 EXPECT_EQ(result, WMError::WM_OK);
1298 EXPECT_EQ(hasFloatWindowForeground, false);
1299
1300 hasFloatWindowForeground = false;
1301 result = ssm_->HasFloatingWindowForeground(token2, hasFloatWindowForeground);
1302 EXPECT_EQ(result, WMError::WM_OK);
1303 EXPECT_EQ(hasFloatWindowForeground, false);
1304 }
1305
1306 /**
1307 * @tc.name: HasFloatingWindowForeground05
1308 * @tc.desc: test HasFloatingWindowForeground with existed forground toast window
1309 * @tc.type: FUNC
1310 */
1311 HWTEST_F(SceneSessionManagerTest12, HasFloatingWindowForeground05, Function | SmallTest | Level3)
1312 {
1313 // create first test sceneSession
1314 SessionInfo sessionInfo;
1315 sessionInfo.sessionState_ = SessionState::STATE_INACTIVE;
1316 sessionInfo.persistentId_ = 1;
1317
1318 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1319 sptr<IRemoteObject> token = sptr<MockIRemoteObject>::MakeSptr();
1320 sceneSession->GetSessionProperty()->SetWindowType(WindowType::WINDOW_TYPE_FLOAT);
1321 sceneSession->SetAbilityToken(token);
1322 sceneSession->SetSessionState(SessionState::STATE_INACTIVE);
1323
1324 ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession });
1325
1326 bool hasFloatWindowForeground = false;
1327 WMError result = ssm_->HasFloatingWindowForeground(token, hasFloatWindowForeground);
1328 EXPECT_EQ(result, WMError::WM_OK);
1329 EXPECT_EQ(hasFloatWindowForeground, false);
1330 }
1331
1332 /**
1333 * @tc.name: HasFloatingWindowForeground06
1334 * @tc.desc: test HasFloatingWindowForeground with other foreground float window
1335 * @tc.type: FUNC
1336 */
1337 HWTEST_F(SceneSessionManagerTest12, HasFloatingWindowForeground06, Function | SmallTest | Level3)
1338 {
1339 // create first test sceneSession
1340 SessionInfo sessionInfo1;
1341 sessionInfo1.sessionState_ = SessionState::STATE_ACTIVE;
1342 sessionInfo1.persistentId_ = 1;
1343
1344 sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(sessionInfo1, nullptr);
1345 sptr<IRemoteObject> token1 = sptr<MockIRemoteObject>::MakeSptr();
1346 sceneSession1->GetSessionProperty()->SetWindowType(WindowType::WINDOW_TYPE_FLOAT);
1347 sceneSession1->SetAbilityToken(token1);
1348 sceneSession1->SetSessionState(SessionState::STATE_ACTIVE);
1349
1350 // create second test sceneSession
1351 SessionInfo sessionInfo2;
1352 sessionInfo2.sessionState_ = SessionState::STATE_BACKGROUND;
1353 sessionInfo2.persistentId_ = 2;
1354
1355 sptr<SceneSession> sceneSession2 = sptr<SceneSession>::MakeSptr(sessionInfo2, nullptr);
1356 sptr<IRemoteObject> token2 = sptr<MockIRemoteObject>::MakeSptr();
1357 sceneSession2->GetSessionProperty()->SetWindowType(WindowType::WINDOW_TYPE_FLOAT);
1358 sceneSession2->SetAbilityToken(token2);
1359 sceneSession2->SetSessionState(SessionState::STATE_BACKGROUND);
1360
1361 ssm_->sceneSessionMap_.insert({ sceneSession1->GetPersistentId(), sceneSession1 });
1362 ssm_->sceneSessionMap_.insert({ sceneSession2->GetPersistentId(), sceneSession2 });
1363
1364 bool hasFloatWindowForeground = false;
1365 WMError result = ssm_->HasFloatingWindowForeground(token2, hasFloatWindowForeground);
1366 EXPECT_EQ(result, WMError::WM_OK);
1367 EXPECT_EQ(hasFloatWindowForeground, false);
1368 }
1369
1370 /**
1371 * @tc.name: UpdateHighlightStatus
1372 * @tc.desc: UpdateHighlightStatus
1373 * @tc.type: FUNC
1374 */
1375 HWTEST_F(SceneSessionManagerTest12, UpdateHighlightStatus, Function | SmallTest | Level3)
1376 {
1377 ASSERT_NE(ssm_, nullptr);
1378 sptr<WindowSessionProperty> property1 = sptr<WindowSessionProperty>::MakeSptr();
1379 sptr<WindowSessionProperty> property2 = sptr<WindowSessionProperty>::MakeSptr();
1380
1381 SessionInfo info1;
1382 info1.abilityName_ = "abilityName_test1";
1383 info1.bundleName_ = "bundleName_test1";
1384
1385 SessionInfo info2;
1386 info2.abilityName_ = "abilityName_test2";
1387 info2.bundleName_ = "bundleName_test2";
1388
1389 sptr<SceneSession> preSceneSession = sptr<SceneSession>::MakeSptr(info1, nullptr);
1390 sptr<SceneSession> currSceneSession = sptr<SceneSession>::MakeSptr(info2, nullptr);
1391
1392 preSceneSession->property_ = property1;
1393 currSceneSession->property_ = property2;
1394 preSceneSession->property_->SetPersistentId(1);
1395 currSceneSession->property_->SetPersistentId(2);
1396
1397 sptr<SceneSession> nullSceneSession1;
1398 sptr<SceneSession> nullSceneSession2;
1399
1400 ssm_->UpdateHighlightStatus(DEFAULT_DISPLAY_ID, nullSceneSession1, nullSceneSession2, false);
1401 ssm_->UpdateHighlightStatus(DEFAULT_DISPLAY_ID, preSceneSession, nullSceneSession2, false);
1402 ssm_->UpdateHighlightStatus(DEFAULT_DISPLAY_ID, preSceneSession, currSceneSession, true);
1403 ssm_->UpdateHighlightStatus(DEFAULT_DISPLAY_ID, preSceneSession, currSceneSession, false);
1404 currSceneSession->property_->isExclusivelyHighlighted_ = false;
1405 info1.isSystem_ = true;
1406 ssm_->UpdateHighlightStatus(DEFAULT_DISPLAY_ID, preSceneSession, currSceneSession, false);
1407 info1.isSystem_ = false;
1408 ssm_->UpdateHighlightStatus(DEFAULT_DISPLAY_ID, preSceneSession, currSceneSession, false);
1409 preSceneSession->property_->SetPersistentId(2);
1410 ssm_->UpdateHighlightStatus(DEFAULT_DISPLAY_ID, preSceneSession, currSceneSession, false);
1411 }
1412
1413 /**
1414 * @tc.name: SetHighlightSessionIds
1415 * @tc.desc: SetHighlightSessionIds
1416 * @tc.type: FUNC
1417 */
1418 HWTEST_F(SceneSessionManagerTest12, SetHighlightSessionIds, Function | SmallTest | Level3)
1419 {
1420 ASSERT_NE(ssm_, nullptr);
1421 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1422 SessionInfo info1;
1423 info1.abilityName_ = "abilityName_test1";
1424 info1.bundleName_ = "bundleName_test1";
1425
1426 sptr<SceneSession> currSceneSession = sptr<SceneSession>::MakeSptr(info1, nullptr);
1427 currSceneSession->property_ = property;
1428 currSceneSession->property_->SetPersistentId(1);
1429 currSceneSession->persistentId_ = 1;
1430 ssm_->highlightIds_.clear();
1431 ssm_->SetHighlightSessionIds(currSceneSession, false);
1432 ASSERT_EQ(ssm_->highlightIds_.count(1) == 1, true);
1433 }
1434
1435 /**
1436 * @tc.name: AddHighlightSessionIds
1437 * @tc.desc: AddHighlightSessionIds
1438 * @tc.type: FUNC
1439 */
1440 HWTEST_F(SceneSessionManagerTest12, AddHighlightSessionIds, Function | SmallTest | Level3)
1441 {
1442 ASSERT_NE(ssm_, nullptr);
1443 sptr<WindowSessionProperty> property1 = sptr<WindowSessionProperty>::MakeSptr();
1444 sptr<WindowSessionProperty> property2 = sptr<WindowSessionProperty>::MakeSptr();
1445
1446 SessionInfo info1;
1447 info1.abilityName_ = "abilityName_test1";
1448 info1.bundleName_ = "bundleName_test1";
1449
1450 SessionInfo info2;
1451 info2.abilityName_ = "abilityName_test2";
1452 info2.bundleName_ = "bundleName_test2";
1453
1454 sptr<SceneSession> preSceneSession = sptr<SceneSession>::MakeSptr(info1, nullptr);
1455 sptr<SceneSession> currSceneSession = sptr<SceneSession>::MakeSptr(info2, nullptr);
1456
1457 preSceneSession->property_->SetPersistentId(1);
1458 currSceneSession->property_->SetPersistentId(2);
1459 preSceneSession->persistentId_ = 1;
1460 currSceneSession->persistentId_ = 2;
1461 preSceneSession->property_ = property1;
1462 currSceneSession->property_ = property2;
1463 ssm_->AddHighlightSessionIds(currSceneSession, false);
1464 ssm_->AddHighlightSessionIds(preSceneSession, false);
1465 ASSERT_EQ(ssm_->highlightIds_.count(1) == 1, true);
1466 ASSERT_EQ(ssm_->highlightIds_.count(2) == 1, true);
1467 }
1468
1469 /**
1470 * @tc.name: RemoveHighlightSessionIds
1471 * @tc.desc: RemoveHighlightSessionIds
1472 * @tc.type: FUNC
1473 */
1474 HWTEST_F(SceneSessionManagerTest12, RemoveHighlightSessionIds, Function | SmallTest | Level3)
1475 {
1476 ASSERT_NE(ssm_, nullptr);
1477 sptr<WindowSessionProperty> property1 = sptr<WindowSessionProperty>::MakeSptr();
1478 sptr<WindowSessionProperty> property2 = sptr<WindowSessionProperty>::MakeSptr();
1479
1480 SessionInfo info1;
1481 info1.abilityName_ = "abilityName_test1";
1482 info1.bundleName_ = "bundleName_test1";
1483
1484 SessionInfo info2;
1485 info2.abilityName_ = "abilityName_test2";
1486 info2.bundleName_ = "bundleName_test2";
1487
1488 sptr<SceneSession> preSceneSession = sptr<SceneSession>::MakeSptr(info1, nullptr);
1489 sptr<SceneSession> currSceneSession = sptr<SceneSession>::MakeSptr(info2, nullptr);
1490
1491 preSceneSession->property_->SetPersistentId(1);
1492 currSceneSession->property_->SetPersistentId(2);
1493
1494 preSceneSession->persistentId_ = 1;
1495 currSceneSession->persistentId_ = 2;
1496
1497 preSceneSession->property_ = property1;
1498 currSceneSession->property_ = property2;
1499 ssm_->AddHighlightSessionIds(currSceneSession, false);
1500 ssm_->AddHighlightSessionIds(preSceneSession, false);
1501 ASSERT_EQ(ssm_->highlightIds_.count(1) == 1, true);
1502 ASSERT_EQ(ssm_->highlightIds_.count(2) == 1, true);
1503 ssm_->RemoveHighlightSessionIds(currSceneSession);
1504 ASSERT_EQ(ssm_->highlightIds_.count(2) == 0, true);
1505 ssm_->RemoveHighlightSessionIds(preSceneSession);
1506 ASSERT_EQ(ssm_->highlightIds_.count(1) == 0, true);
1507 }
1508
1509 /**
1510 * @tc.name: UpdateSessionCrossAxisState
1511 * @tc.desc: test function : UpdateSessionCrossAxisState
1512 * @tc.type: FUNC
1513 */
1514 HWTEST_F(SceneSessionManagerTest12, UpdateSessionCrossAxisState, Function | SmallTest | Level3)
1515 {
1516 SessionInfo info;
1517 info.abilityName_ = "test1";
1518 info.bundleName_ = "test1";
1519 info.windowType_ = static_cast<uint32_t>(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
1520 sptr<SceneSessionMocker> sceneSession = sptr<SceneSessionMocker>::MakeSptr(info, nullptr);
1521 ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
1522 EXPECT_CALL(*sceneSession, UpdateCrossAxis()).Times(1);
1523 ssm_->UpdateSessionCrossAxisState(10, SuperFoldStatus::EXPANDED, SuperFoldStatus::FOLDED);
1524 }
1525
1526 /**
1527 * @tc.name: RemoveLifeCycleTaskByPersistentId
1528 * @tc.desc: test RemoveLifeCycleTaskByPersistentId
1529 * @tc.type: FUNC
1530 */
1531 HWTEST_F(SceneSessionManagerTest12, RemoveLifeCycleTaskByPersistentId, Function | SmallTest | Level2)
1532 {
1533 SessionInfo info;
1534 info.abilityName_ = "testAbilityName1";
1535 info.moduleName_ = "testModleName1";
1536 info.bundleName_ = "testBundleName1";
1537 info.persistentId_ = 100;
1538
1539 sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
1540 EXPECT_NE(sceneSession, nullptr);
1541 ssm_->sceneSessionMap_.emplace(100, sceneSession);
1542
__anonde13cb070602() 1543 auto task = []() {};
1544 sceneSession->PostLifeCycleTask(task, "task1", LifeCycleTaskType::START);
1545 ASSERT_EQ(sceneSession->lifeCycleTaskQueue_.size(), 1);
1546 ssm_->RemoveLifeCycleTaskByPersistentId(100, LifeCycleTaskType::START);
1547 ASSERT_EQ(sceneSession->lifeCycleTaskQueue_.size(), 0);
1548
1549 sceneSession->PostLifeCycleTask(task, "task1", LifeCycleTaskType::START);
1550 ASSERT_EQ(sceneSession->lifeCycleTaskQueue_.size(), 1);
1551 ssm_->RemoveLifeCycleTaskByPersistentId(3, LifeCycleTaskType::START);
1552 ASSERT_EQ(sceneSession->lifeCycleTaskQueue_.size(), 1);
1553 }
1554
1555 /**
1556 * @tc.name: SetStatusBarAvoidHeight
1557 * @tc.desc: test function : SetStatusBarAvoidHeight
1558 * @tc.type: FUNC
1559 */
1560 HWTEST_F(SceneSessionManagerTest12, SetStatusBarAvoidHeight, Function | SmallTest | Level3)
1561 {
1562 SessionInfo info;
1563 info.abilityName_ = "test1";
1564 info.bundleName_ = "test1";
1565 info.windowType_ = static_cast<uint32_t>(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
1566 sptr<SceneSessionMocker> sceneSession = sptr<SceneSessionMocker>::MakeSptr(info, nullptr);
1567 ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
1568 EXPECT_CALL(*sceneSession, UpdateCrossAxis()).Times(1);
1569 int32_t height = 10;
1570 ssm_->SetStatusBarAvoidHeight(height);
1571 WSRect barArea;
1572 ssm_->GetStatusBarAvoidHeight(barArea);
1573 ASSERT_EQ(barArea.height_, height);
1574 }
1575
1576 /**
1577 * @tc.name: AddSkipSelfWhenShowOnVirtualScreenList
1578 * @tc.desc: test function : AddSkipSelfWhenShowOnVirtualScreenList
1579 * @tc.type: FUNC
1580 */
1581 HWTEST_F(SceneSessionManagerTest12, AddSkipSelfWhenShowOnVirtualScreenList, Function | SmallTest | Level1)
1582 {
1583 SessionInfo info;
1584 info.bundleName_ = "AddSkipSelfWhenShowOnVirtualScreenList";
1585 info.abilityName_ = "AddSkipSelfWhenShowOnVirtualScreenList";
1586 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1587 ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
1588 std::vector<int32_t> persistentIds {sceneSession->GetPersistentId()};
1589 auto ret = ssm_->AddSkipSelfWhenShowOnVirtualScreenList(persistentIds);
1590 usleep(WAIT_SYNC_IN_NS);
1591 EXPECT_EQ(ret, WMError::WM_OK);
1592 }
1593
1594 /**
1595 * @tc.name: RemoveSkipSelfWhenShowOnVirtualScreenList
1596 * @tc.desc: test function : RemoveSkipSelfWhenShowOnVirtualScreenList
1597 * @tc.type: FUNC
1598 */
1599 HWTEST_F(SceneSessionManagerTest12, RemoveSkipSelfWhenShowOnVirtualScreenList, Function | SmallTest | Level1)
1600 {
1601 SessionInfo info;
1602 info.bundleName_ = "RemoveSkipSelfWhenShowOnVirtualScreenList";
1603 info.abilityName_ = "RemoveSkipSelfWhenShowOnVirtualScreenList";
1604 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1605 ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
1606 std::vector<int32_t> persistentIds {sceneSession->GetPersistentId()};
1607 auto ret = ssm_->RemoveSkipSelfWhenShowOnVirtualScreenList(persistentIds);
1608 usleep(WAIT_SYNC_IN_NS);
1609 EXPECT_EQ(ret, WMError::WM_OK);
1610 }
1611
1612 /**
1613 * @tc.name: GetCallingWindowInfo1
1614 * @tc.desc: test function : GetCallingWindowInfo
1615 * @tc.type: FUNC
1616 */
1617 HWTEST_F(SceneSessionManagerTest12, GetCallingWindowInfo1, Function | SmallTest | Level2)
1618 {
1619 KeyboardTestData keyboardTestData(0, 57256, 0, WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT, false);
1620 keyboardTestData.SetCallingSessionId(86);
1621 ConstructKeyboardCallingWindowTestData(keyboardTestData);
1622 // Invalid callingWindowId
1623 CallingWindowInfo info(0, -1, 0, GetUserIdByUid(getuid())); // windowId_ callingPid_ displayId_ userId_
1624 WMError ret = ssm_->GetCallingWindowInfo(info);
1625 ASSERT_EQ(WMError::WM_ERROR_NULLPTR, ret);
1626 }
1627
1628 /**
1629 * @tc.name: GetCallingWindowInfo2
1630 * @tc.desc: test function : GetCallingWindowInfo
1631 * @tc.type: FUNC
1632 */
1633 HWTEST_F(SceneSessionManagerTest12, GetCallingWindowInfo2, Function | SmallTest | Level2)
1634 {
1635 KeyboardTestData keyboardTestData(0, 57256, 0, WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT, false);
1636 keyboardTestData.SetCallingSessionId(86);
1637 ConstructKeyboardCallingWindowTestData(keyboardTestData);
1638 // Invalid userId
1639 int32_t userId = GetUserIdByUid(getuid()) + 1;
1640 CallingWindowInfo info(86, -1, 0, userId); // windowId_ callingPid_ displayId_ userId_
1641 WMError ret = ssm_->GetCallingWindowInfo(info);
1642 ASSERT_EQ(WMError::WM_ERROR_INVALID_PARAM, ret);
1643 }
1644
1645 /**
1646 * @tc.name: GetCallingWindowInfo3
1647 * @tc.desc: test function : GetCallingWindowInfo
1648 * @tc.type: FUNC
1649 */
1650 HWTEST_F(SceneSessionManagerTest12, GetCallingWindowInfo3, Function | SmallTest | Level2)
1651 {
1652 KeyboardTestData keyboardTestData(12, 57256, 0, WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT, false);
1653 keyboardTestData.SetCallingSessionId(86);
1654 ConstructKeyboardCallingWindowTestData(keyboardTestData);
1655 int32_t userId = GetUserIdByUid(getuid());
1656 CallingWindowInfo info(86, -1, 0, userId); // windowId_ callingPid_ displayId_ userId_
1657 WMError ret = ssm_->GetCallingWindowInfo(info);
1658 ASSERT_EQ(WMError::WM_OK, ret);
1659 ASSERT_EQ(57256, info.callingPid_);
1660 ASSERT_EQ(12, info.displayId_);
1661 }
1662
1663 /**
1664 * @tc.name: UpdateSessionDisplayId1
1665 * @tc.desc: test function : UpdateSessionDisplayId
1666 * @tc.type: FUNC
1667 */
1668 HWTEST_F(SceneSessionManagerTest12, UpdateSessionDisplayId1, Function | SmallTest | Level2)
1669 {
1670 sptr<WindowManagerAgentLiteMocker> wmAgentLiteMocker = sptr<WindowManagerAgentLiteMocker>::MakeSptr();
1671 SessionManagerAgentController::GetInstance().RegisterWindowManagerAgent(
1672 wmAgentLiteMocker, WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_CALLING_DISPLAY, 12345);
1673 KeyboardTestData keyboardTestData(0, 57256, 0, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, false);
1674 keyboardTestData.SetCallingSessionId(86);
1675 ConstructKeyboardCallingWindowTestData(keyboardTestData);
1676 EXPECT_CALL(*wmAgentLiteMocker, NotifyCallingWindowDisplayChanged(_)).Times(0);
1677 ssm_->UpdateSessionDisplayId(86, 12);
1678
1679 keyboardTestData = {0, 57256, 0, WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT, true};
1680 keyboardTestData.SetCallingSessionId(86);
1681 ConstructKeyboardCallingWindowTestData(keyboardTestData);
1682 EXPECT_CALL(*wmAgentLiteMocker, NotifyCallingWindowDisplayChanged(_)).Times(0);
1683 ssm_->UpdateSessionDisplayId(86, 12);
1684 }
1685
1686 /**
1687 * @tc.name: UpdateSessionDisplayId2
1688 * @tc.desc: test function : UpdateSessionDisplayId
1689 * @tc.type: FUNC
1690 */
1691 HWTEST_F(SceneSessionManagerTest12, UpdateSessionDisplayId2, Function | SmallTest | Level2)
1692 {
1693 sptr<WindowManagerAgentLiteMocker> wmAgentLiteMocker = sptr<WindowManagerAgentLiteMocker>::MakeSptr();
1694 SessionManagerAgentController::GetInstance().RegisterWindowManagerAgent(
1695 wmAgentLiteMocker, WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_CALLING_DISPLAY, 12345);
1696 KeyboardTestData keyboardTestData(0, 57256, 0, WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT, false);
1697 keyboardTestData.SetCallingSessionId(86);
1698 ConstructKeyboardCallingWindowTestData(keyboardTestData);
1699 SessionInfo info;
1700 info.abilityName_ = "non-callingSession";
1701 info.bundleName_ = "non-callingSession";
1702 info.screenId_ = 0;
1703 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1704 sceneSession->callingPid_ = 54321;
1705 sptr<WindowSessionProperty> sceneSessionProperties = sptr<WindowSessionProperty>::MakeSptr();
1706 sceneSessionProperties->SetDisplayId(0);
1707 sceneSession->SetSessionProperty(sceneSessionProperties);
1708 // Add non-callingWindow
1709 ssm_->sceneSessionMap_.insert({90, sceneSession});
1710 // Change display id of non-callingWindow
1711 EXPECT_CALL(*wmAgentLiteMocker, NotifyCallingWindowDisplayChanged(_)).Times(0);
1712 ssm_->UpdateSessionDisplayId(90, 12);
1713 }
1714
1715 /**
1716 * @tc.name: UpdateSessionDisplayId3
1717 * @tc.desc: test function : UpdateSessionDisplayId
1718 * @tc.type: FUNC
1719 */
1720 HWTEST_F(SceneSessionManagerTest12, UpdateSessionDisplayId3, Function | SmallTest | Level2)
1721 {
1722 sptr<WindowManagerAgentLiteMocker> wmAgentLiteMocker = sptr<WindowManagerAgentLiteMocker>::MakeSptr();
1723 SessionManagerAgentController::GetInstance().RegisterWindowManagerAgent(
1724 wmAgentLiteMocker, WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_CALLING_DISPLAY, 12345);
1725 KeyboardTestData keyboardTestData(0, 57256, 0, WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT, false);
1726 keyboardTestData.SetCallingSessionId(86);
1727 ConstructKeyboardCallingWindowTestData(keyboardTestData);
1728 EXPECT_CALL(*wmAgentLiteMocker, NotifyCallingWindowDisplayChanged(_)).Times(1);
1729 ssm_->UpdateSessionDisplayId(86, 12);
1730 }
1731 }
1732 } // namespace Rosen
1733 } // namespace OHOS
1734