• 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 #include "test/mock/base/mock_system_properties.h"
16 #include "test/unittest/core/gestures/gestures_common_test_ng.h"
17 #include "core/components_ng/event/event_constants.h"
18 
19 using namespace testing;
20 using namespace testing::ext;
21 
22 namespace OHOS::Ace::NG {
23 constexpr float GESTURE_EVENT_PROPERTY_DEFAULT_VALUE = 0.0;
24 constexpr float GESTURE_EVENT_PROPERTY_VALUE = 10.0;
25 class PanRecognizerTestNg : public GesturesCommonTestNg {
26 public:
27     static void SetUpTestSuite();
28     static void TearDownTestSuite();
29 };
30 
SetUpTestSuite()31 void PanRecognizerTestNg::SetUpTestSuite()
32 {
33     MockPipelineContext::SetUp();
34 }
35 
TearDownTestSuite()36 void PanRecognizerTestNg::TearDownTestSuite()
37 {
38     MockPipelineContext::TearDown();
39 }
40 
41 /**
42  * @tc.name: PanRecognizerTest001
43  * @tc.desc: Test PanRecognizer function: OnAccepted OnRejected
44  * @tc.type: FUNC
45  */
46 HWTEST_F(PanRecognizerTestNg, PanRecognizerTest001, TestSize.Level1)
47 {
48     /**
49      * @tc.steps: step1. create PanRecognizer.
50      */
51     RefPtr<PanGestureOption> panGestureOption = AceType::MakeRefPtr<PanGestureOption>();
52     RefPtr<PanRecognizer> panRecognizer = AceType::MakeRefPtr<PanRecognizer>(panGestureOption);
53 
54     /**
55      * @tc.steps: step2. call OnAccepted function and compare result.
56      * @tc.expected: step2. result equals.
57      */
58     panRecognizer->OnAccepted();
59     EXPECT_EQ(panRecognizer->refereeState_, RefereeState::SUCCEED);
60 
61     /**
62      * @tc.steps: step3. call OnRejected function and compare result.
63      * @tc.expected: step3. result equals.
64      */
65     panRecognizer->OnRejected();
66     EXPECT_EQ(panRecognizer->refereeState_, RefereeState::SUCCEED);
67 }
68 
69 /**
70  * @tc.name: PanRecognizerPanRecognizerTest001
71  * @tc.desc: Test PanRecognizer function PanRecognizer
72  * @tc.type: FUNC
73  */
74 HWTEST_F(PanRecognizerTestNg, PanRecognizerPanRecognizerTest001, TestSize.Level1)
75 {
76     PanDirection panDirection;
77     panDirection.type = PanDirection::VERTICAL;
78     RefPtr<PanRecognizer> panRecognizer =
79         AceType::MakeRefPtr<PanRecognizer>(FINGER_NUMBER_OVER_MAX, panDirection, 0.0);
80     EXPECT_NE(panRecognizer->refereeState_, RefereeState::FAIL);
81     panDirection.type = PanDirection::NONE;
82     RefPtr<PanRecognizer> panRecognizer1 =
83         AceType::MakeRefPtr<PanRecognizer>(FINGER_NUMBER_OVER_MAX, panDirection, 0.0);
84     EXPECT_NE(panRecognizer1->refereeState_, RefereeState::FAIL);
85     panDirection.type = PanDirection::LEFT;
86     RefPtr<PanRecognizer> panRecognizer2 = AceType::MakeRefPtr<PanRecognizer>(FINGER_NUMBER, panDirection, 0.0);
87     EXPECT_NE(panRecognizer2->refereeState_, RefereeState::FAIL);
88     panDirection.type = PanDirection::RIGHT;
89     RefPtr<PanRecognizer> panRecognizer3 = AceType::MakeRefPtr<PanRecognizer>(FINGER_NUMBER, panDirection, 0.0);
90     EXPECT_NE(panRecognizer3->refereeState_, RefereeState::FAIL);
91     panDirection.type = PanDirection::HORIZONTAL;
92     RefPtr<PanRecognizer> panRecognizer4 = AceType::MakeRefPtr<PanRecognizer>(FINGER_NUMBER, panDirection, 0.0);
93     EXPECT_NE(panRecognizer4->refereeState_, RefereeState::FAIL);
94     panDirection.type = PanDirection::UP;
95     RefPtr<PanRecognizer> panRecognizer5 = AceType::MakeRefPtr<PanRecognizer>(0, panDirection, 0.0);
96     EXPECT_NE(panRecognizer5->refereeState_, RefereeState::FAIL);
97     panDirection.type = PanDirection::DOWN;
98     RefPtr<PanRecognizer> panRecognizer6 = AceType::MakeRefPtr<PanRecognizer>(0, panDirection, 0.0);
99     EXPECT_NE(panRecognizer6->refereeState_, RefereeState::FAIL);
100     panDirection.type = PanDirection::VERTICAL;
101     RefPtr<PanRecognizer> panRecognizer7 = AceType::MakeRefPtr<PanRecognizer>(0, panDirection, 0.0);
102     EXPECT_NE(panRecognizer7->refereeState_, RefereeState::FAIL);
103     panDirection.type = PanDirection::ALL;
104     RefPtr<PanRecognizer> panRecognizer8 = AceType::MakeRefPtr<PanRecognizer>(0, panDirection, 0.0);
105     EXPECT_NE(panRecognizer8->refereeState_, RefereeState::FAIL);
106 }
107 
108 /**
109  * @tc.name: PanRecognizerPanRecognizerTest002
110  * @tc.desc: Test PanRecognizer function PanRecognizer
111  * @tc.type: FUNC
112  */
113 HWTEST_F(PanRecognizerTestNg, PanRecognizerPanRecognizerTest002, TestSize.Level1)
114 {
115     /**
116      * @tc.steps: step1. create PanRecognizer.
117      */
118     RefPtr<PanGestureOption> panGestureOption = AceType::MakeRefPtr<PanGestureOption>();
119     PanDirection panDirection;
120     panGestureOption->fingers_ = FINGER_NUMBER_OVER_MAX;
121     panDirection.type = PanDirection::VERTICAL;
122     panGestureOption->SetDirection(panDirection);
123     RefPtr<PanRecognizer> panRecognizer = AceType::MakeRefPtr<PanRecognizer>(panGestureOption);
124     EXPECT_NE(panRecognizer->refereeState_, RefereeState::SUCCEED);
125     panGestureOption->fingers_ = FINGER_NUMBER;
126     panDirection.type = PanDirection::NONE;
127     panGestureOption->SetDirection(panDirection);
128     RefPtr<PanRecognizer> panRecognizer1 = AceType::MakeRefPtr<PanRecognizer>(panGestureOption);
129     EXPECT_NE(panRecognizer1->refereeState_, RefereeState::SUCCEED);
130     panGestureOption->fingers_ = FINGER_NUMBER_OVER_MAX;
131     panDirection.type = PanDirection::LEFT;
132     panGestureOption->SetDirection(panDirection);
133     RefPtr<PanRecognizer> panRecognizer2 = AceType::MakeRefPtr<PanRecognizer>(panGestureOption);
134     EXPECT_NE(panRecognizer2->refereeState_, RefereeState::SUCCEED);
135     panGestureOption->fingers_ = FINGER_NUMBER;
136     panDirection.type = PanDirection::RIGHT;
137     panGestureOption->SetDirection(panDirection);
138     RefPtr<PanRecognizer> panRecognizer3 = AceType::MakeRefPtr<PanRecognizer>(panGestureOption);
139     EXPECT_NE(panRecognizer3->refereeState_, RefereeState::SUCCEED);
140     panGestureOption->fingers_ = FINGER_NUMBER_OVER_MAX;
141     panDirection.type = PanDirection::HORIZONTAL;
142     panGestureOption->SetDirection(panDirection);
143     RefPtr<PanRecognizer> panRecognizer4 = AceType::MakeRefPtr<PanRecognizer>(panGestureOption);
144     EXPECT_NE(panRecognizer4->refereeState_, RefereeState::SUCCEED);
145     panGestureOption->fingers_ = 0;
146     panDirection.type = PanDirection::UP;
147     panGestureOption->SetDirection(panDirection);
148     RefPtr<PanRecognizer> panRecognizer5 = AceType::MakeRefPtr<PanRecognizer>(panGestureOption);
149     EXPECT_NE(panRecognizer5->refereeState_, RefereeState::SUCCEED);
150     panGestureOption->fingers_ = 0;
151     panDirection.type = PanDirection::DOWN;
152     panGestureOption->SetDirection(panDirection);
153     RefPtr<PanRecognizer> panRecognizer6 = AceType::MakeRefPtr<PanRecognizer>(panGestureOption);
154     EXPECT_NE(panRecognizer6->refereeState_, RefereeState::SUCCEED);
155     panGestureOption->fingers_ = 0;
156     panDirection.type = PanDirection::DOWN;
157     panGestureOption->SetDirection(panDirection);
158     RefPtr<PanRecognizer> panRecognizer7 = AceType::MakeRefPtr<PanRecognizer>(panGestureOption);
159     EXPECT_NE(panRecognizer7->refereeState_, RefereeState::SUCCEED);
160     panGestureOption->fingers_ = 0;
161     panDirection.type = PanDirection::ALL;
162     panGestureOption->SetDirection(panDirection);
163     RefPtr<PanRecognizer> panRecognizer8 = AceType::MakeRefPtr<PanRecognizer>(panGestureOption);
164     EXPECT_NE(panRecognizer8->refereeState_, RefereeState::SUCCEED);
165 }
166 
167 /**
168  * @tc.name: PanRecognizerTest002
169  * @tc.desc: Test PanRecognizer function: HandleTouchDownEvent
170  * @tc.type: FUNC
171  */
172 HWTEST_F(PanRecognizerTestNg, PanRecognizerTest002, TestSize.Level1)
173 {
174     /**
175      * @tc.steps: step1. create PanRecognizer.
176      */
177     RefPtr<PanGestureOption> panGestureOption = AceType::MakeRefPtr<PanGestureOption>();
178     RefPtr<PanRecognizer> panRecognizer = AceType::MakeRefPtr<PanRecognizer>(panGestureOption);
179 
180     /**
181      * @tc.steps: step2. call HandleTouchDown function and compare result.
182      * @tc.steps: case1: call TouchEvent, refereeState is SUCCEED, return
183      * @tc.expected: step2. result equals.
184      */
185     TouchEvent touchEvent;
186     panRecognizer->refereeState_ = RefereeState::SUCCEED;
187     panRecognizer->HandleTouchDownEvent(touchEvent);
188     EXPECT_EQ(panRecognizer->touchPoints_.size(), 1);
189 
190     /**
191      * @tc.steps: step2. call HandleTouchDown function and compare result.
192      * @tc.steps: case2: call TouchEvent, normal case
193      * @tc.expected: step2. result equals.
194      */
195     panRecognizer->refereeState_ = RefereeState::PENDING;
196     panRecognizer->HandleTouchDownEvent(touchEvent);
197     EXPECT_EQ(panRecognizer->deviceId_, touchEvent.deviceId);
198     EXPECT_EQ(panRecognizer->deviceType_, touchEvent.sourceType);
199 
200     /**
201      * @tc.steps: step2. call HandleTouchDown function and compare result.
202      * @tc.steps: case3: call TouchEvent, set fingerNum != fingers_
203      * @tc.expected: step2. result equals.
204      */
205     panRecognizer->fingers_ = FINGER_NUMBER;
206     panRecognizer->HandleTouchDownEvent(touchEvent);
207     EXPECT_EQ(panRecognizer->refereeState_, RefereeState::PENDING);
208 
209     /**
210      * @tc.steps: step2. call HandleTouchDown function and compare result.
211      * @tc.steps: case4: call TouchEvent, set fingerNum = fingers_
212      * @tc.expected: step2. result equals.
213      */
214     panRecognizer->fingers_ = 1;
215     panRecognizer->HandleTouchDownEvent(touchEvent);
216     EXPECT_EQ(panRecognizer->refereeState_, RefereeState::PENDING);
217 
218     /**
219      * @tc.steps: step2. call HandleTouchDown function and compare result.
220      * @tc.steps: case4: call AxisEvent, refereeState is SUCCEED, return
221      * @tc.expected: step2. result equals.
222      */
223     AxisEvent axisEvent;
224     panRecognizer->refereeState_ = RefereeState::SUCCEED;
225     panRecognizer->touchPoints_.clear();
226     panRecognizer->HandleTouchDownEvent(axisEvent);
227     EXPECT_EQ(panRecognizer->touchPoints_.size(), 1);
228 
229     /**
230      * @tc.steps: step2. call HandleTouchDown function and compare result.
231      * @tc.steps: case5: call AxisEvent, refereeState is PENDING, normal case
232      * @tc.expected: step2. result equals.
233      */
234     panRecognizer->refereeState_ = RefereeState::PENDING;
235     panRecognizer->HandleTouchDownEvent(axisEvent);
236     EXPECT_EQ(panRecognizer->deviceId_, axisEvent.deviceId);
237     EXPECT_EQ(panRecognizer->deviceType_, axisEvent.sourceType);
238     EXPECT_EQ(panRecognizer->refereeState_, RefereeState::DETECTING);
239 }
240 
241 /**
242  * @tc.name: PanRecognizerHandleTouchDownEventTest001
243  * @tc.desc: Test PanRecognizer function: HandleTouchDownEvent
244  * @tc.type: FUNC
245  */
246 HWTEST_F(PanRecognizerTestNg, PanRecognizerHandleTouchDownEventTest001, TestSize.Level1)
247 {
248     /**
249      * @tc.steps: step1. create PanRecognizer.
250      */
251     RefPtr<PanGestureOption> panGestureOption = AceType::MakeRefPtr<PanGestureOption>();
252     RefPtr<PanRecognizer> panRecognizer = AceType::MakeRefPtr<PanRecognizer>(panGestureOption);
253 
254     /**
255      * @tc.steps: step2. call HandleTouchDown function and compare result.
256      * @tc.steps: case1: call TouchEvent, refereeState is SUCCEED, return
257      * @tc.expected: step2. result equals.
258      */
259     TouchEvent touchEvent;
260     touchEvent.sourceType = SourceType::MOUSE;
261     panRecognizer->fingers_ = 1;
262     panRecognizer->refereeState_ = RefereeState::SUCCEED;
263     panRecognizer->HandleTouchDownEvent(touchEvent);
264     EXPECT_EQ(panRecognizer->touchPoints_.size(), 1);
265 
266     /**
267      * @tc.steps: step2. call HandleTouchDown function and compare result.
268      * @tc.steps: case2: call TouchEvent, normal case
269      * @tc.expected: step2. result equals.
270      */
271     panRecognizer->refereeState_ = RefereeState::PENDING;
272     panRecognizer->HandleTouchDownEvent(touchEvent);
273     EXPECT_EQ(panRecognizer->deviceId_, touchEvent.deviceId);
274     EXPECT_EQ(panRecognizer->deviceType_, touchEvent.sourceType);
275 
276     /**
277      * @tc.steps: step2. call HandleTouchDown function and compare result.
278      * @tc.steps: case3: call TouchEvent, set fingerNum != fingers_
279      * @tc.expected: step2. result equals.
280      */
281     panRecognizer->fingers_ = FINGER_NUMBER;
282     panRecognizer->HandleTouchDownEvent(touchEvent);
283     EXPECT_EQ(panRecognizer->refereeState_, RefereeState::PENDING);
284 
285     /**
286      * @tc.steps: step2. call HandleTouchDown function and compare result.
287      * @tc.steps: case4: call TouchEvent, set fingerNum = fingers_
288      * @tc.expected: step2. result equals.
289      */
290     panRecognizer->fingers_ = 1;
291     panRecognizer->HandleTouchDownEvent(touchEvent);
292     EXPECT_EQ(panRecognizer->refereeState_, RefereeState::PENDING);
293 
294     /**
295      * @tc.steps: step2. call HandleTouchDown function and compare result.
296      * @tc.steps: case4: call AxisEvent, refereeState is SUCCEED, return
297      * @tc.expected: step2. result equals.
298      */
299     AxisEvent axisEvent;
300     panRecognizer->refereeState_ = RefereeState::SUCCEED;
301     panRecognizer->touchPoints_.clear();
302     panRecognizer->HandleTouchDownEvent(axisEvent);
303     EXPECT_EQ(panRecognizer->touchPoints_.size(), 1);
304 
305     /**
306      * @tc.steps: step2. call HandleTouchDown function and compare result.
307      * @tc.steps: case5: call AxisEvent, refereeState is PENDING, normal case
308      * @tc.expected: step2. result equals.
309      */
310     panRecognizer->refereeState_ = RefereeState::PENDING;
311     panRecognizer->HandleTouchDownEvent(axisEvent);
312     EXPECT_EQ(panRecognizer->deviceId_, axisEvent.deviceId);
313     EXPECT_EQ(panRecognizer->deviceType_, axisEvent.sourceType);
314     EXPECT_EQ(panRecognizer->refereeState_, RefereeState::DETECTING);
315 }
316 
317 /**
318  * @tc.name: PanRecognizerTest003
319  * @tc.desc: Test PanRecognizer function: HandleTouchUpEvent
320  * @tc.type: FUNC
321  */
322 HWTEST_F(PanRecognizerTestNg, PanRecognizerTest003, TestSize.Level1)
323 {
324     /**
325      * @tc.steps: step1. create PanRecognizer.
326      */
327     RefPtr<PanGestureOption> panGestureOption = AceType::MakeRefPtr<PanGestureOption>();
328     RefPtr<PanRecognizer> panRecognizer = AceType::MakeRefPtr<PanRecognizer>(panGestureOption);
329 
330     /**
331      * @tc.steps: step2. call HandleTouchUp function and compare result.
332      * @tc.steps: case1: refereeState is SUCCEED
333      * @tc.expected: step2. result equals.
334      */
335     TouchEvent touchEvent;
336     panRecognizer->refereeState_ = RefereeState::SUCCEED;
337     panRecognizer->HandleTouchUpEvent(touchEvent);
338     EXPECT_EQ(panRecognizer->globalPoint_.GetX(), touchEvent.x);
339     EXPECT_EQ(panRecognizer->globalPoint_.GetY(), touchEvent.y);
340     EXPECT_EQ(panRecognizer->lastTouchEvent_.id, touchEvent.id);
341 
342     /**
343      * @tc.steps: step2. call HandleTouchUp function and compare result.
344      * @tc.steps: case2: refereeState is SUCCEED, size > 1
345      * @tc.expected: step2. result equals.
346      */
347     panRecognizer->touchPoints_[0] = touchEvent;
348     panRecognizer->touchPoints_[1] = touchEvent;
349     panRecognizer->HandleTouchUpEvent(touchEvent);
350     EXPECT_EQ(panRecognizer->globalPoint_.GetX(), touchEvent.x);
351     EXPECT_EQ(panRecognizer->globalPoint_.GetY(), touchEvent.y);
352     EXPECT_EQ(panRecognizer->lastTouchEvent_.id, touchEvent.id);
353 
354     /**
355      * @tc.steps: step2. call HandleTouchUp function and compare result.
356      * @tc.steps: case3: refereeState is FAIL
357      * @tc.expected: step2. result equals.
358      */
359     panRecognizer->refereeState_ = RefereeState::FAIL;
360     EXPECT_EQ(panRecognizer->globalPoint_.GetX(), touchEvent.x);
361     EXPECT_EQ(panRecognizer->globalPoint_.GetY(), touchEvent.y);
362     EXPECT_EQ(panRecognizer->lastTouchEvent_.id, touchEvent.id);
363 
364     /**
365      * @tc.steps: step3. call HandleTouchUp function and compare result.
366      * @tc.steps: case1: refereeState is SUCCEED
367      * @tc.expected: step2. result equals.
368      */
369     AxisEvent axisEvent;
370     panRecognizer->refereeState_ = RefereeState::SUCCEED;
371     panRecognizer->HandleTouchUpEvent(axisEvent);
372     EXPECT_EQ(panRecognizer->globalPoint_.GetX(), axisEvent.x);
373     EXPECT_EQ(panRecognizer->globalPoint_.GetY(), axisEvent.y);
374 
375     /**
376      * @tc.steps: step3. call HandleTouchUp function and compare result.
377      * @tc.steps: case2: refereeState is FAIL
378      * @tc.expected: step2. result equals.
379      */
380     panRecognizer->refereeState_ = RefereeState::FAIL;
381     panRecognizer->HandleTouchUpEvent(axisEvent);
382     EXPECT_EQ(panRecognizer->globalPoint_.GetX(), axisEvent.x);
383     EXPECT_EQ(panRecognizer->globalPoint_.GetY(), axisEvent.y);
384 }
385 
386 /**
387  * @tc.name: PanRecognizerHandleTouchUpEventTest001
388  * @tc.desc: Test PanRecognizer function: HandleTouchUpEvent
389  * @tc.type: FUNC
390  */
391 HWTEST_F(PanRecognizerTestNg, PanRecognizerHandleTouchUpEventTest001, TestSize.Level1)
392 {
393     /**
394      * @tc.steps: step1. create PanRecognizer.
395      */
396     RefPtr<PanGestureOption> panGestureOption = AceType::MakeRefPtr<PanGestureOption>();
397     RefPtr<PanRecognizer> panRecognizer = AceType::MakeRefPtr<PanRecognizer>(panGestureOption);
398 
399     /**
400      * @tc.steps: step2. call HandleTouchUp function and compare result.
401      * @tc.steps: case1: refereeState is SUCCEED
402      * @tc.expected: step2. result equals.
403      */
404     TouchEvent touchEvent;
405     panRecognizer->refereeState_ = RefereeState::SUCCEED;
406     panRecognizer->currentFingers_ = panRecognizer->fingers_;
407     panRecognizer->HandleTouchUpEvent(touchEvent);
408     EXPECT_EQ(panRecognizer->globalPoint_.GetX(), touchEvent.x);
409     EXPECT_EQ(panRecognizer->globalPoint_.GetY(), touchEvent.y);
410     EXPECT_EQ(panRecognizer->lastTouchEvent_.id, touchEvent.id);
411 
412     /**
413      * @tc.steps: step2. call HandleTouchUp function and compare result.
414      * @tc.steps: case2: refereeState is SUCCEED, size > 1
415      * @tc.expected: step2. result equals.
416      */
417     panRecognizer->touchPoints_[0] = touchEvent;
418     panRecognizer->touchPoints_[1] = touchEvent;
419     panRecognizer->currentFingers_ = panRecognizer->fingers_;
420     panRecognizer->refereeState_ = RefereeState::FAIL;
421     panRecognizer->HandleTouchUpEvent(touchEvent);
422     EXPECT_EQ(panRecognizer->globalPoint_.GetX(), touchEvent.x);
423     EXPECT_EQ(panRecognizer->globalPoint_.GetY(), touchEvent.y);
424     EXPECT_EQ(panRecognizer->lastTouchEvent_.id, touchEvent.id);
425 }
426 
427 /**
428  * @tc.name: PanRecognizerHandleTouchMoveEventTest001
429  * @tc.desc: Test PanRecognizer function: HandleTouchMoveEvent
430  * @tc.type: FUNC
431  */
432 HWTEST_F(PanRecognizerTestNg, PanRecognizerHandleTouchMoveEventTest001, TestSize.Level1)
433 {
434     /**
435      * @tc.steps: step1. create PanRecognizer.
436      */
437     RefPtr<PanGestureOption> panGestureOption = AceType::MakeRefPtr<PanGestureOption>();
438     RefPtr<PanRecognizer> panRecognizer = AceType::MakeRefPtr<PanRecognizer>(panGestureOption);
439 
440     /**
441      * @tc.steps: step2. call HandleTouchUp function and compare result.
442      * @tc.steps: case1: direction.type is VERTICAL
443      * @tc.expected: step2. result equals.
444      */
445     TouchEvent touchEvent;
446     panRecognizer->refereeState_ = RefereeState::SUCCEED;
447     panRecognizer->touchPoints_[touchEvent.id] = touchEvent;
448     panRecognizer->direction_.type = PanDirection::VERTICAL;
449     panRecognizer->isFlushTouchEventsEnd_ = true;
450     panRecognizer->currentFingers_ = panRecognizer->fingers_;
451     panRecognizer->HandleTouchMoveEvent(touchEvent);
452     EXPECT_EQ(panRecognizer->globalPoint_.GetX(), touchEvent.x);
453     EXPECT_EQ(panRecognizer->globalPoint_.GetY(), touchEvent.y);
454     EXPECT_EQ(panRecognizer->delta_.GetX(), 0);
455     EXPECT_EQ(panRecognizer->delta_.GetY(), 0);
456     EXPECT_EQ(panRecognizer->averageDistance_.GetX(), 0);
457 
458     /**
459      * @tc.steps: step2. call HandleTouchUp function and compare result.
460      * @tc.steps: case2: direction.type is HORIZONTAL
461      * @tc.expected: step2. result equals.
462      */
463     panRecognizer->direction_.type = PanDirection::HORIZONTAL;
464     panRecognizer->currentFingers_ = panRecognizer->fingers_;
465     panRecognizer->HandleTouchMoveEvent(touchEvent);
466     EXPECT_EQ(panRecognizer->averageDistance_.GetY(), 0);
467 
468     /**
469      * @tc.steps: step2. call HandleTouchUp function and compare result.
470      * @tc.steps: case3: isFlushTouchEventsEnd_ is false
471      * @tc.expected: step2. result equals.
472      */
473     panRecognizer->isFlushTouchEventsEnd_ = false;
474     panRecognizer->currentFingers_ = panRecognizer->fingers_;
475     panRecognizer->HandleTouchMoveEvent(touchEvent);
476     EXPECT_EQ(panRecognizer->averageDistance_.GetY(), 0);
477 
478     /**
479      * @tc.steps: step2. call HandleTouchUp function and compare result.
480      * @tc.steps: case3: isFlushTouchEventsEnd_ is true
481      * @tc.expected: step2. result equals.
482      */
483     panRecognizer->isFlushTouchEventsEnd_ = true;
484     panRecognizer->currentFingers_ = panRecognizer->fingers_;
485     panRecognizer->HandleTouchMoveEvent(touchEvent);
486     EXPECT_EQ(panRecognizer->averageDistance_.GetY(), 0);
487 }
488 
489 /**
490  * @tc.name: PanRecognizerTest004
491  * @tc.desc: Test PanRecognizer function: HandleTouchMoveEvent
492  * @tc.type: FUNC
493  */
494 HWTEST_F(PanRecognizerTestNg, PanRecognizerTest004, TestSize.Level1)
495 {
496     /**
497      * @tc.steps: step1. create PanRecognizer.
498      */
499     RefPtr<PanGestureOption> panGestureOption = AceType::MakeRefPtr<PanGestureOption>();
500     RefPtr<PanRecognizer> panRecognizer = AceType::MakeRefPtr<PanRecognizer>(panGestureOption);
501 
502     /**
503      * @tc.steps: step2. call HandleTouchUp function and compare result.
504      * @tc.steps: case1: direction.type is VERTICAL
505      * @tc.expected: step2. result equals.
506      */
507     TouchEvent touchEvent;
508     panRecognizer->refereeState_ = RefereeState::SUCCEED;
509     panRecognizer->touchPoints_[touchEvent.id] = touchEvent;
510     panRecognizer->direction_.type = PanDirection::VERTICAL;
511     panRecognizer->isFlushTouchEventsEnd_ = true;
512     panRecognizer->HandleTouchMoveEvent(touchEvent);
513     EXPECT_EQ(panRecognizer->globalPoint_.GetX(), touchEvent.x);
514     EXPECT_EQ(panRecognizer->globalPoint_.GetY(), touchEvent.y);
515     EXPECT_EQ(panRecognizer->delta_.GetX(), 0);
516     EXPECT_EQ(panRecognizer->delta_.GetY(), 0);
517     EXPECT_EQ(panRecognizer->averageDistance_.GetX(), 0);
518 
519     /**
520      * @tc.steps: step2. call HandleTouchUp function and compare result.
521      * @tc.steps: case2: direction.type is HORIZONTAL
522      * @tc.expected: step2. result equals.
523      */
524     panRecognizer->direction_.type = PanDirection::HORIZONTAL;
525     panRecognizer->HandleTouchMoveEvent(touchEvent);
526     EXPECT_EQ(panRecognizer->averageDistance_.GetY(), 0);
527 
528     /**
529      * @tc.steps: step2. call HandleTouchUp function and compare result.
530      * @tc.steps: case3: isFlushTouchEventsEnd_ is false
531      * @tc.expected: step2. result equals.
532      */
533     panRecognizer->isFlushTouchEventsEnd_ = false;
534     panRecognizer->HandleTouchMoveEvent(touchEvent);
535     EXPECT_EQ(panRecognizer->averageDistance_.GetY(), 0);
536 }
537 
538 /**
539  * @tc.name: PanRecognizerTest005
540  * @tc.desc: Test PanRecognizer function: OnFlushTouchEvents begin end
541  * @tc.type: FUNC
542  */
543 HWTEST_F(PanRecognizerTestNg, PanRecognizerTest005, TestSize.Level1)
544 {
545     /**
546      * @tc.steps: step1. create PanRecognizer.
547      */
548     RefPtr<PanGestureOption> panGestureOption = AceType::MakeRefPtr<PanGestureOption>();
549     RefPtr<PanRecognizer> panRecognizer = AceType::MakeRefPtr<PanRecognizer>(panGestureOption);
550 
551     /**
552      * @tc.steps: step2. call HandleTouchUp function and compare result.
553      * @tc.expected: step2. result equals.
554      */
555     panRecognizer->OnFlushTouchEventsBegin();
556     EXPECT_EQ(panRecognizer->isFlushTouchEventsEnd_, false);
557     panRecognizer->OnFlushTouchEventsEnd();
558     EXPECT_EQ(panRecognizer->isFlushTouchEventsEnd_, true);
559 }
560 
561 /**
562  * @tc.name: PanRecognizerTest006
563  * @tc.desc: Test PanRecognizer function: IsPanGestureAccept
564  * @tc.type: FUNC
565  */
566 HWTEST_F(PanRecognizerTestNg, PanRecognizerTest006, TestSize.Level1)
567 {
568     /**
569      * @tc.steps: step1. create PanRecognizer.
570      */
571     APIVersionGuard aPIVersionGuard(static_cast<int32_t>(PlatformVersion::VERSION_TWENTY));
572     ASSERT_EQ(static_cast<int32_t>(PlatformVersion::VERSION_TWENTY),
573         AceApplicationInfo::GetInstance().GetApiTargetVersion());
574     RefPtr<PanGestureOption> panGestureOption = AceType::MakeRefPtr<PanGestureOption>();
575     RefPtr<PanRecognizer> panRecognizer = AceType::MakeRefPtr<PanRecognizer>(panGestureOption);
576 
577     /**
578      * @tc.steps: step2. case1: PanDirection::ALL, fabs(offset) >= distance_.
579      * @tc.expected: step2. return ACCEPT.
580      */
581     PanRecognizer::GestureAcceptResult result;
582     panRecognizer->direction_.type = PanDirection::ALL;
583     panRecognizer->distanceMap_[SourceTool::UNKNOWN] = Dimension(0, DimensionUnit::PX);
584     result = panRecognizer->IsPanGestureAccept();
585     EXPECT_EQ(result, PanRecognizer::GestureAcceptResult::ACCEPT);
586 
587     /**
588      * @tc.steps: step2. case2: PanDirection::ALL, fabs(offset) < distance_.
589      * @tc.expected: step2. return DETECTING.
590      */
591     panRecognizer->direction_.type = PanDirection::ALL;
592     panRecognizer->distanceMap_[SourceTool::UNKNOWN] = Dimension(1, DimensionUnit::PX);
593     result = panRecognizer->IsPanGestureAccept();
594     EXPECT_EQ(result, PanRecognizer::GestureAcceptResult::DETECTING);
595 
596     /**
597      * @tc.steps: step2. case3: GetX > GetY, GetX < distance, PanDirection::HORIZONTAL.
598      * @tc.expected: step2. return DETECTING.
599      */
600     panRecognizer->direction_.type = PanDirection::HORIZONTAL;
601     panRecognizer->averageDistance_ = Offset(0, -1);
602     panRecognizer->distanceMap_[SourceTool::UNKNOWN] = Dimension(1, DimensionUnit::PX);
603     result = panRecognizer->IsPanGestureAccept();
604     EXPECT_EQ(result, PanRecognizer::GestureAcceptResult::DETECTING);
605 
606     /**
607      * @tc.steps: step2. case4: GetX > GetY, GetX > 0, GetX > distance_, PanDirection::LEFT.
608      * @tc.expected: step2. return REJECT.
609      */
610     panRecognizer->direction_.type = PanDirection::LEFT;
611     panRecognizer->averageDistance_ = Offset(1, 0);
612     panRecognizer->distanceMap_[SourceTool::UNKNOWN] = Dimension(0, DimensionUnit::PX);
613     result = panRecognizer->IsPanGestureAccept();
614     EXPECT_EQ(result, PanRecognizer::GestureAcceptResult::ACCEPT);
615 
616     /**
617      * @tc.steps: step2. case5: GetX > GetY, GetX > 0, GetX > distance_, PanDirection::VERTICAL.
618      * @tc.expected: step2. return REJECT.
619      */
620     panRecognizer->direction_.type = PanDirection::VERTICAL;
621     panRecognizer->averageDistance_ = Offset(1, 0);
622     panRecognizer->distanceMap_[SourceTool::UNKNOWN] = Dimension(0, DimensionUnit::PX);
623     result = panRecognizer->IsPanGestureAccept();
624     EXPECT_EQ(result, PanRecognizer::GestureAcceptResult::ACCEPT);
625 
626     /**
627      * @tc.steps: step2. case6: GetX > GetY, GetX = distance_ = 0, PanDirection::VERTICAL.
628      * @tc.expected: step2. return ACCEPT.
629      */
630     panRecognizer->direction_.type = PanDirection::VERTICAL;
631     panRecognizer->averageDistance_ = Offset(0, -1);
632     panRecognizer->distanceMap_[SourceTool::UNKNOWN] = Dimension(0, DimensionUnit::PX);
633     result = panRecognizer->IsPanGestureAccept();
634     EXPECT_EQ(result, PanRecognizer::GestureAcceptResult::ACCEPT);
635 }
636 
637 /**
638  * @tc.name: PanRecognizerTest007
639  * @tc.desc: Test PanRecognizer function: IsPanGestureAccept
640  * @tc.type: FUNC
641  */
642 HWTEST_F(PanRecognizerTestNg, PanRecognizerTest007, TestSize.Level1)
643 {
644     /**
645      * @tc.steps: step1. create PanRecognizer.
646      */
647     RefPtr<PanGestureOption> panGestureOption = AceType::MakeRefPtr<PanGestureOption>();
648     RefPtr<PanRecognizer> panRecognizer = AceType::MakeRefPtr<PanRecognizer>(panGestureOption);
649 
650     /**
651      * @tc.steps: step2. case7: GetX <= GetY, GetY < distance_, PanDirection::VERTICAL.
652      * @tc.expected: step2. return DETECTING.
653      */
654     PanRecognizer::GestureAcceptResult result;
655     panRecognizer->direction_.type = PanDirection::VERTICAL;
656     panRecognizer->averageDistance_ = Offset(-1, 0);
657     panRecognizer->distanceMap_[SourceTool::UNKNOWN] = Dimension(1, DimensionUnit::PX);
658     result = panRecognizer->IsPanGestureAccept();
659     EXPECT_EQ(result, PanRecognizer::GestureAcceptResult::DETECTING);
660 
661     /**
662      * @tc.steps: step2. case8: GetX <= GetY, GetY > distance_, GetY < 0, PanDirection::DOWN.
663      * @tc.expected: step2. return ACCEPT.
664      */
665     panRecognizer->direction_.type = PanDirection::DOWN;
666     panRecognizer->averageDistance_ = Offset(-1, 1);
667     panRecognizer->touchPointsDistance_[0] = Offset(-1, 1);
668     panRecognizer->distanceMap_[SourceTool::UNKNOWN] = Dimension(0, DimensionUnit::PX);
669     result = panRecognizer->IsPanGestureAccept();
670     EXPECT_EQ(result, PanRecognizer::GestureAcceptResult::ACCEPT);
671 
672     /**
673      * @tc.steps: step2. case9: GetX <= GetY, GetY > distance_, GetY > 0, PanDirection::UP.
674      * @tc.expected: step2. return ACCEPT.
675      */
676     panRecognizer->direction_.type = PanDirection::UP;
677     panRecognizer->averageDistance_ = Offset(-1, 1);
678     panRecognizer->distanceMap_[SourceTool::UNKNOWN] = Dimension(0, DimensionUnit::PX);
679     result = panRecognizer->IsPanGestureAccept();
680     EXPECT_EQ(result, PanRecognizer::GestureAcceptResult::ACCEPT);
681 
682     /**
683      * @tc.steps: step2. case10: GetX <= GetY, GetY = distance_ = 0, PanDirection::UP.
684      * @tc.expected: step2. return ACCEPT.
685      */
686     panRecognizer->direction_.type = PanDirection::UP;
687     panRecognizer->averageDistance_ = Offset(-1, 0);
688     panRecognizer->distanceMap_[SourceTool::UNKNOWN] = Dimension(0, DimensionUnit::PX);
689     result = panRecognizer->IsPanGestureAccept();
690     EXPECT_EQ(result, PanRecognizer::GestureAcceptResult::ACCEPT);
691 }
692 
693 /**
694  * @tc.name: PanRecognizerTest008
695  * @tc.desc: Test PanRecognizer function: HandleTouchCancelEvent
696  * @tc.type: FUNC
697  */
698 HWTEST_F(PanRecognizerTestNg, PanRecognizerTest008, TestSize.Level1)
699 {
700     /**
701      * @tc.steps: step1. create PanRecognizer.
702      */
703     RefPtr<PanGestureOption> panGestureOption = AceType::MakeRefPtr<PanGestureOption>();
704     RefPtr<PanRecognizer> panRecognizer = AceType::MakeRefPtr<PanRecognizer>(panGestureOption);
705 
706     /**
707      * @tc.steps: step2. call HandleTouchCancel function and compare result.
708      * @tc.steps: case1: Touch, refereeState is SUCCEED
709      * @tc.expected: step2. result equals.
710      */
711     TouchEvent touchEvent;
712     panRecognizer->refereeState_ = RefereeState::SUCCEED;
713     panRecognizer->HandleTouchCancelEvent(touchEvent);
714     EXPECT_EQ(panRecognizer->touchPoints_.size(), 0);
715 
716     /**
717      * @tc.steps: step2. call HandleTouchCancel function and compare result.
718      * @tc.steps: case2: Touch, refereeState is FAIL
719      * @tc.expected: step2. result equals.
720      */
721     panRecognizer->refereeState_ = RefereeState::FAIL;
722     panRecognizer->HandleTouchCancelEvent(touchEvent);
723     EXPECT_EQ(panRecognizer->touchPoints_.size(), 0);
724 
725     /**
726      * @tc.steps: step3. call HandleTouchCancel function and compare result.
727      * @tc.steps: case1: Axis, refereeState is SUCCEED
728      * @tc.expected: step2. result equals.
729      */
730     AxisEvent axisEvent;
731     panRecognizer->refereeState_ = RefereeState::SUCCEED;
732     panRecognizer->HandleTouchCancelEvent(axisEvent);
733     EXPECT_EQ(panRecognizer->touchPoints_.size(), 0);
734 
735     /**
736      * @tc.steps: step3. call HandleTouchCancel function and compare result.
737      * @tc.steps: case2: Axis, refereeState is FAIL
738      * @tc.expected: step2. result equals.
739      */
740     panRecognizer->refereeState_ = RefereeState::FAIL;
741     panRecognizer->HandleTouchCancelEvent(axisEvent);
742     EXPECT_EQ(panRecognizer->touchPoints_.size(), 0);
743 }
744 
745 /**
746  * @tc.name: PanRecognizerTest009
747  * @tc.desc: Test PanRecognizer function: SendCallbackMsg
748  * @tc.type: FUNC
749  */
750 HWTEST_F(PanRecognizerTestNg, PanRecognizerTest009, TestSize.Level1)
751 {
752     /**
753      * @tc.steps: step1. create PanRecognizer.
754      */
755     RefPtr<PanGestureOption> panGestureOption = AceType::MakeRefPtr<PanGestureOption>();
756     RefPtr<PanRecognizer> panRecognizer = AceType::MakeRefPtr<PanRecognizer>(panGestureOption);
757 
758     /**
759      * @tc.steps: step2. call SendCallbackMsg function and compare result.
760      * @tc.steps: case1: onAction is no, *onAction is no
761      * @tc.expected: step2. result equals.
762      */
763     std::unique_ptr<GestureEventFunc> onAction;
764     panRecognizer->SendCallbackMsg(onAction, GestureCallbackType::START);
765     EXPECT_EQ(panRecognizer->touchPoints_.size(), 0);
766 
767     /**
768      * @tc.steps: step2. call SendCallbackMsg function and compare result.
769      * @tc.steps: case2: onAction is yes, *onAction is no
770      * @tc.expected: step2. result equals.
771      */
772     onAction = std::make_unique<GestureEventFunc>();
773     panRecognizer->SendCallbackMsg(onAction, GestureCallbackType::START);
774     EXPECT_EQ(panRecognizer->touchPoints_.size(), 0);
775 
776     /**
777      * @tc.steps: step2. call SendCallbackMsg function and compare result.
778      * @tc.steps: case3: onAction is yes, *onAction is yes, touchEvent is empty, type is AXIS
779      * @tc.expected: step2. result equals.
780      */
__anon4a7b7f5a0102(GestureEvent) 781     onAction = std::make_unique<GestureEventFunc>([](GestureEvent) {});
782     panRecognizer->inputEventType_ = InputEventType::AXIS;
783     panRecognizer->SendCallbackMsg(onAction, GestureCallbackType::START);
784     EXPECT_EQ(panRecognizer->touchPoints_.size(), 0);
785 
786     /**
787      * @tc.steps: step2. call SendCallbackMsg function and compare result.
788      * @tc.steps: case4: touchEvent is not empty, have no X and Y, type is not AXIS
789      * @tc.expected: step2. result equals.
790      */
791     TouchEvent touchEvent;
792     panRecognizer->lastTouchEvent_ = touchEvent;
793     panRecognizer->SendCallbackMsg(onAction, GestureCallbackType::START);
794     EXPECT_EQ(panRecognizer->touchPoints_.size(), 0);
795 
796     /**
797      * @tc.steps: step2. call SendCallbackMsg function and compare result.
798      * @tc.steps: case4: touchEvent is not empty, have no X and Y
799      * @tc.expected: step2. result equals.
800      */
801     touchEvent.tiltX = 0.0f;
802     touchEvent.tiltY = 0.0f;
803     panRecognizer->lastTouchEvent_ = touchEvent;
804     panRecognizer->SendCallbackMsg(onAction, GestureCallbackType::START);
805     EXPECT_EQ(panRecognizer->touchPoints_.size(), 0);
806 }
807 
808 /**
809  * @tc.name: PanRecognizerSendCallbackMsgTest002
810  * @tc.desc: Test PanRecognizer function: SendCallbackMsg
811  * @tc.type: FUNC
812  */
813 HWTEST_F(PanRecognizerTestNg, PanRecognizerSendCallbackMsgTest002, TestSize.Level1)
814 {
815     /**
816      * @tc.steps: step1. create PanRecognizer.
817      */
818     RefPtr<PanGestureOption> panGestureOption = AceType::MakeRefPtr<PanGestureOption>();
819     RefPtr<PanRecognizer> panRecognizer = AceType::MakeRefPtr<PanRecognizer>(panGestureOption);
820 
821     /**
822      * @tc.steps: step2. SendCallbackMsg
823      * @tc.expected: step2. result equals.
824      */
825     TouchEvent touchEvent;
826     panRecognizer->refereeState_ = RefereeState::SUCCEED;
827     panRecognizer->HandleTouchDownEvent(touchEvent);
828     EXPECT_EQ(panRecognizer->touchPoints_.size(), 1);
829     std::unique_ptr<GestureEventFunc> onAction;
830     panRecognizer->SendCallbackMsg(onAction, GestureCallbackType::START);
831     EXPECT_EQ(panRecognizer->touchPoints_.size(), 1);
832 }
833 
834 /**
835  * @tc.name: PanRecognizerSendCallbackMsgTest001
836  * @tc.desc: Test PanRecognizer function: SendCallbackMsg
837  * @tc.type: FUNC
838  */
839 HWTEST_F(PanRecognizerTestNg, PanRecognizerSendCallbackMsgTest001, TestSize.Level1)
840 {
841     /**
842      * @tc.steps: step1. create PanRecognizer.
843      */
844     RefPtr<PanGestureOption> panGestureOption = AceType::MakeRefPtr<PanGestureOption>();
845     RefPtr<PanRecognizer> panRecognizer = AceType::MakeRefPtr<PanRecognizer>(panGestureOption);
846 
847     /**
848      * @tc.steps: step2. call SendCallbackMsg function and compare result.
849      * @tc.steps: case1: onAction is no, *onAction is no
850      * @tc.expected: step2. result equals.
851      */
852     std::unique_ptr<GestureEventFunc> onAction = std::make_unique<GestureEventFunc>();
853     panRecognizer->inputEventType_ = InputEventType::TOUCH_SCREEN;
854     panRecognizer->SendCallbackMsg(onAction, GestureCallbackType::START);
855     EXPECT_EQ(panRecognizer->touchPoints_.size(), 0);
856 }
857 
858 /**
859  * @tc.name: PanRecognizerTest010
860  * @tc.desc: Test PanRecognizer function: ReconcileFrom
861  * @tc.type: FUNC
862  */
863 HWTEST_F(PanRecognizerTestNg, PanRecognizerTest010, TestSize.Level1)
864 {
865     /**
866      * @tc.steps: step1. create PanRecognizer.
867      */
868     RefPtr<PanGestureOption> panGestureOption = AceType::MakeRefPtr<PanGestureOption>();
869     RefPtr<PanRecognizer> panRecognizer = AceType::MakeRefPtr<PanRecognizer>(panGestureOption);
870     RefPtr<PanRecognizer> panRecognizerPtr = AceType::MakeRefPtr<PanRecognizer>(panGestureOption);
871 
872     /**
873      * @tc.steps: step2. call ReconcileFrom function
874      * @tc.steps: case1: recognizer is nullptr
875      * @tc.expected: step2. result equals.
876      */
877     auto result = panRecognizer->ReconcileFrom(nullptr);
878     EXPECT_EQ(result, false);
879 
880     /**
881      * @tc.steps: step2. call ReconcileFrom function
882      * @tc.steps: case2: recognizer is normal
883      * @tc.expected: step2. result equals.
884      */
885     result = panRecognizer->ReconcileFrom(panRecognizerPtr);
886     EXPECT_EQ(result, true);
887 
888     /**
889      * @tc.steps: step2. call ReconcileFrom function
890      * @tc.steps: case3: fingers not same
891      * @tc.expected: step2. result equals.
892      */
893     panRecognizer->fingers_ = panRecognizerPtr->fingers_ + 1;
894     result = panRecognizer->ReconcileFrom(panRecognizerPtr);
895     EXPECT_EQ(result, false);
896 
897     /**
898      * @tc.steps: step2. call ReconcileFrom function
899      * @tc.steps: case4: fingers not same, priority not same
900      * @tc.expected: step2. result equals.
901      */
902     panRecognizer->priorityMask_ = GestureMask::End;
903     result = panRecognizer->ReconcileFrom(panRecognizerPtr);
904     EXPECT_EQ(result, false);
905 
906     /**
907      * @tc.steps: step2. call ReconcileFrom function
908      * @tc.steps: case4: fingers same, priority not same
909      * @tc.expected: step2. result equals.
910      */
911     panRecognizer->fingers_ = panRecognizerPtr->fingers_;
912     result = panRecognizer->ReconcileFrom(panRecognizerPtr);
913     EXPECT_EQ(result, false);
914 }
915 
916 /**
917  * @tc.name: PanRecognizerTest012
918  * @tc.desc: Test PanRecognizer function: ChangeFingers
919  * @tc.type: FUNC
920  */
921 HWTEST_F(PanRecognizerTestNg, PanRecognizerTest012, TestSize.Level1)
922 {
923     /**
924      * @tc.steps: step1. create PanRecognizer.
925      */
926     RefPtr<PanGestureOption> panGestureOption = AceType::MakeRefPtr<PanGestureOption>();
927     RefPtr<PanRecognizer> panRecognizer = AceType::MakeRefPtr<PanRecognizer>(panGestureOption);
928 
929     /**
930      * @tc.steps: step2. call ChangeFingers function
931      * @tc.steps: case1: fingers not same
932      * @tc.expected: step2. result equals.
933      */
934     panRecognizer->fingers_ = 0;
935     panRecognizer->ChangeFingers(1);
936     EXPECT_EQ(panRecognizer->newFingers_, 1);
937 
938     /**
939      * @tc.steps: step2. call ChangeFingers function
940      * @tc.steps: case1: fingers not same
941      * @tc.expected: step2. result equals.
942      */
943     panRecognizer->fingers_ = 1;
944     panRecognizer->ChangeFingers(1);
945     EXPECT_EQ(panRecognizer->newFingers_, 1);
946 }
947 
948 /**
949  * @tc.name: PanRecognizerTest013
950  * @tc.desc: Test PanRecognizer function: ChangeDirection
951  * @tc.type: FUNC
952  */
953 HWTEST_F(PanRecognizerTestNg, PanRecognizerTest013, TestSize.Level1)
954 {
955     /**
956      * @tc.steps: step1. create PanRecognizer.
957      */
958     RefPtr<PanGestureOption> panGestureOption = AceType::MakeRefPtr<PanGestureOption>();
959     RefPtr<PanRecognizer> panRecognizer = AceType::MakeRefPtr<PanRecognizer>(panGestureOption);
960 
961     /**
962      * @tc.steps: step2. call ChangeDirection function
963      * @tc.steps: case1: type not same
964      * @tc.expected: step2. result equals.
965      */
966     PanDirection panDirection;
967     panDirection.type = PanDirection::VERTICAL;
968     panRecognizer->direction_.type = PanDirection::HORIZONTAL;
969     panRecognizer->ChangeDirection(panDirection);
970     EXPECT_EQ(panRecognizer->direction_.type, PanDirection::VERTICAL);
971     EXPECT_EQ(panRecognizer->newDirection_.type, PanDirection::VERTICAL);
972 
973     /**
974      * @tc.steps: step2. call ChangeDirection function
975      * @tc.steps: case2: type same
976      * @tc.expected: step2. result equals.
977      */
978     panDirection.type = PanDirection::VERTICAL;
979     panRecognizer->direction_.type = PanDirection::VERTICAL;
980     panRecognizer->ChangeDirection(panDirection);
981     EXPECT_EQ(panRecognizer->direction_.type, PanDirection::VERTICAL);
982     EXPECT_EQ(panRecognizer->newDirection_.type, PanDirection::VERTICAL);
983 }
984 
985 /**
986  * @tc.name: PanRecognizerTest014
987  * @tc.desc: Test PanRecognizer function: ChangeDistance
988  * @tc.type: FUNC
989  */
990 HWTEST_F(PanRecognizerTestNg, PanRecognizerTest014, TestSize.Level1)
991 {
992     /**
993      * @tc.steps: step1. create PanRecognizer.
994      */
995     RefPtr<PanGestureOption> panGestureOption = AceType::MakeRefPtr<PanGestureOption>();
996     RefPtr<PanRecognizer> panRecognizer = AceType::MakeRefPtr<PanRecognizer>(panGestureOption);
997 
998     /**
999      * @tc.steps: step2. call ChangeDistance function
1000      * @tc.steps: case1: distance not same, refereeState is READY
1001      * @tc.expected: step2. result equals.
1002      */
1003     panRecognizer->distanceMap_[SourceTool::UNKNOWN] = Dimension(0, DimensionUnit::PX);
1004     panRecognizer->ChangeDistance(1);
1005     panRecognizer->refereeState_ = RefereeState::READY;
1006     EXPECT_EQ(panRecognizer->distanceMap_[SourceTool::UNKNOWN].ConvertToPx(), 1);
1007     EXPECT_EQ(panRecognizer->newDistanceMap_[SourceTool::UNKNOWN].ConvertToPx(), 1);
1008 
1009     /**
1010      * @tc.steps: step2. call ChangeDistance function
1011      * @tc.steps: case2: distance not same, refereeState is DETECTING
1012      * @tc.expected: step2. result equals.
1013      */
1014     panRecognizer->distanceMap_[SourceTool::UNKNOWN] = Dimension(0, DimensionUnit::PX);
1015     panRecognizer->ChangeDistance(1);
1016     panRecognizer->refereeState_ = RefereeState::DETECTING;
1017     EXPECT_EQ(panRecognizer->distanceMap_[SourceTool::UNKNOWN].ConvertToPx(), 1);
1018     EXPECT_EQ(panRecognizer->newDistanceMap_[SourceTool::UNKNOWN].ConvertToPx(), 1);
1019 
1020     /**
1021      * @tc.steps: step2. call ChangeDistance function
1022      * @tc.steps: case3: distance not same, refereeState is FAIL
1023      * @tc.expected: step2. result equals.
1024      */
1025     panRecognizer->distanceMap_[SourceTool::UNKNOWN] = Dimension(0, DimensionUnit::PX);
1026     panRecognizer->ChangeDistance(1);
1027     panRecognizer->refereeState_ = RefereeState::FAIL;
1028     EXPECT_EQ(panRecognizer->distanceMap_[SourceTool::UNKNOWN].ConvertToPx(), 1);
1029     EXPECT_EQ(panRecognizer->newDistanceMap_[SourceTool::UNKNOWN].ConvertToPx(), 1);
1030 
1031     /**
1032      * @tc.steps: step2. call ChangeDistance function
1033      * @tc.steps: case4: distance same
1034      * @tc.expected: step2. result equals.
1035      */
1036     panRecognizer->distanceMap_[SourceTool::UNKNOWN] = Dimension(0, DimensionUnit::PX);
1037     panRecognizer->ChangeDistance(0);
1038     panRecognizer->refereeState_ = RefereeState::FAIL;
1039     EXPECT_EQ(panRecognizer->distanceMap_[SourceTool::UNKNOWN].ConvertToPx(), 0);
1040     EXPECT_EQ(panRecognizer->newDistanceMap_[SourceTool::UNKNOWN].ConvertToPx(), 1);
1041 }
1042 
1043 /**
1044  * @tc.name: PanRecognizerChangeDistanceTest001
1045  * @tc.desc: Test PanRecognizer function: ChangeDistance
1046  * @tc.type: FUNC
1047  */
1048 HWTEST_F(PanRecognizerTestNg, PanRecognizerChangeDistanceTest001, TestSize.Level1)
1049 {
1050     /**
1051      * @tc.steps: step1. create PanRecognizer.
1052      */
1053     RefPtr<PanGestureOption> panGestureOption = AceType::MakeRefPtr<PanGestureOption>();
1054     RefPtr<PanRecognizer> panRecognizer = AceType::MakeRefPtr<PanRecognizer>(panGestureOption);
1055 
1056     /**
1057      * @tc.steps: step2. call ChangeDistance function
1058      * @tc.steps: case1: distance not same, refereeState is READY
1059      * @tc.expected: step2. result equals.
1060      */
1061     panRecognizer->distanceMap_[SourceTool::UNKNOWN] = Dimension(0, DimensionUnit::PX);
1062     panRecognizer->refereeState_ = RefereeState::READY;
1063     panRecognizer->ChangeDistance(1);
1064     EXPECT_EQ(panRecognizer->distanceMap_[SourceTool::UNKNOWN].ConvertToPx(), 1);
1065     EXPECT_EQ(panRecognizer->newDistanceMap_[SourceTool::UNKNOWN].ConvertToPx(), 1);
1066 
1067     /**
1068      * @tc.steps: step2. call ChangeDistance function
1069      * @tc.steps: case2: distance not same, refereeState is DETECTING
1070      * @tc.expected: step2. result equals.
1071      */
1072     panRecognizer->distanceMap_[SourceTool::UNKNOWN] = Dimension(0, DimensionUnit::PX);
1073     panRecognizer->refereeState_ = RefereeState::DETECTING;
1074     panRecognizer->ChangeDistance(1);
1075     EXPECT_EQ(panRecognizer->distanceMap_[SourceTool::UNKNOWN].ConvertToPx(), 1);
1076     EXPECT_EQ(panRecognizer->newDistanceMap_[SourceTool::UNKNOWN].ConvertToPx(), 1);
1077 
1078     /**
1079      * @tc.steps: step2. call ChangeDistance function
1080      * @tc.steps: case3: distance not same, refereeState is FAIL
1081      * @tc.expected: step2. result equals.
1082      */
1083     panRecognizer->distanceMap_[SourceTool::UNKNOWN] = Dimension(0, DimensionUnit::PX);
1084     panRecognizer->refereeState_ = RefereeState::FAIL;
1085     panRecognizer->ChangeDistance(1);
1086     EXPECT_EQ(panRecognizer->newDistanceMap_[SourceTool::UNKNOWN].ConvertToPx(), 1);
1087 
1088     /**
1089      * @tc.steps: step2. call ChangeDistance function
1090      * @tc.steps: case4: distance same
1091      * @tc.expected: step2. result equals.
1092      */
1093     panRecognizer->distanceMap_[SourceTool::UNKNOWN] = Dimension(0, DimensionUnit::PX);
1094     panRecognizer->refereeState_ = RefereeState::FAIL;
1095     panRecognizer->ChangeDistance(1);
1096     EXPECT_EQ(panRecognizer->distanceMap_[SourceTool::UNKNOWN].ConvertToPx(), 0);
1097     EXPECT_EQ(panRecognizer->newDistanceMap_[SourceTool::UNKNOWN].ConvertToPx(), 1);
1098 }
1099 
1100 /**
1101  * @tc.name: PanRecognizerTest015
1102  * @tc.desc: Test PanRecognizer function: GetMainAxisDelta
1103  * @tc.type: FUNC
1104  */
1105 HWTEST_F(PanRecognizerTestNg, PanRecognizerTest015, TestSize.Level1)
1106 {
1107     /**
1108      * @tc.steps: step1. create PanRecognizer.
1109      */
1110     RefPtr<PanGestureOption> panGestureOption = AceType::MakeRefPtr<PanGestureOption>();
1111     RefPtr<PanRecognizer> panRecognizer = AceType::MakeRefPtr<PanRecognizer>(panGestureOption);
1112 
1113     /**
1114      * @tc.steps: step2. call ChangeDistance function
1115      * @tc.steps: case1: directionType is ALL
1116      * @tc.expected: step2. result equals.
1117      */
1118     PanDirection panDirection;
1119     panRecognizer->direction_ = panDirection;
1120     panRecognizer->direction_.type = PanDirection::ALL;
1121     auto result = panRecognizer->GetMainAxisDelta();
1122     EXPECT_EQ(result, 0);
1123 
1124     /**
1125      * @tc.steps: step2. call ChangeDistance function
1126      * @tc.steps: case2: directionType is HORIZONTAL
1127      * @tc.expected: step2. result equals.
1128      */
1129     panRecognizer->direction_.type = PanDirection::HORIZONTAL;
1130     result = panRecognizer->GetMainAxisDelta();
1131     EXPECT_EQ(result, 0);
1132 
1133     /**
1134      * @tc.steps: step2. call ChangeDistance function
1135      * @tc.steps: case3: directionType is VERTICAL
1136      * @tc.expected: step2. result equals.
1137      */
1138     panRecognizer->direction_.type = PanDirection::VERTICAL;
1139     result = panRecognizer->GetMainAxisDelta();
1140     EXPECT_EQ(result, 0);
1141 
1142     /**
1143      * @tc.steps: step2. call ChangeDistance function
1144      * @tc.steps: case4: directionType is LEFT
1145      * @tc.expected: step2. result equals.
1146      */
1147     panRecognizer->direction_.type = PanDirection::LEFT;
1148     result = panRecognizer->GetMainAxisDelta();
1149     EXPECT_EQ(result, 0);
1150 }
1151 
1152 /**
1153  * @tc.name: PanRecognizerTest016
1154  * @tc.desc: Test PanRecognizer function: PanRecognizer
1155  * @tc.type: FUNC
1156  */
1157 HWTEST_F(PanRecognizerTestNg, PanRecognizerTest016, TestSize.Level1)
1158 {
1159     /**
1160      * @tc.steps: step1. create PanRecognizer.
1161      */
1162     RefPtr<PanGestureOption> panGestureOption = AceType::MakeRefPtr<PanGestureOption>();
1163 
1164     /**
1165      * @tc.steps: step2. call PanRecognizer function
1166      * @tc.steps: case1: 0 <= direction.type <= 15
1167      * @tc.expected: step2. result equals.
1168      */
1169     RefPtr<PanRecognizer> panRecognizer1 = AceType::MakeRefPtr<PanRecognizer>(panGestureOption);
1170     EXPECT_EQ(panRecognizer1->direction_.type, PanDirection::ALL);
1171 
1172     /**
1173      * @tc.steps: step2. call PanRecognizer function
1174      * @tc.steps: case1: 0 > direction.type
1175      * @tc.expected: step2. result equals.
1176      */
1177     panGestureOption->direction_.type = -1;
1178     RefPtr<PanRecognizer> panRecognizer2 = AceType::MakeRefPtr<PanRecognizer>(panGestureOption);
1179     EXPECT_EQ(panRecognizer2->direction_.type, PanDirection::ALL);
1180 
1181     /**
1182      * @tc.steps: step2. call PanRecognizer function
1183      * @tc.steps: case1: 0 > direction.type
1184      * @tc.expected: step2. result equals.
1185      */
1186     panGestureOption->direction_.type = PanDirection::ALL + 1;
1187     RefPtr<PanRecognizer> panRecognizer3 = AceType::MakeRefPtr<PanRecognizer>(panGestureOption);
1188     EXPECT_EQ(panRecognizer3->direction_.type, PanDirection::ALL);
1189 }
1190 
1191 /**
1192  * @tc.name: PanRecognizerTest017
1193  * @tc.desc: Test PanRecognizer function: HandleTouchMoveEvent(AxisEvent)
1194  * @tc.type: FUNC
1195  */
1196 HWTEST_F(PanRecognizerTestNg, PanRecognizerTest017, TestSize.Level1)
1197 {
1198     /**
1199      * @tc.steps: step1. create PanRecognizer.
1200      */
1201     RefPtr<PanGestureOption> panGestureOption = AceType::MakeRefPtr<PanGestureOption>();
1202     RefPtr<PanRecognizer> panRecognizer = AceType::MakeRefPtr<PanRecognizer>(panGestureOption);
1203     AxisEvent axisEvent;
1204 
1205     /**
1206      * @tc.steps: step2. call HandleTouchMove function and compare result.
1207      * @tc.steps: case1: fingers_ is 0, return
1208      * @tc.expected: step2. result equals.
1209      */
1210     panRecognizer->fingers_ = 0;
1211     panRecognizer->HandleTouchMoveEvent(axisEvent);
1212     EXPECT_EQ(panRecognizer->touchPoints_.size(), 0);
1213 
1214     /**
1215      * @tc.steps: step2. call HandleTouchMove function and compare result.
1216      * @tc.steps: case2: fingers_ is 1, direction is VERTICAL, refereeState is SUCCEED
1217      * @tc.expected: step2. result equals.
1218      */
1219     panRecognizer->fingers_ = 1;
1220     panRecognizer->direction_.type = PanDirection::VERTICAL;
1221     panRecognizer->refereeState_ = RefereeState::SUCCEED;
1222     panRecognizer->HandleTouchMoveEvent(axisEvent);
1223     EXPECT_EQ(panRecognizer->touchPoints_.size(), 1);
1224     EXPECT_EQ(panRecognizer->delta_.GetX(), 0);
1225     EXPECT_EQ(panRecognizer->delta_.GetY(), 0);
1226 
1227     /**
1228      * @tc.steps: step2. call HandleTouchMove function and compare result.
1229      * @tc.steps: case3: fingers_ is 1, direction is HORIZONTAL, refereeState is SUCCEED
1230      * @tc.steps: case3: event.horizontalAxis = 0
1231      * @tc.expected: step2. result equals.
1232      */
1233     panRecognizer->direction_.type = PanDirection::HORIZONTAL;
1234     panRecognizer->refereeState_ = RefereeState::SUCCEED;
1235     axisEvent.horizontalAxis = 0;
1236     panRecognizer->HandleTouchMoveEvent(axisEvent);
1237     EXPECT_EQ(panRecognizer->touchPoints_.size(), 1);
1238     EXPECT_EQ(panRecognizer->delta_.GetX(), 0);
1239     EXPECT_EQ(panRecognizer->delta_.GetY(), 0);
1240 
1241     /**
1242      * @tc.steps: step2. call HandleTouchMove function and compare result.
1243      * @tc.steps: case3: fingers_ is 1, direction is HORIZONTAL, refereeState is PENDING
1244      * @tc.steps: case3: event.horizontalAxis != 0
1245      * @tc.expected: step2. result equals.
1246      */
1247     panRecognizer->direction_.type = PanDirection::HORIZONTAL;
1248     panRecognizer->refereeState_ = RefereeState::PENDING;
1249     axisEvent.horizontalAxis = 1;
1250     panRecognizer->HandleTouchMoveEvent(axisEvent);
1251     EXPECT_EQ(panRecognizer->touchPoints_.size(), 1);
1252 }
1253 
1254 /**
1255  * @tc.name: PanRecognizerTest018
1256  * @tc.desc: Test PanRecognizer function: HandleTouchDownEvent
1257  * @tc.type: FUNC
1258  */
1259 HWTEST_F(PanRecognizerTestNg, PanRecognizerTest018, TestSize.Level1)
1260 {
1261     /**
1262      * @tc.steps: step1. create PanRecognizer.
1263      */
1264     RefPtr<PanGestureOption> panGestureOption = AceType::MakeRefPtr<PanGestureOption>();
1265     RefPtr<PanRecognizer> panRecognizer = AceType::MakeRefPtr<PanRecognizer>(panGestureOption);
1266     ASSERT_NE(panRecognizer, nullptr);
1267 
1268     /**
1269      * @tc.steps: step2. test with HandleTouchDownEvent(AxisEvent).
1270      * @tc.expect: panRecognizer->lastAxisEvent_ is equal to axisEvent
1271      * @tc.expect: panRecognizer->touchPoints_[axisEvent.id].originalId is equal to axisEvent.originalId
1272      * @tc.expect: panRecognizer->touchPoints_[axisEvent.id].screenX is equal to axisEvent.screenX
1273      * @tc.expect: panRecognizer->touchPoints_[axisEvent.id].screenY is equal to axisEvent.screenY
1274      */
1275     AxisEvent axisEvent;
1276     axisEvent.id = TEST_EVENT_ID;
1277     axisEvent.originalId = TEST_EVENT_ID;
1278     axisEvent.isRotationEvent = false;
1279     panRecognizer->refereeState_ = RefereeState::SUCCEED;
1280     panRecognizer->fingers_ = SINGLE_FINGER_NUMBER;
1281     panRecognizer->direction_.type = PanDirection::HORIZONTAL;
1282     panRecognizer->HandleTouchDownEvent(axisEvent);
1283     EXPECT_EQ(panRecognizer->lastAxisEvent_.id, axisEvent.id);
1284     EXPECT_EQ(panRecognizer->touchPoints_[axisEvent.id].originalId, axisEvent.originalId);
1285     EXPECT_EQ(panRecognizer->touchPoints_[axisEvent.id].screenX, axisEvent.screenX);
1286     EXPECT_EQ(panRecognizer->touchPoints_[axisEvent.id].screenY, axisEvent.screenY);
1287 }
1288 
1289 /**
1290  * @tc.name: PanRecognizerTest019
1291  * @tc.desc: Test PanRecognizer function: HandleTouchUpEvent
1292  * @tc.type: FUNC
1293  */
1294 HWTEST_F(PanRecognizerTestNg, PanRecognizerTest019, TestSize.Level1)
1295 {
1296     /**
1297      * @tc.steps: step1. create PanRecognizer.
1298      */
1299     RefPtr<PanGestureOption> panGestureOption = AceType::MakeRefPtr<PanGestureOption>();
1300     RefPtr<PanRecognizer> panRecognizer = AceType::MakeRefPtr<PanRecognizer>(panGestureOption);
1301     ASSERT_NE(panRecognizer, nullptr);
1302 
1303     /**
1304      * @tc.steps: step2. test with HandleTouchUpEvent(AxisEvent).
1305      * @tc.expect: panRecognizer->lastAxisEvent_ is equal to axisEvent
1306      */
1307     AxisEvent axisEvent;
1308     axisEvent.id = TEST_EVENT_ID;
1309     axisEvent.isRotationEvent = false;
1310     panRecognizer->refereeState_ = RefereeState::SUCCEED;
1311     panRecognizer->HandleTouchUpEvent(axisEvent);
1312     EXPECT_EQ(panRecognizer->lastAxisEvent_.id, axisEvent.id);
1313 }
1314 
1315 /**
1316  * @tc.name: PanRecognizerTest020
1317  * @tc.desc: Test PanRecognizer function: HandleTouchMoveEvent
1318  * @tc.type: FUNC
1319  */
1320 HWTEST_F(PanRecognizerTestNg, PanRecognizerTest020, TestSize.Level1)
1321 {
1322     /**
1323      * @tc.steps: step1. create PanRecognizer.
1324      */
1325     RefPtr<PanGestureOption> panGestureOption = AceType::MakeRefPtr<PanGestureOption>();
1326     RefPtr<PanRecognizer> panRecognizer = AceType::MakeRefPtr<PanRecognizer>(panGestureOption);
1327     ASSERT_NE(panRecognizer, nullptr);
1328 
1329     /**
1330      * @tc.steps: step2. test with HandleTouchMoveEvent(AxisEvent).
1331      * @tc.expect: panRecognizer->lastAxisEvent_ is equal to axisEvent
1332      */
1333     AxisEvent axisEvent;
1334     axisEvent.id = TEST_EVENT_ID;
1335     axisEvent.isRotationEvent = false;
1336     panRecognizer->refereeState_ = RefereeState::SUCCEED;
1337     panRecognizer->fingers_ = SINGLE_FINGER_NUMBER;
1338     panRecognizer->HandleTouchMoveEvent(axisEvent);
1339     EXPECT_EQ(panRecognizer->lastAxisEvent_.id, axisEvent.id);
1340 }
1341 
1342 /**
1343  * @tc.name: PanRecognizerSendCallbackMsgTest003
1344  * @tc.desc: Test PanRecognizer function: SendCallbackMsg
1345  * @tc.type: FUNC
1346  */
1347 HWTEST_F(PanRecognizerTestNg, PanRecognizerSendCallbackMsgTest003, TestSize.Level1)
1348 {
1349     /**
1350      * @tc.steps: step1. create PanRecognizer.
1351      */
1352     RefPtr<PanGestureOption> panGestureOption = AceType::MakeRefPtr<PanGestureOption>();
1353     RefPtr<PanRecognizer> panRecognizer = AceType::MakeRefPtr<PanRecognizer>(panGestureOption);
1354     std::unique_ptr<GestureEventFunc> onAction;
1355 
1356     /**
1357      * @tc.steps: step2. call SendCallbackMsg function and compare result.
1358      * @tc.steps: case3: onAction is yes, *onAction is yes, touchEvent is empty, type is AXIS
1359      * @tc.expected: step2. result equals.
1360      */
__anon4a7b7f5a0202(GestureEvent) 1361     onAction = std::make_unique<GestureEventFunc>([](GestureEvent) {});
1362     panRecognizer->inputEventType_ = InputEventType::AXIS;
1363     panRecognizer->SendCallbackMsg(onAction, GestureCallbackType::START);
1364     EXPECT_EQ(panRecognizer->touchPoints_.size(), 0);
1365 
1366     /**
1367      * @tc.steps: step2. call SendCallbackMsg function and compare result.
1368      * @tc.steps: case4: touchEvent is not empty, have no X and Y, type is not AXIS
1369      * @tc.expected: step2. result equals.
1370      */
1371     TouchEvent touchEvent;
1372     panRecognizer->lastTouchEvent_ = touchEvent;
1373     panRecognizer->inputEventType_ = InputEventType::AXIS;
1374     panRecognizer->SendCallbackMsg(onAction, GestureCallbackType::START);
1375     EXPECT_EQ(panRecognizer->touchPoints_.size(), 0);
1376 
1377     /**
1378      * @tc.steps: step2. call SendCallbackMsg function and compare result.
1379      * @tc.steps: case4: touchEvent is not empty, have no X and Y
1380      * @tc.expected: step2. result equals.
1381      */
1382     touchEvent.tiltX = 0.0f;
1383     touchEvent.tiltY = 0.0f;
1384     panRecognizer->lastTouchEvent_ = touchEvent;
1385     panRecognizer->touchPoints_[touchEvent.id] = touchEvent;
1386     panRecognizer->inputEventType_ = InputEventType::AXIS;
1387     panRecognizer->SendCallbackMsg(onAction, GestureCallbackType::START);
1388     EXPECT_EQ(panRecognizer->touchPoints_.size(), 1);
1389 }
1390 
1391 /*
1392  * @tc.name: PanGestureTest001
1393  * @tc.desc: Test PanGesture CreateRecognizer function
1394  */
1395 HWTEST_F(PanRecognizerTestNg, PanGestureTest001, TestSize.Level1)
1396 {
1397     /**
1398      * @tc.steps: step1. create PanGesture.
1399      */
1400     auto panGestureOption = AceType::MakeRefPtr<PanGestureOption>();
1401     auto panGesture = AceType::MakeRefPtr<PanGesture>(panGestureOption);
1402     ASSERT_NE(panGesture, nullptr);
1403     EXPECT_EQ(panGesture->panGestureOption_->fingers_, panGestureOption->fingers_);
1404 
1405     /**
1406      * @tc.steps: step2. call CreateRecognizer function and compare result.
1407      * @tc.expect: panRecognizer create successfully, use the same Option as panGesture.
1408      */
1409     panGesture->priority_ = GesturePriority::Low;
1410     panGesture->gestureMask_ = GestureMask::Normal;
1411     auto panRecognizer = AceType::DynamicCast<PanRecognizer>(panGesture->CreateRecognizer());
1412     ASSERT_NE(panRecognizer, nullptr);
1413     EXPECT_EQ(panRecognizer->GetPriority(), GesturePriority::Low);
1414     EXPECT_EQ(panRecognizer->GetPriorityMask(), GestureMask::Normal);
1415     EXPECT_EQ(panRecognizer->distanceMap_[SourceTool::UNKNOWN], DEFAULT_PAN_DISTANCE);
1416 }
1417 
1418 /**
1419  * @tc.name: PanGestureTest002
1420  * @tc.desc: Test PanGesture CreateRecognizer function
1421  */
1422 HWTEST_F(PanRecognizerTestNg, PanGestureTest002, TestSize.Level1)
1423 {
1424     /**
1425      * @tc.steps: step1. create PanGesture.
1426      */
1427     PanDirection panDirection;
1428     panDirection.type = PanDirection::RIGHT;
1429     auto panGesture = AceType::MakeRefPtr<PanGesture>(SINGLE_FINGER_NUMBER, panDirection, PAN_DISTANCE);
1430     ASSERT_NE(panGesture, nullptr);
1431     EXPECT_EQ(panGesture->fingers_, SINGLE_FINGER_NUMBER);
1432 
1433     /**
1434      * @tc.steps: step2. create onActionStart, onActionUpdate, onActionEnd, onActionCancel for PanRecognizer.
1435      * @tc.expect: panRecognizer create successfully with the OnActionCall.
1436      */
1437     panGesture->priority_ = GesturePriority::Low;
1438     panGesture->gestureMask_ = GestureMask::Normal;
__anon4a7b7f5a0302(GestureEvent& info) 1439     auto onActionStart = [](GestureEvent& info) { return true; };
__anon4a7b7f5a0402(GestureEvent& info) 1440     auto onActionUpdate = [](GestureEvent& info) { return true; };
__anon4a7b7f5a0502(GestureEvent& info) 1441     auto onActionEnd = [](GestureEvent& info) { return true; };
__anon4a7b7f5a0602(GestureEvent& info) 1442     auto onActionCancel = [](GestureEvent& info) { return true; };
1443     panGesture->SetOnActionStartId(onActionStart);
1444     panGesture->SetOnActionUpdateId(onActionUpdate);
1445     panGesture->SetOnActionEndId(onActionEnd);
1446     panGesture->SetOnActionCancelId(onActionCancel);
1447     EXPECT_TRUE(panGesture->onActionStartId_);
1448     EXPECT_TRUE(panGesture->onActionUpdateId_);
1449     EXPECT_TRUE(panGesture->onActionEndId_);
1450     EXPECT_TRUE(panGesture->onActionCancelId_);
1451 
1452     auto panRecognizer = AceType::DynamicCast<PanRecognizer>(panGesture->CreateRecognizer());
1453     ASSERT_NE(panRecognizer, nullptr);
1454     EXPECT_EQ(panRecognizer->GetPriority(), GesturePriority::Low);
1455     EXPECT_EQ(panRecognizer->GetPriorityMask(), GestureMask::Normal);
1456 }
1457 
1458 /**
1459  * @tc.name: PanRecognizerHandleTouchDownEventTest003
1460  * @tc.desc: Test PanRecognizer function: HandleTouchDownEvent
1461  * @tc.type: FUNC
1462  */
1463 HWTEST_F(PanRecognizerTestNg, PanRecognizerHandleTouchDownEventTest003, TestSize.Level1)
1464 {
1465     /**
1466      * @tc.steps: step1. create PanRecognizer.
1467      */
1468     RefPtr<PanGestureOption> panGestureOption = AceType::MakeRefPtr<PanGestureOption>();
1469     RefPtr<PanRecognizer> panRecognizerPtr = AceType::MakeRefPtr<PanRecognizer>(panGestureOption);
1470     TouchEvent touchEvent;
1471     touchEvent.x = 100.0;
1472     touchEvent.y = 100.0;
1473     touchEvent.sourceType = SourceType::MOUSE;
1474 
1475     panRecognizerPtr->direction_.type = PanDirection::NONE;
1476     panRecognizerPtr->isAllowMouse_ = false;
1477     panRecognizerPtr->HandleTouchDownEvent(touchEvent);
1478     EXPECT_EQ(panRecognizerPtr->globalPoint_.GetX(), 0);
1479 }
1480 
1481 
1482 /**
1483  * @tc.name: PanRecognizerHandleTouchCancelEventTest003
1484  * @tc.desc: Test PanRecognizer function: HandleTouchCancelEvent
1485  * @tc.type: FUNC
1486  */
1487 HWTEST_F(PanRecognizerTestNg, PanRecognizerHandleTouchCancelEventTest003, TestSize.Level1)
1488 {
1489     /**
1490      * @tc.steps: step1. create PanRecognizer.
1491      */
1492     RefPtr<PanGestureOption> panGestureOption = AceType::MakeRefPtr<PanGestureOption>();
1493     RefPtr<PanRecognizer> panRecognizerPtr = AceType::MakeRefPtr<PanRecognizer>(panGestureOption);
1494     TouchEvent touchEvent;
1495     touchEvent.x = 100.0;
1496     touchEvent.y = 100.0;
1497     touchEvent.sourceType = SourceType::MOUSE;
1498     AxisEvent axisEvent;
1499 
1500     panRecognizerPtr->refereeState_ = RefereeState::PENDING_BLOCKED;
1501     panRecognizerPtr->HandleTouchCancelEvent(touchEvent);
1502     EXPECT_EQ(panRecognizerPtr->globalPoint_.GetX(), 0);
1503 
1504     panRecognizerPtr->refereeState_ = RefereeState::PENDING_BLOCKED;
1505     panRecognizerPtr->HandleTouchCancelEvent(axisEvent);
1506     EXPECT_EQ(panRecognizerPtr->globalPoint_.GetX(), 0);
1507 }
1508 
1509 /**
1510  * @tc.name: PanRecognizerOnRejectedTest001
1511  * @tc.desc: Test PanRecognizer function: OnRejected
1512  * @tc.type: FUNC
1513  */
1514 HWTEST_F(PanRecognizerTestNg, PanRecognizerOnRejectedTest001, TestSize.Level1)
1515 {
1516     /**
1517      * @tc.steps: step1. create PanRecognizer.
1518      */
1519     RefPtr<PanGestureOption> panGestureOption = AceType::MakeRefPtr<PanGestureOption>();
1520     RefPtr<PanRecognizer> panRecognizerPtr = AceType::MakeRefPtr<PanRecognizer>(panGestureOption);
1521 
1522     panRecognizerPtr->refereeState_ = RefereeState::PENDING_BLOCKED;
1523     panRecognizerPtr->OnRejected();
1524     EXPECT_EQ(panRecognizerPtr->globalPoint_.GetX(), 0);
1525 }
1526 
1527 /**
1528  * @tc.name: PanRecognizerHandleTouchDownEventTest004
1529  * @tc.desc: Test PanRecognizer function: HandleTouchDownEvent
1530  * @tc.type: FUNC
1531  */
1532 HWTEST_F(PanRecognizerTestNg, PanRecognizerHandleTouchDownEventTest004, TestSize.Level1)
1533 {
1534     /**
1535      * @tc.steps: step1. create PanRecognizer.
1536      */
1537     RefPtr<PanGestureOption> panGestureOption = AceType::MakeRefPtr<PanGestureOption>();
1538     RefPtr<PanRecognizer> panRecognizerPtr = AceType::MakeRefPtr<PanRecognizer>(panGestureOption);
1539     TouchEvent touchEvent;
1540     touchEvent.x = 100.0;
1541     touchEvent.y = 100.0;
1542     touchEvent.sourceType = SourceType::MOUSE;
1543 
1544     panRecognizerPtr->newDirection_.type = PanDirection::NONE;
1545     panRecognizerPtr->isAllowMouse_ = false;
1546     panRecognizerPtr->HandleTouchDownEvent(touchEvent);
1547     EXPECT_EQ(panRecognizerPtr->globalPoint_.GetX(), 0);
1548 }
1549 
1550 /**
1551  * @tc.name: PanRecognizerHandleTouchDownEventTest005
1552  * @tc.desc: Test PanRecognizer function: HandleTouchDownEvent
1553  * @tc.type: FUNC
1554  */
1555 HWTEST_F(PanRecognizerTestNg, PanRecognizerHandleTouchDownEventTest005, TestSize.Level1)
1556 {
1557     /**
1558      * @tc.steps: step1. create PanRecognizer.
1559      */
1560     RefPtr<PanGestureOption> panGestureOption = AceType::MakeRefPtr<PanGestureOption>();
1561     RefPtr<PanRecognizer> panRecognizerPtr = AceType::MakeRefPtr<PanRecognizer>(panGestureOption);
1562     TouchEvent touchEvent;
1563     touchEvent.x = 100.0;
1564     touchEvent.y = 100.0;
1565     touchEvent.sourceType = SourceType::MOUSE;
1566     AxisEvent axisEvent;
1567 
1568     panRecognizerPtr->newDirection_.type = PanDirection::NONE;
1569     panRecognizerPtr->newFingers_ = 1;
1570     panRecognizerPtr->isAllowMouse_ = false;
1571     panRecognizerPtr->HandleTouchDownEvent(axisEvent);
1572     EXPECT_EQ(panRecognizerPtr->globalPoint_.GetX(), 0);
1573 
1574     panRecognizerPtr->newDirection_.type = PanDirection::NONE;
1575     panRecognizerPtr->newFingers_ = FINGER_NUMBER;
1576     panRecognizerPtr->isAllowMouse_ = false;
1577     panRecognizerPtr->HandleTouchDownEvent(axisEvent);
1578     EXPECT_EQ(panRecognizerPtr->globalPoint_.GetX(), 0);
1579 }
1580 
1581 /**
1582  * @tc.name: PanRecognizerHandleTouchMoveEventTest005
1583  * @tc.desc: Test PanRecognizer function: HandleTouchMoveEvent
1584  * @tc.type: FUNC
1585  */
1586 HWTEST_F(PanRecognizerTestNg, PanRecognizerHandleTouchMoveEventTest005, TestSize.Level1)
1587 {
1588     /**
1589      * @tc.steps: step1. create PanRecognizer.
1590      */
1591     RefPtr<PanGestureOption> panGestureOption = AceType::MakeRefPtr<PanGestureOption>();
1592     RefPtr<PanRecognizer> panRecognizerPtr = AceType::MakeRefPtr<PanRecognizer>(panGestureOption);
1593     TouchEvent touchEvent;
1594     touchEvent.x = 100.0;
1595     touchEvent.y = 100.0;
1596     touchEvent.sourceType = SourceType::MOUSE;
1597 
1598     panRecognizerPtr->fingers_ = 11;
1599     panRecognizerPtr->currentFingers_ = panRecognizerPtr->fingers_;
1600     panRecognizerPtr->refereeState_ = RefereeState::DETECTING;
1601     panRecognizerPtr->HandleTouchMoveEvent(touchEvent);
1602     EXPECT_EQ(panRecognizerPtr->globalPoint_.GetX(), 0);
1603 
1604     panRecognizerPtr->fingers_ = 0;
1605     panRecognizerPtr->currentFingers_ = panRecognizerPtr->fingers_;
1606     panRecognizerPtr->refereeState_ = RefereeState::DETECTING;
1607     panRecognizerPtr->HandleTouchMoveEvent(touchEvent);
1608     EXPECT_EQ(panRecognizerPtr->globalPoint_.GetX(), touchEvent.x);
1609 }
1610 
1611 /**
1612  * @tc.name: PanRecognizerHandleTouchMoveEventTest006
1613  * @tc.desc: Test PanRecognizer function: HandleTouchMoveEvent
1614  * @tc.type: FUNC
1615  */
1616 HWTEST_F(PanRecognizerTestNg, PanRecognizerHandleTouchMoveEventTest006, TestSize.Level1)
1617 {
1618     /**
1619      * @tc.steps: step1. create PanRecognizer.
1620      */
1621     APIVersionGuard aPIVersionGuard(static_cast<int32_t>(PlatformVersion::VERSION_TWENTY));
1622     ASSERT_EQ(static_cast<int32_t>(PlatformVersion::VERSION_TWENTY),
1623         AceApplicationInfo::GetInstance().GetApiTargetVersion());
1624     RefPtr<PanGestureOption> panGestureOption = AceType::MakeRefPtr<PanGestureOption>();
1625     RefPtr<PanRecognizer> panRecognizer = AceType::MakeRefPtr<PanRecognizer>(panGestureOption);
1626     TouchEvent touchEvent;
1627     touchEvent.x = 100.0;
1628     touchEvent.y = 100.0;
1629 
1630     /**
1631      * @tc.steps: step2. case1: PanDirection::ALL, fabs(offset) >= distance_.
1632      * @tc.expected: step2. return ACCEPT.
1633      */
1634     PanRecognizer::GestureAcceptResult result;
1635     panRecognizer->currentFingers_ = panRecognizer->fingers_;
1636     panRecognizer->refereeState_ = RefereeState::DETECTING;
1637     panRecognizer->direction_.type = PanDirection::ALL;
1638     panRecognizer->distanceMap_[SourceTool::UNKNOWN] = Dimension(0, DimensionUnit::PX);
1639     result = panRecognizer->IsPanGestureAccept();
1640     panRecognizer->HandleTouchMoveEvent(touchEvent);
1641     EXPECT_EQ(result, PanRecognizer::GestureAcceptResult::ACCEPT);
1642 
1643     /**
1644      * @tc.steps: step2. case2: PanDirection::ALL, fabs(offset) < distance_.
1645      * @tc.expected: step2. return DETECTING.
1646      */
1647     panRecognizer->direction_.type = PanDirection::ALL;
1648     panRecognizer->distanceMap_[SourceTool::UNKNOWN] = Dimension(1, DimensionUnit::PX);
1649     result = panRecognizer->IsPanGestureAccept();
1650     panRecognizer->HandleTouchMoveEvent(touchEvent);
1651     EXPECT_EQ(result, PanRecognizer::GestureAcceptResult::DETECTING);
1652 
1653     /**
1654      * @tc.steps: step2. case3: GetX > GetY, GetX < distance, PanDirection::HORIZONTAL.
1655      * @tc.expected: step2. return DETECTING.
1656      */
1657     panRecognizer->direction_.type = PanDirection::HORIZONTAL;
1658     panRecognizer->averageDistance_ = Offset(0, -1);
1659     panRecognizer->distanceMap_[SourceTool::UNKNOWN] = Dimension(1, DimensionUnit::PX);
1660     result = panRecognizer->IsPanGestureAccept();
1661     panRecognizer->HandleTouchMoveEvent(touchEvent);
1662     EXPECT_EQ(result, PanRecognizer::GestureAcceptResult::DETECTING);
1663 
1664     /**
1665      * @tc.steps: step2. case4: GetX > GetY, GetX > 0, GetX > distance_, PanDirection::LEFT.
1666      * @tc.expected: step2. return REJECT.
1667      */
1668     panRecognizer->direction_.type = PanDirection::LEFT;
1669     panRecognizer->averageDistance_ = Offset(1, 0);
1670     panRecognizer->distanceMap_[SourceTool::UNKNOWN] = Dimension(0, DimensionUnit::PX);
1671     result = panRecognizer->IsPanGestureAccept();
1672     panRecognizer->HandleTouchMoveEvent(touchEvent);
1673     EXPECT_EQ(result, PanRecognizer::GestureAcceptResult::ACCEPT);
1674 
1675     /**
1676      * @tc.steps: step2. case5: GetX > GetY, GetX > 0, GetX > distance_, PanDirection::VERTICAL.
1677      * @tc.expected: step2. return REJECT.
1678      */
1679     panRecognizer->direction_.type = PanDirection::VERTICAL;
1680     panRecognizer->averageDistance_ = Offset(1, 0);
1681     panRecognizer->distanceMap_[SourceTool::UNKNOWN] = Dimension(0, DimensionUnit::PX);
1682     result = panRecognizer->IsPanGestureAccept();
1683     panRecognizer->HandleTouchMoveEvent(touchEvent);
1684     EXPECT_EQ(result, PanRecognizer::GestureAcceptResult::ACCEPT);
1685 
1686     /**
1687      * @tc.steps: step2. case6: GetX > GetY, GetX = distance_ = 0, PanDirection::VERTICAL.
1688      * @tc.expected: step2. return ACCEPT.
1689      */
1690     panRecognizer->direction_.type = PanDirection::VERTICAL;
1691     panRecognizer->averageDistance_ = Offset(0, -1);
1692     panRecognizer->distanceMap_[SourceTool::UNKNOWN] = Dimension(0, DimensionUnit::PX);
1693     result = panRecognizer->IsPanGestureAccept();
1694     panRecognizer->HandleTouchMoveEvent(touchEvent);
1695     EXPECT_EQ(result, PanRecognizer::GestureAcceptResult::ACCEPT);
1696 }
1697 
1698 /**
1699  * @tc.name: PanRecognizerHandleTouchMoveEventTest007
1700  * @tc.desc: Test PanRecognizer function: HandleTouchMoveEvent
1701  * @tc.type: FUNC
1702  */
1703 HWTEST_F(PanRecognizerTestNg, PanRecognizerHandleTouchMoveEventTest007, TestSize.Level1)
1704 {
1705     /**
1706      * @tc.steps: step1. create PanRecognizer.
1707      */
1708     RefPtr<PanGestureOption> panGestureOption = AceType::MakeRefPtr<PanGestureOption>();
1709     RefPtr<PanRecognizer> panRecognizer = AceType::MakeRefPtr<PanRecognizer>(panGestureOption);
1710     TouchEvent touchEvent;
1711 
1712     /**
1713      * @tc.steps: step2. case1: PanDirection::ALL, fabs(offset) >= distance_.
1714      * @tc.expected: step2. return ACCEPT.
1715      */
1716     PanRecognizer::GestureAcceptResult result;
1717     panRecognizer->direction_.type = PanDirection::ALL;
1718     panRecognizer->distanceMap_[SourceTool::UNKNOWN] = Dimension(0, DimensionUnit::PX);
1719     result = panRecognizer->IsPanGestureAccept();
1720     panRecognizer->currentFingers_ = panRecognizer->fingers_;
1721     panRecognizer->refereeState_ = RefereeState::DETECTING;
1722     panRecognizer->HandleTouchMoveEvent(touchEvent);
1723     panRecognizer->direction_.type = PanDirection::ALL;
1724     panRecognizer->distanceMap_[SourceTool::UNKNOWN] = Dimension(1, DimensionUnit::PX);
1725     result = panRecognizer->IsPanGestureAccept();
1726     panRecognizer->currentFingers_ = panRecognizer->fingers_;
1727     panRecognizer->refereeState_ = RefereeState::DETECTING;
1728     panRecognizer->HandleTouchMoveEvent(touchEvent);
1729     EXPECT_EQ(result, PanRecognizer::GestureAcceptResult::DETECTING);
1730 
1731     /**
1732      * @tc.steps: step2. case3: GetX > GetY, GetX < distance, PanDirection::HORIZONTAL.
1733      * @tc.expected: step2. return ACCEPT.
1734      */
1735     panRecognizer->direction_.type = PanDirection::HORIZONTAL;
1736     panRecognizer->averageDistance_ = Offset(0, -1);
1737     panRecognizer->distanceMap_[SourceTool::UNKNOWN] = Dimension(1, DimensionUnit::PX);
1738     result = panRecognizer->IsPanGestureAccept();
1739     panRecognizer->currentFingers_ = panRecognizer->fingers_;
1740     panRecognizer->refereeState_ = RefereeState::DETECTING;
1741     panRecognizer->HandleTouchMoveEvent(touchEvent);
1742     panRecognizer->direction_.type = PanDirection::LEFT;
1743     panRecognizer->averageDistance_ = Offset(1, 0);
1744     panRecognizer->distanceMap_[SourceTool::UNKNOWN] = Dimension(0, DimensionUnit::PX);
1745     result = panRecognizer->IsPanGestureAccept();
1746     panRecognizer->currentFingers_ = panRecognizer->fingers_;
1747     panRecognizer->refereeState_ = RefereeState::DETECTING;
1748     panRecognizer->HandleTouchMoveEvent(touchEvent);
1749     EXPECT_EQ(result, PanRecognizer::GestureAcceptResult::ACCEPT);
1750 
1751     /**
1752      * @tc.steps: step2. case5: GetX > GetY, GetX > 0, GetX > distance_, PanDirection::VERTICAL.
1753      * @tc.expected: step2. return REJECT.
1754      */
1755     panRecognizer->direction_.type = PanDirection::VERTICAL;
1756     panRecognizer->averageDistance_ = Offset(1, 0);
1757     panRecognizer->distanceMap_[SourceTool::UNKNOWN] = Dimension(0, DimensionUnit::PX);
1758     result = panRecognizer->IsPanGestureAccept();
1759     panRecognizer->currentFingers_ = panRecognizer->fingers_;
1760     panRecognizer->refereeState_ = RefereeState::DETECTING;
1761     panRecognizer->HandleTouchMoveEvent(touchEvent);
1762     panRecognizer->direction_.type = PanDirection::VERTICAL;
1763     panRecognizer->averageDistance_ = Offset(0, -1);
1764     panRecognizer->distanceMap_[SourceTool::UNKNOWN] = Dimension(0, DimensionUnit::PX);
1765     result = panRecognizer->IsPanGestureAccept();
1766     panRecognizer->currentFingers_ = panRecognizer->fingers_;
1767     panRecognizer->refereeState_ = RefereeState::DETECTING;
1768     panRecognizer->HandleTouchMoveEvent(touchEvent);
1769     EXPECT_EQ(result, PanRecognizer::GestureAcceptResult::ACCEPT);
1770 }
1771 
1772 /**
1773  * @tc.name: PanRecognizerHandleTouchMoveEventTest008
1774  * @tc.desc: Test PanRecognizer function: HandleTouchMoveEvent
1775  * @tc.type: FUNC
1776  */
1777 HWTEST_F(PanRecognizerTestNg, PanRecognizerHandleTouchMoveEventTest008, TestSize.Level1)
1778 {
1779     /**
1780      * @tc.steps: step1. create PanRecognizer.
1781      */
1782     RefPtr<PanGestureOption> panGestureOption = AceType::MakeRefPtr<PanGestureOption>();
1783     RefPtr<PanRecognizer> panRecognizerPtr = AceType::MakeRefPtr<PanRecognizer>(panGestureOption);
1784     AxisEvent axisEvent;
1785 
1786     panRecognizerPtr->fingers_ = 11;
1787     panRecognizerPtr->currentFingers_ = panRecognizerPtr->fingers_;
1788     panRecognizerPtr->refereeState_ = RefereeState::DETECTING;
1789     panRecognizerPtr->HandleTouchMoveEvent(axisEvent);
1790     EXPECT_EQ(panRecognizerPtr->globalPoint_.GetX(), 0);
1791 
1792     panRecognizerPtr->fingers_ = 0;
1793     panRecognizerPtr->currentFingers_ = panRecognizerPtr->fingers_;
1794     panRecognizerPtr->refereeState_ = RefereeState::DETECTING;
1795     panRecognizerPtr->HandleTouchMoveEvent(axisEvent);
1796     EXPECT_EQ(panRecognizerPtr->globalPoint_.GetX(), 0);
1797 }
1798 
1799 /**
1800  * @tc.name: PanRecognizerHandleTouchMoveEventTest009
1801  * @tc.desc: Test PanRecognizer function: HandleTouchMoveEvent
1802  * @tc.type: FUNC
1803  */
1804 HWTEST_F(PanRecognizerTestNg, PanRecognizerHandleTouchMoveEventTest009, TestSize.Level1)
1805 {
1806     /**
1807      * @tc.steps: step1. create PanRecognizer.
1808      */
1809     APIVersionGuard aPIVersionGuard(static_cast<int32_t>(PlatformVersion::VERSION_TWENTY));
1810     ASSERT_EQ(static_cast<int32_t>(PlatformVersion::VERSION_TWENTY),
1811         AceApplicationInfo::GetInstance().GetApiTargetVersion());
1812     RefPtr<PanGestureOption> panGestureOption = AceType::MakeRefPtr<PanGestureOption>();
1813     RefPtr<PanRecognizer> panRecognizer = AceType::MakeRefPtr<PanRecognizer>(panGestureOption);
1814     AxisEvent axisEvent;
1815 
1816     /**
1817      * @tc.steps: step2. case1: PanDirection::ALL, fabs(offset) >= distance_.
1818      * @tc.expected: step2. return ACCEPT.
1819      */
1820     PanRecognizer::GestureAcceptResult result;
1821     panRecognizer->currentFingers_ = panRecognizer->fingers_;
1822     panRecognizer->refereeState_ = RefereeState::DETECTING;
1823     panRecognizer->direction_.type = PanDirection::ALL;
1824     panRecognizer->distanceMap_[SourceTool::UNKNOWN] = Dimension(0, DimensionUnit::PX);
1825     result = panRecognizer->IsPanGestureAccept();
1826     panRecognizer->HandleTouchMoveEvent(axisEvent);
1827     EXPECT_EQ(result, PanRecognizer::GestureAcceptResult::ACCEPT);
1828 
1829     /**
1830      * @tc.steps: step2. case2: PanDirection::ALL, fabs(offset) < distance_.
1831      * @tc.expected: step2. return DETECTING.
1832      */
1833     panRecognizer->direction_.type = PanDirection::ALL;
1834     panRecognizer->distanceMap_[SourceTool::UNKNOWN] = Dimension(1, DimensionUnit::PX);
1835     result = panRecognizer->IsPanGestureAccept();
1836     panRecognizer->HandleTouchMoveEvent(axisEvent);
1837     EXPECT_EQ(result, PanRecognizer::GestureAcceptResult::DETECTING);
1838 
1839     /**
1840      * @tc.steps: step2. case3: GetX > GetY, GetX < distance, PanDirection::HORIZONTAL.
1841      * @tc.expected: step2. return DETECTING.
1842      */
1843     panRecognizer->direction_.type = PanDirection::HORIZONTAL;
1844     panRecognizer->averageDistance_ = Offset(0, -1);
1845     panRecognizer->distanceMap_[SourceTool::UNKNOWN] = Dimension(1, DimensionUnit::PX);
1846     result = panRecognizer->IsPanGestureAccept();
1847     panRecognizer->HandleTouchMoveEvent(axisEvent);
1848     EXPECT_EQ(result, PanRecognizer::GestureAcceptResult::DETECTING);
1849 
1850     /**
1851      * @tc.steps: step2. case4: GetX > GetY, GetX > 0, GetX > distance_, PanDirection::LEFT.
1852      * @tc.expected: step2. return REJECT.
1853      */
1854     panRecognizer->direction_.type = PanDirection::LEFT;
1855     panRecognizer->averageDistance_ = Offset(1, 0);
1856     panRecognizer->distanceMap_[SourceTool::UNKNOWN] = Dimension(0, DimensionUnit::PX);
1857     result = panRecognizer->IsPanGestureAccept();
1858     panRecognizer->HandleTouchMoveEvent(axisEvent);
1859     EXPECT_EQ(result, PanRecognizer::GestureAcceptResult::ACCEPT);
1860 
1861     /**
1862      * @tc.steps: step2. case5: GetX > GetY, GetX > 0, GetX > distance_, PanDirection::VERTICAL.
1863      * @tc.expected: step2. return REJECT.
1864      */
1865     panRecognizer->direction_.type = PanDirection::VERTICAL;
1866     panRecognizer->averageDistance_ = Offset(1, 0);
1867     panRecognizer->distanceMap_[SourceTool::UNKNOWN] = Dimension(0, DimensionUnit::PX);
1868     result = panRecognizer->IsPanGestureAccept();
1869     panRecognizer->HandleTouchMoveEvent(axisEvent);
1870     EXPECT_EQ(result, PanRecognizer::GestureAcceptResult::ACCEPT);
1871 
1872     /**
1873      * @tc.steps: step2. case6: GetX > GetY, GetX = distance_ = 0, PanDirection::VERTICAL.
1874      * @tc.expected: step2. return ACCEPT.
1875      */
1876     panRecognizer->direction_.type = PanDirection::VERTICAL;
1877     panRecognizer->averageDistance_ = Offset(0, -1);
1878     panRecognizer->distanceMap_[SourceTool::UNKNOWN] = Dimension(0, DimensionUnit::PX);
1879     result = panRecognizer->IsPanGestureAccept();
1880     panRecognizer->HandleTouchMoveEvent(axisEvent);
1881     EXPECT_EQ(result, PanRecognizer::GestureAcceptResult::ACCEPT);
1882 }
1883 
1884 /**
1885  * @tc.name: PanRecognizerHandleTouchMoveEventTest010
1886  * @tc.desc: Test PanRecognizer function: HandleTouchMoveEvent
1887  * @tc.type: FUNC
1888  */
1889 HWTEST_F(PanRecognizerTestNg, PanRecognizerHandleTouchMoveEventTest010, TestSize.Level1)
1890 {
1891     /**
1892      * @tc.steps: step1. create PanRecognizer.
1893      */
1894     RefPtr<PanGestureOption> panGestureOption = AceType::MakeRefPtr<PanGestureOption>();
1895     RefPtr<PanRecognizer> panRecognizer = AceType::MakeRefPtr<PanRecognizer>(panGestureOption);
1896     AxisEvent axisEvent;
1897 
1898     /**
1899      * @tc.steps: step2. case1: PanDirection::ALL, fabs(offset) >= distance_.
1900      * @tc.expected: step2. return ACCEPT.
1901      */
1902     PanRecognizer::GestureAcceptResult result;
1903     panRecognizer->direction_.type = PanDirection::ALL;
1904     panRecognizer->distanceMap_[SourceTool::UNKNOWN] = Dimension(0, DimensionUnit::PX);
1905     result = panRecognizer->IsPanGestureAccept();
1906     panRecognizer->currentFingers_ = panRecognizer->fingers_;
1907     panRecognizer->refereeState_ = RefereeState::DETECTING;
1908     panRecognizer->HandleTouchMoveEvent(axisEvent);
1909     panRecognizer->direction_.type = PanDirection::ALL;
1910     panRecognizer->distanceMap_[SourceTool::UNKNOWN] = Dimension(1, DimensionUnit::PX);
1911     result = panRecognizer->IsPanGestureAccept();
1912     panRecognizer->currentFingers_ = panRecognizer->fingers_;
1913     panRecognizer->refereeState_ = RefereeState::DETECTING;
1914     panRecognizer->HandleTouchMoveEvent(axisEvent);
1915     EXPECT_EQ(result, PanRecognizer::GestureAcceptResult::DETECTING);
1916 
1917     /**
1918      * @tc.steps: step2. case3: GetX > GetY, GetX < distance, PanDirection::HORIZONTAL.
1919      * @tc.expected: step2. return ACCEPT.
1920      */
1921     panRecognizer->direction_.type = PanDirection::HORIZONTAL;
1922     panRecognizer->averageDistance_ = Offset(0, -1);
1923     panRecognizer->distanceMap_[SourceTool::UNKNOWN] = Dimension(1, DimensionUnit::PX);
1924     result = panRecognizer->IsPanGestureAccept();
1925     panRecognizer->currentFingers_ = panRecognizer->fingers_;
1926     panRecognizer->refereeState_ = RefereeState::DETECTING;
1927     panRecognizer->HandleTouchMoveEvent(axisEvent);
1928     panRecognizer->direction_.type = PanDirection::LEFT;
1929     panRecognizer->averageDistance_ = Offset(1, 0);
1930     panRecognizer->distanceMap_[SourceTool::UNKNOWN] = Dimension(0, DimensionUnit::PX);
1931     result = panRecognizer->IsPanGestureAccept();
1932     panRecognizer->currentFingers_ = panRecognizer->fingers_;
1933     panRecognizer->refereeState_ = RefereeState::DETECTING;
1934     panRecognizer->HandleTouchMoveEvent(axisEvent);
1935     EXPECT_EQ(result, PanRecognizer::GestureAcceptResult::ACCEPT);
1936 
1937     /**
1938      * @tc.steps: step2. case5: GetX > GetY, GetX > 0, GetX > distance_, PanDirection::VERTICAL.
1939      * @tc.expected: step2. return REJECT.
1940      */
1941     panRecognizer->direction_.type = PanDirection::VERTICAL;
1942     panRecognizer->averageDistance_ = Offset(1, 0);
1943     panRecognizer->distanceMap_[SourceTool::UNKNOWN] = Dimension(0, DimensionUnit::PX);
1944     result = panRecognizer->IsPanGestureAccept();
1945     panRecognizer->currentFingers_ = panRecognizer->fingers_;
1946     panRecognizer->refereeState_ = RefereeState::DETECTING;
1947     panRecognizer->HandleTouchMoveEvent(axisEvent);
1948     panRecognizer->direction_.type = PanDirection::VERTICAL;
1949     panRecognizer->averageDistance_ = Offset(0, -1);
1950     panRecognizer->distanceMap_[SourceTool::UNKNOWN] = Dimension(0, DimensionUnit::PX);
1951     result = panRecognizer->IsPanGestureAccept();
1952     panRecognizer->currentFingers_ = panRecognizer->fingers_;
1953     panRecognizer->refereeState_ = RefereeState::DETECTING;
1954     panRecognizer->HandleTouchMoveEvent(axisEvent);
1955     EXPECT_EQ(result, PanRecognizer::GestureAcceptResult::ACCEPT);
1956 }
1957 
1958 /**
1959  * @tc.name: PanRecognizerHandleTouchMoveEventTest011
1960  * @tc.desc: Test PanRecognizer function: HandleTouchMoveEvent
1961  * @tc.type: FUNC
1962  */
1963 HWTEST_F(PanRecognizerTestNg, PanRecognizerHandleTouchMoveEventTest011, TestSize.Level1)
1964 {
1965     /**
1966      * @tc.steps: step1. create PanRecognizer.
1967      */
1968     APIVersionGuard aPIVersionGuard(static_cast<int32_t>(PlatformVersion::VERSION_FOURTEEN));
1969     ASSERT_EQ(static_cast<int32_t>(PlatformVersion::VERSION_FOURTEEN),
1970         AceApplicationInfo::GetInstance().GetApiTargetVersion());
1971     RefPtr<PanGestureOption> panGestureOption = AceType::MakeRefPtr<PanGestureOption>();
1972     RefPtr<PanRecognizer> panRecognizer = AceType::MakeRefPtr<PanRecognizer>(panGestureOption);
1973     AxisEvent axisEvent;
1974     TouchEvent touchEvent;
1975     touchEvent.x = 100.0;
1976     touchEvent.y = 100.0;
1977     PanRecognizer::GestureAcceptResult result;
1978 
1979     /**
1980      * @tc.steps: step2. case1: GetX > GetY, GetX > 0, GetX > distance_, PanDirection::LEFT.
1981      * @tc.expected: step2. return ACCEPT.
1982      */
1983     panRecognizer->direction_.type = PanDirection::LEFT;
1984     panRecognizer->averageDistance_ = Offset(1, 0);
1985     panRecognizer->distanceMap_[SourceTool::UNKNOWN] = Dimension(0, DimensionUnit::PX);
1986     result = panRecognizer->IsPanGestureAccept();
1987     EXPECT_EQ(result, PanRecognizer::GestureAcceptResult::ACCEPT);
1988 
1989     /**
1990      * @tc.steps: step2. case2: GetX > GetY, GetX > 0, GetX > distance_, PanDirection::VERTICAL.
1991      * @tc.expected: step2. return ACCEPT.
1992      */
1993     panRecognizer->direction_.type = PanDirection::VERTICAL;
1994     panRecognizer->averageDistance_ = Offset(1, 0);
1995     panRecognizer->distanceMap_[SourceTool::UNKNOWN] = Dimension(0, DimensionUnit::PX);
1996     result = panRecognizer->IsPanGestureAccept();
1997     EXPECT_EQ(result, PanRecognizer::GestureAcceptResult::ACCEPT);
1998 
1999     /**
2000      * @tc.steps: step2. case3: GetX > GetY, GetX > 0, GetX > distance_, PanDirection::LEFT.
2001      * @tc.expected: step2. return ACCEPT.
2002      */
2003     panRecognizer->direction_.type = PanDirection::LEFT;
2004     panRecognizer->averageDistance_ = Offset(1, 0);
2005     panRecognizer->distanceMap_[SourceTool::UNKNOWN] = Dimension(0, DimensionUnit::PX);
2006     result = panRecognizer->IsPanGestureAccept();
2007     panRecognizer->HandleTouchMoveEvent(touchEvent);
2008     EXPECT_EQ(result, PanRecognizer::GestureAcceptResult::ACCEPT);
2009 
2010     /**
2011      * @tc.steps: step2. case4: GetX > GetY, GetX > 0, GetX > distance_, PanDirection::VERTICAL.
2012      * @tc.expected: step2. return ACCEPT.
2013      */
2014     panRecognizer->direction_.type = PanDirection::VERTICAL;
2015     panRecognizer->averageDistance_ = Offset(1, 0);
2016     panRecognizer->distanceMap_[SourceTool::UNKNOWN] = Dimension(0, DimensionUnit::PX);
2017     result = panRecognizer->IsPanGestureAccept();
2018     panRecognizer->HandleTouchMoveEvent(touchEvent);
2019     EXPECT_EQ(result, PanRecognizer::GestureAcceptResult::ACCEPT);
2020 
2021     /**
2022      * @tc.steps: step2. case5: GetX > GetY, GetX > 0, GetX > distance_, PanDirection::LEFT.
2023      * @tc.expected: step2. return ACCEPT.
2024      */
2025     panRecognizer->direction_.type = PanDirection::LEFT;
2026     panRecognizer->averageDistance_ = Offset(1, 0);
2027     panRecognizer->distanceMap_[SourceTool::UNKNOWN] = Dimension(0, DimensionUnit::PX);
2028     result = panRecognizer->IsPanGestureAccept();
2029     panRecognizer->HandleTouchMoveEvent(axisEvent);
2030     EXPECT_EQ(result, PanRecognizer::GestureAcceptResult::ACCEPT);
2031 
2032     /**
2033      * @tc.steps: step2. case6: GetX > GetY, GetX > 0, GetX > distance_, PanDirection::VERTICAL.
2034      * @tc.expected: step2. return ACCEPT.
2035      */
2036     panRecognizer->direction_.type = PanDirection::VERTICAL;
2037     panRecognizer->averageDistance_ = Offset(1, 0);
2038     panRecognizer->distanceMap_[SourceTool::UNKNOWN] = Dimension(0, DimensionUnit::PX);
2039     result = panRecognizer->IsPanGestureAccept();
2040     panRecognizer->HandleTouchMoveEvent(axisEvent);
2041     EXPECT_EQ(result, PanRecognizer::GestureAcceptResult::ACCEPT);
2042 }
2043 
2044 /**
2045  * @tc.name: PanRecognizerHandleTouchUpEvent002
2046  * @tc.desc: Test HandleTouchUpEvent in PanRecognizer
2047  */
2048 HWTEST_F(PanRecognizerTestNg, PanRecognizerHandleTouchUpEvent002, TestSize.Level1)
2049 {
2050     /**
2051      * @tc.steps: step1. create PanRecognizer.
2052      */
2053     RefPtr<PanGestureOption> panGestureOption = AceType::MakeRefPtr<PanGestureOption>();
2054     RefPtr<PanRecognizer> panRecognizerPtr = AceType::MakeRefPtr<PanRecognizer>(panGestureOption);
2055     TouchEvent touchEvent;
2056 
2057     panRecognizerPtr->refereeState_ = RefereeState::DETECTING;
2058     panRecognizerPtr->fingers_ = 0;
2059     panRecognizerPtr->isForDrag_ = true;
2060     panRecognizerPtr->currentFingers_ = panRecognizerPtr->fingers_;
2061     panRecognizerPtr->HandleTouchUpEvent(touchEvent);
2062     EXPECT_EQ(panRecognizerPtr->refereeState_, RefereeState::FAIL);
2063 
2064     panRecognizerPtr->refereeState_ = RefereeState::DETECTING;
2065     panRecognizerPtr->fingers_ = 0;
2066     panRecognizerPtr->isForDrag_ = false;
2067     panRecognizerPtr->currentFingers_ = panRecognizerPtr->fingers_;
2068     panRecognizerPtr->HandleTouchUpEvent(touchEvent);
2069     EXPECT_EQ(panRecognizerPtr->refereeState_, RefereeState::FAIL);
2070 }
2071 
2072 /**
2073  * @tc.name: PanRecognizerHandleTouchUpEvent005
2074  * @tc.desc: Test HandleTouchUpEvent in PanRecognizer
2075  */
2076 HWTEST_F(PanRecognizerTestNg, PanRecognizerHandleTouchUpEvent005, TestSize.Level1)
2077 {
2078     /**
2079      * @tc.steps: step1. create PanRecognizer.
2080      */
2081     RefPtr<PanGestureOption> panGestureOption = AceType::MakeRefPtr<PanGestureOption>();
2082     RefPtr<PanRecognizer> panRecognizerPtr = AceType::MakeRefPtr<PanRecognizer>(panGestureOption);
2083     AxisEvent axisEvent;
2084 
2085     panRecognizerPtr->refereeState_ = RefereeState::DETECTING;
2086     panRecognizerPtr->HandleTouchUpEvent(axisEvent);
2087     EXPECT_EQ(panRecognizerPtr->refereeState_, RefereeState::FAIL);
2088 }
2089 
2090 /**
2091  * @tc.name: SetOnActionCancelTest001
2092  * @tc.desc: Test SendCallbackMsg function in the HandleTouchCancelEvent with touch event input. The onActionCancel
2093  * function will return GestureEvent info.
2094  * @tc.type: FUNC
2095  */
2096 HWTEST_F(PanRecognizerTestNg, SetOnActionCancelTest001, TestSize.Level1)
2097 {
2098     /**
2099      * @tc.steps: step1. Create PanRecognizerTestNg.
2100      */
2101     RefPtr<PanGestureOption> panGestureOption = AceType::MakeRefPtr<PanGestureOption>();
2102     RefPtr<PanRecognizer> panRecognizer = AceType::MakeRefPtr<PanRecognizer>(panGestureOption);
2103 
2104     /**
2105      * @tc.steps: step2. Call SetOnActionCancel.
2106      * @tc.expected: panRecognizer's callback onActionCancel is not nullptr.
2107      */
2108     panRecognizer->deviceId_ = GESTURE_EVENT_PROPERTY_VALUE;
2109     double unknownPropertyValue = GESTURE_EVENT_PROPERTY_DEFAULT_VALUE;
2110     auto onActionCancel = [&unknownPropertyValue](
__anon4a7b7f5a0702( GestureEvent& info) 2111                                 GestureEvent& info) { unknownPropertyValue = info.GetDeviceId(); };
2112     panRecognizer->SetOnActionCancel(onActionCancel);
2113     EXPECT_NE(panRecognizer->onActionCancel_, nullptr);
2114 
2115     /**
2116      * @tc.steps: step3. Invoke HandleTouchCancelEvent when onActionCancel_ is not null.
2117      * @tc.expected: The functions have been executed and the unknownPropertyValue has been assigned the correct
2118      * value. panRecognizer->refereeState_ = RefereeState::READY
2119      */
2120     TouchEvent touchEvent;
2121     panRecognizer->touchPoints_[touchEvent.id] = touchEvent;
2122     panRecognizer->refereeState_ = RefereeState::SUCCEED;
2123     panRecognizer->currentFingers_ = panRecognizer->fingers_;
2124     panRecognizer->HandleTouchCancelEvent(touchEvent);
2125     EXPECT_EQ(unknownPropertyValue, GESTURE_EVENT_PROPERTY_VALUE);
2126     EXPECT_EQ(panRecognizer->refereeState_, RefereeState::READY);
2127 }
2128 
2129 /**
2130  * @tc.name: SetOnActionCancelTest002
2131  * @tc.desc: Test SendCallbackMsg function in the HandleTouchCancelEvent with axis event input. The onActionCancel
2132  * function will return GestureEvent info.
2133  * @tc.type: FUNC
2134  */
2135 HWTEST_F(PanRecognizerTestNg, SetOnActionCancelTest002, TestSize.Level1)
2136 {
2137     /**
2138      * @tc.steps: step1. Create PanRecognizerTestNg.
2139      */
2140     RefPtr<PanGestureOption> panGestureOption = AceType::MakeRefPtr<PanGestureOption>();
2141     RefPtr<PanRecognizer> panRecognizer = AceType::MakeRefPtr<PanRecognizer>(panGestureOption);
2142 
2143     /**
2144      * @tc.steps: step2. Call SetOnActionCancel.
2145      * @tc.expected: panRecognizerPtr's callback onActionCancel is not nullptr.
2146      */
2147     panRecognizer->deviceId_ = GESTURE_EVENT_PROPERTY_VALUE;
2148     double unknownPropertyValue = GESTURE_EVENT_PROPERTY_DEFAULT_VALUE;
2149     auto onActionCancel = [&unknownPropertyValue](
__anon4a7b7f5a0802( GestureEvent& info) 2150                                 GestureEvent& info) { unknownPropertyValue = info.GetDeviceId(); };
2151     panRecognizer->SetOnActionCancel(onActionCancel);
2152     EXPECT_NE(panRecognizer->onActionCancel_, nullptr);
2153 
2154     /**
2155      * @tc.steps: step3. Invoke HandleTouchCancelEvent when onActionCancel_ is not null.
2156      * @tc.expected: The functions have been executed and the unknownPropertyValue has been assigned the correct
2157      * value.
2158      */
2159     AxisEvent axisEvent;
2160     panRecognizer->refereeState_ = RefereeState::SUCCEED;
2161     panRecognizer->HandleTouchCancelEvent(axisEvent);
2162     EXPECT_EQ(unknownPropertyValue, GESTURE_EVENT_PROPERTY_VALUE);
2163 }
2164 
2165 /**
2166  * @tc.name: SetOnActionCancelTest003
2167  * @tc.desc: Test SendCallbackMsg function in the ReconcileFrom. The onActionCancel function will return
2168  * GestureEvent info.
2169  * @tc.type: FUNC
2170  */
2171 HWTEST_F(PanRecognizerTestNg, SetOnActionCancelTest003, TestSize.Level1)
2172 {
2173     /**
2174      * @tc.steps: step1. Create PanRecognizer.
2175      */
2176     RefPtr<PanGestureOption> panGestureOption = AceType::MakeRefPtr<PanGestureOption>();
2177     RefPtr<PanRecognizer> panRecognizer = AceType::MakeRefPtr<PanRecognizer>(panGestureOption);
2178     RefPtr<PanRecognizer> panRecognizerPtr = AceType::MakeRefPtr<PanRecognizer>(panGestureOption);
2179 
2180     /**
2181      * @tc.steps: step2. Call SetOnActionCancel.
2182      * @tc.expected: panRecognizer's callback onActionCancel is not nullptr.
2183      */
2184     panRecognizer->deviceId_ = GESTURE_EVENT_PROPERTY_VALUE;
2185     double unknownPropertyValue = GESTURE_EVENT_PROPERTY_DEFAULT_VALUE;
2186     auto onActionCancel = [&unknownPropertyValue](
__anon4a7b7f5a0902( GestureEvent& info) 2187                                 GestureEvent& info) { unknownPropertyValue = info.GetDeviceId(); };
2188     panRecognizer->SetOnActionCancel(onActionCancel);
2189     EXPECT_NE(panRecognizer->onActionCancel_, nullptr);
2190 
2191     /**
2192      * @tc.steps: step3. Invoke ReconcileFrom when onActionCancel_ is not null.
2193      * @tc.expected: The functions have been executed and the unknownPropertyValue has been assigned the correct
2194      * value.
2195      */
2196     TouchEvent touchEvent;
2197     panRecognizer->touchPoints_[touchEvent.id] = touchEvent;
2198     panRecognizer->fingers_ = 0;
2199     panRecognizer->refereeState_ = RefereeState::SUCCEED;
2200     auto result = panRecognizer->ReconcileFrom(panRecognizerPtr);
2201     EXPECT_EQ(unknownPropertyValue, GESTURE_EVENT_PROPERTY_VALUE);
2202     EXPECT_EQ(result, false);
2203 }
2204 
2205 /**
2206  * @tc.name: SetOnActionCancelTest004
2207  * @tc.desc: Test SendCallbackMsg function in the OnSucceedCancel. The onActionCancel function will return
2208  * GestureEvent info.
2209  * @tc.type: FUNC
2210  */
2211 HWTEST_F(PanRecognizerTestNg, SetOnActionCancelTest004, TestSize.Level1)
2212 {
2213     /**
2214      * @tc.steps: step1. Create PanRecognizer.
2215      */
2216     RefPtr<PanGestureOption> panGestureOption = AceType::MakeRefPtr<PanGestureOption>();
2217     RefPtr<PanRecognizer> panRecognizer = AceType::MakeRefPtr<PanRecognizer>(panGestureOption);
2218 
2219     /**
2220      * @tc.steps: step2. Call SetOnActionCancel.
2221      * @tc.expected: panRecognizer's callback onActionCancel is not nullptr.
2222      */
2223     panRecognizer->deviceId_ = GESTURE_EVENT_PROPERTY_VALUE;
2224     double unknownPropertyValue = GESTURE_EVENT_PROPERTY_DEFAULT_VALUE;
2225     auto onActionCancel = [&unknownPropertyValue](
__anon4a7b7f5a0a02( GestureEvent& info) 2226                                 GestureEvent& info) { unknownPropertyValue = info.GetDeviceId(); };
2227     panRecognizer->SetOnActionCancel(onActionCancel);
2228     EXPECT_NE(panRecognizer->onActionCancel_, nullptr);
2229 
2230     /**
2231      * @tc.steps: step4. Invoke OnSucceedCancel when onActionCancel_ is not null.
2232      * @tc.expected: The functions have been executed and the unknownPropertyValue has been assigned the correct
2233      * value.
2234      */
2235     panRecognizer->OnSucceedCancel();
2236     EXPECT_EQ(unknownPropertyValue, GESTURE_EVENT_PROPERTY_VALUE);
2237 }
2238 
2239 /**
2240  * @tc.name: PanGestureLimitFingerTest001
2241  * @tc.desc: Test PanGesture CreateRecognizer function
2242  */
2243 HWTEST_F(PanRecognizerTestNg, PanGestureLimitFingerTest001, TestSize.Level1)
2244 {
2245     /**
2246      * @tc.steps: step1. create PanGesture.
2247      */
2248     PanDirection panDirection;
2249     panDirection.type = PanDirection::RIGHT;
2250     auto panGesture = AceType::MakeRefPtr<PanGesture>(
2251         SINGLE_FINGER_NUMBER, panDirection, PAN_DISTANCE, IS_LIMIT_FINGER_COUNT);
2252     ASSERT_NE(panGesture, nullptr);
2253     EXPECT_EQ(panGesture->fingers_, SINGLE_FINGER_NUMBER);
2254     EXPECT_EQ(panGesture->isLimitFingerCount_, IS_LIMIT_FINGER_COUNT);
2255 
2256     /**
2257      * @tc.steps: step2. create onActionStart, onActionUpdate, onActionEnd, onActionCancel for PanRecognizer.
2258      * @tc.steps: case1: onActionId, onActionEndId, onActionCancelId not existed
2259      * @tc.expect: panRecognizer create successfully with the OnActionCall.
2260      */
2261     panGesture->priority_ = GesturePriority::Low;
2262     panGesture->gestureMask_ = GestureMask::Normal;
2263     auto panRecognizer = AceType::DynamicCast<PanRecognizer>(panGesture->CreateRecognizer());
2264     ASSERT_NE(panRecognizer, nullptr);
2265     EXPECT_EQ(panRecognizer->GetPriority(), GesturePriority::Low);
2266     EXPECT_EQ(panRecognizer->GetPriorityMask(), GestureMask::Normal);
2267     EXPECT_EQ(panRecognizer->isLimitFingerCount_, IS_LIMIT_FINGER_COUNT);
2268 
2269     /**
2270      * @tc.steps: step2. create onActionStart, onActionUpdate, onActionEnd, onActionCancel for PanRecognizer.
2271      * @tc.steps: case2: onActionId, onActionEndId, onActionCancelId not existed
2272      * @tc.expect: panRecognizer create successfully without the OnActionCall.
2273      */
2274     panGesture->priority_ = GesturePriority::Low;
2275     panGesture->gestureMask_ = GestureMask::Normal;
2276     auto panRecognizerWithoutFunc = AceType::DynamicCast<PanRecognizer>(panGesture->CreateRecognizer());
2277     ASSERT_NE(panRecognizerWithoutFunc, nullptr);
2278     EXPECT_EQ(panRecognizerWithoutFunc->GetPriority(), GesturePriority::Low);
2279     EXPECT_EQ(panRecognizerWithoutFunc->GetPriorityMask(), GestureMask::Normal);
2280     EXPECT_EQ(panRecognizerWithoutFunc->isLimitFingerCount_, IS_LIMIT_FINGER_COUNT);
2281 }
2282 
2283 /**
2284  * @tc.name: PanGestureLimitFingerTest002
2285  * @tc.desc: Test PanGesture CreateRecognizer function
2286  */
2287 HWTEST_F(PanRecognizerTestNg, PanGestureLimitFingerTest002, TestSize.Level1)
2288 {
2289     /**
2290      * @tc.steps: step1. create PanGesture.
2291      */
2292     PanDirection panDirection;
2293     panDirection.type = PanDirection::RIGHT;
2294     auto panGesture = AceType::MakeRefPtr<PanGesture>(
2295         SINGLE_FINGER_NUMBER, panDirection, PAN_DISTANCE, IS_NOT_LIMIT_FINGER_COUNT);
2296     ASSERT_NE(panGesture, nullptr);
2297     EXPECT_EQ(panGesture->fingers_, SINGLE_FINGER_NUMBER);
2298     EXPECT_EQ(panGesture->isLimitFingerCount_, IS_NOT_LIMIT_FINGER_COUNT);
2299 
2300     /**
2301      * @tc.steps: step2. create onActionStart, onActionUpdate, onActionEnd, onActionCancel for PanRecognizer.
2302      * @tc.steps: case1: onActionId, onActionEndId, onActionCancelId not existed
2303      * @tc.expect: panRecognizer create successfully with the OnActionCall.
2304      */
2305     panGesture->priority_ = GesturePriority::Low;
2306     panGesture->gestureMask_ = GestureMask::Normal;
2307     auto panRecognizer = AceType::DynamicCast<PanRecognizer>(panGesture->CreateRecognizer());
2308     ASSERT_NE(panRecognizer, nullptr);
2309     EXPECT_EQ(panRecognizer->GetPriority(), GesturePriority::Low);
2310     EXPECT_EQ(panRecognizer->GetPriorityMask(), GestureMask::Normal);
2311     EXPECT_EQ(panRecognizer->isLimitFingerCount_, IS_NOT_LIMIT_FINGER_COUNT);
2312 
2313     /**
2314      * @tc.steps: step2. create onActionStart, onActionUpdate, onActionEnd, onActionCancel for PanRecognizer.
2315      * @tc.steps: case2: onActionId, onActionEndId, onActionCancelId existed
2316      * @tc.expect: panRecognizer create successfully with the OnActionCall.
2317      */
2318     panGesture->priority_ = GesturePriority::Low;
2319     panGesture->gestureMask_ = GestureMask::Normal;
__anon4a7b7f5a0b02(GestureEvent& info) 2320     auto onActionStart = [](GestureEvent& info) { return true; };
__anon4a7b7f5a0c02(GestureEvent& info) 2321     auto onActionUpdate = [](GestureEvent& info) { return true; };
__anon4a7b7f5a0d02(GestureEvent& info) 2322     auto onActionEnd = [](GestureEvent& info) { return true; };
__anon4a7b7f5a0e02(GestureEvent& info) 2323     auto onActionCancel = [](GestureEvent& info) { return true; };
2324     panGesture->SetOnActionStartId(onActionStart);
2325     panGesture->SetOnActionUpdateId(onActionUpdate);
2326     panGesture->SetOnActionEndId(onActionEnd);
2327     panGesture->SetOnActionCancelId(onActionCancel);
2328     EXPECT_TRUE(panGesture->onActionStartId_);
2329     EXPECT_TRUE(panGesture->onActionUpdateId_);
2330     EXPECT_TRUE(panGesture->onActionEndId_);
2331     EXPECT_TRUE(panGesture->onActionCancelId_);
2332 
2333     auto panRecognizerWithFunc = AceType::DynamicCast<PanRecognizer>(panGesture->CreateRecognizer());
2334     ASSERT_NE(panRecognizerWithFunc, nullptr);
2335     EXPECT_EQ(panRecognizerWithFunc->GetPriority(), GesturePriority::Low);
2336     EXPECT_EQ(panRecognizerWithFunc->GetPriorityMask(), GestureMask::Normal);
2337     EXPECT_EQ(panRecognizerWithFunc->isLimitFingerCount_, IS_NOT_LIMIT_FINGER_COUNT);
2338 }
2339 
2340 /**
2341  * @tc.name: IsPanGestureAcceptInAllDirection001
2342  * @tc.desc: Test IsPanGestureAcceptInAllDirection function
2343  */
2344 HWTEST_F(PanRecognizerTestNg, IsPanGestureAcceptInAllDirection001, TestSize.Level1)
2345 {
2346     /**
2347      * @tc.steps: step1. Create PanRecognizer.
2348      */
2349     RefPtr<PanGestureOption> panGestureOption = AceType::MakeRefPtr<PanGestureOption>();
2350     PanRecognizer panRecognizer = PanRecognizer(panGestureOption);
2351 
2352     /**
2353      * @tc.steps: step2. set judgeDistance is 0.0 and call IsPanGestureAcceptInAllDirection function.
2354      * @tc.expect: gestureAcceptResult is equal to GestureAcceptResult::ACCEPT.
2355      */
2356     double judgeDistance = 0.0;
2357     auto gestureAcceptResult = panRecognizer.IsPanGestureAcceptInAllDirection(judgeDistance);
2358     EXPECT_EQ(gestureAcceptResult, PanRecognizer::GestureAcceptResult::ACCEPT);
2359 
2360     /**
2361      * @tc.steps: step3. set judgeDistance is 1.0 and call IsPanGestureAcceptInAllDirection function.
2362      * @tc.expect: gestureAcceptResult is equal to GestureAcceptResult::DETECTING.
2363      */
2364     judgeDistance = 1.0;
2365     gestureAcceptResult = panRecognizer.IsPanGestureAcceptInAllDirection(judgeDistance);
2366     EXPECT_EQ(gestureAcceptResult, PanRecognizer::GestureAcceptResult::DETECTING);
2367 }
2368 
2369 /**
2370  * @tc.name: PanRecognizerTest001
2371  * @tc.desc: Test OnAccepted function
2372  * @tc.type: FUNC
2373  */
2374 HWTEST_F(PanRecognizerTestNg, OnAcceptedTest001, TestSize.Level1)
2375 {
2376     /**
2377      * @tc.steps: step1. create PanRecognizer.
2378      */
2379     RefPtr<PanGestureOption> panGestureOption = AceType::MakeRefPtr<PanGestureOption>();
2380     PanRecognizer panRecognizer = PanRecognizer(panGestureOption);
2381 
2382     /**
2383      * @tc.steps: step2. call OnAccepted function and compare result.
2384      * @tc.expected: step2. result equals.
2385      */
2386     auto currentTime = GetSysTimestamp();
2387     std::chrono::nanoseconds nanoseconds(currentTime);
2388     TimeStamp time(nanoseconds);
2389     panRecognizer.firstInputTime_ = time;
2390     panRecognizer.lastTouchEvent_.time = time;
2391     panRecognizer.isTouchEventFinished_ = true;
2392     panRecognizer.SetEnabled(false);
2393     panRecognizer.OnAccepted();
2394     EXPECT_EQ(panRecognizer.refereeState_, RefereeState::SUCCEED);
2395     EXPECT_FALSE(panRecognizer.isStartTriggered_);
2396 
2397     /**
2398      * @tc.steps: step3. set lastTouchEvent_.sourceType is SourceType::TOUCH and call OnAccepted function.
2399      * @tc.expected: result equals.
2400      */
2401     panRecognizer.lastTouchEvent_.sourceType = SourceType::TOUCH;
2402     panRecognizer.OnAccepted();
2403     EXPECT_EQ(panRecognizer.refereeState_, RefereeState::SUCCEED);
2404     EXPECT_FALSE(panRecognizer.isStartTriggered_);
2405 }
2406 
2407 /**
2408  * @tc.name: HandleTouchUpEvent001
2409  * @tc.desc: Test HandleTouchUpEvent function
2410  * @tc.type: FUNC
2411  */
2412 HWTEST_F(PanRecognizerTestNg, HandleTouchUpEvent001, TestSize.Level1)
2413 {
2414     /**
2415      * @tc.steps: step1. create PanRecognizer.
2416      */
2417     RefPtr<PanGestureOption> panGestureOption = AceType::MakeRefPtr<PanGestureOption>();
2418     PanRecognizer panRecognizer = PanRecognizer(panGestureOption);
2419 
2420     /**
2421      * @tc.steps: step2. set axisEvent.isRotationEvent is true and call HandleTouchUp function.
2422      * @tc.expected: result equals.
2423      */
2424     AxisEvent axisEvent;
2425     axisEvent.isRotationEvent = true;
2426     panRecognizer.HandleTouchUpEvent(axisEvent);
2427     EXPECT_EQ(panRecognizer.globalPoint_.GetX(), axisEvent.x);
2428     EXPECT_EQ(panRecognizer.globalPoint_.GetY(), axisEvent.y);
2429 }
2430 /**
2431  * @tc.name: PanRecognizerTypeTest001
2432  * @tc.desc: Test PanRecognizerType
2433  * @tc.type: FUNC
2434  */
2435 HWTEST_F(PanRecognizerTestNg, PanRecognizerTypeTest001, TestSize.Level1)
2436 {
2437     RefPtr<PanGestureOption> panGestureOption = AceType::MakeRefPtr<PanGestureOption>();
2438     PanRecognizer panRecognizer = PanRecognizer(panGestureOption);
2439     auto frameNode = FrameNode::CreateFrameNode("myButton", 100, AceType::MakeRefPtr<Pattern>());
2440     panRecognizer.AttachFrameNode(frameNode);
2441     panRecognizer.SetRecognizerType(GestureTypeName::PAN_GESTURE);
2442     GestureEvent info;
2443     panRecognizer.HandleReports(info, GestureCallbackType::END);
2444     EXPECT_EQ(panRecognizer.GetRecognizerType(), GestureTypeName::PAN_GESTURE);
2445 }
2446 
2447 /**
2448  * @tc.name: OnResetStatus001
2449  * @tc.desc: Test OnResetStatus function
2450  * @tc.type: FUNC
2451  */
2452 HWTEST_F(PanRecognizerTestNg, OnResetStatus001, TestSize.Level1)
2453 {
2454     /**
2455       * @tc.steps: step1. create PanRecognizer.
2456       */
2457     RefPtr<PanGestureOption> panGestureOption = AceType::MakeRefPtr<PanGestureOption>();
2458     PanRecognizer panRecognizer = PanRecognizer(panGestureOption);
2459 
2460     /**
2461       * @tc.steps: step2. call OnResetStatus function.
2462       * @tc.expected: result equals.
2463       */
2464     panRecognizer.OnResetStatus();
2465     EXPECT_EQ(panRecognizer.touchPoints_.size(), 0);
2466     EXPECT_EQ(panRecognizer.isStartTriggered_, false);
2467 }
2468 
2469 /**
2470  * @tc.name: HandlePanExtAccept001
2471  * @tc.desc: Test HandlePanExtAccept function
2472  * @tc.type: FUNC
2473  */
2474 HWTEST_F(PanRecognizerTestNg, HandlePanExtAccept001, TestSize.Level1)
2475 {
2476     /**
2477       * @tc.steps: step1. create PanRecognizer.
2478       */
2479     RefPtr<PanGestureOption> panGestureOption = AceType::MakeRefPtr<PanGestureOption>();
2480     PanRecognizer panRecognizer = PanRecognizer(panGestureOption);
2481 
2482     /**
2483       * @tc.steps: step2. call HandlePanExtAccept function.
2484       * @tc.describe: set onActionExtUpdate_ to null.
2485       * @tc.expected: result equals.
2486       */
2487     uint32_t tag = 0;
2488     panRecognizer.onActionExtUpdate_ = nullptr;
2489     panRecognizer.HandlePanExtAccept();
2490 
2491     /**
2492       * @tc.steps: step3. call HandlePanExtAccept function.
2493       * @tc.describe: set onActionExtUpdate_ to custom callback.
2494       * @tc.expected: result equals.
2495       */
__anon4a7b7f5a0f02(GestureEvent& info) 2496     panRecognizer.onActionExtUpdate_ = std::make_unique<GestureEventFunc>([&tag](GestureEvent& info) {
2497         tag = 1;
2498     });
2499     panRecognizer.HandlePanExtAccept();
2500     EXPECT_NE(tag, 0);
2501 }
2502 } // namespace OHOS::Ace::NG