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 <cstdio>
17 #include <gtest/gtest.h>
18 #include <gmock/gmock.h>
19
20 #include "general_mouse.h"
21 #include "general_touchpad.h"
22 #include "mouse_transform_processor.h"
23 #include "window_info.h"
24 #include "mouse_device_state.h"
25 #include "input_device_manager.h"
26 #include "input_windows_manager.h"
27 #include "i_input_windows_manager.h"
28 #include "libinput_wrapper.h"
29 #include "multimodal_input_preferences_manager.h"
30
31 namespace OHOS {
32 namespace MMI {
33 namespace {
34 using namespace testing::ext;
35 using namespace testing;
36 constexpr int32_t BTN_RIGHT_MENUE_CODE = 0x118;
37 constexpr int32_t HARD_PC_PRO_DEVICE_WIDTH = 2880;
38 constexpr int32_t HARD_PC_PRO_DEVICE_HEIGHT = 1920;
39 }
40 class MockPreferenceManager : public MultiModalInputPreferencesManager {
41 public:
42 MOCK_METHOD(int32_t, SetPreValue, (const std::string &, const std::string &,
43 const NativePreferences::PreferencesValue &));
44 };
45
46 class MouseTransformProcessorTest : public testing::Test {
47 public:
48 static void SetUpTestCase(void);
49 static void TearDownTestCase(void);
50 static void SetupMouse();
51 static void CloseMouse();
52 void SetUp();
53 void TearDown();
54
55 private:
56 static GeneralMouse vMouse_;
57 static GeneralTouchpad vTouchpad_ ;
58 static LibinputWrapper libinput_;
59
60 MouseTransformProcessor g_processor_ { 0 };
61 int32_t prePointerSpeed_ { 5 };
62 int32_t prePrimaryButton_ { 0 };
63 int32_t preScrollRows_ { 3 };
64 int32_t preTouchpadPointerSpeed_ { 9 };
65 int32_t preRightClickType_ { 1 };
66 bool preScrollSwitch_ { true };
67 bool preScrollDirection_ { true };
68 bool preTapSwitch_ { true };
69 std::shared_ptr<MockPreferenceManager> mockPreferencesMgr;
70 };
71
72 GeneralMouse MouseTransformProcessorTest::vMouse_;
73 GeneralTouchpad MouseTransformProcessorTest::vTouchpad_;
74 LibinputWrapper MouseTransformProcessorTest::libinput_;
75
SetUpTestCase(void)76 void MouseTransformProcessorTest::SetUpTestCase(void)
77 {
78 ASSERT_TRUE(libinput_.Init());
79 SetupMouse();
80 }
81
TearDownTestCase(void)82 void MouseTransformProcessorTest::TearDownTestCase(void)
83 {
84 CloseMouse();
85 }
86
SetupMouse()87 void MouseTransformProcessorTest::SetupMouse()
88 {
89 ASSERT_TRUE(vMouse_.SetUp());
90 std::cout << "device node name: " << vMouse_.GetDevPath() << std::endl;
91 ASSERT_TRUE(libinput_.AddPath(vMouse_.GetDevPath()));
92
93 ASSERT_TRUE(vTouchpad_.SetUp());
94 std::cout << "device node name: " << vTouchpad_.GetDevPath() << std::endl;
95 ASSERT_TRUE(libinput_.AddPath(vTouchpad_.GetDevPath()));
96
97 libinput_event *event = libinput_.Dispatch();
98 ASSERT_TRUE(event != nullptr);
99 ASSERT_EQ(libinput_event_get_type(event), LIBINPUT_EVENT_DEVICE_ADDED);
100 struct libinput_device *device = libinput_event_get_device(event);
101 ASSERT_TRUE(device != nullptr);
102 INPUT_DEV_MGR->OnInputDeviceAdded(device);
103 }
104
CloseMouse()105 void MouseTransformProcessorTest::CloseMouse()
106 {
107 libinput_.RemovePath(vMouse_.GetDevPath());
108 vMouse_.Close();
109 libinput_.RemovePath(vTouchpad_.GetDevPath());
110 vTouchpad_.Close();
111 }
112
SetUp()113 void MouseTransformProcessorTest::SetUp()
114 {
115 prePointerSpeed_ = g_processor_.GetPointerSpeed();
116 prePrimaryButton_ = g_processor_.GetMousePrimaryButton();
117 preScrollRows_ = g_processor_.GetMouseScrollRows();
118 mockPreferencesMgr = std::make_shared<MockPreferenceManager>();
119 g_processor_.GetTouchpadPointerSpeed(preTouchpadPointerSpeed_);
120 g_processor_.GetTouchpadRightClickType(preRightClickType_);
121 g_processor_.GetTouchpadScrollSwitch(preScrollSwitch_);
122 g_processor_.GetTouchpadScrollDirection(preScrollDirection_);
123 g_processor_.GetTouchpadTapSwitch(preTapSwitch_);
124 }
125
TearDown()126 void MouseTransformProcessorTest::TearDown()
127 {
128 g_processor_.SetPointerSpeed(prePointerSpeed_);
129 g_processor_.SetMousePrimaryButton(prePrimaryButton_);
130 g_processor_.SetMouseScrollRows(preScrollRows_);
131 g_processor_.SetTouchpadPointerSpeed(preTouchpadPointerSpeed_);
132 g_processor_.SetTouchpadRightClickType(preRightClickType_);
133 int32_t pid = 1;
134 g_processor_.SetTouchpadScrollSwitch(pid, preScrollSwitch_);
135 g_processor_.SetTouchpadScrollDirection(preScrollDirection_);
136 g_processor_.SetTouchpadTapSwitch(preTapSwitch_);
137 }
138
139 /**
140 * @tc.name: MouseTransformProcessorTest_DeletePressedButton_001
141 * @tc.desc: Test DeletePressedButton
142 * @tc.type: FUNC
143 * @tc.require:
144 */
145 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_DeletePressedButton_001, TestSize.Level1)
146 {
147 int32_t deviceId = 0;
148 MouseTransformProcessor processor(deviceId);
149 int32_t originButton = 1;
150 ASSERT_NO_FATAL_FAILURE(processor.DeletePressedButton(originButton));
151 }
152
153 /**
154 * @tc.name: MouseTransformProcessorTest_DeletePressedButton_002
155 * @tc.desc: Test DeletePressedButton
156 * @tc.type: FUNC
157 * @tc.require:
158 */
159 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_DeletePressedButton_002, TestSize.Level1)
160 {
161 int32_t deviceId = 0;
162 MouseTransformProcessor processor(deviceId);
163 int32_t originButton = 1;
164 int32_t mappedButton = 2;
165 processor.buttonMapping_[originButton] = mappedButton;
166 ASSERT_NO_FATAL_FAILURE(processor.DeletePressedButton(originButton));
167 }
168
169 /**
170 * @tc.name: MouseTransformProcessorTest_HandleAxisAccelateTouchPad_001
171 * @tc.desc: Test HandleAxisAccelateTouchPad
172 * @tc.type: FUNC
173 * @tc.require:
174 */
175 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_HandleAxisAccelateTouchPad_001, TestSize.Level1)
176 {
177 int32_t deviceId = 0;
178 MouseTransformProcessor processor(deviceId);
179 double axisValue = 2.0;
180 auto inputWindowsManager = std::static_pointer_cast<InputWindowsManager>(WIN_MGR);
181 ASSERT_NE(inputWindowsManager, nullptr);
182 inputWindowsManager->captureModeInfo_.isCaptureMode = true;
183 double ret = processor.HandleAxisAccelateTouchPad(axisValue);
184 ASSERT_EQ(ret, 2.0);
185 }
186
187 /**
188 * @tc.name: MouseTransformProcessorTest_CheckDeviceType_01
189 * @tc.desc: Test CheckDeviceType
190 * @tc.type: FUNC
191 * @tc.require:
192 */
193 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_CheckDeviceType_01, TestSize.Level1)
194 {
195 int32_t deviceId = 0;
196 MouseTransformProcessor processor(deviceId);
197 int32_t width = HARD_PC_PRO_DEVICE_WIDTH;
198 int32_t height = HARD_PC_PRO_DEVICE_HEIGHT;
199 ASSERT_NO_FATAL_FAILURE(processor.CheckDeviceType(width, height));
200 }
201
202 /**
203 * @tc.name: MouseTransformProcessorTest_Dump_002
204 * @tc.desc: Test Dump
205 * @tc.type: FUNC
206 * @tc.require:
207 */
208 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_Dump_002, TestSize.Level1)
209 {
210 std::vector<std::string> args;
211 std::vector<std::string> idNames;
212 int32_t deviceId = 0;
213 MouseTransformProcessor processor(deviceId);
214 int32_t fd = 0;
215 processor.Dump(fd, args);
216 ASSERT_EQ(args, idNames);
217 }
218
219 /**
220 * @tc.name: MouseTransformProcessorTest_NormalizeMoveMouse_003
221 * @tc.desc: Test NormalizeMoveMouse
222 * @tc.type: FUNC
223 * @tc.require:
224 */
225 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_NormalizeMoveMouse_003, TestSize.Level1)
226 {
227 bool isNormalize = true;
228 int32_t deviceId = 0;
229 MouseTransformProcessor processor(deviceId);
230 int32_t offsetX = 0;
231 int32_t offsetY = 0;
232 ASSERT_EQ(processor.NormalizeMoveMouse(offsetX, offsetY), isNormalize);
233 }
234
235 /**
236 * @tc.name: MouseTransformProcessorTest_GetDisplayId_004
237 * @tc.desc: Test GetDisplayId
238 * @tc.type: FUNC
239 * @tc.require:
240 */
241 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_GetDisplayId_004, TestSize.Level1)
242 {
243 int32_t idNames = -1;
244 int32_t deviceId = 0;
245 MouseTransformProcessor processor(deviceId);
246 ASSERT_EQ(processor.GetDisplayId(), idNames);
247 }
248
249 /**
250 * @tc.name: MouseTransformProcessorTest_SetPointerSpeed_005
251 * @tc.desc: Test SetPointerSpeed
252 * @tc.type: FUNC
253 * @tc.require:
254 */
255 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_SetPointerSpeed_005, TestSize.Level1)
256 {
257 int32_t idNames = 0;
258 int32_t deviceId = 0;
259 MouseTransformProcessor processor(deviceId);
260 int32_t speed = 5;
261 ASSERT_EQ(processor.SetPointerSpeed(speed), idNames);
262 }
263
264 /**
265 * @tc.name: MouseTransformProcessorTest_SetPointerSpeed_006
266 * @tc.desc: Test GetPointerSpeed
267 * @tc.type: FUNC
268 * @tc.require:
269 */
270 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_SetPointerSpeed_006, TestSize.Level1)
271 {
272 int32_t idNames = 5;
273 int32_t deviceId = 0;
274 MouseTransformProcessor processor(deviceId);
275 int32_t speed = 5;
276 processor.SetPointerSpeed(speed);
277 ASSERT_EQ(processor.GetPointerSpeed(), idNames);
278 }
279
280 /**
281 * @tc.name: MouseTransformProcessorTest_SetPointerLocation_008
282 * @tc.desc: Test SetPointerLocation
283 * @tc.type: FUNC
284 * @tc.require:
285 */
286 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_SetPointerLocation_008, TestSize.Level1)
287 {
288 int32_t idNames = -1;
289 int32_t deviceId = 0;
290 int32_t displayId = -1;
291 MouseTransformProcessor processor(deviceId);
292 int32_t x = 0;
293 int32_t y = 0;
294 ASSERT_EQ(processor.SetPointerLocation(x, y, displayId), idNames);
295 }
296
297 /**
298 * @tc.name: MouseTransformProcessorTest_SetPointerSpeed_009
299 * @tc.desc: Test GetPointerSpeed
300 * @tc.type: FUNC
301 * @tc.require:
302 */
303 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_SetPointerSpeed_009, TestSize.Level1)
304 {
305 int32_t idNames = 1;
306 int32_t deviceId = 0;
307 MouseTransformProcessor processor(deviceId);
308 int32_t speed = 0;
309 processor.SetPointerSpeed(speed);
310 ASSERT_EQ(processor.GetPointerSpeed(), idNames);
311 }
312
313 /**
314 * @tc.name: MouseTransformProcessorTest_SetMousePrimaryButton_010
315 * @tc.desc: Test SetMousePrimaryButton
316 * @tc.type: FUNC
317 * @tc.require:
318 */
319 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_SetMousePrimaryButton_010, TestSize.Level1)
320 {
321 int32_t deviceId = 1;
322 MouseTransformProcessor processor(deviceId);
323 int32_t primaryButton = 1;
324 ASSERT_TRUE(processor.SetMousePrimaryButton(primaryButton) == RET_OK);
325 }
326
327 /**
328 * @tc.name: MouseTransformProcessorTest_GetMousePrimaryButton_011
329 * @tc.desc: Test GetMousePrimaryButton
330 * @tc.type: FUNC
331 * @tc.require:
332 */
333 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_GetMousePrimaryButton_011, TestSize.Level1)
334 {
335 int32_t deviceId = 0;
336 MouseTransformProcessor processor(deviceId);
337 int32_t primaryButton = 1;
338 processor.SetMousePrimaryButton(primaryButton);
339 int32_t primaryButtonRes = 1;
340 ASSERT_TRUE(processor.GetMousePrimaryButton() == primaryButtonRes);
341 }
342
343 /**
344 * @tc.name: MouseTransformProcessorTest_SetMouseScrollRows_012
345 * @tc.desc: Test SetMouseScrollRows
346 * @tc.type: FUNC
347 * @tc.require:
348 */
349 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_SetMouseScrollRows_012, TestSize.Level1)
350 {
351 int32_t deviceId = 1;
352 MouseTransformProcessor processor(deviceId);
353 int32_t rows = 1;
354 ASSERT_TRUE(processor.SetMouseScrollRows(rows) == RET_OK);
355 }
356
357 /**
358 * @tc.name: MouseTransformProcessorTest_GetMouseScrollRows_013
359 * @tc.desc: Test GetMouseScrollRows
360 * @tc.type: FUNC
361 * @tc.require:
362 */
363 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_GetMouseScrollRows_013, TestSize.Level1)
364 {
365 int32_t deviceId = 0;
366 MouseTransformProcessor processor(deviceId);
367 int32_t rows = 1;
368 processor.SetMouseScrollRows(rows);
369 int32_t newRows = 1;
370 ASSERT_TRUE(processor.GetMouseScrollRows() == newRows);
371 }
372 /**
373 * @tc.name: MouseTransformProcessorTest_SetTouchpadScrollSwitch_014
374 * @tc.desc: Test SetTouchpadScrollSwitch
375 * @tc.type: FUNC
376 * @tc.require:
377 */
378 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_SetTouchpadScrollSwitch_014, TestSize.Level1)
379 {
380 int32_t deviceId = 6;
381 MouseTransformProcessor processor(deviceId);
382 int32_t pid = 1;
383 bool flag = false;
384 ASSERT_TRUE(processor.SetTouchpadScrollSwitch(pid, flag) == RET_OK);
385 }
386
387 /**
388 * @tc.name: MouseTransformProcessorTest_GetTouchpadScrollSwitch_015
389 * @tc.desc: Test GetTouchpadScrollSwitch
390 * @tc.type: FUNC
391 * @tc.require:
392 */
393 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_GetTouchpadScrollSwitch_015, TestSize.Level1)
394 {
395 int32_t deviceId = 6;
396 MouseTransformProcessor processor(deviceId);
397 int32_t pid = 1;
398 bool flag = true;
399 processor.SetTouchpadScrollSwitch(pid, flag);
400 bool newFlag = true;
401 processor.GetTouchpadScrollSwitch(flag);
402 ASSERT_TRUE(flag == newFlag);
403 }
404
405 /**
406 * @tc.name: MouseTransformProcessorTest_SetTouchpadScrollSwitch_014
407 * @tc.desc: Test SetTouchpadScrollDirection
408 * @tc.type: FUNC
409 * @tc.require:
410 */
411 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_SetTouchpadScrollDirection_016, TestSize.Level1)
412 {
413 int32_t deviceId = 6;
414 MouseTransformProcessor processor(deviceId);
415 bool state = false;
416 ASSERT_TRUE(processor.SetTouchpadScrollDirection(state) == RET_OK);
417 }
418
419 /**
420 * @tc.name: MouseTransformProcessorTest_GetTouchpadScrollDirection_017
421 * @tc.desc: Test GetTouchpadScrollDirection
422 * @tc.type: FUNC
423 * @tc.require:
424 */
425 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_GetTouchpadScrollDirection_017, TestSize.Level1)
426 {
427 int32_t deviceId = 6;
428 MouseTransformProcessor processor(deviceId);
429 bool state = true;
430 processor.SetTouchpadScrollDirection(state);
431 bool newState = true;
432 processor.GetTouchpadScrollDirection(state);
433 ASSERT_TRUE(state == newState);
434 }
435
436 /**
437 * @tc.name: MouseTransformProcessorTest_SetTouchpadTapSwitch_018
438 * @tc.desc: Test SetTouchpadTapSwitch
439 * @tc.type: FUNC
440 * @tc.require:
441 */
442 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_SetTouchpadTapSwitch_018, TestSize.Level1)
443 {
444 int32_t deviceId = 6;
445 MouseTransformProcessor processor(deviceId);
446 bool flag = false;
447 ASSERT_TRUE(processor.SetTouchpadTapSwitch(flag) == RET_OK);
448 }
449
450 /**
451 * @tc.name: MouseTransformProcessorTest_GetTouchpadTapSwitch_019
452 * @tc.desc: Test GetTouchpadTapSwitch
453 * @tc.type: FUNC
454 * @tc.require:
455 */
456 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_GetTouchpadTapSwitch_019, TestSize.Level1)
457 {
458 int32_t deviceId = 6;
459 MouseTransformProcessor processor(deviceId);
460 bool flag = false;
461 processor.SetTouchpadTapSwitch(flag);
462 bool newFlag = false;
463 processor.GetTouchpadTapSwitch(flag);
464 ASSERT_TRUE(flag == newFlag);
465 }
466
467 /**
468 * @tc.name: MouseTransformProcessorTest_SetTouchpadPointerSpeed_020
469 * @tc.desc: Test SetTouchpadPointerSpeed
470 * @tc.type: FUNC
471 * @tc.require:
472 */
473 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_SetTouchpadPointerSpeed_020, TestSize.Level1)
474 {
475 int32_t deviceId = 6;
476 MouseTransformProcessor processor(deviceId);
477 int32_t speed = 2;
478 ASSERT_TRUE(processor.SetTouchpadPointerSpeed(speed) == RET_OK);
479 }
480
481 /**
482 * @tc.name: MouseTransformProcessorTest_GetTouchpadPointerSpeed_021
483 * @tc.desc: Test GetTouchpadPointerSpeed
484 * @tc.type: FUNC
485 * @tc.require:
486 */
487 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_GetTouchpadPointerSpeed_021, TestSize.Level1)
488 {
489 int32_t deviceId = 6;
490 MouseTransformProcessor processor(deviceId);
491 int32_t speed = 2;
492 processor.SetTouchpadPointerSpeed(speed);
493 int32_t newSpeed = 3;
494 processor.GetTouchpadPointerSpeed(newSpeed);
495 ASSERT_TRUE(speed == newSpeed);
496 }
497
498 /**
499 * @tc.name: MouseTransformProcessorTest_SetTouchpadPointerSpeed_022
500 * @tc.desc: Test SetTouchpadPointerSpeed
501 * @tc.type: FUNC
502 * @tc.require:
503 */
504 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_SetTouchpadPointerSpeed_022, TestSize.Level1)
505 {
506 int32_t deviceId = 6;
507 MouseTransformProcessor processor(deviceId);
508 int32_t speed = 8;
509 ASSERT_TRUE(processor.SetTouchpadPointerSpeed(speed) == RET_OK);
510 }
511
512 /**
513 * @tc.name: MouseTransformProcessorTest_GetTouchpadPointerSpeed_023
514 * @tc.desc: Test GetTouchpadPointerSpeed
515 * @tc.type: FUNC
516 * @tc.require:
517 */
518 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_GetTouchpadPointerSpeed_023, TestSize.Level1)
519 {
520 int32_t deviceId = 6;
521 MouseTransformProcessor processor(deviceId);
522 int32_t speed = 8;
523 processor.SetTouchpadPointerSpeed(speed);
524 int32_t newSpeed = 7;
525 processor.GetTouchpadPointerSpeed(newSpeed);
526 ASSERT_TRUE(speed == newSpeed);
527 }
528
529 /**
530 * @tc.name: MouseTransformProcessorTest_SetTouchpadRightClickType_001
531 * @tc.desc: Test SetTouchpadRightClickType
532 * @tc.type: FUNC
533 * @tc.require:
534 */
535 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_SetTouchpadRightClickType_001, TestSize.Level1)
536 {
537 int32_t deviceId = 6;
538 MouseTransformProcessor processor(deviceId);
539 int32_t type = 2;
540 ASSERT_TRUE(processor.SetTouchpadRightClickType(type) == RET_OK);
541 }
542
543 /**
544 * @tc.name: MouseTransformProcessorTest_SetTouchpadRightClickType_002
545 * @tc.desc: Test SetTouchpadRightClickType
546 * @tc.type: FUNC
547 * @tc.require:
548 */
549 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_SetTouchpadRightClickType_002, TestSize.Level1)
550 {
551 int32_t deviceId = 6;
552 auto originInstance = PREFERENCES_MGR;
553 MouseTransformProcessor processor(deviceId);
554 EXPECT_CALL(*mockPreferencesMgr, SetPreValue(_, _, _)).WillOnce(Return(RET_ERR));
555 PREFERENCES_MGR->SetInstanceForTesting(mockPreferencesMgr);
556 int32_t result = processor.SetTouchpadRightClickType(1);
557 PREFERENCES_MGR->SetInstanceForTesting(originInstance);
558 EXPECT_EQ(result, RET_ERR);
559 }
560
561 /**
562 * @tc.name: MouseTransformProcessorTest_GetTouchpadRightClickType_025
563 * @tc.desc: Test GetTouchpadRightClickType
564 * @tc.type: FUNC
565 * @tc.require:
566 */
567 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_GetTouchpadRightClickType_025, TestSize.Level1)
568 {
569 int32_t deviceId = 6;
570 MouseTransformProcessor processor(deviceId);
571 int32_t type = 1;
572 processor.SetTouchpadRightClickType(type);
573 int32_t newType = 3;
574 processor.GetTouchpadRightClickType(newType);
575 ASSERT_TRUE(type == newType);
576 }
577
578 /**
579 * @tc.name: MouseTransformProcessorTest_GetPointerEvent_001
580 * @tc.desc: Get pointer event verify
581 * @tc.type: FUNC
582 * @tc.require:
583 */
584 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_GetPointerEvent_001, TestSize.Level1)
585 {
586 int32_t deviceId = 0;
587 MouseTransformProcessor processor(deviceId);
588 auto ret = processor.GetPointerEvent();
589 ASSERT_NE(ret, nullptr);
590 }
591
592 /**
593 * @tc.name: MouseTransformProcessorTest_HandleMotionInner_001
594 * @tc.desc: Handle motion inner verify
595 * @tc.type: FUNC
596 * @tc.require:
597 */
598 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_HandleMotionInner_001, TestSize.Level1)
599 {
600 int32_t deviceId = 0;
601 MouseTransformProcessor processor(deviceId);
602 struct libinput_event_pointer* data = nullptr;
603 struct libinput_event* event = nullptr;
604 auto ret = processor.HandleMotionInner(data, event);
605 ASSERT_NE(ret, RET_OK);
606 }
607
608 /**
609 * @tc.name: MouseTransformProcessorTest_CalculateOffset_001
610 * @tc.desc: Calculate offset verify
611 * @tc.type: FUNC
612 * @tc.require:
613 */
614 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_CalculateOffset_001, TestSize.Level1)
615 {
616 int32_t deviceId = 0;
617 MouseTransformProcessor processor(deviceId);
618 Offset offset;
619 OLD::DisplayInfo displayInfo;
620 displayInfo.direction = DIRECTION90;
621 displayInfo.displayDirection = DIRECTION0;
622 ASSERT_NO_FATAL_FAILURE(processor.CalculateOffset(&displayInfo, offset));
623 }
624
625 /**
626 * @tc.name: MouseTransformProcessorTest_CalculateOffset_002
627 * @tc.desc: Calculate offset verify
628 * @tc.type: FUNC
629 * @tc.require:
630 */
631 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_CalculateOffset_002, TestSize.Level1)
632 {
633 int32_t deviceId = 0;
634 MouseTransformProcessor processor(deviceId);
635 Offset offset;
636 OLD::DisplayInfo displayInfo;
637 displayInfo.direction = DIRECTION180;
638 displayInfo.displayDirection = DIRECTION0;
639 ASSERT_NO_FATAL_FAILURE(processor.CalculateOffset(&displayInfo, offset));
640 }
641
642 /**
643 * @tc.name: MouseTransformProcessorTest_CalculateOffset_003
644 * @tc.desc: Calculate offset verify
645 * @tc.type: FUNC
646 * @tc.require:
647 */
648 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_CalculateOffset_003, TestSize.Level1)
649 {
650 int32_t deviceId = 0;
651 MouseTransformProcessor processor(deviceId);
652 Offset offset;
653 OLD::DisplayInfo displayInfo;
654 displayInfo.direction = DIRECTION270;
655 displayInfo.displayDirection = DIRECTION0;
656 ASSERT_NO_FATAL_FAILURE(processor.CalculateOffset(&displayInfo, offset));
657 }
658
659 /**
660 * @tc.name: MouseTransformProcessorTest_HandleButtonInner_001
661 * @tc.desc: Handle button inner verify
662 * @tc.type: FUNC
663 * @tc.require:
664 */
665 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_HandleButtonInner_001, TestSize.Level1)
666 {
667 int32_t deviceId = 0;
668 MouseTransformProcessor processor(deviceId);
669 struct libinput_event_pointer* data = nullptr;
670 struct libinput_event* event = nullptr;
671 auto ret = processor.HandleButtonInner(data, event);
672 ASSERT_NE(ret, RET_OK);
673 }
674
675 /**
676 * @tc.name: MouseTransformProcessorTest_HandleButtonValueInner_001
677 * @tc.desc: Handle button value inner verify
678 * @tc.type: FUNC
679 * @tc.require:
680 */
681 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_HandleButtonValueInner_001, TestSize.Level1)
682 {
683 int32_t deviceId = 0;
684 MouseTransformProcessor processor(deviceId);
685 struct libinput_event_pointer* data = nullptr;
686 uint32_t button = -1;
687 int32_t type = 0;
688 auto ret = processor.HandleButtonValueInner(data, button, type);
689 ASSERT_NE(ret, RET_ERR);
690 }
691
692 /**
693 * @tc.name: MouseTransformProcessorTest_HandleButtonValueInner_002
694 * @tc.desc: Handle button value inner verify
695 * @tc.type: FUNC
696 * @tc.require:
697 */
698 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_HandleButtonValueInner_002, TestSize.Level1)
699 {
700 int32_t deviceId = 0;
701 MouseTransformProcessor processor(deviceId);
702 struct libinput_event_pointer* data = nullptr;
703 uint32_t button = 272;
704 int32_t type = 1;
705 auto ret = processor.HandleButtonValueInner(data, button, type);
706 ASSERT_NE(ret, RET_OK);
707 }
708
709 /**
710 * @tc.name: MouseTransformProcessorTest_HandleTouchPadAxisState_001
711 * @tc.desc: Handle touch pad axis state verify
712 * @tc.type: FUNC
713 * @tc.require:
714 */
715 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_HandleTouchPadAxisState_001, TestSize.Level1)
716 {
717 int32_t deviceId = 0;
718 MouseTransformProcessor processor(deviceId);
719 libinput_pointer_axis_source source = LIBINPUT_POINTER_AXIS_SOURCE_FINGER;
720 int32_t direction = 0;
721 bool tpScrollSwitch = false;
722 ASSERT_NO_FATAL_FAILURE(processor.HandleTouchPadAxisState(source, direction, tpScrollSwitch));
723 }
724
725 /**
726 * @tc.name: MouseTransformProcessorTest_HandleAxisInner_001
727 * @tc.desc: Handle axis inner verify
728 * @tc.type: FUNC
729 * @tc.require:
730 */
731 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_HandleAxisInner_001, TestSize.Level1)
732 {
733 int32_t deviceId = 0;
734 MouseTransformProcessor processor(deviceId);
735 struct libinput_event_pointer* data = nullptr;
736 auto ret = processor.HandleAxisInner(data);
737 ASSERT_NE(ret, RET_OK);
738 }
739
740 /**
741 * @tc.name: MouseTransformProcessorTest_HandleAxisBeginEndInner_001
742 * @tc.desc: Handle axis begin end inner verify
743 * @tc.type: FUNC
744 * @tc.require:
745 */
746 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_HandleAxisBeginEndInner_001, TestSize.Level1)
747 {
748 int32_t deviceId = 0;
749 MouseTransformProcessor processor(deviceId);
750 struct libinput_event* event = nullptr;
751 auto ret = processor.HandleAxisBeginEndInner(event);
752 ASSERT_NE(ret, RET_OK);
753 }
754
755 /**
756 * @tc.name: MouseTransformProcessorTest_HandleAxisPostInner_001
757 * @tc.desc: Handle axis post inner verify
758 * @tc.type: FUNC
759 * @tc.require:
760 */
761 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_HandleAxisPostInner_001, TestSize.Level1)
762 {
763 int32_t deviceId = 0;
764 MouseTransformProcessor processor(deviceId);
765 PointerEvent::PointerItem pointerItem;
766 ASSERT_NO_FATAL_FAILURE(processor.HandleAxisPostInner(pointerItem));
767 }
768
769 /**
770 * @tc.name: MouseTransformProcessorTest_HandlePostInner_001
771 * @tc.desc: Handle post inner verify
772 * @tc.type: FUNC
773 * @tc.require:
774 */
775 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_HandlePostInner_001, TestSize.Level1)
776 {
777 int32_t deviceId = 0;
778 MouseTransformProcessor processor(deviceId);
779 struct libinput_event_pointer* data = nullptr;
780 PointerEvent::PointerItem pointerItem;
781 ASSERT_NO_FATAL_FAILURE(processor.HandlePostInner(data, pointerItem));
782 }
783
784 /**
785 * @tc.name: MouseTransformProcessorTest_Normalize_001
786 * @tc.desc: Normalize verify
787 * @tc.type: FUNC
788 * @tc.require:
789 */
790 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_Normalize_001, TestSize.Level1)
791 {
792 int32_t deviceId = 0;
793 MouseTransformProcessor processor(deviceId);
794 struct libinput_event* event = nullptr;
795 auto ret = processor.Normalize(event);
796 ASSERT_NE(ret, RET_OK);
797 }
798
799 /**
800 * @tc.name: MouseTransformProcessorTest_NormalizeRotateEvent_001
801 * @tc.desc: Normalize rotate event verify
802 * @tc.type: FUNC
803 * @tc.require:
804 */
805 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_NormalizeRotateEvent_001, TestSize.Level1)
806 {
807 int32_t deviceId = 0;
808 MouseTransformProcessor processor(deviceId);
809 struct libinput_event* event = nullptr;
810 int32_t type = 1;
811 double angle = 90.0;
812 auto ret = processor.NormalizeRotateEvent(event, type, angle);
813 ASSERT_NE(ret, RET_OK);
814 }
815
816 /**
817 * @tc.name: MouseTransformProcessorTest_HandleMotionMoveMouse_001
818 * @tc.desc: Handle motion move mouse verify
819 * @tc.type: FUNC
820 * @tc.require:
821 */
822 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_HandleMotionMoveMouse_001, TestSize.Level1)
823 {
824 int32_t deviceId = 0;
825 MouseTransformProcessor processor(deviceId);
826 int32_t offsetX = 10;
827 int32_t offsetY = 20;
828 ASSERT_NO_FATAL_FAILURE(processor.HandleMotionMoveMouse(offsetX, offsetY));
829 }
830
831 /**
832 * @tc.name: MouseTransformProcessorTest_HandleMotionMoveMouse_002
833 * @tc.desc: Handle motion move mouse verify
834 * @tc.type: FUNC
835 * @tc.require:
836 */
837 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_HandleMotionMoveMouse_002, TestSize.Level1)
838 {
839 int32_t deviceId = 0;
840 MouseTransformProcessor processor(deviceId);
841 int32_t offsetX = -1000;
842 int32_t offsetY = 500;
843 ASSERT_NO_FATAL_FAILURE(processor.HandleMotionMoveMouse(offsetX, offsetY));
844 }
845
846 /**
847 * @tc.name: MouseTransformProcessorTest_OnDisplayLost_001
848 * @tc.desc: On display lost verify
849 * @tc.type: FUNC
850 * @tc.require:
851 */
852 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_OnDisplayLost_001, TestSize.Level1)
853 {
854 int32_t deviceId = 0;
855 MouseTransformProcessor processor(deviceId);
856 int32_t displayId = -1;
857 ASSERT_NO_FATAL_FAILURE(processor.OnDisplayLost(displayId));
858 }
859
860 /**
861 * @tc.name: MouseTransformProcessorTest_OnDisplayLost_002
862 * @tc.desc: On display lost verify
863 * @tc.type: FUNC
864 * @tc.require:
865 */
866 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_OnDisplayLost_002, TestSize.Level1)
867 {
868 int32_t deviceId = 0;
869 MouseTransformProcessor processor(deviceId);
870 int32_t displayId = 1;
871 ASSERT_NO_FATAL_FAILURE(processor.OnDisplayLost(displayId));
872 }
873
874 /**
875 * @tc.name: MouseTransformProcessorTest_HandlePostMoveMouse_001
876 * @tc.desc: Handle post move mouse verify
877 * @tc.type: FUNC
878 * @tc.require:
879 */
880 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_HandlePostMoveMouse_001, TestSize.Level1)
881 {
882 int32_t deviceId = 0;
883 MouseTransformProcessor processor(deviceId);
884 PointerEvent::PointerItem pointerItem;
885 ASSERT_NO_FATAL_FAILURE(processor.HandlePostMoveMouse(pointerItem));
886 }
887
888 /**
889 * @tc.name: MouseTransformProcessorTest_DumpInner_001
890 * @tc.desc: Dump inner verify
891 * @tc.type: FUNC
892 * @tc.require:
893 */
894 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_DumpInner_001, TestSize.Level1)
895 {
896 int32_t deviceId = 0;
897 MouseTransformProcessor processor(deviceId);
898 ASSERT_NO_FATAL_FAILURE(processor.DumpInner());
899 }
900
901 /**
902 * @tc.name: MouseTransformProcessorTest_GetTouchpadSpeed_001
903 * @tc.desc: Get touchpad speed verify
904 * @tc.type: FUNC
905 * @tc.require:
906 */
907 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_GetTouchpadSpeed_001, TestSize.Level1)
908 {
909 int32_t deviceId = 0;
910 MouseTransformProcessor processor(deviceId);
911 auto ret = processor.GetTouchpadSpeed();
912 ASSERT_NE(ret, RET_OK);
913 }
914
915 /**
916 * @tc.name: MouseTransformProcessorTest_Normalize_01
917 * @tc.desc: Test the branch that handles mouse movement events
918 * @tc.type: FUNC
919 * @tc.require:
920 */
921 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_Normalize_01, TestSize.Level1)
922 {
923 CALL_TEST_DEBUG;
924 vMouse_.SendEvent(EV_REL, REL_X, 5);
925 vMouse_.SendEvent(EV_REL, REL_Y, -10);
926 vMouse_.SendEvent(EV_SYN, SYN_REPORT, 0);
927 libinput_event *event = libinput_.Dispatch();
928 ASSERT_TRUE(event != nullptr);
929 struct libinput_device *dev = libinput_event_get_device(event);
930 ASSERT_TRUE(dev != nullptr);
931 std::cout << "pointer device: " << libinput_device_get_name(dev) << std::endl;
932 int32_t deviceId = 0;
933 MouseTransformProcessor processor(deviceId);
934 EXPECT_EQ(processor.Normalize(event), RET_ERR);
935 }
936
937 /**
938 * @tc.name: MouseTransformProcessorTest_Normalize_02
939 * @tc.desc: Tests the branch that handles the left mouse button event
940 * @tc.type: FUNC
941 * @tc.require:
942 */
943 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_Normalize_02, TestSize.Level1)
944 {
945 CALL_TEST_DEBUG;
946 vMouse_.SendEvent(EV_KEY, BTN_LEFT, 1);
947 vMouse_.SendEvent(EV_SYN, SYN_REPORT, 0);
948 libinput_event *event = libinput_.Dispatch();
949 ASSERT_TRUE(event != nullptr);
950 struct libinput_device *dev = libinput_event_get_device(event);
951 ASSERT_TRUE(dev != nullptr);
952 std::cout << "pointer device: " << libinput_device_get_name(dev) << std::endl;
953 int32_t deviceId = 0;
954 MouseTransformProcessor processor(deviceId);
955 EXPECT_EQ(processor.Normalize(event), RET_ERR);
956 }
957
958 /**
959 * @tc.name: MouseTransformProcessorTest_NormalizeRotateEvent_01
960 * @tc.desc: Test normal conditions
961 * @tc.type: FUNC
962 * @tc.require:
963 */
964 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_NormalizeRotateEvent_01, TestSize.Level1)
965 {
966 CALL_TEST_DEBUG;
967 vMouse_.SendEvent(EV_REL, REL_X, 5);
968 vMouse_.SendEvent(EV_REL, REL_Y, -10);
969 vMouse_.SendEvent(EV_SYN, SYN_REPORT, 0);
970 libinput_event *event = libinput_.Dispatch();
971 ASSERT_TRUE(event != nullptr);
972 struct libinput_device *dev = libinput_event_get_device(event);
973 ASSERT_TRUE(dev != nullptr);
974 std::cout << "pointer device: " << libinput_device_get_name(dev) << std::endl;
975 int32_t deviceId = 0;
976 MouseTransformProcessor processor(deviceId);
977 int32_t type = 1;
978 double angle = 90.0;
979 int32_t result = processor.NormalizeRotateEvent(event, type, angle);
980 EXPECT_EQ(result, RET_OK);
981 }
982
983 /**
984 * @tc.name: MouseTransformProcessorTest_NormalizeRotateEvent_02
985 * @tc.desc: Tests HandlePostInner return false
986 * @tc.type: FUNC
987 * @tc.require:
988 */
989 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_NormalizeRotateEvent_02, TestSize.Level1)
990 {
991 CALL_TEST_DEBUG;
992 vMouse_.SendEvent(EV_REL, REL_X, 5);
993 vMouse_.SendEvent(EV_REL, REL_Y, -10);
994 vMouse_.SendEvent(EV_SYN, SYN_REPORT, 0);
995 libinput_event *event = libinput_.Dispatch();
996 ASSERT_TRUE(event != nullptr);
997 struct libinput_device *dev = libinput_event_get_device(event);
998 ASSERT_TRUE(dev != nullptr);
999 std::cout << "pointer device: " << libinput_device_get_name(dev) << std::endl;
1000 int32_t deviceId = 0;
1001 MouseTransformProcessor processor(deviceId);
1002 int32_t type = 0;
1003 double angle = 0.0;
1004 std::shared_ptr<PointerEvent::PointerItem> pointerItem = nullptr;
1005 int32_t result = processor.NormalizeRotateEvent(event, type, angle);
1006 EXPECT_EQ(result, RET_OK);
1007 }
1008
1009 /**
1010 * @tc.name: MouseTransformProcessorTest_HandleTouchpadLeftButton_001
1011 * @tc.desc: Handle touchpad left button verify
1012 * @tc.type: FUNC
1013 * @tc.require:
1014 */
1015 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_HandleTouchpadLeftButton_001, TestSize.Level1)
1016 {
1017 int32_t deviceId = 0;
1018 MouseTransformProcessor processor(deviceId);
1019 struct libinput_event_pointer* data = nullptr;
1020 int32_t eventType = 1;
1021 uint32_t button = 0x118;
1022 ASSERT_NO_FATAL_FAILURE(processor.HandleTouchpadLeftButton(data, eventType, button));
1023 }
1024
1025 /**
1026 * @tc.name: MouseTransformProcessorTest_HandleTouchpadLeftButton_002
1027 * @tc.desc: Handle touchpad left button verify
1028 * @tc.type: FUNC
1029 * @tc.require:
1030 */
1031 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_HandleTouchpadLeftButton_002, TestSize.Level1)
1032 {
1033 int32_t deviceId = 0;
1034 MouseTransformProcessor processor(deviceId);
1035 struct libinput_event_pointer* data = nullptr;
1036 int32_t eventType = 1;
1037 uint32_t button = MouseDeviceState::LIBINPUT_RIGHT_BUTTON_CODE;
1038 ASSERT_NO_FATAL_FAILURE(processor.HandleTouchpadLeftButton(data, eventType, button));
1039 }
1040
1041 /**
1042 * @tc.name: MouseTransformProcessorTest_HandleTouchpadLeftButton_003
1043 * @tc.desc: Handle touchpad left button verify
1044 * @tc.type: FUNC
1045 * @tc.require:
1046 */
1047 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_HandleTouchpadLeftButton_003, TestSize.Level1)
1048 {
1049 int32_t deviceId = 0;
1050 MouseTransformProcessor processor(deviceId);
1051 struct libinput_event_pointer* data = nullptr;
1052 int32_t eventType = LIBINPUT_EVENT_POINTER_TAP;
1053 uint32_t button = MouseDeviceState::LIBINPUT_RIGHT_BUTTON_CODE;
1054 ASSERT_NO_FATAL_FAILURE(processor.HandleTouchpadLeftButton(data, eventType, button));
1055 }
1056
1057 /**
1058 * @tc.name: MouseTransformProcessorTest_HandleTouchpadLeftButton_004
1059 * @tc.desc: Handle touchpad left button verify
1060 * @tc.type: FUNC
1061 * @tc.require:
1062 */
1063 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_HandleTouchpadLeftButton_004, TestSize.Level1)
1064 {
1065 int32_t deviceId = 0;
1066 MouseTransformProcessor processor(deviceId);
1067 struct libinput_event_pointer* data = nullptr;
1068 int32_t eventType = LIBINPUT_EVENT_POINTER_BUTTON_TOUCHPAD;
1069 uint32_t button = MouseDeviceState::LIBINPUT_LEFT_BUTTON_CODE;
1070 ASSERT_NO_FATAL_FAILURE(processor.HandleTouchpadLeftButton(data, eventType, button));
1071 }
1072
1073 /**
1074 * @tc.name: MouseTransformProcessorTest_HandleAxisBeginEndInner_01
1075 * @tc.desc: Test HandleAxisBeginEndInner
1076 * @tc.type: FUNC
1077 * @tc.require:
1078 */
1079 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_HandleAxisBeginEndInner_01, TestSize.Level1)
1080 {
1081 CALL_TEST_DEBUG;
1082 int32_t deviceId = 1;
1083 bool isAxisBegin;
1084 bool isPressed;
1085 MouseTransformProcessor processor(deviceId);
1086
1087 vMouse_.SendEvent(EV_REL, REL_X, 5);
1088 vMouse_.SendEvent(EV_REL, REL_Y, -10);
1089 vMouse_.SendEvent(EV_SYN, SYN_REPORT, 0);
1090 libinput_event *event = libinput_.Dispatch();
1091 ASSERT_TRUE(event != nullptr);
1092 struct libinput_device *dev = libinput_event_get_device(event);
1093 ASSERT_TRUE(dev != nullptr);
1094
1095 isAxisBegin = false;
1096 isPressed = true;
1097 int32_t ret = processor.HandleAxisBeginEndInner(event);
1098 EXPECT_EQ(ret, RET_ERR);
1099 }
1100
1101 /**
1102 * @tc.name: MouseTransformProcessorTest_HandleAxisBeginEndInner_02
1103 * @tc.desc: Test HandleAxisBeginEndInner
1104 * @tc.type: FUNC
1105 * @tc.require:
1106 */
1107 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_HandleAxisBeginEndInner_02, TestSize.Level1)
1108 {
1109 CALL_TEST_DEBUG;
1110 bool isAxisBegin;
1111 bool isPressed;
1112 int32_t deviceId = 1;
1113 MouseTransformProcessor processor(deviceId);
1114 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
1115 ASSERT_TRUE(pointerEvent != nullptr);
1116
1117 vMouse_.SendEvent(EV_REL, REL_X, 5);
1118 vMouse_.SendEvent(EV_REL, REL_Y, -10);
1119 vMouse_.SendEvent(EV_SYN, SYN_REPORT, 0);
1120 libinput_event *event = libinput_.Dispatch();
1121 ASSERT_TRUE(event != nullptr);
1122 struct libinput_device *dev = libinput_event_get_device(event);
1123 ASSERT_TRUE(dev != nullptr);
1124
1125 isAxisBegin = true;
1126 isPressed = true;
1127 int32_t ret = processor.HandleAxisBeginEndInner(event);
1128 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_AXIS_END);
1129 EXPECT_EQ(ret, RET_ERR);
1130 }
1131
1132 /**
1133 * @tc.name: MouseTransformProcessorTest_HandleAxisBeginEndInner_03
1134 * @tc.desc: Test HandleAxisBeginEndInner
1135 * @tc.type: FUNC
1136 * @tc.require:
1137 */
1138 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_HandleAxisBeginEndInner_03, TestSize.Level1)
1139 {
1140 CALL_TEST_DEBUG;
1141 int32_t buttonId;
1142 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
1143 ASSERT_TRUE(pointerEvent != nullptr);
1144 int32_t deviceId = 1;
1145 MouseTransformProcessor processor(deviceId);
1146
1147 vMouse_.SendEvent(EV_REL, REL_X, 5);
1148 vMouse_.SendEvent(EV_REL, REL_Y, -10);
1149 vMouse_.SendEvent(EV_SYN, SYN_REPORT, 0);
1150 libinput_event *event = libinput_.Dispatch();
1151 ASSERT_TRUE(event != nullptr);
1152 struct libinput_device *dev = libinput_event_get_device(event);
1153 ASSERT_TRUE(dev != nullptr);
1154
1155 buttonId = PointerEvent::BUTTON_NONE;
1156 int32_t ret = processor.HandleAxisBeginEndInner(event);
1157 EXPECT_EQ(ret, RET_ERR);
1158 }
1159
1160 /**
1161 * @tc.name: MouseTransformProcessorTest_CheckAndPackageAxisEvent_001
1162 * @tc.desc: Test isAxisBegin is false
1163 * @tc.type: FUNC
1164 * @tc.require:
1165 */
1166 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_CheckAndPackageAxisEvent_001, TestSize.Level1)
1167 {
1168 CALL_TEST_DEBUG;
1169 int32_t deviceId = 0;
1170 MouseTransformProcessor processor(deviceId);
1171 processor.isAxisBegin_ = false;
1172 bool result = processor.CheckAndPackageAxisEvent();
1173 EXPECT_FALSE(result);
1174 }
1175
1176 /**
1177 * @tc.name: MouseTransformProcessorTest_CheckAndPackageAxisEvent_002
1178 * @tc.desc: Test isAxisBegin is true
1179 * @tc.type: FUNC
1180 * @tc.require:
1181 */
1182 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_CheckAndPackageAxisEvent_002, TestSize.Level1)
1183 {
1184 CALL_TEST_DEBUG;
1185 int32_t deviceId = 0;
1186 MouseTransformProcessor processor(deviceId);
1187 processor.isAxisBegin_ = true;
1188 bool result = processor.CheckAndPackageAxisEvent();
1189 EXPECT_TRUE(result);
1190 }
1191
1192 /**
1193 * @tc.name: MouseTransformProcessorTest_HandleButtonValueInner_003
1194 * @tc.desc: The corresponding key type cannot be found in the test overlay buttonId
1195 * @tc.type: FUNC
1196 * @tc.require:
1197 */
1198 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_HandleButtonValueInner_003, TestSize.Level1)
1199 {
1200 CALL_TEST_DEBUG;
1201 vMouse_.SendEvent(EV_REL, REL_X, 5);
1202 vMouse_.SendEvent(EV_REL, REL_Y, -10);
1203 vMouse_.SendEvent(EV_SYN, SYN_REPORT, 0);
1204 libinput_event *event = libinput_.Dispatch();
1205 ASSERT_TRUE(event != nullptr);
1206 auto data = libinput_event_get_pointer_event(event);
1207 ASSERT_TRUE(data != nullptr);
1208 int32_t deviceId = 0;
1209 MouseTransformProcessor processor(deviceId);
1210 uint32_t button = 0;
1211 int32_t type = 2;
1212 int32_t ret = processor.HandleButtonValueInner(data, button, type);
1213 EXPECT_EQ(ret, RET_ERR);
1214 }
1215
1216 /**
1217 * @tc.name: MouseTransformProcessorTest_HandleButtonValueInner_004
1218 * @tc.desc: Test overwrite buttonId to find corresponding key type
1219 * @tc.type: FUNC
1220 * @tc.require:
1221 */
1222 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_HandleButtonValueInner_004, TestSize.Level1)
1223 {
1224 CALL_TEST_DEBUG;
1225 vMouse_.SendEvent(EV_REL, REL_X, 5);
1226 vMouse_.SendEvent(EV_REL, REL_Y, -10);
1227 vMouse_.SendEvent(EV_SYN, SYN_REPORT, 0);
1228 libinput_event *event = libinput_.Dispatch();
1229 ASSERT_TRUE(event != nullptr);
1230 auto data = libinput_event_get_pointer_event(event);
1231 ASSERT_TRUE(data != nullptr);
1232 int32_t deviceId = 0;
1233 MouseTransformProcessor processor(deviceId);
1234 uint32_t button = MouseDeviceState::LIBINPUT_LEFT_BUTTON_CODE;
1235 int32_t type = 2;
1236 int32_t ret = processor.HandleButtonValueInner(data, button, type);
1237 EXPECT_EQ(ret, RET_OK);
1238 }
1239
1240 /**
1241 * @tc.name: MouseTransformProcessorTest_HandleButtonValueInner_005
1242 * @tc.desc: Test the case that the buttonId covers different key types
1243 * @tc.type: FUNC
1244 * @tc.require:
1245 */
1246 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_HandleButtonValueInner_005, TestSize.Level1)
1247 {
1248 CALL_TEST_DEBUG;
1249 vMouse_.SendEvent(EV_REL, REL_X, 5);
1250 vMouse_.SendEvent(EV_REL, REL_Y, -10);
1251 vMouse_.SendEvent(EV_SYN, SYN_REPORT, 0);
1252 libinput_event *event = libinput_.Dispatch();
1253 ASSERT_TRUE(event != nullptr);
1254 auto data = libinput_event_get_pointer_event(event);
1255 ASSERT_TRUE(data != nullptr);
1256 int32_t deviceId = 0;
1257 MouseTransformProcessor processor(deviceId);
1258 uint32_t button = MouseDeviceState::LIBINPUT_RIGHT_BUTTON_CODE;
1259 int32_t type = 2;
1260 int32_t ret = processor.HandleButtonValueInner(data, button, type);
1261 EXPECT_EQ(ret, RET_OK);
1262 button = MouseDeviceState::LIBINPUT_MIDDLE_BUTTON_CODE;
1263 ret = processor.HandleButtonValueInner(data, button, type);
1264 EXPECT_EQ(ret, RET_OK);
1265 }
1266
1267 /**
1268 * @tc.name: MouseTransformProcessorTest_HandleMotionInner_002
1269 * @tc.desc: Test HandleMotionInner
1270 * @tc.type: FUNC
1271 * @tc.require:
1272 */
1273 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_HandleMotionInner_002, TestSize.Level1)
1274 {
1275 CALL_TEST_DEBUG;
1276 vMouse_.SendEvent(EV_REL, REL_X, 5);
1277 vMouse_.SendEvent(EV_REL, REL_Y, -10);
1278 vMouse_.SendEvent(EV_SYN, SYN_REPORT, 0);
1279 libinput_event *event = libinput_.Dispatch();
1280 ASSERT_TRUE(event != nullptr);
1281 auto data = libinput_event_get_pointer_event(event);
1282 ASSERT_TRUE(data != nullptr);
1283 int32_t deviceId = 0;
1284 MouseTransformProcessor processor(deviceId);
1285 int32_t ret = processor.HandleMotionInner(data, event);
1286 EXPECT_EQ(ret, RET_ERR);
1287 }
1288
1289 /**
1290 * @tc.name: MouseTransformProcessorTest_HandleMotionInner_003
1291 * @tc.desc: Test HandleMotionInner
1292 * @tc.type: FUNC
1293 * @tc.require:
1294 */
1295 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_HandleMotionInner_003, TestSize.Level1)
1296 {
1297 CALL_TEST_DEBUG;
1298 vMouse_.SendEvent(EV_REL, REL_X, 5);
1299 vMouse_.SendEvent(EV_REL, REL_Y, -10);
1300 vMouse_.SendEvent(EV_SYN, SYN_REPORT, 0);
1301 libinput_event *event = libinput_.Dispatch();
1302 ASSERT_TRUE(event != nullptr);
1303 auto data = libinput_event_get_pointer_event(event);
1304 ASSERT_TRUE(data != nullptr);
1305 int32_t deviceId = 0;
1306 MouseTransformProcessor processor(deviceId);
1307 CursorPosition cursorPos;
1308 cursorPos.displayId = -1;
1309 int32_t type = LIBINPUT_EVENT_POINTER_MOTION_TOUCHPAD;
1310 int32_t ret = processor.HandleMotionInner(data, event);
1311 EXPECT_EQ(ret, RET_ERR);
1312 type = LIBINPUT_EVENT_POINTER_BUTTON;
1313 ret = processor.HandleMotionInner(data, event);
1314 EXPECT_EQ(ret, RET_ERR);
1315 }
1316
1317 /**
1318 * @tc.name: MouseTransformProcessorTest_HandleButtonInner_002
1319 * @tc.desc: Test HandleButtonInner
1320 * @tc.type: FUNC
1321 * @tc.require:
1322 */
1323 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_HandleButtonInner_002, TestSize.Level1)
1324 {
1325 CALL_TEST_DEBUG;
1326 vMouse_.SendEvent(EV_REL, REL_X, 5);
1327 vMouse_.SendEvent(EV_REL, REL_Y, -10);
1328 vMouse_.SendEvent(EV_SYN, SYN_REPORT, 0);
1329 libinput_event *event = libinput_.Dispatch();
1330 ASSERT_TRUE(event != nullptr);
1331 auto data = libinput_event_get_pointer_event(event);
1332 ASSERT_TRUE(data != nullptr);
1333 int32_t deviceId = 0;
1334 MouseTransformProcessor processor(deviceId);
1335 int32_t ret = processor.HandleButtonInner(data, event);
1336 EXPECT_EQ(ret, RET_ERR);
1337 }
1338
1339 /**
1340 * @tc.name: MouseTransformProcessorTest_HandleTouchPadAxisState_01
1341 * @tc.desc: Test HandleTouchPadAxisState
1342 * @tc.type: FUNC
1343 * @tc.require:
1344 */
1345 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_HandleTouchPadAxisState_01, TestSize.Level1)
1346 {
1347 int32_t deviceId = 0;
1348 MouseTransformProcessor processor(deviceId);
1349 libinput_pointer_axis_source source = LIBINPUT_POINTER_AXIS_SOURCE_FINGER;
1350 int32_t direction = 1;
1351 bool tpScrollSwitch = true;
1352 processor.HandleTouchPadAxisState(source, direction, tpScrollSwitch);
1353 }
1354
1355 /**
1356 * @tc.name: MouseTransformProcessorTest_HandleTouchpadLeftButton_01
1357 * @tc.desc: Test HandleTouchpadLeftButton
1358 * @tc.type: FUNC
1359 * @tc.require:
1360 */
1361 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_HandleTouchpadLeftButton_01, TestSize.Level1)
1362 {
1363 int32_t deviceId = 0;
1364 MouseTransformProcessor processor(deviceId);
1365 struct libinput_event_pointer *data = nullptr;
1366 int32_t evenType = LIBINPUT_EVENT_POINTER_BUTTON_TOUCHPAD;
1367 uint32_t button = BTN_RIGHT_MENUE_CODE;
1368 ASSERT_NO_FATAL_FAILURE(processor.HandleTouchpadLeftButton(data, evenType, button));
1369 }
1370
1371 /**
1372 * @tc.name: MouseTransformProcessorTest_HandleTouchpadLeftButton_02
1373 * @tc.desc: Test HandleTouchpadLeftButton
1374 * @tc.type: FUNC
1375 * @tc.require:
1376 */
1377 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_HandleTouchpadLeftButton_02, TestSize.Level1)
1378 {
1379 int32_t deviceId = 0;
1380 MouseTransformProcessor processor(deviceId);
1381 struct libinput_event_pointer *data = nullptr;
1382 int32_t evenType = LIBINPUT_EVENT_POINTER_BUTTON_TOUCHPAD;
1383 uint32_t button = MouseDeviceState::LIBINPUT_BUTTON_CODE::LIBINPUT_RIGHT_BUTTON_CODE;
1384 ASSERT_NO_FATAL_FAILURE(processor.HandleTouchpadLeftButton(data, evenType, button));
1385 }
1386
1387 /**
1388 * @tc.name: MouseTransformProcessorTest_HandleTouchpadLeftButton_03
1389 * @tc.desc: Test HandleTouchpadLeftButton
1390 * @tc.type: FUNC
1391 * @tc.require:
1392 */
1393 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_HandleTouchpadLeftButton_03, TestSize.Level1)
1394 {
1395 int32_t deviceId = 0;
1396 MouseTransformProcessor processor(deviceId);
1397 struct libinput_event_pointer *data = nullptr;
1398 int32_t evenType = LIBINPUT_EVENT_POINTER_TAP;
1399 uint32_t button = MouseDeviceState::LIBINPUT_BUTTON_CODE::LIBINPUT_RIGHT_BUTTON_CODE;
1400 ASSERT_NO_FATAL_FAILURE(processor.HandleTouchpadLeftButton(data, evenType, button));
1401 }
1402
1403 /**
1404 * @tc.name: MouseTransformProcessorTest_HandleTouchpadLeftButton_04
1405 * @tc.desc: Test HandleTouchpadLeftButton
1406 * @tc.type: FUNC
1407 * @tc.require:
1408 */
1409 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_HandleTouchpadLeftButton_04, TestSize.Level1)
1410 {
1411 int32_t deviceId = 0;
1412 MouseTransformProcessor processor(deviceId);
1413 struct libinput_event_pointer *data = nullptr;
1414 int32_t evenType = LIBINPUT_EVENT_POINTER_BUTTON_TOUCHPAD;
1415 uint32_t button = MouseDeviceState::LIBINPUT_BUTTON_CODE::LIBINPUT_LEFT_BUTTON_CODE;
1416 ASSERT_NO_FATAL_FAILURE(processor.HandleTouchpadLeftButton(data, evenType, button));
1417 }
1418
1419 /**
1420 * @tc.name: MouseTransformProcessorTest_TransTouchpadRightButton_04
1421 * @tc.desc: Test TransTouchpadRightButton
1422 * @tc.type: FUNC
1423 * @tc.require:
1424 */
1425 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_TransTouchpadRightButton_04, TestSize.Level1)
1426 {
1427 int32_t deviceId = 0;
1428 MouseTransformProcessor processor(deviceId);
1429 struct libinput_event_pointer *data = nullptr;
1430 int32_t evenType = LIBINPUT_EVENT_KEYBOARD_KEY;
1431 uint32_t button = BTN_RIGHT_MENUE_CODE;
1432 processor.TransTouchpadRightButton(data, evenType, button);
1433 }
1434
1435 /**
1436 * @tc.name: MouseTransformProcessorTest_TransTouchpadRightButton_05
1437 * @tc.desc: Test TransTouchpadRightButton
1438 * @tc.type: FUNC
1439 * @tc.require:
1440 */
1441 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_TransTouchpadRightButton_05, TestSize.Level1)
1442 {
1443 int32_t deviceId = 0;
1444 MouseTransformProcessor processor(deviceId);
1445 struct libinput_event_pointer *data = nullptr;
1446 int32_t evenType = 55;
1447 uint32_t button = BTN_RIGHT_MENUE_CODE;
1448 processor.TransTouchpadRightButton(data, evenType, button);
1449 }
1450
1451 /**
1452 * @tc.name: MouseTransformProcessorTest_TransTouchpadRightButton_06
1453 * @tc.desc: Test TransTouchpadRightButton
1454 * @tc.type: FUNC
1455 * @tc.require:
1456 */
1457 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_TransTouchpadRightButton_06, TestSize.Level1)
1458 {
1459 int32_t deviceId = 0;
1460 MouseTransformProcessor processor(deviceId);
1461 processor.SetTouchpadRightClickType(2);
1462 struct libinput_event_pointer *data = nullptr;
1463 int32_t evenType = 60;
1464 uint32_t button = BTN_RIGHT_MENUE_CODE;
1465 processor.TransTouchpadRightButton(data, evenType, button);
1466 }
1467
1468 /**
1469 * @tc.name: MouseTransformProcessorTest_TransTouchpadRightButton_07
1470 * @tc.desc: Test TransTouchpadRightButton
1471 * @tc.type: FUNC
1472 * @tc.require:
1473 */
1474 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_TransTouchpadRightButton_07, TestSize.Level1)
1475 {
1476 int32_t deviceId = 0;
1477 MouseTransformProcessor processor(deviceId);
1478 int32_t type = 4;
1479 processor.SetTouchpadRightClickType(type);
1480 struct libinput_event_pointer *data = nullptr;
1481 int32_t evenType = 60;
1482 uint32_t button = BTN_RIGHT_MENUE_CODE;
1483 processor.TransTouchpadRightButton(data, evenType, button);
1484 int32_t newType = 1;
1485 processor.GetTouchpadRightClickType(newType);
1486 ASSERT_TRUE(type == newType);
1487 }
1488
1489 /**
1490 * @tc.name: MouseTransformProcessorTest_TransTouchpadRightButton_08
1491 * @tc.desc: Test TransTouchpadRightButton
1492 * @tc.type: FUNC
1493 * @tc.require:
1494 */
1495 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_TransTouchpadRightButton_08, TestSize.Level1)
1496 {
1497 int32_t deviceId = 0;
1498 MouseTransformProcessor processor(deviceId);
1499 int32_t type = 5;
1500 processor.SetTouchpadRightClickType(type);
1501 struct libinput_event_pointer *data = nullptr;
1502 int32_t evenType = 60;
1503 uint32_t button = BTN_RIGHT_MENUE_CODE;
1504 processor.TransTouchpadRightButton(data, evenType, button);
1505 int32_t newType = 1;
1506 processor.GetTouchpadRightClickType(newType);
1507 ASSERT_TRUE(type == newType);
1508 }
1509
1510 /**
1511 * @tc.name: MouseTransformProcessorTest_HandlePostInner_01
1512 * @tc.desc: Test HandlePostInner
1513 * @tc.type: FUNC
1514 * @tc.require:
1515 */
1516 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_HandlePostInner_01, TestSize.Level1)
1517 {
1518 CALL_TEST_DEBUG;
1519 int32_t deviceId = 1;
1520 MouseTransformProcessor processor(deviceId);
1521 PointerEvent::PointerItem item;
1522 item.SetDisplayX(10);
1523 item.SetDisplayY(15);
1524 item.SetWindowX(0);
1525 item.SetWindowY(0);
1526 item.SetPointerId(1);
1527 item.SetPressed(true);
1528 item.SetDownTime(1000);
1529 item.SetWidth(0);
1530 item.SetHeight(0);
1531 item.SetPressure(0.5);
1532
1533 vTouchpad_.SendEvent(EV_ABS, ABS_MT_TRACKING_ID, 2);
1534 vTouchpad_.SendEvent(EV_ABS, ABS_MT_POSITION_X, 2220);
1535 vTouchpad_.SendEvent(EV_ABS, ABS_MT_POSITION_Y, 727);
1536 vTouchpad_.SendEvent(EV_SYN, SYN_REPORT, 0);
1537 vTouchpad_.SendEvent(EV_ABS, ABS_MT_POSITION_Y, 710);
1538 vTouchpad_.SendEvent(EV_SYN, SYN_REPORT, 0);
1539 libinput_event *event = libinput_.Dispatch();
1540 ASSERT_TRUE(event != nullptr);
1541 libinput_event_pointer* data = libinput_event_get_pointer_event(event);
1542 ASSERT_TRUE(data != nullptr);
1543 libinput_pointer_axis_source source = libinput_event_pointer_get_axis_source(data);
1544 source = LIBINPUT_POINTER_AXIS_SOURCE_FINGER;
1545
1546 bool ret = processor.HandlePostInner(data, item);
1547 EXPECT_TRUE(ret);
1548 }
1549
1550 /**
1551 * @tc.name: MouseTransformProcessorTest_HandleAxisInner_02
1552 * @tc.desc: Test HandleAxisInner
1553 * @tc.type: FUNC
1554 * @tc.require:
1555 */
1556 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_HandleAxisInner_02, TestSize.Level1)
1557 {
1558 CALL_TEST_DEBUG;
1559 int32_t deviceId = 1;
1560 bool isAxisBegin;
1561 MouseTransformProcessor processor(deviceId);
1562
1563 vTouchpad_.SendEvent(EV_ABS, ABS_MT_TRACKING_ID, 2);
1564 vTouchpad_.SendEvent(EV_ABS, ABS_MT_POSITION_X, 2220);
1565 vTouchpad_.SendEvent(EV_ABS, ABS_MT_POSITION_Y, 727);
1566 vTouchpad_.SendEvent(EV_SYN, SYN_REPORT, 0);
1567 vTouchpad_.SendEvent(EV_ABS, ABS_MT_POSITION_Y, 710);
1568 vTouchpad_.SendEvent(EV_SYN, SYN_REPORT, 0);
1569 libinput_event *event = libinput_.Dispatch();
1570 ASSERT_TRUE(event != nullptr);
1571 auto data = libinput_event_get_pointer_event(event);
1572
1573 isAxisBegin = false;
1574 int32_t ret = processor.HandleAxisInner(data);
1575 EXPECT_EQ(ret, ERROR_NULL_POINTER);
1576 }
1577
1578 /**
1579 * @tc.name: MouseTransformProcessorTest_SetPointerSpeed_00
1580 * @tc.desc: Test the funcation SetPointerSpeed
1581 * @tc.type: FUNC
1582 * @tc.require:
1583 */
1584 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_SetPointerSpeed_001, TestSize.Level1)
1585 {
1586 CALL_TEST_DEBUG;
1587 int32_t deviceId = 1;
1588 MouseTransformProcessor processor(deviceId);
1589 int32_t speed = -1;
1590 ASSERT_EQ(processor.SetPointerSpeed(speed), 0);
1591 speed = 15;
1592 ASSERT_EQ(processor.SetPointerSpeed(speed), 0);
1593 speed = 5;
1594 EXPECT_NO_FATAL_FAILURE(processor.SetPointerSpeed(speed));
1595 }
1596
1597 /**
1598 * @tc.name: MouseTransformProcessorTest_HandleAxisBeginEndInner_002
1599 * @tc.desc: Test the funcation HandleAxisBeginEndInner
1600 * @tc.type: FUNC
1601 * @tc.require:
1602 */
1603 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_HandleAxisBeginEndInner_002, TestSize.Level1)
1604 {
1605 CALL_TEST_DEBUG;
1606 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
1607 ASSERT_TRUE(pointerEvent != nullptr);
1608 int32_t deviceId = 1;
1609 MouseTransformProcessor processor(deviceId);
1610 vMouse_.SendEvent(EV_REL, REL_X, 5);
1611 vMouse_.SendEvent(EV_REL, REL_Y, -10);
1612 vMouse_.SendEvent(EV_SYN, SYN_REPORT, 0);
1613 libinput_event *event = libinput_.Dispatch();
1614 ASSERT_TRUE(event != nullptr);
1615 struct libinput_device *dev = libinput_event_get_device(event);
1616 ASSERT_TRUE(dev != nullptr);
1617 processor.buttonId_ = PointerEvent::BUTTON_NONE;
1618 processor.isAxisBegin_ = false;
1619 processor.isPressed_ = true;
1620 int32_t ret = processor.HandleAxisBeginEndInner(event);
1621 EXPECT_EQ(ret, RET_ERR);
1622 processor.isAxisBegin_ = true;
1623 ret = processor.HandleAxisBeginEndInner(event);
1624 EXPECT_EQ(ret, RET_OK);
1625 processor.isPressed_ = false;
1626 ret = processor.HandleAxisBeginEndInner(event);
1627 EXPECT_EQ(ret, RET_ERR);
1628 }
1629
1630 /**
1631 * @tc.name: MouseTransformProcessorTest_HandleTouchpadRightButton_001
1632 * @tc.desc: Test the funcation HandleTouchpadRightButton
1633 * @tc.type: FUNC
1634 * @tc.require:
1635 */
1636 HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_HandleTouchpadRightButton_001, TestSize.Level1)
1637 {
1638 int32_t deviceId = 1;
1639 MouseTransformProcessor processor(deviceId);
1640 struct libinput_event_pointer* data = nullptr;
1641 int32_t evenType = 10;
1642 uint32_t button = BTN_RIGHT_MENUE_CODE;
1643 ASSERT_NO_FATAL_FAILURE(processor.HandleTouchpadRightButton(data, evenType, button));
1644 button = MouseDeviceState::LIBINPUT_RIGHT_BUTTON_CODE;
1645 evenType = LIBINPUT_EVENT_POINTER_TAP;
1646 processor.HandleTouchpadRightButton(data, evenType, button);
1647 ASSERT_EQ (button, 0);
1648 }
1649 }
1650 }