• 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 <cstdio>
17 #include <gtest/gtest.h>
18 
19 #include "define_multimodal.h"
20 #include "general_touchscreen.h"
21 #include "general_uwb_remote_control.h"
22 #include "input_device_manager.h"
23 #include "i_input_windows_manager.h"
24 #include "libinput-private.h"
25 #include "libinput_wrapper.h"
26 #include "touch_transform_processor.h"
27 
28 namespace OHOS {
29 namespace MMI {
30 namespace {
31 using namespace testing::ext;
32 constexpr int32_t MAX_MOVE_FLAG = 6;
33 } // namespace
34 
35 class TouchTransformProcessorTest : public testing::Test {
36 public:
37     static void SetUpTestCase(void);
38     static void TearDownTestCase(void);
39     void SetUp();
40     void TearDown();
41 
42 private:
43     static void SetupTouchscreen();
44     static void SetupUwbRemoteControl();
45     static void CloseTouchscreen();
46     static void CloseUwbRemoteControl();
47     static GeneralUwbRemoteControl vUwbRemoteControl_;
48     static GeneralTouchscreen vTouchscreen_;
49     static LibinputWrapper libinput_;
50 };
51 
52 GeneralUwbRemoteControl TouchTransformProcessorTest::vUwbRemoteControl_;
53 GeneralTouchscreen TouchTransformProcessorTest::vTouchscreen_;
54 LibinputWrapper TouchTransformProcessorTest::libinput_;
55 
SetUpTestCase(void)56 void TouchTransformProcessorTest::SetUpTestCase(void)
57 {
58     ASSERT_TRUE(libinput_.Init());
59     SetupTouchscreen();
60     SetupUwbRemoteControl();
61 }
62 
TearDownTestCase(void)63 void TouchTransformProcessorTest::TearDownTestCase(void)
64 {
65     CloseTouchscreen();
66     CloseUwbRemoteControl();
67 }
68 
SetupTouchscreen()69 void TouchTransformProcessorTest::SetupTouchscreen()
70 {
71     ASSERT_TRUE(vTouchscreen_.SetUp());
72     std::cout << "device node name: " << vTouchscreen_.GetDevPath() << std::endl;
73     ASSERT_TRUE(libinput_.AddPath(vTouchscreen_.GetDevPath()));
74     libinput_event *event = libinput_.Dispatch();
75     ASSERT_TRUE(event != nullptr);
76     ASSERT_EQ(libinput_event_get_type(event), LIBINPUT_EVENT_DEVICE_ADDED);
77     struct libinput_device *device = libinput_event_get_device(event);
78     ASSERT_TRUE(device != nullptr);
79 }
80 
SetupUwbRemoteControl()81 void TouchTransformProcessorTest::SetupUwbRemoteControl()
82 {
83     ASSERT_TRUE(vUwbRemoteControl_.SetUp());
84     std::cout << "device node name: " << vUwbRemoteControl_.GetDevPath() << std::endl;
85     ASSERT_TRUE(libinput_.AddPath(vUwbRemoteControl_.GetDevPath()));
86     libinput_event *event = libinput_.Dispatch();
87     ASSERT_TRUE(event != nullptr);
88     ASSERT_EQ(libinput_event_get_type(event), LIBINPUT_EVENT_DEVICE_ADDED);
89     struct libinput_device *device = libinput_event_get_device(event);
90     ASSERT_TRUE(device != nullptr);
91 }
92 
CloseTouchscreen()93 void TouchTransformProcessorTest::CloseTouchscreen()
94 {
95     libinput_.RemovePath(vTouchscreen_.GetDevPath());
96     vTouchscreen_.Close();
97 }
98 
CloseUwbRemoteControl()99 void TouchTransformProcessorTest::CloseUwbRemoteControl()
100 {
101     libinput_.RemovePath(vUwbRemoteControl_.GetDevPath());
102     vUwbRemoteControl_.Close();
103 }
104 
SetUp()105 void TouchTransformProcessorTest::SetUp()
106 {
107 }
108 
TearDown()109 void TouchTransformProcessorTest::TearDown()
110 {
111 }
112 
113 /**
114  * @tc.name: TouchTransformProcessorTest_OnEventTouchDown_001
115  * @tc.desc: Test the funcation OnEventTouchDown
116  * @tc.type: FUNC
117  * @tc.require:
118  */
119 HWTEST_F(TouchTransformProcessorTest, OnEventTouchDown_001, TestSize.Level1)
120 {
121     int32_t deviceId = 6;
122     TouchTransformProcessor processor(deviceId);
123     libinput_event* event = nullptr;
124     bool ret = processor.OnEventTouchDown(event);
125     ASSERT_FALSE(ret);
126 }
127 
128 /**
129  * @tc.name: TouchTransformProcessorTest_UpdatePointerItemProperties_001
130  * @tc.desc: Test the funcation UpdatePointerItemProperties
131  * @tc.type: FUNC
132  * @tc.require:
133  */
134 HWTEST_F(TouchTransformProcessorTest, UpdatePointerItemProperties_001, TestSize.Level1)
135 {
136     PointerEvent::PointerItem item;
137     EventTouch touchInfo;
138     touchInfo.point.x = 10;
139     touchInfo.point.y = 20;
140     touchInfo.toolRect.point.x = 30;
141     touchInfo.toolRect.point.y = 40;
142     touchInfo.toolRect.width = 50;
143     touchInfo.toolRect.height = 60;
144     int32_t deviceId = 6;
145     TouchTransformProcessor processor(deviceId);
146     processor.UpdatePointerItemProperties(item, touchInfo);
147     ASSERT_EQ(item.GetDisplayX(), touchInfo.point.x);
148     ASSERT_EQ(item.GetDisplayY(), touchInfo.point.y);
149     ASSERT_EQ(item.GetDisplayXPos(), touchInfo.point.x);
150     ASSERT_EQ(item.GetDisplayYPos(), touchInfo.point.y);
151     ASSERT_EQ(item.GetRawDisplayX(), touchInfo.point.x);
152     ASSERT_EQ(item.GetRawDisplayY(), touchInfo.point.y);
153     ASSERT_EQ(item.GetToolDisplayX(), touchInfo.toolRect.point.x);
154     ASSERT_EQ(item.GetToolDisplayY(), touchInfo.toolRect.point.y);
155     ASSERT_EQ(item.GetToolWidth(), touchInfo.toolRect.width);
156     ASSERT_EQ(item.GetToolHeight(), touchInfo.toolRect.height);
157 }
158 
159 /**
160  * @tc.name: TouchTransformProcessorTest_OnEventTouchMotion_001
161  * @tc.desc: Test the funcation OnEventTouchMotion
162  * @tc.type: FUNC
163  * @tc.require:
164  */
165 HWTEST_F(TouchTransformProcessorTest, OnEventTouchMotion_001, TestSize.Level1)
166 {
167     int32_t deviceId = 6;
168     TouchTransformProcessor processor(deviceId);
169     libinput_event* event = nullptr;
170     bool ret = processor.OnEventTouchMotion(event);
171     ASSERT_FALSE(ret);
172 }
173 
174 /**
175  * @tc.name: TouchTransformProcessorTest_OnEventTouchUp_001
176  * @tc.desc: Test the funcation OnEventTouchUp
177  * @tc.type: FUNC
178  * @tc.require:
179  */
180 HWTEST_F(TouchTransformProcessorTest, OnEventTouchUp_001, TestSize.Level1)
181 {
182     int32_t deviceId = 6;
183     TouchTransformProcessor processor(deviceId);
184     libinput_event* event = nullptr;
185     bool ret = processor.OnEventTouchUp(event);
186     ASSERT_FALSE(ret);
187 }
188 
189 /**
190  * @tc.name: TouchTransformProcessorTest_GetTouchToolType_001
191  * @tc.desc: Test the funcation GetTouchToolType
192  * @tc.type: FUNC
193  * @tc.require:
194  */
195 HWTEST_F(TouchTransformProcessorTest, GetTouchToolType_001, TestSize.Level1)
196 {
197     int32_t deviceId = 6;
198     TouchTransformProcessor processor(deviceId);
199     struct libinput_device *device = nullptr;
200     int32_t toolType = processor.GetTouchToolType(device);
201     ASSERT_EQ(toolType, PointerEvent::TOOL_TYPE_FINGER);
202 }
203 
204 /**
205  * @tc.name: TouchTransformProcessorTest_InitToolTypes_001
206  * @tc.desc: Test the funcation InitToolTypes
207  * @tc.type: FUNC
208  * @tc.require:
209  */
210 HWTEST_F(TouchTransformProcessorTest, InitToolTypes_001, TestSize.Level1)
211 {
212     int32_t deviceId = 6;
213     TouchTransformProcessor processor(deviceId);
214     processor.InitToolTypes();
215     ASSERT_EQ(processor.vecToolType_.size(), 16);
216     ASSERT_EQ(processor.vecToolType_[0].first, BTN_TOOL_PEN);
217     ASSERT_EQ(processor.vecToolType_[0].second, PointerEvent::TOOL_TYPE_PEN);
218     ASSERT_EQ(processor.vecToolType_[1].first, BTN_TOOL_RUBBER);
219     ASSERT_EQ(processor.vecToolType_[1].second, PointerEvent::TOOL_TYPE_RUBBER);
220     ASSERT_EQ(processor.vecToolType_[2].first, BTN_TOOL_BRUSH);
221     ASSERT_EQ(processor.vecToolType_[2].second, PointerEvent::TOOL_TYPE_BRUSH);
222     ASSERT_EQ(processor.vecToolType_[3].first, BTN_TOOL_PENCIL);
223     ASSERT_EQ(processor.vecToolType_[3].second, PointerEvent::TOOL_TYPE_PENCIL);
224     ASSERT_EQ(processor.vecToolType_[4].first, BTN_TOOL_AIRBRUSH);
225     ASSERT_EQ(processor.vecToolType_[4].second, PointerEvent::TOOL_TYPE_AIRBRUSH);
226     ASSERT_EQ(processor.vecToolType_[5].first, BTN_TOOL_FINGER);
227     ASSERT_EQ(processor.vecToolType_[5].second, PointerEvent::TOOL_TYPE_FINGER);
228     ASSERT_EQ(processor.vecToolType_[6].first, BTN_TOOL_MOUSE);
229     ASSERT_EQ(processor.vecToolType_[6].second, PointerEvent::TOOL_TYPE_MOUSE);
230     ASSERT_EQ(processor.vecToolType_[7].first, BTN_TOOL_LENS);
231     ASSERT_EQ(processor.vecToolType_[7].second, PointerEvent::TOOL_TYPE_LENS);
232 }
233 
234 /**
235  * @tc.name: TouchTransformProcessorTest_OnEventTouchDown_002
236  * @tc.desc: Test the funcation OnEventTouchDown
237  * @tc.type: FUNC
238  * @tc.require:
239  */
240 HWTEST_F(TouchTransformProcessorTest, OnEventTouchDown_002, TestSize.Level1)
241 {
242     CALL_TEST_DEBUG;
243     int32_t deviceId = 6;
244     TouchTransformProcessor processor(deviceId);
245     libinput_event* event = nullptr;
246     bool ret = processor.OnEventTouchDown(event);
247     ASSERT_FALSE(ret);
248     processor.pointerEvent_ = PointerEvent::Create();
249     ASSERT_TRUE(processor.pointerEvent_ != nullptr);
250     vTouchscreen_.SendEvent(EV_ABS, ABS_MT_TRACKING_ID, 0);
251     vTouchscreen_.SendEvent(EV_ABS, ABS_MT_POSITION_X, 5190);
252     vTouchscreen_.SendEvent(EV_ABS, ABS_MT_POSITION_Y, 8306);
253     vTouchscreen_.SendEvent(EV_ABS, ABS_MT_PRESSURE, 321);
254     vTouchscreen_.SendEvent(EV_ABS, ABS_MT_TOUCH_MAJOR, 198);
255     vTouchscreen_.SendEvent(EV_ABS, ABS_MT_TOUCH_MINOR, 180);
256     vTouchscreen_.SendEvent(EV_ABS, ABS_MT_ORIENTATION, -64);
257     vTouchscreen_.SendEvent(EV_ABS, ABS_MT_BLOB_ID, 2);
258     vTouchscreen_.SendEvent(EV_SYN, SYN_MT_REPORT, 0);
259     vTouchscreen_.SendEvent(EV_KEY, BTN_TOUCH, 1);
260     vTouchscreen_.SendEvent(EV_SYN, SYN_REPORT, 0);
261     event = libinput_.Dispatch();
262     ASSERT_TRUE(event != nullptr);
263     auto touch = libinput_event_get_touch_event(event);
264     ASSERT_TRUE(touch != nullptr);
265     auto device = libinput_event_get_device(event);
266     ASSERT_TRUE(device != nullptr);
267     ret = processor.OnEventTouchDown(event);
268     ASSERT_FALSE(ret);
269 }
270 
271 /**
272  * @tc.name: TouchTransformProcessorTest_NotifyFingersenseProcess_001
273  * @tc.desc: Test the funcation NotifyFingersenseProcess
274  * @tc.type: FUNC
275  * @tc.require:
276  */
277 HWTEST_F(TouchTransformProcessorTest, NotifyFingersenseProcess_001, TestSize.Level1)
278 {
279     CALL_TEST_DEBUG;
280     int32_t deviceId = 6;
281     TouchTransformProcessor processor(deviceId);
282     PointerEvent::PointerItem item;
283     int32_t toolType = 0;
284     EXPECT_NO_FATAL_FAILURE(processor.NotifyFingersenseProcess(item, toolType));
285 }
286 
287 /**
288  * @tc.name: TouchTransformProcessorTest_OnEventTouchMotion_002
289  * @tc.desc: Test the funcation OnEventTouchMotion
290  * @tc.type: FUNC
291  * @tc.require:
292  */
293 HWTEST_F(TouchTransformProcessorTest, OnEventTouchMotion_002, TestSize.Level1)
294 {
295     CALL_TEST_DEBUG;
296     int32_t deviceId = 6;
297     TouchTransformProcessor processor(deviceId);
298     libinput_event* event = nullptr;
299     bool ret = processor.OnEventTouchMotion(event);
300     ASSERT_FALSE(ret);
301     processor.pointerEvent_ = PointerEvent::Create();
302     ASSERT_TRUE(processor.pointerEvent_ != nullptr);
303     vTouchscreen_.SendEvent(EV_ABS, ABS_MT_POSITION_X, 5199);
304     vTouchscreen_.SendEvent(EV_ABS, ABS_MT_POSITION_Y, 8297);
305     vTouchscreen_.SendEvent(EV_ABS, ABS_MT_PRESSURE, 356);
306     vTouchscreen_.SendEvent(EV_ABS, ABS_MT_TRACKING_ID, 0);
307     vTouchscreen_.SendEvent(EV_ABS, ABS_MT_TOUCH_MAJOR, 216);
308     vTouchscreen_.SendEvent(EV_ABS, ABS_MT_TOUCH_MINOR, 162);
309     vTouchscreen_.SendEvent(EV_ABS, ABS_MT_ORIENTATION, -79);
310     vTouchscreen_.SendEvent(EV_ABS, ABS_MT_BLOB_ID, 2);
311     vTouchscreen_.SendEvent(EV_SYN, SYN_MT_REPORT, 0);
312     vTouchscreen_.SendEvent(EV_SYN, SYN_REPORT, 0);
313     event = libinput_.Dispatch();
314     ASSERT_TRUE(event != nullptr);
315     auto touch = libinput_event_get_touch_event(event);
316     ASSERT_TRUE(touch != nullptr);
317     EXPECT_NO_FATAL_FAILURE(processor.OnEventTouchMotion(event));
318 }
319 
320 /**
321  * @tc.name: TouchTransformProcessorTest_OnEventTouchUp_002
322  * @tc.desc: Test the funcation OnEventTouchUp
323  * @tc.type: FUNC
324  * @tc.require:
325  */
326 HWTEST_F(TouchTransformProcessorTest, OnEventTouchUp_002, TestSize.Level1)
327 {
328     CALL_TEST_DEBUG;
329     int32_t deviceId = 6;
330     TouchTransformProcessor processor(deviceId);
331     libinput_event* event = nullptr;
332     bool ret = processor.OnEventTouchUp(event);
333     ASSERT_FALSE(ret);
334     processor.pointerEvent_ = PointerEvent::Create();
335     ASSERT_TRUE(processor.pointerEvent_ != nullptr);
336     vTouchscreen_.SendEvent(EV_ABS, ABS_MT_POSITION_X, 6486);
337     vTouchscreen_.SendEvent(EV_ABS, ABS_MT_POSITION_Y, 7289);
338     vTouchscreen_.SendEvent(EV_ABS, ABS_MT_PRESSURE, 313);
339     vTouchscreen_.SendEvent(EV_ABS, ABS_MT_TRACKING_ID, 0);
340     vTouchscreen_.SendEvent(EV_ABS, ABS_MT_TOUCH_MAJOR, 198);
341     vTouchscreen_.SendEvent(EV_ABS, ABS_MT_TOUCH_MINOR, 180);
342     vTouchscreen_.SendEvent(EV_ABS, ABS_MT_ORIENTATION, -58);
343     vTouchscreen_.SendEvent(EV_ABS, ABS_MT_BLOB_ID, 2);
344     vTouchscreen_.SendEvent(EV_SYN, SYN_MT_REPORT, 0);
345     vTouchscreen_.SendEvent(EV_KEY, BTN_TOUCH, 0);
346     vTouchscreen_.SendEvent(EV_SYN, SYN_REPORT, 0);
347     event = libinput_.Dispatch();
348     ASSERT_TRUE(event != nullptr);
349     auto touch = libinput_event_get_touch_event(event);
350     ASSERT_TRUE(touch != nullptr);
351     EXPECT_NO_FATAL_FAILURE(processor.OnEventTouchUp(event));
352 }
353 
354 /**
355  * @tc.name: TouchTransformProcessorTest_OnEvent_001
356  * @tc.desc: Test OnEvent
357  * @tc.type: FUNC
358  * @tc.require:
359  */
360 HWTEST_F(TouchTransformProcessorTest, TouchTransformProcessorTest_OnEvent_001, TestSize.Level1)
361 {
362     CALL_TEST_DEBUG;
363     int32_t deviceId = 6;
364     vTouchscreen_.SendEvent(EV_ABS, ABS_MT_TRACKING_ID, 0);
365     vTouchscreen_.SendEvent(EV_ABS, ABS_MT_POSITION_X, 5190);
366     vTouchscreen_.SendEvent(EV_ABS, ABS_MT_POSITION_Y, 8306);
367     vTouchscreen_.SendEvent(EV_ABS, ABS_MT_PRESSURE, 321);
368     vTouchscreen_.SendEvent(EV_ABS, ABS_MT_TOUCH_MAJOR, 198);
369     vTouchscreen_.SendEvent(EV_ABS, ABS_MT_TOUCH_MINOR, 180);
370     vTouchscreen_.SendEvent(EV_ABS, ABS_MT_ORIENTATION, -64);
371     vTouchscreen_.SendEvent(EV_ABS, ABS_MT_BLOB_ID, 2);
372     vTouchscreen_.SendEvent(EV_SYN, SYN_MT_REPORT, 0);
373     vTouchscreen_.SendEvent(EV_KEY, BTN_TOUCH, 1);
374     vTouchscreen_.SendEvent(EV_SYN, SYN_REPORT, 0);
375     libinput_event *event = libinput_.Dispatch();
376     ASSERT_TRUE(event != nullptr);
377     struct libinput_device *dev = libinput_event_get_device(event);
378     ASSERT_TRUE(dev != nullptr);
379     std::cout << "pointer device: " << libinput_device_get_name(dev) << std::endl;
380     TouchTransformProcessor processor(deviceId);
381     processor.pointerEvent_ = nullptr;
382     auto ret = processor.OnEvent(event);
383     ASSERT_FALSE(ret);
384     processor.pointerEvent_ = PointerEvent::Create();
385     ASSERT_TRUE(processor.pointerEvent_ != nullptr);
386     EXPECT_NO_FATAL_FAILURE(processor.OnEvent(event));
387 }
388 
389 /**
390  * @tc.name: TouchTransformProcessorTest_OnEvent_002
391  * @tc.desc: Test OnEvent
392  * @tc.type: FUNC
393  * @tc.require:
394  */
395 HWTEST_F(TouchTransformProcessorTest, TouchTransformProcessorTest_OnEvent_002, TestSize.Level1)
396 {
397     CALL_TEST_DEBUG;
398     int32_t deviceId = 6;
399     TouchTransformProcessor processor(deviceId);
400     processor.pointerEvent_ = PointerEvent::Create();
401     ASSERT_TRUE(processor.pointerEvent_ != nullptr);
402     vTouchscreen_.SendEvent(EV_ABS, ABS_MT_POSITION_X, 5199);
403     vTouchscreen_.SendEvent(EV_ABS, ABS_MT_POSITION_Y, 8297);
404     vTouchscreen_.SendEvent(EV_ABS, ABS_MT_PRESSURE, 356);
405     vTouchscreen_.SendEvent(EV_ABS, ABS_MT_TRACKING_ID, 0);
406     vTouchscreen_.SendEvent(EV_ABS, ABS_MT_TOUCH_MAJOR, 216);
407     vTouchscreen_.SendEvent(EV_ABS, ABS_MT_TOUCH_MINOR, 162);
408     vTouchscreen_.SendEvent(EV_ABS, ABS_MT_ORIENTATION, -79);
409     vTouchscreen_.SendEvent(EV_ABS, ABS_MT_BLOB_ID, 2);
410     vTouchscreen_.SendEvent(EV_SYN, SYN_MT_REPORT, 0);
411     vTouchscreen_.SendEvent(EV_SYN, SYN_REPORT, 0);
412     libinput_event *event = libinput_.Dispatch();
413     ASSERT_TRUE(event != nullptr);
414     struct libinput_device *dev = libinput_event_get_device(event);
415     ASSERT_TRUE(dev != nullptr);
416     std::cout << "pointer device: " << libinput_device_get_name(dev) << std::endl;
417     EXPECT_NO_FATAL_FAILURE(processor.OnEvent(event));
418 }
419 
420 /**
421  * @tc.name: TouchTransformProcessorTest_OnEvent_003
422  * @tc.desc: Test OnEvent
423  * @tc.type: FUNC
424  * @tc.require:
425  */
426 HWTEST_F(TouchTransformProcessorTest, TouchTransformProcessorTest_OnEvent_003, TestSize.Level1)
427 {
428     CALL_TEST_DEBUG;
429     int32_t deviceId = 6;
430     TouchTransformProcessor processor(deviceId);
431     processor.pointerEvent_ = PointerEvent::Create();
432     ASSERT_TRUE(processor.pointerEvent_ != nullptr);
433     vTouchscreen_.SendEvent(EV_ABS, ABS_MT_POSITION_X, 6486);
434     vTouchscreen_.SendEvent(EV_ABS, ABS_MT_POSITION_Y, 7289);
435     vTouchscreen_.SendEvent(EV_ABS, ABS_MT_PRESSURE, 313);
436     vTouchscreen_.SendEvent(EV_ABS, ABS_MT_TRACKING_ID, 0);
437     vTouchscreen_.SendEvent(EV_ABS, ABS_MT_TOUCH_MAJOR, 198);
438     vTouchscreen_.SendEvent(EV_ABS, ABS_MT_TOUCH_MINOR, 180);
439     vTouchscreen_.SendEvent(EV_ABS, ABS_MT_ORIENTATION, -58);
440     vTouchscreen_.SendEvent(EV_ABS, ABS_MT_BLOB_ID, 2);
441     vTouchscreen_.SendEvent(EV_SYN, SYN_MT_REPORT, 0);
442     vTouchscreen_.SendEvent(EV_KEY, BTN_TOUCH, 0);
443     vTouchscreen_.SendEvent(EV_SYN, SYN_REPORT, 0);
444     libinput_event *event = libinput_.Dispatch();
445     ASSERT_TRUE(event != nullptr);
446     struct libinput_device *dev = libinput_event_get_device(event);
447     ASSERT_TRUE(dev != nullptr);
448     std::cout << "pointer device: " << libinput_device_get_name(dev) << std::endl;
449     EXPECT_NO_FATAL_FAILURE(processor.OnEvent(event));
450 }
451 
452 /**
453  * @tc.name: TouchTransformProcessorTest_TouchTransformProcessorTest_MoveFlag_001
454  * @tc.desc: Test the field MoveFlag
455  * @tc.type: FUNC
456  * @tc.require:
457  */
458 HWTEST_F(TouchTransformProcessorTest, TouchTransformProcessorTest_MoveFlag_001, TestSize.Level1)
459 {
460     CALL_TEST_DEBUG;
461     libinput_.DrainEvents();
462     int32_t varMoveFlag = 0;
463     for (varMoveFlag = 1; varMoveFlag <= MAX_MOVE_FLAG; varMoveFlag++) {
464         vUwbRemoteControl_.SendEvent(EV_ABS, ABS_MT_TRACKING_ID, 0);
465         vUwbRemoteControl_.SendEvent(EV_ABS, ABS_MT_POSITION_X, 5190 + varMoveFlag*30);
466         vUwbRemoteControl_.SendEvent(EV_ABS, ABS_MT_POSITION_Y, 8306);
467         vUwbRemoteControl_.SendEvent(EV_ABS, ABS_MT_PRESSURE, 321);
468         vUwbRemoteControl_.SendEvent(EV_ABS, ABS_MT_TOUCH_MAJOR, 198);
469         vUwbRemoteControl_.SendEvent(EV_ABS, ABS_MT_TOUCH_MINOR, 180);
470         vUwbRemoteControl_.SendEvent(EV_ABS, ABS_MT_ORIENTATION, -64);
471         vUwbRemoteControl_.SendEvent(EV_ABS, ABS_MT_BLOB_ID, 2);
472         vUwbRemoteControl_.SendEvent(EV_SYN, SYN_MT_REPORT, 0);
473         if (varMoveFlag != MAX_MOVE_FLAG) {
474             vUwbRemoteControl_.SendEvent(EV_KEY, BTN_TOUCH, 1);
475         } else {
476             vUwbRemoteControl_.SendEvent(EV_KEY, BTN_TOUCH, 0);
477         }
478         vUwbRemoteControl_.SendEvent(EV_SYN, SYN_REPORT, 0);
479     }
480     libinput_event *event = libinput_.Dispatch();
481     while (event != nullptr) {
482         auto type = libinput_event_get_type(event);
483         if (type == LIBINPUT_EVENT_TOUCH_CANCEL || type == LIBINPUT_EVENT_TOUCH_FRAME) {
484             event = libinput_.Dispatch();
485             continue;
486         }
487         auto touch = libinput_event_get_touch_event(event);
488         ASSERT_TRUE(touch != nullptr);
489         int32_t moveFlag = libinput_event_touch_get_move_flag(touch);
490         ASSERT_EQ(moveFlag, -1);
491         event = libinput_.Dispatch();
492     }
493 }
494 
495 /**
496  * @tc.name: TouchTransformProcessorTest_TouchTransformProcessorTest_MoveFlag_002
497  * @tc.desc: Test the field MoveFlag
498  * @tc.type: FUNC
499  * @tc.require:
500  */
501 HWTEST_F(TouchTransformProcessorTest, TouchTransformProcessorTest_MoveFlag_002, TestSize.Level1)
502 {
503     CALL_TEST_DEBUG;
504     libinput_.DrainEvents();
505     int32_t varMoveFlag = 0;
506     for (varMoveFlag = 1; varMoveFlag <= MAX_MOVE_FLAG; varMoveFlag++) {
507         vUwbRemoteControl_.SendEvent(EV_ABS, ABS_MT_TRACKING_ID, 0);
508         vUwbRemoteControl_.SendEvent(EV_ABS, ABS_MT_POSITION_X, 5190 + varMoveFlag*30);
509         vUwbRemoteControl_.SendEvent(EV_ABS, ABS_MT_POSITION_Y, 8306);
510         vUwbRemoteControl_.SendEvent(EV_ABS, ABS_MT_PRESSURE, 321);
511         vUwbRemoteControl_.SendEvent(EV_ABS, ABS_MT_MOVEFLAG, varMoveFlag);
512         vUwbRemoteControl_.SendEvent(EV_ABS, ABS_MT_TOUCH_MAJOR, 198);
513         vUwbRemoteControl_.SendEvent(EV_ABS, ABS_MT_TOUCH_MINOR, 180);
514         vUwbRemoteControl_.SendEvent(EV_ABS, ABS_MT_ORIENTATION, -64);
515         vUwbRemoteControl_.SendEvent(EV_ABS, ABS_MT_BLOB_ID, 2);
516         vUwbRemoteControl_.SendEvent(EV_SYN, SYN_MT_REPORT, 0);
517         if (varMoveFlag != MAX_MOVE_FLAG) {
518             vUwbRemoteControl_.SendEvent(EV_KEY, BTN_TOUCH, 1);
519         } else {
520             vUwbRemoteControl_.SendEvent(EV_KEY, BTN_TOUCH, 0);
521         }
522         vUwbRemoteControl_.SendEvent(EV_SYN, SYN_REPORT, 0);
523     }
524     libinput_event *event = libinput_.Dispatch();
525     varMoveFlag = 1;
526     while (event != nullptr) {
527         auto type = libinput_event_get_type(event);
528         if (type == LIBINPUT_EVENT_TOUCH_CANCEL || type == LIBINPUT_EVENT_TOUCH_FRAME) {
529             event = libinput_.Dispatch();
530             continue;
531         }
532         auto touch = libinput_event_get_touch_event(event);
533         ASSERT_TRUE(touch != nullptr);
534         int32_t moveFlag = libinput_event_touch_get_move_flag(touch);
535         ASSERT_EQ(moveFlag, varMoveFlag);
536         varMoveFlag++;
537         event = libinput_.Dispatch();
538     }
539 }
540 } // namespace MMI
541 } // namespace OHOS