From 9597bb48d0a29847fa823e07de33c1202d1a02fa Mon Sep 17 00:00:00 2001 From: r00447448 Date: Fri, 20 Oct 2023 15:36:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=89=E6=8C=87/=E5=9B=9B=E6=8C=87=E6=89=8B?= =?UTF-8?q?=E5=8A=BF=E8=AF=86=E5=88=AB=20Signed-off-by:=20ranzhiqiang=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../accessibility_gesture_recognizer.h | 21 +- .../accessibility_multifinger_multitap.h | 230 +++++- .../aams/include/accessibility_touch_guider.h | 11 +- .../accessibility_multifinger_multitap.cpp | 633 ++++++++++++--- .../aams/src/accessibility_touch_guider.cpp | 17 +- .../aams_accessibility_touch_guider_test.cpp | 764 +++++++++++++++++- 6 files changed, 1500 insertions(+), 176 deletions(-) diff --git a/services/aams/include/accessibility_gesture_recognizer.h b/services/aams/include/accessibility_gesture_recognizer.h index 7f3d9eb4..379136dc 100644 --- a/services/aams/include/accessibility_gesture_recognizer.h +++ b/services/aams/include/accessibility_gesture_recognizer.h @@ -83,35 +83,36 @@ public: virtual bool OnStarted(); /** - * @brief The callback function when recognized an event stream as a two finger gesture. + * @brief The callback function when recognized an event stream as a multi finger gesture. + * @param isTwoFingerGesture whether the gesture is triggered by two finger. */ - virtual void TwoFingerGestureOnStarted(); + virtual void MultiFingerGestureOnStarted(bool isTwoFingerGesture); /** * @brief The callback function when decided the event stream is a gesture. - * @param gestureId the recognized gesture ID. + * @param gestureId the recognized gesture ID. * @return true if the event is consumed, else false */ virtual bool OnCompleted(GestureType gestureId); /** - * @brief The callback function when decided the event stream is a two finger gesture. - * @param gestureId the recognized gesture ID. + * @brief The callback function when decided the event stream is a multi finger gesture. + * @param gestureId the recognized gesture ID. */ - virtual void TwoFingerGestureOnCompleted(GestureType gestureId); + virtual void MultiFingerGestureOnCompleted(GestureType gestureId); /** * @brief The callback function when decided an event stream doesn't match any known gesture. - * @param event the touch event received. + * @param event the touch event received. * @return true if the event is consumed, else false */ virtual bool OnCancelled(MMI::PointerEvent &event); /** - * @brief The callback function when decided an event stream doesn't match any known two finger gesture. - * @param isNoDelayFlag whether the gesture recognize process is immediately canceled. + * @brief The callback function when decided an event stream doesn't match any known multi finger gesture. + * @param isNoDelayFlag whether the gesture recognize process is immediately canceled. */ - virtual void TwoFingerGestureOnCancelled(const bool isNoDelayFlag); + virtual void MultiFingerGestureOnCancelled(const bool isNoDelayFlag); }; class AccessibilityGestureRecognizer : public AppExecFwk::EventHandler { diff --git a/services/aams/include/accessibility_multifinger_multitap.h b/services/aams/include/accessibility_multifinger_multitap.h index 0b4aeb89..b3b21457 100644 --- a/services/aams/include/accessibility_multifinger_multitap.h +++ b/services/aams/include/accessibility_multifinger_multitap.h @@ -23,6 +23,7 @@ #include "accessibility_display_manager.h" #include "accessibility_event_info.h" #include "accessible_ability_manager_service.h" +#include "accessibility_def.h" #include "event_handler.h" #include "event_runner.h" #include "pointer_event.h" @@ -30,6 +31,17 @@ namespace OHOS { namespace Accessibility { +namespace { + constexpr uint32_t MAX_TAP_NUM = 3; + constexpr uint32_t MAX_MULTI_FINGER_TYPE = 3; +} // namespace + +enum MoveGirectionType : int32_t { + SWIPE_LEFT = 0, + SWIPE_RIGHT = 1, + SWIPE_UP = 2, + SWIPE_DOWN = 3 +}; enum FingerTouchUpState : int32_t { NOT_ALL_FINGER_TOUCH_UP = 0, @@ -58,10 +70,25 @@ public: virtual void ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event) override; private: /** - * @brief Process the two finger gesture event. + * @brief Process the multi finger gesture by Gesture type. + * @param gestureType Indicates the gesture type to be processed. + */ + void ProcessMultiFingerGestureTypeEvent(const GestureType gestureType); + + /** + * @brief Process the multi finger gesture event. * @param event Indicates the event to be processed. + * @return true if the gesture event is processed success, else false. + */ + bool ProcessMultiFingerGestureEvent(const AppExecFwk::InnerEvent::Pointer &event); + + /** + * @brief check whether the gesture is a tap gesture. + * @param gestureType Indicates the gesture to be processed. + * @return true if the gesture is a tap gesture, else false. */ - bool ProcessTwoFingerGestureEvent(const AppExecFwk::InnerEvent::Pointer &event); + bool IsTapGesture(const GestureType gestureType); + AccessibilityMultiTapGestureRecognizer &server_; }; @@ -71,12 +98,60 @@ public: static constexpr uint32_t TWO_FINGER_LONG_PRESS_MSG = 4; static constexpr uint32_t TWO_FINGER_DOUBLE_TAP_MSG = 5; static constexpr uint32_t TWO_FINGER_DOUBLE_TAP_AND_HOLD_MSG = 6; - static constexpr uint32_t TWO_FINGER_TRIPLE_TAP_AND_HOLD_MSG = 7; - static constexpr uint32_t TWO_FINGER_TRIPLE_TAP_MSG = 8; - static constexpr uint32_t WAIT_ANOTHER_FINGER_DOWN_MSG = 9; - static constexpr uint32_t CANCEL_WAIT_FINGER_DOWN_MSG = 10; - static constexpr uint32_t CANCEL_GESTURE = 11; - static constexpr uint32_t COMPLETE_GESTURE = 12; + static constexpr uint32_t TWO_FINGER_TRIPLE_TAP_MSG = 7; + static constexpr uint32_t TWO_FINGER_TRIPLE_TAP_AND_HOLD_MSG = 8; + static constexpr uint32_t THREE_FINGER_SINGLE_TAP_MSG = 9; + static constexpr uint32_t THREE_FINGER_LONG_PRESS_MSG = 10; + static constexpr uint32_t THREE_FINGER_DOUBLE_TAP_MSG = 11; + static constexpr uint32_t THREE_FINGER_DOUBLE_TAP_AND_HOLD_MSG = 12; + static constexpr uint32_t THREE_FINGER_TRIPLE_TAP_MSG = 13; + static constexpr uint32_t THREE_FINGER_TRIPLE_TAP_AND_HOLD_MSG = 14; + static constexpr uint32_t FOUR_FINGER_SINGLE_TAP_MSG = 15; + static constexpr uint32_t FOUR_FINGER_LONG_PRESS_MSG = 16; + static constexpr uint32_t FOUR_FINGER_DOUBLE_TAP_MSG = 17; + static constexpr uint32_t FOUR_FINGER_DOUBLE_TAP_AND_HOLD_MSG = 18; + static constexpr uint32_t FOUR_FINGER_TRIPLE_TAP_MSG = 19; + static constexpr uint32_t FOUR_FINGER_TRIPLE_TAP_AND_HOLD_MSG = 20; + static constexpr uint32_t WAIT_ANOTHER_FINGER_DOWN_MSG = 21; + static constexpr uint32_t CANCEL_WAIT_FINGER_DOWN_MSG = 22; + static constexpr uint32_t CANCEL_GESTURE = 23; + static constexpr uint32_t COMPLETE_GESTURE = 24; + + static constexpr uint32_t GESTURE_TAP_MSG[MAX_TAP_NUM][MAX_MULTI_FINGER_TYPE] = { + { + TWO_FINGER_SINGLE_TAP_MSG, + THREE_FINGER_SINGLE_TAP_MSG, + FOUR_FINGER_SINGLE_TAP_MSG, + }, + { + TWO_FINGER_DOUBLE_TAP_MSG, + THREE_FINGER_DOUBLE_TAP_MSG, + FOUR_FINGER_DOUBLE_TAP_MSG, + }, + { + TWO_FINGER_TRIPLE_TAP_MSG, + THREE_FINGER_TRIPLE_TAP_MSG, + FOUR_FINGER_TRIPLE_TAP_MSG, + } + }; + + static constexpr uint32_t GESTURE_HOLD_MSG[MAX_TAP_NUM][MAX_MULTI_FINGER_TYPE] = { + { + TWO_FINGER_LONG_PRESS_MSG, + THREE_FINGER_LONG_PRESS_MSG, + FOUR_FINGER_LONG_PRESS_MSG, + }, + { + TWO_FINGER_DOUBLE_TAP_AND_HOLD_MSG, + THREE_FINGER_DOUBLE_TAP_AND_HOLD_MSG, + FOUR_FINGER_DOUBLE_TAP_AND_HOLD_MSG, + }, + { + TWO_FINGER_TRIPLE_TAP_AND_HOLD_MSG, + THREE_FINGER_TRIPLE_TAP_AND_HOLD_MSG, + FOUR_FINGER_TRIPLE_TAP_AND_HOLD_MSG, + } + }; AccessibilityMultiTapGestureRecognizer(); ~AccessibilityMultiTapGestureRecognizer() = default; @@ -178,6 +253,27 @@ private: */ void CancelTwoFingerEvent(); + /** + * @brief Cancle the pendding three finger gesture recognize event. + */ + void CancelThreeFingerEvent(); + + /** + * @brief Cancle the pendding four finger gesture recognize event. + */ + void CancelFourFingerEvent(); + + /** + * @brief Cancle the pendding finger gesture recognize event by finger num. + * @param fingerNum which type gesture pendding event to be canceled. + */ + void CancelTapAndHoldGestureEvent(const int32_t fingerNum); + + /** + * @brief Cancle the pendding multi finger hold gesture recognize event. + */ + void CancelHoldGestureEvent(); + /** * @brief Cancle All pendding inner event. */ @@ -191,16 +287,107 @@ private: /** * @brief param check for two finger Double tap recognize gesture. + * @param fingerNum the touch event from Multimodal. * @return true if the used param is ok, else false. */ - bool ParamCheck(); + bool ParamCheck(const int32_t fingerNum); + + /** + * @brief Get the last touch up time of the first finger. + * @param fingerNum total touch down finger nums, means the lastUpPoint_ size. + * @return the first finger's last touch up time. + */ + int64_t GetLastFirstPointUpTime(const int32_t fingerNum); + + /** + * @brief Get the current and pre PointerItems with fingerNum, store in curPoints and prePoints. + * @param curPoints to store the cur touch event pointerItems rst, size is fingerNum. + * @param prePoints to store the pre touch event pointerItems rst, size is fingerNum. + * @param event current touch event, to get the curPoints. + * @param prePointsEventInfo pre touch Event storage, to get the prePoints. + * @return true if the get rst is ok, else false. + */ + bool GetPointerItemWithFingerNum(int32_t fingerNum, std::vector &curPoints, + std::vector &prePoints, MMI::PointerEvent &event, + std::map> &prePointsEventInfo); + + /** + * @brief check whether the two taps offset is less than slop threshold. + * @param fingerNum touch down finger nums to be processed. + * @param curPoints current touch down pointer infos, size is fingerNum. + * @param prePoints first round touch down pointer infos, size is fingfingerNumerNums. + * @return true if the offset of two taps is less than slop threshold, else false. + */ + bool IsDoubelTapSlopConditionMatch(const int32_t fingerNum, + const std::vector &curPoints, + const std::vector &prePoints); /** - * @brief Determine whether it is a two finger double tap gesture. + * @brief Determine whether it is a multi finger double tap gesture. * @param event the touch event from Multimodal. - * @return true if the gesture is two finger double tap, else false. + * @param fingerNum the target fingerNum to be processed. + * @return true if the gesture is multi finger double tap, else false. + */ + bool IsMultiFingerDoubleTap(MMI::PointerEvent &event, const int32_t fingerNum); + + /** + * @brief save touch down point event info. + */ + void storeBaseDownPoint(); + + /** + * @brief Get move direction by move distance. + * @param dx the x axis distance between base point and current point. + * @param dy the y axis distance between base point and current point. + * @return the move direction, value range is MoveGirectionType. + */ + int32_t GetSwipeDirection(const int32_t dx, const int32_t dy); + + /** + * @brief Get the base point Item info by point Id. + * @param basePointerIterm to save th base pointItem info. + * @param pId the point Id to get the pointItem. + * @param pointInfo the touch down event point info storage. + * @return true if get base pointItem success, else false. + */ + bool GetBasePointItem(MMI::PointerEvent::PointerItem &basePointerIterm, + int32_t pId, std::map> &pointInfo); + + /** + * @brief Save move gesture path info. + * @param event the touch event to be handled. + * @param pId the point Id to be handled. + * @param pointerIterm the point Item info to be saved. + * @param dx the x axis distance between base point and current point. + * @param dy the y axis distance between base point and current point. */ - bool IsTwoFingerDoubleTap(MMI::PointerEvent &event); + void SaveMoveGesturePointerInfo(MMI::PointerEvent &event, + const int32_t pId, const MMI::PointerEvent::PointerItem &pointerIterm, const int32_t dx, const int32_t dy); + + /** + * @brief recognize the move path is correct and match a move gesture. + * @param path move path pointer info storage. + * @return true if the move path is correct and match a move gesture, else false. + */ + bool recognizeGesturePath(const std::vector &path); + + /** + * @brief Get the matched move gesture by moveDirection and fingerNum. + * @return the matched gesture Id. + */ + GestureType GetMoveGestureId(); + + /** + * @brief whether the multi finger move event match a move gesture. + * @return true if multi finger move event match a move gesture, else false. + */ + bool IsMoveGestureRecognize(); + + /** + * @brief Save move gesture path info when finger up. + * @param event the touch event to be handled. + */ + void StoreUpPointInPointerRoute(MMI::PointerEvent &event); /** * @brief Handle the first touch down event. @@ -215,10 +402,10 @@ private: void HandleContinueTouchDownEvent(MMI::PointerEvent &event); /** - * @brief Handle the two finger touch move event. + * @brief Handle the multi finger touch move event. * @param event the touch event to be handled. */ - void HandleTwoFingerMoveEvent(MMI::PointerEvent &event); + void HandleMultiFingerMoveEvent(MMI::PointerEvent &event); /** * @brief Handle the touch up event, not a move gesture. @@ -226,17 +413,30 @@ private: */ void HandleMultiFingerTouchUpEvent(MMI::PointerEvent &event); + /** + * @brief Handle the continue touch down event, decide whether it is a multi tap event. + * @param event the touch event to be handled. + * @param fingerNum the touch down fingerNum to be handled. + */ + void HandleMultiTapEvent(MMI::PointerEvent &event, const int32_t fingerNum); + float touchSlop_ = 0.0f; int32_t doubleTapOffsetThresh_ = 0; int32_t targetFingers_ = -1; // touch down finger numbers before first time the finger touch up - int32_t addContinueTapNum_ = 0; // total number of touch down, except the first touch down + uint32_t addContinueTapNum_ = 0; // total number of touch down, except the first touch down int32_t multiFingerGestureState_ = 0; // recognize state, value is MultiFingerGestureState int32_t fingerTouchUpState_ = FingerTouchUpState::ALL_FINGER_TOUCH_UP; bool isFirstUp_ = 0; // whether the first time finger touch up + bool isMoveGestureRecognizing = false; // in move gesture recognize process or not + int32_t moveDirection = -1; + float mMinPixelsBetweenSamplesX_ = 0; + float mMinPixelsBetweenSamplesY_ = 0; std::map> firstDownPoint_; // first round touch down points std::map> currentDownPoint_; // current round touch down points + std::map> preGesturePoint_; // pre move event points std::map> lastUpPoint_; // last time finger touch up points + std::map> pointerRoute_; AccessibilityGestureRecognizeListener *listener_ = nullptr; std::shared_ptr handler_ = nullptr; // multi finger gesture recognize event handler diff --git a/services/aams/include/accessibility_touch_guider.h b/services/aams/include/accessibility_touch_guider.h index 5681cc4c..bf0ce00e 100644 --- a/services/aams/include/accessibility_touch_guider.h +++ b/services/aams/include/accessibility_touch_guider.h @@ -237,9 +237,10 @@ private: bool OnStarted() override; /** - * @brief Send GESTURE_BEGIN to AccessibleAbility when two finger gesture start. + * @brief Send GESTURE_BEGIN to AccessibleAbility when multi finger gesture start. + * @param isTwoFingerGesture whether the gesture is triggered by two finger. */ - void TwoFingerGestureOnStarted() override; + void MultiFingerGestureOnStarted(bool isTwoFingerGesture) override; /** * @brief Send GESTURE_END and TOUCH_END to AccessibleAbility. @@ -248,10 +249,10 @@ private: bool OnCompleted(GestureType gestureId) override; /** - * @brief Send GESTURE_END and TOUCH_END to AccessibleAbility when two finger gesture complete. + * @brief Send GESTURE_END and TOUCH_END to AccessibleAbility when multi finger gesture complete. * @param gestureId the id of gesture. */ - void TwoFingerGestureOnCompleted(GestureType gestureId) override; + void MultiFingerGestureOnCompleted(GestureType gestureId) override; /** * @brief The gesture has been cancelled. @@ -263,7 +264,7 @@ private: * @brief The gesture has been cancelled. * @param isNoDelayFlag whether the gesture recognize process is immediately canceled. */ - void TwoFingerGestureOnCancelled(const bool isNoDelayFlag) override; + void MultiFingerGestureOnCancelled(const bool isNoDelayFlag) override; private: TouchGuider &server_; }; diff --git a/services/aams/src/accessibility_multifinger_multitap.cpp b/services/aams/src/accessibility_multifinger_multitap.cpp index acf6aab1..137d9605 100644 --- a/services/aams/src/accessibility_multifinger_multitap.cpp +++ b/services/aams/src/accessibility_multifinger_multitap.cpp @@ -13,6 +13,7 @@ * limitations under the License. */ +#include #include "accessibility_multifinger_multitap.h" #include "hilog_wrapper.h" @@ -22,9 +23,11 @@ namespace { constexpr float SLOP_DELTA = 0.5f; constexpr int32_t POINTER_COUNT_1 = 1; constexpr int32_t POINTER_COUNT_2 = 2; - constexpr int32_t POINTER_COTINUE_TAP_ONE_TIME = 1; + constexpr int32_t POINTER_COUNT_3 = 3; + constexpr int32_t POINTER_COUNT_4 = 4; constexpr int32_t MULTI_FINGER_MAX_CONTINUE_TAP_NUM = 3; constexpr float TOUCH_SLOP = 8.0f; + constexpr uint32_t MIN_MOVE_POINTER_NUM = 2; } // namespace MultiFingerGestureHandler::MultiFingerGestureHandler(const std::shared_ptr &runner, @@ -32,55 +35,90 @@ MultiFingerGestureHandler::MultiFingerGestureHandler(const std::shared_ptr(event->GetInnerEventId())); + if (gestureType == GestureType::GESTURE_TWO_FINGER_DOUBLE_TAP_AND_HOLD || + gestureType == GestureType::GESTURE_THREE_FINGER_DOUBLE_TAP_AND_HOLD || + gestureType == GestureType::GESTURE_FOUR_FINGER_DOUBLE_TAP_AND_HOLD || + gestureType == GestureType::GESTURE_TWO_FINGER_TRIPLE_TAP_AND_HOLD || + gestureType == GestureType::GESTURE_THREE_FINGER_TRIPLE_TAP_AND_HOLD || + gestureType == GestureType::GESTURE_FOUR_FINGER_TRIPLE_TAP_AND_HOLD || + gestureType == GestureType::GESTURE_INVALID) { + return false; + } - uint32_t eventId = static_cast(event->GetInnerEventId()); - if (eventId == AccessibilityMultiTapGestureRecognizer::TWO_FINGER_SINGLE_TAP_MSG) { - if (server_.GetFingerTouchUpState() == FingerTouchUpState::ALL_FINGER_TOUCH_UP) { - server_.GetRecognizeListener()->TwoFingerGestureOnCompleted( - GestureType::GESTURE_TWO_FINGER_SINGLE_TAP); - server_.SetMultiFingerGestureState(MultiFingerGestureState::GESTURE_COMPLETE); - server_.Clear(); - } - } else if (eventId == AccessibilityMultiTapGestureRecognizer::TWO_FINGER_LONG_PRESS_MSG) { - if (server_.GetFingerTouchUpState() != FingerTouchUpState::NOT_ALL_FINGER_TOUCH_UP) { - server_.SetMultiFingerGestureState(MultiFingerGestureState::GESTURE_COMPLETE); - } - server_.Clear(); - } else if (eventId == AccessibilityMultiTapGestureRecognizer::TWO_FINGER_DOUBLE_TAP_MSG) { - if (server_.GetFingerTouchUpState() == FingerTouchUpState::ALL_FINGER_TOUCH_UP) { - server_.GetRecognizeListener()->TwoFingerGestureOnCompleted( - GestureType::GESTURE_TWO_FINGER_DOUBLE_TAP); - server_.SetMultiFingerGestureState(MultiFingerGestureState::GESTURE_COMPLETE); - server_.Clear(); - } - } else if (eventId == AccessibilityMultiTapGestureRecognizer::TWO_FINGER_DOUBLE_TAP_AND_HOLD_MSG) { - if (server_.GetFingerTouchUpState() != FingerTouchUpState::NOT_ALL_FINGER_TOUCH_UP) { - server_.GetRecognizeListener()->TwoFingerGestureOnCompleted( - GestureType::GESTURE_TWO_FINGER_DOUBLE_TAP_AND_HOLD); - server_.SetMultiFingerGestureState(MultiFingerGestureState::GESTURE_COMPLETE); - } - server_.Clear(); - } else if (eventId == AccessibilityMultiTapGestureRecognizer::TWO_FINGER_TRIPLE_TAP_MSG) { + return true; +} + +void MultiFingerGestureHandler::ProcessMultiFingerGestureTypeEvent(const GestureType gestureType) +{ + HILOG_DEBUG("gesture id: %d", static_cast(gestureType)); + + if (IsTapGesture(gestureType)) { if (server_.GetFingerTouchUpState() == FingerTouchUpState::ALL_FINGER_TOUCH_UP) { - server_.GetRecognizeListener()->TwoFingerGestureOnCompleted( - GestureType::GESTURE_TWO_FINGER_TRIPLE_TAP); + server_.GetRecognizeListener()->MultiFingerGestureOnCompleted(gestureType); server_.SetMultiFingerGestureState(MultiFingerGestureState::GESTURE_COMPLETE); server_.Clear(); } - } else if (eventId == AccessibilityMultiTapGestureRecognizer::TWO_FINGER_TRIPLE_TAP_AND_HOLD_MSG) { + } else { if (server_.GetFingerTouchUpState() != FingerTouchUpState::NOT_ALL_FINGER_TOUCH_UP) { - server_.GetRecognizeListener()->TwoFingerGestureOnCompleted( - GestureType::GESTURE_TWO_FINGER_TRIPLE_TAP_AND_HOLD); + if (gestureType != GestureType::GESTURE_INVALID) { + server_.GetRecognizeListener()->MultiFingerGestureOnCompleted(gestureType); + } server_.SetMultiFingerGestureState(MultiFingerGestureState::GESTURE_COMPLETE); } server_.Clear(); - } else { + } +} + +bool MultiFingerGestureHandler::ProcessMultiFingerGestureEvent(const AppExecFwk::InnerEvent::Pointer &event) +{ + HILOG_DEBUG("Inner Event Id id: %u", static_cast(event->GetInnerEventId())); + + static std::map MULTI_GESTURE_TYPE = { + {AccessibilityMultiTapGestureRecognizer::TWO_FINGER_SINGLE_TAP_MSG, + GestureType::GESTURE_TWO_FINGER_SINGLE_TAP}, + {AccessibilityMultiTapGestureRecognizer::TWO_FINGER_LONG_PRESS_MSG, GestureType::GESTURE_INVALID}, + {AccessibilityMultiTapGestureRecognizer::TWO_FINGER_DOUBLE_TAP_MSG, + GestureType::GESTURE_TWO_FINGER_DOUBLE_TAP}, + {AccessibilityMultiTapGestureRecognizer::TWO_FINGER_DOUBLE_TAP_AND_HOLD_MSG, + GestureType::GESTURE_TWO_FINGER_DOUBLE_TAP_AND_HOLD}, + {AccessibilityMultiTapGestureRecognizer::TWO_FINGER_TRIPLE_TAP_MSG, + GestureType::GESTURE_TWO_FINGER_TRIPLE_TAP}, + {AccessibilityMultiTapGestureRecognizer::TWO_FINGER_TRIPLE_TAP_AND_HOLD_MSG, + GestureType::GESTURE_TWO_FINGER_TRIPLE_TAP_AND_HOLD}, + {AccessibilityMultiTapGestureRecognizer::THREE_FINGER_SINGLE_TAP_MSG, + GestureType::GESTURE_THREE_FINGER_SINGLE_TAP}, + {AccessibilityMultiTapGestureRecognizer::THREE_FINGER_LONG_PRESS_MSG, GestureType::GESTURE_INVALID}, + {AccessibilityMultiTapGestureRecognizer::THREE_FINGER_DOUBLE_TAP_MSG, + GestureType::GESTURE_THREE_FINGER_DOUBLE_TAP}, + {AccessibilityMultiTapGestureRecognizer::THREE_FINGER_DOUBLE_TAP_AND_HOLD_MSG, + GestureType::GESTURE_THREE_FINGER_DOUBLE_TAP_AND_HOLD}, + {AccessibilityMultiTapGestureRecognizer::THREE_FINGER_TRIPLE_TAP_MSG, + GestureType::GESTURE_THREE_FINGER_TRIPLE_TAP}, + {AccessibilityMultiTapGestureRecognizer::THREE_FINGER_TRIPLE_TAP_AND_HOLD_MSG, + GestureType::GESTURE_THREE_FINGER_TRIPLE_TAP_AND_HOLD}, + {AccessibilityMultiTapGestureRecognizer::FOUR_FINGER_SINGLE_TAP_MSG, + GestureType::GESTURE_FOUR_FINGER_SINGLE_TAP}, + {AccessibilityMultiTapGestureRecognizer::FOUR_FINGER_LONG_PRESS_MSG, GestureType::GESTURE_INVALID}, + {AccessibilityMultiTapGestureRecognizer::FOUR_FINGER_DOUBLE_TAP_MSG, + GestureType::GESTURE_FOUR_FINGER_DOUBLE_TAP}, + {AccessibilityMultiTapGestureRecognizer::FOUR_FINGER_DOUBLE_TAP_AND_HOLD_MSG, + GestureType::GESTURE_FOUR_FINGER_DOUBLE_TAP_AND_HOLD}, + {AccessibilityMultiTapGestureRecognizer::FOUR_FINGER_TRIPLE_TAP_MSG, + GestureType::GESTURE_FOUR_FINGER_TRIPLE_TAP}, + {AccessibilityMultiTapGestureRecognizer::FOUR_FINGER_TRIPLE_TAP_AND_HOLD_MSG, + GestureType::GESTURE_FOUR_FINGER_TRIPLE_TAP_AND_HOLD} + }; + + uint32_t eventId = static_cast(event->GetInnerEventId()); + if (MULTI_GESTURE_TYPE.find(eventId) == MULTI_GESTURE_TYPE.end()) { return false; } + GestureType gestureType = MULTI_GESTURE_TYPE.at(eventId); + ProcessMultiFingerGestureTypeEvent(gestureType); + return true; } @@ -93,7 +131,7 @@ void MultiFingerGestureHandler::ProcessEvent(const AppExecFwk::InnerEvent::Point return; } - if (ProcessTwoFingerGestureEvent(event)) { + if (ProcessMultiFingerGestureEvent(event)) { return; } @@ -108,7 +146,7 @@ void MultiFingerGestureHandler::ProcessEvent(const AppExecFwk::InnerEvent::Point if (server_.GetFingerTouchUpState() != FingerTouchUpState::ALL_FINGER_TOUCH_UP) { server_.SetFingerTouchUpState(FingerTouchUpState::NOT_ALL_FINGER_TOUCH_UP); } - server_.GetRecognizeListener()->TwoFingerGestureOnCancelled(true); + server_.GetRecognizeListener()->MultiFingerGestureOnCancelled(true); server_.SetMultiFingerGestureState(MultiFingerGestureState::GESTURE_CANCLE); server_.Clear(); break; @@ -130,8 +168,10 @@ AccessibilityMultiTapGestureRecognizer::AccessibilityMultiTapGestureRecognizer() float density = display->GetVirtualPixelRatio(); int32_t slop = static_cast(density * DOUBLE_TAP_SLOP + SLOP_DELTA); - doubleTapOffsetThresh_ = slop * slop; + doubleTapOffsetThresh_ = slop; touchSlop_ = TOUCH_SLOP; + mMinPixelsBetweenSamplesX_ = MIN_PIXELS(display->GetWidth()); + mMinPixelsBetweenSamplesY_ = MIN_PIXELS(display->GetHeight()); runner_ = Singleton::GetInstance().GetMainRunner(); if (!runner_) { @@ -170,6 +210,79 @@ void AccessibilityMultiTapGestureRecognizer::CancelTwoFingerEvent() handler_->RemoveEvent(TWO_FINGER_TRIPLE_TAP_AND_HOLD_MSG); } +void AccessibilityMultiTapGestureRecognizer::CancelThreeFingerEvent() +{ + HILOG_DEBUG(); + + if (!handler_) { + HILOG_ERROR("handler_ is null ptr"); + return; + } + + handler_->RemoveEvent(THREE_FINGER_SINGLE_TAP_MSG); + handler_->RemoveEvent(THREE_FINGER_LONG_PRESS_MSG); + handler_->RemoveEvent(THREE_FINGER_DOUBLE_TAP_MSG); + handler_->RemoveEvent(THREE_FINGER_DOUBLE_TAP_AND_HOLD_MSG); + handler_->RemoveEvent(THREE_FINGER_TRIPLE_TAP_MSG); + handler_->RemoveEvent(THREE_FINGER_TRIPLE_TAP_AND_HOLD_MSG); +} + +void AccessibilityMultiTapGestureRecognizer::CancelFourFingerEvent() +{ + HILOG_DEBUG(); + + if (!handler_) { + HILOG_ERROR("handler_ is null ptr"); + return; + } + + handler_->RemoveEvent(FOUR_FINGER_SINGLE_TAP_MSG); + handler_->RemoveEvent(TWO_FINGER_LONG_PRESS_MSG); + handler_->RemoveEvent(TWO_FINGER_DOUBLE_TAP_MSG); + handler_->RemoveEvent(TWO_FINGER_DOUBLE_TAP_AND_HOLD_MSG); + handler_->RemoveEvent(TWO_FINGER_TRIPLE_TAP_MSG); + handler_->RemoveEvent(TWO_FINGER_TRIPLE_TAP_AND_HOLD_MSG); +} + +void AccessibilityMultiTapGestureRecognizer::CancelTapAndHoldGestureEvent(const int32_t fingerNum) +{ + HILOG_DEBUG(); + + switch (fingerNum) { + case POINTER_COUNT_2: + CancelTwoFingerEvent(); + break; + case POINTER_COUNT_3: + CancelThreeFingerEvent(); + break; + case POINTER_COUNT_4: + CancelFourFingerEvent(); + break; + default: + break; + } +} + +void AccessibilityMultiTapGestureRecognizer::CancelHoldGestureEvent() +{ + HILOG_DEBUG(); + + if (!handler_) { + HILOG_ERROR("handler_ is null ptr"); + return; + } + + handler_->RemoveEvent(TWO_FINGER_LONG_PRESS_MSG); + handler_->RemoveEvent(TWO_FINGER_DOUBLE_TAP_AND_HOLD_MSG); + handler_->RemoveEvent(TWO_FINGER_TRIPLE_TAP_AND_HOLD_MSG); + handler_->RemoveEvent(THREE_FINGER_LONG_PRESS_MSG); + handler_->RemoveEvent(THREE_FINGER_DOUBLE_TAP_AND_HOLD_MSG); + handler_->RemoveEvent(THREE_FINGER_TRIPLE_TAP_AND_HOLD_MSG); + handler_->RemoveEvent(FOUR_FINGER_LONG_PRESS_MSG); + handler_->RemoveEvent(FOUR_FINGER_DOUBLE_TAP_AND_HOLD_MSG); + handler_->RemoveEvent(FOUR_FINGER_TRIPLE_TAP_AND_HOLD_MSG); +} + void AccessibilityMultiTapGestureRecognizer::CancelAllPenddingEvent() { HILOG_DEBUG(); @@ -182,6 +295,8 @@ void AccessibilityMultiTapGestureRecognizer::CancelAllPenddingEvent() handler_->RemoveEvent(CANCEL_GESTURE); handler_->RemoveEvent(CANCEL_WAIT_FINGER_DOWN_MSG); CancelTwoFingerEvent(); + CancelThreeFingerEvent(); + CancelFourFingerEvent(); } void AccessibilityMultiTapGestureRecognizer::Clear() @@ -190,9 +305,13 @@ void AccessibilityMultiTapGestureRecognizer::Clear() targetFingers_ = -1; addContinueTapNum_ = 0; + isMoveGestureRecognizing = 0; + moveDirection = -1; firstDownPoint_.clear(); lastUpPoint_.clear(); currentDownPoint_.clear(); + preGesturePoint_.clear(); + pointerRoute_.clear(); CancelAllPenddingEvent(); } @@ -211,36 +330,116 @@ void AccessibilityMultiTapGestureRecognizer::CancelGesture(bool isNoDelayFlag) return; } - listener_->TwoFingerGestureOnCancelled(isNoDelayFlag); + listener_->MultiFingerGestureOnCancelled(isNoDelayFlag); Clear(); } -bool AccessibilityMultiTapGestureRecognizer::ParamCheck() +bool AccessibilityMultiTapGestureRecognizer::ParamCheck(const int32_t fingerNum) { - if (!lastUpPoint_.count(0) || !lastUpPoint_.count(1) || !firstDownPoint_.count(0) || !firstDownPoint_.count(1)) { - HILOG_ERROR("last_up point or first_down point container has wrong value"); + if (lastUpPoint_.size() < fingerNum || firstDownPoint_.size() < fingerNum) { + HILOG_ERROR("last_up point or first_down point size is less than target fingerNum"); return false; } - if (!lastUpPoint_[0] || !lastUpPoint_[1] || !firstDownPoint_[0] || !firstDownPoint_[1]) { - HILOG_ERROR("last_up point or first_down point container has null ptr value"); - return false; + for (int pId = 0; pId < fingerNum; pId++) { + if (!lastUpPoint_.count(pId) || !lastUpPoint_[pId]) { + HILOG_ERROR("last_up point or first_down point container has wrong value and pId is: %d", pId); + return false; + } } return true; } -bool AccessibilityMultiTapGestureRecognizer::IsTwoFingerDoubleTap(MMI::PointerEvent &event) +int64_t AccessibilityMultiTapGestureRecognizer::GetLastFirstPointUpTime(const int32_t fingerNum) { - HILOG_DEBUG("doubleTapOffsetThresh: %d", doubleTapOffsetThresh_); + HILOG_DEBUG(); - if (!ParamCheck()) { + int64_t timeRst = lastUpPoint_[0]->GetActionTime(); + for (int32_t pId = 1; pId < fingerNum; pId++) { + if (lastUpPoint_[pId]->GetActionTime() < timeRst) { + timeRst = lastUpPoint_[pId]->GetActionTime(); + } + } + return timeRst; +} + +bool AccessibilityMultiTapGestureRecognizer::IsDoubelTapSlopConditionMatch(const int32_t fingerNum, + const std::vector &curPoints, + const std::vector &prePoints) +{ + HILOG_DEBUG("doubleTapOffsetThresh_, %d", doubleTapOffsetThresh_); + + std::vector excludePid(fingerNum, -1); + for (auto curPoint : curPoints) { + float moveDelta = FLT_MAX; + int32_t nearestPid = -1; + int32_t curX = curPoint.GetDisplayX(); + int32_t curY = curPoint.GetDisplayY(); + for (auto prePoint : prePoints) { + int32_t pId = prePoint.GetPointerId(); + if (std::find(excludePid.begin(), excludePid.end(), pId) != excludePid.end()) { + continue; + } + int32_t preX = prePoint.GetDisplayX(); + int32_t preY = prePoint.GetDisplayY(); + int32_t offsetX = curX - preX; + int32_t offsetY = curY - preY; + if (offsetX == 0 && offsetY == 0) { + nearestPid = pId; + moveDelta = 0; + break; + } + + float delta = hypot(offsetX, offsetY); + if (delta < moveDelta) { + moveDelta = delta; + nearestPid = pId; + } + } + HILOG_DEBUG("moveDelta = %f, right = %d", moveDelta, doubleTapOffsetThresh_ * fingerNum); + if (moveDelta < doubleTapOffsetThresh_ * fingerNum) { + excludePid.push_back(nearestPid); + } else { + return false; + } + } + + return true; +} + +bool AccessibilityMultiTapGestureRecognizer::GetPointerItemWithFingerNum(int32_t fingerNum, + std::vector &curPoints, + std::vector &prePoints, MMI::PointerEvent &event, + std::map> &prePointsEventInfo) +{ + HILOG_DEBUG(); + + std::vector pIds = event.GetPointerIds(); + for (int32_t pId = 0; pId < fingerNum; pId++) { + if (!event.GetPointerItem(pIds[pId], curPoints[pId])) { + HILOG_ERROR("curPoint GetPointerItem(%d) failed", pIds[pId]); + return false; + } + if (!prePointsEventInfo[pId]->GetPointerItem(prePointsEventInfo[pId]->GetPointerId(), prePoints[pId])) { + HILOG_ERROR("prePoint GetPointerItem(%d) failed", prePointsEventInfo[pId]->GetPointerId()); + return false; + } + } + return true; +} + +bool AccessibilityMultiTapGestureRecognizer::IsMultiFingerDoubleTap(MMI::PointerEvent &event, + const int32_t fingerNum) +{ + HILOG_DEBUG("fingerNum is %d", fingerNum); + + if (!ParamCheck(fingerNum)) { return false; } // first pointer up time to second pointer down time - int64_t firstUpTime = lastUpPoint_[0]->GetActionTime() > lastUpPoint_[1]->GetActionTime() ? - lastUpPoint_[1]->GetActionTime() : lastUpPoint_[0]->GetActionTime(); + int64_t firstUpTime = GetLastFirstPointUpTime(fingerNum); int64_t durationTime = event.GetActionTime() - firstUpTime; if (durationTime > DOUBLE_TAP_TIMEOUT || durationTime < MIN_DOUBLE_TAP_TIME) { HILOG_WARN("durationTime[%{public}" PRId64 "] is wrong", durationTime); @@ -248,45 +447,17 @@ bool AccessibilityMultiTapGestureRecognizer::IsTwoFingerDoubleTap(MMI::PointerEv } std::vector pIds = event.GetPointerIds(); - if (pIds.size() != POINTER_COUNT_2) { + if (pIds.size() != fingerNum) { return false; } - MMI::PointerEvent::PointerItem pointerF = {}; - MMI::PointerEvent::PointerItem pointerS = {}; - if (!event.GetPointerItem(pIds[0], pointerF)) { - HILOG_ERROR("GetPointerItem(%d) failed", pIds[0]); + std::vector curPoints(fingerNum); + std::vector prePoints(fingerNum); + if (!GetPointerItemWithFingerNum(fingerNum, curPoints, prePoints, event, firstDownPoint_)) { return false; } - if (!event.GetPointerItem(pIds[1], pointerS)) { - HILOG_ERROR("GetPointerItem(%d) failed", pIds[1]); - return false; - } - - MMI::PointerEvent::PointerItem firstPI; - MMI::PointerEvent::PointerItem secondPI; - firstDownPoint_[0]->GetPointerItem(firstDownPoint_[0]->GetPointerId(), firstPI); - firstDownPoint_[1]->GetPointerItem(firstDownPoint_[1]->GetPointerId(), secondPI); - HILOG_DEBUG("first finger preDown x: %d, y: %d. curDown x: %d, y: %d", - firstPI.GetDisplayX(), firstPI.GetDisplayY(), pointerF.GetDisplayX(), pointerF.GetDisplayY()); - HILOG_DEBUG("second finger preDown x: %d, y: %d. curDown x: %d, y: %d", - secondPI.GetDisplayX(), secondPI.GetDisplayY(), pointerS.GetDisplayX(), pointerS.GetDisplayY()); - - int32_t durationXff = firstPI.GetDisplayX() - pointerF.GetDisplayX(); - int32_t durationYff = firstPI.GetDisplayY() - pointerF.GetDisplayY(); - int32_t durationXss = secondPI.GetDisplayX() - pointerS.GetDisplayX(); - int32_t durationYss = secondPI.GetDisplayY() - pointerS.GetDisplayY(); - - int32_t durationXfs = firstPI.GetDisplayX() - pointerS.GetDisplayX(); - int32_t durationYfs = firstPI.GetDisplayY() - pointerS.GetDisplayY(); - int32_t durationXsf = secondPI.GetDisplayX() - pointerF.GetDisplayX(); - int32_t durationYsf = secondPI.GetDisplayY() - pointerF.GetDisplayY(); - - return ((durationXff * durationXff + durationYff * durationYff < doubleTapOffsetThresh_ && - durationXss * durationXss + durationYss * durationYss < doubleTapOffsetThresh_) || - (durationXfs * durationXfs + durationYfs * durationYfs < doubleTapOffsetThresh_ && - durationXsf * durationXsf + durationYsf * durationYsf < doubleTapOffsetThresh_)); + return IsDoubelTapSlopConditionMatch(fingerNum, curPoints, prePoints); } void AccessibilityMultiTapGestureRecognizer::HanleFirstTouchDownEvent(MMI::PointerEvent &event) @@ -317,15 +488,44 @@ void AccessibilityMultiTapGestureRecognizer::HanleFirstTouchDownEvent(MMI::Point if (event.GetPointerIds().size() == POINTER_COUNT_1) { SetMultiFingerGestureState(MultiFingerGestureState::GESTURE_WAIT); } else if (event.GetPointerIds().size() == POINTER_COUNT_2) { - listener_->TwoFingerGestureOnStarted(); + listener_->MultiFingerGestureOnStarted(true); SetMultiFingerGestureState(MultiFingerGestureState::GESTURE_START); handler_->SendEvent(TWO_FINGER_SINGLE_TAP_MSG, 0, DOUBLE_TAP_TIMEOUT / US_TO_MS); handler_->SendEvent(TWO_FINGER_LONG_PRESS_MSG, 0, LONG_PRESS_TIMEOUT / US_TO_MS); + } else if (event.GetPointerIds().size() == POINTER_COUNT_3) { + listener_->MultiFingerGestureOnStarted(false); + handler_->SendEvent(THREE_FINGER_SINGLE_TAP_MSG, 0, DOUBLE_TAP_TIMEOUT / US_TO_MS); + handler_->SendEvent(THREE_FINGER_LONG_PRESS_MSG, 0, LONG_PRESS_TIMEOUT / US_TO_MS); + } else if (event.GetPointerIds().size() == POINTER_COUNT_4) { + handler_->SendEvent(FOUR_FINGER_SINGLE_TAP_MSG, 0, DOUBLE_TAP_TIMEOUT / US_TO_MS); + handler_->SendEvent(FOUR_FINGER_LONG_PRESS_MSG, 0, LONG_PRESS_TIMEOUT / US_TO_MS); } else { CancelGesture(true); } } +void AccessibilityMultiTapGestureRecognizer::HandleMultiTapEvent(MMI::PointerEvent &event, const int32_t fingerNum) +{ + HILOG_DEBUG("fingerNum is %d", fingerNum); + + // check is double tap + if (firstDownPoint_.size() == fingerNum && lastUpPoint_.size() == fingerNum && + IsMultiFingerDoubleTap(event, fingerNum)) { + HILOG_DEBUG("two finger Double tap is recognized, addContinueTapNum %d", addContinueTapNum_); + addContinueTapNum_ = (addContinueTapNum_ + 1) % MULTI_FINGER_MAX_CONTINUE_TAP_NUM; + } else { + addContinueTapNum_ = 0; + } + if (fingerNum < POINTER_COUNT_2 || fingerNum > POINTER_COUNT_4 || + addContinueTapNum_ >= MULTI_FINGER_MAX_CONTINUE_TAP_NUM) { + HILOG_ERROR("fingerNum: %d or tap times: %u is wrong", fingerNum, addContinueTapNum_); + return; + } + uint32_t fingerNumIndex = static_cast(fingerNum - 2); + handler_->SendEvent(GESTURE_TAP_MSG[addContinueTapNum_][fingerNumIndex], 0, DOUBLE_TAP_TIMEOUT / US_TO_MS); + handler_->SendEvent(GESTURE_HOLD_MSG[addContinueTapNum_][fingerNumIndex], 0, LONG_PRESS_TIMEOUT / US_TO_MS); +} + void AccessibilityMultiTapGestureRecognizer::HandleContinueTouchDownEvent(MMI::PointerEvent &event) { HILOG_DEBUG("fingerNum is %d, gestureState is %d, touchUpstate is %d", @@ -350,64 +550,234 @@ void AccessibilityMultiTapGestureRecognizer::HandleContinueTouchDownEvent(MMI::P if (pointerSize < targetFingers_) { handler_->SendEvent(CANCEL_GESTURE, 0, TAP_INTERVAL_TIMEOUT / US_TO_MS); } else if (pointerSize == targetFingers_) { - // check is double tap - if (firstDownPoint_.size() == POINTER_COUNT_2 && lastUpPoint_.size() == POINTER_COUNT_2 && - IsTwoFingerDoubleTap(event)) { - HILOG_DEBUG("two finger Double tap is recognized, addContinueTapNum %d", addContinueTapNum_); - addContinueTapNum_ = (addContinueTapNum_ + 1) % MULTI_FINGER_MAX_CONTINUE_TAP_NUM; - } else { - addContinueTapNum_ = 0; - } + HandleMultiTapEvent(event, targetFingers_); + } else { + HILOG_DEBUG("current fingers is more than last touch down finger nums"); + CancelGesture(true); + } +} - if (addContinueTapNum_ == 0) { - handler_->SendEvent(TWO_FINGER_SINGLE_TAP_MSG, 0, DOUBLE_TAP_TIMEOUT / US_TO_MS); - handler_->SendEvent(TWO_FINGER_LONG_PRESS_MSG, 0, LONG_PRESS_TIMEOUT / US_TO_MS); - } else if (addContinueTapNum_ == POINTER_COTINUE_TAP_ONE_TIME) { - handler_->SendEvent(TWO_FINGER_DOUBLE_TAP_AND_HOLD_MSG, 0, LONG_PRESS_TIMEOUT / US_TO_MS); - handler_->SendEvent(TWO_FINGER_DOUBLE_TAP_MSG, 0, DOUBLE_TAP_TIMEOUT / US_TO_MS); - } else { - handler_->SendEvent(TWO_FINGER_TRIPLE_TAP_AND_HOLD_MSG, 0, LONG_PRESS_TIMEOUT / US_TO_MS); - handler_->SendEvent(TWO_FINGER_TRIPLE_TAP_MSG, 0, DOUBLE_TAP_TIMEOUT / US_TO_MS); +void AccessibilityMultiTapGestureRecognizer::storeBaseDownPoint() +{ + HILOG_DEBUG(); + + for (auto iter : currentDownPoint_) { + Pointer mp; + MMI::PointerEvent::PointerItem pointerIterm; + std::vector mpVec; + int32_t pId = iter.first; + + if (!iter.second->GetPointerItem(pId, pointerIterm)) { + HILOG_ERROR("get GetPointerItem(%d) failed", pId); + return; } + + mp.px_ = static_cast(pointerIterm.GetDisplayX()); + mp.py_ = static_cast(pointerIterm.GetDisplayY()); + mpVec.push_back(mp); + pointerRoute_.insert(std::make_pair(pId, mpVec)); + } +} + +int32_t AccessibilityMultiTapGestureRecognizer::GetSwipeDirection(const int32_t dx, const int32_t dy) +{ + HILOG_DEBUG(); + + if (abs(dx) > abs(dy)) { + return (dx < 0) ? MoveGirectionType::SWIPE_LEFT : MoveGirectionType::SWIPE_RIGHT; } else { - HILOG_DEBUG("current fingers is more than last touch down finger nums"); + return (dy < 0) ? MoveGirectionType::SWIPE_UP : MoveGirectionType::SWIPE_DOWN; + } +} + +void AccessibilityMultiTapGestureRecognizer::SaveMoveGesturePointerInfo(MMI::PointerEvent &event, + const int32_t pId, const MMI::PointerEvent::PointerItem &pointerIterm, const int32_t dx, const int32_t dy) +{ + HILOG_DEBUG(); + + int32_t currentDirection = GetSwipeDirection(dx, dy); + if (!isMoveGestureRecognizing) { + storeBaseDownPoint(); + moveDirection = currentDirection; + isMoveGestureRecognizing = true; + return; + } + + if (moveDirection != currentDirection) { CancelGesture(true); + return; } + Pointer mp; + mp.px_ = static_cast(pointerIterm.GetDisplayX()); + mp.py_ = static_cast(pointerIterm.GetDisplayY()); + pointerRoute_[pId].push_back(mp); + //update preGesturePoint_ + preGesturePoint_[pId] = std::make_shared(event); } -void AccessibilityMultiTapGestureRecognizer::HandleTwoFingerMoveEvent(MMI::PointerEvent &event) +bool AccessibilityMultiTapGestureRecognizer::GetBasePointItem(MMI::PointerEvent::PointerItem &basePointerIterm, + int32_t pId, std::map> &pointInfo) { - HILOG_DEBUG("finger num is %d, pId is %d", static_cast(currentDownPoint_.size()), event.GetPointerId()); + HILOG_DEBUG(); + if (pointInfo.count(pId) == 0 || !pointInfo[pId]) { + return false; + } + if (!pointInfo[pId]->GetPointerItem(pointInfo[pId]->GetPointerId(), basePointerIterm)) { + HILOG_ERROR("base down point get GetPointerItem(%d) failed", pId); + return false; + } + + return true; +} + +void AccessibilityMultiTapGestureRecognizer::HandleMultiFingerMoveEvent(MMI::PointerEvent &event) +{ + int32_t pIdSize = event.GetPointerIds().size(); + int32_t downPointSize = currentDownPoint_.size(); int32_t pId = event.GetPointerId(); + HILOG_DEBUG("pointer num is %d, down pointer size is %d, pointId is %d", pIdSize, downPointSize, pId); + MMI::PointerEvent::PointerItem pointerIterm; if (!event.GetPointerItem(pId, pointerIterm)) { HILOG_ERROR("get GetPointerItem(%d) failed", pId); return; } - if (currentDownPoint_.size() != POINTER_COUNT_2 || currentDownPoint_.count(pId) == 0 || - !currentDownPoint_[pId]) { - CancelGesture(false); + MMI::PointerEvent::PointerItem basePointerIterm; + if (isMoveGestureRecognizing) { + if (!GetBasePointItem(basePointerIterm, pId, preGesturePoint_)) { + return; + } + } else { + if (!GetBasePointItem(basePointerIterm, pId, currentDownPoint_)) { + return; + } + } + + int32_t offsetX = pointerIterm.GetDisplayX() - basePointerIterm.GetDisplayX(); + int32_t offsetY = pointerIterm.GetDisplayY() - basePointerIterm.GetDisplayY(); + HILOG_DEBUG("current point and first down point: pid %d, %d, %d, %d, %d", pId, pointerIterm.GetDisplayX(), + pointerIterm.GetDisplayY(), basePointerIterm.GetDisplayX(), basePointerIterm.GetDisplayY()); + + // two finger move will cancel gesture, but three or four finger move will enter move gesture recognize + if (!isMoveGestureRecognizing && hypot(offsetX, offsetY) >= TOUCH_SLOP * downPointSize) { + if (downPointSize == POINTER_COUNT_2) { + HILOG_DEBUG("cancel gesture because finger move"); + CancelGesture(false); + } else { + CancelThreeFingerEvent(); + CancelFourFingerEvent(); + SaveMoveGesturePointerInfo(event, pId, pointerIterm, offsetX, offsetY); + } + } else if (isMoveGestureRecognizing && (abs(offsetX) >= mMinPixelsBetweenSamplesX_ || + abs(offsetY) >= mMinPixelsBetweenSamplesY_)) { + SaveMoveGesturePointerInfo(event, pId, pointerIterm, offsetX, offsetY); + } +} + +void AccessibilityMultiTapGestureRecognizer::StoreUpPointInPointerRoute(MMI::PointerEvent &event) +{ + HILOG_DEBUG(); + + if (!isMoveGestureRecognizing || multiFingerGestureState_ != MultiFingerGestureState::GESTURE_START) { + return; + } + + MMI::PointerEvent::PointerItem pointerIterm; + int32_t pId = event.GetPointerId(); + if (!event.GetPointerItem(pId, pointerIterm)) { + HILOG_ERROR("get GetPointerItem(%d) failed", pId); return; } - MMI::PointerEvent::PointerItem firstDownPointerIterm; - if (!currentDownPoint_[pId]->GetPointerItem(currentDownPoint_[pId]->GetPointerId(), firstDownPointerIterm)) { - HILOG_ERROR("first down point get GetPointerItem(%d) failed", pId); + MMI::PointerEvent::PointerItem basePointerIterm; + if (!GetBasePointItem(basePointerIterm, pId, preGesturePoint_)) { return; } - int32_t offsetX = firstDownPointerIterm.GetDisplayX() - pointerIterm.GetDisplayX(); - int32_t offsetY = firstDownPointerIterm.GetDisplayY() - pointerIterm.GetDisplayY(); - HILOG_DEBUG("current point and first down point: %d, %d, %d, %d", pointerIterm.GetDisplayX(), - pointerIterm.GetDisplayY(), firstDownPointerIterm.GetDisplayX(), firstDownPointerIterm.GetDisplayY()); + int32_t offsetX = pointerIterm.GetDisplayX() - basePointerIterm.GetDisplayX(); + int32_t offsetY = pointerIterm.GetDisplayY() - basePointerIterm.GetDisplayY(); + if (abs(offsetX) > mMinPixelsBetweenSamplesX_ || abs(offsetY) > mMinPixelsBetweenSamplesY_) { + SaveMoveGesturePointerInfo(event, pId, pointerIterm, offsetX, offsetY); + } +} - // two finger move not recognize as a gesture - if (hypot(offsetX, offsetY) >= TOUCH_SLOP * event.GetPointerIds().size()) { - HILOG_DEBUG("cancel gesture because finger move"); - CancelGesture(false); +bool AccessibilityMultiTapGestureRecognizer::recognizeGesturePath(const std::vector &path) +{ + HILOG_DEBUG(); + + for (int routerIndex = 0; routerIndex < path.size() - 1; routerIndex++) { + int32_t dx = static_cast(path[routerIndex + 1].px_ - path[routerIndex].px_); + int32_t dy = static_cast(path[routerIndex + 1].py_ - path[routerIndex].py_); + if (GetSwipeDirection(dx, dy) != moveDirection) { + return false; + } } + return true; +} + +GestureType AccessibilityMultiTapGestureRecognizer::GetMoveGestureId() +{ + HILOG_DEBUG(); + + int32_t downPointSize = currentDownPoint_.size(); + if (downPointSize == POINTER_COUNT_3) { + switch (moveDirection) { + case MoveGirectionType::SWIPE_LEFT: + return GestureType::GESTURE_THREE_FINGER_SWIPE_LEFT; + case MoveGirectionType::SWIPE_RIGHT: + return GestureType::GESTURE_THREE_FINGER_SWIPE_RIGHT; + case MoveGirectionType::SWIPE_UP: + return GestureType::GESTURE_THREE_FINGER_SWIPE_UP; + case MoveGirectionType::SWIPE_DOWN: + return GestureType::GESTURE_THREE_FINGER_SWIPE_DOWN; + default: + return GestureType::GESTURE_INVALID; + } + } else if (downPointSize == POINTER_COUNT_4) { + switch (moveDirection) { + case MoveGirectionType::SWIPE_LEFT: + return GestureType::GESTURE_FOUR_FINGER_SWIPE_LEFT; + case MoveGirectionType::SWIPE_RIGHT: + return GestureType::GESTURE_FOUR_FINGER_SWIPE_RIGHT; + case MoveGirectionType::SWIPE_UP: + return GestureType::GESTURE_FOUR_FINGER_SWIPE_UP; + case MoveGirectionType::SWIPE_DOWN: + return GestureType::GESTURE_FOUR_FINGER_SWIPE_DOWN; + default: + return GestureType::GESTURE_INVALID; + } + } + return GestureType::GESTURE_INVALID; +} + +bool AccessibilityMultiTapGestureRecognizer::IsMoveGestureRecognize() +{ + HILOG_DEBUG(); + + if (!isMoveGestureRecognizing || multiFingerGestureState_ != MultiFingerGestureState::GESTURE_START) { + return false; + } + + int32_t downPointSize = currentDownPoint_.size(); + if (pointerRoute_.size() != downPointSize) { + return false; + } + + for (int32_t pIndex = 0; pIndex < downPointSize; pIndex++) { + if (pointerRoute_.count(pIndex) == 0 || pointerRoute_[pIndex].size() < MIN_MOVE_POINTER_NUM) { + return false; + } + if (!recognizeGesturePath(pointerRoute_[pIndex])) { + return false; + } + } + + GestureType gestureId = GetMoveGestureId(); + listener_->MultiFingerGestureOnCompleted(gestureId); + + return true; } void AccessibilityMultiTapGestureRecognizer::HandleMultiFingerTouchUpEvent(MMI::PointerEvent &event) @@ -416,17 +786,26 @@ void AccessibilityMultiTapGestureRecognizer::HandleMultiFingerTouchUpEvent(MMI:: multiFingerGestureState_, isFirstUp_, targetFingers_); handler_->RemoveEvent(WAIT_ANOTHER_FINGER_DOWN_MSG); - handler_->RemoveEvent(TWO_FINGER_LONG_PRESS_MSG); - handler_->RemoveEvent(TWO_FINGER_DOUBLE_TAP_AND_HOLD_MSG); - handler_->RemoveEvent(TWO_FINGER_TRIPLE_TAP_AND_HOLD_MSG); + CancelHoldGestureEvent(); if (multiFingerGestureState_ == MultiFingerGestureState::GESTURE_WAIT) { handler_->SendEvent(CANCEL_WAIT_FINGER_DOWN_MSG, event.GetPointerIds().size(), DOUBLE_TAP_TIMEOUT / US_TO_MS); } + StoreUpPointInPointerRoute(event); if (event.GetPointerIds().size() == POINTER_COUNT_1) { + if (IsMoveGestureRecognize()) { + SetMultiFingerGestureState(MultiFingerGestureState::GESTURE_COMPLETE); + fingerTouchUpState_ = FingerTouchUpState::ALL_FINGER_TOUCH_UP; + Clear(); + return; + } fingerTouchUpState_ = FingerTouchUpState::ALL_FINGER_TOUCH_UP; currentDownPoint_.clear(); + preGesturePoint_.clear(); + pointerRoute_.clear(); + moveDirection = -1; + isMoveGestureRecognizing = false; } else { fingerTouchUpState_ = FingerTouchUpState::NOT_ALL_FINGER_TOUCH_UP; } @@ -441,7 +820,7 @@ void AccessibilityMultiTapGestureRecognizer::HandleMultiFingerTouchUpEvent(MMI:: lastUpPoint_[event.GetPointerId()] = std::make_shared(event); if (targetFingers_ == -1 && multiFingerGestureState_ == MultiFingerGestureState::GESTURE_START) { - targetFingers_ = static_cast(event.GetPointerIds().size()); + targetFingers_ = event.GetPointerIds().size(); } } @@ -455,6 +834,7 @@ bool AccessibilityMultiTapGestureRecognizer::OnPointerEvent(MMI::PointerEvent &e CancelAllPenddingEvent(); isFirstUp_ = true; currentDownPoint_[event.GetPointerId()] = std::make_shared(event); + preGesturePoint_[event.GetPointerId()] = std::make_shared(event); if (targetFingers_ == -1) { HanleFirstTouchDownEvent(event); } else { @@ -465,10 +845,7 @@ bool AccessibilityMultiTapGestureRecognizer::OnPointerEvent(MMI::PointerEvent &e if (multiFingerGestureState_ != MultiFingerGestureState::GESTURE_START) { return false; } - - if (event.GetPointerIds().size() == POINTER_COUNT_2) { - HandleTwoFingerMoveEvent(event); - } + HandleMultiFingerMoveEvent(event); break; case MMI::PointerEvent::POINTER_ACTION_UP: HandleMultiFingerTouchUpEvent(event); diff --git a/services/aams/src/accessibility_touch_guider.cpp b/services/aams/src/accessibility_touch_guider.cpp index 6e441122..58cdb271 100755 --- a/services/aams/src/accessibility_touch_guider.cpp +++ b/services/aams/src/accessibility_touch_guider.cpp @@ -232,10 +232,15 @@ bool TouchGuider::TouchGuideListener::OnStarted() return true; } -void TouchGuider::TouchGuideListener::TwoFingerGestureOnStarted() +void TouchGuider::TouchGuideListener::MultiFingerGestureOnStarted(bool isTwoFingerGesture) { HILOG_DEBUG(); + if (!isTwoFingerGesture) { + server_.currentState_ = static_cast(TouchGuideState::TRANSMITTING); + return; + } + server_.CancelPostEventIfNeed(SEND_HOVER_ENTER_MOVE_MSG); server_.CancelPostEventIfNeed(SEND_HOVER_EXIT_MSG); server_.PostGestureRecognizeExit(); @@ -261,7 +266,7 @@ bool TouchGuider::TouchGuideListener::OnCompleted(GestureType gestureId) return true; } -void TouchGuider::TouchGuideListener::TwoFingerGestureOnCompleted(GestureType gestureId) +void TouchGuider::TouchGuideListener::MultiFingerGestureOnCompleted(GestureType gestureId) { HILOG_DEBUG("gestureId is %{public}d", gestureId); @@ -302,10 +307,13 @@ bool TouchGuider::TouchGuideListener::OnCancelled(MMI::PointerEvent &event) return true; } -void TouchGuider::TouchGuideListener::TwoFingerGestureOnCancelled(const bool isNoDelayFlag) +void TouchGuider::TouchGuideListener::MultiFingerGestureOnCancelled(const bool isNoDelayFlag) { HILOG_DEBUG(); + if (static_cast(server_.currentState_) == TouchGuideState::TRANSMITTING) { + server_.currentState_ = static_cast(TouchGuideState::TOUCH_GUIDING); + } server_.SendAccessibilityEventToAA(EventType::TYPE_TOUCH_GUIDE_GESTURE_END); server_.CancelPostEvent(EXIT_GESTURE_REC_MSG); if (isNoDelayFlag) { @@ -431,7 +439,8 @@ void TouchGuider::HandleTransmitingState(MMI::PointerEvent &event) } break; case MMI::PointerEvent::POINTER_ACTION_UP: - if (event.GetPointerIds().size() == POINTER_COUNT_1) { + if (event.GetPointerIds().size() == POINTER_COUNT_1 && !IsTouchInteractionEnd() && + !multiFingerGestureRecognizer_.IsMultiFingerRecognize()) { if (longPressPointId_ >= 0) { // Adjust this event's location. MMI::PointerEvent::PointerItem pointer = {}; diff --git a/services/test/moduletest/aamstest/aams_accessibility_touch_guider_test/aams_accessibility_touch_guider_test.cpp b/services/test/moduletest/aamstest/aams_accessibility_touch_guider_test/aams_accessibility_touch_guider_test.cpp index c5f36ba6..8f04f7f5 100755 --- a/services/test/moduletest/aamstest/aams_accessibility_touch_guider_test/aams_accessibility_touch_guider_test.cpp +++ b/services/test/moduletest/aamstest/aams_accessibility_touch_guider_test/aams_accessibility_touch_guider_test.cpp @@ -75,6 +75,11 @@ public: MMI::PointerEvent::PointerItem point1, MMI::PointerEvent::PointerItem point2, bool isSeparateFlag); bool TwoFingerTapAndOneFingerTapEventProduce(std::vector &points, MMI::PointerEvent::PointerItem point1, MMI::PointerEvent::PointerItem point2); + bool MultiFingerTapEventProduce(std::vector &points, + std::vector &pointsVec, int32_t tapTimes, bool holdFlag); + bool MultiFingerTapAndMoveEventProduce(std::vector &points, + std::vector &pointStartVec, + std::vector &pointEndVec); void SetUp(); void TearDown(); @@ -361,6 +366,86 @@ bool AamsTouchGuideTest::TwoFingerTapAndOneFingerTapEventProduce(std::vector &points, + std::vector &pointsVec, int32_t tapTimes, bool holdFlag) +{ + auto inputEventConsumer = MMI::MockInputManager::GetInputEventConsumer(); + if (!inputEventConsumer) { + GTEST_LOG_(INFO) << "AamsTouchGuideTest MultiFingerTapEventProduce inputEventConsumer is null"; + return false; + } + + std::shared_ptr event; + int64_t occurredTime = 0; + for (int32_t tapIndex = 1; tapIndex <= tapTimes; tapIndex++) { + points.clear(); + int32_t pId = 0; + for (auto iter : pointsVec) { + points.emplace_back(iter); + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, occurredTime, 0, pId); + pId++; + inputEventConsumer->OnInputEvent(event); + } + + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, points, 0, 0, POINT_ID_0); + inputEventConsumer->OnInputEvent(event); + + if (holdFlag && tapIndex == tapTimes) { + sleep(1); + } + + pId = pointsVec.size() - 1; + for (int32_t pointsVecIndex = 0; pointsVecIndex < pointsVec.size(); pointsVecIndex++) { + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, occurredTime, 0, pId); + points.pop_back(); + pId--; + inputEventConsumer->OnInputEvent(event); + } + + occurredTime += TAP_TIME_INTERVAL; + } + return true; +} + +bool AamsTouchGuideTest::MultiFingerTapAndMoveEventProduce(std::vector &points, + std::vector &pointStartVec, + std::vector &pointEndVec) +{ + auto inputEventConsumer = MMI::MockInputManager::GetInputEventConsumer(); + if (!inputEventConsumer) { + GTEST_LOG_(INFO) << "AamsTouchGuideTest MultiFingerTapAndMoveEventProduce inputEventConsumer is null"; + return false; + } + + std::shared_ptr event; + int64_t occurredTime = 0; + points.clear(); + int32_t pId = 0; + for (auto iter : pointStartVec) { + points.emplace_back(iter); + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, occurredTime, 0, pId); + pId++; + inputEventConsumer->OnInputEvent(event); + } + + points.clear(); + for (auto iter : pointEndVec) { + points.emplace_back(iter); + } + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, points, occurredTime, 0, 0); + inputEventConsumer->OnInputEvent(event); + + pId = pointEndVec.size() - 1; + for (int32_t pointsEndVecIndex = 0; pointsEndVecIndex < pointEndVec.size(); pointsEndVecIndex++) { + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, occurredTime, 0, pId); + points.pop_back(); + pId--; + inputEventConsumer->OnInputEvent(event); + } + + return true; +} + void AamsTouchGuideTest::TouchGuiderPointSet(MMI::PointerEvent::PointerItem &point, int id, int x, int y) { point.SetPointerId(id); @@ -636,9 +721,9 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent003, Te EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), EventType::TYPE_TOUCH_GUIDE_GESTURE_END); // Determine action - EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(0), MMI::PointerEvent::BUTTON_NONE); - EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(1), MMI::PointerEvent::BUTTON_NONE); - EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(2), MMI::PointerEvent::BUTTON_NONE); + EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(0), MMI::PointerEvent::POINTER_ACTION_MOVE); + EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(1), MMI::PointerEvent::POINTER_ACTION_MOVE); + EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(2), MMI::PointerEvent::POINTER_ACTION_MOVE); // Determine gesture type retOnPointerEvent3 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { if (AccessibilityHelper::GetInstance().GetGestureId() == @@ -696,9 +781,9 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent004, Te EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), EventType::TYPE_TOUCH_GUIDE_GESTURE_END); // Determine action - EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(0), MMI::PointerEvent::BUTTON_NONE); - EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(1), MMI::PointerEvent::BUTTON_NONE); - EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(2), MMI::PointerEvent::BUTTON_NONE); + EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(0), MMI::PointerEvent::POINTER_ACTION_MOVE); + EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(1), MMI::PointerEvent::POINTER_ACTION_MOVE); + EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(2), MMI::PointerEvent::POINTER_ACTION_MOVE); // Determine gesture type retOnPointerEvent4 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { if (AccessibilityHelper::GetInstance().GetGestureId() == @@ -756,9 +841,9 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent005, Te EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), EventType::TYPE_TOUCH_GUIDE_GESTURE_END); // Determine action - EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(0), MMI::PointerEvent::BUTTON_NONE); - EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(1), MMI::PointerEvent::BUTTON_NONE); - EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(2), MMI::PointerEvent::BUTTON_NONE); + EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(0), MMI::PointerEvent::POINTER_ACTION_MOVE); + EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(1), MMI::PointerEvent::POINTER_ACTION_MOVE); + EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(2), MMI::PointerEvent::POINTER_ACTION_MOVE); // Determine gesture type retOnPointerEvent5 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { if (AccessibilityHelper::GetInstance().GetGestureId() == @@ -816,9 +901,9 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent006, Te EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), EventType::TYPE_TOUCH_GUIDE_GESTURE_END); // Determine action - EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(0), MMI::PointerEvent::BUTTON_NONE); - EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(1), MMI::PointerEvent::BUTTON_NONE); - EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(2), MMI::PointerEvent::BUTTON_NONE); + EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(0), MMI::PointerEvent::POINTER_ACTION_MOVE); + EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(1), MMI::PointerEvent::POINTER_ACTION_MOVE); + EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(2), MMI::PointerEvent::POINTER_ACTION_MOVE); // Determine gesture type retOnPointerEvent6 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { if (AccessibilityHelper::GetInstance().GetGestureId() == @@ -874,8 +959,8 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent007, Te EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), EventType::TYPE_TOUCH_GUIDE_GESTURE_END); // Determine action - EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(0), MMI::PointerEvent::BUTTON_NONE); - EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(1), MMI::PointerEvent::BUTTON_NONE); + EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(0), MMI::PointerEvent::POINTER_ACTION_MOVE); + EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(1), MMI::PointerEvent::POINTER_ACTION_MOVE); // Determine gesture type retOnPointerEvent7 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { if (AccessibilityHelper::GetInstance().GetGestureId() == static_cast(GestureType::GESTURE_SWIPE_UP)) { @@ -1494,5 +1579,656 @@ HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent019, Te GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent019 ends"; } + +/** + * @tc.number: OnPointerEvent020 + * @tc.name:OnPointerEvent + * @tc.desc: Check the three finger single tap event. + */ +HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent020, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent020 starts"; + + AccessibilityHelper::GetInstance().GetEventType() = {}; + MMI::MockInputManager::ClearTouchActions(); + + std::vector points = {}; + MMI::PointerEvent::PointerItem point1 = {}; + TouchGuiderPointSet(point1, 0, 100, 100); + MMI::PointerEvent::PointerItem point2 = {}; + TouchGuiderPointSet(point2, 1, 200, 100); + MMI::PointerEvent::PointerItem point3 = {}; + TouchGuiderPointSet(point3, 2, 300, 100); + std::vector pointVec{point1, point2, point3}; + + bool eventProduceRst = MultiFingerTapEventProduce(points, pointVec, 1, false); + if (!eventProduceRst) { + GTEST_LOG_(INFO) << "AamsTouchGuideTest OnPointerEvent0020 inputEventConsumer is null"; + return; + } + + // eventType + bool ret = + AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { + if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3) == + EventType::TYPE_TOUCH_END) { + return true; + } else { + return false; + } + }), SLEEP_TIME_3); + EXPECT_TRUE(ret); + EXPECT_EQ(static_cast(AccessibilityHelper::GetInstance().GetEventType().size()), 4); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), + EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), + EventType::TYPE_TOUCH_GUIDE_GESTURE_END); + + // gestureId + EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), + static_cast(GestureType::GESTURE_THREE_FINGER_SINGLE_TAP)); + + GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent020 ends"; +} + +/** + * @tc.number: OnPointerEvent021 + * @tc.name:OnPointerEvent + * @tc.desc: Check the four finger single tap event. + */ +HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent021, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent021 starts"; + + AccessibilityHelper::GetInstance().GetEventType() = {}; + MMI::MockInputManager::ClearTouchActions(); + + std::vector points = {}; + MMI::PointerEvent::PointerItem point1 = {}; + TouchGuiderPointSet(point1, 0, 100, 100); + MMI::PointerEvent::PointerItem point2 = {}; + TouchGuiderPointSet(point2, 1, 200, 100); + MMI::PointerEvent::PointerItem point3 = {}; + TouchGuiderPointSet(point3, 2, 300, 100); + MMI::PointerEvent::PointerItem point4 = {}; + TouchGuiderPointSet(point4, 3, 400, 100); + std::vector pointVec{point1, point2, point3, point4}; + + bool eventProduceRst = MultiFingerTapEventProduce(points, pointVec, 1, false); + if (!eventProduceRst) { + GTEST_LOG_(INFO) << "AamsTouchGuideTest OnPointerEvent0021 inputEventConsumer is null"; + return; + } + + // eventType + bool ret = + AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { + if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3) == + EventType::TYPE_TOUCH_END) { + return true; + } else { + return false; + } + }), SLEEP_TIME_3); + EXPECT_TRUE(ret); + EXPECT_EQ(static_cast(AccessibilityHelper::GetInstance().GetEventType().size()), 4); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), + EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), + EventType::TYPE_TOUCH_GUIDE_GESTURE_END); + + // gestureId + EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), + static_cast(GestureType::GESTURE_FOUR_FINGER_SINGLE_TAP)); + + GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent021 ends"; +} + +/** + * @tc.number: OnPointerEvent022 + * @tc.name:OnPointerEvent + * @tc.desc: Check the three finger double tap event. + */ +HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent022, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent022 starts"; + + AccessibilityHelper::GetInstance().GetEventType() = {}; + MMI::MockInputManager::ClearTouchActions(); + + std::vector points = {}; + MMI::PointerEvent::PointerItem point1 = {}; + TouchGuiderPointSet(point1, 0, 100, 100); + MMI::PointerEvent::PointerItem point2 = {}; + TouchGuiderPointSet(point2, 1, 200, 100); + MMI::PointerEvent::PointerItem point3 = {}; + TouchGuiderPointSet(point3, 2, 300, 100); + std::vector pointVec{point1, point2, point3}; + + bool eventProduceRst = MultiFingerTapEventProduce(points, pointVec, 2, false); + if (!eventProduceRst) { + GTEST_LOG_(INFO) << "AamsTouchGuideTest OnPointerEvent0022 inputEventConsumer is null"; + return; + } + + // eventType + bool ret = + AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { + if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3) == + EventType::TYPE_TOUCH_END) { + return true; + } else { + return false; + } + }), SLEEP_TIME_3); + EXPECT_TRUE(ret); + EXPECT_EQ(static_cast(AccessibilityHelper::GetInstance().GetEventType().size()), 4); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), + EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), + EventType::TYPE_TOUCH_GUIDE_GESTURE_END); + + // gestureId + EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), + static_cast(GestureType::GESTURE_THREE_FINGER_DOUBLE_TAP)); + + GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent022 ends"; +} + +/** + * @tc.number: OnPointerEvent023 + * @tc.name:OnPointerEvent + * @tc.desc: Check the three finger double tap and hold event. + */ +HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent023, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent023 starts"; + + AccessibilityHelper::GetInstance().GetEventType() = {}; + MMI::MockInputManager::ClearTouchActions(); + + std::vector points = {}; + MMI::PointerEvent::PointerItem point1 = {}; + TouchGuiderPointSet(point1, 0, 100, 100); + MMI::PointerEvent::PointerItem point2 = {}; + TouchGuiderPointSet(point2, 1, 200, 100); + MMI::PointerEvent::PointerItem point3 = {}; + TouchGuiderPointSet(point3, 2, 300, 100); + std::vector pointVec{point1, point2, point3}; + + bool eventProduceRst = MultiFingerTapEventProduce(points, pointVec, 2, true); + if (!eventProduceRst) { + GTEST_LOG_(INFO) << "AamsTouchGuideTest OnPointerEvent0023 inputEventConsumer is null"; + return; + } + + // eventType + bool ret = + AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { + if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3) == + EventType::TYPE_TOUCH_END) { + return true; + } else { + return false; + } + }), SLEEP_TIME_3); + EXPECT_TRUE(ret); + EXPECT_EQ(static_cast(AccessibilityHelper::GetInstance().GetEventType().size()), 4); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), + EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), + EventType::TYPE_TOUCH_GUIDE_GESTURE_END); + + // gestureId + EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), + static_cast(GestureType::GESTURE_THREE_FINGER_DOUBLE_TAP_AND_HOLD)); + + GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent023 ends"; +} + +/** + * @tc.number: OnPointerEvent024 + * @tc.name:OnPointerEvent + * @tc.desc: Check the three finger triple tap event. + */ +HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent024, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent024 starts"; + + AccessibilityHelper::GetInstance().GetEventType() = {}; + MMI::MockInputManager::ClearTouchActions(); + + std::vector points = {}; + MMI::PointerEvent::PointerItem point1 = {}; + TouchGuiderPointSet(point1, 0, 100, 100); + MMI::PointerEvent::PointerItem point2 = {}; + TouchGuiderPointSet(point2, 1, 200, 100); + MMI::PointerEvent::PointerItem point3 = {}; + TouchGuiderPointSet(point3, 2, 300, 100); + std::vector pointVec{point1, point2, point3}; + + bool eventProduceRst = MultiFingerTapEventProduce(points, pointVec, 3, false); + if (!eventProduceRst) { + GTEST_LOG_(INFO) << "AamsTouchGuideTest OnPointerEvent0024 inputEventConsumer is null"; + return; + } + + // eventType + bool ret = + AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { + if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3) == + EventType::TYPE_TOUCH_END) { + return true; + } else { + return false; + } + }), SLEEP_TIME_3); + EXPECT_TRUE(ret); + EXPECT_EQ(static_cast(AccessibilityHelper::GetInstance().GetEventType().size()), 4); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), + EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), + EventType::TYPE_TOUCH_GUIDE_GESTURE_END); + + // gestureId + EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), + static_cast(GestureType::GESTURE_THREE_FINGER_TRIPLE_TAP)); + + GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent024 ends"; +} + +/** + * @tc.number: OnPointerEvent025 + * @tc.name:OnPointerEvent + * @tc.desc: Check the three finger triple tap and hold event. + */ +HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent025, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent025 starts"; + + AccessibilityHelper::GetInstance().GetEventType() = {}; + MMI::MockInputManager::ClearTouchActions(); + + std::vector points = {}; + MMI::PointerEvent::PointerItem point1 = {}; + TouchGuiderPointSet(point1, 0, 100, 100); + MMI::PointerEvent::PointerItem point2 = {}; + TouchGuiderPointSet(point2, 1, 200, 100); + MMI::PointerEvent::PointerItem point3 = {}; + TouchGuiderPointSet(point3, 2, 300, 100); + std::vector pointVec{point1, point2, point3}; + + bool eventProduceRst = MultiFingerTapEventProduce(points, pointVec, 3, true); + if (!eventProduceRst) { + GTEST_LOG_(INFO) << "AamsTouchGuideTest OnPointerEvent0025 inputEventConsumer is null"; + return; + } + + // eventType + bool ret = + AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { + if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3) == + EventType::TYPE_TOUCH_END) { + return true; + } else { + return false; + } + }), SLEEP_TIME_3); + EXPECT_TRUE(ret); + EXPECT_EQ(static_cast(AccessibilityHelper::GetInstance().GetEventType().size()), 4); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), + EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), + EventType::TYPE_TOUCH_GUIDE_GESTURE_END); + + // gestureId + EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), + static_cast(GestureType::GESTURE_THREE_FINGER_TRIPLE_TAP_AND_HOLD)); + + GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent025 ends"; +} + +/** + * @tc.number: OnPointerEvent026 + * @tc.name:OnPointerEvent + * @tc.desc: Check the four finger double tap event. + */ +HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent026, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent026 starts"; + + AccessibilityHelper::GetInstance().GetEventType() = {}; + MMI::MockInputManager::ClearTouchActions(); + + std::vector points = {}; + MMI::PointerEvent::PointerItem point1 = {}; + TouchGuiderPointSet(point1, 0, 100, 100); + MMI::PointerEvent::PointerItem point2 = {}; + TouchGuiderPointSet(point2, 1, 200, 100); + MMI::PointerEvent::PointerItem point3 = {}; + TouchGuiderPointSet(point3, 2, 300, 100); + MMI::PointerEvent::PointerItem point4 = {}; + TouchGuiderPointSet(point4, 3, 400, 100); + std::vector pointVec{point1, point2, point3, point4}; + + bool eventProduceRst = MultiFingerTapEventProduce(points, pointVec, 2, false); + if (!eventProduceRst) { + GTEST_LOG_(INFO) << "AamsTouchGuideTest OnPointerEvent0026 inputEventConsumer is null"; + return; + } + + // eventType + bool ret = + AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { + if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3) == + EventType::TYPE_TOUCH_END) { + return true; + } else { + return false; + } + }), SLEEP_TIME_3); + EXPECT_TRUE(ret); + EXPECT_EQ(static_cast(AccessibilityHelper::GetInstance().GetEventType().size()), 4); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), + EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), + EventType::TYPE_TOUCH_GUIDE_GESTURE_END); + + // gestureId + EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), + static_cast(GestureType::GESTURE_FOUR_FINGER_DOUBLE_TAP)); + + GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent026 ends"; +} + +/** + * @tc.number: OnPointerEvent027 + * @tc.name:OnPointerEvent + * @tc.desc: Check the four finger double tap event and hold. + */ +HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent027, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent027 starts"; + + AccessibilityHelper::GetInstance().GetEventType() = {}; + MMI::MockInputManager::ClearTouchActions(); + + std::vector points = {}; + MMI::PointerEvent::PointerItem point1 = {}; + TouchGuiderPointSet(point1, 0, 100, 100); + MMI::PointerEvent::PointerItem point2 = {}; + TouchGuiderPointSet(point2, 1, 200, 100); + MMI::PointerEvent::PointerItem point3 = {}; + TouchGuiderPointSet(point3, 2, 300, 100); + MMI::PointerEvent::PointerItem point4 = {}; + TouchGuiderPointSet(point4, 3, 400, 100); + std::vector pointVec{point1, point2, point3, point4}; + + bool eventProduceRst = MultiFingerTapEventProduce(points, pointVec, 2, true); + if (!eventProduceRst) { + GTEST_LOG_(INFO) << "AamsTouchGuideTest OnPointerEvent0027 inputEventConsumer is null"; + return; + } + + // eventType + bool ret = + AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { + if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3) == + EventType::TYPE_TOUCH_END) { + return true; + } else { + return false; + } + }), SLEEP_TIME_3); + EXPECT_TRUE(ret); + EXPECT_EQ(static_cast(AccessibilityHelper::GetInstance().GetEventType().size()), 4); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), + EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), + EventType::TYPE_TOUCH_GUIDE_GESTURE_END); + + // gestureId + EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), + static_cast(GestureType::GESTURE_FOUR_FINGER_DOUBLE_TAP_AND_HOLD)); + + GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent027 ends"; +} + +/** + * @tc.number: OnPointerEvent028 + * @tc.name:OnPointerEvent + * @tc.desc: Check the four finger triple tap event. + */ +HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent028, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent028 starts"; + + AccessibilityHelper::GetInstance().GetEventType() = {}; + MMI::MockInputManager::ClearTouchActions(); + + std::vector points = {}; + MMI::PointerEvent::PointerItem point1 = {}; + TouchGuiderPointSet(point1, 0, 100, 100); + MMI::PointerEvent::PointerItem point2 = {}; + TouchGuiderPointSet(point2, 1, 200, 100); + MMI::PointerEvent::PointerItem point3 = {}; + TouchGuiderPointSet(point3, 2, 300, 100); + MMI::PointerEvent::PointerItem point4 = {}; + TouchGuiderPointSet(point4, 3, 400, 100); + std::vector pointVec{point1, point2, point3, point4}; + + bool eventProduceRst = MultiFingerTapEventProduce(points, pointVec, 3, false); + if (!eventProduceRst) { + GTEST_LOG_(INFO) << "AamsTouchGuideTest OnPointerEvent0028 inputEventConsumer is null"; + return; + } + + // eventType + bool ret = + AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { + if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3) == + EventType::TYPE_TOUCH_END) { + return true; + } else { + return false; + } + }), SLEEP_TIME_3); + EXPECT_TRUE(ret); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), + EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), + EventType::TYPE_TOUCH_GUIDE_GESTURE_END); + + // gestureId + EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), + static_cast(GestureType::GESTURE_FOUR_FINGER_TRIPLE_TAP)); + + GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent028 ends"; +} + +/** + * @tc.number: OnPointerEvent029 + * @tc.name:OnPointerEvent + * @tc.desc: Check the four finger tri[le tap event and hold. + */ +HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent029, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent029 starts"; + + AccessibilityHelper::GetInstance().GetEventType() = {}; + MMI::MockInputManager::ClearTouchActions(); + + std::vector points = {}; + MMI::PointerEvent::PointerItem point1 = {}; + TouchGuiderPointSet(point1, 0, 100, 100); + MMI::PointerEvent::PointerItem point2 = {}; + TouchGuiderPointSet(point2, 1, 200, 100); + MMI::PointerEvent::PointerItem point3 = {}; + TouchGuiderPointSet(point3, 2, 300, 100); + MMI::PointerEvent::PointerItem point4 = {}; + TouchGuiderPointSet(point4, 3, 400, 100); + std::vector pointVec{point1, point2, point3, point4}; + + bool eventProduceRst = MultiFingerTapEventProduce(points, pointVec, 3, true); + if (!eventProduceRst) { + GTEST_LOG_(INFO) << "AamsTouchGuideTest OnPointerEvent0029 inputEventConsumer is null"; + return; + } + + // eventType + bool ret = + AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { + if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3) == + EventType::TYPE_TOUCH_END) { + return true; + } else { + return false; + } + }), SLEEP_TIME_3); + EXPECT_TRUE(ret); + EXPECT_EQ(static_cast(AccessibilityHelper::GetInstance().GetEventType().size()), 4); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), + EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), + EventType::TYPE_TOUCH_GUIDE_GESTURE_END); + + // gestureId + EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), + static_cast(GestureType::GESTURE_FOUR_FINGER_TRIPLE_TAP_AND_HOLD)); + + GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent029 ends"; +} + +/** + * @tc.number: OnPointerEvent030 + * @tc.name:OnPointerEvent + * @tc.desc: Check the three finger swipe down. + */ +HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent030, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent030 starts"; + + AccessibilityHelper::GetInstance().GetEventType() = {}; + MMI::MockInputManager::ClearTouchActions(); + + std::vector points = {}; + MMI::PointerEvent::PointerItem point1 = {}; + TouchGuiderPointSet(point1, 0, 100, 100); + MMI::PointerEvent::PointerItem point2 = {}; + TouchGuiderPointSet(point2, 1, 200, 100); + MMI::PointerEvent::PointerItem point3 = {}; + TouchGuiderPointSet(point3, 2, 300, 100); + std::vector pointStartVec{point1, point2, point3}; + + MMI::PointerEvent::PointerItem point11 = {}; + TouchGuiderPointSet(point11, 0, 100, 800); + MMI::PointerEvent::PointerItem point22 = {}; + TouchGuiderPointSet(point22, 1, 200, 800); + MMI::PointerEvent::PointerItem point33 = {}; + TouchGuiderPointSet(point33, 2, 300, 800); + std::vector pointEndVec{point11, point22, point33}; + + bool eventProduceRst = MultiFingerTapAndMoveEventProduce(points, pointStartVec, pointEndVec); + if (!eventProduceRst) { + GTEST_LOG_(INFO) << "AamsTouchGuideTest OnPointerEvent0030 inputEventConsumer is null"; + return; + } + + // eventType + bool ret = + AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { + if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3) == + EventType::TYPE_TOUCH_END) { + return true; + } else { + return false; + } + }), SLEEP_TIME_3); + EXPECT_TRUE(ret); + EXPECT_EQ(static_cast(AccessibilityHelper::GetInstance().GetEventType().size()), 4); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), + EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), + EventType::TYPE_TOUCH_GUIDE_GESTURE_END); + + // gestureId + EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), + static_cast(GestureType::GESTURE_THREE_FINGER_SWIPE_DOWN)); + GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent030 ends"; +} + +/** + * @tc.number: OnPointerEvent031 + * @tc.name:OnPointerEvent + * @tc.desc: Check the four finger swipe down. + */ +HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent031, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent031 starts"; + + AccessibilityHelper::GetInstance().GetEventType() = {}; + MMI::MockInputManager::ClearTouchActions(); + + std::vector points = {}; + MMI::PointerEvent::PointerItem point1 = {}; + TouchGuiderPointSet(point1, 0, 100, 100); + MMI::PointerEvent::PointerItem point2 = {}; + TouchGuiderPointSet(point2, 1, 200, 100); + MMI::PointerEvent::PointerItem point3 = {}; + TouchGuiderPointSet(point3, 2, 300, 100); + MMI::PointerEvent::PointerItem point4 = {}; + TouchGuiderPointSet(point4, 3, 400, 100); + std::vector pointStartVec{point1, point2, point3, point4}; + + MMI::PointerEvent::PointerItem point11 = {}; + TouchGuiderPointSet(point11, 0, 100, 800); + MMI::PointerEvent::PointerItem point22 = {}; + TouchGuiderPointSet(point22, 1, 200, 800); + MMI::PointerEvent::PointerItem point33 = {}; + TouchGuiderPointSet(point33, 2, 300, 800); + MMI::PointerEvent::PointerItem point44 = {}; + TouchGuiderPointSet(point44, 3, 400, 800); + std::vector pointEndVec{point11, point22, point33, point44}; + + bool eventProduceRst = MultiFingerTapAndMoveEventProduce(points, pointStartVec, pointEndVec); + if (!eventProduceRst) { + GTEST_LOG_(INFO) << "AamsTouchGuideTest OnPointerEvent0031 inputEventConsumer is null"; + return; + } + + // eventType + bool ret = + AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { + if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3) == + EventType::TYPE_TOUCH_END) { + return true; + } else { + return false; + } + }), SLEEP_TIME_3); + EXPECT_TRUE(ret); + EXPECT_EQ(static_cast(AccessibilityHelper::GetInstance().GetEventType().size()), 4); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), + EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), + EventType::TYPE_TOUCH_GUIDE_GESTURE_END); + + // gestureId + EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), + static_cast(GestureType::GESTURE_FOUR_FINGER_SWIPE_DOWN)); + GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent031 ends"; +} } // namespace Accessibility } // namespace OHOS \ No newline at end of file -- Gitee