• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "session/host/include/keyboard_session.h"
17 #include <gtest/gtest.h>
18 
19 #include "interfaces/include/ws_common.h"
20 #include "mock/mock_session_stage.h"
21 #include "mock/mock_keyboard_session.h"
22 #include "session/host/include/session.h"
23 #include "session/host/include/scene_session.h"
24 #include "screen_session_manager_client/include/screen_session_manager_client.h"
25 #include "ui/rs_surface_node.h"
26 #include "window_helper.h"
27 #include "window_manager_hilog.h"
28 
29 using namespace testing;
30 using namespace testing::ext;
31 
32 namespace OHOS {
33 namespace Rosen {
34 namespace {
35 constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "KeyboardSessionTest2" };
36 std::string g_logMsg;
KeyboardSessionTest2Callback(const LogType type,const LogLevel level,const unsigned int domain,const char * tag,const char * msg)37 void KeyboardSessionTest2Callback(const LogType type, const LogLevel level,
38     const unsigned int domain, const char *tag, const char *msg)
39 {
40     g_logMsg += msg;
41 }
42 }
43 
44 class KeyboardSessionTest2 : public testing::Test, public IScreenConnectionListener {
45 public:
46     static void SetUpTestCase();
47     static void TearDownTestCase();
48     void SetUp() override;
49     void TearDown() override;
50     void OnScreenConnected(const sptr<ScreenSession>& screenSession) override;
51     void OnScreenDisconnected(const sptr<ScreenSession>& screenSession) override;
52     void ConstructKeyboardCallingWindowTestData(sptr<SceneSession>& callingSession,
53                                                 sptr<KeyboardSession>& keyboardSession,
54                                                 sptr<SceneSession>& statusBarSession);
55 
56 private:
57     sptr<KeyboardSession> GetKeyboardSession(const std::string& abilityName, const std::string& bundleName);
58     sptr<SceneSession> GetSceneSession(const std::string& abilityName, const std::string& bundleName);
59     sptr<KSSceneSessionMocker> GetSceneSessionMocker(const std::string& abilityName, const std::string& bundleName);
60 };
61 
SetUpTestCase()62 void KeyboardSessionTest2::SetUpTestCase() {}
63 
TearDownTestCase()64 void KeyboardSessionTest2::TearDownTestCase() {}
65 
SetUp()66 void KeyboardSessionTest2::SetUp() {}
67 
TearDown()68 void KeyboardSessionTest2::TearDown() {}
69 
OnScreenConnected(const sptr<ScreenSession> & screenSession)70 void KeyboardSessionTest2::OnScreenConnected(const sptr<ScreenSession>& screenSession) {}
71 
OnScreenDisconnected(const sptr<ScreenSession> & screenSession)72 void KeyboardSessionTest2::OnScreenDisconnected(const sptr<ScreenSession>& screenSession) {}
73 
ConstructKeyboardCallingWindowTestData(sptr<SceneSession> & callingSession,sptr<KeyboardSession> & keyboardSession,sptr<SceneSession> & statusBarSession)74 void KeyboardSessionTest2::ConstructKeyboardCallingWindowTestData(sptr<SceneSession>& callingSession,
75                                                                   sptr<KeyboardSession>& keyboardSession,
76                                                                   sptr<SceneSession>& statusBarSession)
77 {
78     SessionInfo info;
79     info.abilityName_ = "KeyboardSessionTest2";
80     info.bundleName_ = "KeyboardSessionTest2";
81     sptr<SceneSession::SpecificSessionCallback> specCallback = sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
82     callingSession = sptr<SceneSession>::MakeSptr(info, specCallback);
83     keyboardSession = sptr<KeyboardSession>::MakeSptr(info, nullptr, nullptr);
84     sptr<WindowSessionProperty> windowSessionProperty = sptr<WindowSessionProperty>::MakeSptr();
85     keyboardSession->property_ = windowSessionProperty;
86     SessionInfo info1;
87     info1.abilityName_ = "BindKeyboardPanelSession";
88     info1.bundleName_ = "BindKeyboardPanelSession";
89     sptr<SceneSession> panelSession = sptr<SceneSession>::MakeSptr(info1, nullptr);
90     keyboardSession->BindKeyboardPanelSession(panelSession);
91     sptr<SceneSession> getPanelSession = keyboardSession->GetKeyboardPanelSession();
92     SessionInfo info2;
93     info2.abilityName_ = "GetStatusBarHeight";
94     info2.bundleName_ = "GetStatusBarHeight";
95     sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
96         sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
97     statusBarSession = sptr<SceneSession>::MakeSptr(info2, specificCallback_);
98     WSRect rect({ 0, 0, 0, 10 });
99     statusBarSession->GetLayoutController()->SetSessionRect(rect);
100     specificCallback_->onGetSceneSessionVectorByTypeAndDisplayId_ = [&](WindowType type,
101         uint64_t displayId) -> std::vector<sptr<SceneSession>>{
102         std::vector<sptr<SceneSession>> vec;
103         vec.push_back(statusBarSession);
104         return vec;
105     };
106 }
107 
GetKeyboardSession(const std::string & abilityName,const std::string & bundleName)108 sptr<KeyboardSession> KeyboardSessionTest2::GetKeyboardSession(const std::string& abilityName,
109                                                                const std::string& bundleName)
110 {
111     SessionInfo info;
112     info.abilityName_ = abilityName;
113     info.bundleName_ = bundleName;
114     sptr<SceneSession::SpecificSessionCallback> specificCb = sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
115     EXPECT_NE(specificCb, nullptr);
116     sptr<KeyboardSession::KeyboardSessionCallback> keyboardCb =
117         sptr<KeyboardSession::KeyboardSessionCallback>::MakeSptr();
118     EXPECT_NE(keyboardCb, nullptr);
119     sptr<KeyboardSession> keyboardSession = sptr<KeyboardSession>::MakeSptr(info, specificCb, keyboardCb);
120     EXPECT_NE(keyboardSession, nullptr);
121 
122     sptr<WindowSessionProperty> keyboardProperty = sptr<WindowSessionProperty>::MakeSptr();
123     EXPECT_NE(keyboardProperty, nullptr);
124     keyboardProperty->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
125     keyboardSession->SetSessionProperty(keyboardProperty);
126 
127     return keyboardSession;
128 }
129 
GetSceneSession(const std::string & abilityName,const std::string & bundleName)130 sptr<SceneSession> KeyboardSessionTest2::GetSceneSession(const std::string& abilityName, const std::string& bundleName)
131 {
132     SessionInfo info;
133     info.abilityName_ = abilityName;
134     info.bundleName_ = bundleName;
135     sptr<SceneSession::SpecificSessionCallback> specificCb = sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
136     EXPECT_NE(specificCb, nullptr);
137     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, specificCb);
138 
139     return sceneSession;
140 }
141 
GetSceneSessionMocker(const std::string & abilityName,const std::string & bundleName)142 sptr<KSSceneSessionMocker> KeyboardSessionTest2::GetSceneSessionMocker(const std::string& abilityName,
143                                                                        const std::string& bundleName)
144 {
145     SessionInfo info;
146     info.abilityName_ = abilityName;
147     info.bundleName_ = bundleName;
148     sptr<SceneSession::SpecificSessionCallback> specificCb = sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
149     EXPECT_NE(specificCb, nullptr);
150     sptr<KSSceneSessionMocker> mockSession = sptr<KSSceneSessionMocker>::MakeSptr(info, nullptr);
151 
152     return mockSession;
153 }
154 
155 namespace {
156 /**
157  * @tc.name: AdjustKeyboardLayout01
158  * @tc.desc: AdjustKeyboardLayout
159  * @tc.type: FUNC
160  */
161 HWTEST_F(KeyboardSessionTest2, AdjustKeyboardLayout01, TestSize.Level1)
162 {
163     SessionInfo info;
164     info.abilityName_ = "AdjustKeyboardLayout01";
165     info.bundleName_ = "AdjustKeyboardLayout01";
166     sptr<SceneSession::SpecificSessionCallback> specificCb = sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
167     EXPECT_NE(specificCb, nullptr);
168     sptr<KeyboardSession::KeyboardSessionCallback> keyboardCb =
169         sptr<KeyboardSession::KeyboardSessionCallback>::MakeSptr();
170     EXPECT_NE(keyboardCb, nullptr);
171     sptr<KeyboardSession> keyboardSession = sptr<KeyboardSession>::MakeSptr(info, specificCb, keyboardCb);
172     EXPECT_NE(keyboardSession, nullptr);
173     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
174     property->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
175     keyboardSession->SetSessionProperty(property);
176 
177     KeyboardLayoutParams params;
178     ASSERT_EQ(keyboardSession->AdjustKeyboardLayout(params), WSError::WS_OK);
179 
180     keyboardSession->adjustKeyboardLayoutFunc_ = nullptr;
181     ASSERT_EQ(keyboardSession->AdjustKeyboardLayout(params), WSError::WS_OK);
182 
__anonb4c106780402(const KeyboardLayoutParams& params) 183     keyboardSession->adjustKeyboardLayoutFunc_ = [](const KeyboardLayoutParams& params) {};
184     ASSERT_EQ(keyboardSession->AdjustKeyboardLayout(params), WSError::WS_OK);
185 }
186 
187 /**
188  * @tc.name: AdjustKeyboardLayout02
189  * @tc.desc: AdjustKeyboardLayout
190  * @tc.type: FUNC
191  */
192 HWTEST_F(KeyboardSessionTest2, AdjustKeyboardLayout02, TestSize.Level1)
193 {
194     SessionInfo info;
195     info.abilityName_ = "AdjustKeyboardLayout02";
196     info.bundleName_ = "AdjustKeyboardLayout02";
197     sptr<SceneSession::SpecificSessionCallback> specificCb = sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
198     EXPECT_NE(specificCb, nullptr);
199     sptr<KeyboardSession::KeyboardSessionCallback> keyboardCb =
200         sptr<KeyboardSession::KeyboardSessionCallback>::MakeSptr();
201     EXPECT_NE(keyboardCb, nullptr);
202     sptr<KeyboardSession> keyboardSession = sptr<KeyboardSession>::MakeSptr(info, specificCb, keyboardCb);
203     EXPECT_NE(keyboardSession, nullptr);
204 
205     KeyboardLayoutParams params;
206     // params gravity is WINDOW_GRAVITY_BOTTOM
207     ASSERT_EQ(keyboardSession->AdjustKeyboardLayout(params), WSError::WS_OK);
208     keyboardSession->state_ = SessionState::STATE_FOREGROUND;
209     ASSERT_EQ(keyboardSession->AdjustKeyboardLayout(params), WSError::WS_OK);
210 
211     // params gravity is WINDOW_GRAVITY_FLOAT
212     params.gravity_ = WindowGravity::WINDOW_GRAVITY_FLOAT;
213     ASSERT_EQ(keyboardSession->AdjustKeyboardLayout(params), WSError::WS_OK);
214 }
215 
216 /**
217  * @tc.name: AdjustKeyboardLayout03
218  * @tc.desc: AdjustKeyboardLayout test
219  * @tc.type: FUNC
220  */
221 HWTEST_F(KeyboardSessionTest2, AdjustKeyboardLayout03, Function | SmallTest | Level1)
222 {
223     SessionInfo info;
224     info.abilityName_ = "AdjustKeyboardLayout03";
225     info.bundleName_ = "AdjustKeyboardLayout03";
226     sptr<SceneSession::SpecificSessionCallback> specificCb =
227         sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
228     ASSERT_NE(specificCb, nullptr);
229     sptr<KeyboardSession::KeyboardSessionCallback> keyboardCb =
230         sptr<KeyboardSession::KeyboardSessionCallback>::MakeSptr();
231     ASSERT_NE(keyboardCb, nullptr);
232     sptr<KeyboardSession> keyboardSession = sptr<KeyboardSession>::MakeSptr(info, specificCb, keyboardCb);
233     ASSERT_NE(keyboardSession, nullptr);
234     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
235     ASSERT_NE(property, nullptr);
236     property->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
237     keyboardSession->SetSessionProperty(property);
238 
239     KeyboardLayoutParams params;
240     EXPECT_EQ(keyboardSession->AdjustKeyboardLayout(params), WSError::WS_OK);
241 
242     keyboardSession->adjustKeyboardLayoutFunc_ = nullptr;
243     EXPECT_EQ(keyboardSession->AdjustKeyboardLayout(params), WSError::WS_OK);
244 
__anonb4c106780502(const KeyboardLayoutParams& params)245     keyboardSession->adjustKeyboardLayoutFunc_ = [](const KeyboardLayoutParams& params){};
246     EXPECT_EQ(keyboardSession->AdjustKeyboardLayout(params), WSError::WS_OK);
247 
248     params.displayId_ = 100;
249     EXPECT_EQ(keyboardSession->AdjustKeyboardLayout(params), WSError::WS_OK);
250 
251     keyboardSession->adjustKeyboardLayoutFunc_ = nullptr;
252     EXPECT_EQ(keyboardSession->AdjustKeyboardLayout(params), WSError::WS_OK);
253 }
254 
255 /**
256  * @tc.name: AdjustKeyboardLayout04
257  * @tc.desc: AdjustKeyboardLayout test
258  * @tc.type: FUNC
259  */
260 HWTEST_F(KeyboardSessionTest2, AdjustKeyboardLayout04, Function | SmallTest | Level1)
261 {
262     g_logMsg.clear();
263     LOG_SetCallback(KeyboardSessionTest2Callback);
264     SessionInfo info;
265     info.abilityName_ = "AdjustKeyboardLayout04";
266     info.bundleName_ = "AdjustKeyboardLayout04";
267     sptr<KeyboardSession::KeyboardSessionCallback> keyboardCb =
268         sptr<KeyboardSession::KeyboardSessionCallback>::MakeSptr();
269     sptr<SceneSession::SpecificSessionCallback> specificCb =
270         sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
271     sptr<KeyboardSession> keyboardSession = sptr<KeyboardSession>::MakeSptr(info, specificCb, keyboardCb);
272 
273     //all conditions met, expect: need recalculate occupiedArea.
274     KeyboardLayoutParams lastParams;
275     lastParams.landscapeAvoidHeight_ = 300;
276     lastParams.portraitAvoidHeight_ = 700;
277     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
278     property->SetKeyboardLayoutParams(lastParams);
279     keyboardSession->SetSessionProperty(property);
280     KeyboardLayoutParams params;
281     params.landscapeAvoidHeight_ = 200;
282     params.portraitAvoidHeight_ = 600;
283 
284     keyboardSession->state_ = SessionState::STATE_FOREGROUND;
285     keyboardSession->AdjustKeyboardLayout(params);
286     EXPECT_TRUE(g_logMsg.find("Keyboard avoidHeight is set") != std::string::npos);
287 
288     //params.landscapeAvoidHeight_ < 0, expect: skip recalculate occupiedArea.
289     g_logMsg.clear();
290     params.landscapeAvoidHeight_ = -100;
291     keyboardSession->AdjustKeyboardLayout(params);
292     EXPECT_TRUE(g_logMsg.find("Keyboard avoidHeight is set") == std::string::npos);
293 
294     //params.portraitAvoidHeight_ < 0, expect: skip recalculate occupiedArea.
295     params.landscapeAvoidHeight_ = 200;
296     params.portraitAvoidHeight_ = -100;
297     keyboardSession->AdjustKeyboardLayout(params);
298     EXPECT_TRUE(g_logMsg.find("Keyboard avoidHeight is set") == std::string::npos);
299     LOG_SetCallback(nullptr);
300 
301     params.landscapeAvoidHeight_ = 0;
302     keyboardSession->state_ = SessionState::STATE_BACKGROUND;
303     keyboardSession->AdjustKeyboardLayout(params);
304     EXPECT_TRUE(g_logMsg.find("Keyboard avoidHeight is set") == std::string::npos);
305 
306     keyboardSession->state_ = SessionState::STATE_FOREGROUND;
307     keyboardSession->AdjustKeyboardLayout(params);
308     EXPECT_TRUE(g_logMsg.find("Keyboard avoidHeight is set") == std::string::npos);
309     LOG_SetCallback(nullptr);
310 }
311 
312 /**
313  * @tc.name: AdjustKeyboardLayout05
314  * @tc.desc: AdjustKeyboardLayout test
315  * @tc.type: FUNC
316  */
317 HWTEST_F(KeyboardSessionTest2, AdjustKeyboardLayout05, Function | SmallTest | Level1)
318 {
319     g_logMsg.clear();
320     LOG_SetCallback(KeyboardSessionTest2Callback);
321     SessionInfo info;
322     info.abilityName_ = "AdjustKeyboardLayout05";
323     info.bundleName_ = "AdjustKeyboardLayout05";
324     sptr<KeyboardSession::KeyboardSessionCallback> keyboardCb =
325         sptr<KeyboardSession::KeyboardSessionCallback>::MakeSptr();
326     sptr<SceneSession::SpecificSessionCallback> specificCb =
327         sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
328     sptr<KeyboardSession> keyboardSession = sptr<KeyboardSession>::MakeSptr(info, specificCb, keyboardCb);
329 
330     //params == lastParams, expect: skip recalculate occupiedArea.
331     KeyboardLayoutParams lastParams;
332     lastParams.landscapeAvoidHeight_ = 300;
333     lastParams.portraitAvoidHeight_ = 700;
334     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
335     property->SetKeyboardLayoutParams(lastParams);
336     keyboardSession->SetSessionProperty(property);
337     KeyboardLayoutParams params;
338     params.landscapeAvoidHeight_ = 300;
339     params.portraitAvoidHeight_ = 700;
340 
341     keyboardSession->state_ = SessionState::STATE_FOREGROUND;
342     keyboardSession->AdjustKeyboardLayout(params);
343     EXPECT_TRUE(g_logMsg.find("Keyboard avoidHeight is set") == std::string::npos);
344 
345     //lastParams.landscapeAvoidHeight_  < 0, expect: skip recalculate occupiedArea.
346     lastParams.landscapeAvoidHeight_ = -300;
347     lastParams.portraitAvoidHeight_ = 700;
348     property->SetKeyboardLayoutParams(lastParams);
349     keyboardSession->SetSessionProperty(property);
350     keyboardSession->AdjustKeyboardLayout(params);
351     EXPECT_TRUE(g_logMsg.find("Keyboard avoidHeight is set") == std::string::npos);
352 
353     //lastParams.portraitAvoidHeight_  < 0, expect: skip recalculate occupiedArea.
354     lastParams.landscapeAvoidHeight_ = 300;
355     lastParams.portraitAvoidHeight_ = -700;
356     property->SetKeyboardLayoutParams(lastParams);
357     keyboardSession->SetSessionProperty(property);
358     keyboardSession->AdjustKeyboardLayout(params);
359     EXPECT_TRUE(g_logMsg.find("Keyboard avoidHeight is set") == std::string::npos);
360     LOG_SetCallback(nullptr);
361 }
362 
363 /**
364  * @tc.name: HandleMoveDragSurfaceNode01
365  * @tc.desc: HandleMoveDragSurfaceNode test
366  * @tc.type: FUNC
367  */
368 HWTEST_F(KeyboardSessionTest2, HandleMoveDragSurfaceNode01, Function | SmallTest | Level1)
369 {
370     g_logMsg.clear();
371     LOG_SetCallback(KeyboardSessionTest2Callback);
372     sptr<KeyboardSession> keyboardSession =
373         GetKeyboardSession("HandleMoveDragSurfaceNode01", "HandleMoveDragSurfaceNode01");
374     ASSERT_NE(keyboardSession, nullptr);
375 
376     ScreenSessionManagerClient::GetInstance().RegisterScreenConnectionListener(this);
377     SessionOption option = {
378         .rsId_ = 0,
379         .isExtend_ = false,
380         .screenId_ = 0,
381     };
382     ScreenEvent screenEvent = ScreenEvent::CONNECTED;
383     ScreenSessionManagerClient::GetInstance().OnScreenConnectionChanged(option, screenEvent);
384 
385     sptr<MoveDragController> moveDragController = keyboardSession->GetMoveDragController();
386     ASSERT_NE(moveDragController, nullptr);
387     WSRect rect = { 0, 0, 200, 200 };
388     moveDragController->SetTargetRect(rect);
389     keyboardSession->HandleMoveDragSurfaceNode(SizeChangeReason::DRAG_MOVE);
390     EXPECT_TRUE(g_logMsg.find("keyboardPanelSession_ is null") != std::string::npos);
391 
392     moveDragController->ResetCrossMoveDragProperty();
393     moveDragController->SetTargetRect(rect);
394     SessionInfo info;
395     info.abilityName_ = "HandleMoveDragSurfaceNode01";
396     info.bundleName_ = "HandleMoveDragSurfaceNode01";
397     sptr<SceneSession> panelSession = sptr<SceneSession>::MakeSptr(info, nullptr);
398     ASSERT_NE(panelSession, nullptr);
399     keyboardSession->BindKeyboardPanelSession(panelSession);
400     keyboardSession->HandleMoveDragSurfaceNode(SizeChangeReason::DRAG_MOVE);
401     EXPECT_TRUE(g_logMsg.find("keyboardPanelSurfaceNode is null") != std::string::npos);
402 
403     moveDragController->ResetCrossMoveDragProperty();
404     moveDragController->SetTargetRect(rect);
405     struct RSSurfaceNodeConfig config;
406     std::shared_ptr<RSSurfaceNode> surfaceNode = RSSurfaceNode::Create(config);
407     panelSession->SetSurfaceNode(surfaceNode);
408     keyboardSession->HandleMoveDragSurfaceNode(SizeChangeReason::DRAG_MOVE);
409     EXPECT_TRUE(g_logMsg.find("Add widow") != std::string::npos);
410 
411     keyboardSession->HandleMoveDragSurfaceNode(SizeChangeReason::DRAG_END);
412     EXPECT_TRUE(g_logMsg.find("Remove window") != std::string::npos);
413 }
414 
415 /**
416  * @tc.name: CheckIfNeedRaiseCallingSession
417  * @tc.desc: CheckIfNeedRaiseCallingSession
418  * @tc.type: FUNC
419  */
420 HWTEST_F(KeyboardSessionTest2, CheckIfNeedRaiseCallingSession, TestSize.Level1)
421 {
422     WLOGFI("CheckIfNeedRaiseCallingSession begin!");
423     SessionInfo info;
424     info.abilityName_ = "CheckIfNeedRaiseCallingSession";
425     info.bundleName_ = "CheckIfNeedRaiseCallingSession";
426     sptr<SceneSession::SpecificSessionCallback> specificCb = sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
427     EXPECT_NE(specificCb, nullptr);
428     sptr<KeyboardSession::KeyboardSessionCallback> keyboardCb =
429         sptr<KeyboardSession::KeyboardSessionCallback>::MakeSptr();
430     EXPECT_NE(keyboardCb, nullptr);
431     sptr<KeyboardSession> keyboardSession = sptr<KeyboardSession>::MakeSptr(info, specificCb, keyboardCb);
432     EXPECT_NE(keyboardSession, nullptr);
433     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
434     EXPECT_NE(property, nullptr);
435     property->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
436     keyboardSession->SetSessionProperty(property);
437 
438     ASSERT_FALSE(keyboardSession->CheckIfNeedRaiseCallingSession(nullptr, true));
439 
440     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, specificCb);
441     EXPECT_NE(sceneSession, nullptr);
442 
443     keyboardSession->property_->keyboardLayoutParams_.gravity_ = WindowGravity::WINDOW_GRAVITY_FLOAT;
444     ASSERT_FALSE(keyboardSession->CheckIfNeedRaiseCallingSession(sceneSession, true));
445 
446     keyboardSession->property_->keyboardLayoutParams_.gravity_ = WindowGravity::WINDOW_GRAVITY_BOTTOM;
447     ASSERT_TRUE(keyboardSession->CheckIfNeedRaiseCallingSession(sceneSession, false));
448 
449     property->SetWindowType(WindowType::SYSTEM_WINDOW_BASE);
450 
451     keyboardSession->systemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW;
452     ASSERT_FALSE(keyboardSession->CheckIfNeedRaiseCallingSession(sceneSession, true));
453 
454     property->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
455     keyboardSession->CheckIfNeedRaiseCallingSession(sceneSession, true);
456 
457     WLOGFI("CheckIfNeedRaiseCallingSession end!");
458 }
459 
460 /**
461  * @tc.name: CheckIfNeedRaiseCallingSession01
462  * @tc.desc: CheckIfNeedRaiseCallingSession01
463  * @tc.type: FUNC
464  */
465 HWTEST_F(KeyboardSessionTest2, CheckIfNeedRaiseCallingSession01, TestSize.Level1)
466 {
467     SessionInfo info;
468     info.abilityName_ = "CheckIfNeedRaiseCallingSession";
469     info.bundleName_ = "CheckIfNeedRaiseCallingSession";
470     sptr<SceneSession::SpecificSessionCallback> specificCb = sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
471     ASSERT_NE(specificCb, nullptr);
472     sptr<SceneSession> callingSession = sptr<SceneSession>::MakeSptr(info, specificCb);
473     ASSERT_NE(callingSession, nullptr);
474     sptr<KeyboardSession> keyboardSession = sptr<KeyboardSession>::MakeSptr(info, nullptr, nullptr);
475     ASSERT_NE(keyboardSession, nullptr);
476     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
477     EXPECT_NE(property, nullptr);
478     keyboardSession->SetSessionProperty(property);
479     ASSERT_NE(keyboardSession->property_, nullptr);
480     keyboardSession->property_->keyboardLayoutParams_.gravity_ = WindowGravity::WINDOW_GRAVITY_BOTTOM;
481     keyboardSession->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
482     keyboardSession->systemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW;
483     callingSession->systemConfig_.freeMultiWindowSupport_ = true;
484     callingSession->systemConfig_.freeMultiWindowEnable_ = true;
485     auto ret = keyboardSession->CheckIfNeedRaiseCallingSession(callingSession, true);
486     EXPECT_EQ(ret, true);
487     callingSession->systemConfig_.freeMultiWindowEnable_ = false;
488     ret = keyboardSession->CheckIfNeedRaiseCallingSession(callingSession, true);
489     EXPECT_EQ(ret, false);
490     callingSession->systemConfig_.freeMultiWindowEnable_ = true;
491     keyboardSession->systemConfig_.windowUIType_ = WindowUIType::PAD_WINDOW;
492     ret = keyboardSession->CheckIfNeedRaiseCallingSession(callingSession, true);
493     EXPECT_EQ(ret, true);
494     keyboardSession->systemConfig_.windowUIType_ = WindowUIType::PC_WINDOW;
495     callingSession->systemConfig_.freeMultiWindowEnable_ = false;
496     ret = keyboardSession->CheckIfNeedRaiseCallingSession(callingSession, true);
497     EXPECT_EQ(ret, true);
498     keyboardSession->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_END);
499     ret = keyboardSession->CheckIfNeedRaiseCallingSession(callingSession, true);
500     EXPECT_EQ(ret, true);
501     ret = keyboardSession->CheckIfNeedRaiseCallingSession(callingSession, false);
502     EXPECT_EQ(ret, true);
503 }
504 
505 /**
506  * @tc.name: CheckIfNeedRaiseCallingSession02
507  * @tc.desc: CheckIfNeedRaiseCallingSession02
508  * @tc.type: FUNC
509  */
510 HWTEST_F(KeyboardSessionTest2, CheckIfNeedRaiseCallingSession02, TestSize.Level1)
511 {
512     SessionInfo info;
513     info.abilityName_ = "CheckIfNeedRaiseCallingSession02";
514     info.bundleName_ = "CheckIfNeedRaiseCallingSession02";
515     sptr<KeyboardSession> keyboardSession = sptr<KeyboardSession>::MakeSptr(info, nullptr, nullptr);
516     ASSERT_NE(keyboardSession, nullptr);
517     ASSERT_NE(keyboardSession->property_, nullptr);
518     keyboardSession->property_->keyboardLayoutParams_.gravity_ = WindowGravity::WINDOW_GRAVITY_BOTTOM;
519 
520 
521     sptr<SceneSession> callingSession = sptr<SceneSession>::MakeSptr(info, nullptr);
522     ASSERT_NE(callingSession, nullptr);
523     callingSession->isSubWindowResizingOrMoving_ = true;
524     callingSession->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
525     auto ret = keyboardSession->CheckIfNeedRaiseCallingSession(callingSession, false);
526     EXPECT_EQ(ret, true);
527 
528     callingSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
529     ret = keyboardSession->CheckIfNeedRaiseCallingSession(callingSession, false);
530     EXPECT_EQ(ret, false);
531 }
532 
533 /**
534  * @tc.name: RaiseCallingSession01
535  * @tc.desc: RaiseCallingSession01
536  * @tc.type: FUNC
537  */
538 HWTEST_F(KeyboardSessionTest2, RaiseCallingSession01, TestSize.Level1)
539 {
540     sptr<SceneSession> callingSession = nullptr;
541     sptr<KeyboardSession> keyboardSession = nullptr;
542     sptr<SceneSession> statusBarSession = nullptr;
543     sptr<OccupiedAreaChangeInfo> occupiedAreaInfo = nullptr;
544     ConstructKeyboardCallingWindowTestData(callingSession, keyboardSession, statusBarSession);
545 
546     keyboardSession->keyboardAvoidAreaActive_ = false;
547     auto ret = keyboardSession->RaiseCallingSession(callingSession, occupiedAreaInfo);
548     EXPECT_EQ(ret, false);
549 
550     keyboardSession->keyboardAvoidAreaActive_ = true;
551     keyboardSession->SetSessionState(SessionState::STATE_BACKGROUND);
552     ret = keyboardSession->RaiseCallingSession(callingSession, occupiedAreaInfo);
553     EXPECT_EQ(ret, false);
554 
555     callingSession->GetSessionProperty()->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
556     keyboardSession->property_->keyboardLayoutParams_.gravity_ = WindowGravity::WINDOW_GRAVITY_FLOAT;
557     ret = keyboardSession->RaiseCallingSession(callingSession, occupiedAreaInfo);
558     EXPECT_EQ(ret, false);
559 }
560 
561 /**
562  * @tc.name: RaiseCallingSession02
563  * @tc.desc: RaiseCallingSession02
564  * @tc.type: FUNC
565  */
566 HWTEST_F(KeyboardSessionTest2, RaiseCallingSession02, TestSize.Level1)
567 {
568     sptr<SceneSession> callingSession = nullptr;
569     sptr<KeyboardSession> keyboardSession = nullptr;
570     sptr<SceneSession> statusBarSession = nullptr;
571     sptr<OccupiedAreaChangeInfo> occupiedAreaInfo = nullptr;
572     ConstructKeyboardCallingWindowTestData(callingSession, keyboardSession, statusBarSession);
573     sptr<SceneSession> panelSession = keyboardSession->GetKeyboardPanelSession();
574     callingSession->GetSessionProperty()->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
575 
576     keyboardSession->SetSessionState(SessionState::STATE_FOREGROUND);
577     KeyboardLayoutParams params;
578     params.landscapeAvoidHeight_ = -10;
579     keyboardSession->property_->SetKeyboardLayoutParams(params);
580     callingSession->SetOriPosYBeforeRaisedByKeyboard(10);
581     WSRect lastSafeRect = { 1, 50, 100, 100 };
582     callingSession->SetLastSafeRect(lastSafeRect);
583     WSRect rect1 = { 1, 1, 100, 100 };
584     callingSession->SetSessionRect(rect1);
585     WSRect rect2 = { 200, 200, 100, 100 };
586     panelSession->SetSessionRect(rect2);
587     auto ret = keyboardSession->RaiseCallingSession(callingSession, occupiedAreaInfo);
588     EXPECT_EQ(ret, true);
589 
590     lastSafeRect = { 0, 0, 0, 0 };
591     callingSession->SetLastSafeRect(lastSafeRect);
592     rect1 = { 1, 1, 100, 100 };
593     callingSession->SetSessionRect(rect1);
594     rect2 = { 200, 200, 100, 100 };
595     panelSession->SetSessionRect(rect2);
596     ret = keyboardSession->RaiseCallingSession(callingSession, occupiedAreaInfo);
597     EXPECT_EQ(ret, false);
598 }
599 
600 /**
601  * @tc.name: RaiseCallingSession03
602  * @tc.desc: RaiseCallingSession03
603  * @tc.type: FUNC
604  */
605 HWTEST_F(KeyboardSessionTest2, RaiseCallingSession03, TestSize.Level1)
606 {
607     sptr<SceneSession> callingSession = nullptr;
608     sptr<KeyboardSession> keyboardSession = nullptr;
609     sptr<SceneSession> statusBarSession = nullptr;
610     sptr<OccupiedAreaChangeInfo> occupiedAreaInfo = nullptr;
611     ConstructKeyboardCallingWindowTestData(callingSession, keyboardSession, statusBarSession);
612     sptr<SceneSession> panelSession = keyboardSession->GetKeyboardPanelSession();
613 
614     keyboardSession->SetSessionState(SessionState::STATE_FOREGROUND);
615     keyboardSession->property_->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
616     int32_t statusHeight = callingSession->GetStatusBarHeight();
617     WSRect callingSessionRect = { 0, statusHeight+10, 100, 100 };
618     callingSession->SetSessionRect(callingSessionRect);
619     KeyboardLayoutParams params;
620     params.gravity_ = WindowGravity::WINDOW_GRAVITY_BOTTOM;
621     keyboardSession->property_->SetKeyboardLayoutParams(params);
622     callingSession->SetIsMidScene(true);
623     callingSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
624     callingSession->systemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW;
625     callingSession->SetOriPosYBeforeRaisedByKeyboard(0);
626     WSRect lastSafeRect = { 1, 50, 100, 100 };
627     callingSession->SetLastSafeRect(lastSafeRect);
628     WSRect rect1 = { 1, 1, 100, 100 };
629     callingSession->SetSessionRect(rect1);
630     WSRect rect2 = { 50, 50, 100, 100 };
631     panelSession->SetSessionRect(rect2);
632     auto ret = keyboardSession->RaiseCallingSession(callingSession, occupiedAreaInfo);
633     EXPECT_EQ(ret, true);
634     callingSession->SetIsMidScene(false);
635     callingSession->property_->SetWindowType(WindowType::WINDOW_TYPE_FLOAT);
636     callingSession->systemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW;
637     callingSession->SetOriPosYBeforeRaisedByKeyboard(10);
638     lastSafeRect = { 50, 50, 51, 51 };
639     callingSession->SetLastSafeRect(lastSafeRect);
640     callingSession->SetSessionRect(rect1);
641     panelSession->SetSessionRect(rect2);
642     ret = keyboardSession->RaiseCallingSession(callingSession, occupiedAreaInfo);
643     EXPECT_EQ(ret, false);
644     callingSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
645     callingSession->systemConfig_.windowUIType_ = WindowUIType::PC_WINDOW;
646     callingSession->SetOriPosYBeforeRaisedByKeyboard(10);
647     lastSafeRect = { 1, 50, 100, 100 };
648     callingSession->SetLastSafeRect(lastSafeRect);
649     callingSession->SetSessionRect(rect1);
650     panelSession->SetSessionRect(rect2);
651     ret = keyboardSession->RaiseCallingSession(callingSession, occupiedAreaInfo);
652     EXPECT_EQ(ret, true);
653 }
654 
655 /**
656  * @tc.name: RaiseCallingSession04
657  * @tc.desc: RaiseCallingSession04
658  * @tc.type: FUNC
659  */
660 HWTEST_F(KeyboardSessionTest2, RaiseCallingSession04, TestSize.Level1)
661 {
662     sptr<SceneSession> callingSession = nullptr;
663     sptr<KeyboardSession> keyboardSession = nullptr;
664     sptr<SceneSession> statusBarSession = nullptr;
665     sptr<OccupiedAreaChangeInfo> occupiedAreaInfo = nullptr;
666     ConstructKeyboardCallingWindowTestData(callingSession, keyboardSession, statusBarSession);
667     sptr<SceneSession> panelSession = keyboardSession->GetKeyboardPanelSession();
668 
669     int32_t statusHeight = statusBarSession->GetStatusBarHeight();
670     ASSERT_EQ(statusHeight, 10);
671     keyboardSession->SetSessionState(SessionState::STATE_FOREGROUND);
672     callingSession->property_->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
673     WSRect lastSafeRect = { 1, 50, 100, 100 };
674     callingSession->SetLastSafeRect(lastSafeRect);
675     WSRect rect1 = { 1, 1, 100, 100 };
676     callingSession->SetSessionRect(rect1);
677     WSRect rect2 = { 50, 50, 100, 100 };
678     panelSession->SetSessionRect(rect2);
679     auto ret = keyboardSession->RaiseCallingSession(callingSession, occupiedAreaInfo);
680     EXPECT_EQ(ret, true);
681     callingSession->property_->SetWindowType(WindowType::WINDOW_TYPE_FLOAT);
682     lastSafeRect = { 1, statusHeight-1, 10, 9 };
683     callingSession->SetLastSafeRect(lastSafeRect);
684     rect1 = { 1, statusHeight-1, 10, 10 };
685     callingSession->SetSessionRect(rect1);
686     rect2 = { 1, statusHeight-2, 10, 10 };
687     panelSession->SetSessionRect(rect2);
688     ret = keyboardSession->RaiseCallingSession(callingSession, occupiedAreaInfo);
689     EXPECT_EQ(ret, false);
690     callingSession->SetLastSafeRect(lastSafeRect);
691     rect1 = { 1, statusHeight, 100, 100 };
692     callingSession->SetSessionRect(rect1);
693     rect2 = { 50, statusHeight-1, 100, 100 };
694     panelSession->SetSessionRect(rect2);
695     ret = keyboardSession->RaiseCallingSession(callingSession, occupiedAreaInfo);
696     EXPECT_EQ(ret, true);
697 }
698 
699 /**
700  * @tc.name: RaiseCallingSession05
701  * @tc.desc: RaiseCallingSession05
702  * @tc.type: FUNC
703  */
704 HWTEST_F(KeyboardSessionTest2, RaiseCallingSession05, TestSize.Level1)
705 {
706     sptr<SceneSession> callingSession = nullptr;
707     sptr<KeyboardSession> keyboardSession = nullptr;
708     sptr<SceneSession> statusBarSession = nullptr;
709     sptr<OccupiedAreaChangeInfo> occupiedAreaInfo = nullptr;
710     ConstructKeyboardCallingWindowTestData(callingSession, keyboardSession, statusBarSession);
711     sptr<SceneSession> panelSession = keyboardSession->GetKeyboardPanelSession();
712 
713     KeyboardLayoutParams params;
714     params.gravity_ = WindowGravity::WINDOW_GRAVITY_BOTTOM;
715     keyboardSession->property_->SetKeyboardLayoutParams(params);
716     keyboardSession->systemConfig_.windowUIType_ = WindowUIType::PAD_WINDOW;
717     callingSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
718     callingSession->systemConfig_.freeMultiWindowEnable_ = true;
719     callingSession->systemConfig_.freeMultiWindowSupport_ = true;
720     keyboardSession->SetSessionState(SessionState::STATE_FOREGROUND);
721     keyboardSession->isVisible_ = true;
722     WSRect lastSafeRect = { 0, 0, 0, 0 };
723     callingSession->SetLastSafeRect(lastSafeRect);
724     WSRect rect1 = { 1, 1, 10, 10 };
725     callingSession->SetSessionRect(rect1);
726     WSRect rect2 = { 5, 5, 10, 10 };
727     panelSession->SetSessionRect(rect2);
728     auto ret = keyboardSession->RaiseCallingSession(callingSession, occupiedAreaInfo);
729     EXPECT_EQ(ret, true);
730     lastSafeRect = { 1, 1, 1, 1 };
731     callingSession->SetLastSafeRect(lastSafeRect);
732     rect1 = { 1, 1, 10, 10 };
733     callingSession->SetSessionRect(rect1);
734     rect2 = { 5, 5, 10, 10 };
735     panelSession->SetSessionRect(rect2);
736     ret = keyboardSession->RaiseCallingSession(callingSession, occupiedAreaInfo);
737     EXPECT_EQ(ret, true);
738     lastSafeRect = { 0, 0, 0, 0 };
739     callingSession->SetLastSafeRect(lastSafeRect);
740     rect1 = { 1, 1, 1, 1 };
741     callingSession->SetSessionRect(rect1);
742     rect2 = { 10, 10, 1, 1 };
743     panelSession->SetSessionRect(rect2);
744     ret = keyboardSession->RaiseCallingSession(callingSession, occupiedAreaInfo);
745     EXPECT_EQ(ret, false);
746 }
747 
748 /**
749  * @tc.name: RaiseCallingSession06
750  * @tc.desc: RaiseCallingSession06
751  * @tc.type: FUNC
752  */
753 HWTEST_F(KeyboardSessionTest2, RaiseCallingSession06, TestSize.Level1)
754 {
755     sptr<SceneSession> callingSession = nullptr;
756     sptr<KeyboardSession> keyboardSession = nullptr;
757     sptr<SceneSession> statusBarSession = nullptr;
758     sptr<OccupiedAreaChangeInfo> occupiedAreaInfo = nullptr;
759     ConstructKeyboardCallingWindowTestData(callingSession, keyboardSession, statusBarSession);
760     sptr<SceneSession> panelSession = keyboardSession->GetKeyboardPanelSession();
761 
762     callingSession->property_->SetDisplayId(999);
763     keyboardSession->SetScreenId(0);
764     auto ret = keyboardSession->RaiseCallingSession(callingSession, occupiedAreaInfo);
765     EXPECT_EQ(ret, false);
766 }
767 
768 /**
769  * @tc.name: RaiseCallingSession07
770  * @tc.desc: RaiseCallingSession07
771  * @tc.type: FUNC
772  */
773 HWTEST_F(KeyboardSessionTest2, RaiseCallingSession07, TestSize.Level1)
774 {
775     sptr<SceneSession> callingSession = nullptr;
776     sptr<KeyboardSession> keyboardSession = nullptr;
777     sptr<SceneSession> statusBarSession = nullptr;
778     sptr<OccupiedAreaChangeInfo> occupiedAreaInfo = nullptr;
779     ConstructKeyboardCallingWindowTestData(callingSession, keyboardSession, statusBarSession);
780     sptr<SceneSession> panelSession = keyboardSession->GetKeyboardPanelSession();
781 
782     KeyboardLayoutParams params;
783     params.gravity_ = WindowGravity::WINDOW_GRAVITY_FLOAT;
784     keyboardSession->property_->SetKeyboardLayoutParams(params);
785     callingSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
786 
787     WSRect lastSafeRect = { 1, 1, 1, 1 };
788     callingSession->SetLastSafeRect(lastSafeRect);
789     WSRect rect1 = { 1, 1, 100, 100 };
790     callingSession->SetSessionRect(rect1);
791     WSRect rect2 = { 1, 50, 100, 100 };
792     panelSession->SetSessionRect(rect2);
793     auto ret = keyboardSession->RaiseCallingSession(callingSession, occupiedAreaInfo);
794     EXPECT_EQ(ret, false);
795 
796     params.gravity_ = WindowGravity::WINDOW_GRAVITY_BOTTOM;
797     keyboardSession->property_->SetKeyboardLayoutParams(params);
798     callingSession->property_->SetWindowType(WindowType::WINDOW_TYPE_FLOAT);
799     callingSession->SetIsMidScene(false);
800     callingSession->systemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW;
801     callingSession->systemConfig_.freeMultiWindowEnable_ = false;
802     callingSession->systemConfig_.freeMultiWindowSupport_ = false;
803     ret = keyboardSession->RaiseCallingSession(callingSession, occupiedAreaInfo);
804     EXPECT_EQ(ret, false);
805 }
806 
807 /**
808  * @tc.name: RaiseCallingSession08
809  * @tc.desc: RaiseCallingSession08
810  * @tc.type: FUNC
811  */
812 HWTEST_F(KeyboardSessionTest2, RaiseCallingSession08, TestSize.Level1)
813 {
814     sptr<SceneSession> callingSession = nullptr;
815     sptr<KeyboardSession> keyboardSession = nullptr;
816     sptr<SceneSession> statusBarSession = nullptr;
817     sptr<OccupiedAreaChangeInfo> occupiedAreaInfo = nullptr;
818     ConstructKeyboardCallingWindowTestData(callingSession, keyboardSession, statusBarSession);
819     sptr<SceneSession> panelSession = keyboardSession->GetKeyboardPanelSession();
820 
821     KeyboardLayoutParams params;
822     params.landscapeAvoidHeight_ = 10;
823     keyboardSession->property_->SetKeyboardLayoutParams(params);
824     WSRect lastSafeRect = { 1, 1, 1, 1 };
825     callingSession->SetLastSafeRect(lastSafeRect);
826     WSRect rect1 = { 1, 1, 100, 100 };
827     callingSession->SetSessionRect(rect1);
828     WSRect rect2 = { 200, 200, 100, 100 };
829     panelSession->SetSessionRect(rect2);
830     keyboardSession->SetSessionState(SessionState::STATE_FOREGROUND);
831     auto ret = keyboardSession->RaiseCallingSession(callingSession, occupiedAreaInfo);
832     EXPECT_EQ(ret, true);
833 }
834 
835 /**
836  * @tc.name: RaiseCallingSession09
837  * @tc.desc: RaiseCallingSession09
838  * @tc.type: FUNC
839  */
840 HWTEST_F(KeyboardSessionTest2, RaiseCallingSession09, TestSize.Level1)
841 {
842     sptr<SceneSession> callingSession = nullptr;
843     sptr<KeyboardSession> keyboardSession = nullptr;
844     sptr<SceneSession> statusBarSession = nullptr;
845     sptr<OccupiedAreaChangeInfo> occupiedAreaInfo = nullptr;
846     ConstructKeyboardCallingWindowTestData(callingSession, keyboardSession, statusBarSession);
847     sptr<SceneSession> panelSession = keyboardSession->GetKeyboardPanelSession();
848     keyboardSession->property_->SetIsSystemKeyboard(false);
849     keyboardSession->SetSessionState(SessionState::STATE_FOREGROUND);
850 
851     callingSession->layoutController_->SetScale(1.0, 1.0, 0.5, 0.5);
852     callingSession->layoutController_->SetSessionRect({500, 0, 2000, 2000});
853     callingSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
854     callingSession->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
855 
856     callingSession->SetLastSafeRect({0, 0, 0, 0});
857     panelSession->layoutController_->SetSessionRect({0, 1990, 3000, 1000});
858     auto ret = keyboardSession->RaiseCallingSession(callingSession, occupiedAreaInfo);
859     EXPECT_EQ(ret, true);
860     ASSERT_NE(nullptr, occupiedAreaInfo);
861     EXPECT_EQ(10, occupiedAreaInfo->safeHeight_);
862 
863     callingSession->SetLastSafeRect({0, 0, 0, 0});
864     callingSession->layoutController_->SetSessionRect({500, 30, 2000, 2000});
865     panelSession->layoutController_->SetSessionRect({0, 1980, 3000, 1000});
866     ret = keyboardSession->RaiseCallingSession(callingSession, occupiedAreaInfo);
867     EXPECT_EQ(ret, true);
868     ASSERT_NE(nullptr, occupiedAreaInfo);
869     EXPECT_EQ(20, occupiedAreaInfo->safeHeight_);
870 
871     callingSession->layoutController_->SetScale(1.5, 1.5, 0.5, 0.5);
872     callingSession->layoutController_->SetSessionRect({500, 500, 2000, 2000});
873     panelSession->layoutController_->SetSessionRect({0, 3000, 4000, 1000});
874     callingSession->SetOriPosYBeforeRaisedByKeyboard(0);
875     ret = keyboardSession->RaiseCallingSession(callingSession, occupiedAreaInfo);
876     EXPECT_EQ(ret, true);
877     ASSERT_NE(nullptr, occupiedAreaInfo);
878     EXPECT_EQ(0, occupiedAreaInfo->safeHeight_);
879 
880     callingSession->layoutController_->SetSessionRect({500, 550, 2000, 2000});
881     panelSession->layoutController_->SetSessionRect({0, 2990, 4000, 1000});
882     callingSession->SetOriPosYBeforeRaisedByKeyboard(0);
883     ret = keyboardSession->RaiseCallingSession(callingSession, occupiedAreaInfo);
884     EXPECT_EQ(ret, true);
885     ASSERT_NE(nullptr, occupiedAreaInfo);
886     EXPECT_EQ(60, occupiedAreaInfo->safeHeight_);
887 }
888 } // namespace
889 } // namespace Rosen
890 } // namespace OHOS
891