1 /*
2  * Copyright (C) 2023 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 <map>
18 #include <memory>
19 #include "accessibility_common_helper.h"
20 #include "accessibility_screen_touch.h"
21 #include "accessibility_ut_helper.h"
22 #include "accessible_ability_manager_service.h"
23 
24 using namespace testing;
25 using namespace testing::ext;
26 
27 namespace OHOS {
28 namespace Accessibility {
29 namespace {
30     constexpr uint32_t CLICK_RESPONSE_TIME_SHORT = 0; // ms
31     constexpr uint32_t CLICK_RESPONSE_TIME_MEDIUM = 300; // ms
32     constexpr uint32_t CLICK_RESPONSE_TIME_LONG = 600; // ms
33     constexpr uint32_t IGNORE_REPEAT_CLICK_TIME_SHORTEST = 100; // ms
34     constexpr uint32_t IGNORE_REPEAT_CLICK_TIME_MEDIUM = 700; // ms
35     constexpr uint32_t IGNORE_REPEAT_CLICK_TIME_LONGEST = 1300; // ms
36     constexpr uint32_t CLICK_RESPONSE_DELAY_SHORT = 0;
37     constexpr uint32_t CLICK_RESPONSE_DELAY_MEDIUM = 1;
38     constexpr uint32_t CLICK_RESPONSE_DELAY_LONG = 2;
39     constexpr uint32_t IGNORE_REPEAT_CLICK_SHORTEST = 0;
40     constexpr uint32_t IGNORE_REPEAT_CLICK_MEDIUM = 2;
41     constexpr uint32_t IGNORE_REPEAT_CLICK_LONGEST = 4;
42     constexpr uint32_t TIMESTAMP_800 = 800;
43     constexpr uint32_t TIMESTAMP_1200 = 1200;
44     constexpr uint32_t TIMESTAMP_1500 = 1500;
45     constexpr uint32_t TIMESTAMP_1600 = 1600;
46     constexpr uint32_t TIMESTAMP_1700 = 1700;
47     constexpr uint32_t TIMESTAMP_2500 = 2500;
48     constexpr uint32_t TIMESTAMP_2700 = 2700;
49     constexpr uint32_t TIMESTAMP_2800 = 2800;
50     constexpr uint32_t SLEEP_TIME_MS = 500;
51 } // namespace
52 
53 class AccessibilityScreenTouchUnitTest : public ::testing::Test {
54 public:
AccessibilityScreenTouchUnitTest()55     AccessibilityScreenTouchUnitTest()
56     {}
~AccessibilityScreenTouchUnitTest()57     ~AccessibilityScreenTouchUnitTest()
58     {}
59 
60     static void SetUpTestCase();
61     static void TearDownTestCase();
62     void SetUp() override;
63     void TearDown() override;
64     std::shared_ptr<MMI::PointerEvent> SetPointerEvent(uint32_t time, uint32_t action);
65     std::shared_ptr<MMI::PointerEvent> SetPointerEvent(uint32_t time, uint32_t action,
66         std::vector<MMI::PointerEvent::PointerItem> &points, int32_t pointerId);
67 
68     std::shared_ptr<AccessibilityScreenTouch> screenTouch_ = nullptr;
69     static uint32_t lastUpTime_;
70 };
71 
72 uint32_t AccessibilityScreenTouchUnitTest::lastUpTime_ = 0;
73 
SetUpTestCase()74 void AccessibilityScreenTouchUnitTest::SetUpTestCase()
75 {
76     GTEST_LOG_(INFO) << "###################### AccessibilityScreenTouchUnitTest Start ######################";
77     Singleton<AccessibleAbilityManagerService>::GetInstance().OnStart();
78 }
79 
TearDownTestCase()80 void AccessibilityScreenTouchUnitTest::TearDownTestCase()
81 {
82     GTEST_LOG_(INFO) << "###################### AccessibilityScreenTouchUnitTest End ######################";
83     Singleton<AccessibleAbilityManagerService>::GetInstance().OnStop();
84 }
85 
SetUp()86 void AccessibilityScreenTouchUnitTest::SetUp()
87 {
88     GTEST_LOG_(INFO) << "SetUp";
89 }
90 
TearDown()91 void AccessibilityScreenTouchUnitTest::TearDown()
92 {
93     GTEST_LOG_(INFO) << "TearDown";
94     screenTouch_ = nullptr;
95     AccessibilityAbilityHelper::GetInstance().ClearTouchEventActionVector();
96 
97     sptr<AccessibilityAccountData> accountData =
98         Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
99     if (!accountData) {
100         GTEST_LOG_(INFO) << "accountData is nullptr";
101         return;
102     }
103     accountData->GetConfig()->SetClickResponseTime(0);
104     accountData->GetConfig()->SetIgnoreRepeatClickState(false);
105 }
106 
SetPointerEvent(uint32_t time, uint32_t action)107 std::shared_ptr<MMI::PointerEvent> AccessibilityScreenTouchUnitTest::SetPointerEvent(uint32_t time, uint32_t action)
108 {
109     std::shared_ptr<MMI::PointerEvent> event = MMI::PointerEvent::Create();
110     event->SetSourceType(MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
111     event->SetPointerAction(action);
112     event->SetPointerId(0);
113     MMI::PointerEvent::PointerItem item;
114     item.SetPointerId(0);
115     event->AddPointerItem(item);
116     event->SetActionTime(time);
117     return event;
118 }
119 
SetPointerEvent(uint32_t time, uint32_t action, std::vector<MMI::PointerEvent::PointerItem> &points, int32_t pointerId)120 std::shared_ptr<MMI::PointerEvent> AccessibilityScreenTouchUnitTest::SetPointerEvent(uint32_t time, uint32_t action,
121     std::vector<MMI::PointerEvent::PointerItem> &points, int32_t pointerId)
122 {
123     std::shared_ptr<MMI::PointerEvent> event = MMI::PointerEvent::Create();
124 
125     for (auto &point : points) {
126         if (point.GetPointerId() == pointerId) {
127             point.SetPressed(action == MMI::PointerEvent::POINTER_ACTION_UP ? false : true);
128         } else {
129             point.SetPressed(true);
130         }
131         event->AddPointerItem(point);
132     }
133     event->SetSourceType(MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
134     event->SetPointerAction(action);
135     event->SetPointerId(pointerId);
136     event->SetActionTime(time);
137     return event;
138 }
139 
140 /**
141  * @tc.number: AccessibilityScreenTouch_Unittest_SetClickResponseTime_001
142  * @tc.name: SetClickResponseTime
143  * @tc.desc: Test function SetClickResponseTime
144  */
HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_SetClickResponseTime_001, TestSize.Level1)145 HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_SetClickResponseTime_001, TestSize.Level1)
146 {
147     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_SetClickResponseTime_001 start";
148     sptr<AccessibilityAccountData> accountData =
149         Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
150     if (!accountData) {
151         GTEST_LOG_(INFO) << "accountData is nullptr";
152         return;
153     }
154 
155     accountData->GetConfig()->SetClickResponseTime(CLICK_RESPONSE_DELAY_SHORT);
156     screenTouch_ = std::make_shared<AccessibilityScreenTouch>();
157 
158     EXPECT_EQ(screenTouch_->GetRealClickResponseTime(), CLICK_RESPONSE_TIME_SHORT);
159     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_SetClickResponseTime_001 end";
160 }
161 
162 /**
163  * @tc.number: AccessibilityScreenTouch_Unittest_SetClickResponseTime_002
164  * @tc.name: SetClickResponseTime
165  * @tc.desc: Test function SetClickResponseTime
166  */
HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_SetClickResponseTime_002, TestSize.Level1)167 HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_SetClickResponseTime_002, TestSize.Level1)
168 {
169     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_SetClickResponseTime_002 start";
170     sptr<AccessibilityAccountData> accountData =
171         Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
172     if (!accountData) {
173         GTEST_LOG_(INFO) << "accountData is nullptr";
174         return;
175     }
176 
177     accountData->GetConfig()->SetClickResponseTime(CLICK_RESPONSE_DELAY_MEDIUM);
178     screenTouch_ = std::make_shared<AccessibilityScreenTouch>();
179 
180     EXPECT_EQ(screenTouch_->GetRealClickResponseTime(), CLICK_RESPONSE_TIME_MEDIUM);
181     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_SetClickResponseTime_002 end";
182 }
183 
184 /**
185  * @tc.number: AccessibilityScreenTouch_Unittest_SetClickResponseTime_003
186  * @tc.name: SetClickResponseTime
187  * @tc.desc: Test function SetClickResponseTime
188  */
HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_SetClickResponseTime_003, TestSize.Level1)189 HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_SetClickResponseTime_003, TestSize.Level1)
190 {
191     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_SetClickResponseTime_003 start";
192     sptr<AccessibilityAccountData> accountData =
193         Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
194     if (!accountData) {
195         GTEST_LOG_(INFO) << "accountData is nullptr";
196         return;
197     }
198 
199     accountData->GetConfig()->SetClickResponseTime(CLICK_RESPONSE_DELAY_LONG);
200     screenTouch_ = std::make_shared<AccessibilityScreenTouch>();
201 
202     EXPECT_EQ(screenTouch_->GetRealClickResponseTime(), CLICK_RESPONSE_TIME_LONG);
203     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_SetClickResponseTime_003 end";
204 }
205 
206 /**
207  * @tc.number: AccessibilityScreenTouch_Unittest_SetIgnoreRepeatClickState_001
208  * @tc.name: SetIgnoreRepeatClickState
209  * @tc.desc: Test function SetIgnoreRepeatClickState
210  */
HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_SetIgnoreRepeatClickState_001, TestSize.Level1)211 HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_SetIgnoreRepeatClickState_001,
212     TestSize.Level1)
213 {
214     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_SetIgnoreRepeatClickState_001 start";
215     sptr<AccessibilityAccountData> accountData =
216         Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
217     if (!accountData) {
218         GTEST_LOG_(INFO) << "accountData is nullptr";
219         return;
220     }
221 
222     accountData->GetConfig()->SetIgnoreRepeatClickState(true);
223     screenTouch_ = std::make_shared<AccessibilityScreenTouch>();
224 
225     EXPECT_EQ(screenTouch_->GetRealIgnoreRepeatClickState(), true);
226     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_SetIgnoreRepeatClickState_001 end";
227 }
228 
229 /**
230  * @tc.number: AccessibilityScreenTouch_Unittest_SetIgnoreRepeatClickState_002
231  * @tc.name: SetIgnoreRepeatClickState
232  * @tc.desc: Test function SetIgnoreRepeatClickState
233  */
HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_SetIgnoreRepeatClickState_002, TestSize.Level1)234 HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_SetIgnoreRepeatClickState_002,
235     TestSize.Level1)
236 {
237     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_SetIgnoreRepeatClickState_002 start";
238     sptr<AccessibilityAccountData> accountData =
239         Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
240     if (!accountData) {
241         GTEST_LOG_(INFO) << "accountData is nullptr";
242         return;
243     }
244 
245     accountData->GetConfig()->SetIgnoreRepeatClickState(false);
246     screenTouch_ = std::make_shared<AccessibilityScreenTouch>();
247 
248     EXPECT_EQ(screenTouch_->GetRealIgnoreRepeatClickState(), false);
249     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_SetIgnoreRepeatClickState_002 end";
250 }
251 
252 /**
253  * @tc.number: AccessibilityScreenTouch_Unittest_SetIgnoreRepeatClickTime_001
254  * @tc.name: SetIgnoreRepeatClickTime
255  * @tc.desc: Test function SetIgnoreRepeatClickTime
256  */
HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_SetIgnoreRepeatClickTime_001, TestSize.Level1)257 HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_SetIgnoreRepeatClickTime_001,
258     TestSize.Level1)
259 {
260     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_SetIgnoreRepeatClickTime_001 start";
261     sptr<AccessibilityAccountData> accountData =
262         Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
263     if (!accountData) {
264         GTEST_LOG_(INFO) << "accountData is nullptr";
265         return;
266     }
267 
268     accountData->GetConfig()->SetIgnoreRepeatClickState(true);
269     accountData->GetConfig()->SetIgnoreRepeatClickTime(IGNORE_REPEAT_CLICK_SHORTEST);
270     screenTouch_ = std::make_shared<AccessibilityScreenTouch>();
271 
272     EXPECT_EQ(screenTouch_->GetRealIgnoreRepeatClickTime(), IGNORE_REPEAT_CLICK_TIME_SHORTEST);
273     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_SetIgnoreRepeatClickTime_001 end";
274 }
275 
276 /**
277  * @tc.number: AccessibilityScreenTouch_Unittest_SetIgnoreRepeatClickTime_002
278  * @tc.name: SetIgnoreRepeatClickTime
279  * @tc.desc: Test function SetIgnoreRepeatClickTime
280  */
HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_SetIgnoreRepeatClickTime_002, TestSize.Level1)281 HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_SetIgnoreRepeatClickTime_002,
282     TestSize.Level1)
283 {
284     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_SetIgnoreRepeatClickTime_002 start";
285     sptr<AccessibilityAccountData> accountData =
286         Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
287     if (!accountData) {
288         GTEST_LOG_(INFO) << "accountData is nullptr";
289         return;
290     }
291 
292     accountData->GetConfig()->SetIgnoreRepeatClickState(true);
293     accountData->GetConfig()->SetIgnoreRepeatClickTime(IGNORE_REPEAT_CLICK_MEDIUM);
294     screenTouch_ = std::make_shared<AccessibilityScreenTouch>();
295 
296     EXPECT_EQ(screenTouch_->GetRealIgnoreRepeatClickTime(), IGNORE_REPEAT_CLICK_TIME_MEDIUM);
297     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_SetIgnoreRepeatClickTime_002 end";
298 }
299 
300 /**
301  * @tc.number: AccessibilityScreenTouch_Unittest_SetIgnoreRepeatClickTime_003
302  * @tc.name: SetIgnoreRepeatClickTime
303  * @tc.desc: Test function SetIgnoreRepeatClickTime
304  */
HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_SetIgnoreRepeatClickTime_003, TestSize.Level1)305 HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_SetIgnoreRepeatClickTime_003,
306     TestSize.Level1)
307 {
308     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_SetIgnoreRepeatClickTime_003 start";
309     sptr<AccessibilityAccountData> accountData =
310         Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
311     if (!accountData) {
312         GTEST_LOG_(INFO) << "accountData is nullptr";
313         return;
314     }
315 
316     accountData->GetConfig()->SetIgnoreRepeatClickState(true);
317     accountData->GetConfig()->SetIgnoreRepeatClickTime(IGNORE_REPEAT_CLICK_LONGEST);
318     screenTouch_ = std::make_shared<AccessibilityScreenTouch>();
319 
320     EXPECT_EQ(screenTouch_->GetRealIgnoreRepeatClickTime(), IGNORE_REPEAT_CLICK_TIME_LONGEST);
321     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_SetIgnoreRepeatClickTime_003 end";
322 }
323 
324 /**
325  * @tc.number: AccessibilityScreenTouch_Unittest_OnPointerEvent_001
326  * @tc.name: OnPointerEvent
327  * @tc.desc: Test function OnPointerEvent
328  */
HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_OnPointerEvent_001, TestSize.Level1)329 HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_OnPointerEvent_001, TestSize.Level1)
330 {
331     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_OnPointerEvent_001 start";
332     screenTouch_ = std::make_shared<AccessibilityScreenTouch>();
333     std::shared_ptr<MMI::PointerEvent> event = MMI::PointerEvent::Create();
334     if (screenTouch_ == nullptr || event == nullptr) {
335         GTEST_LOG_(INFO) << "null pointer";
336     }
337 
338     MMI::PointerEvent::PointerItem pointer = {};
339     pointer.SetPointerId(0);
340     event->SetPointerId(0);
341     event->AddPointerItem(pointer);
342     event->SetSourceType(MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
343     EXPECT_EQ(screenTouch_->OnPointerEvent(*event), true);
344     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_OnPointerEvent_001 end";
345 }
346 
347 /**
348  * @tc.number: AccessibilityScreenTouch_Unittest_OnPointerEvent_002
349  * @tc.name: OnPointerEvent
350  * @tc.desc: Test function OnPointerEvent
351  */
HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_OnPointerEvent_002, TestSize.Level1)352 HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_OnPointerEvent_002, TestSize.Level1)
353 {
354     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_OnPointerEvent_002 start";
355     screenTouch_ = std::make_shared<AccessibilityScreenTouch>();
356     std::shared_ptr<MMI::PointerEvent> event = MMI::PointerEvent::Create();
357     if (screenTouch_ == nullptr || event == nullptr) {
358         GTEST_LOG_(INFO) << "null pointer";
359     }
360 
361     MMI::PointerEvent::PointerItem pointer = {};
362     pointer.SetPointerId(0);
363     event->SetPointerId(0);
364     event->AddPointerItem(pointer);
365     event->SetSourceType(MMI::PointerEvent::SOURCE_TYPE_MOUSE);
366     EXPECT_EQ(screenTouch_->OnPointerEvent(*event), false);
367     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_OnPointerEvent_002 end";
368 }
369 
370 /**
371  * @tc.number: AccessibilityScreenTouch_Unittest_OnPointerEvent_003
372  * @tc.name: OnPointerEvent
373  * @tc.desc: Test function OnPointerEvent
374  */
HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_OnPointerEvent_003, TestSize.Level1)375 HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_OnPointerEvent_003, TestSize.Level1)
376 {
377     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_OnPointerEvent_003 start";
378     screenTouch_ = std::make_shared<AccessibilityScreenTouch>();
379     std::shared_ptr<MMI::PointerEvent> event = MMI::PointerEvent::Create();
380     if (screenTouch_ == nullptr || event == nullptr) {
381         GTEST_LOG_(INFO) << "null pointer";
382     }
383 
384     event->SetSourceType(MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
385     EXPECT_EQ(screenTouch_->OnPointerEvent(*event), false);
386     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_OnPointerEvent_003 end";
387 }
388 
389 /**
390  * @tc.number: AccessibilityScreenTouch_Unittest_OnPointerEvent_004
391  * @tc.name: OnPointerEvent
392  * @tc.desc: Test function OnPointerEvent
393  */
HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_OnPointerEvent_004, TestSize.Level1)394 HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_OnPointerEvent_004, TestSize.Level1)
395 {
396     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_OnPointerEvent_004 start";
397     screenTouch_ = std::make_shared<AccessibilityScreenTouch>();
398     std::shared_ptr<MMI::PointerEvent> event = MMI::PointerEvent::Create();
399     if (screenTouch_ == nullptr || event == nullptr) {
400         GTEST_LOG_(INFO) << "null pointer";
401     }
402 
403     MMI::PointerEvent::PointerItem pointer = {};
404     pointer.SetPointerId(1);
405     pointer.SetToolType(MMI::PointerEvent::TOOL_TYPE_KNUCKLE);
406     event->SetPointerId(1);
407     event->AddPointerItem(pointer);
408     event->SetSourceType(MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
409     event->SetPointerAction(MMI::PointerEvent::POINTER_ACTION_DOWN);
410 
411     EXPECT_EQ(screenTouch_->OnPointerEvent(*event), false);
412     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_OnPointerEvent_004 end";
413 }
414 
415 /**
416  * @tc.number: AccessibilityScreenTouch_Unittest_OnPointerEvent_005
417  * @tc.name: OnPointerEvent
418  * @tc.desc: Test function OnPointerEvent
419  */
HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_OnPointerEvent_005, TestSize.Level1)420 HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_OnPointerEvent_005, TestSize.Level1)
421 {
422     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_OnPointerEvent_005 start";
423     screenTouch_ = std::make_shared<AccessibilityScreenTouch>();
424     std::shared_ptr<MMI::PointerEvent> event = MMI::PointerEvent::Create();
425     if (screenTouch_ == nullptr || event == nullptr) {
426         GTEST_LOG_(INFO) << "null pointer";
427     }
428 
429     MMI::PointerEvent::PointerItem pointer = {};
430     pointer.SetPointerId(1);
431     pointer.SetToolType(MMI::PointerEvent::TOOL_TYPE_KNUCKLE);
432     event->SetPointerId(2);
433     event->AddPointerItem(pointer);
434     event->SetSourceType(MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
435     event->SetPointerAction(MMI::PointerEvent::POINTER_ACTION_DOWN);
436 
437     EXPECT_EQ(screenTouch_->OnPointerEvent(*event), false);
438     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_OnPointerEvent_005 end";
439 }
440 
441 /**
442  * @tc.number: AccessibilityScreenTouch_Unittest_OnPointerEvent_006
443  * @tc.name: OnPointerEvent
444  * @tc.desc: Test function OnPointerEvent
445  */
HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_OnPointerEvent_006, TestSize.Level1)446 HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_OnPointerEvent_006, TestSize.Level1)
447 {
448     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_OnPointerEvent_006 start";
449     screenTouch_ = std::make_shared<AccessibilityScreenTouch>();
450     std::shared_ptr<MMI::PointerEvent> event = MMI::PointerEvent::Create();
451     if (screenTouch_ == nullptr || event == nullptr) {
452         GTEST_LOG_(INFO) << "null pointer";
453     }
454 
455     MMI::PointerEvent::PointerItem pointer = {};
456     pointer.SetPointerId(1);
457     pointer.SetToolType(MMI::PointerEvent::TOOL_TYPE_KNUCKLE);
458     event->SetPointerId(1);
459     event->AddPointerItem(pointer);
460     event->SetSourceType(MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
461     event->SetPointerAction(MMI::PointerEvent::POINTER_ACTION_UP);
462 
463     EXPECT_EQ(screenTouch_->OnPointerEvent(*event), false);
464     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_OnPointerEvent_006 end";
465 }
466 
467 /**
468  * @tc.number: AccessibilityScreenTouch_Unittest_OnPointerEvent_007
469  * @tc.name: OnPointerEvent
470  * @tc.desc: Test function OnPointerEvent
471  */
HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_OnPointerEvent_007, TestSize.Level1)472 HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_OnPointerEvent_007, TestSize.Level1)
473 {
474     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_OnPointerEvent_007 start";
475     screenTouch_ = std::make_shared<AccessibilityScreenTouch>();
476     std::shared_ptr<MMI::PointerEvent> event = MMI::PointerEvent::Create();
477     if (screenTouch_ == nullptr || event == nullptr) {
478         GTEST_LOG_(INFO) << "null pointer";
479     }
480 
481     MMI::PointerEvent::PointerItem pointer = {};
482     pointer.SetPointerId(1);
483     event->SetPointerId(1);
484     event->AddPointerItem(pointer);
485     event->SetSourceType(MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
486     event->SetPointerAction(MMI::PointerEvent::POINTER_ACTION_CANCEL);
487     screenTouch_->OnPointerEvent(*event);
488 
489     EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionVector().size(), 0);
490     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_OnPointerEvent_007 end.";
491 }
492 
493 /**
494  * @tc.number: AccessibilityScreenTouch_Unittest_OnPointerEvent_008
495  * @tc.name: OnPointerEvent
496  * @tc.desc: Test function OnPointerEvent
497  */
HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_OnPointerEvent_008, TestSize.Level1)498 HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_OnPointerEvent_008, TestSize.Level1)
499 {
500     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_OnPointerEvent_008 start";
501     screenTouch_ = std::make_shared<AccessibilityScreenTouch>();
502     std::shared_ptr<MMI::PointerEvent> event = MMI::PointerEvent::Create();
503     if (screenTouch_ == nullptr || event == nullptr) {
504         GTEST_LOG_(INFO) << "null pointer";
505     }
506 
507     MMI::PointerEvent::PointerItem pointer = {};
508     pointer.SetPointerId(1);
509     event->SetPointerId(2);
510     event->AddPointerItem(pointer);
511     event->SetSourceType(MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
512     event->SetPointerAction(MMI::PointerEvent::POINTER_ACTION_CANCEL);
513     screenTouch_->OnPointerEvent(*event);
514 
515     EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionVector().size(), 0);
516     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_OnPointerEvent_008 end.";
517 }
518 
519 /**
520  * @tc.number: AccessibilityScreenTouch_Unittest_OnPointerEvent_009
521  * @tc.name: OnPointerEvent
522  * @tc.desc: Test function OnPointerEvent
523  */
HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_OnPointerEvent_009, TestSize.Level1)524 HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_OnPointerEvent_009, TestSize.Level1)
525 {
526     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_OnPointerEvent_009 start";
527     screenTouch_ = std::make_shared<AccessibilityScreenTouch>();
528     std::shared_ptr<MMI::PointerEvent> event = MMI::PointerEvent::Create();
529     if (screenTouch_ == nullptr || event == nullptr) {
530         GTEST_LOG_(INFO) << "null pointer";
531     }
532 
533     MMI::PointerEvent::PointerItem pointer = {};
534     pointer.SetPointerId(0);
535     MMI::PointerEvent::PointerItem anotherPointer = {};
536     anotherPointer.SetPointerId(1);
537     event->SetPointerId(1);
538     event->AddPointerItem(pointer);
539     event->AddPointerItem(anotherPointer);
540     event->SetSourceType(MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
541     event->SetPointerAction(MMI::PointerEvent::POINTER_ACTION_CANCEL);
542     screenTouch_->OnPointerEvent(*event);
543 
544     EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionVector().size(), 0);
545     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_OnPointerEvent_009 end.";
546 }
547 
548 /**
549  * @tc.number: AccessibilityScreenTouch_Unittest_HandleIgnoreRepeatClickState_001
550  * @tc.name: HandleIgnoreRepeatClickState
551  * @tc.desc: Test function HandleIgnoreRepeatClickState
552  */
HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleIgnoreRepeatClickState_001, TestSize.Level1)553 HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleIgnoreRepeatClickState_001,
554     TestSize.Level1)
555 {
556     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleIgnoreRepeatClickState_001 start";
557     sptr<AccessibilityAccountData> accountData =
558         Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
559     if (accountData == nullptr) {
560         return;
561     }
562 
563     accountData->GetConfig()->SetClickResponseTime(0);
564     accountData->GetConfig()->SetIgnoreRepeatClickState(true);
565     accountData->GetConfig()->SetIgnoreRepeatClickTime(IGNORE_REPEAT_CLICK_LONGEST);
566 
567     screenTouch_ = std::make_shared<AccessibilityScreenTouch>();
568     if (screenTouch_ == nullptr) {
569         return;
570     }
571 
572     auto eventDown = SetPointerEvent(TIMESTAMP_1500 * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_DOWN);
573     screenTouch_->OnPointerEvent(*eventDown);
574 
575     auto eventMove = SetPointerEvent(TIMESTAMP_1600 * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_MOVE);
576     screenTouch_->OnPointerEvent(*eventMove);
577 
578     auto eventUp = SetPointerEvent(TIMESTAMP_1700 * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_UP);
579     screenTouch_->OnPointerEvent(*eventUp);
580 
581     EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionVector().size(), 3);
582     int32_t touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0);
583     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_DOWN);
584     touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(1);
585     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_MOVE);
586     touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(2);
587     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_UP);
588 
589     lastUpTime_ = TIMESTAMP_1700;
590 
591     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleIgnoreRepeatClickState_001 end";
592 }
593 
594 /**
595  * @tc.number: AccessibilityScreenTouch_Unittest_HandleIgnoreRepeatClickState_002
596  * @tc.name: HandleIgnoreRepeatClickState
597  * @tc.desc: Test function HandleIgnoreRepeatClickState
598  */
HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleIgnoreRepeatClickState_002, TestSize.Level1)599 HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleIgnoreRepeatClickState_002,
600     TestSize.Level1)
601 {
602     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleIgnoreRepeatClickState_002 start";
603     sptr<AccessibilityAccountData> accountData =
604         Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
605     if (accountData == nullptr) {
606         return;
607     }
608 
609     accountData->GetConfig()->SetClickResponseTime(0);
610     accountData->GetConfig()->SetIgnoreRepeatClickState(false);
611     accountData->GetConfig()->SetIgnoreRepeatClickTime(IGNORE_REPEAT_CLICK_LONGEST);
612 
613     screenTouch_ = std::make_shared<AccessibilityScreenTouch>();
614     if (screenTouch_ == nullptr) {
615         return;
616     }
617 
618     auto eventDown = SetPointerEvent((lastUpTime_ + TIMESTAMP_1500) * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_DOWN);
619     screenTouch_->OnPointerEvent(*eventDown);
620 
621     auto eventMove = SetPointerEvent((lastUpTime_ + TIMESTAMP_1600) * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_MOVE);
622     screenTouch_->OnPointerEvent(*eventMove);
623 
624     auto eventUp = SetPointerEvent((lastUpTime_ + TIMESTAMP_1700) * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_UP);
625     screenTouch_->OnPointerEvent(*eventUp);
626 
627     EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionVector().size(), 3);
628     int32_t touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0);
629     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_DOWN);
630     touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(1);
631     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_MOVE);
632     touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(2);
633     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_UP);
634 
635     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleIgnoreRepeatClickState_002 end";
636 }
637 
638 /**
639  * @tc.number: AccessibilityScreenTouch_Unittest_HandleIgnoreRepeatClickState_003
640  * @tc.name: HandleIgnoreRepeatClickState
641  * @tc.desc: Test function HandleIgnoreRepeatClickState
642  */
HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleIgnoreRepeatClickState_003, TestSize.Level1)643 HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleIgnoreRepeatClickState_003,
644     TestSize.Level1)
645 {
646     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleIgnoreRepeatClickState_003 start";
647     sptr<AccessibilityAccountData> accountData =
648         Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
649     if (accountData == nullptr) {
650         return;
651     }
652 
653     accountData->GetConfig()->SetClickResponseTime(0);
654     accountData->GetConfig()->SetIgnoreRepeatClickState(true);
655     accountData->GetConfig()->SetIgnoreRepeatClickTime(IGNORE_REPEAT_CLICK_SHORTEST);
656 
657     screenTouch_ = std::make_shared<AccessibilityScreenTouch>();
658     if (screenTouch_ == nullptr) {
659         return;
660     }
661 
662     auto eventDown = SetPointerEvent((lastUpTime_ + TIMESTAMP_1500) * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_DOWN);
663     screenTouch_->OnPointerEvent(*eventDown);
664 
665     auto eventMove = SetPointerEvent((lastUpTime_ + TIMESTAMP_1600) * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_MOVE);
666     screenTouch_->OnPointerEvent(*eventMove);
667 
668     auto eventUp = SetPointerEvent((lastUpTime_ + TIMESTAMP_1700) * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_UP);
669     screenTouch_->OnPointerEvent(*eventUp);
670 
671     EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionVector().size(), 3);
672     int32_t touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0);
673     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_DOWN);
674     touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(1);
675     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_MOVE);
676     touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(2);
677     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_UP);
678 
679     lastUpTime_ += TIMESTAMP_1700;
680 
681     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleIgnoreRepeatClickState_003 end";
682 }
683 
684 /**
685  * @tc.number: AccessibilityScreenTouch_Unittest_HandleIgnoreRepeatClickState_004
686  * @tc.name: HandleIgnoreRepeatClickState
687  * @tc.desc: Test function HandleIgnoreRepeatClickState
688  */
HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleIgnoreRepeatClickState_004, TestSize.Level1)689 HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleIgnoreRepeatClickState_004,
690     TestSize.Level1)
691 {
692     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleIgnoreRepeatClickState_004 start";
693     sptr<AccessibilityAccountData> accountData =
694         Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
695     if (accountData == nullptr) {
696         return;
697     }
698 
699     accountData->GetConfig()->SetClickResponseTime(0);
700     accountData->GetConfig()->SetIgnoreRepeatClickState(true);
701     accountData->GetConfig()->SetIgnoreRepeatClickTime(IGNORE_REPEAT_CLICK_LONGEST);
702 
703     screenTouch_ = std::make_shared<AccessibilityScreenTouch>();
704     if (screenTouch_ == nullptr) {
705         return;
706     }
707 
708     auto eventDown = SetPointerEvent((lastUpTime_ + TIMESTAMP_1200) * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_DOWN);
709     screenTouch_->OnPointerEvent(*eventDown);
710 
711     auto eventMove = SetPointerEvent((lastUpTime_ + TIMESTAMP_1600) * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_MOVE);
712     screenTouch_->OnPointerEvent(*eventMove);
713 
714     auto eventUp = SetPointerEvent((lastUpTime_ + TIMESTAMP_1700) * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_UP);
715     screenTouch_->OnPointerEvent(*eventUp);
716 
717     EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionVector().size(), 0);
718 
719     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleIgnoreRepeatClickState_004 end";
720 }
721 
722 /**
723  * @tc.number: AccessibilityScreenTouch_Unittest_HandleIgnoreRepeatClickState_005
724  * @tc.name: HandleIgnoreRepeatClickState
725  * @tc.desc: Test function HandleIgnoreRepeatClickState
726  */
HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleIgnoreRepeatClickState_005, TestSize.Level1)727 HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleIgnoreRepeatClickState_005,
728     TestSize.Level1)
729 {
730     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleIgnoreRepeatClickState_005 start";
731     sptr<AccessibilityAccountData> accountData =
732         Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
733     if (accountData == nullptr) {
734         return;
735     }
736 
737     accountData->GetConfig()->SetClickResponseTime(0);
738     accountData->GetConfig()->SetIgnoreRepeatClickState(false);
739     accountData->GetConfig()->SetIgnoreRepeatClickTime(IGNORE_REPEAT_CLICK_LONGEST);
740 
741     screenTouch_ = std::make_shared<AccessibilityScreenTouch>();
742     if (screenTouch_ == nullptr) {
743         return;
744     }
745 
746     auto eventDown = SetPointerEvent((lastUpTime_ + TIMESTAMP_1200) * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_DOWN);
747     screenTouch_->OnPointerEvent(*eventDown);
748 
749     auto eventMove = SetPointerEvent((lastUpTime_ + TIMESTAMP_1600) * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_MOVE);
750     screenTouch_->OnPointerEvent(*eventMove);
751 
752     auto eventUp = SetPointerEvent((lastUpTime_ + TIMESTAMP_1700) * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_UP);
753     screenTouch_->OnPointerEvent(*eventUp);
754 
755     EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionVector().size(), 3);
756     int32_t touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0);
757     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_DOWN);
758     touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(1);
759     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_MOVE);
760     touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(2);
761     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_UP);
762 
763     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleIgnoreRepeatClickState_005 end";
764 }
765 
766 /**
767  * @tc.number: AccessibilityScreenTouch_Unittest_HandleIgnoreRepeatClickState_006
768  * @tc.name: HandleIgnoreRepeatClickState
769  * @tc.desc: Test function HandleIgnoreRepeatClickState
770  */
HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleIgnoreRepeatClickState_006, TestSize.Level1)771 HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleIgnoreRepeatClickState_006,
772     TestSize.Level1)
773 {
774     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleIgnoreRepeatClickState_006 start";
775     sptr<AccessibilityAccountData> accountData =
776         Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
777     if (accountData == nullptr) {
778         return;
779     }
780 
781     accountData->GetConfig()->SetClickResponseTime(0);
782     accountData->GetConfig()->SetIgnoreRepeatClickState(true);
783     accountData->GetConfig()->SetIgnoreRepeatClickTime(IGNORE_REPEAT_CLICK_LONGEST);
784 
785     screenTouch_ = std::make_shared<AccessibilityScreenTouch>();
786     if (screenTouch_ == nullptr) {
787         return;
788     }
789 
790     auto eventDown = SetPointerEvent((lastUpTime_ + TIMESTAMP_1200) * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_DOWN);
791     screenTouch_->OnPointerEvent(*eventDown);
792 
793     auto eventMove = SetPointerEvent((lastUpTime_ + TIMESTAMP_1500) * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_MOVE);
794     screenTouch_->OnPointerEvent(*eventMove);
795 
796     auto eventUp = SetPointerEvent((lastUpTime_ + TIMESTAMP_1600) * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_UP);
797     screenTouch_->OnPointerEvent(*eventUp);
798 
799     EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionVector().size(), 0);
800 
801     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleIgnoreRepeatClickState_006 end";
802 }
803 
804 /**
805  * @tc.number: AccessibilityScreenTouch_Unittest_HandleIgnoreRepeatClickState_007
806  * @tc.name: HandleIgnoreRepeatClickState
807  * @tc.desc: Test function HandleIgnoreRepeatClickState
808  */
HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleIgnoreRepeatClickState_007, TestSize.Level1)809 HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleIgnoreRepeatClickState_007,
810     TestSize.Level1)
811 {
812     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleIgnoreRepeatClickState_007 start";
813     sptr<AccessibilityAccountData> accountData =
814         Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
815     if (accountData == nullptr) {
816         return;
817     }
818 
819     accountData->GetConfig()->SetClickResponseTime(0);
820     accountData->GetConfig()->SetIgnoreRepeatClickState(true);
821     accountData->GetConfig()->SetIgnoreRepeatClickTime(IGNORE_REPEAT_CLICK_LONGEST);
822 
823     screenTouch_ = std::make_shared<AccessibilityScreenTouch>();
824     if (screenTouch_ == nullptr) {
825         return;
826     }
827 
828     auto eventDown = SetPointerEvent((lastUpTime_ + TIMESTAMP_1500) * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_DOWN);
829     screenTouch_->OnPointerEvent(*eventDown);
830 
831     auto eventMove = SetPointerEvent((lastUpTime_ + TIMESTAMP_1600) * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_MOVE);
832     screenTouch_->OnPointerEvent(*eventMove);
833 
834     auto eventUp = SetPointerEvent((lastUpTime_ + TIMESTAMP_1700) * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_UP);
835     screenTouch_->OnPointerEvent(*eventUp);
836 
837     auto eventDownContinue = SetPointerEvent((lastUpTime_ + TIMESTAMP_2500) * US_TO_MS,
838         MMI::PointerEvent::POINTER_ACTION_DOWN);
839     screenTouch_->OnPointerEvent(*eventDownContinue);
840 
841     auto eventMoveContinue = SetPointerEvent((lastUpTime_ + TIMESTAMP_2700) * US_TO_MS,
842         MMI::PointerEvent::POINTER_ACTION_MOVE);
843     screenTouch_->OnPointerEvent(*eventMoveContinue);
844 
845     auto eventUpContinue = SetPointerEvent((lastUpTime_ + TIMESTAMP_2800) * US_TO_MS,
846         MMI::PointerEvent::POINTER_ACTION_UP);
847     screenTouch_->OnPointerEvent(*eventUpContinue);
848 
849     EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionVector().size(), 3);
850     int32_t touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0);
851     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_DOWN);
852     touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(1);
853     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_MOVE);
854     touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(2);
855     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_UP);
856 
857     lastUpTime_ += TIMESTAMP_1700;
858 
859     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleIgnoreRepeatClickState_007 end";
860 }
861 
862 /**
863  * @tc.number: AccessibilityScreenTouch_Unittest_HandleIgnoreRepeatClickState_008
864  * @tc.name: HandleIgnoreRepeatClickState
865  * @tc.desc: Test function HandleIgnoreRepeatClickState
866  */
HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleIgnoreRepeatClickState_008, TestSize.Level1)867 HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleIgnoreRepeatClickState_008,
868     TestSize.Level1)
869 {
870     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleIgnoreRepeatClickState_008 start";
871     sptr<AccessibilityAccountData> accountData =
872         Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
873     if (accountData == nullptr) {
874         return;
875     }
876 
877     accountData->GetConfig()->SetClickResponseTime(0);
878     accountData->GetConfig()->SetIgnoreRepeatClickState(false);
879     accountData->GetConfig()->SetIgnoreRepeatClickTime(IGNORE_REPEAT_CLICK_LONGEST);
880 
881     screenTouch_ = std::make_shared<AccessibilityScreenTouch>();
882     if (screenTouch_ == nullptr) {
883         return;
884     }
885 
886     auto eventDown = SetPointerEvent((lastUpTime_ + TIMESTAMP_1500) * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_DOWN);
887     screenTouch_->OnPointerEvent(*eventDown);
888 
889     auto eventMove = SetPointerEvent((lastUpTime_ + TIMESTAMP_1600) * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_MOVE);
890     screenTouch_->OnPointerEvent(*eventMove);
891 
892     auto eventUp = SetPointerEvent((lastUpTime_ + TIMESTAMP_1700) * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_UP);
893     screenTouch_->OnPointerEvent(*eventUp);
894 
895     auto eventDownContinue = SetPointerEvent((lastUpTime_ + TIMESTAMP_2500) * US_TO_MS,
896         MMI::PointerEvent::POINTER_ACTION_DOWN);
897     screenTouch_->OnPointerEvent(*eventDownContinue);
898 
899     auto eventMoveContinue = SetPointerEvent((lastUpTime_ + TIMESTAMP_2700) * US_TO_MS,
900         MMI::PointerEvent::POINTER_ACTION_MOVE);
901     screenTouch_->OnPointerEvent(*eventMoveContinue);
902 
903     auto eventUpContinue = SetPointerEvent((lastUpTime_ + TIMESTAMP_2800) * US_TO_MS,
904         MMI::PointerEvent::POINTER_ACTION_UP);
905     screenTouch_->OnPointerEvent(*eventUpContinue);
906 
907     EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionVector().size(), 6);
908     int32_t touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0);
909     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_DOWN);
910     touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(1);
911     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_MOVE);
912     touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(2);
913     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_UP);
914     touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(3);
915     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_DOWN);
916     touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(4);
917     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_MOVE);
918     touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(5);
919     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_UP);
920 
921     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleIgnoreRepeatClickState_008 end";
922 }
923 
924 /**
925  * @tc.number: AccessibilityScreenTouch_Unittest_HandleIgnoreRepeatClickState_009
926  * @tc.name: HandleIgnoreRepeatClickState
927  * @tc.desc: Test function HandleIgnoreRepeatClickState
928  */
HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleIgnoreRepeatClickState_009, TestSize.Level1)929 HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleIgnoreRepeatClickState_009,
930     TestSize.Level1)
931 {
932     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleIgnoreRepeatClickState_009 start";
933     sptr<AccessibilityAccountData> accountData =
934         Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
935     if (accountData == nullptr) {
936         return;
937     }
938 
939     accountData->GetConfig()->SetClickResponseTime(0);
940     accountData->GetConfig()->SetIgnoreRepeatClickState(true);
941     accountData->GetConfig()->SetIgnoreRepeatClickTime(IGNORE_REPEAT_CLICK_LONGEST);
942 
943     screenTouch_ = std::make_shared<AccessibilityScreenTouch>();
944     if (screenTouch_ == nullptr) {
945         return;
946     }
947 
948     auto eventDown = SetPointerEvent((lastUpTime_ + TIMESTAMP_1200) * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_DOWN);
949     screenTouch_->OnPointerEvent(*eventDown);
950 
951     auto eventMove = SetPointerEvent((lastUpTime_ + TIMESTAMP_1500) * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_MOVE);
952     screenTouch_->OnPointerEvent(*eventMove);
953 
954     auto eventUp = SetPointerEvent((lastUpTime_ + TIMESTAMP_1600) * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_UP);
955     screenTouch_->OnPointerEvent(*eventUp);
956 
957     auto eventDownContinue = SetPointerEvent((lastUpTime_ + TIMESTAMP_1200) * US_TO_MS,
958         MMI::PointerEvent::POINTER_ACTION_DOWN);
959     screenTouch_->OnPointerEvent(*eventDownContinue);
960 
961     auto eventMoveContinue = SetPointerEvent((lastUpTime_ + TIMESTAMP_1500) * US_TO_MS,
962         MMI::PointerEvent::POINTER_ACTION_MOVE);
963     screenTouch_->OnPointerEvent(*eventMoveContinue);
964 
965     auto eventUpContinue = SetPointerEvent((lastUpTime_ + TIMESTAMP_1600) * US_TO_MS,
966         MMI::PointerEvent::POINTER_ACTION_UP);
967     screenTouch_->OnPointerEvent(*eventUpContinue);
968 
969     EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionVector().size(), 0);
970 
971     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleIgnoreRepeatClickState_009 end";
972 }
973 
974 /**
975  * @tc.number: AccessibilityScreenTouch_Unittest_HandleIgnoreRepeatClickState_010
976  * @tc.name: HandleIgnoreRepeatClickState
977  * @tc.desc: Test function HandleIgnoreRepeatClickState
978  */
HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleIgnoreRepeatClickState_010, TestSize.Level1)979 HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleIgnoreRepeatClickState_010,
980     TestSize.Level1)
981 {
982     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleIgnoreRepeatClickState_010 start";
983     sptr<AccessibilityAccountData> accountData =
984         Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
985     if (accountData == nullptr) {
986         return;
987     }
988 
989     accountData->GetConfig()->SetClickResponseTime(0);
990     accountData->GetConfig()->SetIgnoreRepeatClickState(true);
991     accountData->GetConfig()->SetIgnoreRepeatClickTime(IGNORE_REPEAT_CLICK_LONGEST);
992 
993     screenTouch_ = std::make_shared<AccessibilityScreenTouch>();
994     if (screenTouch_ == nullptr) {
995         return;
996     }
997 
998     std::vector<MMI::PointerEvent::PointerItem> points = {};
999     MMI::PointerEvent::PointerItem firstPoint = {};
1000     firstPoint.SetPointerId(0);
1001     points.emplace_back(firstPoint);
1002     auto firstDownEvent = SetPointerEvent((lastUpTime_ + TIMESTAMP_1500) * US_TO_MS,
1003         MMI::PointerEvent::POINTER_ACTION_DOWN, points, 0);
1004     screenTouch_->OnPointerEvent(*firstDownEvent);
1005 
1006     auto firstMoveEvent = SetPointerEvent((lastUpTime_ + TIMESTAMP_1500) * US_TO_MS,
1007         MMI::PointerEvent::POINTER_ACTION_MOVE, points, 0);
1008     screenTouch_->OnPointerEvent(*firstMoveEvent);
1009 
1010     MMI::PointerEvent::PointerItem secondPoint = {};
1011     secondPoint.SetPointerId(1);
1012     points.emplace_back(secondPoint);
1013     auto secondDownEvent = SetPointerEvent((lastUpTime_ + TIMESTAMP_1600) * US_TO_MS,
1014         MMI::PointerEvent::POINTER_ACTION_DOWN, points, 1);
1015     screenTouch_->OnPointerEvent(*secondDownEvent);
1016 
1017     auto secondMoveEvent = SetPointerEvent((lastUpTime_ + TIMESTAMP_1600) * US_TO_MS,
1018         MMI::PointerEvent::POINTER_ACTION_MOVE, points, 1);
1019     screenTouch_->OnPointerEvent(*secondMoveEvent);
1020 
1021     auto secondUpEvent = SetPointerEvent((lastUpTime_ + TIMESTAMP_1700) * US_TO_MS,
1022         MMI::PointerEvent::POINTER_ACTION_UP, points, 1);
1023     screenTouch_->OnPointerEvent(*secondUpEvent);
1024 
1025     auto firstUpEvent = SetPointerEvent((lastUpTime_ + TIMESTAMP_1700) * US_TO_MS,
1026         MMI::PointerEvent::POINTER_ACTION_UP);
1027     screenTouch_->OnPointerEvent(*firstUpEvent);
1028 
1029     EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionVector().size(), 6);
1030     int32_t touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0);
1031     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_DOWN);
1032     touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(2);
1033     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_DOWN);
1034     touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(5);
1035     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_UP);
1036 
1037     lastUpTime_ += TIMESTAMP_1700;
1038 
1039     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleIgnoreRepeatClickState_010 end";
1040 }
1041 
1042 /**
1043  * @tc.number: AccessibilityScreenTouch_Unittest_HandleIgnoreRepeatClickState_011
1044  * @tc.name: HandleIgnoreRepeatClickState
1045  * @tc.desc: Test function HandleIgnoreRepeatClickState
1046  */
HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleIgnoreRepeatClickState_011, TestSize.Level1)1047 HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleIgnoreRepeatClickState_011,
1048     TestSize.Level1)
1049 {
1050     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleIgnoreRepeatClickState_011 start";
1051     sptr<AccessibilityAccountData> accountData =
1052         Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
1053     if (accountData == nullptr) {
1054         return;
1055     }
1056 
1057     accountData->GetConfig()->SetClickResponseTime(0);
1058     accountData->GetConfig()->SetIgnoreRepeatClickState(false);
1059     accountData->GetConfig()->SetIgnoreRepeatClickTime(IGNORE_REPEAT_CLICK_LONGEST);
1060 
1061     screenTouch_ = std::make_shared<AccessibilityScreenTouch>();
1062     if (screenTouch_ == nullptr) {
1063         return;
1064     }
1065 
1066     std::vector<MMI::PointerEvent::PointerItem> points = {};
1067     MMI::PointerEvent::PointerItem firstPoint = {};
1068     firstPoint.SetPointerId(0);
1069     points.emplace_back(firstPoint);
1070     auto firstDownEvent = SetPointerEvent((lastUpTime_ + TIMESTAMP_1500) * US_TO_MS,
1071         MMI::PointerEvent::POINTER_ACTION_DOWN, points, 0);
1072     screenTouch_->OnPointerEvent(*firstDownEvent);
1073 
1074     auto firstMoveEvent = SetPointerEvent((lastUpTime_ + TIMESTAMP_1500) * US_TO_MS,
1075         MMI::PointerEvent::POINTER_ACTION_MOVE, points, 0);
1076     screenTouch_->OnPointerEvent(*firstMoveEvent);
1077 
1078     MMI::PointerEvent::PointerItem secondPoint = {};
1079     secondPoint.SetPointerId(1);
1080     points.emplace_back(secondPoint);
1081     auto secondDownEvent = SetPointerEvent((lastUpTime_ + TIMESTAMP_1600) * US_TO_MS,
1082         MMI::PointerEvent::POINTER_ACTION_DOWN, points, 1);
1083     screenTouch_->OnPointerEvent(*secondDownEvent);
1084 
1085     auto secondMoveEvent = SetPointerEvent((lastUpTime_ + TIMESTAMP_1600) * US_TO_MS,
1086         MMI::PointerEvent::POINTER_ACTION_MOVE, points, 1);
1087     screenTouch_->OnPointerEvent(*secondMoveEvent);
1088 
1089     auto secondUpEvent = SetPointerEvent((lastUpTime_ + TIMESTAMP_1700) * US_TO_MS,
1090         MMI::PointerEvent::POINTER_ACTION_UP, points, 1);
1091     screenTouch_->OnPointerEvent(*secondUpEvent);
1092 
1093     auto firstUpEvent = SetPointerEvent((lastUpTime_ + TIMESTAMP_1700) * US_TO_MS,
1094         MMI::PointerEvent::POINTER_ACTION_UP);
1095     screenTouch_->OnPointerEvent(*firstUpEvent);
1096 
1097     EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionVector().size(), 6);
1098 
1099     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleIgnoreRepeatClickState_011 end";
1100 }
1101 
1102 /**
1103  * @tc.number: AccessibilityScreenTouch_Unittest_HandleIgnoreRepeatClickState_012
1104  * @tc.name: HandleIgnoreRepeatClickState
1105  * @tc.desc: Test function HandleIgnoreRepeatClickState
1106  */
HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleIgnoreRepeatClickState_012, TestSize.Level1)1107 HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleIgnoreRepeatClickState_012,
1108     TestSize.Level1)
1109 {
1110     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleIgnoreRepeatClickState_012 start";
1111     sptr<AccessibilityAccountData> accountData =
1112         Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
1113     if (accountData == nullptr) {
1114         return;
1115     }
1116 
1117     accountData->GetConfig()->SetClickResponseTime(0);
1118     accountData->GetConfig()->SetIgnoreRepeatClickState(true);
1119     accountData->GetConfig()->SetIgnoreRepeatClickTime(IGNORE_REPEAT_CLICK_LONGEST);
1120 
1121     screenTouch_ = std::make_shared<AccessibilityScreenTouch>();
1122     if (screenTouch_ == nullptr) {
1123         return;
1124     }
1125 
1126     std::vector<MMI::PointerEvent::PointerItem> points = {};
1127     MMI::PointerEvent::PointerItem firstPoint = {};
1128     firstPoint.SetPointerId(0);
1129     points.emplace_back(firstPoint);
1130     auto firstDownEvent = SetPointerEvent((lastUpTime_ + TIMESTAMP_1200) * US_TO_MS,
1131         MMI::PointerEvent::POINTER_ACTION_DOWN, points, 0);
1132     screenTouch_->OnPointerEvent(*firstDownEvent);
1133 
1134     auto firstMoveEvent = SetPointerEvent((lastUpTime_ + TIMESTAMP_1500) * US_TO_MS,
1135         MMI::PointerEvent::POINTER_ACTION_MOVE, points, 0);
1136     screenTouch_->OnPointerEvent(*firstMoveEvent);
1137 
1138     MMI::PointerEvent::PointerItem secondPoint = {};
1139     secondPoint.SetPointerId(1);
1140     points.emplace_back(secondPoint);
1141     auto secondDownEvent = SetPointerEvent((lastUpTime_ + TIMESTAMP_1200) * US_TO_MS,
1142         MMI::PointerEvent::POINTER_ACTION_DOWN, points, 1);
1143     screenTouch_->OnPointerEvent(*secondDownEvent);
1144 
1145     auto secondMoveEvent = SetPointerEvent((lastUpTime_ + TIMESTAMP_1500) * US_TO_MS,
1146         MMI::PointerEvent::POINTER_ACTION_MOVE, points, 1);
1147     screenTouch_->OnPointerEvent(*secondMoveEvent);
1148 
1149     auto secondUpEvent = SetPointerEvent((lastUpTime_ + TIMESTAMP_1600) * US_TO_MS,
1150         MMI::PointerEvent::POINTER_ACTION_UP, points, 1);
1151     screenTouch_->OnPointerEvent(*secondUpEvent);
1152 
1153     auto firstUpEvent = SetPointerEvent((lastUpTime_ + TIMESTAMP_1600) * US_TO_MS,
1154         MMI::PointerEvent::POINTER_ACTION_UP);
1155     screenTouch_->OnPointerEvent(*firstUpEvent);
1156 
1157     EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionVector().size(), 0);
1158 
1159     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleIgnoreRepeatClickState_012 end";
1160 }
1161 
1162 /**
1163  * @tc.number: AccessibilityScreenTouch_Unittest_HandleResponseDelayState_001
1164  * @tc.name: HandleResponseDelayState
1165  * @tc.desc: Test function HandleResponseDelayState
1166  */
HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleResponseDelayState_001, TestSize.Level1)1167 HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleResponseDelayState_001,
1168     TestSize.Level1)
1169 {
1170     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleResponseDelayState_001 start";
1171     sptr<AccessibilityAccountData> accountData =
1172         Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
1173     if (accountData == nullptr) {
1174         return;
1175     }
1176 
1177     accountData->GetConfig()->SetClickResponseTime(CLICK_RESPONSE_DELAY_LONG);
1178     accountData->GetConfig()->SetIgnoreRepeatClickState(false);
1179 
1180     screenTouch_ = std::make_shared<AccessibilityScreenTouch>();
1181     if (screenTouch_ == nullptr) {
1182         return;
1183     }
1184 
1185     auto eventDown = SetPointerEvent(TIMESTAMP_1500 * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_DOWN);
1186     screenTouch_->OnPointerEvent(*eventDown);
1187 
1188     auto eventMove = SetPointerEvent(TIMESTAMP_1600 * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_MOVE);
1189     screenTouch_->OnPointerEvent(*eventMove);
1190 
1191     sleep(1);
1192 
1193     auto eventUp = SetPointerEvent(TIMESTAMP_1700 * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_UP);
1194     screenTouch_->OnPointerEvent(*eventUp);
1195 
1196     EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionVector().size(), 2);
1197     int32_t touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0);
1198     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_DOWN);
1199     touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(1);
1200     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_UP);
1201 
1202     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleResponseDelayState_001 end";
1203 }
1204 
1205 /**
1206  * @tc.number: AccessibilityScreenTouch_Unittest_HandleResponseDelayState_002
1207  * @tc.name: HandleResponseDelayState
1208  * @tc.desc: Test function HandleResponseDelayState
1209  */
HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleResponseDelayState_002, TestSize.Level1)1210 HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleResponseDelayState_002,
1211     TestSize.Level1)
1212 {
1213     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleResponseDelayState_002 start";
1214     sptr<AccessibilityAccountData> accountData =
1215         Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
1216     if (accountData == nullptr) {
1217         return;
1218     }
1219 
1220     accountData->GetConfig()->SetClickResponseTime(CLICK_RESPONSE_DELAY_SHORT);
1221     accountData->GetConfig()->SetIgnoreRepeatClickState(false);
1222 
1223     screenTouch_ = std::make_shared<AccessibilityScreenTouch>();
1224     if (screenTouch_ == nullptr) {
1225         return;
1226     }
1227 
1228     auto eventDown = SetPointerEvent(TIMESTAMP_1500 * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_DOWN);
1229     screenTouch_->OnPointerEvent(*eventDown);
1230 
1231     auto eventMove = SetPointerEvent(TIMESTAMP_1600 * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_MOVE);
1232     screenTouch_->OnPointerEvent(*eventMove);
1233 
1234     sleep(1);
1235 
1236     auto eventUp = SetPointerEvent(TIMESTAMP_1700 * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_UP);
1237     screenTouch_->OnPointerEvent(*eventUp);
1238 
1239     EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionVector().size(), 3);
1240     int32_t touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0);
1241     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_DOWN);
1242     touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(1);
1243     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_MOVE);
1244     touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(2);
1245     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_UP);
1246 
1247     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleResponseDelayState_002 end";
1248 }
1249 
1250 /**
1251  * @tc.number: AccessibilityScreenTouch_Unittest_HandleResponseDelayState_003
1252  * @tc.name: HandleResponseDelayState
1253  * @tc.desc: Test function HandleResponseDelayState
1254  */
HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleResponseDelayState_003, TestSize.Level1)1255 HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleResponseDelayState_003,
1256     TestSize.Level1)
1257 {
1258     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleResponseDelayState_003 start";
1259     sptr<AccessibilityAccountData> accountData =
1260         Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
1261     if (accountData == nullptr) {
1262         return;
1263     }
1264 
1265     accountData->GetConfig()->SetClickResponseTime(CLICK_RESPONSE_DELAY_MEDIUM);
1266     accountData->GetConfig()->SetIgnoreRepeatClickState(false);
1267 
1268     screenTouch_ = std::make_shared<AccessibilityScreenTouch>();
1269     if (screenTouch_ == nullptr) {
1270         return;
1271     }
1272 
1273     auto eventDown = SetPointerEvent(TIMESTAMP_1500 * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_DOWN);
1274     screenTouch_->OnPointerEvent(*eventDown);
1275 
1276     auto eventMove = SetPointerEvent(TIMESTAMP_1600 * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_MOVE);
1277     screenTouch_->OnPointerEvent(*eventMove);
1278 
1279     sleep(1);
1280 
1281     auto eventUp = SetPointerEvent(TIMESTAMP_1700 * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_UP);
1282     screenTouch_->OnPointerEvent(*eventUp);
1283 
1284     EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionVector().size(), 2);
1285     int32_t touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0);
1286     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_DOWN);
1287     touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(1);
1288     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_UP);
1289 
1290     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleResponseDelayState_003 end";
1291 }
1292 
1293 /**
1294  * @tc.number: AccessibilityScreenTouch_Unittest_HandleResponseDelayState_004
1295  * @tc.name: HandleResponseDelayState
1296  * @tc.desc: Test function HandleResponseDelayState
1297  */
HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleResponseDelayState_004, TestSize.Level1)1298 HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleResponseDelayState_004,
1299     TestSize.Level1)
1300 {
1301     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleResponseDelayState_004 start";
1302     sptr<AccessibilityAccountData> accountData =
1303         Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
1304     if (accountData == nullptr) {
1305         return;
1306     }
1307 
1308     accountData->GetConfig()->SetClickResponseTime(CLICK_RESPONSE_DELAY_LONG);
1309     accountData->GetConfig()->SetIgnoreRepeatClickState(false);
1310 
1311     screenTouch_ = std::make_shared<AccessibilityScreenTouch>();
1312     if (screenTouch_ == nullptr) {
1313         return;
1314     }
1315 
1316     auto eventDown = SetPointerEvent(TIMESTAMP_1500 * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_DOWN);
1317     screenTouch_->OnPointerEvent(*eventDown);
1318 
1319     auto eventMove = SetPointerEvent(TIMESTAMP_1600 * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_MOVE);
1320     screenTouch_->OnPointerEvent(*eventMove);
1321 
1322     usleep(SLEEP_TIME_MS);
1323 
1324     auto eventUp = SetPointerEvent(TIMESTAMP_1700 * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_UP);
1325     screenTouch_->OnPointerEvent(*eventUp);
1326 
1327     EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionVector().size(), 0);
1328 
1329     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleResponseDelayState_004 end";
1330 }
1331 
1332 /**
1333  * @tc.number: AccessibilityScreenTouch_Unittest_HandleResponseDelayState_005
1334  * @tc.name: HandleResponseDelayState
1335  * @tc.desc: Test function HandleResponseDelayState
1336  */
HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleResponseDelayState_005, TestSize.Level1)1337 HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleResponseDelayState_005,
1338     TestSize.Level1)
1339 {
1340     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleResponseDelayState_005 start";
1341     sptr<AccessibilityAccountData> accountData =
1342         Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
1343     if (accountData == nullptr) {
1344         return;
1345     }
1346 
1347     accountData->GetConfig()->SetClickResponseTime(CLICK_RESPONSE_DELAY_SHORT);
1348     accountData->GetConfig()->SetIgnoreRepeatClickState(false);
1349 
1350     screenTouch_ = std::make_shared<AccessibilityScreenTouch>();
1351     if (screenTouch_ == nullptr) {
1352         return;
1353     }
1354 
1355     auto eventDown = SetPointerEvent(TIMESTAMP_1500 * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_DOWN);
1356     screenTouch_->OnPointerEvent(*eventDown);
1357 
1358     auto eventMove = SetPointerEvent(TIMESTAMP_1600 * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_MOVE);
1359     screenTouch_->OnPointerEvent(*eventMove);
1360 
1361     usleep(SLEEP_TIME_MS);
1362 
1363     auto eventUp = SetPointerEvent(TIMESTAMP_1700 * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_UP);
1364     screenTouch_->OnPointerEvent(*eventUp);
1365 
1366     EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionVector().size(), 3);
1367     int32_t touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0);
1368     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_DOWN);
1369     touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(1);
1370     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_MOVE);
1371     touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(2);
1372     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_UP);
1373 
1374     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleResponseDelayState_005 end";
1375 }
1376 
1377 /**
1378  * @tc.number: AccessibilityScreenTouch_Unittest_HandleResponseDelayState_006
1379  * @tc.name: HandleResponseDelayState
1380  * @tc.desc: Test function HandleResponseDelayState
1381  */
HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleResponseDelayState_006, TestSize.Level1)1382 HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleResponseDelayState_006,
1383     TestSize.Level1)
1384 {
1385     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleResponseDelayState_006 start";
1386     sptr<AccessibilityAccountData> accountData =
1387         Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
1388     if (accountData == nullptr) {
1389         return;
1390     }
1391 
1392     accountData->GetConfig()->SetClickResponseTime(CLICK_RESPONSE_DELAY_MEDIUM);
1393     accountData->GetConfig()->SetIgnoreRepeatClickState(false);
1394 
1395     screenTouch_ = std::make_shared<AccessibilityScreenTouch>();
1396     if (screenTouch_ == nullptr) {
1397         return;
1398     }
1399 
1400     auto eventDown = SetPointerEvent(TIMESTAMP_1500 * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_DOWN);
1401     screenTouch_->OnPointerEvent(*eventDown);
1402 
1403     auto eventMove = SetPointerEvent(TIMESTAMP_1600 * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_MOVE);
1404     screenTouch_->OnPointerEvent(*eventMove);
1405 
1406     usleep(SLEEP_TIME_MS);
1407 
1408     auto eventUp = SetPointerEvent(TIMESTAMP_1700 * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_UP);
1409     screenTouch_->OnPointerEvent(*eventUp);
1410 
1411     EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionVector().size(), 0);
1412 
1413     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleResponseDelayState_006 end";
1414 }
1415 
1416 /**
1417  * @tc.number: AccessibilityScreenTouch_Unittest_HandleResponseDelayState_007
1418  * @tc.name: HandleResponseDelayState
1419  * @tc.desc: Test function HandleResponseDelayState
1420  */
HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleResponseDelayState_007, TestSize.Level1)1421 HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleResponseDelayState_007,
1422     TestSize.Level1)
1423 {
1424     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleResponseDelayState_007 start";
1425     sptr<AccessibilityAccountData> accountData =
1426         Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
1427     if (accountData == nullptr) {
1428         return;
1429     }
1430 
1431     accountData->GetConfig()->SetClickResponseTime(CLICK_RESPONSE_DELAY_LONG);
1432     accountData->GetConfig()->SetIgnoreRepeatClickState(false);
1433 
1434     screenTouch_ = std::make_shared<AccessibilityScreenTouch>();
1435     if (screenTouch_ == nullptr) {
1436         return;
1437     }
1438 
1439     std::vector<MMI::PointerEvent::PointerItem> points = {};
1440     MMI::PointerEvent::PointerItem point = {};
1441     point.SetPointerId(0);
1442     point.SetDisplayX(0);
1443     point.SetDisplayY(0);
1444     points.emplace_back(point);
1445     auto eventDown = SetPointerEvent(TIMESTAMP_1500 * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_DOWN, points, 0);
1446     screenTouch_->OnPointerEvent(*eventDown);
1447 
1448     points.clear();
1449     point.SetDisplayX(500);
1450     point.SetDisplayY(500);
1451     points.emplace_back(point);
1452     auto eventMove = SetPointerEvent(TIMESTAMP_1600 * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_MOVE, points, 0);
1453     screenTouch_->OnPointerEvent(*eventMove);
1454 
1455     auto eventUp = SetPointerEvent(TIMESTAMP_1700 * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_UP, points, 0);
1456     screenTouch_->OnPointerEvent(*eventUp);
1457 
1458     EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionVector().size(), 3);
1459     int32_t touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0);
1460     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_DOWN);
1461     touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(1);
1462     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_MOVE);
1463     touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(2);
1464     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_UP);
1465 
1466     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleResponseDelayState_007 end";
1467 }
1468 
1469 /**
1470  * @tc.number: AccessibilityScreenTouch_Unittest_HandleResponseDelayState_008
1471  * @tc.name: HandleResponseDelayState
1472  * @tc.desc: Test function HandleResponseDelayState
1473  */
HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleResponseDelayState_008, TestSize.Level1)1474 HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleResponseDelayState_008,
1475     TestSize.Level1)
1476 {
1477     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleResponseDelayState_008 start";
1478     sptr<AccessibilityAccountData> accountData =
1479         Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
1480     if (accountData == nullptr) {
1481         return;
1482     }
1483 
1484     accountData->GetConfig()->SetClickResponseTime(CLICK_RESPONSE_DELAY_SHORT);
1485     accountData->GetConfig()->SetIgnoreRepeatClickState(false);
1486 
1487     screenTouch_ = std::make_shared<AccessibilityScreenTouch>();
1488     if (screenTouch_ == nullptr) {
1489         return;
1490     }
1491 
1492     std::vector<MMI::PointerEvent::PointerItem> points = {};
1493     MMI::PointerEvent::PointerItem point = {};
1494     point.SetPointerId(0);
1495     point.SetDisplayX(0);
1496     point.SetDisplayY(0);
1497     points.emplace_back(point);
1498     auto eventDown = SetPointerEvent(TIMESTAMP_1500 * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_DOWN, points, 0);
1499     screenTouch_->OnPointerEvent(*eventDown);
1500 
1501     points.clear();
1502     point.SetDisplayX(500);
1503     point.SetDisplayY(500);
1504     points.emplace_back(point);
1505     auto eventMove = SetPointerEvent(TIMESTAMP_1600 * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_MOVE, points, 0);
1506     screenTouch_->OnPointerEvent(*eventMove);
1507 
1508     auto eventUp = SetPointerEvent(TIMESTAMP_1700 * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_UP, points, 0);
1509     screenTouch_->OnPointerEvent(*eventUp);
1510 
1511     EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionVector().size(), 3);
1512     int32_t touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0);
1513     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_DOWN);
1514     touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(1);
1515     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_MOVE);
1516     touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(2);
1517     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_UP);
1518 
1519     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleResponseDelayState_008 end";
1520 }
1521 
1522 /**
1523  * @tc.number: AccessibilityScreenTouch_Unittest_HandleResponseDelayState_009
1524  * @tc.name: HandleResponseDelayState
1525  * @tc.desc: Test function HandleResponseDelayState
1526  */
HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleResponseDelayState_009, TestSize.Level1)1527 HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleResponseDelayState_009,
1528     TestSize.Level1)
1529 {
1530     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleResponseDelayState_009 start";
1531     sptr<AccessibilityAccountData> accountData =
1532         Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
1533     if (accountData == nullptr) {
1534         return;
1535     }
1536 
1537     accountData->GetConfig()->SetClickResponseTime(CLICK_RESPONSE_DELAY_MEDIUM);
1538     accountData->GetConfig()->SetIgnoreRepeatClickState(false);
1539 
1540     screenTouch_ = std::make_shared<AccessibilityScreenTouch>();
1541     if (screenTouch_ == nullptr) {
1542         return;
1543     }
1544 
1545     std::vector<MMI::PointerEvent::PointerItem> points = {};
1546     MMI::PointerEvent::PointerItem point = {};
1547     point.SetPointerId(0);
1548     point.SetDisplayX(0);
1549     point.SetDisplayY(0);
1550     points.emplace_back(point);
1551     auto eventDown = SetPointerEvent(TIMESTAMP_1500 * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_DOWN, points, 0);
1552     screenTouch_->OnPointerEvent(*eventDown);
1553 
1554     points.clear();
1555     point.SetDisplayX(500);
1556     point.SetDisplayY(500);
1557     points.emplace_back(point);
1558     auto eventMove = SetPointerEvent(TIMESTAMP_1600 * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_MOVE, points, 0);
1559     screenTouch_->OnPointerEvent(*eventMove);
1560 
1561     auto eventUp = SetPointerEvent(TIMESTAMP_1700 * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_UP, points, 0);
1562     screenTouch_->OnPointerEvent(*eventUp);
1563 
1564     EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionVector().size(), 3);
1565     int32_t touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0);
1566     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_DOWN);
1567     touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(1);
1568     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_MOVE);
1569     touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(2);
1570     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_UP);
1571 
1572     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleResponseDelayState_009 end";
1573 }
1574 
1575 /**
1576  * @tc.number: AccessibilityScreenTouch_Unittest_HandleResponseDelayState_010
1577  * @tc.name: HandleResponseDelayState
1578  * @tc.desc: Test function HandleResponseDelayState
1579  */
HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleResponseDelayState_010, TestSize.Level1)1580 HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleResponseDelayState_010,
1581     TestSize.Level1)
1582 {
1583     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleResponseDelayState_010 start";
1584     sptr<AccessibilityAccountData> accountData =
1585         Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
1586     if (accountData == nullptr) {
1587         return;
1588     }
1589 
1590     accountData->GetConfig()->SetClickResponseTime(CLICK_RESPONSE_DELAY_LONG);
1591     accountData->GetConfig()->SetIgnoreRepeatClickState(false);
1592 
1593     screenTouch_ = std::make_shared<AccessibilityScreenTouch>();
1594     if (screenTouch_ == nullptr) {
1595         return;
1596     }
1597 
1598     std::vector<MMI::PointerEvent::PointerItem> points = {};
1599     MMI::PointerEvent::PointerItem firstPoint = {};
1600     firstPoint.SetPointerId(0);
1601     points.emplace_back(firstPoint);
1602     auto firstDownEvent = SetPointerEvent(TIMESTAMP_1500 * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_DOWN, points, 0);
1603     screenTouch_->OnPointerEvent(*firstDownEvent);
1604 
1605     auto firstMoveEvent = SetPointerEvent(TIMESTAMP_1500 * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_MOVE, points, 0);
1606     screenTouch_->OnPointerEvent(*firstMoveEvent);
1607 
1608     MMI::PointerEvent::PointerItem secondPoint = {};
1609     secondPoint.SetPointerId(1);
1610     points.emplace_back(secondPoint);
1611     auto secondDownEvent = SetPointerEvent(TIMESTAMP_1600 * US_TO_MS,
1612         MMI::PointerEvent::POINTER_ACTION_DOWN, points, 1);
1613     screenTouch_->OnPointerEvent(*secondDownEvent);
1614 
1615     auto secondMoveEvent = SetPointerEvent(TIMESTAMP_1600 * US_TO_MS,
1616         MMI::PointerEvent::POINTER_ACTION_MOVE, points, 1);
1617     screenTouch_->OnPointerEvent(*secondMoveEvent);
1618 
1619     sleep(1);
1620 
1621     auto secondUpEvent = SetPointerEvent(TIMESTAMP_1700 * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_UP, points, 1);
1622     screenTouch_->OnPointerEvent(*secondUpEvent);
1623 
1624     auto firstUpEvent = SetPointerEvent(TIMESTAMP_1700 * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_UP);
1625     screenTouch_->OnPointerEvent(*firstUpEvent);
1626 
1627     EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionVector().size(), 4);
1628     int32_t touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0);
1629     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_DOWN);
1630     touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(1);
1631     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_DOWN);
1632     touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(2);
1633     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_UP);
1634     touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(3);
1635     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_UP);
1636 
1637     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleResponseDelayState_010 end";
1638 }
1639 
1640 /**
1641  * @tc.number: AccessibilityScreenTouch_Unittest_HandleResponseDelayState_011
1642  * @tc.name: HandleResponseDelayState
1643  * @tc.desc: Test function HandleResponseDelayState
1644  */
HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleResponseDelayState_011, TestSize.Level1)1645 HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleResponseDelayState_011,
1646     TestSize.Level1)
1647 {
1648     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleResponseDelayState_011 start";
1649     sptr<AccessibilityAccountData> accountData =
1650         Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
1651     if (accountData == nullptr) {
1652         return;
1653     }
1654 
1655     accountData->GetConfig()->SetClickResponseTime(CLICK_RESPONSE_DELAY_SHORT);
1656     accountData->GetConfig()->SetIgnoreRepeatClickState(false);
1657 
1658     screenTouch_ = std::make_shared<AccessibilityScreenTouch>();
1659     if (screenTouch_ == nullptr) {
1660         return;
1661     }
1662 
1663     std::vector<MMI::PointerEvent::PointerItem> points = {};
1664     MMI::PointerEvent::PointerItem firstPoint = {};
1665     firstPoint.SetPointerId(0);
1666     points.emplace_back(firstPoint);
1667     auto firstDownEvent = SetPointerEvent(TIMESTAMP_1500 * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_DOWN, points, 0);
1668     screenTouch_->OnPointerEvent(*firstDownEvent);
1669 
1670     auto firstMoveEvent = SetPointerEvent(TIMESTAMP_1500 * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_MOVE, points, 0);
1671     screenTouch_->OnPointerEvent(*firstMoveEvent);
1672 
1673     MMI::PointerEvent::PointerItem secondPoint = {};
1674     secondPoint.SetPointerId(1);
1675     points.emplace_back(secondPoint);
1676     auto secondDownEvent = SetPointerEvent(TIMESTAMP_1600 * US_TO_MS,
1677         MMI::PointerEvent::POINTER_ACTION_DOWN, points, 1);
1678     screenTouch_->OnPointerEvent(*secondDownEvent);
1679 
1680     auto secondMoveEvent = SetPointerEvent(TIMESTAMP_1600 * US_TO_MS,
1681         MMI::PointerEvent::POINTER_ACTION_MOVE, points, 1);
1682     screenTouch_->OnPointerEvent(*secondMoveEvent);
1683 
1684     sleep(1);
1685 
1686     auto secondUpEvent = SetPointerEvent(TIMESTAMP_1700 * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_UP, points, 1);
1687     screenTouch_->OnPointerEvent(*secondUpEvent);
1688 
1689     auto firstUpEvent = SetPointerEvent(TIMESTAMP_1700 * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_UP);
1690     screenTouch_->OnPointerEvent(*firstUpEvent);
1691 
1692     EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionVector().size(), 6);
1693     int32_t touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0);
1694     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_DOWN);
1695     touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(2);
1696     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_DOWN);
1697     touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(4);
1698     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_UP);
1699     touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(5);
1700     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_UP);
1701 
1702     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleResponseDelayState_011 end";
1703 }
1704 
1705 /**
1706  * @tc.number: AccessibilityScreenTouch_Unittest_HandleResponseDelayState_012
1707  * @tc.name: HandleResponseDelayState
1708  * @tc.desc: Test function HandleResponseDelayState
1709  */
HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleResponseDelayState_012, TestSize.Level1)1710 HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleResponseDelayState_012,
1711     TestSize.Level1)
1712 {
1713     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleResponseDelayState_012 start";
1714     sptr<AccessibilityAccountData> accountData =
1715         Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
1716     if (accountData == nullptr) {
1717         return;
1718     }
1719 
1720     accountData->GetConfig()->SetClickResponseTime(CLICK_RESPONSE_DELAY_MEDIUM);
1721     accountData->GetConfig()->SetIgnoreRepeatClickState(false);
1722 
1723     screenTouch_ = std::make_shared<AccessibilityScreenTouch>();
1724     if (screenTouch_ == nullptr) {
1725         return;
1726     }
1727 
1728     std::vector<MMI::PointerEvent::PointerItem> points = {};
1729     MMI::PointerEvent::PointerItem firstPoint = {};
1730     firstPoint.SetPointerId(0);
1731     points.emplace_back(firstPoint);
1732     auto firstDownEvent = SetPointerEvent(TIMESTAMP_1500 * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_DOWN, points, 0);
1733     screenTouch_->OnPointerEvent(*firstDownEvent);
1734 
1735     auto firstMoveEvent = SetPointerEvent(TIMESTAMP_1500 * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_MOVE, points, 0);
1736     screenTouch_->OnPointerEvent(*firstMoveEvent);
1737 
1738     MMI::PointerEvent::PointerItem secondPoint = {};
1739     secondPoint.SetPointerId(1);
1740     points.emplace_back(secondPoint);
1741     auto secondDownEvent = SetPointerEvent(TIMESTAMP_1600 * US_TO_MS,
1742         MMI::PointerEvent::POINTER_ACTION_DOWN, points, 1);
1743     screenTouch_->OnPointerEvent(*secondDownEvent);
1744 
1745     auto secondMoveEvent = SetPointerEvent(TIMESTAMP_1600 * US_TO_MS,
1746         MMI::PointerEvent::POINTER_ACTION_MOVE, points, 1);
1747     screenTouch_->OnPointerEvent(*secondMoveEvent);
1748 
1749     sleep(1);
1750 
1751     auto secondUpEvent = SetPointerEvent(TIMESTAMP_1700 * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_UP, points, 1);
1752     screenTouch_->OnPointerEvent(*secondUpEvent);
1753 
1754     auto firstUpEvent = SetPointerEvent(TIMESTAMP_1700 * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_UP);
1755     screenTouch_->OnPointerEvent(*firstUpEvent);
1756 
1757     EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionVector().size(), 4);
1758     int32_t touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0);
1759     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_DOWN);
1760     touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(1);
1761     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_DOWN);
1762     touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(2);
1763     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_UP);
1764     touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(3);
1765     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_UP);
1766 
1767     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleResponseDelayState_012 end";
1768 }
1769 
1770 /**
1771  * @tc.number: AccessibilityScreenTouch_Unittest_HandleResponseDelayState_013
1772  * @tc.name: HandleResponseDelayState
1773  * @tc.desc: Test function HandleResponseDelayState
1774  */
HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleResponseDelayState_013, TestSize.Level1)1775 HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleResponseDelayState_013,
1776     TestSize.Level1)
1777 {
1778     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleResponseDelayState_013 start";
1779     sptr<AccessibilityAccountData> accountData =
1780         Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
1781     if (accountData == nullptr) {
1782         return;
1783     }
1784 
1785     accountData->GetConfig()->SetClickResponseTime(CLICK_RESPONSE_DELAY_LONG);
1786     accountData->GetConfig()->SetIgnoreRepeatClickState(false);
1787 
1788     screenTouch_ = std::make_shared<AccessibilityScreenTouch>();
1789     if (screenTouch_ == nullptr) {
1790         return;
1791     }
1792 
1793     std::vector<MMI::PointerEvent::PointerItem> points = {};
1794     MMI::PointerEvent::PointerItem firstPoint = {};
1795     firstPoint.SetPointerId(0);
1796     points.emplace_back(firstPoint);
1797     auto firstDownEvent = SetPointerEvent(TIMESTAMP_1500 * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_DOWN, points, 0);
1798     screenTouch_->OnPointerEvent(*firstDownEvent);
1799 
1800     auto firstMoveEvent = SetPointerEvent(TIMESTAMP_1500 * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_MOVE, points, 0);
1801     screenTouch_->OnPointerEvent(*firstMoveEvent);
1802 
1803     sleep(1);
1804 
1805     MMI::PointerEvent::PointerItem secondPoint = {};
1806     secondPoint.SetPointerId(1);
1807     points.emplace_back(secondPoint);
1808     auto secondDownEvent = SetPointerEvent(TIMESTAMP_1600 * US_TO_MS,
1809         MMI::PointerEvent::POINTER_ACTION_DOWN, points, 1);
1810     screenTouch_->OnPointerEvent(*secondDownEvent);
1811 
1812     auto secondMoveEvent = SetPointerEvent(TIMESTAMP_1600 * US_TO_MS,
1813         MMI::PointerEvent::POINTER_ACTION_MOVE, points, 1);
1814     screenTouch_->OnPointerEvent(*secondMoveEvent);
1815 
1816     auto secondUpEvent = SetPointerEvent(TIMESTAMP_1700 * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_UP, points, 1);
1817     screenTouch_->OnPointerEvent(*secondUpEvent);
1818 
1819     auto firstUpEvent = SetPointerEvent(TIMESTAMP_1700 * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_UP);
1820     screenTouch_->OnPointerEvent(*firstUpEvent);
1821 
1822     EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionVector().size(), 3);
1823     int32_t touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0);
1824     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_DOWN);
1825     touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(1);
1826     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_MOVE);
1827     touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(2);
1828     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_UP);
1829 
1830     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleResponseDelayState_013 end";
1831 }
1832 
1833 /**
1834  * @tc.number: AccessibilityScreenTouch_Unittest_HandleResponseDelayState_014
1835  * @tc.name: HandleResponseDelayState
1836  * @tc.desc: Test function HandleResponseDelayState
1837  */
HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleResponseDelayState_014, TestSize.Level1)1838 HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleResponseDelayState_014,
1839     TestSize.Level1)
1840 {
1841     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleResponseDelayState_014 start";
1842     sptr<AccessibilityAccountData> accountData =
1843         Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
1844     if (accountData == nullptr) {
1845         return;
1846     }
1847 
1848     accountData->GetConfig()->SetClickResponseTime(CLICK_RESPONSE_DELAY_SHORT);
1849     accountData->GetConfig()->SetIgnoreRepeatClickState(false);
1850 
1851     screenTouch_ = std::make_shared<AccessibilityScreenTouch>();
1852     if (screenTouch_ == nullptr) {
1853         return;
1854     }
1855 
1856     std::vector<MMI::PointerEvent::PointerItem> points = {};
1857     MMI::PointerEvent::PointerItem firstPoint = {};
1858     firstPoint.SetPointerId(0);
1859     points.emplace_back(firstPoint);
1860     auto firstDownEvent = SetPointerEvent(TIMESTAMP_1500 * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_DOWN, points, 0);
1861     screenTouch_->OnPointerEvent(*firstDownEvent);
1862 
1863     auto firstMoveEvent = SetPointerEvent(TIMESTAMP_1500 * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_MOVE, points, 0);
1864     screenTouch_->OnPointerEvent(*firstMoveEvent);
1865 
1866     sleep(1);
1867 
1868     MMI::PointerEvent::PointerItem secondPoint = {};
1869     secondPoint.SetPointerId(1);
1870     points.emplace_back(secondPoint);
1871     auto secondDownEvent = SetPointerEvent(TIMESTAMP_1600 * US_TO_MS,
1872         MMI::PointerEvent::POINTER_ACTION_DOWN, points, 1);
1873     screenTouch_->OnPointerEvent(*secondDownEvent);
1874 
1875     auto secondMoveEvent = SetPointerEvent(TIMESTAMP_1600 * US_TO_MS,
1876         MMI::PointerEvent::POINTER_ACTION_MOVE, points, 1);
1877     screenTouch_->OnPointerEvent(*secondMoveEvent);
1878 
1879     auto secondUpEvent = SetPointerEvent(TIMESTAMP_1700 * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_UP, points, 1);
1880     screenTouch_->OnPointerEvent(*secondUpEvent);
1881 
1882     auto firstUpEvent = SetPointerEvent(TIMESTAMP_1700 * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_UP);
1883     screenTouch_->OnPointerEvent(*firstUpEvent);
1884 
1885     EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionVector().size(), 6);
1886     int32_t touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0);
1887     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_DOWN);
1888     touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(2);
1889     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_DOWN);
1890     touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(4);
1891     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_UP);
1892 
1893     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleResponseDelayState_014 end";
1894 }
1895 
1896 /**
1897  * @tc.number: AccessibilityScreenTouch_Unittest_HandleResponseDelayState_015
1898  * @tc.name: HandleResponseDelayState
1899  * @tc.desc: Test function HandleResponseDelayState
1900  */
HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleResponseDelayState_015, TestSize.Level1)1901 HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleResponseDelayState_015,
1902     TestSize.Level1)
1903 {
1904     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleResponseDelayState_015 start";
1905     sptr<AccessibilityAccountData> accountData =
1906         Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
1907     if (accountData == nullptr) {
1908         return;
1909     }
1910 
1911     accountData->GetConfig()->SetClickResponseTime(CLICK_RESPONSE_DELAY_MEDIUM);
1912     accountData->GetConfig()->SetIgnoreRepeatClickState(false);
1913 
1914     screenTouch_ = std::make_shared<AccessibilityScreenTouch>();
1915     if (screenTouch_ == nullptr) {
1916         return;
1917     }
1918 
1919     std::vector<MMI::PointerEvent::PointerItem> points = {};
1920     MMI::PointerEvent::PointerItem firstPoint = {};
1921     firstPoint.SetPointerId(0);
1922     points.emplace_back(firstPoint);
1923     auto firstDownEvent = SetPointerEvent(TIMESTAMP_1500 * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_DOWN, points, 0);
1924     screenTouch_->OnPointerEvent(*firstDownEvent);
1925 
1926     auto firstMoveEvent = SetPointerEvent(TIMESTAMP_1500 * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_MOVE, points, 0);
1927     screenTouch_->OnPointerEvent(*firstMoveEvent);
1928 
1929     sleep(1);
1930 
1931     MMI::PointerEvent::PointerItem secondPoint = {};
1932     secondPoint.SetPointerId(1);
1933     points.emplace_back(secondPoint);
1934     auto secondDownEvent = SetPointerEvent(TIMESTAMP_1600 * US_TO_MS,
1935         MMI::PointerEvent::POINTER_ACTION_DOWN, points, 1);
1936     screenTouch_->OnPointerEvent(*secondDownEvent);
1937 
1938     auto secondMoveEvent = SetPointerEvent(TIMESTAMP_1600 * US_TO_MS,
1939         MMI::PointerEvent::POINTER_ACTION_MOVE, points, 1);
1940     screenTouch_->OnPointerEvent(*secondMoveEvent);
1941 
1942     auto secondUpEvent = SetPointerEvent(TIMESTAMP_1700 * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_UP, points, 1);
1943     screenTouch_->OnPointerEvent(*secondUpEvent);
1944 
1945     auto firstUpEvent = SetPointerEvent(TIMESTAMP_1700 * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_UP);
1946     screenTouch_->OnPointerEvent(*firstUpEvent);
1947 
1948     EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionVector().size(), 3);
1949     int32_t touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0);
1950     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_DOWN);
1951     touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(1);
1952     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_MOVE);
1953     touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(2);
1954     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_UP);
1955 
1956     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleResponseDelayState_015 end";
1957 }
1958 
1959 /**
1960  * @tc.number: AccessibilityScreenTouch_Unittest_HandleBothState_001
1961  * @tc.name: HandleBothState
1962  * @tc.desc: Test function HandleBothState
1963  */
HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleBothState_001, TestSize.Level1)1964 HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleBothState_001, TestSize.Level1)
1965 {
1966     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleBothState_001 start";
1967     sptr<AccessibilityAccountData> accountData =
1968         Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
1969     if (accountData == nullptr) {
1970         return;
1971     }
1972 
1973     accountData->GetConfig()->SetClickResponseTime(CLICK_RESPONSE_DELAY_LONG);
1974     accountData->GetConfig()->SetIgnoreRepeatClickState(true);
1975     accountData->GetConfig()->SetIgnoreRepeatClickTime(IGNORE_REPEAT_CLICK_LONGEST);
1976 
1977     screenTouch_ = std::make_shared<AccessibilityScreenTouch>();
1978     if (screenTouch_ == nullptr) {
1979         return;
1980     }
1981 
1982     auto eventDown = SetPointerEvent((lastUpTime_ + TIMESTAMP_1500) * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_DOWN);
1983     screenTouch_->OnPointerEvent(*eventDown);
1984 
1985     sleep(1);
1986 
1987     auto eventMove = SetPointerEvent((lastUpTime_ + TIMESTAMP_1600) * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_MOVE);
1988     screenTouch_->OnPointerEvent(*eventMove);
1989 
1990     auto eventUp = SetPointerEvent((lastUpTime_ + TIMESTAMP_1700) * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_UP);
1991     screenTouch_->OnPointerEvent(*eventUp);
1992 
1993     EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionVector().size(), 3);
1994     int32_t touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0);
1995     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_DOWN);
1996     touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(1);
1997     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_MOVE);
1998     touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(2);
1999     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_UP);
2000 
2001     lastUpTime_ += TIMESTAMP_1700;
2002 
2003     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleBothState_001 end";
2004 }
2005 
2006 /**
2007  * @tc.number: AccessibilityScreenTouch_Unittest_HandleBothState_002
2008  * @tc.name: HandleBothState
2009  * @tc.desc: Test function HandleBothState
2010  */
HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleBothState_002, TestSize.Level1)2011 HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleBothState_002, TestSize.Level1)
2012 {
2013     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleBothState_002 start";
2014     sptr<AccessibilityAccountData> accountData =
2015         Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
2016     if (accountData == nullptr) {
2017         return;
2018     }
2019 
2020     accountData->GetConfig()->SetClickResponseTime(CLICK_RESPONSE_DELAY_LONG);
2021     accountData->GetConfig()->SetIgnoreRepeatClickState(true);
2022     accountData->GetConfig()->SetIgnoreRepeatClickTime(IGNORE_REPEAT_CLICK_MEDIUM);
2023 
2024     screenTouch_ = std::make_shared<AccessibilityScreenTouch>();
2025     if (screenTouch_ == nullptr) {
2026         return;
2027     }
2028 
2029     auto eventDown = SetPointerEvent((lastUpTime_ + TIMESTAMP_1500) * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_DOWN);
2030     screenTouch_->OnPointerEvent(*eventDown);
2031 
2032     sleep(1);
2033 
2034     auto eventMove = SetPointerEvent((lastUpTime_ + TIMESTAMP_1600) * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_MOVE);
2035     screenTouch_->OnPointerEvent(*eventMove);
2036 
2037     auto eventUp = SetPointerEvent((lastUpTime_ + TIMESTAMP_1700) * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_UP);
2038     screenTouch_->OnPointerEvent(*eventUp);
2039 
2040     EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionVector().size(), 3);
2041     int32_t touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0);
2042     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_DOWN);
2043     touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(1);
2044     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_MOVE);
2045     touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(2);
2046     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_UP);
2047 
2048     lastUpTime_ += TIMESTAMP_1700;
2049 
2050     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleBothState_002 end";
2051 }
2052 
2053 /**
2054  * @tc.number: AccessibilityScreenTouch_Unittest_HandleBothState_003
2055  * @tc.name: HandleBothState
2056  * @tc.desc: Test function HandleBothState
2057  */
HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleBothState_003, TestSize.Level1)2058 HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleBothState_003, TestSize.Level1)
2059 {
2060     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleBothState_003 start";
2061     sptr<AccessibilityAccountData> accountData =
2062         Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
2063     if (accountData == nullptr) {
2064         return;
2065     }
2066 
2067     accountData->GetConfig()->SetClickResponseTime(CLICK_RESPONSE_DELAY_MEDIUM);
2068     accountData->GetConfig()->SetIgnoreRepeatClickState(true);
2069     accountData->GetConfig()->SetIgnoreRepeatClickTime(IGNORE_REPEAT_CLICK_MEDIUM);
2070 
2071     screenTouch_ = std::make_shared<AccessibilityScreenTouch>();
2072     if (screenTouch_ == nullptr) {
2073         return;
2074     }
2075 
2076     auto eventDown = SetPointerEvent((lastUpTime_ + TIMESTAMP_1500) * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_DOWN);
2077     screenTouch_->OnPointerEvent(*eventDown);
2078 
2079     sleep(1);
2080 
2081     auto eventMove = SetPointerEvent((lastUpTime_ + TIMESTAMP_1600) * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_MOVE);
2082     screenTouch_->OnPointerEvent(*eventMove);
2083 
2084     auto eventUp = SetPointerEvent((lastUpTime_ + TIMESTAMP_1700) * US_TO_MS, MMI::PointerEvent::POINTER_ACTION_UP);
2085     screenTouch_->OnPointerEvent(*eventUp);
2086 
2087     EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionVector().size(), 3);
2088     int32_t touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0);
2089     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_DOWN);
2090     touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(1);
2091     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_MOVE);
2092     touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(2);
2093     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_UP);
2094 
2095     lastUpTime_ += TIMESTAMP_1700;
2096 
2097     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleBothState_003 end";
2098 }
2099 
2100 /**
2101  * @tc.number: AccessibilityScreenTouch_Unittest_HandleBothState_004
2102  * @tc.name: HandleBothState
2103  * @tc.desc: Test function HandleBothState
2104  */
HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleBothState_004, TestSize.Level1)2105 HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleBothState_004, TestSize.Level1)
2106 {
2107     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleBothState_004 start";
2108     sptr<AccessibilityAccountData> accountData =
2109         Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
2110     if (accountData == nullptr) {
2111         return;
2112     }
2113 
2114     accountData->GetConfig()->SetClickResponseTime(CLICK_RESPONSE_DELAY_LONG);
2115     accountData->GetConfig()->SetIgnoreRepeatClickState(true);
2116     accountData->GetConfig()->SetIgnoreRepeatClickTime(IGNORE_REPEAT_CLICK_LONGEST);
2117 
2118     screenTouch_ = std::make_shared<AccessibilityScreenTouch>();
2119     if (screenTouch_ == nullptr) {
2120         return;
2121     }
2122 
2123     std::vector<MMI::PointerEvent::PointerItem> points = {};
2124     MMI::PointerEvent::PointerItem firstPoint = {};
2125     firstPoint.SetPointerId(0);
2126     points.emplace_back(firstPoint);
2127     auto firstDownEvent = SetPointerEvent((lastUpTime_ + TIMESTAMP_1500) * US_TO_MS,
2128         MMI::PointerEvent::POINTER_ACTION_DOWN, points, 0);
2129     screenTouch_->OnPointerEvent(*firstDownEvent);
2130 
2131     auto firstMoveEvent = SetPointerEvent((lastUpTime_ + TIMESTAMP_1500) * US_TO_MS,
2132         MMI::PointerEvent::POINTER_ACTION_MOVE, points, 0);
2133     screenTouch_->OnPointerEvent(*firstMoveEvent);
2134 
2135     MMI::PointerEvent::PointerItem secondPoint = {};
2136     secondPoint.SetPointerId(1);
2137     points.emplace_back(secondPoint);
2138     auto secondDownEvent = SetPointerEvent((lastUpTime_ + TIMESTAMP_1600) * US_TO_MS,
2139         MMI::PointerEvent::POINTER_ACTION_DOWN, points, 1);
2140     screenTouch_->OnPointerEvent(*secondDownEvent);
2141 
2142     auto secondMoveEvent = SetPointerEvent((lastUpTime_ + TIMESTAMP_1600) * US_TO_MS,
2143         MMI::PointerEvent::POINTER_ACTION_MOVE, points, 1);
2144     screenTouch_->OnPointerEvent(*secondMoveEvent);
2145 
2146     sleep(1);
2147 
2148     auto secondUpEvent = SetPointerEvent((lastUpTime_ + TIMESTAMP_1700) * US_TO_MS,
2149         MMI::PointerEvent::POINTER_ACTION_UP, points, 1);
2150     screenTouch_->OnPointerEvent(*secondUpEvent);
2151 
2152     auto firstUpEvent = SetPointerEvent((lastUpTime_ + TIMESTAMP_1700) * US_TO_MS,
2153         MMI::PointerEvent::POINTER_ACTION_UP);
2154     screenTouch_->OnPointerEvent(*firstUpEvent);
2155 
2156     EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionVector().size(), 4);
2157     int32_t touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0);
2158     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_DOWN);
2159     touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(1);
2160     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_DOWN);
2161     touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(3);
2162     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_UP);
2163 
2164     lastUpTime_ += TIMESTAMP_1700;
2165 
2166     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleBothState_004 end";
2167 }
2168 
2169 /**
2170  * @tc.number: AccessibilityScreenTouch_Unittest_HandleBothState_005
2171  * @tc.name: HandleBothState
2172  * @tc.desc: Test function HandleBothState
2173  */
HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleBothState_005, TestSize.Level1)2174 HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleBothState_005, TestSize.Level1)
2175 {
2176     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleBothState_005 start";
2177     sptr<AccessibilityAccountData> accountData =
2178         Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
2179     if (accountData == nullptr) {
2180         return;
2181     }
2182 
2183     accountData->GetConfig()->SetClickResponseTime(CLICK_RESPONSE_DELAY_LONG);
2184     accountData->GetConfig()->SetIgnoreRepeatClickState(true);
2185     accountData->GetConfig()->SetIgnoreRepeatClickTime(IGNORE_REPEAT_CLICK_MEDIUM);
2186 
2187     screenTouch_ = std::make_shared<AccessibilityScreenTouch>();
2188     if (screenTouch_ == nullptr) {
2189         return;
2190     }
2191 
2192     std::vector<MMI::PointerEvent::PointerItem> points = {};
2193     MMI::PointerEvent::PointerItem firstPoint = {};
2194     firstPoint.SetPointerId(0);
2195     points.emplace_back(firstPoint);
2196     auto firstDownEvent = SetPointerEvent((lastUpTime_ + TIMESTAMP_1500) * US_TO_MS,
2197         MMI::PointerEvent::POINTER_ACTION_DOWN, points, 0);
2198     screenTouch_->OnPointerEvent(*firstDownEvent);
2199 
2200     auto firstMoveEvent = SetPointerEvent((lastUpTime_ + TIMESTAMP_1500) * US_TO_MS,
2201         MMI::PointerEvent::POINTER_ACTION_MOVE, points, 0);
2202     screenTouch_->OnPointerEvent(*firstMoveEvent);
2203 
2204     MMI::PointerEvent::PointerItem secondPoint = {};
2205     secondPoint.SetPointerId(1);
2206     points.emplace_back(secondPoint);
2207     auto secondDownEvent = SetPointerEvent((lastUpTime_ + TIMESTAMP_1600) * US_TO_MS,
2208         MMI::PointerEvent::POINTER_ACTION_DOWN, points, 1);
2209     screenTouch_->OnPointerEvent(*secondDownEvent);
2210 
2211     auto secondMoveEvent = SetPointerEvent((lastUpTime_ + TIMESTAMP_1600) * US_TO_MS,
2212         MMI::PointerEvent::POINTER_ACTION_MOVE, points, 1);
2213     screenTouch_->OnPointerEvent(*secondMoveEvent);
2214 
2215     sleep(1);
2216 
2217     auto secondUpEvent = SetPointerEvent((lastUpTime_ + TIMESTAMP_1700) * US_TO_MS,
2218         MMI::PointerEvent::POINTER_ACTION_UP, points, 1);
2219     screenTouch_->OnPointerEvent(*secondUpEvent);
2220 
2221     auto firstUpEvent = SetPointerEvent((lastUpTime_ + TIMESTAMP_1700) * US_TO_MS,
2222         MMI::PointerEvent::POINTER_ACTION_UP);
2223     screenTouch_->OnPointerEvent(*firstUpEvent);
2224 
2225     EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionVector().size(), 4);
2226     int32_t touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0);
2227     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_DOWN);
2228     touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(1);
2229     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_DOWN);
2230     touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(3);
2231     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_UP);
2232 
2233     lastUpTime_ += TIMESTAMP_1700;
2234 
2235     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleBothState_005 end";
2236 }
2237 
2238 /**
2239  * @tc.number: AccessibilityScreenTouch_Unittest_HandleBothState_006
2240  * @tc.name: HandleBothState
2241  * @tc.desc: Test function HandleBothState
2242  */
HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleBothState_006, TestSize.Level1)2243 HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_HandleBothState_006, TestSize.Level1)
2244 {
2245     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleBothState_006 start";
2246     sptr<AccessibilityAccountData> accountData =
2247         Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
2248     if (accountData == nullptr) {
2249         return;
2250     }
2251 
2252     accountData->GetConfig()->SetClickResponseTime(CLICK_RESPONSE_DELAY_MEDIUM);
2253     accountData->GetConfig()->SetIgnoreRepeatClickState(true);
2254     accountData->GetConfig()->SetIgnoreRepeatClickTime(IGNORE_REPEAT_CLICK_MEDIUM);
2255 
2256     screenTouch_ = std::make_shared<AccessibilityScreenTouch>();
2257     if (screenTouch_ == nullptr) {
2258         return;
2259     }
2260 
2261     std::vector<MMI::PointerEvent::PointerItem> points = {};
2262     MMI::PointerEvent::PointerItem firstPoint = {};
2263     firstPoint.SetPointerId(0);
2264     points.emplace_back(firstPoint);
2265     auto firstDownEvent = SetPointerEvent((lastUpTime_ + TIMESTAMP_1500) * US_TO_MS,
2266         MMI::PointerEvent::POINTER_ACTION_DOWN, points, 0);
2267     screenTouch_->OnPointerEvent(*firstDownEvent);
2268 
2269     auto firstMoveEvent = SetPointerEvent((lastUpTime_ + TIMESTAMP_1500) * US_TO_MS,
2270         MMI::PointerEvent::POINTER_ACTION_MOVE, points, 0);
2271     screenTouch_->OnPointerEvent(*firstMoveEvent);
2272 
2273     MMI::PointerEvent::PointerItem secondPoint = {};
2274     secondPoint.SetPointerId(1);
2275     points.emplace_back(secondPoint);
2276     auto secondDownEvent = SetPointerEvent((lastUpTime_ + TIMESTAMP_1600) * US_TO_MS,
2277         MMI::PointerEvent::POINTER_ACTION_DOWN, points, 1);
2278     screenTouch_->OnPointerEvent(*secondDownEvent);
2279 
2280     auto secondMoveEvent = SetPointerEvent((lastUpTime_ + TIMESTAMP_1600) * US_TO_MS,
2281         MMI::PointerEvent::POINTER_ACTION_MOVE, points, 1);
2282     screenTouch_->OnPointerEvent(*secondMoveEvent);
2283 
2284     sleep(1);
2285 
2286     auto secondUpEvent = SetPointerEvent((lastUpTime_ + TIMESTAMP_1700) * US_TO_MS,
2287         MMI::PointerEvent::POINTER_ACTION_UP, points, 1);
2288     screenTouch_->OnPointerEvent(*secondUpEvent);
2289 
2290     auto firstUpEvent = SetPointerEvent((lastUpTime_ + TIMESTAMP_1700) * US_TO_MS,
2291         MMI::PointerEvent::POINTER_ACTION_UP);
2292     screenTouch_->OnPointerEvent(*firstUpEvent);
2293 
2294     EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionVector().size(), 4);
2295     int32_t touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0);
2296     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_DOWN);
2297     touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(1);
2298     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_DOWN);
2299     touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(3);
2300     EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_UP);
2301 
2302     lastUpTime_ += TIMESTAMP_1700;
2303 
2304     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_HandleBothState_006 end";
2305 }
2306 
2307 /**
2308  * @tc.number: AccessibilityScreenTouch_Unittest_GetRealClickResponseTime_001
2309  * @tc.name: GetRealClickResponseTime
2310  * @tc.desc: Test function GetRealClickResponseTime
2311  */
HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_GetRealClickResponseTime_001, TestSize.Level1)2312 HWTEST_F(AccessibilityScreenTouchUnitTest,
2313     AccessibilityScreenTouch_Unittest_GetRealClickResponseTime_001, TestSize.Level1)
2314 {
2315     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_GetRealClickResponseTime_001 start";
2316     sptr<AccessibilityAccountData> accountData =
2317         Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
2318     if (!accountData) {
2319         GTEST_LOG_(INFO) << "accountData is nullptr";
2320         return;
2321     }
2322 
2323     accountData->GetConfig()->SetClickResponseTime(900);
2324     screenTouch_ = std::make_shared<AccessibilityScreenTouch>();
2325 
2326     EXPECT_EQ(screenTouch_->GetRealClickResponseTime(), 0);
2327     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_GetRealClickResponseTime_001 end";
2328 }
2329 
2330 /**
2331  * @tc.number: AccessibilityScreenTouch_Unittest_GetRealIgnoreRepeatClickTime_001
2332  * @tc.name: GetRealIgnoreRepeatClickTime
2333  * @tc.desc: Test function OnPointerEvent
2334  */
HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_GetRealIgnoreRepeatClickTime_001, TestSize.Level1)2335 HWTEST_F(AccessibilityScreenTouchUnitTest,
2336     AccessibilityScreenTouch_Unittest_GetRealIgnoreRepeatClickTime_001, TestSize.Level1)
2337 {
2338     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_GetRealIgnoreRepeatClickTime_001 start";
2339     sptr<AccessibilityAccountData> accountData =
2340         Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData();
2341     if (!accountData) {
2342         GTEST_LOG_(INFO) << "accountData is nullptr";
2343         return;
2344     }
2345 
2346     accountData->GetConfig()->SetIgnoreRepeatClickTime(2000);
2347     screenTouch_ = std::make_shared<AccessibilityScreenTouch>();
2348 
2349     EXPECT_EQ(screenTouch_->GetRealIgnoreRepeatClickTime(), IGNORE_REPEAT_CLICK_TIME_SHORTEST);
2350     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_GetRealIgnoreRepeatClickTime end";
2351 }
2352 
2353 /**
2354  * @tc.number: AccessibilityScreenTouch_Unittest_SendInterceptedEvent_001
2355  * @tc.name: SendInterceptedEvent
2356  * @tc.desc: Test function SendInterceptedEvent
2357  */
HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_SendInterceptedEvent_001, TestSize.Level1)2358 HWTEST_F(AccessibilityScreenTouchUnitTest, AccessibilityScreenTouch_Unittest_SendInterceptedEvent_001, TestSize.Level1)
2359 {
2360     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_SendInterceptedEvent_001 start";
2361     screenTouch_ = std::make_shared<AccessibilityScreenTouch>();
2362     screenTouch_->SendInterceptedEvent();
2363     GTEST_LOG_(INFO) << "AccessibilityScreenTouch_Unittest_SendInterceptedEvent_001 end";
2364 }
2365 } // namespace Accessibility
2366 } // namespace OHOS