• 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 "input_method_ability.h"
20 #include "input_method_ability_utils.h"
21 #include "input_method_controller.h"
22 #include "input_method_system_ability.h"
23 #undef private
24 
25 #include <gtest/gtest.h>
26 #include <sys/time.h>
27 #include <unistd.h>
28 
29 #include <condition_variable>
30 #include <cstdint>
31 #include <string>
32 
33 #include "common_event_data.h"
34 #include "common_event_manager.h"
35 #include "common_event_subscribe_info.h"
36 #include "common_event_subscriber.h"
37 #include "common_event_support.h"
38 #include "display_manager.h"
39 #include "global.h"
40 #include "identity_checker_mock.h"
41 #include "ime_event_monitor_manager.h"
42 #include "input_method_ability.h"
43 #include "input_method_controller.h"
44 #include "input_method_engine_listener_impl.h"
45 #include "matching_skills.h"
46 #include "panel_status_listener.h"
47 #include "scene_board_judgement.h"
48 #include "scope_utils.h"
49 #include "tdd_util.h"
50 #include "text_listener.h"
51 
52 using namespace testing::ext;
53 namespace OHOS {
54 namespace MiscServices {
55 constexpr uint32_t IMC_WAIT_PANEL_STATUS_LISTEN_TIME = 500;
56 constexpr float FIXED_SOFT_KEYBOARD_PANEL_RATIO = 0.7;
57 constexpr float NON_FIXED_SOFT_KEYBOARD_PANEL_RATIO = 1;
58 constexpr const char *COMMON_EVENT_INPUT_PANEL_STATUS_CHANGED = "usual.event.imf.input_panel_status_changed";
59 constexpr const char *COMMON_EVENT_PARAM_PANEL_STATE = "panelState";
60 enum ListeningStatus : uint32_t { ON, OFF, NONE };
61 class InputMethodPanelTest : public testing::Test {
62 public:
63     static void SetUpTestCase(void);
64     static void TearDownTestCase(void);
65     void SetUp();
66     void TearDown();
67     static std::shared_ptr<InputMethodPanel> CreatePanel();
68     static void DestroyPanel(const std::shared_ptr<InputMethodPanel> &panel);
69     static void Attach();
70     static bool TriggerShowCallback(std::shared_ptr<InputMethodPanel> &inputMethodPanel);
71     static bool TriggerHideCallback(std::shared_ptr<InputMethodPanel> &inputMethodPanel);
72     static void ImaCreatePanel(const PanelInfo &info, std::shared_ptr<InputMethodPanel> &panel);
73     static void ImaDestroyPanel(const std::shared_ptr<InputMethodPanel> &panel);
74     static void ImcPanelListeningTestRestore();
75     static void ImcPanelShowNumCheck(uint32_t num);
76     static void ImcPanelHideNumCheck(uint32_t num);
77     static void ImcPanelShowInfoCheck(const InputWindowInfo &windowInfo);
78     static void ImcPanelHideInfoCheck(const InputWindowInfo &windowInfo);
79     static void TestShowPanel(const std::shared_ptr<InputMethodPanel> &panel);
80     static void TestHidePanel(const std::shared_ptr<InputMethodPanel> &panel);
81     static void TestIsPanelShown(const PanelInfo &info, bool expectedResult);
82     static void TriggerPanelStatusChangeToImc(const std::shared_ptr<InputMethodPanel> &panel, InputWindowStatus status);
83     class PanelStatusListenerImpl : public PanelStatusListener {
84     public:
PanelStatusListenerImpl()85         PanelStatusListenerImpl()
86         {
87             std::shared_ptr<AppExecFwk::EventRunner> runner = AppExecFwk::EventRunner::Create("InputMethodPanelTest");
88             panelHandler_ = std::make_shared<AppExecFwk::EventHandler>(runner);
89         }
90         ~PanelStatusListenerImpl() = default;
OnPanelStatus(uint32_t windowId,bool isShow)91         void OnPanelStatus(uint32_t windowId, bool isShow)
92         {
93             {
94                 std::unique_lock<std::mutex> lock(InputMethodPanelTest::panelListenerLock_);
95                 if (isShow) {
96                     InputMethodPanelTest::status_ = InputWindowStatus::SHOW;
97                 } else {
98                     InputMethodPanelTest::status_ = InputWindowStatus::HIDE;
99                 }
100             }
101             InputMethodPanelTest::panelListenerCv_.notify_one();
102             IMSA_HILOGI("PanelStatusListenerImpl OnPanelStatus in, isShow is %{public}s", isShow ? "true" : "false");
103         }
OnSizeChange(uint32_t windowId,const WindowSize & size)104         void OnSizeChange(uint32_t windowId, const WindowSize &size) {}
OnSizeChange(uint32_t windowId,const WindowSize & size,const PanelAdjustInfo & keyboardArea,const std::string & event)105         void OnSizeChange(
106             uint32_t windowId, const WindowSize &size, const PanelAdjustInfo &keyboardArea, const std::string &event)
107         {
108         }
109     };
110     static std::mutex imcPanelStatusListenerLock_;
111     static std::condition_variable imcPanelStatusListenerCv_;
112     static InputWindowStatus status_;
113     static InputWindowInfo windowInfo_;
114     static uint32_t imeShowCallbackNum_;
115     static uint32_t imeHideCallbackNum_;
116 
117     static sptr<InputMethodController> imc_;
118     static sptr<InputMethodAbility> ima_;
119     static sptr<InputMethodSystemAbility> imsa_;
120     static uint32_t windowWidth_;
121     static uint32_t windowHeight_;
122     static std::condition_variable panelListenerCv_;
123     static std::mutex panelListenerLock_;
124     static constexpr uint32_t DELAY_TIME = 100;
125     static constexpr int32_t INTERVAL = 10;
126     static std::shared_ptr<AppExecFwk::EventHandler> panelHandler_;
127     static int32_t currentImeUid_;
128     static uint64_t currentImeTokenId_;
129     static sptr<OnTextChangedListener> textListener_;
130     static std::shared_ptr<InputMethodEngineListener> imeListener_;
131     static bool isScbEnable_;
132 };
133 class InputMethodSettingListenerImpl : public ImeEventListener {
134 public:
135     InputMethodSettingListenerImpl() = default;
136     ~InputMethodSettingListenerImpl() = default;
OnImeShow(const ImeWindowInfo & info)137     void OnImeShow(const ImeWindowInfo &info) override
138     {
139         IMSA_HILOGI("InputMethodPanelTest::OnImeShow");
140         std::unique_lock<std::mutex> lock(InputMethodPanelTest::imcPanelStatusListenerLock_);
141         InputMethodPanelTest::status_ = InputWindowStatus::SHOW;
142         InputMethodPanelTest::windowInfo_ = info.windowInfo;
143         InputMethodPanelTest::imeShowCallbackNum_++;
144         InputMethodPanelTest::imcPanelStatusListenerCv_.notify_one();
145     }
OnImeHide(const ImeWindowInfo & info)146     void OnImeHide(const ImeWindowInfo &info) override
147     {
148         IMSA_HILOGI("InputMethodPanelTest::OnImeHide");
149         std::unique_lock<std::mutex> lock(InputMethodPanelTest::imcPanelStatusListenerLock_);
150         InputMethodPanelTest::status_ = InputWindowStatus::HIDE;
151         InputMethodPanelTest::windowInfo_ = info.windowInfo;
152         InputMethodPanelTest::imeHideCallbackNum_++;
153         InputMethodPanelTest::imcPanelStatusListenerCv_.notify_one();
154     }
155 };
156 
157 class TestEventSubscriber : public EventFwk::CommonEventSubscriber {
158 public:
TestEventSubscriber(const EventFwk::CommonEventSubscribeInfo & subscribeInfo)159     explicit TestEventSubscriber(const EventFwk::CommonEventSubscribeInfo &subscribeInfo)
160         : EventFwk::CommonEventSubscriber(subscribeInfo)
161     {
162     }
OnReceiveEvent(const EventFwk::CommonEventData & data)163     void OnReceiveEvent(const EventFwk::CommonEventData &data)
164     {
165         std::unique_lock<std::mutex> lock(InputMethodPanelTest::imcPanelStatusListenerLock_);
166         auto const &want = data.GetWant();
167         action_ = want.GetAction();
168         bool visible = want.GetBoolParam(COMMON_EVENT_PARAM_PANEL_STATE, false);
169         status_ = visible ? InputWindowStatus::SHOW : InputWindowStatus::HIDE;
170         InputMethodPanelTest::imcPanelStatusListenerCv_.notify_one();
171     }
ResetParam()172     void ResetParam()
173     {
174         action_ = "";
175         status_ = InputWindowStatus::NONE;
176     }
177     std::string action_;
178     InputWindowStatus status_{ InputWindowStatus::NONE };
179 };
180 
181 std::condition_variable InputMethodPanelTest::panelListenerCv_;
182 std::mutex InputMethodPanelTest::panelListenerLock_;
183 std::shared_ptr<AppExecFwk::EventHandler> InputMethodPanelTest::panelHandler_{ nullptr };
184 std::condition_variable InputMethodPanelTest::imcPanelStatusListenerCv_;
185 std::mutex InputMethodPanelTest::imcPanelStatusListenerLock_;
186 InputWindowStatus InputMethodPanelTest::status_{ InputWindowStatus::NONE };
187 InputWindowInfo InputMethodPanelTest::windowInfo_;
188 uint32_t InputMethodPanelTest::imeShowCallbackNum_{ 0 };
189 uint32_t InputMethodPanelTest::imeHideCallbackNum_{ 0 };
190 sptr<InputMethodController> InputMethodPanelTest::imc_{ nullptr };
191 sptr<InputMethodAbility> InputMethodPanelTest::ima_{ nullptr };
192 sptr<InputMethodSystemAbility> InputMethodPanelTest::imsa_{ nullptr };
193 uint32_t InputMethodPanelTest::windowWidth_ = 0;
194 uint32_t InputMethodPanelTest::windowHeight_ = 0;
195 uint64_t InputMethodPanelTest::currentImeTokenId_ = 0;
196 int32_t InputMethodPanelTest::currentImeUid_ = 0;
197 sptr<OnTextChangedListener> InputMethodPanelTest::textListener_{ nullptr };
198 std::shared_ptr<InputMethodEngineListener> InputMethodPanelTest::imeListener_{ nullptr };
199 bool InputMethodPanelTest::isScbEnable_{ false };
SetUpTestCase(void)200 void InputMethodPanelTest::SetUpTestCase(void)
201 {
202     IMSA_HILOGI("InputMethodPanelTest::SetUpTestCase");
203     IdentityCheckerMock::ResetParam();
204     isScbEnable_ = Rosen::SceneBoardJudgement::IsSceneBoardEnabled();
205     // storage current token id
206     TddUtil::StorageSelfTokenID();
207 
208     auto listener = std::make_shared<InputMethodSettingListenerImpl>();
209     imc_ = InputMethodController::GetInstance();
210     textListener_ = new (std::nothrow) TextListener();
211     imeListener_ = std::make_shared<InputMethodEngineListenerImpl>();
212     // set token as current input method
213     std::shared_ptr<Property> property = InputMethodController::GetInstance()->GetCurrentInputMethod();
214     std::string bundleName = property != nullptr ? property->name : "default.inputmethod.unittest";
215     currentImeTokenId_ = TddUtil::GetTestTokenID(bundleName);
216     currentImeUid_ = TddUtil::GetUid(bundleName);
217 
218     imsa_ = new (std::nothrow) InputMethodSystemAbility();
219     if (imsa_ == nullptr) {
220         return;
221     }
222     imsa_->OnStart();
223     imsa_->userId_ = TddUtil::GetCurrentUserId();
224     imsa_->identityChecker_ = std::make_shared<IdentityCheckerMock>();
225 
226     imc_->abilityManager_ = imsa_;
227 
228     ima_ = InputMethodAbility::GetInstance();
229     ima_->abilityManager_ = imsa_;
230     TddUtil::InitCurrentImePermissionInfo();
231     IdentityCheckerMock::SetBundleName(TddUtil::currentBundleNameMock_);
232     ima_->SetCoreAndAgent();
233     InputMethodPanelTest::ima_->SetImeListener(imeListener_);
234 
235     ImaUtils::abilityManager_ = imsa_;
236 }
237 
TearDownTestCase(void)238 void InputMethodPanelTest::TearDownTestCase(void)
239 {
240     IMSA_HILOGI("InputMethodPanelTest::TearDownTestCase");
241     TddUtil::RestoreSelfTokenID();
242     IdentityCheckerMock::ResetParam();
243     imsa_->OnStop();
244     ImaUtils::abilityManager_ = nullptr;
245 }
246 
SetUp(void)247 void InputMethodPanelTest::SetUp(void)
248 {
249     IMSA_HILOGI("InputMethodPanelTest::SetUp");
250 }
251 
TearDown(void)252 void InputMethodPanelTest::TearDown(void)
253 {
254     TddUtil::RestoreSelfTokenID();
255     IMSA_HILOGI("InputMethodPanelTest::TearDown");
256 }
257 
CreatePanel()258 std::shared_ptr<InputMethodPanel> InputMethodPanelTest::CreatePanel()
259 {
260     AccessScope scope(currentImeTokenId_, currentImeUid_);
261     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
262     PanelInfo panelInfo = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FIXED };
263     auto ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
264     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
265     return inputMethodPanel;
266 }
267 
DestroyPanel(const std::shared_ptr<InputMethodPanel> & panel)268 void InputMethodPanelTest::DestroyPanel(const std::shared_ptr<InputMethodPanel> &panel)
269 {
270     ASSERT_NE(panel, nullptr);
271     AccessScope scope(currentImeTokenId_, currentImeUid_);
272     auto ret = panel->DestroyPanel();
273     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
274 }
275 
ImaCreatePanel(const PanelInfo & info,std::shared_ptr<InputMethodPanel> & panel)276 void InputMethodPanelTest::ImaCreatePanel(const PanelInfo &info, std::shared_ptr<InputMethodPanel> &panel)
277 {
278     AccessScope scope(currentImeTokenId_, currentImeUid_);
279     auto ret = ima_->CreatePanel(nullptr, info, panel);
280     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
281 }
282 
ImaDestroyPanel(const std::shared_ptr<InputMethodPanel> & panel)283 void InputMethodPanelTest::ImaDestroyPanel(const std::shared_ptr<InputMethodPanel> &panel)
284 {
285     AccessScope scope(currentImeTokenId_, currentImeUid_);
286     auto ret = ima_->DestroyPanel(panel);
287     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
288 }
289 
Attach()290 void InputMethodPanelTest::Attach()
291 {
292     IdentityCheckerMock::SetFocused(true);
293     auto ret = imc_->Attach(textListener_, false);
294     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
295     IdentityCheckerMock::SetFocused(false);
296 }
297 
TriggerShowCallback(std::shared_ptr<InputMethodPanel> & inputMethodPanel)298 bool InputMethodPanelTest::TriggerShowCallback(std::shared_ptr<InputMethodPanel> &inputMethodPanel)
299 {
300     IMSA_HILOGI("start");
301     status_ = InputWindowStatus::NONE;
302     panelHandler_->PostTask([&inputMethodPanel]() { TestShowPanel(inputMethodPanel); }, InputMethodPanelTest::INTERVAL);
303     {
304         std::unique_lock<std::mutex> lock(panelListenerLock_);
305         return panelListenerCv_.wait_for(lock, std::chrono::milliseconds(InputMethodPanelTest::DELAY_TIME),
306             [] { return status_ == InputWindowStatus::SHOW; });
307     }
308 }
309 
TriggerHideCallback(std::shared_ptr<InputMethodPanel> & inputMethodPanel)310 bool InputMethodPanelTest::TriggerHideCallback(std::shared_ptr<InputMethodPanel> &inputMethodPanel)
311 {
312     IMSA_HILOGI("start");
313     status_ = InputWindowStatus::NONE;
314     panelHandler_->PostTask([&inputMethodPanel]() { TestHidePanel(inputMethodPanel); }, InputMethodPanelTest::INTERVAL);
315     {
316         std::unique_lock<std::mutex> lock(panelListenerLock_);
317         return panelListenerCv_.wait_for(lock, std::chrono::milliseconds(InputMethodPanelTest::DELAY_TIME),
318             [] { return status_ == InputWindowStatus::HIDE; });
319     }
320 }
321 
ImcPanelShowNumCheck(uint32_t num)322 void InputMethodPanelTest::ImcPanelShowNumCheck(uint32_t num)
323 {
324     std::unique_lock<std::mutex> lock(imcPanelStatusListenerLock_);
325     if (num == 0) {
326         auto ret =
327             imcPanelStatusListenerCv_.wait_for(lock, std::chrono::milliseconds(IMC_WAIT_PANEL_STATUS_LISTEN_TIME));
328         EXPECT_EQ(ret, std::cv_status::timeout);
329         return;
330     }
331     bool ret = imcPanelStatusListenerCv_.wait_for(lock, std::chrono::milliseconds(IMC_WAIT_PANEL_STATUS_LISTEN_TIME),
332         [&num] { return num == imeShowCallbackNum_; });
333     EXPECT_TRUE(ret);
334 }
335 
ImcPanelHideNumCheck(uint32_t num)336 void InputMethodPanelTest::ImcPanelHideNumCheck(uint32_t num)
337 {
338     std::unique_lock<std::mutex> lock(imcPanelStatusListenerLock_);
339     if (num == 0) {
340         auto ret =
341             imcPanelStatusListenerCv_.wait_for(lock, std::chrono::milliseconds(IMC_WAIT_PANEL_STATUS_LISTEN_TIME));
342         EXPECT_EQ(ret, std::cv_status::timeout);
343         return;
344     }
345     bool ret = imcPanelStatusListenerCv_.wait_for(lock, std::chrono::milliseconds(IMC_WAIT_PANEL_STATUS_LISTEN_TIME),
346         [&num] { return num <= imeHideCallbackNum_; });
347     EXPECT_TRUE(ret);
348 }
349 
ImcPanelShowInfoCheck(const InputWindowInfo & windowInfo)350 void InputMethodPanelTest::ImcPanelShowInfoCheck(const InputWindowInfo &windowInfo)
351 {
352     std::unique_lock<std::mutex> lock(imcPanelStatusListenerLock_);
353     bool ret = imcPanelStatusListenerCv_.wait_for(lock, std::chrono::milliseconds(IMC_WAIT_PANEL_STATUS_LISTEN_TIME),
354         [] { return status_ == InputWindowStatus::SHOW; });
355     EXPECT_TRUE(ret);
356     IMSA_HILOGI("InputMethodPanelTest::name: %{public}s, ret:[%{public}d, %{public}d,%{public}d, %{public}d]",
357         windowInfo_.name.c_str(), windowInfo_.top, windowInfo_.left, windowInfo_.width, windowInfo_.height);
358     EXPECT_FALSE(windowInfo_.name.empty());
359 }
360 
ImcPanelHideInfoCheck(const InputWindowInfo & windowInfo)361 void InputMethodPanelTest::ImcPanelHideInfoCheck(const InputWindowInfo &windowInfo)
362 {
363     std::unique_lock<std::mutex> lock(imcPanelStatusListenerLock_);
364     bool ret = imcPanelStatusListenerCv_.wait_for(lock, std::chrono::milliseconds(IMC_WAIT_PANEL_STATUS_LISTEN_TIME),
365         [] { return status_ == InputWindowStatus::HIDE; });
366     EXPECT_TRUE(ret);
367     IMSA_HILOGI("InputMethodPanelTest::name: %{public}s, ret:[%{public}d, %{public}d,%{public}d, %{public}d]",
368         windowInfo_.name.c_str(), windowInfo_.top, windowInfo_.left, windowInfo_.width, windowInfo_.height);
369     EXPECT_FALSE(windowInfo_.name.empty());
370 }
371 
ImcPanelListeningTestRestore()372 void InputMethodPanelTest::ImcPanelListeningTestRestore()
373 {
374     status_ = InputWindowStatus::NONE;
375     windowInfo_ = {};
376     imeShowCallbackNum_ = 0;
377     imeHideCallbackNum_ = 0;
378 }
379 
TestShowPanel(const std::shared_ptr<InputMethodPanel> & panel)380 void InputMethodPanelTest::TestShowPanel(const std::shared_ptr<InputMethodPanel> &panel)
381 {
382     ASSERT_NE(panel, nullptr);
383     // set tokenId and uid as current ime
384     AccessScope scope(currentImeTokenId_, currentImeUid_);
385     auto ret = panel->ShowPanel();
386     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
387 }
388 
TestHidePanel(const std::shared_ptr<InputMethodPanel> & panel)389 void InputMethodPanelTest::TestHidePanel(const std::shared_ptr<InputMethodPanel> &panel)
390 {
391     ASSERT_NE(panel, nullptr);
392     // set tokenId and uid as current ime
393     AccessScope scope(currentImeTokenId_, currentImeUid_);
394     auto ret = panel->HidePanel();
395     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
396 }
397 
TestIsPanelShown(const PanelInfo & info,bool expectedResult)398 void InputMethodPanelTest::TestIsPanelShown(const PanelInfo &info, bool expectedResult)
399 {
400     IdentityCheckerMock::SetSystemApp(true);
401     bool result = !expectedResult;
402     auto ret = imc_->IsPanelShown(info, result);
403     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
404     EXPECT_EQ(result, expectedResult);
405     IdentityCheckerMock::SetSystemApp(false);
406 }
407 
TriggerPanelStatusChangeToImc(const std::shared_ptr<InputMethodPanel> & panel,InputWindowStatus status)408 void InputMethodPanelTest::TriggerPanelStatusChangeToImc(
409     const std::shared_ptr<InputMethodPanel> &panel, InputWindowStatus status)
410 {
411     ASSERT_NE(panel, nullptr);
412     if (isScbEnable_) {
413         IdentityCheckerMock::SetBundleNameValid(true);
414         // add for SetTestTokenID in mainThread, but has no effect for other thread ipc
415         panel->PanelStatusChangeToImc(status, { 0, 0, 0, 0 });
416         IdentityCheckerMock::SetBundleNameValid(false);
417     }
418 }
419 
420 /**
421 * @tc.name: testCreatePanel
422 * @tc.desc: Test CreatePanel.
423 * @tc.type: FUNC
424 */
425 HWTEST_F(InputMethodPanelTest, testCreatePanel, TestSize.Level0)
426 {
427     IMSA_HILOGI("InputMethodPanelTest::testCreatePanel start.");
428     AccessScope scope(currentImeTokenId_, currentImeUid_);
429     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
430     PanelInfo panelInfo = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FLOATING };
431     auto ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
432     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
433     ret = inputMethodPanel->DestroyPanel();
434     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
435 }
436 
437 /**
438 * @tc.name: testDestroyPanel
439 * @tc.desc: Test DestroyPanel.
440 * @tc.type: FUNC
441 */
442 HWTEST_F(InputMethodPanelTest, testDestroyPanel, TestSize.Level0)
443 {
444     IMSA_HILOGI("InputMethodPanelTest::testDestroyPanel start.");
445     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
446     // not CreatePanel, DestroyPanel failed
447     auto ret = inputMethodPanel->DestroyPanel();
448     EXPECT_EQ(ret, ErrorCode::ERROR_NULL_POINTER);
449 }
450 
451 /**
452 * @tc.name: testResizePanel001
453 * @tc.desc: Test Resize panel. Panels non fixed soft keyboard.
454 * @tc.type: FUNC
455 */
456 HWTEST_F(InputMethodPanelTest, testResizePanel001, TestSize.Level0)
457 {
458     IMSA_HILOGI("InputMethodPanelTest::testResizePanel001 start.");
459     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
460     // not CreatePanel, Resize failed
461     auto ret = inputMethodPanel->Resize(1, 1);
462     EXPECT_EQ(ret, ErrorCode::ERROR_NULL_POINTER);
463 
464     AccessScope scope(currentImeTokenId_, currentImeUid_);
465     PanelInfo panelInfo = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FLOATING };
466     ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
467     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
468     auto defaultDisplay = Rosen::DisplayManager::GetInstance().GetDefaultDisplay();
469     ASSERT_TRUE(defaultDisplay != nullptr);
470     int32_t width = defaultDisplay->GetWidth();
471     int32_t height = defaultDisplay->GetHeight();
472 
473     ret = inputMethodPanel->Resize(width - 1, height * NON_FIXED_SOFT_KEYBOARD_PANEL_RATIO - 1);
474     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
475 
476     ret = inputMethodPanel->Resize(width, height * NON_FIXED_SOFT_KEYBOARD_PANEL_RATIO);
477     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
478 
479     ret = inputMethodPanel->Resize(width + 1, height * NON_FIXED_SOFT_KEYBOARD_PANEL_RATIO);
480     EXPECT_EQ(ret, ErrorCode::ERROR_BAD_PARAMETERS);
481 
482     ret = inputMethodPanel->Resize(width, height * NON_FIXED_SOFT_KEYBOARD_PANEL_RATIO + 1);
483     EXPECT_EQ(ret, ErrorCode::ERROR_BAD_PARAMETERS);
484 
485     ret = inputMethodPanel->Resize(width + 1, height * NON_FIXED_SOFT_KEYBOARD_PANEL_RATIO + 1);
486     EXPECT_EQ(ret, ErrorCode::ERROR_BAD_PARAMETERS);
487 
488     ret = inputMethodPanel->DestroyPanel();
489     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
490 }
491 
492 /**
493 * @tc.name: testResizePanel002
494 * @tc.desc: Test Resize panel. Fixed soft keyboard panel .
495 * @tc.type: FUNC
496 */
497 HWTEST_F(InputMethodPanelTest, testResizePanel002, TestSize.Level0)
498 {
499     IMSA_HILOGI("InputMethodPanelTest::testResizePanel002 start.");
500     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
501     // not CreatePanel, Resize failed
502     auto ret = inputMethodPanel->Resize(1, 1);
503     EXPECT_EQ(ret, ErrorCode::ERROR_NULL_POINTER);
504 
505     PanelInfo panelInfo = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FIXED };
506     AccessScope scope(currentImeTokenId_, currentImeUid_);
507     ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
508     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
509     auto defaultDisplay = Rosen::DisplayManager::GetInstance().GetDefaultDisplay();
510     ASSERT_TRUE(defaultDisplay != nullptr);
511     int32_t width = defaultDisplay->GetWidth();
512     int32_t height = defaultDisplay->GetHeight();
513 
514     ret = inputMethodPanel->Resize(width - 1, height * FIXED_SOFT_KEYBOARD_PANEL_RATIO - 1);
515     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
516 
517     ret = inputMethodPanel->Resize(width, height * FIXED_SOFT_KEYBOARD_PANEL_RATIO);
518     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
519 
520     ret = inputMethodPanel->Resize(width + 1, height * FIXED_SOFT_KEYBOARD_PANEL_RATIO);
521     EXPECT_EQ(ret, ErrorCode::ERROR_BAD_PARAMETERS);
522 
523     ret = inputMethodPanel->Resize(width, height * FIXED_SOFT_KEYBOARD_PANEL_RATIO + 1);
524     EXPECT_EQ(ret, ErrorCode::ERROR_BAD_PARAMETERS);
525 
526     ret = inputMethodPanel->Resize(width + 1, height * FIXED_SOFT_KEYBOARD_PANEL_RATIO + 1);
527     EXPECT_EQ(ret, ErrorCode::ERROR_BAD_PARAMETERS);
528 
529     ret = inputMethodPanel->DestroyPanel();
530     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
531 }
532 
533 /**
534 * @tc.name: testMovePanel
535 * @tc.desc: Test Move panel. SOFT_KEYBOARD panel with FLG_FIXED can not be moved.
536 * @tc.type: FUNC
537 */
538 HWTEST_F(InputMethodPanelTest, testMovePanel, TestSize.Level0)
539 {
540     IMSA_HILOGI("InputMethodPanelTest::testMovePanel start.");
541     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
542     // not CreatePanel, MoveTo failed
543     auto ret = inputMethodPanel->MoveTo(10, 100);
544     EXPECT_EQ(ret, ErrorCode::ERROR_NULL_POINTER);
545 
546     AccessScope scope(currentImeTokenId_, currentImeUid_);
547     PanelInfo panelInfo = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FIXED };
548     ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
549     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
550 
551     ret = inputMethodPanel->MoveTo(10, 100);
552     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
553 
554     ret = inputMethodPanel->ChangePanelFlag(PanelFlag::FLG_FLOATING);
555     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
556     ret = inputMethodPanel->MoveTo(10, 100);
557     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
558 
559     ret = inputMethodPanel->DestroyPanel();
560     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
561 
562     panelInfo.panelType = STATUS_BAR;
563     ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
564     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
565     ret = inputMethodPanel->MoveTo(10, 100);
566     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
567     ret = inputMethodPanel->DestroyPanel();
568     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
569 }
570 
571 /**
572 * @tc.name: testShowPanel
573 * @tc.desc: Test Show panel.
574 * @tc.type: FUNC
575 */
576 HWTEST_F(InputMethodPanelTest, testShowPanel, TestSize.Level0)
577 {
578     IMSA_HILOGI("InputMethodPanelTest::testShowPanel start.");
579     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
580     PanelInfo panelInfo = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FIXED };
581     // 0、not create panel, show panel failed.
582     auto ret = inputMethodPanel->ShowPanel();
583     EXPECT_EQ(ret, ErrorCode::ERROR_NULL_POINTER);
584 
585     // 1 create panel, show success
586     AccessScope scope(currentImeTokenId_, currentImeUid_);
587     ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
588     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
589     ret = inputMethodPanel->ShowPanel();
590     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
591 
592     auto statusListener = std::make_shared<InputMethodPanelTest::PanelStatusListenerImpl>();
593     EXPECT_TRUE(statusListener != nullptr);
594     std::string type = "show";
595     inputMethodPanel->SetPanelStatusListener(statusListener, type);
596     ret = inputMethodPanel->ShowPanel();
597     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
598 
599     // 2、show floating type panel.
600     ret = inputMethodPanel->ChangePanelFlag(PanelFlag::FLG_FLOATING);
601     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
602     ret = inputMethodPanel->ShowPanel();
603     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
604 
605     ret = inputMethodPanel->DestroyPanel();
606     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
607 
608     // 4、show status bar.
609     panelInfo.panelType = STATUS_BAR;
610     ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
611     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
612     ret = inputMethodPanel->ShowPanel();
613     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
614     ret = inputMethodPanel->HidePanel();
615     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
616     ret = inputMethodPanel->DestroyPanel();
617     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
618 }
619 
620 /**
621  * @tc.name: testIsPanelShown_001
622  * @tc.desc: Test is panel shown.
623  * @tc.type: FUNC
624  */
625 HWTEST_F(InputMethodPanelTest, testIsPanelShown_001, TestSize.Level0)
626 {
627     IMSA_HILOGI("InputMethodPanelTest::testIsPanelShown_001 start.");
628     InputMethodPanelTest::Attach();
629     PanelInfo panelInfo = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FIXED };
630     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
631     InputMethodPanelTest::ImaCreatePanel(panelInfo, inputMethodPanel);
632 
633     // query when fixed soft keyboard is showing
634     InputMethodPanelTest::TestShowPanel(inputMethodPanel);
635     InputMethodPanelTest::TestIsPanelShown(panelInfo, true);
636 
637     // query when fixed soft keyboard is hidden
638     InputMethodPanelTest::TestHidePanel(inputMethodPanel);
639     InputMethodPanelTest::TestIsPanelShown(panelInfo, false);
640 
641     InputMethodPanelTest::ImaDestroyPanel(inputMethodPanel);
642     InputMethodPanelTest::imc_->Close();
643 }
644 
645 /**
646  * @tc.name: testIsPanelShown_002
647  * @tc.desc: Test is panel shown.
648  * @tc.type: FUNC
649  */
650 HWTEST_F(InputMethodPanelTest, testIsPanelShown_002, TestSize.Level0)
651 {
652     IMSA_HILOGI("InputMethodPanelTest::testIsPanelShown_002 start.");
653     InputMethodPanelTest::Attach();
654     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
655     PanelInfo panelInfo = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FIXED };
656     InputMethodPanelTest::ImaCreatePanel(panelInfo, inputMethodPanel);
657 
658     // query panel with old info when panel changes its flag.
659     auto ret = inputMethodPanel->ChangePanelFlag(PanelFlag::FLG_FLOATING);
660     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
661     InputMethodPanelTest::TestShowPanel(inputMethodPanel);
662     InputMethodPanelTest::TestIsPanelShown(panelInfo, false);
663 
664     // query panel with updated shown one's info when panel changes its flag.
665     panelInfo.panelFlag = PanelFlag::FLG_FLOATING;
666     InputMethodPanelTest::TestIsPanelShown(panelInfo, true);
667 
668     InputMethodPanelTest::ImaDestroyPanel(inputMethodPanel);
669     InputMethodPanelTest::imc_->Close();
670 }
671 
672 /**
673  * @tc.name: testIsPanelShown_003
674  * @tc.desc: Test is panel shown.
675  * @tc.type: FUNC
676  */
677 HWTEST_F(InputMethodPanelTest, testIsPanelShown_003, TestSize.Level0)
678 {
679     IMSA_HILOGI("InputMethodPanelTest::testIsPanelShown_003 start.");
680     InputMethodPanelTest::Attach();
681     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
682     PanelInfo panelInfo = { .panelType = STATUS_BAR };
683     InputMethodPanelTest::ImaCreatePanel(panelInfo, inputMethodPanel);
684 
685     // query status bar's status when it is showing
686     InputMethodPanelTest::TestShowPanel(inputMethodPanel);
687     InputMethodPanelTest::TestIsPanelShown(panelInfo, true);
688 
689     // query status bar's status when it is hidden
690     InputMethodPanelTest::TestHidePanel(inputMethodPanel);
691     InputMethodPanelTest::TestIsPanelShown(panelInfo, false);
692 
693     InputMethodPanelTest::ImaDestroyPanel(inputMethodPanel);
694     InputMethodPanelTest::imc_->Close();
695 }
696 
697 /**
698 * @tc.name: testSetPanelStatusListener01
699 * @tc.desc: Test testSetPanelStatusListener01.
700 * @tc.type: FUNC
701 */
702 HWTEST_F(InputMethodPanelTest, testSetPanelStatusListener01, TestSize.Level0)
703 {
704     IMSA_HILOGI("InputMethodPanelTest::testSetPanelStatusListener01 start.");
705     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
706     auto statusListener = std::make_shared<InputMethodPanelTest::PanelStatusListenerImpl>();
707     // on('show')->on('hide')->show->hide
708     inputMethodPanel->SetPanelStatusListener(statusListener, "show");
709     inputMethodPanel->SetPanelStatusListener(statusListener, "hide");
710 
711     AccessScope scope(InputMethodPanelTest::currentImeTokenId_, InputMethodPanelTest::currentImeUid_);
712     PanelInfo panelInfo = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FIXED };
713     auto ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
714     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
715 
716     EXPECT_TRUE(InputMethodPanelTest::TriggerShowCallback(inputMethodPanel));
717     EXPECT_TRUE(InputMethodPanelTest::TriggerHideCallback(inputMethodPanel));
718 
719     InputMethodPanelTest::ImaDestroyPanel(inputMethodPanel);
720 }
721 
722 /**
723 * @tc.name: testSetPanelStatusListener02
724 * @tc.desc: Test testSetPanelStatusListener02.
725 * @tc.type: FUNC
726 */
727 HWTEST_F(InputMethodPanelTest, testSetPanelStatusListener02, TestSize.Level0)
728 {
729     IMSA_HILOGI("InputMethodPanelTest::testSetPanelStatusListener02 start.");
730     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
731     auto statusListener = std::make_shared<InputMethodPanelTest::PanelStatusListenerImpl>();
732 
733     AccessScope scope(InputMethodPanelTest::currentImeTokenId_, InputMethodPanelTest::currentImeUid_);
734     PanelInfo panelInfo = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FIXED };
735     auto ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
736     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
737 
738     // panelStatusListener_ not nullptr
739     inputMethodPanel->panelStatusListener_ = statusListener;
740 
741     // subscribe 'show' after panel shown, get 'show' callback
742     InputMethodPanelTest::status_ = InputWindowStatus::NONE;
743     InputMethodPanelTest::TestShowPanel(inputMethodPanel);
744     inputMethodPanel->SetPanelStatusListener(statusListener, "show");
745     EXPECT_EQ(status_, InputWindowStatus::SHOW);
746 
747     // subscribe 'hide' after panel hidden, get 'hide' callback
748     InputMethodPanelTest::status_ = InputWindowStatus::NONE;
749     InputMethodPanelTest::TestHidePanel(inputMethodPanel);
750     inputMethodPanel->SetPanelStatusListener(statusListener, "hide");
751     EXPECT_EQ(status_, InputWindowStatus::HIDE);
752 
753     InputMethodPanelTest::ImaDestroyPanel(inputMethodPanel);
754 }
755 
756 /**
757 * @tc.name: testGetPanelType
758 * @tc.desc: Test GetPanelType.
759 * @tc.type: FUNC
760 */
761 HWTEST_F(InputMethodPanelTest, testGetPanelType, TestSize.Level0)
762 {
763     IMSA_HILOGI("InputMethodPanelTest::testGetPanelType start.");
764     AccessScope scope(InputMethodPanelTest::currentImeTokenId_, InputMethodPanelTest::currentImeUid_);
765     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
766     PanelInfo panelInfo = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FLOATING };
767     auto ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
768     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
769     auto type = inputMethodPanel->GetPanelType();
770     EXPECT_EQ(type, panelInfo.panelType);
771     ret = inputMethodPanel->DestroyPanel();
772     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
773 }
774 
775 /**
776  * @tc.name: testGetPanelFlag
777  * @tc.desc: Test GetPanelFlag.
778  * @tc.type: FUNC
779  */
780 HWTEST_F(InputMethodPanelTest, testGetPanelFlag, TestSize.Level0)
781 {
782     IMSA_HILOGI("InputMethodPanelTest::testGetPanelFlag start.");
783     AccessScope scope(InputMethodPanelTest::currentImeTokenId_, InputMethodPanelTest::currentImeUid_);
784     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
785     PanelInfo panelInfo = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FLOATING };
786     auto ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
787     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
788     auto flag = inputMethodPanel->GetPanelFlag();
789     EXPECT_EQ(flag, panelInfo.panelFlag);
790 
791     ret = inputMethodPanel->ChangePanelFlag(PanelFlag::FLG_CANDIDATE_COLUMN);
792     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
793     flag = inputMethodPanel->GetPanelFlag();
794     EXPECT_EQ(flag, PanelFlag::FLG_CANDIDATE_COLUMN);
795 
796     ret = inputMethodPanel->DestroyPanel();
797     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
798 }
799 
800 /**
801 * @tc.name: testChangePanelFlag
802 * @tc.desc: Test ChangePanelFlag.
803 * @tc.type: FUNC
804 */
805 HWTEST_F(InputMethodPanelTest, testChangePanelFlag, TestSize.Level0)
806 {
807     IMSA_HILOGI("InputMethodPanelTest::testChangePanelFlag start.");
808     AccessScope scope(InputMethodPanelTest::currentImeTokenId_, InputMethodPanelTest::currentImeUid_);
809     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
810     PanelFlag flag = FLG_FLOATING;
811 
812     // not CreatePanel, ChangePanelFlag failed
813     auto ret = inputMethodPanel->ChangePanelFlag(flag);
814     EXPECT_EQ(ret, ErrorCode::ERROR_NULL_POINTER);
815 
816     PanelInfo panelInfo = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FLOATING };
817     ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
818     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
819 
820     // panelFlag is same with the original
821     ret = inputMethodPanel->ChangePanelFlag(flag);
822     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
823 
824     // panelFlag modify to FLG_FIXED
825     flag = FLG_FIXED;
826     ret = inputMethodPanel->ChangePanelFlag(flag);
827     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
828 
829     inputMethodPanel->DestroyPanel();
830 
831     panelInfo = { .panelType = STATUS_BAR, .panelFlag = FLG_FLOATING };
832     ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
833     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
834     // panelType is STATUS_BAR, not allow ChangePanelFlag
835     ret = inputMethodPanel->ChangePanelFlag(flag);
836     EXPECT_EQ(ret, ErrorCode::ERROR_BAD_PARAMETERS);
837 
838     inputMethodPanel->DestroyPanel();
839 }
840 
841 /**
842 * @tc.name: testClearPanelListener
843 * @tc.desc: Test ClearPanelListener.
844 * @tc.type: FUNC
845 */
846 HWTEST_F(InputMethodPanelTest, testClearPanelListener, TestSize.Level0)
847 {
848     IMSA_HILOGI("InputMethodPanelTest::testClearPanelListener start.");
849     auto inputMethodPanel = InputMethodPanelTest::CreatePanel();
850     auto statusListener = std::make_shared<InputMethodPanelTest::PanelStatusListenerImpl>();
851     inputMethodPanel->SetPanelStatusListener(statusListener, "show");
852     inputMethodPanel->SetPanelStatusListener(statusListener, "hide");
853 
854     inputMethodPanel->ClearPanelListener("show");
855     EXPECT_FALSE(InputMethodPanelTest::TriggerShowCallback(inputMethodPanel));
856     EXPECT_TRUE(InputMethodPanelTest::TriggerHideCallback(inputMethodPanel));
857 
858     inputMethodPanel->ClearPanelListener("hide");
859     EXPECT_FALSE(InputMethodPanelTest::TriggerShowCallback(inputMethodPanel));
860     EXPECT_FALSE(InputMethodPanelTest::TriggerHideCallback(inputMethodPanel));
861 
862     InputMethodPanelTest::DestroyPanel(inputMethodPanel);
863 }
864 
865 /**
866 * @tc.name: testRegisterListener
867 * @tc.desc: Test ClearPanelListener.
868 * @tc.type: FUNC
869 */
870 HWTEST_F(InputMethodPanelTest, testRegisterListener, TestSize.Level0)
871 {
872     // on('show')->on('hide')->show->hide->off('show')->show->hide->on('show')->show
873     IMSA_HILOGI("InputMethodPanelTest::testRegisterListener start.");
874     auto inputMethodPanel = InputMethodPanelTest::CreatePanel();
875 
876     auto statusListener = std::make_shared<InputMethodPanelTest::PanelStatusListenerImpl>();
877     inputMethodPanel->SetPanelStatusListener(statusListener, "show");
878     inputMethodPanel->SetPanelStatusListener(statusListener, "hide");
879     EXPECT_TRUE(InputMethodPanelTest::TriggerShowCallback(inputMethodPanel));
880     EXPECT_TRUE(InputMethodPanelTest::TriggerHideCallback(inputMethodPanel));
881 
882     inputMethodPanel->ClearPanelListener("show");
883     EXPECT_FALSE(InputMethodPanelTest::TriggerShowCallback(inputMethodPanel));
884     EXPECT_TRUE(InputMethodPanelTest::TriggerHideCallback(inputMethodPanel));
885 
886     inputMethodPanel->SetPanelStatusListener(statusListener, "show");
887     EXPECT_TRUE(InputMethodPanelTest::TriggerShowCallback(inputMethodPanel));
888 
889     InputMethodPanelTest::DestroyPanel(inputMethodPanel);
890 }
891 
892 /*
893 * @tc.name: testImcPanelListening_001
894 * @tc.desc: SOFT_KEYBOARD/FLG_FIXED, listener(system app)
895 * @tc.type: FUNC
896 */
897 HWTEST_F(InputMethodPanelTest, testImcPanelListening_001, TestSize.Level0)
898 {
899     IMSA_HILOGI("InputMethodPanelTest::testImcPanelListening_001 start.");
900     // system app for RegisterImeEventListener and currentIme for PanelStatusChangeToImc
901     IdentityCheckerMock::SetSystemApp(true);
902     IdentityCheckerMock::SetBundleNameValid(true);
903     auto listener = std::make_shared<InputMethodSettingListenerImpl>();
904     ImeEventMonitorManager::GetInstance().RegisterImeEventListener(EVENT_IME_SHOW_MASK | EVENT_IME_HIDE_MASK, listener);
905     PanelInfo panelInfo = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FIXED };
906     std::shared_ptr<InputMethodPanel> panel = nullptr;
907     ImaCreatePanel(panelInfo, panel);
908     // imeShow
909     InputMethodPanelTest::ImcPanelListeningTestRestore();
910     InputMethodPanelTest::TestShowPanel(panel);
911     InputMethodPanelTest::TriggerPanelStatusChangeToImc(panel, InputWindowStatus::SHOW);
912     InputMethodPanelTest::ImcPanelShowNumCheck(1);
913     // imeHide
914     InputMethodPanelTest::ImcPanelListeningTestRestore();
915     InputMethodPanelTest::TestHidePanel(panel);
916     InputMethodPanelTest::TriggerPanelStatusChangeToImc(panel, InputWindowStatus::HIDE);
917     InputMethodPanelTest::ImcPanelHideNumCheck(1);
918     ImaDestroyPanel(panel);
919     ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener(
920         EVENT_IME_SHOW_MASK | EVENT_IME_HIDE_MASK, listener);
921     IdentityCheckerMock::SetSystemApp(false);
922     IdentityCheckerMock::SetBundleNameValid(false);
923 }
924 
925 /*
926 * @tc.name: testImcPanelListening_002
927 * @tc.desc: SOFT_KEYBOARD/FLG_FLOATING, listener(system app)
928 * @tc.type: FUNC
929 */
930 HWTEST_F(InputMethodPanelTest, testImcPanelListening_002, TestSize.Level0)
931 {
932     IMSA_HILOGI("InputMethodPanelTest::testImcPanelListening_002 start.");
933     // system app for RegisterImeEventListener and currentIme for PanelStatusChangeToImc
934     IdentityCheckerMock::SetSystemApp(true);
935     IdentityCheckerMock::SetBundleNameValid(true);
936     auto listener = std::make_shared<InputMethodSettingListenerImpl>();
937     ImeEventMonitorManager::GetInstance().RegisterImeEventListener(EVENT_IME_SHOW_MASK | EVENT_IME_HIDE_MASK, listener);
938 
939     AccessScope scope(currentImeTokenId_, currentImeUid_);
940     PanelInfo panelInfo = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FLOATING };
941     std::shared_ptr<InputMethodPanel> panel = nullptr;
942     ImaCreatePanel(panelInfo, panel);
943     // imeShow
944     InputMethodPanelTest::ImcPanelListeningTestRestore();
945     InputMethodPanelTest::TestShowPanel(panel);
946     InputMethodPanelTest::TriggerPanelStatusChangeToImc(panel, InputWindowStatus::SHOW);
947     InputMethodPanelTest::ImcPanelShowNumCheck(1);
948     // imeHide
949     InputMethodPanelTest::ImcPanelListeningTestRestore();
950     InputMethodPanelTest::TestHidePanel(panel);
951     InputMethodPanelTest::TriggerPanelStatusChangeToImc(panel, InputWindowStatus::HIDE);
952     InputMethodPanelTest::ImcPanelHideNumCheck(1);
953     ImaDestroyPanel(panel);
954 
955     ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener(
956         EVENT_IME_SHOW_MASK | EVENT_IME_HIDE_MASK, listener);
957     IdentityCheckerMock::SetSystemApp(false);
958     IdentityCheckerMock::SetBundleNameValid(false);
959 }
960 
961 /*
962 * @tc.name: testImcPanelListening_003
963 * @tc.desc: SOFT_KEYBOARD/FLG_CANDIDATE_COLUMN, listener(system app)
964 * @tc.type: FUNC
965 */
966 HWTEST_F(InputMethodPanelTest, testImcPanelListening_003, TestSize.Level0)
967 {
968     IMSA_HILOGI("InputMethodPanelTest::testImcPanelListening_003 start.");
969     // system app for RegisterImeEventListener and currentIme for PanelStatusChangeToImc
970     IdentityCheckerMock::SetSystemApp(true);
971     IdentityCheckerMock::SetBundleNameValid(true);
972     auto listener = std::make_shared<InputMethodSettingListenerImpl>();
973 
974     ImeEventMonitorManager::GetInstance().RegisterImeEventListener(EVENT_IME_SHOW_MASK | EVENT_IME_HIDE_MASK, listener);
975 
976     PanelInfo panelInfo = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_CANDIDATE_COLUMN };
977     std::shared_ptr<InputMethodPanel> panel = nullptr;
978     ImaCreatePanel(panelInfo, panel);
979     // imeShow
980     InputMethodPanelTest::ImcPanelListeningTestRestore();
981     InputMethodPanelTest::TestShowPanel(panel);
982     InputMethodPanelTest::TriggerPanelStatusChangeToImc(panel, InputWindowStatus::SHOW);
983     InputMethodPanelTest::ImcPanelShowNumCheck(0);
984     // imeHide
985     InputMethodPanelTest::ImcPanelListeningTestRestore();
986     InputMethodPanelTest::TestHidePanel(panel);
987     InputMethodPanelTest::TriggerPanelStatusChangeToImc(panel, InputWindowStatus::HIDE);
988     InputMethodPanelTest::ImcPanelHideNumCheck(0);
989     ImaDestroyPanel(panel);
990 
991     ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener(
992         EVENT_IME_SHOW_MASK | EVENT_IME_HIDE_MASK, listener);
993     IdentityCheckerMock::SetSystemApp(false);
994     IdentityCheckerMock::SetBundleNameValid(false);
995 }
996 
997 /**
998 * @tc.name: testImcPanelListening_004
999 * @tc.desc: STATUS_BAR, listener(system app)
1000 * @tc.type: FUNC
1001 */
1002 HWTEST_F(InputMethodPanelTest, testImcPanelListening_004, TestSize.Level0)
1003 {
1004     IMSA_HILOGI("InputMethodPanelTest::testImcPanelListening_004 start.");
1005     // system app for RegisterImeEventListener and currentIme for PanelStatusChangeToImc
1006     IdentityCheckerMock::SetSystemApp(true);
1007     IdentityCheckerMock::SetBundleNameValid(true);
1008     auto listener = std::make_shared<InputMethodSettingListenerImpl>();
1009 
1010     ImeEventMonitorManager::GetInstance().RegisterImeEventListener(EVENT_IME_SHOW_MASK | EVENT_IME_HIDE_MASK, listener);
1011 
1012     PanelInfo panelInfo = { .panelType = STATUS_BAR };
1013     std::shared_ptr<InputMethodPanel> panel = nullptr;
1014     ImaCreatePanel(panelInfo, panel);
1015     // imeShow
1016     InputMethodPanelTest::ImcPanelListeningTestRestore();
1017     InputMethodPanelTest::TestShowPanel(panel);
1018     InputMethodPanelTest::ImcPanelShowNumCheck(0);
1019     // imeHide
1020     InputMethodPanelTest::ImcPanelListeningTestRestore();
1021     InputMethodPanelTest::TestHidePanel(panel);
1022     InputMethodPanelTest::ImcPanelHideNumCheck(0);
1023     ImaDestroyPanel(panel);
1024 
1025     ImeEventMonitorManager::GetInstance().UnRegisterImeEventListener(
1026         EVENT_IME_SHOW_MASK | EVENT_IME_HIDE_MASK, listener);
1027     IdentityCheckerMock::SetSystemApp(false);
1028     IdentityCheckerMock::SetBundleNameValid(false);
1029 }
1030 
1031 /*
1032 * @tc.name: testPanelStatusChangeEventPublicTest
1033 * @tc.desc: test subscriber can receive the panel status change event published by IMSA
1034 * @tc.type: FUNC
1035 */
1036 HWTEST_F(InputMethodPanelTest, testPanelStatusChangeEventPublicTest, TestSize.Level0)
1037 {
1038     IMSA_HILOGI("InputMethodPanelTest::testPanelStatusChangeEventPublicTest start.");
1039     // currentIme for PanelStatusChangeToImc
1040     IdentityCheckerMock::SetBundleNameValid(true);
1041     EventFwk::MatchingSkills matchingSkills;
1042     matchingSkills.AddEvent(COMMON_EVENT_INPUT_PANEL_STATUS_CHANGED);
1043     EventFwk::CommonEventSubscribeInfo subscriberInfo(matchingSkills);
1044     auto subscriber = std::make_shared<TestEventSubscriber>(subscriberInfo);
1045     auto ret = EventFwk::CommonEventManager::SubscribeCommonEvent(subscriber);
1046     EXPECT_TRUE(ret);
1047     PanelInfo panelInfo = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FLOATING };
1048     std::shared_ptr<InputMethodPanel> panel = nullptr;
1049     ImaCreatePanel(panelInfo, panel);
1050     // imeShow
1051     subscriber->ResetParam();
1052     InputMethodPanelTest::TestShowPanel(panel);
1053     InputMethodPanelTest::TriggerPanelStatusChangeToImc(panel, InputWindowStatus::SHOW);
1054     {
1055         std::unique_lock<std::mutex> lock(imcPanelStatusListenerLock_);
1056         auto waitRet = imcPanelStatusListenerCv_.wait_for(
__anonb14db8d50902() 1057             lock, std::chrono::milliseconds(IMC_WAIT_PANEL_STATUS_LISTEN_TIME), [subscriber]() {
1058                 return subscriber->action_ == COMMON_EVENT_INPUT_PANEL_STATUS_CHANGED
1059                        && subscriber->status_ == InputWindowStatus::SHOW;
1060             });
1061         EXPECT_TRUE(waitRet);
1062     }
1063     // imeHide
1064     subscriber->ResetParam();
1065     InputMethodPanelTest::TestHidePanel(panel);
1066     InputMethodPanelTest::TriggerPanelStatusChangeToImc(panel, InputWindowStatus::HIDE);
1067     {
1068         std::unique_lock<std::mutex> lock(imcPanelStatusListenerLock_);
1069         auto waitRet = imcPanelStatusListenerCv_.wait_for(
__anonb14db8d50a02() 1070             lock, std::chrono::milliseconds(IMC_WAIT_PANEL_STATUS_LISTEN_TIME), [subscriber]() {
1071                 return subscriber->action_ == COMMON_EVENT_INPUT_PANEL_STATUS_CHANGED
1072                        && subscriber->status_ == InputWindowStatus::HIDE;
1073             });
1074         EXPECT_TRUE(waitRet);
1075     }
1076     ImaDestroyPanel(panel);
1077     IdentityCheckerMock::SetBundleNameValid(false);
1078 }
1079 
1080 /**
1081 * @tc.name: testSetCallingWindow
1082 * @tc.desc: test SetCallingWindow
1083 * @tc.type: FUNC
1084 */
1085 HWTEST_F(InputMethodPanelTest, testSetCallingWindow, TestSize.Level0)
1086 {
1087     IMSA_HILOGI("InputMethodPanelTest::testSetCallingWindow start.");
1088     AccessScope scope(InputMethodPanelTest::currentImeTokenId_, InputMethodPanelTest::currentImeUid_);
1089     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
1090     // not CreatePanel, SetCallingWindow failed
1091     uint32_t windowId = 8;
1092     auto ret = inputMethodPanel->SetCallingWindow(windowId);
1093     EXPECT_EQ(ret, ErrorCode::ERROR_PANEL_NOT_FOUND);
1094 
1095     PanelInfo panelInfo = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FIXED };
1096     ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
1097     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
1098 
1099     ret = inputMethodPanel->SetCallingWindow(windowId);
1100     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
1101 
1102     ret = inputMethodPanel->DestroyPanel();
1103     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
1104 }
1105 
1106 /*
1107 * @tc.name: testKeyboardPanelInfoChangeListenerRegister_001
1108 * @tc.desc: SOFT_KEYBOARD
1109 * @tc.type: FUNC
1110 */
1111 HWTEST_F(InputMethodPanelTest, testKeyboardPanelInfoChangeListenerRegister_001, TestSize.Level0)
1112 {
1113     IMSA_HILOGI("InputMethodPanelTest::testKeyboardPanelInfoChangeListenerRegister_001 start.");
1114     PanelInfo panelInfo = { .panelType = SOFT_KEYBOARD };
1115     std::shared_ptr<InputMethodPanel> panel = nullptr;
1116     ImaCreatePanel(panelInfo, panel);
1117     ASSERT_NE(panel, nullptr);
1118     if (isScbEnable_) {
1119         EXPECT_NE(panel->kbPanelInfoListener_, nullptr);
1120     } else {
1121         EXPECT_EQ(panel->kbPanelInfoListener_, nullptr);
1122     }
1123     ImaDestroyPanel(panel);
1124     EXPECT_EQ(panel->kbPanelInfoListener_, nullptr);
1125 }
1126 
1127 /*
1128 * @tc.name: testKeyboardPanelInfoChangeListenerRegister_002
1129 * @tc.desc: STATUS_BAR
1130 * @tc.type: FUNC
1131 */
1132 HWTEST_F(InputMethodPanelTest, testKeyboardPanelInfoChangeListenerRegister_002, TestSize.Level0)
1133 {
1134     IMSA_HILOGI("InputMethodPanelTest::testKeyboardPanelInfoChangeListenerRegister_002 start.");
1135     PanelInfo panelInfo = { .panelType = STATUS_BAR };
1136     std::shared_ptr<InputMethodPanel> panel = nullptr;
1137     ImaCreatePanel(panelInfo, panel);
1138     ASSERT_NE(panel, nullptr);
1139     EXPECT_EQ(panel->kbPanelInfoListener_, nullptr);
1140     ImaDestroyPanel(panel);
1141 }
1142 
1143 /**
1144 * @tc.name: testAdjustPanelRect_001
1145 * @tc.desc: Test AdjustPanelRect with FLG_FIXED invalid params.
1146 * @tc.type: FUNC
1147 */
1148 HWTEST_F(InputMethodPanelTest, testAdjustPanelRect_001, TestSize.Level0)
1149 {
1150     InputMethodPanelTest::Attach();
1151     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
1152     PanelInfo panelInfo = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FIXED };
1153     InputMethodPanelTest::ImaCreatePanel(panelInfo, inputMethodPanel);
1154     PanelFlag panelFlag = PanelFlag::FLG_FIXED;
1155     LayoutParams layoutParams;
1156     layoutParams.landscapeRect = {0, 0, 0, 0};
1157     layoutParams.portraitRect = {0, 0, 0, 0};
1158     auto ret = inputMethodPanel->AdjustPanelRect(panelFlag, layoutParams);
1159     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
1160     InputMethodPanelTest::ImaDestroyPanel(inputMethodPanel);
1161     InputMethodPanelTest::imc_->Close();
1162     TddUtil::DestroyWindow();
1163 }
1164 
1165 /**
1166 * @tc.name: testAdjustPanelRect_002
1167 * @tc.desc: Test AdjustPanelRect with FLG_FIXED invalid params.
1168 * @tc.type: FUNC
1169 */
1170 HWTEST_F(InputMethodPanelTest, testAdjustPanelRect_002, TestSize.Level0)
1171 {
1172     InputMethodPanelTest::Attach();
1173     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
1174     PanelInfo panelInfo = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FIXED };
1175     InputMethodPanelTest::ImaCreatePanel(panelInfo, inputMethodPanel);
1176     PanelFlag panelFlag = PanelFlag::FLG_FIXED;
1177     LayoutParams layoutParams;
1178     layoutParams.landscapeRect = {-1, 0, 0, 0};
1179     layoutParams.portraitRect = {-1, 0, 0, 0};
1180     auto ret = inputMethodPanel->AdjustPanelRect(panelFlag, layoutParams);
1181     EXPECT_EQ(ret, ErrorCode::ERROR_PARAMETER_CHECK_FAILED);
1182     InputMethodPanelTest::ImaDestroyPanel(inputMethodPanel);
1183     InputMethodPanelTest::imc_->Close();
1184     TddUtil::DestroyWindow();
1185 }
1186 
1187 /**
1188 * @tc.name: testAdjustPanelRect_003
1189 * @tc.desc: Test AdjustPanelRect with FLG_FIXED invalid params.
1190 * @tc.type: FUNC
1191 */
1192 HWTEST_F(InputMethodPanelTest, testAdjustPanelRect_003, TestSize.Level0)
1193 {
1194     InputMethodPanelTest::Attach();
1195     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
1196     PanelInfo panelInfo = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FIXED };
1197     InputMethodPanelTest::ImaCreatePanel(panelInfo, inputMethodPanel);
1198     PanelFlag panelFlag = PanelFlag::FLG_FIXED;
1199     LayoutParams layoutParams;
1200     layoutParams.landscapeRect = {0, -1, 0, 0};
1201     layoutParams.portraitRect = {0, -1, 0, 0};
1202     auto ret = inputMethodPanel->AdjustPanelRect(panelFlag, layoutParams);
1203     EXPECT_EQ(ret, ErrorCode::ERROR_PARAMETER_CHECK_FAILED);
1204     InputMethodPanelTest::ImaDestroyPanel(inputMethodPanel);
1205     InputMethodPanelTest::imc_->Close();
1206     TddUtil::DestroyWindow();
1207 }
1208 
1209 /**
1210 * @tc.name: testAdjustPanelRect_004
1211 * @tc.desc: Test AdjustPanelRect with FLG_FIXED invalid params.
1212 * @tc.type: FUNC
1213 */
1214 HWTEST_F(InputMethodPanelTest, testAdjustPanelRect_004, TestSize.Level0)
1215 {
1216     InputMethodPanelTest::Attach();
1217     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
1218     PanelInfo panelInfo = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FIXED };
1219     InputMethodPanelTest::ImaCreatePanel(panelInfo, inputMethodPanel);
1220     PanelFlag panelFlag = PanelFlag::FLG_FIXED;
1221     LayoutParams layoutParams;
1222     layoutParams.landscapeRect = {0, 0, -1, 0};
1223     layoutParams.portraitRect = {0, 0, -1, 0};
1224     auto ret = inputMethodPanel->AdjustPanelRect(panelFlag, layoutParams);
1225     EXPECT_EQ(ret, ErrorCode::ERROR_PARAMETER_CHECK_FAILED);
1226     InputMethodPanelTest::ImaDestroyPanel(inputMethodPanel);
1227     InputMethodPanelTest::imc_->Close();
1228     TddUtil::DestroyWindow();
1229 }
1230 
1231 /**
1232 * @tc.name: testAdjustPanelRect_005
1233 * @tc.desc: Test AdjustPanelRect with FLG_FIXED invalid params.
1234 * @tc.type: FUNC
1235 */
1236 HWTEST_F(InputMethodPanelTest, testAdjustPanelRect_005, TestSize.Level0)
1237 {
1238     InputMethodPanelTest::Attach();
1239     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
1240     PanelInfo panelInfo = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FIXED };
1241     InputMethodPanelTest::ImaCreatePanel(panelInfo, inputMethodPanel);
1242     PanelFlag panelFlag = PanelFlag::FLG_FIXED;
1243     LayoutParams layoutParams;
1244     layoutParams.landscapeRect = {0, 0, 0, -1};
1245     layoutParams.portraitRect = {0, 0, 0, -1};
1246     auto ret = inputMethodPanel->AdjustPanelRect(panelFlag, layoutParams);
1247     EXPECT_EQ(ret, ErrorCode::ERROR_PARAMETER_CHECK_FAILED);
1248     InputMethodPanelTest::ImaDestroyPanel(inputMethodPanel);
1249     InputMethodPanelTest::imc_->Close();
1250     TddUtil::DestroyWindow();
1251 }
1252 
1253 /**
1254 * @tc.name: testAdjustPanelRect_006
1255 * @tc.desc: Test AdjustPanelRect with FLG_FIXED valid params.
1256 * @tc.type: FUNC
1257 */
1258 HWTEST_F(InputMethodPanelTest, testAdjustPanelRect_006, TestSize.Level0)
1259 {
1260     InputMethodPanelTest::Attach();
1261     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
1262     PanelInfo panelInfo = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FIXED };
1263     InputMethodPanelTest::ImaCreatePanel(panelInfo, inputMethodPanel);
1264     auto defaultDisplay = Rosen::DisplayManager::GetInstance().GetDefaultDisplay();
1265     ASSERT_TRUE(defaultDisplay != nullptr);
1266     windowWidth_ = defaultDisplay->GetWidth();
1267     windowHeight_ = defaultDisplay->GetHeight();
1268     PanelFlag panelFlag = PanelFlag::FLG_FIXED;
1269     LayoutParams layoutParams;
1270     layoutParams.landscapeRect = {0, 0, windowHeight_, 0};
1271     layoutParams.portraitRect = {0, 0, windowWidth_, 0};
1272     auto ret = inputMethodPanel->AdjustPanelRect(panelFlag, layoutParams);
1273     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
1274     InputMethodPanelTest::ImaDestroyPanel(inputMethodPanel);
1275     InputMethodPanelTest::imc_->Close();
1276     TddUtil::DestroyWindow();
1277 }
1278 
1279 /**
1280 * @tc.name: testAdjustPanelRect_007
1281 * @tc.desc: Test AdjustPanelRect with FLG_FIXED invalid params.
1282 * @tc.type: FUNC
1283 */
1284 HWTEST_F(InputMethodPanelTest, testAdjustPanelRect_007, TestSize.Level0)
1285 {
1286     InputMethodPanelTest::Attach();
1287     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
1288     PanelInfo panelInfo = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FIXED };
1289     InputMethodPanelTest::ImaCreatePanel(panelInfo, inputMethodPanel);
1290     auto defaultDisplay = Rosen::DisplayManager::GetInstance().GetDefaultDisplay();
1291     ASSERT_TRUE(defaultDisplay != nullptr);
1292     windowWidth_ = defaultDisplay->GetWidth();
1293     windowHeight_ = defaultDisplay->GetHeight();
1294     PanelFlag panelFlag = PanelFlag::FLG_FIXED;
1295     LayoutParams layoutParams;
1296     layoutParams.landscapeRect = {0, 0, windowHeight_ + 1, 0};
1297     layoutParams.portraitRect = {0, 0, windowWidth_ + 1, 0};
1298     auto ret = inputMethodPanel->AdjustPanelRect(panelFlag, layoutParams);
1299     EXPECT_EQ(ret, ErrorCode::ERROR_PARAMETER_CHECK_FAILED);
1300     InputMethodPanelTest::ImaDestroyPanel(inputMethodPanel);
1301     InputMethodPanelTest::imc_->Close();
1302     TddUtil::DestroyWindow();
1303 }
1304 
1305 
1306 /**
1307 * @tc.name: testAdjustPanelRect_008
1308 * @tc.desc: Test AdjustPanelRect with FLG_FIXED invalid params.
1309 * @tc.type: FUNC
1310 */
1311 HWTEST_F(InputMethodPanelTest, testAdjustPanelRect_008, TestSize.Level0)
1312 {
1313     InputMethodPanelTest::Attach();
1314     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
1315     PanelInfo panelInfo = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FIXED };
1316     InputMethodPanelTest::ImaCreatePanel(panelInfo, inputMethodPanel);
1317     auto defaultDisplay = Rosen::DisplayManager::GetInstance().GetDefaultDisplay();
1318     ASSERT_TRUE(defaultDisplay != nullptr);
1319     windowWidth_ = defaultDisplay->GetWidth();
1320     windowHeight_ = defaultDisplay->GetHeight();
1321     PanelFlag panelFlag = PanelFlag::FLG_FIXED;
1322     LayoutParams layoutParams;
1323     layoutParams.landscapeRect = {0, 0, windowHeight_, windowWidth_*0.7 + 1};
1324     layoutParams.portraitRect = {0, 0, windowWidth_, windowHeight_*0.7 + 1};
1325     auto ret = inputMethodPanel->AdjustPanelRect(panelFlag, layoutParams);
1326     EXPECT_EQ(ret, ErrorCode::ERROR_PARAMETER_CHECK_FAILED);
1327     InputMethodPanelTest::ImaDestroyPanel(inputMethodPanel);
1328     InputMethodPanelTest::imc_->Close();
1329     TddUtil::DestroyWindow();
1330 }
1331 
1332 /**
1333 * @tc.name: testAdjustPanelRect_009
1334 * @tc.desc: Test AdjustPanelRect with FLG_FIXED valid params.
1335 * @tc.type: FUNC
1336 */
1337 HWTEST_F(InputMethodPanelTest, testAdjustPanelRect_009, TestSize.Level0)
1338 {
1339     InputMethodPanelTest::Attach();
1340     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
1341     PanelInfo panelInfo = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FIXED };
1342     InputMethodPanelTest::ImaCreatePanel(panelInfo, inputMethodPanel);
1343     auto defaultDisplay = Rosen::DisplayManager::GetInstance().GetDefaultDisplay();
1344     ASSERT_TRUE(defaultDisplay != nullptr);
1345     windowWidth_ = defaultDisplay->GetWidth();
1346     windowHeight_ = defaultDisplay->GetHeight();
1347     PanelFlag panelFlag = PanelFlag::FLG_FIXED;
1348     LayoutParams layoutParams;
1349     layoutParams.landscapeRect = {0, 0, windowHeight_, windowWidth_*0.7};
1350     layoutParams.portraitRect = {0, 0, windowWidth_, windowHeight_*0.7};
1351     auto ret = inputMethodPanel->AdjustPanelRect(panelFlag, layoutParams);
1352     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
1353     InputMethodPanelTest::ImaDestroyPanel(inputMethodPanel);
1354     InputMethodPanelTest::imc_->Close();
1355     TddUtil::DestroyWindow();
1356 }
1357 
1358 /**
1359 * @tc.name: testAdjustPanelRect_010
1360 * @tc.desc: Test AdjustPanelRect with FLG_FLOATING valid params.
1361 * @tc.type: FUNC
1362 */
1363 HWTEST_F(InputMethodPanelTest, testAdjustPanelRect_010, TestSize.Level0)
1364 {
1365     InputMethodPanelTest::Attach();
1366     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
1367     PanelInfo panelInfo = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FLOATING };
1368     InputMethodPanelTest::ImaCreatePanel(panelInfo, inputMethodPanel);
1369     PanelFlag panelFlag = PanelFlag::FLG_FLOATING;
1370     LayoutParams layoutParams;
1371     layoutParams.landscapeRect = {0, 0, 0, 0};
1372     layoutParams.portraitRect = {0, 0, 0, 0};
1373     auto ret = inputMethodPanel->AdjustPanelRect(panelFlag, layoutParams);
1374     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
1375     InputMethodPanelTest::ImaDestroyPanel(inputMethodPanel);
1376     InputMethodPanelTest::imc_->Close();
1377     TddUtil::DestroyWindow();
1378 }
1379 
1380 /**
1381 * @tc.name: testAdjustPanelRect_011
1382 * @tc.desc: Test AdjustPanelRect with FLG_FLOATING invalid params.
1383 * @tc.type: FUNC
1384 */
1385 HWTEST_F(InputMethodPanelTest, testAdjustPanelRect_011, TestSize.Level0)
1386 {
1387     InputMethodPanelTest::Attach();
1388     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
1389     PanelInfo panelInfo = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FLOATING };
1390     InputMethodPanelTest::ImaCreatePanel(panelInfo, inputMethodPanel);
1391     PanelFlag panelFlag = PanelFlag::FLG_FLOATING;
1392     LayoutParams layoutParams;
1393     layoutParams.landscapeRect = {-1, 0, 0, 0};
1394     layoutParams.portraitRect = {-1, 0, 0, 0};
1395     auto ret = inputMethodPanel->AdjustPanelRect(panelFlag, layoutParams);
1396     EXPECT_EQ(ret, ErrorCode::ERROR_PARAMETER_CHECK_FAILED);
1397     InputMethodPanelTest::ImaDestroyPanel(inputMethodPanel);
1398     InputMethodPanelTest::imc_->Close();
1399     TddUtil::DestroyWindow();
1400 }
1401 
1402 /**
1403 * @tc.name: testAdjustPanelRect_012
1404 * @tc.desc: Test AdjustPanelRect with FLG_FLOATING invalid params.
1405 * @tc.type: FUNC
1406 */
1407 HWTEST_F(InputMethodPanelTest, testAdjustPanelRect_012, TestSize.Level0)
1408 {
1409     InputMethodPanelTest::Attach();
1410     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
1411     PanelInfo panelInfo = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FLOATING };
1412     InputMethodPanelTest::ImaCreatePanel(panelInfo, inputMethodPanel);
1413     PanelFlag panelFlag = PanelFlag::FLG_FLOATING;
1414     LayoutParams layoutParams;
1415     layoutParams.landscapeRect = {0, -1, 0, 0};
1416     layoutParams.portraitRect = {0, -1, 0, 0};
1417     auto ret = inputMethodPanel->AdjustPanelRect(panelFlag, layoutParams);
1418     EXPECT_EQ(ret, ErrorCode::ERROR_PARAMETER_CHECK_FAILED);
1419     InputMethodPanelTest::ImaDestroyPanel(inputMethodPanel);
1420     InputMethodPanelTest::imc_->Close();
1421     TddUtil::DestroyWindow();
1422 }
1423 
1424 /**
1425 * @tc.name: testAdjustPanelRect_013
1426 * @tc.desc: Test AdjustPanelRect with FLG_FLOATING invalid params.
1427 * @tc.type: FUNC
1428 */
1429 HWTEST_F(InputMethodPanelTest, testAdjustPanelRect_013, TestSize.Level0)
1430 {
1431     InputMethodPanelTest::Attach();
1432     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
1433     PanelInfo panelInfo = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FLOATING };
1434     InputMethodPanelTest::ImaCreatePanel(panelInfo, inputMethodPanel);
1435     PanelFlag panelFlag = PanelFlag::FLG_FLOATING;
1436     LayoutParams layoutParams;
1437     layoutParams.landscapeRect = {0, 0, -1, 0};
1438     layoutParams.portraitRect = {0, 0, -1, 0};
1439     auto ret = inputMethodPanel->AdjustPanelRect(panelFlag, layoutParams);
1440     EXPECT_EQ(ret, ErrorCode::ERROR_PARAMETER_CHECK_FAILED);
1441     InputMethodPanelTest::ImaDestroyPanel(inputMethodPanel);
1442     InputMethodPanelTest::imc_->Close();
1443     TddUtil::DestroyWindow();
1444 }
1445 
1446 /**
1447 * @tc.name: testAdjustPanelRect_014
1448 * @tc.desc: Test AdjustPanelRect with FLG_FLOATING valid params.
1449 * @tc.type: FUNC
1450 */
1451 HWTEST_F(InputMethodPanelTest, testAdjustPanelRect_014, TestSize.Level0)
1452 {
1453     InputMethodPanelTest::Attach();
1454     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
1455     PanelInfo panelInfo = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FLOATING };
1456     InputMethodPanelTest::ImaCreatePanel(panelInfo, inputMethodPanel);
1457     auto defaultDisplay = Rosen::DisplayManager::GetInstance().GetDefaultDisplay();
1458     ASSERT_TRUE(defaultDisplay != nullptr);
1459     windowWidth_ = defaultDisplay->GetWidth();
1460     windowHeight_ = defaultDisplay->GetHeight();
1461     PanelFlag panelFlag = PanelFlag::FLG_FLOATING;
1462     LayoutParams layoutParams;
1463     layoutParams.landscapeRect = {0, 0, windowWidth_, 0};
1464     layoutParams.portraitRect = {0, 0, windowWidth_, 0};
1465     auto ret = inputMethodPanel->AdjustPanelRect(panelFlag, layoutParams);
1466     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
1467     InputMethodPanelTest::ImaDestroyPanel(inputMethodPanel);
1468     InputMethodPanelTest::imc_->Close();
1469     TddUtil::DestroyWindow();
1470 }
1471 
1472 /**
1473 * @tc.name: testAdjustPanelRect_015
1474 * @tc.desc: Test AdjustPanelRect with FLG_FLOATING invalid params.
1475 * @tc.type: FUNC
1476 */
1477 HWTEST_F(InputMethodPanelTest, testAdjustPanelRect_015, TestSize.Level0)
1478 {
1479     InputMethodPanelTest::Attach();
1480     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
1481     PanelInfo panelInfo = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FLOATING };
1482     InputMethodPanelTest::ImaCreatePanel(panelInfo, inputMethodPanel);
1483     auto defaultDisplay = Rosen::DisplayManager::GetInstance().GetDefaultDisplay();
1484     ASSERT_TRUE(defaultDisplay != nullptr);
1485     windowWidth_ = defaultDisplay->GetWidth();
1486     windowHeight_ = defaultDisplay->GetHeight();
1487     PanelFlag panelFlag = PanelFlag::FLG_FLOATING;
1488     LayoutParams layoutParams;
1489     layoutParams.landscapeRect = {0, 0, windowHeight_+1, 0};
1490     layoutParams.portraitRect = {0, 0, windowWidth_+1, 0};
1491     auto ret = inputMethodPanel->AdjustPanelRect(panelFlag, layoutParams);
1492     EXPECT_EQ(ret, ErrorCode::ERROR_PARAMETER_CHECK_FAILED);
1493     InputMethodPanelTest::ImaDestroyPanel(inputMethodPanel);
1494     InputMethodPanelTest::imc_->Close();
1495     TddUtil::DestroyWindow();
1496 }
1497 
1498 /**
1499 * @tc.name: testAdjustPanelRect_016
1500 * @tc.desc: Test AdjustPanelRect with FLG_FLOATING valid params.
1501 * @tc.type: FUNC
1502 */
1503 HWTEST_F(InputMethodPanelTest, testAdjustPanelRect_016, TestSize.Level0)
1504 {
1505     InputMethodPanelTest::Attach();
1506     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
1507     PanelInfo panelInfo = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FLOATING };
1508     InputMethodPanelTest::ImaCreatePanel(panelInfo, inputMethodPanel);
1509     auto defaultDisplay = Rosen::DisplayManager::GetInstance().GetDefaultDisplay();
1510     ASSERT_TRUE(defaultDisplay != nullptr);
1511     windowWidth_ = defaultDisplay->GetWidth();
1512     windowHeight_ = defaultDisplay->GetHeight();
1513     PanelFlag panelFlag = PanelFlag::FLG_FLOATING;
1514     LayoutParams layoutParams;
1515     layoutParams.landscapeRect = {0, 0, windowHeight_, windowWidth_*0.7 + 1};
1516     layoutParams.portraitRect = {0, 0, windowWidth_, windowHeight_*0.7 + 1};
1517     auto ret = inputMethodPanel->AdjustPanelRect(panelFlag, layoutParams);
1518     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
1519     InputMethodPanelTest::ImaDestroyPanel(inputMethodPanel);
1520     InputMethodPanelTest::imc_->Close();
1521     TddUtil::DestroyWindow();
1522 }
1523 
1524 /**
1525 * @tc.name: testAdjustPanelRect_017
1526 * @tc.desc: Test AdjustPanelRect with FLG_FLOATING valid params.
1527 * @tc.type: FUNC
1528 */
1529 HWTEST_F(InputMethodPanelTest, testAdjustPanelRect_017, TestSize.Level0)
1530 {
1531     InputMethodPanelTest::Attach();
1532     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
1533     PanelInfo panelInfo = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FLOATING };
1534     InputMethodPanelTest::ImaCreatePanel(panelInfo, inputMethodPanel);
1535     auto defaultDisplay = Rosen::DisplayManager::GetInstance().GetDefaultDisplay();
1536     ASSERT_TRUE(defaultDisplay != nullptr);
1537     windowWidth_ = defaultDisplay->GetWidth();
1538     windowHeight_ = defaultDisplay->GetHeight();
1539     PanelFlag panelFlag = PanelFlag::FLG_FLOATING;
1540     LayoutParams layoutParams;
1541     layoutParams.landscapeRect = {0, 0, windowHeight_, windowWidth_};
1542     layoutParams.portraitRect = {0, 0, windowWidth_, windowHeight_};
1543     auto ret = inputMethodPanel->AdjustPanelRect(panelFlag, layoutParams);
1544     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
1545     InputMethodPanelTest::ImaDestroyPanel(inputMethodPanel);
1546     InputMethodPanelTest::imc_->Close();
1547     TddUtil::DestroyWindow();
1548 }
1549 
1550 /**
1551 * @tc.name: testAdjustPanelRect_018
1552 * @tc.desc: Test AdjustPanelRect with FLG_FLOATING invalid params.
1553 * @tc.type: FUNC
1554 */
1555 HWTEST_F(InputMethodPanelTest, testAdjustPanelRect_018, TestSize.Level0)
1556 {
1557     InputMethodPanelTest::Attach();
1558     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
1559     PanelInfo panelInfo = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FLOATING };
1560     InputMethodPanelTest::ImaCreatePanel(panelInfo, inputMethodPanel);
1561     auto defaultDisplay = Rosen::DisplayManager::GetInstance().GetDefaultDisplay();
1562     ASSERT_TRUE(defaultDisplay != nullptr);
1563     windowWidth_ = defaultDisplay->GetWidth();
1564     windowHeight_ = defaultDisplay->GetHeight();
1565     PanelFlag panelFlag = PanelFlag::FLG_FLOATING;
1566     LayoutParams layoutParams;
1567     layoutParams.landscapeRect = {0, 0, windowHeight_, windowWidth_ + 1};
1568     layoutParams.portraitRect = {0, 0, windowWidth_, windowHeight_ + 1};
1569     auto ret = inputMethodPanel->AdjustPanelRect(panelFlag, layoutParams);
1570     EXPECT_EQ(ret, ErrorCode::ERROR_PARAMETER_CHECK_FAILED);
1571     InputMethodPanelTest::ImaDestroyPanel(inputMethodPanel);
1572     InputMethodPanelTest::imc_->Close();
1573     TddUtil::DestroyWindow();
1574 }
1575 
1576 /**
1577 * @tc.name: testSetPrivacyMode
1578 * @tc.desc: Test SetPrivacyMode.
1579 * @tc.type: FUNC
1580 */
1581 HWTEST_F(InputMethodPanelTest, testSetPrivacyMode, TestSize.Level0)
1582 {
1583     InputMethodPanelTest::Attach();
1584     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
1585     PanelInfo panelInfo = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FLOATING };
1586     InputMethodPanelTest::ImaCreatePanel(panelInfo, inputMethodPanel);
1587     auto ret = inputMethodPanel->SetPrivacyMode(true);
1588     EXPECT_NE(ret, ErrorCode::NO_ERROR);
1589     InputMethodPanelTest::ImaDestroyPanel(inputMethodPanel);
1590     InputMethodPanelTest::imc_->Close();
1591     TddUtil::DestroyWindow();
1592 }
1593 
1594 /**
1595  * @tc.name: testStartMoving01
1596  * @tc.desc: Test StartMoving
1597  * @tc.type: FUNC
1598  */
1599 HWTEST_F(InputMethodPanelTest, testStartMoving01, TestSize.Level0)
1600 {
1601     IMSA_HILOGI("InputMethodPanelTest::testStartMoving start.");
1602     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
1603     auto ret = inputMethodPanel->StartMoving();
1604     EXPECT_EQ(ret, ErrorCode::ERROR_IME);
1605 
1606     AccessScope scope(currentImeTokenId_, currentImeUid_);
1607     PanelInfo panelInfo = { .panelType = STATUS_BAR, .panelFlag = FLG_FLOATING };
1608     ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
1609     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
1610     ret = inputMethodPanel->StartMoving();
1611     EXPECT_GE(ret, ErrorCode::NO_ERROR);
1612     ret = inputMethodPanel->DestroyPanel();
1613     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
1614 
1615     panelInfo.panelType = SOFT_KEYBOARD;
1616     ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
1617     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
1618     ret = inputMethodPanel->StartMoving();
1619     EXPECT_EQ(ret, ErrorCode::ERROR_INVALID_PANEL_TYPE);
1620     ret = inputMethodPanel->DestroyPanel();
1621     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
1622 
1623     panelInfo.panelType = STATUS_BAR;
1624     panelInfo.panelFlag = FLG_FIXED;
1625     ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
1626     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
1627     ret = inputMethodPanel->StartMoving();
1628     EXPECT_EQ(ret, ErrorCode::ERROR_INVALID_PANEL_FLAG);
1629     ret = inputMethodPanel->DestroyPanel();
1630     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
1631 }
1632 
1633 /**
1634  * @tc.name: testGetDisplayId01
1635  * @tc.desc: Test GetDisplayId
1636  * @tc.type: FUNC
1637  */
1638 HWTEST_F(InputMethodPanelTest, testGetDisplayId01, TestSize.Level0)
1639 {
1640     IMSA_HILOGI("InputMethodPanelTest::testGetDisplayId start.");
1641     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
1642     uint64_t displayId;
1643     auto ret = inputMethodPanel->GetDisplayId(displayId);
1644     EXPECT_EQ(ret, ErrorCode::ERROR_IME);
1645 
1646     AccessScope scope(currentImeTokenId_, currentImeUid_);
1647     PanelInfo panelInfo = { .panelType = STATUS_BAR, .panelFlag = FLG_FLOATING };
1648     ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
1649     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
1650 
1651     ret = inputMethodPanel->GetDisplayId(displayId);
1652     EXPECT_GE(ret, ErrorCode::NO_ERROR);
1653 
1654     ret = inputMethodPanel->DestroyPanel();
1655     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
1656 }
1657 
1658 /**
1659  * @tc.name: testSetImmersiveMode
1660  * @tc.desc: Test set immersive mode.
1661  * @tc.type: FUNC
1662  */
1663 HWTEST_F(InputMethodPanelTest, testSetImmersiveMode, TestSize.Level0)
1664 {
1665     IMSA_HILOGI("InputMethodPanelTest::testSetImmersiveMode start.");
1666     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
1667     PanelInfo panelInfo = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FIXED };
1668 
1669     AccessScope scope(currentImeTokenId_, currentImeUid_);
1670     auto ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
1671     EXPECT_EQ(ErrorCode::NO_ERROR, ret);
1672     ret = inputMethodPanel->ShowPanel();
1673     EXPECT_EQ(ErrorCode::NO_ERROR, ret);
1674 
1675     ret = inputMethodPanel->SetImmersiveMode(ImmersiveMode::NONE_IMMERSIVE);
1676     EXPECT_EQ(ErrorCode::NO_ERROR, ret);
1677     ret = inputMethodPanel->SetImmersiveMode(ImmersiveMode::LIGHT_IMMERSIVE);
1678     EXPECT_EQ(ErrorCode::NO_ERROR, ret);
1679     ret = inputMethodPanel->SetImmersiveMode(ImmersiveMode::DARK_IMMERSIVE);
1680     EXPECT_EQ(ErrorCode::NO_ERROR, ret);
1681     ret = inputMethodPanel->SetImmersiveMode(ImmersiveMode::IMMERSIVE);
1682     EXPECT_EQ(ErrorCode::ERROR_PARAMETER_CHECK_FAILED, ret);
1683 
1684     ret = inputMethodPanel->HidePanel();
1685     EXPECT_EQ(ErrorCode::NO_ERROR, ret);
1686     ret = inputMethodPanel->DestroyPanel();
1687     EXPECT_EQ(ErrorCode::NO_ERROR, ret);
1688 }
1689 
1690 /**
1691  * @tc.name: testGetImmersiveMode
1692  * @tc.desc: Test get immersive mode.
1693  * @tc.type: FUNC
1694  */
1695 HWTEST_F(InputMethodPanelTest, testGetImmersiveMode, TestSize.Level0)
1696 {
1697     IMSA_HILOGI("InputMethodPanelTest::testGetImmersiveMode start.");
1698     auto inputMethodPanel = std::make_shared<InputMethodPanel>();
1699     PanelInfo panelInfo = { .panelType = SOFT_KEYBOARD, .panelFlag = FLG_FIXED };
1700 
1701     AccessScope scope(currentImeTokenId_, currentImeUid_);
1702     auto ret = inputMethodPanel->CreatePanel(nullptr, panelInfo);
1703     EXPECT_EQ(ErrorCode::NO_ERROR, ret);
1704     ret = inputMethodPanel->ShowPanel();
1705     EXPECT_EQ(ErrorCode::NO_ERROR, ret);
1706 
1707     ret = inputMethodPanel->SetImmersiveMode(ImmersiveMode::NONE_IMMERSIVE);
1708     EXPECT_EQ(ErrorCode::NO_ERROR, ret);
1709     auto mode = inputMethodPanel->GetImmersiveMode();
1710     EXPECT_EQ(ImmersiveMode::NONE_IMMERSIVE, mode);
1711 
1712     ret = inputMethodPanel->HidePanel();
1713     EXPECT_EQ(ErrorCode::NO_ERROR, ret);
1714     ret = inputMethodPanel->DestroyPanel();
1715     EXPECT_EQ(ErrorCode::NO_ERROR, ret);
1716 }
1717 } // namespace MiscServices
1718 } // namespace OHOS