1 /*
2  * Copyright (C) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <gtest/gtest.h>
17 #include <unistd.h>
18 #include "accessibility_touch_guider.h"
19 #include "accessibility_account_data.h"
20 #include "accessibility_common_helper.h"
21 #include "accessibility_display_manager.h"
22 #include "accessibility_element_operator_stub.h"
23 #include "accessibility_input_interceptor.h"
24 #include "accessibility_mt_helper.h"
25 #include "accessible_ability_channel.h"
26 #include "accessible_ability_connection.h"
27 #include "accessible_ability_manager_service.h"
28 #include "iservice_registry.h"
29 #include "mock_accessibility_element_operator_callback.h"
30 #include "mock_accessibility_element_operator_impl.h"
31 #include "mock_accessibility_element_operator_proxy.h"
32 #include "mock_input_manager.h"
33 
34 using namespace testing;
35 using namespace testing::ext;
36 
37 namespace OHOS {
38 namespace Accessibility {
39 namespace {
40     constexpr int32_t POINT_ID_0 = 0;
41     constexpr int32_t POINT_ID_1 = 1;
42     constexpr int32_t POINT_ID_2 = 2;
43     const int32_t SLEEP_TIME_3 = 3;
44     const int32_t TAP_TIMES_1 = 1;
45     const int32_t TAP_TIMES_2 = 2;
46     const int32_t TAP_TIMES_3 = 3;
47     const int64_t TAP_TIME_INTERVAL = 100000;
48     const int32_t POINTER_ACTION_INVALID = -1;
49 } // namespace
50 
51 class MockAamsTouchGuideTest : public testing::Test {
52 public:
MockAamsTouchGuideTest()53     MockAamsTouchGuideTest()
54     {}
~MockAamsTouchGuideTest()55     ~MockAamsTouchGuideTest()
56     {}
57     static void SetUpTestCase();
58     static void TearDownTestCase();
59     static void TouchGuiderPointSet(MMI::PointerEvent::PointerItem &point, int id, int x, int y);
60     bool OnPointerEventOnePointsTest1(std::vector<MMI::PointerEvent::PointerItem> &points,
61         MMI::PointerEvent::PointerItem point1, MMI::PointerEvent::PointerItem point2,
62         MMI::PointerEvent::PointerItem point3, MMI::PointerEvent::PointerItem point4);
63     bool OnPointerEventOnePointsTest3(std::vector<MMI::PointerEvent::PointerItem> &point,
64         MMI::PointerEvent::PointerItem point1, MMI::PointerEvent::PointerItem point2,
65         MMI::PointerEvent::PointerItem point3, MMI::PointerEvent::PointerItem point4);
66     bool OnPointerEventOnePointsTest7(std::vector<MMI::PointerEvent::PointerItem> &points,
67         MMI::PointerEvent::PointerItem point1, MMI::PointerEvent::PointerItem point2,
68         MMI::PointerEvent::PointerItem point3);
69     bool TwoFingerTapEventProduce(std::vector<MMI::PointerEvent::PointerItem> &points,
70         MMI::PointerEvent::PointerItem point1, MMI::PointerEvent::PointerItem point2, int32_t tapTimes,
71         bool holdFlag);
72     bool TwoFingerMoveEventProduce(std::vector<MMI::PointerEvent::PointerItem> &points,
73         MMI::PointerEvent::PointerItem point1, MMI::PointerEvent::PointerItem point2,
74         MMI::PointerEvent::PointerItem point3, MMI::PointerEvent::PointerItem point4);
75     bool OneFingerTapAndTwoFingerTapEventProduce(std::vector<MMI::PointerEvent::PointerItem> &points,
76         MMI::PointerEvent::PointerItem point1, MMI::PointerEvent::PointerItem point2, bool isSeparateFlag);
77     bool TwoFingerTapAndOneFingerTapEventProduce(std::vector<MMI::PointerEvent::PointerItem> &points,
78         MMI::PointerEvent::PointerItem point1, MMI::PointerEvent::PointerItem point2);
79     bool MultiFingerTapEventProduce(std::vector<MMI::PointerEvent::PointerItem> &points,
80         std::vector<MMI::PointerEvent::PointerItem> &pointsVec, int32_t tapTimes, bool holdFlag);
81     bool MultiFingerTapAndMoveEventProduce(std::vector<MMI::PointerEvent::PointerItem> &points,
82         std::vector<MMI::PointerEvent::PointerItem> &pointStartVec,
83         std::vector<MMI::PointerEvent::PointerItem> &pointEndVec);
84     void SetUp();
85     void TearDown();
86 
87 protected:
88     std::shared_ptr<MMI::PointerEvent> CreateMoveEvent(int32_t pointerCount, int32_t pointId);
89     std::shared_ptr<MMI::PointerEvent> CreateTouchEvent(int32_t action, int32_t pointId);
90     std::shared_ptr<MMI::PointerEvent> CreateTouchEvent(int32_t action,
91         std::vector<MMI::PointerEvent::PointerItem> &point, int64_t occurredTime, int64_t startTime,
92         int32_t pointId);
93 
94     sptr<AccessibleAbilityChannel> aastub_ = nullptr;
95     std::shared_ptr<MMI::IInputEventConsumer> interceptorId_ = nullptr;
96     void WritefileAll(const char* fname, const char* data);
97     void AddAccessibilityWindowConnection();
98 };
99 
OnPointerEventOnePointsTest1(std::vector<MMI::PointerEvent::PointerItem> &points, MMI::PointerEvent::PointerItem point1, MMI::PointerEvent::PointerItem point2, MMI::PointerEvent::PointerItem point3, MMI::PointerEvent::PointerItem point4)100 bool MockAamsTouchGuideTest::OnPointerEventOnePointsTest1(std::vector<MMI::PointerEvent::PointerItem> &points,
101     MMI::PointerEvent::PointerItem point1, MMI::PointerEvent::PointerItem point2,
102     MMI::PointerEvent::PointerItem point3, MMI::PointerEvent::PointerItem point4)
103 {
104     points.emplace_back(point1);
105     std::shared_ptr<MMI::PointerEvent> event =
106         CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, 0, 0, 1);
107     auto inputEventConsumer = MMI::MockInputManager::GetInputEventConsumer();
108     if (!inputEventConsumer) {
109         return false;
110     }
111     inputEventConsumer->OnInputEvent(event);
112 
113     points.emplace_back(point2);
114     event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, 0, 0, POINT_ID_2);
115     inputEventConsumer->OnInputEvent(event);
116 
117     event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, points, 0, 0, 1);
118     inputEventConsumer->OnInputEvent(event);
119 
120     points.clear();
121     points.emplace_back(point3);
122     points.emplace_back(point4);
123     event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, points, 0, 0, POINT_ID_2);
124     inputEventConsumer->OnInputEvent(event);
125 
126     points.clear();
127     points.emplace_back(point3);
128     event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, 0, 0, 1);
129     inputEventConsumer->OnInputEvent(event);
130 
131     points.clear();
132     points.emplace_back(point4);
133     event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, 0, 0, POINT_ID_2);
134     inputEventConsumer->OnInputEvent(event);
135     return true;
136 }
137 
OnPointerEventOnePointsTest3(std::vector<MMI::PointerEvent::PointerItem> &point, MMI::PointerEvent::PointerItem point1, MMI::PointerEvent::PointerItem point2, MMI::PointerEvent::PointerItem point3, MMI::PointerEvent::PointerItem point4)138 bool MockAamsTouchGuideTest::OnPointerEventOnePointsTest3(std::vector<MMI::PointerEvent::PointerItem> &point,
139     MMI::PointerEvent::PointerItem point1, MMI::PointerEvent::PointerItem point2,
140     MMI::PointerEvent::PointerItem point3, MMI::PointerEvent::PointerItem point4)
141 {
142     point.emplace_back(point1);
143     std::shared_ptr<MMI::PointerEvent> event =
144         CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, point, 0, 0, 1);
145     auto inputEventConsumer = MMI::MockInputManager::GetInputEventConsumer();
146     if (!inputEventConsumer) {
147         // GTEST_LOG_(INFO) << "MockAamsTouchGuideTest OnPointerEvent003 inputEventConsumer is null";
148         return false;
149     }
150     inputEventConsumer->OnInputEvent(event);
151 
152     point.clear();
153     point.emplace_back(point2);
154     event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, point, 0, 0, 1);
155     inputEventConsumer->OnInputEvent(event);
156 
157     point.clear();
158     point.emplace_back(point3);
159     event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, point, 0, 0, 1);
160     inputEventConsumer->OnInputEvent(event);
161 
162     point.clear();
163     point.emplace_back(point4);
164     event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, point, 0, 0, 1);
165     inputEventConsumer->OnInputEvent(event);
166 
167     event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, point, 0, 0, 1);
168     inputEventConsumer->OnInputEvent(event);
169     return true;
170 }
171 
OnPointerEventOnePointsTest7(std::vector<MMI::PointerEvent::PointerItem> &points, MMI::PointerEvent::PointerItem point1, MMI::PointerEvent::PointerItem point2, MMI::PointerEvent::PointerItem point3)172 bool MockAamsTouchGuideTest::OnPointerEventOnePointsTest7(std::vector<MMI::PointerEvent::PointerItem> &points,
173     MMI::PointerEvent::PointerItem point1, MMI::PointerEvent::PointerItem point2,
174     MMI::PointerEvent::PointerItem point3)
175 {
176     points.emplace_back(point1);
177     std::shared_ptr<MMI::PointerEvent> event =
178         CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, 0, 0, 1);
179     auto inputEventConsumer = MMI::MockInputManager::GetInputEventConsumer();
180     if (!inputEventConsumer) {
181         return false;
182     }
183     inputEventConsumer->OnInputEvent(event);
184 
185     points.clear();
186     points.emplace_back(point2);
187     event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, points, 0, 0, 1);
188     inputEventConsumer->OnInputEvent(event);
189 
190     points.clear();
191     points.emplace_back(point3);
192     event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, points, 0, 0, 1);
193     inputEventConsumer->OnInputEvent(event);
194 
195     event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, 0, 0, 1);
196     inputEventConsumer->OnInputEvent(event);
197     return true;
198 }
199 
TwoFingerTapEventProduce(std::vector<MMI::PointerEvent::PointerItem> &points, MMI::PointerEvent::PointerItem point1, MMI::PointerEvent::PointerItem point2, int32_t tapTimes, bool holdFlag)200 bool MockAamsTouchGuideTest::TwoFingerTapEventProduce(std::vector<MMI::PointerEvent::PointerItem> &points,
201     MMI::PointerEvent::PointerItem point1, MMI::PointerEvent::PointerItem point2, int32_t tapTimes, bool holdFlag)
202 {
203     auto inputEventConsumer = MMI::MockInputManager::GetInputEventConsumer();
204     if (!inputEventConsumer) {
205         GTEST_LOG_(INFO) << "MockAamsTouchGuideTest TwoFingerTapEventProduce inputEventConsumer is nullptr";
206         return false;
207     }
208 
209     std::shared_ptr<MMI::PointerEvent> event;
210     int64_t occurredTime = 0;
211     for (int32_t tapIndex = 1; tapIndex <= tapTimes; tapIndex++) {
212         points.clear();
213         points.emplace_back(point1);
214         event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, occurredTime, 0, POINT_ID_0);
215         inputEventConsumer->OnInputEvent(event);
216 
217         points.emplace_back(point2);
218         event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, occurredTime, 0, POINT_ID_1);
219         inputEventConsumer->OnInputEvent(event);
220 
221         event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, points, 0, 0, POINT_ID_0);
222         inputEventConsumer->OnInputEvent(event);
223 
224         if (holdFlag && tapIndex == tapTimes) {
225             sleep(1);
226         }
227 
228         event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, 0, 0, POINT_ID_0);
229         inputEventConsumer->OnInputEvent(event);
230 
231         points.clear();
232         points.emplace_back(point2);
233         event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, 0, 0, POINT_ID_1);
234         inputEventConsumer->OnInputEvent(event);
235 
236         occurredTime += TAP_TIME_INTERVAL;
237     }
238     return true;
239 }
240 
TwoFingerMoveEventProduce(std::vector<MMI::PointerEvent::PointerItem> &points, MMI::PointerEvent::PointerItem point1, MMI::PointerEvent::PointerItem point2, MMI::PointerEvent::PointerItem point3, MMI::PointerEvent::PointerItem point4)241 bool MockAamsTouchGuideTest::TwoFingerMoveEventProduce(std::vector<MMI::PointerEvent::PointerItem> &points,
242     MMI::PointerEvent::PointerItem point1, MMI::PointerEvent::PointerItem point2,
243     MMI::PointerEvent::PointerItem point3, MMI::PointerEvent::PointerItem point4)
244 {
245     auto inputEventConsumer = MMI::MockInputManager::GetInputEventConsumer();
246     if (!inputEventConsumer) {
247         GTEST_LOG_(INFO) << "MockAamsTouchGuideTest TwoFingerMoveEventProduce inputEventConsumer is null";
248         return false;
249     }
250 
251     std::shared_ptr<MMI::PointerEvent> event;
252     points.clear();
253     points.emplace_back(point1);
254     event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, 0, 0, POINT_ID_0);
255     inputEventConsumer->OnInputEvent(event);
256 
257     points.emplace_back(point2);
258     event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, 0, 0, POINT_ID_1);
259     inputEventConsumer->OnInputEvent(event);
260 
261     points.clear();
262     points.emplace_back(point3);
263     points.emplace_back(point4);
264     event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, points, 0, 0, POINT_ID_0);
265     inputEventConsumer->OnInputEvent(event);
266 
267     event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, points, 0, 0, POINT_ID_1);
268     inputEventConsumer->OnInputEvent(event);
269 
270     event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, 0, 0, POINT_ID_0);
271     inputEventConsumer->OnInputEvent(event);
272 
273     points.clear();
274     points.emplace_back(point4);
275     event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, 0, 0, POINT_ID_1);
276     inputEventConsumer->OnInputEvent(event);
277 
278     return true;
279 }
280 
OneFingerTapAndTwoFingerTapEventProduce(std::vector<MMI::PointerEvent::PointerItem> &pts, MMI::PointerEvent::PointerItem point1, MMI::PointerEvent::PointerItem point2, bool isSeparateFlag)281 bool MockAamsTouchGuideTest::OneFingerTapAndTwoFingerTapEventProduce(std::vector<MMI::PointerEvent::PointerItem> &pts,
282     MMI::PointerEvent::PointerItem point1, MMI::PointerEvent::PointerItem point2, bool isSeparateFlag)
283 {
284     auto inputEventConsumer = MMI::MockInputManager::GetInputEventConsumer();
285     if (!inputEventConsumer) {
286         GTEST_LOG_(INFO) << "MockAamsTouchGuideTest OneFingerTapAndTwoFingerTapEventProduce inputEventConsumer is null";
287         return false;
288     }
289 
290     std::shared_ptr<MMI::PointerEvent> event;
291     // one finger event start
292     pts.clear();
293     pts.emplace_back(point1);
294     event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, pts, 0, 0, POINT_ID_0);
295     inputEventConsumer->OnInputEvent(event);
296 
297     event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, pts, 0, 0, POINT_ID_0);
298     inputEventConsumer->OnInputEvent(event);
299 
300     if (isSeparateFlag) {
301         sleep(1);
302     }
303     // two finger event start
304     event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, pts, TAP_TIME_INTERVAL, 0, POINT_ID_0);
305     inputEventConsumer->OnInputEvent(event);
306 
307     pts.emplace_back(point2);
308     event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, pts, TAP_TIME_INTERVAL, 0, POINT_ID_1);
309     inputEventConsumer->OnInputEvent(event);
310 
311     event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, pts, 0, 0, POINT_ID_0);
312     inputEventConsumer->OnInputEvent(event);
313 
314     event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, pts, 0, 0, POINT_ID_0);
315     inputEventConsumer->OnInputEvent(event);
316 
317     pts.clear();
318     pts.emplace_back(point2);
319     event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, pts, 0, 0, POINT_ID_1);
320     inputEventConsumer->OnInputEvent(event);
321 
322     return true;
323 }
324 
TwoFingerTapAndOneFingerTapEventProduce(std::vector<MMI::PointerEvent::PointerItem> &pts, MMI::PointerEvent::PointerItem point1, MMI::PointerEvent::PointerItem point2)325 bool MockAamsTouchGuideTest::TwoFingerTapAndOneFingerTapEventProduce(std::vector<MMI::PointerEvent::PointerItem> &pts,
326     MMI::PointerEvent::PointerItem point1, MMI::PointerEvent::PointerItem point2)
327 {
328     auto inputEventConsumer = MMI::MockInputManager::GetInputEventConsumer();
329     if (!inputEventConsumer) {
330         GTEST_LOG_(INFO) << "MockAamsTouchGuideTest TwoFingerTapAndOneFingerTapEventProduce inputEventConsumer is null";
331         return false;
332     }
333 
334     std::shared_ptr<MMI::PointerEvent> event;
335     // two finger event start
336     pts.clear();
337     pts.emplace_back(point1);
338     event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, pts, 0, 0, POINT_ID_0);
339     inputEventConsumer->OnInputEvent(event);
340 
341     pts.emplace_back(point2);
342     event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, pts, 0, 0, POINT_ID_1);
343     inputEventConsumer->OnInputEvent(event);
344 
345     event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, pts, 0, 0, POINT_ID_0);
346     inputEventConsumer->OnInputEvent(event);
347 
348     event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, pts, 0, 0, POINT_ID_0);
349     inputEventConsumer->OnInputEvent(event);
350 
351     pts.clear();
352     pts.emplace_back(point2);
353     event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, pts, 0, 0, POINT_ID_1);
354 
355     // one finger event start
356     pts.clear();
357     pts.emplace_back(point1);
358     event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, pts, TAP_TIME_INTERVAL, 0, POINT_ID_0);
359     inputEventConsumer->OnInputEvent(event);
360 
361     event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, pts, 0, 0, POINT_ID_0);
362     inputEventConsumer->OnInputEvent(event);
363 
364     event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, pts, 0, 0, POINT_ID_0);
365     inputEventConsumer->OnInputEvent(event);
366 
367     return true;
368 }
369 
MultiFingerTapEventProduce(std::vector<MMI::PointerEvent::PointerItem> &points, std::vector<MMI::PointerEvent::PointerItem> &pointsVec, int32_t tapTimes, bool holdFlag)370 bool MockAamsTouchGuideTest::MultiFingerTapEventProduce(std::vector<MMI::PointerEvent::PointerItem> &points,
371     std::vector<MMI::PointerEvent::PointerItem> &pointsVec, int32_t tapTimes, bool holdFlag)
372 {
373     auto inputEventConsumer = MMI::MockInputManager::GetInputEventConsumer();
374     if (!inputEventConsumer) {
375         GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MultiFingerTapEventProduce inputEventConsumer is null";
376         return false;
377     }
378 
379     std::shared_ptr<MMI::PointerEvent> event;
380     int64_t occurredTime = 0;
381     for (int32_t tapIndex = 1; tapIndex <= tapTimes; tapIndex++) {
382         points.clear();
383         int32_t pId = 0;
384         for (auto iter : pointsVec) {
385             points.emplace_back(iter);
386             event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, occurredTime, 0, pId);
387             pId++;
388             inputEventConsumer->OnInputEvent(event);
389         }
390 
391         event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, points, 0, 0, POINT_ID_0);
392         inputEventConsumer->OnInputEvent(event);
393 
394         if (holdFlag && tapIndex == tapTimes) {
395             sleep(1);
396         }
397 
398         pId = pointsVec.size() - 1;
399         for (int32_t pointsVecIndex = 0; pointsVecIndex < pointsVec.size(); pointsVecIndex++) {
400             event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, occurredTime, 0, pId);
401             points.pop_back();
402             pId--;
403             inputEventConsumer->OnInputEvent(event);
404         }
405 
406         occurredTime += TAP_TIME_INTERVAL;
407     }
408     return true;
409 }
410 
MultiFingerTapAndMoveEventProduce(std::vector<MMI::PointerEvent::PointerItem> &points, std::vector<MMI::PointerEvent::PointerItem> &pointStartVec, std::vector<MMI::PointerEvent::PointerItem> &pointEndVec)411 bool MockAamsTouchGuideTest::MultiFingerTapAndMoveEventProduce(std::vector<MMI::PointerEvent::PointerItem> &points,
412     std::vector<MMI::PointerEvent::PointerItem> &pointStartVec,
413     std::vector<MMI::PointerEvent::PointerItem> &pointEndVec)
414 {
415     auto inputEventConsumer = MMI::MockInputManager::GetInputEventConsumer();
416     if (!inputEventConsumer) {
417         GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MultiFingerTapAndMoveEventProduce inputEventConsumer is null";
418         return false;
419     }
420 
421     std::shared_ptr<MMI::PointerEvent> event;
422     int64_t occurredTime = 0;
423     points.clear();
424     int32_t pId = 0;
425     for (auto iter : pointStartVec) {
426         points.emplace_back(iter);
427         event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, occurredTime, 0, pId);
428         pId++;
429         inputEventConsumer->OnInputEvent(event);
430     }
431 
432     points.clear();
433     for (auto iter : pointEndVec) {
434         points.emplace_back(iter);
435     }
436     event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, points, occurredTime, 0, 0);
437     inputEventConsumer->OnInputEvent(event);
438 
439     pId = pointEndVec.size() - 1;
440     for (int32_t pointsEndVecIndex = 0; pointsEndVecIndex < pointEndVec.size(); pointsEndVecIndex++) {
441         event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, occurredTime, 0, pId);
442         points.pop_back();
443         pId--;
444         inputEventConsumer->OnInputEvent(event);
445     }
446 
447     return true;
448 }
449 
TouchGuiderPointSet(MMI::PointerEvent::PointerItem &point, int id, int x, int y)450 void MockAamsTouchGuideTest::TouchGuiderPointSet(MMI::PointerEvent::PointerItem &point, int id, int x, int y)
451 {
452     point.SetPointerId(id);
453     point.SetDisplayX(x);
454     point.SetDisplayY(y);
455 }
456 
WritefileAll(const char* fname, const char* data)457 void MockAamsTouchGuideTest::WritefileAll(const char* fname, const char* data)
458 {
459     FILE* fp = nullptr;
460     if (!(fp = fopen(fname, "w"))) {
461         printf("open file %s fail \n", fname);
462         return;
463     }
464 
465     (void)fprintf(fp, "%s", data);
466     (void)fclose(fp);
467 }
468 
SetUpTestCase()469 void MockAamsTouchGuideTest::SetUpTestCase()
470 {
471     GTEST_LOG_(INFO) << "MockAamsTouchGuideTest SetUpTestCase";
472     Singleton<AccessibleAbilityManagerService>::GetInstance().OnStart();
473     AccessibilityCommonHelper::GetInstance().WaitForServicePublish();
474     Singleton<AccessibleAbilityManagerService>::GetInstance().SwitchedUser(AccessibilityHelper::accountId_);
475     GTEST_LOG_(INFO) << "AccessibleAbilityManagerService is published";
476 }
477 
TearDownTestCase()478 void MockAamsTouchGuideTest::TearDownTestCase()
479 {
480     GTEST_LOG_(INFO) << "MockAamsTouchGuideTest TearDownTestCase";
481     AccessibilityHelper::GetInstance().SetGestureId(0);
482     AccessibilityHelper::GetInstance().GetEventType().clear();
483     Singleton<AccessibleAbilityManagerService>::GetInstance().OnStop();
484 }
485 
SetUp()486 void MockAamsTouchGuideTest::SetUp()
487 {
488     GTEST_LOG_(INFO) << "MockAamsTouchGuideTest SetUp";
489 
490     interceptorId_ = std::make_shared<AccessibilityInputEventConsumer>();
491     MMI::InputManager::GetInstance()->AddInterceptor(interceptorId_);
492 
493     // add an ability connection client
494     AccessibilityAbilityInitParams initParams;
495     std::shared_ptr<AccessibilityAbilityInfo> abilityInfo = std::make_shared<AccessibilityAbilityInfo>(initParams);
496     abilityInfo->SetAccessibilityAbilityType(AccessibilityAbilityTypes::ACCESSIBILITY_ABILITY_TYPE_ALL);
497     abilityInfo->SetCapabilityValues(Capability::CAPABILITY_TOUCH_GUIDE);
498     AppExecFwk::ElementName elementName("deviceId", "bundleName", "name");
499     auto accountData = Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
500     accountData->AddInstalledAbility(*abilityInfo);
501     sleep(1);
502     sptr<AccessibleAbilityConnection> connection =
503         new AccessibleAbilityConnection(accountData->GetAccountId(), 0, *abilityInfo);
504     aastub_ = new AccessibleAbilityChannel(accountData->GetAccountId(), abilityInfo->GetId());
505     connection->OnAbilityConnectDoneSync(elementName, aastub_);
506 
507     AddAccessibilityWindowConnection();
508 }
509 
TearDown()510 void MockAamsTouchGuideTest::TearDown()
511 {
512     GTEST_LOG_(INFO) << "MockAamsTouchGuideTest TearDown";
513 
514     Singleton<AccessibleAbilityManagerService>::GetInstance().DeregisterElementOperator(0);
515     sleep(SLEEP_TIME_3);
516     aastub_ = nullptr;
517     interceptorId_ = nullptr;
518     AccessibilityHelper::GetInstance().SetGestureId(0);
519     AccessibilityHelper::GetInstance().GetEventType().clear();
520     MMI::MockInputManager::ClearTouchActions();
521 }
522 
CreateTouchEvent(int32_t action, int32_t pointId)523 std::shared_ptr<MMI::PointerEvent> MockAamsTouchGuideTest::CreateTouchEvent(int32_t action, int32_t pointId)
524 {
525     std::shared_ptr<MMI::PointerEvent> touchEvent = MMI::PointerEvent::Create();
526     MMI::PointerEvent::PointerItem item = {};
527 
528     item.SetPointerId(1);
529     item.SetPressed(action == MMI::PointerEvent::POINTER_ACTION_UP ? false : true);
530     touchEvent->AddPointerItem(item);
531     touchEvent->SetSourceType(MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
532     touchEvent->SetPointerAction(action);
533     touchEvent->SetPointerId(pointId);
534 
535     return touchEvent;
536 }
537 
CreateMoveEvent(int32_t pointerCount, int32_t pointId)538 std::shared_ptr<MMI::PointerEvent> MockAamsTouchGuideTest::CreateMoveEvent(int32_t pointerCount, int32_t pointId)
539 {
540     std::shared_ptr<MMI::PointerEvent> touchEvent = MMI::PointerEvent::Create();
541     MMI::PointerEvent::PointerItem item = {};
542 
543     for (int32_t i = 0; i < pointerCount; i++) {
544         item.SetPointerId(i + 1);
545         item.SetPressed(true);
546         touchEvent->AddPointerItem(item);
547     }
548     touchEvent->SetSourceType(MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
549     touchEvent->SetPointerAction(MMI::PointerEvent::POINTER_ACTION_MOVE);
550     touchEvent->SetPointerId(pointId);
551 
552     return touchEvent;
553 }
554 
CreateTouchEvent(int32_t action, std::vector<MMI::PointerEvent::PointerItem> &points, int64_t occurredTime, int64_t startTime, int32_t pointId)555 std::shared_ptr<MMI::PointerEvent> MockAamsTouchGuideTest::CreateTouchEvent(int32_t action,
556     std::vector<MMI::PointerEvent::PointerItem> &points, int64_t occurredTime, int64_t startTime,
557     int32_t pointId)
558 {
559     std::shared_ptr<MMI::PointerEvent> pointerEvent = MMI::PointerEvent::Create();
560 
561     for (auto &point : points) {
562         if (point.GetPointerId() == pointId) {
563             point.SetPressed(action == MMI::PointerEvent::POINTER_ACTION_UP ? false : true);
564         } else {
565             point.SetPressed(true);
566         }
567         pointerEvent->AddPointerItem(point);
568     }
569     pointerEvent->SetPointerId(pointId);
570     pointerEvent->SetSourceType(MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
571     pointerEvent->SetPointerAction(action);
572     pointerEvent->SetActionStartTime(startTime);
573     pointerEvent->SetActionTime(occurredTime);
574 
575     return pointerEvent;
576 }
577 
AddAccessibilityWindowConnection()578 void MockAamsTouchGuideTest::AddAccessibilityWindowConnection()
579 {
580     GTEST_LOG_(INFO) << "aamsAccessibleAbilityChannelTest AddAccessibilityWindowConnection";
581     // accessibility interaction connection
582     int32_t windowId = 0;
583     std::shared_ptr<MockAccessibilityElementOperatorCallback> mockCallback =
584         std::make_shared<MockAccessibilityElementOperatorCallback>();
585     sptr<AccessibilityElementOperatorStub> stub =
586         new MockAccessibilityElementOperatorImpl(windowId, nullptr, *mockCallback);
587     sptr<IAccessibilityElementOperator> proxy = new MockAccessibilityElementOperatorProxy(stub);
588     GTEST_LOG_(INFO) << "aams  RegisterElementOperator";
589     Singleton<AccessibleAbilityManagerService>::GetInstance().RegisterElementOperator(windowId, proxy, true);
590 }
591 
592 /**
593  * @tc.number: OnPointerEvent001
594  * @tc.name:OnPointerEvent
595  * @tc.desc: Check the event that two fingers moving in same directions in dragging state.
596  */
HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent001, TestSize.Level1)597 HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent001, TestSize.Level1)
598 {
599     GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent001 starts";
600     sleep(SLEEP_TIME_3);
601 
602     AccessibilityHelper::GetInstance().GetEventType() = {};
603     MMI::MockInputManager::ClearTouchActions();
604     std::vector<MMI::PointerEvent::PointerItem> points = {};
605     MMI::PointerEvent::PointerItem point1 = {};
606     TouchGuiderPointSet(point1, 1, 500, 500);
607     MMI::PointerEvent::PointerItem point2 = {};
608     TouchGuiderPointSet(point2, 2, 1000, 500);
609     MMI::PointerEvent::PointerItem point3 = {};
610     TouchGuiderPointSet(point3, 1, 2000, 500);
611     MMI::PointerEvent::PointerItem point4 = {};
612     TouchGuiderPointSet(point4, 1, 2500, 500);
613 
614     bool flag = OnPointerEventOnePointsTest1(points, point1, point2, point3, point4);
615     if (!flag) {
616         GTEST_LOG_(INFO) << "MockAamsTouchGuideTest OnPointerEvent001 inputEventConsumer is null";
617         return;
618     }
619 
620     bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool {
621         sleep(1);
622         int32_t eventTypeSize =
623             static_cast<int32_t>(AccessibilityHelper::GetInstance().GetEventType().size());
624         if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(eventTypeSize - 1) ==
625             EventType::TYPE_TOUCH_GUIDE_GESTURE_END) {
626             return true;
627         } else {
628             return false;
629         }
630         }), SLEEP_TIME_3);
631     EXPECT_TRUE(ret);
632     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN);
633 
634     ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool {
635         if (MMI::MockInputManager::GetTouchActionOfTargetIndex(2) == MMI::PointerEvent::POINTER_ACTION_UP) {
636             return true;
637         } else {
638             return false;
639         }
640         }), SLEEP_TIME_3);
641     EXPECT_TRUE(ret);
642     EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(0), MMI::PointerEvent::POINTER_ACTION_DOWN);
643     EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(1), MMI::PointerEvent::POINTER_ACTION_MOVE);
644     GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent001 ENDs";
645 }
646 
647 /**
648  * @tc.number: OnPointerEvent002
649  * @tc.name:OnPointerEvent
650  * @tc.desc: Check the event that move slowly with one finger.
651  */
HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent002, TestSize.Level1)652 HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent002, TestSize.Level1)
653 {
654     GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent002 starts";
655 
656     AccessibilityHelper::GetInstance().GetEventType() = {};
657     MMI::MockInputManager::ClearTouchActions();
658     std::shared_ptr<MMI::PointerEvent> event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, 1);
659     auto inputEventConsumer = MMI::MockInputManager::GetInputEventConsumer();
660     if (!inputEventConsumer) {
661         GTEST_LOG_(INFO) << "MockAamsTouchGuideTest OnPointerEvent002 inputEventConsumer is null";
662         return;
663     }
664     inputEventConsumer->OnInputEvent(event);
665     bool retOnPointerEvent2 =
666         AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool {
667         if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1) ==
668             EventType::TYPE_TOUCH_GUIDE_BEGIN) {
669             return true;
670         } else {
671             return false;
672         }
673         }), SLEEP_TIME_3);
674     EXPECT_TRUE(retOnPointerEvent2);
675     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN);
676 
677     event = CreateMoveEvent(1, 1);
678     inputEventConsumer->OnInputEvent(event);
679     event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, 1);
680     inputEventConsumer->OnInputEvent(event);
681     retOnPointerEvent2 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool {
682         if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3) ==
683             EventType::TYPE_TOUCH_GUIDE_END) {
684             return true;
685         } else {
686             return false;
687         }
688         }), SLEEP_TIME_3);
689     EXPECT_TRUE(retOnPointerEvent2);
690     EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(0), MMI::PointerEvent::POINTER_ACTION_HOVER_ENTER);
691     EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(1), MMI::PointerEvent::POINTER_ACTION_HOVER_MOVE);
692     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), EventType::TYPE_TOUCH_END);
693 
694     GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent002 ENDs";
695 }
696 
697 /**
698  * @tc.number: OnPointerEvent003
699  * @tc.name:OnPointerEvent
700  * @tc.desc: Check the GESTURE_SWIPE_LEFT_THEN_RIGHT gesture.
701  */
HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent003, TestSize.Level1)702 HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent003, TestSize.Level1)
703 {
704     GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent003 starts";
705 
706     AccessibilityHelper::GetInstance().GetEventType() = {};
707     MMI::MockInputManager::ClearTouchActions();
708     std::vector<MMI::PointerEvent::PointerItem> points = {};
709     MMI::PointerEvent::PointerItem point1 = {};
710     TouchGuiderPointSet(point1, 1, 2500, 2500);
711     MMI::PointerEvent::PointerItem point2 = {};
712     TouchGuiderPointSet(point2, 1, 1500, 2500);
713     MMI::PointerEvent::PointerItem point3 = {};
714     TouchGuiderPointSet(point3, 1, 0, 2500);
715     MMI::PointerEvent::PointerItem point4 = {};
716     TouchGuiderPointSet(point4, 1, 2500, 2250);
717 
718     OnPointerEventOnePointsTest3(points, point1, point2, point3, point4);
719 
720     // Determine event type
721     bool retOnPointerEvent3 =
722         AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool {
723         if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) ==
724             EventType::TYPE_TOUCH_END) {
725             return true;
726         } else {
727             return false;
728         }
729         }), SLEEP_TIME_3);
730     EXPECT_TRUE(retOnPointerEvent3);
731     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0),
732         EventType::TYPE_TOUCH_BEGIN);
733     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1),
734         EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN);
735     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3),
736         EventType::TYPE_TOUCH_GUIDE_GESTURE_END);
737     // Determine action
738     EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(0), MMI::PointerEvent::POINTER_ACTION_MOVE);
739     EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(1), MMI::PointerEvent::POINTER_ACTION_MOVE);
740     EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(2), MMI::PointerEvent::POINTER_ACTION_MOVE);
741     // Determine gesture type
742     retOnPointerEvent3 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool {
743         if (AccessibilityHelper::GetInstance().GetGestureId() ==
744             static_cast<int32_t>(GestureType::GESTURE_SWIPE_LEFT_THEN_RIGHT)) {
745             return true;
746         } else {
747             return false;
748         }
749         }), SLEEP_TIME_3);
750     EXPECT_TRUE(retOnPointerEvent3);
751 
752     GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent003 ENDs";
753 }
754 
755 /**
756  * @tc.number: OnPointerEvent004
757  * @tc.name:OnPointerEvent
758  * @tc.desc: Check the GESTURE_SWIPE_DOWN_THEN_UP gesture.
759  */
HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent004, TestSize.Level1)760 HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent004, TestSize.Level1)
761 {
762     GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent004 starts";
763 
764     AccessibilityHelper::GetInstance().GetEventType() = {};
765     MMI::MockInputManager::ClearTouchActions();
766     std::vector<MMI::PointerEvent::PointerItem> points = {};
767     MMI::PointerEvent::PointerItem point1 = {};
768     TouchGuiderPointSet(point1, 1, 2500, 2500);
769     MMI::PointerEvent::PointerItem point2 = {};
770     TouchGuiderPointSet(point2, 1, 2500, 3500);
771     MMI::PointerEvent::PointerItem point3 = {};
772     TouchGuiderPointSet(point3, 1, 2500, 5000);
773     MMI::PointerEvent::PointerItem point4 = {};
774     TouchGuiderPointSet(point4, 1, 2250, 2500);
775 
776     bool flag = OnPointerEventOnePointsTest3(points, point1, point2, point3, point4);
777     if (!flag) {
778         GTEST_LOG_(INFO) << "MockAamsTouchGuideTest OnPointerEvent003 inputEventConsumer is null";
779         return;
780     }
781 
782     // Determine event type
783     bool retOnPointerEvent4 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool {
784         if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) ==
785             EventType::TYPE_TOUCH_END) {
786             return true;
787         } else {
788             return false;
789         }
790         }), SLEEP_TIME_3);
791     EXPECT_TRUE(retOnPointerEvent4);
792     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0),
793         EventType::TYPE_TOUCH_BEGIN);
794     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1),
795         EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN);
796     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3),
797         EventType::TYPE_TOUCH_GUIDE_GESTURE_END);
798     // Determine action
799     EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(0), MMI::PointerEvent::POINTER_ACTION_MOVE);
800     EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(1), MMI::PointerEvent::POINTER_ACTION_MOVE);
801     EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(2), MMI::PointerEvent::POINTER_ACTION_MOVE);
802     // Determine gesture type
803     retOnPointerEvent4 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool {
804         if (AccessibilityHelper::GetInstance().GetGestureId() ==
805             static_cast<int32_t>(GestureType::GESTURE_SWIPE_DOWN_THEN_UP)) {
806             return true;
807         } else {
808             return false;
809         }
810         }), SLEEP_TIME_3);
811     EXPECT_TRUE(retOnPointerEvent4);
812 
813     GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent004 ENDs";
814 }
815 
816 /**
817  * @tc.number: OnPointerEvent005
818  * @tc.name:OnPointerEvent
819  * @tc.desc: Check the GESTURE_SWIPE_RIGHT_THEN_LEFT gesture.
820  */
HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent005, TestSize.Level1)821 HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent005, TestSize.Level1)
822 {
823     GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent005 starts";
824 
825     AccessibilityHelper::GetInstance().GetEventType() = {};
826     MMI::MockInputManager::ClearTouchActions();
827     std::vector<MMI::PointerEvent::PointerItem> points = {};
828     MMI::PointerEvent::PointerItem point1 = {};
829     TouchGuiderPointSet(point1, 1, 2500, 2500);
830     MMI::PointerEvent::PointerItem point2 = {};
831     TouchGuiderPointSet(point2, 1, 3500, 2500);
832     MMI::PointerEvent::PointerItem point3 = {};
833     TouchGuiderPointSet(point3, 1, 5000, 2500);
834     MMI::PointerEvent::PointerItem point4 = {};
835     TouchGuiderPointSet(point4, 1, 2500, 2250);
836 
837     bool flag = OnPointerEventOnePointsTest3(points, point1, point2, point3, point4);
838     if (!flag) {
839         GTEST_LOG_(INFO) << "MockAamsTouchGuideTest OnPointerEvent005 inputEventConsumer is null";
840         return;
841     }
842 
843     // Determine event type
844     bool retOnPointerEvent5 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool {
845         if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) ==
846             EventType::TYPE_TOUCH_END) {
847             return true;
848         } else {
849             return false;
850         }
851         }), SLEEP_TIME_3);
852     EXPECT_TRUE(retOnPointerEvent5);
853     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0),
854         EventType::TYPE_TOUCH_BEGIN);
855     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1),
856         EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN);
857     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3),
858         EventType::TYPE_TOUCH_GUIDE_GESTURE_END);
859     // Determine action
860     EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(0), MMI::PointerEvent::POINTER_ACTION_MOVE);
861     EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(1), MMI::PointerEvent::POINTER_ACTION_MOVE);
862     EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(2), MMI::PointerEvent::POINTER_ACTION_MOVE);
863     // Determine gesture type
864     retOnPointerEvent5 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool {
865         if (AccessibilityHelper::GetInstance().GetGestureId() ==
866             static_cast<int32_t>(GestureType::GESTURE_SWIPE_RIGHT_THEN_LEFT)) {
867             return true;
868         } else {
869             return false;
870         }
871         }), SLEEP_TIME_3);
872     EXPECT_TRUE(retOnPointerEvent5);
873 
874     GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent005 ENDs";
875 }
876 
877 /**
878  * @tc.number: OnPointerEvent006
879  * @tc.name:OnPointerEvent
880  * @tc.desc: Check the GESTURE_SWIPE_UP_THEN_DOWN gesture.
881  */
HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent006, TestSize.Level1)882 HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent006, TestSize.Level1)
883 {
884     GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent006 starts";
885 
886     AccessibilityHelper::GetInstance().GetEventType() = {};
887     MMI::MockInputManager::ClearTouchActions();
888     std::vector<MMI::PointerEvent::PointerItem> points = {};
889     MMI::PointerEvent::PointerItem point1 = {};
890     TouchGuiderPointSet(point1, 1, 2500, 2500);
891     MMI::PointerEvent::PointerItem point2 = {};
892     TouchGuiderPointSet(point2, 1, 2500, 1500);
893     MMI::PointerEvent::PointerItem point3 = {};
894     TouchGuiderPointSet(point3, 1, 2500, 0);
895     MMI::PointerEvent::PointerItem point4 = {};
896     TouchGuiderPointSet(point4, 1, 2250, 2500);
897 
898     bool flag = OnPointerEventOnePointsTest3(points, point1, point2, point3, point4);
899     if (!flag) {
900         GTEST_LOG_(INFO) << "MockAamsTouchGuideTest OnPointerEvent006 inputEventConsumer is null";
901         return;
902     }
903 
904     // Determine event type
905     bool retOnPointerEvent6 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool {
906         if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) ==
907             EventType::TYPE_TOUCH_END) {
908             return true;
909         } else {
910             return false;
911         }
912         }), SLEEP_TIME_3);
913     EXPECT_TRUE(retOnPointerEvent6);
914     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0),
915         EventType::TYPE_TOUCH_BEGIN);
916     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1),
917         EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN);
918     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3),
919         EventType::TYPE_TOUCH_GUIDE_GESTURE_END);
920     // Determine action
921     EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(0), MMI::PointerEvent::POINTER_ACTION_MOVE);
922     EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(1), MMI::PointerEvent::POINTER_ACTION_MOVE);
923     EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(2), MMI::PointerEvent::POINTER_ACTION_MOVE);
924     // Determine gesture type
925     retOnPointerEvent6 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool {
926         if (AccessibilityHelper::GetInstance().GetGestureId() ==
927             static_cast<int32_t>(GestureType::GESTURE_SWIPE_UP_THEN_DOWN)) {
928             return true;
929         } else {
930             return false;
931         }
932         }), SLEEP_TIME_3);
933     EXPECT_TRUE(retOnPointerEvent6);
934 
935     GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent006 ENDs";
936 }
937 
938 /**
939  * @tc.number: OnPointerEvent007
940  * @tc.name:OnPointerEvent
941  * @tc.desc: Check the UP gesture.
942  */
HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent007, TestSize.Level1)943 HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent007, TestSize.Level1)
944 {
945     GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent007 starts";
946 
947     AccessibilityHelper::GetInstance().GetEventType() = {};
948     MMI::MockInputManager::ClearTouchActions();
949     std::vector<MMI::PointerEvent::PointerItem> points = {};
950     MMI::PointerEvent::PointerItem point1 = {};
951     TouchGuiderPointSet(point1, 1, 2500, 2500);
952     MMI::PointerEvent::PointerItem point2 = {};
953     TouchGuiderPointSet(point2, 1, 2500, 1500);
954     MMI::PointerEvent::PointerItem point3 = {};
955     TouchGuiderPointSet(point3, 1, 2500, 0);
956 
957     bool flag = OnPointerEventOnePointsTest7(points, point1, point2, point3);
958     if (!flag) {
959         GTEST_LOG_(INFO) << "MockAamsTouchGuideTest OnPointerEvent007 inputEventConsumer is null";
960         return;
961     }
962 
963     // Determine event type
964     bool retOnPointerEvent7 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool {
965         if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) ==
966             EventType::TYPE_TOUCH_END) {
967             return true;
968         } else {
969             return false;
970         }
971         }), SLEEP_TIME_3);
972     EXPECT_TRUE(retOnPointerEvent7);
973     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0),
974         EventType::TYPE_TOUCH_BEGIN);
975     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1),
976         EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN);
977     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3),
978         EventType::TYPE_TOUCH_GUIDE_GESTURE_END);
979     // Determine action
980     EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(0), MMI::PointerEvent::POINTER_ACTION_MOVE);
981     EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(1), MMI::PointerEvent::POINTER_ACTION_MOVE);
982     // Determine gesture type
983     retOnPointerEvent7 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool {
984         if (AccessibilityHelper::GetInstance().GetGestureId() == static_cast<int32_t>(GestureType::GESTURE_SWIPE_UP)) {
985             return true;
986         } else {
987             return false;
988         }
989         }), SLEEP_TIME_3);
990     EXPECT_TRUE(retOnPointerEvent7);
991 
992     GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent007 ENDs";
993 }
994 
995 /**
996  * @tc.number: OnPointerEvent008
997  * @tc.name:OnPointerEvent
998  * @tc.desc: Check the single tap event.
999  */
HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent008, TestSize.Level1)1000 HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent008, TestSize.Level1)
1001 {
1002     GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent008 starts";
1003 
1004     AccessibilityHelper::GetInstance().GetEventType() = {};
1005     MMI::MockInputManager::ClearTouchActions();
1006     std::shared_ptr<MMI::PointerEvent> event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, 1);
1007     auto inputEventConsumer = MMI::MockInputManager::GetInputEventConsumer();
1008     if (!inputEventConsumer) {
1009         GTEST_LOG_(INFO) << "MockAamsTouchGuideTest OnPointerEvent009 inputEventConsumer is null";
1010         return;
1011     }
1012     inputEventConsumer->OnInputEvent(event);
1013 
1014     event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, 1);
1015     inputEventConsumer->OnInputEvent(event);
1016     // Determine event type
1017     bool retOnPointerEvent8 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool {
1018         if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3) ==
1019             EventType::TYPE_TOUCH_GUIDE_END) {
1020             return true;
1021         } else {
1022             return false;
1023         }
1024         }), SLEEP_TIME_3);
1025     EXPECT_TRUE(retOnPointerEvent8);
1026     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN);
1027     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1),
1028         EventType::TYPE_TOUCH_END);
1029     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2),
1030         EventType::TYPE_TOUCH_GUIDE_BEGIN);
1031     // Determine action
1032     EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(0), MMI::PointerEvent::POINTER_ACTION_HOVER_ENTER);
1033     EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(1), MMI::PointerEvent::POINTER_ACTION_HOVER_EXIT);
1034 
1035     GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent008 ends";
1036 }
1037 
1038 /**
1039  * @tc.number: OnPointerEvent009
1040  * @tc.name:OnPointerEvent
1041  * @tc.desc: Check the double tap and long press event.
1042  */
HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent009, TestSize.Level1)1043 HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent009, TestSize.Level1)
1044 {
1045     GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent009 starts";
1046 
1047     AccessibilityHelper::GetInstance().GetEventType() = {};
1048     MMI::MockInputManager::ClearTouchActions();
1049     std::vector<MMI::PointerEvent::PointerItem> points = {};
1050     MMI::PointerEvent::PointerItem point1 = {};
1051     point1.SetDisplayX(300);
1052     point1.SetDisplayY(500);
1053     point1.SetPointerId(1);
1054 
1055     points.emplace_back(point1);
1056     std::shared_ptr<MMI::PointerEvent> event =
1057         CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, 0, 0, 1);
1058     auto inputEventConsumer = MMI::MockInputManager::GetInputEventConsumer();
1059     if (!inputEventConsumer) {
1060         GTEST_LOG_(INFO) << "MockAamsTouchGuideTest OnPointerEvent009 inputEventConsumer is null";
1061         return;
1062     }
1063     inputEventConsumer->OnInputEvent(event);
1064     sleep(1);
1065     event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, 40, 0, 1);
1066     inputEventConsumer->OnInputEvent(event);
1067     event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, 200, 0, 1);
1068     inputEventConsumer->OnInputEvent(event);
1069     sleep(SLEEP_TIME_3);
1070 
1071     event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, 0, 0, 1);
1072     inputEventConsumer->OnInputEvent(event);
1073     // Determine event type
1074     bool retOnPointerEvent9 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool {
1075         if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(6) ==
1076             EventType::TYPE_TOUCH_END) {
1077             return true;
1078         } else {
1079             return false;
1080         }
1081         }), SLEEP_TIME_3);
1082     EXPECT_TRUE(retOnPointerEvent9);
1083     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN);
1084     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), EventType::TYPE_TOUCH_GUIDE_BEGIN);
1085     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), EventType::TYPE_TOUCH_END);
1086     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3), EventType::TYPE_TOUCH_BEGIN);
1087     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(4), EventType::TYPE_TOUCH_GUIDE_END);
1088     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(5), EventType::TYPE_TOUCH_GUIDE_BEGIN);
1089     // Determine action
1090     EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(0), MMI::PointerEvent::POINTER_ACTION_HOVER_ENTER);
1091 
1092     GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent009 ends";
1093 }
1094 
1095 /**
1096  * @tc.number: OnPointerEvent010
1097  * @tc.name:OnPointerEvent
1098  * @tc.desc: Check the double-tap event.
1099  */
HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent010, TestSize.Level1)1100 HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent010, TestSize.Level1)
1101 {
1102     GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent010 starts";
1103 
1104     AccessibilityHelper::GetInstance().GetEventType() = {};
1105     MMI::MockInputManager::ClearTouchActions();
1106     std::vector<MMI::PointerEvent::PointerItem> points = {};
1107     MMI::PointerEvent::PointerItem point1 = {};
1108     point1.SetDisplayX(300);
1109     point1.SetDisplayY(500);
1110     point1.SetPointerId(1);
1111 
1112     points.emplace_back(point1);
1113     std::shared_ptr<MMI::PointerEvent> event =
1114         CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, 0, 0, 1);
1115     auto inputEventConsumer = MMI::MockInputManager::GetInputEventConsumer();
1116     if (!inputEventConsumer) {
1117         GTEST_LOG_(INFO) << "MockAamsTouchGuideTest OnPointerEvent010 inputEventConsumer is null";
1118         return;
1119     }
1120     inputEventConsumer->OnInputEvent(event);
1121     sleep(1);
1122     event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, 0, 0, 1);
1123     inputEventConsumer->OnInputEvent(event);
1124     event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, 100, 0, 1);
1125     inputEventConsumer->OnInputEvent(event);
1126     event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, 0, 0, 1);
1127     inputEventConsumer->OnInputEvent(event);
1128 
1129     // Determine event type
1130     bool retOnPointerEvent10 =
1131         AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool {
1132         if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(5) ==
1133             EventType::TYPE_TOUCH_END) {
1134             return true;
1135         } else {
1136             return false;
1137         }
1138         }), SLEEP_TIME_3);
1139     EXPECT_TRUE(retOnPointerEvent10);
1140     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN);
1141     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), EventType::TYPE_TOUCH_GUIDE_BEGIN);
1142     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), EventType::TYPE_TOUCH_END);
1143     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3), EventType::TYPE_TOUCH_BEGIN);
1144     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(4), EventType::TYPE_TOUCH_GUIDE_END);
1145     // Determine action
1146     EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(0), POINTER_ACTION_INVALID);
1147 
1148     GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent010 ends";
1149 }
1150 
1151 /**
1152  * @tc.number: OnPointerEvent011
1153  * @tc.name:OnPointerEvent
1154  * @tc.desc: Check the two finger tap event.
1155  */
HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent011, TestSize.Level1)1156 HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent011, TestSize.Level1)
1157 {
1158     GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent011 starts";
1159 
1160     AccessibilityHelper::GetInstance().GetEventType() = {};
1161     MMI::MockInputManager::ClearTouchActions();
1162     std::vector<MMI::PointerEvent::PointerItem> points = {};
1163     MMI::PointerEvent::PointerItem point1 = {};
1164     TouchGuiderPointSet(point1, 0, 100, 100);
1165     MMI::PointerEvent::PointerItem point2 = {};
1166     TouchGuiderPointSet(point2, 1, 200, 100);
1167 
1168     bool eventProduceRst = TwoFingerTapEventProduce(points, point1, point2, TAP_TIMES_1, false);
1169     if (!eventProduceRst) {
1170         GTEST_LOG_(INFO) << "MockAamsTouchGuideTest OnPointerEvent0011 inputEventConsumer is null";
1171         return;
1172     }
1173 
1174     sleep(1);
1175 
1176     // eventType
1177     bool retOnPointerEvent11 =
1178         AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool {
1179         if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) ==
1180             EventType::TYPE_TOUCH_END) {
1181             return true;
1182         } else {
1183             return false;
1184         }
1185         }), SLEEP_TIME_3);
1186     EXPECT_TRUE(retOnPointerEvent11);
1187     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0),
1188         EventType::TYPE_TOUCH_BEGIN);
1189     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1),
1190         EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN);
1191 
1192     // gestureId
1193     EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), 25);
1194 
1195     GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent011 ends";
1196 }
1197 
1198 /**
1199  * @tc.number: OnPointerEvent012
1200  * @tc.name:OnPointerEvent
1201  * @tc.desc: Check the two finger double tap event.
1202  */
HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent012, TestSize.Level1)1203 HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent012, TestSize.Level1)
1204 {
1205     GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent012 starts";
1206 
1207     AccessibilityHelper::GetInstance().GetEventType() = {};
1208     MMI::MockInputManager::ClearTouchActions();
1209 
1210     std::vector<MMI::PointerEvent::PointerItem> points = {};
1211     MMI::PointerEvent::PointerItem point1 = {};
1212     TouchGuiderPointSet(point1, 0, 100, 100);
1213     MMI::PointerEvent::PointerItem point2 = {};
1214     TouchGuiderPointSet(point2, 1, 200, 100);
1215 
1216     bool eventProduceRst = TwoFingerTapEventProduce(points, point1, point2, TAP_TIMES_2, false);
1217     if (!eventProduceRst) {
1218         GTEST_LOG_(INFO) << "MockAamsTouchGuideTest OnPointerEvent0011 inputEventConsumer is null";
1219         return;
1220     }
1221 
1222     sleep(1);
1223 
1224     // eventType
1225     bool retOnPointerEvent12 =
1226         AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool {
1227         if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(4) ==
1228             EventType::TYPE_TOUCH_END) {
1229             return true;
1230         } else {
1231             return false;
1232         }
1233         }), SLEEP_TIME_3);
1234     EXPECT_TRUE(retOnPointerEvent12);
1235     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0),
1236         EventType::TYPE_TOUCH_BEGIN);
1237     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1),
1238         EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN);
1239 
1240     // gestureId
1241     EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(),
1242         static_cast<int32_t>(GestureType::GESTURE_TWO_FINGER_DOUBLE_TAP));
1243 
1244     GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent012 ends";
1245 }
1246 
1247 /**
1248  * @tc.number: OnPointerEvent013
1249  * @tc.name:OnPointerEvent
1250  * @tc.desc: Check the two finger triple tap event.
1251  */
HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent013, TestSize.Level1)1252 HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent013, TestSize.Level1)
1253 {
1254     GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent013 starts";
1255 
1256     AccessibilityHelper::GetInstance().GetEventType() = {};
1257     MMI::MockInputManager::ClearTouchActions();
1258 
1259     std::vector<MMI::PointerEvent::PointerItem> points = {};
1260     MMI::PointerEvent::PointerItem point1 = {};
1261     TouchGuiderPointSet(point1, 0, 100, 100);
1262     MMI::PointerEvent::PointerItem point2 = {};
1263     TouchGuiderPointSet(point2, 1, 200, 100);
1264 
1265     bool eventProduceRst = TwoFingerTapEventProduce(points, point1, point2, TAP_TIMES_3, false);
1266     if (!eventProduceRst) {
1267         GTEST_LOG_(INFO) << "MockAamsTouchGuideTest OnPointerEvent0011 inputEventConsumer is null";
1268         return;
1269     }
1270 
1271     sleep(1);
1272 
1273     // eventType
1274     bool retOnPointerEvent13 =
1275         AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool {
1276         if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(6) ==
1277             EventType::TYPE_TOUCH_END) {
1278             return true;
1279         } else {
1280             return false;
1281         }
1282         }), SLEEP_TIME_3);
1283     EXPECT_TRUE(retOnPointerEvent13);
1284     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0),
1285         EventType::TYPE_TOUCH_BEGIN);
1286     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1),
1287         EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN);
1288 
1289     // gestureId
1290     EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(),
1291         static_cast<int32_t>(GestureType::GESTURE_TWO_FINGER_TRIPLE_TAP));
1292 
1293     GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent013 ends";
1294 }
1295 
1296 /**
1297  * @tc.number: OnPointerEvent014
1298  * @tc.name:OnPointerEvent
1299  * @tc.desc: Check the two finger double tap and hold event.
1300  */
HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent014, TestSize.Level1)1301 HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent014, TestSize.Level1)
1302 {
1303     GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent014 starts";
1304 
1305     AccessibilityHelper::GetInstance().GetEventType() = {};
1306     MMI::MockInputManager::ClearTouchActions();
1307 
1308     std::vector<MMI::PointerEvent::PointerItem> points = {};
1309     MMI::PointerEvent::PointerItem point1 = {};
1310     TouchGuiderPointSet(point1, 0, 100, 100);
1311     MMI::PointerEvent::PointerItem point2 = {};
1312     TouchGuiderPointSet(point2, 1, 200, 100);
1313 
1314     bool eventProduceRst = TwoFingerTapEventProduce(points, point1, point2, TAP_TIMES_2, true);
1315     if (!eventProduceRst) {
1316         GTEST_LOG_(INFO) << "MockAamsTouchGuideTest OnPointerEvent0014 inputEventConsumer is null";
1317         return;
1318     }
1319 
1320     sleep(1);
1321 
1322     // eventType
1323     bool retOnPointerEvent14 =
1324         AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool {
1325         if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) ==
1326             EventType::TYPE_TOUCH_END) {
1327             return true;
1328         } else {
1329             return false;
1330         }
1331         }), SLEEP_TIME_3);
1332     EXPECT_TRUE(retOnPointerEvent14);
1333     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0),
1334         EventType::TYPE_TOUCH_BEGIN);
1335     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1),
1336         EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN);
1337     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(4),
1338         EventType::TYPE_TOUCH_GUIDE_GESTURE_END);
1339 
1340     // gestureId
1341     EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(),
1342         static_cast<int32_t>(GestureType::GESTURE_TWO_FINGER_DOUBLE_TAP_AND_HOLD));
1343 
1344     GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent014 ends";
1345 }
1346 
1347 /**
1348  * @tc.number: OnPointerEvent015
1349  * @tc.name:OnPointerEvent
1350  * @tc.desc: Check the two finger triple tap and hold event.
1351  */
HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent015, TestSize.Level1)1352 HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent015, TestSize.Level1)
1353 {
1354     GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent015 starts";
1355 
1356     AccessibilityHelper::GetInstance().GetEventType() = {};
1357     MMI::MockInputManager::ClearTouchActions();
1358 
1359     std::vector<MMI::PointerEvent::PointerItem> points = {};
1360     MMI::PointerEvent::PointerItem point1 = {};
1361     TouchGuiderPointSet(point1, 0, 100, 100);
1362     MMI::PointerEvent::PointerItem point2 = {};
1363     TouchGuiderPointSet(point2, 1, 200, 100);
1364 
1365     bool eventProduceRst = TwoFingerTapEventProduce(points, point1, point2, TAP_TIMES_3, true);
1366     if (!eventProduceRst) {
1367         GTEST_LOG_(INFO) << "MockAamsTouchGuideTest OnPointerEvent0015 inputEventConsumer is null";
1368         return;
1369     }
1370 
1371     sleep(1);
1372 
1373     // eventType
1374     bool retOnPointerEvent15 =
1375         AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool {
1376         if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) ==
1377             EventType::TYPE_TOUCH_END) {
1378             return true;
1379         } else {
1380             return false;
1381         }
1382         }), SLEEP_TIME_3);
1383     EXPECT_TRUE(retOnPointerEvent15);
1384     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0),
1385         EventType::TYPE_TOUCH_BEGIN);
1386     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1),
1387         EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN);
1388     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(6),
1389         EventType::TYPE_TOUCH_GUIDE_GESTURE_END);
1390 
1391     // gestureId
1392     EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(),
1393         static_cast<int32_t>(GestureType::GESTURE_TWO_FINGER_TRIPLE_TAP_AND_HOLD));
1394 
1395     GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent015 ends";
1396 }
1397 
1398 /**
1399  * @tc.number: OnPointerEvent016
1400  * @tc.name:OnPointerEvent
1401  * @tc.desc: Check the two finger move event.
1402  */
HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent016, TestSize.Level1)1403 HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent016, TestSize.Level1)
1404 {
1405     GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent016 starts";
1406 
1407     AccessibilityHelper::GetInstance().GetEventType() = {};
1408     MMI::MockInputManager::ClearTouchActions();
1409 
1410     std::vector<MMI::PointerEvent::PointerItem> points = {};
1411     MMI::PointerEvent::PointerItem point1 = {};
1412     TouchGuiderPointSet(point1, 0, 100, 100);
1413     MMI::PointerEvent::PointerItem point2 = {};
1414     TouchGuiderPointSet(point2, 1, 200, 100);
1415     MMI::PointerEvent::PointerItem point3 = {};
1416     TouchGuiderPointSet(point3, 0, 100, 400);
1417     MMI::PointerEvent::PointerItem point4 = {};
1418     TouchGuiderPointSet(point4, 1, 200, 400);
1419 
1420     bool eventProduceRst = TwoFingerMoveEventProduce(points, point1, point2, point3, point4);
1421     if (!eventProduceRst) {
1422         GTEST_LOG_(INFO) << "MockAamsTouchGuideTest OnPointerEvent0016 inputEventConsumer is null";
1423         return;
1424     }
1425 
1426     // eventType
1427     bool retOnPointerEvent15 =
1428         AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool {
1429         if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3) ==
1430             EventType::TYPE_TOUCH_END) {
1431             return true;
1432         } else {
1433             return false;
1434         }
1435         }), SLEEP_TIME_3);
1436     EXPECT_TRUE(retOnPointerEvent15);
1437     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0),
1438         EventType::TYPE_TOUCH_BEGIN);
1439     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1),
1440         EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN);
1441     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2),
1442         EventType::TYPE_TOUCH_GUIDE_GESTURE_END);
1443 
1444     EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(0), MMI::PointerEvent::POINTER_ACTION_DOWN);
1445     EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(1), MMI::PointerEvent::POINTER_ACTION_MOVE);
1446     EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(2), MMI::PointerEvent::POINTER_ACTION_UP);
1447 
1448     // gestureId
1449     EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), static_cast<int32_t>(GestureType::GESTURE_INVALID));
1450 
1451     GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent016 ends";
1452 }
1453 
1454 /**
1455  * @tc.number: OnPointerEvent017
1456  * @tc.name:OnPointerEvent
1457  * @tc.desc: Check the one finger tap and then two finger tap event, expect do not recognize as any gesture.
1458  */
HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent017, TestSize.Level1)1459 HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent017, TestSize.Level1)
1460 {
1461     GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent017 starts";
1462 
1463     AccessibilityHelper::GetInstance().GetEventType() = {};
1464     MMI::MockInputManager::ClearTouchActions();
1465 
1466     std::vector<MMI::PointerEvent::PointerItem> points = {};
1467     MMI::PointerEvent::PointerItem point1 = {};
1468     TouchGuiderPointSet(point1, 0, 100, 100);
1469     MMI::PointerEvent::PointerItem point2 = {};
1470     TouchGuiderPointSet(point2, 1, 200, 100);
1471 
1472     bool eventProduceRst = OneFingerTapAndTwoFingerTapEventProduce(points, point1, point2, false);
1473     if (!eventProduceRst) {
1474         GTEST_LOG_(INFO) << "MockAamsTouchGuideTest OnPointerEvent0017 inputEventConsumer is null";
1475         return;
1476     }
1477 
1478     // eventType
1479     bool retOnPointerEvent15 =
1480         AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool {
1481         if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1) ==
1482             EventType::TYPE_TOUCH_END) {
1483             return true;
1484         } else {
1485             return false;
1486         }
1487         }), SLEEP_TIME_3);
1488     EXPECT_TRUE(retOnPointerEvent15);
1489     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN);
1490 
1491     // gestureId
1492     EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), static_cast<int32_t>(GestureType::GESTURE_INVALID));
1493 
1494     // touch action to multimode
1495     EXPECT_EQ(static_cast<int32_t>(MMI::MockInputManager::GetTouchActions().size()), 0);
1496 
1497     GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent017 ends";
1498 }
1499 
1500 /**
1501  * @tc.number: OnPointerEvent018
1502  * @tc.name:OnPointerEvent
1503  * @tc.desc: Check the two finger tap and then one finger tap event, expect do not recognize as any gesture.
1504  */
HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent018, TestSize.Level1)1505 HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent018, TestSize.Level1)
1506 {
1507     GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent018 starts";
1508 
1509     AccessibilityHelper::GetInstance().GetEventType() = {};
1510     MMI::MockInputManager::ClearTouchActions();
1511 
1512     std::vector<MMI::PointerEvent::PointerItem> points = {};
1513     MMI::PointerEvent::PointerItem point1 = {};
1514     TouchGuiderPointSet(point1, 0, 100, 100);
1515     MMI::PointerEvent::PointerItem point2 = {};
1516     TouchGuiderPointSet(point2, 1, 200, 100);
1517 
1518     bool eventProduceRst = TwoFingerTapAndOneFingerTapEventProduce(points, point1, point2);
1519     if (!eventProduceRst) {
1520         GTEST_LOG_(INFO) << "MockAamsTouchGuideTest OnPointerEvent0018 inputEventConsumer is null";
1521         return;
1522     }
1523 
1524     // eventType
1525     bool retOnPointerEvent15 =
1526         AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool {
1527         if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(4) ==
1528             EventType::TYPE_TOUCH_END) {
1529             return true;
1530         } else {
1531             return false;
1532         }
1533         }), SLEEP_TIME_3);
1534     EXPECT_TRUE(retOnPointerEvent15);
1535     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0),
1536         EventType::TYPE_TOUCH_BEGIN);
1537     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1),
1538         EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN);
1539     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3),
1540         EventType::TYPE_TOUCH_GUIDE_GESTURE_END);
1541 
1542     // gestureId
1543     EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), static_cast<int32_t>(GestureType::GESTURE_INVALID));
1544 
1545     // touch action to multimode
1546     EXPECT_EQ(static_cast<int32_t>(MMI::MockInputManager::GetTouchActions().size()), 0);
1547     GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent018 ends";
1548 }
1549 
1550 /**
1551  * @tc.number: OnPointerEvent019
1552  * @tc.name:OnPointerEvent
1553  * @tc.desc: Check the one finger tap and then two finger tap event, interval > 300ms, expect two gesture event.
1554  */
HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent019, TestSize.Level1)1555 HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent019, TestSize.Level1)
1556 {
1557     GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent019 starts";
1558 
1559     AccessibilityHelper::GetInstance().GetEventType() = {};
1560     MMI::MockInputManager::ClearTouchActions();
1561 
1562     std::vector<MMI::PointerEvent::PointerItem> points = {};
1563     MMI::PointerEvent::PointerItem point1 = {};
1564     TouchGuiderPointSet(point1, 0, 100, 100);
1565     MMI::PointerEvent::PointerItem point2 = {};
1566     TouchGuiderPointSet(point2, 1, 200, 100);
1567 
1568     bool eventProduceRst = OneFingerTapAndTwoFingerTapEventProduce(points, point1, point2, true);
1569     if (!eventProduceRst) {
1570         GTEST_LOG_(INFO) << "MockAamsTouchGuideTest OnPointerEvent0019 inputEventConsumer is null";
1571         return;
1572     }
1573 
1574     sleep(1);
1575 
1576     // eventType
1577     bool retOnPointerEvent15 =
1578         AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool {
1579         if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(5) ==
1580             EventType::TYPE_TOUCH_GUIDE_GESTURE_END) {
1581             return true;
1582         } else {
1583             return false;
1584         }
1585         }), SLEEP_TIME_3);
1586     EXPECT_TRUE(retOnPointerEvent15);
1587 
1588     // gestureId
1589     EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), 25);
1590 
1591     GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent019 ends";
1592 }
1593 
1594 /**
1595  * @tc.number: OnPointerEvent020
1596  * @tc.name:OnPointerEvent
1597  * @tc.desc: Check the three finger single tap event.
1598  */
HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent020, TestSize.Level1)1599 HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent020, TestSize.Level1)
1600 {
1601     GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent020 starts";
1602 
1603     AccessibilityHelper::GetInstance().GetEventType() = {};
1604     MMI::MockInputManager::ClearTouchActions();
1605 
1606     std::vector<MMI::PointerEvent::PointerItem> points = {};
1607     MMI::PointerEvent::PointerItem point1 = {};
1608     TouchGuiderPointSet(point1, 0, 100, 100);
1609     MMI::PointerEvent::PointerItem point2 = {};
1610     TouchGuiderPointSet(point2, 1, 200, 100);
1611     MMI::PointerEvent::PointerItem point3 = {};
1612     TouchGuiderPointSet(point3, 2, 300, 100);
1613     std::vector<MMI::PointerEvent::PointerItem> pointVec{point1, point2, point3};
1614 
1615     bool eventProduceRst = MultiFingerTapEventProduce(points, pointVec, 1, false);
1616     if (!eventProduceRst) {
1617         GTEST_LOG_(INFO) << "MockAamsTouchGuideTest OnPointerEvent0020 inputEventConsumer is null";
1618         return;
1619     }
1620 
1621     sleep(1);
1622 
1623     // eventType
1624     bool ret =
1625         AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool {
1626         if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) ==
1627             EventType::TYPE_TOUCH_END) {
1628             return true;
1629         } else {
1630             return false;
1631         }
1632         }), SLEEP_TIME_3);
1633     EXPECT_TRUE(ret);
1634     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN);
1635     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1),
1636         EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN);
1637     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3),
1638         EventType::TYPE_TOUCH_GUIDE_GESTURE_END);
1639 
1640     // gestureId
1641     EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(),
1642         static_cast<int32_t>(GestureType::GESTURE_THREE_FINGER_SINGLE_TAP));
1643 
1644     GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent020 ends";
1645 }
1646 
1647 /**
1648  * @tc.number: OnPointerEvent021
1649  * @tc.name:OnPointerEvent
1650  * @tc.desc: Check the four finger single tap event.
1651  */
HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent021, TestSize.Level1)1652 HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent021, TestSize.Level1)
1653 {
1654     GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent021 starts";
1655 
1656     AccessibilityHelper::GetInstance().GetEventType() = {};
1657     MMI::MockInputManager::ClearTouchActions();
1658 
1659     std::vector<MMI::PointerEvent::PointerItem> points = {};
1660     MMI::PointerEvent::PointerItem point1 = {};
1661     TouchGuiderPointSet(point1, 0, 100, 100);
1662     MMI::PointerEvent::PointerItem point2 = {};
1663     TouchGuiderPointSet(point2, 1, 200, 100);
1664     MMI::PointerEvent::PointerItem point3 = {};
1665     TouchGuiderPointSet(point3, 2, 300, 100);
1666     MMI::PointerEvent::PointerItem point4 = {};
1667     TouchGuiderPointSet(point4, 3, 400, 100);
1668     std::vector<MMI::PointerEvent::PointerItem> pointVec{point1, point2, point3, point4};
1669 
1670     bool eventProduceRst = MultiFingerTapEventProduce(points, pointVec, 1, false);
1671     if (!eventProduceRst) {
1672         GTEST_LOG_(INFO) << "MockAamsTouchGuideTest OnPointerEvent0021 inputEventConsumer is null";
1673         return;
1674     }
1675 
1676     sleep(1);
1677 
1678     // eventType
1679     bool ret =
1680         AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool {
1681         if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) ==
1682             EventType::TYPE_TOUCH_END) {
1683             return true;
1684         } else {
1685             return false;
1686         }
1687         }), SLEEP_TIME_3);
1688     EXPECT_TRUE(ret);
1689     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN);
1690     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1),
1691         EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN);
1692     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3),
1693         EventType::TYPE_TOUCH_GUIDE_GESTURE_END);
1694 
1695     // gestureId
1696     EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(),
1697         static_cast<int32_t>(GestureType::GESTURE_FOUR_FINGER_SINGLE_TAP));
1698 
1699     GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent021 ends";
1700 }
1701 
1702 /**
1703  * @tc.number: OnPointerEvent022
1704  * @tc.name:OnPointerEvent
1705  * @tc.desc: Check the three finger double tap event.
1706  */
HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent022, TestSize.Level1)1707 HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent022, TestSize.Level1)
1708 {
1709     GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent022 starts";
1710 
1711     AccessibilityHelper::GetInstance().GetEventType() = {};
1712     MMI::MockInputManager::ClearTouchActions();
1713 
1714     std::vector<MMI::PointerEvent::PointerItem> points = {};
1715     MMI::PointerEvent::PointerItem point1 = {};
1716     TouchGuiderPointSet(point1, 0, 100, 100);
1717     MMI::PointerEvent::PointerItem point2 = {};
1718     TouchGuiderPointSet(point2, 1, 200, 100);
1719     MMI::PointerEvent::PointerItem point3 = {};
1720     TouchGuiderPointSet(point3, 2, 300, 100);
1721     std::vector<MMI::PointerEvent::PointerItem> pointVec{point1, point2, point3};
1722 
1723     bool eventProduceRst = MultiFingerTapEventProduce(points, pointVec, 2, false);
1724     if (!eventProduceRst) {
1725         GTEST_LOG_(INFO) << "MockAamsTouchGuideTest OnPointerEvent0022 inputEventConsumer is null";
1726         return;
1727     }
1728 
1729     sleep(1);
1730 
1731     // eventType
1732     bool ret =
1733         AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool {
1734         if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(4) ==
1735             EventType::TYPE_TOUCH_END) {
1736             return true;
1737         } else {
1738             return false;
1739         }
1740         }), SLEEP_TIME_3);
1741     EXPECT_TRUE(ret);
1742     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN);
1743     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1),
1744         EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN);
1745     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(5),
1746         EventType::TYPE_TOUCH_GUIDE_GESTURE_END);
1747 
1748     // gestureId
1749     EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(),
1750         static_cast<int32_t>(GestureType::GESTURE_THREE_FINGER_DOUBLE_TAP));
1751 
1752     GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent022 ends";
1753 }
1754 
1755 /**
1756  * @tc.number: OnPointerEvent023
1757  * @tc.name:OnPointerEvent
1758  * @tc.desc: Check the three finger double tap and hold event.
1759  */
HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent023, TestSize.Level1)1760 HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent023, TestSize.Level1)
1761 {
1762     GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent023 starts";
1763 
1764     AccessibilityHelper::GetInstance().GetEventType() = {};
1765     MMI::MockInputManager::ClearTouchActions();
1766 
1767     std::vector<MMI::PointerEvent::PointerItem> points = {};
1768     MMI::PointerEvent::PointerItem point1 = {};
1769     TouchGuiderPointSet(point1, 0, 100, 100);
1770     MMI::PointerEvent::PointerItem point2 = {};
1771     TouchGuiderPointSet(point2, 1, 200, 100);
1772     MMI::PointerEvent::PointerItem point3 = {};
1773     TouchGuiderPointSet(point3, 2, 300, 100);
1774     std::vector<MMI::PointerEvent::PointerItem> pointVec{point1, point2, point3};
1775 
1776     bool eventProduceRst = MultiFingerTapEventProduce(points, pointVec, 2, true);
1777     if (!eventProduceRst) {
1778         GTEST_LOG_(INFO) << "MockAamsTouchGuideTest OnPointerEvent0023 inputEventConsumer is null";
1779         return;
1780     }
1781 
1782     sleep(1);
1783 
1784     // eventType
1785     bool ret =
1786         AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool {
1787         if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) ==
1788             EventType::TYPE_TOUCH_END) {
1789             return true;
1790         } else {
1791             return false;
1792         }
1793         }), SLEEP_TIME_3);
1794     EXPECT_TRUE(ret);
1795     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN);
1796     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1),
1797         EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN);
1798     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(4),
1799         EventType::TYPE_TOUCH_GUIDE_GESTURE_END);
1800 
1801     // gestureId
1802     EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(),
1803         static_cast<int32_t>(GestureType::GESTURE_THREE_FINGER_DOUBLE_TAP_AND_HOLD));
1804 
1805     GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent023 ends";
1806 }
1807 
1808 /**
1809  * @tc.number: OnPointerEvent024
1810  * @tc.name:OnPointerEvent
1811  * @tc.desc: Check the three finger triple tap event.
1812  */
HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent024, TestSize.Level1)1813 HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent024, TestSize.Level1)
1814 {
1815     GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent024 starts";
1816 
1817     AccessibilityHelper::GetInstance().GetEventType() = {};
1818     MMI::MockInputManager::ClearTouchActions();
1819 
1820     std::vector<MMI::PointerEvent::PointerItem> points = {};
1821     MMI::PointerEvent::PointerItem point1 = {};
1822     TouchGuiderPointSet(point1, 0, 100, 100);
1823     MMI::PointerEvent::PointerItem point2 = {};
1824     TouchGuiderPointSet(point2, 1, 200, 100);
1825     MMI::PointerEvent::PointerItem point3 = {};
1826     TouchGuiderPointSet(point3, 2, 300, 100);
1827     std::vector<MMI::PointerEvent::PointerItem> pointVec{point1, point2, point3};
1828 
1829     bool eventProduceRst = MultiFingerTapEventProduce(points, pointVec, 3, false);
1830     if (!eventProduceRst) {
1831         GTEST_LOG_(INFO) << "MockAamsTouchGuideTest OnPointerEvent0024 inputEventConsumer is null";
1832         return;
1833     }
1834 
1835     sleep(1);
1836 
1837     // eventType
1838     bool ret =
1839         AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool {
1840         if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(6) ==
1841             EventType::TYPE_TOUCH_END) {
1842             return true;
1843         } else {
1844             return false;
1845         }
1846         }), SLEEP_TIME_3);
1847     EXPECT_TRUE(ret);
1848     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN);
1849     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1),
1850         EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN);
1851     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(7),
1852         EventType::TYPE_TOUCH_GUIDE_GESTURE_END);
1853 
1854     // gestureId
1855     EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(),
1856         static_cast<int32_t>(GestureType::GESTURE_THREE_FINGER_TRIPLE_TAP));
1857 
1858     GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent024 ends";
1859 }
1860 
1861 /**
1862  * @tc.number: OnPointerEvent025
1863  * @tc.name:OnPointerEvent
1864  * @tc.desc: Check the three finger triple tap and hold event.
1865  */
HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent025, TestSize.Level1)1866 HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent025, TestSize.Level1)
1867 {
1868     GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent025 starts";
1869 
1870     AccessibilityHelper::GetInstance().GetEventType() = {};
1871     MMI::MockInputManager::ClearTouchActions();
1872 
1873     std::vector<MMI::PointerEvent::PointerItem> points = {};
1874     MMI::PointerEvent::PointerItem point1 = {};
1875     TouchGuiderPointSet(point1, 0, 100, 100);
1876     MMI::PointerEvent::PointerItem point2 = {};
1877     TouchGuiderPointSet(point2, 1, 200, 100);
1878     MMI::PointerEvent::PointerItem point3 = {};
1879     TouchGuiderPointSet(point3, 2, 300, 100);
1880     std::vector<MMI::PointerEvent::PointerItem> pointVec{point1, point2, point3};
1881 
1882     bool eventProduceRst = MultiFingerTapEventProduce(points, pointVec, 3, true);
1883     if (!eventProduceRst) {
1884         GTEST_LOG_(INFO) << "MockAamsTouchGuideTest OnPointerEvent0025 inputEventConsumer is null";
1885         return;
1886     }
1887 
1888     sleep(1);
1889 
1890     // eventType
1891     bool ret =
1892         AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool {
1893         if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) ==
1894             EventType::TYPE_TOUCH_END) {
1895             return true;
1896         } else {
1897             return false;
1898         }
1899         }), SLEEP_TIME_3);
1900     EXPECT_TRUE(ret);
1901     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN);
1902     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1),
1903         EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN);
1904     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(6),
1905         EventType::TYPE_TOUCH_GUIDE_GESTURE_END);
1906 
1907     // gestureId
1908     EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(),
1909         static_cast<int32_t>(GestureType::GESTURE_THREE_FINGER_TRIPLE_TAP_AND_HOLD));
1910 
1911     GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent025 ends";
1912 }
1913 
1914 /**
1915  * @tc.number: OnPointerEvent026
1916  * @tc.name:OnPointerEvent
1917  * @tc.desc: Check the four finger double tap event.
1918  */
HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent026, TestSize.Level1)1919 HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent026, TestSize.Level1)
1920 {
1921     GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent026 starts";
1922 
1923     AccessibilityHelper::GetInstance().GetEventType() = {};
1924     MMI::MockInputManager::ClearTouchActions();
1925 
1926     std::vector<MMI::PointerEvent::PointerItem> points = {};
1927     MMI::PointerEvent::PointerItem point1 = {};
1928     TouchGuiderPointSet(point1, 0, 100, 100);
1929     MMI::PointerEvent::PointerItem point2 = {};
1930     TouchGuiderPointSet(point2, 1, 200, 100);
1931     MMI::PointerEvent::PointerItem point3 = {};
1932     TouchGuiderPointSet(point3, 2, 300, 100);
1933     MMI::PointerEvent::PointerItem point4 = {};
1934     TouchGuiderPointSet(point4, 3, 400, 100);
1935     std::vector<MMI::PointerEvent::PointerItem> pointVec{point1, point2, point3, point4};
1936 
1937     bool eventProduceRst = MultiFingerTapEventProduce(points, pointVec, 2, false);
1938     if (!eventProduceRst) {
1939         GTEST_LOG_(INFO) << "MockAamsTouchGuideTest OnPointerEvent0026 inputEventConsumer is null";
1940         return;
1941     }
1942 
1943     sleep(1);
1944 
1945     // eventType
1946     bool ret =
1947         AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool {
1948         if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(4) ==
1949             EventType::TYPE_TOUCH_END) {
1950             return true;
1951         } else {
1952             return false;
1953         }
1954         }), SLEEP_TIME_3);
1955     EXPECT_TRUE(ret);
1956     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN);
1957     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1),
1958         EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN);
1959     EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(5),
1960         EventType::TYPE_TOUCH_GUIDE_GESTURE_END);
1961 
1962     // gestureId
1963     EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(),
1964         static_cast<int32_t>(GestureType::GESTURE_FOUR_FINGER_DOUBLE_TAP));
1965 
1966     GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent026 ends";
1967 }
1968 } // namespace Accessibility
1969 } // namespace OHOS