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