• 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/unittest/core/gestures/gestures_common_test_ng.h"
16 #include "ui/base/ace_type.h"
17 #include "ui/base/referenced.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 struct MockRotationRecognizerCase {
26     int32_t fingers;
27     double angle;
28     RefereeState refereeState;
29     int32_t expectedFingers;
30     double expectedAngle;
31     RefereeState expectedRefereeState;
32     std::vector<TouchEvent> inputTouchEvents;
33 };
34 class RotationRecognizerTestNg : public GesturesCommonTestNg {
35 public:
36     static void SetUpTestSuite();
37     static void TearDownTestSuite();
38 };
39 
SetUpTestSuite()40 void RotationRecognizerTestNg::SetUpTestSuite()
41 {
42     MockPipelineContext::SetUp();
43 }
44 
TearDownTestSuite()45 void RotationRecognizerTestNg::TearDownTestSuite()
46 {
47     MockPipelineContext::TearDown();
48 }
49 
50 /**
51  * @tc.name: RotationRecognizerTest001
52  * @tc.desc: Test RotationRecognizer function: OnAccepted OnRejected
53  * @tc.type: FUNC
54  */
55 HWTEST_F(RotationRecognizerTestNg, RotationRecognizerTest001, TestSize.Level1)
56 {
57     /**
58      * @tc.steps: step1. create RotationRecognizer.
59      */
60     RefPtr<RotationRecognizer> rotationRecognizer =
61         AceType::MakeRefPtr<RotationRecognizer>(SINGLE_FINGER_NUMBER, ROTATION_GESTURE_ANGLE);
62 
63     /**
64      * @tc.steps: step2. call OnAccepted function and compare result.
65      * @tc.expected: step2. result equals.
66      */
67     rotationRecognizer->OnAccepted();
68     EXPECT_EQ(rotationRecognizer->refereeState_, RefereeState::SUCCEED);
69 
70     /**
71      * @tc.steps: step3. call OnRejected function and compare result.
72      * @tc.expected: step3. result equals.
73      */
74     rotationRecognizer->OnRejected();
75     EXPECT_EQ(rotationRecognizer->refereeState_, RefereeState::SUCCEED);
76 }
77 
78 /**
79  * @tc.name: RotationRecognizerTest002
80  * @tc.desc: Test RotationRecognizer function: TouchDown TouchUp TouchMove
81  * @tc.type: FUNC
82  */
83 HWTEST_F(RotationRecognizerTestNg, RotationRecognizerTest002, TestSize.Level1)
84 {
85     /**
86      * @tc.steps: step1. create RotationRecognizer.
87      */
88     auto rotationRecognizer = AceType::MakeRefPtr<RotationRecognizer>(SINGLE_FINGER_NUMBER, ROTATION_GESTURE_ANGLE);
89 
90     /**
91      * @tc.steps: step2. call HandleTouchDownEvent function and compare result.
92      * @tc.steps: case1: touchPoints.size == fingers
93      * @tc.expected: step2. result equals.
94      */
95     TouchEvent touchEvent;
96     rotationRecognizer->HandleTouchDownEvent(touchEvent);
97     EXPECT_EQ(rotationRecognizer->touchPoints_[touchEvent.id].id, touchEvent.id);
98 
99     /**
100      * @tc.steps: step2. call HandleTouchDownEvent function and compare result.
101      * @tc.steps: case2: touchPoints.size < fingers
102      * @tc.expected: step2. result equals.
103      */
104     rotationRecognizer->fingers_ = FINGER_NUMBER;
105     rotationRecognizer->refereeState_ = RefereeState::SUCCEED;
106     rotationRecognizer->HandleTouchDownEvent(touchEvent);
107     rotationRecognizer->HandleTouchUpEvent(touchEvent);
108     rotationRecognizer->HandleTouchMoveEvent(touchEvent);
109     rotationRecognizer->HandleTouchCancelEvent(touchEvent);
110     EXPECT_EQ(rotationRecognizer->refereeState_, RefereeState::FAIL);
111     EXPECT_EQ(rotationRecognizer->resultAngle_, 0);
112 
113     /**
114      * @tc.steps: step2. call HandleTouchDownEvent function and compare result.
115      * @tc.steps: case3: touchPoints.size < fingers
116      * @tc.expected: step2. result equals.
117      */
118     rotationRecognizer->fingers_ = FINGER_NUMBER;
119     rotationRecognizer->refereeState_ = RefereeState::FAIL;
120     rotationRecognizer->HandleTouchDownEvent(touchEvent);
121     rotationRecognizer->HandleTouchUpEvent(touchEvent);
122     rotationRecognizer->HandleTouchMoveEvent(touchEvent);
123     rotationRecognizer->HandleTouchCancelEvent(touchEvent);
124     EXPECT_EQ(rotationRecognizer->refereeState_, RefereeState::FAIL);
125     EXPECT_EQ(rotationRecognizer->resultAngle_, 0);
126 }
127 
128 /**
129  * @tc.name: RotationRecognizerHandleTouchDownEventTest001
130  * @tc.desc: Test RotationRecognizer function: TouchDown TouchUp TouchMove
131  * @tc.type: FUNC
132  */
133 HWTEST_F(RotationRecognizerTestNg, RotationRecognizerHandleTouchDownEventTest001, TestSize.Level1)
134 {
135     /**
136      * @tc.steps: step1. create RotationRecognizer.
137      */
138     auto rotationRecognizer = AceType::MakeRefPtr<RotationRecognizer>(SINGLE_FINGER_NUMBER, ROTATION_GESTURE_ANGLE);
139 
140     /**
141      * @tc.steps: step2. call HandleTouchDownEvent function and compare result.
142      * @tc.steps: case1: touchPoints.size == fingers
143      * @tc.expected: step2. result equals.
144      */
145     TouchEvent touchEvent;
146     rotationRecognizer->fingers_ = FINGER_NUMBER_OVER_MAX;
147     rotationRecognizer->HandleTouchDownEvent(touchEvent);
148     EXPECT_EQ(rotationRecognizer->touchPoints_[touchEvent.id].id, touchEvent.id);
149 
150     /**
151      * @tc.steps: step2. call HandleTouchDownEvent function and compare result.
152      * @tc.steps: case2: touchPoints.size < fingers
153      * @tc.expected: step2. result equals.
154      */
155     rotationRecognizer->refereeState_ = RefereeState::SUCCEED;
156     rotationRecognizer->fingers_ = FINGER_NUMBER_OVER_MAX;
157     rotationRecognizer->HandleTouchDownEvent(touchEvent);
158     rotationRecognizer->HandleTouchUpEvent(touchEvent);
159     rotationRecognizer->HandleTouchMoveEvent(touchEvent);
160     rotationRecognizer->HandleTouchCancelEvent(touchEvent);
161     EXPECT_EQ(rotationRecognizer->refereeState_, RefereeState::FAIL);
162     EXPECT_EQ(rotationRecognizer->resultAngle_, 0);
163 
164     /**
165      * @tc.steps: step2. call HandleTouchDownEvent function and compare result.
166      * @tc.steps: case3: touchPoints.size < fingers
167      * @tc.expected: step2. result equals.
168      */
169     rotationRecognizer->refereeState_ = RefereeState::FAIL;
170     rotationRecognizer->fingers_ = FINGER_NUMBER_OVER_MAX;
171     rotationRecognizer->HandleTouchDownEvent(touchEvent);
172     rotationRecognizer->HandleTouchUpEvent(touchEvent);
173     rotationRecognizer->HandleTouchMoveEvent(touchEvent);
174     rotationRecognizer->HandleTouchCancelEvent(touchEvent);
175     EXPECT_EQ(rotationRecognizer->refereeState_, RefereeState::FAIL);
176     EXPECT_EQ(rotationRecognizer->resultAngle_, 0);
177 }
178 
179 /**
180  * @tc.name: RotationRecognizerHandleTouchDownEventTest002
181  * @tc.desc: Test RotationRecognizer function: HandleTouchDownEvent
182  * @tc.type: FUNC
183  */
184 HWTEST_F(RotationRecognizerTestNg, RotationRecognizerHandleTouchDownEventTest002, TestSize.Level1)
185 {
186     /**
187      * @tc.steps: step1. create RotationRecognizer.
188      */
189     RefPtr<RotationRecognizer> rotationRecognizer =
190         AceType::MakeRefPtr<RotationRecognizer>(SINGLE_FINGER_NUMBER, ROTATION_GESTURE_ANGLE);
191 
192     /**
193      * @tc.steps: step2. call HandleTouchDownEvent function and compare result.
194      * @tc.steps: case1: touchPoints.size == fingers
195      * @tc.expected: step2. result equals.
196      */
197     TouchEvent touchEvent;
198     rotationRecognizer->fingers_ = 0;
199     rotationRecognizer->HandleTouchDownEvent(touchEvent);
200     EXPECT_EQ(rotationRecognizer->touchPoints_[touchEvent.id].id, touchEvent.id);
201 
202     /**
203      * @tc.steps: step2. call HandleTouchDownEvent function and compare result.
204      * @tc.steps: case2: touchPoints.size < fingers
205      * @tc.expected: step2. result equals.
206      */
207     rotationRecognizer->refereeState_ = RefereeState::SUCCEED;
208     rotationRecognizer->fingers_ = 0;
209     rotationRecognizer->HandleTouchDownEvent(touchEvent);
210     EXPECT_EQ(rotationRecognizer->resultAngle_, 0);
211 
212     /**
213      * @tc.steps: step2. call HandleTouchDownEvent function and compare result.
214      * @tc.steps: case3: touchPoints.size < fingers
215      * @tc.expected: step2. result equals.
216      */
217     rotationRecognizer->refereeState_ = RefereeState::FAIL;
218     rotationRecognizer->fingers_ = 0;
219     rotationRecognizer->HandleTouchDownEvent(touchEvent);
220     EXPECT_EQ(rotationRecognizer->resultAngle_, 0);
221 }
222 
223 /**
224  * @tc.name: RotationRecognizerHandleTouchUpEventTest001
225  * @tc.desc: Test RotationRecognizer function: HandleTouchUpEvent
226  * @tc.type: FUNC
227  */
228 HWTEST_F(RotationRecognizerTestNg, RotationRecognizerHandleTouchUpEventTest001, TestSize.Level1)
229 {
230     /**
231      * @tc.steps: step1. create RotationRecognizer.
232      */
233     RefPtr<RotationRecognizer> rotationRecognizer =
234         AceType::MakeRefPtr<RotationRecognizer>(SINGLE_FINGER_NUMBER, ROTATION_GESTURE_ANGLE);
235 
236     /**
237      * @tc.steps: step2. call HandleTouchDownEvent function and compare result.
238      * @tc.steps: case1: touchPoints.size == fingers
239      * @tc.expected: step2. result equals.
240      */
241     TouchEvent touchEvent;
242 
243     /**
244      * @tc.steps: step2. call HandleTouchDownEvent function and compare result.
245      * @tc.steps: case2: touchPoints.size < fingers
246      * @tc.expected: step2. result equals.
247      */
248     rotationRecognizer->fingers_ = FINGER_NUMBER;
249     rotationRecognizer->refereeState_ = RefereeState::SUCCEED;
250     rotationRecognizer->currentFingers_ = rotationRecognizer->fingers_;
251     rotationRecognizer->HandleTouchUpEvent(touchEvent);
252     EXPECT_EQ(rotationRecognizer->refereeState_, RefereeState::SUCCEED);
253     EXPECT_EQ(rotationRecognizer->resultAngle_, 0);
254 
255     /**
256      * @tc.steps: step2. call HandleTouchDownEvent function and compare result.
257      * @tc.steps: case3: touchPoints.size < fingers
258      * @tc.expected: step2. result equals.
259      */
260     rotationRecognizer->fingers_ = FINGER_NUMBER;
261     rotationRecognizer->refereeState_ = RefereeState::FAIL;
262     rotationRecognizer->currentFingers_ = rotationRecognizer->fingers_;
263     rotationRecognizer->HandleTouchUpEvent(touchEvent);
264     EXPECT_EQ(rotationRecognizer->refereeState_, RefereeState::FAIL);
265     EXPECT_EQ(rotationRecognizer->resultAngle_, 0);
266 }
267 
268 /**
269  * @tc.name: RotationRecognizerHandleTouchMoveEventTest001
270  * @tc.desc: Test RotationRecognizer function: HandleTouchMoveEvent
271  * @tc.type: FUNC
272  */
273 HWTEST_F(RotationRecognizerTestNg, RotationRecognizerHandleTouchMoveEventTest001, TestSize.Level1)
274 {
275     /**
276      * @tc.steps: step1. create RotationRecognizer.
277      */
278     RefPtr<RotationRecognizer> rotationRecognizer =
279         AceType::MakeRefPtr<RotationRecognizer>(SINGLE_FINGER_NUMBER, ROTATION_GESTURE_ANGLE);
280 
281     /**
282      * @tc.steps: step2. call HandleTouchDownEvent function and compare result.
283      * @tc.steps: case1: touchPoints.size == fingers
284      * @tc.expected: step2. result equals.
285      */
286     TouchEvent touchEvent;
287 
288     /**
289      * @tc.steps: step2. call HandleTouchDownEvent function and compare result.
290      * @tc.steps: case2: touchPoints.size < fingers
291      * @tc.expected: step2. result equals.
292      */
293     rotationRecognizer->fingers_ = FINGER_NUMBER;
294     rotationRecognizer->refereeState_ = RefereeState::SUCCEED;
295     rotationRecognizer->currentFingers_ = rotationRecognizer->fingers_;
296     rotationRecognizer->HandleTouchMoveEvent(touchEvent);
297     EXPECT_EQ(rotationRecognizer->refereeState_, RefereeState::SUCCEED);
298     EXPECT_EQ(rotationRecognizer->resultAngle_, 0);
299 
300     /**
301      * @tc.steps: step2. call HandleTouchDownEvent function and compare result.
302      * @tc.steps: case3: touchPoints.size < fingers
303      * @tc.expected: step2. result equals.
304      */
305     rotationRecognizer->fingers_ = FINGER_NUMBER;
306     rotationRecognizer->refereeState_ = RefereeState::FAIL;
307     rotationRecognizer->currentFingers_ = rotationRecognizer->fingers_;
308     rotationRecognizer->HandleTouchMoveEvent(touchEvent);
309     EXPECT_EQ(rotationRecognizer->refereeState_, RefereeState::FAIL);
310     EXPECT_EQ(rotationRecognizer->resultAngle_, 0);
311 }
312 
313 /**
314  * @tc.name: RotationRecognizerHandleTouchMoveEventTest002
315  * @tc.desc: Test RotationRecognizer function: HandleTouchMoveEvent
316  * @tc.type: FUNC
317  */
318 HWTEST_F(RotationRecognizerTestNg, RotationRecognizerHandleTouchMoveEventTest002, TestSize.Level1)
319 {
320     /**
321      * @tc.steps: step1. create RotationRecognizer.
322      */
323     RefPtr<RotationRecognizer> rotationRecognizer =
324         AceType::MakeRefPtr<RotationRecognizer>(SINGLE_FINGER_NUMBER, ROTATION_GESTURE_ANGLE);
325 
326     /**
327      * @tc.steps: step2. call HandleTouchDownEvent function and compare result.
328      * @tc.steps: case1: touchPoints.size == fingers
329      * @tc.expected: step2. result equals.
330      */
331     TouchEvent touchEvent;
332 
333     /**
334      * @tc.steps: step2. call HandleTouchDownEvent function and compare result.
335      * @tc.steps: case2: touchPoints.size < fingers
336      * @tc.expected: step2. result equals.
337      */
338     rotationRecognizer->fingers_ = FINGER_NUMBER_OVER_MAX;
339     rotationRecognizer->refereeState_ = RefereeState::SUCCEED;
340     rotationRecognizer->currentFingers_ = rotationRecognizer->fingers_;
341     rotationRecognizer->HandleTouchMoveEvent(touchEvent);
342     EXPECT_EQ(rotationRecognizer->refereeState_, RefereeState::SUCCEED);
343     EXPECT_EQ(rotationRecognizer->resultAngle_, 0);
344 
345     /**
346      * @tc.steps: step2. call HandleTouchDownEvent function and compare result.
347      * @tc.steps: case3: touchPoints.size < fingers
348      * @tc.expected: step2. result equals.
349      */
350     rotationRecognizer->fingers_ = 0;
351     rotationRecognizer->refereeState_ = RefereeState::FAIL;
352     rotationRecognizer->currentFingers_ = rotationRecognizer->fingers_;
353     rotationRecognizer->HandleTouchMoveEvent(touchEvent);
354     EXPECT_EQ(rotationRecognizer->refereeState_, RefereeState::FAIL);
355     EXPECT_EQ(rotationRecognizer->resultAngle_, 0);
356 }
357 
358 /**
359  * @tc.name: RotationRecognizerHandleTouchMoveEventTest003
360  * @tc.desc: Test RotationRecognizer function: HandleTouchMoveEvent
361  * @tc.type: FUNC
362  */
363 HWTEST_F(RotationRecognizerTestNg, RotationRecognizerHandleTouchMoveEventTest003, TestSize.Level1)
364 {
365     /**
366      * @tc.steps: step1. create RotationRecognizer.
367      */
368     RefPtr<RotationRecognizer> rotationRecognizer =
369         AceType::MakeRefPtr<RotationRecognizer>(SINGLE_FINGER_NUMBER, ROTATION_GESTURE_ANGLE);
370 
371     /**
372      * @tc.steps: step2. call HandleTouchDownEvent function and compare result.
373      * @tc.steps: case1: touchPoints.size == fingers
374      * @tc.expected: step2. result equals.
375      */
376     TouchEvent touchEvent;
377 
378     /**
379      * @tc.steps: step2. call HandleTouchDownEvent function and compare result.
380      * @tc.steps: case2: touchPoints.size < fingers
381      * @tc.expected: step2. result equals.
382      */
383     rotationRecognizer->fingers_ = FINGER_NUMBER_OVER_MAX;
384     rotationRecognizer->refereeState_ = RefereeState::SUCCEED;
385     rotationRecognizer->currentFingers_ = rotationRecognizer->fingers_;
386     rotationRecognizer->HandleTouchMoveEvent(touchEvent);
387     EXPECT_EQ(rotationRecognizer->refereeState_, RefereeState::SUCCEED);
388     EXPECT_EQ(rotationRecognizer->resultAngle_, 0);
389 
390     /**
391      * @tc.steps: step2. call HandleTouchDownEvent function and compare result.
392      * @tc.steps: case3: touchPoints.size < fingers
393      * @tc.expected: step2. result equals.
394      */
395     rotationRecognizer->fingers_ = 0;
396     rotationRecognizer->refereeState_ = RefereeState::SUCCEED;
397     rotationRecognizer->currentFingers_ = rotationRecognizer->fingers_;
398     rotationRecognizer->HandleTouchMoveEvent(touchEvent);
399     EXPECT_EQ(rotationRecognizer->refereeState_, RefereeState::SUCCEED);
400     EXPECT_EQ(rotationRecognizer->resultAngle_, 0);
401 }
402 
403 /**
404  * @tc.name: RotationRecognizerTest003
405  * @tc.desc: Test RotationRecognizer function: ChangeValueRange
406  * @tc.type: FUNC
407  */
408 HWTEST_F(RotationRecognizerTestNg, RotationRecognizerTest003, TestSize.Level1)
409 {
410     /**
411      * @tc.steps: step1. create RotationRecognizer.
412      */
413     RefPtr<RotationRecognizer> rotationRecognizer =
414         AceType::MakeRefPtr<RotationRecognizer>(SINGLE_FINGER_NUMBER, ROTATION_GESTURE_ANGLE);
415 
416     /**
417      * @tc.steps: step2. call ChangeValueRange function and compare result.
418      * @tc.expected: step2. result equals.
419      */
420     auto result = rotationRecognizer->ChangeValueRange(COMMON_VALUE_RANGE_CASE);
421     EXPECT_EQ(result, COMMON_VALUE_RANGE_CASE);
422 
423     result = rotationRecognizer->ChangeValueRange(SPECIAL_VALUE_RANGE_CASE1);
424     EXPECT_EQ(result, SPECIAL_VALUE_RANGE_CASE1 - PI);
425 
426     result = rotationRecognizer->ChangeValueRange(SPECIAL_VALUE_RANGE_CASE2);
427     EXPECT_EQ(result, SPECIAL_VALUE_RANGE_CASE2 + PI);
428 }
429 
430 /**
431  * @tc.name: RotationRecognizerTest004
432  * @tc.desc: Test RotationRecognizer function: ComputeAngle
433  * @tc.type: FUNC
434  */
435 HWTEST_F(RotationRecognizerTestNg, RotationRecognizerTest004, TestSize.Level1)
436 {
437     /**
438      * @tc.steps: step1. create RotationRecognizer.
439      */
440     RefPtr<RotationRecognizer> rotationRecognizer =
441         AceType::MakeRefPtr<RotationRecognizer>(SINGLE_FINGER_NUMBER, ROTATION_GESTURE_ANGLE);
442 
443     /**
444      * @tc.steps: step2. call ComputeAngle function and compare result.
445      * @tc.expected: step2. result equals.
446      */
447     TouchEvent touchEventStart;
448     touchEventStart.id = 0;
449     rotationRecognizer->touchPoints_[0] = touchEventStart;
450     TouchEvent touchEventEnd;
451     touchEventEnd.id = 1;
452     rotationRecognizer->touchPoints_[1] = touchEventEnd;
453     auto result = rotationRecognizer->ComputeAngle();
454     EXPECT_EQ(result, 0);
455 }
456 
457 /**
458  * @tc.name: RotationRecognizerTest005
459  * @tc.desc: Test RotationRecognizer function: OnResetStatus
460  * @tc.type: FUNC
461  */
462 HWTEST_F(RotationRecognizerTestNg, RotationRecognizerTest005, TestSize.Level1)
463 {
464     /**
465      * @tc.steps: step1. create RotationRecognizer.
466      */
467     RefPtr<RotationRecognizer> rotationRecognizer =
468         AceType::MakeRefPtr<RotationRecognizer>(SINGLE_FINGER_NUMBER, ROTATION_GESTURE_ANGLE);
469 
470     /**
471      * @tc.steps: step2. call OnResetStatus function and compare result.
472      * @tc.expected: step2. result equals.
473      */
474     rotationRecognizer->OnResetStatus();
475     EXPECT_EQ(rotationRecognizer->initialAngle_, 0.0);
476     EXPECT_EQ(rotationRecognizer->currentAngle_, 0.0);
477     EXPECT_EQ(rotationRecognizer->resultAngle_, 0.0);
478 }
479 
480 /**
481  * @tc.name: RotationRecognizerTest006
482  * @tc.desc: Test RotationRecognizer function: SendCallbackMsg
483  * @tc.type: FUNC
484  */
485 HWTEST_F(RotationRecognizerTestNg, RotationRecognizerTest006, TestSize.Level1)
486 {
487     /**
488      * @tc.steps: step1. create RotationRecognizer.
489      */
490     RefPtr<RotationRecognizer> rotationRecognizer =
491         AceType::MakeRefPtr<RotationRecognizer>(SINGLE_FINGER_NUMBER, ROTATION_GESTURE_ANGLE);
492 
493     /**
494      * @tc.steps: step2. call SendCallbackMsg function and compare result.
495      * @tc.steps: case1: onAction is no, *onAction is no
496      * @tc.expected: step2. result equals.
497      */
498     std::unique_ptr<GestureEventFunc> onAction;
499     rotationRecognizer->SendCallbackMsg(onAction, GestureCallbackType::ACTION);
500     EXPECT_EQ(rotationRecognizer->touchPoints_.size(), 0);
501 
502     /**
503      * @tc.steps: step2. call SendCallbackMsg function and compare result.
504      * @tc.steps: case2: onAction is yes, *onAction is no
505      * @tc.expected: step2. result equals.
506      */
507     onAction = std::make_unique<GestureEventFunc>();
508     rotationRecognizer->SendCallbackMsg(onAction, GestureCallbackType::ACTION);
509     EXPECT_EQ(rotationRecognizer->touchPoints_.size(), 0);
510 
511     /**
512      * @tc.steps: step2. call SendCallbackMsg function and compare result.
513      * @tc.steps: case3: onAction is yes, *onAction is yes, touchEvent is empty
514      * @tc.expected: step2. result equals.
515      */
__anon9c07e5eb0102(GestureEvent) 516     onAction = std::make_unique<GestureEventFunc>([](GestureEvent) {});
517     rotationRecognizer->SendCallbackMsg(onAction, GestureCallbackType::ACTION);
518     EXPECT_EQ(rotationRecognizer->touchPoints_.size(), 0);
519 
520     /**
521      * @tc.steps: step2. call SendCallbackMsg function and compare result.
522      * @tc.steps: case4: touchEvent is not empty, have no X and Y
523      * @tc.expected: step2. result equals.
524      */
525     TouchEvent touchEvent;
526     rotationRecognizer->touchPoints_[touchEvent.id] = touchEvent;
527     rotationRecognizer->SendCallbackMsg(onAction, GestureCallbackType::ACTION);
528     EXPECT_EQ(rotationRecognizer->touchPoints_.size(), 1);
529 
530     /**
531      * @tc.steps: step2. call SendCallbackMsg function and compare result.
532      * @tc.steps: case4: touchEvent is not empty, have no X and Y
533      * @tc.expected: step2. result equals.
534      */
535     touchEvent.tiltX = 0.0f;
536     touchEvent.tiltY = 0.0f;
537     rotationRecognizer->touchPoints_[touchEvent.id] = touchEvent;
538     rotationRecognizer->SendCallbackMsg(onAction, GestureCallbackType::ACTION);
539     EXPECT_EQ(rotationRecognizer->touchPoints_.size(), 1);
540 }
541 
542 /**
543  * @tc.name: RotationRecognizerTest007
544  * @tc.desc: Test RotationRecognizer function: ReconcileFrom
545  * @tc.type: FUNC
546  */
547 HWTEST_F(RotationRecognizerTestNg, RotationRecognizerTest007, TestSize.Level1)
548 {
549     /**
550      * @tc.steps: step1. create ClickRecognizer.
551      */
552     RefPtr<RotationRecognizer> rotationRecognizer =
553         AceType::MakeRefPtr<RotationRecognizer>(SINGLE_FINGER_NUMBER, ROTATION_GESTURE_ANGLE);
554     RefPtr<RotationRecognizer> rotationRecognizerPtr =
555         AceType::MakeRefPtr<RotationRecognizer>(SINGLE_FINGER_NUMBER, ROTATION_GESTURE_ANGLE);
556     bool result = false;
557 
558     /**
559      * @tc.steps: step2. call ReconcileFrom function and compare result.
560      * @tc.steps: case1: recognizerPtr is nullptr
561      * @tc.expected: step2. result equals.
562      */
563     result = rotationRecognizer->ReconcileFrom(nullptr);
564     EXPECT_EQ(result, false);
565 
566     /**
567      * @tc.steps: step2. call ReconcileFrom function and compare result.
568      * @tc.steps: case2: recognizerPtr is normal, curr->fingers != fingers
569      * @tc.expected: step2. result equals.
570      */
571     rotationRecognizer->fingers_ = rotationRecognizerPtr->fingers_ + 1;
572     result = rotationRecognizer->ReconcileFrom(rotationRecognizerPtr);
573     EXPECT_EQ(result, false);
574 
575     /**
576      * @tc.steps: step2. call ReconcileFrom function and compare result.
577      * @tc.steps: case2: recognizerPtr is normal, curr->angle != angle
578      * @tc.expected: step2. result equals.
579      */
580     rotationRecognizer->fingers_ = rotationRecognizerPtr->fingers_;
581     rotationRecognizer->angle_ = rotationRecognizerPtr->angle_ + 1;
582     result = rotationRecognizer->ReconcileFrom(rotationRecognizerPtr);
583     EXPECT_EQ(result, false);
584 
585     /**
586      * @tc.steps: step2. call ReconcileFrom function and compare result.
587      * @tc.steps: case2: recognizerPtr is normal, curr->priorityMask != priorityMask
588      * @tc.expected: step2. result equals.
589      */
590     rotationRecognizer->fingers_ = rotationRecognizerPtr->fingers_;
591     rotationRecognizer->angle_ = rotationRecognizerPtr->angle_;
592     rotationRecognizer->priorityMask_ = GestureMask::Begin;
593     result = rotationRecognizer->ReconcileFrom(rotationRecognizerPtr);
594     EXPECT_EQ(result, false);
595 
596     /**
597      * @tc.steps: step2. call ReconcileFrom function and compare result.
598      * @tc.steps: case2: recognizerPtr is normal
599      * @tc.expected: step2. result equals.
600      */
601     rotationRecognizer->fingers_ = rotationRecognizerPtr->fingers_;
602     rotationRecognizer->angle_ = rotationRecognizerPtr->angle_;
603     rotationRecognizer->priorityMask_ = rotationRecognizerPtr->priorityMask_;
604     result = rotationRecognizer->ReconcileFrom(rotationRecognizerPtr);
605     EXPECT_EQ(result, true);
606 }
607 
608 /**
609  * @tc.name: RotationRecognizerTest008
610  * @tc.desc: Test RotationRecognizer function: HandleTouchDownEvent
611  * @tc.type: FUNC
612  */
613 HWTEST_F(RotationRecognizerTestNg, RotationRecognizerTest008, TestSize.Level1)
614 {
615     /**
616      * @tc.steps: step1. create rotationRecognizer->
617      */
618     auto rotationRecognizer = AceType::MakeRefPtr<RotationRecognizer>(SINGLE_FINGER_NUMBER, ROTATION_GESTURE_ANGLE);
619     ASSERT_NE(rotationRecognizer, nullptr);
620 
621     /**
622      * @tc.steps: step2. test with HandleTouchDownEvent(AxisEvent).
623      * @tc.expect: rotationRecognizer->lastAxisEvent_ is equal to axisEvent
624      * @tc.expect: rotationRecognizer->touchPoints_[axisEvent.id].originalId is equal to axisEvent.originalId
625      * @tc.expect: rotationRecognizer->touchPoints_[axisEvent.id].screenX is equal to axisEvent.screenX
626      * @tc.expect: rotationRecognizer->touchPoints_[axisEvent.id].screenY is equal to axisEvent.screenY
627      */
628     AxisEvent axisEvent;
629     axisEvent.id = TEST_EVENT_ID;
630     axisEvent.originalId = TEST_EVENT_ID;
631     axisEvent.isRotationEvent = true;
632 
633     rotationRecognizer->refereeState_ = RefereeState::SUCCEED;
634     rotationRecognizer->currentFingers_ = rotationRecognizer->fingers_;
635     rotationRecognizer->HandleTouchDownEvent(axisEvent);
636     EXPECT_EQ(rotationRecognizer->lastAxisEvent_.id, axisEvent.id);
637     EXPECT_EQ(rotationRecognizer->touchPoints_[axisEvent.id].originalId, axisEvent.originalId);
638     EXPECT_EQ(rotationRecognizer->touchPoints_[axisEvent.id].screenX, axisEvent.screenX);
639     EXPECT_EQ(rotationRecognizer->touchPoints_[axisEvent.id].screenY, axisEvent.screenY);
640 }
641 
642 /**
643  * @tc.name: RotationRecognizerTest009
644  * @tc.desc: Test RotationRecognizer function: HandleTouchUpEvent
645  * @tc.type: FUNC
646  */
647 HWTEST_F(RotationRecognizerTestNg, RotationRecognizerTest009, TestSize.Level1)
648 {
649     /**
650      * @tc.steps: step1. create rotationRecognizer->
651      */
652     auto rotationRecognizer = AceType::MakeRefPtr<RotationRecognizer>(SINGLE_FINGER_NUMBER, ROTATION_GESTURE_ANGLE);
653     ASSERT_NE(rotationRecognizer, nullptr);
654 
655     /**
656      * @tc.steps: step2. test with HandleTouchUpEvent(AxisEvent).
657      * @tc.expect: rotationRecognizer->lastAxisEvent_ is equal to axisEvent
658      */
659     AxisEvent axisEvent;
660     axisEvent.isRotationEvent = true;
661     axisEvent.id = TEST_EVENT_ID;
662     rotationRecognizer->refereeState_ = RefereeState::SUCCEED;
663     rotationRecognizer->currentFingers_ = rotationRecognizer->fingers_;
664     rotationRecognizer->HandleTouchUpEvent(axisEvent);
665     EXPECT_EQ(rotationRecognizer->lastAxisEvent_.id, axisEvent.id);
666 }
667 
668 /**
669  * @tc.name: RotationRecognizerTest010
670  * @tc.desc: Test RotationRecognizer function: HandleTouchMoveEvent
671  * @tc.type: FUNC
672  */
673 HWTEST_F(RotationRecognizerTestNg, RotationRecognizerTest010, TestSize.Level1)
674 {
675     /**
676      * @tc.steps: step1. create rotationRecognizer->
677      */
678     auto rotationRecognizer = AceType::MakeRefPtr<RotationRecognizer>(SINGLE_FINGER_NUMBER, ROTATION_GESTURE_ANGLE);
679     ASSERT_NE(rotationRecognizer, nullptr);
680 
681     /**
682      * @tc.steps: step2. test with HandleTouchMoveEvent(AxisEvent).
683      * @tc.expect: rotationRecognizer->lastAxisEvent_ is equal to axisEvent
684      * @tc.expect: rotationRecognizer->touchPoints_[axisEvent.id].originalId is equal to axisEvent.originalId
685      * @tc.expect: rotationRecognizer->touchPoints_[axisEvent.id].screenX is equal to axisEvent.screenX
686      * @tc.expect: rotationRecognizer->touchPoints_[axisEvent.id].screenY is equal to axisEvent.screenY
687      */
688     AxisEvent axisEvent;
689     axisEvent.id = TEST_EVENT_ID;
690     axisEvent.originalId = TEST_EVENT_ID;
691     axisEvent.isRotationEvent = true;
692     rotationRecognizer->refereeState_ = RefereeState::SUCCEED;
693     rotationRecognizer->currentFingers_ = rotationRecognizer->fingers_;
694     rotationRecognizer->HandleTouchMoveEvent(axisEvent);
695     EXPECT_EQ(rotationRecognizer->lastAxisEvent_.id, axisEvent.id);
696     EXPECT_EQ(rotationRecognizer->touchPoints_[axisEvent.id].originalId, axisEvent.originalId);
697     EXPECT_EQ(rotationRecognizer->touchPoints_[axisEvent.id].screenX, axisEvent.screenX);
698     EXPECT_EQ(rotationRecognizer->touchPoints_[axisEvent.id].screenY, axisEvent.screenY);
699 }
700 
701 /**
702  * @tc.name: RotationRecognizerSendCallbackMsgTest001
703  * @tc.desc: Test RotationRecognizer function: SendCallbackMsg
704  * @tc.type: FUNC
705  */
706 HWTEST_F(RotationRecognizerTestNg, RotationRecognizerSendCallbackMsgTest001, TestSize.Level1)
707 {
708     /**
709      * @tc.steps: step1. create RotationRecognizer.
710      */
711     RefPtr<RotationRecognizer> rotationRecognizer =
712         AceType::MakeRefPtr<RotationRecognizer>(SINGLE_FINGER_NUMBER, ROTATION_GESTURE_ANGLE);
713     std::unique_ptr<GestureEventFunc> onAction;
714 
715     /**
716      * @tc.steps: step2. call SendCallbackMsg function and compare result.
717      * @tc.steps: case3: onAction is yes, *onAction is yes, touchEvent is empty, type is AXIS
718      * @tc.expected: step2. result equals.
719      */
__anon9c07e5eb0202(GestureEvent) 720     onAction = std::make_unique<GestureEventFunc>([](GestureEvent) {});
721     rotationRecognizer->SendCallbackMsg(onAction, GestureCallbackType::ACTION);
722     EXPECT_EQ(rotationRecognizer->touchPoints_.size(), 0);
723 }
724 
725 /**
726  * @tc.name: RotationGestureTest001
727  * @tc.desc: Test RotationGesture CreateRecognizer function
728  */
729 HWTEST_F(RotationRecognizerTestNg, RotationGestureTest001, TestSize.Level1)
730 {
731     /**
732      * @tc.steps: step1. create RotationGestureGesture.
733      */
734     RotationGestureModelNG rotationGestureModelNG;
735     rotationGestureModelNG.Create(FINGER_NUMBER, ROTATION_GESTURE_ANGLE);
736 
737     RefPtr<GestureProcessor> gestureProcessor;
738     gestureProcessor = NG::ViewStackProcessor::GetInstance()->GetOrCreateGestureProcessor();
739     auto rotationGestureNG = AceType::DynamicCast<NG::RotationGesture>(gestureProcessor->TopGestureNG());
740     EXPECT_EQ(rotationGestureNG->angle_, ROTATION_GESTURE_ANGLE);
741 
742     RotationGesture rotationGesture = RotationGesture(FINGER_NUMBER, ROTATION_GESTURE_ANGLE);
743     EXPECT_EQ(rotationGesture.angle_, ROTATION_GESTURE_ANGLE);
744 
745     /**
746      * @tc.steps: step2. call CreateRecognizer function and compare result
747      * @tc.steps: case1: functions are not existed
748      */
749     rotationGesture.priority_ = GesturePriority::Low;
750     rotationGesture.gestureMask_ = GestureMask::Normal;
751     auto rotationRecognizer = AceType::DynamicCast<RotationRecognizer>(rotationGesture.CreateRecognizer());
752     EXPECT_NE(rotationRecognizer, nullptr);
753     EXPECT_EQ(rotationRecognizer->GetPriority(), GesturePriority::Low);
754     EXPECT_EQ(rotationRecognizer->GetPriorityMask(), GestureMask::Normal);
755 
756     // /**
757     //  * @tc.steps: step2. call CreateRecognizer function and compare result
758     //  * @tc.steps: case2: functions are existed
759     //  */
760     std::unique_ptr<GestureEventFunc> onActionStartId;
761     std::unique_ptr<GestureEventFunc> onActionUpdateId;
762     std::unique_ptr<GestureEventFunc> onActionEndId;
763     std::unique_ptr<GestureEventFunc> onActionCancelId;
764     rotationGesture.onActionStartId_ = std::move(onActionStartId);
765     rotationGesture.onActionUpdateId_ = std::move(onActionUpdateId);
766     rotationGesture.onActionEndId_ = std::move(onActionEndId);
767     rotationGesture.onActionCancelId_ = std::move(onActionCancelId);
768     rotationRecognizer = AceType::DynamicCast<RotationRecognizer>(rotationGesture.CreateRecognizer());
769     EXPECT_EQ(rotationRecognizer->priority_, rotationGesture.priority_);
770     EXPECT_EQ(rotationRecognizer->priorityMask_, rotationGesture.gestureMask_);
771 }
772 
773 /**
774  * @tc.name: RotationGestureCreateRecognizerTest001
775  * @tc.desc: Test RotationGesture CreateRecognizer function
776  */
777 HWTEST_F(RotationRecognizerTestNg, RotationGestureCreateRecognizerTest001, TestSize.Level1)
778 {
779     /**
780      * @tc.steps: step1. create RotationGestureGesture.
781      */
782     RotationGestureModelNG rotationGestureModelNG;
783     rotationGestureModelNG.Create(FINGER_NUMBER, ROTATION_GESTURE_ANGLE);
784 
785     RefPtr<GestureProcessor> gestureProcessor;
786     gestureProcessor = NG::ViewStackProcessor::GetInstance()->GetOrCreateGestureProcessor();
787     auto rotationGestureNG = AceType::DynamicCast<NG::RotationGesture>(gestureProcessor->TopGestureNG());
788     EXPECT_EQ(rotationGestureNG->angle_, ROTATION_GESTURE_ANGLE);
789 
790     RotationGesture rotationGesture = RotationGesture(FINGER_NUMBER, 0.0);
791     EXPECT_EQ(rotationGesture.angle_, ROTATION_GESTURE_ANGLE);
792     RotationGesture rotationGestureTwo = RotationGesture(FINGER_NUMBER, -1.0);
793     EXPECT_EQ(rotationGestureTwo.angle_, ROTATION_GESTURE_ANGLE);
794     RotationGesture rotationGestureThree = RotationGesture(FINGER_NUMBER, 361.0);
795     EXPECT_EQ(rotationGestureThree.angle_, ROTATION_GESTURE_ANGLE);
796 }
797 
798 
799 /**
800  * @tc.name: RotationGestureCreateRecognizerTest002
801  * @tc.desc: Test RotationGesture CreateRecognizer function
802  */
803 HWTEST_F(RotationRecognizerTestNg, RotationGestureCreateRecognizerTest002, TestSize.Level1)
804 {
805     /**
806      * @tc.steps: step1. create RotationGestureGesture.
807      */
808     RotationGestureModelNG rotationGestureModelNG;
809     rotationGestureModelNG.Create(FINGER_NUMBER, ROTATION_GESTURE_ANGLE);
810 
811     RefPtr<GestureProcessor> gestureProcessor;
812     gestureProcessor = NG::ViewStackProcessor::GetInstance()->GetOrCreateGestureProcessor();
813     auto rotationGestureNG = AceType::DynamicCast<NG::RotationGesture>(gestureProcessor->TopGestureNG());
814     EXPECT_EQ(rotationGestureNG->angle_, ROTATION_GESTURE_ANGLE);
815 
816     RotationGesture rotationGesture = RotationGesture(FINGER_NUMBER, ROTATION_GESTURE_ANGLE);
817     EXPECT_EQ(rotationGesture.angle_, ROTATION_GESTURE_ANGLE);
818 
819     /**
820      * @tc.steps: step2. call CreateRecognizer function and compare result
821      * @tc.steps: case1: functions are not existed
822      */
823     rotationGesture.priority_ = GesturePriority::Low;
824     rotationGesture.gestureMask_ = GestureMask::Normal;
825     auto rotationRecognizer = AceType::DynamicCast<RotationRecognizer>(rotationGesture.CreateRecognizer());
826     EXPECT_NE(rotationRecognizer, nullptr);
827     EXPECT_EQ(rotationRecognizer->GetPriority(), GesturePriority::Low);
828     EXPECT_EQ(rotationRecognizer->GetPriorityMask(), GestureMask::Normal);
829 
830     // /**
831     //  * @tc.steps: step2. call CreateRecognizer function and compare result
832     //  * @tc.steps: case2: functions are existed
833     //  */
834     std::unique_ptr<GestureEventFunc> onActionStartId;
835     std::unique_ptr<GestureEventFunc> onActionUpdateId;
836     std::unique_ptr<GestureEventFunc> onActionEndId;
837     std::unique_ptr<GestureEventFunc> onActionCancelId;
838     rotationGesture.onActionStartId_ = std::move(onActionStartId);
839     rotationGesture.onActionUpdateId_ = std::move(onActionUpdateId);
840     rotationGesture.onActionEndId_ = std::move(onActionEndId);
841     rotationGesture.onActionCancelId_ = std::move(onActionCancelId);
842     rotationGesture.priority_ = GesturePriority::Low;
843     rotationGesture.gestureMask_ = GestureMask::Normal;
__anon9c07e5eb0302(GestureEvent& info) 844     auto onActionStart = [](GestureEvent& info) { return true; };
__anon9c07e5eb0402(GestureEvent& info) 845     auto onActionUpdate = [](GestureEvent& info) { return true; };
__anon9c07e5eb0502(GestureEvent& info) 846     auto onActionEnd = [](GestureEvent& info) { return true; };
__anon9c07e5eb0602(GestureEvent& info) 847     auto onActionCancel = [](GestureEvent& info) { return true; };
848     rotationGesture.SetOnActionStartId(onActionStart);
849     rotationGesture.SetOnActionUpdateId(onActionUpdate);
850     rotationGesture.SetOnActionEndId(onActionEnd);
851     rotationGesture.SetOnActionCancelId(onActionCancel);
852     rotationRecognizer = AceType::DynamicCast<RotationRecognizer>(rotationGesture.CreateRecognizer());
853     EXPECT_EQ(rotationRecognizer->priority_, rotationGesture.priority_);
854     EXPECT_EQ(rotationRecognizer->priorityMask_, rotationGesture.gestureMask_);
855 }
856 
857 /**
858  * @tc.name: RotationRecognizerHandleTouchUpEventTest002
859  * @tc.desc: Test HandleTouchUpEvent in RotationRecognizer
860  */
861 HWTEST_F(RotationRecognizerTestNg, RotationRecognizerHandleTouchUpEventTest002, TestSize.Level1)
862 {
863     /**
864      * @tc.steps: step1. create clickRecognizerPtr.
865      */
866     RefPtr<RotationRecognizer> rotationRecognizerPtr =
867         AceType::MakeRefPtr<RotationRecognizer>(SINGLE_FINGER_NUMBER, ROTATION_GESTURE_ANGLE);
868     TouchEvent touchEvent;
869     rotationRecognizerPtr->activeFingers_.emplace_back(touchEvent.id);
870 
871     rotationRecognizerPtr->refereeState_ = RefereeState::PENDING;
872     rotationRecognizerPtr->currentFingers_ = rotationRecognizerPtr->fingers_;
873     rotationRecognizerPtr->HandleTouchUpEvent(touchEvent);
874     EXPECT_EQ(rotationRecognizerPtr->refereeState_, RefereeState::FAIL);
875 }
876 
877 /**
878  * @tc.name: RotationRecognizerHandleTouchCancelEventTest002
879  * @tc.desc: Test HandleTouchCancelEvent in RotationRecognizer
880  */
881 HWTEST_F(RotationRecognizerTestNg, RotationRecognizerHandleTouchCancelEventTest002, TestSize.Level1)
882 {
883     /**
884      * @tc.steps: step1. create clickRecognizerPtr.
885      */
886     RefPtr<RotationRecognizer> rotationRecognizerPtr =
887         AceType::MakeRefPtr<RotationRecognizer>(SINGLE_FINGER_NUMBER, ROTATION_GESTURE_ANGLE);
888     TouchEvent touchEvent;
889 
890     rotationRecognizerPtr->activeFingers_.emplace_back(touchEvent.id);
891     rotationRecognizerPtr->refereeState_ = RefereeState::PENDING;
892     rotationRecognizerPtr->HandleTouchCancelEvent(touchEvent);
893     EXPECT_EQ(rotationRecognizerPtr->refereeState_, RefereeState::FAIL);
894 }
895 
896 /**
897  * @tc.name: RotationRecognizerHandleTouchMoveEventTest006
898  * @tc.desc: Test HandleTouchMoveEvent in RotationRecognizer
899  */
900 HWTEST_F(RotationRecognizerTestNg, RotationRecognizerHandleTouchMoveEventTest006, TestSize.Level1)
901 {
902     /**
903      * @tc.steps: step1. create clickRecognizerPtr.
904      */
905     RefPtr<RotationRecognizer> rotationRecognizerPtr =
906         AceType::MakeRefPtr<RotationRecognizer>(SINGLE_FINGER_NUMBER, ROTATION_GESTURE_ANGLE);
907     TouchEvent touchEvent;
908 
909     rotationRecognizerPtr->refereeState_ = RefereeState::DETECTING;
910     rotationRecognizerPtr->fingers_ = 0;
911     rotationRecognizerPtr->currentFingers_ = rotationRecognizerPtr->fingers_;
912     rotationRecognizerPtr->HandleTouchMoveEvent(touchEvent);
913     EXPECT_EQ(rotationRecognizerPtr->refereeState_, RefereeState::DETECTING);
914 }
915 
916 /**
917  * @tc.name: RotationRecognizerPtrHandleTouchUpEventTest001
918  * @tc.desc: Test RotationRecognizer function: HandleTouchUpEvent
919  * @tc.type: FUNC
920  */
921 HWTEST_F(RotationRecognizerTestNg, RotationRecognizerPtrHandleTouchUpEventTest001, TestSize.Level1)
922 {
923     /**
924      * @tc.steps: step1. create and set Recognizer、TargetComponent.
925      */
926     RefPtr<RotationRecognizer> rotationRecognizerPtr =
927         AceType::MakeRefPtr<RotationRecognizer>(SINGLE_FINGER_NUMBER, ROTATION_GESTURE_ANGLE);
928     RefPtr<NG::TargetComponent> targetComponent = AceType::MakeRefPtr<TargetComponent>();
__anon9c07e5eb0702(const RefPtr<GestureInfo>& gestureInfo, const std::shared_ptr<BaseGestureEvent>& info) 929     auto gestureJudgeFunc = [](const RefPtr<GestureInfo>& gestureInfo, const std::shared_ptr<BaseGestureEvent>& info) {
930         return GestureJudgeResult::REJECT;};
931     targetComponent->SetOnGestureJudgeBegin(gestureJudgeFunc);
932     TouchEvent touchEvent;
933     touchEvent.tiltX.emplace(1.0f);
934     touchEvent.tiltY.emplace(1.0f);
935     rotationRecognizerPtr->targetComponent_ = targetComponent;
936     /**
937      * @tc.steps: step2. test the function who calls TriggerGestureJudgeCallback.
938      * @tc.expected: step2. result equals REJECT.
939      */
940     rotationRecognizerPtr->refereeState_ = RefereeState::DETECTING;
941     rotationRecognizerPtr->currentFingers_ = 2;
942     rotationRecognizerPtr->fingers_ = 2;
943     rotationRecognizerPtr->activeFingers_.push_back(touchEvent.id);
944     rotationRecognizerPtr->activeFingers_.push_back(1);
945     rotationRecognizerPtr->angle_ = 0;
946     rotationRecognizerPtr->HandleTouchMoveEvent(touchEvent);
947     EXPECT_EQ(rotationRecognizerPtr->disposal_, GestureDisposal::REJECT);
948 }
949 
950 /**
951  * @tc.name: RotationRecognizerHandleTouchDownEventTest001
952  * @tc.desc: Test RotationRecognizer function with axis event input: Down
953  * @tc.type: FUNC
954  */
955 HWTEST_F(RotationRecognizerTestNg, RotationRecognizerHandleAxisEventTest001, TestSize.Level1)
956 {
957     /**
958      * @tc.steps: step1. create rotation recognizer and axis event.
959      */
960     AxisEvent event;
961     RefPtr<RotationRecognizer> recognizer =
962         AceType::MakeRefPtr<RotationRecognizer>(SINGLE_FINGER_NUMBER, ROTATION_GESTURE_ANGLE);
963     /**
964      * @tc.steps: step2. Test HandleTouchDownEvent
965      */
966     event.isRotationEvent = false;
967     recognizer->refereeState_ = RefereeState::READY;
968     recognizer->HandleTouchDownEvent(event);
969     EXPECT_EQ(recognizer->refereeState_, RefereeState::READY);
970 
971     event.isRotationEvent = true;
972     recognizer->refereeState_ = RefereeState::READY;
973     recognizer->HandleTouchDownEvent(event);
974     EXPECT_EQ(recognizer->refereeState_, RefereeState::DETECTING);
975 
976     event.isRotationEvent = true;
977     recognizer->refereeState_ = RefereeState::SUCCEED;
978     recognizer->HandleTouchDownEvent(event);
979     EXPECT_EQ(recognizer->refereeState_, RefereeState::SUCCEED);
980 }
981 /**
982  * @tc.name: RotationRecognizerHandleTouchDownEventTest002
983  * @tc.desc: Test RotationRecognizer function with axis event input: Up
984  * @tc.type: FUNC
985  */
986 HWTEST_F(RotationRecognizerTestNg, RotationRecognizerHandleAxisEventTest002, TestSize.Level1)
987 {
988     /**
989      * @tc.steps: step1. create rotation recognizer and axis event.
990      */
991     AxisEvent event;
992     RefPtr<RotationRecognizer> recognizer =
993         AceType::MakeRefPtr<RotationRecognizer>(SINGLE_FINGER_NUMBER, ROTATION_GESTURE_ANGLE);
994     /**
995      * @tc.steps: step2. Test HandleTouchUpEvent
996      */
997     recognizer->refereeState_ = RefereeState::READY;
998     recognizer->HandleTouchUpEvent(event);
999     EXPECT_EQ(recognizer->refereeState_, RefereeState::READY);
1000 
1001     recognizer->refereeState_ = RefereeState::SUCCEED;
1002     recognizer->HandleTouchUpEvent(event);
1003     EXPECT_EQ(recognizer->refereeState_, RefereeState::SUCCEED);
1004 }
1005 /**
1006  * @tc.name: RotationRecognizerHandleTouchDownEventTest003
1007  * @tc.desc: Test RotationRecognizer function with axis event input: Move
1008  * @tc.type: FUNC
1009  */
1010 HWTEST_F(RotationRecognizerTestNg, RotationRecognizerHandleAxisEventTest003, TestSize.Level1)
1011 {
1012     /**
1013      * @tc.steps: step1. create rotation recognizer and axis event.
1014      */
1015     AxisEvent event;
1016     RefPtr<RotationRecognizer> recognizer =
1017         AceType::MakeRefPtr<RotationRecognizer>(SINGLE_FINGER_NUMBER, ROTATION_GESTURE_ANGLE);
1018     /**
1019      * @tc.steps: step2. Test HandleTouchMoveEvent
1020      */
1021     event.isRotationEvent = true;
1022     recognizer->refereeState_ = RefereeState::DETECTING;
1023     recognizer->HandleTouchMoveEvent(event);
1024     EXPECT_EQ(recognizer->refereeState_, RefereeState::DETECTING);
1025 
1026     event.isRotationEvent = true;
1027     event.rotateAxisAngle = ROTATION_GESTURE_ANGLE;
1028     recognizer->refereeState_ = RefereeState::DETECTING;
1029     recognizer->HandleTouchMoveEvent(event);
1030     EXPECT_EQ(recognizer->refereeState_, RefereeState::DETECTING);
1031 
1032     event.isRotationEvent = true;
1033     event.rotateAxisAngle = 2 * ROTATION_GESTURE_ANGLE;
1034     recognizer->refereeState_ = RefereeState::DETECTING;
1035     recognizer->HandleTouchMoveEvent(event);
1036     EXPECT_NE(recognizer->refereeState_, RefereeState::DETECTING);
1037 
1038     event.isRotationEvent = true;
1039     recognizer->refereeState_ = RefereeState::SUCCEED;
1040     recognizer->HandleTouchMoveEvent(event);
1041     EXPECT_EQ(recognizer->refereeState_, RefereeState::SUCCEED);
1042 
1043     event.isRotationEvent = true;
1044     recognizer->refereeState_ = RefereeState::READY;
1045     recognizer->HandleTouchMoveEvent(event);
1046     EXPECT_EQ(recognizer->refereeState_, RefereeState::READY);
1047 
1048     event.isRotationEvent = false;
1049     recognizer->refereeState_ = RefereeState::READY;
1050     recognizer->HandleTouchMoveEvent(event);
1051     EXPECT_EQ(recognizer->refereeState_, RefereeState::READY);
1052 }
1053 /**
1054  * @tc.name: RotationRecognizerHandleTouchDownEventTest004
1055  * @tc.desc: Test RotationRecognizer function with axis event input: Cancel
1056  * @tc.type: FUNC
1057  */
1058 HWTEST_F(RotationRecognizerTestNg, RotationRecognizerHandleAxisEventTest004, TestSize.Level1)
1059 {
1060     /**
1061      * @tc.steps: step1. create rotation recognizer and axis event.
1062      */
1063     AxisEvent event;
1064     RefPtr<RotationRecognizer> recognizer =
1065         AceType::MakeRefPtr<RotationRecognizer>(SINGLE_FINGER_NUMBER, ROTATION_GESTURE_ANGLE);
1066     /**
1067      * @tc.steps: step2. Test HandleTouchCancelEvent
1068      */
1069     recognizer->refereeState_ = RefereeState::READY;
1070     recognizer->HandleTouchCancelEvent(event);
1071     EXPECT_EQ(recognizer->refereeState_, RefereeState::FAIL);
1072 
1073     recognizer->refereeState_ = RefereeState::SUCCEED;
1074     recognizer->HandleTouchCancelEvent(event);
1075     EXPECT_EQ(recognizer->refereeState_, RefereeState::SUCCEED);
1076 }
1077 
1078 /**
1079  * @tc.name: SetOnActionCancelTest001
1080  * @tc.desc: Test SendCallbackMsg function in the HandleTouchCancelEvent with touch event input. The onActionCancel
1081  * function will return GestureEvent info.
1082  * @tc.type: FUNC
1083  */
1084 HWTEST_F(RotationRecognizerTestNg, SetOnActionCancelTest001, TestSize.Level1)
1085 {
1086     /**
1087      * @tc.steps: step1. Create RotationRecognizerTestNg.
1088      */
1089     RefPtr<RotationRecognizer> rotationRecognizer =
1090         AceType::MakeRefPtr<RotationRecognizer>(SINGLE_FINGER_NUMBER, ROTATION_GESTURE_ANGLE);
1091 
1092     /**
1093      * @tc.steps: step2. Call SetOnActionCancel.
1094      * @tc.expected: RotationRecognizer's callback onActionCancel is not nullptr.
1095      */
1096     rotationRecognizer->deviceId_ = GESTURE_EVENT_PROPERTY_VALUE;
1097     double unknownPropertyValue = GESTURE_EVENT_PROPERTY_DEFAULT_VALUE;
1098     auto onActionCancel = [&unknownPropertyValue](
__anon9c07e5eb0802( GestureEvent& info) 1099                                 GestureEvent& info) { unknownPropertyValue = info.GetDeviceId(); };
1100     rotationRecognizer->SetOnActionCancel(onActionCancel);
1101     EXPECT_NE(rotationRecognizer->onActionCancel_, nullptr);
1102 
1103     /**
1104      * @tc.steps: step3. Invoke HandleTouchCancelEvent when onActionCancel_ is not null.
1105      * @tc.expected: The functions have been executed and the unknownPropertyValue has been assigned the correct
1106      * value. rotationRecognizer->refereeState_ = RefereeState::READY
1107      */
1108     TouchEvent touchEvent;
1109     rotationRecognizer->touchPoints_[touchEvent.id] = touchEvent;
1110     rotationRecognizer->refereeState_ = RefereeState::SUCCEED;
1111     rotationRecognizer->activeFingers_.emplace_back(touchEvent.id);
1112     rotationRecognizer->activeFingers_.push_back(1);
1113     rotationRecognizer->HandleTouchCancelEvent(touchEvent);
1114     EXPECT_EQ(unknownPropertyValue, GESTURE_EVENT_PROPERTY_VALUE);
1115     EXPECT_EQ(rotationRecognizer->refereeState_, RefereeState::READY);
1116 }
1117 
1118 /**
1119  * @tc.name: SetOnActionCancelTest002
1120  * @tc.desc: Test SendCallbackMsg function in the HandleTouchCancelEvent with axis event input. The onActionCancel
1121  * function will return GestureEvent info.
1122  * @tc.type: FUNC
1123  */
1124 HWTEST_F(RotationRecognizerTestNg, SetOnActionCancelTest002, TestSize.Level1)
1125 {
1126     /**
1127      * @tc.steps: step1. Create RotationRecognizer.
1128      */
1129     RefPtr<RotationRecognizer> rotationRecognizer =
1130         AceType::MakeRefPtr<RotationRecognizer>(SINGLE_FINGER_NUMBER, ROTATION_GESTURE_ANGLE);
1131 
1132     /**
1133      * @tc.steps: step2. Call SetOnActionCancel.
1134      * @tc.expected: rotationRecognizer's callback onActionCancel is not nullptr.
1135      */
1136     rotationRecognizer->deviceId_ = GESTURE_EVENT_PROPERTY_VALUE;
1137     double unknownPropertyValue = GESTURE_EVENT_PROPERTY_DEFAULT_VALUE;
1138     auto onActionCancel = [&unknownPropertyValue](
__anon9c07e5eb0902( GestureEvent& info) 1139                                 GestureEvent& info) { unknownPropertyValue = info.GetDeviceId(); };
1140     rotationRecognizer->SetOnActionCancel(onActionCancel);
1141     EXPECT_NE(rotationRecognizer->onActionCancel_, nullptr);
1142 
1143     /**
1144      * @tc.steps: step3. Invoke HandleTouchCancelEvent when onActionCancel_ is not null.
1145      * @tc.expected: The functions have been executed and the unknownPropertyValue has been assigned the correct
1146      * value.
1147      */
1148     AxisEvent axisEvent;
1149     rotationRecognizer->refereeState_ = RefereeState::SUCCEED;
1150     rotationRecognizer->HandleTouchCancelEvent(axisEvent);
1151     EXPECT_EQ(unknownPropertyValue, GESTURE_EVENT_PROPERTY_VALUE);
1152 }
1153 
1154 /**
1155  * @tc.name: SetOnActionCancelTest003
1156  * @tc.desc: Test SendCallbackMsg function in the ReconcileFrom. The onActionCancel function will return
1157  * GestureEvent info.
1158  * @tc.type: FUNC
1159  */
1160 HWTEST_F(RotationRecognizerTestNg, SetOnActionCancelTest003, TestSize.Level1)
1161 {
1162     /**
1163      * @tc.steps: step1. Create RotationRecognizer.
1164      */
1165     RefPtr<RotationRecognizer> rotationRecognizer =
1166         AceType::MakeRefPtr<RotationRecognizer>(SINGLE_FINGER_NUMBER, ROTATION_GESTURE_ANGLE);
1167     RefPtr<RotationRecognizer> rotationRecognizerPtr =
1168         AceType::MakeRefPtr<RotationRecognizer>(SINGLE_FINGER_NUMBER, ROTATION_GESTURE_ANGLE);
1169 
1170     /**
1171      * @tc.steps: step2. Call SetOnActionCancel.
1172      * @tc.expected: rotationRecognizer's callback onActionCancel is not nullptr.
1173      */
1174     rotationRecognizer->deviceId_ = GESTURE_EVENT_PROPERTY_VALUE;
1175     double unknownPropertyValue = GESTURE_EVENT_PROPERTY_DEFAULT_VALUE;
1176     auto onActionCancel = [&unknownPropertyValue](
__anon9c07e5eb0a02( GestureEvent& info) 1177                                 GestureEvent& info) { unknownPropertyValue = info.GetDeviceId(); };
1178     rotationRecognizer->SetOnActionCancel(onActionCancel);
1179     EXPECT_NE(rotationRecognizer->onActionCancel_, nullptr);
1180 
1181     /**
1182      * @tc.steps: step3. Invoke ReconcileFrom when onActionCancel_ is not null.
1183      * @tc.expected: The functions have been executed and the unknownPropertyValue has been assigned the correct
1184      * value.
1185      */
1186     rotationRecognizer->fingers_ = 0;
1187     rotationRecognizer->refereeState_ = RefereeState::SUCCEED;
1188     rotationRecognizer->activeFingers_.push_back(1);
1189     rotationRecognizer->activeFingers_.push_back(2);
1190     auto result = rotationRecognizer->ReconcileFrom(rotationRecognizerPtr);
1191     EXPECT_EQ(unknownPropertyValue, GESTURE_EVENT_PROPERTY_VALUE);
1192     EXPECT_EQ(result, false);
1193 }
1194 
1195 /**
1196  * @tc.name: RotationGestureLimitFingerTest001
1197  * @tc.desc: Test RotationGesture CreateRecognizer function
1198  */
1199 HWTEST_F(RotationRecognizerTestNg, RotationGestureLimitFingerTest001, TestSize.Level1)
1200 {
1201     /**
1202      * @tc.steps: step1. create RotationGestureGesture.
1203      */
1204     RotationGestureModelNG rotationGestureModelNG;
1205     rotationGestureModelNG.Create(FINGER_NUMBER, ROTATION_GESTURE_ANGLE, IS_LIMIT_FINGER_COUNT);
1206 
1207     RefPtr<GestureProcessor> gestureProcessor;
1208     gestureProcessor = NG::ViewStackProcessor::GetInstance()->GetOrCreateGestureProcessor();
1209     auto rotationGestureNG = AceType::DynamicCast<NG::RotationGesture>(gestureProcessor->TopGestureNG());
1210     EXPECT_EQ(rotationGestureNG->angle_, ROTATION_GESTURE_ANGLE);
1211     EXPECT_EQ(rotationGestureNG->isLimitFingerCount_, IS_LIMIT_FINGER_COUNT);
1212 
1213     RotationGesture rotationGesture = RotationGesture(FINGER_NUMBER, ROTATION_GESTURE_ANGLE, IS_LIMIT_FINGER_COUNT);
1214     EXPECT_EQ(rotationGesture.angle_, ROTATION_GESTURE_ANGLE);
1215     EXPECT_EQ(rotationGesture.isLimitFingerCount_, IS_LIMIT_FINGER_COUNT);
1216 
1217     /**
1218      * @tc.steps: step2. call CreateRecognizer function and compare result
1219      * @tc.steps: case1: functions are not existed
1220      */
1221     rotationGesture.priority_ = GesturePriority::Low;
1222     rotationGesture.gestureMask_ = GestureMask::Normal;
1223     auto rotationRecognizer = AceType::DynamicCast<RotationRecognizer>(rotationGesture.CreateRecognizer());
1224     EXPECT_NE(rotationRecognizer, nullptr);
1225     EXPECT_EQ(rotationRecognizer->GetPriority(), GesturePriority::Low);
1226     EXPECT_EQ(rotationRecognizer->GetPriorityMask(), GestureMask::Normal);
1227     EXPECT_EQ(rotationRecognizer->isLimitFingerCount_, IS_LIMIT_FINGER_COUNT);
1228 
1229     // /**
1230     //  * @tc.steps: step2. call CreateRecognizer function and compare result
1231     //  * @tc.steps: case2: functions are existed
1232     //  */
1233     std::unique_ptr<GestureEventFunc> onActionStartId;
1234     std::unique_ptr<GestureEventFunc> onActionUpdateId;
1235     std::unique_ptr<GestureEventFunc> onActionEndId;
1236     std::unique_ptr<GestureEventFunc> onActionCancelId;
1237     rotationGesture.onActionStartId_ = std::move(onActionStartId);
1238     rotationGesture.onActionUpdateId_ = std::move(onActionUpdateId);
1239     rotationGesture.onActionEndId_ = std::move(onActionEndId);
1240     rotationGesture.onActionCancelId_ = std::move(onActionCancelId);
1241     rotationRecognizer = AceType::DynamicCast<RotationRecognizer>(rotationGesture.CreateRecognizer());
1242     EXPECT_EQ(rotationRecognizer->priority_, rotationGesture.priority_);
1243     EXPECT_EQ(rotationRecognizer->priorityMask_, rotationGesture.gestureMask_);
1244     EXPECT_EQ(rotationRecognizer->isLimitFingerCount_, IS_LIMIT_FINGER_COUNT);
1245 }
1246 
1247 /**
1248  * @tc.name: RotationGestureLimitFingerTest002
1249  * @tc.desc: Test RotationGesture CreateRecognizer function
1250  */
1251 HWTEST_F(RotationRecognizerTestNg, RotationGestureLimitFingerTest002, TestSize.Level1)
1252 {
1253     /**
1254      * @tc.steps: step1. create RotationGestureGesture.
1255      */
1256     RotationGestureModelNG rotationGestureModelNG;
1257     rotationGestureModelNG.Create(FINGER_NUMBER, ROTATION_GESTURE_ANGLE, IS_NOT_LIMIT_FINGER_COUNT);
1258 
1259     RefPtr<GestureProcessor> gestureProcessor;
1260     gestureProcessor = NG::ViewStackProcessor::GetInstance()->GetOrCreateGestureProcessor();
1261     auto rotationGestureNG = AceType::DynamicCast<NG::RotationGesture>(gestureProcessor->TopGestureNG());
1262     EXPECT_EQ(rotationGestureNG->angle_, ROTATION_GESTURE_ANGLE);
1263     EXPECT_EQ(rotationGestureNG->isLimitFingerCount_, IS_NOT_LIMIT_FINGER_COUNT);
1264 
1265     RotationGesture rotationGesture = RotationGesture(FINGER_NUMBER, ROTATION_GESTURE_ANGLE, IS_NOT_LIMIT_FINGER_COUNT);
1266     EXPECT_EQ(rotationGesture.angle_, ROTATION_GESTURE_ANGLE);
1267     EXPECT_EQ(rotationGesture.isLimitFingerCount_, IS_NOT_LIMIT_FINGER_COUNT);
1268 
1269     /**
1270      * @tc.steps: step2. call CreateRecognizer function and compare result
1271      * @tc.steps: case1: functions are not existed
1272      */
1273     rotationGesture.priority_ = GesturePriority::Low;
1274     rotationGesture.gestureMask_ = GestureMask::Normal;
1275     auto rotationRecognizer = AceType::DynamicCast<RotationRecognizer>(rotationGesture.CreateRecognizer());
1276     EXPECT_NE(rotationRecognizer, nullptr);
1277     EXPECT_EQ(rotationRecognizer->GetPriority(), GesturePriority::Low);
1278     EXPECT_EQ(rotationRecognizer->GetPriorityMask(), GestureMask::Normal);
1279     EXPECT_EQ(rotationRecognizer->isLimitFingerCount_, IS_NOT_LIMIT_FINGER_COUNT);
1280 
1281     // /**
1282     //  * @tc.steps: step2. call CreateRecognizer function and compare result
1283     //  * @tc.steps: case2: functions are existed
1284     //  */
1285     std::unique_ptr<GestureEventFunc> onActionStartId;
1286     std::unique_ptr<GestureEventFunc> onActionUpdateId;
1287     std::unique_ptr<GestureEventFunc> onActionEndId;
1288     std::unique_ptr<GestureEventFunc> onActionCancelId;
1289     rotationGesture.onActionStartId_ = std::move(onActionStartId);
1290     rotationGesture.onActionUpdateId_ = std::move(onActionUpdateId);
1291     rotationGesture.onActionEndId_ = std::move(onActionEndId);
1292     rotationGesture.onActionCancelId_ = std::move(onActionCancelId);
1293     rotationRecognizer = AceType::DynamicCast<RotationRecognizer>(rotationGesture.CreateRecognizer());
1294     EXPECT_EQ(rotationRecognizer->priority_, rotationGesture.priority_);
1295     EXPECT_EQ(rotationRecognizer->priorityMask_, rotationGesture.gestureMask_);
1296     EXPECT_EQ(rotationRecognizer->isLimitFingerCount_, IS_NOT_LIMIT_FINGER_COUNT);
1297 }
1298 
1299 /**
1300  * @tc.name: OnAcceptedTest001
1301  * @tc.desc: Test OnAccepted function
1302  */
1303 HWTEST_F(RotationRecognizerTestNg, OnAcceptedTest001, TestSize.Level1)
1304 {
1305     RotationGestureModelNG rotationGestureModelNG;
1306     rotationGestureModelNG.Create(FINGER_NUMBER, ROTATION_GESTURE_ANGLE, IS_NOT_LIMIT_FINGER_COUNT);
1307     RefPtr<GestureProcessor> gestureProcessor;
1308     gestureProcessor = NG::ViewStackProcessor::GetInstance()->GetOrCreateGestureProcessor();
1309     auto rotationGestureNG = AceType::DynamicCast<NG::RotationGesture>(gestureProcessor->TopGestureNG());
1310     RotationGesture rotationGesture = RotationGesture(FINGER_NUMBER, ROTATION_GESTURE_ANGLE, IS_NOT_LIMIT_FINGER_COUNT);
1311 
1312     rotationGesture.priority_ = GesturePriority::Low;
1313     rotationGesture.gestureMask_ = GestureMask::Normal;
1314     auto rotationRecognizer = AceType::DynamicCast<RotationRecognizer>(rotationGesture.CreateRecognizer());
1315     TimeStamp timeStape = std::chrono::high_resolution_clock::now();
1316     rotationRecognizer->firstInputTime_ = timeStape;
1317     SystemProperties::traceInputEventEnable_ = true;
1318     rotationRecognizer->OnAccepted();
1319     EXPECT_NE(rotationRecognizer, nullptr);
1320 }
1321 
1322 /**
1323  * @tc.name: HandleTouchUpEvent001
1324  * @tc.desc: Test HandleTouchUpEvent function
1325  */
1326 HWTEST_F(RotationRecognizerTestNg, HandleTouchUpEvent001, TestSize.Level1)
1327 {
1328     RotationGestureModelNG rotationGestureModelNG;
1329     rotationGestureModelNG.Create(FINGER_NUMBER, ROTATION_GESTURE_ANGLE, IS_NOT_LIMIT_FINGER_COUNT);
1330     RefPtr<GestureProcessor> gestureProcessor;
1331     gestureProcessor = NG::ViewStackProcessor::GetInstance()->GetOrCreateGestureProcessor();
1332     auto rotationGestureNG = AceType::DynamicCast<NG::RotationGesture>(gestureProcessor->TopGestureNG());
1333     RotationGesture rotationGesture = RotationGesture(FINGER_NUMBER, ROTATION_GESTURE_ANGLE, IS_NOT_LIMIT_FINGER_COUNT);
1334 
1335     rotationGesture.priority_ = GesturePriority::Low;
1336     rotationGesture.gestureMask_ = GestureMask::Normal;
1337     auto rotationRecognizer = AceType::DynamicCast<RotationRecognizer>(rotationGesture.CreateRecognizer());
1338     TouchEvent touchEvent;
1339 
1340     rotationRecognizer->isNeedResetVoluntarily_ = true;
1341     rotationRecognizer->currentFingers_ = 1;
1342     rotationRecognizer->HandleTouchUpEvent(touchEvent);
1343     EXPECT_EQ(rotationRecognizer->isNeedResetVoluntarily_, false);
1344 
1345     rotationRecognizer->isNeedResetVoluntarily_ = false;
1346     rotationRecognizer->currentFingers_ = 1;
1347     rotationRecognizer->HandleTouchUpEvent(touchEvent);
1348     EXPECT_EQ(rotationRecognizer->isNeedResetVoluntarily_, false);
1349 
1350     rotationRecognizer->isNeedResetVoluntarily_ = true;
1351     rotationRecognizer->currentFingers_ = 0;
1352     rotationRecognizer->HandleTouchUpEvent(touchEvent);
1353     EXPECT_EQ(rotationRecognizer->isNeedResetVoluntarily_, true);
1354 
1355     rotationRecognizer->isNeedResetVoluntarily_ = false;
1356     rotationRecognizer->currentFingers_ = 0;
1357     rotationRecognizer->HandleTouchUpEvent(touchEvent);
1358     EXPECT_EQ(rotationRecognizer->isNeedResetVoluntarily_, false);
1359 }
1360 
1361 /**
1362  * @tc.name: HandleTouchUpEvent002
1363  * @tc.desc: Test HandleTouchUpEvent function
1364  */
1365 HWTEST_F(RotationRecognizerTestNg, HandleTouchUpEvent002, TestSize.Level1)
1366 {
1367     int32_t DEFAULT_ROTATION_FINGERS = 2;
1368     auto rotationRecognizer = AceType::MakeRefPtr<RotationRecognizer>(SINGLE_FINGER_NUMBER, ROTATION_GESTURE_ANGLE);
1369 
1370     int32_t testId = 1;
1371     int32_t testId2 = 2;
1372     TouchEvent touchEvent;
1373     touchEvent.id = testId;
1374     rotationRecognizer->activeFingers_.push_front(testId);
1375     rotationRecognizer->activeFingers_.push_front(testId2);
1376     rotationRecognizer->refereeState_ = RefereeState::SUCCEED;
1377     rotationRecognizer->HandleTouchUpEvent(touchEvent);
1378     EXPECT_EQ(rotationRecognizer->activeFingers_.size(), DEFAULT_ROTATION_FINGERS - 1);
1379     EXPECT_TRUE(rotationRecognizer->isNeedResetVoluntarily_);
1380     rotationRecognizer->activeFingers_.push_front(testId);
1381     TimeStamp timeStape = std::chrono::high_resolution_clock::now();
1382     rotationRecognizer->firstInputTime_ = timeStape;
1383     SystemProperties::traceInputEventEnable_ = false;
1384     rotationRecognizer->HandleTouchUpEvent(touchEvent);
1385     EXPECT_EQ(rotationRecognizer->activeFingers_.size(), DEFAULT_ROTATION_FINGERS - 1);
1386     EXPECT_TRUE(rotationRecognizer->isNeedResetVoluntarily_);
1387 
1388     auto rotationRecognizer1 = AceType::MakeRefPtr<RotationRecognizer>(SINGLE_FINGER_NUMBER, ROTATION_GESTURE_ANGLE);
1389     rotationRecognizer1->activeFingers_.clear();
1390     rotationRecognizer1->refereeState_ = RefereeState::SUCCEED;
1391     rotationRecognizer1->activeFingers_.push_front(testId);
1392     rotationRecognizer1->HandleTouchUpEvent(touchEvent);
1393     EXPECT_FALSE(rotationRecognizer1->isNeedResetVoluntarily_);
1394 
1395     auto rotationRecognizer2 = AceType::MakeRefPtr<RotationRecognizer>(SINGLE_FINGER_NUMBER, ROTATION_GESTURE_ANGLE);
1396     rotationRecognizer2->activeFingers_.clear();
1397     rotationRecognizer2->activeFingers_.push_front(testId2);
1398     rotationRecognizer2->activeFingers_.push_front(testId);
1399     rotationRecognizer2->refereeState_ = RefereeState::FAIL;
1400     rotationRecognizer2->HandleTouchUpEvent(touchEvent);
1401     EXPECT_FALSE(rotationRecognizer2->isNeedResetVoluntarily_);
1402 
1403     auto rotationRecognizer3 = AceType::MakeRefPtr<RotationRecognizer>(SINGLE_FINGER_NUMBER, ROTATION_GESTURE_ANGLE);
1404     int32_t testId3 = 3;
1405     rotationRecognizer3->activeFingers_.clear();
1406     rotationRecognizer3->activeFingers_.push_front(testId);
1407     rotationRecognizer3->activeFingers_.push_front(testId2);
1408     rotationRecognizer3->activeFingers_.push_front(testId3);
1409     rotationRecognizer3->refereeState_ = RefereeState::FAIL;
1410     rotationRecognizer3->HandleTouchUpEvent(touchEvent);
1411     EXPECT_FALSE(rotationRecognizer3->isNeedResetVoluntarily_);
1412 }
1413 
1414 /**
1415  * @tc.name: HandleTouchUpEvent003
1416  * @tc.desc: Test HandleTouchUpEvent function
1417  */
1418 HWTEST_F(RotationRecognizerTestNg, HandleTouchUpEvent003, TestSize.Level1)
1419 {
1420     auto rotationRecognizer = AceType::MakeRefPtr<RotationRecognizer>(SINGLE_FINGER_NUMBER, ROTATION_GESTURE_ANGLE);
1421 
1422     AxisEvent event;
1423     event.isRotationEvent = true;
1424     rotationRecognizer->refereeState_ = RefereeState::FAIL;
1425     rotationRecognizer->HandleTouchUpEvent(event);
1426     EXPECT_TRUE(rotationRecognizer->lastAxisEvent_.isRotationEvent);
1427 
1428     rotationRecognizer->refereeState_ = RefereeState::READY;
1429     rotationRecognizer->HandleTouchUpEvent(event);
1430     EXPECT_TRUE(rotationRecognizer->lastAxisEvent_.isRotationEvent);
1431 
1432     rotationRecognizer->refereeState_ = RefereeState::SUCCEED;
1433     TimeStamp timeStape = std::chrono::high_resolution_clock::now();
1434     rotationRecognizer->firstInputTime_ = timeStape;
1435     SystemProperties::traceInputEventEnable_ = true;
1436     rotationRecognizer->HandleTouchUpEvent(event);
1437     EXPECT_TRUE(rotationRecognizer->lastAxisEvent_.isRotationEvent);
1438 }
1439 
1440 /**
1441  * @tc.name: RotationRecognizerPtrHandleTouchUpEventTest002
1442  * @tc.desc: Test RotationRecognizer function: HandleTouchUpEvent
1443  * @tc.type: FUNC
1444  */
1445 HWTEST_F(RotationRecognizerTestNg, RotationRecognizerPtrHandleTouchUpEventTest002, TestSize.Level1)
1446 {
1447     RefPtr<RotationRecognizer> rotationRecognizerPtr =
1448         AceType::MakeRefPtr<RotationRecognizer>(SINGLE_FINGER_NUMBER, ROTATION_GESTURE_ANGLE);
1449     RefPtr<NG::TargetComponent> targetComponent = AceType::MakeRefPtr<TargetComponent>();
__anon9c07e5eb0b02(const RefPtr<GestureInfo>& gestureInfo, const std::shared_ptr<BaseGestureEvent>& info) 1450     auto gestureJudgeFunc = [](const RefPtr<GestureInfo>& gestureInfo, const std::shared_ptr<BaseGestureEvent>& info) {
1451         return GestureJudgeResult::REJECT;};
1452     targetComponent->SetOnGestureJudgeBegin(gestureJudgeFunc);
1453     TouchEvent touchEvent;
1454     touchEvent.tiltX.emplace(1.0f);
1455     touchEvent.tiltY.emplace(1.0f);
1456     rotationRecognizerPtr->targetComponent_ = targetComponent;
1457 
1458     rotationRecognizerPtr->refereeState_ = RefereeState::DETECTING;
1459     rotationRecognizerPtr->currentFingers_ = 2;
1460     rotationRecognizerPtr->fingers_ = 2;
1461     rotationRecognizerPtr->activeFingers_.push_back(touchEvent.id);
1462     rotationRecognizerPtr->angle_ = 0;
1463     rotationRecognizerPtr->HandleTouchMoveEvent(touchEvent);
1464     EXPECT_EQ(rotationRecognizerPtr->lastAngle_, 0.0);
1465     EXPECT_EQ(rotationRecognizerPtr->angleSignChanged_, false);
1466 }
1467 
1468 /**
1469  * @tc.name: RotationRecognizerPtrHandleTouchUpEventTest003
1470  * @tc.desc: Test RotationRecognizer function: HandleTouchUpEvent
1471  * @tc.type: FUNC
1472  */
1473 HWTEST_F(RotationRecognizerTestNg, RotationRecognizerPtrHandleTouchUpEventTest003, TestSize.Level1)
1474 {
1475     RefPtr<RotationRecognizer> rotationRecognizerPtr =
1476         AceType::MakeRefPtr<RotationRecognizer>(SINGLE_FINGER_NUMBER, ROTATION_GESTURE_ANGLE);
1477     RefPtr<NG::TargetComponent> targetComponent = AceType::MakeRefPtr<TargetComponent>();
__anon9c07e5eb0c02(const RefPtr<GestureInfo>& gestureInfo, const std::shared_ptr<BaseGestureEvent>& info) 1478     auto gestureJudgeFunc = [](const RefPtr<GestureInfo>& gestureInfo, const std::shared_ptr<BaseGestureEvent>& info) {
1479         return GestureJudgeResult::REJECT;};
1480     targetComponent->SetOnGestureJudgeBegin(gestureJudgeFunc);
1481     TouchEvent touchEvent;
1482     touchEvent.id = 1;
1483     touchEvent.SetX(-100);
1484     touchEvent.SetY(200);
1485     TouchEvent touchEvent2;
1486     touchEvent2.id = 2;
1487     touchEvent2.SetX(0);
1488     touchEvent2.SetY(0);
1489     rotationRecognizerPtr->targetComponent_ = targetComponent;
1490 
1491     rotationRecognizerPtr->refereeState_ = RefereeState::DETECTING;
1492     rotationRecognizerPtr->currentFingers_ = 2;
1493     rotationRecognizerPtr->fingers_ = 2;
1494     rotationRecognizerPtr->activeFingers_.push_back(touchEvent.id);
1495     rotationRecognizerPtr->activeFingers_.push_back(touchEvent2.id);
1496     rotationRecognizerPtr->angle_ = 0;
1497     rotationRecognizerPtr->lastAngle_ = -10;
1498 
1499     rotationRecognizerPtr->touchPoints_[touchEvent2.id] = touchEvent2;
1500     rotationRecognizerPtr->touchPoints_[touchEvent.id] = touchEvent;
1501     rotationRecognizerPtr->HandleTouchMoveEvent(touchEvent);
1502     EXPECT_EQ(rotationRecognizerPtr->angleSignChanged_, false);
1503 
1504     rotationRecognizerPtr->initialAngle_ = 1;
1505     rotationRecognizerPtr->refereeState_ = RefereeState::DETECTING;
1506     rotationRecognizerPtr->lastAngle_ = -10;
1507     rotationRecognizerPtr->HandleTouchMoveEvent(touchEvent);
1508     EXPECT_EQ(rotationRecognizerPtr->angleSignChanged_, false);
1509 
1510     touchEvent.SetX(100);
1511     rotationRecognizerPtr->lastAngle_ = 10;
1512     rotationRecognizerPtr->activeFingers_.clear();
1513     rotationRecognizerPtr->activeFingers_.push_back(touchEvent.id);
1514     rotationRecognizerPtr->activeFingers_.push_back(touchEvent2.id);
1515     rotationRecognizerPtr->touchPoints_.clear();
1516     rotationRecognizerPtr->touchPoints_[touchEvent2.id] = touchEvent2;
1517     rotationRecognizerPtr->touchPoints_[touchEvent.id] = touchEvent;
1518     rotationRecognizerPtr->refereeState_ = RefereeState::DETECTING;
1519     rotationRecognizerPtr->HandleTouchMoveEvent(touchEvent);
1520     EXPECT_EQ(rotationRecognizerPtr->angleSignChanged_, false);
1521 }
1522 
1523 /**
1524  * @tc.name: RotationRecognizerPtrHandleTouchUpEventTest004
1525  * @tc.desc: Test RotationRecognizer function: HandleTouchUpEvent
1526  * @tc.type: FUNC
1527  */
1528 HWTEST_F(RotationRecognizerTestNg, RotationRecognizerPtrHandleTouchUpEventTest004, TestSize.Level1)
1529 {
1530     RefPtr<RotationRecognizer> rotationRecognizerPtr =
1531         AceType::MakeRefPtr<RotationRecognizer>(SINGLE_FINGER_NUMBER, ROTATION_GESTURE_ANGLE);
1532     RefPtr<NG::TargetComponent> targetComponent = AceType::MakeRefPtr<TargetComponent>();
__anon9c07e5eb0d02(const RefPtr<GestureInfo>& gestureInfo, const std::shared_ptr<BaseGestureEvent>& info) 1533     auto gestureJudgeFunc = [](const RefPtr<GestureInfo>& gestureInfo, const std::shared_ptr<BaseGestureEvent>& info) {
1534         return GestureJudgeResult::REJECT;};
1535     targetComponent->SetOnGestureJudgeBegin(gestureJudgeFunc);
1536     TouchEvent touchEvent;
1537     touchEvent.id = 1;
1538     touchEvent.SetX(-100);
1539     touchEvent.SetY(200);
1540     TouchEvent touchEvent2;
1541     touchEvent2.id = 2;
1542     touchEvent2.SetX(0);
1543     touchEvent2.SetY(0);
1544     rotationRecognizerPtr->targetComponent_ = targetComponent;
1545 
1546     rotationRecognizerPtr->refereeState_ = RefereeState::DETECTING;
1547     rotationRecognizerPtr->currentFingers_ = 2;
1548     rotationRecognizerPtr->fingers_ = 2;
1549     rotationRecognizerPtr->activeFingers_.push_back(touchEvent.id);
1550     rotationRecognizerPtr->activeFingers_.push_back(touchEvent2.id);
1551     rotationRecognizerPtr->angle_ = 0;
1552     rotationRecognizerPtr->lastAngle_ = 10;
1553 
1554     rotationRecognizerPtr->touchPoints_[touchEvent2.id] = touchEvent2;
1555     rotationRecognizerPtr->touchPoints_[touchEvent.id] = touchEvent;
1556     rotationRecognizerPtr->HandleTouchMoveEvent(touchEvent);
1557     EXPECT_EQ(rotationRecognizerPtr->angleSignChanged_, false);
1558 
1559     touchEvent.SetX(100);
1560     rotationRecognizerPtr->lastAngle_ = -10;
1561     rotationRecognizerPtr->activeFingers_.clear();
1562     rotationRecognizerPtr->activeFingers_.push_back(touchEvent.id);
1563     rotationRecognizerPtr->activeFingers_.push_back(touchEvent2.id);
1564     rotationRecognizerPtr->touchPoints_.clear();
1565     rotationRecognizerPtr->touchPoints_[touchEvent2.id] = touchEvent2;
1566     rotationRecognizerPtr->touchPoints_[touchEvent.id] = touchEvent;
1567     rotationRecognizerPtr->refereeState_ = RefereeState::DETECTING;
1568     rotationRecognizerPtr->HandleTouchMoveEvent(touchEvent);
1569     EXPECT_EQ(rotationRecognizerPtr->angleSignChanged_, false);
1570 }
1571 
1572 /**
1573  * @tc.name: RotationRecognizerPtrHandleTouchUpEventTest005
1574  * @tc.desc: Test RotationRecognizer function: HandleTouchUpEvent
1575  * @tc.type: FUNC
1576  */
1577 HWTEST_F(RotationRecognizerTestNg, RotationRecognizerPtrHandleTouchUpEventTest005, TestSize.Level1)
1578 {
1579     RefPtr<RotationRecognizer> rotationRecognizerPtr =
1580         AceType::MakeRefPtr<RotationRecognizer>(SINGLE_FINGER_NUMBER, ROTATION_GESTURE_ANGLE);
1581     RefPtr<NG::TargetComponent> targetComponent = AceType::MakeRefPtr<TargetComponent>();
__anon9c07e5eb0e02(const RefPtr<GestureInfo>& gestureInfo, const std::shared_ptr<BaseGestureEvent>& info) 1582     auto gestureJudgeFunc = [](const RefPtr<GestureInfo>& gestureInfo, const std::shared_ptr<BaseGestureEvent>& info) {
1583         return GestureJudgeResult::REJECT;};
1584     targetComponent->SetOnGestureJudgeBegin(gestureJudgeFunc);
1585     TouchEvent touchEvent;
1586     touchEvent.id = 1;
1587     touchEvent.SetX(-100);
1588     touchEvent.SetY(200);
1589     TouchEvent touchEvent2;
1590     touchEvent2.id = 2;
1591     touchEvent2.SetX(0);
1592     touchEvent2.SetY(0);
1593     rotationRecognizerPtr->targetComponent_ = targetComponent;
1594 
1595     rotationRecognizerPtr->refereeState_ = RefereeState::SUCCEED;
1596     rotationRecognizerPtr->currentFingers_ = 2;
1597     rotationRecognizerPtr->fingers_ = 1;
1598     rotationRecognizerPtr->activeFingers_.push_back(touchEvent.id);
1599     rotationRecognizerPtr->activeFingers_.push_back(touchEvent2.id);
1600     rotationRecognizerPtr->isLimitFingerCount_ = true;
1601     rotationRecognizerPtr->lastAngle_ = 10;
1602 
1603     rotationRecognizerPtr->touchPoints_[touchEvent2.id] = touchEvent2;
1604     rotationRecognizerPtr->touchPoints_[touchEvent.id] = touchEvent;
1605     rotationRecognizerPtr->HandleTouchMoveEvent(touchEvent);
1606     EXPECT_EQ(rotationRecognizerPtr->angleSignChanged_, false);
1607 
1608     rotationRecognizerPtr->fingers_ = 2;
1609     rotationRecognizerPtr->refereeState_ = RefereeState::SUCCEED;
1610     rotationRecognizerPtr->HandleTouchMoveEvent(touchEvent);
1611     EXPECT_EQ(rotationRecognizerPtr->angleSignChanged_, false);
1612 
1613     rotationRecognizerPtr->isLimitFingerCount_ = false;
1614     rotationRecognizerPtr->fingers_ = 1;
1615     rotationRecognizerPtr->refereeState_ = RefereeState::SUCCEED;
1616     rotationRecognizerPtr->HandleTouchMoveEvent(touchEvent);
1617     EXPECT_EQ(rotationRecognizerPtr->angleSignChanged_, false);
1618 
1619     rotationRecognizerPtr->isLimitFingerCount_ = false;
1620     rotationRecognizerPtr->fingers_ = 2;
1621     rotationRecognizerPtr->refereeState_ = RefereeState::SUCCEED;
1622     rotationRecognizerPtr->HandleTouchMoveEvent(touchEvent);
1623     EXPECT_EQ(rotationRecognizerPtr->angleSignChanged_, false);
1624 }
1625 
1626 /**
1627  * @tc.name: HandleTouchCancelEvent001
1628  * @tc.desc: Test RotationRecognizer function: HandleTouchCancelEvent
1629  * @tc.type: FUNC
1630  */
1631 HWTEST_F(RotationRecognizerTestNg, HandleTouchCancelEvent001, TestSize.Level1)
1632 {
1633     int32_t DEFAULT_ROTATION_FINGERS = 2;
1634     RefPtr<RotationRecognizer> rotationRecognizerPtr =
1635         AceType::MakeRefPtr<RotationRecognizer>(SINGLE_FINGER_NUMBER, ROTATION_GESTURE_ANGLE);
1636     RefPtr<NG::TargetComponent> targetComponent = AceType::MakeRefPtr<TargetComponent>();
__anon9c07e5eb0f02(const RefPtr<GestureInfo>& gestureInfo, const std::shared_ptr<BaseGestureEvent>& info) 1637     auto gestureJudgeFunc = [](const RefPtr<GestureInfo>& gestureInfo, const std::shared_ptr<BaseGestureEvent>& info) {
1638         return GestureJudgeResult::REJECT;};
1639     targetComponent->SetOnGestureJudgeBegin(gestureJudgeFunc);
1640     TouchEvent touchEvent;
1641     rotationRecognizerPtr->targetComponent_ = targetComponent;
1642     rotationRecognizerPtr->refereeState_ = RefereeState::FAIL;
1643     rotationRecognizerPtr->activeFingers_.push_back(touchEvent.id);
1644     rotationRecognizerPtr->activeFingers_.push_back(1);
1645     rotationRecognizerPtr->HandleTouchCancelEvent(touchEvent);
1646     EXPECT_EQ(rotationRecognizerPtr->activeFingers_.size(), DEFAULT_ROTATION_FINGERS);
1647 
1648     rotationRecognizerPtr->refereeState_ = RefereeState::SUCCEED;
1649     rotationRecognizerPtr->activeFingers_.push_back(touchEvent.id);
1650     rotationRecognizerPtr->HandleTouchCancelEvent(touchEvent);
1651     EXPECT_EQ(rotationRecognizerPtr->angleSignChanged_, false);
1652 
1653     rotationRecognizerPtr->refereeState_ = RefereeState::FAIL;
1654     rotationRecognizerPtr->activeFingers_.push_back(touchEvent.id);
1655     rotationRecognizerPtr->HandleTouchCancelEvent(touchEvent);
1656     EXPECT_EQ(rotationRecognizerPtr->angleSignChanged_, false);
1657 }
1658 
1659 /**
1660  * @tc.name: HandleTouchCancelEvent002
1661  * @tc.desc: Test RotationRecognizer function: HandleTouchCancelEvent
1662  * @tc.type: FUNC
1663  */
1664 HWTEST_F(RotationRecognizerTestNg, HandleTouchCancelEvent002, TestSize.Level1)
1665 {
1666     RefPtr<RotationRecognizer> rotationRecognizerPtr =
1667         AceType::MakeRefPtr<RotationRecognizer>(SINGLE_FINGER_NUMBER, ROTATION_GESTURE_ANGLE);
1668     RefPtr<NG::TargetComponent> targetComponent = AceType::MakeRefPtr<TargetComponent>();
__anon9c07e5eb1002(const RefPtr<GestureInfo>& gestureInfo, const std::shared_ptr<BaseGestureEvent>& info) 1669     auto gestureJudgeFunc = [](const RefPtr<GestureInfo>& gestureInfo, const std::shared_ptr<BaseGestureEvent>& info) {
1670         return GestureJudgeResult::REJECT;};
1671     targetComponent->SetOnGestureJudgeBegin(gestureJudgeFunc);
1672     AxisEvent axisEvent;
1673     rotationRecognizerPtr->targetComponent_ = targetComponent;
1674     rotationRecognizerPtr->refereeState_ = RefereeState::SUCCEED;
1675     rotationRecognizerPtr->HandleTouchCancelEvent(axisEvent);
1676     EXPECT_EQ(rotationRecognizerPtr->angleSignChanged_, false);
1677 }
1678 
1679 /**
1680  * @tc.name: SendCallbackMsg001
1681  * @tc.desc: Test RotationRecognizer function: SendCallbackMsg
1682  * @tc.type: FUNC
1683  */
1684 HWTEST_F(RotationRecognizerTestNg, SendCallbackMsg001, TestSize.Level1)
1685 {
1686     RefPtr<RotationRecognizer> rotationRecognizerPtr =
1687         AceType::MakeRefPtr<RotationRecognizer>(SINGLE_FINGER_NUMBER, ROTATION_GESTURE_ANGLE);
1688     OHOS::Ace::GestureEventFunc onActionCancel1;
1689     std::unique_ptr<GestureEventFunc> onActionCancel =  std::make_unique<GestureEventFunc>();
1690     rotationRecognizerPtr->SetOnActionCancel(onActionCancel1);
1691     rotationRecognizerPtr->SendCallbackMsg(onActionCancel, GestureCallbackType::CANCEL);
1692     EXPECT_NE(rotationRecognizerPtr->onActionCancel_, nullptr);
1693 
1694     auto gestureInfo = AceType::MakeRefPtr<GestureInfo>();
1695     rotationRecognizerPtr->SetGestureInfo(gestureInfo);
1696     rotationRecognizerPtr->SendCallbackMsg(onActionCancel, GestureCallbackType::CANCEL);
1697     EXPECT_FALSE(gestureInfo->disposeTag_);
1698 
1699     gestureInfo->SetDisposeTag(true);
1700     rotationRecognizerPtr->SetGestureInfo(gestureInfo);
1701     rotationRecognizerPtr->SendCallbackMsg(onActionCancel, GestureCallbackType::CANCEL);
1702     EXPECT_TRUE(gestureInfo->disposeTag_);
1703 }
1704 
1705 /**
1706  * @tc.name: RotationRecognizerBasicInfoTest001
1707  * @tc.desc: Test case basic input info check.
1708  * @tc.type: FUNC
1709  */
1710 HWTEST_F(RotationRecognizerTestNg, RotationRecognizerBasicInfoTest001, TestSize.Level1)
1711 {
1712     /**
1713       * @tc.steps: step1. Create basic info testCases.
1714       * @tc.expected: set rotationRecognizer basic info correct.
1715       */
1716     const std::vector<MockRotationRecognizerCase> mockRotationRecognizerCases = {
1717         {2, 1, RefereeState::READY, 2, 1, RefereeState::READY, {}},
1718         {2, -1, RefereeState::READY, 2, -1, RefereeState::READY, {}},
1719         {-1, 1, RefereeState::READY, 2, 1, RefereeState::READY, {}},
1720     };
1721     for (auto i = 0; i < mockRotationRecognizerCases.size(); i++) {
1722         RefPtr<RotationRecognizer> rotationRecognizer = AceType::MakeRefPtr<RotationRecognizer>(mockRotationRecognizerCases[i].fingers, mockRotationRecognizerCases[i].angle);
1723         rotationRecognizer->refereeState_ = mockRotationRecognizerCases[i].refereeState;
1724         EXPECT_EQ(rotationRecognizer->angle_, mockRotationRecognizerCases[i].expectedAngle);
1725         EXPECT_EQ(rotationRecognizer->fingers_, mockRotationRecognizerCases[i].expectedFingers);
1726         EXPECT_EQ(rotationRecognizer->refereeState_, mockRotationRecognizerCases[i].expectedRefereeState);
1727     }
1728 }
1729 
1730 /**
1731   * @tc.name: RotationRecognizerInjectEventsTest001
1732   * @tc.desc: Test case inject events.
1733   * @tc.type: FUNC
1734   */
1735 HWTEST_F(RotationRecognizerTestNg, RotationRecognizerInjectEventsTest001, TestSize.Level1)
1736 {
1737     /**
1738       * @tc.steps: step1. Create basic info testCases.
1739       * @tc.expected: set rotationRecognizer basic info correct.
1740       */
1741     TouchEvent downEventFinger0 = TouchEvent();
1742     downEventFinger0.type = TouchType::DOWN;
1743     downEventFinger0.id = 0;
1744 
1745     TouchEvent moveEventFinger0 = TouchEvent();
1746     moveEventFinger0.type = TouchType::MOVE;
1747     moveEventFinger0.id = 0;
1748 
1749     TouchEvent upEventFinger0 = TouchEvent();
1750     upEventFinger0.type = TouchType::UP;
1751     upEventFinger0.id = 0;
1752 
1753     const std::vector<MockRotationRecognizerCase> mockRotationRecognizerCases = {
1754         {2, 1, RefereeState::READY, 2, 1, RefereeState::READY, {downEventFinger0}},
1755         {2, -1, RefereeState::READY, 2, -1, RefereeState::READY, {downEventFinger0, moveEventFinger0}},
1756         {2, 1, RefereeState::READY, 2, 1, RefereeState::FAIL, {downEventFinger0, moveEventFinger0, upEventFinger0}},
1757     };
1758     for (auto i = 0; i < mockRotationRecognizerCases.size(); i++) {
1759         RefPtr<RotationRecognizer> rotationRecognizer = AceType::MakeRefPtr<RotationRecognizer>(mockRotationRecognizerCases[i].fingers, mockRotationRecognizerCases[i].angle);
1760         rotationRecognizer->refereeState_ = mockRotationRecognizerCases[i].refereeState;
1761         for (auto j = 0; j < mockRotationRecognizerCases[i].inputTouchEvents.size(); j++) {
1762             rotationRecognizer->ProcessTouchEvent(mockRotationRecognizerCases[i].inputTouchEvents[j]);
1763         }
1764         EXPECT_EQ(rotationRecognizer->angle_, mockRotationRecognizerCases[i].expectedAngle);
1765         EXPECT_EQ(rotationRecognizer->fingers_, mockRotationRecognizerCases[i].expectedFingers);
1766         EXPECT_EQ(rotationRecognizer->refereeState_, mockRotationRecognizerCases[i].expectedRefereeState);
1767     }
1768 }
1769 
1770 /**
1771   * @tc.name: RotationRecognizerInjectEventsTest002
1772   * @tc.desc: Test case inject events.
1773   * @tc.type: FUNC
1774   */
1775 HWTEST_F(RotationRecognizerTestNg, RotationRecognizerInjectEventsTest002, TestSize.Level1)
1776 {
1777     /**
1778       * @tc.steps: step1. Create basic info testCases.
1779       * @tc.expected: set rotationRecognizer basic info correct.
1780       */
1781     TouchEvent downEventFinger0 = TouchEvent();
1782     TouchEvent downEventFinger1 = TouchEvent();
1783     downEventFinger0.type = TouchType::DOWN;
1784     downEventFinger1.type = TouchType::DOWN;
1785     downEventFinger0.id = 0;
1786     downEventFinger1.id = 1;
1787 
1788     TouchEvent moveEventFinger0 = TouchEvent();
1789     TouchEvent moveEventFinger1 = TouchEvent();
1790     moveEventFinger0.type = TouchType::MOVE;
1791     moveEventFinger1.type = TouchType::MOVE;
1792     moveEventFinger0.id = 0;
1793     moveEventFinger1.id = 1;
1794 
1795     TouchEvent upEventFinger0 = TouchEvent();
1796     TouchEvent upEventFinger1 = TouchEvent();
1797     upEventFinger0.type = TouchType::UP;
1798     upEventFinger1.type = TouchType::UP;
1799     upEventFinger0.id = 0;
1800     upEventFinger1.id = 1;
1801 
1802     const std::vector<MockRotationRecognizerCase> mockRotationRecognizerCases = {
1803         {2, 1, RefereeState::READY, 2, 1, RefereeState::DETECTING, {downEventFinger0, downEventFinger1}},
1804         {2, 1, RefereeState::READY, 2, 1, RefereeState::DETECTING,
1805             {downEventFinger0, downEventFinger1, moveEventFinger0, moveEventFinger1}},
1806         {2, 1, RefereeState::READY, 2, 1, RefereeState::FAIL,
1807             {downEventFinger0, downEventFinger1, moveEventFinger0, moveEventFinger1, upEventFinger0, upEventFinger1}},
1808         {2, -1, RefereeState::READY, 2, -1, RefereeState::SUCCEED,
1809             {downEventFinger0, downEventFinger1, moveEventFinger0, moveEventFinger1}},
1810     };
1811     for (auto i = 0; i < mockRotationRecognizerCases.size(); i++) {
1812         RefPtr<RotationRecognizer> rotationRecognizer = AceType::MakeRefPtr<RotationRecognizer>(
1813             mockRotationRecognizerCases[i].fingers, mockRotationRecognizerCases[i].angle);
1814         rotationRecognizer->refereeState_ = mockRotationRecognizerCases[i].refereeState;
1815         for (auto j = 0; j < mockRotationRecognizerCases[i].inputTouchEvents.size(); j++) {
1816             rotationRecognizer->ProcessTouchEvent(mockRotationRecognizerCases[i].inputTouchEvents[j]);
1817         }
1818         EXPECT_EQ(rotationRecognizer->angle_, mockRotationRecognizerCases[i].expectedAngle);
1819         EXPECT_EQ(rotationRecognizer->fingers_, mockRotationRecognizerCases[i].expectedFingers);
1820         EXPECT_EQ(rotationRecognizer->refereeState_, mockRotationRecognizerCases[i].expectedRefereeState);
1821     }
1822 }
1823 
1824 /**
1825  * @tc.name: RotationRecognizerTypeTest001
1826  * @tc.desc: Test RotationRecognizerType
1827  * @tc.type: FUNC
1828  */
1829 HWTEST_F(RotationRecognizerTestNg, RotationRecognizerTypeTest001, TestSize.Level1)
1830 {
1831     RefPtr<RotationRecognizer> rotationRecognizerPtr =
1832         AceType::MakeRefPtr<RotationRecognizer>(SINGLE_FINGER_NUMBER, ROTATION_GESTURE_ANGLE);
1833     auto frameNode = FrameNode::CreateFrameNode("myButton", 100, AceType::MakeRefPtr<Pattern>());
1834     rotationRecognizerPtr->AttachFrameNode(frameNode);
1835     rotationRecognizerPtr->SetRecognizerType(GestureTypeName::ROTATION_GESTURE);
1836 
1837     GestureEvent info;
1838     rotationRecognizerPtr->HandleReports(info, GestureCallbackType::END);
1839     EXPECT_EQ(rotationRecognizerPtr->GetRecognizerType(), GestureTypeName::ROTATION_GESTURE);
1840 }
1841 } // namespace OHOS::Ace::NG