1 /*
2  * Copyright (C) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #define private public
17 #define protected public
18 #include "ime_cfg_manager.h"
19 #include "input_method_ability.h"
20 #include "input_method_controller.h"
21 #include "input_method_system_ability.h"
22 #include "inputmethod_sysevent.h"
23 #undef private
24 
25 #include <gtest/gtest.h>
26 #include <sys/time.h>
27 #include <unistd.h>
28 
29 #include <cstdint>
30 #include <string>
31 
32 #include "global.h"
33 #include "hisysevent_base_manager.h"
34 #include "hisysevent_listener.h"
35 #include "hisysevent_manager.h"
36 #include "hisysevent_query_callback.h"
37 #include "hisysevent_record.h"
38 #include "identity_checker_mock.h"
39 #include "input_method_ability.h"
40 #include "input_method_controller.h"
41 #include "input_method_engine_listener_impl.h"
42 #include "tdd_util.h"
43 #include "text_listener.h"
44 
45 using namespace testing::ext;
46 using namespace OHOS::HiviewDFX;
47 namespace OHOS {
48 namespace MiscServices {
49 using WindowMgr = TddUtil::WindowManager;
50 constexpr const char *CMD1 = "hidumper -s 3703 -a -a";
51 constexpr const char *CMD2 = "hidumper -s 3703 -a -h";
52 constexpr const char *CMD3 = "hidumper -s 3703 -a -test";
53 constexpr const char *PARAM_KEY = "OPERATE_INFO";
54 constexpr const char *STATE = "STATE";
55 constexpr const char *PID = "PID";
56 constexpr const char *BUNDLE_NAME = "BUNDLE_NAME";
57 constexpr const char *DOMAIN = "INPUTMETHOD";
58 constexpr const char *OPERATE_SOFTKEYBOARD_EVENT_NAME = "OPERATE_SOFTKEYBOARD";
59 constexpr const char *IME_STATE_CHANGED_EVENT_NAME = "IME_STATE_CHANGED";
60 
61 class Watcher : public HiSysEventListener {
62 public:
Watcher(const std::string & operateInfo)63     explicit Watcher(const std::string &operateInfo) : operateInfo_(operateInfo)
64     {
65     }
~Watcher()66     virtual ~Watcher()
67     {
68     }
OnEvent(std::shared_ptr<HiSysEventRecord> sysEvent)69     void OnEvent(std::shared_ptr<HiSysEventRecord> sysEvent) final
70     {
71         if (sysEvent == nullptr) {
72             IMSA_HILOGE("sysEvent is nullptr!");
73             return;
74         }
75         std::string result;
76         sysEvent->GetParamValue(PARAM_KEY, result);
77         IMSA_HILOGI("result = %{public}s", result.c_str());
78         if (result != operateInfo_) {
79             IMSA_HILOGE("string is not matched.");
80             return;
81         }
82         std::unique_lock<std::mutex> lock(cvMutex_);
83         watcherCv_.notify_all();
84     }
OnServiceDied()85     void OnServiceDied() final
86     {
87         IMSA_HILOGE("Watcher::OnServiceDied");
88     }
89     std::mutex cvMutex_;
90     std::condition_variable watcherCv_;
91 
92 private:
93     std::string operateInfo_;
94 };
95 
96 class WatcherImeChange : public HiSysEventListener {
97 public:
WatcherImeChange(const std::string & state,const std::string & pid,const std::string & bundleName)98     explicit WatcherImeChange(const std::string &state, const std::string &pid, const std::string &bundleName)
99         : state_(state), pid_(pid), bundleName_(bundleName)
100     {
101     }
~WatcherImeChange()102     virtual ~WatcherImeChange()
103     {
104     }
OnEvent(std::shared_ptr<HiSysEventRecord> sysEvent)105     void OnEvent(std::shared_ptr<HiSysEventRecord> sysEvent) final
106     {
107         if (sysEvent == nullptr) {
108             IMSA_HILOGE("sysEvent is nullptr!");
109             return;
110         }
111         std::string pid;
112         std::string state;
113         std::string bundleName;
114         sysEvent->GetParamValue(STATE, state);
115         sysEvent->GetParamValue(PID, pid);
116         sysEvent->GetParamValue(BUNDLE_NAME, bundleName);
117         IMSA_HILOGI("bundleName: %{public}s, state: %{public}s, pid: %{public}s", bundleName.c_str(), state.c_str(),
118             pid.c_str());
119         if (state != state_ || pid != pid_ || bundleName != bundleName_) {
120             IMSA_HILOGE("string is not matched.");
121             return;
122         }
123         std::unique_lock<std::mutex> lock(cvMutexImeChange_);
124         watcherCvImeChange_.notify_all();
125     }
OnServiceDied()126     void OnServiceDied() final
127     {
128         IMSA_HILOGE("WatcherImeChange::OnServiceDied");
129     }
130     std::mutex cvMutexImeChange_;
131     std::condition_variable watcherCvImeChange_;
132 
133 private:
134     std::string state_;
135     std::string pid_;
136     std::string bundleName_;
137 };
138 
139 class InputMethodDfxTest : public testing::Test {
140 public:
141     using ExecFunc = std::function<void()>;
142     static void SetUpTestCase(void);
143     static void TearDownTestCase(void);
144     static bool WriteAndWatch(const std::shared_ptr<Watcher> &watcher, const InputMethodDfxTest::ExecFunc &exec);
145     static bool WriteAndWatchImeChange(
146         const std::shared_ptr<WatcherImeChange> &watcher, const InputMethodDfxTest::ExecFunc &exec);
147     void SetUp();
148     void TearDown();
149     static sptr<InputMethodController> inputMethodController_;
150     static sptr<OnTextChangedListener> textListener_;
151     static sptr<InputMethodAbility> inputMethodAbility_;
152     static std::shared_ptr<InputMethodEngineListenerImpl> imeListener_;
153     static sptr<InputMethodSystemAbility> imsa_;
154 };
155 sptr<InputMethodController> InputMethodDfxTest::inputMethodController_;
156 sptr<OnTextChangedListener> InputMethodDfxTest::textListener_;
157 sptr<InputMethodAbility> InputMethodDfxTest::inputMethodAbility_;
158 std::shared_ptr<InputMethodEngineListenerImpl> InputMethodDfxTest::imeListener_;
159 sptr<InputMethodSystemAbility> InputMethodDfxTest::imsa_;
160 
WriteAndWatch(const std::shared_ptr<Watcher> & watcher,const InputMethodDfxTest::ExecFunc & exec)161 bool InputMethodDfxTest::WriteAndWatch(
162     const std::shared_ptr<Watcher> &watcher, const InputMethodDfxTest::ExecFunc &exec)
163 {
164     OHOS::HiviewDFX::ListenerRule listenerRule(
165         DOMAIN, OPERATE_SOFTKEYBOARD_EVENT_NAME, "", OHOS::HiviewDFX::RuleType::WHOLE_WORD);
166     std::vector<OHOS::HiviewDFX::ListenerRule> sysRules;
167     sysRules.emplace_back(listenerRule);
168     auto ret = OHOS::HiviewDFX::HiSysEventManager::AddListener(watcher, sysRules);
169     if (ret != SUCCESS) {
170         IMSA_HILOGE("AddListener failed! ret = %{public}d", ret);
171         return false;
172     }
173     std::unique_lock<std::mutex> lock(watcher->cvMutex_);
174     exec();
175     bool result = watcher->watcherCv_.wait_for(lock, std::chrono::seconds(3)) != std::cv_status::timeout;
176     ret = OHOS::HiviewDFX::HiSysEventManager::RemoveListener(watcher);
177     if (ret != SUCCESS || !result) {
178         IMSA_HILOGE("RemoveListener ret = %{public}d, wait_for result = %{public}s", ret, result ? "true" : "false");
179         return false;
180     }
181     return true;
182 }
183 
WriteAndWatchImeChange(const std::shared_ptr<WatcherImeChange> & watcher,const InputMethodDfxTest::ExecFunc & exec)184 bool InputMethodDfxTest::WriteAndWatchImeChange(
185     const std::shared_ptr<WatcherImeChange> &watcher, const InputMethodDfxTest::ExecFunc &exec)
186 {
187     OHOS::HiviewDFX::ListenerRule listenerRule(
188         DOMAIN, IME_STATE_CHANGED_EVENT_NAME, "", OHOS::HiviewDFX::RuleType::WHOLE_WORD);
189     std::vector<OHOS::HiviewDFX::ListenerRule> sysRules;
190     sysRules.emplace_back(listenerRule);
191     auto ret = OHOS::HiviewDFX::HiSysEventManager::AddListener(watcher, sysRules);
192     if (ret != SUCCESS) {
193         IMSA_HILOGE("AddListener failed! ret = %{public}d", ret);
194         return false;
195     }
196     std::unique_lock<std::mutex> lock(watcher->cvMutexImeChange_);
197     exec();
198     bool result = watcher->watcherCvImeChange_.wait_for(lock, std::chrono::seconds(1)) != std::cv_status::timeout;
199     ret = OHOS::HiviewDFX::HiSysEventManager::RemoveListener(watcher);
200     if (ret != SUCCESS || !result) {
201         IMSA_HILOGE("RemoveListener ret = %{public}d, wait_for result = %{public}s", ret, result ? "true" : "false");
202         return false;
203     }
204     return true;
205 }
206 
SetUpTestCase(void)207 void InputMethodDfxTest::SetUpTestCase(void)
208 {
209     IMSA_HILOGI("InputMethodDfxTest::SetUpTestCase");
210     IdentityCheckerMock::ResetParam();
211     imsa_ = new (std::nothrow) InputMethodSystemAbility();
212     if (imsa_ == nullptr) {
213         return;
214     }
215     imsa_->OnStart();
216     imsa_->userId_ = TddUtil::GetCurrentUserId();
217     imsa_->identityChecker_ = std::make_shared<IdentityCheckerMock>();
218     IdentityCheckerMock::SetFocused(true);
219 
220     inputMethodAbility_ = InputMethodAbility::GetInstance();
221     imeListener_ = std::make_shared<InputMethodEngineListenerImpl>();
222     inputMethodAbility_->abilityManager_ = imsa_;
223     TddUtil::InitCurrentImePermissionInfo();
224     IdentityCheckerMock::SetBundleName(TddUtil::currentBundleNameMock_);
225     inputMethodAbility_->SetCoreAndAgent();
226     inputMethodAbility_->SetImeListener(imeListener_);
227 
228     inputMethodController_ = InputMethodController::GetInstance();
229     inputMethodController_->abilityManager_ = imsa_;
230     textListener_ = new TextListener();
231 }
232 
TearDownTestCase(void)233 void InputMethodDfxTest::TearDownTestCase(void)
234 {
235     IMSA_HILOGI("InputMethodDfxTest::TearDownTestCase");
236     IdentityCheckerMock::ResetParam();
237     imsa_->OnStop();
238     ImeCfgManager::GetInstance().imeConfigs_.clear();
239 }
240 
SetUp(void)241 void InputMethodDfxTest::SetUp(void)
242 {
243     IMSA_HILOGI("InputMethodDfxTest::SetUp");
244 }
245 
TearDown(void)246 void InputMethodDfxTest::TearDown(void)
247 {
248     IMSA_HILOGI("InputMethodDfxTest::TearDown");
249 }
250 
251 /**
252 * @tc.name: InputMethodDfxTest_DumpAllMethod_001
253 * @tc.desc: DumpAllMethod
254 * @tc.type: FUNC
255 * @tc.require: issueI61PMG
256 * @tc.author: chenyu
257 */
258 HWTEST_F(InputMethodDfxTest, InputMethodDfxTest_DumpAllMethod_001, TestSize.Level0)
259 {
260     IMSA_HILOGI("InputMethodDfxTest::InputMethodDfxTest_DumpAllMethod_001");
261     std::string result;
262     auto ret = TddUtil::ExecuteCmd(CMD1, result);
263     EXPECT_TRUE(ret);
264     EXPECT_NE(result.find("imeList"), std::string::npos);
265     EXPECT_NE(result.find("com.example.testIme"), std::string::npos);
266 }
267 
268 /**
269 * @tc.name: InputMethodDfxTest_Dump_ShowHelp_001
270 * @tc.desc: Dump ShowHelp.
271 * @tc.type: FUNC
272 * @tc.require: issueI61PMG
273 * @tc.author: chenyu
274 */
275 HWTEST_F(InputMethodDfxTest, InputMethodDfxTest_Dump_ShowHelp_001, TestSize.Level0)
276 {
277     IMSA_HILOGI("InputMethodDfxTest::InputMethodDfxTest_Dump_ShowHelp_001");
278     std::string result;
279     auto ret = TddUtil::ExecuteCmd(CMD2, result);
280     EXPECT_TRUE(ret);
281     EXPECT_NE(result.find("Description:"), std::string::npos);
282     EXPECT_NE(result.find("-h show help"), std::string::npos);
283     EXPECT_NE(result.find("-a dump all input methods"), std::string::npos);
284 }
285 
286 /**
287 * @tc.name: InputMethodDfxTest_Dump_ShowIllealInformation_001
288 * @tc.desc: Dump ShowIllealInformation.
289 * @tc.type: FUNC
290 * @tc.require: issueI61PMG
291 * @tc.author: chenyu
292 */
293 HWTEST_F(InputMethodDfxTest, InputMethodDfxTest_Dump_ShowIllealInformation_001, TestSize.Level0)
294 {
295     IMSA_HILOGI("InputMethodDfxTest::InputMethodDfxTest_Dump_ShowIllealInformation_001");
296     std::string result;
297     auto ret = TddUtil::ExecuteCmd(CMD3, result);
298     EXPECT_TRUE(ret);
299     EXPECT_NE(result.find("input dump parameter error,enter '-h' for usage."), std::string::npos);
300 }
301 
302 /**
303 * @tc.name: InputMethodDfxTest_Hisysevent_Attach
304 * @tc.desc: Hisysevent attach.
305 * @tc.type: FUNC
306 */
307 HWTEST_F(InputMethodDfxTest, InputMethodDfxTest_Hisysevent_Attach, TestSize.Level0)
308 {
309     IMSA_HILOGI("InputMethodDfxTest::InputMethodDfxTest_Hisysevent_Attach");
310     auto watcher = std::make_shared<Watcher>(
311         InputMethodSysEvent::GetInstance().GetOperateInfo(static_cast<int32_t>(OperateIMEInfoCode::IME_SHOW_ATTACH)));
__anonff3e3efd0102() 312     auto attach = []() { inputMethodController_->Attach(textListener_, true); };
313     EXPECT_TRUE(InputMethodDfxTest::WriteAndWatch(watcher, attach));
314 }
315 
316 /**
317 * @tc.name: InputMethodDfxTest_Hisysevent_HideTextInput
318 * @tc.desc: Hisysevent HideTextInput.
319 * @tc.type: FUNC
320 */
321 HWTEST_F(InputMethodDfxTest, InputMethodDfxTest_Hisysevent_HideTextInput, TestSize.Level0)
322 {
323     IMSA_HILOGI("InputMethodDfxTest::InputMethodDfxTest_Hisysevent_HideTextInput");
324     auto ret = inputMethodController_->Attach(textListener_, true);
325     EXPECT_EQ(ret, ErrorCode::NO_ERROR);
326     auto watcher = std::make_shared<Watcher>(InputMethodSysEvent::GetInstance().GetOperateInfo(
327         static_cast<int32_t>(OperateIMEInfoCode::IME_HIDE_UNEDITABLE)));
__anonff3e3efd0202() 328     auto hideTextInput = []() { inputMethodController_->HideTextInput(); };
329     EXPECT_TRUE(InputMethodDfxTest::WriteAndWatch(watcher, hideTextInput));
330 }
331 
332 /**
333 * @tc.name: InputMethodDfxTest_Hisysevent_ShowTextInput
334 * @tc.desc: Hisysevent ShowTextInput.
335 * @tc.type: FUNC
336 */
337 HWTEST_F(InputMethodDfxTest, InputMethodDfxTest_Hisysevent_ShowTextInput, TestSize.Level0)
338 {
339     IMSA_HILOGI("InputMethodDfxTest::InputMethodDfxTest_Hisysevent_ShowTextInput");
340     auto watcher = std::make_shared<Watcher>(InputMethodSysEvent::GetInstance().GetOperateInfo(
341         static_cast<int32_t>(OperateIMEInfoCode::IME_SHOW_ENEDITABLE)));
__anonff3e3efd0302() 342     auto showTextInput = []() { inputMethodController_->ShowTextInput(); };
343     EXPECT_TRUE(InputMethodDfxTest::WriteAndWatch(watcher, showTextInput));
344 }
345 
346 /**
347 * @tc.name: InputMethodDfxTest_Hisysevent_HideCurrentInput
348 * @tc.desc: Hisysevent HideCurrentInput.
349 * @tc.type: FUNC
350 */
351 HWTEST_F(InputMethodDfxTest, InputMethodDfxTest_Hisysevent_HideCurrentInput, TestSize.Level0)
352 {
353     IMSA_HILOGI("InputMethodDfxTest::InputMethodDfxTest_Hisysevent_HideCurrentInput");
354     auto watcher = std::make_shared<Watcher>(
355         InputMethodSysEvent::GetInstance().GetOperateInfo(static_cast<int32_t>(OperateIMEInfoCode::IME_HIDE_NORMAL)));
__anonff3e3efd0402() 356     auto hideCurrentInput = []() { inputMethodController_->HideCurrentInput(); };
357     EXPECT_TRUE(InputMethodDfxTest::WriteAndWatch(watcher, hideCurrentInput));
358 }
359 
360 /**
361 * @tc.name: InputMethodDfxTest_Hisysevent_ShowCurrentInput
362 * @tc.desc: Hisysevent ShowCurrentInput.
363 * @tc.type: FUNC
364 */
365 HWTEST_F(InputMethodDfxTest, InputMethodDfxTest_Hisysevent_ShowCurrentInput, TestSize.Level0)
366 {
367     IMSA_HILOGI("InputMethodDfxTest::InputMethodDfxTest_Hisysevent_ShowCurrentInput");
368     auto watcher = std::make_shared<Watcher>(
369         InputMethodSysEvent::GetInstance().GetOperateInfo(static_cast<int32_t>(OperateIMEInfoCode::IME_SHOW_NORMAL)));
__anonff3e3efd0502() 370     auto showCurrentInput = []() { inputMethodController_->ShowCurrentInput(); };
371     EXPECT_TRUE(InputMethodDfxTest::WriteAndWatch(watcher, showCurrentInput));
372 }
373 
374 /**
375 * @tc.name: InputMethodDfxTest_Hisysevent_HideSoftKeyboard
376 * @tc.desc: Hisysevent HideSoftKeyboard.
377 * @tc.type: FUNC
378 */
379 HWTEST_F(InputMethodDfxTest, InputMethodDfxTest_Hisysevent_HideSoftKeyboard, TestSize.Level0)
380 {
381     IMSA_HILOGI("InputMethodDfxTest::InputMethodDfxTest_Hisysevent_HideSoftKeyboard");
382     auto watcher = std::make_shared<Watcher>(
383         InputMethodSysEvent::GetInstance().GetOperateInfo(static_cast<int32_t>(OperateIMEInfoCode::IME_HIDE_NORMAL)));
__anonff3e3efd0602() 384     auto hideSoftKeyboard = []() { inputMethodController_->HideSoftKeyboard(); };
385     EXPECT_TRUE(InputMethodDfxTest::WriteAndWatch(watcher, hideSoftKeyboard));
386 }
387 
388 /**
389 * @tc.name: InputMethodDfxTest_Hisysevent_ShowSoftKeyboard
390 * @tc.desc: Hisysevent ShowSoftKeyboard.
391 * @tc.type: FUNC
392 */
393 HWTEST_F(InputMethodDfxTest, InputMethodDfxTest_Hisysevent_ShowSoftKeyboard, TestSize.Level0)
394 {
395     IMSA_HILOGI("InputMethodDfxTest::InputMethodDfxTest_Hisysevent_ShowSoftKeyboard");
396     auto watcher = std::make_shared<Watcher>(
397         InputMethodSysEvent::GetInstance().GetOperateInfo(static_cast<int32_t>(OperateIMEInfoCode::IME_SHOW_NORMAL)));
__anonff3e3efd0702() 398     auto showSoftKeyboard = []() { inputMethodController_->ShowSoftKeyboard(); };
399     EXPECT_TRUE(InputMethodDfxTest::WriteAndWatch(watcher, showSoftKeyboard));
400 }
401 
402 /**
403 * @tc.name: InputMethodDfxTest_Hisysevent_HideKeyboardSelf
404 * @tc.desc: Hisysevent HideKeyboardSelf.
405 * @tc.type: FUNC
406 */
407 HWTEST_F(InputMethodDfxTest, InputMethodDfxTest_Hisysevent_HideKeyboardSelf, TestSize.Level0)
408 {
409     IMSA_HILOGI("InputMethodDfxTest::InputMethodDfxTest_Hisysevent_HideKeyboardSelf");
410     auto watcher = std::make_shared<Watcher>(
411         InputMethodSysEvent::GetInstance().GetOperateInfo(static_cast<int32_t>(OperateIMEInfoCode::IME_HIDE_SELF)));
__anonff3e3efd0802() 412     auto hideKeyboardSelf = []() { inputMethodAbility_->HideKeyboardSelf(); };
413     EXPECT_TRUE(InputMethodDfxTest::WriteAndWatch(watcher, hideKeyboardSelf));
414 }
415 
416 /**
417 * @tc.name: InputMethodDfxTest_Hisysevent_Close
418 * @tc.desc: Hisysevent Close.
419 * @tc.type: FUNC
420 */
421 HWTEST_F(InputMethodDfxTest, InputMethodDfxTest_Hisysevent_Close, TestSize.Level0)
422 {
423     IMSA_HILOGI("InputMethodDfxTest::InputMethodDfxTest_Hisysevent_Close");
424     auto watcher = std::make_shared<Watcher>(
425         InputMethodSysEvent::GetInstance().GetOperateInfo(static_cast<int32_t>(OperateIMEInfoCode::IME_UNBIND)));
__anonff3e3efd0902() 426     auto close = []() { inputMethodController_->Close(); };
427     EXPECT_TRUE(InputMethodDfxTest::WriteAndWatch(watcher, close));
428 }
429 
430 /**
431 * @tc.name: InputMethodDfxTest_Hisysevent_UnBind
432 * @tc.desc: Hisysevent UnBind.
433 * @tc.type: FUNC
434 */
435 HWTEST_F(InputMethodDfxTest, InputMethodDfxTest_Hisysevent_UnBind, TestSize.Level0)
436 {
437     IMSA_HILOGI("InputMethodDfxTest::InputMethodDfxTest_Hisysevent_UnBind");
438     auto watcherImeChange = std::make_shared<WatcherImeChange>(std::to_string(static_cast<int32_t>(ImeState::UNBIND)),
439         std::to_string(static_cast<int32_t>(getpid())), TddUtil::currentBundleNameMock_);
__anonff3e3efd0a02() 440     auto imeStateUnBind = []() {
441         inputMethodController_->Attach(textListener_, true);
442         inputMethodController_->Close();
443     };
444     EXPECT_TRUE(InputMethodDfxTest::WriteAndWatchImeChange(watcherImeChange, imeStateUnBind));
445 }
446 
447 /**
448 * @tc.name: InputMethodDfxTest_Hisysevent_Bind
449 * @tc.desc: Hisysevent Bind.
450 * @tc.type: FUNC
451 */
452 HWTEST_F(InputMethodDfxTest, InputMethodDfxTest_Hisysevent_Bind, TestSize.Level0)
453 {
454     IMSA_HILOGI("InputMethodDfxTest::InputMethodDfxTest_Hisysevent_Bind");
455     auto watcherImeChange = std::make_shared<WatcherImeChange>(std::to_string(static_cast<int32_t>(ImeState::BIND)),
456         std::to_string(static_cast<int32_t>(getpid())), TddUtil::currentBundleNameMock_);
__anonff3e3efd0b02() 457     auto imeStateBind = []() { inputMethodController_->RequestShowInput(); };
458     EXPECT_TRUE(InputMethodDfxTest::WriteAndWatchImeChange(watcherImeChange, imeStateBind));
459 }
460 
461 /**
462 * @tc.name: InputMethod_Dump_HELP
463 * @tc.desc: InputMethodDump.
464 * @tc.type: FUNC
465 */
466 HWTEST_F(InputMethodDfxTest, InputMethodDfxTest_Dump_HELP, TestSize.Level0)
467 {
468     IMSA_HILOGI("InputMethodDump::InputMethod_Dump_HELP");
469     std::vector<std::string> args = {"-h"};
470     int fd = 1;
471     EXPECT_TRUE(InputmethodDump::GetInstance().Dump(fd, args));
472 }
473 
474 /**
475 * @tc.name: InputMethod_Dump_ALL
476 * @tc.desc: InputMethodDump.
477 * @tc.type: FUNC
478 */
479 HWTEST_F(InputMethodDfxTest, InputMethodDfxTest_Dump_ALL, TestSize.Level0)
480 {
481     IMSA_HILOGI("InputMethodDump::InputMethod_Dump_ALL");
__anonff3e3efd0c02(int32_t fd) 482     InputmethodDump::GetInstance().AddDumpAllMethod([](int32_t fd) { return; });
483     std::vector<std::string> args = {"-a"};
484     int fd = 1;
485     EXPECT_FALSE(!InputmethodDump::GetInstance().Dump(fd, args));
486 }
487 } // namespace MiscServices
488 } // namespace OHOS
489