• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 #define private public
16 #define protected public
17 #include "input_method_panel.h"
18 
19 #include "ime_info_inquirer.h"
20 #include "input_method_ability.h"
21 #include "input_method_ability_utils.h"
22 #include "input_method_controller.h"
23 #include "input_method_system_ability.h"
24 #include "task_manager.h"
25 #undef private
26 
27 #include <gtest/gtest.h>
28 #include <sys/time.h>
29 #include <unistd.h>
30 
31 #include <condition_variable>
32 #include <cstdint>
33 #include <string>
34 
35 #include "common_event_data.h"
36 #include "common_event_manager.h"
37 #include "common_event_subscribe_info.h"
38 #include "common_event_subscriber.h"
39 #include "common_event_support.h"
40 #include "display_manager.h"
41 #include "global.h"
42 #include "identity_checker_mock.h"
43 #include "ime_event_monitor_manager.h"
44 #include "input_method_ability.h"
45 #include "input_method_controller.h"
46 #include "input_method_engine_listener_impl.h"
47 #include "matching_skills.h"
48 #include "panel_status_listener.h"
49 #include "scene_board_judgement.h"
50 #include "scope_utils.h"
51 #include "tdd_util.h"
52 #include "text_listener.h"
53 
54 using namespace testing::ext;
55 using namespace OHOS::Rosen;
56 namespace OHOS {
57 namespace MiscServices {
58 constexpr uint32_t IMC_WAIT_PANEL_STATUS_LISTEN_TIME = 500;
59 constexpr float FIXED_SOFT_KEYBOARD_PANEL_RATIO = 0.7;
60 constexpr float NON_FIXED_SOFT_KEYBOARD_PANEL_RATIO = 1;
61 constexpr const char *COMMON_EVENT_INPUT_PANEL_STATUS_CHANGED = "usual.event.imf.input_panel_status_changed";
62 constexpr const char *COMMON_EVENT_PARAM_PANEL_STATE = "panelState";
63 const constexpr char *IMMERSIVE_EFFECT = "immersive_effect";
64 // Test constants
65 constexpr uint32_t GRADIENT_HEIGHT = 10;          // Gradient height from immersive effect
66 constexpr int32_t PORTRAIT_AVOID_HEIGHT = 20;     // Initial portrait avoid height
67 constexpr int32_t LANDSCAPE_AVOID_HEIGHT = 15;    // Initial landscape avoid height
68 constexpr uint32_t INITIAL_PORTRAIT_HEIGHT = 25;  // Initial portrait panel height
69 constexpr uint32_t INITIAL_LANDSCAPE_HEIGHT = 20; // Initial landscape panel height
70 constexpr int32_t INITIAL_PORTRAIT_POS_Y = 100;   // Initial Y position for portrait
71 constexpr int32_t INITIAL_LANDSCAPE_POS_Y = 200;  // Initial Y position for landscape
72 constexpr int32_t DEFAULT_WIDTH = 100;
73 constexpr int32_t DEFAULT_HEIGHT = 200;
74 constexpr int32_t LANDSCAPE_WIDTH = 150;
75 constexpr int32_t LANDSCAPE_HEIGHT = 300;
76 constexpr int32_t INVALID_POS_Y = -1;
77 constexpr int32_t VALID_POS_Y = 0;
78 enum ListeningStatus : uint32_t {
79     ON,
80     OFF,
81     NONE
82 };
83 class InputMethodPanelTest : public testing::Test {
84 public:
85     static void SetUpTestCase(void);
86     static void TearDownTestCase(void);
87     void SetUp();
88     void TearDown();
89     static std::shared_ptr<InputMethodPanel> CreatePanel();
90     static void DestroyPanel(const std::shared_ptr<InputMethodPanel> &panel);
91     static void Attach();
92     static bool TriggerShowCallback(std::shared_ptr<InputMethodPanel> &inputMethodPanel);
93     static bool TriggerHideCallback(std::shared_ptr<InputMethodPanel> &inputMethodPanel);
94     static void ImaCreatePanel(const PanelInfo &info, std::shared_ptr<InputMethodPanel> &panel);
95     static void ImaDestroyPanel(const std::shared_ptr<InputMethodPanel> &panel);
96     static void ImcPanelListeningTestRestore();
97     static void ImcPanelShowNumCheck(uint32_t num);
98     static void ImcPanelHideNumCheck(uint32_t num);
99     static void ImcPanelShowInfoCheck(const InputWindowInfo &windowInfo);
100     static void ImcPanelHideInfoCheck(const InputWindowInfo &windowInfo);
101     static void TestShowPanel(const std::shared_ptr<InputMethodPanel> &panel);
102     static void TestHidePanel(const std::shared_ptr<InputMethodPanel> &panel);
103     static void TestIsPanelShown(const PanelInfo &info, bool expectedResult);
104     static void TriggerPanelStatusChangeToImc(const std::shared_ptr<InputMethodPanel> &panel, InputWindowStatus status);
105     static int32_t GetDisplaySize(DisplaySize &size);
106     class PanelStatusListenerImpl : public PanelStatusListener {
107     public:
PanelStatusListenerImpl()108         PanelStatusListenerImpl()
109         {
110             std::shared_ptr<AppExecFwk::EventRunner> runner = AppExecFwk::EventRunner::Create("InputMethodPanelTest");
111             panelHandler_ = std::make_shared<AppExecFwk::EventHandler>(runner);
112         }
113         ~PanelStatusListenerImpl() = default;
OnPanelStatus(uint32_t windowId,bool isShow)114         void OnPanelStatus(uint32_t windowId, bool isShow)
115         {
116             {
117                 std::unique_lock<std::mutex> lock(InputMethodPanelTest::panelListenerLock_);
118                 if (isShow) {
119                     InputMethodPanelTest::status_ = InputWindowStatus::SHOW;
120                 } else {
121                     InputMethodPanelTest::status_ = InputWindowStatus::HIDE;
122                 }
123             }
124             InputMethodPanelTest::panelListenerCv_.notify_one();
125             IMSA_HILOGI("PanelStatusListenerImpl OnPanelStatus in, isShow is %{public}s", isShow ? "true" : "false");
126         }
OnSizeChange(uint32_t windowId,const WindowSize & size)127         void OnSizeChange(uint32_t windowId, const WindowSize &size) {}
OnSizeChange(uint32_t windowId,const WindowSize & size,const PanelAdjustInfo & keyboardArea,const std::string & event)128         void OnSizeChange(
129             uint32_t windowId, const WindowSize &size, const PanelAdjustInfo &keyboardArea, const std::string &event)
130         {
131         }
132     };
133     static std::mutex imcPanelStatusListenerLock_;
134     static std::condition_variable imcPanelStatusListenerCv_;
135     static InputWindowStatus status_;
136     static InputWindowInfo windowInfo_;
137     static uint32_t imeShowCallbackNum_;
138     static uint32_t imeHideCallbackNum_;
139 
140     static sptr<InputMethodController> imc_;
141     static InputMethodAbility &ima_;
142     static sptr<InputMethodSystemAbility> imsa_;
143     static uint32_t windowWidth_;
144     static uint32_t windowHeight_;
145     static std::condition_variable panelListenerCv_;
146     static std::mutex panelListenerLock_;
147     static constexpr uint32_t DELAY_TIME = 100;
148     static constexpr int32_t INTERVAL = 10;
149     static std::shared_ptr<AppExecFwk::EventHandler> panelHandler_;
150     static int32_t currentImeUid_;
151     static uint64_t currentImeTokenId_;
152     static sptr<OnTextChangedListener> textListener_;
153     static std::shared_ptr<InputMethodEngineListener> imeListener_;
154     static bool isScbEnable_;
155 };
156 class InputMethodSettingListenerImpl : public ImeEventListener {
157 public:
158     InputMethodSettingListenerImpl() = default;
159     ~InputMethodSettingListenerImpl() = default;
OnImeShow(const ImeWindowInfo & info)160     void OnImeShow(const ImeWindowInfo &info) override
161     {
162         IMSA_HILOGI("InputMethodPanelTest::OnImeShow");
163         std::unique_lock<std::mutex> lock(InputMethodPanelTest::imcPanelStatusListenerLock_);
164         InputMethodPanelTest::status_ = InputWindowStatus::SHOW;
165         InputMethodPanelTest::windowInfo_ = info.windowInfo;
166         InputMethodPanelTest::imeShowCallbackNum_++;
167         InputMethodPanelTest::imcPanelStatusListenerCv_.notify_one();
168     }
OnImeHide(const ImeWindowInfo & info)169     void OnImeHide(const ImeWindowInfo &info) override
170     {
171         IMSA_HILOGI("InputMethodPanelTest::OnImeHide");
172         std::unique_lock<std::mutex> lock(InputMethodPanelTest::imcPanelStatusListenerLock_);
173         InputMethodPanelTest::status_ = InputWindowStatus::HIDE;
174         InputMethodPanelTest::windowInfo_ = info.windowInfo;
175         InputMethodPanelTest::imeHideCallbackNum_++;
176         InputMethodPanelTest::imcPanelStatusListenerCv_.notify_one();
177     }
178 };
179 
180 class TestEventSubscriber : public EventFwk::CommonEventSubscriber {
181 public:
TestEventSubscriber(const EventFwk::CommonEventSubscribeInfo & subscribeInfo)182     explicit TestEventSubscriber(const EventFwk::CommonEventSubscribeInfo &subscribeInfo)
183         : EventFwk::CommonEventSubscriber(subscribeInfo)
184     {
185     }
OnReceiveEvent(const EventFwk::CommonEventData & data)186     void OnReceiveEvent(const EventFwk::CommonEventData &data)
187     {
188         std::unique_lock<std::mutex> lock(InputMethodPanelTest::imcPanelStatusListenerLock_);
189         auto const &want = data.GetWant();
190         action_ = want.GetAction();
191         bool visible = want.GetBoolParam(COMMON_EVENT_PARAM_PANEL_STATE, false);
192         status_ = visible ? InputWindowStatus::SHOW : InputWindowStatus::HIDE;
193         InputMethodPanelTest::imcPanelStatusListenerCv_.notify_one();
194     }
ResetParam()195     void ResetParam()
196     {
197         action_ = "";
198         status_ = InputWindowStatus::NONE;
199     }
200     std::string action_;
201     InputWindowStatus status_ { InputWindowStatus::NONE };
202 };
203 
204 std::condition_variable InputMethodPanelTest::panelListenerCv_;
205 std::mutex InputMethodPanelTest::panelListenerLock_;
206 std::shared_ptr<AppExecFwk::EventHandler> InputMethodPanelTest::panelHandler_ { nullptr };
207 std::condition_variable InputMethodPanelTest::imcPanelStatusListenerCv_;
208 std::mutex InputMethodPanelTest::imcPanelStatusListenerLock_;
209 InputWindowStatus InputMethodPanelTest::status_ { InputWindowStatus::NONE };
210 InputWindowInfo InputMethodPanelTest::windowInfo_;
211 uint32_t InputMethodPanelTest::imeShowCallbackNum_ { 0 };
212 uint32_t InputMethodPanelTest::imeHideCallbackNum_ { 0 };
213 sptr<InputMethodController> InputMethodPanelTest::imc_ { nullptr };
214 InputMethodAbility &InputMethodPanelTest::ima_ = InputMethodAbility::GetInstance();
215 sptr<InputMethodSystemAbility> InputMethodPanelTest::imsa_ { nullptr };
216 uint32_t InputMethodPanelTest::windowWidth_ = 0;
217 uint32_t InputMethodPanelTest::windowHeight_ = 0;
218 uint64_t InputMethodPanelTest::currentImeTokenId_ = 0;
219 int32_t InputMethodPanelTest::currentImeUid_ = 0;
220 sptr<OnTextChangedListener> InputMethodPanelTest::textListener_ { nullptr };
221 std::shared_ptr<InputMethodEngineListener> InputMethodPanelTest::imeListener_ { nullptr };
222 bool InputMethodPanelTest::isScbEnable_ { false };
SetUpTestCase(void)223 void InputMethodPanelTest::SetUpTestCase(void)
224 {
225     IMSA_HILOGI("InputMethodPanelTest::SetUpTestCase");
226     IdentityCheckerMock::ResetParam();
227     isScbEnable_ = Rosen::SceneBoardJudgement::IsSceneBoardEnabled();
228     // storage current token id
229     TddUtil::StorageSelfTokenID();
230 
231     auto listener = std::make_shared<InputMethodSettingListenerImpl>();
232     imc_ = InputMethodController::GetInstance();
233     textListener_ = new (std::nothrow) TextListener();
234     imeListener_ = std::make_shared<InputMethodEngineListenerImpl>();
235     // set token as current input method
236     std::shared_ptr<Property> property = InputMethodController::GetInstance()->GetCurrentInputMethod();
237     std::string bundleName = property != nullptr ? property->name : "default.inputmethod.unittest";
238     currentImeTokenId_ = TddUtil::GetTestTokenID(bundleName);
239     currentImeUid_ = TddUtil::GetUid(bundleName);
240 
241     imsa_ = new (std::nothrow) InputMethodSystemAbility();
242     if (imsa_ == nullptr) {
243         return;
244     }
245     imsa_->OnStart();
246     imsa_->userId_ = TddUtil::GetCurrentUserId();
247     imsa_->identityChecker_ = std::make_shared<IdentityCheckerMock>();
248     imc_->abilityManager_ = imsa_;
249     {
250         TokenScope scope(currentImeTokenId_);
251         ima_.InitConnect();
252     }
253     ima_.abilityManager_ = imsa_;
254     TddUtil::InitCurrentImePermissionInfo();
255     IdentityCheckerMock::SetBundleName(TddUtil::currentBundleNameMock_);
256     ima_.SetCoreAndAgent();
257     InputMethodPanelTest::ima_.SetImeListener(imeListener_);
258 
259     ImaUtils::abilityManager_ = imsa_;
260 }
261 
TearDownTestCase(void)262 void InputMethodPanelTest::TearDownTestCase(void)
263 {
264     IMSA_HILOGI("InputMethodPanelTest::TearDownTestCase");
265     TddUtil::RestoreSelfTokenID();
266     IdentityCheckerMock::ResetParam();
267     imsa_->OnStop();
268     ImaUtils::abilityManager_ = nullptr;
269 }
270 
SetUp(void)271 void InputMethodPanelTest::SetUp(void)
272 {
273     IMSA_HILOGI("InputMethodPanelTest::SetUp");
274     TaskManager::GetInstance().SetInited(true);
275 }
276 
TearDown(void)277 void InputMethodPanelTest::TearDown(void)
278 {
279     TddUtil::RestoreSelfTokenID();
280     IMSA_HILOGI("InputMethodPanelTest::TearDown");
281     std::this_thread::sleep_for(std::chrono::seconds(1));
282     TaskManager::GetInstance().Reset();
283 }
284 
CreatePanel()285 std::shared_ptr<InputMethodPanel> InputMethodPanelTest::CreatePanel()
286 {
287     AccessScope scope(currentImeTokenId_, currentImeUid_);
288     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
289     PanelInfo panelInfo;
290     panelInfo.panelType = SOFT_KEYBOARD;
291     panelInfo.panelFlag = FLG_FIXED;
292     auto ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
293     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
294     return inputMethodPanel;
295 }
296 
DestroyPanel(const std::shared_ptr<InputMethodPanel> & panel)297 void InputMethodPanelTest::DestroyPanel(const std::shared_ptr<InputMethodPanel> &panel)
298 {
299     ASSERT_NE(panel, nullptr);
300     AccessScope scope(currentImeTokenId_, currentImeUid_);
301     auto ret = panel->DestroyPanel();
302     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
303 }
304 
ImaCreatePanel(const PanelInfo & info,std::shared_ptr<InputMethodPanel> & panel)305 void InputMethodPanelTest::ImaCreatePanel(const PanelInfo &info, std::shared_ptr<InputMethodPanel> &panel)
306 {
307     AccessScope scope(currentImeTokenId_, currentImeUid_);
308     auto ret = ima_.CreatePanel(nullptr, info, panel);
309     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
310 }
311 
ImaDestroyPanel(const std::shared_ptr<InputMethodPanel> & panel)312 void InputMethodPanelTest::ImaDestroyPanel(const std::shared_ptr<InputMethodPanel> &panel)
313 {
314     AccessScope scope(currentImeTokenId_, currentImeUid_);
315     auto ret = ima_.DestroyPanel(panel);
316     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
317 }
318 
Attach()319 void InputMethodPanelTest::Attach()
320 {
321     IdentityCheckerMock::SetFocused(true);
322     auto ret = imc_->Attach(textListener_, false);
323     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
324     std::this_thread::sleep_for(std::chrono::seconds(1));
325     IdentityCheckerMock::SetFocused(false);
326 }
327 
TriggerShowCallback(std::shared_ptr<InputMethodPanel> & inputMethodPanel)328 bool InputMethodPanelTest::TriggerShowCallback(std::shared_ptr<InputMethodPanel> &inputMethodPanel)
329 {
330     IMSA_HILOGI("start");
331     status_ = InputWindowStatus::NONE;
332     panelHandler_->PostTask(
333         [&inputMethodPanel]() {
334             TestShowPanel(inputMethodPanel);
335         },
336         InputMethodPanelTest::INTERVAL);
337     {
338         std::unique_lock<std::mutex> lock(panelListenerLock_);
339         return panelListenerCv_.wait_for(lock, std::chrono::milliseconds(InputMethodPanelTest::DELAY_TIME), [] {
340             return status_ == InputWindowStatus::SHOW;
341         });
342     }
343 }
344 
TriggerHideCallback(std::shared_ptr<InputMethodPanel> & inputMethodPanel)345 bool InputMethodPanelTest::TriggerHideCallback(std::shared_ptr<InputMethodPanel> &inputMethodPanel)
346 {
347     IMSA_HILOGI("start");
348     status_ = InputWindowStatus::NONE;
349     panelHandler_->PostTask(
350         [&inputMethodPanel]() {
351             TestHidePanel(inputMethodPanel);
352         },
353         InputMethodPanelTest::INTERVAL);
354     {
355         std::unique_lock<std::mutex> lock(panelListenerLock_);
356         return panelListenerCv_.wait_for(lock, std::chrono::milliseconds(InputMethodPanelTest::DELAY_TIME), [] {
357             return status_ == InputWindowStatus::HIDE;
358         });
359     }
360 }
361 
ImcPanelShowNumCheck(uint32_t num)362 void InputMethodPanelTest::ImcPanelShowNumCheck(uint32_t num)
363 {
364     std::unique_lock<std::mutex> lock(imcPanelStatusListenerLock_);
365     if (num == 0) {
366         auto ret =
367             imcPanelStatusListenerCv_.wait_for(lock, std::chrono::milliseconds(IMC_WAIT_PANEL_STATUS_LISTEN_TIME));
368         EXPECT_EQ(ret, std::cv_status::timeout);
369         return;
370     }
371     bool ret =
372         imcPanelStatusListenerCv_.wait_for(lock, std::chrono::milliseconds(IMC_WAIT_PANEL_STATUS_LISTEN_TIME), [&num] {
373             return num == imeShowCallbackNum_;
374         });
375     EXPECT_TRUE(ret);
376 }
377 
ImcPanelHideNumCheck(uint32_t num)378 void InputMethodPanelTest::ImcPanelHideNumCheck(uint32_t num)
379 {
380     std::unique_lock<std::mutex> lock(imcPanelStatusListenerLock_);
381     if (num == 0) {
382         auto ret =
383             imcPanelStatusListenerCv_.wait_for(lock, std::chrono::milliseconds(IMC_WAIT_PANEL_STATUS_LISTEN_TIME));
384         EXPECT_EQ(ret, std::cv_status::timeout);
385         return;
386     }
387     bool ret = imcPanelStatusListenerCv_.wait_for(lock, std::chrono::milliseconds(IMC_WAIT_PANEL_STATUS_LISTEN_TIME),
388         [&num] { return num <= imeHideCallbackNum_; });
389     EXPECT_TRUE(ret);
390 }
391 
ImcPanelShowInfoCheck(const InputWindowInfo & windowInfo)392 void InputMethodPanelTest::ImcPanelShowInfoCheck(const InputWindowInfo &windowInfo)
393 {
394     std::unique_lock<std::mutex> lock(imcPanelStatusListenerLock_);
395     bool ret =
396         imcPanelStatusListenerCv_.wait_for(lock, std::chrono::milliseconds(IMC_WAIT_PANEL_STATUS_LISTEN_TIME), [] {
397             return status_ == InputWindowStatus::SHOW;
398         });
399     EXPECT_TRUE(ret);
400     IMSA_HILOGI("InputMethodPanelTest::name: %{public}s, ret:[%{public}d, %{public}d,%{public}d, %{public}d]",
401         windowInfo_.name.c_str(), windowInfo_.top, windowInfo_.left, windowInfo_.width, windowInfo_.height);
402     EXPECT_FALSE(windowInfo_.name.empty());
403 }
404 
ImcPanelHideInfoCheck(const InputWindowInfo & windowInfo)405 void InputMethodPanelTest::ImcPanelHideInfoCheck(const InputWindowInfo &windowInfo)
406 {
407     std::unique_lock<std::mutex> lock(imcPanelStatusListenerLock_);
408     bool ret =
409         imcPanelStatusListenerCv_.wait_for(lock, std::chrono::milliseconds(IMC_WAIT_PANEL_STATUS_LISTEN_TIME), [] {
410             return status_ == InputWindowStatus::HIDE;
411         });
412     EXPECT_TRUE(ret);
413     IMSA_HILOGI("InputMethodPanelTest::name: %{public}s, ret:[%{public}d, %{public}d,%{public}d, %{public}d]",
414         windowInfo_.name.c_str(), windowInfo_.top, windowInfo_.left, windowInfo_.width, windowInfo_.height);
415     EXPECT_FALSE(windowInfo_.name.empty());
416 }
417 
ImcPanelListeningTestRestore()418 void InputMethodPanelTest::ImcPanelListeningTestRestore()
419 {
420     status_ = InputWindowStatus::NONE;
421     windowInfo_ = {};
422     imeShowCallbackNum_ = 0;
423     imeHideCallbackNum_ = 0;
424 }
425 
TestShowPanel(const std::shared_ptr<InputMethodPanel> & panel)426 void InputMethodPanelTest::TestShowPanel(const std::shared_ptr<InputMethodPanel> &panel)
427 {
428     ASSERT_NE(panel, nullptr);
429     // set tokenId and uid as current ime
430     AccessScope scope(currentImeTokenId_, currentImeUid_);
431     auto ret = panel->ShowPanel();
432     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
433 }
434 
TestHidePanel(const std::shared_ptr<InputMethodPanel> & panel)435 void InputMethodPanelTest::TestHidePanel(const std::shared_ptr<InputMethodPanel> &panel)
436 {
437     ASSERT_NE(panel, nullptr);
438     // set tokenId and uid as current ime
439     AccessScope scope(currentImeTokenId_, currentImeUid_);
440     auto ret = panel->HidePanel();
441     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
442 }
443 
TestIsPanelShown(const PanelInfo & info,bool expectedResult)444 void InputMethodPanelTest::TestIsPanelShown(const PanelInfo &info, bool expectedResult)
445 {
446     IdentityCheckerMock::SetSystemApp(true);
447     bool result = !expectedResult;
448     auto ret = imc_->IsPanelShown(info, result);
449     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
450     EXPECT_EQ(result, expectedResult);
451     IdentityCheckerMock::SetSystemApp(false);
452 }
453 
TriggerPanelStatusChangeToImc(const std::shared_ptr<InputMethodPanel> & panel,InputWindowStatus status)454 void InputMethodPanelTest::TriggerPanelStatusChangeToImc(
455     const std::shared_ptr<InputMethodPanel> &panel, InputWindowStatus status)
456 {
457     ASSERT_NE(panel, nullptr);
458     if (isScbEnable_) {
459         IdentityCheckerMock::SetBundleNameValid(true);
460         // add for SetTestTokenID in mainThread, but has no effect for other thread ipc
461         panel->PanelStatusChangeToImc(status, { 0, 0, 0, 0 });
462         IdentityCheckerMock::SetBundleNameValid(false);
463     }
464 }
465 
GetDisplaySize(DisplaySize & size)466 int32_t InputMethodPanelTest::GetDisplaySize(DisplaySize &size)
467 {
468     auto defaultDisplay = Rosen::DisplayManager::GetInstance().GetDefaultDisplay();
469     if (defaultDisplay == nullptr) {
470         IMSA_HILOGE("GetDefaultDisplay failed!");
471         return ErrorCode::ERROR_WINDOW_MANAGER;
472     }
473     auto width = defaultDisplay->GetWidth();
474     auto height = defaultDisplay->GetHeight();
475     if (width < height) {
476         size.portrait = { .width = width, .height = height };
477         size.landscape = { .width = height, .height = width };
478     } else {
479         size.portrait = { .width = height, .height = width };
480         size.landscape = { .width = width, .height = height };
481     }
482     return ErrorCode::NO_ERROR;
483 }
484 
485 /**
486  * @tc.name: testCreatePanel
487  * @tc.desc: Test CreatePanel.
488  * @tc.type: FUNC
489  */
490 HWTEST_F(InputMethodPanelTest, testCreatePanel, TestSize.Level0)
491 {
492     IMSA_HILOGI("InputMethodPanelTest::testCreatePanel start.");
493     AccessScope scope(currentImeTokenId_, currentImeUid_);
494     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
495     PanelInfo panelInfo;
496     panelInfo.panelType = SOFT_KEYBOARD;
497     panelInfo.panelFlag = FLG_FLOATING;
498     auto ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
499     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
500     ret = inputMethodPanel->DestroyPanel();
501     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
502 }
503 
504 /**
505  * @tc.name: testDestroyPanel
506  * @tc.desc: Test DestroyPanel.
507  * @tc.type: FUNC
508  */
509 HWTEST_F(InputMethodPanelTest, testDestroyPanel, TestSize.Level0)
510 {
511     IMSA_HILOGI("InputMethodPanelTest::testDestroyPanel start.");
512     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
513     // not CreatePanel, DestroyPanel failed
514     auto ret = inputMethodPanel->DestroyPanel();
515     EXPECT_EQ(ret, ErrorCode::ERROR_NULL_POINTER);
516 }
517 
518 /**
519  * @tc.name: testResizePanel001
520  * @tc.desc: Test Resize panel. Panels non fixed soft keyboard.
521  * @tc.type: FUNC
522  */
523 HWTEST_F(InputMethodPanelTest, testResizePanel001, TestSize.Level0)
524 {
525     IMSA_HILOGI("InputMethodPanelTest::testResizePanel001 start.");
526     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
527     // not CreatePanel, Resize failed
528     auto ret = inputMethodPanel->Resize(1, 1);
529     EXPECT_EQ(ret, ErrorCode::ERROR_NULL_POINTER);
530 
531     AccessScope scope(currentImeTokenId_, currentImeUid_);
532     PanelInfo panelInfo;
533     panelInfo.panelType = SOFT_KEYBOARD;
534     panelInfo.panelFlag = FLG_FLOATING;
535     ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
536     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
537     auto defaultDisplay = Rosen::DisplayManager::GetInstance().GetDefaultDisplay();
538     ASSERT_TRUE(defaultDisplay != nullptr);
539     int32_t width = defaultDisplay->GetWidth();
540     int32_t height = defaultDisplay->GetHeight();
541 
542     ret = inputMethodPanel->Resize(width - 1, height * NON_FIXED_SOFT_KEYBOARD_PANEL_RATIO - 1);
543     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
544 
545     ret = inputMethodPanel->Resize(width, height * NON_FIXED_SOFT_KEYBOARD_PANEL_RATIO);
546     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
547 
548     ret = inputMethodPanel->Resize(width + 1, height * NON_FIXED_SOFT_KEYBOARD_PANEL_RATIO);
549     EXPECT_EQ(ret, ErrorCode::ERROR_BAD_PARAMETERS);
550 
551     ret = inputMethodPanel->Resize(width, height * NON_FIXED_SOFT_KEYBOARD_PANEL_RATIO + 1);
552     EXPECT_EQ(ret, ErrorCode::ERROR_BAD_PARAMETERS);
553 
554     ret = inputMethodPanel->Resize(width + 1, height * NON_FIXED_SOFT_KEYBOARD_PANEL_RATIO + 1);
555     EXPECT_EQ(ret, ErrorCode::ERROR_BAD_PARAMETERS);
556 
557     ret = inputMethodPanel->DestroyPanel();
558     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
559 }
560 
561 /**
562  * @tc.name: testResizePanel002
563  * @tc.desc: Test Resize panel. Fixed soft keyboard panel .
564  * @tc.type: FUNC
565  */
566 HWTEST_F(InputMethodPanelTest, testResizePanel002, TestSize.Level0)
567 {
568     IMSA_HILOGI("InputMethodPanelTest::testResizePanel002 start.");
569     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
570     // not CreatePanel, Resize failed
571     auto ret = inputMethodPanel->Resize(1, 1);
572     EXPECT_EQ(ret, ErrorCode::ERROR_NULL_POINTER);
573 
574     PanelInfo panelInfo;
575     panelInfo.panelType = SOFT_KEYBOARD;
576     panelInfo.panelFlag = FLG_FIXED;
577     AccessScope scope(currentImeTokenId_, currentImeUid_);
578     ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
579     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
580     auto defaultDisplay = Rosen::DisplayManager::GetInstance().GetDefaultDisplay();
581     ASSERT_TRUE(defaultDisplay != nullptr);
582     int32_t width = defaultDisplay->GetWidth();
583     int32_t height = defaultDisplay->GetHeight();
584 
585     ret = inputMethodPanel->Resize(width - 1, height * FIXED_SOFT_KEYBOARD_PANEL_RATIO - 1);
586     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
587 
588     ret = inputMethodPanel->Resize(width, height * FIXED_SOFT_KEYBOARD_PANEL_RATIO);
589     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
590 
591     ret = inputMethodPanel->Resize(width + 1, height * FIXED_SOFT_KEYBOARD_PANEL_RATIO);
592     EXPECT_EQ(ret, ErrorCode::ERROR_BAD_PARAMETERS);
593 
594     ret = inputMethodPanel->Resize(width, height * FIXED_SOFT_KEYBOARD_PANEL_RATIO + 1);
595     EXPECT_EQ(ret, ErrorCode::ERROR_BAD_PARAMETERS);
596 
597     ret = inputMethodPanel->Resize(width + 1, height * FIXED_SOFT_KEYBOARD_PANEL_RATIO + 1);
598     EXPECT_EQ(ret, ErrorCode::ERROR_BAD_PARAMETERS);
599 
600     ret = inputMethodPanel->DestroyPanel();
601     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
602 }
603 
604 /**
605  * @tc.name: testMovePanel
606  * @tc.desc: Test Move panel. SOFT_KEYBOARD panel with FLG_FIXED can not be moved.
607  * @tc.type: FUNC
608  */
609 HWTEST_F(InputMethodPanelTest, testMovePanel, TestSize.Level0)
610 {
611     IMSA_HILOGI("InputMethodPanelTest::testMovePanel start.");
612     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
613     // not CreatePanel, MoveTo failed
614     auto ret = inputMethodPanel->MoveTo(10, 100);
615     EXPECT_EQ(ret, ErrorCode::ERROR_NULL_POINTER);
616 
617     AccessScope scope(currentImeTokenId_, currentImeUid_);
618     PanelInfo panelInfo;
619     panelInfo.panelType = SOFT_KEYBOARD;
620     panelInfo.panelFlag = FLG_FIXED;
621     ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
622     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
623 
624     ret = inputMethodPanel->MoveTo(10, 100);
625     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
626 
627     ret = inputMethodPanel->ChangePanelFlag(PanelFlag::FLG_FLOATING);
628     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
629     ret = inputMethodPanel->MoveTo(10, 100);
630     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
631 
632     ret = inputMethodPanel->DestroyPanel();
633     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
634 
635     panelInfo.panelType = STATUS_BAR;
636     ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
637     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
638     ret = inputMethodPanel->MoveTo(10, 100);
639     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
640     ret = inputMethodPanel->DestroyPanel();
641     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
642 }
643 
644 /**
645  * @tc.name: testShowPanel
646  * @tc.desc: Test Show panel.
647  * @tc.type: FUNC
648  */
649 HWTEST_F(InputMethodPanelTest, testShowPanel, TestSize.Level0)
650 {
651     IMSA_HILOGI("InputMethodPanelTest::testShowPanel start.");
652     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
653     PanelInfo panelInfo;
654     panelInfo.panelType = SOFT_KEYBOARD;
655     panelInfo.panelFlag = FLG_FIXED;
656     // 0、not create panel, show panel failed.
657     auto ret = inputMethodPanel->ShowPanel();
658     EXPECT_EQ(ret, ErrorCode::ERROR_IMA_NULLPTR);
659 
660     // 1 create panel, show success
661     AccessScope scope(currentImeTokenId_, currentImeUid_);
662     ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
663     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
664     ret = inputMethodPanel->ShowPanel();
665     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
666 
667     auto statusListener = std::make_shared<InputMethodPanelTest::PanelStatusListenerImpl>();
668     EXPECT_TRUE(statusListener != nullptr);
669     std::string type = "show";
670     inputMethodPanel->SetPanelStatusListener(statusListener, type);
671     ret = inputMethodPanel->ShowPanel();
672     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
673 
674     // 2、show floating type panel.
675     ret = inputMethodPanel->ChangePanelFlag(PanelFlag::FLG_FLOATING);
676     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
677     ret = inputMethodPanel->ShowPanel();
678     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
679 
680     ret = inputMethodPanel->DestroyPanel();
681     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
682 
683     // 4、show status bar.
684     panelInfo.panelType = STATUS_BAR;
685     ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
686     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
687     ret = inputMethodPanel->ShowPanel();
688     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
689     ret = inputMethodPanel->HidePanel();
690     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
691     ret = inputMethodPanel->DestroyPanel();
692     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
693 }
694 
695 /**
696  * @tc.name: testIsPanelShown_001
697  * @tc.desc: Test is panel shown.
698  * @tc.type: FUNC
699  */
700 HWTEST_F(InputMethodPanelTest, testIsPanelShown_001, TestSize.Level0)
701 {
702     IMSA_HILOGI("InputMethodPanelTest::testIsPanelShown_001 start.");
703     InputMethodPanelTest::Attach();
704     PanelInfo panelInfo;
705     panelInfo.panelType = SOFT_KEYBOARD;
706     panelInfo.panelFlag = FLG_FIXED;
707     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
708     InputMethodPanelTest::ImaCreatePanel(panelInfo, inputMethodPanel);
709 
710     // query when fixed soft keyboard is showing
711     InputMethodPanelTest::TestShowPanel(inputMethodPanel);
712     InputMethodPanelTest::TestIsPanelShown(panelInfo, true);
713 
714     // query when fixed soft keyboard is hidden
715     InputMethodPanelTest::TestHidePanel(inputMethodPanel);
716     InputMethodPanelTest::TestIsPanelShown(panelInfo, false);
717 
718     InputMethodPanelTest::ImaDestroyPanel(inputMethodPanel);
719     InputMethodPanelTest::imc_->Close();
720 }
721 
722 /**
723  * @tc.name: testIsPanelShown_002
724  * @tc.desc: Test is panel shown.
725  * @tc.type: FUNC
726  */
727 HWTEST_F(InputMethodPanelTest, testIsPanelShown_002, TestSize.Level0)
728 {
729     IMSA_HILOGI("InputMethodPanelTest::testIsPanelShown_002 start.");
730     InputMethodPanelTest::Attach();
731     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
732     PanelInfo panelInfo;
733     panelInfo.panelType = SOFT_KEYBOARD;
734     panelInfo.panelFlag = FLG_FIXED;
735     InputMethodPanelTest::ImaCreatePanel(panelInfo, inputMethodPanel);
736 
737     // query panel with old info when panel changes its flag.
738     auto ret = inputMethodPanel->ChangePanelFlag(PanelFlag::FLG_FLOATING);
739     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
740     InputMethodPanelTest::TestShowPanel(inputMethodPanel);
741     InputMethodPanelTest::TestIsPanelShown(panelInfo, false);
742 
743     // query panel with updated shown one's info when panel changes its flag.
744     panelInfo.panelFlag = PanelFlag::FLG_FLOATING;
745     InputMethodPanelTest::TestIsPanelShown(panelInfo, true);
746 
747     InputMethodPanelTest::ImaDestroyPanel(inputMethodPanel);
748     InputMethodPanelTest::imc_->Close();
749 }
750 
751 /**
752  * @tc.name: testIsPanelShown_003
753  * @tc.desc: Test is panel shown.
754  * @tc.type: FUNC
755  */
756 HWTEST_F(InputMethodPanelTest, testIsPanelShown_003, TestSize.Level0)
757 {
758     IMSA_HILOGI("InputMethodPanelTest::testIsPanelShown_003 start.");
759     InputMethodPanelTest::Attach();
760     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
761     PanelInfo panelInfo;
762     panelInfo.panelType = STATUS_BAR;
763     InputMethodPanelTest::ImaCreatePanel(panelInfo, inputMethodPanel);
764 
765     // query status bar's status when it is showing
766     InputMethodPanelTest::TestShowPanel(inputMethodPanel);
767     InputMethodPanelTest::TestIsPanelShown(panelInfo, true);
768 
769     // query status bar's status when it is hidden
770     InputMethodPanelTest::TestHidePanel(inputMethodPanel);
771     InputMethodPanelTest::TestIsPanelShown(panelInfo, false);
772 
773     InputMethodPanelTest::ImaDestroyPanel(inputMethodPanel);
774     InputMethodPanelTest::imc_->Close();
775 }
776 
777 /**
778  * @tc.name: testSetPanelStatusListener01
779  * @tc.desc: Test testSetPanelStatusListener01.
780  * @tc.type: FUNC
781  */
782 HWTEST_F(InputMethodPanelTest, testSetPanelStatusListener01, TestSize.Level0)
783 {
784     IMSA_HILOGI("InputMethodPanelTest::testSetPanelStatusListener01 start.");
785     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
786     auto statusListener = std::make_shared<InputMethodPanelTest::PanelStatusListenerImpl>();
787     // on('show')->on('hide')->show->hide
788     inputMethodPanel->SetPanelStatusListener(statusListener, "show");
789     inputMethodPanel->SetPanelStatusListener(statusListener, "hide");
790 
791     AccessScope scope(InputMethodPanelTest::currentImeTokenId_, InputMethodPanelTest::currentImeUid_);
792     PanelInfo panelInfo;
793     panelInfo.panelType = SOFT_KEYBOARD;
794     panelInfo.panelFlag = FLG_FIXED;
795     auto ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
796     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
797 
798     EXPECT_TRUE(InputMethodPanelTest::TriggerShowCallback(inputMethodPanel));
799     EXPECT_TRUE(InputMethodPanelTest::TriggerHideCallback(inputMethodPanel));
800 
801     InputMethodPanelTest::ImaDestroyPanel(inputMethodPanel);
802 }
803 
804 /**
805  * @tc.name: testSetPanelStatusListener02
806  * @tc.desc: Test testSetPanelStatusListener02.
807  * @tc.type: FUNC
808  */
809 HWTEST_F(InputMethodPanelTest, testSetPanelStatusListener02, TestSize.Level0)
810 {
811     IMSA_HILOGI("InputMethodPanelTest::testSetPanelStatusListener02 start.");
812     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
813     auto statusListener = std::make_shared<InputMethodPanelTest::PanelStatusListenerImpl>();
814 
815     AccessScope scope(InputMethodPanelTest::currentImeTokenId_, InputMethodPanelTest::currentImeUid_);
816     PanelInfo panelInfo;
817     panelInfo.panelType = SOFT_KEYBOARD;
818     panelInfo.panelFlag = FLG_FIXED;
819     auto ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
820     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
821 
822     // panelStatusListener_ not nullptr
823     inputMethodPanel->panelStatusListener_ = statusListener;
824 
825     // subscribe 'show' after panel shown, get 'show' callback
826     InputMethodPanelTest::status_ = InputWindowStatus::NONE;
827     InputMethodPanelTest::TestShowPanel(inputMethodPanel);
828     inputMethodPanel->SetPanelStatusListener(statusListener, "show");
829     EXPECT_EQ(status_, InputWindowStatus::SHOW);
830 
831     // subscribe 'hide' after panel hidden, get 'hide' callback
832     InputMethodPanelTest::status_ = InputWindowStatus::NONE;
833     InputMethodPanelTest::TestHidePanel(inputMethodPanel);
834     inputMethodPanel->SetPanelStatusListener(statusListener, "hide");
835     EXPECT_EQ(status_, InputWindowStatus::HIDE);
836 
837     InputMethodPanelTest::ImaDestroyPanel(inputMethodPanel);
838 }
839 
840 /**
841  * @tc.name: testGetPanelType
842  * @tc.desc: Test GetPanelType.
843  * @tc.type: FUNC
844  */
845 HWTEST_F(InputMethodPanelTest, testGetPanelType, TestSize.Level0)
846 {
847     IMSA_HILOGI("InputMethodPanelTest::testGetPanelType start.");
848     AccessScope scope(InputMethodPanelTest::currentImeTokenId_, InputMethodPanelTest::currentImeUid_);
849     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
850     PanelInfo panelInfo;
851     panelInfo.panelType = SOFT_KEYBOARD;
852     panelInfo.panelFlag = FLG_FLOATING;
853     auto ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
854     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
855     auto type = inputMethodPanel->GetPanelType();
856     EXPECT_EQ(type, panelInfo.panelType);
857     ret = inputMethodPanel->DestroyPanel();
858     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
859 }
860 
861 /**
862  * @tc.name: testGetPanelFlag
863  * @tc.desc: Test GetPanelFlag.
864  * @tc.type: FUNC
865  */
866 HWTEST_F(InputMethodPanelTest, testGetPanelFlag, TestSize.Level0)
867 {
868     IMSA_HILOGI("InputMethodPanelTest::testGetPanelFlag start.");
869     AccessScope scope(InputMethodPanelTest::currentImeTokenId_, InputMethodPanelTest::currentImeUid_);
870     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
871     PanelInfo panelInfo;
872     panelInfo.panelType = SOFT_KEYBOARD;
873     panelInfo.panelFlag = FLG_FLOATING;
874     auto ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
875     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
876     auto flag = inputMethodPanel->GetPanelFlag();
877     EXPECT_EQ(flag, panelInfo.panelFlag);
878 
879     ret = inputMethodPanel->ChangePanelFlag(PanelFlag::FLG_CANDIDATE_COLUMN);
880     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
881     flag = inputMethodPanel->GetPanelFlag();
882     EXPECT_EQ(flag, PanelFlag::FLG_CANDIDATE_COLUMN);
883 
884     ret = inputMethodPanel->DestroyPanel();
885     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
886 }
887 
888 /**
889  * @tc.name: testChangePanelFlag
890  * @tc.desc: Test ChangePanelFlag.
891  * @tc.type: FUNC
892  */
893 HWTEST_F(InputMethodPanelTest, testChangePanelFlag, TestSize.Level0)
894 {
895     IMSA_HILOGI("InputMethodPanelTest::testChangePanelFlag start.");
896     AccessScope scope(InputMethodPanelTest::currentImeTokenId_, InputMethodPanelTest::currentImeUid_);
897     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
898     PanelFlag flag = FLG_FLOATING;
899 
900     // not CreatePanel, ChangePanelFlag failed
901     auto ret = inputMethodPanel->ChangePanelFlag(flag);
902     EXPECT_EQ(ret, ErrorCode::ERROR_NULL_POINTER);
903 
904     PanelInfo panelInfo1;
905     panelInfo1.panelType = SOFT_KEYBOARD;
906     panelInfo1.panelFlag = FLG_FLOATING;
907     ret = inputMethodPanel->CreatePanel(nullptr, panelInfo1);
908     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
909 
910     // panelFlag is same with the original
911     ret = inputMethodPanel->ChangePanelFlag(flag);
912     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
913 
914     // panelFlag modify to FLG_FIXED
915     flag = FLG_FIXED;
916     ret = inputMethodPanel->ChangePanelFlag(flag);
917     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
918 
919     inputMethodPanel->DestroyPanel();
920 
921     PanelInfo panelInfo;
922     panelInfo.panelType = STATUS_BAR;
923     panelInfo.panelFlag = FLG_FLOATING;
924     ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
925     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
926     // panelType is STATUS_BAR, not allow ChangePanelFlag
927     ret = inputMethodPanel->ChangePanelFlag(flag);
928     EXPECT_EQ(ret, ErrorCode::ERROR_BAD_PARAMETERS);
929 
930     inputMethodPanel->DestroyPanel();
931 }
932 
933 /**
934  * @tc.name: testClearPanelListener
935  * @tc.desc: Test ClearPanelListener.
936  * @tc.type: FUNC
937  */
938 HWTEST_F(InputMethodPanelTest, testClearPanelListener, TestSize.Level0)
939 {
940     IMSA_HILOGI("InputMethodPanelTest::testClearPanelListener start.");
941     auto inputMethodPanel = InputMethodPanelTest::CreatePanel();
942     auto statusListener = std::make_shared<InputMethodPanelTest::PanelStatusListenerImpl>();
943     inputMethodPanel->SetPanelStatusListener(statusListener, "show");
944     inputMethodPanel->SetPanelStatusListener(statusListener, "hide");
945 
946     inputMethodPanel->ClearPanelListener("show");
947     EXPECT_FALSE(InputMethodPanelTest::TriggerShowCallback(inputMethodPanel));
948     EXPECT_TRUE(InputMethodPanelTest::TriggerHideCallback(inputMethodPanel));
949 
950     inputMethodPanel->ClearPanelListener("hide");
951     EXPECT_FALSE(InputMethodPanelTest::TriggerShowCallback(inputMethodPanel));
952     EXPECT_FALSE(InputMethodPanelTest::TriggerHideCallback(inputMethodPanel));
953 
954     InputMethodPanelTest::DestroyPanel(inputMethodPanel);
955 }
956 
957 /**
958  * @tc.name: testRegisterListener
959  * @tc.desc: Test ClearPanelListener.
960  * @tc.type: FUNC
961  */
962 HWTEST_F(InputMethodPanelTest, testRegisterListener, TestSize.Level0)
963 {
964     // on('show')->on('hide')->show->hide->off('show')->show->hide->on('show')->show
965     IMSA_HILOGI("InputMethodPanelTest::testRegisterListener start.");
966     auto inputMethodPanel = InputMethodPanelTest::CreatePanel();
967 
968     auto statusListener = std::make_shared<InputMethodPanelTest::PanelStatusListenerImpl>();
969     inputMethodPanel->SetPanelStatusListener(statusListener, "show");
970     inputMethodPanel->SetPanelStatusListener(statusListener, "hide");
971     EXPECT_TRUE(InputMethodPanelTest::TriggerShowCallback(inputMethodPanel));
972     EXPECT_TRUE(InputMethodPanelTest::TriggerHideCallback(inputMethodPanel));
973 
974     inputMethodPanel->ClearPanelListener("show");
975     EXPECT_FALSE(InputMethodPanelTest::TriggerShowCallback(inputMethodPanel));
976     EXPECT_TRUE(InputMethodPanelTest::TriggerHideCallback(inputMethodPanel));
977 
978     inputMethodPanel->SetPanelStatusListener(statusListener, "show");
979     EXPECT_TRUE(InputMethodPanelTest::TriggerShowCallback(inputMethodPanel));
980 
981     InputMethodPanelTest::DestroyPanel(inputMethodPanel);
982 }
983 
984 /*
985  * @tc.name: testImcPanelListening_001
986  * @tc.desc: SOFT_KEYBOARD/FLG_FIXED, listener(system app)
987  * @tc.type: FUNC
988  */
989 HWTEST_F(InputMethodPanelTest, testImcPanelListening_001, TestSize.Level0)
990 {
991     IMSA_HILOGI("InputMethodPanelTest::testImcPanelListening_001 start.");
992     // system app for RegisterImeEventListener and currentIme for PanelStatusChangeToImc
993     IdentityCheckerMock::SetSystemApp(true);
994     IdentityCheckerMock::SetBundleNameValid(true);
995     auto listener = std::make_shared<InputMethodSettingListenerImpl>();
996     ImeEventMonitorManager::GetInstance().RegisterImeEventListener(EVENT_IME_SHOW_MASK | EVENT_IME_HIDE_MASK, listener);
997     PanelInfo panelInfo;
998     panelInfo.panelType = SOFT_KEYBOARD;
999     panelInfo.panelFlag = FLG_FIXED;
1000     std::shared_ptr<InputMethodPanel> panel = nullptr;
1001     ImaCreatePanel(panelInfo, panel);
1002     // imeShow
1003     InputMethodPanelTest::ImcPanelListeningTestRestore();
1004     InputMethodPanelTest::TestShowPanel(panel);
1005     InputMethodPanelTest::TriggerPanelStatusChangeToImc(panel, InputWindowStatus::SHOW);
1006     InputMethodPanelTest::ImcPanelShowNumCheck(1);
1007     // imeHide
1008     InputMethodPanelTest::ImcPanelListeningTestRestore();
1009     InputMethodPanelTest::TestHidePanel(panel);
1010     InputMethodPanelTest::TriggerPanelStatusChangeToImc(panel, InputWindowStatus::HIDE);
1011     InputMethodPanelTest::ImcPanelHideNumCheck(1);
1012     ImaDestroyPanel(panel);
1013     ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener(
1014         EVENT_IME_SHOW_MASK | EVENT_IME_HIDE_MASK, listener);
1015     IdentityCheckerMock::SetSystemApp(false);
1016     IdentityCheckerMock::SetBundleNameValid(false);
1017 }
1018 
1019 /*
1020  * @tc.name: testImcPanelListening_002
1021  * @tc.desc: SOFT_KEYBOARD/FLG_FLOATING, listener(system app)
1022  * @tc.type: FUNC
1023  */
1024 HWTEST_F(InputMethodPanelTest, testImcPanelListening_002, TestSize.Level0)
1025 {
1026     IMSA_HILOGI("InputMethodPanelTest::testImcPanelListening_002 start.");
1027     // system app for RegisterImeEventListener and currentIme for PanelStatusChangeToImc
1028     IdentityCheckerMock::SetSystemApp(true);
1029     IdentityCheckerMock::SetBundleNameValid(true);
1030     auto listener = std::make_shared<InputMethodSettingListenerImpl>();
1031     ImeEventMonitorManager::GetInstance().RegisterImeEventListener(EVENT_IME_SHOW_MASK | EVENT_IME_HIDE_MASK, listener);
1032 
1033     AccessScope scope(currentImeTokenId_, currentImeUid_);
1034     PanelInfo panelInfo;
1035     panelInfo.panelType = SOFT_KEYBOARD;
1036     panelInfo.panelFlag = FLG_FLOATING;
1037     std::shared_ptr<InputMethodPanel> panel = nullptr;
1038     ImaCreatePanel(panelInfo, panel);
1039     // imeShow
1040     InputMethodPanelTest::ImcPanelListeningTestRestore();
1041     InputMethodPanelTest::TestShowPanel(panel);
1042     InputMethodPanelTest::TriggerPanelStatusChangeToImc(panel, InputWindowStatus::SHOW);
1043     InputMethodPanelTest::ImcPanelShowNumCheck(1);
1044     // imeHide
1045     InputMethodPanelTest::ImcPanelListeningTestRestore();
1046     InputMethodPanelTest::TestHidePanel(panel);
1047     InputMethodPanelTest::TriggerPanelStatusChangeToImc(panel, InputWindowStatus::HIDE);
1048     InputMethodPanelTest::ImcPanelHideNumCheck(1);
1049     ImaDestroyPanel(panel);
1050 
1051     ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener(
1052         EVENT_IME_SHOW_MASK | EVENT_IME_HIDE_MASK, listener);
1053     IdentityCheckerMock::SetSystemApp(false);
1054     IdentityCheckerMock::SetBundleNameValid(false);
1055 }
1056 
1057 /*
1058  * @tc.name: testImcPanelListening_003
1059  * @tc.desc: SOFT_KEYBOARD/FLG_CANDIDATE_COLUMN, listener(system app)
1060  * @tc.type: FUNC
1061  */
1062 HWTEST_F(InputMethodPanelTest, testImcPanelListening_003, TestSize.Level0)
1063 {
1064     IMSA_HILOGI("InputMethodPanelTest::testImcPanelListening_003 start.");
1065     // system app for RegisterImeEventListener and currentIme for PanelStatusChangeToImc
1066     IdentityCheckerMock::SetSystemApp(true);
1067     IdentityCheckerMock::SetBundleNameValid(true);
1068     auto listener = std::make_shared<InputMethodSettingListenerImpl>();
1069 
1070     ImeEventMonitorManager::GetInstance().RegisterImeEventListener(EVENT_IME_SHOW_MASK | EVENT_IME_HIDE_MASK, listener);
1071 
1072     PanelInfo panelInfo;
1073     panelInfo.panelType = SOFT_KEYBOARD;
1074     panelInfo.panelFlag = FLG_CANDIDATE_COLUMN;
1075     std::shared_ptr<InputMethodPanel> panel = nullptr;
1076     ImaCreatePanel(panelInfo, panel);
1077     // imeShow
1078     InputMethodPanelTest::ImcPanelListeningTestRestore();
1079     InputMethodPanelTest::TestShowPanel(panel);
1080     InputMethodPanelTest::TriggerPanelStatusChangeToImc(panel, InputWindowStatus::SHOW);
1081     InputMethodPanelTest::ImcPanelShowNumCheck(0);
1082     // imeHide
1083     InputMethodPanelTest::ImcPanelListeningTestRestore();
1084     InputMethodPanelTest::TestHidePanel(panel);
1085     InputMethodPanelTest::TriggerPanelStatusChangeToImc(panel, InputWindowStatus::HIDE);
1086     InputMethodPanelTest::ImcPanelHideNumCheck(0);
1087     ImaDestroyPanel(panel);
1088 
1089     ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener(
1090         EVENT_IME_SHOW_MASK | EVENT_IME_HIDE_MASK, listener);
1091     IdentityCheckerMock::SetSystemApp(false);
1092     IdentityCheckerMock::SetBundleNameValid(false);
1093 }
1094 
1095 /**
1096  * @tc.name: testImcPanelListening_004
1097  * @tc.desc: STATUS_BAR, listener(system app)
1098  * @tc.type: FUNC
1099  */
1100 HWTEST_F(InputMethodPanelTest, testImcPanelListening_004, TestSize.Level0)
1101 {
1102     IMSA_HILOGI("InputMethodPanelTest::testImcPanelListening_004 start.");
1103     // system app for RegisterImeEventListener and currentIme for PanelStatusChangeToImc
1104     IdentityCheckerMock::SetSystemApp(true);
1105     IdentityCheckerMock::SetBundleNameValid(true);
1106     auto listener = std::make_shared<InputMethodSettingListenerImpl>();
1107 
1108     ImeEventMonitorManager::GetInstance().RegisterImeEventListener(EVENT_IME_SHOW_MASK | EVENT_IME_HIDE_MASK, listener);
1109 
1110     PanelInfo panelInfo;
1111     panelInfo.panelType = STATUS_BAR;
1112     std::shared_ptr<InputMethodPanel> panel = nullptr;
1113     ImaCreatePanel(panelInfo, panel);
1114     // imeShow
1115     InputMethodPanelTest::ImcPanelListeningTestRestore();
1116     InputMethodPanelTest::TestShowPanel(panel);
1117     InputMethodPanelTest::ImcPanelShowNumCheck(0);
1118     // imeHide
1119     InputMethodPanelTest::ImcPanelListeningTestRestore();
1120     InputMethodPanelTest::TestHidePanel(panel);
1121     InputMethodPanelTest::ImcPanelHideNumCheck(0);
1122     ImaDestroyPanel(panel);
1123 
1124     ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener(
1125         EVENT_IME_SHOW_MASK | EVENT_IME_HIDE_MASK, listener);
1126     IdentityCheckerMock::SetSystemApp(false);
1127     IdentityCheckerMock::SetBundleNameValid(false);
1128 }
1129 
1130 /*
1131  * @tc.name: testPanelStatusChangeEventPublicTest
1132  * @tc.desc: test subscriber can receive the panel status change event published by IMSA
1133  * @tc.type: FUNC
1134  */
1135 HWTEST_F(InputMethodPanelTest, testPanelStatusChangeEventPublicTest, TestSize.Level0)
1136 {
1137     IMSA_HILOGI("InputMethodPanelTest::testPanelStatusChangeEventPublicTest start.");
1138     // currentIme for PanelStatusChangeToImc
1139     IdentityCheckerMock::SetBundleNameValid(true);
1140     EventFwk::MatchingSkills matchingSkills;
1141     matchingSkills.AddEvent(COMMON_EVENT_INPUT_PANEL_STATUS_CHANGED);
1142     EventFwk::CommonEventSubscribeInfo subscriberInfo(matchingSkills);
1143     auto subscriber = std::make_shared<TestEventSubscriber>(subscriberInfo);
1144     auto ret = EventFwk::CommonEventManager::SubscribeCommonEvent(subscriber);
1145     EXPECT_TRUE(ret);
1146     PanelInfo panelInfo;
1147     panelInfo.panelType = SOFT_KEYBOARD;
1148     panelInfo.panelFlag = FLG_FLOATING;
1149     std::shared_ptr<InputMethodPanel> panel = nullptr;
1150     ImaCreatePanel(panelInfo, panel);
1151     // imeShow
1152     subscriber->ResetParam();
1153     InputMethodPanelTest::TestShowPanel(panel);
1154     InputMethodPanelTest::TriggerPanelStatusChangeToImc(panel, InputWindowStatus::SHOW);
1155     {
1156         std::unique_lock<std::mutex> lock(imcPanelStatusListenerLock_);
1157         auto waitRet = imcPanelStatusListenerCv_.wait_for(
__anoncfeab7b50902() 1158             lock, std::chrono::milliseconds(IMC_WAIT_PANEL_STATUS_LISTEN_TIME), [subscriber]() {
1159                 return subscriber->action_ == COMMON_EVENT_INPUT_PANEL_STATUS_CHANGED &&
1160                     subscriber->status_ == InputWindowStatus::SHOW;
1161             });
1162         EXPECT_TRUE(waitRet);
1163     }
1164     // imeHide
1165     subscriber->ResetParam();
1166     InputMethodPanelTest::TestHidePanel(panel);
1167     InputMethodPanelTest::TriggerPanelStatusChangeToImc(panel, InputWindowStatus::HIDE);
1168     {
1169         std::unique_lock<std::mutex> lock(imcPanelStatusListenerLock_);
1170         auto waitRet = imcPanelStatusListenerCv_.wait_for(
__anoncfeab7b50a02() 1171             lock, std::chrono::milliseconds(IMC_WAIT_PANEL_STATUS_LISTEN_TIME), [subscriber]() {
1172                 return subscriber->action_ == COMMON_EVENT_INPUT_PANEL_STATUS_CHANGED &&
1173                     subscriber->status_ == InputWindowStatus::HIDE;
1174             });
1175         EXPECT_TRUE(waitRet);
1176     }
1177     ImaDestroyPanel(panel);
1178     IdentityCheckerMock::SetBundleNameValid(false);
1179 }
1180 
1181 /**
1182  * @tc.name: testSetCallingWindow
1183  * @tc.desc: test SetCallingWindow
1184  * @tc.type: FUNC
1185  */
1186 HWTEST_F(InputMethodPanelTest, testSetCallingWindow, TestSize.Level0)
1187 {
1188     IMSA_HILOGI("InputMethodPanelTest::testSetCallingWindow start.");
1189     AccessScope scope(InputMethodPanelTest::currentImeTokenId_, InputMethodPanelTest::currentImeUid_);
1190     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
1191     // not CreatePanel, SetCallingWindow failed
1192     uint32_t windowId = 8;
1193     auto ret = inputMethodPanel->SetCallingWindow(windowId);
1194     EXPECT_EQ(ret, ErrorCode::ERROR_PANEL_NOT_FOUND);
1195 
1196     PanelInfo panelInfo;
1197     panelInfo.panelType = SOFT_KEYBOARD;
1198     panelInfo.panelFlag = FLG_FIXED;
1199     ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
1200     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
1201 
1202     ret = inputMethodPanel->SetCallingWindow(windowId);
1203     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
1204 
1205     ret = inputMethodPanel->DestroyPanel();
1206     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
1207 }
1208 
1209 /*
1210  * @tc.name: testKeyboardPanelInfoChangeListenerRegister_001
1211  * @tc.desc: SOFT_KEYBOARD
1212  * @tc.type: FUNC
1213  */
1214 HWTEST_F(InputMethodPanelTest, testKeyboardPanelInfoChangeListenerRegister_001, TestSize.Level0)
1215 {
1216     IMSA_HILOGI("InputMethodPanelTest::testKeyboardPanelInfoChangeListenerRegister_001 start.");
1217     PanelInfo panelInfo;
1218     panelInfo.panelType = SOFT_KEYBOARD;
1219     std::shared_ptr<InputMethodPanel> panel = nullptr;
1220     ImaCreatePanel(panelInfo, panel);
1221     ASSERT_NE(panel, nullptr);
1222     if (isScbEnable_) {
1223         EXPECT_NE(panel->kbPanelInfoListener_, nullptr);
1224     } else {
1225         EXPECT_EQ(panel->kbPanelInfoListener_, nullptr);
1226     }
1227     ImaDestroyPanel(panel);
1228     EXPECT_EQ(panel->kbPanelInfoListener_, nullptr);
1229 }
1230 
1231 /*
1232  * @tc.name: testKeyboardPanelInfoChangeListenerRegister_002
1233  * @tc.desc: STATUS_BAR
1234  * @tc.type: FUNC
1235  */
1236 HWTEST_F(InputMethodPanelTest, testKeyboardPanelInfoChangeListenerRegister_002, TestSize.Level0)
1237 {
1238     IMSA_HILOGI("InputMethodPanelTest::testKeyboardPanelInfoChangeListenerRegister_002 start.");
1239     PanelInfo panelInfo;
1240     panelInfo.panelType = STATUS_BAR;
1241     std::shared_ptr<InputMethodPanel> panel = nullptr;
1242     ImaCreatePanel(panelInfo, panel);
1243     ASSERT_NE(panel, nullptr);
1244     EXPECT_EQ(panel->kbPanelInfoListener_, nullptr);
1245     ImaDestroyPanel(panel);
1246 }
1247 
1248 /**
1249  * @tc.name: testAdjustPanelRect_001
1250  * @tc.desc: Test AdjustPanelRect with FLG_FIXED invalid params.
1251  * @tc.type: FUNC
1252  */
1253 HWTEST_F(InputMethodPanelTest, testAdjustPanelRect_001, TestSize.Level0)
1254 {
1255     IMSA_HILOGI("InputMethodPanelTest::testAdjustPanelRect_001 start.");
1256     InputMethodPanelTest::Attach();
1257     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
1258     PanelInfo panelInfo;
1259     panelInfo.panelType = SOFT_KEYBOARD;
1260     panelInfo.panelFlag = FLG_FIXED;
1261     InputMethodPanelTest::ImaCreatePanel(panelInfo, inputMethodPanel);
1262     PanelFlag panelFlag = PanelFlag::FLG_FIXED;
1263     LayoutParams layoutParams;
1264     layoutParams.landscapeRect = { 0, 0, 0, 0 };
1265     layoutParams.portraitRect = { 0, 0, 0, 0 };
1266     auto ret = inputMethodPanel->AdjustPanelRect(panelFlag, layoutParams);
1267     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
1268     InputMethodPanelTest::ImaDestroyPanel(inputMethodPanel);
1269     InputMethodPanelTest::imc_->Close();
1270     TddUtil::DestroyWindow();
1271 }
1272 
1273 /**
1274  * @tc.name: testAdjustPanelRect_002
1275  * @tc.desc: Test AdjustPanelRect with FLG_FIXED invalid params.
1276  * @tc.type: FUNC
1277  */
1278 HWTEST_F(InputMethodPanelTest, testAdjustPanelRect_002, TestSize.Level0)
1279 {
1280     IMSA_HILOGI("InputMethodPanelTest::testAdjustPanelRect_002 start.");
1281     InputMethodPanelTest::Attach();
1282     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
1283     PanelInfo panelInfo;
1284     panelInfo.panelType = SOFT_KEYBOARD;
1285     panelInfo.panelFlag = FLG_FIXED;
1286     InputMethodPanelTest::ImaCreatePanel(panelInfo, inputMethodPanel);
1287     PanelFlag panelFlag = PanelFlag::FLG_FIXED;
1288     LayoutParams layoutParams;
1289     layoutParams.landscapeRect = { -1, 0, 0, 0 };
1290     layoutParams.portraitRect = { -1, 0, 0, 0 };
1291     auto ret = inputMethodPanel->AdjustPanelRect(panelFlag, layoutParams);
1292     EXPECT_EQ(ret, ErrorCode::ERROR_PARAMETER_CHECK_FAILED);
1293     InputMethodPanelTest::ImaDestroyPanel(inputMethodPanel);
1294     InputMethodPanelTest::imc_->Close();
1295     TddUtil::DestroyWindow();
1296 }
1297 
1298 /**
1299  * @tc.name: testAdjustPanelRect_003
1300  * @tc.desc: Test AdjustPanelRect with FLG_FIXED invalid params.
1301  * @tc.type: FUNC
1302  */
1303 HWTEST_F(InputMethodPanelTest, testAdjustPanelRect_003, TestSize.Level0)
1304 {
1305     IMSA_HILOGI("InputMethodPanelTest::testAdjustPanelRect_003 start.");
1306     InputMethodPanelTest::Attach();
1307     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
1308     PanelInfo panelInfo;
1309     panelInfo.panelType = SOFT_KEYBOARD;
1310     panelInfo.panelFlag = FLG_FIXED;
1311     InputMethodPanelTest::ImaCreatePanel(panelInfo, inputMethodPanel);
1312     PanelFlag panelFlag = PanelFlag::FLG_FIXED;
1313     LayoutParams layoutParams;
1314     layoutParams.landscapeRect = { 0, -1, 0, 0 };
1315     layoutParams.portraitRect = { 0, -1, 0, 0 };
1316     auto ret = inputMethodPanel->AdjustPanelRect(panelFlag, layoutParams);
1317     EXPECT_EQ(ret, ErrorCode::ERROR_PARAMETER_CHECK_FAILED);
1318     InputMethodPanelTest::ImaDestroyPanel(inputMethodPanel);
1319     InputMethodPanelTest::imc_->Close();
1320     TddUtil::DestroyWindow();
1321 }
1322 
1323 /**
1324  * @tc.name: testAdjustPanelRect_004
1325  * @tc.desc: Test AdjustPanelRect with FLG_FIXED invalid params.
1326  * @tc.type: FUNC
1327  */
1328 HWTEST_F(InputMethodPanelTest, testAdjustPanelRect_004, TestSize.Level0)
1329 {
1330     IMSA_HILOGI("InputMethodPanelTest::testAdjustPanelRect_004 start.");
1331     InputMethodPanelTest::Attach();
1332     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
1333     PanelInfo panelInfo;
1334     panelInfo.panelType = SOFT_KEYBOARD;
1335     panelInfo.panelFlag = FLG_FIXED;
1336     InputMethodPanelTest::ImaCreatePanel(panelInfo, inputMethodPanel);
1337     PanelFlag panelFlag = PanelFlag::FLG_FIXED;
1338     LayoutParams layoutParams;
1339     layoutParams.landscapeRect = { 0, 0, -1, 0 };
1340     layoutParams.portraitRect = { 0, 0, -1, 0 };
1341     auto ret = inputMethodPanel->AdjustPanelRect(panelFlag, layoutParams);
1342     EXPECT_EQ(ret, ErrorCode::ERROR_PARAMETER_CHECK_FAILED);
1343     InputMethodPanelTest::ImaDestroyPanel(inputMethodPanel);
1344     InputMethodPanelTest::imc_->Close();
1345     TddUtil::DestroyWindow();
1346 }
1347 
1348 /**
1349  * @tc.name: testAdjustPanelRect_005
1350  * @tc.desc: Test AdjustPanelRect with FLG_FIXED invalid params.
1351  * @tc.type: FUNC
1352  */
1353 HWTEST_F(InputMethodPanelTest, testAdjustPanelRect_005, TestSize.Level0)
1354 {
1355     IMSA_HILOGI("InputMethodPanelTest::testAdjustPanelRect_005 start.");
1356     InputMethodPanelTest::Attach();
1357     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
1358     PanelInfo panelInfo;
1359     panelInfo.panelType = SOFT_KEYBOARD;
1360     panelInfo.panelFlag = FLG_FIXED;
1361     InputMethodPanelTest::ImaCreatePanel(panelInfo, inputMethodPanel);
1362     PanelFlag panelFlag = PanelFlag::FLG_FIXED;
1363     LayoutParams layoutParams;
1364     layoutParams.landscapeRect = { 0, 0, 0, -1 };
1365     layoutParams.portraitRect = { 0, 0, 0, -1 };
1366     auto ret = inputMethodPanel->AdjustPanelRect(panelFlag, layoutParams);
1367     EXPECT_EQ(ret, ErrorCode::ERROR_PARAMETER_CHECK_FAILED);
1368     InputMethodPanelTest::ImaDestroyPanel(inputMethodPanel);
1369     InputMethodPanelTest::imc_->Close();
1370     TddUtil::DestroyWindow();
1371 }
1372 
1373 /**
1374  * @tc.name: testAdjustPanelRect_006
1375  * @tc.desc: Test AdjustPanelRect with FLG_FIXED valid params.
1376  * @tc.type: FUNC
1377  */
1378 HWTEST_F(InputMethodPanelTest, testAdjustPanelRect_006, TestSize.Level0)
1379 {
1380     IMSA_HILOGI("InputMethodPanelTest::testAdjustPanelRect_006 start.");
1381     InputMethodPanelTest::Attach();
1382     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
1383     PanelInfo panelInfo;
1384     panelInfo.panelType = SOFT_KEYBOARD;
1385     panelInfo.panelFlag = FLG_FIXED;
1386     InputMethodPanelTest::ImaCreatePanel(panelInfo, inputMethodPanel);
1387     DisplaySize displaySize;
1388     ASSERT_EQ(InputMethodPanelTest::GetDisplaySize(displaySize), ErrorCode::NO_ERROR);
1389     PanelFlag panelFlag = PanelFlag::FLG_FIXED;
1390     LayoutParams layoutParams;
1391     layoutParams.landscapeRect = { 0, 0, displaySize.landscape.width, 0 };
1392     layoutParams.portraitRect = { 0, 0, displaySize.portrait.width, 0 };
1393     auto ret = inputMethodPanel->AdjustPanelRect(panelFlag, layoutParams);
1394     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
1395     InputMethodPanelTest::ImaDestroyPanel(inputMethodPanel);
1396     InputMethodPanelTest::imc_->Close();
1397     TddUtil::DestroyWindow();
1398 }
1399 
1400 /**
1401  * @tc.name: testAdjustPanelRect_007
1402  * @tc.desc: Test AdjustPanelRect with FLG_FIXED invalid params.
1403  * @tc.type: FUNC
1404  */
1405 HWTEST_F(InputMethodPanelTest, testAdjustPanelRect_007, TestSize.Level0)
1406 {
1407     IMSA_HILOGI("InputMethodPanelTest::testAdjustPanelRect_007 start.");
1408     InputMethodPanelTest::Attach();
1409     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
1410     PanelInfo panelInfo;
1411     panelInfo.panelType = SOFT_KEYBOARD;
1412     panelInfo.panelFlag = FLG_FIXED;
1413     InputMethodPanelTest::ImaCreatePanel(panelInfo, inputMethodPanel);
1414     DisplaySize displaySize;
1415     ASSERT_EQ(InputMethodPanelTest::GetDisplaySize(displaySize), ErrorCode::NO_ERROR);
1416     PanelFlag panelFlag = PanelFlag::FLG_FIXED;
1417     LayoutParams layoutParams;
1418     layoutParams.landscapeRect = { 0, 0, displaySize.landscape.width + 1, 0 };
1419     layoutParams.portraitRect = { 0, 0, displaySize.portrait.width + 1, 0 };
1420     auto ret = inputMethodPanel->AdjustPanelRect(panelFlag, layoutParams);
1421     EXPECT_EQ(ret, ErrorCode::ERROR_PARAMETER_CHECK_FAILED);
1422     InputMethodPanelTest::ImaDestroyPanel(inputMethodPanel);
1423     InputMethodPanelTest::imc_->Close();
1424     TddUtil::DestroyWindow();
1425 }
1426 
1427 /**
1428  * @tc.name: testAdjustPanelRect_008
1429  * @tc.desc: Test AdjustPanelRect with FLG_FIXED invalid params.
1430  * @tc.type: FUNC
1431  */
1432 HWTEST_F(InputMethodPanelTest, testAdjustPanelRect_008, TestSize.Level0)
1433 {
1434     IMSA_HILOGI("InputMethodPanelTest::testAdjustPanelRect_008 start.");
1435     InputMethodPanelTest::Attach();
1436     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
1437     PanelInfo panelInfo;
1438     panelInfo.panelType = SOFT_KEYBOARD;
1439     panelInfo.panelFlag = FLG_FIXED;
1440     InputMethodPanelTest::ImaCreatePanel(panelInfo, inputMethodPanel);
1441     DisplaySize displaySize;
1442     ASSERT_EQ(InputMethodPanelTest::GetDisplaySize(displaySize), ErrorCode::NO_ERROR);
1443     PanelFlag panelFlag = PanelFlag::FLG_FIXED;
1444     LayoutParams layoutParams;
1445     layoutParams.landscapeRect = { 0, 0, displaySize.landscape.width,
1446         static_cast<uint32_t>(static_cast<float>(displaySize.landscape.height) * 0.7) + 1 };
1447     layoutParams.portraitRect = { 0, 0, displaySize.portrait.width,
1448         static_cast<uint32_t>(static_cast<float>(displaySize.portrait.height) * 0.7) + 1 };
1449     auto ret = inputMethodPanel->AdjustPanelRect(panelFlag, layoutParams);
1450     EXPECT_EQ(ret, ErrorCode::ERROR_PARAMETER_CHECK_FAILED);
1451     InputMethodPanelTest::ImaDestroyPanel(inputMethodPanel);
1452     InputMethodPanelTest::imc_->Close();
1453     TddUtil::DestroyWindow();
1454 }
1455 
1456 /**
1457  * @tc.name: testAdjustPanelRect_009
1458  * @tc.desc: Test AdjustPanelRect with FLG_FIXED valid params.
1459  * @tc.type: FUNC
1460  */
1461 HWTEST_F(InputMethodPanelTest, testAdjustPanelRect_009, TestSize.Level0)
1462 {
1463     IMSA_HILOGI("InputMethodPanelTest::testAdjustPanelRect_009 start.");
1464     InputMethodPanelTest::Attach();
1465     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
1466     PanelInfo panelInfo;
1467     panelInfo.panelType = SOFT_KEYBOARD;
1468     panelInfo.panelFlag = FLG_FIXED;
1469     InputMethodPanelTest::ImaCreatePanel(panelInfo, inputMethodPanel);
1470     DisplaySize displaySize;
1471     ASSERT_EQ(InputMethodPanelTest::GetDisplaySize(displaySize), ErrorCode::NO_ERROR);
1472     PanelFlag panelFlag = PanelFlag::FLG_FIXED;
1473     LayoutParams layoutParams;
1474     layoutParams.landscapeRect = { 0, 0, displaySize.landscape.width,
1475         static_cast<uint32_t>(static_cast<float>(displaySize.landscape.height) * 0.7) };
1476     layoutParams.portraitRect = { 0, 0, displaySize.portrait.width,
1477         static_cast<uint32_t>(static_cast<float>(displaySize.portrait.height) * 0.7) };
1478     auto ret = inputMethodPanel->AdjustPanelRect(panelFlag, layoutParams);
1479     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
1480     InputMethodPanelTest::ImaDestroyPanel(inputMethodPanel);
1481     InputMethodPanelTest::imc_->Close();
1482     TddUtil::DestroyWindow();
1483 }
1484 
1485 /**
1486  * @tc.name: testAdjustPanelRect_010
1487  * @tc.desc: Test AdjustPanelRect with FLG_FLOATING valid params.
1488  * @tc.type: FUNC
1489  */
1490 HWTEST_F(InputMethodPanelTest, testAdjustPanelRect_010, TestSize.Level0)
1491 {
1492     IMSA_HILOGI("InputMethodPanelTest::testAdjustPanelRect_010 start.");
1493     InputMethodPanelTest::Attach();
1494     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
1495     PanelInfo panelInfo;
1496     panelInfo.panelType = SOFT_KEYBOARD;
1497     panelInfo.panelFlag = FLG_FLOATING;
1498     InputMethodPanelTest::ImaCreatePanel(panelInfo, inputMethodPanel);
1499     PanelFlag panelFlag = PanelFlag::FLG_FLOATING;
1500     LayoutParams layoutParams;
1501     layoutParams.landscapeRect = { 0, 0, 0, 0 };
1502     layoutParams.portraitRect = { 0, 0, 0, 0 };
1503     auto ret = inputMethodPanel->AdjustPanelRect(panelFlag, layoutParams);
1504     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
1505     InputMethodPanelTest::ImaDestroyPanel(inputMethodPanel);
1506     InputMethodPanelTest::imc_->Close();
1507     TddUtil::DestroyWindow();
1508 }
1509 
1510 /**
1511  * @tc.name: testAdjustPanelRect_011
1512  * @tc.desc: Test AdjustPanelRect with FLG_FLOATING invalid params.
1513  * @tc.type: FUNC
1514  */
1515 HWTEST_F(InputMethodPanelTest, testAdjustPanelRect_011, TestSize.Level0)
1516 {
1517     IMSA_HILOGI("InputMethodPanelTest::testAdjustPanelRect_011 start.");
1518     InputMethodPanelTest::Attach();
1519     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
1520     PanelInfo panelInfo;
1521     panelInfo.panelType = SOFT_KEYBOARD;
1522     panelInfo.panelFlag = FLG_FLOATING;
1523     InputMethodPanelTest::ImaCreatePanel(panelInfo, inputMethodPanel);
1524     PanelFlag panelFlag = PanelFlag::FLG_FLOATING;
1525     LayoutParams layoutParams;
1526     layoutParams.landscapeRect = { -1, 0, 0, 0 };
1527     layoutParams.portraitRect = { -1, 0, 0, 0 };
1528     auto ret = inputMethodPanel->AdjustPanelRect(panelFlag, layoutParams);
1529     EXPECT_EQ(ret, ErrorCode::ERROR_PARAMETER_CHECK_FAILED);
1530     InputMethodPanelTest::ImaDestroyPanel(inputMethodPanel);
1531     InputMethodPanelTest::imc_->Close();
1532     TddUtil::DestroyWindow();
1533 }
1534 
1535 /**
1536  * @tc.name: testAdjustPanelRect_012
1537  * @tc.desc: Test AdjustPanelRect with FLG_FLOATING invalid params.
1538  * @tc.type: FUNC
1539  */
1540 HWTEST_F(InputMethodPanelTest, testAdjustPanelRect_012, TestSize.Level0)
1541 {
1542     IMSA_HILOGI("InputMethodPanelTest::testAdjustPanelRect_012 start.");
1543     InputMethodPanelTest::Attach();
1544     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
1545     PanelInfo panelInfo;
1546     panelInfo.panelType = SOFT_KEYBOARD;
1547     panelInfo.panelFlag = FLG_FLOATING;
1548     InputMethodPanelTest::ImaCreatePanel(panelInfo, inputMethodPanel);
1549     PanelFlag panelFlag = PanelFlag::FLG_FLOATING;
1550     LayoutParams layoutParams;
1551     layoutParams.landscapeRect = { 0, -1, 0, 0 };
1552     layoutParams.portraitRect = { 0, -1, 0, 0 };
1553     auto ret = inputMethodPanel->AdjustPanelRect(panelFlag, layoutParams);
1554     EXPECT_EQ(ret, ErrorCode::ERROR_PARAMETER_CHECK_FAILED);
1555     InputMethodPanelTest::ImaDestroyPanel(inputMethodPanel);
1556     InputMethodPanelTest::imc_->Close();
1557     TddUtil::DestroyWindow();
1558 }
1559 
1560 /**
1561  * @tc.name: testAdjustPanelRect_013
1562  * @tc.desc: Test AdjustPanelRect with FLG_FLOATING invalid params.
1563  * @tc.type: FUNC
1564  */
1565 HWTEST_F(InputMethodPanelTest, testAdjustPanelRect_013, TestSize.Level0)
1566 {
1567     IMSA_HILOGI("InputMethodPanelTest::testAdjustPanelRect_013 start.");
1568     InputMethodPanelTest::Attach();
1569     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
1570     PanelInfo panelInfo;
1571     panelInfo.panelType = SOFT_KEYBOARD;
1572     panelInfo.panelFlag = FLG_FLOATING;
1573     InputMethodPanelTest::ImaCreatePanel(panelInfo, inputMethodPanel);
1574     PanelFlag panelFlag = PanelFlag::FLG_FLOATING;
1575     LayoutParams layoutParams;
1576     layoutParams.landscapeRect = { 0, 0, -1, 0 };
1577     layoutParams.portraitRect = { 0, 0, -1, 0 };
1578     auto ret = inputMethodPanel->AdjustPanelRect(panelFlag, layoutParams);
1579     EXPECT_EQ(ret, ErrorCode::ERROR_PARAMETER_CHECK_FAILED);
1580     InputMethodPanelTest::ImaDestroyPanel(inputMethodPanel);
1581     InputMethodPanelTest::imc_->Close();
1582     TddUtil::DestroyWindow();
1583 }
1584 
1585 /**
1586  * @tc.name: testAdjustPanelRect_014
1587  * @tc.desc: Test AdjustPanelRect with FLG_FLOATING valid params.
1588  * @tc.type: FUNC
1589  */
1590 HWTEST_F(InputMethodPanelTest, testAdjustPanelRect_014, TestSize.Level0)
1591 {
1592     IMSA_HILOGI("InputMethodPanelTest::testAdjustPanelRect_014 start.");
1593     InputMethodPanelTest::Attach();
1594     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
1595     PanelInfo panelInfo;
1596     panelInfo.panelType = SOFT_KEYBOARD;
1597     panelInfo.panelFlag = FLG_FLOATING;
1598     InputMethodPanelTest::ImaCreatePanel(panelInfo, inputMethodPanel);
1599     DisplaySize displaySize;
1600     ASSERT_EQ(InputMethodPanelTest::GetDisplaySize(displaySize), ErrorCode::NO_ERROR);
1601     PanelFlag panelFlag = PanelFlag::FLG_FLOATING;
1602     LayoutParams layoutParams;
1603     layoutParams.landscapeRect = { 0, 0, displaySize.landscape.width, 0 };
1604     layoutParams.portraitRect = { 0, 0, displaySize.portrait.width, 0 };
1605     auto ret = inputMethodPanel->AdjustPanelRect(panelFlag, layoutParams);
1606     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
1607     InputMethodPanelTest::ImaDestroyPanel(inputMethodPanel);
1608     InputMethodPanelTest::imc_->Close();
1609     TddUtil::DestroyWindow();
1610 }
1611 
1612 /**
1613  * @tc.name: testAdjustPanelRect_015
1614  * @tc.desc: Test AdjustPanelRect with FLG_FLOATING invalid params.
1615  * @tc.type: FUNC
1616  */
1617 HWTEST_F(InputMethodPanelTest, testAdjustPanelRect_015, TestSize.Level0)
1618 {
1619     IMSA_HILOGI("InputMethodPanelTest::testAdjustPanelRect_015 start.");
1620     InputMethodPanelTest::Attach();
1621     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
1622     PanelInfo panelInfo;
1623     panelInfo.panelType = SOFT_KEYBOARD;
1624     panelInfo.panelFlag = FLG_FLOATING;
1625     InputMethodPanelTest::ImaCreatePanel(panelInfo, inputMethodPanel);
1626     DisplaySize displaySize;
1627     ASSERT_EQ(InputMethodPanelTest::GetDisplaySize(displaySize), ErrorCode::NO_ERROR);
1628     PanelFlag panelFlag = PanelFlag::FLG_FLOATING;
1629     LayoutParams layoutParams;
1630     layoutParams.landscapeRect = { 0, 0, displaySize.landscape.width + 1, 0 };
1631     layoutParams.portraitRect = { 0, 0, displaySize.portrait.width + 1, 0 };
1632     auto ret = inputMethodPanel->AdjustPanelRect(panelFlag, layoutParams);
1633     EXPECT_EQ(ret, ErrorCode::ERROR_PARAMETER_CHECK_FAILED);
1634     InputMethodPanelTest::ImaDestroyPanel(inputMethodPanel);
1635     InputMethodPanelTest::imc_->Close();
1636     TddUtil::DestroyWindow();
1637 }
1638 
1639 /**
1640  * @tc.name: testAdjustPanelRect_016
1641  * @tc.desc: Test AdjustPanelRect with FLG_FLOATING valid params.
1642  * @tc.type: FUNC
1643  */
1644 HWTEST_F(InputMethodPanelTest, testAdjustPanelRect_016, TestSize.Level0)
1645 {
1646     IMSA_HILOGI("InputMethodPanelTest::testAdjustPanelRect_016 start.");
1647     InputMethodPanelTest::Attach();
1648     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
1649     PanelInfo panelInfo;
1650     panelInfo.panelType = SOFT_KEYBOARD;
1651     panelInfo.panelFlag = FLG_FLOATING;
1652     InputMethodPanelTest::ImaCreatePanel(panelInfo, inputMethodPanel);
1653     DisplaySize displaySize;
1654     ASSERT_EQ(InputMethodPanelTest::GetDisplaySize(displaySize), ErrorCode::NO_ERROR);
1655     PanelFlag panelFlag = PanelFlag::FLG_FLOATING;
1656     LayoutParams layoutParams;
1657     layoutParams.landscapeRect = { 0, 0, displaySize.landscape.width,
1658         static_cast<uint32_t>(static_cast<float>(displaySize.landscape.height) * 0.7) + 1 };
1659     layoutParams.portraitRect = { 0, 0, displaySize.portrait.width,
1660         static_cast<uint32_t>(static_cast<float>(displaySize.portrait.height) * 0.7) + 1 };
1661     auto ret = inputMethodPanel->AdjustPanelRect(panelFlag, layoutParams);
1662     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
1663     InputMethodPanelTest::ImaDestroyPanel(inputMethodPanel);
1664     InputMethodPanelTest::imc_->Close();
1665     TddUtil::DestroyWindow();
1666 }
1667 
1668 /**
1669  * @tc.name: testAdjustPanelRect_017
1670  * @tc.desc: Test AdjustPanelRect with FLG_FLOATING valid params.
1671  * @tc.type: FUNC
1672  */
1673 HWTEST_F(InputMethodPanelTest, testAdjustPanelRect_017, TestSize.Level0)
1674 {
1675     IMSA_HILOGI("InputMethodPanelTest::testAdjustPanelRect_017 start.");
1676     InputMethodPanelTest::Attach();
1677     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
1678     PanelInfo panelInfo;
1679     panelInfo.panelType = SOFT_KEYBOARD;
1680     panelInfo.panelFlag = FLG_FLOATING;
1681     InputMethodPanelTest::ImaCreatePanel(panelInfo, inputMethodPanel);
1682     DisplaySize displaySize;
1683     ASSERT_EQ(InputMethodPanelTest::GetDisplaySize(displaySize), ErrorCode::NO_ERROR);
1684     PanelFlag panelFlag = PanelFlag::FLG_FLOATING;
1685     LayoutParams layoutParams = { .landscapeRect = { 0, 0, displaySize.landscape.width, displaySize.landscape.height },
1686         .portraitRect = { 0, 0, displaySize.portrait.width, displaySize.portrait.height } };
1687     auto ret = inputMethodPanel->AdjustPanelRect(panelFlag, layoutParams);
1688     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
1689     InputMethodPanelTest::ImaDestroyPanel(inputMethodPanel);
1690     InputMethodPanelTest::imc_->Close();
1691     TddUtil::DestroyWindow();
1692 }
1693 
1694 /**
1695  * @tc.name: testAdjustPanelRect_018
1696  * @tc.desc: Test AdjustPanelRect with FLG_FLOATING invalid params.
1697  * @tc.type: FUNC
1698  */
1699 HWTEST_F(InputMethodPanelTest, testAdjustPanelRect_018, TestSize.Level0)
1700 {
1701     IMSA_HILOGI("InputMethodPanelTest::testAdjustPanelRect_018 start.");
1702     InputMethodPanelTest::Attach();
1703     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
1704     PanelInfo panelInfo;
1705     panelInfo.panelType = SOFT_KEYBOARD;
1706     panelInfo.panelFlag = FLG_FLOATING;
1707     InputMethodPanelTest::ImaCreatePanel(panelInfo, inputMethodPanel);
1708     DisplaySize displaySize;
1709     ASSERT_EQ(InputMethodPanelTest::GetDisplaySize(displaySize), ErrorCode::NO_ERROR);
1710     PanelFlag panelFlag = PanelFlag::FLG_FLOATING;
1711     LayoutParams layoutParams;
1712     layoutParams.landscapeRect = { 0, 0, displaySize.landscape.width, displaySize.landscape.height + 1 };
1713     layoutParams.portraitRect = { 0, 0, displaySize.portrait.width, displaySize.portrait.height + 1 };
1714     auto ret = inputMethodPanel->AdjustPanelRect(panelFlag, layoutParams);
1715     EXPECT_EQ(ret, ErrorCode::ERROR_PARAMETER_CHECK_FAILED);
1716     InputMethodPanelTest::ImaDestroyPanel(inputMethodPanel);
1717     InputMethodPanelTest::imc_->Close();
1718     TddUtil::DestroyWindow();
1719 }
1720 
1721 /**
1722  * @tc.name: testAdjustKeyboard_001
1723  * @tc.desc: Test AdjustKeyboard
1724  * @tc.type: FUNC
1725  */
1726 HWTEST_F(InputMethodPanelTest, testAdjustKeyboard_001, TestSize.Level0)
1727 {
1728     IMSA_HILOGI("InputMethodPanelTest::testAdjustKeyboard_001 start.");
1729     InputMethodPanelTest::Attach();
1730     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
1731     PanelInfo panelInfo;
1732     panelInfo.panelType = SOFT_KEYBOARD;
1733     panelInfo.panelFlag = FLG_FLOATING;
1734     InputMethodPanelTest::ImaCreatePanel(panelInfo, inputMethodPanel);
1735     auto ret = inputMethodPanel->AdjustKeyboard();
1736     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
1737     InputMethodPanelTest::ImaDestroyPanel(inputMethodPanel);
1738     InputMethodPanelTest::imc_->Close();
1739     TddUtil::DestroyWindow();
1740 }
1741 
1742 /**
1743  * @tc.name: testSetPrivacyMode
1744  * @tc.desc: Test SetPrivacyMode.
1745  * @tc.type: FUNC
1746  */
1747 HWTEST_F(InputMethodPanelTest, testSetPrivacyMode, TestSize.Level0)
1748 {
1749     InputMethodPanelTest::Attach();
1750     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
1751     PanelInfo panelInfo;
1752     panelInfo.panelType = SOFT_KEYBOARD;
1753     panelInfo.panelFlag = FLG_FLOATING;
1754     InputMethodPanelTest::ImaCreatePanel(panelInfo, inputMethodPanel);
1755     auto ret = inputMethodPanel->SetPrivacyMode(true);
1756     EXPECT_NE(ret, ErrorCode::NO_ERROR);
1757     InputMethodPanelTest::ImaDestroyPanel(inputMethodPanel);
1758     InputMethodPanelTest::imc_->Close();
1759     TddUtil::DestroyWindow();
1760 }
1761 
1762 /**
1763  * @tc.name: testSetPanelProperties
1764  * @tc.desc: Test SetPanelProperties.
1765  * @tc.type: FUNC
1766  */
1767 HWTEST_F(InputMethodPanelTest, testSetPanelProperties, TestSize.Level0)
1768 {
1769     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
1770     auto ret = inputMethodPanel->SetPanelProperties();
1771     EXPECT_EQ(ret, ErrorCode::ERROR_OPERATE_PANEL);
1772     inputMethodPanel->UnregisterKeyboardPanelInfoChangeListener();
1773     ret = inputMethodPanel->SetPrivacyMode(false);
1774     EXPECT_EQ(ret, ErrorCode::ERROR_NULL_POINTER);
1775 }
1776 
1777 /**
1778  * @tc.name: testGetKeyboardSize
1779  * @tc.desc: Test GetKeyboardSize.
1780  * @tc.type: FUNC
1781  */
1782 HWTEST_F(InputMethodPanelTest, testGetKeyboardSize, TestSize.Level0)
1783 {
1784     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
1785     auto boardSize = inputMethodPanel->GetKeyboardSize();
1786     EXPECT_EQ(boardSize.width, 0);
1787     EXPECT_EQ(boardSize.height, 0);
1788 }
1789 
1790 /**
1791  * @tc.name: testMarkListener
1792  * @tc.desc: Test MarkListener.
1793  * @tc.type: FUNC
1794  */
1795 HWTEST_F(InputMethodPanelTest, testMarkListener, TestSize.Level0)
1796 {
1797     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
1798     auto statusListener = std::make_shared<InputMethodPanelTest::PanelStatusListenerImpl>();
1799     auto ret = inputMethodPanel->SetPanelStatusListener(statusListener, "text");
1800     EXPECT_FALSE(ret);
1801     inputMethodPanel->ClearPanelListener("text");
1802     ret = inputMethodPanel->MarkListener("contenInfo", true);
1803     EXPECT_FALSE(ret);
1804     ret = inputMethodPanel->MarkListener("sizeChange", true);
1805     EXPECT_TRUE(ret);
1806 }
1807 
1808 /**
1809  * @tc.name: testSizeChange
1810  * @tc.desc: Test SizeChange.
1811  * @tc.type: FUNC
1812  */
1813 HWTEST_F(InputMethodPanelTest, testSizeChange, TestSize.Level0)
1814 {
1815     AccessScope scope(currentImeTokenId_, currentImeUid_);
1816     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
1817     PanelInfo panelInfo;
1818     panelInfo.panelType = SOFT_KEYBOARD;
1819     panelInfo.panelFlag = FLG_FLOATING;
1820     auto statusListener = std::make_shared<InputMethodPanelTest::PanelStatusListenerImpl>();
1821     auto ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
1822     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
1823     inputMethodPanel->panelStatusListener_ = statusListener;
1824     WindowSize windowSize;
1825     ret = inputMethodPanel->SizeChange(windowSize);
1826     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
1827     ret = inputMethodPanel->DestroyPanel();
1828     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
1829 }
1830 
1831 /**
1832  * @tc.name: testSetTextFieldAvoidInfo01
1833  * @tc.desc: Test SetTextFieldAvoidInfo.
1834  * @tc.type: FUNC
1835  */
1836 HWTEST_F(InputMethodPanelTest, testSetTextFieldAvoidInfo01, TestSize.Level0)
1837 {
1838     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
1839     auto ret = inputMethodPanel->SetTextFieldAvoidInfo(0, 0);
1840     EXPECT_EQ(ret, ErrorCode::ERROR_NULL_POINTER);
1841 }
1842 
1843 /**
1844  * @tc.name: testSetTextFieldAvoidInfo02
1845  * @tc.desc: Test SetTextFieldAvoidInfo.
1846  * @tc.type: FUNC
1847  */
1848 HWTEST_F(InputMethodPanelTest, testSetTextFieldAvoidInfo02, TestSize.Level0)
1849 {
1850     InputMethodPanelTest::Attach();
1851     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
1852     PanelInfo panelInfo;
1853     panelInfo.panelType = SOFT_KEYBOARD;
1854     panelInfo.panelFlag = FLG_FLOATING;
1855     InputMethodPanelTest::ImaCreatePanel(panelInfo, inputMethodPanel);
1856     auto ret = inputMethodPanel->SetTextFieldAvoidInfo(0, 0);
1857     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
1858     InputMethodPanelTest::ImaDestroyPanel(inputMethodPanel);
1859     InputMethodPanelTest::imc_->Close();
1860     TddUtil::DestroyWindow();
1861 }
1862 
1863 /**
1864  * @tc.name: testGetCallingWindowInfo01
1865  * @tc.desc: Test GetCallingWindowInfo.
1866  * @tc.type: FUNC
1867  */
1868 HWTEST_F(InputMethodPanelTest, testGetCallingWindowInfo01, TestSize.Level0)
1869 {
1870     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
1871     CallingWindowInfo windowInfo;
1872     auto ret = inputMethodPanel->GetCallingWindowInfo(windowInfo);
1873     EXPECT_EQ(ret, ErrorCode::ERROR_PANEL_NOT_FOUND);
1874 }
1875 
1876 /**
1877  * @tc.name: testGetCallingWindowInfo02
1878  * @tc.desc: Test GetCallingWindowInfo.
1879  * @tc.type: FUNC
1880  */
1881 HWTEST_F(InputMethodPanelTest, testGetCallingWindowInfo02, TestSize.Level0)
1882 {
1883     InputMethodPanelTest::Attach();
1884     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
1885     PanelInfo panelInfo;
1886     panelInfo.panelType = SOFT_KEYBOARD;
1887     panelInfo.panelFlag = FLG_FLOATING;
1888     InputMethodPanelTest::ImaCreatePanel(panelInfo, inputMethodPanel);
1889     CallingWindowInfo windowInfo;
1890     auto ret = inputMethodPanel->GetCallingWindowInfo(windowInfo);
1891     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
1892     InputMethodPanelTest::ImaDestroyPanel(inputMethodPanel);
1893     InputMethodPanelTest::imc_->Close();
1894     TddUtil::DestroyWindow();
1895 }
1896 
1897 /**
1898  * @tc.name: testSetUiContent01
1899  * @tc.desc: Test SetUiContent.
1900  * @tc.type: FUNC
1901  */
1902 HWTEST_F(InputMethodPanelTest, testSetUiContent01, TestSize.Level0)
1903 {
1904     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
1905     auto ret = inputMethodPanel->SetUiContent("text", nullptr, nullptr);
1906     EXPECT_EQ(ret, ErrorCode::ERROR_NULL_POINTER);
1907 }
1908 
1909 /**
1910  * @tc.name: testSetUiContent02
1911  * @tc.desc: Test SetUiContent.
1912  * @tc.type: FUNC
1913  */
1914 HWTEST_F(InputMethodPanelTest, testSetUiContent02, TestSize.Level0)
1915 {
1916     InputMethodPanelTest::Attach();
1917     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
1918     PanelInfo panelInfo;
1919     panelInfo.panelType = SOFT_KEYBOARD;
1920     panelInfo.panelFlag = FLG_FLOATING;
1921     InputMethodPanelTest::ImaCreatePanel(panelInfo, inputMethodPanel);
1922     auto ret = inputMethodPanel->SetUiContent("text", nullptr, nullptr);
1923     EXPECT_EQ(ret, ErrorCode::ERROR_PARAMETER_CHECK_FAILED);
1924     InputMethodPanelTest::ImaDestroyPanel(inputMethodPanel);
1925     InputMethodPanelTest::imc_->Close();
1926     TddUtil::DestroyWindow();
1927 }
1928 
1929 /**
1930  * @tc.name: testIsSizeValid
1931  * @tc.desc: Test IsSizeValid
1932  * @tc.type: FUNC
1933  */
1934 HWTEST_F(InputMethodPanelTest, testIsSizeValid, TestSize.Level0)
1935 {
1936     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
1937     EXPECT_FALSE(inputMethodPanel->IsSizeValid(INT32_MAX + 1, INT32_MAX));
1938     EXPECT_FALSE(inputMethodPanel->IsSizeValid(INT32_MAX, INT32_MAX + 1));
1939 }
1940 
1941 /**
1942  * @tc.name: testGenerateSequenceId
1943  * @tc.desc: Test GenerateSequenceId
1944  * @tc.type: FUNC
1945  */
1946 HWTEST_F(InputMethodPanelTest, testGenerateSequenceId, TestSize.Level0)
1947 {
1948     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
1949     inputMethodPanel->sequenceId_ = std::numeric_limits<uint32_t>::max() - 1;
1950     uint32_t seqId = inputMethodPanel->GenerateSequenceId();
1951     EXPECT_EQ(seqId, 0);
1952 }
1953 
1954 /**
1955  * @tc.name: testPanelStatusListener01
1956  * @tc.desc: Test SetPanelStatusListener
1957  * @tc.type: FUNC
1958  */
1959 HWTEST_F(InputMethodPanelTest, testPanelStatusListener01, TestSize.Level0)
1960 {
1961     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
1962     inputMethodPanel->panelStatusListener_ = nullptr;
1963     inputMethodPanel->ClearPanelListener("show");
1964 
1965     AccessScope scope(currentImeTokenId_, currentImeUid_);
1966     PanelInfo panelInfo;
1967     panelInfo.panelType = STATUS_BAR;
1968     panelInfo.panelFlag = FLG_FIXED;
1969     auto statusListener = std::make_shared<InputMethodPanelTest::PanelStatusListenerImpl>();
1970     auto ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
1971     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
1972     inputMethodPanel->panelStatusListener_ = statusListener;
1973     EXPECT_TRUE(inputMethodPanel->SetPanelStatusListener(statusListener, "sizeChange"));
1974     ret = inputMethodPanel->DestroyPanel();
1975     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
1976 }
1977 
1978 /**
1979  * @tc.name: testPanelStatusListener02
1980  * @tc.desc: Test SetPanelStatusListener
1981  * @tc.type: FUNC
1982  */
1983 HWTEST_F(InputMethodPanelTest, testPanelStatusListener02, TestSize.Level0)
1984 {
1985     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
1986     AccessScope scope(currentImeTokenId_, currentImeUid_);
1987     PanelInfo panelInfo;
1988     panelInfo.panelType = SOFT_KEYBOARD;
1989     panelInfo.panelFlag = FLG_FIXED;
1990     auto statusListener = std::make_shared<InputMethodPanelTest::PanelStatusListenerImpl>();
1991     auto ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
1992     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
1993     inputMethodPanel->panelStatusListener_ = statusListener;
1994     EXPECT_TRUE(inputMethodPanel->SetPanelStatusListener(statusListener, "sizeChange"));
1995     EXPECT_TRUE(inputMethodPanel->SetPanelStatusListener(nullptr, "sizeChange"));
1996     inputMethodPanel->panelStatusListener_ = nullptr;
1997     EXPECT_TRUE(inputMethodPanel->SetPanelStatusListener(nullptr, "sizeChange"));
1998     EXPECT_TRUE(inputMethodPanel->SetPanelStatusListener(statusListener, "sizeChange"));
1999     ret = inputMethodPanel->DestroyPanel();
2000     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
2001 }
2002 
2003 /**
2004  * @tc.name: testStartMoving01
2005  * @tc.desc: Test StartMoving
2006  * @tc.type: FUNC
2007  */
2008 HWTEST_F(InputMethodPanelTest, testStartMoving01, TestSize.Level0)
2009 {
2010     IMSA_HILOGI("InputMethodPanelTest::testStartMoving start.");
2011     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
2012     auto ret = inputMethodPanel->StartMoving();
2013     EXPECT_EQ(ret, ErrorCode::ERROR_IME);
2014 
2015     AccessScope scope(currentImeTokenId_, currentImeUid_);
2016     PanelInfo panelInfo;
2017     panelInfo.panelType = STATUS_BAR;
2018     panelInfo.panelFlag = FLG_FLOATING;
2019     ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
2020     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
2021     ret = inputMethodPanel->StartMoving();
2022     EXPECT_TRUE(ret == ErrorCode::NO_ERROR || ret == ErrorCode::ERROR_DEVICE_UNSUPPORTED);
2023     ret = inputMethodPanel->DestroyPanel();
2024     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
2025 
2026     panelInfo.panelType = SOFT_KEYBOARD;
2027     ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
2028     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
2029     ret = inputMethodPanel->StartMoving();
2030     EXPECT_TRUE(ret == ErrorCode::NO_ERROR || ret == ErrorCode::ERROR_DEVICE_UNSUPPORTED);
2031     ret = inputMethodPanel->DestroyPanel();
2032     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
2033 
2034     panelInfo.panelType = STATUS_BAR;
2035     panelInfo.panelFlag = FLG_FIXED;
2036     ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
2037     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
2038     ret = inputMethodPanel->StartMoving();
2039     EXPECT_TRUE(ret == ErrorCode::NO_ERROR || ret == ErrorCode::ERROR_DEVICE_UNSUPPORTED);
2040     ret = inputMethodPanel->DestroyPanel();
2041     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
2042 }
2043 
2044 /**
2045  * @tc.name: testStartMoving02
2046  * @tc.desc: Test StartMoving
2047  * @tc.type: FUNC
2048  */
2049 HWTEST_F(InputMethodPanelTest, testStartMoving02, TestSize.Level0)
2050 {
2051     IMSA_HILOGI("InputMethodPanelTest::testStartMoving start.");
2052     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
2053     auto ret = inputMethodPanel->StartMoving();
2054     EXPECT_EQ(ret, ErrorCode::ERROR_IME);
2055 
2056     AccessScope scope(currentImeTokenId_, currentImeUid_);
2057     PanelInfo panelInfo;
2058     panelInfo.panelType = STATUS_BAR;
2059     panelInfo.panelFlag = FLG_CANDIDATE_COLUMN;
2060     ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
2061     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
2062     ret = inputMethodPanel->StartMoving();
2063     EXPECT_TRUE(ret == ErrorCode::NO_ERROR || ret == ErrorCode::ERROR_DEVICE_UNSUPPORTED);
2064     ret = inputMethodPanel->DestroyPanel();
2065     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
2066 
2067     panelInfo.panelType = SOFT_KEYBOARD;
2068     ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
2069     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
2070     ret = inputMethodPanel->StartMoving();
2071     EXPECT_TRUE(ret == ErrorCode::NO_ERROR || ret == ErrorCode::ERROR_DEVICE_UNSUPPORTED);
2072     ret = inputMethodPanel->DestroyPanel();
2073     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
2074 
2075     panelInfo.panelFlag = FLG_FIXED;
2076     ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
2077     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
2078     ret = inputMethodPanel->StartMoving();
2079     EXPECT_EQ(ret, ErrorCode::ERROR_INVALID_PANEL_FLAG);
2080     ret = inputMethodPanel->DestroyPanel();
2081     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
2082 }
2083 
2084 /**
2085  * @tc.name: testGetDisplayId01
2086  * @tc.desc: Test GetDisplayId
2087  * @tc.type: FUNC
2088  */
2089 HWTEST_F(InputMethodPanelTest, testGetDisplayId01, TestSize.Level0)
2090 {
2091     IMSA_HILOGI("InputMethodPanelTest::testGetDisplayId start.");
2092     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
2093     uint64_t displayId;
2094     auto ret = inputMethodPanel->GetDisplayId(displayId);
2095     EXPECT_EQ(ret, ErrorCode::ERROR_IME);
2096 
2097     AccessScope scope(currentImeTokenId_, currentImeUid_);
2098     PanelInfo panelInfo;
2099     panelInfo.panelType = STATUS_BAR;
2100     panelInfo.panelFlag = FLG_FLOATING;
2101     ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
2102     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
2103 
2104     ret = inputMethodPanel->GetDisplayId(displayId);
2105     EXPECT_GE(ret, ErrorCode::NO_ERROR);
2106 
2107     ret = inputMethodPanel->DestroyPanel();
2108     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
2109 }
2110 
2111 /**
2112  * @tc.name: testSetImmersiveMode
2113  * @tc.desc: Test set immersive mode.
2114  * @tc.type: FUNC
2115  */
2116 HWTEST_F(InputMethodPanelTest, testSetImmersiveMode, TestSize.Level0)
2117 {
2118     IMSA_HILOGI("InputMethodPanelTest::testSetImmersiveMode start.");
2119     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
2120     PanelInfo panelInfo;
2121     panelInfo.panelType = SOFT_KEYBOARD;
2122     panelInfo.panelFlag = FLG_FIXED;
2123 
2124     AccessScope scope(currentImeTokenId_, currentImeUid_);
2125     auto ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
2126     EXPECT_EQ(ErrorCode::NO_ERROR, ret);
2127     ret = inputMethodPanel->ShowPanel();
2128     EXPECT_EQ(ErrorCode::NO_ERROR, ret);
2129 
2130     ret = inputMethodPanel->SetImmersiveMode(ImmersiveMode::NONE_IMMERSIVE);
2131     EXPECT_EQ(ErrorCode::NO_ERROR, ret);
2132     ret = inputMethodPanel->SetImmersiveMode(ImmersiveMode::LIGHT_IMMERSIVE);
2133     EXPECT_EQ(ErrorCode::NO_ERROR, ret);
2134     ret = inputMethodPanel->SetImmersiveMode(ImmersiveMode::DARK_IMMERSIVE);
2135     EXPECT_EQ(ErrorCode::NO_ERROR, ret);
2136     ret = inputMethodPanel->SetImmersiveMode(ImmersiveMode::IMMERSIVE);
2137     EXPECT_EQ(ErrorCode::ERROR_PARAMETER_CHECK_FAILED, ret);
2138 
2139     ret = inputMethodPanel->HidePanel();
2140     EXPECT_EQ(ErrorCode::NO_ERROR, ret);
2141     ret = inputMethodPanel->DestroyPanel();
2142     EXPECT_EQ(ErrorCode::NO_ERROR, ret);
2143 }
2144 
2145 /**
2146  * @tc.name: testGetImmersiveMode
2147  * @tc.desc: Test get immersive mode.
2148  * @tc.type: FUNC
2149  */
2150 HWTEST_F(InputMethodPanelTest, testGetImmersiveMode, TestSize.Level0)
2151 {
2152     IMSA_HILOGI("InputMethodPanelTest::testGetImmersiveMode start.");
2153     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
2154     PanelInfo panelInfo;
2155     panelInfo.panelType = SOFT_KEYBOARD;
2156     panelInfo.panelFlag = FLG_FIXED;
2157 
2158     AccessScope scope(currentImeTokenId_, currentImeUid_);
2159     auto ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
2160     EXPECT_EQ(ErrorCode::NO_ERROR, ret);
2161     ret = inputMethodPanel->ShowPanel();
2162     EXPECT_EQ(ErrorCode::NO_ERROR, ret);
2163 
2164     ret = inputMethodPanel->SetImmersiveMode(ImmersiveMode::NONE_IMMERSIVE);
2165     EXPECT_EQ(ErrorCode::NO_ERROR, ret);
2166     auto mode = inputMethodPanel->GetImmersiveMode();
2167     EXPECT_EQ(ImmersiveMode::NONE_IMMERSIVE, mode);
2168 
2169     ret = inputMethodPanel->HidePanel();
2170     EXPECT_EQ(ErrorCode::NO_ERROR, ret);
2171     ret = inputMethodPanel->DestroyPanel();
2172     EXPECT_EQ(ErrorCode::NO_ERROR, ret);
2173 }
2174 
2175 /**
2176  * @tc.name: testParameterValidationInterface
2177  * @tc.desc: Test Parameter validation interface
2178  * @tc.type: FUNC
2179  */
2180 HWTEST_F(InputMethodPanelTest, testParameterValidationInterface, TestSize.Level0)
2181 {
2182     IMSA_HILOGI("InputMethodPanelTest::testParameterValidationInterface start.");
2183     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
2184     PanelInfo panelInfo;
2185     panelInfo.panelType = SOFT_KEYBOARD;
2186     panelInfo.panelFlag = FLG_FIXED;
2187 
2188     AccessScope scope(currentImeTokenId_, currentImeUid_);
2189     auto ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
2190     EnhancedLayoutParams enhancedLayoutParams;
2191     FullPanelAdjustInfo adjustInfo;
2192     enhancedLayoutParams.portrait.avoidY = 10;
2193     enhancedLayoutParams.landscape.avoidY = 20;
2194     adjustInfo.portrait = {0, 0, 100, 100};
2195     adjustInfo.landscape = {0, 0, 200, 200};
2196     PanelAdjustInfo keyboardArea;
2197 
2198     ret = inputMethodPanel->GetKeyboardArea(PanelFlag::FLG_FIXED, {100, 200}, keyboardArea);
2199 
2200     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
2201     EXPECT_EQ(keyboardArea.top, inputMethodPanel->enhancedLayoutParams_.portrait.avoidY);
2202 
2203     uint32_t validWidth = 100;
2204     uint32_t validHeight = 200;
2205     ret = inputMethodPanel->ResizeWithoutAdjust(validWidth, validHeight);
2206     EXPECT_EQ(ErrorCode::NO_ERROR, ret);
2207 
2208     ret = inputMethodPanel->ResizeWithoutAdjust(INT32_MAX + 1, INT32_MAX + 1);
2209     EXPECT_EQ(ErrorCode::ERROR_BAD_PARAMETERS, ret);
2210 
2211     inputMethodPanel->panelType_ = PanelType::STATUS_BAR;
2212     ret = inputMethodPanel->IsEnhancedParamValid(PanelFlag::FLG_FIXED, enhancedLayoutParams);
2213     EXPECT_EQ(ErrorCode::ERROR_INVALID_PANEL_TYPE, ret);
2214 
2215     Rosen::Rect rect1{10, 20, 100, 200};
2216     WindowSize displaySize1 {800, 600};
2217     EXPECT_TRUE(inputMethodPanel->IsRectValid(rect1, displaySize1));
2218 
2219     Rosen::Rect rect2{-10, 20, 100, 200};
2220     WindowSize displaySize2{800, 600};
2221     EXPECT_FALSE(inputMethodPanel->IsRectValid(rect2, displaySize2));
2222 
2223     Rosen::Rect rect3{10, 20, INT32_MAX, 200};
2224     WindowSize displaySize3{800, 600};
2225     EXPECT_FALSE(inputMethodPanel->IsRectValid(rect3, displaySize3));
2226 
2227     Rosen::Rect rect4{10, 20, 9000, 20000};
2228     WindowSize displaySize4{800, 600};
2229     EXPECT_FALSE(inputMethodPanel->IsRectValid(rect4, displaySize4));
2230 
2231     inputMethodPanel->window_ = nullptr;
2232     ret= inputMethodPanel->IsEnhancedParamValid(PanelFlag::FLG_FIXED, enhancedLayoutParams);
2233     EXPECT_EQ(ErrorCode::ERROR_WINDOW_MANAGER, ret);
2234 
2235     ret = inputMethodPanel->DestroyPanel();
2236     EXPECT_EQ(ErrorCode::ERROR_NULL_POINTER, ret);
2237 }
2238 
2239 /**
2240   * @tc.name: testMoveEnhancedPanelRect
2241   * @tc.desc: Test Move Enhanced Panel Rect
2242   * @tc.type: FUNC
2243   */
2244 HWTEST_F(InputMethodPanelTest, testMoveEnhancedPanelRect, TestSize.Level0)
2245 {
2246     IMSA_HILOGI("InputMethodPanelTest::testMoveEnhancedPanelRect start.");
2247     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
2248     PanelInfo panelInfo;
2249     panelInfo.panelType = SOFT_KEYBOARD;
2250     panelInfo.panelFlag = FLG_FLOATING;
2251 
2252     AccessScope scope(currentImeTokenId_, currentImeUid_);
2253     auto ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
2254     EXPECT_EQ(ErrorCode::NO_ERROR, ret);
2255 
2256     int32_t portraitX = 10;
2257     int32_t portraitY = 20;
2258     int32_t portraitRet = inputMethodPanel->MoveEnhancedPanelRect(portraitX, portraitY);
2259     EXPECT_EQ(ErrorCode::NO_ERROR, portraitRet);
2260 
2261     int32_t landscapeX = 30;
2262     int32_t landscapeY = 40;
2263     int32_t landscapeRet = inputMethodPanel->MoveEnhancedPanelRect(landscapeX, landscapeY);
2264     EXPECT_EQ(ErrorCode::NO_ERROR, landscapeRet);
2265 
2266     int32_t minX = -100;
2267     int32_t minY = -200;
2268     int32_t minRet = inputMethodPanel->MoveEnhancedPanelRect(minX, minY);
2269     EXPECT_EQ(ErrorCode::ERROR_PARAMETER_CHECK_FAILED, minRet);
2270 
2271     const std::string type = "sizeUpdate";
2272     EXPECT_TRUE(inputMethodPanel->MarkListener(type, false));
2273 
2274     uint32_t windowWidth = 100;
2275     bool isPortrait = false;
2276     ret = inputMethodPanel->GetWindowOrientation(PanelFlag::FLG_FIXED, windowWidth, isPortrait);
2277     EXPECT_EQ(ErrorCode::NO_ERROR, ret);
2278 
2279     ret = inputMethodPanel->SetImmersiveMode(ImmersiveMode::NONE_IMMERSIVE);
2280     EXPECT_EQ(ErrorCode::NO_ERROR, ret);
2281     inputMethodPanel->window_ = nullptr;
2282     ret = inputMethodPanel->SetImmersiveMode(ImmersiveMode::NONE_IMMERSIVE);
2283     EXPECT_EQ(ErrorCode::NO_ERROR, ret);
2284 
2285     ret = inputMethodPanel->DestroyPanel();
2286     EXPECT_EQ(ErrorCode::ERROR_NULL_POINTER, ret);
2287 }
2288 
2289 /**
2290  * @tc.name: testSetImmersiveEffect
2291  * @tc.desc: Test SetImmersiveEffect device not supported.
2292  * @tc.type: FUNC
2293  */
2294 HWTEST_F(InputMethodPanelTest, testSetImmersiveEffect, TestSize.Level0)
2295 {
2296     IMSA_HILOGI("InputMethodPanelAdjustTest testSetImmersiveEffect Test START");
2297     auto supportedCapacityList = ImeInfoInquirer::GetInstance().GetSystemConfig().supportedCapacityList;
2298     supportedCapacityList.erase(IMMERSIVE_EFFECT);
2299     ImeInfoInquirer::GetInstance().systemConfig_.supportedCapacityList = supportedCapacityList;
2300 
2301     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
2302     PanelInfo panelInfo;
2303     panelInfo.panelType = SOFT_KEYBOARD;
2304     InputMethodPanelTest::ImaCreatePanel(panelInfo, inputMethodPanel);
2305 
2306     ImmersiveEffect immersiveEffect = {
2307         .gradientHeight = 20, .gradientMode = GradientMode::LINEAR_GRADIENT, .fluidLightMode = FluidLightMode::NONE
2308     };
2309     int32_t ret = inputMethodPanel->SetImmersiveEffect(immersiveEffect);
2310     EXPECT_EQ(ret, ErrorCode::ERROR_DEVICE_UNSUPPORTED);
2311     InputMethodPanelTest::ImaDestroyPanel(inputMethodPanel);
2312 }
2313 
2314 /**
2315  * @tc.name: testSetKeepScreenOn1
2316  * @tc.desc: Test SetKeepScreenOn.
2317  * @tc.type: FUNC
2318  */
2319 HWTEST_F(InputMethodPanelTest, testSetKeepScreenOn1, TestSize.Level0)
2320 {
2321     IMSA_HILOGI("InputMethodPanelTest::testSetKeepScreenOn1 start.");
2322 
2323     auto inputMethodPanel = InputMethodPanelTest::CreatePanel();
2324     ASSERT_NE(inputMethodPanel, nullptr);
2325     InputMethodPanelTest::DestroyPanel(inputMethodPanel);
2326     inputMethodPanel->window_ = nullptr;
2327     bool isKeepScreenOn = false;
2328     auto ret = inputMethodPanel->SetKeepScreenOn(isKeepScreenOn);
2329     EXPECT_EQ(ret, ErrorCode::ERROR_WINDOW_MANAGER);
2330 }
2331 
2332 /**
2333  * @tc.name: testSetKeepScreenOn2
2334  * @tc.desc: Test SetKeepScreenOn.
2335  * @tc.type: FUNC
2336  */
2337 HWTEST_F(InputMethodPanelTest, testSetKeepScreenOn2, TestSize.Level0)
2338 {
2339     IMSA_HILOGI("InputMethodPanelTest::testSetKeepScreenOn2 start.");
2340 
2341     auto inputMethodPanel = InputMethodPanelTest::CreatePanel();
2342     ASSERT_NE(inputMethodPanel, nullptr);
2343     bool isKeepScreenOn = true;
2344     auto ret = inputMethodPanel->SetKeepScreenOn(isKeepScreenOn);
2345     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
2346     InputMethodPanelTest::DestroyPanel(inputMethodPanel);
2347 }
2348 
2349 /**
2350  * @tc.name: testInvalidParams
2351  * @tc.desc: Test testInvalidParams
2352  * @tc.type: FUNC
2353  */
2354 HWTEST_F(InputMethodPanelTest, testInvalidParams, TestSize.Level0)
2355 {
2356     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
2357     inputMethodPanel->immersiveEffect_.gradientHeight = GRADIENT_HEIGHT; // Configure gradient
2358     KeyboardLayoutParams param;
2359     param.portraitAvoidHeight_ = -1; // Set invalid negative value
2360     auto ret = inputMethodPanel->FullScreenPrepare(param, inputMethodPanel->immersiveEffect_);
2361     EXPECT_EQ(ret, ErrorCode::ERROR_INVALID_RANGE);
2362 
2363     param.portraitAvoidHeight_ = PORTRAIT_AVOID_HEIGHT;
2364     param.landscapeAvoidHeight_ = -1; // Set invalid negative value
2365     ret = inputMethodPanel->FullScreenPrepare(param, inputMethodPanel->immersiveEffect_);
2366     EXPECT_EQ(ret, ErrorCode::ERROR_INVALID_RANGE);
2367 
2368     param.landscapeAvoidHeight_ = LANDSCAPE_AVOID_HEIGHT;
2369     param.PortraitPanelRect_.posY_ = -1; // Set invalid negative value
2370     ret = inputMethodPanel->FullScreenPrepare(param, inputMethodPanel->immersiveEffect_);
2371     EXPECT_EQ(ret, ErrorCode::ERROR_INVALID_RANGE);
2372 
2373     param.PortraitPanelRect_.posY_ = VALID_POS_Y;
2374     param.LandscapePanelRect_.posY_ = -1; // Set invalid negative value
2375     ret = inputMethodPanel->FullScreenPrepare(param, inputMethodPanel->immersiveEffect_);
2376     EXPECT_EQ(ret, ErrorCode::ERROR_INVALID_RANGE);
2377 }
2378 
2379 /**
2380  * @tc.name: testPortraitAdjustmentNeeded
2381  * @tc.desc: Test testPortraitAdjustmentNeeded
2382  * @tc.type: FUNC
2383  */
2384 HWTEST_F(InputMethodPanelTest, testPortraitAdjustmentNeeded, TestSize.Level0)
2385 {
2386     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
2387     inputMethodPanel->immersiveEffect_.gradientHeight = GRADIENT_HEIGHT; // Configure gradient
2388     KeyboardLayoutParams param;
2389     // Configure valid parameters
2390     param.portraitAvoidHeight_ = PORTRAIT_AVOID_HEIGHT;
2391     param.landscapeAvoidHeight_ = LANDSCAPE_AVOID_HEIGHT;
2392     param.PortraitPanelRect_.height_ = INITIAL_PORTRAIT_HEIGHT; // 25 < 20+10=30 → needs adjustment
2393     param.PortraitPanelRect_.posY_ = INITIAL_PORTRAIT_POS_Y;
2394 
2395     auto ret = inputMethodPanel->FullScreenPrepare(param, inputMethodPanel->immersiveEffect_);
2396     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
2397 
2398     // Calculate expected values
2399     const uint32_t expectedHeight = PORTRAIT_AVOID_HEIGHT + GRADIENT_HEIGHT;
2400     const uint32_t expectedChangeY = expectedHeight - INITIAL_PORTRAIT_HEIGHT;
2401     const int32_t expectedPosY = INITIAL_PORTRAIT_POS_Y - static_cast<int32_t>(expectedChangeY);
2402 
2403     EXPECT_EQ(inputMethodPanel->changeY_.portrait, expectedChangeY);
2404     EXPECT_EQ(param.PortraitPanelRect_.height_, expectedHeight);
2405     EXPECT_EQ(param.PortraitPanelRect_.posY_, expectedPosY);
2406 }
2407 
2408 /**
2409  * @tc.name: testLargegradientHeight
2410  * @tc.desc: Test testLargegradientHeight
2411  * @tc.type: FUNC
2412  */
2413 HWTEST_F(InputMethodPanelTest, testLargegradientHeight, TestSize.Level1)
2414 {
2415     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
2416     KeyboardLayoutParams param;
2417     // Configure valid parameters
2418     param.portraitAvoidHeight_ = PORTRAIT_AVOID_HEIGHT;
2419     param.landscapeAvoidHeight_ = LANDSCAPE_AVOID_HEIGHT;
2420     param.PortraitPanelRect_.height_ = INITIAL_PORTRAIT_HEIGHT;
2421     param.PortraitPanelRect_.posY_ = INITIAL_PORTRAIT_POS_Y;
2422 
2423     inputMethodPanel->immersiveEffect_.gradientHeight = static_cast<uint32_t>(INT32_MAX);
2424     auto ret = inputMethodPanel->FullScreenPrepare(param, inputMethodPanel->immersiveEffect_);
2425     EXPECT_EQ(ret, ErrorCode::ERROR_INVALID_RANGE);
2426 
2427     inputMethodPanel->immersiveEffect_.gradientHeight = static_cast<uint32_t>(INT32_MAX - LANDSCAPE_AVOID_HEIGHT - 1);
2428     ret = inputMethodPanel->FullScreenPrepare(param, inputMethodPanel->immersiveEffect_);
2429     EXPECT_EQ(ret, ErrorCode::ERROR_INVALID_RANGE);
2430 }
2431 
2432 /**
2433  * @tc.name: testLandscapeAdjustmentNeeded
2434  * @tc.desc: Test testLandscapeAdjustmentNeeded
2435  * @tc.type: FUNC
2436  */
2437 HWTEST_F(InputMethodPanelTest, testLandscapeAdjustmentNeeded, TestSize.Level0)
2438 {
2439     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
2440     inputMethodPanel->immersiveEffect_.gradientHeight = GRADIENT_HEIGHT; // Configure gradient
2441     KeyboardLayoutParams param;
2442     param.portraitAvoidHeight_ = PORTRAIT_AVOID_HEIGHT;
2443     param.landscapeAvoidHeight_ = LANDSCAPE_AVOID_HEIGHT;
2444     param.LandscapePanelRect_.height_ = INITIAL_LANDSCAPE_HEIGHT; // 20 < 15+10=25 → needs adjustment
2445     param.LandscapePanelRect_.posY_ = INITIAL_LANDSCAPE_POS_Y;
2446 
2447     auto ret = inputMethodPanel->FullScreenPrepare(param, inputMethodPanel->immersiveEffect_);
2448     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
2449 
2450     // Calculate expected values
2451     const uint32_t expectedHeight = LANDSCAPE_AVOID_HEIGHT + GRADIENT_HEIGHT;
2452     const uint32_t expectedChangeY = expectedHeight - INITIAL_LANDSCAPE_HEIGHT;
2453     const int32_t expectedPosY = INITIAL_LANDSCAPE_POS_Y - static_cast<int32_t>(expectedChangeY);
2454 
2455     EXPECT_EQ(inputMethodPanel->changeY_.landscape, expectedChangeY);
2456     EXPECT_EQ(param.LandscapePanelRect_.height_, expectedHeight);
2457     EXPECT_EQ(param.LandscapePanelRect_.posY_, expectedPosY);
2458 }
2459 
2460 /**
2461  * @tc.name: ShouldRejectNegativePortraitPosition
2462  * @tc.desc: Test ShouldRejectNegativePortraitPosition
2463  * @tc.type: FUNC
2464  */
2465 HWTEST_F(InputMethodPanelTest, ShouldRejectNegativePortraitPosition, TestSize.Level0)
2466 {
2467     // Create fresh test instance
2468     auto panel = std::make_shared<InputMethodPanel>();
2469     Rosen::KeyboardLayoutParams param;
2470 
2471     // Configure test parameters
2472     panel->immersiveEffect_.gradientHeight = GRADIENT_HEIGHT;
2473     param.PortraitPanelRect_ = { 0, INVALID_POS_Y, DEFAULT_WIDTH, DEFAULT_HEIGHT };
2474     param.LandscapePanelRect_ = { 0, VALID_POS_Y, LANDSCAPE_WIDTH, LANDSCAPE_HEIGHT };
2475 
2476     // Verify error handling
2477     ASSERT_EQ(panel->NormalImePrepare(param, panel->immersiveEffect_), ErrorCode::ERROR_INVALID_RANGE);
2478 }
2479 
2480 /**
2481  * @tc.name: ShouldRejectNegativeLandscapePosition
2482  * @tc.desc: Test ShouldRejectNegativeLandscapePosition
2483  * @tc.type: FUNC
2484  */
2485 HWTEST_F(InputMethodPanelTest, ShouldRejectNegativeLandscapePosition, TestSize.Level0)
2486 {
2487     auto panel = std::make_shared<InputMethodPanel>();
2488     Rosen::KeyboardLayoutParams param;
2489 
2490     panel->immersiveEffect_.gradientHeight = GRADIENT_HEIGHT;
2491     param.PortraitPanelRect_ = { 0, VALID_POS_Y, DEFAULT_WIDTH, DEFAULT_HEIGHT };
2492     param.LandscapePanelRect_ = { 0, INVALID_POS_Y, LANDSCAPE_WIDTH, LANDSCAPE_HEIGHT };
2493 
2494     ASSERT_EQ(panel->NormalImePrepare(param, panel->immersiveEffect_), ErrorCode::ERROR_INVALID_RANGE);
2495 }
2496 
2497 /**
2498  * @tc.name: ShouldAdjustValidParametersCorrectly
2499  * @tc.desc: Test ShouldAdjustValidParametersCorrectly
2500  * @tc.type: FUNC
2501  */
2502 HWTEST_F(InputMethodPanelTest, ShouldAdjustValidParametersCorrectly, TestSize.Level0)
2503 {
2504     auto panel = std::make_shared<InputMethodPanel>();
2505     Rosen::KeyboardLayoutParams param;
2506 
2507     const int originalPortraitHeight = DEFAULT_HEIGHT;
2508     const int originalLandscapeHeight = LANDSCAPE_HEIGHT;
2509     panel->immersiveEffect_.gradientHeight = GRADIENT_HEIGHT;
2510 
2511     param.PortraitPanelRect_ = { 0, VALID_POS_Y, DEFAULT_WIDTH, originalPortraitHeight };
2512     param.LandscapePanelRect_ = { 0, VALID_POS_Y, LANDSCAPE_WIDTH, originalLandscapeHeight };
2513 
2514     // Execute operation
2515     ASSERT_EQ(panel->NormalImePrepare(param, panel->immersiveEffect_), ErrorCode::NO_ERROR);
2516 
2517     // Verify height adjustments
2518     EXPECT_EQ(param.PortraitPanelRect_.height_, originalPortraitHeight + GRADIENT_HEIGHT);
2519     EXPECT_EQ(param.LandscapePanelRect_.height_, originalLandscapeHeight + GRADIENT_HEIGHT);
2520 
2521     // Verify position adjustments
2522     EXPECT_EQ(param.PortraitPanelRect_.posY_, 0);
2523     EXPECT_EQ(param.LandscapePanelRect_.posY_, 0);
2524 
2525     // Verify member variables
2526     EXPECT_EQ(panel->changeY_.portrait, GRADIENT_HEIGHT);
2527     EXPECT_EQ(panel->changeY_.landscape, GRADIENT_HEIGHT);
2528 }
2529 
2530 /**
2531  * @tc.name: SetNoneWhenHeightZero
2532  * @tc.desc: Tests behavior when gradientHeight is already 0
2533  * @tc.type: FUNC
2534  */
2535 HWTEST_F(InputMethodPanelTest, SetNoneWhenHeightZero, TestSize.Level0)
2536 {
2537     auto panel = std::make_shared<InputMethodPanel>();
2538     // Setup initial state
2539     panel->immersiveEffect_.gradientHeight = 0;
2540     panel->immersiveEffect_.gradientMode = GradientMode::LINEAR_GRADIENT;
2541     panel->immersiveEffect_.fluidLightMode = FluidLightMode::BACKGROUND_FLUID_LIGHT;
2542 
2543     // Execute target function
2544     panel->SetImmersiveEffectToNone();
2545 
2546     // Verify effect configuration
2547     EXPECT_EQ(panel->immersiveEffect_.gradientMode, GradientMode::NONE);
2548     EXPECT_EQ(panel->immersiveEffect_.fluidLightMode, FluidLightMode::NONE);
2549     EXPECT_EQ(panel->immersiveEffect_.gradientHeight, 0);
2550 }
2551 
2552 /**
2553  * @tc.name: ReturnWhenLayoutNotInitialized
2554  * @tc.desc: Tests return when keyboard layout is uninitialized
2555  * @tc.type: FUNC
2556  */
2557 HWTEST_F(InputMethodPanelTest, ReturnWhenLayoutNotInitialized, TestSize.Level0)
2558 {
2559     auto panel = std::make_shared<InputMethodPanel>();
2560     // Set non-zero gradient height
2561     panel->immersiveEffect_.gradientHeight = GRADIENT_HEIGHT;
2562 
2563     // Set empty keyboard layout params
2564     Rosen::KeyboardLayoutParams emptyParams;
2565     panel->keyboardLayoutParams_ = emptyParams;
2566 
2567     panel->SetImmersiveEffectToNone();
2568     EXPECT_EQ(panel->immersiveEffect_.gradientHeight, GRADIENT_HEIGHT);
2569 }
2570 
2571 /**
2572  * @tc.name: RestoreConfigWhenAdjustFails
2573  * @tc.desc: Tests configuration restoration when layout adjustment fails
2574  * @tc.type: FUNC
2575  */
2576 HWTEST_F(InputMethodPanelTest, RestoreConfigWhenAdjustFails, TestSize.Level1)
2577 {
2578     auto panel = std::make_shared<InputMethodPanel>();
2579     // Set initial state
2580     panel->immersiveEffect_.gradientHeight = GRADIENT_HEIGHT;
2581     panel->immersiveEffect_.gradientMode = GradientMode::LINEAR_GRADIENT;
2582 
2583     // Set valid layout parameters
2584     Rosen::KeyboardLayoutParams validParams;
2585     validParams.landscapeAvoidHeight_ = LANDSCAPE_AVOID_HEIGHT;
2586     panel->keyboardLayoutParams_ = validParams;
2587 
2588     panel->SetImmersiveEffectToNone();
2589 
2590     // Verify configuration restoration
2591     EXPECT_EQ(panel->immersiveEffect_.gradientHeight, GRADIENT_HEIGHT);
2592     EXPECT_EQ(panel->immersiveEffect_.gradientMode, GradientMode::LINEAR_GRADIENT);
2593 }
2594 
2595 /**
2596  * @tc.name: TestInitAdjustInfo
2597  * @tc.desc: Test InitAdjustInfo
2598  * @tc.type: FUNC
2599  */
2600 HWTEST_F(InputMethodPanelTest, TestInitAdjustInfo, TestSize.Level0)
2601 {
2602     IMSA_HILOGI("InputMethodPanelTest::TestInitAdjustInfo.");
2603     auto panel = std::make_shared<InputMethodPanel>();
2604     InputMethodAbility::GetInstance().inputAttribute_.callingDisplayId = 0;
2605     panel->isAdjustInfoInitialized_ = false;
2606     panel->adjustInfoDisplayId_ = 0;
2607     panel->panelAdjust_.clear();
2608     auto ret = panel->InitAdjustInfo();
2609     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
2610     panel->isAdjustInfoInitialized_ = true;
2611     panel->adjustInfoDisplayId_ = 1000;
2612     panel->panelAdjust_.clear();
2613     ret = panel->InitAdjustInfo();
2614     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
2615     panel->isAdjustInfoInitialized_ = true;
2616     panel->adjustInfoDisplayId_ = 0;
2617     panel->panelAdjust_.clear();
2618     ret = panel->InitAdjustInfo();
2619     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
2620 }
2621 } // namespace MiscServices
2622 } // namespace OHOS