• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <gtest/gtest.h>
17 
18 #include "proto.h"
19 
20 #include "input_event_handler.h"
21 #include "mmi_log.h"
22 #include "mmi_service.h"
23 #include "udp_wrap.h"
24 
25 #undef MMI_LOG_TAG
26 #define MMI_LOG_TAG "MMIServerTest"
27 namespace OHOS {
28 namespace MMI {
29 namespace {
30 using namespace testing::ext;
31 } // namespace
32 
33 class MMIServerTest : public testing::Test {
34 public:
SetUpTestCase(void)35     static void SetUpTestCase(void) {}
TearDownTestCase(void)36     static void TearDownTestCase(void) {}
37 };
38 
39 /**
40  * @tc.name: MMIServerTest_OnThread_01
41  * @tc.desc: Test OnThread
42  * @tc.type: FUNC
43  * @tc.require:
44  */
45 HWTEST_F(MMIServerTest, MMIServerTest_OnThread_01, TestSize.Level1)
46 {
47     MMIService mmiService;
48     EpollEventType epollType;
49     epollType = EPOLL_EVENT_INPUT;
50     ASSERT_NO_FATAL_FAILURE(mmiService.OnThread());
51 }
52 
53 /**
54  * @tc.name: ShiftAppPointerEvent_001
55  * @tc.desc: Test the function ShiftAppPointerEvent
56  * @tc.type: FUNC
57  * @tc.require:
58  */
59 HWTEST_F(MMIServerTest, ShiftAppPointerEvent_001, TestSize.Level1)
60 {
61     MMIService mmiService;
62     ShiftWindowParam param;
63     param.sourceWindowId = -100;
64     param.targetWindowId = -200;
65     bool autoGenDown = true;
66     int32_t ret = mmiService.ShiftAppPointerEvent(param, autoGenDown);
67     EXPECT_NE(ret, RET_OK);
68 }
69 
70 /**
71  * @tc.name: MMIServerTest_OnThread_02
72  * @tc.desc: Test OnThread
73  * @tc.type: FUNC
74  * @tc.require:
75  */
76 HWTEST_F(MMIServerTest, MMIServerTest_OnThread_02, TestSize.Level1)
77 {
78     MMIService mmiService;
79     EpollEventType epollType;
80     epollType = EPOLL_EVENT_SOCKET;
81     ASSERT_NO_FATAL_FAILURE(mmiService.OnThread());
82 }
83 
84 /**
85  * @tc.name: MMIServerTest_OnThread_03
86  * @tc.desc: Test OnThread
87  * @tc.type: FUNC
88  * @tc.require:
89  */
90 HWTEST_F(MMIServerTest, MMIServerTest_OnThread_03, TestSize.Level1)
91 {
92     MMIService mmiService;
93     EpollEventType epollType;
94     epollType = EPOLL_EVENT_SIGNAL;
95     ASSERT_NO_FATAL_FAILURE(mmiService.OnThread());
96 }
97 
98 /**
99  * @tc.name: MMIServerTest_OnThread_04
100  * @tc.desc: Test OnThread
101  * @tc.type: FUNC
102  * @tc.require:
103  */
104 HWTEST_F(MMIServerTest, MMIServerTest_OnThread_04, TestSize.Level1)
105 {
106     MMIService mmiService;
107     EpollEventType epollType;
108     epollType = EPOLL_EVENT_ETASK;
109     ASSERT_NO_FATAL_FAILURE(mmiService.OnThread());
110 }
111 
112 /**
113  * @tc.name: MMIServerTest_EnableInputDevice_01
114  * @tc.desc: Test EnableInputDevice
115  * @tc.type: FUNC
116  * @tc.require:
117  */
118 HWTEST_F(MMIServerTest, MMIServerTest_EnableInputDevice_01, TestSize.Level1)
119 {
120     MMIService mmiService;
121     bool enable = true;
122     int32_t ret = mmiService.EnableInputDevice(enable);
123     EXPECT_EQ(ret, ETASKS_POST_SYNCTASK_FAIL);
124 }
125 
126 /**
127  * @tc.name: MMIServerTest_EnableInputDevice_02
128  * @tc.desc: Test EnableInputDevice
129  * @tc.type: FUNC
130  * @tc.require:
131  */
132 HWTEST_F(MMIServerTest, MMIServerTest_EnableInputDevice_02, TestSize.Level1)
133 {
134     MMIService mmiService;
135     bool enable = false;
136     int32_t ret = mmiService.EnableInputDevice(enable);
137     EXPECT_EQ(ret, ETASKS_POST_SYNCTASK_FAIL);
138 }
139 
140 /**
141  * @tc.name: MMIServerTest_OnDisconnected_01
142  * @tc.desc: Test OnDisconnected
143  * @tc.type: FUNC
144  * @tc.require:
145  */
146 HWTEST_F(MMIServerTest, MMIServerTest_OnDisconnected_01, TestSize.Level1)
147 {
148     MMIService mmiService;
149     SessionPtr session;
150     auto ret1 = mmiService.RemoveInputEventFilter(-1);
151     EXPECT_EQ(ret1, ETASKS_POST_SYNCTASK_FAIL);
152     ASSERT_NO_FATAL_FAILURE(mmiService.OnDisconnected(session));
153 }
154 
155 /**
156  * @tc.name: MMIServerTest_OnDisconnected_02
157  * @tc.desc: Test OnDisconnected
158  * @tc.type: FUNC
159  * @tc.require:
160  */
161 HWTEST_F(MMIServerTest, MMIServerTest_OnDisconnected_02, TestSize.Level1)
162 {
163     MMIService mmiService;
164     SessionPtr session;
165     auto ret1 = mmiService.RemoveInputEventFilter(2);
166     EXPECT_EQ(ret1, ETASKS_POST_SYNCTASK_FAIL);
167     ASSERT_NO_FATAL_FAILURE(mmiService.OnDisconnected(session));
168 }
169 
170 /**
171  * @tc.name: MMIServerTest_AddInputHandler_01
172  * @tc.desc: Test the function AddInputHandler
173  * @tc.type: FUNC
174  * @tc.require:
175  */
176 HWTEST_F(MMIServerTest, MMIServerTest_AddInputHandler_01, TestSize.Level1)
177 {
178     MMIService mmiService;
179     InputHandlerType handlerType = InputHandlerType::MONITOR;
180     HandleEventType eventType = HANDLE_EVENT_TYPE_KEY;
181     int32_t priority = 1;
182     uint32_t deviceTags = 3;
183     int32_t ret = mmiService.AddInputHandler(handlerType, eventType, priority, deviceTags);
184     EXPECT_NE(ret, RET_ERR);
185 }
186 
187 /**
188  * @tc.name: MMIServerTest_RemoveInputHandler_01
189  * @tc.desc: Test the function RemoveInputHandler
190  * @tc.type: FUNC
191  * @tc.require:
192  */
193 HWTEST_F(MMIServerTest, MMIServerTest_RemoveInputHandler_01, TestSize.Level1)
194 {
195     MMIService mmiService;
196     InputHandlerType handlerType = InputHandlerType::INTERCEPTOR;
197     HandleEventType eventType = HANDLE_EVENT_TYPE_POINTER;
198     int32_t priority = 1;
199     uint32_t deviceTags = 2;
200     int32_t ret = mmiService.RemoveInputHandler(handlerType, eventType, priority, deviceTags);
201     EXPECT_NE(ret, RET_ERR);
202 }
203 
204 /**
205  * @tc.name: AddEpollAndDelEpoll_001
206  * @tc.desc: Test the function AddEpoll and DelEpoll
207  * @tc.type: FUNC
208  * @tc.require:
209  */
210 HWTEST_F(MMIServerTest, AddEpollAndDelEpoll_001, TestSize.Level1)
211 {
212     CALL_TEST_DEBUG;
213     MMIService mmiService;
214     int32_t fd = -1;
215     int32_t ret = mmiService.AddEpoll(EPOLL_EVENT_INPUT, fd);
216     EXPECT_EQ(ret, RET_ERR);
217     ret = mmiService.DelEpoll(EPOLL_EVENT_INPUT, fd);
218     EXPECT_EQ(ret, RET_ERR);
219     fd = 1;
220     ret = mmiService.AddEpoll(EPOLL_EVENT_INPUT, fd);
221     EXPECT_EQ(ret, RET_ERR);
222     ret = mmiService.DelEpoll(EPOLL_EVENT_INPUT, fd);
223     EXPECT_EQ(ret, RET_ERR);
224     ret = mmiService.AddEpoll(EPOLL_EVENT_END, fd);
225     EXPECT_EQ(ret, RET_ERR);
226     ret = mmiService.DelEpoll(EPOLL_EVENT_END, fd);
227     EXPECT_EQ(ret, RET_ERR);
228 }
229 
230 /**
231  * @tc.name: InitLibinputService_001
232  * @tc.desc: Test the function InitLibinputService
233  * @tc.type: FUNC
234  * @tc.require:
235  */
236 HWTEST_F(MMIServerTest, InitLibinputService_001, TestSize.Level1)
237 {
238     CALL_TEST_DEBUG;
239     MMIService mmiService;
240     bool ret = mmiService.InitService();
241     EXPECT_FALSE(ret);
242     ret = mmiService.InitDelegateTasks();
243     EXPECT_FALSE(ret);
244 }
245 
246 /**
247  * @tc.name: AddAppDebugListener_001
248  * @tc.desc: Test the function AddAppDebugListener and RemoveAppDebugListener
249  * @tc.type: FUNC
250  * @tc.require:
251  */
252 HWTEST_F(MMIServerTest, AddAppDebugListener_001, TestSize.Level1)
253 {
254     CALL_TEST_DEBUG;
255     MMIService mmiService;
256     ASSERT_NO_FATAL_FAILURE(mmiService.AddAppDebugListener());
257     ASSERT_NO_FATAL_FAILURE(mmiService.RemoveAppDebugListener());
258 }
259 
260 /**
261  * @tc.name: AllocSocketFd_001
262  * @tc.desc: Test the function AllocSocketFd
263  * @tc.type: FUNC
264  * @tc.require:
265  */
266 HWTEST_F(MMIServerTest, AllocSocketFd_001, TestSize.Level1)
267 {
268     CALL_TEST_DEBUG;
269     MMIService mmiService;
270     const std::string programName = "programName";
271     const int32_t moduleType = 1;
272     int32_t toReturnClientFd = 1;
273     int32_t tokenType = 1;
274     int32_t returnCode = 65142804;
275     int32_t ret = mmiService.AllocSocketFd(programName, moduleType, toReturnClientFd, tokenType);
276     EXPECT_EQ(ret, returnCode);
277 }
278 
279 /**
280  * @tc.name: AddInputEventFilter_001
281  * @tc.desc: Test the function AddInputEventFilter and RemoveInputEventFilter
282  * @tc.type: FUNC
283  * @tc.require:
284  */
285 HWTEST_F(MMIServerTest, AddInputEventFilter_001, TestSize.Level1)
286 {
287     CALL_TEST_DEBUG;
288     MMIService mmiService;
289     int32_t filterId = 1;
290     int32_t priority = 1;
291     uint32_t deviceTags = 1;
292     int32_t returnCode0 = 65142804;
293     int32_t returnCode = 65142786;
294     sptr<IEventFilter> filter;
295     int32_t ret = mmiService.AddInputEventFilter(filter, filterId, priority, deviceTags);
296     EXPECT_EQ(ret, returnCode);
297     ret = mmiService.RemoveInputEventFilter(filterId);
298     EXPECT_EQ(ret, returnCode0);
299 }
300 
301 /**
302  * @tc.name: OnConnected_001
303  * @tc.desc: Test the function OnConnected and OnDisconnected
304  * @tc.type: FUNC
305  * @tc.require:
306  */
307 HWTEST_F(MMIServerTest, OnConnected_001, TestSize.Level1)
308 {
309     CALL_TEST_DEBUG;
310     MMIService mmiService;
311     SessionPtr session;
312     ASSERT_NO_FATAL_FAILURE(mmiService.OnConnected(session));
313     ASSERT_NO_FATAL_FAILURE(mmiService.OnDisconnected(session));
314 }
315 
316 /**
317  * @tc.name: SetCustomCursor_001
318  * @tc.desc: Test the function SetCustomCursor
319  * @tc.type: FUNC
320  * @tc.require:
321  */
322 HWTEST_F(MMIServerTest, SetCustomCursor_001, TestSize.Level1)
323 {
324     CALL_TEST_DEBUG;
325     MMIService mmiService;
326     int32_t pid = 1;
327     int32_t windowId = 1;
328     int32_t focusX = 200;
329     int32_t focusY = 500;
330     void* pixelMap = nullptr;
331     int32_t ret = mmiService.SetCustomCursor(pid, windowId, focusX, focusY, pixelMap);
332     EXPECT_EQ(ret, RET_ERR);
333 }
334 
335 /**
336  * @tc.name: SetMouseIcon_001
337  * @tc.desc: Test the function SetMouseIcon
338  * @tc.type: FUNC
339  * @tc.require:
340  */
341 HWTEST_F(MMIServerTest, SetMouseIcon_001, TestSize.Level1)
342 {
343     CALL_TEST_DEBUG;
344     MMIService mmiService;
345     int32_t windowId = 1;
346     void* pixelMap = nullptr;
347     int32_t ret = mmiService.SetMouseIcon(windowId, pixelMap);
348     EXPECT_NE(ret, RET_OK);
349 }
350 
351 /**
352  * @tc.name: SetMouseHotSpot_001
353  * @tc.desc: Test the function SetMouseHotSpot
354  * @tc.type: FUNC
355  * @tc.require:
356  */
357 HWTEST_F(MMIServerTest, SetMouseHotSpot_001, TestSize.Level1)
358 {
359     CALL_TEST_DEBUG;
360     MMIService mmiService;
361     int32_t pid = 1;
362     int32_t windowId = 1;
363     int32_t hotSpotX = 100;
364     int32_t hotSpotY = 200;
365     int32_t ret = mmiService.SetMouseHotSpot(pid, windowId, hotSpotX, hotSpotY);
366     EXPECT_EQ(ret, RET_ERR);
367 }
368 
369 /**
370  * @tc.name: SetNapStatus_001
371  * @tc.desc: Test the function SetNapStatus
372  * @tc.type: FUNC
373  * @tc.require:
374  */
375 HWTEST_F(MMIServerTest, SetNapStatus_001, TestSize.Level1)
376 {
377     CALL_TEST_DEBUG;
378     MMIService mmiService;
379     int32_t pid = 1;
380     int32_t uid = 2;
381     std::string bundleName = "bundleName";
382     int32_t napStatus = 1;
383     int32_t ret = mmiService.SetNapStatus(pid, uid, bundleName, napStatus);
384     EXPECT_EQ(ret, RET_ERR);
385 }
386 
387 /**
388  * @tc.name: ReadMouseScrollRows_001
389  * @tc.desc: Test the function ReadMouseScrollRows
390  * @tc.type: FUNC
391  * @tc.require:
392  */
393 HWTEST_F(MMIServerTest, ReadMouseScrollRows_001, TestSize.Level1)
394 {
395     CALL_TEST_DEBUG;
396     MMIService mmiService;
397     int32_t rows = 1;
398     int32_t ret = mmiService.ReadMouseScrollRows(rows);
399     EXPECT_EQ(ret, RET_OK);
400 }
401 
402 /**
403  * @tc.name: SetMousePrimaryButton_001
404  * @tc.desc: Test the function SetMousePrimaryButton
405  * @tc.type: FUNC
406  * @tc.require:
407  */
408 HWTEST_F(MMIServerTest, SetMousePrimaryButton_001, TestSize.Level1)
409 {
410     CALL_TEST_DEBUG;
411     MMIService mmiService;
412     int32_t primaryButton = 1;
413     int32_t returnCode = 65142804;
414     int32_t ret = mmiService.SetMousePrimaryButton(primaryButton);
415     EXPECT_EQ(ret, returnCode);
416 }
417 
418 /**
419  * @tc.name: ReadMousePrimaryButton_001
420  * @tc.desc: Test the function ReadMousePrimaryButton
421  * @tc.type: FUNC
422  * @tc.require:
423  */
424 HWTEST_F(MMIServerTest, ReadMousePrimaryButton_001, TestSize.Level1)
425 {
426     CALL_TEST_DEBUG;
427     MMIService mmiService;
428     int32_t primaryButton = 1;
429     int32_t ret = mmiService.ReadMousePrimaryButton(primaryButton);
430     EXPECT_EQ(ret, RET_OK);
431 }
432 
433 /**
434  * @tc.name: GetMousePrimaryButton_001
435  * @tc.desc: Test the function GetMousePrimaryButton
436  * @tc.type: FUNC
437  * @tc.require:
438  */
439 HWTEST_F(MMIServerTest, GetMousePrimaryButton_001, TestSize.Level1)
440 {
441     CALL_TEST_DEBUG;
442     MMIService mmiService;
443     int32_t primaryButton = 1;
444     int32_t returnCode = 65142804;
445     int32_t ret = mmiService.GetMousePrimaryButton(primaryButton);
446     EXPECT_EQ(ret, returnCode);
447 }
448 
449 /**
450  * @tc.name: CheckPointerVisible_001
451  * @tc.desc: Test the function CheckPointerVisible
452  * @tc.type: FUNC
453  * @tc.require:
454  */
455 HWTEST_F(MMIServerTest, CheckPointerVisible_001, TestSize.Level1)
456 {
457     CALL_TEST_DEBUG;
458     MMIService mmiService;
459     bool visible = true;
460     int32_t ret = mmiService.CheckPointerVisible(visible);
461     EXPECT_EQ(ret, RET_OK);
462 }
463 
464 /**
465  * @tc.name: MarkProcessed_001
466  * @tc.desc: Test the function MarkProcessed
467  * @tc.type: FUNC
468  * @tc.require:
469  */
470 HWTEST_F(MMIServerTest, MarkProcessed_001, TestSize.Level1)
471 {
472     CALL_TEST_DEBUG;
473     MMIService mmiService;
474     int32_t eventType = 1;
475     int32_t eventId = 1;
476     int32_t returnCode = 65142804;
477     int32_t ret = mmiService.MarkProcessed(eventType, eventId);
478     EXPECT_EQ(ret, returnCode);
479 }
480 
481 /**
482  * @tc.name: ReadPointerColor_001
483  * @tc.desc: Test the function ReadPointerColor
484  * @tc.type: FUNC
485  * @tc.require:
486  */
487 HWTEST_F(MMIServerTest, ReadPointerColor_001, TestSize.Level1)
488 {
489     CALL_TEST_DEBUG;
490     MMIService mmiService;
491     int32_t color = 1;
492     int32_t ret = mmiService.ReadPointerColor(color);
493     EXPECT_EQ(ret, RET_OK);
494 }
495 
496 /**
497  * @tc.name: NotifyNapOnline_001
498  * @tc.desc: Test the function NotifyNapOnline
499  * @tc.type: FUNC
500  * @tc.require:
501  */
502 HWTEST_F(MMIServerTest, NotifyNapOnline_001, TestSize.Level1)
503 {
504     CALL_TEST_DEBUG;
505     MMIService mmiService;
506     int32_t ret = mmiService.NotifyNapOnline();
507     EXPECT_EQ(ret, RET_OK);
508 }
509 
510 /**
511  * @tc.name: RemoveInputEventObserver_001
512  * @tc.desc: Test the function RemoveInputEventObserver
513  * @tc.type: FUNC
514  * @tc.require:
515  */
516 HWTEST_F(MMIServerTest, RemoveInputEventObserver_001, TestSize.Level1)
517 {
518     CALL_TEST_DEBUG;
519     MMIService mmiService;
520     int32_t ret = mmiService.RemoveInputEventObserver();
521     EXPECT_EQ(ret, RET_OK);
522 }
523 
524 /**
525  * @tc.name: ClearWindowPointerStyle_001
526  * @tc.desc: Test the function ClearWindowPointerStyle
527  * @tc.type: FUNC
528  * @tc.require:
529  */
530 HWTEST_F(MMIServerTest, ClearWindowPointerStyle_001, TestSize.Level1)
531 {
532     CALL_TEST_DEBUG;
533     MMIService mmiService;
534     int32_t pid = 1;
535     int32_t windowId = 2;
536     int32_t ret = mmiService.ClearWindowPointerStyle(pid, windowId);
537     EXPECT_EQ(ret, RET_ERR);
538 }
539 
540 /**
541  * @tc.name: ReadHoverScrollState_001
542  * @tc.desc: Test the function ReadHoverScrollState
543  * @tc.type: FUNC
544  * @tc.require:
545  */
546 HWTEST_F(MMIServerTest, ReadHoverScrollState_001, TestSize.Level1)
547 {
548     CALL_TEST_DEBUG;
549     MMIService mmiService;
550     bool state = true;
551     int32_t ret = mmiService.ReadHoverScrollState(state);
552     EXPECT_EQ(ret, RET_OK);
553 }
554 
555 /**
556  * @tc.name: OnSupportKeys_001
557  * @tc.desc: Test the function OnSupportKeys
558  * @tc.type: FUNC
559  * @tc.require:
560  */
561 HWTEST_F(MMIServerTest, OnSupportKeys_001, TestSize.Level1)
562 {
563     CALL_TEST_DEBUG;
564     MMIService mmiService;
565     int32_t deviceId = 1;
566     int32_t return_code = 401;
567     std::vector<int32_t> keys{ 1 };
568     std::vector<bool> keystroke{ true, true };
569     std::vector<bool> keystroke1{ true, true, true, true, true, true };
570     int32_t ret = mmiService.OnSupportKeys(deviceId, keys, keystroke);
571     EXPECT_EQ(ret, return_code);
572     ret = mmiService.OnSupportKeys(deviceId, keys, keystroke1);
573     EXPECT_EQ(ret, return_code);
574 }
575 
576 /**
577  * @tc.name: SupportKeys_001
578  * @tc.desc: Test the function SupportKeys
579  * @tc.type: FUNC
580  * @tc.require:
581  */
582 HWTEST_F(MMIServerTest, SupportKeys_001, TestSize.Level1)
583 {
584     CALL_TEST_DEBUG;
585     MMIService mmiService;
586     int32_t deviceId = 1;
587     int32_t returnCode = 65142804;
588     std::vector<int32_t> keys{ 1 };
589     std::vector<bool> keystroke{ true, true };
590     int32_t ret = mmiService.SupportKeys(deviceId, keys, keystroke);
591     EXPECT_EQ(ret, returnCode);
592 }
593 
594 /**
595  * @tc.name: OnGetDeviceIds_001
596  * @tc.desc: Test the function OnGetDeviceIds
597  * @tc.type: FUNC
598  * @tc.require:
599  */
600 HWTEST_F(MMIServerTest, OnGetDeviceIds_001, TestSize.Level1)
601 {
602     CALL_TEST_DEBUG;
603     MMIService mmiService;
604     std::vector<int32_t> ids{ 1 };
605     int32_t ret = mmiService.OnGetDeviceIds(ids);
606     EXPECT_EQ(ret, RET_OK);
607 }
608 
609 /**
610  * @tc.name: GetDeviceIds_001
611  * @tc.desc: Test the function GetDeviceIds
612  * @tc.type: FUNC
613  * @tc.require:
614  */
615 HWTEST_F(MMIServerTest, GetDeviceIds_001, TestSize.Level1)
616 {
617     CALL_TEST_DEBUG;
618     MMIService mmiService;
619     std::vector<int32_t> ids{ 1 };
620     int32_t returnCode = 65142804;
621     int32_t ret = mmiService.GetDeviceIds(ids);
622     EXPECT_EQ(ret, returnCode);
623 }
624 
625 /**
626  * @tc.name: OnGetDevice_001
627  * @tc.desc: Test the function OnGetDevice
628  * @tc.type: FUNC
629  * @tc.require:
630  */
631 HWTEST_F(MMIServerTest, OnGetDevice_001, TestSize.Level1)
632 {
633     CALL_TEST_DEBUG;
634     MMIService mmiService;
635     int32_t deviceId = 1;
636     int32_t return_code = 401;
637     std::shared_ptr<InputDevice> inputDevice = std::make_shared<InputDevice>();
638     int32_t ret = mmiService.OnGetDevice(deviceId, inputDevice);
639     EXPECT_EQ(ret, return_code);
640 }
641 
642 /**
643  * @tc.name: GetDevice_001
644  * @tc.desc: Test the function GetDevice
645  * @tc.type: FUNC
646  * @tc.require:
647  */
648 HWTEST_F(MMIServerTest, GetDevice_001, TestSize.Level1)
649 {
650     CALL_TEST_DEBUG;
651     MMIService mmiService;
652     int32_t returnCode = 65142804;
653     int32_t deviceId = 1;
654     std::shared_ptr<InputDevice> inputDevice = std::make_shared<InputDevice>();
655     int32_t ret = mmiService.GetDevice(deviceId, inputDevice);
656     EXPECT_EQ(ret, returnCode);
657 }
658 
659 /**
660  * @tc.name: OnRegisterDevListener_001
661  * @tc.desc: Test the function OnRegisterDevListener
662  * @tc.type: FUNC
663  * @tc.require:
664  */
665 HWTEST_F(MMIServerTest, OnRegisterDevListener_001, TestSize.Level1)
666 {
667     CALL_TEST_DEBUG;
668     MMIService mmiService;
669     int32_t pid = 1;
670     int32_t ret = mmiService.OnRegisterDevListener(pid);
671     EXPECT_EQ(ret, RET_ERR);
672 }
673 
674 /**
675  * @tc.name: RegisterDevListener_001
676  * @tc.desc: Test the function RegisterDevListener and OnUnregisterDevListener
677  * @tc.type: FUNC
678  * @tc.require:
679  */
680 HWTEST_F(MMIServerTest, RegisterDevListener_001, TestSize.Level1)
681 {
682     CALL_TEST_DEBUG;
683     MMIService mmiService;
684     int32_t pid = 1;
685     int32_t returnCode = 65142804;
686     int32_t ret = mmiService.RegisterDevListener();
687     EXPECT_EQ(ret, returnCode);
688     ret = mmiService.UnregisterDevListener();
689     EXPECT_EQ(ret, returnCode);
690     ret = mmiService.OnUnregisterDevListener(pid);
691     EXPECT_EQ(ret, RET_OK);
692 }
693 
694 /**
695  * @tc.name: OnGetKeyboardType_001
696  * @tc.desc: Test the function OnGetKeyboardType
697  * @tc.type: FUNC
698  * @tc.require:
699  */
700 HWTEST_F(MMIServerTest, OnGetKeyboardType_001, TestSize.Level1)
701 {
702     CALL_TEST_DEBUG;
703     MMIService mmiService;
704     int32_t deviceId = 1;
705     int32_t keyboardType = 1;
706     int32_t return_code = 401;
707     int32_t ret = mmiService.OnGetKeyboardType(deviceId, keyboardType);
708     EXPECT_EQ(ret, return_code);
709 }
710 
711 /**
712  * @tc.name: GetKeyboardType_001
713  * @tc.desc: Test the function GetKeyboardType
714  * @tc.type: FUNC
715  * @tc.require:
716  */
717 HWTEST_F(MMIServerTest, GetKeyboardType_001, TestSize.Level1)
718 {
719     CALL_TEST_DEBUG;
720     MMIService mmiService;
721     int32_t returnCode = 65142804;
722     int32_t deviceId = 1;
723     int32_t keyboardType = 1;
724     int32_t ret = mmiService.GetKeyboardType(deviceId, keyboardType);
725     EXPECT_EQ(ret, returnCode);
726 }
727 
728 /**
729  * @tc.name: GetKeyboardRepeatDelay_001
730  * @tc.desc: Test the function GetKeyboardRepeatDelay
731  * @tc.type: FUNC
732  * @tc.require:
733  */
734 HWTEST_F(MMIServerTest, GetKeyboardRepeatDelay_001, TestSize.Level1)
735 {
736     CALL_TEST_DEBUG;
737     MMIService mmiService;
738     int32_t returnCode = 65142804;
739     int32_t delay = 1;
740     int32_t ret = mmiService.GetKeyboardRepeatDelay(delay);
741     EXPECT_EQ(ret, returnCode);
742 }
743 
744 /**
745  * @tc.name: GetKeyboardRepeatRate_001
746  * @tc.desc: Test the function GetKeyboardRepeatRate
747  * @tc.type: FUNC
748  * @tc.require:
749  */
750 HWTEST_F(MMIServerTest, GetKeyboardRepeatRate_001, TestSize.Level1)
751 {
752     CALL_TEST_DEBUG;
753     MMIService mmiService;
754     int32_t returnCode = 65142804;
755     int32_t rate = 1;
756     int32_t ret = mmiService.GetKeyboardRepeatRate(rate);
757     EXPECT_EQ(ret, returnCode);
758 }
759 
760 /**
761  * @tc.name: CheckAddInput_001
762  * @tc.desc: Test the function CheckAddInput
763  * @tc.type: FUNC
764  * @tc.require:
765  */
766 HWTEST_F(MMIServerTest, CheckAddInput_001, TestSize.Level1)
767 {
768     CALL_TEST_DEBUG;
769     MMIService mmiService;
770     int32_t returnCode = 65142786;
771     int32_t pid = 1;
772     InputHandlerType handlerType = InputHandlerType::MONITOR;
773     HandleEventType eventType = 10;
774     int32_t priority = 1;
775     uint32_t deviceTags = 1;
776     int32_t ret = mmiService.CheckAddInput(pid, handlerType, eventType, priority, deviceTags);
777     EXPECT_EQ(ret, returnCode);
778 }
779 
780 /**
781  * @tc.name: AddInputHandler_001
782  * @tc.desc: Test the function AddInputHandler
783  * @tc.type: FUNC
784  * @tc.require:
785  */
786 HWTEST_F(MMIServerTest, AddInputHandler_001, TestSize.Level1)
787 {
788     CALL_TEST_DEBUG;
789     MMIService mmiService;
790     InputHandlerType handlerType = InputHandlerType::INTERCEPTOR;
791     HandleEventType eventType = 10;
792     int32_t priority = 1;
793     uint32_t deviceTags = 1;
794     int32_t returnCode = 65142804;
795     int32_t ret = mmiService.AddInputHandler(handlerType, eventType, priority, deviceTags);
796     EXPECT_EQ(ret, returnCode);
797 }
798 
799 /**
800  * @tc.name: CheckRemoveInput_001
801  * @tc.desc: Test the function CheckRemoveInput
802  * @tc.type: FUNC
803  * @tc.require:
804  */
805 HWTEST_F(MMIServerTest, CheckRemoveInput_001, TestSize.Level1)
806 {
807     CALL_TEST_DEBUG;
808     MMIService mmiService;
809     int32_t returnCode = 65142786;
810     int32_t pid = 1;
811     InputHandlerType handlerType = InputHandlerType::INTERCEPTOR;
812     HandleEventType eventType = 1;
813     int32_t priority = 1;
814     uint32_t deviceTags = 1;
815     int32_t ret = mmiService.CheckRemoveInput(pid, handlerType, eventType, priority, deviceTags);
816     EXPECT_EQ(ret, returnCode);
817 }
818 
819 /**
820  * @tc.name: RemoveInputHandler_001
821  * @tc.desc: Test the function RemoveInputHandler
822  * @tc.type: FUNC
823  * @tc.require:
824  */
825 HWTEST_F(MMIServerTest, RemoveInputHandler_001, TestSize.Level1)
826 {
827     CALL_TEST_DEBUG;
828     MMIService mmiService;
829     InputHandlerType handlerType = InputHandlerType::INTERCEPTOR;
830     HandleEventType eventType = 1;
831     int32_t priority = 1;
832     uint32_t deviceTags = 1;
833     int32_t returnCode = 65142804;
834     int32_t ret = mmiService.RemoveInputHandler(handlerType, eventType, priority, deviceTags);
835     EXPECT_EQ(ret, returnCode);
836 }
837 
838 /**
839  * @tc.name: CheckMarkConsumed_001
840  * @tc.desc: Test the function CheckMarkConsumed
841  * @tc.type: FUNC
842  * @tc.require:
843  */
844 HWTEST_F(MMIServerTest, CheckMarkConsumed_001, TestSize.Level1)
845 {
846     CALL_TEST_DEBUG;
847     MMIService mmiService;
848     int32_t returnCode = 65142786;
849     int32_t pid = 1;
850     int32_t eventId = 1;
851     int32_t ret = mmiService.CheckMarkConsumed(pid, eventId);
852     EXPECT_EQ(ret, returnCode);
853 }
854 
855 /**
856  * @tc.name: MoveMouseEvent_001
857  * @tc.desc: Test the function MoveMouseEvent
858  * @tc.type: FUNC
859  * @tc.require:
860  */
861 HWTEST_F(MMIServerTest, MoveMouseEvent_001, TestSize.Level1)
862 {
863     CALL_TEST_DEBUG;
864     MMIService mmiService;
865     int32_t offsetX = 100;
866     int32_t offsetY = 200;
867     int32_t returnCode = 65142804;
868     int32_t ret = mmiService.MoveMouseEvent(offsetX, offsetY);
869     EXPECT_EQ(ret, returnCode);
870 }
871 
872 /**
873  * @tc.name: CheckInjectKeyEvent_001
874  * @tc.desc: Test the function CheckInjectKeyEvent
875  * @tc.type: FUNC
876  * @tc.require:
877  */
878 HWTEST_F(MMIServerTest, CheckInjectKeyEvent_001, TestSize.Level1)
879 {
880     CALL_TEST_DEBUG;
881     MMIService mmiService;
882     int32_t returnCode = 65142786;
883     std::shared_ptr<KeyEvent> Event{ nullptr };
884     int32_t pid = 1;
885     bool isNativeInject = false;
886     int32_t ret = mmiService.CheckInjectKeyEvent(Event, pid, isNativeInject);
887     EXPECT_EQ(ret, returnCode);
888 }
889 
890 /**
891  * @tc.name: OnAddSystemAbility_001
892  * @tc.desc: Test the function OnAddSystemAbility
893  * @tc.type: FUNC
894  * @tc.require:
895  */
896 HWTEST_F(MMIServerTest, OnAddSystemAbility_001, TestSize.Level1)
897 {
898     CALL_TEST_DEBUG;
899     MMIService mmiService;
900     int32_t systemAbilityId = 1;
901     std::string deviceId = "device_id";
902     systemAbilityId = RES_SCHED_SYS_ABILITY_ID;
903     ASSERT_NO_FATAL_FAILURE(mmiService.OnAddSystemAbility(systemAbilityId, deviceId));
904     systemAbilityId = COMMON_EVENT_SERVICE_ID;
905     ASSERT_NO_FATAL_FAILURE(mmiService.OnAddSystemAbility(systemAbilityId, deviceId));
906     systemAbilityId = APP_MGR_SERVICE_ID;
907     ASSERT_NO_FATAL_FAILURE(mmiService.OnAddSystemAbility(systemAbilityId, deviceId));
908 }
909 
910 /**
911  * @tc.name: SubscribeKeyEvent_001
912  * @tc.desc: Test the function SubscribeKeyEvent
913  * @tc.type: FUNC
914  * @tc.require:
915  */
916 HWTEST_F(MMIServerTest, SubscribeKeyEvent_001, TestSize.Level1)
917 {
918     CALL_TEST_DEBUG;
919     MMIService mmiService;
920     int32_t subscribeId = 1;
921     int32_t returnCode = 65142804;
922     std::shared_ptr<KeyOption> option = std::make_shared<KeyOption>();
923     int32_t ret = mmiService.SubscribeKeyEvent(subscribeId, option);
924     EXPECT_EQ(ret, returnCode);
925     ret = mmiService.UnsubscribeKeyEvent(subscribeId);
926     EXPECT_EQ(ret, returnCode);
927 }
928 
929 /**
930  * @tc.name: GetDisplayBindInfo_001
931  * @tc.desc: Test the function GetDisplayBindInfo
932  * @tc.type: FUNC
933  * @tc.require:
934  */
935 HWTEST_F(MMIServerTest, GetDisplayBindInfo_001, TestSize.Level1)
936 {
937     CALL_TEST_DEBUG;
938     MMIService mmiService;
939     DisplayBindInfos infos;
940     int32_t returnCode = 65142804;
941     int32_t ret = mmiService.GetDisplayBindInfo(infos);
942     EXPECT_EQ(ret, returnCode);
943 }
944 
945 /**
946  * @tc.name: SetDisplayBind_001
947  * @tc.desc: Test the function SetDisplayBind
948  * @tc.type: FUNC
949  * @tc.require:
950  */
951 HWTEST_F(MMIServerTest, SetDisplayBind_001, TestSize.Level1)
952 {
953     CALL_TEST_DEBUG;
954     MMIService mmiService;
955     int32_t deviceId = 1;
956     int32_t displayId = 2;
957     std::string msg = "test";
958     int32_t returnCode = 65142804;
959     int32_t ret = mmiService.SetDisplayBind(deviceId, displayId, msg);
960     EXPECT_EQ(ret, returnCode);
961 }
962 
963 /**
964  * @tc.name: SetFunctionKeyState_001
965  * @tc.desc: Test the function SetFunctionKeyState
966  * @tc.type: FUNC
967  * @tc.require:
968  */
969 HWTEST_F(MMIServerTest, SetFunctionKeyState_001, TestSize.Level1)
970 {
971     CALL_TEST_DEBUG;
972     MMIService mmiService;
973     int32_t funcKey = 1;
974     bool enable = true;
975     bool state = false;
976     int32_t returnCode = 65142804;
977     int32_t ret = mmiService.SetFunctionKeyState(funcKey, enable);
978     EXPECT_EQ(ret, returnCode);
979     ret = mmiService.GetFunctionKeyState(funcKey, state);
980     EXPECT_EQ(ret, returnCode);
981 }
982 
983 /**
984  * @tc.name: OnDelegateTask_001
985  * @tc.desc: Test the function OnDelegateTask
986  * @tc.type: FUNC
987  * @tc.require:
988  */
989 HWTEST_F(MMIServerTest, OnDelegateTask_001, TestSize.Level1)
990 {
991     CALL_TEST_DEBUG;
992     MMIService mmiService;
993     epoll_event ev;
994     ev.events = 0;
995     ASSERT_NO_FATAL_FAILURE(mmiService.OnDelegateTask(ev));
996     ev.events = 1;
997     ASSERT_NO_FATAL_FAILURE(mmiService.OnDelegateTask(ev));
998 }
999 
1000 /**
1001  * @tc.name: OnThread_001
1002  * @tc.desc: Test the function OnThread
1003  * @tc.type: FUNC
1004  * @tc.require:
1005  */
1006 HWTEST_F(MMIServerTest, OnThread_001, TestSize.Level1)
1007 {
1008     CALL_TEST_DEBUG;
1009     MMIService mmiService;
1010     ASSERT_NO_FATAL_FAILURE(mmiService.OnThread());
1011 }
1012 
1013 /**
1014  * @tc.name: InitSignalHandler_001
1015  * @tc.desc: Test the function InitSignalHandler
1016  * @tc.type: FUNC
1017  * @tc.require:
1018  */
1019 HWTEST_F(MMIServerTest, InitSignalHandler_001, TestSize.Level1)
1020 {
1021     CALL_TEST_DEBUG;
1022     MMIService mmiService;
1023     bool ret = mmiService.InitSignalHandler();
1024     EXPECT_EQ(ret, false);
1025 }
1026 
1027 /**
1028  * @tc.name: AddReloadDeviceTimer_001
1029  * @tc.desc: Test the function AddReloadDeviceTimer
1030  * @tc.type: FUNC
1031  * @tc.require:
1032  */
1033 HWTEST_F(MMIServerTest, AddReloadDeviceTimer_001, TestSize.Level1)
1034 {
1035     CALL_TEST_DEBUG;
1036     MMIService mmiService;
1037     ASSERT_NO_FATAL_FAILURE(mmiService.AddReloadDeviceTimer());
1038 }
1039 
1040 /**
1041  * @tc.name: Dump_001
1042  * @tc.desc: Test the function Dump
1043  * @tc.type: FUNC
1044  * @tc.require:
1045  */
1046 HWTEST_F(MMIServerTest, Dump_001, TestSize.Level1)
1047 {
1048     CALL_TEST_DEBUG;
1049     MMIService mmiService;
1050     int32_t fd = -1;
1051     std::vector<std::u16string> args;
1052     int32_t ret = mmiService.Dump(fd, args);
1053     EXPECT_EQ(ret, DUMP_PARAM_ERR);
1054     fd = 1;
1055     ret = mmiService.Dump(fd, args);
1056     EXPECT_EQ(ret, DUMP_PARAM_ERR);
1057 }
1058 
1059 /**
1060  * @tc.name: SetMouseCaptureMode_001
1061  * @tc.desc: Test the function SetMouseCaptureMode
1062  * @tc.type: FUNC
1063  * @tc.require:
1064  */
1065 HWTEST_F(MMIServerTest, SetMouseCaptureMode_001, TestSize.Level1)
1066 {
1067     CALL_TEST_DEBUG;
1068     MMIService mmiService;
1069     int32_t windowId = 1;
1070     bool isCaptureMode = false;
1071     int32_t returnCode = 65142804;
1072     int32_t ret = mmiService.SetMouseCaptureMode(windowId, isCaptureMode);
1073     EXPECT_EQ(ret, returnCode);
1074     isCaptureMode = true;
1075     ret = mmiService.SetMouseCaptureMode(windowId, isCaptureMode);
1076     EXPECT_EQ(ret, returnCode);
1077 }
1078 
1079 /**
1080  * @tc.name: OnGetWindowPid_001
1081  * @tc.desc: Test the function OnGetWindowPid
1082  * @tc.type: FUNC
1083  * @tc.require:
1084  */
1085 HWTEST_F(MMIServerTest, OnGetWindowPid_001, TestSize.Level1)
1086 {
1087     CALL_TEST_DEBUG;
1088     MMIService mmiService;
1089     int32_t windowId = 1;
1090     int32_t windowPid = 1;
1091     int32_t ret = mmiService.OnGetWindowPid(windowId, windowPid);
1092     EXPECT_EQ(ret, RET_ERR);
1093 }
1094 
1095 /**
1096  * @tc.name: GetWindowPid_001
1097  * @tc.desc: Test the function GetWindowPid
1098  * @tc.type: FUNC
1099  * @tc.require:
1100  */
1101 HWTEST_F(MMIServerTest, GetWindowPid_001, TestSize.Level1)
1102 {
1103     CALL_TEST_DEBUG;
1104     MMIService mmiService;
1105     int32_t windowId = 1;
1106     int32_t returnCode = 65142804;
1107     int32_t ret = mmiService.GetWindowPid(windowId);
1108     EXPECT_EQ(ret, returnCode);
1109 }
1110 
1111 /**
1112  * @tc.name: CheckPidPermission_001
1113  * @tc.desc: Test the function CheckPidPermission
1114  * @tc.type: FUNC
1115  * @tc.require:
1116  */
1117 HWTEST_F(MMIServerTest, CheckPidPermission_001, TestSize.Level1)
1118 {
1119     CALL_TEST_DEBUG;
1120     MMIService mmiService;
1121     int32_t pid = 10;
1122     int32_t ret = mmiService.CheckPidPermission(pid);
1123     EXPECT_EQ(ret, RET_ERR);
1124 }
1125 
1126 /**
1127  * @tc.name: SetShieldStatus_001
1128  * @tc.desc: Test the function SetShieldStatus
1129  * @tc.type: FUNC
1130  * @tc.require:
1131  */
1132 HWTEST_F(MMIServerTest, SetShieldStatus_001, TestSize.Level1)
1133 {
1134     CALL_TEST_DEBUG;
1135     MMIService mmiService;
1136     int32_t returnCode = 65142804;
1137     int32_t shieldMode = 1;
1138     bool isShield = 0;
1139     int32_t ret = mmiService.SetShieldStatus(shieldMode, isShield);
1140     EXPECT_EQ(ret, returnCode);
1141     ret = mmiService.GetShieldStatus(shieldMode, isShield);
1142     EXPECT_EQ(ret, returnCode);
1143 }
1144 
1145 /**
1146  * @tc.name: MMIServerTest_InitService
1147  * @tc.desc: Test Init Service
1148  * @tc.type: FUNC
1149  * @tc.require:
1150  */
1151 HWTEST_F(MMIServerTest, MMIServerTest_InitService, TestSize.Level1)
1152 {
1153     CALL_TEST_DEBUG;
1154     MMIService service;
1155     service.state_ = ServiceRunningState::STATE_RUNNING;
1156     ASSERT_FALSE(service.InitService());
1157     service.state_ = ServiceRunningState::STATE_NOT_START;
1158     service.mmiFd_ = 1000;
1159     ASSERT_FALSE(service.InitService());
1160 }
1161 } // namespace MMI
1162 } // namespace OHOS