diff --git a/common/interface/test/unittest/BUILD.gn b/common/interface/test/unittest/BUILD.gn index 3a2a072f..84987c64 100644 --- a/common/interface/test/unittest/BUILD.gn +++ b/common/interface/test/unittest/BUILD.gn @@ -60,16 +60,14 @@ ohos_unittest("accessibility_parcel_test") { "../../../../resources/config/build:coverage_flags", ] - deps = [ - "../../../../../../../third_party/googletest:gmock_main", - "../../../../../../../third_party/googletest:gtest_main", - "../../../../interfaces/innerkits/common:accessibility_common", - ] + deps = [ "../../../../interfaces/innerkits/common:accessibility_common" ] external_deps = [ "access_token:libaccesstoken_sdk", "access_token:libtokenid_sdk", "c_utils:utils", + "googletest:gmock_main", + "googletest:gtest_main", "hilog:libhilog", "input:libmmi-client", "ipc:ipc_single", diff --git a/frameworks/aafwk/test/BUILD.gn b/frameworks/aafwk/test/BUILD.gn index 820bf3bb..32b34703 100755 --- a/frameworks/aafwk/test/BUILD.gn +++ b/frameworks/aafwk/test/BUILD.gn @@ -27,7 +27,6 @@ config("module_private_config") { } include_dirs = aams_mock_include_dirs include_dirs += [ - "${ability_runtime_inner_api_path}/ability_manager/include", "../../../common/log/include", "../include", "./mock/include", @@ -73,8 +72,6 @@ ohos_unittest("accessibility_ui_test_ability_impl_test") { ] deps = [ - "../../../../../../third_party/googletest:gmock_main", - "../../../../../../third_party/googletest:gtest_main", "../../../common/interface:accessibility_interface", "../../../interfaces/innerkits/common:accessibility_common", ] @@ -92,6 +89,8 @@ ohos_unittest("accessibility_ui_test_ability_impl_test") { "data_share:datashare_consumer", "eventhandler:libeventhandler", "ffrt:libffrt", + "googletest:gmock_main", + "googletest:gtest_main", "hilog:libhilog", "init:libbeget_proxy", "init:libbegetutil", @@ -161,8 +160,6 @@ ohos_unittest("accessible_ability_test") { ] deps = [ - "../../../../../../third_party/googletest:gmock_main", - "../../../../../../third_party/googletest:gtest_main", "../../../common/interface:accessibility_interface", "../../../interfaces/innerkits/common:accessibility_common", ] @@ -180,6 +177,8 @@ ohos_unittest("accessible_ability_test") { "display_manager:displaymgr", "eventhandler:libeventhandler", "ffrt:libffrt", + "googletest:gmock_main", + "googletest:gtest_main", "graphic_2d:librender_service_client", "hicollie:libhicollie", "hilog:libhilog", diff --git a/frameworks/acfwk/test/BUILD.gn b/frameworks/acfwk/test/BUILD.gn index 9a5ad252..e5be19fc 100644 --- a/frameworks/acfwk/test/BUILD.gn +++ b/frameworks/acfwk/test/BUILD.gn @@ -12,7 +12,6 @@ # limitations under the License. import("//build/test.gni") -import("../../../accessibility_aafwk.gni") module_output_path = "accessibility/accessibility" @@ -25,11 +24,6 @@ config("module_private_config") { } include_dirs = [ - "${ability_base_path}/interfaces/inner_api/base/include", - "${ability_base_path}/interfaces/kits/native/uri/include", - "${ability_base_path}/interfaces/kits/native/want/include", - "${ability_out_base_path}/notification/common_event_service/interfaces/inner_api", - "${ability_json_path}/notification/common_event_service/interfaces/inner_api", "../../../services/interface/include", "../include", "../../../interfaces/innerkits/acfwk/include", @@ -61,8 +55,6 @@ ohos_unittest("ac_unit_test") { ] deps = [ - "../../../../../../third_party/googletest:gmock_main", - "../../../../../../third_party/googletest:gtest_main", "../../../common/interface:accessibility_interface", "../../../interfaces/innerkits/common:accessibility_common", ] @@ -80,6 +72,8 @@ ohos_unittest("ac_unit_test") { "display_manager:displaymgr", "eventhandler:libeventhandler", "ffrt:libffrt", + "googletest:gmock_main", + "googletest:gtest_main", "hilog:libhilog", "init:libbegetutil", "ipc:ipc_core", diff --git a/frameworks/asacfwk/test/BUILD.gn b/frameworks/asacfwk/test/BUILD.gn index c3bcad4b..0139c41f 100644 --- a/frameworks/asacfwk/test/BUILD.gn +++ b/frameworks/asacfwk/test/BUILD.gn @@ -12,7 +12,6 @@ # limitations under the License. import("//build/test.gni") -import("../../../accessibility_aafwk.gni") module_output_path = "accessibility/accessibility" @@ -60,8 +59,6 @@ ohos_unittest("asac_unit_test") { ] deps = [ - "../../../../../../third_party/googletest:gmock_main", - "../../../../../../third_party/googletest:gtest_main", "../../../common/interface:accessibility_interface", "../../../interfaces/innerkits/common:accessibility_common", ] @@ -80,6 +77,8 @@ ohos_unittest("asac_unit_test") { "data_share:datashare_consumer", "eventhandler:libeventhandler", "ffrt:libffrt", + "googletest:gmock_main", + "googletest:gtest_main", "hilog:libhilog", "init:libbegetutil", "ipc:ipc_core", diff --git a/frameworks/common/test/BUILD.gn b/frameworks/common/test/BUILD.gn index 805437d6..c8e75a6b 100644 --- a/frameworks/common/test/BUILD.gn +++ b/frameworks/common/test/BUILD.gn @@ -48,13 +48,13 @@ ohos_unittest("accessibility_common_test") { "../../../resources/config/build:coverage_flags", ] - deps = [ - "../../../../../../third_party/googletest:gmock_main", - "../../../../../../third_party/googletest:gtest_main", - "../../../interfaces/innerkits/common:accessibility_common", - ] + deps = [ "../../../interfaces/innerkits/common:accessibility_common" ] - external_deps = [ "hilog:libhilog" ] + external_deps = [ + "googletest:gmock_main", + "googletest:gtest_main", + "hilog:libhilog", + ] } ############################################################################### diff --git a/interfaces/innerkits/aafwk/BUILD.gn b/interfaces/innerkits/aafwk/BUILD.gn index 46f7f7cb..0ec03527 100644 --- a/interfaces/innerkits/aafwk/BUILD.gn +++ b/interfaces/innerkits/aafwk/BUILD.gn @@ -12,7 +12,6 @@ # limitations under the License. import("//build/ohos.gni") -import("../../../accessibility_aafwk.gni") import("../../../accessibility_manager_service.gni") aafwk_path = "../../../frameworks/aafwk" diff --git a/interfaces/innerkits/common/include/accessibility_def.h b/interfaces/innerkits/common/include/accessibility_def.h index b8493526..dde601f5 100644 --- a/interfaces/innerkits/common/include/accessibility_def.h +++ b/interfaces/innerkits/common/include/accessibility_def.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 Huawei Device Co., Ltd. + * Copyright (C) 2022-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -380,6 +380,7 @@ constexpr int32_t DEFAULT_INT32 = 0; constexpr int32_t CODE_SUCCESS = 0; constexpr int32_t CODE_FAILED = -1; constexpr int32_t CHAE_BUFFER_MAX = 1024; +constexpr int32_t US_TO_MS = 1000; const std::string ERROR_MESSAGE_PARAMETER_ERROR = "Parameter error. Possible causes:" "1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed."; const std::string ERROR_MESSAGE_NO_PERMISSION = "Permission verification failed." diff --git a/interfaces/kits/napi/BUILD.gn b/interfaces/kits/napi/BUILD.gn index 3075b661..83610ffc 100644 --- a/interfaces/kits/napi/BUILD.gn +++ b/interfaces/kits/napi/BUILD.gn @@ -12,7 +12,6 @@ # limitations under the License. import("//build/ohos.gni") -import("../../../accessibility_aafwk.gni") ohos_shared_library("accessibility_napi") { branch_protector_ret = "pac_ret" diff --git a/interfaces/kits/napi/accessibility_extension/BUILD.gn b/interfaces/kits/napi/accessibility_extension/BUILD.gn index 9d47d42f..0e3fdfae 100644 --- a/interfaces/kits/napi/accessibility_extension/BUILD.gn +++ b/interfaces/kits/napi/accessibility_extension/BUILD.gn @@ -12,8 +12,7 @@ # limitations under the License. import("//build/ohos.gni") -import( - "../../../../../../../arkcompiler/ets_frontend/es2panda/es2abc_config.gni") +import("//build/templates/abc/ohos_abc.gni") es2abc_gen_abc("gen_accessibility_extension_abc") { src_js = rebase_path("accessibility_extension.js") diff --git a/interfaces/kits/napi/accessibility_extension_context/BUILD.gn b/interfaces/kits/napi/accessibility_extension_context/BUILD.gn index 81697ca1..bb51ebf0 100644 --- a/interfaces/kits/napi/accessibility_extension_context/BUILD.gn +++ b/interfaces/kits/napi/accessibility_extension_context/BUILD.gn @@ -12,8 +12,7 @@ # limitations under the License. import("//build/ohos.gni") -import( - "../../../../../../../arkcompiler/ets_frontend/es2panda/es2abc_config.gni") +import("//build/templates/abc/ohos_abc.gni") es2abc_gen_abc("gen_accessibility_extension_context_abc") { src_js = rebase_path("accessibility_extension_context.js") diff --git a/services/aams/BUILD.gn b/services/aams/BUILD.gn index 47c239a2..9f338254 100644 --- a/services/aams/BUILD.gn +++ b/services/aams/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (C) 2022 Huawei Device Co., Ltd. +# Copyright (C) 2022-2024 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -55,17 +55,15 @@ accessibleabilityms_files = [ "${services_path}/src/accessibility_window_connection.cpp", "${services_path}/src/accessibility_zoom_gesture.cpp", "${services_path}/src/accessibility_common_event.cpp", - "${services_path}/src/accessibility_touch_guider.cpp", - "${services_path}/src/accessibility_gesture_recognizer.cpp", "${services_path}/src/accessibility_event_transmission.cpp", "${services_path}/src/accessibility_input_interceptor.cpp", - "${services_path}/src/accessibility_touchEvent_injector.cpp", "${services_path}/src/accessibility_keyevent_filter.cpp", "${services_path}/src/accessibility_mouse_autoclick.cpp", - "${services_path}/src/accessibility_multifinger_multitap.cpp", "${services_path}/src/accessibility_mouse_key.cpp", "${services_path}/src/accessibility_screen_touch.cpp", "${services_path}/src/accessibility_short_key.cpp", + "${services_path}/src/accessibility_touchEvent_injector.cpp", + "${services_path}/src/accessibility_touch_exploration.cpp", "${services_path}/src/accessibility_window_manager.cpp", "${services_path}/src/utils.cpp", "${services_path}/src/accessibility_dumper.cpp", diff --git a/services/aams/include/accessibility_gesture_recognizer.h b/services/aams/include/accessibility_gesture_recognizer.h deleted file mode 100644 index 76026769..00000000 --- a/services/aams/include/accessibility_gesture_recognizer.h +++ /dev/null @@ -1,369 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ACCESSIBILITY_GESTURE_RECOGNIZER_H -#define ACCESSIBILITY_GESTURE_RECOGNIZER_H - -#include -#include - -#ifdef OHOS_BUILD_ENABLE_DISPLAY_MANAGER -#include "accessibility_display_manager.h" -#endif -#include "accessibility_event_info.h" -#include "accessible_ability_manager_service.h" -#include "event_handler.h" -#include "event_runner.h" -#include "pointer_event.h" -#include "singleton.h" - -namespace OHOS { -namespace Accessibility { -const int64_t GESTURE_STARTED_TIME_THRESHOLD = 300000; // microsecond -const int64_t GESTURE_NOT_STARTED_TIME_THRESHOLD = 200000; // microsecond -const float DOUBLE_TAP_SLOP = 100.0f; -const int64_t MIN_DOUBLE_TAP_TIME = 40000; // microsecond -const int64_t DOUBLE_TAP_TIMEOUT = 300000; // microsecond -const int64_t LONG_PRESS_TIMEOUT = 300000; // microsecond -const int64_t TAP_INTERVAL_TIMEOUT = 100000; // microsecond -const float DEGREES_THRESHOLD = 0.0f; -const int32_t DIRECTION_NUM = 4; -const int64_t US_TO_MS = 1000; -const int32_t MM_PER_CM = 10; -#define CALCULATION_DIMENSION(xdpi) ((xdpi) * 0.25f) -#define MIN_PIXELS(xyDpi) ((xyDpi) * 0.1f) - -struct Pointer { - float px_; - float py_; -}; - -class AccessibilityGestureRecognizer; -class GestureHandler : public AppExecFwk::EventHandler { -public: - GestureHandler(const std::shared_ptr &runner, AccessibilityGestureRecognizer &server); - virtual ~GestureHandler() = default; - /** - * @brief Process the event of install system bundles. - * @param event Indicates the event to be processed. - */ - virtual void ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event) override; -private: - AccessibilityGestureRecognizer &server_; -}; - -class AccessibilityGestureRecognizeListener { -public: - /** - * @brief A destructor used to delete the listener instance. - */ - virtual ~AccessibilityGestureRecognizeListener() = default; - - /** - * @brief The callback function when lifted the finger on the second tap of a double tap. - * - * @param event the touch event received. - * @return true if the event is consumed, else false - */ - virtual bool OnDoubleTap(MMI::PointerEvent &event); - - /** - * @brief The callback function when recognized an event stream as a gesture. - * @return true if the event is consumed, else false - */ - virtual bool OnStarted(); - - /** - * @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 MultiFingerGestureOnStarted(bool isTwoFingerGesture); - - /** - * @brief The callback function when decided the event stream is a gesture. - * @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 multi finger gesture. - * @param gestureId the recognized gesture ID. - */ - 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. - * @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 multi finger gesture. - * @param isNoDelayFlag whether the gesture recognize process is immediately canceled. - */ - virtual void MultiFingerGestureOnCancelled(const bool isNoDelayFlag); -}; - -class AccessibilityGestureRecognizer : public AppExecFwk::EventHandler { -public: - static constexpr uint32_t LONG_PRESS_MSG = 1; - static constexpr uint32_t SINGLE_TAP_MSG = 2; - - /** - * @brief A constructor used to create a accessibilityGestureRecognizer instance. - */ - AccessibilityGestureRecognizer(); - - /** - * @brief A destructor used to delete the accessibilityGestureRecognizer instance. - */ - ~AccessibilityGestureRecognizer() {} - - /** - * @brief Register GestureRecognizeListener. - * @param listener the listener from touchguide - */ - void RegisterListener(AccessibilityGestureRecognizeListener& listener); - - /** - * @brief Register GestureRecognizeListener. - * @param listener the listener from touchguide - */ - void UnregisterListener(); - - /** - * @brief Determine whether a single tap has occurred. - * @return true if a single tap has occurred, else false. - */ - bool IsfirstTap() - { - return isFirstTapUp_; - } - - /** - * @brief Determine whether a double tap has occurred. - * @return true if a double tap has occurred, else false. - */ - bool GetIsDoubleTap() - { - return isDoubleTap_; - } - - /** - * @brief Determine whether a longpress has occurred. - * @return true if longpress has occurred, else false. - */ - bool GetIsLongpress() - { - return isLongpress_; - } - - /** - * @brief Handle a touch event. If an action is completed, the appropriate callback is called. - * - * @param event the touch event to be handled. - * @param rawEvent The raw touch event. - * @return true if the gesture be recognized, else false - */ - bool OnPointerEvent(MMI::PointerEvent &event); - - /** - * @brief Clear state. - */ - void Clear(); - - /** - * @brief Judge whether the double click and long press gesture is recognized. - * @param event the touch event from touchguide - */ - void MaybeRecognizeLongPress(MMI::PointerEvent &event); - - /** - * @brief If a single tap completed. - */ - void SingleTapDetected(); - - /** - * @brief Set isLongpress_ flag; - * @param value set isLongpress_ flag - */ - void SetIsLongpress (bool value) - { - isLongpress_ = value; - } - - /** - * @brief Get pCurDown_ ptr. - */ - std::shared_ptr GetCurDown() - { - return pCurDown_; - } - - /** - * @brief Get continueDown_ flag. - */ - bool GetContinueDown() - { - return continueDown_; - } - -private: - /** - * @brief Recognize the standard gesture. - * @param event the touch event from touchguide - * @return true if the standard gesture be recognized, else false - */ - bool StandardGestureRecognizer(MMI::PointerEvent &event); - - /** - * @brief A double tap has occurred, call OnDoubleTap callback. - * @param event the touch event from touchguide - * @return true if the DoubleTap be recognized, else false - */ - bool DoubleTapRecognized(MMI::PointerEvent &event); - - /** - * @brief Recognize gestures based on the sequence of motions. - * @param event the touch event from touchguide - * @return true if the Direction be recognized, else false - */ - bool recognizeDirectionGesture(MMI::PointerEvent &event); - - /** - * @brief Handle the down event from touchguide. - * @param event the touch event from touchguide - */ - void HandleTouchDownEvent(MMI::PointerEvent &event); - - /** - * @brief Handle the move event from touchguide. - * @param event the touch event from touchguide - */ - bool HandleTouchMoveEvent(MMI::PointerEvent &event); - - /** - * @brief Handle the up event from touchguide. - * @param event the touch event from touchguide - */ - bool HandleTouchUpEvent(MMI::PointerEvent &event); - - /** - * @brief Check if it's double tap. - * @param event the touch event from touchguide - * @return true if it's double tap, else false - */ - bool isDoubleTap(MMI::PointerEvent &event); - - /** - * @brief Cancel the gesture. - */ - void StandardGestureCanceled(); - - /** - * @brief Add position to pointer route. - * @param pointerIterm the touch item from touchguide - */ - void AddSwipePosition(MMI::PointerEvent::PointerItem &pointerIterm); - - /** - * @brief Calculate the move threshold for the double tap gesture. - * @param densityDpi the physical density - */ - float GetDoubleTapMoveThreshold(float densityDpi); - - /** - * @brief Get pointer path. - * @param route all pointer route - * @return the vector of PointerPath - */ - std::vector GetPointerPath(std::vector &route); - - /** - * @brief Get swipe direction. - * @param firstP the start point - * @param secondP the endpoint - * @return the type of swipe direction - */ - int32_t GetSwipeDirection(Pointer firstP, Pointer secondP); - - static constexpr int32_t SWIPE_UP = 0; - static constexpr int32_t SWIPE_DOWN = 1; - static constexpr int32_t SWIPE_LEFT = 2; - static constexpr int32_t SWIPE_RIGHT = 3; - - static constexpr GestureType GESTURE_DIRECTION[DIRECTION_NUM] = { - GestureType::GESTURE_SWIPE_UP, - GestureType::GESTURE_SWIPE_DOWN, - GestureType::GESTURE_SWIPE_LEFT, - GestureType::GESTURE_SWIPE_RIGHT - }; - - static constexpr GestureType GESTURE_DIRECTION_TO_ID[DIRECTION_NUM][DIRECTION_NUM] = { - { - GestureType::GESTURE_SWIPE_UP, - GestureType::GESTURE_SWIPE_UP_THEN_DOWN, - GestureType::GESTURE_SWIPE_UP_THEN_LEFT, - GestureType::GESTURE_SWIPE_UP_THEN_RIGHT, - }, - { - GestureType::GESTURE_SWIPE_DOWN_THEN_UP, - GestureType::GESTURE_SWIPE_DOWN, - GestureType::GESTURE_SWIPE_DOWN_THEN_LEFT, - GestureType::GESTURE_SWIPE_DOWN_THEN_RIGHT, - - }, - { - GestureType::GESTURE_SWIPE_LEFT_THEN_UP, - GestureType::GESTURE_SWIPE_LEFT_THEN_DOWN, - GestureType::GESTURE_SWIPE_LEFT, - GestureType::GESTURE_SWIPE_LEFT_THEN_RIGHT, - - }, - { - GestureType::GESTURE_SWIPE_RIGHT_THEN_UP, - GestureType::GESTURE_SWIPE_RIGHT_THEN_DOWN, - GestureType::GESTURE_SWIPE_RIGHT_THEN_LEFT, - GestureType::GESTURE_SWIPE_RIGHT - } - }; - - bool continueDown_ = false; - bool isLongpress_ = false; - bool isDoubleTapdetecting_ = false; - bool isTapDown_ = false; - bool isFirstTapUp_ = false; - bool isDoubleTap_ = false; - bool isRecognizingGesture_ = false; - bool isGestureStarted_ = false; - int64_t startTime_ = 0; // microsecond - float xMinPixels_ = 0; - float yMinPixels_ = 0; - float threshold_ = 0; - int32_t doubleTapScaledSlop_ = 0; - MMI::PointerEvent::PointerItem prePointer_ = {}; - MMI::PointerEvent::PointerItem startPointer_ = {}; - std::vector pointerRoute_ {}; - AccessibilityGestureRecognizeListener *listener_ = nullptr; - std::unique_ptr pPreUp_ = nullptr; - std::shared_ptr pCurDown_ = nullptr; - std::shared_ptr handler_ = nullptr; - std::shared_ptr runner_ = nullptr; -}; -} // namespace Accessibility -} // namespace OHOS -#endif // ACCESSIBILITY_GESTURE_RECOGNIZER_H \ No newline at end of file diff --git a/services/aams/include/accessibility_multifinger_multitap.h b/services/aams/include/accessibility_multifinger_multitap.h deleted file mode 100644 index 83eb16fe..00000000 --- a/services/aams/include/accessibility_multifinger_multitap.h +++ /dev/null @@ -1,448 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ACCESSIBILITY_MULTIFINGER_MULTITAP_H -#define ACCESSIBILITY_MULTIFINGER_MULTITAP_H - -#include -#include - -#include "accessibility_gesture_recognizer.h" -#ifdef OHOS_BUILD_ENABLE_DISPLAY_MANAGER -#include "accessibility_display_manager.h" -#endif -#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" -#include "singleton.h" - -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, - ALL_FINGER_TOUCH_UP = 1, - TOUCH_DOWN_AFTER_ALL_FINGER_TOUCH_UP = 2, -}; - -enum MultiFingerGestureState : int32_t { - GESTURE_NOT_START = 0, - GESTURE_START = 1, - GESTURE_CANCLE = 2, - GESTURE_COMPLETE = 3, - GESTURE_WAIT = 4, -}; - -class AccessibilityMultiTapGestureRecognizer; -class MultiFingerGestureHandler : public AppExecFwk::EventHandler { -public: - MultiFingerGestureHandler(const std::shared_ptr &runner, - AccessibilityMultiTapGestureRecognizer &server); - virtual ~MultiFingerGestureHandler() = default; - /** - * @brief Process the event of install system bundles. - * @param event Indicates the event to be processed. - */ - virtual void ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event) override; -private: - /** - * @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 IsTapGesture(const GestureType gestureType); - - AccessibilityMultiTapGestureRecognizer &server_; -}; - -class AccessibilityMultiTapGestureRecognizer : public AppExecFwk::EventHandler { -public: - static constexpr uint32_t TWO_FINGER_SINGLE_TAP_MSG = 3; - 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_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; - - /** - * @brief Register GestureRecognizeListener. - * @param listener the listener from touchguide. - */ - void RegisterListener(AccessibilityGestureRecognizeListener &listener); - - /** - * @brief Get the GestureRecognizeListener. - * @return AccessibilityGestureRecognizeListener ptr. - */ - AccessibilityGestureRecognizeListener *GetRecognizeListener() const - { - return listener_; - } - - /** - * @brief Handle a touch event. If an action is completed, the appropriate callback is called. - * - * @param event the touch event to be handled. - */ - void OnPointerEvent(MMI::PointerEvent &event); - - /** - * @brief Cancle multi finger gesture rocognize state, buffer etc. - */ - void Clear(); - - /** - * @brief Get the target fingers number touch down in first round. - * @return the finger numbers touch down in first round. - */ - int32_t GetTargetFingers() const - { - return targetFingers_; - } - - /** - * @brief Get finger touch up state. - * @return the touch up state, indicates if fingers is still on the screen. - */ - int32_t GetFingerTouchUpState() const - { - return fingerTouchUpState_; - } - - /** - * @brief Set the finger touch up state when touch up or finish touch down. - * @param touchUpState the touchUpState to be set. - */ - void SetFingerTouchUpState(const int32_t touchUpState) - { - fingerTouchUpState_ = touchUpState; - } - - /** - * @brief Set multi finger gesture state, when gesture recognize start, cancel, complete etc. - * @param gestureState the multiFingerGestureState to be set. - */ - void SetMultiFingerGestureState(const int32_t gestureState) - { - multiFingerGestureState_ = gestureState; - } - - /** - * @brief Determine whether multi finger gesture is started. - * @return true if gesture recognize is started, else false. - */ - bool IsMultiFingerGestureStarted() const - { - return multiFingerGestureState_ == MultiFingerGestureState::GESTURE_START; - } - - /** - * @brief Determine whether multi finger gesture is started or finished. - * @return true if gesture recognize is started or finished, else false. - */ - bool IsMultiFingerRecognize() const - { - return (multiFingerGestureState_ == MultiFingerGestureState::GESTURE_START || - multiFingerGestureState_ == MultiFingerGestureState::GESTURE_COMPLETE); - } - - /** - * @brief Get the two finger move threshold. - * @return the two finger move threshold, indicates tap state to move state. - */ - float GetTouchSlop() const - { - return touchSlop_; - } -private: - /** - * @brief Cancle the pendding two finger gesture recognize event. - */ - 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. - */ - void CancelAllPenddingEvent(); - - /** - * @brief Cancel the multi gesture recognize process. - * @param isNoDelayFlag if gesture cancel event is immediately processed. - */ - void CancelGesture(const bool isNoDelayFlag); - - /** - * @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(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 multi finger double tap gesture. - * @param event the touch event from Multimodal. - * @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. - */ - 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. - * @param event the touch event to be handled. - */ - void HanleFirstTouchDownEvent(MMI::PointerEvent &event); - - /** - * @brief Handle the continue touch down event. - * @param event the touch event to be handled. - */ - void HandleContinueTouchDownEvent(MMI::PointerEvent &event); - - /** - * @brief Handle the multi finger touch move event. - * @param event the touch event to be handled. - */ - void HandleMultiFingerMoveEvent(MMI::PointerEvent &event); - - /** - * @brief Handle the touch up event, not a move gesture. - * @param event the touch event to be handled. - */ - 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 - 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 - std::shared_ptr runner_ = nullptr; -}; -} // namespace Accessibility -} // namespace OHOS -#endif // ACCESSIBILITY_MULTIFINGER_MULTITAP_H \ No newline at end of file diff --git a/services/aams/include/accessibility_screen_touch.h b/services/aams/include/accessibility_screen_touch.h index 49575ec3..88466ddb 100644 --- a/services/aams/include/accessibility_screen_touch.h +++ b/services/aams/include/accessibility_screen_touch.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Huawei Device Co., Ltd. + * Copyright (C) 2023-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -20,7 +20,8 @@ #include #include #include "accessibility_event_transmission.h" -#include "accessibility_gesture_recognizer.h" +#include "event_handler.h" +#include "event_runner.h" namespace OHOS { namespace Accessibility { @@ -123,4 +124,4 @@ private: }; } // namespace Accessibility } // namespace OHOS -#endif // ACCESSIBILITY_TOUCH_GUIDER_H \ No newline at end of file +#endif // ACCESSIBILITY_SCREEN_TOUCH_H \ No newline at end of file diff --git a/services/aams/include/accessibility_touch_exploration.h b/services/aams/include/accessibility_touch_exploration.h new file mode 100644 index 00000000..2898bdfe --- /dev/null +++ b/services/aams/include/accessibility_touch_exploration.h @@ -0,0 +1,388 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ACCESSIBILITY_TOUCH_EXPLORATION_H +#define ACCESSIBILITY_TOUCH_EXPLORATION_H + +#include +#include +#include +#include +#include +#include "accessibility_element_info.h" +#include "accessibility_element_operator_callback_stub.h" +#include "accessibility_event_transmission.h" +#include "accessible_ability_manager_service.h" +#include "accessibility_def.h" +#include "event_handler.h" + +namespace OHOS { +namespace Accessibility { +class TouchExploration; + +const int32_t POINTER_COUNT_1 = 1; +const int32_t POINTER_COUNT_2 = 2; +const int32_t POINTER_COUNT_3 = 3; +const int32_t POINTER_COUNT_4 = 4; +const uint32_t MAX_MULTI_FINGER_TYPE = 3; +const int32_t LIMIT_SIZE_TWO = 2; +const int32_t LIMIT_SIZE_THREE = 3; +const int32_t DIRECTION_NUM = 4; +const int32_t TAP_COUNT_MAXIMUM = 3; +const int64_t LONG_PRESS_TIMEOUT = 200000; // microsecond +const int64_t DOUBLE_TAP_TIMEOUT = 300000; // microsecond +const int64_t MULTI_FINGER_TAP_INTERVAL_TIMEOUT = 100000; // microsecond +const int64_t SWIPE_COMPLETE_TIMEOUT = 300000; // microsecond +const int32_t MINI_POINTER_DISTANCE_DIP = 200; +const float DEGREES_THRESHOLD = 0.0f; +const uint32_t MIN_MULTI_FINGER_SWIPE_POINTER_NUM = 2; +const float TOUCH_SLOP = 8.0f; +const float MULTI_TAP_SLOP = 100.0f; +const float MULTI_TAP_SLOP_DELTA = 0.5f; +const int32_t SCREEN_AXIS_NUM = 2; +const double MAX_DRAG_GESTURE_COSINE = 0.525321989; +const int32_t MM_PER_CM = 10; +const double EPSINON = 0.01; +const float PIXEL_MULTIPLIER = 0.1f; +const int32_t DIVIDE_NUM = 2; +#define BIND(func) [this](MMI::PointerEvent& event) { (func(event)); } + +/** + * @brief touch exploration state define + */ +enum class TouchExplorationState : int32_t { + TOUCH_INIT, + PASSING_THROUGH, + INVALID, + + ONE_FINGER_DOWN, + ONE_FINGER_LONG_PRESS, + ONE_FINGER_SWIPE, + ONE_FINGER_SINGLE_TAP, + ONE_FINGER_SINGLE_TAP_THEN_DOWN, + + TWO_FINGERS_DOWN, + TWO_FINGERS_DRAG, + TWO_FINGERS_TAP, + TWO_FINGERS_CONTINUE_DOWN, + TWO_FINGERS_UNKNOWN, + + THREE_FINGERS_DOWN, + THREE_FINGERS_SWIPE, + THREE_FINGERS_TAP, + THREE_FINGERS_CONTINUE_DOWN, + + FOUR_FINGERS_DOWN, + FOUR_FINGERS_SWIPE, + FOUR_FINGERS_TAP, + FOUR_FINGERS_CONTINUE_DOWN +}; + +enum class ChangeAction : int32_t { + NO_CHANGE, + HOVER_MOVE, + POINTER_DOWN, + POINTER_UP, + HOVER_ENTER, + HOVER_EXIT, + HOVER_CANCEL +}; + +struct Pointer { + float px_; + float py_; +}; + +class TouchExplorationEventHandler : public AppExecFwk::EventHandler { +public: + TouchExplorationEventHandler(const std::shared_ptr &runner, + TouchExploration &tgServer); + virtual ~TouchExplorationEventHandler() = default; + /** + * @brief Process the event of install system bundles. + * @param event Indicates the event to be processed. + */ + virtual void ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event) override; + +private: + TouchExploration &server_; +}; + +class TouchExploration : public EventTransmission { +public: + static constexpr uint32_t SEND_HOVER_MSG = 0; + static constexpr uint32_t LONG_PRESS_MSG = 1; + static constexpr uint32_t DOUBLE_TAP_MSG = 2; + static constexpr uint32_t SWIPE_COMPLETE_TIMEOUT_MSG = 3; + static constexpr uint32_t TWO_FINGER_SINGLE_TAP_MSG = 4; + static constexpr uint32_t TWO_FINGER_LONG_PRESS_MSG = 5; + static constexpr uint32_t TWO_FINGER_DOUBLE_TAP_MSG = 6; + static constexpr uint32_t TWO_FINGER_DOUBLE_TAP_AND_HOLD_MSG = 7; + static constexpr uint32_t TWO_FINGER_TRIPLE_TAP_MSG = 8; + static constexpr uint32_t TWO_FINGER_TRIPLE_TAP_AND_HOLD_MSG = 9; + static constexpr uint32_t THREE_FINGER_SINGLE_TAP_MSG = 10; + static constexpr uint32_t THREE_FINGER_LONG_PRESS_MSG = 11; + static constexpr uint32_t THREE_FINGER_DOUBLE_TAP_MSG = 12; + static constexpr uint32_t THREE_FINGER_DOUBLE_TAP_AND_HOLD_MSG = 13; + static constexpr uint32_t THREE_FINGER_TRIPLE_TAP_MSG = 14; + static constexpr uint32_t THREE_FINGER_TRIPLE_TAP_AND_HOLD_MSG = 15; + static constexpr uint32_t FOUR_FINGER_SINGLE_TAP_MSG = 16; + static constexpr uint32_t FOUR_FINGER_LONG_PRESS_MSG = 17; + static constexpr uint32_t FOUR_FINGER_DOUBLE_TAP_MSG = 18; + static constexpr uint32_t FOUR_FINGER_DOUBLE_TAP_AND_HOLD_MSG = 19; + static constexpr uint32_t FOUR_FINGER_TRIPLE_TAP_MSG = 20; + static constexpr uint32_t FOUR_FINGER_TRIPLE_TAP_AND_HOLD_MSG = 21; + static constexpr uint32_t WAIT_ANOTHER_FINGER_DOWN_MSG = 22; + + static constexpr int32_t SWIPE_UP = 0; + static constexpr int32_t SWIPE_DOWN = 1; + static constexpr int32_t SWIPE_LEFT = 2; + static constexpr int32_t SWIPE_RIGHT = 3; + + static constexpr GestureType GESTURE_DIRECTION[DIRECTION_NUM] = { + GestureType::GESTURE_SWIPE_UP, + GestureType::GESTURE_SWIPE_DOWN, + GestureType::GESTURE_SWIPE_LEFT, + GestureType::GESTURE_SWIPE_RIGHT + }; + + static constexpr GestureType GESTURE_DIRECTION_TO_ID[DIRECTION_NUM][DIRECTION_NUM] = { + { + GestureType::GESTURE_SWIPE_UP, + GestureType::GESTURE_SWIPE_UP_THEN_DOWN, + GestureType::GESTURE_SWIPE_UP_THEN_LEFT, + GestureType::GESTURE_SWIPE_UP_THEN_RIGHT, + }, + { + GestureType::GESTURE_SWIPE_DOWN_THEN_UP, + GestureType::GESTURE_SWIPE_DOWN, + GestureType::GESTURE_SWIPE_DOWN_THEN_LEFT, + GestureType::GESTURE_SWIPE_DOWN_THEN_RIGHT, + + }, + { + GestureType::GESTURE_SWIPE_LEFT_THEN_UP, + GestureType::GESTURE_SWIPE_LEFT_THEN_DOWN, + GestureType::GESTURE_SWIPE_LEFT, + GestureType::GESTURE_SWIPE_LEFT_THEN_RIGHT, + + }, + { + GestureType::GESTURE_SWIPE_RIGHT_THEN_UP, + GestureType::GESTURE_SWIPE_RIGHT_THEN_DOWN, + GestureType::GESTURE_SWIPE_RIGHT_THEN_LEFT, + GestureType::GESTURE_SWIPE_RIGHT + } + }; + + static constexpr uint32_t GESTURE_TAP_MSG[TAP_COUNT_MAXIMUM][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[TAP_COUNT_MAXIMUM][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, + } + }; + + TouchExploration(); + ~TouchExploration() {} + void StartUp(); + + void Clear(); + void HoverEventRunner(); + void SendAccessibilityEventToAA(EventType eventType); + void SendTouchEventToAA(MMI::PointerEvent &event); + void SendGestureEventToAA(GestureType gestureId); + void SendEventToMultimodal(MMI::PointerEvent &event, ChangeAction action); + void SendScreenWakeUpEvent(MMI::PointerEvent &event); + void SendUpForDraggingDownEvent(); + void ProcessMultiFingerGesture(uint32_t eventId); + void CancelPostEvent(uint32_t innerEventID); + void CancelMultiFingerTapEvent(); + void CancelMultiFingerTapAndHoldEvent(); + + /** + * @brief Handle pointer events from previous event stream node. + * + * @param event the pointer event to be handled. + * @return true: the event has been processed and does not need to be passed to the next node; + * false: the event is not processed. + */ + bool OnPointerEvent(MMI::PointerEvent &event) override; + + /* Set current state */ + inline void SetCurrentState(TouchExplorationState state) + { + currentState_ = state; + } + + /* Get current state */ + inline TouchExplorationState GetCurrentState() + { + return currentState_; + } + +private: + // Processing Functions in the State Machine + void HandleInitStateDown(MMI::PointerEvent &event); + void HandleInitStateUp(MMI::PointerEvent &event); + void HandleInitStateMove(MMI::PointerEvent &event); + void HandlePassingThroughState(MMI::PointerEvent &event); + void HandleInvalidState(MMI::PointerEvent &event); + void HandleOneFingerDownStateDown(MMI::PointerEvent &event); + void HandleOneFingerDownStateUp(MMI::PointerEvent &event); + void HandleOneFingerDownStateMove(MMI::PointerEvent &event); + void HandleOneFingerLongPressStateDown(MMI::PointerEvent &event); + void HandleOneFingerLongPressStateUp(MMI::PointerEvent &event); + void HandleOneFingerLongPressStateMove(MMI::PointerEvent &event); + void HandleOneFingerSwipeStateDown(MMI::PointerEvent &event); + void HandleOneFingerSwipeStateUp(MMI::PointerEvent &event); + void HandleOneFingerSwipeStateMove(MMI::PointerEvent &event); + void HandleOneFingerSingleTapStateDown(MMI::PointerEvent &event); + void HandleOneFingerSingleTapThenDownStateDown(MMI::PointerEvent &event); + void HandleOneFingerSingleTapThenDownStateUp(MMI::PointerEvent &event); + void HandleOneFingerSingleTapThenDownStateMove(MMI::PointerEvent &event); + void HandleTwoFingersDownStateDown(MMI::PointerEvent &event); + void HandleTwoFingersDownStateUp(MMI::PointerEvent &event); + void HandleTwoFingersDownStateMove(MMI::PointerEvent &event); + void HandleTwoFingersDragStateDown(MMI::PointerEvent &event); + void HandleTwoFingersDragStateUp(MMI::PointerEvent &event); + void HandleTwoFingersDragStateMove(MMI::PointerEvent &event); + void HandleTwoFingersTapStateDown(MMI::PointerEvent &event); + void HandleMultiFingersTapStateUp(MMI::PointerEvent &event); + void HandleTwoFingersTapStateMove(MMI::PointerEvent &event); + void HandleMultiFingersContinueDownStateDown(MMI::PointerEvent &event); + void HandleTwoFingersContinueDownStateUp(MMI::PointerEvent &event); + void HandleTwoFingersContinueDownStateMove(MMI::PointerEvent &event); + void HandleTwoFingersUnknownStateDown(MMI::PointerEvent &event); + void HandleTwoFingersUnknownStateUp(MMI::PointerEvent &event); + void HandleTwoFingersUnknownStateMove(MMI::PointerEvent &event); + void HandleThreeFingersDownStateDown(MMI::PointerEvent &event); + void HandleThreeFingersDownStateUp(MMI::PointerEvent &event); + void HandleThreeFingersDownStateMove(MMI::PointerEvent &event); + void HandleThreeFingersSwipeStateDown(MMI::PointerEvent &event); + void HandleThreeFingersSwipeStateUp(MMI::PointerEvent &event); + void HandleThreeFingersSwipeStateMove(MMI::PointerEvent &event); + void HandleThreeFingersTapStateDown(MMI::PointerEvent &event); + void HandleThreeFingersTapStateMove(MMI::PointerEvent &event); + void HandleThreeFingersContinueDownStateUp(MMI::PointerEvent &event); + void HandleThreeFingersContinueDownStateMove(MMI::PointerEvent &event); + void HandleFourFingersDownStateDown(MMI::PointerEvent &event); + void HandleFourFingersDownStateUp(MMI::PointerEvent &event); + void HandleFourFingersDownStateMove(MMI::PointerEvent &event); + void HandleFourFingersSwipeStateDown(MMI::PointerEvent &event); + void HandleFourFingersSwipeStateUp(MMI::PointerEvent &event); + void HandleFourFingersSwipeStateMove(MMI::PointerEvent &event); + void HandleFourFingersTapStateDown(MMI::PointerEvent &event); + void HandleFourFingersTapStateMove(MMI::PointerEvent &event); + void HandleFourFingersContinueDownStateUp(MMI::PointerEvent &event); + void HandleFourFingersContinueDownStateMove(MMI::PointerEvent &event); + void HandleCancelEvent(MMI::PointerEvent &event); + + void InitOneFingerGestureFuncMap(); + void InitTwoFingerGestureFuncMap(); + void InitThreeFingerGestureFuncMap(); + void InitFourFingerGestureFuncMap(); + void HandlePointerEvent(MMI::PointerEvent &event); + void AddOneFingerSwipeEvent(MMI::PointerEvent &event); + std::vector GetOneFingerSwipePath(); + int32_t GetSwipeDirection(const int32_t dx, const int32_t dy); + void RecordFocusedLocation(MMI::PointerEvent &event); + void OffsetEvent(MMI::PointerEvent &event); + bool GetBasePointItem(MMI::PointerEvent::PointerItem &basePointerIterm, int32_t pId); + void GetPointOffset(MMI::PointerEvent &event, std::vector &firstPointOffset, + std::vector &secondPointOffset); + float GetAngleCos(float offsetX, float offsetY, bool isGetX); + bool IsDragGestureAccept(MMI::PointerEvent &event); + void SendDragDownEventToMultimodal(MMI::PointerEvent event); + bool GetPointerItemWithFingerNum(int32_t fingerNum, std::vector &curPoints, + std::vector &prePoints, MMI::PointerEvent &event); + bool IsMultiFingerMultiTap(MMI::PointerEvent &event, const int32_t fingerNum); + bool IsMultiFingerMultiTapGesture(MMI::PointerEvent &event, const int32_t fingerNum); + void HandleMultiFingersTapStateDown(MMI::PointerEvent &event, int32_t fingerNum); + void HandleMultiFingersTapStateMove(MMI::PointerEvent &event, int32_t fingerNum); + void HandleMultiFingersContinueDownStateUp(MMI::PointerEvent &event, int32_t fingerNum); + void HandleMultiFingersContinueDownStateMove(MMI::PointerEvent &event, int32_t fingerNum); + void StoreMultiFingerSwipeBaseDownPoint(); + bool GetMultiFingerSwipeBasePointerItem(MMI::PointerEvent::PointerItem &basePointerIterm, int32_t pId); + bool SaveMultiFingerSwipeGesturePointerInfo(MMI::PointerEvent &event); + bool RecognizeMultiFingerSwipePath(const std::vector &path); + GestureType GetMultiFingerSwipeGestureId(int32_t fingerNum); + void HandleMultiFingersSwipeStateUp(MMI::PointerEvent &event, int32_t fingerNum); + std::map GetMultiFingerMsgToGestureMap(); + + inline float CalculateMoveThreshold(int dpi) + { + return dpi * (1.0f / 25.4f) * MM_PER_CM; + } + + std::shared_ptr handler_ = nullptr; + std::shared_ptr runner_ = nullptr; + using HandleEventFunc = std::function; + std::map> handleEventFuncMap_ = {}; + + TouchExplorationState currentState_ = TouchExplorationState::TOUCH_INIT; + std::list receivedPointerEvents_ {}; + std::list injectedPointerDownEvents_ {}; + + // single-finger gesture + int32_t offsetX_ = 0; + int32_t offsetY_ = 0; + float moveThreshold_ = 0; + float xMinPixels_ = 0; + float yMinPixels_ = 0; + std::vector oneFingerSwipeRoute_ {}; + MMI::PointerEvent::PointerItem oneFingerSwipePrePointer_ {}; + + // multi-finger gesture + int32_t draggingPid_ = -1; + int32_t multiTapNum_ = 0; + int32_t multiTapOffsetThresh_ = 0; + int32_t multiFingerSwipeDirection_ = -1; + float mMinPixelsBetweenSamplesX_ = 0; + float mMinPixelsBetweenSamplesY_ = 0; + std::map> multiFingerSwipeRoute_ {}; + std::map> multiFingerSwipePrePoint_ {}; +}; +} // namespace Accessibility +} // namespace OHOS +#endif // ACCESSIBILITY_TOUCH_EXPLORATION_H \ No newline at end of file diff --git a/services/aams/include/accessibility_touch_guider.h b/services/aams/include/accessibility_touch_guider.h deleted file mode 100644 index 795342df..00000000 --- a/services/aams/include/accessibility_touch_guider.h +++ /dev/null @@ -1,532 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ACCESSIBILITY_TOUCH_GUIDER_H -#define ACCESSIBILITY_TOUCH_GUIDER_H - -#include -#include "accessibility_element_info.h" -#include "accessibility_element_operator_callback_stub.h" -#include "accessibility_event_transmission.h" -#include "accessibility_gesture_recognizer.h" -#include "accessibility_multifinger_multitap.h" -#include "accessible_ability_manager_service.h" - -namespace OHOS { -namespace Accessibility { -class TouchGuider; - -const int64_t EXIT_GESTURE_REC_TIMEOUT = 400; // millisecond -const double MAX_DRAG_GESTURE_COSINE = 0.525321989; -const int32_t MINI_POINTER_DISTANCE_DIP = 200; -const int32_t INDEX_0 = 0; -const int32_t INDEX_1 = 1; -const int32_t INIT_POINT_ID = -1; -const float INIT_MMIPOINT = 0.0f; -const int32_t INIT_POINT_DISPLAY = 0; -#define DIVIDE_2(num) ((num) / 2) -#define EPSINON 0.01 - -/** - * @brief touch Guider state define - */ -enum class TouchGuideState : int32_t { - TOUCH_GUIDING, - DRAGGING, - TRANSMITTING, - GESTURE_RECOGNIZING, - PASSING_THROUGH -}; - -/** - * @brief Click location define - */ -enum ClickLocation : int32_t { - CLICK_NONE, - CLICK_ACCESSIBILITY_FOCUS, - CLICK_LAST_TOUCH_GUIDE -}; - -/** - * @brief struct to record injected pointers. - */ -struct InjectedEventRecorder { - std::set downPointers {}; - int32_t downPointerNum; - int64_t lastDownTime; - std::shared_ptr lastHoverEvent; -}; - -/** - * @brief struct to record received pointers. - */ -struct ReceivedEventRecorder { - std::map pointerDownX; - std::map pointerDownY; - std::map pointerActionTime; - std::shared_ptr lastEvent; -}; - -enum ChangeAction : int32_t { - NO_CHANGE, - HOVER_MOVE, - POINTER_DOWN, - POINTER_UP, - POINTER_MOVE, - HOVER_ENTER, - HOVER_EXIT, -}; - -class TGEventHandler : public AppExecFwk::EventHandler { -public: - TGEventHandler(const std::shared_ptr &runner, - TouchGuider &tgServer); - virtual ~TGEventHandler() = default; - /** - * @brief Process the event of install system bundles. - * @param event Indicates the event to be processed. - */ - virtual void ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event) override; - -private: - /** - * @brief Send HoverEnter and HoverMove to Multimodal. - */ - void HoverEnterAndMoveRunner(); - - /** - * @brief Send HoverExit to Multimodal. - */ - void HoverExitRunner(); - TouchGuider &tgServer_; -}; - -class TouchGuider : public EventTransmission { -public: - static constexpr uint32_t EXIT_GESTURE_REC_MSG = 0; - static constexpr uint32_t SEND_HOVER_ENTER_MOVE_MSG = 1; - static constexpr uint32_t SEND_HOVER_EXIT_MSG = 2; - static constexpr uint32_t SEND_TOUCH_INTERACTION_END_MSG = 3; - static constexpr uint32_t SEND_TOUCH_GUIDE_END_MSG = 4; - - /** - * @brief A constructor used to create a touchGuide instance. - */ - TouchGuider(); - - /** - * @brief A destructor used to delete the touchGuide instance. - */ - ~TouchGuider() {} - - /** - * @brief TouchGuide start up. - */ - void StartUp(); - - /** - * @brief Handle pointer events from previous event stream node. - * - * @param event the pointer event to be handled. - * @return true: the event has been processed and does not need to be passed to the next node; - * false: the event is not processed. - */ - bool OnPointerEvent(MMI::PointerEvent &event) override; - - /** - * @brief Handle pointer events from previous event stream node. - * - * @param event the pointer event to be handled. - */ - void HandlePointerEvent(MMI::PointerEvent &event); - - /** - * @brief Destroy event state. - */ - void DestroyEvents() override; - - /** - * @brief Send pointer down event to multimodal input. - * @param event event the touch event from Multimodal, set the down point to the event and send. - * @param action point action send to multimode. - */ - void SendPointerDownEventToMultimodal(MMI::PointerEvent event, int32_t action); - - /** - * @brief Send event to multimodal input. - * @param event the event prepared to send to Multimodal - * @param action the action of the event - */ - void SendEventToMultimodal(MMI::PointerEvent &event, int32_t action); - - /** - * @brief Send accessibility event to specific AccessibleAbility. - * @param eventType the type of the event - */ - void SendAccessibilityEventToAA(EventType eventType); - - /** - * @brief Send gesture event to specific AccessibleAbility. - * @param gestureId the gesture id of the event - */ - void SendGestureEventToAA(GestureType gestureId); - - /** - * @brief Get hover enter and move event. - * @return Returns pointerEvents_ list. - */ - std::list getHoverEnterAndMoveEvent(); - - /** - * @brief Clear hover enter and move event. - */ - void ClearHoverEnterAndMoveEvent(); - - /** - * @brief Get last received event. - * @return Returns last event ptr. - */ - std::shared_ptr getLastReceivedEvent(); - - /* For TouchGuide */ - inline void OnTouchInteractionStart() - { - isTouchStart_ = true; - } - - inline void OnTouchInteractionEnd() - { - isTouchStart_ = false; - } - - /** - * @brief whether touch guide end. - * @return true if touch guide end, else false. - */ - inline bool IsTouchInteractionEnd() - { - return isTouchStart_ == false; - } - - /** - * @brief Perform action on Accessibility Focus. - * @param action the action of Accessibility node. - * @return Returns true if the action perform successfully; returns false code otherwise. - */ - bool ExecuteActionOnAccessibilityFocused(const ActionType &action); - - static int64_t lastDoubleTapTime; -private: - class TouchGuideListener : public AccessibilityGestureRecognizeListener { - public: - /** - * @brief A constructor used to create a TouchGuideListener instance. - */ - explicit TouchGuideListener(TouchGuider &server) : server_(server) {}; - - /** - * @brief Prepare to send the event corresponding to the single tap to the Multimodal. - * @param event the touch event from Multimodal - */ - bool OnDoubleTap(MMI::PointerEvent &event) override; - - /** - * @brief Send GESTURE_BEGIN to AccessibleAbility. - */ - bool OnStarted() override; - - /** - * @brief Send GESTURE_BEGIN to AccessibleAbility when multi finger gesture start. - * @param isTwoFingerGesture whether the gesture is triggered by two finger. - */ - void MultiFingerGestureOnStarted(bool isTwoFingerGesture) override; - - /** - * @brief Send GESTURE_END and TOUCH_END to AccessibleAbility. - * @param gestureId the id of gesture - */ - bool OnCompleted(GestureType gestureId) override; - - /** - * @brief Send GESTURE_END and TOUCH_END to AccessibleAbility when multi finger gesture complete. - * @param gestureId the id of gesture. - */ - void MultiFingerGestureOnCompleted(GestureType gestureId) override; - - /** - * @brief The gesture has been cancelled. - * @param event the touch event from Multimodal - */ - bool OnCancelled(MMI::PointerEvent &event) override; - - /** - * @brief The gesture has been cancelled. - * @param isNoDelayFlag whether the gesture recognize process is immediately canceled. - */ - void MultiFingerGestureOnCancelled(const bool isNoDelayFlag) override; - private: - TouchGuider &server_; - }; - - class ElementOperatorCallbackImpl : public AccessibilityElementOperatorCallbackStub { - public: - ElementOperatorCallbackImpl() = default; - ~ElementOperatorCallbackImpl() = default; - - virtual void SetSearchElementInfoByAccessibilityIdResult(const std::vector &infos, - const int32_t requestId) override; - virtual void SetSearchElementInfoByTextResult(const std::vector &infos, - const int32_t requestId) override; - virtual void SetFindFocusedElementInfoResult(const AccessibilityElementInfo &info, - const int32_t requestId) override; - virtual void SetFocusMoveSearchResult(const AccessibilityElementInfo &info, const int32_t requestId) override; - virtual void SetExecuteActionResult(const bool succeeded, const int32_t requestId) override; - - private: - ffrt::promise promise_; - bool executeActionResult_ = false; - AccessibilityElementInfo accessibilityInfoResult_ = {}; - std::vector elementInfosResult_; - - friend class TouchGuider; - }; - - /** - * @brief Determine whether to clear the touchguide. - */ - void Clear(); - - /** - * @brief clear the touchguide. - * @param event the last event from Multimodal - */ - void Clear(MMI::PointerEvent &event); - - /** - * @brief Handle touch events on touchExploring state. - * @param event the touch event from Multimodal - */ - void HandleTouchGuidingState(MMI::PointerEvent &event); - - /** - * @brief Handle touch events on dragging state. - * @param event the touch event from Multimodal - */ - void HandleDraggingState(MMI::PointerEvent &event); - - /** - * @brief Handle touch events on transmitting state. - * @param event the touch event from Multimodal - */ - void HandleTransmitingState(MMI::PointerEvent &event); - - /** - * @brief Handle touch events on passing through state. - * @param event the touch event from Multimodal - */ - void HandlePassingThroughState(MMI::PointerEvent &event); - - /** - * @brief Determine whether it is a drag gesture. - * @param event the touch event from Multimodal - * @return whether the dragGesture is accepted. - */ - bool IsDragGestureAccept(MMI::PointerEvent &event); - - /** - * @brief Get the offset of current points and touch down points. - * @param event the current touch event from Multimodal. - * @param firstPointOffset the first finger offset result, xAxis offset and yAxis offset. - * @param firstPointOffset the second finger offset result, xAxis offset and yAxis offset. - */ - void GetPointOffset(MMI::PointerEvent &event, std::vector &firstPointOffset, - std::vector &secondPointOffset) const; - - /** - * @brief Determine whether it is a move gesture. - * @param event the touch event from Multimodal. - * @return whether this is a scolling. - */ - bool IsRealMoveState(MMI::PointerEvent &event) const; - - /** - * @brief Get Angle Cos value. - * @param offsetX the X value - * @param offsetY the Y value - * @param isGetX whether is the Angle corresponding to the X axis - * @return Angle Cos value. - */ - float GetAngleCos(float offsetX, float offsetY, bool isGetX); - - /** - * @brief Get the info of injected event. - * @param event the event prepared to send to Multimodal - */ - void RecordInjectedEvent(MMI::PointerEvent &event); - - /** - * @brief Get the info of Received event. - * @param event event the touch event from Multimodal - */ - void RecordReceivedEvent(MMI::PointerEvent &event); - - /** - * @brief Send touch event to specific AccessibleAbility. - * @param event the touch event from Multimodal - */ - void SendTouchEventToAA(MMI::PointerEvent &event); - - /** - * @brief Clear received recorder info. - */ - void ClearReceivedEventRecorder(); - - /** - * @brief Clear Injected recorder info. - */ - void ClearInjectedEventRecorder(); - - /** - * @brief Send exit event to multimodal. - */ - void SendExitEvents(); - - /** - * @brief Send all down events to multimodal. - * @param event the event prepared to send to Multimodal - */ - void SendAllDownEvents(MMI::PointerEvent &event); - - /** - * @brief Send all up events to multimodal. - * @param event the event prepared to send to Multimodal - */ - void SendAllUpEvents(MMI::PointerEvent &event); - - /** - * @brief Send all up events to multimodal. - * @param event the event prepared to send to Multimodal - */ - void SendUpForAllInjectedEvent(MMI::PointerEvent &event); - - /** - * @brief Send exit message. - */ - void PostGestureRecognizeExit(); - - /** - * @brief Send enter and move message. - * @param event event the touch event from Multimodal - */ - void PostHoverEnterAndMove(MMI::PointerEvent &event); - - /** - * @brief Send exit message. - */ - void PostHoverExit(); - - /** - * @brief Send accessibility event message. - * @param innerEventID the id of inner event - */ - void PostAccessibilityEvent(uint32_t innerEventID); - - /** - * @brief Cancel message. - * @param innerEventID the id of inner event - */ - void CancelPostEvent(uint32_t innerEventID); - - /** - * @brief Cancel message if it has been sent. - * @param innerEventID the id of inner event - */ - void CancelPostEventIfNeed(uint32_t innerEventID); - - /** - * @brief Check whether it has been sending. - * @param innerEventID the id of inner event - */ - bool HasEventPending(uint32_t innerEventID); - - /** - * @brief Force send and remove event. - * @param innerEventID the id of inner event - * @param event event the touch event from Multimodal - */ - void ForceSendAndRemoveEvent(uint32_t innerEventID, MMI::PointerEvent &event); - - /** - * @brief Handle down events on touchExploring state. - * @param event event the touch event from Multimodal - */ - void HandleTouchGuidingStateInnerDown(MMI::PointerEvent &event); - - /** - * @brief Handle move events on touchExploring state. - * @param event event the touch event from Multimodal - */ - void HandleTouchGuidingStateInnerMove(MMI::PointerEvent &event); - - /** - * @brief Handle move events on dragging state. - * @param event event the touch event from Multimodal - */ - void HandleDraggingStateInnerMove(MMI::PointerEvent &event); - - /** - * @brief Ignore repeat execute action. - */ - bool IgnoreRepeatExecuteAction(); - - /** - * @brief Calculate Offset. - * @param event event the touch event from Multimodal - */ - void OffsetEvent(MMI::PointerEvent &event); - - /** - * @brief Find Focused Element. - * @param elementInfo the focused element. - * @return Returns true if find focused flement successfully; returns false code otherwise. - */ - bool FindFocusedElement(AccessibilityElementInfo &elementInfo); - - int32_t currentState_ = -1; - int32_t longPressPointId_ = INIT_POINT_ID; - float longPressOffsetX_ = INIT_MMIPOINT; - float longPressOffsetY_ = INIT_MMIPOINT; - bool isTouchStart_ = false; - bool isTouchGuiding_ = false; - ReceivedEventRecorder receivedRecorder_ = {}; - InjectedEventRecorder injectedRecorder_ = {}; - std::list pointerEvents_ {}; - AccessibilityGestureRecognizer gestureRecognizer_; - AccessibilityMultiTapGestureRecognizer multiFingerGestureRecognizer_; - std::unique_ptr touchGuideListener_ = nullptr; - std::shared_ptr handler_ = nullptr; - std::shared_ptr runner_ = nullptr; - std::shared_ptr doubleTapLongPressDownEvent_ = nullptr; - bool focusedElementExist_ = false; - int32_t leftTopX_ = INIT_POINT_DISPLAY; - int32_t leftTopY_ = INIT_POINT_DISPLAY; - int32_t rightBottomX_ = INIT_POINT_DISPLAY; - int32_t rightBottomY_ = INIT_POINT_DISPLAY; - int32_t currentPid_ = -1; - std::list cachedPointerEvents_ {}; -}; -} // namespace Accessibility -} // namespace OHOS -#endif // ACCESSIBILITY_TOUCH_GUIDER_H \ No newline at end of file diff --git a/services/aams/src/accessibility_gesture_recognizer.cpp b/services/aams/src/accessibility_gesture_recognizer.cpp deleted file mode 100755 index 634dba13..00000000 --- a/services/aams/src/accessibility_gesture_recognizer.cpp +++ /dev/null @@ -1,480 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed On an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "accessibility_gesture_recognizer.h" -#include "hilog_wrapper.h" -#include - -namespace OHOS { -namespace Accessibility { -namespace { - constexpr int32_t LIMIT_SIZE_TWO = 2; - constexpr int32_t LIMIT_SIZE_THREE = 3; - constexpr int32_t POINTER_COUNT_1 = 1; - constexpr float EPSINON = 0.0001f; - constexpr float TOUCH_SLOP = 8.0f; -} // namespace - -GestureHandler::GestureHandler(const std::shared_ptr &runner, - AccessibilityGestureRecognizer &server) : AppExecFwk::EventHandler(runner), server_(server) -{ -} - -void GestureHandler::ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event) -{ - HILOG_DEBUG(); - if (!event) { - HILOG_ERROR("event is null"); - return; - } - - switch (event->GetInnerEventId()) { - case AccessibilityGestureRecognizer::LONG_PRESS_MSG: - RemoveEvent(AccessibilityGestureRecognizer::SINGLE_TAP_MSG); - server_.SetIsLongpress(true); - server_.MaybeRecognizeLongPress(*server_.GetCurDown()); - break; - case AccessibilityGestureRecognizer::SINGLE_TAP_MSG: - if (!server_.GetContinueDown()) { - server_.SingleTapDetected(); - } - break; - default: - break; - } -} - -float AccessibilityGestureRecognizer::GetDoubleTapMoveThreshold(float densityDpi) -{ - return densityDpi * (1.0f / 25.4f) * MM_PER_CM; -} - -AccessibilityGestureRecognizer::AccessibilityGestureRecognizer() -{ - HILOG_DEBUG(); -#ifdef OHOS_BUILD_ENABLE_DISPLAY_MANAGER - AccessibilityDisplayManager &displayMgr = Singleton::GetInstance(); - auto display = displayMgr.GetDefaultDisplay(); - if (!display) { - HILOG_ERROR("get display is nullptr"); - return; - } - - threshold_ = GetDoubleTapMoveThreshold(display->GetDpi()); - xMinPixels_ = MIN_PIXELS(display->GetWidth()); - yMinPixels_ = MIN_PIXELS(display->GetHeight()); - - float densityPixels = display->GetVirtualPixelRatio(); - int32_t slop = static_cast(densityPixels * DOUBLE_TAP_SLOP + 0.5f); - doubleTapScaledSlop_ = slop * slop; -#else - HILOG_DEBUG("not support display manager"); - threshold_ = 1; - xMinPixels_ = 1; - yMinPixels_ = 1; - int32_t slop = static_cast(1 * DOUBLE_TAP_SLOP + 0.5f); - doubleTapScaledSlop_ = slop * slop; -#endif - - runner_ = Singleton::GetInstance().GetMainRunner(); - if (!runner_) { - HILOG_ERROR("get runner failed"); - return; - } - handler_ = std::make_shared(runner_, *this); - if (!handler_) { - HILOG_ERROR("create event handler failed"); - return; - } -} - -void AccessibilityGestureRecognizer::RegisterListener(AccessibilityGestureRecognizeListener& listener) -{ - HILOG_DEBUG(); - - listener_ = &listener; -} - -void AccessibilityGestureRecognizer::UnregisterListener() -{ - HILOG_DEBUG(); - - listener_ = nullptr; -} - -bool AccessibilityGestureRecognizer::OnPointerEvent(MMI::PointerEvent &event) -{ - HILOG_DEBUG(); - - switch (event.GetPointerAction()) { - case MMI::PointerEvent::POINTER_ACTION_DOWN: - if (isDoubleTap_ && isLongpress_) { - HILOG_INFO("isDoubleTap and longpress, on down event"); - return false; - } - if (event.GetPointerIds().size() == POINTER_COUNT_1) { - HandleTouchDownEvent(event); - } else { - Clear(); - isRecognizingGesture_ = false; - isGestureStarted_ = false; - pointerRoute_.clear(); - } - break; - case MMI::PointerEvent::POINTER_ACTION_MOVE: - if (isDoubleTap_ && isLongpress_) { - HILOG_DEBUG("isDoubleTap and isLongpress, send move event to Multimodel."); - return false; - } - return HandleTouchMoveEvent(event); - case MMI::PointerEvent::POINTER_ACTION_UP: - if (event.GetPointerIds().size() == POINTER_COUNT_1) { - return HandleTouchUpEvent(event); - } - break; - case MMI::PointerEvent::POINTER_ACTION_CANCEL: - Clear(); - break; - default: - break; - } - if (!isRecognizingGesture_) { - return false; - } - return StandardGestureRecognizer(event); -} - -void AccessibilityGestureRecognizer::Clear() -{ - HILOG_DEBUG(); - - isFirstTapUp_ = false; - isDoubleTap_ = false; - isGestureStarted_ = false; - isRecognizingGesture_ = false; - pointerRoute_.clear(); - continueDown_ = false; - StandardGestureCanceled(); -} - -void AccessibilityGestureRecognizer::HandleTouchDownEvent(MMI::PointerEvent &event) -{ - HILOG_DEBUG(); - - Pointer mp; - MMI::PointerEvent::PointerItem pointerIterm; - if (!event.GetPointerItem(event.GetPointerId(), pointerIterm)) { - HILOG_WARN("get GetPointerItem(%{public}d) failed", event.GetPointerId()); - } - mp.px_ = static_cast(pointerIterm.GetDisplayX()); - mp.py_ = static_cast(pointerIterm.GetDisplayY()); - isDoubleTap_ = false; - isRecognizingGesture_ = true; - isGestureStarted_ = false; - pointerRoute_.clear(); - pointerRoute_.push_back(mp); - prePointer_ = pointerIterm; - startPointer_ = pointerIterm; - startTime_ = event.GetActionTime(); -} - -void AccessibilityGestureRecognizer::AddSwipePosition(MMI::PointerEvent::PointerItem &pointerIterm) -{ - HILOG_DEBUG(); - - Pointer mp; - prePointer_ = pointerIterm; - mp.px_ = pointerIterm.GetDisplayX(); - mp.py_ = pointerIterm.GetDisplayY(); - pointerRoute_.push_back(mp); -} - -bool AccessibilityGestureRecognizer::HandleTouchMoveEvent(MMI::PointerEvent &event) -{ - HILOG_DEBUG(); - - MMI::PointerEvent::PointerItem pointerIterm; - if (!event.GetPointerItem(event.GetPointerId(), pointerIterm)) { - HILOG_ERROR("get GetPointerItem(%{public}d) failed", event.GetPointerId()); - return false; - } - int64_t eventTime = event.GetActionTime(); - float offsetX = startPointer_.GetDisplayX() - pointerIterm.GetDisplayX(); - float offsetY = startPointer_.GetDisplayY() - pointerIterm.GetDisplayY(); - double duration = hypot(offsetX, offsetY); - if (isRecognizingGesture_) { - if (isDoubleTap_ && duration > TOUCH_SLOP) { - HILOG_DEBUG("Cancel double tap event because the finger moves beyond preset slop."); - isRecognizingGesture_ = false; - isDoubleTap_ = false; - return listener_->OnCancelled(event); - } else if (duration > threshold_) { - startPointer_ = pointerIterm; - startTime_ = eventTime; - isFirstTapUp_ = false; - isDoubleTap_ = false; - if (!isGestureStarted_) { - isGestureStarted_ = true; - listener_->OnStarted(); - return false; - } - } else if (!isFirstTapUp_) { - int64_t durationTime = eventTime - startTime_; - int64_t thresholdTime = isGestureStarted_ ? - GESTURE_STARTED_TIME_THRESHOLD : GESTURE_NOT_STARTED_TIME_THRESHOLD; - if (durationTime > thresholdTime) { - isRecognizingGesture_ = false; - isGestureStarted_ = false; - pointerRoute_.clear(); - return listener_->OnCancelled(event); - } - } - if ((abs(pointerIterm.GetDisplayX() - prePointer_.GetDisplayX())) >= xMinPixels_ || - (abs(pointerIterm.GetDisplayY() - prePointer_.GetDisplayY())) >= yMinPixels_) { - AddSwipePosition(pointerIterm); - } - } - if (!isRecognizingGesture_) { - return false; - } - - return StandardGestureRecognizer(event); -} - -bool AccessibilityGestureRecognizer::HandleTouchUpEvent(MMI::PointerEvent &event) -{ - HILOG_DEBUG(); - - Pointer mp; - MMI::PointerEvent::PointerItem pointerIterm; - if (!event.GetPointerItem(event.GetPointerId(), pointerIterm)) { - HILOG_WARN("get GetPointerItem(%{public}d) failed", event.GetPointerId()); - } - - if (isDoubleTap_) { - if (isLongpress_) { - HILOG_DEBUG("up event, isDoubleTap and longpress."); - return false; - } else { - HILOG_DEBUG(); - return DoubleTapRecognized(event); - } - } - if (isGestureStarted_) { - if ((abs(pointerIterm.GetDisplayX() - prePointer_.GetDisplayX())) >= xMinPixels_ || - (abs(pointerIterm.GetDisplayY() - prePointer_.GetDisplayY())) >= yMinPixels_) { - HILOG_DEBUG("Add position to pointer route."); - mp.px_ = pointerIterm.GetDisplayX(); - mp.py_ = pointerIterm.GetDisplayY(); - pointerRoute_.push_back(mp); - } - return recognizeDirectionGesture(event); - } - if (!isRecognizingGesture_) { - return false; - } - return StandardGestureRecognizer(event); -} - -bool AccessibilityGestureRecognizer::StandardGestureRecognizer(MMI::PointerEvent &event) -{ - HILOG_DEBUG(); - - switch (event.GetPointerAction()) { - case MMI::PointerEvent::POINTER_ACTION_DOWN: - if (event.GetPointerIds().size() == POINTER_COUNT_1) { - if (pCurDown_ && pPreUp_ && isDoubleTap(event)) { - HILOG_DEBUG("Double tap is recognized"); - isDoubleTapdetecting_ = true; - isDoubleTap_ = true; - } else { - handler_->SendEvent(SINGLE_TAP_MSG, 0, DOUBLE_TAP_TIMEOUT / US_TO_MS); - } - pCurDown_ = std::make_shared(event); - isTapDown_ = true; - continueDown_ = true; - isLongpress_ = false; - handler_->RemoveEvent(LONG_PRESS_MSG); - handler_->SendEvent(LONG_PRESS_MSG, 0, LONG_PRESS_TIMEOUT / US_TO_MS); - } else { - StandardGestureCanceled(); - } - break; - case MMI::PointerEvent::POINTER_ACTION_UP: - if (event.GetPointerIds().size() == POINTER_COUNT_1) { - continueDown_ = false; - if (isLongpress_) { - handler_->RemoveEvent(SINGLE_TAP_MSG); - isLongpress_ = false; - } else if (!isDoubleTapdetecting_ && isTapDown_) { - isFirstTapUp_ = true; - } - pPreUp_ = std::make_unique(event); - isDoubleTapdetecting_ = false; - handler_->RemoveEvent(LONG_PRESS_MSG); - } - break; - default: - break; - } - return false; -} - -void AccessibilityGestureRecognizer::StandardGestureCanceled() -{ - HILOG_DEBUG(); - - handler_->RemoveEvent(LONG_PRESS_MSG); - handler_->RemoveEvent(SINGLE_TAP_MSG); - isLongpress_ = false; - isDoubleTapdetecting_ = false; - isTapDown_ = false; - isDoubleTap_ = false; -} - -void AccessibilityGestureRecognizer::SingleTapDetected() -{ - HILOG_DEBUG(); - - Clear(); -} - -void AccessibilityGestureRecognizer::MaybeRecognizeLongPress(MMI::PointerEvent &event) -{ - HILOG_DEBUG(); -} - -bool AccessibilityGestureRecognizer::DoubleTapRecognized(MMI::PointerEvent &event) -{ - HILOG_DEBUG(); - - Clear(); - return listener_->OnDoubleTap(event); -} - -bool AccessibilityGestureRecognizer::recognizeDirectionGesture(MMI::PointerEvent &event) -{ - HILOG_DEBUG(); - if (!listener_) { - HILOG_ERROR("listener_ is nullptr."); - return false; - } - - if (pointerRoute_.size() < LIMIT_SIZE_TWO) { - return listener_->OnCancelled(event); - } - - // Check the angle of the most recent motion vector versus the preceding motion vector, - // segment the line if the angle is about 90 degrees. - std::vector pointerPath = GetPointerPath(pointerRoute_); - - if (pointerPath.size() == LIMIT_SIZE_TWO) { - int32_t swipeDirection = GetSwipeDirection(pointerPath[0], pointerPath[1]); - return listener_->OnCompleted(GESTURE_DIRECTION[swipeDirection]); - } else if (pointerPath.size() == LIMIT_SIZE_THREE) { - int32_t swipeDirectionH = GetSwipeDirection(pointerPath[0], pointerPath[1]); - int32_t swipeDirectionHV = GetSwipeDirection(pointerPath[1], pointerPath[2]); - return listener_->OnCompleted(GESTURE_DIRECTION_TO_ID[swipeDirectionH][swipeDirectionHV]); - } - return listener_->OnCancelled(event); -} - -int32_t AccessibilityGestureRecognizer::GetSwipeDirection(Pointer firstP, Pointer secondP) -{ - float offsetX = secondP.px_ - firstP.px_; - float offsetY = secondP.py_ - firstP.py_; - if (abs(offsetX) > abs(offsetY)) { - return offsetX > EPSINON ? SWIPE_RIGHT : SWIPE_LEFT; - } else { - return offsetY < EPSINON ? SWIPE_UP : SWIPE_DOWN; - } -} - -std::vector AccessibilityGestureRecognizer::GetPointerPath(std::vector &route) -{ - HILOG_DEBUG(); - - std::vector pointerPath; - Pointer firstSeparation = route[0]; - Pointer nextPoint; - Pointer newSeparation; - float xUnitVector = 0; - float yUnitVector = 0; - float xVector = 0; - float yVector = 0; - float vectorLength = 0; - int32_t numSinceFirstSep = 0; - - pointerPath.push_back(firstSeparation); - for (size_t i = 1; i < route.size(); i++) { - nextPoint = route[i]; - if (numSinceFirstSep > 0) { - xVector = xUnitVector / numSinceFirstSep; - yVector = yUnitVector / numSinceFirstSep; - newSeparation.px_ = vectorLength * xVector + firstSeparation.px_; - newSeparation.py_ = vectorLength * yVector + firstSeparation.py_; - - float xNextUnitVector = nextPoint.px_ - newSeparation.px_; - float yNextUnitVector = nextPoint.py_ - newSeparation.py_; - float nextVectorLength = hypot(xNextUnitVector, yNextUnitVector); - if (nextVectorLength > EPSINON) { - xNextUnitVector /= nextVectorLength; - yNextUnitVector /= nextVectorLength; - } - - if ((xVector * xNextUnitVector + yVector * yNextUnitVector) < DEGREES_THRESHOLD) { - pointerPath.push_back(newSeparation); - firstSeparation = newSeparation; - xUnitVector = 0; - yUnitVector = 0; - numSinceFirstSep = 0; - } - } - xVector = nextPoint.px_ - firstSeparation.px_; - yVector = nextPoint.py_ - firstSeparation.py_; - vectorLength = hypot(xVector, yVector); - numSinceFirstSep += 1; - if (vectorLength > EPSINON) { - xUnitVector += xVector / vectorLength; - yUnitVector += yVector / vectorLength; - } - } - pointerPath.push_back(nextPoint); - return pointerPath; -} - -bool AccessibilityGestureRecognizer::isDoubleTap(MMI::PointerEvent &event) -{ - HILOG_DEBUG(); - int64_t durationTime = event.GetActionTime() - pPreUp_->GetActionTime(); - if (!(durationTime <= DOUBLE_TAP_TIMEOUT)) { - HILOG_WARN("durationTime[%{public}" PRId64 "] is wrong", durationTime); - return false; - } - - MMI::PointerEvent::PointerItem curPI; - if (!event.GetPointerItem(event.GetPointerId(), curPI)) { - HILOG_WARN("get GetPointerItem(%{public}d) failed", event.GetPointerId()); - } - - MMI::PointerEvent::PointerItem firstPI; - pCurDown_->GetPointerItem(pCurDown_->GetPointerId(), firstPI); - int32_t durationX = firstPI.GetDisplayX() - curPI.GetDisplayX(); - int32_t durationY = firstPI.GetDisplayY() - curPI.GetDisplayY(); - - return (durationX * durationX + durationY * durationY < doubleTapScaledSlop_); -} -} // namespace Accessibility -} // namespace OHOS diff --git a/services/aams/src/accessibility_input_interceptor.cpp b/services/aams/src/accessibility_input_interceptor.cpp index 7bb62a00..d9ad3309 100644 --- a/services/aams/src/accessibility_input_interceptor.cpp +++ b/services/aams/src/accessibility_input_interceptor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 Huawei Device Co., Ltd. + * Copyright (C) 2022-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -18,7 +18,7 @@ #include "accessibility_mouse_autoclick.h" #include "accessibility_short_key.h" #include "accessibility_screen_touch.h" -#include "accessibility_touch_guider.h" +#include "accessibility_touch_exploration.h" #include "accessibility_touchEvent_injector.h" #include "accessibility_zoom_gesture.h" #include "accessible_ability_manager_service.h" @@ -79,8 +79,14 @@ bool AccessibilityInputInterceptor::OnKeyEvent(MMI::KeyEvent &event) bool AccessibilityInputInterceptor::OnPointerEvent(MMI::PointerEvent &event) { - HILOG_DEBUG("PointerAction:%{public}d, SourceType:%{public}d, PointerId:%{public}d", - event.GetPointerAction(), event.GetSourceType(), event.GetPointerId()); + if (event.GetPointerAction() != MMI::PointerEvent::POINTER_ACTION_MOVE && + event.GetPointerAction() != MMI::PointerEvent::POINTER_ACTION_HOVER_MOVE) { + HILOG_INFO("PointerAction:%{public}d, SourceType:%{public}d, PointerId:%{public}d", + event.GetPointerAction(), event.GetSourceType(), event.GetPointerId()); + } else { + HILOG_DEBUG("PointerAction:%{public}d, SourceType:%{public}d, PointerId:%{public}d", + event.GetPointerAction(), event.GetSourceType(), event.GetPointerId()); + } event.AddFlag(MMI::InputEvent::EVENT_FLAG_NO_INTERCEPT); std::shared_ptr pointerEvent = std::make_shared(event); @@ -180,13 +186,13 @@ void AccessibilityInputInterceptor::CreatePointerEventTransmitters() } if (availableFunctions_& FEATURE_TOUCH_EXPLORATION) { - sptr touchGuider = new(std::nothrow) TouchGuider(); - if (!touchGuider) { - HILOG_ERROR("touchGuider is null"); + sptr touchExploration = new(std::nothrow) TouchExploration(); + if (!touchExploration) { + HILOG_ERROR("touchExploration is null"); return; } - touchGuider->StartUp(); - SetNextEventTransmitter(header, current, touchGuider); + touchExploration->StartUp(); + SetNextEventTransmitter(header, current, touchExploration); } if ((availableFunctions_ & FEATURE_SCREEN_TOUCH) && ((availableFunctions_ & FEATURE_TOUCH_EXPLORATION) == 0)) { @@ -385,8 +391,14 @@ void AccessibilityInputEventConsumer::OnInputEvent(std::shared_ptrGetPointerAction(), pointerEvent->GetSourceType(), pointerEvent->GetPointerId()); + + if (pointerEvent->GetPointerAction() != MMI::PointerEvent::POINTER_ACTION_MOVE) { + HILOG_INFO("PointerAction:%{public}d, SourceType:%{public}d, PointerId:%{public}d.", + pointerEvent->GetPointerAction(), pointerEvent->GetSourceType(), pointerEvent->GetPointerId()); + } else { + HILOG_DEBUG("PointerAction:%{public}d, SourceType:%{public}d, PointerId:%{public}d.", + pointerEvent->GetPointerAction(), pointerEvent->GetSourceType(), pointerEvent->GetPointerId()); + } auto interceptor = AccessibilityInputInterceptor::GetInstance(); if (!interceptor) { diff --git a/services/aams/src/accessibility_multifinger_multitap.cpp b/services/aams/src/accessibility_multifinger_multitap.cpp deleted file mode 100644 index 8854f3d0..00000000 --- a/services/aams/src/accessibility_multifinger_multitap.cpp +++ /dev/null @@ -1,881 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed On an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include "accessibility_multifinger_multitap.h" -#include "hilog_wrapper.h" -#include - -namespace OHOS { -namespace Accessibility { -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_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, - AccessibilityMultiTapGestureRecognizer &server) : AppExecFwk::EventHandler(runner), server_(server) -{ -} - -bool MultiFingerGestureHandler::IsTapGesture(const GestureType gestureType) -{ - 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; - } - - return true; -} - -void MultiFingerGestureHandler::ProcessMultiFingerGestureTypeEvent(const GestureType gestureType) -{ - HILOG_DEBUG("gesture id: %{public}d", static_cast(gestureType)); - - if (IsTapGesture(gestureType)) { - if (server_.GetFingerTouchUpState() == FingerTouchUpState::ALL_FINGER_TOUCH_UP) { - server_.GetRecognizeListener()->MultiFingerGestureOnCompleted(gestureType); - server_.SetMultiFingerGestureState(MultiFingerGestureState::GESTURE_COMPLETE); - server_.Clear(); - } - } else { - if (server_.GetFingerTouchUpState() != FingerTouchUpState::NOT_ALL_FINGER_TOUCH_UP) { - if (gestureType != GestureType::GESTURE_INVALID) { - server_.GetRecognizeListener()->MultiFingerGestureOnCompleted(gestureType); - } - server_.SetMultiFingerGestureState(MultiFingerGestureState::GESTURE_COMPLETE); - } - server_.Clear(); - } -} - -bool MultiFingerGestureHandler::ProcessMultiFingerGestureEvent(const AppExecFwk::InnerEvent::Pointer &event) -{ - HILOG_DEBUG("Inner Event Id id: %{public}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; -} - -void MultiFingerGestureHandler::ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event) -{ - HILOG_DEBUG(); - - if (!event) { - HILOG_ERROR("event is null"); - return; - } - - if (ProcessMultiFingerGestureEvent(event)) { - return; - } - - switch (event->GetInnerEventId()) { - case AccessibilityMultiTapGestureRecognizer::WAIT_ANOTHER_FINGER_DOWN_MSG: - server_.SetFingerTouchUpState(FingerTouchUpState::NOT_ALL_FINGER_TOUCH_UP); - break; - case AccessibilityMultiTapGestureRecognizer::CANCEL_WAIT_FINGER_DOWN_MSG: - server_.SetMultiFingerGestureState(MultiFingerGestureState::GESTURE_NOT_START); - break; - case AccessibilityMultiTapGestureRecognizer::CANCEL_GESTURE: - if (server_.GetFingerTouchUpState() != FingerTouchUpState::ALL_FINGER_TOUCH_UP) { - server_.SetFingerTouchUpState(FingerTouchUpState::NOT_ALL_FINGER_TOUCH_UP); - } - server_.GetRecognizeListener()->MultiFingerGestureOnCancelled(true); - server_.SetMultiFingerGestureState(MultiFingerGestureState::GESTURE_CANCLE); - server_.Clear(); - break; - default: - break; - } -} - -AccessibilityMultiTapGestureRecognizer::AccessibilityMultiTapGestureRecognizer() -{ - HILOG_DEBUG(); - -#ifdef OHOS_BUILD_ENABLE_DISPLAY_MANAGER - AccessibilityDisplayManager &displayMgr = Singleton::GetInstance(); - auto display = displayMgr.GetDefaultDisplay(); - if (!display) { - HILOG_ERROR("get display is nullptr"); - return; - } - - float density = display->GetVirtualPixelRatio(); - int32_t slop = static_cast(density * DOUBLE_TAP_SLOP + SLOP_DELTA); - doubleTapOffsetThresh_ = slop; - touchSlop_ = TOUCH_SLOP; - mMinPixelsBetweenSamplesX_ = MIN_PIXELS(display->GetWidth()); - mMinPixelsBetweenSamplesY_ = MIN_PIXELS(display->GetHeight()); -#else - HILOG_DEBUG("not support display manager"); - doubleTapOffsetThresh_ = static_cast(1 * DOUBLE_TAP_SLOP + SLOP_DELTA); - touchSlop_ = TOUCH_SLOP; - mMinPixelsBetweenSamplesX_ = 1; - mMinPixelsBetweenSamplesY_ = 1; -#endif - - runner_ = Singleton::GetInstance().GetMainRunner(); - if (!runner_) { - HILOG_ERROR("get runner failed"); - return; - } - - handler_ = std::make_shared(runner_, *this); - if (!handler_) { - HILOG_ERROR("create event handler failed"); - return; - } -} - -void AccessibilityMultiTapGestureRecognizer::RegisterListener(AccessibilityGestureRecognizeListener& listener) -{ - HILOG_DEBUG(); - - listener_ = &listener; -} - -void AccessibilityMultiTapGestureRecognizer::CancelTwoFingerEvent() -{ - HILOG_DEBUG(); - - if (!handler_) { - HILOG_ERROR("handler_ is null ptr"); - return; - } - - handler_->RemoveEvent(TWO_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::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(FOUR_FINGER_LONG_PRESS_MSG); - handler_->RemoveEvent(FOUR_FINGER_DOUBLE_TAP_MSG); - handler_->RemoveEvent(FOUR_FINGER_DOUBLE_TAP_AND_HOLD_MSG); - handler_->RemoveEvent(FOUR_FINGER_TRIPLE_TAP_MSG); - handler_->RemoveEvent(FOUR_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(); - - if (!handler_) { - HILOG_ERROR("handler_ is null ptr"); - return; - } - - handler_->RemoveEvent(CANCEL_GESTURE); - handler_->RemoveEvent(CANCEL_WAIT_FINGER_DOWN_MSG); - CancelTwoFingerEvent(); - CancelThreeFingerEvent(); - CancelFourFingerEvent(); -} - -void AccessibilityMultiTapGestureRecognizer::Clear() -{ - HILOG_DEBUG(); - - targetFingers_ = -1; - addContinueTapNum_ = 0; - isMoveGestureRecognizing = 0; - moveDirection = -1; - firstDownPoint_.clear(); - lastUpPoint_.clear(); - currentDownPoint_.clear(); - preGesturePoint_.clear(); - pointerRoute_.clear(); - CancelAllPenddingEvent(); -} - -void AccessibilityMultiTapGestureRecognizer::CancelGesture(bool isNoDelayFlag) -{ - HILOG_DEBUG(); - - SetMultiFingerGestureState(MultiFingerGestureState::GESTURE_CANCLE); - - if (fingerTouchUpState_ != FingerTouchUpState::ALL_FINGER_TOUCH_UP) { - fingerTouchUpState_ = FingerTouchUpState::NOT_ALL_FINGER_TOUCH_UP; - } - - if (!listener_) { - HILOG_ERROR("listener_ is null ptr"); - return; - } - - listener_->MultiFingerGestureOnCancelled(isNoDelayFlag); - Clear(); -} - -bool AccessibilityMultiTapGestureRecognizer::ParamCheck(const int32_t fingerNum) -{ - if (static_cast(lastUpPoint_.size()) < fingerNum || - static_cast(firstDownPoint_.size()) < fingerNum) { - HILOG_ERROR("last_up point or first_down point size is less than target fingerNum"); - 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: %{public}d", pId); - return false; - } - } - - return true; -} - -int64_t AccessibilityMultiTapGestureRecognizer::GetLastFirstPointUpTime(const int32_t fingerNum) -{ - HILOG_DEBUG(); - - 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_, %{public}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 = %{public}f, right = %{public}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(%{public}d) failed", pIds[pId]); - return false; - } - if (!prePointsEventInfo[pId]->GetPointerItem(prePointsEventInfo[pId]->GetPointerId(), prePoints[pId])) { - HILOG_ERROR("prePoint GetPointerItem(%{public}d) failed", prePointsEventInfo[pId]->GetPointerId()); - return false; - } - } - return true; -} - -bool AccessibilityMultiTapGestureRecognizer::IsMultiFingerDoubleTap(MMI::PointerEvent &event, - const int32_t fingerNum) -{ - HILOG_DEBUG("fingerNum is %{public}d", fingerNum); - - if (!ParamCheck(fingerNum)) { - return false; - } - - // first pointer up time to second pointer down time - 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); - return false; - } - - std::vector pIds = event.GetPointerIds(); - if (static_cast(pIds.size()) != fingerNum) { - return false; - } - - std::vector curPoints(fingerNum); - std::vector prePoints(fingerNum); - if (!GetPointerItemWithFingerNum(fingerNum, curPoints, prePoints, event, firstDownPoint_)) { - return false; - } - - return IsDoubelTapSlopConditionMatch(fingerNum, curPoints, prePoints); -} - -void AccessibilityMultiTapGestureRecognizer::HanleFirstTouchDownEvent(MMI::PointerEvent &event) -{ - HILOG_DEBUG("gestureState is %{public}d, touchUpState is %{public}d", multiFingerGestureState_, - fingerTouchUpState_); - - if (multiFingerGestureState_ == MultiFingerGestureState::GESTURE_WAIT) { - if (event.GetPointerId() == 0) { - fingerTouchUpState_ = FingerTouchUpState::NOT_ALL_FINGER_TOUCH_UP; - Clear(); - return; - } else if (!handler_->HasInnerEvent(WAIT_ANOTHER_FINGER_DOWN_MSG)) { - HILOG_DEBUG("do not have WAIT_ANOTHER_FINGER_DOWN_MSG"); - SetMultiFingerGestureState(MultiFingerGestureState::GESTURE_NOT_START); - } - } - - // NOT_ALL_FINGER_TOUCH_UP state can not revice touch down event - if (fingerTouchUpState_ == FingerTouchUpState::NOT_ALL_FINGER_TOUCH_UP) { - Clear(); - return; - } - - // start touch down, change fingerTouchUpState_ to TOUCH_DOWN_AFTER_ALL_FINGER_TOUCH_UP state - fingerTouchUpState_ = FingerTouchUpState::TOUCH_DOWN_AFTER_ALL_FINGER_TOUCH_UP; - firstDownPoint_[event.GetPointerId()] = std::make_shared(event); - handler_->SendEvent(WAIT_ANOTHER_FINGER_DOWN_MSG, 0, TAP_INTERVAL_TIMEOUT / US_TO_MS); - if (event.GetPointerIds().size() == POINTER_COUNT_1) { - SetMultiFingerGestureState(MultiFingerGestureState::GESTURE_WAIT); - } else if (event.GetPointerIds().size() == POINTER_COUNT_2) { - 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 %{public}d", fingerNum); - - // check is double tap - if (static_cast(firstDownPoint_.size()) == fingerNum && - static_cast(lastUpPoint_.size()) == fingerNum && - IsMultiFingerDoubleTap(event, fingerNum)) { - addContinueTapNum_ = addContinueTapNum_ + 1; - HILOG_DEBUG("two finger Double tap is recognized, addContinueTapNum %{public}d", addContinueTapNum_); - } else { - addContinueTapNum_ = 0; - } - if (fingerNum < POINTER_COUNT_2 || fingerNum > POINTER_COUNT_4) { - HILOG_ERROR("fingerNum: %{public}d is wrong", fingerNum); - return; - } - if (addContinueTapNum_ >= MULTI_FINGER_MAX_CONTINUE_TAP_NUM) { - HILOG_ERROR("continue tap times: %{public}u is wrong", addContinueTapNum_); - CancelGesture(true); - 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 %{public}d, gestureState is %{public}d, touchUpstate is %{public}d", - targetFingers_, multiFingerGestureState_, fingerTouchUpState_); - - if (targetFingers_ == POINTER_COUNT_1) { - return; - } - - if (multiFingerGestureState_ != MultiFingerGestureState::GESTURE_START) { - CancelGesture(true); - return; - } - - if (fingerTouchUpState_ == FingerTouchUpState::NOT_ALL_FINGER_TOUCH_UP) { - CancelGesture(true); - return; - } - - fingerTouchUpState_ = FingerTouchUpState::TOUCH_DOWN_AFTER_ALL_FINGER_TOUCH_UP; - int32_t pointerSize = static_cast(event.GetPointerIds().size()); - if (pointerSize < targetFingers_) { - handler_->SendEvent(CANCEL_GESTURE, 0, TAP_INTERVAL_TIMEOUT / US_TO_MS); - } else if (pointerSize == targetFingers_) { - HandleMultiTapEvent(event, targetFingers_); - } else { - HILOG_DEBUG("current fingers is more than last touch down finger nums"); - CancelGesture(true); - } -} - -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(%{public}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 { - 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); -} - -bool AccessibilityMultiTapGestureRecognizer::GetBasePointItem(MMI::PointerEvent::PointerItem &basePointerIterm, - int32_t pId, std::map> &pointInfo) -{ - 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(%{public}d) failed", pId); - return false; - } - - return true; -} - -void AccessibilityMultiTapGestureRecognizer::HandleMultiFingerMoveEvent(MMI::PointerEvent &event) -{ - int32_t pIdSize = static_cast(event.GetPointerIds().size()); - int32_t downPointSize = static_cast(currentDownPoint_.size()); - int32_t pId = event.GetPointerId(); - HILOG_DEBUG("pointer num is %{public}d, down pointer size is %{public}d, pointId is %{public}d", pIdSize, - downPointSize, pId); - - MMI::PointerEvent::PointerItem pointerIterm; - if (!event.GetPointerItem(pId, pointerIterm)) { - HILOG_ERROR("get GetPointerItem(%{public}d) failed", pId); - return; - } - - 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 %{public}d, %{public}d, %{public}d, %{public}d, %{public}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(%{public}d) failed", pId); - return; - } - - MMI::PointerEvent::PointerItem basePointerIterm; - if (!GetBasePointItem(basePointerIterm, pId, preGesturePoint_)) { - return; - } - - 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); - } -} - -bool AccessibilityMultiTapGestureRecognizer::recognizeGesturePath(const std::vector &path) -{ - HILOG_DEBUG(); - if (path.size() < MIN_MOVE_POINTER_NUM) { - return false; - } - - int pathSize = static_cast(path.size() - 1); - for (int routerIndex = 0; routerIndex < pathSize; 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 = static_cast(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 = static_cast(currentDownPoint_.size()); - if (static_cast(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) -{ - HILOG_DEBUG("gestureState is %{public}d, isFirstUp is %{public}d, target finger num is %{public}d", - multiFingerGestureState_, isFirstUp_, targetFingers_); - - handler_->RemoveEvent(WAIT_ANOTHER_FINGER_DOWN_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; - } - - if (isFirstUp_) { - isFirstUp_ = false; - if (targetFingers_ != -1 && static_cast(event.GetPointerIds().size()) != targetFingers_) { - CancelGesture(true); - return; - } - } - - lastUpPoint_[event.GetPointerId()] = std::make_shared(event); - if (targetFingers_ == -1 && multiFingerGestureState_ == MultiFingerGestureState::GESTURE_START) { - targetFingers_ = static_cast(event.GetPointerIds().size()); - } -} - -void AccessibilityMultiTapGestureRecognizer::OnPointerEvent(MMI::PointerEvent &event) -{ - HILOG_DEBUG("gestureState is %{public}d", multiFingerGestureState_); - - switch (event.GetPointerAction()) { - case MMI::PointerEvent::POINTER_ACTION_DOWN: - // cancel last cancel event when recevie a new down event - CancelAllPenddingEvent(); - isFirstUp_ = true; - currentDownPoint_[event.GetPointerId()] = std::make_shared(event); - preGesturePoint_[event.GetPointerId()] = std::make_shared(event); - if (targetFingers_ == -1) { - HanleFirstTouchDownEvent(event); - } else { - HandleContinueTouchDownEvent(event); - } - break; - case MMI::PointerEvent::POINTER_ACTION_MOVE: - if (multiFingerGestureState_ != MultiFingerGestureState::GESTURE_START) { - return; - } - HandleMultiFingerMoveEvent(event); - break; - case MMI::PointerEvent::POINTER_ACTION_UP: - HandleMultiFingerTouchUpEvent(event); - break; - default: - break; - } - return; -} -} // namespace Accessibility -} // namespace OHOS diff --git a/services/aams/src/accessibility_touch_exploration.cpp b/services/aams/src/accessibility_touch_exploration.cpp new file mode 100755 index 00000000..8e294d23 --- /dev/null +++ b/services/aams/src/accessibility_touch_exploration.cpp @@ -0,0 +1,1969 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed On an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "accessibility_touch_exploration.h" +#include "accessibility_window_manager.h" +#include "accessibility_event_info.h" +#include "hilog_wrapper.h" +#include "securec.h" +#include "utils.h" + +namespace OHOS { +namespace Accessibility { + +void TouchExploration::InitOneFingerGestureFuncMap() +{ + handleEventFuncMap_ = { + {TouchExplorationState::TOUCH_INIT, { + {MMI::PointerEvent::POINTER_ACTION_DOWN, BIND(HandleInitStateDown)}, + {MMI::PointerEvent::POINTER_ACTION_UP, BIND(HandleInitStateUp)}, + {MMI::PointerEvent::POINTER_ACTION_MOVE, BIND(HandleInitStateMove)}, + {MMI::PointerEvent::POINTER_ACTION_CANCEL, BIND(HandleCancelEvent)}, + {MMI::PointerEvent::POINTER_ACTION_PULL_MOVE, BIND(HandleInitStateMove)}, + {MMI::PointerEvent::POINTER_ACTION_PULL_UP, BIND(HandleInitStateUp)}} + }, + {TouchExplorationState::ONE_FINGER_DOWN, { + {MMI::PointerEvent::POINTER_ACTION_DOWN, BIND(HandleOneFingerDownStateDown)}, + {MMI::PointerEvent::POINTER_ACTION_UP, BIND(HandleOneFingerDownStateUp)}, + {MMI::PointerEvent::POINTER_ACTION_MOVE, BIND(HandleOneFingerDownStateMove)}, + {MMI::PointerEvent::POINTER_ACTION_CANCEL, BIND(HandleCancelEvent)}} + }, + {TouchExplorationState::ONE_FINGER_LONG_PRESS, { + {MMI::PointerEvent::POINTER_ACTION_DOWN, BIND(HandleOneFingerLongPressStateDown)}, + {MMI::PointerEvent::POINTER_ACTION_UP, BIND(HandleOneFingerLongPressStateUp)}, + {MMI::PointerEvent::POINTER_ACTION_MOVE, BIND(HandleOneFingerLongPressStateMove)}, + {MMI::PointerEvent::POINTER_ACTION_CANCEL, BIND(HandleCancelEvent)}} + }, + {TouchExplorationState::ONE_FINGER_SWIPE, { + {MMI::PointerEvent::POINTER_ACTION_DOWN, BIND(HandleOneFingerSwipeStateDown)}, + {MMI::PointerEvent::POINTER_ACTION_UP, BIND(HandleOneFingerSwipeStateUp)}, + {MMI::PointerEvent::POINTER_ACTION_MOVE, BIND(HandleOneFingerSwipeStateMove)}, + {MMI::PointerEvent::POINTER_ACTION_CANCEL, BIND(HandleCancelEvent)}} + }, + {TouchExplorationState::ONE_FINGER_SINGLE_TAP, { + {MMI::PointerEvent::POINTER_ACTION_DOWN, BIND(HandleOneFingerSingleTapStateDown)}, + {MMI::PointerEvent::POINTER_ACTION_CANCEL, BIND(HandleCancelEvent)}} + }, + {TouchExplorationState::ONE_FINGER_SINGLE_TAP_THEN_DOWN, { + {MMI::PointerEvent::POINTER_ACTION_DOWN, BIND(HandleOneFingerSingleTapThenDownStateDown)}, + {MMI::PointerEvent::POINTER_ACTION_UP, BIND(HandleOneFingerSingleTapThenDownStateUp)}, + {MMI::PointerEvent::POINTER_ACTION_MOVE, BIND(HandleOneFingerSingleTapThenDownStateMove)}, + {MMI::PointerEvent::POINTER_ACTION_CANCEL, BIND(HandleCancelEvent)}, + {MMI::PointerEvent::POINTER_ACTION_PULL_MOVE, BIND(HandleOneFingerSingleTapThenDownStateMove)}, + {MMI::PointerEvent::POINTER_ACTION_PULL_UP, BIND(HandleOneFingerSingleTapThenDownStateUp)}} + } + }; +} + +void TouchExploration::InitTwoFingerGestureFuncMap() +{ + handleEventFuncMap_.insert({ + {TouchExplorationState::TWO_FINGERS_DOWN, { + {MMI::PointerEvent::POINTER_ACTION_DOWN, BIND(HandleTwoFingersDownStateDown)}, + {MMI::PointerEvent::POINTER_ACTION_UP, BIND(HandleTwoFingersDownStateUp)}, + {MMI::PointerEvent::POINTER_ACTION_MOVE, BIND(HandleTwoFingersDownStateMove)}, + {MMI::PointerEvent::POINTER_ACTION_CANCEL, BIND(HandleCancelEvent)}} + }, + {TouchExplorationState::TWO_FINGERS_DRAG, { + {MMI::PointerEvent::POINTER_ACTION_DOWN, BIND(HandleTwoFingersDragStateDown)}, + {MMI::PointerEvent::POINTER_ACTION_UP, BIND(HandleTwoFingersDragStateUp)}, + {MMI::PointerEvent::POINTER_ACTION_MOVE, BIND(HandleTwoFingersDragStateMove)}, + {MMI::PointerEvent::POINTER_ACTION_CANCEL, BIND(HandleCancelEvent)}} + }, + {TouchExplorationState::TWO_FINGERS_TAP, { + {MMI::PointerEvent::POINTER_ACTION_DOWN, BIND(HandleTwoFingersTapStateDown)}, + {MMI::PointerEvent::POINTER_ACTION_UP, BIND(HandleMultiFingersTapStateUp)}, + {MMI::PointerEvent::POINTER_ACTION_MOVE, BIND(HandleTwoFingersTapStateMove)}, + {MMI::PointerEvent::POINTER_ACTION_CANCEL, BIND(HandleCancelEvent)}} + }, + {TouchExplorationState::TWO_FINGERS_CONTINUE_DOWN, { + {MMI::PointerEvent::POINTER_ACTION_DOWN, BIND(HandleMultiFingersContinueDownStateDown)}, + {MMI::PointerEvent::POINTER_ACTION_UP, BIND(HandleTwoFingersContinueDownStateUp)}, + {MMI::PointerEvent::POINTER_ACTION_MOVE, BIND(HandleTwoFingersContinueDownStateMove)}, + {MMI::PointerEvent::POINTER_ACTION_CANCEL, BIND(HandleCancelEvent)}} + }, + {TouchExplorationState::TWO_FINGERS_UNKNOWN, { + {MMI::PointerEvent::POINTER_ACTION_DOWN, BIND(HandleTwoFingersUnknownStateDown)}, + {MMI::PointerEvent::POINTER_ACTION_UP, BIND(HandleTwoFingersUnknownStateUp)}, + {MMI::PointerEvent::POINTER_ACTION_MOVE, BIND(HandleTwoFingersUnknownStateMove)}, + {MMI::PointerEvent::POINTER_ACTION_CANCEL, BIND(HandleCancelEvent)}} + } + }); +} + +void TouchExploration::InitThreeFingerGestureFuncMap() +{ + handleEventFuncMap_.insert({ + {TouchExplorationState::THREE_FINGERS_DOWN, { + {MMI::PointerEvent::POINTER_ACTION_DOWN, BIND(HandleThreeFingersDownStateDown)}, + {MMI::PointerEvent::POINTER_ACTION_UP, BIND(HandleThreeFingersDownStateUp)}, + {MMI::PointerEvent::POINTER_ACTION_MOVE, BIND(HandleThreeFingersDownStateMove)}, + {MMI::PointerEvent::POINTER_ACTION_CANCEL, BIND(HandleCancelEvent)}} + }, + {TouchExplorationState::THREE_FINGERS_SWIPE, { + {MMI::PointerEvent::POINTER_ACTION_DOWN, BIND(HandleThreeFingersSwipeStateDown)}, + {MMI::PointerEvent::POINTER_ACTION_UP, BIND(HandleThreeFingersSwipeStateUp)}, + {MMI::PointerEvent::POINTER_ACTION_MOVE, BIND(HandleThreeFingersSwipeStateMove)}, + {MMI::PointerEvent::POINTER_ACTION_CANCEL, BIND(HandleCancelEvent)}} + }, + {TouchExplorationState::THREE_FINGERS_TAP, { + {MMI::PointerEvent::POINTER_ACTION_DOWN, BIND(HandleThreeFingersTapStateDown)}, + {MMI::PointerEvent::POINTER_ACTION_UP, BIND(HandleMultiFingersTapStateUp)}, + {MMI::PointerEvent::POINTER_ACTION_MOVE, BIND(HandleThreeFingersTapStateMove)}, + {MMI::PointerEvent::POINTER_ACTION_CANCEL, BIND(HandleCancelEvent)}} + }, + {TouchExplorationState::THREE_FINGERS_CONTINUE_DOWN, { + {MMI::PointerEvent::POINTER_ACTION_DOWN, BIND(HandleMultiFingersContinueDownStateDown)}, + {MMI::PointerEvent::POINTER_ACTION_UP, BIND(HandleThreeFingersContinueDownStateUp)}, + {MMI::PointerEvent::POINTER_ACTION_MOVE, BIND(HandleThreeFingersContinueDownStateMove)}, + {MMI::PointerEvent::POINTER_ACTION_CANCEL, BIND(HandleCancelEvent)}} + } + }); +} + +void TouchExploration::InitFourFingerGestureFuncMap() +{ + handleEventFuncMap_.insert({ + {TouchExplorationState::THREE_FINGERS_CONTINUE_DOWN, { + {MMI::PointerEvent::POINTER_ACTION_DOWN, BIND(HandleMultiFingersContinueDownStateDown)}, + {MMI::PointerEvent::POINTER_ACTION_UP, BIND(HandleThreeFingersContinueDownStateUp)}, + {MMI::PointerEvent::POINTER_ACTION_MOVE, BIND(HandleThreeFingersContinueDownStateMove)}, + {MMI::PointerEvent::POINTER_ACTION_CANCEL, BIND(HandleCancelEvent)}} + }, + {TouchExplorationState::FOUR_FINGERS_DOWN, { + {MMI::PointerEvent::POINTER_ACTION_DOWN, BIND(HandleFourFingersDownStateDown)}, + {MMI::PointerEvent::POINTER_ACTION_UP, BIND(HandleFourFingersDownStateUp)}, + {MMI::PointerEvent::POINTER_ACTION_MOVE, BIND(HandleFourFingersDownStateMove)}, + {MMI::PointerEvent::POINTER_ACTION_CANCEL, BIND(HandleCancelEvent)}} + }, + {TouchExplorationState::FOUR_FINGERS_SWIPE, { + {MMI::PointerEvent::POINTER_ACTION_DOWN, BIND(HandleFourFingersSwipeStateDown)}, + {MMI::PointerEvent::POINTER_ACTION_UP, BIND(HandleFourFingersSwipeStateUp)}, + {MMI::PointerEvent::POINTER_ACTION_MOVE, BIND(HandleFourFingersSwipeStateMove)}, + {MMI::PointerEvent::POINTER_ACTION_CANCEL, BIND(HandleCancelEvent)}} + }, + {TouchExplorationState::FOUR_FINGERS_TAP, { + {MMI::PointerEvent::POINTER_ACTION_DOWN, BIND(HandleFourFingersTapStateDown)}, + {MMI::PointerEvent::POINTER_ACTION_UP, BIND(HandleMultiFingersTapStateUp)}, + {MMI::PointerEvent::POINTER_ACTION_MOVE, BIND(HandleFourFingersTapStateMove)}, + {MMI::PointerEvent::POINTER_ACTION_CANCEL, BIND(HandleCancelEvent)}} + }, + {TouchExplorationState::FOUR_FINGERS_CONTINUE_DOWN, { + {MMI::PointerEvent::POINTER_ACTION_DOWN, BIND(HandleMultiFingersContinueDownStateDown)}, + {MMI::PointerEvent::POINTER_ACTION_UP, BIND(HandleFourFingersContinueDownStateUp)}, + {MMI::PointerEvent::POINTER_ACTION_MOVE, BIND(HandleFourFingersContinueDownStateMove)}, + {MMI::PointerEvent::POINTER_ACTION_CANCEL, BIND(HandleCancelEvent)}} + } + }); +} + +TouchExplorationEventHandler::TouchExplorationEventHandler( + const std::shared_ptr &runner, TouchExploration &server): AppExecFwk::EventHandler(runner), + server_(server) +{ +} + +void TouchExplorationEventHandler::ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event) +{ + HILOG_INFO("TEhandler process event id = %{public}d, currentState is %{public}d", event->GetInnerEventId(), + server_.GetCurrentState()); + + switch (event->GetInnerEventId()) { + case TouchExploration::SEND_HOVER_MSG: + server_.HoverEventRunner(); + break; + case TouchExploration::LONG_PRESS_MSG: + HILOG_INFO("currentState is changed from ONE_FINGER_DOWN to ONE_FINGER_LONG_PRESS."); + server_.CancelPostEvent(TouchExploration::SEND_HOVER_MSG); + server_.HoverEventRunner(); + server_.SetCurrentState(TouchExplorationState::ONE_FINGER_LONG_PRESS); + break; + case TouchExploration::DOUBLE_TAP_MSG: + server_.Clear(); + HILOG_INFO("currentState is changed from ONE_FINGER_SINGLE_TAP to TOUCH_INIT."); + server_.SetCurrentState(TouchExplorationState::TOUCH_INIT); + break; + case TouchExploration::SWIPE_COMPLETE_TIMEOUT_MSG: + server_.Clear(); + HILOG_ERROR("swipe gesture timeout, currentState is changed from ONE_FINGER_SWIPE to INVALID."); + server_.SetCurrentState(TouchExplorationState::INVALID); + break; + case TouchExploration::WAIT_ANOTHER_FINGER_DOWN_MSG: + if (server_.GetCurrentState() == TouchExplorationState::TWO_FINGERS_TAP || + server_.GetCurrentState() == TouchExplorationState::THREE_FINGERS_TAP || + server_.GetCurrentState() == TouchExplorationState::FOUR_FINGERS_TAP) { + server_.Clear(); + HILOG_INFO("wait another finger timeout, currentState is changed to INVALID."); + server_.SetCurrentState(TouchExplorationState::INVALID); + } + break; + default: + server_.ProcessMultiFingerGesture(event->GetInnerEventId()); + break; + } +} + +TouchExploration::TouchExploration() +{ + InitOneFingerGestureFuncMap(); + InitTwoFingerGestureFuncMap(); + InitThreeFingerGestureFuncMap(); + InitFourFingerGestureFuncMap(); + +#ifdef OHOS_BUILD_ENABLE_DISPLAY_MANAGER + AccessibilityDisplayManager &displayMgr = Singleton::GetInstance(); + auto display = displayMgr.GetDefaultDisplay(); + if (display == nullptr) { + HILOG_ERROR("get display is nullptr"); + return; + } + moveThreshold_ = CalculateMoveThreshold(display->GetDpi()); + xMinPixels_ = display->GetWidth() * PIXEL_MULTIPLIER; + yMinPixels_ = display->GetHeight() * PIXEL_MULTIPLIER; + float density = display->GetVirtualPixelRatio(); + multiTapOffsetThresh_ = static_cast(density * MULTI_TAP_SLOP + MULTI_TAP_SLOP_DELTA); + mMinPixelsBetweenSamplesX_ = display->GetWidth() * PIXEL_MULTIPLIER; + mMinPixelsBetweenSamplesY_ = display->GetHeight() * PIXEL_MULTIPLIER; +#else + HILOG_WARN("not support display manager"); + moveThreshold_ = 1; + xMinPixels_ = 1; + yMinPixels_ = 1; + multiTapOffsetThresh_ = static_cast(1 * MULTI_TAP_SLOP + MULTI_TAP_SLOP_DELTA); + mMinPixelsBetweenSamplesX_ = 1; + mMinPixelsBetweenSamplesY_ = 1; +#endif +} + +void TouchExploration::StartUp() +{ + runner_ = Singleton::GetInstance().GetMainRunner(); + if (!runner_) { + HILOG_ERROR("get runner failed"); + return; + } + + handler_ = std::make_shared(runner_, *this); + if (!handler_) { + HILOG_ERROR("create event handler failed"); + return; + } +} + +bool TouchExploration::OnPointerEvent(MMI::PointerEvent &event) +{ + HILOG_DEBUG("PointerAction:%{public}d, PointerId:%{public}d.", event.GetPointerAction(), event.GetPointerId()); + + if (event.GetSourceType() != MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN) { + EventTransmission::OnPointerEvent(event); + return false; + } + + MMI::PointerEvent::PointerItem pointerIterm; + std::vector pIds = event.GetPointerIds(); + for (auto& pid : pIds) { + if (!event.GetPointerItem(pid, pointerIterm)) { + HILOG_ERROR("get pointerItem(%{public}d) failed", pid); + return false; + } + } + + // Send touch event to AA to control volume adjustment. + SendTouchEventToAA(event); + + HandlePointerEvent(event); + return true; +} + +void TouchExploration::HandlePointerEvent(MMI::PointerEvent &event) +{ + HILOG_DEBUG(); + + if (GetCurrentState() == TouchExplorationState::PASSING_THROUGH) { + HandlePassingThroughState(event); + return; + } else if (GetCurrentState() == TouchExplorationState::INVALID) { + HandleInvalidState(event); + return; + } + + auto iter = handleEventFuncMap_.find(GetCurrentState()); + if (iter != handleEventFuncMap_.end()) { + auto funcMap = iter->second.find(event.GetPointerAction()); + if (funcMap != iter->second.end()) { + funcMap->second(event); + return; + } + } + + MMI::PointerEvent::PointerItem pointerIterm; + event.GetPointerItem(event.GetPointerId(), pointerIterm); + // If the event is not processed, GetCurrentState() is set to TOUCH_INIT when the last finger is lifted. + if (event.GetPointerIds().size() == POINTER_COUNT_1 || !pointerIterm.IsPressed()) { + Clear(); + HILOG_INFO("currentState is changed from %{pinlic}d to TOUCH_INIT.", GetCurrentState()); + SetCurrentState(TouchExplorationState::TOUCH_INIT); + } +} + +void TouchExploration::SendAccessibilityEventToAA(EventType eventType) +{ + HILOG_INFO("eventType is 0x%{public}x.", eventType); + + AccessibilityEventInfo eventInfo {}; + eventInfo.SetEventType(eventType); + int32_t windowsId = Singleton::GetInstance().GetActiveWindowId(); + eventInfo.SetWindowId(windowsId); + Singleton::GetInstance().SendEvent(eventInfo); +} + +void TouchExploration::SendTouchEventToAA(MMI::PointerEvent &event) +{ + if (event.GetPointerIds().size() != POINTER_COUNT_1) { + return; + } + + MMI::PointerEvent::PointerItem pointerIterm = {}; + event.GetPointerItem(event.GetPointerId(), pointerIterm); + if (event.GetPointerAction() == MMI::PointerEvent::POINTER_ACTION_DOWN) { + SendAccessibilityEventToAA(EventType::TYPE_TOUCH_BEGIN); + } else if (!pointerIterm.IsPressed()) { + SendAccessibilityEventToAA(EventType::TYPE_TOUCH_END); + } +} + +void TouchExploration::SendGestureEventToAA(GestureType gestureId) +{ + HILOG_INFO("gestureId is %{public}d.", static_cast(gestureId)); + + AccessibilityEventInfo eventInfo {}; + int32_t windowsId = Singleton::GetInstance().GetActiveWindowId(); + eventInfo.SetWindowId(windowsId); + eventInfo.SetEventType(EventType::TYPE_GESTURE_EVENT); + eventInfo.SetGestureType(gestureId); + Singleton::GetInstance().SendEvent(eventInfo); +} + +void TouchExploration::SendEventToMultimodal(MMI::PointerEvent &event, ChangeAction action) +{ + HILOG_DEBUG("action:%{public}d, SourceType:%{public}d.", action, event.GetSourceType()); + + switch (action) { + case ChangeAction::HOVER_MOVE: + event.SetPointerAction(MMI::PointerEvent::POINTER_ACTION_HOVER_MOVE); + break; + case ChangeAction::POINTER_DOWN: + event.SetPointerAction(MMI::PointerEvent::POINTER_ACTION_DOWN); + break; + case ChangeAction::POINTER_UP: + event.SetPointerAction(MMI::PointerEvent::POINTER_ACTION_UP); + break; + case ChangeAction::HOVER_ENTER: + event.SetPointerAction(MMI::PointerEvent::POINTER_ACTION_HOVER_ENTER); + break; + case ChangeAction::HOVER_EXIT: + event.SetPointerAction(MMI::PointerEvent::POINTER_ACTION_HOVER_EXIT); + break; + case ChangeAction::HOVER_CANCEL: + event.SetPointerAction(MMI::PointerEvent::POINTER_ACTION_HOVER_CANCEL); + break; + default: + break; + } + EventTransmission::OnPointerEvent(event); + + if (event.GetPointerAction() == MMI::PointerEvent::POINTER_ACTION_DOWN) { + injectedPointerDownEvents_.push_back(event); + return; + } + if (event.GetPointerAction() == MMI::PointerEvent::POINTER_ACTION_UP) { + for (auto iter = injectedPointerDownEvents_.begin(); iter != injectedPointerDownEvents_.end(); ++iter) { + if (iter->GetPointerId() == event.GetPointerId()) { + injectedPointerDownEvents_.erase(iter); + } + } + } +} + +void TouchExploration::SendScreenWakeUpEvent(MMI::PointerEvent &event) +{ + HILOG_DEBUG(); + + // Send move event to wake up the screen and prevent the screen from turning off. + MMI::PointerEvent::PointerItem pointerItem = {}; + for (auto& pid : event.GetPointerIds()) { + event.GetPointerItem(pid, pointerItem); + pointerItem.SetPressed(false); + event.RemovePointerItem(pid); + event.AddPointerItem(pointerItem); + } + SendEventToMultimodal(event, ChangeAction::NO_CHANGE); +} + +void TouchExploration::HoverEventRunner() +{ + for (auto& event : receivedPointerEvents_) { + if (event.GetPointerAction() == MMI::PointerEvent::POINTER_ACTION_DOWN) { + SendEventToMultimodal(event, ChangeAction::HOVER_ENTER); + } else if (event.GetPointerAction() == MMI::PointerEvent::POINTER_ACTION_MOVE) { + SendEventToMultimodal(event, ChangeAction::HOVER_MOVE); + } else if (event.GetPointerAction() == MMI::PointerEvent::POINTER_ACTION_UP) { + SendEventToMultimodal(event, ChangeAction::HOVER_EXIT); + } + } + Clear(); +} + +std::map TouchExploration::GetMultiFingerMsgToGestureMap() +{ + static std::map MULTI_GESTURE_TYPE = { + {TouchExploration::TWO_FINGER_SINGLE_TAP_MSG, GestureType::GESTURE_TWO_FINGER_SINGLE_TAP}, + {TouchExploration::TWO_FINGER_LONG_PRESS_MSG, GestureType::GESTURE_INVALID}, + {TouchExploration::TWO_FINGER_DOUBLE_TAP_MSG, GestureType::GESTURE_TWO_FINGER_DOUBLE_TAP}, + {TouchExploration::TWO_FINGER_DOUBLE_TAP_AND_HOLD_MSG, GestureType::GESTURE_TWO_FINGER_DOUBLE_TAP_AND_HOLD}, + {TouchExploration::TWO_FINGER_TRIPLE_TAP_MSG, GestureType::GESTURE_TWO_FINGER_TRIPLE_TAP}, + {TouchExploration::TWO_FINGER_TRIPLE_TAP_AND_HOLD_MSG, GestureType::GESTURE_TWO_FINGER_TRIPLE_TAP_AND_HOLD}, + {TouchExploration::THREE_FINGER_SINGLE_TAP_MSG, GestureType::GESTURE_THREE_FINGER_SINGLE_TAP}, + {TouchExploration::THREE_FINGER_LONG_PRESS_MSG, GestureType::GESTURE_INVALID}, + {TouchExploration::THREE_FINGER_DOUBLE_TAP_MSG, GestureType::GESTURE_THREE_FINGER_DOUBLE_TAP}, + {TouchExploration::THREE_FINGER_DOUBLE_TAP_AND_HOLD_MSG, GestureType::GESTURE_THREE_FINGER_DOUBLE_TAP_AND_HOLD}, + {TouchExploration::THREE_FINGER_TRIPLE_TAP_MSG, GestureType::GESTURE_THREE_FINGER_TRIPLE_TAP}, + {TouchExploration::THREE_FINGER_TRIPLE_TAP_AND_HOLD_MSG, GestureType::GESTURE_THREE_FINGER_TRIPLE_TAP_AND_HOLD}, + {TouchExploration::FOUR_FINGER_SINGLE_TAP_MSG, GestureType::GESTURE_FOUR_FINGER_SINGLE_TAP}, + {TouchExploration::FOUR_FINGER_LONG_PRESS_MSG, GestureType::GESTURE_INVALID}, + {TouchExploration::FOUR_FINGER_DOUBLE_TAP_MSG, GestureType::GESTURE_FOUR_FINGER_DOUBLE_TAP}, + {TouchExploration::FOUR_FINGER_DOUBLE_TAP_AND_HOLD_MSG, GestureType::GESTURE_FOUR_FINGER_DOUBLE_TAP_AND_HOLD}, + {TouchExploration::FOUR_FINGER_TRIPLE_TAP_MSG, GestureType::GESTURE_FOUR_FINGER_TRIPLE_TAP}, + {TouchExploration::FOUR_FINGER_TRIPLE_TAP_AND_HOLD_MSG, GestureType::GESTURE_FOUR_FINGER_TRIPLE_TAP_AND_HOLD} + }; + return MULTI_GESTURE_TYPE; +} + +void TouchExploration::ProcessMultiFingerGesture(uint32_t eventId) +{ + std::map multiGestureMap = GetMultiFingerMsgToGestureMap(); + if (multiGestureMap.find(eventId) == multiGestureMap.end()) { + return; + } + + static std::map MULTI_FINGER_TAP_GESTURE_TO_STATE = { + {GestureType::GESTURE_TWO_FINGER_SINGLE_TAP, TouchExplorationState::TWO_FINGERS_TAP}, + {GestureType::GESTURE_TWO_FINGER_DOUBLE_TAP, TouchExplorationState::TWO_FINGERS_TAP}, + {GestureType::GESTURE_TWO_FINGER_TRIPLE_TAP, TouchExplorationState::TWO_FINGERS_TAP}, + {GestureType::GESTURE_THREE_FINGER_SINGLE_TAP, TouchExplorationState::THREE_FINGERS_TAP}, + {GestureType::GESTURE_THREE_FINGER_DOUBLE_TAP, TouchExplorationState::THREE_FINGERS_TAP}, + {GestureType::GESTURE_THREE_FINGER_TRIPLE_TAP, TouchExplorationState::THREE_FINGERS_TAP}, + {GestureType::GESTURE_FOUR_FINGER_SINGLE_TAP, TouchExplorationState::FOUR_FINGERS_TAP}, + {GestureType::GESTURE_FOUR_FINGER_DOUBLE_TAP, TouchExplorationState::FOUR_FINGERS_TAP}, + {GestureType::GESTURE_FOUR_FINGER_TRIPLE_TAP, TouchExplorationState::FOUR_FINGERS_TAP} + }; + GestureType gestureType = multiGestureMap.at(eventId); + if (MULTI_FINGER_TAP_GESTURE_TO_STATE.find(gestureType) != MULTI_FINGER_TAP_GESTURE_TO_STATE.end()) { + // multi-finger multi-tap gesture + if (GetCurrentState() == MULTI_FINGER_TAP_GESTURE_TO_STATE.at(gestureType)) { + SendGestureEventToAA(gestureType); + Clear(); + HILOG_INFO("currentState is changed from %{public}d to TOUCH_INIT.", GetCurrentState()); + SetCurrentState(TouchExplorationState::TOUCH_INIT); + } + } else if (gestureType == GestureType::GESTURE_INVALID) { + Clear(); + HILOG_ERROR("currentState is changed from %{public}d to INVALID.", GetCurrentState()); + SetCurrentState(TouchExplorationState::INVALID); + } else { + // multi-finger multi-tap-and-hold gesture + SendGestureEventToAA(gestureType); + Clear(); + HILOG_INFO("currentState is changed from %{public}d to INVALID.", GetCurrentState()); + SetCurrentState(TouchExplorationState::INVALID); + } +} + +void TouchExploration::HandleInitStateDown(MMI::PointerEvent &event) +{ + if (event.GetPointerIds().size() == POINTER_COUNT_1) { + receivedPointerEvents_.push_back(event); + HILOG_INFO("currentState is changed from INIT to ONE_FINGER_DOWN."); + SetCurrentState(TouchExplorationState::ONE_FINGER_DOWN); + handler_->SendEvent(SEND_HOVER_MSG, 0, DOUBLE_TAP_TIMEOUT / US_TO_MS); + handler_->SendEvent(LONG_PRESS_MSG, 0, LONG_PRESS_TIMEOUT / US_TO_MS); + handler_->SendEvent(WAIT_ANOTHER_FINGER_DOWN_MSG, 0, MULTI_FINGER_TAP_INTERVAL_TIMEOUT / US_TO_MS); + return; + } + + HILOG_INFO("currentState is changed from INIT to PASSING_THROUGH."); + SendEventToMultimodal(event, ChangeAction::NO_CHANGE); + SetCurrentState(TouchExplorationState::PASSING_THROUGH); +} + +void TouchExploration::HandleInitStateUp(MMI::PointerEvent &event) +{ + SendEventToMultimodal(event, ChangeAction::NO_CHANGE); + + if (event.GetPointerIds().size() != POINTER_COUNT_1) { + HILOG_INFO("currentState is changed from INIT to PASSING_THROUGH."); + SetCurrentState(TouchExplorationState::PASSING_THROUGH); + } +} + +void TouchExploration::HandleInitStateMove(MMI::PointerEvent &event) +{ + HILOG_INFO("currentState is changed from INIT to PASSING_THROUGH."); + SendEventToMultimodal(event, ChangeAction::NO_CHANGE); + SetCurrentState(TouchExplorationState::PASSING_THROUGH); +} + +void TouchExploration::HandlePassingThroughState(MMI::PointerEvent &event) +{ + HILOG_DEBUG(); + + SendEventToMultimodal(event, ChangeAction::NO_CHANGE); + + MMI::PointerEvent::PointerItem pointerIterm = {}; + event.GetPointerItem(event.GetPointerId(), pointerIterm); + + // the last finger is lifted + if ((event.GetPointerIds().size() == POINTER_COUNT_1) && (!pointerIterm.IsPressed())) { + HILOG_INFO("currentState is changed from PASSING_THROUGH to TOUCH_INIT."); + SetCurrentState(TouchExplorationState::TOUCH_INIT); + } +} + +void TouchExploration::HandleInvalidState(MMI::PointerEvent &event) +{ + HILOG_DEBUG(); + + MMI::PointerEvent::PointerItem pointerIterm = {}; + event.GetPointerItem(event.GetPointerId(), pointerIterm); + + if (event.GetPointerAction() == MMI::PointerEvent::POINTER_ACTION_MOVE) { + SendScreenWakeUpEvent(event); + } + + // the last finger is lifted + if ((event.GetPointerIds().size() == POINTER_COUNT_1) && (!pointerIterm.IsPressed())) { + HILOG_INFO("currentState is changed from INVALID to TOUCH_INIT."); + SetCurrentState(TouchExplorationState::TOUCH_INIT); + } +} + +void TouchExploration::HandleCancelEvent(MMI::PointerEvent &event) +{ + HILOG_DEBUG(); + + if (GetCurrentState() == TouchExplorationState::TWO_FINGERS_DRAG && event.GetPointerId() == draggingPid_) { + SendEventToMultimodal(event, ChangeAction::NO_CHANGE); + } + SendEventToMultimodal(event, ChangeAction::HOVER_CANCEL); + + MMI::PointerEvent::PointerItem pointerIterm = {}; + event.GetPointerItem(event.GetPointerId(), pointerIterm); + + // the last finger is lifted + if ((event.GetPointerIds().size() == POINTER_COUNT_1) && (!pointerIterm.IsPressed())) { + Clear(); + HILOG_INFO("currentState is changed from %{public}d to TOUCH_INIT.", GetCurrentState()); + SetCurrentState(TouchExplorationState::TOUCH_INIT); + } +} + +void TouchExploration::HandleOneFingerDownStateDown(MMI::PointerEvent &event) +{ + receivedPointerEvents_.push_back(event); + CancelPostEvent(SEND_HOVER_MSG); + CancelPostEvent(LONG_PRESS_MSG); + if (!handler_->HasInnerEvent(WAIT_ANOTHER_FINGER_DOWN_MSG)) { + draggingPid_ = event.GetPointerId(); + HILOG_INFO("currentState is changed from ONE_FINGER_DOWN to TWO_FINGERS_UNKNOWN."); + SetCurrentState(TouchExplorationState::TWO_FINGERS_UNKNOWN); + return; + } + + CancelPostEvent(WAIT_ANOTHER_FINGER_DOWN_MSG); + handler_->SendEvent(WAIT_ANOTHER_FINGER_DOWN_MSG, 0, MULTI_FINGER_TAP_INTERVAL_TIMEOUT / US_TO_MS); + handler_->SendEvent(TWO_FINGER_SINGLE_TAP_MSG, 0, DOUBLE_TAP_TIMEOUT / US_TO_MS); + handler_->SendEvent(TWO_FINGER_LONG_PRESS_MSG, 0, DOUBLE_TAP_TIMEOUT / US_TO_MS); + HILOG_INFO("currentState is changed from ONE_FINGER_DOWN to TWO_FINGERS_DOWN."); + SetCurrentState(TouchExplorationState::TWO_FINGERS_DOWN); +} + +void TouchExploration::HandleOneFingerDownStateUp(MMI::PointerEvent &event) +{ + CancelPostEvent(LONG_PRESS_MSG); + CancelPostEvent(WAIT_ANOTHER_FINGER_DOWN_MSG); + receivedPointerEvents_.push_back(event); + + handler_->SendEvent(DOUBLE_TAP_MSG, 0, DOUBLE_TAP_TIMEOUT / US_TO_MS); + + HILOG_INFO("currentState is changed from ONE_FINGER_DOWN to ONE_FINGER_SINGLE_TAP."); + SetCurrentState(TouchExplorationState::ONE_FINGER_SINGLE_TAP); +} + +void TouchExploration::HandleOneFingerDownStateMove(MMI::PointerEvent &event) +{ + HILOG_DEBUG(); + + receivedPointerEvents_.push_back(event); + + MMI::PointerEvent::PointerItem pointerIterm; + event.GetPointerItem(event.GetPointerId(), pointerIterm); + + MMI::PointerEvent startPointerEvent = receivedPointerEvents_.front(); + MMI::PointerEvent::PointerItem startPointerIterm; + startPointerEvent.GetPointerItem(startPointerEvent.GetPointerId(), startPointerIterm); + + float offsetX = startPointerIterm.GetDisplayX() - pointerIterm.GetDisplayX(); + float offsetY = startPointerIterm.GetDisplayY() - pointerIterm.GetDisplayY(); + double duration = hypot(offsetX, offsetY); + if (duration > moveThreshold_) { + CancelPostEvent(SEND_HOVER_MSG); + CancelPostEvent(WAIT_ANOTHER_FINGER_DOWN_MSG); + CancelPostEvent(LONG_PRESS_MSG); + receivedPointerEvents_.clear(); + receivedPointerEvents_.push_back(event); + oneFingerSwipePrePointer_ = startPointerIterm; + Pointer mp; + mp.px_ = static_cast(startPointerIterm.GetDisplayX()); + mp.py_ = static_cast(startPointerIterm.GetDisplayY()); + oneFingerSwipeRoute_.clear(); + oneFingerSwipeRoute_.push_back(mp); + handler_->SendEvent(SWIPE_COMPLETE_TIMEOUT_MSG, 0, SWIPE_COMPLETE_TIMEOUT / US_TO_MS); + HILOG_INFO("currentState is changed from ONE_FINGER_DOWN to ONE_FINGER_SWIPE."); + SetCurrentState(TouchExplorationState::ONE_FINGER_SWIPE); + SendScreenWakeUpEvent(event); + } +} + +void TouchExploration::HandleOneFingerLongPressStateDown(MMI::PointerEvent &event) +{ + receivedPointerEvents_.push_back(event); + draggingPid_ = event.GetPointerId(); + HILOG_INFO("currentState is changed from ONE_FINGER_LONG_PRESS to TWO_FINGERS_UNKNOWN."); + SetCurrentState(TouchExplorationState::TWO_FINGERS_UNKNOWN); +} + +void TouchExploration::HandleOneFingerLongPressStateUp(MMI::PointerEvent &event) +{ + Clear(); + SendEventToMultimodal(event, ChangeAction::HOVER_EXIT); + + HILOG_INFO("currentState is changed from ONE_FINGER_LONG_PRESS to TOUCH_INIT."); + SetCurrentState(TouchExplorationState::TOUCH_INIT); +} + +void TouchExploration::HandleOneFingerLongPressStateMove(MMI::PointerEvent &event) +{ + HILOG_DEBUG(); + SendEventToMultimodal(event, ChangeAction::HOVER_MOVE); +} + +void TouchExploration::HandleOneFingerSwipeStateDown(MMI::PointerEvent &event) +{ + oneFingerSwipeRoute_.clear(); + receivedPointerEvents_.push_back(event); + draggingPid_ = event.GetPointerId(); + HILOG_INFO("currentState is changed from ONE_FINGER_SWIPE to TWO_FINGERS_UNKNOWN."); + SetCurrentState(TouchExplorationState::TWO_FINGERS_UNKNOWN); +} + +void TouchExploration::AddOneFingerSwipeEvent(MMI::PointerEvent &event) +{ + HILOG_DEBUG(); + + MMI::PointerEvent::PointerItem pointerIterm = {}; + event.GetPointerItem(event.GetPointerId(), pointerIterm); + + if (receivedPointerEvents_.empty()) { + HILOG_ERROR("received pointer event is null!"); + return; + } + + MMI::PointerEvent preMoveEvent = receivedPointerEvents_.back(); + MMI::PointerEvent::PointerItem preMovePointerIterm = {}; + preMoveEvent.GetPointerItem(preMoveEvent.GetPointerId(), preMovePointerIterm); + float offsetX = preMovePointerIterm.GetDisplayX() - pointerIterm.GetDisplayX(); + float offsetY = preMovePointerIterm.GetDisplayY() - pointerIterm.GetDisplayY(); + double duration = hypot(offsetX, offsetY); + if (duration > moveThreshold_) { + receivedPointerEvents_.push_back(event); + CancelPostEvent(SWIPE_COMPLETE_TIMEOUT_MSG); + handler_->SendEvent(SWIPE_COMPLETE_TIMEOUT_MSG, 0, SWIPE_COMPLETE_TIMEOUT / US_TO_MS); + } + + if ((abs(pointerIterm.GetDisplayX() - oneFingerSwipePrePointer_.GetDisplayX())) >= xMinPixels_ || + (abs(pointerIterm.GetDisplayY() - oneFingerSwipePrePointer_.GetDisplayY())) >= yMinPixels_) { + Pointer mp; + oneFingerSwipePrePointer_ = pointerIterm; + mp.px_ = pointerIterm.GetDisplayX(); + mp.py_ = pointerIterm.GetDisplayY(); + oneFingerSwipeRoute_.push_back(mp); + } +} + +std::vector TouchExploration::GetOneFingerSwipePath() +{ + HILOG_DEBUG(); + + std::vector pointerPath; + Pointer firstSeparation = oneFingerSwipeRoute_[0]; + Pointer nextPoint; + Pointer newSeparation; + float xUnitVector = 0; + float yUnitVector = 0; + float xVector = 0; + float yVector = 0; + float vectorLength = 0; + int32_t numSinceFirstSep = 0; + + pointerPath.push_back(firstSeparation); + for (size_t i = 1; i < oneFingerSwipeRoute_.size(); i++) { + nextPoint = oneFingerSwipeRoute_[i]; + if (numSinceFirstSep > 0) { + xVector = xUnitVector / numSinceFirstSep; + yVector = yUnitVector / numSinceFirstSep; + newSeparation.px_ = vectorLength * xVector + firstSeparation.px_; + newSeparation.py_ = vectorLength * yVector + firstSeparation.py_; + + float xNextUnitVector = nextPoint.px_ - newSeparation.px_; + float yNextUnitVector = nextPoint.py_ - newSeparation.py_; + float nextVectorLength = hypot(xNextUnitVector, yNextUnitVector); + if (nextVectorLength > EPSINON) { + xNextUnitVector /= nextVectorLength; + yNextUnitVector /= nextVectorLength; + } + + if ((xVector * xNextUnitVector + yVector * yNextUnitVector) < DEGREES_THRESHOLD) { + pointerPath.push_back(newSeparation); + firstSeparation = newSeparation; + xUnitVector = 0; + yUnitVector = 0; + numSinceFirstSep = 0; + } + } + xVector = nextPoint.px_ - firstSeparation.px_; + yVector = nextPoint.py_ - firstSeparation.py_; + vectorLength = hypot(xVector, yVector); + numSinceFirstSep += 1; + if (vectorLength > EPSINON) { + xUnitVector += xVector / vectorLength; + yUnitVector += yVector / vectorLength; + } + } + pointerPath.push_back(nextPoint); + return pointerPath; +} + +int32_t TouchExploration::GetSwipeDirection(const int32_t dx, const int32_t dy) +{ + if (abs(dx) > abs(dy)) { + return dx > EPSINON ? SWIPE_RIGHT : SWIPE_LEFT; + } else { + return dy < EPSINON ? SWIPE_UP : SWIPE_DOWN; + } +} + +void TouchExploration::HandleOneFingerSwipeStateUp(MMI::PointerEvent &event) +{ + AddOneFingerSwipeEvent(event); + CancelPostEvent(SWIPE_COMPLETE_TIMEOUT_MSG); + + if (oneFingerSwipeRoute_.size() < LIMIT_SIZE_TWO) { + Clear(); + HILOG_ERROR("fail to parse swipe direction, currentState is changed from ONE_FINGER_SWIPE to TOUCH_INIT."); + SetCurrentState(TouchExplorationState::TOUCH_INIT); + return; + } + + std::vector pointerPath = GetOneFingerSwipePath(); + if (pointerPath.size() == LIMIT_SIZE_TWO) { + int32_t swipeDirection = GetSwipeDirection(pointerPath[1].px_ - pointerPath[0].px_, + pointerPath[1].py_ - pointerPath[0].py_); + SendGestureEventToAA(GESTURE_DIRECTION[swipeDirection]); + } else if (pointerPath.size() == LIMIT_SIZE_THREE) { + int32_t swipeDirectionH = GetSwipeDirection(pointerPath[1].px_ - pointerPath[0].px_, + pointerPath[1].py_ - pointerPath[0].py_); + int32_t swipeDirectionHV = GetSwipeDirection(pointerPath[2].px_ - pointerPath[1].px_, + pointerPath[2].py_ - pointerPath[1].py_); + SendGestureEventToAA(GESTURE_DIRECTION_TO_ID[swipeDirectionH][swipeDirectionHV]); + } + + Clear(); + HILOG_INFO("currentState is changed from ONE_FINGER_SWIPE to TOUCH_INIT."); + SetCurrentState(TouchExplorationState::TOUCH_INIT); +} + +void TouchExploration::HandleOneFingerSwipeStateMove(MMI::PointerEvent &event) +{ + HILOG_DEBUG(); + AddOneFingerSwipeEvent(event); + SendScreenWakeUpEvent(event); +} + +void TouchExploration::RecordFocusedLocation(MMI::PointerEvent &event) +{ + HILOG_DEBUG(); + + AccessibilityElementInfo focusedElementInfo = {}; + bool ret = Singleton::GetInstance().FindFocusedElement(focusedElementInfo); + if (!ret) { + HILOG_ERROR("find focused element failed."); + return; + } + + MMI::PointerEvent::PointerItem pointer = {}; + event.GetPointerItem(event.GetPointerId(), pointer); + offsetX_ = (focusedElementInfo.GetRectInScreen().GetLeftTopXScreenPostion() + + focusedElementInfo.GetRectInScreen().GetRightBottomXScreenPostion()) / DIVIDE_NUM - pointer.GetDisplayX(); + offsetY_ = (focusedElementInfo.GetRectInScreen().GetLeftTopYScreenPostion() + + focusedElementInfo.GetRectInScreen().GetRightBottomYScreenPostion()) / DIVIDE_NUM - pointer.GetDisplayY(); +} + +void TouchExploration::HandleOneFingerSingleTapStateDown(MMI::PointerEvent &event) +{ + Clear(); + CancelPostEvent(SEND_HOVER_MSG); + CancelPostEvent(DOUBLE_TAP_MSG); + receivedPointerEvents_.push_back(event); + + RecordFocusedLocation(event); + OffsetEvent(event); + SendEventToMultimodal(event, ChangeAction::NO_CHANGE); + + HILOG_INFO("currentState is changed from ONE_FINGER_SINGLE_TAP to ONE_FINGER_SINGLE_TAP_THEN_DOWN."); + SetCurrentState(TouchExplorationState::ONE_FINGER_SINGLE_TAP_THEN_DOWN); +} + +void TouchExploration::HandleOneFingerSingleTapThenDownStateDown(MMI::PointerEvent &event) +{ + HILOG_DEBUG(); + OffsetEvent(event); + SendEventToMultimodal(event, ChangeAction::NO_CHANGE); +} + +void TouchExploration::OffsetEvent(MMI::PointerEvent &event) +{ + HILOG_DEBUG(); + + if (receivedPointerEvents_.empty()) { + HILOG_ERROR("received pointer event is null!"); + return; + } + + MMI::PointerEvent startPointerEvent = receivedPointerEvents_.front(); + if (event.GetPointerId() != startPointerEvent.GetPointerId()) { + return; + } + + MMI::PointerEvent::PointerItem pointer = {}; + event.GetPointerItem(event.GetPointerId(), pointer); + pointer.SetDisplayX(offsetX_ + pointer.GetDisplayX()); + pointer.SetDisplayY(offsetY_ + pointer.GetDisplayY()); + event.RemovePointerItem(event.GetPointerId()); + event.AddPointerItem(pointer); +} + +void TouchExploration::HandleOneFingerSingleTapThenDownStateUp(MMI::PointerEvent &event) +{ + HILOG_DEBUG(); + + OffsetEvent(event); + SendEventToMultimodal(event, ChangeAction::NO_CHANGE); + + if (event.GetPointerIds().size() == POINTER_COUNT_1) { + Clear(); + HILOG_INFO("currentState is changed from ONE_FINGER_SINGLE_TAP_THEN_DOWN to TOUCH_INIT."); + SetCurrentState(TouchExplorationState::TOUCH_INIT); + } +} + +void TouchExploration::HandleOneFingerSingleTapThenDownStateMove(MMI::PointerEvent &event) +{ + HILOG_DEBUG(); + OffsetEvent(event); + SendEventToMultimodal(event, ChangeAction::NO_CHANGE); +} + +void TouchExploration::HandleTwoFingersDownStateDown(MMI::PointerEvent &event) +{ + receivedPointerEvents_.push_back(event); + CancelPostEvent(TWO_FINGER_SINGLE_TAP_MSG); + CancelPostEvent(TWO_FINGER_LONG_PRESS_MSG); + + if (event.GetPointerIds().size() != POINTER_COUNT_3) { + CancelPostEvent(WAIT_ANOTHER_FINGER_DOWN_MSG); + Clear(); + HILOG_ERROR("invalid pointer num, currentState is changed from TWO_FINGERS_DOWN to INVALID."); + SetCurrentState(TouchExplorationState::INVALID); + return; + } + + if (!handler_->HasInnerEvent(WAIT_ANOTHER_FINGER_DOWN_MSG)) { + Clear(); + HILOG_ERROR("timeout, currentState is changed from TWO_FINGERS_DOWN to INVALID."); + SetCurrentState(TouchExplorationState::INVALID); + return; + } + + CancelPostEvent(WAIT_ANOTHER_FINGER_DOWN_MSG); + handler_->SendEvent(WAIT_ANOTHER_FINGER_DOWN_MSG, 0, MULTI_FINGER_TAP_INTERVAL_TIMEOUT / US_TO_MS); + handler_->SendEvent(THREE_FINGER_SINGLE_TAP_MSG, 0, DOUBLE_TAP_TIMEOUT / US_TO_MS); + handler_->SendEvent(THREE_FINGER_LONG_PRESS_MSG, 0, DOUBLE_TAP_TIMEOUT / US_TO_MS); + HILOG_INFO("currentState is changed from TWO_FINGERS_DOWN to THREE_FINGERS_DOWN."); + SetCurrentState(TouchExplorationState::THREE_FINGERS_DOWN); +} + +void TouchExploration::HandleTwoFingersDownStateUp(MMI::PointerEvent &event) +{ + HILOG_DEBUG(); + + receivedPointerEvents_.push_back(event); + CancelPostEvent(WAIT_ANOTHER_FINGER_DOWN_MSG); + CancelPostEvent(TWO_FINGER_LONG_PRESS_MSG); + + int32_t pointerSize = static_cast(event.GetPointerIds().size()); + if (pointerSize == POINTER_COUNT_1) { + HILOG_INFO("currentState is changed from TWO_FINGERS_DOWN to TWO_FINGERS_TAP."); + SetCurrentState(TouchExplorationState::TWO_FINGERS_TAP); + } else if (pointerSize > POINTER_COUNT_2) { + Clear(); + CancelPostEvent(TWO_FINGER_SINGLE_TAP_MSG); + HILOG_ERROR("invalid pointer num, currentState is changed from TWO_FINGERS_DOWN to INVALID."); + SetCurrentState(TouchExplorationState::INVALID); + } +} + +bool TouchExploration::GetBasePointItem(MMI::PointerEvent::PointerItem &basePointerIterm, int32_t pId) +{ + HILOG_DEBUG(); + + for (auto rIter = receivedPointerEvents_.rbegin(); rIter != receivedPointerEvents_.rend(); ++rIter) { + if ((rIter->GetPointerId() == pId) && (rIter->GetPointerAction() == MMI::PointerEvent::POINTER_ACTION_DOWN)) { + rIter->GetPointerItem(pId, basePointerIterm); + return true; + } + } + return false; +} + +void TouchExploration::GetPointOffset(MMI::PointerEvent &event, std::vector &firstPointOffset, + std::vector &secondPointOffset) +{ + HILOG_DEBUG(); + + std::vector pIds = event.GetPointerIds(); + if (pIds.size() != POINTER_COUNT_2) { + return; + } + + MMI::PointerEvent::PointerItem pointerF = {}; + MMI::PointerEvent::PointerItem pointerS = {}; + event.GetPointerItem(pIds[0], pointerF); + event.GetPointerItem(pIds[1], pointerS); + + MMI::PointerEvent::PointerItem basePointerF = {}; + MMI::PointerEvent::PointerItem basePointerS = {}; + if (GetBasePointItem(basePointerF, pIds[0]) && GetBasePointItem(basePointerS, pIds[1])) { + firstPointOffset.push_back(pointerF.GetDisplayX() - basePointerF.GetDisplayX()); + firstPointOffset.push_back(pointerF.GetDisplayY() - basePointerF.GetDisplayY()); + secondPointOffset.push_back(pointerS.GetDisplayX() - basePointerS.GetDisplayX()); + secondPointOffset.push_back(pointerS.GetDisplayY() - basePointerS.GetDisplayY()); + } +} + +float TouchExploration::GetAngleCos(float offsetX, float offsetY, bool isGetX) +{ + HILOG_DEBUG(); + + float ret = isGetX ? offsetX : offsetY; + double duration = hypot(offsetX, offsetY); + if (duration < - EPSINON || duration > EPSINON) { + ret = ret / duration; + } + return ret; +} + +bool TouchExploration::IsDragGestureAccept(MMI::PointerEvent &event) +{ + HILOG_DEBUG(); + + std::vector firstPointOffset; + std::vector secondPointOffset; + GetPointOffset(event, firstPointOffset, secondPointOffset); + if (firstPointOffset.size() != SCREEN_AXIS_NUM || secondPointOffset.size() != SCREEN_AXIS_NUM) { + return false; + } + + float firstOffsetX = firstPointOffset[0]; + float firstOffsetY = firstPointOffset[1]; + float secondOffsetX = secondPointOffset[0]; + float secondOffsetY = secondPointOffset[1]; + if ((!firstOffsetX && !firstOffsetY) || + (!secondOffsetX && !secondOffsetY)) { + return true; + } + + float firstXCos = GetAngleCos(firstOffsetX, firstOffsetY, true); + float firstYCos = GetAngleCos(firstOffsetX, firstOffsetY, false); + float secondXCos = GetAngleCos(secondOffsetX, secondOffsetY, true); + float secondYCos = GetAngleCos(secondOffsetX, secondOffsetY, false); + if ((firstXCos * secondXCos + firstYCos * secondYCos) < MAX_DRAG_GESTURE_COSINE) { + return false; + } + return true; +} + +void TouchExploration::SendDragDownEventToMultimodal(MMI::PointerEvent event) +{ + HILOG_DEBUG(); + + std::vector pIds = event.GetPointerIds(); + int32_t xPointDown = 0; + int32_t yPointDown = 0; + int64_t actionTime = 0; + MMI::PointerEvent::PointerItem basePointerIterm = {}; + + for (auto &baseEvent : receivedPointerEvents_) { + if ((baseEvent.GetPointerId() == event.GetPointerId()) && + (baseEvent.GetPointerAction() == MMI::PointerEvent::POINTER_ACTION_DOWN)) { + baseEvent.GetPointerItem(event.GetPointerId(), basePointerIterm); + xPointDown = basePointerIterm.GetDisplayX(); + yPointDown = basePointerIterm.GetDisplayY(); + actionTime = baseEvent.GetActionTime(); + break; + } + } + + MMI::PointerEvent::PointerItem pointer = {}; + event.GetPointerItem(draggingPid_, pointer); + pointer.SetDisplayX(xPointDown); + pointer.SetDisplayY(yPointDown); + event.RemovePointerItem(draggingPid_); + event.AddPointerItem(pointer); + event.SetActionTime(actionTime); + int32_t removePid = draggingPid_ == pIds[0] ? pIds[1] : pIds[0]; + event.RemovePointerItem(removePid); + SendEventToMultimodal(event, ChangeAction::POINTER_DOWN); +} + +void TouchExploration::HandleTwoFingersDownStateMove(MMI::PointerEvent &event) +{ + HILOG_DEBUG(); + + receivedPointerEvents_.push_back(event); + + MMI::PointerEvent::PointerItem pointerIterm; + event.GetPointerItem(event.GetPointerId(), pointerIterm); + + MMI::PointerEvent::PointerItem basePointerIterm; + if (!GetBasePointItem(basePointerIterm, event.GetPointerId())) { + HILOG_ERROR("get base point item failed, pid = %{public}d.", event.GetPointerId()); + return; + } + + int32_t offsetX = pointerIterm.GetDisplayX() - basePointerIterm.GetDisplayX(); + int32_t offsetY = pointerIterm.GetDisplayY() - basePointerIterm.GetDisplayY(); + if (hypot(offsetX, offsetY) > TOUCH_SLOP * POINTER_COUNT_2) { + HILOG_DEBUG("cancel two-finger tap gesture because finger move"); + CancelPostEvent(WAIT_ANOTHER_FINGER_DOWN_MSG); + CancelPostEvent(TWO_FINGER_SINGLE_TAP_MSG); + CancelPostEvent(TWO_FINGER_LONG_PRESS_MSG); + if (event.GetPointerIds().size() != POINTER_COUNT_2) { + Clear(); + SendScreenWakeUpEvent(event); + HILOG_ERROR("invalid pointer num, currentState is changed from TWO_FINGERS_DOWN to INVALID."); + SetCurrentState(TouchExplorationState::INVALID); + return; + } + if (IsDragGestureAccept(event)) { + draggingPid_ = event.GetPointerId(); + SendDragDownEventToMultimodal(event); + SendEventToMultimodal(event, ChangeAction::NO_CHANGE); + HILOG_INFO("currentState is changed from TWO_FINGERS_DOWN to TWO_FINGERS_DRAG."); + SetCurrentState(TouchExplorationState::TWO_FINGERS_DRAG); + } else { + for (auto &receivedEvent : receivedPointerEvents_) { + SendEventToMultimodal(receivedEvent, ChangeAction::NO_CHANGE); + } + Clear(); + HILOG_INFO("currentState is changed from TWO_FINGERS_DOWN to PASSING_THROUGH."); + SetCurrentState(TouchExplorationState::PASSING_THROUGH); + } + } +} + +void TouchExploration::SendUpForDraggingDownEvent() +{ + HILOG_DEBUG(); + + if (receivedPointerEvents_.empty()) { + HILOG_ERROR("received pointer event is null!"); + return; + } + + MMI::PointerEvent lastMoveEvent = receivedPointerEvents_.back(); + MMI::PointerEvent::PointerItem pointerIterm; + lastMoveEvent.GetPointerItem(lastMoveEvent.GetPointerId(), pointerIterm); + int32_t x = pointerIterm.GetDisplayX(); + int32_t y = pointerIterm.GetDisplayY(); + + MMI::PointerEvent::PointerItem pointerItem = {}; + for (auto& event : injectedPointerDownEvents_) { + event.SetActionTime(Utils::GetSystemTime() * US_TO_MS); + event.GetPointerItem(event.GetPointerId(), pointerItem); + pointerItem.SetPressed(false); + pointerItem.SetDisplayX(x); + pointerItem.SetDisplayY(y); + event.RemovePointerItem(event.GetPointerId()); + event.AddPointerItem(pointerItem); + SendEventToMultimodal(event, ChangeAction::POINTER_UP); + } +} + +void TouchExploration::HandleTwoFingersDragStateDown(MMI::PointerEvent &event) +{ + HILOG_DEBUG(); + + if (event.GetPointerIds().size() != POINTER_COUNT_2) { + SendUpForDraggingDownEvent(); + Clear(); + HILOG_ERROR("invalid pointer num, currentState is changed from TWO_FINGERS_DRAG to INVALID."); + SetCurrentState(TouchExplorationState::INVALID); + } +} + +void TouchExploration::HandleTwoFingersDragStateUp(MMI::PointerEvent &event) +{ + HILOG_DEBUG(); + + if (event.GetPointerIds().size() == POINTER_COUNT_1) { + SendUpForDraggingDownEvent(); + Clear(); + HILOG_INFO("currentState is changed from TWO_FINGERS_DRAG to TOUCH_INIT."); + SetCurrentState(TouchExplorationState::TOUCH_INIT); + } +} + +void TouchExploration::HandleTwoFingersDragStateMove(MMI::PointerEvent &event) +{ + HILOG_DEBUG(); + + std::vector pIds = event.GetPointerIds(); + if (pIds.size() != POINTER_COUNT_2 || event.GetPointerId() != draggingPid_) { + return; + } + + receivedPointerEvents_.push_back(event); + +#ifdef OHOS_BUILD_ENABLE_DISPLAY_MANAGER + // Get densityPixels from WMS + AccessibilityDisplayManager &displayMgr = Singleton::GetInstance(); + auto display = displayMgr.GetDefaultDisplay(); + float densityPixels = display->GetVirtualPixelRatio(); + int32_t miniZoomPointerDistance = static_cast(MINI_POINTER_DISTANCE_DIP * densityPixels); +#else + HILOG_DEBUG("not support display manager"); + int32_t miniZoomPointerDistance = static_cast(MINI_POINTER_DISTANCE_DIP * 1); +#endif + + MMI::PointerEvent::PointerItem pointerF = {}; + MMI::PointerEvent::PointerItem pointerS = {}; + event.GetPointerItem(pIds[0], pointerF); + event.GetPointerItem(pIds[1], pointerS); + float xPointF = pointerF.GetDisplayX(); + float xPointS = pointerS.GetDisplayX(); + float yPointF = pointerF.GetDisplayY(); + float yPointS = pointerS.GetDisplayY(); + float offsetX = abs(xPointF - xPointS); + float offsetY = abs(yPointF - yPointS); + double duration = hypot(offsetX, offsetY); + if (duration > miniZoomPointerDistance) { + // Adjust this event's location. + MMI::PointerEvent::PointerItem pointer = {}; + event.GetPointerItem(event.GetPointerId(), pointer); + pointer.SetDisplayX(pointer.GetDisplayX() + offsetX / DIVIDE_NUM); + pointer.SetDisplayY(pointer.GetDisplayY() + offsetY / DIVIDE_NUM); + event.RemovePointerItem(event.GetPointerId()); + event.AddPointerItem(pointer); + } + int32_t removePid = draggingPid_ == pIds[0]? pIds[1] : pIds[0]; + event.RemovePointerItem(removePid); + SendEventToMultimodal(event, ChangeAction::NO_CHANGE); +} + +bool TouchExploration::GetPointerItemWithFingerNum(int32_t fingerNum, + std::vector &curPoints, + std::vector &prePoints, MMI::PointerEvent &event) +{ + HILOG_DEBUG(); + + bool findPrePointer = false; + std::vector pIds = event.GetPointerIds(); + for (int32_t i = 0; i < fingerNum; i++) { + findPrePointer = false; + event.GetPointerItem(pIds[i], curPoints[i]); + for (auto &preEvent : receivedPointerEvents_) { + if ((preEvent.GetPointerId() == i) && + (preEvent.GetPointerAction() == MMI::PointerEvent::POINTER_ACTION_DOWN)) { + findPrePointer = true; + preEvent.GetPointerItem(i, prePoints[i]); + break; + } + } + if (!findPrePointer) { + HILOG_ERROR("get prePointerItem(%{public}d) failed", i); + return false; + } + } + return true; +} + +bool TouchExploration::IsMultiFingerMultiTap(MMI::PointerEvent &event, const int32_t fingerNum) +{ + HILOG_DEBUG(); + + std::vector curPoints(fingerNum); + std::vector prePoints(fingerNum); + if (!GetPointerItemWithFingerNum(fingerNum, curPoints, prePoints, event)) { + return false; + } + + 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; + } + } + if (moveDelta < multiTapOffsetThresh_ * fingerNum) { + excludePid.push_back(nearestPid); + } else { + return false; + } + } + + return true; +} + +bool TouchExploration::IsMultiFingerMultiTapGesture(MMI::PointerEvent &event, const int32_t fingerNum) +{ + HILOG_DEBUG(); + + if (IsMultiFingerMultiTap(event, fingerNum)) { + multiTapNum_ = multiTapNum_ + 1; + HILOG_DEBUG("%{public}d finger %{public}d tap is recognized", fingerNum, multiTapNum_ + 1); + } else { + Clear(); + HILOG_ERROR("invalid gesture, currentState is changed from %{public}d to INVALID.", GetCurrentState()); + SetCurrentState(TouchExplorationState::INVALID); + return false; + } + + uint32_t fingerNumIndex = static_cast(fingerNum - 2); + handler_->SendEvent(GESTURE_TAP_MSG[multiTapNum_][fingerNumIndex], 0, DOUBLE_TAP_TIMEOUT / US_TO_MS); + handler_->SendEvent(GESTURE_HOLD_MSG[multiTapNum_][fingerNumIndex], 0, DOUBLE_TAP_TIMEOUT / US_TO_MS); + return true; +} + +void TouchExploration::HandleMultiFingersTapStateDown(MMI::PointerEvent &event, int32_t fingerNum) +{ + HILOG_DEBUG(); + + receivedPointerEvents_.push_back(event); + CancelMultiFingerTapEvent(); + CancelPostEvent(WAIT_ANOTHER_FINGER_DOWN_MSG); + + if (multiTapNum_ == TAP_COUNT_MAXIMUM - 1) { + Clear(); + HILOG_ERROR("Exceeds max continuous tap count, currentState is changed from %{public}d to INVALID.", + GetCurrentState()); + SetCurrentState(TouchExplorationState::INVALID); + return; + } + + int32_t pointerSize = static_cast(event.GetPointerIds().size()); + if (pointerSize < fingerNum) { + handler_->SendEvent(WAIT_ANOTHER_FINGER_DOWN_MSG, 0, MULTI_FINGER_TAP_INTERVAL_TIMEOUT / US_TO_MS); + } else if (pointerSize == fingerNum) { + if (IsMultiFingerMultiTapGesture(event, fingerNum)) { + if (fingerNum == POINTER_COUNT_2) { + HILOG_INFO("currentState is changed from TWO_FINGERS_TAP to TWO_FINGERS_CONTINUE_DOWN."); + SetCurrentState(TouchExplorationState::TWO_FINGERS_CONTINUE_DOWN); + } else if (fingerNum == POINTER_COUNT_3) { + HILOG_INFO("currentState is changed from THREE_FINGERS_TAP to THREE_FINGERS_CONTINUE_DOWN."); + SetCurrentState(TouchExplorationState::THREE_FINGERS_CONTINUE_DOWN); + } else { + HILOG_INFO("currentState is changed from FOUR_FINGERS_TAP to FOUR_FINGERS_CONTINUE_DOWN."); + SetCurrentState(TouchExplorationState::FOUR_FINGERS_CONTINUE_DOWN); + } + } + } else { + Clear(); + HILOG_INFO("invalid pointer num, currentState is changed from TWO_FINGERS_TAP to INVALID."); + SetCurrentState(TouchExplorationState::INVALID); + } +} + +void TouchExploration::HandleTwoFingersTapStateDown(MMI::PointerEvent &event) +{ + HILOG_DEBUG(); + HandleMultiFingersTapStateDown(event, POINTER_COUNT_2); +} + +void TouchExploration::HandleMultiFingersTapStateUp(MMI::PointerEvent &event) +{ + Clear(); + CancelPostEvent(WAIT_ANOTHER_FINGER_DOWN_MSG); + + int32_t pointerSize = static_cast(event.GetPointerIds().size()); + if (pointerSize == POINTER_COUNT_1) { + HILOG_INFO("currentState is changed from %{public}d to TOUCH_INIT.", GetCurrentState()); + SetCurrentState(TouchExplorationState::TOUCH_INIT); + } else { + HILOG_ERROR("receive up event, currentState is changed from %{public}d to INVALID.", GetCurrentState()); + SetCurrentState(TouchExplorationState::INVALID); + } +} + +void TouchExploration::HandleMultiFingersTapStateMove(MMI::PointerEvent &event, int32_t fingerNum) +{ + HILOG_DEBUG(); + + if (static_cast(event.GetPointerIds().size()) >= fingerNum) { + Clear(); + HILOG_ERROR("invalid pointer num, currentState is changed from %{public}d to INVALID.", GetCurrentState()); + SetCurrentState(TouchExplorationState::INVALID); + return; + } + + receivedPointerEvents_.push_back(event); + + MMI::PointerEvent::PointerItem pointerIterm; + event.GetPointerItem(event.GetPointerId(), pointerIterm); + + MMI::PointerEvent::PointerItem basePointerIterm; + if (!GetBasePointItem(basePointerIterm, event.GetPointerId())) { + HILOG_ERROR("get base point item failed, pid = %{public}d.", event.GetPointerId()); + return; + } + + int32_t offsetX = pointerIterm.GetDisplayX() - basePointerIterm.GetDisplayX(); + int32_t offsetY = pointerIterm.GetDisplayY() - basePointerIterm.GetDisplayY(); + if (hypot(offsetX, offsetY) > TOUCH_SLOP * (fingerNum - 1)) { + CancelPostEvent(WAIT_ANOTHER_FINGER_DOWN_MSG); + Clear(); + HILOG_ERROR("receive move event, currentState is changed from %{public}d to INVALID.", GetCurrentState()); + SetCurrentState(TouchExplorationState::INVALID); + } + + SendScreenWakeUpEvent(event); +} + +void TouchExploration::HandleTwoFingersTapStateMove(MMI::PointerEvent &event) +{ + HILOG_DEBUG(); + HandleMultiFingersTapStateMove(event, POINTER_COUNT_2); +} + +void TouchExploration::HandleMultiFingersContinueDownStateDown(MMI::PointerEvent &event) +{ + CancelMultiFingerTapEvent(); + CancelMultiFingerTapAndHoldEvent(); + Clear(); + HILOG_ERROR("receive down event, currentState is changed from %{public}d to INVALID.", GetCurrentState()); + SetCurrentState(TouchExplorationState::INVALID); +} + +void TouchExploration::HandleMultiFingersContinueDownStateUp(MMI::PointerEvent &event, int32_t fingerNum) +{ + HILOG_DEBUG(); + + receivedPointerEvents_.push_back(event); + CancelMultiFingerTapAndHoldEvent(); + + int32_t pointerSize = static_cast(event.GetPointerIds().size()); + if (pointerSize == POINTER_COUNT_1) { + if (fingerNum == POINTER_COUNT_2) { + HILOG_INFO("currentState is changed from TWO_FINGERS_CONTINUE_DOWN to TWO_FINGERS_TAP."); + SetCurrentState(TouchExplorationState::TWO_FINGERS_TAP); + } else if (fingerNum == POINTER_COUNT_3) { + HILOG_INFO("currentState is changed from THREE_FINGERS_CONTINUE_DOWN to THREE_FINGERS_TAP."); + SetCurrentState(TouchExplorationState::THREE_FINGERS_TAP); + } else { + HILOG_INFO("currentState is changed from FOUR_FINGERS_CONTINUE_DOWN to FOUR_FINGERS_TAP."); + SetCurrentState(TouchExplorationState::FOUR_FINGERS_TAP); + } + } else if (pointerSize > fingerNum) { + CancelMultiFingerTapEvent(); + Clear(); + HILOG_ERROR("invalid pointer num, currentState is changed from %{public}d to INVALID.", GetCurrentState()); + SetCurrentState(TouchExplorationState::INVALID); + } +} + +void TouchExploration::HandleTwoFingersContinueDownStateUp(MMI::PointerEvent &event) +{ + HILOG_DEBUG(); + HandleMultiFingersContinueDownStateUp(event, POINTER_COUNT_2); +} + +void TouchExploration::HandleMultiFingersContinueDownStateMove(MMI::PointerEvent &event, int32_t fingerNum) +{ + HILOG_DEBUG(); + + receivedPointerEvents_.push_back(event); + + MMI::PointerEvent::PointerItem pointerIterm; + event.GetPointerItem(event.GetPointerId(), pointerIterm); + + MMI::PointerEvent::PointerItem basePointerIterm; + if (!GetBasePointItem(basePointerIterm, event.GetPointerId())) { + HILOG_ERROR("get base point item failed, pid = %{public}d.", event.GetPointerId()); + return; + } + + int32_t offsetX = pointerIterm.GetDisplayX() - basePointerIterm.GetDisplayX(); + int32_t offsetY = pointerIterm.GetDisplayY() - basePointerIterm.GetDisplayY(); + if (hypot(offsetX, offsetY) > TOUCH_SLOP * fingerNum) { + Clear(); + CancelMultiFingerTapEvent(); + CancelMultiFingerTapAndHoldEvent(); + HILOG_ERROR("receive move event, currentState is changed from %{public}d to INVALID.", GetCurrentState()); + SetCurrentState(TouchExplorationState::INVALID); + } + + SendScreenWakeUpEvent(event); +} + +void TouchExploration::HandleTwoFingersContinueDownStateMove(MMI::PointerEvent &event) +{ + HILOG_DEBUG(); + HandleMultiFingersContinueDownStateMove(event, POINTER_COUNT_2); +} + +void TouchExploration::HandleTwoFingersUnknownStateDown(MMI::PointerEvent &event) +{ + HILOG_DEBUG(); + + if (event.GetPointerIds().size() == POINTER_COUNT_2) { + receivedPointerEvents_.push_back(event); + return; + } + + Clear(); + HILOG_ERROR("receive down event, currentState is changed from TWO_FINGERS_UNKNOWN to INVALID."); + SetCurrentState(TouchExplorationState::INVALID); +} + +void TouchExploration::HandleTwoFingersUnknownStateUp(MMI::PointerEvent &event) +{ + HILOG_DEBUG(); + + receivedPointerEvents_.push_back(event); + if (event.GetPointerIds().size() == POINTER_COUNT_1) { + Clear(); + HILOG_INFO("currentState is changed from TWO_FINGERS_UNKNOWN to TOUCH_INIT."); + SetCurrentState(TouchExplorationState::TOUCH_INIT); + } +} + +void TouchExploration::HandleTwoFingersUnknownStateMove(MMI::PointerEvent &event) +{ + HILOG_DEBUG(); + + if ((event.GetPointerIds().size() != POINTER_COUNT_2) || (event.GetPointerId() != draggingPid_)) { + return; + } + + receivedPointerEvents_.push_back(event); + + std::vector pIds = event.GetPointerIds(); + if (IsDragGestureAccept(event)) { + int32_t removePid = draggingPid_ == pIds[0] ? pIds[1] : pIds[0]; + event.RemovePointerItem(removePid); + SendEventToMultimodal(event, ChangeAction::POINTER_DOWN); + HILOG_INFO("currentState is changed from TWO_FINGERS_UNKNOWN to TWO_FINGERS_DRAG."); + SetCurrentState(TouchExplorationState::TWO_FINGERS_DRAG); + return; + } +} + +void TouchExploration::HandleThreeFingersDownStateDown(MMI::PointerEvent &event) +{ + receivedPointerEvents_.push_back(event); + CancelPostEvent(THREE_FINGER_SINGLE_TAP_MSG); + CancelPostEvent(THREE_FINGER_LONG_PRESS_MSG); + + if (event.GetPointerIds().size() != POINTER_COUNT_4) { + CancelPostEvent(WAIT_ANOTHER_FINGER_DOWN_MSG); + Clear(); + HILOG_ERROR("invalid pointer num, currentState is changed from THREE_FINGERS_DOWN to INVALID."); + SetCurrentState(TouchExplorationState::INVALID); + return; + } + + if (!handler_->HasInnerEvent(WAIT_ANOTHER_FINGER_DOWN_MSG)) { + Clear(); + HILOG_ERROR("timeout, currentState is changed from THREE_FINGERS_DOWN to INVALID."); + SetCurrentState(TouchExplorationState::INVALID); + return; + } + + CancelPostEvent(WAIT_ANOTHER_FINGER_DOWN_MSG); + handler_->SendEvent(FOUR_FINGER_SINGLE_TAP_MSG, 0, DOUBLE_TAP_TIMEOUT / US_TO_MS); + handler_->SendEvent(FOUR_FINGER_LONG_PRESS_MSG, 0, DOUBLE_TAP_TIMEOUT / US_TO_MS); + HILOG_INFO("currentState is changed from THREE_FINGERS_DOWN to FOUR_FINGERS_DOWN."); + SetCurrentState(TouchExplorationState::FOUR_FINGERS_DOWN); +} + +void TouchExploration::HandleThreeFingersDownStateUp(MMI::PointerEvent &event) +{ + HILOG_DEBUG(); + + receivedPointerEvents_.push_back(event); + CancelPostEvent(WAIT_ANOTHER_FINGER_DOWN_MSG); + CancelPostEvent(THREE_FINGER_LONG_PRESS_MSG); + + int32_t pointerSize = static_cast(event.GetPointerIds().size()); + if (pointerSize == POINTER_COUNT_1) { + HILOG_INFO("currentState is changed from THREE_FINGERS_DOWN to THREE_FINGERS_TAP."); + SetCurrentState(TouchExplorationState::THREE_FINGERS_TAP); + } else if (pointerSize > POINTER_COUNT_3) { + CancelPostEvent(THREE_FINGER_SINGLE_TAP_MSG); + Clear(); + HILOG_ERROR("invalid pointer num, currentState is changed from THREE_FINGERS_DOWN to INVALID."); + SetCurrentState(TouchExplorationState::INVALID); + } +} + +void TouchExploration::StoreMultiFingerSwipeBaseDownPoint() +{ + HILOG_DEBUG(); + + for (auto& event : receivedPointerEvents_) { + if (event.GetPointerAction() == MMI::PointerEvent::POINTER_ACTION_DOWN) { + Pointer mp; + MMI::PointerEvent::PointerItem pointerIterm; + std::vector mpVec; + int32_t pId = event.GetPointerId(); + event.GetPointerItem(pId, pointerIterm); + mp.px_ = static_cast(pointerIterm.GetDisplayX()); + mp.py_ = static_cast(pointerIterm.GetDisplayY()); + mpVec.push_back(mp); + multiFingerSwipeRoute_.insert(std::make_pair(pId, mpVec)); + multiFingerSwipePrePoint_[event.GetPointerId()] = std::make_shared(event); + } + } +} + +void TouchExploration::HandleThreeFingersDownStateMove(MMI::PointerEvent &event) +{ + HILOG_DEBUG(); + + receivedPointerEvents_.push_back(event); + + MMI::PointerEvent::PointerItem pointerIterm; + event.GetPointerItem(event.GetPointerId(), pointerIterm); + + MMI::PointerEvent::PointerItem basePointerIterm; + if (!GetBasePointItem(basePointerIterm, event.GetPointerId())) { + HILOG_ERROR("get base point item failed, pid = %{public}d.", event.GetPointerId()); + return; + } + + int32_t offsetX = pointerIterm.GetDisplayX() - basePointerIterm.GetDisplayX(); + int32_t offsetY = pointerIterm.GetDisplayY() - basePointerIterm.GetDisplayY(); + if (hypot(offsetX, offsetY) > TOUCH_SLOP * POINTER_COUNT_3) { + CancelPostEvent(WAIT_ANOTHER_FINGER_DOWN_MSG); + CancelPostEvent(THREE_FINGER_SINGLE_TAP_MSG); + CancelPostEvent(THREE_FINGER_LONG_PRESS_MSG); + if (event.GetPointerIds().size() != POINTER_COUNT_3) { + Clear(); + SendScreenWakeUpEvent(event); + HILOG_ERROR("invalid pointer num, currentState is changed from THREE_FINGERS_DOWN to INVALID."); + SetCurrentState(TouchExplorationState::INVALID); + return; + } + StoreMultiFingerSwipeBaseDownPoint(); + multiFingerSwipeDirection_ = GetSwipeDirection(offsetX, offsetY); + HILOG_INFO("currentState is changed from THREE_FINGERS_DOWN to THREE_FINGERS_SWIPE."); + SetCurrentState(TouchExplorationState::THREE_FINGERS_SWIPE); + } + + SendScreenWakeUpEvent(event); +} + +void TouchExploration::HandleThreeFingersSwipeStateDown(MMI::PointerEvent &event) +{ + Clear(); + HILOG_ERROR("receive down event, currentState is changed from THREE_FINGERS_SWIPE to INVALID."); + SetCurrentState(TouchExplorationState::INVALID); +} + +bool TouchExploration::GetMultiFingerSwipeBasePointerItem(MMI::PointerEvent::PointerItem &basePointerIterm, int32_t pId) +{ + HILOG_DEBUG(); + + if (multiFingerSwipePrePoint_.count(pId) == 0 || !multiFingerSwipePrePoint_[pId]) { + HILOG_ERROR("get base pointEvent(%{public}d) failed", pId); + return false; + } + multiFingerSwipePrePoint_[pId]->GetPointerItem(pId, basePointerIterm); + return true; +} + +bool TouchExploration::SaveMultiFingerSwipeGesturePointerInfo(MMI::PointerEvent &event) +{ + HILOG_DEBUG(); + + MMI::PointerEvent::PointerItem pointerIterm; + int32_t pId = event.GetPointerId(); + event.GetPointerItem(pId, pointerIterm); + + MMI::PointerEvent::PointerItem basePointerIterm; + if (!GetMultiFingerSwipeBasePointerItem(basePointerIterm, pId)) { + HILOG_WARN("get base point item failed, pid = %{public}d.", pId); + return true; + } + + int32_t offsetX = pointerIterm.GetDisplayX() - basePointerIterm.GetDisplayX(); + int32_t offsetY = pointerIterm.GetDisplayY() - basePointerIterm.GetDisplayY(); + if (abs(offsetX) > mMinPixelsBetweenSamplesX_ || abs(offsetY) > mMinPixelsBetweenSamplesY_) { + if (multiFingerSwipeDirection_ != GetSwipeDirection(offsetX, offsetY)) { + Clear(); + if ((event.GetPointerAction() == MMI::PointerEvent::POINTER_ACTION_UP) && + (event.GetPointerIds().size() == POINTER_COUNT_1)) { + HILOG_INFO("direction changed, currentState is changed from THREE_FINGERS_SWIPE to TOUCH_INIT."); + SetCurrentState(TouchExplorationState::TOUCH_INIT); + } else { + HILOG_INFO("direction changed, currentState is changed from THREE_FINGERS_SWIPE to INVALID."); + SetCurrentState(TouchExplorationState::INVALID); + } + return false; + } + + Pointer mp; + mp.px_ = static_cast(pointerIterm.GetDisplayX()); + mp.py_ = static_cast(pointerIterm.GetDisplayY()); + multiFingerSwipeRoute_[pId].push_back(mp); + multiFingerSwipePrePoint_[pId] = std::make_shared(event); + } + + return true; +} + +bool TouchExploration::RecognizeMultiFingerSwipePath(const std::vector &path) +{ + HILOG_DEBUG(); + if (path.size() < MIN_MULTI_FINGER_SWIPE_POINTER_NUM) { + return false; + } + + int pathSize = static_cast(path.size() - 1); + for (int routerIndex = 0; routerIndex < pathSize; 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) != multiFingerSwipeDirection_) { + return false; + } + } + return true; +} + +GestureType TouchExploration::GetMultiFingerSwipeGestureId(int32_t fingerNum) +{ + HILOG_DEBUG(); + + if (fingerNum == POINTER_COUNT_3) { + switch (multiFingerSwipeDirection_) { + case SWIPE_LEFT: + return GestureType::GESTURE_THREE_FINGER_SWIPE_LEFT; + case SWIPE_RIGHT: + return GestureType::GESTURE_THREE_FINGER_SWIPE_RIGHT; + case SWIPE_UP: + return GestureType::GESTURE_THREE_FINGER_SWIPE_UP; + case SWIPE_DOWN: + return GestureType::GESTURE_THREE_FINGER_SWIPE_DOWN; + default: + return GestureType::GESTURE_INVALID; + } + } else if (fingerNum == POINTER_COUNT_4) { + switch (multiFingerSwipeDirection_) { + case SWIPE_LEFT: + return GestureType::GESTURE_FOUR_FINGER_SWIPE_LEFT; + case SWIPE_RIGHT: + return GestureType::GESTURE_FOUR_FINGER_SWIPE_RIGHT; + case SWIPE_UP: + return GestureType::GESTURE_FOUR_FINGER_SWIPE_UP; + case SWIPE_DOWN: + return GestureType::GESTURE_FOUR_FINGER_SWIPE_DOWN; + default: + return GestureType::GESTURE_INVALID; + } + } + return GestureType::GESTURE_INVALID; +} + +void TouchExploration::HandleMultiFingersSwipeStateUp(MMI::PointerEvent &event, int32_t fingerNum) +{ + HILOG_DEBUG(); + + receivedPointerEvents_.push_back(event); + + if (!SaveMultiFingerSwipeGesturePointerInfo(event)) { + return; + } + + if (event.GetPointerIds().size() == POINTER_COUNT_1) { + for (int32_t pIndex = 0; pIndex < fingerNum; pIndex++) { + if (multiFingerSwipeRoute_.count(pIndex) == 0 || + multiFingerSwipeRoute_[pIndex].size() < MIN_MULTI_FINGER_SWIPE_POINTER_NUM) { + Clear(); + HILOG_ERROR("invalid route, currentState is changed from %{public}d to TOUCH_INIT.", GetCurrentState()); + SetCurrentState(TouchExplorationState::TOUCH_INIT); + return; + } + if (!RecognizeMultiFingerSwipePath(multiFingerSwipeRoute_[pIndex])) { + Clear(); + HILOG_ERROR("fail to parse swipe direction, currentState is changed from %{public}d to TOUCH_INIT.", + GetCurrentState()); + SetCurrentState(TouchExplorationState::TOUCH_INIT); + return; + } + } + + GestureType gestureId = GetMultiFingerSwipeGestureId(fingerNum); + SendGestureEventToAA(gestureId); + Clear(); + HILOG_INFO("currentState is changed from %{public}d to TOUCH_INIT.", GetCurrentState()); + SetCurrentState(TouchExplorationState::TOUCH_INIT); + } +} + +void TouchExploration::HandleThreeFingersSwipeStateUp(MMI::PointerEvent &event) +{ + HILOG_DEBUG(); + HandleMultiFingersSwipeStateUp(event, POINTER_COUNT_3); +} + +void TouchExploration::HandleThreeFingersSwipeStateMove(MMI::PointerEvent &event) +{ + HILOG_DEBUG(); + + receivedPointerEvents_.push_back(event); + SaveMultiFingerSwipeGesturePointerInfo(event); + SendScreenWakeUpEvent(event); +} + +void TouchExploration::HandleThreeFingersTapStateDown(MMI::PointerEvent &event) +{ + HILOG_DEBUG(); + HandleMultiFingersTapStateDown(event, POINTER_COUNT_3); +} + +void TouchExploration::HandleThreeFingersTapStateMove(MMI::PointerEvent &event) +{ + HILOG_DEBUG(); + HandleMultiFingersTapStateMove(event, POINTER_COUNT_3); +} + +void TouchExploration::HandleThreeFingersContinueDownStateUp(MMI::PointerEvent &event) +{ + HILOG_DEBUG(); + HandleMultiFingersContinueDownStateUp(event, POINTER_COUNT_3); +} + +void TouchExploration::HandleThreeFingersContinueDownStateMove(MMI::PointerEvent &event) +{ + HILOG_DEBUG(); + HandleMultiFingersContinueDownStateMove(event, POINTER_COUNT_3); +} + +void TouchExploration::HandleFourFingersDownStateDown(MMI::PointerEvent &event) +{ + Clear(); + HILOG_ERROR("receive down event, currentState is changed from FOUR_FINGERS_DOWN to INVALID."); + SetCurrentState(TouchExplorationState::INVALID); +} + +void TouchExploration::HandleFourFingersDownStateUp(MMI::PointerEvent &event) +{ + HILOG_DEBUG(); + + receivedPointerEvents_.push_back(event); + CancelPostEvent(FOUR_FINGER_LONG_PRESS_MSG); + + int32_t pointerSize = static_cast(event.GetPointerIds().size()); + if (pointerSize == POINTER_COUNT_1) { + HILOG_INFO("currentState is changed from FOUR_FINGERS_DOWN to FOUR_FINGERS_TAP."); + SetCurrentState(TouchExplorationState::FOUR_FINGERS_TAP); + } else if (pointerSize > POINTER_COUNT_4) { + Clear(); + CancelPostEvent(FOUR_FINGER_SINGLE_TAP_MSG); + HILOG_ERROR("invalid pointer num, currentState is changed from FOUR_FINGERS_DOWN to INVALID."); + SetCurrentState(TouchExplorationState::INVALID); + } +} + +void TouchExploration::HandleFourFingersDownStateMove(MMI::PointerEvent &event) +{ + HILOG_DEBUG(); + + receivedPointerEvents_.push_back(event); + + MMI::PointerEvent::PointerItem pointerIterm; + event.GetPointerItem(event.GetPointerId(), pointerIterm); + MMI::PointerEvent::PointerItem basePointerIterm; + if (!GetBasePointItem(basePointerIterm, event.GetPointerId())) { + HILOG_ERROR("get base point item failed, pid = %{public}d.", event.GetPointerId()); + return; + } + + int32_t offsetX = pointerIterm.GetDisplayX() - basePointerIterm.GetDisplayX(); + int32_t offsetY = pointerIterm.GetDisplayY() - basePointerIterm.GetDisplayY(); + if (hypot(offsetX, offsetY) > TOUCH_SLOP * POINTER_COUNT_4) { + CancelPostEvent(FOUR_FINGER_SINGLE_TAP_MSG); + CancelPostEvent(FOUR_FINGER_LONG_PRESS_MSG); + if (event.GetPointerIds().size() != POINTER_COUNT_4) { + Clear(); + SendScreenWakeUpEvent(event); + HILOG_ERROR("invalid pointer num, currentState is changed from FOUR_FINGERS_DOWN to INVALID."); + SetCurrentState(TouchExplorationState::INVALID); + return; + } + StoreMultiFingerSwipeBaseDownPoint(); + multiFingerSwipeDirection_ = GetSwipeDirection(offsetX, offsetY); + HILOG_INFO("currentState is changed from FOUR_FINGERS_DOWN to FOUR_FINGERS_SWIPE."); + SetCurrentState(TouchExplorationState::FOUR_FINGERS_SWIPE); + } + + SendScreenWakeUpEvent(event); +} + +void TouchExploration::HandleFourFingersSwipeStateDown(MMI::PointerEvent &event) +{ + Clear(); + HILOG_ERROR("receive down event, currentState is changed from FOUR_FINGERS_SWIPE to INVALID."); + SetCurrentState(TouchExplorationState::INVALID); +} + +void TouchExploration::HandleFourFingersSwipeStateUp(MMI::PointerEvent &event) +{ + HILOG_DEBUG(); + HandleMultiFingersSwipeStateUp(event, POINTER_COUNT_4); +} + +void TouchExploration::HandleFourFingersSwipeStateMove(MMI::PointerEvent &event) +{ + HILOG_DEBUG(); + + receivedPointerEvents_.push_back(event); + SaveMultiFingerSwipeGesturePointerInfo(event); + SendScreenWakeUpEvent(event); +} + +void TouchExploration::HandleFourFingersTapStateDown(MMI::PointerEvent &event) +{ + HILOG_DEBUG(); + HandleMultiFingersTapStateDown(event, POINTER_COUNT_4); +} + +void TouchExploration::HandleFourFingersTapStateMove(MMI::PointerEvent &event) +{ + HILOG_DEBUG(); + HandleMultiFingersTapStateMove(event, POINTER_COUNT_4); +} + +void TouchExploration::HandleFourFingersContinueDownStateUp(MMI::PointerEvent &event) +{ + HILOG_DEBUG(); + HandleMultiFingersContinueDownStateUp(event, POINTER_COUNT_4); +} + +void TouchExploration::HandleFourFingersContinueDownStateMove(MMI::PointerEvent &event) +{ + HILOG_DEBUG(); + HandleMultiFingersContinueDownStateMove(event, POINTER_COUNT_4); +} + +void TouchExploration::CancelPostEvent(uint32_t innerEventID) +{ + HILOG_DEBUG("innerEventID = %{public}u", innerEventID); + if (handler_->HasInnerEvent(innerEventID)) { + handler_->RemoveEvent(innerEventID); + } +} + +void TouchExploration::CancelMultiFingerTapEvent() +{ + HILOG_DEBUG(); + CancelPostEvent(TWO_FINGER_SINGLE_TAP_MSG); + CancelPostEvent(TWO_FINGER_DOUBLE_TAP_MSG); + CancelPostEvent(TWO_FINGER_TRIPLE_TAP_MSG); + CancelPostEvent(THREE_FINGER_SINGLE_TAP_MSG); + CancelPostEvent(THREE_FINGER_DOUBLE_TAP_MSG); + CancelPostEvent(THREE_FINGER_TRIPLE_TAP_MSG); + CancelPostEvent(FOUR_FINGER_SINGLE_TAP_MSG); + CancelPostEvent(FOUR_FINGER_DOUBLE_TAP_MSG); + CancelPostEvent(FOUR_FINGER_TRIPLE_TAP_MSG); +} + +void TouchExploration::CancelMultiFingerTapAndHoldEvent() +{ + HILOG_DEBUG(); + CancelPostEvent(TWO_FINGER_DOUBLE_TAP_AND_HOLD_MSG); + CancelPostEvent(TWO_FINGER_TRIPLE_TAP_AND_HOLD_MSG); + CancelPostEvent(THREE_FINGER_DOUBLE_TAP_AND_HOLD_MSG); + CancelPostEvent(THREE_FINGER_TRIPLE_TAP_AND_HOLD_MSG); + CancelPostEvent(FOUR_FINGER_DOUBLE_TAP_AND_HOLD_MSG); + CancelPostEvent(FOUR_FINGER_TRIPLE_TAP_AND_HOLD_MSG); +} + +void TouchExploration::Clear() +{ + HILOG_DEBUG(); + receivedPointerEvents_.clear(); + injectedPointerDownEvents_.clear(); + offsetX_ = 0; + offsetY_ = 0; + oneFingerSwipeRoute_.clear(); + oneFingerSwipePrePointer_ = {}; + draggingPid_ = -1; + multiTapNum_ = 0; + multiFingerSwipeDirection_ = -1; + multiFingerSwipeRoute_.clear(); + multiFingerSwipePrePoint_.clear(); +} +} // namespace Accessibility +} // namespace OHOS \ No newline at end of file diff --git a/services/aams/src/accessibility_touch_guider.cpp b/services/aams/src/accessibility_touch_guider.cpp deleted file mode 100755 index 6c723df5..00000000 --- a/services/aams/src/accessibility_touch_guider.cpp +++ /dev/null @@ -1,1209 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed On an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "accessibility_touch_guider.h" -#include "accessibility_window_manager.h" -#include "accessibility_event_info.h" -#include "hilog_wrapper.h" -#include "securec.h" -#include "utils.h" - -namespace OHOS { -namespace Accessibility { -namespace { - constexpr int32_t POINTER_COUNT_1 = 1; - constexpr int32_t POINTER_COUNT_2 = 2; - constexpr int32_t SCREEN_AXIS_NUM = 2; - constexpr int32_t REMOVE_POINTER_ID_1 = 1; - constexpr int64_t IGNORE_REPEAT_EXECUTE_INTERVAL = 300; -} // namespace - -TGEventHandler::TGEventHandler( - const std::shared_ptr &runner, TouchGuider &tgServer) - : AppExecFwk::EventHandler(runner), tgServer_(tgServer) -{ -} - -int64_t TouchGuider::lastDoubleTapTime = 0; - -TouchGuider::TouchGuider() -{ - HILOG_DEBUG(); - currentState_ = static_cast(TouchGuideState::TOUCH_GUIDING); -} - -void TouchGuider::StartUp() -{ - HILOG_DEBUG(); - touchGuideListener_ = std::make_unique(*this); - gestureRecognizer_.RegisterListener(*touchGuideListener_.get()); - multiFingerGestureRecognizer_.RegisterListener(*touchGuideListener_.get()); - - runner_ = Singleton::GetInstance().GetMainRunner(); - if (!runner_) { - HILOG_ERROR("get runner failed"); - return; - } - - handler_ = std::make_shared(runner_, *this); - if (!handler_) { - HILOG_ERROR("create event handler failed"); - return; - } -} - -void TGEventHandler::ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event) -{ - HILOG_DEBUG(); - switch (event->GetInnerEventId()) { - case TouchGuider::EXIT_GESTURE_REC_MSG: - tgServer_.SendAccessibilityEventToAA(EventType::TYPE_TOUCH_GUIDE_GESTURE_END); - break; - case TouchGuider::SEND_HOVER_ENTER_MOVE_MSG: - HoverEnterAndMoveRunner(); - break; - case TouchGuider::SEND_HOVER_EXIT_MSG: - HoverExitRunner(); - break; - case TouchGuider::SEND_TOUCH_GUIDE_END_MSG: - tgServer_.SendAccessibilityEventToAA(EventType::TYPE_TOUCH_GUIDE_END); - break; - default: - break; - } -} - -void TouchGuider::SendTouchEventToAA(MMI::PointerEvent &event) -{ - HILOG_DEBUG(); - - if (event.GetPointerIds().size() != POINTER_COUNT_1) { - return; - } - - MMI::PointerEvent::PointerItem pointerIterm = {}; - if (!event.GetPointerItem(event.GetPointerId(), pointerIterm)) { - HILOG_WARN("GetPointerItem(%{public}d) failed", event.GetPointerId()); - } - - if (event.GetPointerAction() == MMI::PointerEvent::POINTER_ACTION_DOWN) { - SendAccessibilityEventToAA(EventType::TYPE_TOUCH_BEGIN); - } else if (!pointerIterm.IsPressed()) { - SendAccessibilityEventToAA(EventType::TYPE_TOUCH_END); - } -} - -bool TouchGuider::OnPointerEvent(MMI::PointerEvent &event) -{ - HILOG_DEBUG(); - if (event.GetSourceType() != MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN) { - EventTransmission::OnPointerEvent(event); - return false; - } - - if (event.GetPointerAction() == MMI::PointerEvent::POINTER_ACTION_DOWN || - event.GetPointerAction() == MMI::PointerEvent::POINTER_ACTION_UP) { - HILOG_INFO("PointerAction:%{public}d, PointerId:%{public}d.", event.GetPointerAction(), - event.GetPointerId()); - } - SendTouchEventToAA(event); - - if (event.GetPointerAction() == MMI::PointerEvent::POINTER_ACTION_CANCEL) { - if ((static_cast(currentState_) == TouchGuideState::DRAGGING) && - event.GetPointerId() == currentPid_) { - EventTransmission::OnPointerEvent(event); - } else if (static_cast(currentState_) != TouchGuideState::DRAGGING) { - Clear(event); - } - event.SetPointerAction(MMI::PointerEvent::POINTER_ACTION_HOVER_CANCEL); - EventTransmission::OnPointerEvent(event); - return true; - } - RecordReceivedEvent(event); - - bool gestureRecognizedFlag = false; - if (!multiFingerGestureRecognizer_.IsMultiFingerGestureStarted() && - gestureRecognizer_.OnPointerEvent(event)) { - gestureRecognizedFlag = true; - } - if (gestureRecognizer_.GetIsDoubleTap() && gestureRecognizer_.GetIsLongpress()) { - HILOG_DEBUG("recognize doubleTap and longpress"); - if (doubleTapLongPressDownEvent_ != nullptr) { - SendEventToMultimodal(*doubleTapLongPressDownEvent_, NO_CHANGE); - doubleTapLongPressDownEvent_ = nullptr; - } - SendEventToMultimodal(event, NO_CHANGE); - gestureRecognizedFlag = true; - } - - multiFingerGestureRecognizer_.OnPointerEvent(event); - - if (!gestureRecognizedFlag) { - HandlePointerEvent(event); - } - return true; -} - -void TouchGuider::HandlePointerEvent(MMI::PointerEvent &event) -{ - switch (static_cast(currentState_)) { - case TouchGuideState::TOUCH_GUIDING: - if (event.GetPointerAction() == MMI::PointerEvent::POINTER_ACTION_DOWN && - event.GetPointerIds().size() == POINTER_COUNT_1) { - cachedPointerEvents_.clear(); - } - cachedPointerEvents_.push_back(event); - HandleTouchGuidingState(event); - break; - case TouchGuideState::DRAGGING: - HandleDraggingState(event); - break; - case TouchGuideState::TRANSMITTING: - HandleTransmitingState(event); - break; - case TouchGuideState::PASSING_THROUGH: - HandlePassingThroughState(event); - break; - default: - break; - } -} - -void TouchGuider::DestroyEvents() -{ - HILOG_DEBUG(); - - Clear(); - EventTransmission::DestroyEvents(); -} - -void TouchGuider::SendAccessibilityEventToAA(EventType eventType) -{ - HILOG_DEBUG("eventType is 0x%{public}x.", eventType); - - AccessibilityEventInfo eventInfo {}; - eventInfo.SetEventType(eventType); - int32_t windowsId = Singleton::GetInstance().GetActiveWindowId(); - eventInfo.SetWindowId(windowsId); - Singleton::GetInstance().SendEvent(eventInfo); - if (eventType == EventType::TYPE_TOUCH_GUIDE_BEGIN) { - isTouchGuiding_ = true; - } else if (eventType == EventType::TYPE_TOUCH_GUIDE_END) { - isTouchGuiding_ = false; - } -} - -void TouchGuider::SendGestureEventToAA(GestureType gestureId) -{ - HILOG_DEBUG("gestureId is %{public}d.", gestureId); - - AccessibilityEventInfo eventInfo {}; - int32_t windowsId = Singleton::GetInstance().GetActiveWindowId(); - eventInfo.SetWindowId(windowsId); - eventInfo.SetEventType(EventType::TYPE_GESTURE_EVENT); - eventInfo.SetGestureType(gestureId); - Singleton::GetInstance().SendEvent(eventInfo); -} - -void TouchGuider::OffsetEvent(MMI::PointerEvent &event) -{ - HILOG_DEBUG("OffsetEvent"); - MMI::PointerEvent::PointerItem pointer = {}; - event.GetPointerItem(event.GetPointerId(), pointer); - - // add offset - int32_t newDisplayX = pointer.GetDisplayX() + static_cast(longPressOffsetX_); - int32_t newDisplayY = pointer.GetDisplayY() + static_cast(longPressOffsetY_); - - HILOG_DEBUG("newDisplayX: %{public}d, newDisplayY: %{public}d", newDisplayX, newDisplayY); - pointer.SetDisplayX(newDisplayX); - pointer.SetDisplayY(newDisplayY); - event.RemovePointerItem(event.GetPointerId()); - event.AddPointerItem(pointer); -} - -void TouchGuider::SendEventToMultimodal(MMI::PointerEvent &event, int32_t action) -{ - HILOG_DEBUG("action:%{public}d, SourceType:%{public}d.", action, event.GetSourceType()); - - if (gestureRecognizer_.GetIsDoubleTap() && gestureRecognizer_.GetIsLongpress()) { - bool focusedElementExistFlag = true; - if (!focusedElementExist_) { - HILOG_DEBUG("send long press event to multimodal, but no focused element."); - focusedElementExistFlag = false; - } - OffsetEvent(event); - if (event.GetPointerAction() == MMI::PointerEvent::POINTER_ACTION_UP && - event.GetPointerIds().size() == POINTER_COUNT_1) { - HILOG_INFO("doubleTap and longpress end"); - Clear(event); - } - if (!focusedElementExistFlag) { - return; - } - } - - switch (action) { - case HOVER_MOVE: - if (event.GetSourceType() == MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN) { - event.SetPointerAction(MMI::PointerEvent::POINTER_ACTION_HOVER_MOVE); - } - break; - case POINTER_DOWN: - if (event.GetSourceType() == MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN) { - event.SetPointerAction(MMI::PointerEvent::POINTER_ACTION_DOWN); - } - break; - case POINTER_UP: - if (event.GetSourceType() == MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN) { - event.SetPointerAction(MMI::PointerEvent::POINTER_ACTION_UP); - } - break; - case HOVER_ENTER: - if (event.GetSourceType() == MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN) { - event.SetPointerAction(MMI::PointerEvent::POINTER_ACTION_HOVER_ENTER); - } - break; - case HOVER_EXIT: - if (event.GetSourceType() == MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN) { - event.SetPointerAction(MMI::PointerEvent::POINTER_ACTION_HOVER_EXIT); - } - break; - default: - break; - } - EventTransmission::OnPointerEvent(event); - RecordInjectedEvent(event); -} - -std::list TouchGuider::getHoverEnterAndMoveEvent() -{ - HILOG_DEBUG(); - - return pointerEvents_; -} - -void TouchGuider::ClearHoverEnterAndMoveEvent() -{ - HILOG_DEBUG(); - - pointerEvents_.clear(); - gestureRecognizer_.Clear(); -} - -std::shared_ptr TouchGuider::getLastReceivedEvent() -{ - HILOG_DEBUG(); - - return receivedRecorder_.lastEvent; -} - -bool TouchGuider::TouchGuideListener::OnDoubleTap(MMI::PointerEvent &event) -{ - HILOG_INFO(); - - if (server_.currentState_ != static_cast(TouchGuideState::TOUCH_GUIDING)) { - return false; - } - server_.OnTouchInteractionEnd(); - server_.CancelPostEventIfNeed(server_.SEND_HOVER_ENTER_MOVE_MSG); - server_.CancelPostEventIfNeed(server_.SEND_HOVER_EXIT_MSG); - server_.ForceSendAndRemoveEvent(server_.SEND_TOUCH_GUIDE_END_MSG, event); - - return server_.ExecuteActionOnAccessibilityFocused(ActionType::ACCESSIBILITY_ACTION_CLICK); -} - -bool TouchGuider::TouchGuideListener::OnStarted() -{ - HILOG_DEBUG(); - - server_.currentState_ = static_cast(TouchGuideState::TRANSMITTING); - server_.CancelPostEventIfNeed(SEND_HOVER_ENTER_MOVE_MSG); - server_.CancelPostEventIfNeed(SEND_HOVER_EXIT_MSG); - server_.PostGestureRecognizeExit(); - server_.SendAccessibilityEventToAA(EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN); - return true; -} - -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(); - server_.SendAccessibilityEventToAA(EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN); -} - -bool TouchGuider::TouchGuideListener::OnCompleted(GestureType gestureId) -{ - HILOG_INFO("gestureId is %{public}d", gestureId); - - if (server_.currentState_ != static_cast(TouchGuideState::TRANSMITTING)) { - HILOG_DEBUG("OnCompleted, state is not transmitting."); - return false; - } - server_.OnTouchInteractionEnd(); - server_.SendAccessibilityEventToAA(EventType::TYPE_TOUCH_GUIDE_GESTURE_END); - server_.CancelPostEvent(EXIT_GESTURE_REC_MSG); - server_.currentState_ = static_cast(TouchGuideState::TOUCH_GUIDING); - - // Send customize gesture type to aa - server_.SendGestureEventToAA(gestureId); - return true; -} - -void TouchGuider::TouchGuideListener::MultiFingerGestureOnCompleted(GestureType gestureId) -{ - HILOG_INFO("gestureId is %{public}d", gestureId); - - server_.OnTouchInteractionEnd(); - server_.SendAccessibilityEventToAA(EventType::TYPE_TOUCH_GUIDE_GESTURE_END); - server_.CancelPostEvent(EXIT_GESTURE_REC_MSG); - server_.currentState_ = static_cast(TouchGuideState::TOUCH_GUIDING); - - // Send customize gesture type to aa - server_.SendGestureEventToAA(gestureId); -} - -bool TouchGuider::TouchGuideListener::OnCancelled(MMI::PointerEvent &event) -{ - HILOG_DEBUG(); - - switch (static_cast(server_.currentState_)) { - case TouchGuideState::TRANSMITTING: - server_.SendAccessibilityEventToAA(EventType::TYPE_TOUCH_GUIDE_GESTURE_END); - if (event.GetPointerAction() == MMI::PointerEvent::POINTER_ACTION_UP && - event.GetPointerIds().size() == POINTER_COUNT_1) { - server_.OnTouchInteractionEnd(); - } - server_.CancelPostEvent(EXIT_GESTURE_REC_MSG); - server_.currentState_ = static_cast(TouchGuideState::TOUCH_GUIDING); - break; - case TouchGuideState::TOUCH_GUIDING: - server_.pointerEvents_.push_back(event); - server_.ForceSendAndRemoveEvent(SEND_HOVER_ENTER_MOVE_MSG, event); - server_.CancelPostEventIfNeed(SEND_HOVER_EXIT_MSG); - server_.SendEventToMultimodal(event, HOVER_MOVE); - break; - default: - return false; - } - return true; -} - -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) { - server_.OnTouchInteractionEnd(); - } -} - -void TouchGuider::ElementOperatorCallbackImpl::SetFindFocusedElementInfoResult(const AccessibilityElementInfo &info, - const int32_t requestId) -{ - HILOG_DEBUG("Response [requestId:%{public}d]", requestId); - accessibilityInfoResult_ = info; - promise_.set_value(); -} - -void TouchGuider::ElementOperatorCallbackImpl::SetSearchElementInfoByTextResult( - const std::vector &infos, const int32_t requestId) -{ - HILOG_DEBUG("Response [requestId:%{public}d]", requestId); - elementInfosResult_ = infos; - promise_.set_value(); -} - -void TouchGuider::ElementOperatorCallbackImpl::SetSearchElementInfoByAccessibilityIdResult( - const std::vector &infos, const int32_t requestId) -{ - HILOG_DEBUG("Response [requestId:%{public}d]", requestId); - elementInfosResult_ = infos; - promise_.set_value(); -} - -void TouchGuider::ElementOperatorCallbackImpl::SetFocusMoveSearchResult(const AccessibilityElementInfo &info, - const int32_t requestId) -{ - HILOG_DEBUG("Response [requestId:%{public}d]", requestId); - accessibilityInfoResult_ = info; - promise_.set_value(); -} - -void TouchGuider::ElementOperatorCallbackImpl::SetExecuteActionResult(const bool succeeded, const int32_t requestId) -{ - HILOG_DEBUG("Response [result:%{public}d, requestId:%{public}d]", succeeded, requestId); - executeActionResult_ = succeeded; - promise_.set_value(); -} - -void TouchGuider::HandleTouchGuidingState(MMI::PointerEvent &event) -{ - HILOG_DEBUG("action: %{public}d", event.GetPointerAction()); - - switch (event.GetPointerAction()) { - case MMI::PointerEvent::POINTER_ACTION_DOWN: - if (event.GetPointerIds().size() == POINTER_COUNT_1) { - HandleTouchGuidingStateInnerDown(event); - } else if (gestureRecognizer_.GetIsDoubleTap() && gestureRecognizer_.GetIsLongpress()) { - SendEventToMultimodal(event, NO_CHANGE); - } else { - CancelPostEventIfNeed(SEND_HOVER_ENTER_MOVE_MSG); - CancelPostEventIfNeed(SEND_HOVER_EXIT_MSG); - } - break; - case MMI::PointerEvent::POINTER_ACTION_MOVE: - HandleTouchGuidingStateInnerMove(event); - break; - case MMI::PointerEvent::POINTER_ACTION_UP: - if (event.GetPointerIds().size() == POINTER_COUNT_1 && !IsTouchInteractionEnd() && - !multiFingerGestureRecognizer_.IsMultiFingerRecognize()) { - if (gestureRecognizer_.GetIsDoubleTap() && gestureRecognizer_.GetIsLongpress()) { - HILOG_DEBUG(); - SendEventToMultimodal(event, NO_CHANGE); - Clear(event); - break; - } - OnTouchInteractionEnd(); - if (HasEventPending(SEND_HOVER_ENTER_MOVE_MSG)) { - PostHoverExit(); - } else if (isTouchGuiding_) { - SendExitEvents(); - PostHoverExit(); - } - } - break; - case MMI::PointerEvent::POINTER_ACTION_PULL_MOVE: - SendEventToMultimodal(event, NO_CHANGE); - break; - case MMI::PointerEvent::POINTER_ACTION_PULL_UP: - SendEventToMultimodal(event, NO_CHANGE); - break; - default: - break; - } -} - -void TouchGuider::HandleDraggingState(MMI::PointerEvent &event) -{ - HILOG_DEBUG(); - std::vector pIds = event.GetPointerIds(); - switch (event.GetPointerAction()) { - case MMI::PointerEvent::POINTER_ACTION_DOWN: - if (event.GetPointerIds().size() == POINTER_COUNT_1) { - Clear(event); - } else { - currentState_ = static_cast(TouchGuideState::TRANSMITTING); - SendAllUpEvents(event); - } - break; - case MMI::PointerEvent::POINTER_ACTION_MOVE: - if (event.GetPointerId() == currentPid_) { - HandleDraggingStateInnerMove(event); - } - break; - case MMI::PointerEvent::POINTER_ACTION_UP: - if (pIds.size() == POINTER_COUNT_1) { - if (event.GetPointerId() == currentPid_) { - HILOG_DEBUG("single currentPid_ move: %{public}d", event.GetPointerId()); - OnTouchInteractionEnd(); - SendEventToMultimodal(event, NO_CHANGE); - currentState_ = static_cast(TouchGuideState::TOUCH_GUIDING); - } - } else { - if (event.GetPointerId() == currentPid_ && pIds.size() == POINTER_COUNT_2) { - HILOG_DEBUG("double currentPid_ move: %{public}d", event.GetPointerId()); - int32_t removePid = currentPid_ == pIds[0]? pIds[1] : pIds[0]; - event.RemovePointerItem(removePid); - OnTouchInteractionEnd(); - SendEventToMultimodal(event, NO_CHANGE); - currentState_ = static_cast(TouchGuideState::TOUCH_GUIDING); - } - } - - break; - default: - break; - } -} - -void TouchGuider::HandleTransmitingState(MMI::PointerEvent &event) -{ - HILOG_DEBUG(); - - switch (event.GetPointerAction()) { - case MMI::PointerEvent::POINTER_ACTION_DOWN: - if (event.GetPointerIds().size() == POINTER_COUNT_1) { - Clear(event); - } - break; - case MMI::PointerEvent::POINTER_ACTION_UP: - if (event.GetPointerIds().size() == POINTER_COUNT_1 && !IsTouchInteractionEnd() && - !multiFingerGestureRecognizer_.IsMultiFingerRecognize()) { - if (longPressPointId_ >= 0) { - // Adjust this event's location. - MMI::PointerEvent::PointerItem pointer = {}; - event.GetPointerItem(event.GetPointerId(), pointer); - pointer.SetDisplayX(pointer.GetDisplayX() + longPressOffsetX_); - pointer.SetDisplayY(pointer.GetDisplayY() + longPressOffsetY_); - event.RemovePointerItem(event.GetPointerId()); - event.AddPointerItem(pointer); - longPressPointId_ = INIT_POINT_ID; - longPressOffsetX_ = INIT_MMIPOINT; - longPressOffsetY_ = INIT_MMIPOINT; - } - SendEventToMultimodal(event, NO_CHANGE); - OnTouchInteractionEnd(); - currentState_ = static_cast(TouchGuideState::TOUCH_GUIDING); - } - break; - default: - MMI::PointerEvent::PointerItem pointerItem = {}; - for (auto& pid : event.GetPointerIds()) { - event.GetPointerItem(pid, pointerItem); - pointerItem.SetPressed(false); - event.RemovePointerItem(pid); - event.AddPointerItem(pointerItem); - } - SendEventToMultimodal(event, NO_CHANGE); - break; - } -} - -void TouchGuider::HandlePassingThroughState(MMI::PointerEvent &event) -{ - HILOG_DEBUG(); - - if (event.GetPointerAction() == MMI::PointerEvent::POINTER_ACTION_UP && - event.GetPointerIds().size() == POINTER_COUNT_1) { - SendEventToMultimodal(event, NO_CHANGE); - OnTouchInteractionEnd(); - currentState_ = static_cast(TouchGuideState::TOUCH_GUIDING); - return; - } - - SendEventToMultimodal(event, NO_CHANGE); - return; -} - -void TouchGuider::Clear(MMI::PointerEvent &event) -{ - HILOG_DEBUG(); - - if (currentState_ == static_cast(TouchGuideState::TOUCH_GUIDING)) { - SendExitEvents(); - } else if (currentState_ == static_cast(TouchGuideState::DRAGGING) || - currentState_ == static_cast(TouchGuideState::TRANSMITTING)) { - SendUpForAllInjectedEvent(event); - } - - CancelPostEvent(EXIT_GESTURE_REC_MSG); - CancelPostEvent(SEND_TOUCH_GUIDE_END_MSG); - CancelPostEventIfNeed(SEND_HOVER_ENTER_MOVE_MSG); - CancelPostEventIfNeed(SEND_HOVER_EXIT_MSG); - ClearInjectedEventRecorder(); - ClearReceivedEventRecorder(); - pointerEvents_.clear(); - currentState_ = static_cast(TouchGuideState::TOUCH_GUIDING); - isTouchGuiding_ = false; - gestureRecognizer_.Clear(); - longPressPointId_ = INIT_POINT_ID; - longPressOffsetX_ = INIT_MMIPOINT; - longPressOffsetY_ = INIT_MMIPOINT; - leftTopX_ = INIT_POINT_DISPLAY; - leftTopY_ = INIT_POINT_DISPLAY; - rightBottomX_ = INIT_POINT_DISPLAY; - rightBottomY_ = INIT_POINT_DISPLAY; - focusedElementExist_ = false; - currentPid_ = -1; - cachedPointerEvents_.clear(); - OnTouchInteractionEnd(); -} - -void TouchGuider::Clear() -{ - HILOG_DEBUG(); - - std::shared_ptr event = getLastReceivedEvent(); - if (event) { - Clear(*event); - } -} - -void TouchGuider::SendExitEvents() -{ - HILOG_DEBUG(); - - if (!HasEventPending(SEND_TOUCH_GUIDE_END_MSG)) { - PostAccessibilityEvent(SEND_TOUCH_GUIDE_END_MSG); - } -} - -void TouchGuider::HandleTouchGuidingStateInnerDown(MMI::PointerEvent &event) -{ - HILOG_DEBUG(); - - OnTouchInteractionStart(); - CancelPostEventIfNeed(SEND_HOVER_ENTER_MOVE_MSG); - CancelPostEventIfNeed(SEND_HOVER_EXIT_MSG); - if (isTouchGuiding_) { - SendExitEvents(); - } - if (!gestureRecognizer_.IsfirstTap() && !multiFingerGestureRecognizer_.IsMultiFingerGestureStarted()) { - ForceSendAndRemoveEvent(SEND_TOUCH_GUIDE_END_MSG, event); - if (!isTouchGuiding_) { - if (!HasEventPending(SEND_HOVER_ENTER_MOVE_MSG)) { - PostHoverEnterAndMove(event); - } else { - pointerEvents_.push_back(event); - } - } - } else if (gestureRecognizer_.GetIsDoubleTap() && !multiFingerGestureRecognizer_.IsMultiFingerGestureStarted()) { - doubleTapLongPressDownEvent_ = nullptr; - - AccessibilityElementInfo focusedElementInfo = {}; - if (!FindFocusedElement(focusedElementInfo)) { - HILOG_ERROR("FindFocusedElement failed."); - return; - } - HILOG_DEBUG("FindFocusedElement success"); - MMI::PointerEvent::PointerItem pointerIterm = {}; - if (!event.GetPointerItem(event.GetPointerId(), pointerIterm)) { - HILOG_ERROR("event.GetPointerItem failed"); - return; - } - HILOG_DEBUG("GetPointerItem success"); - focusedElementExist_ = true; - - // set point x,y range and offset - leftTopX_ = focusedElementInfo.GetRectInScreen().GetLeftTopXScreenPostion(); - leftTopY_ = focusedElementInfo.GetRectInScreen().GetLeftTopYScreenPostion(); - rightBottomX_ = focusedElementInfo.GetRectInScreen().GetRightBottomXScreenPostion(); - rightBottomY_ = focusedElementInfo.GetRectInScreen().GetRightBottomYScreenPostion(); - longPressOffsetX_ = static_cast(DIVIDE_2(leftTopX_ + rightBottomX_) - pointerIterm.GetDisplayX()); - longPressOffsetY_ = static_cast(DIVIDE_2(leftTopY_ + rightBottomY_) - pointerIterm.GetDisplayY()); - - doubleTapLongPressDownEvent_ = std::make_shared(event); - } -} - -void TouchGuider::SendPointerDownEventToMultimodal(MMI::PointerEvent event, int32_t action) -{ - currentPid_ = event.GetPointerId(); - int32_t xPointDown = 0; - int32_t yPointDown = 0; - int64_t actionTime = 0; - - if (receivedRecorder_.pointerDownX.find(currentPid_) != receivedRecorder_.pointerDownX.end()) { - xPointDown = receivedRecorder_.pointerDownX.find(currentPid_)->second; - yPointDown = receivedRecorder_.pointerDownY.find(currentPid_)->second; - actionTime = receivedRecorder_.pointerActionTime.find(currentPid_)->second; - } - - HILOG_DEBUG("first down point info is: xPos: %{public}d, yPos: %{public}d, actionTime: [%{public}" PRId64 "], " - "currentTime: [%{public}" PRId64 "]", xPointDown, yPointDown, actionTime, event.GetActionTime()); - MMI::PointerEvent::PointerItem pointer = {}; - event.GetPointerItem(currentPid_, pointer); - pointer.SetDisplayX(xPointDown); - pointer.SetDisplayY(yPointDown); - event.RemovePointerItem(currentPid_); - event.AddPointerItem(pointer); - event.SetActionTime(actionTime); - int32_t removePid = currentPid_ == 0 ? REMOVE_POINTER_ID_1 : 0; - event.RemovePointerItem(removePid); - SendEventToMultimodal(event, action); -} - -void TouchGuider::HandleTouchGuidingStateInnerMove(MMI::PointerEvent &event) -{ - HILOG_DEBUG(); - - switch (event.GetPointerIds().size()) { - case POINTER_COUNT_1: - if (HasEventPending(SEND_HOVER_ENTER_MOVE_MSG)) { - pointerEvents_.push_back(event); - } else if (isTouchGuiding_) { - SendEventToMultimodal(event, HOVER_MOVE); - } else if (gestureRecognizer_.GetIsDoubleTap() && gestureRecognizer_.GetIsLongpress()) { - HILOG_DEBUG(); - if (doubleTapLongPressDownEvent_ != nullptr) { - HILOG_DEBUG("doubleTapLongPressDownEvent_ is not null"); - SendEventToMultimodal(*doubleTapLongPressDownEvent_, NO_CHANGE); - doubleTapLongPressDownEvent_ = nullptr; - } - SendEventToMultimodal(event, NO_CHANGE); - } else { - HILOG_DEBUG("other case"); - } - break; - case POINTER_COUNT_2: - CancelPostEventIfNeed(SEND_HOVER_ENTER_MOVE_MSG); - CancelPostEventIfNeed(SEND_HOVER_EXIT_MSG); - if (!IsRealMoveState(event)) { - HILOG_DEBUG("not a move"); - break; - } - if (IsDragGestureAccept(event)) { - currentState_ = static_cast(TouchGuideState::DRAGGING); - SendPointerDownEventToMultimodal(event, POINTER_DOWN); - SendEventToMultimodal(event, NO_CHANGE); - } else { - for (auto iter = cachedPointerEvents_.begin(); iter != cachedPointerEvents_.end(); ++iter) { - EventTransmission::OnPointerEvent(*iter); - } - cachedPointerEvents_.clear(); - currentState_ = static_cast(TouchGuideState::PASSING_THROUGH); - } - break; - default: - if (HasEventPending(SEND_HOVER_ENTER_MOVE_MSG)) { - CancelPostEventIfNeed(SEND_HOVER_ENTER_MOVE_MSG); - CancelPostEventIfNeed(SEND_HOVER_EXIT_MSG); - } else { - SendExitEvents(); - } - currentState_ = static_cast(TouchGuideState::TRANSMITTING); - break; - } -} - -void TouchGuider::HandleDraggingStateInnerMove(MMI::PointerEvent &event) -{ - HILOG_DEBUG(); - std::vector pIds = event.GetPointerIds(); - uint32_t pointCount = pIds.size(); - if (pointCount == POINTER_COUNT_1) { - HILOG_DEBUG("Only two pointers can be received in the dragging state"); - } else if (pointCount == POINTER_COUNT_2) { -#ifdef OHOS_BUILD_ENABLE_DISPLAY_MANAGER - // Get densityPixels from WMS - AccessibilityDisplayManager &displayMgr = Singleton::GetInstance(); - auto display = displayMgr.GetDefaultDisplay(); - float densityPixels = display->GetVirtualPixelRatio(); - int32_t miniZoomPointerDistance = static_cast(MINI_POINTER_DISTANCE_DIP * densityPixels); -#else - HILOG_DEBUG("not support display manager"); - int32_t miniZoomPointerDistance = static_cast(MINI_POINTER_DISTANCE_DIP * 1); -#endif - MMI::PointerEvent::PointerItem pointerF = {}; - MMI::PointerEvent::PointerItem pointerS = {}; - event.GetPointerItem(pIds[INDEX_0], pointerF); - event.GetPointerItem(pIds[INDEX_1], pointerS); - float xPointF = pointerF.GetDisplayX(); - float xPointS = pointerS.GetDisplayX(); - float yPointF = pointerF.GetDisplayY(); - float yPointS = pointerS.GetDisplayY(); - float offsetX = abs(xPointF - xPointS); - float offsetY = abs(yPointF - yPointS); - double duration = hypot(offsetX, offsetY); - if (duration > miniZoomPointerDistance) { - // Adjust this event's location. - MMI::PointerEvent::PointerItem pointer = {}; - event.GetPointerItem(event.GetPointerId(), pointer); - pointer.SetDisplayX(pointer.GetDisplayX() + DIVIDE_2(offsetX)); - pointer.SetDisplayY(pointer.GetDisplayY() + DIVIDE_2(offsetY)); - event.RemovePointerItem(event.GetPointerId()); - event.AddPointerItem(pointer); - } - int32_t removePid = currentPid_ == pIds[0]? pIds[1] : pIds[0]; - HILOG_DEBUG("removePid when move: (%{public}d)", removePid); - event.RemovePointerItem(removePid); - SendEventToMultimodal(event, NO_CHANGE); - } else { - currentState_ = static_cast(TouchGuideState::TRANSMITTING); - SendAllUpEvents(event); - } -} - -float TouchGuider::GetAngleCos(float offsetX, float offsetY, bool isGetX) -{ - HILOG_DEBUG(); - - float ret = isGetX ? offsetX : offsetY; - double duration = hypot(offsetX, offsetY); - if (duration < - EPSINON || duration > EPSINON) { - ret = ret / duration; - } - return ret; -} - -void TouchGuider::GetPointOffset(MMI::PointerEvent &event, std::vector &firstPointOffset, - std::vector &secondPointOffset) const -{ - HILOG_DEBUG(); - - std::vector pIds = event.GetPointerIds(); - if (pIds.size() != POINTER_COUNT_2) { - return; - } - - MMI::PointerEvent::PointerItem pointerF = {}; - MMI::PointerEvent::PointerItem pointerS = {}; - if (!event.GetPointerItem(pIds[0], pointerF)) { - HILOG_ERROR("GetPointerItem(%{public}d) failed", pIds[0]); - return; - } - - if (!event.GetPointerItem(pIds[1], pointerS)) { - HILOG_ERROR("GetPointerItem(%{public}d) failed", pIds[1]); - return; - } - - float xPointF = pointerF.GetDisplayX(); - float xPointS = pointerS.GetDisplayX(); - float yPointF = pointerF.GetDisplayY(); - float yPointS = pointerS.GetDisplayY(); - float xPointDownF = 0; - float xPointDownS = 0; - float yPointDownF = 0; - float yPointDownS = 0; - if (receivedRecorder_.pointerDownX.find(INDEX_0) != receivedRecorder_.pointerDownX.end()) { - xPointDownF = receivedRecorder_.pointerDownX.find(INDEX_0)->second; - yPointDownF = receivedRecorder_.pointerDownY.find(INDEX_0)->second; - } - if (receivedRecorder_.pointerDownX.find(INDEX_1) != receivedRecorder_.pointerDownX.end()) { - xPointDownS = receivedRecorder_.pointerDownX.find(INDEX_1)->second; - yPointDownS = receivedRecorder_.pointerDownY.find(INDEX_1)->second; - } - - firstPointOffset.push_back(xPointF - xPointDownF); // firstOffsetX - firstPointOffset.push_back(yPointF - yPointDownF); // firstOffsetY - secondPointOffset.push_back(xPointS - xPointDownS); // secondOffsetX - secondPointOffset.push_back(yPointS - yPointDownS); // secondOffsetY -} - -bool TouchGuider::IsDragGestureAccept(MMI::PointerEvent &event) -{ - HILOG_DEBUG(); - - std::vector firstPointOffset; - std::vector secondPointOffset; - GetPointOffset(event, firstPointOffset, secondPointOffset); - if (firstPointOffset.size() != SCREEN_AXIS_NUM || secondPointOffset.size() != SCREEN_AXIS_NUM) { - return false; - } - - float firstOffsetX = firstPointOffset[0]; - float firstOffsetY = firstPointOffset[1]; - float secondOffsetX = secondPointOffset[0]; - float secondOffsetY = secondPointOffset[1]; - if ((!firstOffsetX && !firstOffsetY) || - (!secondOffsetX && !secondOffsetY)) { - return true; - } - - float firstXCos = GetAngleCos(firstOffsetX, firstOffsetY, true); - float firstYCos = GetAngleCos(firstOffsetX, firstOffsetY, false); - float secondXCos = GetAngleCos(secondOffsetX, secondOffsetY, true); - float secondYCos = GetAngleCos(secondOffsetX, secondOffsetY, false); - if ((firstXCos * secondXCos + firstYCos * secondYCos) < MAX_DRAG_GESTURE_COSINE) { - return false; - } - return true; -} - -bool TouchGuider::IsRealMoveState(MMI::PointerEvent &event) const -{ - HILOG_DEBUG("moveThreshold: %{public}f", multiFingerGestureRecognizer_.GetTouchSlop()); - - std::vector firstPointOffset; - std::vector secondPointOffset; - GetPointOffset(event, firstPointOffset, secondPointOffset); - if (firstPointOffset.size() != SCREEN_AXIS_NUM || secondPointOffset.size() != SCREEN_AXIS_NUM) { - return false; - } - - HILOG_DEBUG("offset of fisrt down points and current points: %{public}f, %{public}f,%{public}f, %{public}f", - firstPointOffset[0], firstPointOffset[1], secondPointOffset[0], secondPointOffset[1]); - if (hypot(firstPointOffset[0], firstPointOffset[1]) >= multiFingerGestureRecognizer_.GetTouchSlop() && - hypot(secondPointOffset[0], secondPointOffset[1]) >= multiFingerGestureRecognizer_.GetTouchSlop()) { - return true; - } - return false; -} - -void TouchGuider::RecordInjectedEvent(MMI::PointerEvent &event) -{ - HILOG_DEBUG(); - - int32_t pointerId = event.GetPointerId(); - switch (event.GetPointerAction()) { - case MMI::PointerEvent::POINTER_ACTION_DOWN: - injectedRecorder_.downPointerNum++; - injectedRecorder_.downPointers.insert(pointerId); - injectedRecorder_.lastDownTime = event.GetActionTime() / US_TO_MS; - break; - case MMI::PointerEvent::POINTER_ACTION_UP: - injectedRecorder_.downPointers.erase(pointerId); - if (injectedRecorder_.downPointerNum > 0) { - injectedRecorder_.downPointerNum--; - } - if (injectedRecorder_.downPointers.empty()) { - injectedRecorder_.lastDownTime = 0; - } - break; - case MMI::PointerEvent::POINTER_ACTION_MOVE: - injectedRecorder_.lastHoverEvent = std::make_shared(event); - break; - default: - break; - } -} - -void TouchGuider::RecordReceivedEvent(MMI::PointerEvent &event) -{ - HILOG_DEBUG(); - - int32_t pointId = event.GetPointerId(); - MMI::PointerEvent::PointerItem pointer; - if (!event.GetPointerItem(pointId, pointer)) { - HILOG_ERROR("GetPointerItem(%{public}d) failed", pointId); - } - receivedRecorder_.lastEvent = std::make_shared(event); - switch (event.GetPointerAction()) { - case MMI::PointerEvent::POINTER_ACTION_DOWN: - receivedRecorder_.pointerDownX[pointId] = pointer.GetDisplayX(); - receivedRecorder_.pointerDownY[pointId] = pointer.GetDisplayY(); - receivedRecorder_.pointerActionTime[pointId] = event.GetActionTime(); - break; - case MMI::PointerEvent::POINTER_ACTION_UP: - receivedRecorder_.pointerDownX.erase(pointId); - receivedRecorder_.pointerDownY.erase(pointId); - receivedRecorder_.pointerActionTime.erase(pointId); - break; - default: - break; - } -} - -void TouchGuider::ClearReceivedEventRecorder() -{ - HILOG_DEBUG(); - - receivedRecorder_.pointerDownX.clear(); - receivedRecorder_.pointerDownY.clear(); - receivedRecorder_.pointerActionTime.clear(); - receivedRecorder_.lastEvent = nullptr; -} - -void TouchGuider::ClearInjectedEventRecorder() -{ - HILOG_DEBUG(); - - injectedRecorder_.downPointerNum = 0; - injectedRecorder_.downPointers.clear(); - injectedRecorder_.lastHoverEvent = nullptr; -} - -void TouchGuider::SendAllDownEvents(MMI::PointerEvent &event) -{ - HILOG_DEBUG(); - - std::vector pIds = event.GetPointerIds(); - for (auto& pId : pIds) { - if (injectedRecorder_.downPointers.find(pId) == injectedRecorder_.downPointers.end()) { - event.SetPointerId(pId); - SendEventToMultimodal(event, POINTER_DOWN); - } - } -} - -void TouchGuider::SendAllUpEvents(MMI::PointerEvent &event) -{ - HILOG_DEBUG(); - - std::vector pIds = event.GetPointerIds(); - for (auto& pId : pIds) { - event.SetPointerId(pId); - SendEventToMultimodal(event, POINTER_UP); - } -} - -void TouchGuider::SendUpForAllInjectedEvent(MMI::PointerEvent &event) -{ - HILOG_DEBUG(); - - std::vector pIds = event.GetPointerIds(); - for (const auto& pId : pIds) { - if (injectedRecorder_.downPointers.find(pId) == injectedRecorder_.downPointers.end()) { - continue; - } - SendEventToMultimodal(event, POINTER_UP); - } -} - -void TouchGuider::PostGestureRecognizeExit() -{ - HILOG_DEBUG(); - - handler_->SendEvent(EXIT_GESTURE_REC_MSG, 0, EXIT_GESTURE_REC_TIMEOUT); -} - -void TouchGuider::PostHoverEnterAndMove(MMI::PointerEvent &event) -{ - HILOG_DEBUG(); - - CancelPostEventIfNeed(SEND_HOVER_ENTER_MOVE_MSG); - pointerEvents_.push_back(event); - handler_->SendEvent(SEND_HOVER_ENTER_MOVE_MSG, 0, DOUBLE_TAP_TIMEOUT / US_TO_MS); -} - -void TouchGuider::PostHoverExit() -{ - HILOG_DEBUG(); - - CancelPostEventIfNeed(SEND_HOVER_EXIT_MSG); - handler_->SendEvent(SEND_HOVER_EXIT_MSG, 0, DOUBLE_TAP_TIMEOUT / US_TO_MS); -} - -void TouchGuider::PostAccessibilityEvent(uint32_t innerEventID) -{ - HILOG_DEBUG(); - - handler_->SendEvent(innerEventID, 0, EXIT_GESTURE_REC_TIMEOUT); -} - -void TouchGuider::CancelPostEvent(uint32_t innerEventID) -{ - HILOG_DEBUG(); - - handler_->RemoveEvent(innerEventID); -} - -void TouchGuider::CancelPostEventIfNeed(uint32_t innerEventID) -{ - HILOG_DEBUG(); - - if (HasEventPending(innerEventID)) { - handler_->RemoveEvent(innerEventID); - if (innerEventID == SEND_HOVER_ENTER_MOVE_MSG) { - pointerEvents_.clear(); - } - } -} - -bool TouchGuider::HasEventPending(uint32_t innerEventID) -{ - HILOG_DEBUG(); - - return handler_->HasInnerEvent(innerEventID); -} - -void TouchGuider::ForceSendAndRemoveEvent(uint32_t innerEventID, MMI::PointerEvent &event) -{ - HILOG_DEBUG(); - - if (!HasEventPending(innerEventID)) { - HILOG_DEBUG("No pending event."); - return; - } - - switch (innerEventID) { - case SEND_HOVER_ENTER_MOVE_MSG: - SendAccessibilityEventToAA(EventType::TYPE_TOUCH_GUIDE_BEGIN); - if (pointerEvents_.empty()) { - break; - } - for (auto iter = pointerEvents_.begin(); iter != pointerEvents_.end(); ++iter) { - if (iter->GetPointerAction() == MMI::PointerEvent::POINTER_ACTION_DOWN) { - SendEventToMultimodal(*iter, HOVER_ENTER); - } else { - SendEventToMultimodal(*iter, HOVER_MOVE); - } - } - pointerEvents_.clear(); - break; - case SEND_TOUCH_GUIDE_END_MSG: - SendAccessibilityEventToAA(EventType::TYPE_TOUCH_GUIDE_END); - break; - default: - break; - } - CancelPostEvent(innerEventID); -} - -bool TouchGuider::IgnoreRepeatExecuteAction() -{ - HILOG_DEBUG(); - int64_t time = Utils::GetSystemTime(); - if (time - lastDoubleTapTime < IGNORE_REPEAT_EXECUTE_INTERVAL) { - HILOG_DEBUG("time interval < 300ms"); - lastDoubleTapTime = time; - return true; - } - - lastDoubleTapTime = time; - return false; -} - -bool TouchGuider::ExecuteActionOnAccessibilityFocused(const ActionType &action) -{ - HILOG_DEBUG(); - if (IgnoreRepeatExecuteAction()) { - return true; - } - return Singleton::GetInstance().ExecuteActionOnAccessibilityFocused(action); -} - -bool TouchGuider::FindFocusedElement(AccessibilityElementInfo &elementInfo) -{ - HILOG_DEBUG(); - return Singleton::GetInstance().FindFocusedElement(elementInfo); -} - -void TGEventHandler::HoverEnterAndMoveRunner() -{ - HILOG_DEBUG(); - - std::list motionEvent = tgServer_.getHoverEnterAndMoveEvent(); - tgServer_.SendAccessibilityEventToAA(EventType::TYPE_TOUCH_GUIDE_BEGIN); - if (!motionEvent.empty()) { - for (auto iter = motionEvent.begin(); iter != motionEvent.end(); ++iter) { - if (iter->GetPointerAction() == MMI::PointerEvent::POINTER_ACTION_DOWN) { - tgServer_.SendEventToMultimodal(*iter, HOVER_ENTER); - } else { - tgServer_.SendEventToMultimodal(*iter, HOVER_MOVE); - } - } - } - tgServer_.ClearHoverEnterAndMoveEvent(); -} - -void TGEventHandler::HoverExitRunner() -{ - HILOG_DEBUG(); - - std::shared_ptr pEvent = tgServer_.getLastReceivedEvent(); - tgServer_.SendEventToMultimodal(*pEvent, HOVER_EXIT); - if (!HasInnerEvent(TouchGuider::SEND_TOUCH_GUIDE_END_MSG)) { - RemoveEvent(TouchGuider::SEND_TOUCH_GUIDE_END_MSG); - SendEvent(TouchGuider::SEND_TOUCH_GUIDE_END_MSG, 0, EXIT_GESTURE_REC_TIMEOUT); - } -} -} // namespace Accessibility -} // namespace OHOS \ No newline at end of file diff --git a/services/aams/src/accessibility_zoom_gesture.cpp b/services/aams/src/accessibility_zoom_gesture.cpp index f192fefd..772ff412 100755 --- a/services/aams/src/accessibility_zoom_gesture.cpp +++ b/services/aams/src/accessibility_zoom_gesture.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 Huawei Device Co., Ltd. + * Copyright (C) 2022-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -31,7 +31,6 @@ namespace { constexpr float TAP_MIN_DISTANCE = 8.0f; constexpr int32_t MULTI_TAP_TIMER = 250; // ms constexpr int32_t LONG_PRESS_TIMER = 300; // ms - constexpr int64_t US_TO_MS = 1000; constexpr float DOUBLE_TAP_SLOP = 100.0f; constexpr float HALF = 0.5f; constexpr uint32_t DOUBLE = 2; diff --git a/services/aams/test/BUILD.gn b/services/aams/test/BUILD.gn index d5f87f2d..294cb9b0 100644 --- a/services/aams/test/BUILD.gn +++ b/services/aams/test/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (C) 2022 Huawei Device Co., Ltd. +# Copyright (C) 2022-2024 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -37,22 +37,7 @@ config("module_private_config") { "../../test/mock/common", "../../../common/interface/include", "../../../common/interface/include/parcel", - "${ability_base_path}/interfaces/inner_api/base/include", - "${ability_base_path}/interfaces/kits/native/uri/include", - "${ability_base_path}/interfaces/kits/native/want/include", - "${ability_runtime_path}/interfaces/kits/native/ability/native/", - "${ability_runtime_path}/interfaces/kits/native/appkit/app/", - "${ability_runtime_inner_api_path}/ability_manager/include", - "${ability_runtime_inner_api_path}/app_manager/include/appmgr/", - "${ability_runtime_services_path}/abilitymgr/include", "mock", - "../../../../graphic/graphic_2d/rosen/modules/render_service_base/include", - "../../../../graphic/graphic_2d/rosen/modules/2d_graphics/include", - "../../../../multimedia/image_framework/interfaces/innerkits/include", - "../../../../multimedia/image_framework/interfaces/kits/native/include", - "../../../../window/window_manager/previewer/mock", - "../../../../multimodalinput/input/util/common/include", - "../../../../window/window_manager/utils/include", ] defines = [ @@ -75,12 +60,10 @@ ohos_unittest("accessibility_account_data_test") { "../src/accessibility_display_manager.cpp", "../src/accessibility_dumper.cpp", "../src/accessibility_event_transmission.cpp", - "../src/accessibility_gesture_recognizer.cpp", "../src/accessibility_input_interceptor.cpp", "../src/accessibility_keyevent_filter.cpp", "../src/accessibility_mouse_autoclick.cpp", "../src/accessibility_mouse_key.cpp", - "../src/accessibility_multifinger_multitap.cpp", "../src/accessibility_power_manager.cpp", "../src/accessibility_screen_touch.cpp", "../src/accessibility_setting_observer.cpp", @@ -88,7 +71,7 @@ ohos_unittest("accessibility_account_data_test") { "../src/accessibility_short_key.cpp", "../src/accessibility_short_key_dialog.cpp", "../src/accessibility_touchEvent_injector.cpp", - "../src/accessibility_touch_guider.cpp", + "../src/accessibility_touch_exploration.cpp", "../src/accessibility_window_connection.cpp", "../src/accessibility_window_manager.cpp", "../src/accessibility_zoom_gesture.cpp", @@ -112,8 +95,6 @@ ohos_unittest("accessibility_account_data_test") { ] deps = [ - "../../../../../../third_party/googletest:gmock_main", - "../../../../../../third_party/googletest:gtest_main", "../../../common/interface:accessibility_interface", "../../../interfaces/innerkits/common:accessibility_common", ] @@ -132,6 +113,8 @@ ohos_unittest("accessibility_account_data_test") { "display_manager:displaymgr", "eventhandler:libeventhandler", "ffrt:libffrt", + "googletest:gmock_main", + "googletest:gtest_main", "graphic_2d:2d_graphics", "graphic_2d:librender_service_client", "hicollie:libhicollie", @@ -169,12 +152,10 @@ ohos_unittest("accessible_ability_manager_service_test") { "../src/accessibility_display_manager.cpp", "../src/accessibility_dumper.cpp", "../src/accessibility_event_transmission.cpp", - "../src/accessibility_gesture_recognizer.cpp", "../src/accessibility_input_interceptor.cpp", "../src/accessibility_keyevent_filter.cpp", "../src/accessibility_mouse_autoclick.cpp", "../src/accessibility_mouse_key.cpp", - "../src/accessibility_multifinger_multitap.cpp", "../src/accessibility_power_manager.cpp", "../src/accessibility_screen_touch.cpp", "../src/accessibility_setting_observer.cpp", @@ -183,7 +164,7 @@ ohos_unittest("accessible_ability_manager_service_test") { "../src/accessibility_settings_config.cpp", "../src/accessibility_short_key.cpp", "../src/accessibility_touchEvent_injector.cpp", - "../src/accessibility_touch_guider.cpp", + "../src/accessibility_touch_exploration.cpp", "../src/accessibility_window_connection.cpp", "../src/accessibility_zoom_gesture.cpp", "../src/accessible_ability_channel.cpp", @@ -209,8 +190,6 @@ ohos_unittest("accessible_ability_manager_service_test") { ] deps = [ - "../../../../../../third_party/googletest:gmock_main", - "../../../../../../third_party/googletest:gtest_main", "../../../common/interface:accessibility_interface", "../../../interfaces/innerkits/common:accessibility_common", ] @@ -229,6 +208,8 @@ ohos_unittest("accessible_ability_manager_service_test") { "display_manager:displaymgr", "eventhandler:libeventhandler", "ffrt:libffrt", + "googletest:gmock_main", + "googletest:gtest_main", "graphic_2d:2d_graphics", "graphic_2d:librender_service_client", "hicollie:libhicollie", @@ -249,7 +230,7 @@ ohos_unittest("accessible_ability_manager_service_test") { } ################################################################################ -ohos_unittest("accessibility_touch_guider_test") { +ohos_unittest("accessibility_touch_exploration_test") { module_out_path = module_output_path sources = [ "../../../common/interface/src/accessibility_element_operator_callback_stub.cpp", @@ -265,11 +246,9 @@ ohos_unittest("accessibility_touch_guider_test") { "../../test/mock/mock_matching_skill.cpp", "../src/accessibility_datashare_helper.cpp", "../src/accessibility_display_manager.cpp", - "../src/accessibility_gesture_recognizer.cpp", - "../src/accessibility_multifinger_multitap.cpp", "../src/accessibility_setting_observer.cpp", "../src/accessibility_settings_config.cpp", - "../src/accessibility_touch_guider.cpp", + "../src/accessibility_touch_exploration.cpp", "../src/accessibility_window_connection.cpp", "../src/accessible_ability_manager_service_event_handler.cpp", "../src/utils.cpp", @@ -286,7 +265,7 @@ ohos_unittest("accessibility_touch_guider_test") { "mock/src/mock_accessible_ability_manager_service_stub.cpp", "mock/src/mock_display.cpp", "mock/src/mock_system_ability.cpp", - "unittest/accessibility_touch_guider_test.cpp", + "unittest/accessibility_touch_exploration_test.cpp", ] sources += aams_mock_distributeddatamgr_src @@ -295,11 +274,7 @@ ohos_unittest("accessibility_touch_guider_test") { "../../../resources/config/build:coverage_flags", ] - deps = [ - "../../../../../../third_party/googletest:gmock_main", - "../../../../../../third_party/googletest:gtest_main", - "../../../interfaces/innerkits/common:accessibility_common", - ] + deps = [ "../../../interfaces/innerkits/common:accessibility_common" ] external_deps = [ "ability_base:want", @@ -316,6 +291,8 @@ ohos_unittest("accessibility_touch_guider_test") { "data_share:datashare_consumer", "eventhandler:libeventhandler", "ffrt:libffrt", + "googletest:gmock_main", + "googletest:gtest_main", "hicollie:libhicollie", "hilog:libhilog", "hisysevent:libhisysevent", @@ -323,6 +300,7 @@ ohos_unittest("accessibility_touch_guider_test") { "input:libmmi-client", "ipc:ipc_core", "os_account:os_account_innerkits", + "power_manager:powermgr_client", "resource_management:global_resmgr", "safwk:system_ability_fwk", "samgr:samgr_proxy", @@ -348,12 +326,10 @@ ohos_unittest("accessibility_common_event_registry_test") { "../src/accessibility_display_manager.cpp", "../src/accessibility_dumper.cpp", "../src/accessibility_event_transmission.cpp", - "../src/accessibility_gesture_recognizer.cpp", "../src/accessibility_input_interceptor.cpp", "../src/accessibility_keyevent_filter.cpp", "../src/accessibility_mouse_autoclick.cpp", "../src/accessibility_mouse_key.cpp", - "../src/accessibility_multifinger_multitap.cpp", "../src/accessibility_power_manager.cpp", "../src/accessibility_screen_touch.cpp", "../src/accessibility_setting_observer.cpp", @@ -363,7 +339,7 @@ ohos_unittest("accessibility_common_event_registry_test") { "../src/accessibility_short_key.cpp", "../src/accessibility_short_key_dialog.cpp", "../src/accessibility_touchEvent_injector.cpp", - "../src/accessibility_touch_guider.cpp", + "../src/accessibility_touch_exploration.cpp", "../src/accessibility_window_connection.cpp", "../src/accessibility_window_manager.cpp", "../src/accessibility_zoom_gesture.cpp", @@ -384,8 +360,6 @@ ohos_unittest("accessibility_common_event_registry_test") { ] deps = [ - "../../../../../../third_party/googletest:gmock_main", - "../../../../../../third_party/googletest:gtest_main", "../../../common/interface:accessibility_interface", "../../../interfaces/innerkits/common:accessibility_common", ] @@ -404,6 +378,8 @@ ohos_unittest("accessibility_common_event_registry_test") { "display_manager:displaymgr", "eventhandler:libeventhandler", "ffrt:libffrt", + "googletest:gmock_main", + "googletest:gtest_main", "graphic_2d:2d_graphics", "graphic_2d:librender_service_client", "hicollie:libhicollie", @@ -442,11 +418,9 @@ ohos_unittest("accessibility_input_interceptor_test") { "../src/accessibility_display_manager.cpp", "../src/accessibility_dumper.cpp", "../src/accessibility_event_transmission.cpp", - "../src/accessibility_gesture_recognizer.cpp", "../src/accessibility_input_interceptor.cpp", "../src/accessibility_mouse_autoclick.cpp", "../src/accessibility_mouse_key.cpp", - "../src/accessibility_multifinger_multitap.cpp", "../src/accessibility_power_manager.cpp", "../src/accessibility_screen_touch.cpp", "../src/accessibility_setting_observer.cpp", @@ -455,7 +429,7 @@ ohos_unittest("accessibility_input_interceptor_test") { "../src/accessibility_settings_config.cpp", "../src/accessibility_short_key.cpp", "../src/accessibility_short_key_dialog.cpp", - "../src/accessibility_touch_guider.cpp", + "../src/accessibility_touch_exploration.cpp", "../src/accessibility_window_connection.cpp", "../src/accessibility_zoom_gesture.cpp", "../src/accessible_ability_channel.cpp", @@ -481,8 +455,6 @@ ohos_unittest("accessibility_input_interceptor_test") { ] deps = [ - "../../../../../../third_party/googletest:gmock_main", - "../../../../../../third_party/googletest:gtest_main", "../../../common/interface:accessibility_interface", "../../../interfaces/innerkits/common:accessibility_common", ] @@ -501,6 +473,8 @@ ohos_unittest("accessibility_input_interceptor_test") { "display_manager:displaymgr", "eventhandler:libeventhandler", "ffrt:libffrt", + "googletest:gmock_main", + "googletest:gtest_main", "graphic_2d:2d_graphics", "graphic_2d:librender_service_client", "hicollie:libhicollie", @@ -534,12 +508,10 @@ ohos_unittest("accessibility_window_manager_test") { "../src/accessibility_display_manager.cpp", "../src/accessibility_dumper.cpp", "../src/accessibility_event_transmission.cpp", - "../src/accessibility_gesture_recognizer.cpp", "../src/accessibility_input_interceptor.cpp", "../src/accessibility_keyevent_filter.cpp", "../src/accessibility_mouse_autoclick.cpp", "../src/accessibility_mouse_key.cpp", - "../src/accessibility_multifinger_multitap.cpp", "../src/accessibility_power_manager.cpp", "../src/accessibility_screen_touch.cpp", "../src/accessibility_setting_observer.cpp", @@ -549,7 +521,7 @@ ohos_unittest("accessibility_window_manager_test") { "../src/accessibility_short_key.cpp", "../src/accessibility_short_key_dialog.cpp", "../src/accessibility_touchEvent_injector.cpp", - "../src/accessibility_touch_guider.cpp", + "../src/accessibility_touch_exploration.cpp", "../src/accessibility_window_connection.cpp", "../src/accessibility_window_manager.cpp", "../src/accessibility_zoom_gesture.cpp", @@ -574,8 +546,6 @@ ohos_unittest("accessibility_window_manager_test") { ] deps = [ - "../../../../../../third_party/googletest:gmock_main", - "../../../../../../third_party/googletest:gtest_main", "../../../common/interface:accessibility_interface", "../../../interfaces/innerkits/common:accessibility_common", ] @@ -594,6 +564,8 @@ ohos_unittest("accessibility_window_manager_test") { "display_manager:displaymgr", "eventhandler:libeventhandler", "ffrt:libffrt", + "googletest:gmock_main", + "googletest:gtest_main", "graphic_2d:2d_graphics", "graphic_2d:librender_service_client", "hicollie:libhicollie", @@ -622,12 +594,10 @@ ohos_unittest("accessibility_keyevent_filter_test") { "../src/accessibility_datashare_helper.cpp", "../src/accessibility_display_manager.cpp", "../src/accessibility_dumper.cpp", - "../src/accessibility_gesture_recognizer.cpp", "../src/accessibility_input_interceptor.cpp", "../src/accessibility_keyevent_filter.cpp", "../src/accessibility_mouse_autoclick.cpp", "../src/accessibility_mouse_key.cpp", - "../src/accessibility_multifinger_multitap.cpp", "../src/accessibility_power_manager.cpp", "../src/accessibility_screen_touch.cpp", "../src/accessibility_setting_observer.cpp", @@ -637,7 +607,7 @@ ohos_unittest("accessibility_keyevent_filter_test") { "../src/accessibility_short_key.cpp", "../src/accessibility_short_key_dialog.cpp", "../src/accessibility_touchEvent_injector.cpp", - "../src/accessibility_touch_guider.cpp", + "../src/accessibility_touch_exploration.cpp", "../src/accessibility_window_connection.cpp", "../src/accessibility_window_manager.cpp", "../src/accessibility_zoom_gesture.cpp", @@ -658,8 +628,6 @@ ohos_unittest("accessibility_keyevent_filter_test") { ] deps = [ - "../../../../../../third_party/googletest:gmock_main", - "../../../../../../third_party/googletest:gtest_main", "../../../common/interface:accessibility_interface", "../../../interfaces/innerkits/common:accessibility_common", ] @@ -678,6 +646,8 @@ ohos_unittest("accessibility_keyevent_filter_test") { "display_manager:displaymgr", "eventhandler:libeventhandler", "ffrt:libffrt", + "googletest:gmock_main", + "googletest:gtest_main", "graphic_2d:2d_graphics", "graphic_2d:librender_service_client", "hicollie:libhicollie", @@ -716,11 +686,9 @@ ohos_unittest("accessible_ability_connection_test") { "../src/accessibility_display_manager.cpp", "../src/accessibility_dumper.cpp", "../src/accessibility_event_transmission.cpp", - "../src/accessibility_gesture_recognizer.cpp", "../src/accessibility_input_interceptor.cpp", "../src/accessibility_mouse_autoclick.cpp", "../src/accessibility_mouse_key.cpp", - "../src/accessibility_multifinger_multitap.cpp", "../src/accessibility_power_manager.cpp", "../src/accessibility_screen_touch.cpp", "../src/accessibility_setting_observer.cpp", @@ -728,7 +696,7 @@ ohos_unittest("accessible_ability_connection_test") { "../src/accessibility_settings_config.cpp", "../src/accessibility_short_key.cpp", "../src/accessibility_touchEvent_injector.cpp", - "../src/accessibility_touch_guider.cpp", + "../src/accessibility_touch_exploration.cpp", "../src/accessibility_window_connection.cpp", "../src/accessibility_window_manager.cpp", "../src/accessibility_zoom_gesture.cpp", @@ -758,8 +726,6 @@ ohos_unittest("accessible_ability_connection_test") { ] deps = [ - "../../../../../../third_party/googletest:gmock_main", - "../../../../../../third_party/googletest:gtest_main", "../../../common/interface:accessibility_interface", "../../../interfaces/innerkits/common:accessibility_common", ] @@ -781,6 +747,8 @@ ohos_unittest("accessible_ability_connection_test") { "display_manager:displaymgr", "eventhandler:libeventhandler", "ffrt:libffrt", + "googletest:gmock_main", + "googletest:gtest_main", "graphic_2d:2d_graphics", "graphic_2d:librender_service_client", "hicollie:libhicollie", @@ -817,11 +785,7 @@ ohos_unittest("accessibility_display_manager_test") { "../../../resources/config/build:coverage_flags", ] - deps = [ - "../../../../../../third_party/googletest:gmock_main", - "../../../../../../third_party/googletest:gtest_main", - "../../../common/interface:accessibility_interface", - ] + deps = [ "../../../common/interface:accessibility_interface" ] external_deps = [ "ability_base:zuri", @@ -835,6 +799,8 @@ ohos_unittest("accessibility_display_manager_test") { "data_share:datashare_common", "data_share:datashare_consumer", "ffrt:libffrt", + "googletest:gmock_main", + "googletest:gtest_main", "hilog:libhilog", "hisysevent:libhisysevent", "init:libbegetutil", @@ -887,11 +853,7 @@ ohos_unittest("accessibility_dumper_test") { "../../../resources/config/build:coverage_flags", ] - deps = [ - "../../../../../../third_party/googletest:gmock_main", - "../../../../../../third_party/googletest:gtest_main", - "../../../interfaces/innerkits/common:accessibility_common", - ] + deps = [ "../../../interfaces/innerkits/common:accessibility_common" ] external_deps = [ "ability_base:want", @@ -908,12 +870,15 @@ ohos_unittest("accessibility_dumper_test") { "data_share:datashare_consumer", "eventhandler:libeventhandler", "ffrt:libffrt", + "googletest:gmock_main", + "googletest:gtest_main", "hicollie:libhicollie", "hilog:libhilog", "hisysevent:libhisysevent", "init:libbegetutil", "ipc:ipc_core", "os_account:os_account_innerkits", + "power_manager:powermgr_client", "resource_management:global_resmgr", "safwk:system_ability_fwk", "samgr:samgr_proxy", @@ -936,12 +901,10 @@ ohos_unittest("accessibility_touchevent_injector_test") { "../src/accessibility_datashare_helper.cpp", "../src/accessibility_display_manager.cpp", "../src/accessibility_dumper.cpp", - "../src/accessibility_gesture_recognizer.cpp", "../src/accessibility_input_interceptor.cpp", "../src/accessibility_keyevent_filter.cpp", "../src/accessibility_mouse_autoclick.cpp", "../src/accessibility_mouse_key.cpp", - "../src/accessibility_multifinger_multitap.cpp", "../src/accessibility_power_manager.cpp", "../src/accessibility_screen_touch.cpp", "../src/accessibility_setting_observer.cpp", @@ -951,7 +914,7 @@ ohos_unittest("accessibility_touchevent_injector_test") { "../src/accessibility_short_key.cpp", "../src/accessibility_short_key_dialog.cpp", "../src/accessibility_touchEvent_injector.cpp", - "../src/accessibility_touch_guider.cpp", + "../src/accessibility_touch_exploration.cpp", "../src/accessibility_window_connection.cpp", "../src/accessibility_window_manager.cpp", "../src/accessibility_zoom_gesture.cpp", @@ -974,8 +937,6 @@ ohos_unittest("accessibility_touchevent_injector_test") { ] deps = [ - "../../../../../../third_party/googletest:gmock_main", - "../../../../../../third_party/googletest:gtest_main", "../../../common/interface:accessibility_interface", "../../../interfaces/innerkits/common:accessibility_common", ] @@ -994,6 +955,8 @@ ohos_unittest("accessibility_touchevent_injector_test") { "display_manager:displaymgr", "eventhandler:libeventhandler", "ffrt:libffrt", + "googletest:gmock_main", + "googletest:gtest_main", "graphic_2d:2d_graphics", "graphic_2d:librender_service_client", "hicollie:libhicollie", @@ -1059,11 +1022,7 @@ ohos_unittest("accessible_ability_channel_test") { "../../../resources/config/build:coverage_flags", ] - deps = [ - "../../../../../../third_party/googletest:gmock_main", - "../../../../../../third_party/googletest:gtest_main", - "../../../interfaces/innerkits/common:accessibility_common", - ] + deps = [ "../../../interfaces/innerkits/common:accessibility_common" ] external_deps = [ "ability_base:want", @@ -1080,6 +1039,8 @@ ohos_unittest("accessible_ability_channel_test") { "data_share:datashare_consumer", "eventhandler:libeventhandler", "ffrt:libffrt", + "googletest:gmock_main", + "googletest:gtest_main", "graphic_2d:librender_service_client", "hicollie:libhicollie", "hilog:libhilog", @@ -1111,12 +1072,10 @@ ohos_unittest("accessibility_mouse_autoclick_test") { "../src/accessibility_datashare_helper.cpp", "../src/accessibility_display_manager.cpp", "../src/accessibility_dumper.cpp", - "../src/accessibility_gesture_recognizer.cpp", "../src/accessibility_input_interceptor.cpp", "../src/accessibility_keyevent_filter.cpp", "../src/accessibility_mouse_autoclick.cpp", "../src/accessibility_mouse_key.cpp", - "../src/accessibility_multifinger_multitap.cpp", "../src/accessibility_power_manager.cpp", "../src/accessibility_screen_touch.cpp", "../src/accessibility_setting_observer.cpp", @@ -1125,7 +1084,7 @@ ohos_unittest("accessibility_mouse_autoclick_test") { "../src/accessibility_short_key.cpp", "../src/accessibility_short_key_dialog.cpp", "../src/accessibility_touchEvent_injector.cpp", - "../src/accessibility_touch_guider.cpp", + "../src/accessibility_touch_exploration.cpp", "../src/accessibility_window_connection.cpp", "../src/accessibility_window_manager.cpp", "../src/accessibility_zoom_gesture.cpp", @@ -1149,8 +1108,6 @@ ohos_unittest("accessibility_mouse_autoclick_test") { ] deps = [ - "../../../../../../third_party/googletest:gmock_main", - "../../../../../../third_party/googletest:gtest_main", "../../../common/interface:accessibility_interface", "../../../interfaces/innerkits/common:accessibility_common", ] @@ -1169,6 +1126,8 @@ ohos_unittest("accessibility_mouse_autoclick_test") { "display_manager:displaymgr", "eventhandler:libeventhandler", "ffrt:libffrt", + "googletest:gmock_main", + "googletest:gtest_main", "graphic_2d:2d_graphics", "graphic_2d:librender_service_client", "hicollie:libhicollie", @@ -1201,12 +1160,10 @@ ohos_unittest("accessibility_screen_touch_test") { "../src/accessibility_datashare_helper.cpp", "../src/accessibility_display_manager.cpp", "../src/accessibility_dumper.cpp", - "../src/accessibility_gesture_recognizer.cpp", "../src/accessibility_input_interceptor.cpp", "../src/accessibility_keyevent_filter.cpp", "../src/accessibility_mouse_autoclick.cpp", "../src/accessibility_mouse_key.cpp", - "../src/accessibility_multifinger_multitap.cpp", "../src/accessibility_power_manager.cpp", "../src/accessibility_screen_touch.cpp", "../src/accessibility_setting_observer.cpp", @@ -1215,7 +1172,7 @@ ohos_unittest("accessibility_screen_touch_test") { "../src/accessibility_short_key.cpp", "../src/accessibility_short_key_dialog.cpp", "../src/accessibility_touchEvent_injector.cpp", - "../src/accessibility_touch_guider.cpp", + "../src/accessibility_touch_exploration.cpp", "../src/accessibility_window_connection.cpp", "../src/accessibility_window_manager.cpp", "../src/accessibility_zoom_gesture.cpp", @@ -1240,8 +1197,6 @@ ohos_unittest("accessibility_screen_touch_test") { ] deps = [ - "../../../../../../third_party/googletest:gmock_main", - "../../../../../../third_party/googletest:gtest_main", "../../../common/interface:accessibility_interface", "../../../interfaces/innerkits/common:accessibility_common", ] @@ -1260,6 +1215,8 @@ ohos_unittest("accessibility_screen_touch_test") { "display_manager:displaymgr", "eventhandler:libeventhandler", "ffrt:libffrt", + "googletest:gmock_main", + "googletest:gtest_main", "graphic_2d:2d_graphics", "graphic_2d:librender_service_client", "hicollie:libhicollie", @@ -1294,11 +1251,7 @@ ohos_unittest("accessibility_mouse_key_test") { "../../../resources/config/build:coverage_flags", ] - deps = [ - "../../../../../../third_party/googletest:gmock_main", - "../../../../../../third_party/googletest:gtest_main", - "../../../interfaces/innerkits/common:accessibility_common", - ] + deps = [ "../../../interfaces/innerkits/common:accessibility_common" ] external_deps = [ "ability_base:zuri", @@ -1312,6 +1265,8 @@ ohos_unittest("accessibility_mouse_key_test") { "data_share:datashare_common", "data_share:datashare_consumer", "ffrt:libffrt", + "googletest:gmock_main", + "googletest:gtest_main", "hilog:libhilog", "hisysevent:libhisysevent", "init:libbegetutil", @@ -1339,12 +1294,10 @@ ohos_unittest("accessibility_short_key_test") { "../src/accessibility_datashare_helper.cpp", "../src/accessibility_display_manager.cpp", "../src/accessibility_dumper.cpp", - "../src/accessibility_gesture_recognizer.cpp", "../src/accessibility_input_interceptor.cpp", "../src/accessibility_keyevent_filter.cpp", "../src/accessibility_mouse_autoclick.cpp", "../src/accessibility_mouse_key.cpp", - "../src/accessibility_multifinger_multitap.cpp", "../src/accessibility_power_manager.cpp", "../src/accessibility_screen_touch.cpp", "../src/accessibility_setting_observer.cpp", @@ -1354,7 +1307,7 @@ ohos_unittest("accessibility_short_key_test") { "../src/accessibility_short_key.cpp", "../src/accessibility_short_key_dialog.cpp", "../src/accessibility_touchEvent_injector.cpp", - "../src/accessibility_touch_guider.cpp", + "../src/accessibility_touch_exploration.cpp", "../src/accessibility_window_connection.cpp", "../src/accessibility_window_manager.cpp", "../src/accessibility_zoom_gesture.cpp", @@ -1377,8 +1330,6 @@ ohos_unittest("accessibility_short_key_test") { ] deps = [ - "../../../../../../third_party/googletest:gmock_main", - "../../../../../../third_party/googletest:gtest_main", "../../../common/interface:accessibility_interface", "../../../interfaces/innerkits/common:accessibility_common", ] @@ -1397,6 +1348,8 @@ ohos_unittest("accessibility_short_key_test") { "display_manager:displaymgr", "eventhandler:libeventhandler", "ffrt:libffrt", + "googletest:gmock_main", + "googletest:gtest_main", "graphic_2d:2d_graphics", "graphic_2d:librender_service_client", "hicollie:libhicollie", @@ -1459,8 +1412,6 @@ ohos_unittest("accessibility_short_key_dialog_test") { ] deps = [ - "../../../../../../third_party/googletest:gmock_main", - "../../../../../../third_party/googletest:gtest_main", "../../../common/interface:accessibility_interface", "../../../interfaces/innerkits/common:accessibility_common", ] @@ -1479,6 +1430,8 @@ ohos_unittest("accessibility_short_key_dialog_test") { "display_manager:displaymgr", "eventhandler:libeventhandler", "ffrt:libffrt", + "googletest:gmock_main", + "googletest:gtest_main", "graphic_2d:2d_graphics", "graphic_2d:librender_service_client", "hicollie:libhicollie", @@ -1509,12 +1462,10 @@ ohos_unittest("accessibility_settings_config_test") { "../src/accessibility_display_manager.cpp", "../src/accessibility_dumper.cpp", "../src/accessibility_event_transmission.cpp", - "../src/accessibility_gesture_recognizer.cpp", "../src/accessibility_input_interceptor.cpp", "../src/accessibility_keyevent_filter.cpp", "../src/accessibility_mouse_autoclick.cpp", "../src/accessibility_mouse_key.cpp", - "../src/accessibility_multifinger_multitap.cpp", "../src/accessibility_power_manager.cpp", "../src/accessibility_screen_touch.cpp", "../src/accessibility_setting_observer.cpp", @@ -1524,7 +1475,7 @@ ohos_unittest("accessibility_settings_config_test") { "../src/accessibility_short_key.cpp", "../src/accessibility_short_key_dialog.cpp", "../src/accessibility_touchEvent_injector.cpp", - "../src/accessibility_touch_guider.cpp", + "../src/accessibility_touch_exploration.cpp", "../src/accessibility_window_connection.cpp", "../src/accessibility_window_manager.cpp", "../src/accessibility_zoom_gesture.cpp", @@ -1542,8 +1493,6 @@ ohos_unittest("accessibility_settings_config_test") { ] deps = [ - "../../../../../../third_party/googletest:gmock_main", - "../../../../../../third_party/googletest:gtest_main", "../../../common/interface:accessibility_interface", "../../../interfaces/innerkits/common:accessibility_common", ] @@ -1562,6 +1511,8 @@ ohos_unittest("accessibility_settings_config_test") { "display_manager:displaymgr", "eventhandler:libeventhandler", "ffrt:libffrt", + "googletest:gmock_main", + "googletest:gtest_main", "graphic_2d:2d_graphics", "graphic_2d:librender_service_client", "hicollie:libhicollie", @@ -1594,12 +1545,10 @@ ohos_unittest("accessibility_zoom_gesture_test") { "../src/accessibility_circle_drawing_manager.cpp", "../src/accessibility_datashare_helper.cpp", "../src/accessibility_dumper.cpp", - "../src/accessibility_gesture_recognizer.cpp", "../src/accessibility_input_interceptor.cpp", "../src/accessibility_keyevent_filter.cpp", "../src/accessibility_mouse_autoclick.cpp", "../src/accessibility_mouse_key.cpp", - "../src/accessibility_multifinger_multitap.cpp", "../src/accessibility_power_manager.cpp", "../src/accessibility_screen_touch.cpp", "../src/accessibility_setting_observer.cpp", @@ -1609,7 +1558,7 @@ ohos_unittest("accessibility_zoom_gesture_test") { "../src/accessibility_short_key.cpp", "../src/accessibility_short_key_dialog.cpp", "../src/accessibility_touchEvent_injector.cpp", - "../src/accessibility_touch_guider.cpp", + "../src/accessibility_touch_exploration.cpp", "../src/accessibility_window_connection.cpp", "../src/accessibility_window_manager.cpp", "../src/accessibility_zoom_gesture.cpp", @@ -1633,8 +1582,6 @@ ohos_unittest("accessibility_zoom_gesture_test") { ] deps = [ - "../../../../../../third_party/googletest:gmock_main", - "../../../../../../third_party/googletest:gtest_main", "../../../common/interface:accessibility_interface", "../../../interfaces/innerkits/common:accessibility_common", ] @@ -1653,6 +1600,8 @@ ohos_unittest("accessibility_zoom_gesture_test") { "display_manager:displaymgr", "eventhandler:libeventhandler", "ffrt:libffrt", + "googletest:gmock_main", + "googletest:gtest_main", "graphic_2d:2d_graphics", "graphic_2d:librender_service_client", "hicollie:libhicollie", @@ -1689,7 +1638,7 @@ group("unittest") { ":accessibility_screen_touch_test", ":accessibility_settings_config_test", ":accessibility_short_key_test", - ":accessibility_touch_guider_test", + ":accessibility_touch_exploration_test", ":accessibility_touchevent_injector_test", ":accessibility_window_manager_test", ":accessibility_zoom_gesture_test", diff --git a/services/aams/test/mock/include/mock_accessibility_touch_guider.h b/services/aams/test/mock/include/mock_accessibility_touch_guider.h deleted file mode 100644 index 67a33b42..00000000 --- a/services/aams/test/mock/include/mock_accessibility_touch_guider.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef MOCK_ACCESSIBILITY_TOUCH_GUIDER_H -#define MOCK_ACCESSIBILITY_TOUCH_GUIDER_H - -#include -#include "accessibility_touch_guider.h" - -namespace OHOS { -namespace Accessibility { -class MockTGEventHandler : public TGEventHandler { -public: - MockTGEventHandler(const std::shared_ptr& runner, TouchGuider& tgServer); - virtual ~MockTGEventHandler() = default; - - MOCK_METHOD1(ProcessEvent, void(const AppExecFwk::InnerEvent::Pointer& event)); -}; - -class MockTouchGuider : public TouchGuider { -public: - MockTouchGuider(); - ~MockTouchGuider() - {} - - MOCK_METHOD0(StartUp, void()); - MOCK_METHOD1(OnPointerEvent, void(MMI::PointerEvent& event)); - MOCK_METHOD0(DestroyEvents, void()); - MOCK_METHOD2(SendEventToMultimodal, void(MMI::PointerEvent& event, int32_t action)); - MOCK_METHOD1(SendAccessibilityEventToAA, void(EventType eventType)); - MOCK_METHOD0(getHoverEnterAndMoveEvent, std::list()); - MOCK_METHOD0(ClearHoverEnterAndMoveEvent, void()); - MOCK_METHOD0(getLastReceivedEvent, std::shared_ptr()); - - /* For TouchGuide */ - inline void OnTouchInteractionStart() - { - isTouchStart_ = true; - } - - inline void OnTouchInteractionEnd() - { - isTouchStart_ = false; - } -}; -} // namespace Accessibility -} // namespace OHOS -#endif // MOCK_ACCESSIBILITY_TOUCH_GUIDER_H \ No newline at end of file diff --git a/services/aams/test/mock/src/mock_accessibility_input_interceptor.cpp b/services/aams/test/mock/src/mock_accessibility_input_interceptor.cpp index 7911a9f9..1e260d3b 100644 --- a/services/aams/test/mock/src/mock_accessibility_input_interceptor.cpp +++ b/services/aams/test/mock/src/mock_accessibility_input_interceptor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2021-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -15,7 +15,7 @@ #include "accessibility_input_interceptor.h" #include "accessibility_keyevent_filter.h" -#include "accessibility_touch_guider.h" +#include "accessibility_touch_exploration.h" #include "accessibility_touchEvent_injector.h" #include "accessible_ability_manager_service.h" #include "hilog_wrapper.h" diff --git a/services/aams/test/mock/src/mock_accessibility_touch_guider.cpp b/services/aams/test/mock/src/mock_accessibility_touch_guider.cpp deleted file mode 100755 index 3fcd552c..00000000 --- a/services/aams/test/mock/src/mock_accessibility_touch_guider.cpp +++ /dev/null @@ -1,790 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed On an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "accessibility_touch_guider.h" -#include "accessibility_window_manager.h" -#include "hilog_wrapper.h" -#include "securec.h" - -namespace OHOS { -namespace Accessibility { -namespace { - constexpr int32_t POINTER_COUNT_1 = 1; - constexpr int32_t POINTER_COUNT_2 = 2; -} // namespace - -TGEventHandler::TGEventHandler(const std::shared_ptr& runner, TouchGuider& tgServer) - : AppExecFwk::EventHandler(runner), tgServer_(tgServer) -{ -} - -TouchGuider::TouchGuider() -{ - HILOG_DEBUG(); - currentState_ = static_cast(TouchGuideState::TOUCH_GUIDING); -} - -void TouchGuider::StartUp() -{ - HILOG_DEBUG(); - touchGuideListener_ = std::make_unique(*this); - gestureRecognizer_.RegisterListener(*touchGuideListener_.get()); - runner_ = Singleton::GetInstance().GetMainRunner(); - if (!runner_) { - HILOG_ERROR("get runner failed"); - return; - } - - handler_ = std::make_shared(runner_, *this); - if (!handler_) { - HILOG_ERROR("create event handler failed"); - return; - } -} - -void TGEventHandler::ProcessEvent(const AppExecFwk::InnerEvent::Pointer& event) -{ - HILOG_DEBUG(); - switch (event->GetInnerEventId()) { - case TouchGuider::EXIT_GESTURE_REC_MSG: - tgServer_.SendAccessibilityEventToAA(EventType::TYPE_TOUCH_GUIDE_GESTURE_END); - break; - case TouchGuider::SEND_HOVER_ENTER_MOVE_MSG: - HoverEnterAndMoveRunner(); - break; - case TouchGuider::SEND_HOVER_EXIT_MSG: - HoverExitRunner(); - break; - case TouchGuider::SEND_TOUCH_INTERACTION_END_MSG: - tgServer_.SendAccessibilityEventToAA(EventType::TYPE_TOUCH_END); - break; - case TouchGuider::SEND_TOUCH_GUIDE_END_MSG: - tgServer_.SendAccessibilityEventToAA(EventType::TYPE_TOUCH_GUIDE_END); - break; - default: - break; - } -} - -bool TouchGuider::OnPointerEvent(MMI::PointerEvent& event) -{ - HILOG_DEBUG(); - if (event.GetSourceType() != MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN) { - EventTransmission::OnPointerEvent(event); - return false; - } - if (event.GetPointerAction() == MMI::PointerEvent::POINTER_ACTION_CANCEL) { - Clear(event); - return true; - } - RecordReceivedEvent(event); - if (gestureRecognizer_.OnPointerEvent(event)) { - return true; - } - switch (static_cast(currentState_)) { - case TouchGuideState::TOUCH_GUIDING: - HandleTouchGuidingState(event); - break; - case TouchGuideState::DRAGGING: - HandleDraggingState(event); - break; - case TouchGuideState::TRANSMITTING: - HandleTransmitingState(event); - break; - default: - break; - } - return true; -} - -void TouchGuider::DestroyEvents() -{ - HILOG_DEBUG(); - - Clear(); - EventTransmission::DestroyEvents(); -} - -void TouchGuider::SendAccessibilityEventToAA(EventType eventType) -{ - HILOG_DEBUG("eventType is 0x%{public}x.", eventType); - - AccessibilityEventInfo eventInfo {}; - eventInfo.SetEventType(eventType); - int32_t windowsId = Singleton::GetInstance().activeWindowId_; - eventInfo.SetWindowId(windowsId); - Singleton::GetInstance().SendEvent(eventInfo); - if (eventType == EventType::TYPE_TOUCH_GUIDE_BEGIN) { - isTouchGuiding_ = true; - } else if (eventType == EventType::TYPE_TOUCH_GUIDE_END) { - isTouchGuiding_ = false; - } -} - -void TouchGuider::SendEventToMultimodal(MMI::PointerEvent& event, int32_t action) -{ - HILOG_DEBUG("action is %{public}d.", action); - HILOG_DEBUG("SourceType is %{public}d.", event.GetSourceType()); - - switch (action) { - case HOVER_MOVE: - if (event.GetSourceType() == MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN) { - event.SetPointerAction(MMI::PointerEvent::POINTER_ACTION_MOVE); - event.SetSourceType(MMI::PointerEvent::SOURCE_TYPE_MOUSE); - } - break; - case POINTER_DOWN: - if (event.GetSourceType() == MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN) { - event.SetPointerAction(MMI::PointerEvent::POINTER_ACTION_DOWN); - } - break; - case POINTER_UP: - if (event.GetSourceType() == MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN) { - event.SetPointerAction(MMI::PointerEvent::POINTER_ACTION_UP); - } - break; - default: - break; - } - EventTransmission::OnPointerEvent(event); - RecordInjectedEvent(event); -} - -std::list TouchGuider::getHoverEnterAndMoveEvent() -{ - HILOG_DEBUG(); - - return pointerEvents_; -} - -void TouchGuider::ClearHoverEnterAndMoveEvent() -{ - HILOG_DEBUG(); - - pointerEvents_.clear(); - gestureRecognizer_.Clear(); -} - -std::shared_ptr TouchGuider::getLastReceivedEvent() -{ - HILOG_DEBUG(); - - return receivedRecorder_.lastEvent; -} - -bool TouchGuider::TouchGuideListener::OnDoubleTap(MMI::PointerEvent& event) -{ - HILOG_DEBUG(); - - MMI::PointerEvent::PointerItem clickPoint = {}; - if (server_.currentState_ != static_cast(TouchGuideState::TOUCH_GUIDING)) { - return false; - } - server_.OnTouchInteractionEnd(); - server_.CancelPostEventIfNeed(server_.SEND_HOVER_ENTER_MOVE_MSG); - server_.CancelPostEventIfNeed(server_.SEND_HOVER_EXIT_MSG); - server_.ForceSendAndRemoveEvent(server_.SEND_TOUCH_GUIDE_END_MSG, event); - server_.SendAccessibilityEventToAA(EventType::TYPE_TOUCH_END); - - return server_.ExecuteActionOnAccessibilityFocused(ActionType::ACCESSIBILITY_ACTION_CLICK); -} - -bool TouchGuider::TouchGuideListener::OnStarted() -{ - HILOG_DEBUG(); - - server_.currentState_ = static_cast(TouchGuideState::TRANSMITTING); - server_.CancelPostEventIfNeed(SEND_HOVER_ENTER_MOVE_MSG); - server_.CancelPostEventIfNeed(SEND_HOVER_EXIT_MSG); - server_.PostGestureRecognizeExit(); - server_.SendAccessibilityEventToAA(EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN); - return false; -} - -bool TouchGuider::TouchGuideListener::OnCompleted(GestureType gestureId) -{ - HILOG_DEBUG("OnCompleted, gestureId is %{public}d", gestureId); - - if (server_.currentState_ != static_cast(TouchGuideState::TRANSMITTING)) { - HILOG_DEBUG("OnCompleted, state is not transmitting."); - return false; - } - server_.OnTouchInteractionEnd(); - server_.SendAccessibilityEventToAA(EventType::TYPE_TOUCH_GUIDE_GESTURE_END); - server_.SendAccessibilityEventToAA(EventType::TYPE_TOUCH_END); - server_.CancelPostEvent(EXIT_GESTURE_REC_MSG); - server_.currentState_ = static_cast(TouchGuideState::TOUCH_GUIDING); - - AccessibilityEventInfo eventInfo {}; - eventInfo.SetEventType(EventType::TYPE_GESTURE_EVENT); - eventInfo.SetGestureType(gestureId); - Singleton::GetInstance().SendEvent(eventInfo); - return true; -} - -bool TouchGuider::TouchGuideListener::OnCancelled(MMI::PointerEvent& event) -{ - HILOG_DEBUG(); - - switch (static_cast(server_.currentState_)) { - case TouchGuideState::TRANSMITTING: - server_.OnTouchInteractionEnd(); - server_.SendAccessibilityEventToAA(EventType::TYPE_TOUCH_GUIDE_GESTURE_END); - if (event.GetPointerAction() == MMI::PointerEvent::POINTER_ACTION_UP && - event.GetPointerIds().size() == POINTER_COUNT_1) { - server_.SendAccessibilityEventToAA(EventType::TYPE_TOUCH_END); - } - server_.CancelPostEvent(EXIT_GESTURE_REC_MSG); - server_.currentState_ = static_cast(TouchGuideState::TOUCH_GUIDING); - break; - case TouchGuideState::TOUCH_GUIDING: - server_.pointerEvents_.push_back(event); - server_.ForceSendAndRemoveEvent(SEND_HOVER_ENTER_MOVE_MSG, event); - server_.CancelPostEventIfNeed(SEND_HOVER_EXIT_MSG); - server_.SendEventToMultimodal(event, HOVER_MOVE); - break; - default: - return false; - } - return true; -} - -void TouchGuider::HandleTouchGuidingState(MMI::PointerEvent& event) -{ - HILOG_DEBUG(); - - switch (event.GetPointerAction()) { - case MMI::PointerEvent::POINTER_ACTION_DOWN: - if (event.GetPointerIds().size() == POINTER_COUNT_1) { - HandleTouchGuidingStateInnerDown(event); - } else { - CancelPostEventIfNeed(SEND_HOVER_ENTER_MOVE_MSG); - CancelPostEventIfNeed(SEND_HOVER_EXIT_MSG); - } - break; - case MMI::PointerEvent::POINTER_ACTION_MOVE: - HandleTouchGuidingStateInnerMove(event); - break; - case MMI::PointerEvent::POINTER_ACTION_UP: - if (event.GetPointerIds().size() == POINTER_COUNT_1) { - OnTouchInteractionEnd(); - if (HasEventPending(SEND_HOVER_ENTER_MOVE_MSG)) { - PostHoverExit(); - } else { - SendExitEvents(); - } - if (!HasEventPending(SEND_TOUCH_INTERACTION_END_MSG)) { - PostAccessibilityEvent(SEND_TOUCH_INTERACTION_END_MSG); - } - } - break; - default: - break; - } -} - -void TouchGuider::HandleDraggingState(MMI::PointerEvent& event) -{ - HILOG_DEBUG(); - - switch (event.GetPointerAction()) { - case MMI::PointerEvent::POINTER_ACTION_DOWN: - HILOG_DEBUG("MMI::PointerEvent::POINTER_ACTION_DOWN"); - if (event.GetPointerIds().size() == POINTER_COUNT_1) { - Clear(event); - } else { - currentState_ = static_cast(TouchGuideState::TRANSMITTING); - SendAllUpEvents(event); - } - break; - case MMI::PointerEvent::POINTER_ACTION_MOVE: - HILOG_DEBUG("MMI::PointerEvent::POINTER_ACTION_MOVE"); - HandleDraggingStateInnerMove(event); - break; - case MMI::PointerEvent::POINTER_ACTION_UP: - HILOG_DEBUG("MMI::PointerEvent::POINTER_ACTION_UP"); - if (event.GetPointerIds().size() == POINTER_COUNT_1) { - OnTouchInteractionEnd(); - SendAccessibilityEventToAA(EventType::TYPE_TOUCH_END); - SendEventToMultimodal(event, NO_CHANGE); - currentState_ = static_cast(TouchGuideState::TOUCH_GUIDING); - } else { - SendEventToMultimodal(event, NO_CHANGE); - } - break; - default: - break; - } -} - -void TouchGuider::HandleTransmitingState(MMI::PointerEvent& event) -{ - HILOG_DEBUG(); - - switch (event.GetPointerAction()) { - case MMI::PointerEvent::POINTER_ACTION_DOWN: - if (event.GetPointerIds().size() == POINTER_COUNT_1) { - Clear(event); - } - break; - case MMI::PointerEvent::POINTER_ACTION_UP: - if (event.GetPointerIds().size() == POINTER_COUNT_1) { - if (longPressPointId_ >= 0) { - // Adjust this event's location. - MMI::PointerEvent::PointerItem pointer = {}; - event.GetPointerItem(event.GetPointerId(), pointer); - pointer.SetDisplayX(pointer.GetDisplayX() + longPressOffsetX_); - pointer.SetDisplayY(pointer.GetDisplayY() + longPressOffsetY_); - event.RemovePointerItem(event.GetPointerId()); - event.AddPointerItem(pointer); - longPressPointId_ = INIT_POINT_ID; - longPressOffsetX_ = INIT_MMIPOINT; - longPressOffsetY_ = INIT_MMIPOINT; - } - SendEventToMultimodal(event, NO_CHANGE); - OnTouchInteractionEnd(); - SendAccessibilityEventToAA(EventType::TYPE_TOUCH_END); - currentState_ = static_cast(TouchGuideState::TOUCH_GUIDING); - } - break; - default: - SendEventToMultimodal(event, NO_CHANGE); - break; - } -} - -void TouchGuider::Clear(MMI::PointerEvent& event) -{ - HILOG_DEBUG(); - - if (currentState_ == static_cast(TouchGuideState::TOUCH_GUIDING)) { - SendExitEvents(); - } else if (currentState_ == static_cast(TouchGuideState::DRAGGING) || - currentState_ == static_cast(TouchGuideState::TRANSMITTING)) { - SendUpForAllInjectedEvent(event); - } - - CancelPostEvent(EXIT_GESTURE_REC_MSG); - CancelPostEvent(SEND_TOUCH_INTERACTION_END_MSG); - CancelPostEvent(SEND_TOUCH_GUIDE_END_MSG); - CancelPostEventIfNeed(SEND_HOVER_ENTER_MOVE_MSG); - CancelPostEventIfNeed(SEND_HOVER_EXIT_MSG); - ClearInjectedEventRecorder(); - ClearReceivedEventRecorder(); - pointerEvents_.clear(); - currentState_ = static_cast(TouchGuideState::TOUCH_GUIDING); - isTouchGuiding_ = false; - gestureRecognizer_.Clear(); - longPressPointId_ = INIT_POINT_ID; - longPressOffsetX_ = INIT_MMIPOINT; - longPressOffsetY_ = INIT_MMIPOINT; - OnTouchInteractionEnd(); -} - -void TouchGuider::Clear() -{ - HILOG_DEBUG(); - - std::shared_ptr event = getLastReceivedEvent(); - if (event) { - Clear(*event); - } -} - -void TouchGuider::SendExitEvents() -{ - HILOG_DEBUG(); - - if (!HasEventPending(SEND_TOUCH_GUIDE_END_MSG)) { - PostAccessibilityEvent(SEND_TOUCH_GUIDE_END_MSG); - } -} - -void TouchGuider::HandleTouchGuidingStateInnerDown(MMI::PointerEvent& event) -{ - (void)event; -} - -void TouchGuider::HandleTouchGuidingStateInnerMove(MMI::PointerEvent& event) -{ - HILOG_DEBUG(); - - switch (event.GetPointerIds().size()) { - case POINTER_COUNT_1: - HILOG_DEBUG("POINTER_COUNT_1 begin"); - if (HasEventPending(SEND_HOVER_ENTER_MOVE_MSG)) { - pointerEvents_.push_back(event); - } else if (isTouchGuiding_) { - SendEventToMultimodal(event, HOVER_MOVE); - } - HILOG_DEBUG("POINTER_COUNT_1 end"); - break; - case POINTER_COUNT_2: - HILOG_DEBUG("POINTER_COUNT_2 begin"); - CancelPostEventIfNeed(SEND_HOVER_ENTER_MOVE_MSG); - CancelPostEventIfNeed(SEND_HOVER_EXIT_MSG); - if (IsDragGestureAccept(event)) { - currentState_ = static_cast(TouchGuideState::DRAGGING); - SendEventToMultimodal(event, POINTER_DOWN); - } else { - currentState_ = static_cast(TouchGuideState::TRANSMITTING); - } - HILOG_DEBUG("POINTER_COUNT_2 end"); - break; - default: - HILOG_DEBUG("default begin"); - if (HasEventPending(SEND_HOVER_ENTER_MOVE_MSG)) { - CancelPostEventIfNeed(SEND_HOVER_ENTER_MOVE_MSG); - CancelPostEventIfNeed(SEND_HOVER_EXIT_MSG); - } else { - SendExitEvents(); - } - currentState_ = static_cast(TouchGuideState::TRANSMITTING); - HILOG_DEBUG("default end"); - break; - } -} - -void TouchGuider::HandleDraggingStateInnerMove(MMI::PointerEvent& event) -{ - HILOG_DEBUG(); - - std::vector pIds = event.GetPointerIds(); - int32_t pointCount = pIds.size(); - if (pointCount == POINTER_COUNT_1) { - HILOG_INFO("Only two pointers can be received in the dragging state"); - } else if (pointCount == POINTER_COUNT_2 && IsDragGestureAccept(event)) { - /* get densityPixels from WMS */ - AccessibilityDisplayManager& displayMgr = Singleton::GetInstance(); - auto display = displayMgr.GetDefaultDisplay(); - float densityPixels = display->GetVirtualPixelRatio(); - int32_t miniZoomPointerDistance = static_cast(MINI_POINTER_DISTANCE_DIP * densityPixels); - MMI::PointerEvent::PointerItem pointerF = {}; - MMI::PointerEvent::PointerItem pointerS = {}; - event.GetPointerItem(pIds[INDEX_0], pointerF); - event.GetPointerItem(pIds[INDEX_1], pointerS); - float xPointF = pointerF.GetDisplayX(); - float xPointS = pointerS.GetDisplayX(); - float yPointF = pointerF.GetDisplayY(); - float yPointS = pointerS.GetDisplayY(); - float offsetX = abs(xPointF - xPointS); - float offsetY = abs(yPointF - yPointS); - double duration = hypot(offsetX, offsetY); - if (duration > miniZoomPointerDistance) { - // Adjust this event's location. - MMI::PointerEvent::PointerItem pointer = {}; - event.GetPointerItem(event.GetPointerId(), pointer); - pointer.SetDisplayX(pointer.GetDisplayX() + DIVIDE_2(offsetX)); - pointer.SetDisplayY(pointer.GetDisplayY() + DIVIDE_2(offsetY)); - event.RemovePointerItem(event.GetPointerId()); - event.AddPointerItem(pointer); - } - SendEventToMultimodal(event, NO_CHANGE); - } else { - currentState_ = static_cast(TouchGuideState::TRANSMITTING); - SendAllUpEvents(event); - } -} - -float TouchGuider::GetAngleCos(float offsetX, float offsetY, bool isGetX) -{ - HILOG_DEBUG(); - - float ret = isGetX ? offsetX : offsetY; - double duration = hypot(offsetX, offsetY); - if (duration == 0) { - return ret; - } - ret = ret / duration; - return ret; -} - -bool TouchGuider::IsDragGestureAccept(MMI::PointerEvent& event) -{ - HILOG_DEBUG(); - - std::vector pIds = event.GetPointerIds(); - MMI::PointerEvent::PointerItem pointerF = {}; - MMI::PointerEvent::PointerItem pointerS = {}; - if (!event.GetPointerItem(pIds[0], pointerF)) { - HILOG_ERROR("GetPointerItem(%{public}d) failed", pIds[0]); - } - if (!event.GetPointerItem(pIds[1], pointerS)) { - HILOG_ERROR("GetPointerItem(%{public}d) failed", pIds[1]); - } - - float xPointF = pointerF.GetDisplayX(); - float xPointS = pointerS.GetDisplayX(); - float yPointF = pointerF.GetDisplayY(); - float yPointS = pointerS.GetDisplayY(); - float xPointDownF = 0; - float xPointDownS = 0; - float yPointDownF = 0; - float yPointDownS = 0; - if (receivedRecorder_.pointerDownX.find(INDEX_0) != receivedRecorder_.pointerDownX.end()) { - xPointDownF = receivedRecorder_.pointerDownX.find(INDEX_0)->second; - yPointDownF = receivedRecorder_.pointerDownY.find(INDEX_0)->second; - } - if (receivedRecorder_.pointerDownX.find(INDEX_1) != receivedRecorder_.pointerDownX.end()) { - xPointDownS = receivedRecorder_.pointerDownX.find(INDEX_1)->second; - yPointDownS = receivedRecorder_.pointerDownY.find(INDEX_1)->second; - } - - float firstOffsetX = xPointF - xPointDownF; - float firstOffsetY = yPointF - yPointDownF; - float secondOffsetX = xPointS - xPointDownS; - float secondOffsetY = yPointS - yPointDownS; - if ((!firstOffsetX && !firstOffsetY) || (!secondOffsetX && !secondOffsetY)) { - return true; - } - - float firstXCos = GetAngleCos(firstOffsetX, firstOffsetY, true); - float firstYCos = GetAngleCos(firstOffsetX, firstOffsetY, false); - float secondXCos = GetAngleCos(secondOffsetX, secondOffsetY, true); - float secondYCos = GetAngleCos(secondOffsetX, secondOffsetY, false); - if ((firstXCos * secondXCos + firstYCos * secondYCos) < MAX_DRAG_GESTURE_COSINE) { - return false; - } - return true; -} - -void TouchGuider::RecordInjectedEvent(MMI::PointerEvent& event) -{ - HILOG_DEBUG(); - - int32_t pointerId = event.GetPointerId(); - switch (event.GetPointerAction()) { - case MMI::PointerEvent::POINTER_ACTION_DOWN: - injectedRecorder_.downPointerNum++; - injectedRecorder_.downPointers.insert(pointerId); - injectedRecorder_.lastDownTime = event.GetActionTime() / US_TO_MS; - break; - case MMI::PointerEvent::POINTER_ACTION_UP: - injectedRecorder_.downPointers.erase(pointerId); - if (injectedRecorder_.downPointerNum > 0) { - injectedRecorder_.downPointerNum--; - } - if (injectedRecorder_.downPointers.empty()) { - injectedRecorder_.lastDownTime = 0; - } - break; - case MMI::PointerEvent::POINTER_ACTION_MOVE: - injectedRecorder_.lastHoverEvent = std::make_shared(event); - break; - default: - break; - } -} - -void TouchGuider::RecordReceivedEvent(MMI::PointerEvent& event) -{ - HILOG_DEBUG(); - - int32_t pointId = event.GetPointerId(); - MMI::PointerEvent::PointerItem pointer; - if (!event.GetPointerItem(pointId, pointer)) { - HILOG_ERROR("GetPointerItem(%{public}d) failed", pointId); - } - receivedRecorder_.lastEvent = std::make_shared(event); - switch (event.GetPointerAction()) { - case MMI::PointerEvent::POINTER_ACTION_DOWN: - receivedRecorder_.pointerDownX[pointId] = pointer.GetDisplayX(); - receivedRecorder_.pointerDownY[pointId] = pointer.GetDisplayY(); - break; - case MMI::PointerEvent::POINTER_ACTION_UP: - receivedRecorder_.pointerDownX.erase(pointId); - receivedRecorder_.pointerDownY.erase(pointId); - break; - default: - break; - } -} - -void TouchGuider::ClearReceivedEventRecorder() -{ - HILOG_DEBUG(); - - receivedRecorder_.pointerDownX.clear(); - receivedRecorder_.pointerDownY.clear(); - receivedRecorder_.lastEvent = nullptr; -} - -void TouchGuider::ClearInjectedEventRecorder() -{ - HILOG_DEBUG(); - - injectedRecorder_.downPointerNum = 0; - injectedRecorder_.downPointers.clear(); - injectedRecorder_.lastHoverEvent = nullptr; -} - -void TouchGuider::SendAllDownEvents(MMI::PointerEvent& event) -{ - HILOG_DEBUG(); - - std::vector pIds = event.GetPointerIds(); - for (auto& pId : pIds) { - if (injectedRecorder_.downPointers.find(pId) == injectedRecorder_.downPointers.end()) { - event.SetPointerId(pId); - SendEventToMultimodal(event, POINTER_DOWN); - } - } -} - -void TouchGuider::SendAllUpEvents(MMI::PointerEvent &event) -{ - HILOG_DEBUG(); - - std::vector pIds = event.GetPointerIds(); - for (auto& pId : pIds) { - event.SetPointerId(pId); - SendEventToMultimodal(event, POINTER_UP); - } -} - -void TouchGuider::SendUpForAllInjectedEvent(MMI::PointerEvent& event) -{ - HILOG_DEBUG(); - - std::vector pIds = event.GetPointerIds(); - for (const auto& pId : pIds) { - if (injectedRecorder_.downPointers.find(pId) == injectedRecorder_.downPointers.end()) { - continue; - } - SendEventToMultimodal(event, POINTER_UP); - } -} - -void TouchGuider::PostGestureRecognizeExit() -{ - HILOG_DEBUG(); - - handler_->SendEvent(EXIT_GESTURE_REC_MSG, 0, EXIT_GESTURE_REC_TIMEOUT); -} - -void TouchGuider::PostHoverEnterAndMove(MMI::PointerEvent& event) -{ - HILOG_DEBUG(); - - CancelPostEventIfNeed(SEND_HOVER_ENTER_MOVE_MSG); - pointerEvents_.push_back(event); - handler_->SendEvent(SEND_HOVER_ENTER_MOVE_MSG, 0, DOUBLE_TAP_TIMEOUT); -} - -void TouchGuider::PostHoverExit() -{ - HILOG_DEBUG(); - - CancelPostEventIfNeed(SEND_HOVER_EXIT_MSG); - handler_->SendEvent(SEND_HOVER_EXIT_MSG, 0, DOUBLE_TAP_TIMEOUT); -} - -void TouchGuider::PostAccessibilityEvent(uint32_t innerEventID) -{ - HILOG_DEBUG(); - - handler_->SendEvent(innerEventID, 0, EXIT_GESTURE_REC_TIMEOUT); -} - -void TouchGuider::CancelPostEvent(uint32_t innerEventID) -{ - HILOG_DEBUG(); - - handler_->RemoveEvent(innerEventID); -} - -void TouchGuider::CancelPostEventIfNeed(uint32_t innerEventID) -{ - HILOG_DEBUG(); - - if (HasEventPending(innerEventID)) { - handler_->RemoveEvent(innerEventID); - if (innerEventID == SEND_HOVER_ENTER_MOVE_MSG) { - pointerEvents_.clear(); - } - } -} - -bool TouchGuider::HasEventPending(uint32_t innerEventID) -{ - HILOG_DEBUG(); - - return handler_->HasInnerEvent(innerEventID); -} - -void TouchGuider::ForceSendAndRemoveEvent(uint32_t innerEventID, MMI::PointerEvent& event) -{ - (void)event; - HILOG_DEBUG(); - - if (!HasEventPending(innerEventID)) { - HILOG_DEBUG("No pending event."); - return; - } - - switch (innerEventID) { - case SEND_HOVER_ENTER_MOVE_MSG: - SendAccessibilityEventToAA(EventType::TYPE_TOUCH_GUIDE_BEGIN); - if (pointerEvents_.empty()) { - break; - } - for (auto iter = pointerEvents_.begin(); iter != pointerEvents_.end(); ++iter) { - SendEventToMultimodal(*iter, HOVER_MOVE); - } - pointerEvents_.clear(); - break; - case SEND_TOUCH_INTERACTION_END_MSG: - SendAccessibilityEventToAA(EventType::TYPE_TOUCH_END); - break; - case SEND_TOUCH_GUIDE_END_MSG: - SendAccessibilityEventToAA(EventType::TYPE_TOUCH_GUIDE_END); - break; - default: - break; - } - CancelPostEvent(innerEventID); -} - -void TGEventHandler::HoverEnterAndMoveRunner() -{ - HILOG_DEBUG(); - - std::list motionEvent = tgServer_.getHoverEnterAndMoveEvent(); - tgServer_.SendAccessibilityEventToAA(EventType::TYPE_TOUCH_GUIDE_BEGIN); - if (!motionEvent.empty()) { - for (auto iter = motionEvent.begin(); iter != motionEvent.end(); ++iter) { - tgServer_.SendEventToMultimodal(*iter, HOVER_MOVE); - } - } - tgServer_.ClearHoverEnterAndMoveEvent(); -} - -void TGEventHandler::HoverExitRunner() -{ - HILOG_DEBUG(); - - std::shared_ptr pEvent = tgServer_.getLastReceivedEvent(); - tgServer_.SendEventToMultimodal(*pEvent, HOVER_MOVE); - if (!HasInnerEvent(TouchGuider::SEND_TOUCH_GUIDE_END_MSG)) { - RemoveEvent(TouchGuider::SEND_TOUCH_GUIDE_END_MSG); - SendEvent(TouchGuider::SEND_TOUCH_GUIDE_END_MSG, 0, EXIT_GESTURE_REC_TIMEOUT); - } - if (HasInnerEvent(TouchGuider::SEND_TOUCH_INTERACTION_END_MSG)) { - RemoveEvent(TouchGuider::SEND_TOUCH_INTERACTION_END_MSG); - SendEvent(TouchGuider::SEND_TOUCH_INTERACTION_END_MSG, 0, EXIT_GESTURE_REC_TIMEOUT); - } -} -} // namespace Accessibility -} // namespace OHOS \ No newline at end of file diff --git a/services/aams/test/mock/src/mock_display.cpp b/services/aams/test/mock/src/mock_display.cpp index 2d074bc7..42961875 100644 --- a/services/aams/test/mock/src/mock_display.cpp +++ b/services/aams/test/mock/src/mock_display.cpp @@ -15,7 +15,7 @@ #include #include "display.h" -#include "window/window_manager/utils/include/display_info.h" +#include "display_info.h" namespace OHOS::Rosen { namespace { diff --git a/services/aams/test/unittest/accessibility_touch_exploration_test.cpp b/services/aams/test/unittest/accessibility_touch_exploration_test.cpp new file mode 100755 index 00000000..fe7768cb --- /dev/null +++ b/services/aams/test/unittest/accessibility_touch_exploration_test.cpp @@ -0,0 +1,2248 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include "accessibility_common_helper.h" +#include "accessibility_element_operator_proxy.h" +#include "accessibility_touch_exploration.h" +#include "accessibility_ut_helper.h" + +using namespace testing; +using namespace testing::ext; + +namespace OHOS { +namespace Accessibility { +namespace { + constexpr int32_t POINT_ID_0 = 0; + constexpr int32_t POINT_ID_1 = 1; + constexpr int32_t POINT_ID_2 = 2; + constexpr int32_t POINT_ID_3 = 3; + constexpr int32_t SLEEP_US_50 = 50; + constexpr int32_t SLEEP_US_300 = 300; + constexpr int32_t ACTION_INVALID = -1; + constexpr int32_t DISPLAY_10 = 10; + constexpr int32_t DISPLAY_500 = 500; + constexpr int32_t DISPLAY_1000 = 1000; + constexpr int32_t DISPLAY_1500 = 1500; +} // namespace + +class TouchExplorationTest : public testing::Test { +public: + TouchExplorationTest() + {} + ~TouchExplorationTest() + {} + + static void SetUpTestCase(); + static void TearDownTestCase(); + static void SetTouchExplorationPoint(MMI::PointerEvent::PointerItem &point, int id, int x, int y); + void SetUp() override; + void TearDown() override; + +protected: + std::shared_ptr CreateTouchEvent(int32_t action, int32_t pointerId, int32_t displayX, + int32_t displayY); + std::shared_ptr CreateTouchEvent(int32_t action, + std::vector &points, int32_t pointerCount); + std::unique_ptr touchExploration_ = nullptr; +}; + +void TouchExplorationTest::SetTouchExplorationPoint(MMI::PointerEvent::PointerItem &point, int id, int x, int y) +{ + point.SetPointerId(id); + point.SetDisplayX(x); + point.SetDisplayY(y); +} + +void TouchExplorationTest::SetUpTestCase() +{ + GTEST_LOG_(INFO) << "TouchExplorationTest SetUpTestCase"; + Singleton::GetInstance().OnStart(); +} + +void TouchExplorationTest::TearDownTestCase() +{ + GTEST_LOG_(INFO) << "TouchExplorationTest TearDownTestCase"; + Singleton::GetInstance().OnStop(); +} + +void TouchExplorationTest::SetUp() +{ + GTEST_LOG_(INFO) << "TouchExplorationTest SetUp"; + + touchExploration_ = std::make_unique(); + if (!touchExploration_) { + GTEST_LOG_(INFO) << "TouchExploration new failed!"; + return; + } + touchExploration_->StartUp(); +} + +void TouchExplorationTest::TearDown() +{ + GTEST_LOG_(INFO) << "TouchExplorationTest TearDown"; + AccessibilityAbilityHelper::GetInstance().ClearEventTypeActionVector(); + AccessibilityAbilityHelper::GetInstance().ClearTouchEventActionVector(); + usleep(SLEEP_US_300); + touchExploration_->Clear(); + touchExploration_->SetCurrentState(TouchExplorationState::TOUCH_INIT); +} + +std::shared_ptr TouchExplorationTest::CreateTouchEvent(int32_t action, int32_t pointerId, + int32_t displayX, int32_t displayY) +{ + std::shared_ptr pointerEvent = MMI::PointerEvent::Create(); + MMI::PointerEvent::PointerItem item = {}; + + item.SetPointerId(pointerId); + item.SetDisplayX(displayX); + item.SetDisplayY(displayY); + item.SetPressed(action == MMI::PointerEvent::POINTER_ACTION_UP ? false : true); + pointerEvent->AddPointerItem(item); + pointerEvent->SetPointerId(pointerId); + pointerEvent->SetSourceType(MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN); + pointerEvent->SetPointerAction(action); + + return pointerEvent; +} + +std::shared_ptr TouchExplorationTest::CreateTouchEvent(int32_t action, + std::vector &points, int32_t pointerId) +{ + std::shared_ptr pointerEvent = MMI::PointerEvent::Create(); + + for (auto &point : points) { + if (point.GetPointerId() == pointerId) { + point.SetPressed(action == MMI::PointerEvent::POINTER_ACTION_UP ? false : true); + } else { + point.SetPressed(true); + } + pointerEvent->AddPointerItem(point); + } + pointerEvent->SetPointerId(pointerId); + pointerEvent->SetSourceType(MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN); + pointerEvent->SetPointerAction(action); + + return pointerEvent; +} + +/** + * @tc.number: HandleInitStateDown001 + * @tc.name: HandleInitStateDown + * @tc.desc: Test func HandleInitStateDown. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleInitStateDown_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleInitStateDown_001 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::TOUCH_INIT); + + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, POINT_ID_0, + 0, 0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::ONE_FINGER_DOWN); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleInitStateDown_001 end"; +} + +/** + * @tc.number: HandleInitStateDown002 + * @tc.name: HandleInitStateDown + * @tc.desc: Test func HandleInitStateDown. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleInitStateDown_002, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleInitStateDown_002 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::TOUCH_INIT); + + std::vector points = {}; + MMI::PointerEvent::PointerItem point = {}; + SetTouchExplorationPoint(point, POINT_ID_0, 0, 0); + MMI::PointerEvent::PointerItem otherPoint = {}; + SetTouchExplorationPoint(otherPoint, POINT_ID_1, 0, 0); + points.emplace_back(point); + points.emplace_back(otherPoint); + std::shared_ptr event = + CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, POINT_ID_1); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0), + MMI::PointerEvent::POINTER_ACTION_DOWN); + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::PASSING_THROUGH); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleInitStateDown_002 end"; +} + +/** + * @tc.number: HandleInitStateUp001 + * @tc.name: HandleInitStateUp + * @tc.desc: Test func HandleInitStateUp. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleInitStateUp_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleInitStateUp_001 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::TOUCH_INIT); + + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, POINT_ID_0, + 0, 0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0), + MMI::PointerEvent::POINTER_ACTION_UP); + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::TOUCH_INIT); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleInitStateUp_001 end"; +} + +/** + * @tc.number: HandleInitStateUp002 + * @tc.name: HandleInitStateUp + * @tc.desc: Test func HandleInitStateUp. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleInitStateUp_002, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleInitStateUp_002 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::TOUCH_INIT); + + std::vector points = {}; + MMI::PointerEvent::PointerItem firstPoint = {}; + SetTouchExplorationPoint(firstPoint, POINT_ID_0, 0, 0); + points.emplace_back(firstPoint); + MMI::PointerEvent::PointerItem secondPoint = {}; + SetTouchExplorationPoint(secondPoint, POINT_ID_1, DISPLAY_10, 0); + points.emplace_back(secondPoint); + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, + POINT_ID_1); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0), + MMI::PointerEvent::POINTER_ACTION_UP); + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::PASSING_THROUGH); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleInitStateUp_002 end"; +} + +/** + * @tc.number: HandleInitStateMove001 + * @tc.name: HandleInitStateMove + * @tc.desc: Test func HandleInitStateMove. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleInitStateMove_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleInitStateMove_001 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::TOUCH_INIT); + + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, POINT_ID_0, + 0, 0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0), + MMI::PointerEvent::POINTER_ACTION_MOVE); + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::PASSING_THROUGH); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleInitStateMove_001 end"; +} + +/** + * @tc.number: HandlePassingThroughState001 + * @tc.name: HandlePassingThroughState + * @tc.desc: Test func HandlePassingThroughState. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandlePassingThroughState_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandlePassingThroughState_001 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::PASSING_THROUGH); + + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, POINT_ID_0, + 0, 0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0), + MMI::PointerEvent::POINTER_ACTION_DOWN); + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::PASSING_THROUGH); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandlePassingThroughState_001 end"; +} + +/** + * @tc.number: HandlePassingThroughState002 + * @tc.name: HandlePassingThroughState + * @tc.desc: Test func HandlePassingThroughState. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandlePassingThroughState_002, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandlePassingThroughState_002 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::PASSING_THROUGH); + + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, POINT_ID_0, + 0, 0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0), + MMI::PointerEvent::POINTER_ACTION_UP); + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::TOUCH_INIT); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandlePassingThroughState_002 end"; +} + +/** + * @tc.number: HandleInvalidState001 + * @tc.name: HandleInvalidState + * @tc.desc: Test func HandleInvalidState. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleInvalidState_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleInvalidState_001 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::INVALID); + + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, POINT_ID_0, + 0, 0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0), ACTION_INVALID); + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::INVALID); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleInvalidState_001 end"; +} + +/** + * @tc.number: HandleInvalidState002 + * @tc.name: HandleInvalidState + * @tc.desc: Test func HandleInvalidState. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleInvalidState_002, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleInvalidState_002 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::INVALID); + + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, POINT_ID_0, + 0, 0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0), ACTION_INVALID); + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::TOUCH_INIT); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleInvalidState_002 end"; +} + +/** + * @tc.number: HandleCancelEvent001 + * @tc.name: HandleCancelEvent + * @tc.desc: Test func HandleCancelEvent. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleCancelEvent_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleCancelEvent_001 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::TOUCH_INIT); + + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_CANCEL, POINT_ID_0, + 0, 0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0), + MMI::PointerEvent::POINTER_ACTION_HOVER_CANCEL); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleCancelEvent_001 end"; +} + +/** + * @tc.number: HandleOneFingerDownStateDown001 + * @tc.name: HandleOneFingerDownStateDown + * @tc.desc: Test func HandleOneFingerDownStateDown. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleOneFingerDownStateDown_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleOneFingerDownStateDown_001 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::ONE_FINGER_DOWN); + + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, POINT_ID_0, + 0, 0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0), ACTION_INVALID); + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::TWO_FINGERS_UNKNOWN); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleOneFingerDownStateDown_001 end"; +} + +/** + * @tc.number: HandleOneFingerDownStateUp001 + * @tc.name: HandleOneFingerDownStateUp + * @tc.desc: Test func HandleOneFingerDownStateUp. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleOneFingerDownStateUp_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleOneFingerDownStateUp_001 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::ONE_FINGER_DOWN); + + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, POINT_ID_0, + 0, 0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0), ACTION_INVALID); + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::ONE_FINGER_SINGLE_TAP); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleOneFingerDownStateUp_001 end"; +} + +/** + * @tc.number: HandleOneFingerDownStateMove001 + * @tc.name: HandleOneFingerDownStateMove + * @tc.desc: Test func HandleOneFingerDownStateMove. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleOneFingerDownStateMove_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleOneFingerDownStateMove_001 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::TOUCH_INIT); + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, POINT_ID_0, + 0, 0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::ONE_FINGER_DOWN); + + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, POINT_ID_0, 0, 0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::ONE_FINGER_DOWN); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleOneFingerDownStateMove_001 end"; +} + +/** + * @tc.number: HandleOneFingerDownStateMove002 + * @tc.name: HandleOneFingerDownStateMove + * @tc.desc: Test func HandleOneFingerDownStateMove. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleOneFingerDownStateMove_002, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleOneFingerDownStateMove_002 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::TOUCH_INIT); + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, POINT_ID_0, + 0, 0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::ONE_FINGER_DOWN); + + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, POINT_ID_0, 0, DISPLAY_500); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::ONE_FINGER_SWIPE); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleOneFingerDownStateMove_002 end"; +} + +/** + * @tc.number: HandleOneFingerLongPressStateDown001 + * @tc.name: HandleOneFingerLongPressStateDown + * @tc.desc: Test func HandleOneFingerLongPressStateDown. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleOneFingerLongPressStateDown_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleOneFingerLongPressStateDown_001 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::ONE_FINGER_LONG_PRESS); + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, POINT_ID_1, + 0, 0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::TWO_FINGERS_UNKNOWN); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleOneFingerLongPressStateDown_001 end"; +} + +/** + * @tc.number: HandleOneFingerLongPressStateUp001 + * @tc.name: HandleOneFingerLongPressStateUp + * @tc.desc: Test func HandleOneFingerLongPressStateUp. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleOneFingerLongPressStateUp_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleOneFingerLongPressStateUp_001 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::ONE_FINGER_LONG_PRESS); + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, POINT_ID_0, + 0, 0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0), + MMI::PointerEvent::POINTER_ACTION_HOVER_EXIT); + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::TOUCH_INIT); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleOneFingerLongPressStateUp_001 end"; +} + +/** + * @tc.number: HandleOneFingerLongPressStateMove001 + * @tc.name: HandleOneFingerLongPressStateMove + * @tc.desc: Test func HandleOneFingerLongPressStateMove. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleOneFingerLongPressStateMove_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleOneFingerLongPressStateMove_001 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::ONE_FINGER_LONG_PRESS); + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, POINT_ID_0, + 0, 0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0), + MMI::PointerEvent::POINTER_ACTION_HOVER_MOVE); + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::ONE_FINGER_LONG_PRESS); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleOneFingerLongPressStateMove_001 end"; +} + +/** + * @tc.number: HandleOneFingerSwipeStateDown001 + * @tc.name: HandleOneFingerSwipeStateDown + * @tc.desc: Test func HandleOneFingerSwipeStateDown. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleOneFingerSwipeStateDown_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleOneFingerSwipeStateDown_001 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::ONE_FINGER_SWIPE); + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, POINT_ID_1, + 0, 0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::TWO_FINGERS_UNKNOWN); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleOneFingerSwipeStateDown_001 end"; +} + +/** + * @tc.number: HandleOneFingerSwipeStateUp001 + * @tc.name: HandleOneFingerSwipeStateUp + * @tc.desc: Test func HandleOneFingerSwipeStateUp. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleOneFingerSwipeStateUp_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleOneFingerSwipeStateUp_001 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::TOUCH_INIT); + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, POINT_ID_0, + 0, 0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::ONE_FINGER_DOWN); + + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, POINT_ID_0, DISPLAY_500, 0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, POINT_ID_0, DISPLAY_500, 0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::TOUCH_INIT); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleOneFingerSwipeStateUp_001 end"; +} + +/** + * @tc.number: HandleOneFingerSwipeStateUp002 + * @tc.name: HandleOneFingerSwipeStateUp + * @tc.desc: Test func HandleOneFingerSwipeStateUp. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleOneFingerSwipeStateUp_002, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleOneFingerSwipeStateUp_002 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::TOUCH_INIT); + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, POINT_ID_0, + 0, 0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::ONE_FINGER_DOWN); + + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, POINT_ID_0, DISPLAY_500, 0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, POINT_ID_0, DISPLAY_1000, 0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, POINT_ID_0, DISPLAY_1500, 0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetGestureId(), + static_cast(GestureType::GESTURE_SWIPE_RIGHT)); + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::TOUCH_INIT); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleOneFingerSwipeStateUp_002 end"; +} + +/** + * @tc.number: HandleOneFingerSingleTapStateDown001 + * @tc.name: HandleOneFingerSingleTapStateDown + * @tc.desc: Test func HandleOneFingerSingleTapStateDown. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleOneFingerSingleTapStateDown_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleOneFingerSingleTapStateDown_001 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::ONE_FINGER_SINGLE_TAP); + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, POINT_ID_0, + 0, 0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0), + MMI::PointerEvent::POINTER_ACTION_DOWN); + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::ONE_FINGER_SINGLE_TAP_THEN_DOWN); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleOneFingerSingleTapStateDown_001 end"; +} + +/** + * @tc.number: HandleOneFingerSingleTapThenDownStateDown001 + * @tc.name: HandleOneFingerSingleTapThenDownStateDown + * @tc.desc: Test func HandleOneFingerSingleTapThenDownStateDown. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleOneFingerSingleTapThenDownStateDown_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleOneFingerSingleTapThenDownStateDown_001 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::ONE_FINGER_SINGLE_TAP_THEN_DOWN); + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, POINT_ID_1, + 0, 0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0), + MMI::PointerEvent::POINTER_ACTION_DOWN); + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::ONE_FINGER_SINGLE_TAP_THEN_DOWN); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleOneFingerSingleTapThenDownStateDown_001 end"; +} + +/** + * @tc.number: HandleOneFingerSingleTapThenDownStateUp001 + * @tc.name: HandleOneFingerSingleTapThenDownStateUp + * @tc.desc: Test func HandleOneFingerSingleTapThenDownStateUp. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleOneFingerSingleTapThenDownStateUp_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleOneFingerSingleTapThenDownStateUp_001 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::ONE_FINGER_SINGLE_TAP_THEN_DOWN); + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, POINT_ID_0, + 0, 0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0), + MMI::PointerEvent::POINTER_ACTION_UP); + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::TOUCH_INIT); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleOneFingerSingleTapThenDownStateUp_001 end"; +} + +/** + * @tc.number: HandleOneFingerSingleTapThenDownStateUp002 + * @tc.name: HandleOneFingerSingleTapThenDownStateUp + * @tc.desc: Test func HandleOneFingerSingleTapThenDownStateUp. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleOneFingerSingleTapThenDownStateUp_002, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleOneFingerSingleTapThenDownStateUp_001 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::ONE_FINGER_SINGLE_TAP_THEN_DOWN); + + std::vector points = {}; + MMI::PointerEvent::PointerItem point = {}; + SetTouchExplorationPoint(point, POINT_ID_0, 0, 0); + MMI::PointerEvent::PointerItem otherPoint = {}; + SetTouchExplorationPoint(otherPoint, POINT_ID_1, 0, 0); + points.emplace_back(point); + points.emplace_back(otherPoint); + std::shared_ptr event = + CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, POINT_ID_1); + touchExploration_->OnPointerEvent(*event); + + EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0), + MMI::PointerEvent::POINTER_ACTION_UP); + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::ONE_FINGER_SINGLE_TAP_THEN_DOWN); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleOneFingerSingleTapThenDownStateUp_002 end"; +} + +/** + * @tc.number: HandleOneFingerSingleTapThenDownStateMove001 + * @tc.name: HandleOneFingerSingleTapThenDownStateMove + * @tc.desc: Test func HandleOneFingerSingleTapThenDownStateMove. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleOneFingerSingleTapThenDownStateMove_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleOneFingerSingleTapThenDownStateMove_001 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::ONE_FINGER_SINGLE_TAP_THEN_DOWN); + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, POINT_ID_0, + 0, 0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0), + MMI::PointerEvent::POINTER_ACTION_MOVE); + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::ONE_FINGER_SINGLE_TAP_THEN_DOWN); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleOneFingerSingleTapThenDownStateMove_001 end"; +} + +/** + * @tc.number: HandleTwoFingersDownStateDown001 + * @tc.name: HandleTwoFingersDownStateDown + * @tc.desc: Test func HandleTwoFingersDownStateDown. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleTwoFingersDownStateDown_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleTwoFingersDownStateDown_001 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::TWO_FINGERS_DOWN); + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, POINT_ID_0, + 0, 0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::INVALID); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleTwoFingersDownStateDown_001 end"; +} + +/** + * @tc.number: HandleTwoFingersDownStateDown002 + * @tc.name: HandleTwoFingersDownStateDown + * @tc.desc: Test func HandleTwoFingersDownStateDown. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleTwoFingersDownStateDown_002, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleTwoFingersDownStateDown_002 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::TWO_FINGERS_DOWN); + + std::vector points = {}; + MMI::PointerEvent::PointerItem firstPoint = {}; + SetTouchExplorationPoint(firstPoint, POINT_ID_0, 0, 0); + MMI::PointerEvent::PointerItem secondPoint = {}; + SetTouchExplorationPoint(secondPoint, POINT_ID_1, 0, 0); + MMI::PointerEvent::PointerItem thirdPoint = {}; + SetTouchExplorationPoint(thirdPoint, POINT_ID_2, 0, 0); + points.emplace_back(firstPoint); + points.emplace_back(secondPoint); + points.emplace_back(thirdPoint); + std::shared_ptr event = + CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, POINT_ID_0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::INVALID); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleTwoFingersDownStateDown_002 end"; +} + +/** + * @tc.number: HandleTwoFingersDownStateDown003 + * @tc.name: HandleTwoFingersDownStateDown + * @tc.desc: Test func HandleTwoFingersDownStateDown. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleTwoFingersDownStateDown_003, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleTwoFingersDownStateDown_003 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::TOUCH_INIT); + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, POINT_ID_0, + 0, 0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + std::vector points = {}; + MMI::PointerEvent::PointerItem firstPoint = {}; + SetTouchExplorationPoint(firstPoint, POINT_ID_0, 0, 0); + MMI::PointerEvent::PointerItem secondPoint = {}; + SetTouchExplorationPoint(secondPoint, POINT_ID_1, DISPLAY_10, 0); + points.emplace_back(firstPoint); + points.emplace_back(secondPoint); + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, POINT_ID_1); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + MMI::PointerEvent::PointerItem thirdPoint = {}; + SetTouchExplorationPoint(thirdPoint, POINT_ID_2, 0, 0); + points.emplace_back(thirdPoint); + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, POINT_ID_2); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::THREE_FINGERS_DOWN); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleTwoFingersDownStateDown_003 end"; +} + +/** + * @tc.number: HandleTwoFingersDownStateUp001 + * @tc.name: HandleTwoFingersDownStateUp + * @tc.desc: Test func HandleTwoFingersDownStateUp. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleTwoFingersDownStateUp_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleTwoFingersDownStateUp_001 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::TWO_FINGERS_DOWN); + + std::vector points = {}; + MMI::PointerEvent::PointerItem firstPoint = {}; + SetTouchExplorationPoint(firstPoint, POINT_ID_0, 0, 0); + MMI::PointerEvent::PointerItem secondPoint = {}; + SetTouchExplorationPoint(secondPoint, POINT_ID_1, 0, 0); + points.emplace_back(firstPoint); + points.emplace_back(secondPoint); + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, + POINT_ID_1); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::TWO_FINGERS_DOWN); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleTwoFingersDownStateUp_001 end"; +} + +/** + * @tc.number: HandleTwoFingersDownStateUp002 + * @tc.name: HandleTwoFingersDownStateUp + * @tc.desc: Test func HandleTwoFingersDownStateUp. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleTwoFingersDownStateUp_002, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleTwoFingersDownStateUp_002 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::TWO_FINGERS_DOWN); + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, POINT_ID_0, + 0, 0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::TWO_FINGERS_TAP); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleTwoFingersDownStateUp_002 end"; +} + +/** + * @tc.number: HandleTwoFingersDownStateUp003 + * @tc.name: HandleTwoFingersDownStateUp + * @tc.desc: Test func HandleTwoFingersDownStateUp. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleTwoFingersDownStateUp_003, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleTwoFingersDownStateUp_003 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::TWO_FINGERS_DOWN); + + std::vector points = {}; + MMI::PointerEvent::PointerItem firstPoint = {}; + SetTouchExplorationPoint(firstPoint, POINT_ID_0, 0, 0); + MMI::PointerEvent::PointerItem secondPoint = {}; + SetTouchExplorationPoint(secondPoint, POINT_ID_1, 0, 0); + MMI::PointerEvent::PointerItem thirdPoint = {}; + SetTouchExplorationPoint(thirdPoint, POINT_ID_2, 0, 0); + points.emplace_back(firstPoint); + points.emplace_back(secondPoint); + points.emplace_back(thirdPoint); + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, + POINT_ID_2); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::INVALID); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleTwoFingersDownStateUp_003 end"; +} + +/** + * @tc.number: HandleTwoFingersDownStateMove001 + * @tc.name: HandleTwoFingersDownStateMove + * @tc.desc: Test func HandleTwoFingersDownStateMove. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleTwoFingersDownStateMove_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleTwoFingersDownStateMove_001 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::TOUCH_INIT); + + std::vector points = {}; + MMI::PointerEvent::PointerItem firstPoint = {}; + SetTouchExplorationPoint(firstPoint, POINT_ID_0, 0, 0); + points.emplace_back(firstPoint); + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, + POINT_ID_0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + MMI::PointerEvent::PointerItem secondPoint = {}; + SetTouchExplorationPoint(secondPoint, POINT_ID_1, DISPLAY_10, 0); + points.emplace_back(secondPoint); + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, POINT_ID_1); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, points, POINT_ID_1); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::TWO_FINGERS_DOWN); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleTwoFingersDownStateMove_001 end"; +} + +/** + * @tc.number: HandleTwoFingersDownStateMove002 + * @tc.name: HandleTwoFingersDownStateMove + * @tc.desc: Test func HandleTwoFingersDownStateMove. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleTwoFingersDownStateMove_002, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleTwoFingersDownStateMove_002 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::TOUCH_INIT); + + std::vector points = {}; + MMI::PointerEvent::PointerItem firstPoint = {}; + SetTouchExplorationPoint(firstPoint, POINT_ID_0, 0, 0); + points.emplace_back(firstPoint); + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, + POINT_ID_0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + MMI::PointerEvent::PointerItem secondPoint = {}; + SetTouchExplorationPoint(secondPoint, POINT_ID_1, DISPLAY_10, 0); + points.emplace_back(secondPoint); + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, POINT_ID_1); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + points.clear(); + SetTouchExplorationPoint(firstPoint, POINT_ID_0, 0, DISPLAY_500); + SetTouchExplorationPoint(secondPoint, POINT_ID_1, DISPLAY_10, DISPLAY_500); + points.emplace_back(firstPoint); + points.emplace_back(secondPoint); + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, points, POINT_ID_1); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0), + MMI::PointerEvent::POINTER_ACTION_DOWN); + EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(1), + MMI::PointerEvent::POINTER_ACTION_MOVE); + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::TWO_FINGERS_DRAG); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleTwoFingersDownStateMove_002 end"; +} + +/** + * @tc.number: HandleTwoFingersDownStateMove003 + * @tc.name: HandleTwoFingersDownStateMove + * @tc.desc: Test func HandleTwoFingersDownStateMove. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleTwoFingersDownStateMove_003, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleTwoFingersDownStateMove_003 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::TOUCH_INIT); + + std::vector points = {}; + MMI::PointerEvent::PointerItem firstPoint = {}; + SetTouchExplorationPoint(firstPoint, POINT_ID_0, 0, 0); + points.emplace_back(firstPoint); + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, + POINT_ID_0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + MMI::PointerEvent::PointerItem secondPoint = {}; + SetTouchExplorationPoint(secondPoint, POINT_ID_1, DISPLAY_10, 0); + points.emplace_back(secondPoint); + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, POINT_ID_1); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + points.clear(); + SetTouchExplorationPoint(firstPoint, POINT_ID_0, 0, DISPLAY_500); + SetTouchExplorationPoint(secondPoint, POINT_ID_1, DISPLAY_500, 0); + points.emplace_back(firstPoint); + points.emplace_back(secondPoint); + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, points, POINT_ID_1); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0), + MMI::PointerEvent::POINTER_ACTION_DOWN); + EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(1), + MMI::PointerEvent::POINTER_ACTION_DOWN); + EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(2), + MMI::PointerEvent::POINTER_ACTION_MOVE); + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::PASSING_THROUGH); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleTwoFingersDownStateMove_003 end"; +} + +/** + * @tc.number: HandleTwoFingersDragStateDown001 + * @tc.name: HandleTwoFingersDragStateDown + * @tc.desc: Test func HandleTwoFingersDragStateDown. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleTwoFingersDragStateDown_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleTwoFingersDragStateDown_001 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::TWO_FINGERS_DRAG); + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, POINT_ID_0, + 0, 0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::INVALID); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleTwoFingersDragStateDown_001 end"; +} + +/** + * @tc.number: HandleTwoFingersDragStateDown002 + * @tc.name: HandleTwoFingersDragStateDown + * @tc.desc: Test func HandleTwoFingersDragStateDown. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleTwoFingersDragStateDown_002, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleTwoFingersDragStateDown_002 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::TWO_FINGERS_DRAG); + + std::vector points = {}; + MMI::PointerEvent::PointerItem firstPoint = {}; + SetTouchExplorationPoint(firstPoint, POINT_ID_0, 0, 0); + points.emplace_back(firstPoint); + MMI::PointerEvent::PointerItem secondPoint = {}; + SetTouchExplorationPoint(secondPoint, POINT_ID_1, DISPLAY_10, 0); + points.emplace_back(secondPoint); + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, + POINT_ID_1); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::TWO_FINGERS_DRAG); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleTwoFingersDragStateDown_002 end"; +} + +/** + * @tc.number: HandleTwoFingersDragStateUp001 + * @tc.name: HandleTwoFingersDragStateUp + * @tc.desc: Test func HandleTwoFingersDragStateUp. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleTwoFingersDragStateUp_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleTwoFingersDragStateUp_001 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::TWO_FINGERS_DRAG); + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, POINT_ID_0, + 0, 0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::TOUCH_INIT); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleTwoFingersDragStateUp_001 end"; +} + +/** + * @tc.number: HandleTwoFingersDragStateUp002 + * @tc.name: HandleTwoFingersDragStateUp + * @tc.desc: Test func HandleTwoFingersDragStateUp. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleTwoFingersDragStateUp_002, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleTwoFingersDragStateUp_002 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::TWO_FINGERS_DRAG); + + std::vector points = {}; + MMI::PointerEvent::PointerItem firstPoint = {}; + SetTouchExplorationPoint(firstPoint, POINT_ID_0, 0, 0); + points.emplace_back(firstPoint); + MMI::PointerEvent::PointerItem secondPoint = {}; + SetTouchExplorationPoint(secondPoint, POINT_ID_1, DISPLAY_10, 0); + points.emplace_back(secondPoint); + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, + POINT_ID_1); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::TWO_FINGERS_DRAG); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleTwoFingersDragStateUp_002 end"; +} + +/** + * @tc.number: HandleTwoFingersDragStateMove001 + * @tc.name: HandleTwoFingersDragStateMove + * @tc.desc: Test func HandleTwoFingersDragStateMove. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleTwoFingersDragStateMove_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleTwoFingersDragStateMove_001 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::TWO_FINGERS_DRAG); + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, POINT_ID_0, + 0, 0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0), ACTION_INVALID); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleTwoFingersDragStateMove_001 end"; +} + +/** + * @tc.number: HandleTwoFingersDragStateMove002 + * @tc.name: HandleTwoFingersDragStateMove + * @tc.desc: Test func HandleTwoFingersDragStateMove. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleTwoFingersDragStateMove_002, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleTwoFingersDragStateMove_002 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::TOUCH_INIT); + + std::vector points = {}; + MMI::PointerEvent::PointerItem firstPoint = {}; + SetTouchExplorationPoint(firstPoint, POINT_ID_0, 0, 0); + points.emplace_back(firstPoint); + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, + POINT_ID_0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + MMI::PointerEvent::PointerItem secondPoint = {}; + SetTouchExplorationPoint(secondPoint, POINT_ID_1, DISPLAY_10, 0); + points.emplace_back(secondPoint); + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, POINT_ID_1); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + points.clear(); + SetTouchExplorationPoint(firstPoint, POINT_ID_0, 0, DISPLAY_500); + SetTouchExplorationPoint(secondPoint, POINT_ID_1, DISPLAY_10, DISPLAY_500); + points.emplace_back(firstPoint); + points.emplace_back(secondPoint); + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, points, POINT_ID_1); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + points.clear(); + SetTouchExplorationPoint(firstPoint, POINT_ID_0, 0, DISPLAY_1000); + SetTouchExplorationPoint(secondPoint, POINT_ID_1, DISPLAY_10, DISPLAY_1000); + points.emplace_back(firstPoint); + points.emplace_back(secondPoint); + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, points, POINT_ID_1); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0), + MMI::PointerEvent::POINTER_ACTION_DOWN); + EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(1), + MMI::PointerEvent::POINTER_ACTION_MOVE); + EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(2), + MMI::PointerEvent::POINTER_ACTION_MOVE); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleTwoFingersDragStateMove_002 end"; +} + +/** + * @tc.number: HandleMultiFingersTapStateDown001 + * @tc.name: HandleMultiFingersTapStateDown + * @tc.desc: Test func HandleMultiFingersTapStateDown. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleMultiFingersTapStateDown_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleMultiFingersTapStateDown_001 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::TWO_FINGERS_TAP); + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, POINT_ID_0, + 0, 0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::TWO_FINGERS_TAP); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleMultiFingersTapStateDown_001 end"; +} + +/** + * @tc.number: HandleMultiFingersTapStateDown002 + * @tc.name: HandleMultiFingersTapStateDown + * @tc.desc: Test func HandleMultiFingersTapStateDown. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleMultiFingersTapStateDown_002, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleMultiFingersTapStateDown_002 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::TWO_FINGERS_TAP); + + std::vector points = {}; + MMI::PointerEvent::PointerItem firstPoint = {}; + SetTouchExplorationPoint(firstPoint, POINT_ID_0, 0, 0); + points.emplace_back(firstPoint); + MMI::PointerEvent::PointerItem secondPoint = {}; + SetTouchExplorationPoint(secondPoint, POINT_ID_1, DISPLAY_10, 0); + points.emplace_back(secondPoint); + MMI::PointerEvent::PointerItem thirdPoint = {}; + SetTouchExplorationPoint(thirdPoint, POINT_ID_2, DISPLAY_10 + DISPLAY_10, 0); + points.emplace_back(thirdPoint); + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, + POINT_ID_2); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::INVALID); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleMultiFingersTapStateDown_002 end"; +} + +/** + * @tc.number: HandleMultiFingersTapStateDown003 + * @tc.name: HandleMultiFingersTapStateDown + * @tc.desc: Test func HandleMultiFingersTapStateDown. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleMultiFingersTapStateDown_003, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleMultiFingersTapStateDown_003 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::TOUCH_INIT); + + std::vector points = {}; + MMI::PointerEvent::PointerItem firstPoint = {}; + SetTouchExplorationPoint(firstPoint, POINT_ID_0, 0, 0); + points.emplace_back(firstPoint); + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, + POINT_ID_0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + MMI::PointerEvent::PointerItem secondPoint = {}; + SetTouchExplorationPoint(secondPoint, POINT_ID_1, DISPLAY_10, 0); + points.emplace_back(secondPoint); + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, POINT_ID_1); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, POINT_ID_1); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, POINT_ID_0, 0, 0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, POINT_ID_0, 0, 0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, POINT_ID_1); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::TWO_FINGERS_CONTINUE_DOWN); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleMultiFingersTapStateDown_003 end"; +} + +/** + * @tc.number: HandleMultiFingersTapStateUp001 + * @tc.name: HandleMultiFingersTapStateUp + * @tc.desc: Test func HandleMultiFingersTapStateUp. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleMultiFingersTapStateUp_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleMultiFingersTapStateUp_001 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::TWO_FINGERS_TAP); + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, POINT_ID_0, + 0, 0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::TOUCH_INIT); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleMultiFingersTapStateUp_001 end"; +} + +/** + * @tc.number: HandleMultiFingersTapStateUp002 + * @tc.name: HandleMultiFingersTapStateUp + * @tc.desc: Test func HandleMultiFingersTapStateUp. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleMultiFingersTapStateUp_002, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleMultiFingersTapStateUp_002 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::TWO_FINGERS_TAP); + + std::vector points = {}; + MMI::PointerEvent::PointerItem firstPoint = {}; + SetTouchExplorationPoint(firstPoint, POINT_ID_0, 0, 0); + points.emplace_back(firstPoint); + MMI::PointerEvent::PointerItem secondPoint = {}; + SetTouchExplorationPoint(secondPoint, POINT_ID_1, DISPLAY_10, 0); + points.emplace_back(secondPoint); + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, + POINT_ID_1); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::INVALID); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleMultiFingersTapStateUp_002 end"; +} + +/** + * @tc.number: HandleMultiFingersTapStateMove001 + * @tc.name: HandleMultiFingersTapStateMove + * @tc.desc: Test func HandleMultiFingersTapStateMove. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleMultiFingersTapStateMove_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleMultiFingersTapStateMove_001 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::TWO_FINGERS_TAP); + + std::vector points = {}; + MMI::PointerEvent::PointerItem firstPoint = {}; + SetTouchExplorationPoint(firstPoint, POINT_ID_0, 0, 0); + points.emplace_back(firstPoint); + MMI::PointerEvent::PointerItem secondPoint = {}; + SetTouchExplorationPoint(secondPoint, POINT_ID_1, DISPLAY_10, 0); + points.emplace_back(secondPoint); + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, points, + POINT_ID_1); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::INVALID); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleMultiFingersTapStateMove_001 end"; +} + +/** + * @tc.number: HandleMultiFingersTapStateMove002 + * @tc.name: HandleMultiFingersTapStateMove + * @tc.desc: Test func HandleMultiFingersTapStateMove. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleMultiFingersTapStateMove_002, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleMultiFingersTapStateMove_002 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::TOUCH_INIT); + + std::vector points = {}; + MMI::PointerEvent::PointerItem firstPoint = {}; + SetTouchExplorationPoint(firstPoint, POINT_ID_0, 0, 0); + points.emplace_back(firstPoint); + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, + POINT_ID_0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + MMI::PointerEvent::PointerItem secondPoint = {}; + SetTouchExplorationPoint(secondPoint, POINT_ID_1, DISPLAY_10, 0); + points.emplace_back(secondPoint); + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, POINT_ID_1); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, POINT_ID_1); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, POINT_ID_0, 0, 0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, POINT_ID_0, 0, 0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::TWO_FINGERS_TAP); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleMultiFingersTapStateMove_002 end"; +} + +/** + * @tc.number: HandleMultiFingersTapStateMove003 + * @tc.name: HandleMultiFingersTapStateMove + * @tc.desc: Test func HandleMultiFingersTapStateMove. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleMultiFingersTapStateMove_003, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleMultiFingersTapStateMove_003 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::TOUCH_INIT); + + std::vector points = {}; + MMI::PointerEvent::PointerItem firstPoint = {}; + SetTouchExplorationPoint(firstPoint, POINT_ID_0, 0, 0); + points.emplace_back(firstPoint); + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, + POINT_ID_0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + MMI::PointerEvent::PointerItem secondPoint = {}; + SetTouchExplorationPoint(secondPoint, POINT_ID_1, DISPLAY_10, 0); + points.emplace_back(secondPoint); + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, POINT_ID_1); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, POINT_ID_1); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, POINT_ID_0, 0, 0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, POINT_ID_0, DISPLAY_500, 0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::INVALID); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleMultiFingersTapStateMove_003 end"; +} + +/** + * @tc.number: HandleMultiFingersContinueDownStateDown001 + * @tc.name: HandleMultiFingersContinueDownStateDown + * @tc.desc: Test func HandleMultiFingersContinueDownStateDown. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleMultiFingersContinueDownStateDown_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleMultiFingersContinueDownStateDown_001 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::TWO_FINGERS_CONTINUE_DOWN); + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, POINT_ID_0, + 0, 0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::INVALID); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleMultiFingersContinueDownStateDown_001 end"; +} + +/** + * @tc.number: HandleMultiFingersContinueDownStateUp001 + * @tc.name: HandleMultiFingersContinueDownStateUp + * @tc.desc: Test func HandleMultiFingersContinueDownStateUp. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleMultiFingersContinueDownStateUp_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleMultiFingersContinueDownStateUp_001 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::TWO_FINGERS_CONTINUE_DOWN); + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, POINT_ID_0, + 0, 0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::TWO_FINGERS_TAP); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleMultiFingersContinueDownStateUp_001 end"; +} + +/** + * @tc.number: HandleMultiFingersContinueDownStateUp002 + * @tc.name: HandleMultiFingersContinueDownStateUp + * @tc.desc: Test func HandleMultiFingersContinueDownStateUp. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleMultiFingersContinueDownStateUp_002, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleMultiFingersContinueDownStateUp_002 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::TWO_FINGERS_CONTINUE_DOWN); + + std::vector points = {}; + MMI::PointerEvent::PointerItem firstPoint = {}; + SetTouchExplorationPoint(firstPoint, POINT_ID_0, 0, 0); + points.emplace_back(firstPoint); + MMI::PointerEvent::PointerItem secondPoint = {}; + SetTouchExplorationPoint(secondPoint, POINT_ID_1, DISPLAY_10, 0); + points.emplace_back(secondPoint); + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, + POINT_ID_1); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::TWO_FINGERS_CONTINUE_DOWN); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleMultiFingersContinueDownStateUp_002 end"; +} + +/** + * @tc.number: HandleMultiFingersContinueDownStateUp003 + * @tc.name: HandleMultiFingersContinueDownStateUp + * @tc.desc: Test func HandleMultiFingersContinueDownStateUp. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleMultiFingersContinueDownStateUp_003, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleMultiFingersContinueDownStateUp_003 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::TWO_FINGERS_CONTINUE_DOWN); + + std::vector points = {}; + MMI::PointerEvent::PointerItem firstPoint = {}; + SetTouchExplorationPoint(firstPoint, POINT_ID_0, 0, 0); + points.emplace_back(firstPoint); + MMI::PointerEvent::PointerItem secondPoint = {}; + SetTouchExplorationPoint(secondPoint, POINT_ID_1, DISPLAY_10, 0); + points.emplace_back(secondPoint); + MMI::PointerEvent::PointerItem thirdPoint = {}; + SetTouchExplorationPoint(thirdPoint, POINT_ID_2, DISPLAY_10, 0); + points.emplace_back(thirdPoint); + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, + POINT_ID_2); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::INVALID); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleMultiFingersContinueDownStateUp_003 end"; +} + +/** + * @tc.number: HandleMultiFingersContinueDownStateUp004 + * @tc.name: HandleMultiFingersContinueDownStateUp + * @tc.desc: Test func HandleMultiFingersContinueDownStateUp. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleMultiFingersContinueDownStateUp_004, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleMultiFingersContinueDownStateUp_004 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::THREE_FINGERS_CONTINUE_DOWN); + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, POINT_ID_0, + 0, 0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::THREE_FINGERS_TAP); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleMultiFingersContinueDownStateUp_004 end"; +} + +/** + * @tc.number: HandleMultiFingersContinueDownStateUp005 + * @tc.name: HandleMultiFingersContinueDownStateUp + * @tc.desc: Test func HandleMultiFingersContinueDownStateUp. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleMultiFingersContinueDownStateUp_005, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleMultiFingersContinueDownStateUp_005 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::FOUR_FINGERS_CONTINUE_DOWN); + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, POINT_ID_0, + 0, 0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::FOUR_FINGERS_TAP); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleMultiFingersContinueDownStateUp_005 end"; +} + +/** + * @tc.number: HandleMultiFingersContinueDownStateMove001 + * @tc.name: HandleMultiFingersContinueDownStateMove + * @tc.desc: Test func HandleMultiFingersContinueDownStateMove. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleMultiFingersContinueDownStateMove_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleMultiFingersContinueDownStateMove_001 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::TOUCH_INIT); + + std::vector points = {}; + MMI::PointerEvent::PointerItem firstPoint = {}; + SetTouchExplorationPoint(firstPoint, POINT_ID_0, 0, 0); + points.emplace_back(firstPoint); + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, + POINT_ID_0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + MMI::PointerEvent::PointerItem secondPoint = {}; + SetTouchExplorationPoint(secondPoint, POINT_ID_1, DISPLAY_10, 0); + points.emplace_back(secondPoint); + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, POINT_ID_1); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, POINT_ID_1); + touchExploration_->OnPointerEvent(*event); + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, POINT_ID_0, 0, 0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, POINT_ID_0, 0, 0); + touchExploration_->OnPointerEvent(*event); + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, POINT_ID_1); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, points, POINT_ID_1); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::TWO_FINGERS_CONTINUE_DOWN); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleMultiFingersContinueDownStateMove_001 end"; +} + +/** + * @tc.number: HandleMultiFingersContinueDownStateMove002 + * @tc.name: HandleMultiFingersContinueDownStateMove + * @tc.desc: Test func HandleMultiFingersContinueDownStateMove. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleMultiFingersContinueDownStateMove_002, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleMultiFingersContinueDownStateMove_002 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::TOUCH_INIT); + + std::vector points = {}; + MMI::PointerEvent::PointerItem firstPoint = {}; + SetTouchExplorationPoint(firstPoint, POINT_ID_0, 0, 0); + points.emplace_back(firstPoint); + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, + POINT_ID_0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + MMI::PointerEvent::PointerItem secondPoint = {}; + SetTouchExplorationPoint(secondPoint, POINT_ID_1, DISPLAY_10, 0); + points.emplace_back(secondPoint); + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, POINT_ID_1); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, POINT_ID_1); + touchExploration_->OnPointerEvent(*event); + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, POINT_ID_0, 0, 0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, POINT_ID_0, 0, 0); + touchExploration_->OnPointerEvent(*event); + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, POINT_ID_1); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + points.clear(); + SetTouchExplorationPoint(firstPoint, POINT_ID_0, 0, DISPLAY_500); + SetTouchExplorationPoint(secondPoint, POINT_ID_1, DISPLAY_10, DISPLAY_500); + points.emplace_back(firstPoint); + points.emplace_back(secondPoint); + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, points, POINT_ID_1); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::INVALID); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleMultiFingersContinueDownStateMove_002 end"; +} + +/** + * @tc.number: HandleTwoFingersUnknownStateDown001 + * @tc.name: HandleTwoFingersUnknownStateDown + * @tc.desc: Test func HandleTwoFingersUnknownStateDown. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleTwoFingersUnknownStateDown_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleTwoFingersUnknownStateDown_001 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::TWO_FINGERS_UNKNOWN); + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, POINT_ID_0, + 0, 0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::INVALID); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleTwoFingersUnknownStateDown_001 end"; +} + +/** + * @tc.number: HandleTwoFingersUnknownStateDown002 + * @tc.name: HandleTwoFingersUnknownStateDown + * @tc.desc: Test func HandleTwoFingersUnknownStateDown. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleTwoFingersUnknownStateDown_002, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleTwoFingersUnknownStateDown_002 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::TWO_FINGERS_UNKNOWN); + + std::vector points = {}; + MMI::PointerEvent::PointerItem firstPoint = {}; + SetTouchExplorationPoint(firstPoint, POINT_ID_0, 0, 0); + points.emplace_back(firstPoint); + MMI::PointerEvent::PointerItem secondPoint = {}; + SetTouchExplorationPoint(secondPoint, POINT_ID_1, DISPLAY_10, 0); + points.emplace_back(secondPoint); + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, + POINT_ID_1); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::TWO_FINGERS_UNKNOWN); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleTwoFingersUnknownStateDown_002 end"; +} + +/** + * @tc.number: HandleTwoFingersUnknownStateUp001 + * @tc.name: HandleTwoFingersUnknownStateUp + * @tc.desc: Test func HandleTwoFingersUnknownStateUp. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleTwoFingersUnknownStateUp_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleTwoFingersUnknownStateUp_001 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::TWO_FINGERS_UNKNOWN); + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, POINT_ID_0, + 0, 0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::TOUCH_INIT); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleTwoFingersUnknownStateUp_001 end"; +} + +/** + * @tc.number: HandleTwoFingersUnknownStateUp002 + * @tc.name: HandleTwoFingersUnknownStateUp + * @tc.desc: Test func HandleTwoFingersUnknownStateUp. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleTwoFingersUnknownStateUp_002, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleTwoFingersUnknownStateUp_002 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::TWO_FINGERS_UNKNOWN); + + std::vector points = {}; + MMI::PointerEvent::PointerItem firstPoint = {}; + SetTouchExplorationPoint(firstPoint, POINT_ID_0, 0, 0); + points.emplace_back(firstPoint); + MMI::PointerEvent::PointerItem secondPoint = {}; + SetTouchExplorationPoint(secondPoint, POINT_ID_1, DISPLAY_10, 0); + points.emplace_back(secondPoint); + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, + POINT_ID_1); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::TWO_FINGERS_UNKNOWN); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleTwoFingersUnknownStateUp_002 end"; +} + +/** + * @tc.number: HandleTwoFingersUnknownStateMove001 + * @tc.name: HandleTwoFingersUnknownStateMove + * @tc.desc: Test func HandleTwoFingersUnknownStateMove. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleTwoFingersUnknownStateMove_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleTwoFingersUnknownStateMove_001 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::TWO_FINGERS_UNKNOWN); + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, POINT_ID_0, + 0, 0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::TWO_FINGERS_UNKNOWN); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleTwoFingersUnknownStateMove_001 end"; +} + +/** + * @tc.number: HandleThreeFingersDownStateDown001 + * @tc.name: HandleThreeFingersDownStateDown + * @tc.desc: Test func HandleThreeFingersDownStateDown. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleThreeFingersDownStateDown_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleThreeFingersDownStateDown_001 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::THREE_FINGERS_DOWN); + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, POINT_ID_0, + 0, 0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::INVALID); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleThreeFingersDownStateDown_001 end"; +} + +/** + * @tc.number: HandleThreeFingersDownStateDown002 + * @tc.name: HandleThreeFingersDownStateDown + * @tc.desc: Test func HandleThreeFingersDownStateDown. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleThreeFingersDownStateDown_002, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleThreeFingersDownStateDown_002 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::THREE_FINGERS_DOWN); + + std::vector points = {}; + MMI::PointerEvent::PointerItem firstPoint = {}; + SetTouchExplorationPoint(firstPoint, POINT_ID_0, 0, 0); + MMI::PointerEvent::PointerItem secondPoint = {}; + SetTouchExplorationPoint(secondPoint, POINT_ID_1, 0, 0); + MMI::PointerEvent::PointerItem thirdPoint = {}; + SetTouchExplorationPoint(thirdPoint, POINT_ID_2, 0, 0); + MMI::PointerEvent::PointerItem fourthPoint = {}; + SetTouchExplorationPoint(fourthPoint, POINT_ID_3, 0, 0); + points.emplace_back(firstPoint); + points.emplace_back(secondPoint); + points.emplace_back(thirdPoint); + points.emplace_back(fourthPoint); + std::shared_ptr event = + CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, POINT_ID_3); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::INVALID); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleThreeFingersDownStateDown_002 end"; +} + +/** + * @tc.number: HandleThreeFingersDownStateDown003 + * @tc.name: HandleThreeFingersDownStateDown + * @tc.desc: Test func HandleThreeFingersDownStateDown. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleThreeFingersDownStateDown_003, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleThreeFingersDownStateDown_003 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::TOUCH_INIT); + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, POINT_ID_0, + 0, 0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + std::vector points = {}; + MMI::PointerEvent::PointerItem firstPoint = {}; + SetTouchExplorationPoint(firstPoint, POINT_ID_0, 0, 0); + MMI::PointerEvent::PointerItem secondPoint = {}; + SetTouchExplorationPoint(secondPoint, POINT_ID_1, DISPLAY_10, 0); + points.emplace_back(firstPoint); + points.emplace_back(secondPoint); + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, POINT_ID_1); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + MMI::PointerEvent::PointerItem thirdPoint = {}; + SetTouchExplorationPoint(thirdPoint, POINT_ID_2, 0, 0); + points.emplace_back(thirdPoint); + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, POINT_ID_2); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + MMI::PointerEvent::PointerItem fourthPoint = {}; + SetTouchExplorationPoint(fourthPoint, POINT_ID_3, 0, 0); + points.emplace_back(fourthPoint); + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, POINT_ID_3); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::FOUR_FINGERS_DOWN); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleThreeFingersDownStateDown_003 end"; +} + +/** + * @tc.number: HandleThreeFingersDownStateUp001 + * @tc.name: HandleThreeFingersDownStateUp + * @tc.desc: Test func HandleThreeFingersDownStateUp. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleThreeFingersDownStateUp_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleThreeFingersDownStateUp_001 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::THREE_FINGERS_DOWN); + + std::vector points = {}; + MMI::PointerEvent::PointerItem firstPoint = {}; + SetTouchExplorationPoint(firstPoint, POINT_ID_0, 0, 0); + MMI::PointerEvent::PointerItem secondPoint = {}; + SetTouchExplorationPoint(secondPoint, POINT_ID_1, 0, 0); + MMI::PointerEvent::PointerItem thirdPoint = {}; + SetTouchExplorationPoint(thirdPoint, POINT_ID_2, 0, 0); + points.emplace_back(firstPoint); + points.emplace_back(secondPoint); + points.emplace_back(thirdPoint); + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, + POINT_ID_2); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::THREE_FINGERS_DOWN); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleThreeFingersDownStateUp_001 end"; +} + +/** + * @tc.number: HandleThreeFingersDownStateUp002 + * @tc.name: HandleThreeFingersDownStateUp + * @tc.desc: Test func HandleThreeFingersDownStateUp. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleThreeFingersDownStateUp_002, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleThreeFingersDownStateUp_002 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::THREE_FINGERS_DOWN); + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, POINT_ID_0, + 0, 0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::THREE_FINGERS_TAP); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleThreeFingersDownStateUp_002 end"; +} + +/** + * @tc.number: HandleThreeFingersDownStateUp003 + * @tc.name: HandleThreeFingersDownStateUp + * @tc.desc: Test func HandleThreeFingersDownStateUp. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleThreeFingersDownStateUp_003, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleThreeFingersDownStateUp_003 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::THREE_FINGERS_DOWN); + + std::vector points = {}; + MMI::PointerEvent::PointerItem firstPoint = {}; + SetTouchExplorationPoint(firstPoint, POINT_ID_0, 0, 0); + MMI::PointerEvent::PointerItem secondPoint = {}; + SetTouchExplorationPoint(secondPoint, POINT_ID_1, 0, 0); + MMI::PointerEvent::PointerItem thirdPoint = {}; + SetTouchExplorationPoint(thirdPoint, POINT_ID_2, 0, 0); + MMI::PointerEvent::PointerItem fourthPoint = {}; + SetTouchExplorationPoint(fourthPoint, POINT_ID_3, 0, 0); + points.emplace_back(firstPoint); + points.emplace_back(secondPoint); + points.emplace_back(thirdPoint); + points.emplace_back(fourthPoint); + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, + POINT_ID_3); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::INVALID); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleThreeFingersDownStateUp_003 end"; +} + +/** + * @tc.number: HandleThreeFingersDownStateMove001 + * @tc.name: HandleThreeFingersDownStateMove + * @tc.desc: Test func HandleThreeFingersDownStateMove. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleThreeFingersDownStateMove_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleThreeFingersDownStateMove_001 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::TOUCH_INIT); + + std::vector points = {}; + MMI::PointerEvent::PointerItem firstPoint = {}; + SetTouchExplorationPoint(firstPoint, POINT_ID_0, 0, 0); + points.emplace_back(firstPoint); + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, + POINT_ID_0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + MMI::PointerEvent::PointerItem secondPoint = {}; + SetTouchExplorationPoint(secondPoint, POINT_ID_1, DISPLAY_10, 0); + points.emplace_back(secondPoint); + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, POINT_ID_1); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + MMI::PointerEvent::PointerItem thirdPoint = {}; + SetTouchExplorationPoint(thirdPoint, POINT_ID_2, DISPLAY_10 + DISPLAY_10, 0); + points.emplace_back(thirdPoint); + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, POINT_ID_2); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + points.clear(); + SetTouchExplorationPoint(firstPoint, POINT_ID_0, 0, DISPLAY_500); + SetTouchExplorationPoint(secondPoint, POINT_ID_1, DISPLAY_10, DISPLAY_500); + SetTouchExplorationPoint(thirdPoint, POINT_ID_2, DISPLAY_10 + DISPLAY_10, DISPLAY_500); + points.emplace_back(firstPoint); + points.emplace_back(secondPoint); + points.emplace_back(thirdPoint); + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, points, POINT_ID_2); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::THREE_FINGERS_SWIPE); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleThreeFingersDownStateMove_001 end"; +} + +/** + * @tc.number: HandleThreeFingersDownStateMove002 + * @tc.name: HandleThreeFingersDownStateMove + * @tc.desc: Test func HandleThreeFingersDownStateMove. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleThreeFingersDownStateMove_002, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleThreeFingersDownStateMove_002 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::TOUCH_INIT); + + std::vector points = {}; + MMI::PointerEvent::PointerItem firstPoint = {}; + SetTouchExplorationPoint(firstPoint, POINT_ID_0, 0, 0); + points.emplace_back(firstPoint); + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, + POINT_ID_0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + MMI::PointerEvent::PointerItem secondPoint = {}; + SetTouchExplorationPoint(secondPoint, POINT_ID_1, DISPLAY_10, 0); + points.emplace_back(secondPoint); + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, POINT_ID_1); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + MMI::PointerEvent::PointerItem thirdPoint = {}; + SetTouchExplorationPoint(thirdPoint, POINT_ID_2, DISPLAY_10 + DISPLAY_10, 0); + points.emplace_back(thirdPoint); + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, POINT_ID_2); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + points.clear(); + SetTouchExplorationPoint(firstPoint, POINT_ID_0, 0, DISPLAY_500); + SetTouchExplorationPoint(secondPoint, POINT_ID_1, DISPLAY_10, DISPLAY_500); + points.emplace_back(firstPoint); + points.emplace_back(secondPoint); + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, points, POINT_ID_1); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::INVALID); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleThreeFingersDownStateMove_002 end"; +} + +/** + * @tc.number: HandleThreeFingersSwipeStateDown001 + * @tc.name: HandleThreeFingersSwipeStateDown + * @tc.desc: Test func HandleThreeFingersSwipeStateDown. + */ +HWTEST_F(TouchExplorationTest, TouchExploration_Unittest_HandleThreeFingersSwipeStateDown_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleThreeFingersSwipeStateDown_001 start"; + + touchExploration_->SetCurrentState(TouchExplorationState::THREE_FINGERS_SWIPE); + std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, POINT_ID_0, + 0, 0); + touchExploration_->OnPointerEvent(*event); + + usleep(SLEEP_US_50); + + EXPECT_EQ(touchExploration_->GetCurrentState(), TouchExplorationState::INVALID); + + GTEST_LOG_(INFO) << "TouchExploration_Unittest_HandleThreeFingersSwipeStateDown_001 end"; +} +} // namespace Accessibility +} // namespace OHOS \ No newline at end of file diff --git a/services/aams/test/unittest/accessibility_touch_guider_test.cpp b/services/aams/test/unittest/accessibility_touch_guider_test.cpp deleted file mode 100755 index 04af2444..00000000 --- a/services/aams/test/unittest/accessibility_touch_guider_test.cpp +++ /dev/null @@ -1,1050 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include "accessibility_common_helper.h" -#include "accessibility_element_operator_proxy.h" -#include "accessibility_touch_guider.h" -#include "accessibility_ut_helper.h" - -using namespace testing; -using namespace testing::ext; - -namespace OHOS { -namespace Accessibility { -namespace { - constexpr uint32_t GET_EVENT_TARGET_INDEX_2 = 2; - constexpr uint32_t GET_EVENT_TARGET_INDEX_3 = 3; - constexpr uint32_t SLEEP_TIME_3 = 3; - constexpr int64_t MS_TO_US = 1000; - constexpr int32_t ACCOUNT_ID = 100; - constexpr int32_t WINDOW_ID = 2; - constexpr int32_t POINT_ID_1 = 1; - constexpr int32_t POINT_ID_2 = 2; - constexpr int32_t POINT_ID_3 = 3; -} // namespace - -class TouchGuiderTest : public testing::Test { -public: - TouchGuiderTest() - {} - ~TouchGuiderTest() - {} - - static void SetUpTestCase(); - static void TearDownTestCase(); - static void SetTouchGuiderPoint(MMI::PointerEvent::PointerItem &point, int id, int x, int y); - static void TouchGuiderExpect(EventType eventType, int32_t GestureTypeInt); - void PointerEventTest(std::vector &points, - MMI::PointerEvent::PointerItem movepoint2, MMI::PointerEvent::PointerItem movepoint3); - bool TestEventType(); - bool TestEventAction(); - void SetUp() override; - void TearDown() override; - -protected: - std::shared_ptr CreateTouchEvent(int32_t action); - std::shared_ptr CreateTouchEvent(int32_t action, - std::vector &points, int32_t pointerCount, int64_t occurredTime, - int64_t startTime); - std::shared_ptr CreateMoveEvent(int32_t pointerCount); - std::unique_ptr touchGuider_ = nullptr; - int32_t pointId_ = -1; -}; - -void TouchGuiderTest::PointerEventTest(std::vector &points, - MMI::PointerEvent::PointerItem movepoint2, MMI::PointerEvent::PointerItem movepoint3) -{ - int32_t expectValue = MMI::PointerEvent::POINTER_ACTION_MOVE; - int32_t touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0); - EXPECT_EQ(touchAction, expectValue); - - points.clear(); - points.emplace_back(movepoint2); - std::shared_ptr event = - CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, points, 1, 0, 0); - touchGuider_->OnPointerEvent(*event); - - touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(1); - EXPECT_EQ(touchAction, expectValue); - - points.clear(); - points.emplace_back(movepoint3); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, points, 1, 0, 0); - touchGuider_->OnPointerEvent(*event); - - touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(GET_EVENT_TARGET_INDEX_2); - EXPECT_EQ(touchAction, expectValue); - - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, 1, 0, 0); - touchGuider_->OnPointerEvent(*event); -} - -void TouchGuiderTest::TouchGuiderExpect(EventType eventType, int32_t GestureTypeInt) -{ - eventType = AccessibilityAbilityHelper::GetInstance().GetEventTypeOfTargetIndex(GET_EVENT_TARGET_INDEX_2); - EXPECT_EQ(eventType, EventType::TYPE_TOUCH_END); - eventType = AccessibilityAbilityHelper::GetInstance().GetEventTypeOfTargetIndex(GET_EVENT_TARGET_INDEX_3); - EXPECT_EQ(eventType, EventType::TYPE_TOUCH_GUIDE_GESTURE_END); - auto uTgestureId = AccessibilityAbilityHelper::GetInstance().GetGestureId(); - EXPECT_EQ(uTgestureId, GestureTypeInt); -} - -void TouchGuiderTest::SetTouchGuiderPoint(MMI::PointerEvent::PointerItem &point, int id, int x, int y) -{ - point.SetPointerId(id); - point.SetDisplayX(x); - point.SetDisplayY(y); -} - -bool TouchGuiderTest::TestEventType() -{ - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityAbilityHelper::GetInstance().GetEventTypeOfTargetIndex(0) == - EventType::TYPE_TOUCH_BEGIN) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - return ret; -} - -bool TouchGuiderTest::TestEventAction() -{ - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0) == - MMI::PointerEvent::POINTER_ACTION_DOWN) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - return ret; -} - -void TouchGuiderTest::SetUpTestCase() -{ - GTEST_LOG_(INFO) << "TouchGuiderTest SetUpTestCase"; - Singleton::GetInstance().OnStart(); -} - -void TouchGuiderTest::TearDownTestCase() -{ - GTEST_LOG_(INFO) << "TouchGuiderTest TearDownTestCase"; - Singleton::GetInstance().OnStop(); -} - -void TouchGuiderTest::SetUp() -{ - GTEST_LOG_(INFO) << "TouchGuiderTest SetUp"; - - touchGuider_ = std::make_unique(); - if (!touchGuider_) { - GTEST_LOG_(INFO) << "touchGuider new failed!"; - return; - } - touchGuider_->StartUp(); - pointId_ = 0; -} - -void TouchGuiderTest::TearDown() -{ - GTEST_LOG_(INFO) << "TouchGuiderTest TearDown"; - AccessibilityAbilityHelper::GetInstance().ClearEventTypeActionVector(); - AccessibilityAbilityHelper::GetInstance().ClearTouchEventActionVector(); -} - -std::shared_ptr TouchGuiderTest::CreateTouchEvent(int32_t action) -{ - std::shared_ptr pointerEvent = MMI::PointerEvent::Create(); - MMI::PointerEvent::PointerItem item = {}; - - item.SetPointerId(pointId_); - item.SetPressed(action == MMI::PointerEvent::POINTER_ACTION_UP ? false : true); - pointerEvent->AddPointerItem(item); - pointerEvent->SetPointerId(pointId_++); - pointerEvent->SetSourceType(MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN); - pointerEvent->SetPointerAction(action); - - return pointerEvent; -} - -std::shared_ptr TouchGuiderTest::CreateTouchEvent(int32_t action, - std::vector &points, int32_t pointerId, int64_t occurredTime, - int64_t startTime) -{ - std::shared_ptr pointerEvent = MMI::PointerEvent::Create(); - - for (auto &point : points) { - if (point.GetPointerId() == pointerId) { - point.SetPressed(action == MMI::PointerEvent::POINTER_ACTION_UP ? false : true); - } else { - point.SetPressed(true); - } - pointerEvent->AddPointerItem(point); - } - pointerEvent->SetPointerId(pointerId); - pointerEvent->SetSourceType(MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN); - pointerEvent->SetPointerAction(action); - pointerEvent->SetActionStartTime(startTime * MS_TO_US); - pointerEvent->SetActionTime(occurredTime * MS_TO_US); - - return pointerEvent; -} - -std::shared_ptr TouchGuiderTest::CreateMoveEvent(int32_t pointerCount) -{ - std::shared_ptr pointerEvent = MMI::PointerEvent::Create(); - MMI::PointerEvent::PointerItem item = {}; - - item.SetPointerId(pointId_); - item.SetPressed(true); - pointerEvent->AddPointerItem(item); - pointerEvent->SetPointerId(pointId_++); - pointerEvent->SetSourceType(MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN); - pointerEvent->SetPointerAction(MMI::PointerEvent::POINTER_ACTION_MOVE); - - return pointerEvent; -} - -/** - * @tc.number: OnPointerEvent001 - * @tc.name: OnPointerEvent - * @tc.desc: Check the first down event. - */ -HWTEST_F(TouchGuiderTest, TouchGuider_Unittest_OnPointerEvent_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "TouchGuider_Unittest_OnPointerEvent_001 start"; - std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN); - touchGuider_->OnPointerEvent(*event); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityAbilityHelper::GetInstance().GetEventTypeOfTargetIndex(0) == EventType::TYPE_TOUCH_BEGIN) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(ret); -} - -/** - * @tc.number: OnPointerEvent002 - * @tc.name: OnPointerEvent - * @tc.desc: Check the first up event. - */ -HWTEST_F(TouchGuiderTest, TouchGuider_Unittest_OnPointerEvent_002, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "TouchGuider_Unittest_OnPointerEvent_002 start"; - std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN); - touchGuider_->OnPointerEvent(*event); - bool retOnPointerEvent2 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityAbilityHelper::GetInstance().GetEventTypeOfTargetIndex(0) == EventType::TYPE_TOUCH_BEGIN) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent2); - - // create - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP); - touchGuider_->OnPointerEvent(*event); - retOnPointerEvent2 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityAbilityHelper::GetInstance().GetEventTypeOfTargetIndex(3) == - EventType::TYPE_TOUCH_GUIDE_END) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent2); - EventType eventType = AccessibilityAbilityHelper::GetInstance().GetEventTypeOfTargetIndex(1); - EXPECT_EQ(eventType, EventType::TYPE_TOUCH_END); - int32_t expectValue = MMI::PointerEvent::POINTER_ACTION_HOVER_ENTER; - int32_t touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0); - EXPECT_EQ(touchAction, expectValue); - eventType = AccessibilityAbilityHelper::GetInstance().GetEventTypeOfTargetIndex(2); - EXPECT_EQ(eventType, EventType::TYPE_TOUCH_GUIDE_BEGIN); - GTEST_LOG_(INFO) << "TouchGuider_Unittest_OnPointerEvent_002 end"; -} - -/** - * @tc.number: OnPointerEvent003 - * @tc.name: OnPointerEvent - * @tc.desc: Check the event that down-up slowly. - */ -HWTEST_F(TouchGuiderTest, TouchGuider_Unittest_OnPointerEvent_003, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "TouchGuider_Unittest_OnPointerEvent_003 start"; - - std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN); - touchGuider_->OnPointerEvent(*event); - bool retOnPointerEvent3 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityAbilityHelper::GetInstance().GetEventTypeOfTargetIndex(1) == - EventType::TYPE_TOUCH_GUIDE_BEGIN) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent3); - EventType eventType = AccessibilityAbilityHelper::GetInstance().GetEventTypeOfTargetIndex(0); - EXPECT_EQ(eventType, EventType::TYPE_TOUCH_BEGIN); - retOnPointerEvent3 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0) == - MMI::PointerEvent::POINTER_ACTION_HOVER_ENTER) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent3); - - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP); - touchGuider_->OnPointerEvent(*event); - retOnPointerEvent3 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityAbilityHelper::GetInstance().GetEventTypeOfTargetIndex(3) == - EventType::TYPE_TOUCH_GUIDE_END) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent3); - eventType = AccessibilityAbilityHelper::GetInstance().GetEventTypeOfTargetIndex(2); - EXPECT_EQ(eventType, EventType::TYPE_TOUCH_END); - - GTEST_LOG_(INFO) << "TouchGuider_Unittest_OnPointerEvent_003 end"; -} - -/** - * @tc.number: OnPointerEvent004 - * @tc.name: OnPointerEvent - * @tc.desc: Check the event that move slowly with one finger. - */ -HWTEST_F(TouchGuiderTest, TouchGuider_Unittest_OnPointerEvent_004, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "TouchGuider_Unittest_OnPointerEvent_004 start"; - std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN); - touchGuider_->OnPointerEvent(*event); - bool retOnPointerEvent4 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityAbilityHelper::GetInstance().GetEventTypeOfTargetIndex(1) == - EventType::TYPE_TOUCH_GUIDE_BEGIN) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent4); - EventType eventType = AccessibilityAbilityHelper::GetInstance().GetEventTypeOfTargetIndex(0); - EXPECT_EQ(eventType, EventType::TYPE_TOUCH_BEGIN); - retOnPointerEvent4 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0) == - MMI::PointerEvent::POINTER_ACTION_HOVER_ENTER) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent4); - - event = CreateMoveEvent(1); - touchGuider_->OnPointerEvent(*event); - int32_t touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(1); - EXPECT_EQ(touchAction, MMI::PointerEvent::POINTER_ACTION_HOVER_MOVE); - - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP); - touchGuider_->OnPointerEvent(*event); - retOnPointerEvent4 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityAbilityHelper::GetInstance().GetEventTypeOfTargetIndex(3) == EventType::TYPE_TOUCH_GUIDE_END) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent4); - eventType = AccessibilityAbilityHelper::GetInstance().GetEventTypeOfTargetIndex(2); - EXPECT_EQ(eventType, EventType::TYPE_TOUCH_END); - - GTEST_LOG_(INFO) << "TouchGuider_Unittest_OnPointerEvent_004 end"; -} - -/** - * @tc.number: OnPointerEvent005 - * @tc.name: OnPointerEvent - * @tc.desc: Check the event that two fingers moving in same directions in touchGuiding state. - */ -HWTEST_F(TouchGuiderTest, TouchGuider_Unittest_OnPointerEvent_005, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "TouchGuider_Unittest_OnPointerEvent_005 start"; - - std::vector points = {}; - MMI::PointerEvent::PointerItem point = {}; - point.SetPointerId(1); - MMI::PointerEvent::PointerItem otherPoint = {}; - SetTouchGuiderPoint(otherPoint, 2, 10, 10); - - points.emplace_back(point); - std::shared_ptr event = - CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, POINT_ID_1, 0, 0); - touchGuider_->OnPointerEvent(*event); - bool retOnPointerEvent5 = TestEventType(); - EXPECT_TRUE(retOnPointerEvent5); - - points.emplace_back(otherPoint); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, POINT_ID_2, 0, 0); - touchGuider_->OnPointerEvent(*event); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, points, POINT_ID_2, 0, 0); - touchGuider_->OnPointerEvent(*event); - retOnPointerEvent5 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0) != - MMI::PointerEvent::POINTER_ACTION_DOWN) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent5); - - points.clear(); - points.emplace_back(otherPoint); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, POINT_ID_2, 0, 0); - touchGuider_->OnPointerEvent(*event); - points.clear(); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, POINT_ID_1, 0, 0); - touchGuider_->OnPointerEvent(*event); - retOnPointerEvent5 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - int32_t eventTypeSize = - static_cast(AccessibilityAbilityHelper::GetInstance().GetEventTypeVector().size()); - if (AccessibilityAbilityHelper::GetInstance().GetEventTypeOfTargetIndex(eventTypeSize - 1) == - EventType::TYPE_TOUCH_END) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent5); - - GTEST_LOG_(INFO) << "TouchGuider_Unittest_OnPointerEvent_005 end"; -} - -/** - * @tc.number: OnPointerEvent006 - * @tc.name: OnPointerEvent - * @tc.desc: Check the event that multi-finger gesture. - */ -HWTEST_F(TouchGuiderTest, TouchGuider_Unittest_OnPointerEvent_006, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "TouchGuider_Unittest_OnPointerEvent_006 start"; - - std::vector points = {}; - MMI::PointerEvent::PointerItem point = {}; - point.SetPointerId(1); - MMI::PointerEvent::PointerItem otherPoint = {}; - SetTouchGuiderPoint(otherPoint, 2, 10, 10); - MMI::PointerEvent::PointerItem otherPoint1 = {}; - SetTouchGuiderPoint(otherPoint1, 3, 10, 10); - - points.emplace_back(point); - std::shared_ptr event = - CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, 1, 0, 0); - touchGuider_->OnPointerEvent(*event); - bool retOnPointerEvent6 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityAbilityHelper::GetInstance().GetEventTypeOfTargetIndex(0) == - EventType::TYPE_TOUCH_BEGIN) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent6); - - points.emplace_back(otherPoint); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, 2, 0, 0); - touchGuider_->OnPointerEvent(*event); - - points.emplace_back(otherPoint1); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, 3, 0, 0); - touchGuider_->OnPointerEvent(*event); - - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, points, 3, 0, 0); - touchGuider_->OnPointerEvent(*event); - retOnPointerEvent6 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0) != - MMI::PointerEvent::POINTER_ACTION_DOWN) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent6); - - GTEST_LOG_(INFO) << "TouchGuider_Unittest_OnPointerEvent_006 end"; -} - -/** - * @tc.number: OnPointerEvent007 - * @tc.name: OnPointerEvent - * @tc.desc: Check the CANCEL event. - */ -HWTEST_F(TouchGuiderTest, TouchGuider_Unittest_OnPointerEvent_007, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "TouchGuider_Unittest_OnPointerEvent_007 start"; - - std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN); - touchGuider_->OnPointerEvent(*event); - bool retOnPointerEvent7 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityAbilityHelper::GetInstance().GetEventTypeOfTargetIndex(1) == - EventType::TYPE_TOUCH_GUIDE_BEGIN) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent7); - EventType eventType = AccessibilityAbilityHelper::GetInstance().GetEventTypeOfTargetIndex(0); - EXPECT_EQ(eventType, EventType::TYPE_TOUCH_BEGIN); - - retOnPointerEvent7 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0) == - MMI::PointerEvent::POINTER_ACTION_HOVER_ENTER) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent7); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_CANCEL); - touchGuider_->OnPointerEvent(*event); - - GTEST_LOG_(INFO) << "TouchGuider_Unittest_OnPointerEvent_007 end"; -} - -/** - * @tc.number: OnPointerEvent008 - * @tc.name: OnPointerEvent - * @tc.desc: Check the OTHER_POINT_DOWN event in draging state. - */ -HWTEST_F(TouchGuiderTest, TouchGuider_Unittest_OnPointerEvent_008, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "TouchGuider_Unittest_OnPointerEvent_008 start"; - - std::vector points = {}; - MMI::PointerEvent::PointerItem point = {}; - point.SetPointerId(1); - MMI::PointerEvent::PointerItem otherPoint = {}; - SetTouchGuiderPoint(otherPoint, 2, 500, 500); - MMI::PointerEvent::PointerItem otherPoint1 = {}; - SetTouchGuiderPoint(otherPoint1, 3, 500, 500); - - points.emplace_back(point); - std::shared_ptr event = - CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, POINT_ID_1, 0, 0); - touchGuider_->OnPointerEvent(*event); - - points.emplace_back(otherPoint); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, POINT_ID_2, 0, 0); - touchGuider_->OnPointerEvent(*event); - - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, points, POINT_ID_2, 0, 0); - touchGuider_->OnPointerEvent(*event); - bool retOnPointerEvent8 = TestEventType(); - EXPECT_TRUE(retOnPointerEvent8); - - EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionVector().size(), 0); - - points.emplace_back(otherPoint1); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, POINT_ID_3, 0, 0); - touchGuider_->OnPointerEvent(*event); - EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionVector().size(), 0); - GTEST_LOG_(INFO) << "TouchGuider_Unittest_OnPointerEvent_008 end"; -} - -/** - * @tc.number: OnPointerEvent009 - * @tc.name: OnPointerEvent - * @tc.desc: Check the event that two fingers moving in same directions in draging state. - */ -HWTEST_F(TouchGuiderTest, TouchGuider_Unittest_OnPointerEvent_009, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "TouchGuider_Unittest_OnPointerEvent_009 start"; - - std::vector points = {}; - MMI::PointerEvent::PointerItem point = {}; - point.SetPointerId(1); - MMI::PointerEvent::PointerItem otherPoint = {}; - SetTouchGuiderPoint(otherPoint, 2, 10, 10); - - points.emplace_back(point); - std::shared_ptr event = - CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, POINT_ID_1, 0, 0); - touchGuider_->OnPointerEvent(*event); - bool retOnPointerEvent9 = TestEventType(); - EXPECT_TRUE(retOnPointerEvent9); - - points.emplace_back(otherPoint); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, POINT_ID_2, 0, 0); - touchGuider_->OnPointerEvent(*event); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, points, POINT_ID_2, 0, 0); - touchGuider_->OnPointerEvent(*event); - retOnPointerEvent9 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0) != - MMI::PointerEvent::POINTER_ACTION_DOWN) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent9); - - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, points, POINT_ID_2, 0, 0); - touchGuider_->OnPointerEvent(*event); - int32_t touchEventSize = - static_cast(AccessibilityAbilityHelper::GetInstance().GetTouchEventActionVector().size()); - EXPECT_EQ(touchEventSize, 0); - - GTEST_LOG_(INFO) << "TouchGuider_Unittest_OnPointerEvent_009 end"; -} - -/** - * @tc.number: OnPointerEvent010 - * @tc.name: OnPointerEvent - * @tc.desc: Check the event that multi-finger moving in draging state. - */ -HWTEST_F(TouchGuiderTest, TouchGuider_Unittest_OnPointerEvent_010, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "TouchGuider_Unittest_OnPointerEvent_010 start"; - - std::vector points = {}; - MMI::PointerEvent::PointerItem point = {}; - point.SetPointerId(1); - MMI::PointerEvent::PointerItem otherPoint = {}; - SetTouchGuiderPoint(otherPoint, 2, 500, 500); - MMI::PointerEvent::PointerItem otherPoint1 = {}; - SetTouchGuiderPoint(otherPoint1, 3, 500, 500); - - points.emplace_back(point); - std::shared_ptr event = - CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, 1, 0, 0); - touchGuider_->OnPointerEvent(*event); - bool retOnPointerEvent10 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityAbilityHelper::GetInstance().GetEventTypeOfTargetIndex(0) == - EventType::TYPE_TOUCH_BEGIN) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent10); - - points.emplace_back(otherPoint); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, POINT_ID_2, 0, 0); - touchGuider_->OnPointerEvent(*event); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, points, POINT_ID_2, 0, 0); - touchGuider_->OnPointerEvent(*event); - points.emplace_back(otherPoint1); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, points, POINT_ID_3, 0, 0); - touchGuider_->OnPointerEvent(*event); - retOnPointerEvent10 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(1) != - MMI::PointerEvent::POINTER_ACTION_DOWN) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent10); - int32_t expectValue = MMI::PointerEvent::BUTTON_NONE; - int32_t touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0); - EXPECT_EQ(touchAction, expectValue); - - GTEST_LOG_(INFO) << "TouchGuider_Unittest_OnPointerEvent_010 end"; -} - -/** - * @tc.number: OnPointerEvent012 - * @tc.name: OnPointerEvent - * @tc.desc: Check cancel the second move event after onstart. - */ -HWTEST_F(TouchGuiderTest, TouchGuider_Unittest_OnPointerEvent_012, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "TouchGuider_Unittest_OnPointerEvent_012 start"; - - std::vector points = {}; - MMI::PointerEvent::PointerItem point = {}; - point.SetPointerId(1); - point.SetDisplayX(500); - point.SetDisplayY(500); - MMI::PointerEvent::PointerItem movepoint = {}; - movepoint.SetPointerId(1); - movepoint.SetDisplayX(2500); - movepoint.SetDisplayY(500); - MMI::PointerEvent::PointerItem othermovepoint = {}; - othermovepoint.SetPointerId(1); - othermovepoint.SetDisplayX(2500); - othermovepoint.SetDisplayY(500); - - points.emplace_back(point); - std::shared_ptr event = - CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, 1, 0, 0); - touchGuider_->OnPointerEvent(*event); - - EventType eventType = AccessibilityAbilityHelper::GetInstance().GetEventTypeOfTargetIndex(0); - EXPECT_EQ(eventType, EventType::TYPE_TOUCH_BEGIN); - - points.clear(); - points.emplace_back(movepoint); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, points, 1, 0, 0); - touchGuider_->OnPointerEvent(*event); - - eventType = AccessibilityAbilityHelper::GetInstance().GetEventTypeOfTargetIndex(1); - EXPECT_EQ(eventType, EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN); - int32_t expectValue= MMI::PointerEvent::POINTER_ACTION_MOVE; - int32_t touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0); - EXPECT_EQ(touchAction, expectValue); - - points.clear(); - points.emplace_back(othermovepoint); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, points, 1, 400, 0); - touchGuider_->OnPointerEvent(*event); - eventType = AccessibilityAbilityHelper::GetInstance().GetEventTypeOfTargetIndex(2); - EXPECT_EQ(eventType, EventType::TYPE_TOUCH_GUIDE_GESTURE_END); - - GTEST_LOG_(INFO) << "TouchGuider_Unittest_OnPointerEvent_012 end"; -} - -/** - * @tc.number: OnPointerEvent013 - * @tc.name: OnPointerEvent - * @tc.desc: Check the GESTURE_SWIPE_RIGHT_THEN_UP gesture. - */ -HWTEST_F(TouchGuiderTest, TouchGuider_Unittest_OnPointerEvent_013, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "TouchGuider_Unittest_OnPointerEvent_013 start"; - - std::vector points = {}; - MMI::PointerEvent::PointerItem point = {}; - SetTouchGuiderPoint(point, 1, 2500, 2500); - MMI::PointerEvent::PointerItem movepoint1 = {}; - SetTouchGuiderPoint(movepoint1, 1, 3500, 2500); - MMI::PointerEvent::PointerItem movepoint2 = {}; - SetTouchGuiderPoint(movepoint2, 1, 5000, 2500); - MMI::PointerEvent::PointerItem movepoint3 = {}; - SetTouchGuiderPoint(movepoint3, 1, 4000, 0); - - points.emplace_back(point); - std::shared_ptr event = - CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, 1, 0, 0); - touchGuider_->OnPointerEvent(*event); - - EventType eventType = AccessibilityAbilityHelper::GetInstance().GetEventTypeOfTargetIndex(0); - EXPECT_EQ(eventType, EventType::TYPE_TOUCH_BEGIN); - - points.clear(); - points.emplace_back(movepoint1); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, points, 1, 0, 0); - touchGuider_->OnPointerEvent(*event); - - eventType = AccessibilityAbilityHelper::GetInstance().GetEventTypeOfTargetIndex(1); - EXPECT_EQ(eventType, EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN); - PointerEventTest(points, movepoint2, movepoint3); - - TouchGuiderExpect(eventType, static_cast(GestureType::GESTURE_SWIPE_RIGHT_THEN_UP)); - - GTEST_LOG_(INFO) << "TouchGuider_Unittest_OnPointerEvent_013 end"; -} - -/** - * @tc.number: OnPointerEvent014 - * @tc.name: OnPointerEvent - * @tc.desc: Check the GESTURE_SWIPE_LEFT_THEN_UP gesture. - */ -HWTEST_F(TouchGuiderTest, TouchGuider_Unittest_OnPointerEvent_014, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "TouchGuider_Unittest_OnPointerEvent_014 start"; - - std::vector points = {}; - MMI::PointerEvent::PointerItem point = {}; - SetTouchGuiderPoint(point, 1, 2500, 2500); - MMI::PointerEvent::PointerItem movepoint1 = {}; - SetTouchGuiderPoint(movepoint1, 1, 1500, 2500); - MMI::PointerEvent::PointerItem movepoint2 = {}; - SetTouchGuiderPoint(movepoint2, 1, 0, 2500); - MMI::PointerEvent::PointerItem movepoint3 = {}; - SetTouchGuiderPoint(movepoint3, 1, 1000, 0); - - points.emplace_back(point); - std::shared_ptr event = - CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, 1, 0, 0); - touchGuider_->OnPointerEvent(*event); - - EventType eventType = AccessibilityAbilityHelper::GetInstance().GetEventTypeOfTargetIndex(0); - EXPECT_EQ(eventType, EventType::TYPE_TOUCH_BEGIN); - - points.clear(); - points.emplace_back(movepoint1); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, points, 1, 0, 0); - touchGuider_->OnPointerEvent(*event); - - eventType = AccessibilityAbilityHelper::GetInstance().GetEventTypeOfTargetIndex(1); - EXPECT_EQ(eventType, EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN); - PointerEventTest(points, movepoint2, movepoint3); - - TouchGuiderExpect(eventType, static_cast(GestureType::GESTURE_SWIPE_LEFT_THEN_UP)); - - GTEST_LOG_(INFO) << "TouchGuider_Unittest_OnPointerEvent_014 end"; -} - -/** - * @tc.number: OnPointerEvent015 - * @tc.name: OnPointerEvent - * @tc.desc: Check the GESTURE_SWIPE_DOWN_THEN_LEFT gesture. - */ -HWTEST_F(TouchGuiderTest, TouchGuider_Unittest_OnPointerEvent_015, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "TouchGuider_Unittest_OnPointerEvent_015 start"; - - std::vector points = {}; - MMI::PointerEvent::PointerItem point = {}; - SetTouchGuiderPoint(point, 1, 2500, 2500); - MMI::PointerEvent::PointerItem movepoint1 = {}; - SetTouchGuiderPoint(movepoint1, 1, 2500, 3500); - MMI::PointerEvent::PointerItem movepoint2 = {}; - SetTouchGuiderPoint(movepoint2, 1, 2500, 5000); - MMI::PointerEvent::PointerItem movepoint3 = {}; - SetTouchGuiderPoint(movepoint3, 1, 0, 4000); - - points.emplace_back(point); - std::shared_ptr event = - CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, 1, 0, 0); - touchGuider_->OnPointerEvent(*event); - - EventType eventType = AccessibilityAbilityHelper::GetInstance().GetEventTypeOfTargetIndex(0); - EXPECT_EQ(eventType, EventType::TYPE_TOUCH_BEGIN); - - points.clear(); - points.emplace_back(movepoint1); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, points, 1, 0, 0); - touchGuider_->OnPointerEvent(*event); - - eventType = AccessibilityAbilityHelper::GetInstance().GetEventTypeOfTargetIndex(1); - EXPECT_EQ(eventType, EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN); - PointerEventTest(points, movepoint2, movepoint3); - - TouchGuiderExpect(eventType, static_cast(GestureType::GESTURE_SWIPE_DOWN_THEN_LEFT)); - - GTEST_LOG_(INFO) << "TouchGuider_Unittest_OnPointerEvent_015 end"; -} - -/** - * @tc.number: OnPointerEvent016 - * @tc.name: OnPointerEvent - * @tc.desc: Check the GESTURE_SWIPE_DOWN_THEN_RIGHT gesture. - */ -HWTEST_F(TouchGuiderTest, TouchGuider_Unittest_OnPointerEvent_016, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "TouchGuider_Unittest_OnPointerEvent_016 start"; - - std::vector points = {}; - MMI::PointerEvent::PointerItem point = {}; - SetTouchGuiderPoint(point, 1, 2500, 2500); - MMI::PointerEvent::PointerItem movepoint1 = {}; - SetTouchGuiderPoint(movepoint1, 1, 2500, 3500); - MMI::PointerEvent::PointerItem movepoint2 = {}; - SetTouchGuiderPoint(movepoint2, 1, 2500, 5000); - MMI::PointerEvent::PointerItem movepoint3 = {}; - SetTouchGuiderPoint(movepoint3, 1, 5000, 4000); - - points.emplace_back(point); - std::shared_ptr event = - CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, 1, 0, 0); - touchGuider_->OnPointerEvent(*event); - - EventType eventType = AccessibilityAbilityHelper::GetInstance().GetEventTypeOfTargetIndex(0); - EXPECT_EQ(eventType, EventType::TYPE_TOUCH_BEGIN); - - points.clear(); - points.emplace_back(movepoint1); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, points, 1, 0, 0); - touchGuider_->OnPointerEvent(*event); - - eventType = AccessibilityAbilityHelper::GetInstance().GetEventTypeOfTargetIndex(1); - EXPECT_EQ(eventType, EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN); - PointerEventTest(points, movepoint2, movepoint3); - - TouchGuiderExpect(eventType, static_cast(GestureType::GESTURE_SWIPE_DOWN_THEN_RIGHT)); - - GTEST_LOG_(INFO) << "TouchGuider_Unittest_OnPointerEvent_016 end"; -} - -/** - * @tc.number: OnPointerEvent017 - * @tc.name: OnPointerEvent - * @tc.desc: Check the LEFT gesture. - */ -HWTEST_F(TouchGuiderTest, TouchGuider_Unittest_OnPointerEvent_017, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "TouchGuider_Unittest_OnPointerEvent_017 start"; - - std::vector points = {}; - MMI::PointerEvent::PointerItem point = {}; - point.SetPointerId(1); - point.SetDisplayX(2500); - point.SetDisplayY(2500); - MMI::PointerEvent::PointerItem movepoint1 = {}; - movepoint1.SetPointerId(1); - movepoint1.SetDisplayX(1000); - movepoint1.SetDisplayY(2500); - MMI::PointerEvent::PointerItem movepoint2 = {}; - movepoint2.SetPointerId(1); - movepoint2.SetDisplayX(0); - movepoint2.SetDisplayY(2500); - - points.emplace_back(point); - std::shared_ptr event = - CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, 1, 0, 0); - touchGuider_->OnPointerEvent(*event); - - EventType eventType = AccessibilityAbilityHelper::GetInstance().GetEventTypeOfTargetIndex(0); - EXPECT_EQ(eventType, EventType::TYPE_TOUCH_BEGIN); - - points.clear(); - points.emplace_back(movepoint1); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, points, 1, 0, 0); - touchGuider_->OnPointerEvent(*event); - - eventType = AccessibilityAbilityHelper::GetInstance().GetEventTypeOfTargetIndex(1); - EXPECT_EQ(eventType, EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN); - int32_t expectValue = MMI::PointerEvent::POINTER_ACTION_MOVE; - int32_t touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(0); - EXPECT_EQ(touchAction, expectValue); - - points.clear(); - points.emplace_back(movepoint2); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, points, 1, 0, 0); - touchGuider_->OnPointerEvent(*event); - - touchAction = AccessibilityAbilityHelper::GetInstance().GetTouchEventActionOfTargetIndex(1); - EXPECT_EQ(touchAction, expectValue); - - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, 1, 0, 0); - touchGuider_->OnPointerEvent(*event); - - eventType = AccessibilityAbilityHelper::GetInstance().GetEventTypeOfTargetIndex(2); - EXPECT_EQ(eventType, EventType::TYPE_TOUCH_END); - eventType = AccessibilityAbilityHelper::GetInstance().GetEventTypeOfTargetIndex(3); - EXPECT_EQ(eventType, EventType::TYPE_TOUCH_GUIDE_GESTURE_END); - auto uTgestureId = AccessibilityAbilityHelper::GetInstance().GetGestureId(); - EXPECT_EQ(uTgestureId, static_cast(GestureType::GESTURE_SWIPE_LEFT)); - - GTEST_LOG_(INFO) << "TouchGuider_Unittest_OnPointerEvent_017 end"; -} - -/** - * @tc.number: OnPointerEvent018 - * @tc.name: OnPointerEvent - * @tc.desc: Check the DoubleTap gesture. - */ -HWTEST_F(TouchGuiderTest, TouchGuider_Unittest_OnPointerEvent_018, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "TouchGuider_Unittest_OnPointerEvent_018 start"; - - if (!touchGuider_) { - GTEST_LOG_(INFO) << "touchGuider_ is null"; - return; - } - - sptr accountData = - Singleton::GetInstance().GetCurrentAccountData(); - if (!accountData) { - GTEST_LOG_(INFO) << "accountData is null"; - return; - } - - AccessibilityAbilityHelper::GetInstance().SetRealId(WINDOW_ID); - sptr proxy = new(std::nothrow) AccessibilityElementOperatorProxy(nullptr); - sptr windowConnection = - new(std::nothrow) AccessibilityWindowConnection(WINDOW_ID, proxy, ACCOUNT_ID); - accountData->AddAccessibilityWindowConnection(WINDOW_ID, windowConnection); - - // send down event - std::vector points = {}; - MMI::PointerEvent::PointerItem point = {}; - point.SetPointerId(1); - point.SetDisplayX(2500); - point.SetDisplayY(2500); - points.emplace_back(point); - std::shared_ptr event = - CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, 1, 0, 0); - touchGuider_->OnPointerEvent(*event); - - // send up event - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, 1, 0, 0); - touchGuider_->OnPointerEvent(*event); - - // send down event - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, 1, 200, 200); - touchGuider_->OnPointerEvent(*event); - - // send up event - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, 1, 200, 200); - touchGuider_->OnPointerEvent(*event); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityAbilityHelper::GetInstance().GetExecuteAction() == ACCESSIBILITY_ACTION_CLICK) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_GE(ret, 0); - - GTEST_LOG_(INFO) << "TouchGuider_Unittest_OnPointerEvent_018 end"; -} - -/** - * @tc.number: DestroyEvents - * @tc.name: DestroyEvents - * @tc.desc: Check DestroyEvents. - */ -HWTEST_F(TouchGuiderTest, TouchGuider_Unittest_DestroyEvents_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "TouchGuider_Unittest_DestroyEvents_001 start"; - - touchGuider_->DestroyEvents(); - bool isDestroyEvents; - isDestroyEvents = AccessibilityAbilityHelper::GetInstance().GetDestroyState(); - EXPECT_EQ(isDestroyEvents, true); - - GTEST_LOG_(INFO) << "TouchGuider_Unittest_DestroyEvents_001 end"; -} - -/** - * @tc.number: StartUp001 - * @tc.name: StartUp - * @tc.desc: Check the first down event. - */ -HWTEST_F(TouchGuiderTest, TouchGuider_Unittest_StartUp_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "TouchGuider_Unittest_StartUp_001 start"; - Singleton::GetInstance().OnStop(); - std::unique_ptr touchGuider = std::make_unique(); - touchGuider->StartUp(); - EXPECT_EQ(nullptr, Singleton::GetInstance().GetMainRunner()); - Singleton::GetInstance().OnStart(); - GTEST_LOG_(INFO) << "TouchGuider_Unittest_StartUp_001 end"; -} -} // namespace Accessibility -} // namespace OHOS \ No newline at end of file diff --git a/services/test/BUILD.gn b/services/test/BUILD.gn index 1d539f97..901d00ab 100644 --- a/services/test/BUILD.gn +++ b/services/test/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (C) 2022 Huawei Device Co., Ltd. +# Copyright (C) 2022-2024 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -41,16 +41,7 @@ config("module_private_config") { "../aams/include", "mock", "./mock/common", - "${ability_runtime_path}/interfaces/kits/native/ability/native/", - "${ability_runtime_path}/interfaces/kits/native/appkit/ability_runtime", - "${ability_runtime_path}/interfaces/kits/native/appkit/ability_runtime/context", - "${ability_runtime_path}/interfaces/kits/native/appkit/app/", - "${ability_runtime_inner_api_path}/ability_manager/include", - "${ability_runtime_inner_api_path}/app_manager/include/appmgr", - "${ability_runtime_services_path}/abilitymgr/include", "mock/aafwk/include", - "${AAMS_FOUNDATION_PATH}/window/window_manager/utils/include", - "../../../graphic/graphic_2d/rosen/modules/2d_graphics/include", ] defines = [ @@ -64,7 +55,7 @@ config("module_private_config") { MockDistributedscheduleSrc = [] ################################################################################ -ohos_moduletest("aams_accessibility_touch_guider_test") { +ohos_moduletest("aams_accessibility_touch_exploration_test") { module_out_path = module_output_path sources = [ @@ -76,12 +67,10 @@ ohos_moduletest("aams_accessibility_touch_guider_test") { "../aams/src/accessibility_display_manager.cpp", "../aams/src/accessibility_dumper.cpp", "../aams/src/accessibility_event_transmission.cpp", - "../aams/src/accessibility_gesture_recognizer.cpp", "../aams/src/accessibility_input_interceptor.cpp", "../aams/src/accessibility_keyevent_filter.cpp", "../aams/src/accessibility_mouse_autoclick.cpp", "../aams/src/accessibility_mouse_key.cpp", - "../aams/src/accessibility_multifinger_multitap.cpp", "../aams/src/accessibility_power_manager.cpp", "../aams/src/accessibility_screen_touch.cpp", "../aams/src/accessibility_setting_observer.cpp", @@ -89,7 +78,7 @@ ohos_moduletest("aams_accessibility_touch_guider_test") { "../aams/src/accessibility_settings_config.cpp", "../aams/src/accessibility_short_key.cpp", "../aams/src/accessibility_touchEvent_injector.cpp", - "../aams/src/accessibility_touch_guider.cpp", + "../aams/src/accessibility_touch_exploration.cpp", "../aams/src/accessibility_window_connection.cpp", "../aams/src/accessibility_window_manager.cpp", "../aams/src/accessibility_zoom_gesture.cpp", @@ -114,7 +103,7 @@ ohos_moduletest("aams_accessibility_touch_guider_test") { "./mock/mock_parameter.c", "./mock/mock_service_registry.cpp", "./mock/mock_system_ability.cpp", - "moduletest/aamstest/aams_accessibility_touch_guider_test/aams_accessibility_touch_guider_test.cpp", + "moduletest/aamstest/aams_accessibility_touch_exploration_test/aams_accessibility_touch_exploration_test.cpp", ] sources += aams_mock_distributeddatamgr_src sources += aams_mock_multimodalinput_src @@ -127,8 +116,6 @@ ohos_moduletest("aams_accessibility_touch_guider_test") { ] deps = [ - "../../../../../third_party/googletest:gmock_main", - "../../../../../third_party/googletest:gtest_main", "../../common/interface:accessibility_interface", "../../interfaces/innerkits/common:accessibility_common", ] @@ -147,6 +134,8 @@ ohos_moduletest("aams_accessibility_touch_guider_test") { "display_manager:displaymgr", "eventhandler:libeventhandler", "ffrt:libffrt", + "googletest:gmock_main", + "googletest:gtest_main", "graphic_2d:2d_graphics", "graphic_2d:librender_service_client", "hicollie:libhicollie", @@ -176,12 +165,10 @@ ohos_moduletest("aams_accessibility_touchEvent_injector_test") { "../aams/src/accessibility_display_manager.cpp", "../aams/src/accessibility_dumper.cpp", "../aams/src/accessibility_event_transmission.cpp", - "../aams/src/accessibility_gesture_recognizer.cpp", "../aams/src/accessibility_input_interceptor.cpp", "../aams/src/accessibility_keyevent_filter.cpp", "../aams/src/accessibility_mouse_autoclick.cpp", "../aams/src/accessibility_mouse_key.cpp", - "../aams/src/accessibility_multifinger_multitap.cpp", "../aams/src/accessibility_power_manager.cpp", "../aams/src/accessibility_screen_touch.cpp", "../aams/src/accessibility_setting_observer.cpp", @@ -189,7 +176,7 @@ ohos_moduletest("aams_accessibility_touchEvent_injector_test") { "../aams/src/accessibility_settings_config.cpp", "../aams/src/accessibility_short_key.cpp", "../aams/src/accessibility_touchEvent_injector.cpp", - "../aams/src/accessibility_touch_guider.cpp", + "../aams/src/accessibility_touch_exploration.cpp", "../aams/src/accessibility_window_connection.cpp", "../aams/src/accessibility_window_manager.cpp", "../aams/src/accessibility_zoom_gesture.cpp", @@ -228,8 +215,6 @@ ohos_moduletest("aams_accessibility_touchEvent_injector_test") { ] deps = [ - "../../../../../third_party/googletest:gmock_main", - "../../../../../third_party/googletest:gtest_main", "../../common/interface:accessibility_interface", "../../interfaces/innerkits/common:accessibility_common", ] @@ -248,6 +233,8 @@ ohos_moduletest("aams_accessibility_touchEvent_injector_test") { "display_manager:displaymgr", "eventhandler:libeventhandler", "ffrt:libffrt", + "googletest:gmock_main", + "googletest:gtest_main", "graphic_2d:2d_graphics", "graphic_2d:librender_service_client", "hicollie:libhicollie", @@ -277,12 +264,10 @@ ohos_moduletest("aams_accessible_ability_channel_test") { "../aams/src/accessibility_display_manager.cpp", "../aams/src/accessibility_dumper.cpp", "../aams/src/accessibility_event_transmission.cpp", - "../aams/src/accessibility_gesture_recognizer.cpp", "../aams/src/accessibility_input_interceptor.cpp", "../aams/src/accessibility_keyevent_filter.cpp", "../aams/src/accessibility_mouse_autoclick.cpp", "../aams/src/accessibility_mouse_key.cpp", - "../aams/src/accessibility_multifinger_multitap.cpp", "../aams/src/accessibility_power_manager.cpp", "../aams/src/accessibility_screen_touch.cpp", "../aams/src/accessibility_setting_observer.cpp", @@ -290,7 +275,7 @@ ohos_moduletest("aams_accessible_ability_channel_test") { "../aams/src/accessibility_settings_config.cpp", "../aams/src/accessibility_short_key.cpp", "../aams/src/accessibility_touchEvent_injector.cpp", - "../aams/src/accessibility_touch_guider.cpp", + "../aams/src/accessibility_touch_exploration.cpp", "../aams/src/accessibility_window_connection.cpp", "../aams/src/accessibility_window_manager.cpp", "../aams/src/accessibility_zoom_gesture.cpp", @@ -335,8 +320,6 @@ ohos_moduletest("aams_accessible_ability_channel_test") { ] deps = [ - "../../../../../third_party/googletest:gmock_main", - "../../../../../third_party/googletest:gtest_main", "../../common/interface:accessibility_interface", "../../interfaces/innerkits/common:accessibility_common", ] @@ -354,6 +337,8 @@ ohos_moduletest("aams_accessible_ability_channel_test") { "display_manager:displaymgr", "eventhandler:libeventhandler", "ffrt:libffrt", + "googletest:gmock_main", + "googletest:gtest_main", "graphic_2d:2d_graphics", "graphic_2d:librender_service_client", "hicollie:libhicollie", @@ -383,12 +368,10 @@ ohos_moduletest("aams_server_test") { "../aams/src/accessibility_display_manager.cpp", "../aams/src/accessibility_dumper.cpp", "../aams/src/accessibility_event_transmission.cpp", - "../aams/src/accessibility_gesture_recognizer.cpp", "../aams/src/accessibility_input_interceptor.cpp", "../aams/src/accessibility_keyevent_filter.cpp", "../aams/src/accessibility_mouse_autoclick.cpp", "../aams/src/accessibility_mouse_key.cpp", - "../aams/src/accessibility_multifinger_multitap.cpp", "../aams/src/accessibility_power_manager.cpp", "../aams/src/accessibility_screen_touch.cpp", "../aams/src/accessibility_setting_observer.cpp", @@ -396,7 +379,7 @@ ohos_moduletest("aams_server_test") { "../aams/src/accessibility_settings_config.cpp", "../aams/src/accessibility_short_key.cpp", "../aams/src/accessibility_touchEvent_injector.cpp", - "../aams/src/accessibility_touch_guider.cpp", + "../aams/src/accessibility_touch_exploration.cpp", "../aams/src/accessibility_window_connection.cpp", "../aams/src/accessibility_window_manager.cpp", "../aams/src/accessibility_zoom_gesture.cpp", @@ -439,8 +422,6 @@ ohos_moduletest("aams_server_test") { ] deps = [ - "../../../../../third_party/googletest:gmock_main", - "../../../../../third_party/googletest:gtest_main", "../../common/interface:accessibility_interface", "../../interfaces/innerkits/common:accessibility_common", ] @@ -458,6 +439,8 @@ ohos_moduletest("aams_server_test") { "display_manager:displaymgr", "eventhandler:libeventhandler", "ffrt:libffrt", + "googletest:gmock_main", + "googletest:gtest_main", "graphic_2d:2d_graphics", "graphic_2d:librender_service_client", "hicollie:libhicollie", @@ -487,12 +470,10 @@ ohos_moduletest("aams_accessibility_keyevent_filter_test") { "../aams/src/accessibility_display_manager.cpp", "../aams/src/accessibility_dumper.cpp", "../aams/src/accessibility_event_transmission.cpp", - "../aams/src/accessibility_gesture_recognizer.cpp", "../aams/src/accessibility_input_interceptor.cpp", "../aams/src/accessibility_keyevent_filter.cpp", "../aams/src/accessibility_mouse_autoclick.cpp", "../aams/src/accessibility_mouse_key.cpp", - "../aams/src/accessibility_multifinger_multitap.cpp", "../aams/src/accessibility_power_manager.cpp", "../aams/src/accessibility_screen_touch.cpp", "../aams/src/accessibility_setting_observer.cpp", @@ -500,7 +481,7 @@ ohos_moduletest("aams_accessibility_keyevent_filter_test") { "../aams/src/accessibility_settings_config.cpp", "../aams/src/accessibility_short_key.cpp", "../aams/src/accessibility_touchEvent_injector.cpp", - "../aams/src/accessibility_touch_guider.cpp", + "../aams/src/accessibility_touch_exploration.cpp", "../aams/src/accessibility_window_connection.cpp", "../aams/src/accessibility_window_manager.cpp", "../aams/src/accessibility_zoom_gesture.cpp", @@ -537,8 +518,6 @@ ohos_moduletest("aams_accessibility_keyevent_filter_test") { ] deps = [ - "../../../../../third_party/googletest:gmock_main", - "../../../../../third_party/googletest:gtest_main", "../../common/interface:accessibility_interface", "../../interfaces/innerkits/common:accessibility_common", ] @@ -557,6 +536,8 @@ ohos_moduletest("aams_accessibility_keyevent_filter_test") { "display_manager:displaymgr", "eventhandler:libeventhandler", "ffrt:libffrt", + "googletest:gmock_main", + "googletest:gtest_main", "graphic_2d:2d_graphics", "graphic_2d:librender_service_client", "hicollie:libhicollie", @@ -586,12 +567,10 @@ ohos_moduletest("aams_common_event_registry_test") { "../aams/src/accessibility_display_manager.cpp", "../aams/src/accessibility_dumper.cpp", "../aams/src/accessibility_event_transmission.cpp", - "../aams/src/accessibility_gesture_recognizer.cpp", "../aams/src/accessibility_input_interceptor.cpp", "../aams/src/accessibility_keyevent_filter.cpp", "../aams/src/accessibility_mouse_autoclick.cpp", "../aams/src/accessibility_mouse_key.cpp", - "../aams/src/accessibility_multifinger_multitap.cpp", "../aams/src/accessibility_power_manager.cpp", "../aams/src/accessibility_screen_touch.cpp", "../aams/src/accessibility_setting_observer.cpp", @@ -599,7 +578,7 @@ ohos_moduletest("aams_common_event_registry_test") { "../aams/src/accessibility_settings_config.cpp", "../aams/src/accessibility_short_key.cpp", "../aams/src/accessibility_touchEvent_injector.cpp", - "../aams/src/accessibility_touch_guider.cpp", + "../aams/src/accessibility_touch_exploration.cpp", "../aams/src/accessibility_window_connection.cpp", "../aams/src/accessibility_window_manager.cpp", "../aams/src/accessibility_zoom_gesture.cpp", @@ -642,8 +621,6 @@ ohos_moduletest("aams_common_event_registry_test") { ] deps = [ - "../../../../../third_party/googletest:gmock_main", - "../../../../../third_party/googletest:gtest_main", "../../common/interface:accessibility_interface", "../../interfaces/innerkits/common:accessibility_common", ] @@ -661,6 +638,8 @@ ohos_moduletest("aams_common_event_registry_test") { "display_manager:displaymgr", "eventhandler:libeventhandler", "ffrt:libffrt", + "googletest:gmock_main", + "googletest:gtest_main", "graphic_2d:2d_graphics", "graphic_2d:librender_service_client", "hicollie:libhicollie", @@ -686,7 +665,7 @@ group("moduletest") { deps += [ ":aams_accessibility_keyevent_filter_test", ":aams_accessibility_touchEvent_injector_test", - ":aams_accessibility_touch_guider_test", + ":aams_accessibility_touch_exploration_test", ":aams_accessible_ability_channel_test", ":aams_common_event_registry_test", ":aams_server_test", diff --git a/services/test/aamstestmock.gni b/services/test/aamstestmock.gni index 2756f599..e48f2d7e 100755 --- a/services/test/aamstestmock.gni +++ b/services/test/aamstestmock.gni @@ -11,11 +11,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -ability_base_path = "//foundation/ability/ability_base" -ability_runtime_path = "//foundation/ability/ability_runtime" -ability_runtime_inner_api_path = "${ability_runtime_path}/interfaces/inner_api" -ability_runtime_kits_path = "${ability_runtime_path}/frameworks/kits" -ability_runtime_services_path = "${ability_runtime_path}/services" AAMS_MOCK_PATH = "//foundation/barrierfree/accessibility/services/test/mock" AAMS_FRAMEWORKS_PATH = "//foundation/barrierfree/accessibility/frameworks" AAMS_INTERFACES_PATH = "//foundation/barrierfree/accessibility/interfaces" @@ -27,39 +22,6 @@ aams_mock_include_dirs = [ "$AAMS_MOCK_PATH/distributeddatamgr/include", "$AAMS_MOCK_PATH/multimodalinput/include", "$AAMS_MOCK_PATH/powermanager/include", - "//base/account/os_account/interfaces/innerkits/common/include", - "//base/account/os_account/interfaces/innerkits/osaccount/native/include", - "//base/global/resource_management/interfaces/inner_api/include", - "//base/hiviewdfx/hiview/adapter/utility/include/extra/singleton.h", - "//base/notification/common_event_service/interfaces/inner_api", - "//base/notification/eventhandler/interfaces/inner_api", - "//base/powermgr/display_manager/utils/native/include", - "//foundation", - "//foundation/arkui/napi/native_engine", - "//foundation/distributeddatamgr/preferences/interfaces/inner_api/include", - "//foundation/multimodalinput/input/interfaces/native/innerkits/proxy/include", - "//foundation/distributeddatamgr/data_share/interfaces/inner_api/common/include", - "//foundation/multimodalinput/input/interfaces/native/innerkits/event/include", - "//base/powermgr/power_manager/interfaces/inner_api/native/include", - "//foundation/bundlemanager/bundle_framework/interfaces/inner_api/appexecfwk_base/include", - "//foundation/bundlemanager/bundle_framework/interfaces/inner_api/appexecfwk_core/include", - "//foundation/bundlemanager/bundle_framework/interfaces/inner_api/appexecfwk_core/include/bundlemgr", - "//foundation/systemabilitymgr/safwk/interfaces/innerkits/safwk", - "//foundation/systemabilitymgr/samgr/interfaces/innerkits/samgr_proxy/include", - "//foundation/systemabilitymgr/samgr/interfaces/innerkits/samgr_proxy/include", - "//foundation/graphic/graphic_2d/rosen/modules/render_service_base/include", - "//foundation/multimedia/image_framework/interfaces/kits/native/include", - "//foundation/multimedia/image_framework/interfaces/innerkits/include", - "//foundation/multimodalinput/input/util/common/include", - "//foundation/window/window_manager/dm/include", - "//foundation/window/window_manager/interfaces/innerkits", - "//foundation/window/window_manager/interfaces/innerkits/dm", - "//foundation/window/window_manager/interfaces/innerkits/wm", - "//foundation/window/window_manager/utils/include", - "//third_party/jsoncpp/include", - "//third_party/jsoncpp/include/json", - "//commonlibrary/c_utils/base/include", - "//utils/system/safwk/native/include", ] aams_mock_distributeddatamgr_src = diff --git a/services/test/mock/mock_aams_accessibility_touchEvent_injector_test.cpp b/services/test/mock/mock_aams_accessibility_touchEvent_injector_test.cpp deleted file mode 100644 index 6a15b8a1..00000000 --- a/services/test/mock/mock_aams_accessibility_touchEvent_injector_test.cpp +++ /dev/null @@ -1,1939 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include "accessibility_common_helper.h" -#include "accessibility_display_manager.h" -#include "accessibility_element_operator_stub.h" -#include "accessibility_input_interceptor.h" -#include "accessibility_mt_helper.h" -#include "accessibility_touch_guider.h" -#include "accessibility_touchEvent_injector.h" -#include "accessibility_window_manager.h" -#include "accessible_ability_channel.h" -#include "accessible_ability_client_proxy.h" -#include "accessible_ability_connection.h" -#include "accessible_ability_manager_service.h" -#include "iservice_registry.h" -#include "mock_accessibility_element_operator_callback.h" -#include "mock_accessibility_element_operator_impl.h" -#include "mock_accessibility_element_operator_proxy.h" -#include "mock_input_manager.h" - -using namespace testing; -using namespace testing::ext; - -namespace OHOS { -namespace Accessibility { -namespace { - const int32_t SLEEP_TIME_2 = 2; -} // namespace - -class MockAamsInjectorTest : public testing::Test { -public: - MockAamsInjectorTest() - {} - ~MockAamsInjectorTest() - {} - - static void SetUpTestCase(); - static void TearDownTestCase(); - void SetUp() override; - void TearDown() override; - - sptr aacs_ = nullptr; - sptr aastub_ = nullptr; - void AddAccessibilityWindowConnection(); -}; - -void MockAamsInjectorTest::SetUpTestCase() -{ - GTEST_LOG_(INFO) << "MockAamsInjectorTest SetUpTestCase"; - Singleton::GetInstance().OnStart(); - AccessibilityCommonHelper::GetInstance().WaitForServicePublish(); - Singleton::GetInstance().SwitchedUser(AccessibilityHelper::accountId_); - GTEST_LOG_(INFO) << "AccessibleAbilityManagerService is published"; -} - -void MockAamsInjectorTest::TearDownTestCase() -{ - GTEST_LOG_(INFO) << "MockAamsInjectorTest TearDownTestCase"; - Singleton::GetInstance().OnStop(); -} - -void MockAamsInjectorTest::SetUp() -{ - GTEST_LOG_(INFO) << "MockAamsInjectorTest SetUp"; - - // add an ability connection client - AccessibilityAbilityInitParams initParams; - std::shared_ptr abilityInfo = std::make_shared(initParams); - abilityInfo->SetAccessibilityAbilityType(AccessibilityAbilityTypes::ACCESSIBILITY_ABILITY_TYPE_ALL); - abilityInfo->SetCapabilityValues(Capability::CAPABILITY_TOUCH_GUIDE | Capability::CAPABILITY_GESTURE); - AppExecFwk::ElementName elementName("deviceId", "bundleName", "name"); - auto accountData = Singleton::GetInstance().GetCurrentAccountData(); - accountData->AddInstalledAbility(*abilityInfo); - sleep(1); - sptr connection = - new AccessibleAbilityConnection(accountData->GetAccountId(), 0, *abilityInfo); - aastub_ = new AccessibleAbilityChannel(accountData->GetAccountId(), abilityInfo->GetId()); - connection->OnAbilityConnectDoneSync(elementName, aastub_); - - AddAccessibilityWindowConnection(); - - std::map> connectionMaps = - Singleton::GetInstance().GetCurrentAccountData()->GetConnectedA11yAbilities(); - auto iter = connectionMaps.begin(); - sptr ptr_connect = iter->second; - if (ptr_connect) { - aacs_ = new AccessibleAbilityChannel(accountData->GetAccountId(), - ptr_connect->GetAbilityInfo().GetId()); - } - GTEST_LOG_(INFO) << "MockAamsInjectorTest SetUp end"; -} - -void MockAamsInjectorTest::TearDown() -{ - GTEST_LOG_(INFO) << "TouchEventInjectorTest TearDown"; - aacs_ = nullptr; - aastub_ = nullptr; - Singleton::GetInstance().DeregisterElementOperator(0); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - auto &aams = Singleton::GetInstance(); - if (aams.GetMainRunner()->GetEventQueue()->IsIdle()) { - return true; - } else { - return false; - } - }), 1); - if (!ret) { - GTEST_LOG_(INFO) << "AamsAccessibleAbilityChannelTest TearDown EventQueue is not empty"; - } - MMI::MockInputManager::ClearTouchActions(); - AccessibilityHelper::GetInstance().GetEventType().clear(); -} - -void MockAamsInjectorTest::AddAccessibilityWindowConnection() -{ - GTEST_LOG_(INFO) << "MockAamsInjectorTest AddAccessibilityWindowConnection"; - int32_t windowId = 0; - std::shared_ptr mockCallback = - std::make_shared(); - sptr stub = - new MockAccessibilityElementOperatorImpl(windowId, nullptr, *mockCallback); - sptr proxy = new MockAccessibilityElementOperatorProxy(stub); - GTEST_LOG_(INFO) << "aams RegisterElementOperator"; - Singleton::GetInstance().RegisterElementOperator(windowId, proxy, true); -} - -/** - * @tc.number: SingleTap001 - * @tc.name:SingleTap - * @tc.desc: Check that the injected single-tap event can be recognized in touchGuide. - */ -HWTEST_F(MockAamsInjectorTest, TouchEventInjector_ModuleTest_SingleTap_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_SingleTap_001 start"; - - AccessibilityHelper::GetInstance().GetEventType().clear(); - MMI::MockInputManager::ClearTouchActions(); - AccessibilityGesturePosition point {500.0f, 500.0f}; - std::shared_ptr gesturePath = std::make_shared(); - gesturePath->AddPosition(point); - gesturePath->SetDurationTime(100); - aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(1)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(!ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_HOVER_ENTER, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (EventType::TYPE_TOUCH_GUIDE_END == AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(EventType::TYPE_TOUCH_BEGIN, AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0)); - EXPECT_EQ(EventType::TYPE_TOUCH_END, AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1)); - EXPECT_EQ(EventType::TYPE_TOUCH_GUIDE_BEGIN, AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2)); - - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_SingleTap_001 end"; -} - -/** - * @tc.number: SingleTap002 - * @tc.name:SingleTap - * @tc.desc: Check that the injected single-tap event can be recognized in touchGuide. - */ -HWTEST_F(MockAamsInjectorTest, TouchEventInjector_ModuleTest_SingleTap_002, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_SingleTap_002 start"; - - AccessibilityHelper::GetInstance().GetEventType().clear(); - MMI::MockInputManager::ClearTouchActions(); - AccessibilityGesturePosition point {500.0f, 500.0f}; - std::shared_ptr gesturePath = std::make_shared(); - gesturePath->AddPosition(point); - gesturePath->SetDurationTime(300); - aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(1)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(!ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_HOVER_ENTER, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (EventType::TYPE_TOUCH_GUIDE_END == AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(EventType::TYPE_TOUCH_BEGIN, AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0)); - EXPECT_EQ(EventType::TYPE_TOUCH_END, AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1)); - EXPECT_EQ(EventType::TYPE_TOUCH_GUIDE_BEGIN, AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2)); - - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_SingleTap_002 end"; -} - -/** - * @tc.number: SingleTap003 - * @tc.name:SingleTap - * @tc.desc: Check that the injected single-tap event can be recognized in touchGuide. - */ -HWTEST_F(MockAamsInjectorTest, TouchEventInjector_ModuleTest_SingleTap_003, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_SingleTap_003 start"; - - AccessibilityHelper::GetInstance().GetEventType().clear(); - MMI::MockInputManager::ClearTouchActions(); - AccessibilityGesturePosition point {500.0f, 500.0f}; - std::shared_ptr gesturePath = std::make_shared(); - gesturePath->AddPosition(point); - gesturePath->SetDurationTime(1000); - aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(1)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(!ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_HOVER_ENTER, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (EventType::TYPE_TOUCH_GUIDE_END == AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(EventType::TYPE_TOUCH_BEGIN, AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0)); - EXPECT_EQ(EventType::TYPE_TOUCH_GUIDE_BEGIN, AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1)); - EXPECT_EQ(EventType::TYPE_TOUCH_END, AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2)); - - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_SingleTap_003 end"; -} - -/** - * @tc.number: Left001 - * @tc.name:Left - * @tc.desc: Check that the injected LEFT gesture can be recognized in touchGuide. - */ -HWTEST_F(MockAamsInjectorTest, TouchEventInjector_ModuleTest_Left_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_Left_001 start"; - - AccessibilityHelper::GetInstance().GetEventType().clear(); - MMI::MockInputManager::ClearTouchActions(); - AccessibilityGesturePosition point1 {2500.0f, 2500.0f}; - AccessibilityGesturePosition point2 {1000.0f, 2500.0f}; - AccessibilityGesturePosition point3 {0.0f, 2500.0f}; - std::shared_ptr gesturePath = std::make_shared(); - gesturePath->AddPosition(point1); - gesturePath->AddPosition(point2); - gesturePath->AddPosition(point3); - gesturePath->SetDurationTime(200); - - aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(1)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_LEFT) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_Left_001 end"; -} - -/** - * @tc.number: Left002 - * @tc.name:Left - * @tc.desc: Check that the injected LEFT gesture can be recognized in touchGuide. - */ -HWTEST_F(MockAamsInjectorTest, TouchEventInjector_ModuleTest_Left_002, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_Left_002 start"; - - AccessibilityHelper::GetInstance().GetEventType().clear(); - MMI::MockInputManager::ClearTouchActions(); - AccessibilityGesturePosition point1 {2500.0f, 2500.0f}; - AccessibilityGesturePosition point2 {1000.0f, 2500.0f}; - AccessibilityGesturePosition point3 {0.0f, 2500.0f}; - std::shared_ptr gesturePath = std::make_shared(); - gesturePath->AddPosition(point1); - gesturePath->AddPosition(point2); - gesturePath->AddPosition(point3); - gesturePath->SetDurationTime(800); - - aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(1)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(!ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_HOVER_ENTER, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_LEFT) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_Left_002 end"; -} - -/** - * @tc.number: Left003 - * @tc.name:Left - * @tc.desc: Check that the injected LEFT gesture can be recognized in touchGuide. - */ -HWTEST_F(MockAamsInjectorTest, TouchEventInjector_ModuleTest_Left_003, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_Left_003 start"; - - AccessibilityHelper::GetInstance().GetEventType().clear(); - MMI::MockInputManager::ClearTouchActions(); - AccessibilityGesturePosition point1 {2500.0f, 2500.0f}; - AccessibilityGesturePosition point2 {1000.0f, 2500.0f}; - AccessibilityGesturePosition point3 {0.0f, 2300.0f}; - std::shared_ptr gesturePath = std::make_shared(); - gesturePath->AddPosition(point1); - gesturePath->AddPosition(point2); - gesturePath->AddPosition(point3); - gesturePath->SetDurationTime(200); - - aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(1)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_LEFT) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_Left_003 end"; -} - -/** - * @tc.number: Left004 - * @tc.name:Left - * @tc.desc: Check that the injected LEFT gesture can be recognized in touchGuide. - */ -HWTEST_F(MockAamsInjectorTest, TouchEventInjector_ModuleTest_Left_004, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_Left_004 start"; - - AccessibilityHelper::GetInstance().GetEventType().clear(); - MMI::MockInputManager::ClearTouchActions(); - AccessibilityGesturePosition point1 {2500.0f, 2500.0f}; - AccessibilityGesturePosition point2 {1000.0f, 2500.0f}; - AccessibilityGesturePosition point3 {0.0f, 1000.0f}; - std::shared_ptr gesturePath = std::make_shared(); - gesturePath->AddPosition(point1); - gesturePath->AddPosition(point2); - gesturePath->AddPosition(point3); - gesturePath->SetDurationTime(200); - - aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(1)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_LEFT) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_Left_004 end"; -} - -/** - * @tc.number: Right001 - * @tc.name:Right - * @tc.desc: Check that the injected RIGHT gesture can be recognized in touchGuide. - */ -HWTEST_F(MockAamsInjectorTest, TouchEventInjector_ModuleTest_Right_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_Right_001 start"; - - AccessibilityHelper::GetInstance().GetEventType().clear(); - MMI::MockInputManager::ClearTouchActions(); - AccessibilityGesturePosition point1 {0.0f, 2500.0f}; - AccessibilityGesturePosition point2 {1000.0f, 2500.0f}; - AccessibilityGesturePosition point3 {2500.0f, 2500.0f}; - std::shared_ptr gesturePath = std::make_shared(); - gesturePath->AddPosition(point1); - gesturePath->AddPosition(point2); - gesturePath->AddPosition(point3); - gesturePath->SetDurationTime(200); - - aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(1)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_RIGHT) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_Right_001 end"; -} - -/** - * @tc.number: Right002 - * @tc.name:Right - * @tc.desc: Check that the injected RIGHT gesture can be recognized in touchGuide. - */ -HWTEST_F(MockAamsInjectorTest, TouchEventInjector_ModuleTest_Right_002, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_Right_002 start"; - - AccessibilityHelper::GetInstance().GetEventType().clear(); - MMI::MockInputManager::ClearTouchActions(); - AccessibilityGesturePosition point1 {0.0f, 2500.0f}; - AccessibilityGesturePosition point2 {1000.0f, 2500.0f}; - AccessibilityGesturePosition point3 {2500.0f, 2500.0f}; - std::shared_ptr gesturePath = std::make_shared(); - gesturePath->AddPosition(point1); - gesturePath->AddPosition(point2); - gesturePath->AddPosition(point3); - gesturePath->SetDurationTime(800); - - aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_HOVER_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(1)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_NE(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_RIGHT) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_Right_002 end"; -} - -/** - * @tc.number: Right003 - * @tc.name:Right - * @tc.desc: Check that the injected RIGHT gesture can be recognized in touchGuide. - */ -HWTEST_F(MockAamsInjectorTest, TouchEventInjector_ModuleTest_Right_003, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_Right_003 start"; - - AccessibilityHelper::GetInstance().GetEventType().clear(); - MMI::MockInputManager::ClearTouchActions(); - AccessibilityGesturePosition point1 {0.0f, 2500.0f}; - AccessibilityGesturePosition point2 {1000.0f, 2500.0f}; - AccessibilityGesturePosition point3 {2500.0f, 2300.0f}; - std::shared_ptr gesturePath = std::make_shared(); - gesturePath->AddPosition(point1); - gesturePath->AddPosition(point2); - gesturePath->AddPosition(point3); - gesturePath->SetDurationTime(200); - - aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(1)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_RIGHT) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_Right_003 end"; -} - -/** - * @tc.number: Right004 - * @tc.name:Right - * @tc.desc: Check that the injected RIGHT gesture can be recognized in touchGuide. - */ -HWTEST_F(MockAamsInjectorTest, TouchEventInjector_ModuleTest_Right_004, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_Right_004 start"; - - AccessibilityHelper::GetInstance().GetEventType().clear(); - MMI::MockInputManager::ClearTouchActions(); - AccessibilityGesturePosition point1 {0.0f, 2500.0f}; - AccessibilityGesturePosition point2 {1000.0f, 2500.0f}; - AccessibilityGesturePosition point3 {2500.0f, 1000.0f}; - std::shared_ptr gesturePath = std::make_shared(); - gesturePath->AddPosition(point1); - gesturePath->AddPosition(point2); - gesturePath->AddPosition(point3); - gesturePath->SetDurationTime(200); - - aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(1)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_RIGHT) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_Right_004 end"; -} - -/** - * @tc.number: Down001 - * @tc.name:Down - * @tc.desc: Check that the injected DOWN gesture can be recognized in touchGuide. - */ -HWTEST_F(MockAamsInjectorTest, TouchEventInjector_ModuleTest_Down_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_Down_001 start"; - - AccessibilityHelper::GetInstance().GetEventType().clear(); - MMI::MockInputManager::ClearTouchActions(); - AccessibilityGesturePosition point1 {1000.0f, 0.0f}; - AccessibilityGesturePosition point2 {1000.0f, 1000.0f}; - AccessibilityGesturePosition point3 {1000.0f, 2500.0f}; - std::shared_ptr gesturePath = std::make_shared(); - gesturePath->AddPosition(point1); - gesturePath->AddPosition(point2); - gesturePath->AddPosition(point3); - gesturePath->SetDurationTime(200); - - aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(1)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_DOWN) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_Down_001 end"; -} - -/** - * @tc.number: Down002 - * @tc.name:Down - * @tc.desc: Check that the injected LEFT gesture can be recognized in touchGuide. - */ -HWTEST_F(MockAamsInjectorTest, TouchEventInjector_ModuleTest_Down_002, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_Down_002 start"; - - AccessibilityHelper::GetInstance().GetEventType().clear(); - MMI::MockInputManager::ClearTouchActions(); - AccessibilityGesturePosition point1 {1000.0f, 0.0f}; - AccessibilityGesturePosition point2 {1000.0f, 1000.0f}; - AccessibilityGesturePosition point3 {1000.0f, 2500.0f}; - std::shared_ptr gesturePath = std::make_shared(); - gesturePath->AddPosition(point1); - gesturePath->AddPosition(point2); - gesturePath->AddPosition(point3); - gesturePath->SetDurationTime(800); - - aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_HOVER_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(1)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_NE(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_DOWN) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_Down_002 end"; -} - -/** - * @tc.number: Down003 - * @tc.name:Down - * @tc.desc: Check that the injected DOWN gesture can be recognized in touchGuide. - */ -HWTEST_F(MockAamsInjectorTest, TouchEventInjector_ModuleTest_Down_003, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_Down_003 start"; - - AccessibilityHelper::GetInstance().GetEventType().clear(); - MMI::MockInputManager::ClearTouchActions(); - AccessibilityGesturePosition point1 {1000.0f, 0.0f}; - AccessibilityGesturePosition point2 {1000.0f, 1000.0f}; - AccessibilityGesturePosition point3 {800.0f, 2500.0f}; - std::shared_ptr gesturePath = std::make_shared(); - gesturePath->AddPosition(point1); - gesturePath->AddPosition(point2); - gesturePath->AddPosition(point3); - gesturePath->SetDurationTime(200); - - aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(1)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_DOWN) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_Down_003 end"; -} - -/** - * @tc.number: Down004 - * @tc.name:Down - * @tc.desc: Check that the injected DOWN gesture can be recognized in touchGuide. - */ -HWTEST_F(MockAamsInjectorTest, TouchEventInjector_ModuleTest_Down_004, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_Down_004 start"; - - AccessibilityHelper::GetInstance().GetEventType().clear(); - MMI::MockInputManager::ClearTouchActions(); - AccessibilityGesturePosition point1 {1000.0f, 0.0f}; - AccessibilityGesturePosition point2 {1000.0f, 1000.0f}; - AccessibilityGesturePosition point3 {1500.0f, 2500.0f}; - std::shared_ptr gesturePath = std::make_shared(); - gesturePath->AddPosition(point1); - gesturePath->AddPosition(point2); - gesturePath->AddPosition(point3); - gesturePath->SetDurationTime(200); - - aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(1)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_DOWN) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_Down_004 end"; -} - -/** - * @tc.number: Up001 - * @tc.name:Up - * @tc.desc: Check that the injected UP gesture can be recognized in touchGuide. - */ -HWTEST_F(MockAamsInjectorTest, TouchEventInjector_ModuleTest_Up_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_Up_001 start"; - - AccessibilityHelper::GetInstance().GetEventType().clear(); - MMI::MockInputManager::ClearTouchActions(); - AccessibilityGesturePosition point1 {1000.0f, 2500.0f}; - AccessibilityGesturePosition point2 {1000.0f, 1000.0f}; - AccessibilityGesturePosition point3 {1000.0f, 0.0f}; - std::shared_ptr gesturePath = std::make_shared(); - gesturePath->AddPosition(point1); - gesturePath->AddPosition(point2); - gesturePath->AddPosition(point3); - gesturePath->SetDurationTime(200); - - aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(1)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_UP) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_Up_001 end"; -} - -/** - * @tc.number: Up002 - * @tc.name:Up - * @tc.desc: Check that the injected UP gesture can be recognized in touchGuide. - */ -HWTEST_F(MockAamsInjectorTest, TouchEventInjector_ModuleTest_Up_002, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_Up_002 start"; - - AccessibilityHelper::GetInstance().GetEventType().clear(); - MMI::MockInputManager::ClearTouchActions(); - AccessibilityGesturePosition point1 {1000.0f, 2500.0f}; - AccessibilityGesturePosition point2 {1000.0f, 1000.0f}; - AccessibilityGesturePosition point3 {1000.0f, 0.0f}; - std::shared_ptr gesturePath = std::make_shared(); - gesturePath->AddPosition(point1); - gesturePath->AddPosition(point2); - gesturePath->AddPosition(point3); - gesturePath->SetDurationTime(800); - - aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_HOVER_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(1)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_NE(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_UP) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_Up_002 end"; -} - -/** - * @tc.number: Up003 - * @tc.name:Up - * @tc.desc: Check that the injected UP gesture can be recognized in touchGuide. - */ -HWTEST_F(MockAamsInjectorTest, TouchEventInjector_ModuleTest_Up_003, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_Up_003 start"; - - AccessibilityHelper::GetInstance().GetEventType().clear(); - MMI::MockInputManager::ClearTouchActions(); - AccessibilityGesturePosition point1 {1000.0f, 2500.0f}; - AccessibilityGesturePosition point2 {1000.0f, 1000.0f}; - AccessibilityGesturePosition point3 {800.0f, 0.0f}; - std::shared_ptr gesturePath = std::make_shared(); - gesturePath->AddPosition(point1); - gesturePath->AddPosition(point2); - gesturePath->AddPosition(point3); - gesturePath->SetDurationTime(200); - - aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(1)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_UP) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_Up_003 end"; -} - -/** - * @tc.number: Up004 - * @tc.name:Up - * @tc.desc: Check that the injected UP gesture can be recognized in touchGuide. - */ -HWTEST_F(MockAamsInjectorTest, TouchEventInjector_ModuleTest_Up_004, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_Up_004 start"; - - AccessibilityHelper::GetInstance().GetEventType().clear(); - MMI::MockInputManager::ClearTouchActions(); - AccessibilityGesturePosition point1 {1000.0f, 2500.0f}; - AccessibilityGesturePosition point2 {1000.0f, 1000.0f}; - AccessibilityGesturePosition point3 {1500.0f, 0.0f}; - std::shared_ptr gesturePath = std::make_shared(); - gesturePath->AddPosition(point1); - gesturePath->AddPosition(point2); - gesturePath->AddPosition(point3); - gesturePath->SetDurationTime(200); - - aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(1)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_UP) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_Up_004 end"; -} - -/** - * @tc.number: RightThenUp001 - * @tc.name:RightThenUp - * @tc.desc: Check that the injected RIGHT_THEN_UP gesture can be recognized in touchGuide. - */ -HWTEST_F(MockAamsInjectorTest, TouchEventInjector_ModuleTest_RightThenUp_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_RightThenUp_001 start"; - - AccessibilityHelper::GetInstance().GetEventType().clear(); - MMI::MockInputManager::ClearTouchActions(); - AccessibilityGesturePosition point1 {2500.0f, 2500.0f}; - AccessibilityGesturePosition point2 {3500.0f, 2500.0f}; - AccessibilityGesturePosition point3 {5000.0f, 2500.0f}; - AccessibilityGesturePosition point4 {4000.0f, 0.0f}; - std::shared_ptr gesturePath = std::make_shared(); - gesturePath->AddPosition(point1); - gesturePath->AddPosition(point2); - gesturePath->AddPosition(point3); - gesturePath->AddPosition(point4); - gesturePath->SetDurationTime(800); - - aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(2)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(1)); - - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_RIGHT_THEN_UP) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_RightThenUp_001 end"; -} - -/** - * @tc.number: RightThenUp002 - * @tc.name:RightThenUp - * @tc.desc: Check that the injected RIGHT_THEN_UP gesture can be recognized in touchGuide. - */ -HWTEST_F(MockAamsInjectorTest, TouchEventInjector_ModuleTest_RightThenUp_002, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_RightThenUp_002 start"; - - AccessibilityHelper::GetInstance().GetEventType().clear(); - MMI::MockInputManager::ClearTouchActions(); - AccessibilityGesturePosition point1 {2500.0f, 2500.0f}; - AccessibilityGesturePosition point2 {3500.0f, 2500.0f}; - AccessibilityGesturePosition point3 {5000.0f, 2500.0f}; - AccessibilityGesturePosition point4 {5000.0f, 0.0f}; - std::shared_ptr gesturePath = std::make_shared(); - gesturePath->AddPosition(point1); - gesturePath->AddPosition(point2); - gesturePath->AddPosition(point3); - gesturePath->AddPosition(point4); - gesturePath->SetDurationTime(300); - - aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(2)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(1)); - - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_RIGHT_THEN_UP) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_FALSE(ret); - - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_RightThenUp_002 end"; -} - -/** - * @tc.number: RightThenUp003 - * @tc.name:RightThenUp - * @tc.desc: Check that the injected RIGHT_THEN_UP gesture can be recognized in touchGuide. - */ -HWTEST_F(MockAamsInjectorTest, TouchEventInjector_ModuleTest_RightThenUp_003, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_RightThenUp_003 start"; - - AccessibilityHelper::GetInstance().GetEventType().clear(); - MMI::MockInputManager::ClearTouchActions(); - AccessibilityGesturePosition point1 {2500.0f, 2500.0f}; - AccessibilityGesturePosition point2 {3500.0f, 2500.0f}; - AccessibilityGesturePosition point3 {5000.0f, 2500.0f}; - AccessibilityGesturePosition point4 {6000.0f, 0.0f}; - std::shared_ptr gesturePath = std::make_shared(); - gesturePath->AddPosition(point1); - gesturePath->AddPosition(point2); - gesturePath->AddPosition(point3); - gesturePath->AddPosition(point4); - gesturePath->SetDurationTime(300); - - aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(2)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(1)); - - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_RIGHT_THEN_UP) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_FALSE(ret); - - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_RightThenUp_003 end"; -} - -/** - * @tc.number: RightThenUp004 - * @tc.name:RightThenUp - * @tc.desc: Check that the injected RIGHT_THEN_UP gesture can be recognized in touchGuide. - */ -HWTEST_F(MockAamsInjectorTest, TouchEventInjector_ModuleTest_RightThenUp_004, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_RightThenUp_004 start"; - - AccessibilityHelper::GetInstance().GetEventType().clear(); - MMI::MockInputManager::ClearTouchActions(); - AccessibilityGesturePosition point1 {2500.0f, 2500.0f}; - AccessibilityGesturePosition point2 {3500.0f, 2500.0f}; - AccessibilityGesturePosition point3 {5000.0f, 2500.0f}; - AccessibilityGesturePosition point4 {8000.0f, 0.0f}; - std::shared_ptr gesturePath = std::make_shared(); - gesturePath->AddPosition(point1); - gesturePath->AddPosition(point2); - gesturePath->AddPosition(point3); - gesturePath->AddPosition(point4); - gesturePath->SetDurationTime(300); - - aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(2)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(1)); - - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_RIGHT_THEN_UP) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_FALSE(ret); - - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_RightThenUp_004 end"; -} - -/** - * @tc.number: RightThenDown001 - * @tc.name:RightThenDown - * @tc.desc: Check that the injected RIGHT_THEN_DOWN gesture can be recognized in touchGuide. - */ -HWTEST_F(MockAamsInjectorTest, TouchEventInjector_ModuleTest_RightThenDown_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_RightThenDown_001 start"; - - AccessibilityHelper::GetInstance().GetEventType().clear(); - MMI::MockInputManager::ClearTouchActions(); - AccessibilityGesturePosition point1 {2500.0f, 0.0f}; - AccessibilityGesturePosition point2 {3500.0f, 0.0f}; - AccessibilityGesturePosition point3 {5000.0f, 0.0f}; - AccessibilityGesturePosition point4 {4000.0f, 2500.0f}; - std::shared_ptr gesturePath = std::make_shared(); - gesturePath->AddPosition(point1); - gesturePath->AddPosition(point2); - gesturePath->AddPosition(point3); - gesturePath->AddPosition(point4); - gesturePath->SetDurationTime(800); - - aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(2)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(1)); - - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_RIGHT_THEN_DOWN) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_RightThenDown_001 end"; -} - -/** - * @tc.number: RightThenDown002 - * @tc.name:RightThenDown - * @tc.desc: Check that the injected RIGHT_THEN_DOWN gesture can be recognized in touchGuide. - */ -HWTEST_F(MockAamsInjectorTest, TouchEventInjector_ModuleTest_RightThenDown_002, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_RightThenDown_002 start"; - - AccessibilityHelper::GetInstance().GetEventType().clear(); - MMI::MockInputManager::ClearTouchActions(); - AccessibilityGesturePosition point1 {2500.0f, 0.0f}; - AccessibilityGesturePosition point2 {3500.0f, 0.0f}; - AccessibilityGesturePosition point3 {5000.0f, 0.0f}; - AccessibilityGesturePosition point4 {5000.0f, 2500.0f}; - std::shared_ptr gesturePath = std::make_shared(); - gesturePath->AddPosition(point1); - gesturePath->AddPosition(point2); - gesturePath->AddPosition(point3); - gesturePath->AddPosition(point4); - gesturePath->SetDurationTime(300); - - aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(2)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(1)); - - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_RIGHT_THEN_DOWN) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_FALSE(ret); - - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_RightThenDown_002 end"; -} - -/** - * @tc.number: RightThenDown003 - * @tc.name:RightThenDown - * @tc.desc: Check that the injected RIGHT_THEN_DOWN gesture can be recognized in touchGuide. - */ -HWTEST_F(MockAamsInjectorTest, TouchEventInjector_ModuleTest_RightThenDown_003, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_RightThenDown_003 start"; - - AccessibilityHelper::GetInstance().GetEventType().clear(); - MMI::MockInputManager::ClearTouchActions(); - AccessibilityGesturePosition point1 {2500.0f, 0.0f}; - AccessibilityGesturePosition point2 {3500.0f, 0.0f}; - AccessibilityGesturePosition point3 {5000.0f, 0.0f}; - AccessibilityGesturePosition point4 {6000.0f, 2500.0f}; - std::shared_ptr gesturePath = std::make_shared(); - gesturePath->AddPosition(point1); - gesturePath->AddPosition(point2); - gesturePath->AddPosition(point3); - gesturePath->AddPosition(point4); - gesturePath->SetDurationTime(300); - - aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(2)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(1)); - - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_RIGHT_THEN_DOWN) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_FALSE(ret); - - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_RightThenDown_003 end"; -} - -/** - * @tc.number: RightThenDown004 - * @tc.name:RightThenDown - * @tc.desc: Check that the injected RIGHT_THEN_DOWN gesture can be recognized in touchGuide. - */ -HWTEST_F(MockAamsInjectorTest, TouchEventInjector_ModuleTest_RightThenDown_004, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_RightThenDown_004 start"; - - AccessibilityHelper::GetInstance().GetEventType().clear(); - MMI::MockInputManager::ClearTouchActions(); - AccessibilityGesturePosition point1 {2500.0f, 0.0f}; - AccessibilityGesturePosition point2 {3500.0f, 0.0f}; - AccessibilityGesturePosition point3 {5000.0f, 0.0f}; - AccessibilityGesturePosition point4 {8000.0f, 2500.0f}; - std::shared_ptr gesturePath = std::make_shared(); - gesturePath->AddPosition(point1); - gesturePath->AddPosition(point2); - gesturePath->AddPosition(point3); - gesturePath->AddPosition(point4); - gesturePath->SetDurationTime(300); - - aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(2)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(1)); - - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_RIGHT_THEN_DOWN) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_FALSE(ret); - - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_RightThenDown_004 end"; -} - -/** - * @tc.number: LeftThenUp001 - * @tc.name:LeftThenUp - * @tc.desc: Check that the injected LEFT_THEN_UP gesture can be recognized in touchGuide. - */ -HWTEST_F(MockAamsInjectorTest, TouchEventInjector_ModuleTest_LeftThenUp_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_LeftThenUp_001 start"; - - AccessibilityHelper::GetInstance().GetEventType().clear(); - MMI::MockInputManager::ClearTouchActions(); - AccessibilityGesturePosition point1 {2500.0f, 2500.0f}; - AccessibilityGesturePosition point2 {1500.0f, 2500.0f}; - AccessibilityGesturePosition point3 {0.0f, 2500.0f}; - AccessibilityGesturePosition point4 {0.0f, 0.0f}; - std::shared_ptr gesturePath = std::make_shared(); - gesturePath->AddPosition(point1); - gesturePath->AddPosition(point2); - gesturePath->AddPosition(point3); - gesturePath->AddPosition(point4); - gesturePath->SetDurationTime(300); - - aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(2)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(1)); - - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_LEFT_THEN_UP) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_FALSE(ret); - - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_LeftThenUp_001 end"; -} - -/** - * @tc.number: LeftThenUp002 - * @tc.name:LeftThenUp - * @tc.desc: Check that the injected LEFT_THEN_UP gesture can be recognized in touchGuide. - */ -HWTEST_F(MockAamsInjectorTest, TouchEventInjector_ModuleTest_LeftThenUp_002, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_LeftThenUp_002 start"; - - AccessibilityHelper::GetInstance().GetEventType().clear(); - MMI::MockInputManager::ClearTouchActions(); - AccessibilityGesturePosition point1 {2500.0f, 2500.0f}; - AccessibilityGesturePosition point2 {1500.0f, 2500.0f}; - AccessibilityGesturePosition point3 {0.0f, 2500.0f}; - AccessibilityGesturePosition point4 {1000.0f, 0.0f}; - std::shared_ptr gesturePath = std::make_shared(); - gesturePath->AddPosition(point1); - gesturePath->AddPosition(point2); - gesturePath->AddPosition(point3); - gesturePath->AddPosition(point4); - gesturePath->SetDurationTime(300); - - aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(2)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(1)); - - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_LEFT_THEN_UP) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_LeftThenUp_002 end"; -} - -/** - * @tc.number: LeftThenUp003 - * @tc.name:LeftThenUp - * @tc.desc: Check that the injected LEFT_THEN_UP gesture can be recognized in touchGuide. - */ -HWTEST_F(MockAamsInjectorTest, TouchEventInjector_ModuleTest_LeftThenUp_003, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_LeftThenUp_003 start"; - - AccessibilityHelper::GetInstance().GetEventType().clear(); - MMI::MockInputManager::ClearTouchActions(); - AccessibilityGesturePosition point1 {2500.0f, 2500.0f}; - AccessibilityGesturePosition point2 {1500.0f, 2500.0f}; - AccessibilityGesturePosition point3 {0.0f, 2500.0f}; - AccessibilityGesturePosition point4 {2000.0f, 0.0f}; - std::shared_ptr gesturePath = std::make_shared(); - gesturePath->AddPosition(point1); - gesturePath->AddPosition(point2); - gesturePath->AddPosition(point3); - gesturePath->AddPosition(point4); - gesturePath->SetDurationTime(300); - - aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(2)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(1)); - - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_LEFT_THEN_UP) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_LeftThenUp_003 end"; -} - -/** - * @tc.number: LeftThenUp004 - * @tc.name: LeftThenUp - * @tc.desc: Check that the injected LEFT_THEN_UP gesture can be recognized in touchGuide. - */ -HWTEST_F(MockAamsInjectorTest, TouchEventInjector_ModuleTest_LeftThenUp_004, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_LeftThenUp_004 start"; - - AccessibilityHelper::GetInstance().GetEventType().clear(); - MMI::MockInputManager::ClearTouchActions(); - AccessibilityGesturePosition point1 {2500.0f, 2500.0f}; - AccessibilityGesturePosition point2 {1500.0f, 2500.0f}; - AccessibilityGesturePosition point3 {0.0f, 2500.0f}; - AccessibilityGesturePosition point4 {1000.0f, 0.0f}; - std::shared_ptr gesturePath = std::make_shared(); - gesturePath->AddPosition(point1); - gesturePath->AddPosition(point2); - gesturePath->AddPosition(point3); - gesturePath->AddPosition(point4); - gesturePath->SetDurationTime(800); - - aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(2)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(1)); - - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_LEFT_THEN_UP) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_LeftThenUp_004 end"; -} - -/** - * @tc.number: LeftThenDown001 - * @tc.name:LeftThenDown - * @tc.desc: Check that the injected LEFT_THEN_DWN gesture can be recognized in touchGuide. - */ -HWTEST_F(MockAamsInjectorTest, TouchEventInjector_ModuleTest_LeftThenDown_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_LeftThenDown_001 start"; - - AccessibilityHelper::GetInstance().GetEventType().clear(); - MMI::MockInputManager::ClearTouchActions(); - AccessibilityGesturePosition point1 {2500.0f, 0.0f}; - AccessibilityGesturePosition point2 {1500.0f, 0.0f}; - AccessibilityGesturePosition point3 {0.0f, 0.0f}; - AccessibilityGesturePosition point4 {0.0f, 2500.0f}; - std::shared_ptr gesturePath = std::make_shared(); - gesturePath->AddPosition(point1); - gesturePath->AddPosition(point2); - gesturePath->AddPosition(point3); - gesturePath->AddPosition(point4); - gesturePath->SetDurationTime(300); - - aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(2)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(1)); - - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_LEFT_THEN_DOWN) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_FALSE(ret); - - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_LeftThenDown_001 end"; -} - -/** - * @tc.number: LeftThenDown002 - * @tc.name:LeftThenDown - * @tc.desc: Check that the injected LEFT_THEN_DOWN gesture can be recognized in touchGuide. - */ -HWTEST_F(MockAamsInjectorTest, TouchEventInjector_ModuleTest_LeftThenDown_002, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_LeftThenDown_002 start"; - - AccessibilityHelper::GetInstance().GetEventType().clear(); - MMI::MockInputManager::ClearTouchActions(); - AccessibilityGesturePosition point1 {2500.0f, 0.0f}; - AccessibilityGesturePosition point2 {1500.0f, 0.0f}; - AccessibilityGesturePosition point3 {0.0f, 0.0f}; - AccessibilityGesturePosition point4 {1000.0f, 2500.0f}; - std::shared_ptr gesturePath = std::make_shared(); - gesturePath->AddPosition(point1); - gesturePath->AddPosition(point2); - gesturePath->AddPosition(point3); - gesturePath->AddPosition(point4); - gesturePath->SetDurationTime(300); - - aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(2)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(1)); - - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_LEFT_THEN_DOWN) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_LeftThenDown_002 end"; -} - -/** - * @tc.number: LeftThenDown003 - * @tc.name:LeftThenDown - * @tc.desc: Check that the injected LEFT_THEN_DOWN gesture can be recognized in touchGuide. - */ -HWTEST_F(MockAamsInjectorTest, TouchEventInjector_ModuleTest_LeftThenDown_003, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_LeftThenDown_003 start"; - - AccessibilityHelper::GetInstance().GetEventType().clear(); - MMI::MockInputManager::ClearTouchActions(); - AccessibilityGesturePosition point1 {2500.0f, 0.0f}; - AccessibilityGesturePosition point2 {1500.0f, 0.0f}; - AccessibilityGesturePosition point3 {0.0f, 0.0f}; - AccessibilityGesturePosition point4 {2000.0f, 2500.0f}; - std::shared_ptr gesturePath = std::make_shared(); - gesturePath->AddPosition(point1); - gesturePath->AddPosition(point2); - gesturePath->AddPosition(point3); - gesturePath->AddPosition(point4); - gesturePath->SetDurationTime(300); - - aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(2)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(1)); - - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_LEFT_THEN_DOWN) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_LeftThenDown_003 end"; -} - -/** - * @tc.number: LeftThenDown004 - * @tc.name:LeftThenDown - * @tc.desc: Check that the injected LEFT_THEN_DOWN gesture can be recognized in touchGuide. - */ -HWTEST_F(MockAamsInjectorTest, TouchEventInjector_ModuleTest_LeftThenDown_004, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_LeftThenDown_004 start"; - - AccessibilityHelper::GetInstance().GetEventType().clear(); - MMI::MockInputManager::ClearTouchActions(); - AccessibilityGesturePosition point1 {2500.0f, 0.0f}; - AccessibilityGesturePosition point2 {1500.0f, 0.0f}; - AccessibilityGesturePosition point3 {0.0f, 0.0f}; - AccessibilityGesturePosition point4 {1000.0f, 2500.0f}; - std::shared_ptr gesturePath = std::make_shared(); - gesturePath->AddPosition(point1); - gesturePath->AddPosition(point2); - gesturePath->AddPosition(point3); - gesturePath->AddPosition(point4); - gesturePath->SetDurationTime(800); - - aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(2)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(1)); - - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_LEFT_THEN_DOWN) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_LeftThenDown_004 end"; -} - -/** - * @tc.number: DownThenLeft001 - * @tc.name:DownThenLeft - * @tc.desc: Check that the injected DOWN_THEN_LEFT gesture can be recognized in touchGuide. - */ -HWTEST_F(MockAamsInjectorTest, TouchEventInjector_ModuleTest_DownThenLeft_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_DownThenLeft_001 start"; - - AccessibilityHelper::GetInstance().GetEventType().clear(); - MMI::MockInputManager::ClearTouchActions(); - AccessibilityGesturePosition point1 {2500.0f, 2500.0f}; - AccessibilityGesturePosition point2 {2500.0f, 3500.0f}; - AccessibilityGesturePosition point3 {2500.0f, 5000.0f}; - AccessibilityGesturePosition point4 {0.0f, 5000.0f}; - std::shared_ptr gesturePath = std::make_shared(); - gesturePath->AddPosition(point1); - gesturePath->AddPosition(point2); - gesturePath->AddPosition(point3); - gesturePath->AddPosition(point4); - gesturePath->SetDurationTime(300); - - aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(2)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(1)); - - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_DOWN_THEN_LEFT) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_FALSE(ret); - - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_DownThenLeft_001 end"; -} - -/** - * @tc.number: DownThenLeft002 - * @tc.name:DownThenLeft - * @tc.desc: Check that the injected DOWN_THEN_LEFT gesture can be recognized in touchGuide. - */ -HWTEST_F(MockAamsInjectorTest, TouchEventInjector_ModuleTest_DownThenLeft_002, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_DownThenLeft_002 start"; - - AccessibilityHelper::GetInstance().GetEventType().clear(); - MMI::MockInputManager::ClearTouchActions(); - AccessibilityGesturePosition point1 {2500.0f, 2500.0f}; - AccessibilityGesturePosition point2 {2500.0f, 3500.0f}; - AccessibilityGesturePosition point3 {2500.0f, 5000.0f}; - AccessibilityGesturePosition point4 {0.0f, 4000.0f}; - std::shared_ptr gesturePath = std::make_shared(); - gesturePath->AddPosition(point1); - gesturePath->AddPosition(point2); - gesturePath->AddPosition(point3); - gesturePath->AddPosition(point4); - gesturePath->SetDurationTime(300); - - aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(2)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(1)); - - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_DOWN_THEN_LEFT) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_DownThenLeft_002 end"; -} - -/** - * @tc.number: DownThenLeft003 - * @tc.name:DownThenLeft - * @tc.desc: Check that the injected DOWN_THEN_LEFT gesture can be recognized in touchGuide. - */ -HWTEST_F(MockAamsInjectorTest, TouchEventInjector_ModuleTest_DownThenLeft_003, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_DownThenLeft_003 start"; - - AccessibilityHelper::GetInstance().GetEventType().clear(); - MMI::MockInputManager::ClearTouchActions(); - AccessibilityGesturePosition point1 {2500.0f, 2500.0f}; - AccessibilityGesturePosition point2 {2500.0f, 3500.0f}; - AccessibilityGesturePosition point3 {2500.0f, 5000.0f}; - AccessibilityGesturePosition point4 {0.0f, 6000.0f}; - std::shared_ptr gesturePath = std::make_shared(); - gesturePath->AddPosition(point1); - gesturePath->AddPosition(point2); - gesturePath->AddPosition(point3); - gesturePath->AddPosition(point4); - gesturePath->SetDurationTime(300); - - aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(2)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(1)); - - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_DOWN_THEN_LEFT) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_FALSE(ret); - - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_DownThenLeft_003 end"; -} - -/** - * @tc.number: DownThenLeft004 - * @tc.name:DownThenLeft - * @tc.desc: Check that the injected DOWN_THEN_LEFT gesture can be recognized in touchGuide. - */ -HWTEST_F(MockAamsInjectorTest, TouchEventInjector_ModuleTest_DownThenLeft_004, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_DownThenLeft_004 start"; - - AccessibilityHelper::GetInstance().GetEventType().clear(); - MMI::MockInputManager::ClearTouchActions(); - AccessibilityGesturePosition point1 {2500.0f, 2500.0f}; - AccessibilityGesturePosition point2 {2500.0f, 3500.0f}; - AccessibilityGesturePosition point3 {2500.0f, 5000.0f}; - AccessibilityGesturePosition point4 {0.0f, 8000.0f}; - std::shared_ptr gesturePath = std::make_shared(); - gesturePath->AddPosition(point1); - gesturePath->AddPosition(point2); - gesturePath->AddPosition(point3); - gesturePath->AddPosition(point4); - gesturePath->SetDurationTime(300); - - aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(2)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(1)); - - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_DOWN_THEN_LEFT) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_FALSE(ret); - - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_DownThenLeft_004 end"; -} - -/** - * @tc.number: DownThenLeft005 - * @tc.name:DownThenLeft - * @tc.desc: Check that the injected DOWN_THEN_LEFT gesture can be recognized in touchGuide. - */ -HWTEST_F(MockAamsInjectorTest, TouchEventInjector_ModuleTest_DownThenLeft_005, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_DownThenLeft_005 start"; - - AccessibilityHelper::GetInstance().GetEventType().clear(); - MMI::MockInputManager::ClearTouchActions(); - AccessibilityGesturePosition point1 {2500.0f, 2500.0f}; - AccessibilityGesturePosition point2 {2500.0f, 3500.0f}; - AccessibilityGesturePosition point3 {2500.0f, 5000.0f}; - AccessibilityGesturePosition point4 {0.0f, 5000.0f}; - std::shared_ptr gesturePath = std::make_shared(); - gesturePath->AddPosition(point1); - gesturePath->AddPosition(point2); - gesturePath->AddPosition(point3); - gesturePath->AddPosition(point4); - gesturePath->SetDurationTime(800); - - aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(2)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(1)); - - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_DOWN_THEN_LEFT) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_FALSE(ret); - - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_DownThenLeft_005 end"; -} -} // namespace Accessibility -} // namespace OHOS \ No newline at end of file diff --git a/services/test/mock/mock_display.cpp b/services/test/mock/mock_display.cpp index dd79ff1f..31936105 100644 --- a/services/test/mock/mock_display.cpp +++ b/services/test/mock/mock_display.cpp @@ -14,7 +14,7 @@ */ #include "display.h" -#include "window/window_manager/utils/include/display_info.h" +#include "display_info.h" namespace OHOS::Rosen { namespace { diff --git a/services/test/mock/mock_display_manager.cpp b/services/test/mock/mock_display_manager.cpp index 214bd639..06bcc135 100644 --- a/services/test/mock/mock_display_manager.cpp +++ b/services/test/mock/mock_display_manager.cpp @@ -18,7 +18,7 @@ #include "display.h" #include "dm_common.h" #include "singleton_delegator.h" -#include "window/window_manager/utils/include/display_info.h" +#include "display_info.h" namespace OHOS::Rosen { WM_IMPLEMENT_SINGLE_INSTANCE(DisplayManager) diff --git a/services/test/moduletest/aamstest/aams_accessibility_touchEvent_injector_test/aams_accessibility_touchEvent_injector_test.cpp b/services/test/moduletest/aamstest/aams_accessibility_touchEvent_injector_test/aams_accessibility_touchEvent_injector_test.cpp index d1e6140a..69246fda 100644 --- a/services/test/moduletest/aamstest/aams_accessibility_touchEvent_injector_test/aams_accessibility_touchEvent_injector_test.cpp +++ b/services/test/moduletest/aamstest/aams_accessibility_touchEvent_injector_test/aams_accessibility_touchEvent_injector_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 Huawei Device Co., Ltd. + * Copyright (C) 2022-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -19,7 +19,7 @@ #include "accessibility_element_operator_stub.h" #include "accessibility_input_interceptor.h" #include "accessibility_mt_helper.h" -#include "accessibility_touch_guider.h" +#include "accessibility_touch_exploration.h" #include "accessibility_touchEvent_injector.h" #include "accessibility_window_manager.h" #include "accessible_ability_channel.h" @@ -154,27 +154,14 @@ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_SingleTap_001, TestSize gesturePath->AddPosition(point); gesturePath->SetDurationTime(100); aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(1)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(!ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_HOVER_ENTER, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (EventType::TYPE_TOUCH_GUIDE_END == AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); + sleep(1); + + EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_HOVER_ENTER, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); + EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_HOVER_EXIT, MMI::MockInputManager::GetTouchActionOfTargetIndex(1)); + EXPECT_EQ(EventType::TYPE_TOUCH_BEGIN, AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0)); EXPECT_EQ(EventType::TYPE_TOUCH_END, AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1)); - EXPECT_EQ(EventType::TYPE_TOUCH_GUIDE_BEGIN, AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2)); GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_SingleTap_001 end"; } @@ -195,72 +182,18 @@ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_SingleTap_002, TestSize gesturePath->AddPosition(point); gesturePath->SetDurationTime(300); aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(1)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(!ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_HOVER_ENTER, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (EventType::TYPE_TOUCH_GUIDE_END == AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); + sleep(1); + + EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_HOVER_ENTER, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); + EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_HOVER_EXIT, MMI::MockInputManager::GetTouchActionOfTargetIndex(1)); + EXPECT_EQ(EventType::TYPE_TOUCH_BEGIN, AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0)); EXPECT_EQ(EventType::TYPE_TOUCH_END, AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1)); - EXPECT_EQ(EventType::TYPE_TOUCH_GUIDE_BEGIN, AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2)); GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_SingleTap_002 end"; } -/** - * @tc.number: SingleTap003 - * @tc.name:SingleTap - * @tc.desc: Check that the injected single-tap event can be recognized in touchGuide. - */ -HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_SingleTap_003, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_SingleTap_003 start"; - - AccessibilityHelper::GetInstance().GetEventType().clear(); - MMI::MockInputManager::ClearTouchActions(); - AccessibilityGesturePosition point {500.0f, 500.0f}; - std::shared_ptr gesturePath = std::make_shared(); - gesturePath->AddPosition(point); - gesturePath->SetDurationTime(1000); - aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(1)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(!ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_HOVER_ENTER, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (EventType::TYPE_TOUCH_GUIDE_END == AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(EventType::TYPE_TOUCH_BEGIN, AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0)); - EXPECT_EQ(EventType::TYPE_TOUCH_GUIDE_BEGIN, AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1)); - EXPECT_EQ(EventType::TYPE_TOUCH_END, AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2)); - - GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_SingleTap_003 end"; -} - /** * @tc.number: Left001 * @tc.name:Left @@ -282,25 +215,11 @@ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_Left_001, TestSize.Leve gesturePath->SetDurationTime(200); aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(1)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); + + sleep(1); + + EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), static_cast(GestureType::GESTURE_SWIPE_LEFT)); - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_LEFT) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_Left_001 end"; } @@ -325,25 +244,11 @@ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_Left_002, TestSize.Leve gesturePath->SetDurationTime(800); aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(1)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(!ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_HOVER_ENTER, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); + + sleep(1); + + EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), static_cast(GestureType::GESTURE_SWIPE_LEFT)); - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_LEFT) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_Left_002 end"; } @@ -368,25 +273,11 @@ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_Left_003, TestSize.Leve gesturePath->SetDurationTime(200); aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(1)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_LEFT) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); + sleep(1); + + EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), static_cast(GestureType::GESTURE_SWIPE_LEFT)); + GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_Left_003 end"; } @@ -411,25 +302,11 @@ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_Left_004, TestSize.Leve gesturePath->SetDurationTime(200); aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(1)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_LEFT) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); + sleep(1); + + EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), static_cast(GestureType::GESTURE_SWIPE_LEFT)); + GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_Left_004 end"; } @@ -454,25 +331,12 @@ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_Right_001, TestSize.Lev gesturePath->SetDurationTime(200); aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(1)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_RIGHT) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); + sleep(1); + + EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), + static_cast(GestureType::GESTURE_SWIPE_RIGHT)); + GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_Right_001 end"; } @@ -497,25 +361,12 @@ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_Right_002, TestSize.Lev gesturePath->SetDurationTime(800); aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_HOVER_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(1)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_NE(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); + + sleep(1); + + EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), + static_cast(GestureType::GESTURE_SWIPE_RIGHT)); - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_RIGHT) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_Right_002 end"; } @@ -540,25 +391,12 @@ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_Right_003, TestSize.Lev gesturePath->SetDurationTime(200); aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(1)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_RIGHT) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); + sleep(1); + + EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), + static_cast(GestureType::GESTURE_SWIPE_RIGHT)); + GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_Right_003 end"; } @@ -583,25 +421,12 @@ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_Right_004, TestSize.Lev gesturePath->SetDurationTime(200); aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(1)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); + + sleep(1); + + EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), + static_cast(GestureType::GESTURE_SWIPE_RIGHT)); - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_RIGHT) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_Right_004 end"; } @@ -626,32 +451,18 @@ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_Down_001, TestSize.Leve gesturePath->SetDurationTime(200); aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(1)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_DOWN) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); + sleep(1); + + EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), static_cast(GestureType::GESTURE_SWIPE_DOWN)); + GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_Down_001 end"; } /** * @tc.number: Down002 * @tc.name:Down - * @tc.desc: Check that the injected LEFT gesture can be recognized in touchGuide. + * @tc.desc: Check that the injected DOWN gesture can be recognized in touchGuide. */ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_Down_002, TestSize.Level1) { @@ -669,25 +480,11 @@ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_Down_002, TestSize.Leve gesturePath->SetDurationTime(800); aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_HOVER_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(1)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_NE(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_DOWN) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); + sleep(1); + + EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), static_cast(GestureType::GESTURE_SWIPE_DOWN)); + GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_Down_002 end"; } @@ -712,25 +509,11 @@ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_Down_003, TestSize.Leve gesturePath->SetDurationTime(200); aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(1)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); + + sleep(1); + + EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), static_cast(GestureType::GESTURE_SWIPE_DOWN)); - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_DOWN) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_Down_003 end"; } @@ -755,25 +538,11 @@ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_Down_004, TestSize.Leve gesturePath->SetDurationTime(200); aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(1)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_DOWN) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); + sleep(1); + + EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), static_cast(GestureType::GESTURE_SWIPE_DOWN)); + GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_Down_004 end"; } @@ -798,25 +567,11 @@ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_Up_001, TestSize.Level1 gesturePath->SetDurationTime(200); aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(1)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); + + sleep(1); + + EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), static_cast(GestureType::GESTURE_SWIPE_UP)); - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_UP) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_Up_001 end"; } @@ -841,25 +596,11 @@ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_Up_002, TestSize.Level1 gesturePath->SetDurationTime(800); aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_HOVER_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(1)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_NE(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_UP) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); + sleep(1); + + EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), static_cast(GestureType::GESTURE_SWIPE_UP)); + GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_Up_002 end"; } @@ -884,25 +625,11 @@ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_Up_003, TestSize.Level1 gesturePath->SetDurationTime(200); aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(1)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_UP) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); + sleep(1); + + EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), static_cast(GestureType::GESTURE_SWIPE_UP)); + GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_Up_003 end"; } @@ -927,25 +654,11 @@ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_Up_004, TestSize.Level1 gesturePath->SetDurationTime(200); aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(1)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_UP) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); + sleep(1); + + EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), static_cast(GestureType::GESTURE_SWIPE_UP)); + GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_Up_004 end"; } @@ -972,26 +685,11 @@ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_RightThenUp_001, TestSi gesturePath->SetDurationTime(800); aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(2)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(1)); - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_RIGHT_THEN_UP) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); + sleep(1); + + EXPECT_NE(AccessibilityHelper::GetInstance().GetGestureId(), + static_cast(GestureType::GESTURE_SWIPE_RIGHT_THEN_UP)); GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_RightThenUp_001 end"; } @@ -1019,26 +717,11 @@ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_RightThenUp_002, TestSi gesturePath->SetDurationTime(300); aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(2)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(1)); - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_RIGHT_THEN_UP) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_FALSE(ret); + sleep(1); + + EXPECT_NE(AccessibilityHelper::GetInstance().GetGestureId(), + static_cast(GestureType::GESTURE_SWIPE_RIGHT_THEN_UP)); GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_RightThenUp_002 end"; } @@ -1053,7 +736,6 @@ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_RightThenUp_003, TestSi GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_RightThenUp_003 start"; AccessibilityHelper::GetInstance().GetEventType().clear(); - MMI::MockInputManager::ClearTouchActions(); AccessibilityGesturePosition point1 {2500.0f, 2500.0f}; AccessibilityGesturePosition point2 {3500.0f, 2500.0f}; AccessibilityGesturePosition point3 {5000.0f, 2500.0f}; @@ -1066,26 +748,11 @@ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_RightThenUp_003, TestSi gesturePath->SetDurationTime(300); aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(2)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(1)); - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_RIGHT_THEN_UP) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_FALSE(ret); + sleep(1); + + EXPECT_NE(AccessibilityHelper::GetInstance().GetGestureId(), + static_cast(GestureType::GESTURE_SWIPE_RIGHT_THEN_UP)); GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_RightThenUp_003 end"; } @@ -1113,26 +780,11 @@ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_RightThenUp_004, TestSi gesturePath->SetDurationTime(300); aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(2)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(1)); - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_RIGHT_THEN_UP) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_FALSE(ret); + sleep(1); + + EXPECT_NE(AccessibilityHelper::GetInstance().GetGestureId(), + static_cast(GestureType::GESTURE_SWIPE_RIGHT_THEN_UP)); GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_RightThenUp_004 end"; } @@ -1160,26 +812,11 @@ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_RightThenDown_001, Test gesturePath->SetDurationTime(800); aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(2)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(1)); - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_RIGHT_THEN_DOWN) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); + sleep(1); + + EXPECT_NE(AccessibilityHelper::GetInstance().GetGestureId(), + static_cast(GestureType::GESTURE_SWIPE_RIGHT_THEN_DOWN)); GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_RightThenDown_001 end"; } @@ -1207,26 +844,11 @@ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_RightThenDown_002, Test gesturePath->SetDurationTime(300); aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(2)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(1)); - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_RIGHT_THEN_DOWN) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_FALSE(ret); + sleep(1); + + EXPECT_NE(AccessibilityHelper::GetInstance().GetGestureId(), + static_cast(GestureType::GESTURE_SWIPE_RIGHT_THEN_DOWN)); GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_RightThenDown_002 end"; } @@ -1254,26 +876,11 @@ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_RightThenDown_003, Test gesturePath->SetDurationTime(300); aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(2)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(1)); - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_RIGHT_THEN_DOWN) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_FALSE(ret); + sleep(1); + + EXPECT_NE(AccessibilityHelper::GetInstance().GetGestureId(), + static_cast(GestureType::GESTURE_SWIPE_RIGHT_THEN_DOWN)); GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_RightThenDown_003 end"; } @@ -1301,26 +908,11 @@ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_RightThenDown_004, Test gesturePath->SetDurationTime(300); aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(2)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(1)); - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_RIGHT_THEN_DOWN) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_FALSE(ret); + sleep(1); + + EXPECT_NE(AccessibilityHelper::GetInstance().GetGestureId(), + static_cast(GestureType::GESTURE_SWIPE_RIGHT_THEN_DOWN)); GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_RightThenDown_004 end"; } @@ -1348,26 +940,11 @@ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_LeftThenUp_001, TestSiz gesturePath->SetDurationTime(300); aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(2)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(1)); - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_LEFT_THEN_UP) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_FALSE(ret); + sleep(1); + + EXPECT_NE(AccessibilityHelper::GetInstance().GetGestureId(), + static_cast(GestureType::GESTURE_SWIPE_LEFT_THEN_UP)); GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_LeftThenUp_001 end"; } @@ -1395,26 +972,11 @@ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_LeftThenUp_002, TestSiz gesturePath->SetDurationTime(300); aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(2)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(1)); - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_LEFT_THEN_UP) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); + sleep(1); + + EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), + static_cast(GestureType::GESTURE_SWIPE_LEFT_THEN_UP)); GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_LeftThenUp_002 end"; } @@ -1442,26 +1004,11 @@ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_LeftThenUp_003, TestSiz gesturePath->SetDurationTime(300); aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(2)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(1)); - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_LEFT_THEN_UP) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); + sleep(1); + + EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), + static_cast(GestureType::GESTURE_SWIPE_LEFT_THEN_UP)); GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_LeftThenUp_003 end"; } @@ -1489,26 +1036,11 @@ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_LeftThenUp_004, TestSiz gesturePath->SetDurationTime(800); aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(2)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(1)); - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_LEFT_THEN_UP) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); + sleep(1); + + EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), + static_cast(GestureType::GESTURE_SWIPE_LEFT_THEN_UP)); GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_LeftThenUp_004 end"; } @@ -1536,26 +1068,11 @@ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_LeftThenDown_001, TestS gesturePath->SetDurationTime(300); aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(2)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(1)); - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_LEFT_THEN_DOWN) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_FALSE(ret); + sleep(1); + + EXPECT_NE(AccessibilityHelper::GetInstance().GetGestureId(), + static_cast(GestureType::GESTURE_SWIPE_LEFT_THEN_DOWN)); GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_LeftThenDown_001 end"; } @@ -1583,26 +1100,11 @@ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_LeftThenDown_002, TestS gesturePath->SetDurationTime(300); aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(2)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(1)); - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_LEFT_THEN_DOWN) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); + sleep(1); + + EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), + static_cast(GestureType::GESTURE_SWIPE_LEFT_THEN_DOWN)); GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_LeftThenDown_002 end"; } @@ -1630,26 +1132,11 @@ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_LeftThenDown_003, TestS gesturePath->SetDurationTime(300); aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(2)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(1)); - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_LEFT_THEN_DOWN) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); + sleep(1); + + EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), + static_cast(GestureType::GESTURE_SWIPE_LEFT_THEN_DOWN)); GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_LeftThenDown_003 end"; } @@ -1677,26 +1164,11 @@ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_LeftThenDown_004, TestS gesturePath->SetDurationTime(800); aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(2)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(1)); - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_LEFT_THEN_DOWN) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); + sleep(1); + + EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), + static_cast(GestureType::GESTURE_SWIPE_LEFT_THEN_DOWN)); GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_LeftThenDown_004 end"; } @@ -1724,26 +1196,11 @@ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_DownThenLeft_001, TestS gesturePath->SetDurationTime(300); aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(2)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(1)); - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_DOWN_THEN_LEFT) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_FALSE(ret); + sleep(1); + + EXPECT_NE(AccessibilityHelper::GetInstance().GetGestureId(), + static_cast(GestureType::GESTURE_SWIPE_DOWN_THEN_LEFT)); GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_DownThenLeft_001 end"; } @@ -1771,26 +1228,11 @@ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_DownThenLeft_002, TestS gesturePath->SetDurationTime(300); aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(2)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(1)); - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_DOWN_THEN_LEFT) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); + sleep(1); + + EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), + static_cast(GestureType::GESTURE_SWIPE_DOWN_THEN_LEFT)); GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_DownThenLeft_002 end"; } @@ -1818,26 +1260,11 @@ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_DownThenLeft_003, TestS gesturePath->SetDurationTime(300); aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(2)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(1)); - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_DOWN_THEN_LEFT) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_FALSE(ret); + sleep(1); + + EXPECT_NE(AccessibilityHelper::GetInstance().GetGestureId(), + static_cast(GestureType::GESTURE_SWIPE_DOWN_THEN_LEFT)); GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_DownThenLeft_003 end"; } @@ -1865,26 +1292,11 @@ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_DownThenLeft_004, TestS gesturePath->SetDurationTime(300); aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(2)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(1)); - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_DOWN_THEN_LEFT) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_FALSE(ret); + sleep(1); + + EXPECT_NE(AccessibilityHelper::GetInstance().GetGestureId(), + static_cast(GestureType::GESTURE_SWIPE_DOWN_THEN_LEFT)); GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_DownThenLeft_004 end"; } @@ -1912,26 +1324,11 @@ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_DownThenLeft_005, TestS gesturePath->SetDurationTime(800); aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(2)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(1)); - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_DOWN_THEN_LEFT) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_FALSE(ret); + sleep(1); + + EXPECT_NE(AccessibilityHelper::GetInstance().GetGestureId(), + static_cast(GestureType::GESTURE_SWIPE_DOWN_THEN_LEFT)); GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_DownThenLeft_005 end"; } @@ -1959,26 +1356,11 @@ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_DownThenRight_001, Test gesturePath->SetDurationTime(300); aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(2)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(1)); - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_DOWN_THEN_RIGHT) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_FALSE(ret); + sleep(1); + + EXPECT_NE(AccessibilityHelper::GetInstance().GetGestureId(), + static_cast(GestureType::GESTURE_SWIPE_DOWN_THEN_RIGHT)); GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_DownThenRight_001 end"; } @@ -2006,26 +1388,11 @@ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_DownThenRight_002, Test gesturePath->SetDurationTime(300); aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(2)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(1)); - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_DOWN_THEN_RIGHT) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); + sleep(1); + + EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), + static_cast(GestureType::GESTURE_SWIPE_DOWN_THEN_RIGHT)); GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_DownThenRight_002 end"; } @@ -2053,26 +1420,11 @@ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_DownThenRight_003, Test gesturePath->SetDurationTime(300); aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(2)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(1)); - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_DOWN_THEN_RIGHT) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_FALSE(ret); + sleep(1); + + EXPECT_NE(AccessibilityHelper::GetInstance().GetGestureId(), + static_cast(GestureType::GESTURE_SWIPE_DOWN_THEN_RIGHT)); GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_DownThenRight_003 end"; } @@ -2100,26 +1452,11 @@ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_DownThenRight_004, Test gesturePath->SetDurationTime(300); aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(2)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(1)); - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_DOWN_THEN_RIGHT) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_FALSE(ret); + sleep(1); + + EXPECT_NE(AccessibilityHelper::GetInstance().GetGestureId(), + static_cast(GestureType::GESTURE_SWIPE_DOWN_THEN_RIGHT)); GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_DownThenRight_004 end"; } @@ -2147,26 +1484,11 @@ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_DownThenRight_005, Test gesturePath->SetDurationTime(800); aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(2)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(1)); - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_DOWN_THEN_RIGHT) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_FALSE(ret); + sleep(1); + + EXPECT_NE(AccessibilityHelper::GetInstance().GetGestureId(), + static_cast(GestureType::GESTURE_SWIPE_DOWN_THEN_RIGHT)); GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_DownThenRight_005 end"; } @@ -2196,26 +1518,11 @@ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_LeftThenRight_001, Test gesturePath->SetDurationTime(300); aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(2)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(1)); - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_LEFT_THEN_RIGHT) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); + sleep(1); + + EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), + static_cast(GestureType::GESTURE_SWIPE_LEFT_THEN_RIGHT)); GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_LeftThenRight_001 end"; } @@ -2245,26 +1552,11 @@ HWTEST_F(AamsInjectorTest, TouchEventInjector_ModuleTest_LeftThenRight_002, Test gesturePath->SetDurationTime(300); aacs_->SendSimulateGesture(gesturePath); - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (MMI::PointerEvent::POINTER_ACTION_MOVE == MMI::MockInputManager::GetTouchActionOfTargetIndex(2)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(0)); - EXPECT_EQ(MMI::PointerEvent::POINTER_ACTION_MOVE, MMI::MockInputManager::GetTouchActionOfTargetIndex(1)); - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([=]() -> bool { - if (static_cast(GestureType::GESTURE_SWIPE_LEFT_THEN_RIGHT) == - AccessibilityHelper::GetInstance().GetGestureId()) { - return true; - } else { - return false; - } - }), SLEEP_TIME_2); - EXPECT_TRUE(ret); + sleep(1); + + EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), + static_cast(GestureType::GESTURE_SWIPE_LEFT_THEN_RIGHT)); GTEST_LOG_(INFO) << "TouchEventInjector_ModuleTest_LeftThenRight_002 end"; } diff --git a/services/test/mock/mock_aams_accessibility_touch_guider.cpp b/services/test/moduletest/aamstest/aams_accessibility_touch_exploration_test/aams_accessibility_touch_exploration_test.cpp similarity index 51% rename from services/test/mock/mock_aams_accessibility_touch_guider.cpp rename to services/test/moduletest/aamstest/aams_accessibility_touch_exploration_test/aams_accessibility_touch_exploration_test.cpp index ab8860b1..44f7fe9e 100755 --- a/services/test/mock/mock_aams_accessibility_touch_guider.cpp +++ b/services/test/moduletest/aamstest/aams_accessibility_touch_exploration_test/aams_accessibility_touch_exploration_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 Huawei Device Co., Ltd. + * Copyright (C) 2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -15,7 +15,7 @@ #include #include -#include "accessibility_touch_guider.h" +#include "accessibility_touch_exploration.h" #include "accessibility_account_data.h" #include "accessibility_common_helper.h" #include "accessibility_display_manager.h" @@ -48,15 +48,15 @@ namespace { const int32_t POINTER_ACTION_INVALID = -1; } // namespace -class MockAamsTouchGuideTest : public testing::Test { +class AamsTouchExplorationTest : public testing::Test { public: - MockAamsTouchGuideTest() + AamsTouchExplorationTest() {} - ~MockAamsTouchGuideTest() + ~AamsTouchExplorationTest() {} static void SetUpTestCase(); static void TearDownTestCase(); - static void TouchGuiderPointSet(MMI::PointerEvent::PointerItem &point, int id, int x, int y); + static void TouchExplorationPointSet(MMI::PointerEvent::PointerItem &point, int id, int x, int y); bool OnPointerEventOnePointsTest1(std::vector &points, MMI::PointerEvent::PointerItem point1, MMI::PointerEvent::PointerItem point2, MMI::PointerEvent::PointerItem point3, MMI::PointerEvent::PointerItem point4); @@ -97,7 +97,7 @@ protected: void AddAccessibilityWindowConnection(); }; -bool MockAamsTouchGuideTest::OnPointerEventOnePointsTest1(std::vector &points, +bool AamsTouchExplorationTest::OnPointerEventOnePointsTest1(std::vector &points, MMI::PointerEvent::PointerItem point1, MMI::PointerEvent::PointerItem point2, MMI::PointerEvent::PointerItem point3, MMI::PointerEvent::PointerItem point4) { @@ -125,6 +125,7 @@ bool MockAamsTouchGuideTest::OnPointerEventOnePointsTest1(std::vectorOnInputEvent(event); @@ -135,7 +136,7 @@ bool MockAamsTouchGuideTest::OnPointerEventOnePointsTest1(std::vector &point, +bool AamsTouchExplorationTest::OnPointerEventOnePointsTest3(std::vector &point, MMI::PointerEvent::PointerItem point1, MMI::PointerEvent::PointerItem point2, MMI::PointerEvent::PointerItem point3, MMI::PointerEvent::PointerItem point4) { @@ -144,7 +145,7 @@ bool MockAamsTouchGuideTest::OnPointerEventOnePointsTest3(std::vectorOnInputEvent(event); @@ -169,7 +170,7 @@ bool MockAamsTouchGuideTest::OnPointerEventOnePointsTest3(std::vector &points, +bool AamsTouchExplorationTest::OnPointerEventOnePointsTest7(std::vector &points, MMI::PointerEvent::PointerItem point1, MMI::PointerEvent::PointerItem point2, MMI::PointerEvent::PointerItem point3) { @@ -197,12 +198,12 @@ bool MockAamsTouchGuideTest::OnPointerEventOnePointsTest7(std::vector &points, +bool AamsTouchExplorationTest::TwoFingerTapEventProduce(std::vector &points, MMI::PointerEvent::PointerItem point1, MMI::PointerEvent::PointerItem point2, int32_t tapTimes, bool holdFlag) { auto inputEventConsumer = MMI::MockInputManager::GetInputEventConsumer(); if (!inputEventConsumer) { - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest TwoFingerTapEventProduce inputEventConsumer is nullptr"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest TwoFingerTapEventProduce inputEventConsumer is nullptr"; return false; } @@ -238,13 +239,13 @@ bool MockAamsTouchGuideTest::TwoFingerTapEventProduce(std::vector &points, +bool AamsTouchExplorationTest::TwoFingerMoveEventProduce(std::vector &points, MMI::PointerEvent::PointerItem point1, MMI::PointerEvent::PointerItem point2, MMI::PointerEvent::PointerItem point3, MMI::PointerEvent::PointerItem point4) { auto inputEventConsumer = MMI::MockInputManager::GetInputEventConsumer(); if (!inputEventConsumer) { - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest TwoFingerMoveEventProduce inputEventConsumer is null"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest TwoFingerMoveEventProduce inputEventConsumer is null"; return false; } @@ -278,101 +279,104 @@ bool MockAamsTouchGuideTest::TwoFingerMoveEventProduce(std::vector &pts, - MMI::PointerEvent::PointerItem point1, MMI::PointerEvent::PointerItem point2, bool isSeparateFlag) +bool AamsTouchExplorationTest::OneFingerTapAndTwoFingerTapEventProduce( + std::vector &points, MMI::PointerEvent::PointerItem point1, + MMI::PointerEvent::PointerItem point2, bool isSeparateFlag) { auto inputEventConsumer = MMI::MockInputManager::GetInputEventConsumer(); if (!inputEventConsumer) { - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest OneFingerTapAndTwoFingerTapEventProduce inputEventConsumer is null"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest inputEventConsumer is null"; return false; } std::shared_ptr event; // one finger event start - pts.clear(); - pts.emplace_back(point1); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, pts, 0, 0, POINT_ID_0); + points.clear(); + points.emplace_back(point1); + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, 0, 0, POINT_ID_0); inputEventConsumer->OnInputEvent(event); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, pts, 0, 0, POINT_ID_0); + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, 0, 0, POINT_ID_0); inputEventConsumer->OnInputEvent(event); if (isSeparateFlag) { sleep(1); } // two finger event start - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, pts, TAP_TIME_INTERVAL, 0, POINT_ID_0); + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, TAP_TIME_INTERVAL, 0, POINT_ID_0); inputEventConsumer->OnInputEvent(event); - pts.emplace_back(point2); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, pts, TAP_TIME_INTERVAL, 0, POINT_ID_1); + points.emplace_back(point2); + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, TAP_TIME_INTERVAL, 0, POINT_ID_1); inputEventConsumer->OnInputEvent(event); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, pts, 0, 0, POINT_ID_0); + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, points, 0, 0, POINT_ID_0); inputEventConsumer->OnInputEvent(event); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, pts, 0, 0, POINT_ID_0); + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, 0, 0, POINT_ID_0); inputEventConsumer->OnInputEvent(event); - pts.clear(); - pts.emplace_back(point2); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, pts, 0, 0, POINT_ID_1); + points.clear(); + points.emplace_back(point2); + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, 0, 0, POINT_ID_1); inputEventConsumer->OnInputEvent(event); return true; } -bool MockAamsTouchGuideTest::TwoFingerTapAndOneFingerTapEventProduce(std::vector &pts, - MMI::PointerEvent::PointerItem point1, MMI::PointerEvent::PointerItem point2) +bool AamsTouchExplorationTest::TwoFingerTapAndOneFingerTapEventProduce( + std::vector &points, MMI::PointerEvent::PointerItem point1, + MMI::PointerEvent::PointerItem point2) { auto inputEventConsumer = MMI::MockInputManager::GetInputEventConsumer(); if (!inputEventConsumer) { - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest TwoFingerTapAndOneFingerTapEventProduce inputEventConsumer is null"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest inputEventConsumer is null"; return false; } std::shared_ptr event; // two finger event start - pts.clear(); - pts.emplace_back(point1); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, pts, 0, 0, POINT_ID_0); + points.clear(); + points.emplace_back(point1); + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, 0, 0, POINT_ID_0); inputEventConsumer->OnInputEvent(event); - pts.emplace_back(point2); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, pts, 0, 0, POINT_ID_1); + points.emplace_back(point2); + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, 0, 0, POINT_ID_1); inputEventConsumer->OnInputEvent(event); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, pts, 0, 0, POINT_ID_0); + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, points, 0, 0, POINT_ID_0); inputEventConsumer->OnInputEvent(event); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, pts, 0, 0, POINT_ID_0); + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, 0, 0, POINT_ID_0); inputEventConsumer->OnInputEvent(event); - pts.clear(); - pts.emplace_back(point2); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, pts, 0, 0, POINT_ID_1); + points.clear(); + points.emplace_back(point2); + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, 0, 0, POINT_ID_1); + inputEventConsumer->OnInputEvent(event); // one finger event start - pts.clear(); - pts.emplace_back(point1); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, pts, TAP_TIME_INTERVAL, 0, POINT_ID_0); + points.clear(); + points.emplace_back(point1); + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, TAP_TIME_INTERVAL, 0, POINT_ID_0); inputEventConsumer->OnInputEvent(event); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, pts, 0, 0, POINT_ID_0); + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, points, 0, 0, POINT_ID_0); inputEventConsumer->OnInputEvent(event); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, pts, 0, 0, POINT_ID_0); + event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, 0, 0, POINT_ID_0); inputEventConsumer->OnInputEvent(event); return true; } -bool MockAamsTouchGuideTest::MultiFingerTapEventProduce(std::vector &points, +bool AamsTouchExplorationTest::MultiFingerTapEventProduce(std::vector &points, std::vector &pointsVec, int32_t tapTimes, bool holdFlag) { auto inputEventConsumer = MMI::MockInputManager::GetInputEventConsumer(); if (!inputEventConsumer) { - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MultiFingerTapEventProduce inputEventConsumer is null"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest MultiFingerTapEventProduce inputEventConsumer is null"; return false; } @@ -408,13 +412,13 @@ bool MockAamsTouchGuideTest::MultiFingerTapEventProduce(std::vector &points, +bool AamsTouchExplorationTest::MultiFingerTapAndMoveEventProduce(std::vector &points, std::vector &pointStartVec, std::vector &pointEndVec) { auto inputEventConsumer = MMI::MockInputManager::GetInputEventConsumer(); if (!inputEventConsumer) { - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MultiFingerTapAndMoveEventProduce inputEventConsumer is null"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest MultiFingerTapAndMoveEventProduce inputEventConsumer is null"; return false; } @@ -447,14 +451,14 @@ bool MockAamsTouchGuideTest::MultiFingerTapAndMoveEventProduce(std::vector::GetInstance().OnStart(); AccessibilityCommonHelper::GetInstance().WaitForServicePublish(); Singleton::GetInstance().SwitchedUser(AccessibilityHelper::accountId_); GTEST_LOG_(INFO) << "AccessibleAbilityManagerService is published"; } -void MockAamsTouchGuideTest::TearDownTestCase() +void AamsTouchExplorationTest::TearDownTestCase() { - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest TearDownTestCase"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest TearDownTestCase"; AccessibilityHelper::GetInstance().SetGestureId(0); AccessibilityHelper::GetInstance().GetEventType().clear(); Singleton::GetInstance().OnStop(); } -void MockAamsTouchGuideTest::SetUp() +void AamsTouchExplorationTest::SetUp() { - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest SetUp"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest SetUp"; interceptorId_ = std::make_shared(); MMI::InputManager::GetInstance()->AddInterceptor(interceptorId_); @@ -507,9 +511,9 @@ void MockAamsTouchGuideTest::SetUp() AddAccessibilityWindowConnection(); } -void MockAamsTouchGuideTest::TearDown() +void AamsTouchExplorationTest::TearDown() { - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest TearDown"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest TearDown"; Singleton::GetInstance().DeregisterElementOperator(0); sleep(SLEEP_TIME_3); @@ -520,7 +524,7 @@ void MockAamsTouchGuideTest::TearDown() MMI::MockInputManager::ClearTouchActions(); } -std::shared_ptr MockAamsTouchGuideTest::CreateTouchEvent(int32_t action, int32_t pointId) +std::shared_ptr AamsTouchExplorationTest::CreateTouchEvent(int32_t action, int32_t pointId) { std::shared_ptr touchEvent = MMI::PointerEvent::Create(); MMI::PointerEvent::PointerItem item = {}; @@ -535,7 +539,7 @@ std::shared_ptr MockAamsTouchGuideTest::CreateTouchEvent(int3 return touchEvent; } -std::shared_ptr MockAamsTouchGuideTest::CreateMoveEvent(int32_t pointerCount, int32_t pointId) +std::shared_ptr AamsTouchExplorationTest::CreateMoveEvent(int32_t pointerCount, int32_t pointId) { std::shared_ptr touchEvent = MMI::PointerEvent::Create(); MMI::PointerEvent::PointerItem item = {}; @@ -552,7 +556,7 @@ std::shared_ptr MockAamsTouchGuideTest::CreateMoveEvent(int32 return touchEvent; } -std::shared_ptr MockAamsTouchGuideTest::CreateTouchEvent(int32_t action, +std::shared_ptr AamsTouchExplorationTest::CreateTouchEvent(int32_t action, std::vector &points, int64_t occurredTime, int64_t startTime, int32_t pointId) { @@ -575,7 +579,7 @@ std::shared_ptr MockAamsTouchGuideTest::CreateTouchEvent(int3 return pointerEvent; } -void MockAamsTouchGuideTest::AddAccessibilityWindowConnection() +void AamsTouchExplorationTest::AddAccessibilityWindowConnection() { GTEST_LOG_(INFO) << "aamsAccessibleAbilityChannelTest AddAccessibilityWindowConnection"; // accessibility interaction connection @@ -594,54 +598,40 @@ void MockAamsTouchGuideTest::AddAccessibilityWindowConnection() * @tc.name:OnPointerEvent * @tc.desc: Check the event that two fingers moving in same directions in dragging state. */ -HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent001, TestSize.Level1) +HWTEST_F(AamsTouchExplorationTest, AamsTouchExplorationTest_Moduletest_OnPointerEvent001, TestSize.Level1) { - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent001 starts"; - sleep(SLEEP_TIME_3); + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent001 starts"; AccessibilityHelper::GetInstance().GetEventType() = {}; MMI::MockInputManager::ClearTouchActions(); std::vector points = {}; MMI::PointerEvent::PointerItem point1 = {}; - TouchGuiderPointSet(point1, 1, 500, 500); + TouchExplorationPointSet(point1, 1, 500, 500); MMI::PointerEvent::PointerItem point2 = {}; - TouchGuiderPointSet(point2, 2, 1000, 500); + TouchExplorationPointSet(point2, 2, 1000, 500); MMI::PointerEvent::PointerItem point3 = {}; - TouchGuiderPointSet(point3, 1, 2000, 500); + TouchExplorationPointSet(point3, 1, 2000, 500); MMI::PointerEvent::PointerItem point4 = {}; - TouchGuiderPointSet(point4, 1, 2500, 500); + TouchExplorationPointSet(point4, 1, 2500, 500); bool flag = OnPointerEventOnePointsTest1(points, point1, point2, point3, point4); if (!flag) { - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest OnPointerEvent001 inputEventConsumer is null"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest OnPointerEvent001 inputEventConsumer is null"; return; } - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - sleep(1); - int32_t eventTypeSize = - static_cast(AccessibilityHelper::GetInstance().GetEventType().size()); - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(eventTypeSize - 1) == - EventType::TYPE_TOUCH_GUIDE_GESTURE_END) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(ret); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN); + sleep(1); - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (MMI::MockInputManager::GetTouchActionOfTargetIndex(2) == MMI::PointerEvent::POINTER_ACTION_UP) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(ret); + // event type + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), EventType::TYPE_TOUCH_END); + + // action type EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(0), MMI::PointerEvent::POINTER_ACTION_DOWN); EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(1), MMI::PointerEvent::POINTER_ACTION_MOVE); - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent001 ENDs"; + EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(2), MMI::PointerEvent::POINTER_ACTION_UP); + + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent001 ENDs"; } /** @@ -649,49 +639,35 @@ HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEven * @tc.name:OnPointerEvent * @tc.desc: Check the event that move slowly with one finger. */ -HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent002, TestSize.Level1) +HWTEST_F(AamsTouchExplorationTest, AamsTouchExplorationTest_Moduletest_OnPointerEvent002, TestSize.Level1) { - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent002 starts"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent002 starts"; AccessibilityHelper::GetInstance().GetEventType() = {}; MMI::MockInputManager::ClearTouchActions(); std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, 1); auto inputEventConsumer = MMI::MockInputManager::GetInputEventConsumer(); if (!inputEventConsumer) { - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest OnPointerEvent002 inputEventConsumer is null"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest OnPointerEvent002 inputEventConsumer is null"; return; } inputEventConsumer->OnInputEvent(event); - bool retOnPointerEvent2 = - AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1) == - EventType::TYPE_TOUCH_GUIDE_BEGIN) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent2); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN); + + sleep(1); event = CreateMoveEvent(1, 1); inputEventConsumer->OnInputEvent(event); event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, 1); inputEventConsumer->OnInputEvent(event); - retOnPointerEvent2 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3) == - EventType::TYPE_TOUCH_GUIDE_END) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent2); + + sleep(1); + + // action type EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(0), MMI::PointerEvent::POINTER_ACTION_HOVER_ENTER); EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(1), MMI::PointerEvent::POINTER_ACTION_HOVER_MOVE); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), EventType::TYPE_TOUCH_END); + EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(2), MMI::PointerEvent::POINTER_ACTION_HOVER_EXIT); - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent002 ENDs"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent002 ENDs"; } /** @@ -699,57 +675,31 @@ HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEven * @tc.name:OnPointerEvent * @tc.desc: Check the GESTURE_SWIPE_LEFT_THEN_RIGHT gesture. */ -HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent003, TestSize.Level1) +HWTEST_F(AamsTouchExplorationTest, AamsTouchExplorationTest_Moduletest_OnPointerEvent003, TestSize.Level1) { - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent003 starts"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent003 starts"; AccessibilityHelper::GetInstance().GetEventType() = {}; MMI::MockInputManager::ClearTouchActions(); std::vector points = {}; MMI::PointerEvent::PointerItem point1 = {}; - TouchGuiderPointSet(point1, 1, 2500, 2500); + TouchExplorationPointSet(point1, 1, 2500, 2500); MMI::PointerEvent::PointerItem point2 = {}; - TouchGuiderPointSet(point2, 1, 1500, 2500); + TouchExplorationPointSet(point2, 1, 1500, 2500); MMI::PointerEvent::PointerItem point3 = {}; - TouchGuiderPointSet(point3, 1, 0, 2500); + TouchExplorationPointSet(point3, 1, 0, 2500); MMI::PointerEvent::PointerItem point4 = {}; - TouchGuiderPointSet(point4, 1, 2500, 2250); + TouchExplorationPointSet(point4, 1, 2500, 2250); OnPointerEventOnePointsTest3(points, point1, point2, point3, point4); - // Determine event type - bool retOnPointerEvent3 = - AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == - EventType::TYPE_TOUCH_END) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent3); - 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(3), - EventType::TYPE_TOUCH_GUIDE_GESTURE_END); - // Determine action - 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() == - static_cast(GestureType::GESTURE_SWIPE_LEFT_THEN_RIGHT)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent3); + sleep(1); - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent003 ENDs"; + // gesture type + EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), + static_cast(GestureType::GESTURE_SWIPE_LEFT_THEN_RIGHT)); + + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent003 ENDs"; } /** @@ -757,60 +707,35 @@ HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEven * @tc.name:OnPointerEvent * @tc.desc: Check the GESTURE_SWIPE_DOWN_THEN_UP gesture. */ -HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent004, TestSize.Level1) +HWTEST_F(AamsTouchExplorationTest, AamsTouchExplorationTest_Moduletest_OnPointerEvent004, TestSize.Level1) { - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent004 starts"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent004 starts"; AccessibilityHelper::GetInstance().GetEventType() = {}; MMI::MockInputManager::ClearTouchActions(); std::vector points = {}; MMI::PointerEvent::PointerItem point1 = {}; - TouchGuiderPointSet(point1, 1, 2500, 2500); + TouchExplorationPointSet(point1, 1, 2500, 2500); MMI::PointerEvent::PointerItem point2 = {}; - TouchGuiderPointSet(point2, 1, 2500, 3500); + TouchExplorationPointSet(point2, 1, 2500, 3500); MMI::PointerEvent::PointerItem point3 = {}; - TouchGuiderPointSet(point3, 1, 2500, 5000); + TouchExplorationPointSet(point3, 1, 2500, 5000); MMI::PointerEvent::PointerItem point4 = {}; - TouchGuiderPointSet(point4, 1, 2250, 2500); + TouchExplorationPointSet(point4, 1, 2250, 2500); bool flag = OnPointerEventOnePointsTest3(points, point1, point2, point3, point4); if (!flag) { - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest OnPointerEvent003 inputEventConsumer is null"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest OnPointerEvent003 inputEventConsumer is null"; return; } - // Determine event type - bool retOnPointerEvent4 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == - EventType::TYPE_TOUCH_END) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent4); - 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(3), - EventType::TYPE_TOUCH_GUIDE_GESTURE_END); - // Determine action - 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() == - static_cast(GestureType::GESTURE_SWIPE_DOWN_THEN_UP)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent4); + sleep(1); - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent004 ENDs"; + // gesture type + EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), + static_cast(GestureType::GESTURE_SWIPE_DOWN_THEN_UP)); + + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent004 ENDs"; } /** @@ -818,60 +743,35 @@ HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEven * @tc.name:OnPointerEvent * @tc.desc: Check the GESTURE_SWIPE_RIGHT_THEN_LEFT gesture. */ -HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent005, TestSize.Level1) +HWTEST_F(AamsTouchExplorationTest, AamsTouchExplorationTest_Moduletest_OnPointerEvent005, TestSize.Level1) { - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent005 starts"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent005 starts"; AccessibilityHelper::GetInstance().GetEventType() = {}; MMI::MockInputManager::ClearTouchActions(); std::vector points = {}; MMI::PointerEvent::PointerItem point1 = {}; - TouchGuiderPointSet(point1, 1, 2500, 2500); + TouchExplorationPointSet(point1, 1, 2500, 2500); MMI::PointerEvent::PointerItem point2 = {}; - TouchGuiderPointSet(point2, 1, 3500, 2500); + TouchExplorationPointSet(point2, 1, 3500, 2500); MMI::PointerEvent::PointerItem point3 = {}; - TouchGuiderPointSet(point3, 1, 5000, 2500); + TouchExplorationPointSet(point3, 1, 5000, 2500); MMI::PointerEvent::PointerItem point4 = {}; - TouchGuiderPointSet(point4, 1, 2500, 2250); + TouchExplorationPointSet(point4, 1, 2500, 2250); bool flag = OnPointerEventOnePointsTest3(points, point1, point2, point3, point4); if (!flag) { - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest OnPointerEvent005 inputEventConsumer is null"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest OnPointerEvent005 inputEventConsumer is null"; return; } - // Determine event type - bool retOnPointerEvent5 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == - EventType::TYPE_TOUCH_END) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent5); - 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(3), - EventType::TYPE_TOUCH_GUIDE_GESTURE_END); - // Determine action - 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() == - static_cast(GestureType::GESTURE_SWIPE_RIGHT_THEN_LEFT)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent5); + sleep(1); - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent005 ENDs"; + // gesture type + EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), + static_cast(GestureType::GESTURE_SWIPE_RIGHT_THEN_LEFT)); + + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent005 ENDs"; } /** @@ -879,60 +779,35 @@ HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEven * @tc.name:OnPointerEvent * @tc.desc: Check the GESTURE_SWIPE_UP_THEN_DOWN gesture. */ -HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent006, TestSize.Level1) +HWTEST_F(AamsTouchExplorationTest, AamsTouchExplorationTest_Moduletest_OnPointerEvent006, TestSize.Level1) { - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent006 starts"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent006 starts"; AccessibilityHelper::GetInstance().GetEventType() = {}; MMI::MockInputManager::ClearTouchActions(); std::vector points = {}; MMI::PointerEvent::PointerItem point1 = {}; - TouchGuiderPointSet(point1, 1, 2500, 2500); + TouchExplorationPointSet(point1, 1, 2500, 2500); MMI::PointerEvent::PointerItem point2 = {}; - TouchGuiderPointSet(point2, 1, 2500, 1500); + TouchExplorationPointSet(point2, 1, 2500, 1500); MMI::PointerEvent::PointerItem point3 = {}; - TouchGuiderPointSet(point3, 1, 2500, 0); + TouchExplorationPointSet(point3, 1, 2500, 0); MMI::PointerEvent::PointerItem point4 = {}; - TouchGuiderPointSet(point4, 1, 2250, 2500); + TouchExplorationPointSet(point4, 1, 2250, 2500); bool flag = OnPointerEventOnePointsTest3(points, point1, point2, point3, point4); if (!flag) { - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest OnPointerEvent006 inputEventConsumer is null"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest OnPointerEvent006 inputEventConsumer is null"; return; } - // Determine event type - bool retOnPointerEvent6 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == - EventType::TYPE_TOUCH_END) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent6); - 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(3), - EventType::TYPE_TOUCH_GUIDE_GESTURE_END); - // Determine action - 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() == - static_cast(GestureType::GESTURE_SWIPE_UP_THEN_DOWN)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent6); + sleep(1); - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent006 ENDs"; + // gesture type + EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), + static_cast(GestureType::GESTURE_SWIPE_UP_THEN_DOWN)); + + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent006 ENDs"; } /** @@ -940,56 +815,33 @@ HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEven * @tc.name:OnPointerEvent * @tc.desc: Check the UP gesture. */ -HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent007, TestSize.Level1) +HWTEST_F(AamsTouchExplorationTest, AamsTouchExplorationTest_Moduletest_OnPointerEvent007, TestSize.Level1) { - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent007 starts"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent007 starts"; AccessibilityHelper::GetInstance().GetEventType() = {}; MMI::MockInputManager::ClearTouchActions(); std::vector points = {}; MMI::PointerEvent::PointerItem point1 = {}; - TouchGuiderPointSet(point1, 1, 2500, 2500); + TouchExplorationPointSet(point1, 1, 2500, 2500); MMI::PointerEvent::PointerItem point2 = {}; - TouchGuiderPointSet(point2, 1, 2500, 1500); + TouchExplorationPointSet(point2, 1, 2500, 1500); MMI::PointerEvent::PointerItem point3 = {}; - TouchGuiderPointSet(point3, 1, 2500, 0); + TouchExplorationPointSet(point3, 1, 2500, 0); bool flag = OnPointerEventOnePointsTest7(points, point1, point2, point3); if (!flag) { - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest OnPointerEvent007 inputEventConsumer is null"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest OnPointerEvent007 inputEventConsumer is null"; return; } - // Determine event type - bool retOnPointerEvent7 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == - EventType::TYPE_TOUCH_END) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent7); - 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(3), - EventType::TYPE_TOUCH_GUIDE_GESTURE_END); - // Determine action - 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)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent7); + sleep(1); - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent007 ENDs"; + // gesture type + EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), + static_cast(GestureType::GESTURE_SWIPE_UP)); + + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent007 ENDs"; } /** @@ -997,42 +849,30 @@ HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEven * @tc.name:OnPointerEvent * @tc.desc: Check the single tap event. */ -HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent008, TestSize.Level1) +HWTEST_F(AamsTouchExplorationTest, AamsTouchExplorationTest_Moduletest_OnPointerEvent008, TestSize.Level1) { - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent008 starts"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent008 starts"; AccessibilityHelper::GetInstance().GetEventType() = {}; MMI::MockInputManager::ClearTouchActions(); std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, 1); auto inputEventConsumer = MMI::MockInputManager::GetInputEventConsumer(); if (!inputEventConsumer) { - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest OnPointerEvent009 inputEventConsumer is null"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest OnPointerEvent009 inputEventConsumer is null"; return; } inputEventConsumer->OnInputEvent(event); event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, 1); inputEventConsumer->OnInputEvent(event); - // Determine event type - bool retOnPointerEvent8 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3) == - EventType::TYPE_TOUCH_GUIDE_END) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent8); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), - EventType::TYPE_TOUCH_END); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), - EventType::TYPE_TOUCH_GUIDE_BEGIN); - // Determine action + + sleep(1); + + // action type EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(0), MMI::PointerEvent::POINTER_ACTION_HOVER_ENTER); EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(1), MMI::PointerEvent::POINTER_ACTION_HOVER_EXIT); - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent008 ends"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent008 ends"; } /** @@ -1040,9 +880,9 @@ HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEven * @tc.name:OnPointerEvent * @tc.desc: Check the double tap and long press event. */ -HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent009, TestSize.Level1) +HWTEST_F(AamsTouchExplorationTest, AamsTouchExplorationTest_Moduletest_OnPointerEvent009, TestSize.Level1) { - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent009 starts"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent009 starts"; AccessibilityHelper::GetInstance().GetEventType() = {}; MMI::MockInputManager::ClearTouchActions(); @@ -1057,39 +897,31 @@ HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEven CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, 0, 0, 1); auto inputEventConsumer = MMI::MockInputManager::GetInputEventConsumer(); if (!inputEventConsumer) { - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest OnPointerEvent009 inputEventConsumer is null"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest OnPointerEvent009 inputEventConsumer is null"; return; } inputEventConsumer->OnInputEvent(event); - sleep(1); event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, 40, 0, 1); inputEventConsumer->OnInputEvent(event); event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, 200, 0, 1); inputEventConsumer->OnInputEvent(event); sleep(SLEEP_TIME_3); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, 0, 0, 1); inputEventConsumer->OnInputEvent(event); - // Determine event type - bool retOnPointerEvent9 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(6) == - EventType::TYPE_TOUCH_END) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent9); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), EventType::TYPE_TOUCH_GUIDE_BEGIN); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), EventType::TYPE_TOUCH_END); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3), EventType::TYPE_TOUCH_BEGIN); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(4), EventType::TYPE_TOUCH_GUIDE_END); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(5), EventType::TYPE_TOUCH_GUIDE_BEGIN); - // Determine action - EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(0), MMI::PointerEvent::POINTER_ACTION_HOVER_ENTER); - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent009 ends"; + sleep(1); + + // event type + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), EventType::TYPE_TOUCH_END); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), EventType::TYPE_TOUCH_BEGIN); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3), EventType::TYPE_TOUCH_END); + + // action type + EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(0), MMI::PointerEvent::POINTER_ACTION_DOWN); + EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(1), MMI::PointerEvent::POINTER_ACTION_UP); + + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent009 ends"; } /** @@ -1097,9 +929,9 @@ HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEven * @tc.name:OnPointerEvent * @tc.desc: Check the double-tap event. */ -HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent010, TestSize.Level1) +HWTEST_F(AamsTouchExplorationTest, AamsTouchExplorationTest_Moduletest_OnPointerEvent010, TestSize.Level1) { - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent010 starts"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent010 starts"; AccessibilityHelper::GetInstance().GetEventType() = {}; MMI::MockInputManager::ClearTouchActions(); @@ -1114,11 +946,10 @@ HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEven CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, 0, 0, 1); auto inputEventConsumer = MMI::MockInputManager::GetInputEventConsumer(); if (!inputEventConsumer) { - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest OnPointerEvent010 inputEventConsumer is null"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest OnPointerEvent010 inputEventConsumer is null"; return; } inputEventConsumer->OnInputEvent(event); - sleep(1); event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, 0, 0, 1); inputEventConsumer->OnInputEvent(event); event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, 100, 0, 1); @@ -1126,26 +957,13 @@ HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEven event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, 0, 0, 1); inputEventConsumer->OnInputEvent(event); - // Determine event type - bool retOnPointerEvent10 = - AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(5) == - EventType::TYPE_TOUCH_END) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent10); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), EventType::TYPE_TOUCH_GUIDE_BEGIN); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), EventType::TYPE_TOUCH_END); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3), EventType::TYPE_TOUCH_BEGIN); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(4), EventType::TYPE_TOUCH_GUIDE_END); - // Determine action - EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(0), POINTER_ACTION_INVALID); + sleep(1); - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent010 ends"; + // action type + EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(0), MMI::PointerEvent::POINTER_ACTION_DOWN); + EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(1), MMI::PointerEvent::POINTER_ACTION_UP); + + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent010 ends"; } /** @@ -1153,46 +971,34 @@ HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEven * @tc.name:OnPointerEvent * @tc.desc: Check the two finger tap event. */ -HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent011, TestSize.Level1) +HWTEST_F(AamsTouchExplorationTest, AamsTouchExplorationTest_Moduletest_OnPointerEvent011, TestSize.Level1) { - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent011 starts"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent011 starts"; AccessibilityHelper::GetInstance().GetEventType() = {}; MMI::MockInputManager::ClearTouchActions(); std::vector points = {}; MMI::PointerEvent::PointerItem point1 = {}; - TouchGuiderPointSet(point1, 0, 100, 100); + TouchExplorationPointSet(point1, 0, 100, 100); MMI::PointerEvent::PointerItem point2 = {}; - TouchGuiderPointSet(point2, 1, 200, 100); + TouchExplorationPointSet(point2, 1, 200, 100); bool eventProduceRst = TwoFingerTapEventProduce(points, point1, point2, TAP_TIMES_1, false); if (!eventProduceRst) { - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest OnPointerEvent0011 inputEventConsumer is null"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest OnPointerEvent0011 inputEventConsumer is null"; return; } sleep(1); - // eventType - bool retOnPointerEvent11 = - AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == - EventType::TYPE_TOUCH_END) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent11); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), - EventType::TYPE_TOUCH_BEGIN); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), - EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN); + // event type + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), EventType::TYPE_TOUCH_END); // gestureId - EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), 25); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), GestureType::GESTURE_TWO_FINGER_SINGLE_TAP); - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent011 ends"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent011 ends"; } /** @@ -1200,48 +1006,32 @@ HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEven * @tc.name:OnPointerEvent * @tc.desc: Check the two finger double tap event. */ -HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent012, TestSize.Level1) +HWTEST_F(AamsTouchExplorationTest, AamsTouchExplorationTest_Moduletest_OnPointerEvent012, TestSize.Level1) { - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent012 starts"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent012 starts"; AccessibilityHelper::GetInstance().GetEventType() = {}; MMI::MockInputManager::ClearTouchActions(); std::vector points = {}; MMI::PointerEvent::PointerItem point1 = {}; - TouchGuiderPointSet(point1, 0, 100, 100); + TouchExplorationPointSet(point1, 0, 100, 100); MMI::PointerEvent::PointerItem point2 = {}; - TouchGuiderPointSet(point2, 1, 200, 100); + TouchExplorationPointSet(point2, 1, 200, 100); bool eventProduceRst = TwoFingerTapEventProduce(points, point1, point2, TAP_TIMES_2, false); if (!eventProduceRst) { - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest OnPointerEvent0011 inputEventConsumer is null"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest OnPointerEvent0011 inputEventConsumer is null"; return; } sleep(1); - // eventType - bool retOnPointerEvent12 = - AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(4) == - EventType::TYPE_TOUCH_END) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent12); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), - EventType::TYPE_TOUCH_BEGIN); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), - EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN); - // gestureId EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), static_cast(GestureType::GESTURE_TWO_FINGER_DOUBLE_TAP)); - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent012 ends"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent012 ends"; } /** @@ -1249,48 +1039,32 @@ HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEven * @tc.name:OnPointerEvent * @tc.desc: Check the two finger triple tap event. */ -HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent013, TestSize.Level1) +HWTEST_F(AamsTouchExplorationTest, AamsTouchExplorationTest_Moduletest_OnPointerEvent013, TestSize.Level1) { - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent013 starts"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent013 starts"; AccessibilityHelper::GetInstance().GetEventType() = {}; MMI::MockInputManager::ClearTouchActions(); std::vector points = {}; MMI::PointerEvent::PointerItem point1 = {}; - TouchGuiderPointSet(point1, 0, 100, 100); + TouchExplorationPointSet(point1, 0, 100, 100); MMI::PointerEvent::PointerItem point2 = {}; - TouchGuiderPointSet(point2, 1, 200, 100); + TouchExplorationPointSet(point2, 1, 200, 100); bool eventProduceRst = TwoFingerTapEventProduce(points, point1, point2, TAP_TIMES_3, false); if (!eventProduceRst) { - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest OnPointerEvent0011 inputEventConsumer is null"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest OnPointerEvent0011 inputEventConsumer is null"; return; } sleep(1); - // eventType - bool retOnPointerEvent13 = - AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(6) == - EventType::TYPE_TOUCH_END) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent13); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), - EventType::TYPE_TOUCH_BEGIN); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), - EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN); - // gestureId EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), static_cast(GestureType::GESTURE_TWO_FINGER_TRIPLE_TAP)); - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent013 ends"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent013 ends"; } /** @@ -1298,50 +1072,32 @@ HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEven * @tc.name:OnPointerEvent * @tc.desc: Check the two finger double tap and hold event. */ -HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent014, TestSize.Level1) +HWTEST_F(AamsTouchExplorationTest, AamsTouchExplorationTest_Moduletest_OnPointerEvent014, TestSize.Level1) { - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent014 starts"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent014 starts"; AccessibilityHelper::GetInstance().GetEventType() = {}; MMI::MockInputManager::ClearTouchActions(); std::vector points = {}; MMI::PointerEvent::PointerItem point1 = {}; - TouchGuiderPointSet(point1, 0, 100, 100); + TouchExplorationPointSet(point1, 0, 100, 100); MMI::PointerEvent::PointerItem point2 = {}; - TouchGuiderPointSet(point2, 1, 200, 100); + TouchExplorationPointSet(point2, 1, 200, 100); bool eventProduceRst = TwoFingerTapEventProduce(points, point1, point2, TAP_TIMES_2, true); if (!eventProduceRst) { - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest OnPointerEvent0014 inputEventConsumer is null"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest OnPointerEvent0014 inputEventConsumer is null"; return; } sleep(1); - // eventType - bool retOnPointerEvent14 = - AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == - EventType::TYPE_TOUCH_END) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent14); - 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(4), - EventType::TYPE_TOUCH_GUIDE_GESTURE_END); - // gestureId EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), static_cast(GestureType::GESTURE_TWO_FINGER_DOUBLE_TAP_AND_HOLD)); - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent014 ends"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent014 ends"; } /** @@ -1349,50 +1105,32 @@ HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEven * @tc.name:OnPointerEvent * @tc.desc: Check the two finger triple tap and hold event. */ -HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent015, TestSize.Level1) +HWTEST_F(AamsTouchExplorationTest, AamsTouchExplorationTest_Moduletest_OnPointerEvent015, TestSize.Level1) { - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent015 starts"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent015 starts"; AccessibilityHelper::GetInstance().GetEventType() = {}; MMI::MockInputManager::ClearTouchActions(); std::vector points = {}; MMI::PointerEvent::PointerItem point1 = {}; - TouchGuiderPointSet(point1, 0, 100, 100); + TouchExplorationPointSet(point1, 0, 100, 100); MMI::PointerEvent::PointerItem point2 = {}; - TouchGuiderPointSet(point2, 1, 200, 100); + TouchExplorationPointSet(point2, 1, 200, 100); bool eventProduceRst = TwoFingerTapEventProduce(points, point1, point2, TAP_TIMES_3, true); if (!eventProduceRst) { - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest OnPointerEvent0015 inputEventConsumer is null"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest OnPointerEvent0015 inputEventConsumer is null"; return; } sleep(1); - // eventType - bool retOnPointerEvent15 = - AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == - EventType::TYPE_TOUCH_END) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent15); - 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(6), - EventType::TYPE_TOUCH_GUIDE_GESTURE_END); - // gestureId EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), static_cast(GestureType::GESTURE_TWO_FINGER_TRIPLE_TAP_AND_HOLD)); - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent015 ends"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent015 ends"; } /** @@ -1400,101 +1138,79 @@ HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEven * @tc.name:OnPointerEvent * @tc.desc: Check the two finger move event. */ -HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent016, TestSize.Level1) +HWTEST_F(AamsTouchExplorationTest, AamsTouchExplorationTest_Moduletest_OnPointerEvent016, TestSize.Level1) { - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent016 starts"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent016 starts"; AccessibilityHelper::GetInstance().GetEventType() = {}; MMI::MockInputManager::ClearTouchActions(); std::vector points = {}; MMI::PointerEvent::PointerItem point1 = {}; - TouchGuiderPointSet(point1, 0, 100, 100); + TouchExplorationPointSet(point1, 0, 100, 100); MMI::PointerEvent::PointerItem point2 = {}; - TouchGuiderPointSet(point2, 1, 200, 100); + TouchExplorationPointSet(point2, 1, 200, 100); MMI::PointerEvent::PointerItem point3 = {}; - TouchGuiderPointSet(point3, 0, 100, 400); + TouchExplorationPointSet(point3, 0, 100, 400); MMI::PointerEvent::PointerItem point4 = {}; - TouchGuiderPointSet(point4, 1, 200, 400); + TouchExplorationPointSet(point4, 1, 200, 400); bool eventProduceRst = TwoFingerMoveEventProduce(points, point1, point2, point3, point4); if (!eventProduceRst) { - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest OnPointerEvent0016 inputEventConsumer is null"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest OnPointerEvent0016 inputEventConsumer is null"; return; } - // eventType - bool retOnPointerEvent15 = - 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(retOnPointerEvent15); - 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); + sleep(1); + // action type EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(0), MMI::PointerEvent::POINTER_ACTION_DOWN); EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(1), MMI::PointerEvent::POINTER_ACTION_MOVE); EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(2), MMI::PointerEvent::POINTER_ACTION_UP); - // gestureId - EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), static_cast(GestureType::GESTURE_INVALID)); - - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent016 ends"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent016 ends"; } /** * @tc.number: OnPointerEvent017 * @tc.name:OnPointerEvent - * @tc.desc: Check the one finger tap and then two finger tap event, expect do not recognize as any gesture. + * @tc.desc: Check the one finger tap and then two finger tap event. */ -HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent017, TestSize.Level1) +HWTEST_F(AamsTouchExplorationTest, AamsTouchExplorationTest_Moduletest_OnPointerEvent017, TestSize.Level1) { - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent017 starts"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent017 starts"; AccessibilityHelper::GetInstance().GetEventType() = {}; MMI::MockInputManager::ClearTouchActions(); std::vector points = {}; MMI::PointerEvent::PointerItem point1 = {}; - TouchGuiderPointSet(point1, 0, 100, 100); + TouchExplorationPointSet(point1, 0, 100, 100); MMI::PointerEvent::PointerItem point2 = {}; - TouchGuiderPointSet(point2, 1, 200, 100); + TouchExplorationPointSet(point2, 1, 200, 100); bool eventProduceRst = OneFingerTapAndTwoFingerTapEventProduce(points, point1, point2, false); if (!eventProduceRst) { - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest OnPointerEvent0017 inputEventConsumer is null"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest OnPointerEvent0017 inputEventConsumer is null"; return; } - // eventType - bool retOnPointerEvent15 = - AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1) == - EventType::TYPE_TOUCH_END) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent15); + sleep(1); + + // event type EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), EventType::TYPE_TOUCH_END); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), EventType::TYPE_TOUCH_BEGIN); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3), EventType::TYPE_TOUCH_END); - // gestureId - EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), static_cast(GestureType::GESTURE_INVALID)); + // action type + EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(0), MMI::PointerEvent::POINTER_ACTION_DOWN); + EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(1), MMI::PointerEvent::POINTER_ACTION_DOWN); + EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(2), MMI::PointerEvent::POINTER_ACTION_MOVE); + EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(3), MMI::PointerEvent::POINTER_ACTION_UP); + EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(4), MMI::PointerEvent::POINTER_ACTION_UP); - // touch action to multimode - EXPECT_EQ(static_cast(MMI::MockInputManager::GetTouchActions().size()), 0); - - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent017 ends"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent017 ends"; } /** @@ -1502,49 +1218,31 @@ HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEven * @tc.name:OnPointerEvent * @tc.desc: Check the two finger tap and then one finger tap event, expect do not recognize as any gesture. */ -HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent018, TestSize.Level1) +HWTEST_F(AamsTouchExplorationTest, AamsTouchExplorationTest_Moduletest_OnPointerEvent018, TestSize.Level1) { - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent018 starts"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent018 starts"; AccessibilityHelper::GetInstance().GetEventType() = {}; MMI::MockInputManager::ClearTouchActions(); std::vector points = {}; MMI::PointerEvent::PointerItem point1 = {}; - TouchGuiderPointSet(point1, 0, 100, 100); + TouchExplorationPointSet(point1, 0, 100, 100); MMI::PointerEvent::PointerItem point2 = {}; - TouchGuiderPointSet(point2, 1, 200, 100); + TouchExplorationPointSet(point2, 1, 200, 100); bool eventProduceRst = TwoFingerTapAndOneFingerTapEventProduce(points, point1, point2); if (!eventProduceRst) { - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest OnPointerEvent0018 inputEventConsumer is null"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest OnPointerEvent0018 inputEventConsumer is null"; return; } - // eventType - bool retOnPointerEvent15 = - AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(4) == - EventType::TYPE_TOUCH_END) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent15); - 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(3), - EventType::TYPE_TOUCH_GUIDE_GESTURE_END); + sleep(1); // gestureId EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), static_cast(GestureType::GESTURE_INVALID)); - // touch action to multimode - EXPECT_EQ(static_cast(MMI::MockInputManager::GetTouchActions().size()), 0); - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent018 ends"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent018 ends"; } /** @@ -1552,43 +1250,41 @@ HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEven * @tc.name:OnPointerEvent * @tc.desc: Check the one finger tap and then two finger tap event, interval > 300ms, expect two gesture event. */ -HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent019, TestSize.Level1) +HWTEST_F(AamsTouchExplorationTest, AamsTouchExplorationTest_Moduletest_OnPointerEvent019, TestSize.Level1) { - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent019 starts"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent019 starts"; AccessibilityHelper::GetInstance().GetEventType() = {}; MMI::MockInputManager::ClearTouchActions(); std::vector points = {}; MMI::PointerEvent::PointerItem point1 = {}; - TouchGuiderPointSet(point1, 0, 100, 100); + TouchExplorationPointSet(point1, 0, 100, 100); MMI::PointerEvent::PointerItem point2 = {}; - TouchGuiderPointSet(point2, 1, 200, 100); + TouchExplorationPointSet(point2, 1, 200, 100); bool eventProduceRst = OneFingerTapAndTwoFingerTapEventProduce(points, point1, point2, true); if (!eventProduceRst) { - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest OnPointerEvent0019 inputEventConsumer is null"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest OnPointerEvent0019 inputEventConsumer is null"; return; } sleep(1); - // eventType - bool retOnPointerEvent15 = - AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(5) == - EventType::TYPE_TOUCH_GUIDE_GESTURE_END) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent15); + // event type + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), EventType::TYPE_TOUCH_END); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), EventType::TYPE_TOUCH_BEGIN); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3), EventType::TYPE_TOUCH_END); + + // action type + EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(0), MMI::PointerEvent::POINTER_ACTION_HOVER_ENTER); + EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(1), MMI::PointerEvent::POINTER_ACTION_HOVER_EXIT); // gestureId - EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), 25); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), GestureType::GESTURE_TWO_FINGER_SINGLE_TAP); - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent019 ends"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent019 ends"; } /** @@ -1596,52 +1292,39 @@ HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEven * @tc.name:OnPointerEvent * @tc.desc: Check the three finger single tap event. */ -HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent020, TestSize.Level1) +HWTEST_F(AamsTouchExplorationTest, AamsTouchExplorationTest_Moduletest_OnPointerEvent020, TestSize.Level1) { - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent020 starts"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent020 starts"; AccessibilityHelper::GetInstance().GetEventType() = {}; MMI::MockInputManager::ClearTouchActions(); std::vector points = {}; MMI::PointerEvent::PointerItem point1 = {}; - TouchGuiderPointSet(point1, 0, 100, 100); + TouchExplorationPointSet(point1, 0, 100, 100); MMI::PointerEvent::PointerItem point2 = {}; - TouchGuiderPointSet(point2, 1, 200, 100); + TouchExplorationPointSet(point2, 1, 200, 100); MMI::PointerEvent::PointerItem point3 = {}; - TouchGuiderPointSet(point3, 2, 300, 100); + TouchExplorationPointSet(point3, 2, 300, 100); std::vector pointVec{point1, point2, point3}; bool eventProduceRst = MultiFingerTapEventProduce(points, pointVec, 1, false); if (!eventProduceRst) { - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest OnPointerEvent0020 inputEventConsumer is null"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest OnPointerEvent0020 inputEventConsumer is null"; return; } sleep(1); - // eventType - bool ret = - AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == - EventType::TYPE_TOUCH_END) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(ret); + // event type 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(3), - EventType::TYPE_TOUCH_GUIDE_GESTURE_END); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), EventType::TYPE_TOUCH_END); // gestureId EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), static_cast(GestureType::GESTURE_THREE_FINGER_SINGLE_TAP)); - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent020 ends"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent020 ends"; } /** @@ -1649,54 +1332,41 @@ HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEven * @tc.name:OnPointerEvent * @tc.desc: Check the four finger single tap event. */ -HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent021, TestSize.Level1) +HWTEST_F(AamsTouchExplorationTest, AamsTouchExplorationTest_Moduletest_OnPointerEvent021, TestSize.Level1) { - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent021 starts"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent021 starts"; AccessibilityHelper::GetInstance().GetEventType() = {}; MMI::MockInputManager::ClearTouchActions(); std::vector points = {}; MMI::PointerEvent::PointerItem point1 = {}; - TouchGuiderPointSet(point1, 0, 100, 100); + TouchExplorationPointSet(point1, 0, 100, 100); MMI::PointerEvent::PointerItem point2 = {}; - TouchGuiderPointSet(point2, 1, 200, 100); + TouchExplorationPointSet(point2, 1, 200, 100); MMI::PointerEvent::PointerItem point3 = {}; - TouchGuiderPointSet(point3, 2, 300, 100); + TouchExplorationPointSet(point3, 2, 300, 100); MMI::PointerEvent::PointerItem point4 = {}; - TouchGuiderPointSet(point4, 3, 400, 100); + TouchExplorationPointSet(point4, 3, 400, 100); std::vector pointVec{point1, point2, point3, point4}; bool eventProduceRst = MultiFingerTapEventProduce(points, pointVec, 1, false); if (!eventProduceRst) { - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest OnPointerEvent0021 inputEventConsumer is null"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest OnPointerEvent0021 inputEventConsumer is null"; return; } sleep(1); - // eventType - bool ret = - AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == - EventType::TYPE_TOUCH_END) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(ret); + // event type 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(3), - EventType::TYPE_TOUCH_GUIDE_GESTURE_END); + EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), EventType::TYPE_TOUCH_END); // gestureId EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), static_cast(GestureType::GESTURE_FOUR_FINGER_SINGLE_TAP)); - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent021 ends"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent021 ends"; } /** @@ -1704,52 +1374,35 @@ HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEven * @tc.name:OnPointerEvent * @tc.desc: Check the three finger double tap event. */ -HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent022, TestSize.Level1) +HWTEST_F(AamsTouchExplorationTest, AamsTouchExplorationTest_Moduletest_OnPointerEvent022, TestSize.Level1) { - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent022 starts"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent022 starts"; AccessibilityHelper::GetInstance().GetEventType() = {}; MMI::MockInputManager::ClearTouchActions(); std::vector points = {}; MMI::PointerEvent::PointerItem point1 = {}; - TouchGuiderPointSet(point1, 0, 100, 100); + TouchExplorationPointSet(point1, 0, 100, 100); MMI::PointerEvent::PointerItem point2 = {}; - TouchGuiderPointSet(point2, 1, 200, 100); + TouchExplorationPointSet(point2, 1, 200, 100); MMI::PointerEvent::PointerItem point3 = {}; - TouchGuiderPointSet(point3, 2, 300, 100); + TouchExplorationPointSet(point3, 2, 300, 100); std::vector pointVec{point1, point2, point3}; bool eventProduceRst = MultiFingerTapEventProduce(points, pointVec, 2, false); if (!eventProduceRst) { - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest OnPointerEvent0022 inputEventConsumer is null"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest OnPointerEvent0022 inputEventConsumer is null"; return; } sleep(1); - // eventType - bool ret = - AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(4) == - 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(5), - EventType::TYPE_TOUCH_GUIDE_GESTURE_END); - // gestureId EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), static_cast(GestureType::GESTURE_THREE_FINGER_DOUBLE_TAP)); - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent022 ends"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent022 ends"; } /** @@ -1757,52 +1410,35 @@ HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEven * @tc.name:OnPointerEvent * @tc.desc: Check the three finger double tap and hold event. */ -HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent023, TestSize.Level1) +HWTEST_F(AamsTouchExplorationTest, AamsTouchExplorationTest_Moduletest_OnPointerEvent023, TestSize.Level1) { - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent023 starts"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent023 starts"; AccessibilityHelper::GetInstance().GetEventType() = {}; MMI::MockInputManager::ClearTouchActions(); std::vector points = {}; MMI::PointerEvent::PointerItem point1 = {}; - TouchGuiderPointSet(point1, 0, 100, 100); + TouchExplorationPointSet(point1, 0, 100, 100); MMI::PointerEvent::PointerItem point2 = {}; - TouchGuiderPointSet(point2, 1, 200, 100); + TouchExplorationPointSet(point2, 1, 200, 100); MMI::PointerEvent::PointerItem point3 = {}; - TouchGuiderPointSet(point3, 2, 300, 100); + TouchExplorationPointSet(point3, 2, 300, 100); std::vector pointVec{point1, point2, point3}; bool eventProduceRst = MultiFingerTapEventProduce(points, pointVec, 2, true); if (!eventProduceRst) { - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest OnPointerEvent0023 inputEventConsumer is null"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest OnPointerEvent0023 inputEventConsumer is null"; return; } sleep(1); - // eventType - bool ret = - AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == - 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(4), - 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) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent023 ends"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent023 ends"; } /** @@ -1810,52 +1446,35 @@ HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEven * @tc.name:OnPointerEvent * @tc.desc: Check the three finger triple tap event. */ -HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent024, TestSize.Level1) +HWTEST_F(AamsTouchExplorationTest, AamsTouchExplorationTest_Moduletest_OnPointerEvent024, TestSize.Level1) { - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent024 starts"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent024 starts"; AccessibilityHelper::GetInstance().GetEventType() = {}; MMI::MockInputManager::ClearTouchActions(); std::vector points = {}; MMI::PointerEvent::PointerItem point1 = {}; - TouchGuiderPointSet(point1, 0, 100, 100); + TouchExplorationPointSet(point1, 0, 100, 100); MMI::PointerEvent::PointerItem point2 = {}; - TouchGuiderPointSet(point2, 1, 200, 100); + TouchExplorationPointSet(point2, 1, 200, 100); MMI::PointerEvent::PointerItem point3 = {}; - TouchGuiderPointSet(point3, 2, 300, 100); + TouchExplorationPointSet(point3, 2, 300, 100); std::vector pointVec{point1, point2, point3}; bool eventProduceRst = MultiFingerTapEventProduce(points, pointVec, 3, false); if (!eventProduceRst) { - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest OnPointerEvent0024 inputEventConsumer is null"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest OnPointerEvent0024 inputEventConsumer is null"; return; } sleep(1); - // eventType - bool ret = - AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(6) == - 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(7), - EventType::TYPE_TOUCH_GUIDE_GESTURE_END); - // gestureId EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), static_cast(GestureType::GESTURE_THREE_FINGER_TRIPLE_TAP)); - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent024 ends"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent024 ends"; } /** @@ -1863,52 +1482,35 @@ HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEven * @tc.name:OnPointerEvent * @tc.desc: Check the three finger triple tap and hold event. */ -HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent025, TestSize.Level1) +HWTEST_F(AamsTouchExplorationTest, AamsTouchExplorationTest_Moduletest_OnPointerEvent025, TestSize.Level1) { - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent025 starts"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent025 starts"; AccessibilityHelper::GetInstance().GetEventType() = {}; MMI::MockInputManager::ClearTouchActions(); std::vector points = {}; MMI::PointerEvent::PointerItem point1 = {}; - TouchGuiderPointSet(point1, 0, 100, 100); + TouchExplorationPointSet(point1, 0, 100, 100); MMI::PointerEvent::PointerItem point2 = {}; - TouchGuiderPointSet(point2, 1, 200, 100); + TouchExplorationPointSet(point2, 1, 200, 100); MMI::PointerEvent::PointerItem point3 = {}; - TouchGuiderPointSet(point3, 2, 300, 100); + TouchExplorationPointSet(point3, 2, 300, 100); std::vector pointVec{point1, point2, point3}; bool eventProduceRst = MultiFingerTapEventProduce(points, pointVec, 3, true); if (!eventProduceRst) { - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest OnPointerEvent0025 inputEventConsumer is null"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest OnPointerEvent0025 inputEventConsumer is null"; return; } sleep(1); - // eventType - bool ret = - AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == - 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(6), - 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) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent025 ends"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent025 ends"; } /** @@ -1916,54 +1518,519 @@ HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEven * @tc.name:OnPointerEvent * @tc.desc: Check the four finger double tap event. */ -HWTEST_F(MockAamsTouchGuideTest, MockAamsTouchGuideTest_Moduletest_OnPointerEvent026, TestSize.Level1) +HWTEST_F(AamsTouchExplorationTest, AamsTouchExplorationTest_Moduletest_OnPointerEvent026, TestSize.Level1) { - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent026 starts"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent026 starts"; AccessibilityHelper::GetInstance().GetEventType() = {}; MMI::MockInputManager::ClearTouchActions(); std::vector points = {}; MMI::PointerEvent::PointerItem point1 = {}; - TouchGuiderPointSet(point1, 0, 100, 100); + TouchExplorationPointSet(point1, 0, 100, 100); MMI::PointerEvent::PointerItem point2 = {}; - TouchGuiderPointSet(point2, 1, 200, 100); + TouchExplorationPointSet(point2, 1, 200, 100); MMI::PointerEvent::PointerItem point3 = {}; - TouchGuiderPointSet(point3, 2, 300, 100); + TouchExplorationPointSet(point3, 2, 300, 100); MMI::PointerEvent::PointerItem point4 = {}; - TouchGuiderPointSet(point4, 3, 400, 100); + TouchExplorationPointSet(point4, 3, 400, 100); std::vector pointVec{point1, point2, point3, point4}; bool eventProduceRst = MultiFingerTapEventProduce(points, pointVec, 2, false); if (!eventProduceRst) { - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest OnPointerEvent0026 inputEventConsumer is null"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest OnPointerEvent0026 inputEventConsumer is null"; return; } sleep(1); - // eventType - bool ret = - AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(4) == - 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(5), - EventType::TYPE_TOUCH_GUIDE_GESTURE_END); - // gestureId EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), static_cast(GestureType::GESTURE_FOUR_FINGER_DOUBLE_TAP)); - GTEST_LOG_(INFO) << "MockAamsTouchGuideTest MockAamsTouchGuideTest_Moduletest_OnPointerEvent026 ends"; + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent026 ends"; +} + +/** + * @tc.number: OnPointerEvent027 + * @tc.name:OnPointerEvent + * @tc.desc: Check the four finger double tap event and hold. + */ +HWTEST_F(AamsTouchExplorationTest, AamsTouchExplorationTest_Moduletest_OnPointerEvent027, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent027 starts"; + + AccessibilityHelper::GetInstance().GetEventType() = {}; + MMI::MockInputManager::ClearTouchActions(); + + std::vector points = {}; + MMI::PointerEvent::PointerItem point1 = {}; + TouchExplorationPointSet(point1, 0, 100, 100); + MMI::PointerEvent::PointerItem point2 = {}; + TouchExplorationPointSet(point2, 1, 200, 100); + MMI::PointerEvent::PointerItem point3 = {}; + TouchExplorationPointSet(point3, 2, 300, 100); + MMI::PointerEvent::PointerItem point4 = {}; + TouchExplorationPointSet(point4, 3, 400, 100); + std::vector pointVec{point1, point2, point3, point4}; + + bool eventProduceRst = MultiFingerTapEventProduce(points, pointVec, 2, true); + if (!eventProduceRst) { + GTEST_LOG_(INFO) << "AamsTouchExplorationTest OnPointerEvent0027 inputEventConsumer is null"; + return; + } + + sleep(1); + + // gestureId + EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), + static_cast(GestureType::GESTURE_FOUR_FINGER_DOUBLE_TAP_AND_HOLD)); + + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent027 ends"; +} + +/** + * @tc.number: OnPointerEvent028 + * @tc.name:OnPointerEvent + * @tc.desc: Check the four finger triple tap event. + */ +HWTEST_F(AamsTouchExplorationTest, AamsTouchExplorationTest_Moduletest_OnPointerEvent028, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent028 starts"; + + AccessibilityHelper::GetInstance().GetEventType() = {}; + MMI::MockInputManager::ClearTouchActions(); + + std::vector points = {}; + MMI::PointerEvent::PointerItem point1 = {}; + TouchExplorationPointSet(point1, 0, 100, 100); + MMI::PointerEvent::PointerItem point2 = {}; + TouchExplorationPointSet(point2, 1, 200, 100); + MMI::PointerEvent::PointerItem point3 = {}; + TouchExplorationPointSet(point3, 2, 300, 100); + MMI::PointerEvent::PointerItem point4 = {}; + TouchExplorationPointSet(point4, 3, 400, 100); + std::vector pointVec{point1, point2, point3, point4}; + + bool eventProduceRst = MultiFingerTapEventProduce(points, pointVec, 3, false); + if (!eventProduceRst) { + GTEST_LOG_(INFO) << "AamsTouchExplorationTest OnPointerEvent0028 inputEventConsumer is null"; + return; + } + + sleep(1); + + // gestureId + EXPECT_LE(AccessibilityHelper::GetInstance().GetGestureId(), + static_cast(GestureType::GESTURE_FOUR_FINGER_TRIPLE_TAP)); + + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent028 ends"; +} + +/** + * @tc.number: OnPointerEvent029 + * @tc.name:OnPointerEvent + * @tc.desc: Check the four finger tri[le tap event and hold. + */ +HWTEST_F(AamsTouchExplorationTest, AamsTouchExplorationTest_Moduletest_OnPointerEvent029, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent029 starts"; + + AccessibilityHelper::GetInstance().GetEventType() = {}; + MMI::MockInputManager::ClearTouchActions(); + + std::vector points = {}; + MMI::PointerEvent::PointerItem point1 = {}; + TouchExplorationPointSet(point1, 0, 100, 100); + MMI::PointerEvent::PointerItem point2 = {}; + TouchExplorationPointSet(point2, 1, 200, 100); + MMI::PointerEvent::PointerItem point3 = {}; + TouchExplorationPointSet(point3, 2, 300, 100); + MMI::PointerEvent::PointerItem point4 = {}; + TouchExplorationPointSet(point4, 3, 400, 100); + std::vector pointVec{point1, point2, point3, point4}; + + bool eventProduceRst = MultiFingerTapEventProduce(points, pointVec, 3, true); + if (!eventProduceRst) { + GTEST_LOG_(INFO) << "AamsTouchExplorationTest OnPointerEvent0029 inputEventConsumer is null"; + return; + } + + sleep(1); + + // gestureId + EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), + static_cast(GestureType::GESTURE_FOUR_FINGER_TRIPLE_TAP_AND_HOLD)); + + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent029 ends"; +} + +/** + * @tc.number: OnPointerEvent030 + * @tc.name:OnPointerEvent + * @tc.desc: Check the three finger swipe down. + */ +HWTEST_F(AamsTouchExplorationTest, AamsTouchExplorationTest_Moduletest_OnPointerEvent030, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent030 starts"; + + AccessibilityHelper::GetInstance().GetEventType() = {}; + MMI::MockInputManager::ClearTouchActions(); + + std::vector points = {}; + MMI::PointerEvent::PointerItem point1 = {}; + TouchExplorationPointSet(point1, 0, 100, 100); + MMI::PointerEvent::PointerItem point2 = {}; + TouchExplorationPointSet(point2, 1, 200, 100); + MMI::PointerEvent::PointerItem point3 = {}; + TouchExplorationPointSet(point3, 2, 300, 100); + std::vector pointStartVec{point1, point2, point3}; + + MMI::PointerEvent::PointerItem point11 = {}; + TouchExplorationPointSet(point11, 0, 100, 800); + MMI::PointerEvent::PointerItem point22 = {}; + TouchExplorationPointSet(point22, 1, 200, 800); + MMI::PointerEvent::PointerItem point33 = {}; + TouchExplorationPointSet(point33, 2, 300, 800); + std::vector pointEndVec{point11, point22, point33}; + + bool eventProduceRst = MultiFingerTapAndMoveEventProduce(points, pointStartVec, pointEndVec); + if (!eventProduceRst) { + GTEST_LOG_(INFO) << "AamsTouchExplorationTest OnPointerEvent0030 inputEventConsumer is null"; + return; + } + + sleep(1); + + // gestureId + EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), + static_cast(GestureType::GESTURE_THREE_FINGER_SWIPE_DOWN)); + + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent030 ends"; +} + +/** + * @tc.number: OnPointerEvent031 + * @tc.name:OnPointerEvent + * @tc.desc: Check the four finger swipe down. + */ +HWTEST_F(AamsTouchExplorationTest, AamsTouchExplorationTest_Moduletest_OnPointerEvent031, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent031 starts"; + + AccessibilityHelper::GetInstance().GetEventType() = {}; + MMI::MockInputManager::ClearTouchActions(); + + std::vector points = {}; + MMI::PointerEvent::PointerItem point1 = {}; + TouchExplorationPointSet(point1, 0, 100, 100); + MMI::PointerEvent::PointerItem point2 = {}; + TouchExplorationPointSet(point2, 1, 200, 100); + MMI::PointerEvent::PointerItem point3 = {}; + TouchExplorationPointSet(point3, 2, 300, 100); + MMI::PointerEvent::PointerItem point4 = {}; + TouchExplorationPointSet(point4, 3, 400, 100); + std::vector pointStartVec{point1, point2, point3, point4}; + + MMI::PointerEvent::PointerItem point11 = {}; + TouchExplorationPointSet(point11, 0, 100, 800); + MMI::PointerEvent::PointerItem point22 = {}; + TouchExplorationPointSet(point22, 1, 200, 800); + MMI::PointerEvent::PointerItem point33 = {}; + TouchExplorationPointSet(point33, 2, 300, 800); + MMI::PointerEvent::PointerItem point44 = {}; + TouchExplorationPointSet(point44, 3, 400, 800); + std::vector pointEndVec{point11, point22, point33, point44}; + + bool eventProduceRst = MultiFingerTapAndMoveEventProduce(points, pointStartVec, pointEndVec); + if (!eventProduceRst) { + GTEST_LOG_(INFO) << "AamsTouchExplorationTest OnPointerEvent0031 inputEventConsumer is null"; + return; + } + + sleep(1); + + // gestureId + EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), + static_cast(GestureType::GESTURE_FOUR_FINGER_SWIPE_DOWN)); + + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent031 ends"; +} + +/** + * @tc.number: OnPointerEvent032 + * @tc.name:OnPointerEvent + * @tc.desc: Check the three finger swipe up. + */ +HWTEST_F(AamsTouchExplorationTest, AamsTouchExplorationTest_Moduletest_OnPointerEvent032, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent032 starts"; + + AccessibilityHelper::GetInstance().GetEventType() = {}; + MMI::MockInputManager::ClearTouchActions(); + + std::vector points = {}; + MMI::PointerEvent::PointerItem point1 = {}; + TouchExplorationPointSet(point1, 0, 100, 800); + MMI::PointerEvent::PointerItem point2 = {}; + TouchExplorationPointSet(point2, 1, 200, 800); + MMI::PointerEvent::PointerItem point3 = {}; + TouchExplorationPointSet(point3, 2, 300, 800); + std::vector pointStartVec{point1, point2, point3}; + + MMI::PointerEvent::PointerItem point11 = {}; + TouchExplorationPointSet(point11, 0, 100, 100); + MMI::PointerEvent::PointerItem point22 = {}; + TouchExplorationPointSet(point22, 1, 200, 100); + MMI::PointerEvent::PointerItem point33 = {}; + TouchExplorationPointSet(point33, 2, 300, 100); + std::vector pointEndVec{point11, point22, point33}; + + bool eventProduceRst = MultiFingerTapAndMoveEventProduce(points, pointStartVec, pointEndVec); + if (!eventProduceRst) { + GTEST_LOG_(INFO) << "AamsTouchExplorationTest OnPointerEvent0032 inputEventConsumer is null"; + return; + } + + sleep(1); + + // gestureId + EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), + static_cast(GestureType::GESTURE_THREE_FINGER_SWIPE_UP)); + + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent032 ends"; +} + +/** + * @tc.number: OnPointerEvent033 + * @tc.name:OnPointerEvent + * @tc.desc: Check the three finger swipe left. + */ +HWTEST_F(AamsTouchExplorationTest, AamsTouchExplorationTest_Moduletest_OnPointerEvent033, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent033 starts"; + + AccessibilityHelper::GetInstance().GetEventType() = {}; + MMI::MockInputManager::ClearTouchActions(); + + std::vector points = {}; + MMI::PointerEvent::PointerItem point1 = {}; + TouchExplorationPointSet(point1, 0, 600, 100); + MMI::PointerEvent::PointerItem point2 = {}; + TouchExplorationPointSet(point2, 1, 600, 200); + MMI::PointerEvent::PointerItem point3 = {}; + TouchExplorationPointSet(point3, 2, 600, 300); + std::vector pointStartVec{point1, point2, point3}; + + MMI::PointerEvent::PointerItem point11 = {}; + TouchExplorationPointSet(point11, 0, 100, 100); + MMI::PointerEvent::PointerItem point22 = {}; + TouchExplorationPointSet(point22, 1, 100, 200); + MMI::PointerEvent::PointerItem point33 = {}; + TouchExplorationPointSet(point33, 2, 100, 300); + std::vector pointEndVec{point11, point22, point33}; + + bool eventProduceRst = MultiFingerTapAndMoveEventProduce(points, pointStartVec, pointEndVec); + if (!eventProduceRst) { + GTEST_LOG_(INFO) << "AamsTouchExplorationTest OnPointerEvent0033 inputEventConsumer is null"; + return; + } + + sleep(1); + + // gestureId + EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), + static_cast(GestureType::GESTURE_THREE_FINGER_SWIPE_LEFT)); + + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent033 ends"; +} + +/** + * @tc.number: OnPointerEvent034 + * @tc.name:OnPointerEvent + * @tc.desc: Check the three finger swipe right. + */ +HWTEST_F(AamsTouchExplorationTest, AamsTouchExplorationTest_Moduletest_OnPointerEvent034, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent034 starts"; + + AccessibilityHelper::GetInstance().GetEventType() = {}; + MMI::MockInputManager::ClearTouchActions(); + + std::vector points = {}; + MMI::PointerEvent::PointerItem point1 = {}; + TouchExplorationPointSet(point1, 0, 100, 100); + MMI::PointerEvent::PointerItem point2 = {}; + TouchExplorationPointSet(point2, 1, 100, 200); + MMI::PointerEvent::PointerItem point3 = {}; + TouchExplorationPointSet(point3, 2, 100, 300); + std::vector pointStartVec{point1, point2, point3}; + + MMI::PointerEvent::PointerItem point11 = {}; + TouchExplorationPointSet(point11, 0, 600, 100); + MMI::PointerEvent::PointerItem point22 = {}; + TouchExplorationPointSet(point22, 1, 600, 200); + MMI::PointerEvent::PointerItem point33 = {}; + TouchExplorationPointSet(point33, 2, 600, 300); + std::vector pointEndVec{point11, point22, point33}; + + bool eventProduceRst = MultiFingerTapAndMoveEventProduce(points, pointStartVec, pointEndVec); + if (!eventProduceRst) { + GTEST_LOG_(INFO) << "AamsTouchExplorationTest OnPointerEvent0034 inputEventConsumer is null"; + return; + } + + sleep(1); + + // gestureId + EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), + static_cast(GestureType::GESTURE_THREE_FINGER_SWIPE_RIGHT)); + + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent034 ends"; +} + +/** + * @tc.number: OnPointerEvent035 + * @tc.name:OnPointerEvent + * @tc.desc: Check the four finger swipe up. + */ +HWTEST_F(AamsTouchExplorationTest, AamsTouchExplorationTest_Moduletest_OnPointerEvent035, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent035 starts"; + + AccessibilityHelper::GetInstance().GetEventType() = {}; + MMI::MockInputManager::ClearTouchActions(); + + std::vector points = {}; + MMI::PointerEvent::PointerItem point1 = {}; + TouchExplorationPointSet(point1, 0, 100, 800); + MMI::PointerEvent::PointerItem point2 = {}; + TouchExplorationPointSet(point2, 1, 200, 800); + MMI::PointerEvent::PointerItem point3 = {}; + TouchExplorationPointSet(point3, 2, 300, 800); + MMI::PointerEvent::PointerItem point4 = {}; + TouchExplorationPointSet(point4, 3, 400, 800); + std::vector pointStartVec{point1, point2, point3, point4}; + + MMI::PointerEvent::PointerItem point11 = {}; + TouchExplorationPointSet(point11, 0, 100, 100); + MMI::PointerEvent::PointerItem point22 = {}; + TouchExplorationPointSet(point22, 1, 200, 100); + MMI::PointerEvent::PointerItem point33 = {}; + TouchExplorationPointSet(point33, 2, 300, 100); + MMI::PointerEvent::PointerItem point44 = {}; + TouchExplorationPointSet(point44, 3, 400, 100); + std::vector pointEndVec{point11, point22, point33, point44}; + + bool eventProduceRst = MultiFingerTapAndMoveEventProduce(points, pointStartVec, pointEndVec); + if (!eventProduceRst) { + GTEST_LOG_(INFO) << "AamsTouchExplorationTest OnPointerEvent0035 inputEventConsumer is null"; + return; + } + + sleep(1); + + // gestureId + EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), + static_cast(GestureType::GESTURE_FOUR_FINGER_SWIPE_UP)); + + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent035 ends"; +} + +/** + * @tc.number: OnPointerEvent036 + * @tc.name:OnPointerEvent + * @tc.desc: Check the four finger swipe left. + */ +HWTEST_F(AamsTouchExplorationTest, AamsTouchExplorationTest_Moduletest_OnPointerEvent036, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent036 starts"; + + AccessibilityHelper::GetInstance().GetEventType() = {}; + MMI::MockInputManager::ClearTouchActions(); + + std::vector points = {}; + MMI::PointerEvent::PointerItem point1 = {}; + TouchExplorationPointSet(point1, 0, 600, 100); + MMI::PointerEvent::PointerItem point2 = {}; + TouchExplorationPointSet(point2, 1, 600, 200); + MMI::PointerEvent::PointerItem point3 = {}; + TouchExplorationPointSet(point3, 2, 600, 300); + MMI::PointerEvent::PointerItem point4 = {}; + TouchExplorationPointSet(point4, 3, 600, 400); + std::vector pointStartVec{point1, point2, point3, point4}; + + MMI::PointerEvent::PointerItem point11 = {}; + TouchExplorationPointSet(point11, 0, 100, 100); + MMI::PointerEvent::PointerItem point22 = {}; + TouchExplorationPointSet(point22, 1, 100, 200); + MMI::PointerEvent::PointerItem point33 = {}; + TouchExplorationPointSet(point33, 2, 100, 300); + MMI::PointerEvent::PointerItem point44 = {}; + TouchExplorationPointSet(point44, 3, 100, 400); + std::vector pointEndVec{point11, point22, point33, point44}; + + bool eventProduceRst = MultiFingerTapAndMoveEventProduce(points, pointStartVec, pointEndVec); + if (!eventProduceRst) { + GTEST_LOG_(INFO) << "AamsTouchExplorationTest OnPointerEvent0036 inputEventConsumer is null"; + return; + } + + sleep(1); + + // gestureId + EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), + static_cast(GestureType::GESTURE_FOUR_FINGER_SWIPE_LEFT)); + + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent036 ends"; +} + +/** + * @tc.number: OnPointerEvent037 + * @tc.name:OnPointerEvent + * @tc.desc: Check the four finger swipe right. + */ +HWTEST_F(AamsTouchExplorationTest, AamsTouchExplorationTest_Moduletest_OnPointerEvent037, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent037 starts"; + + AccessibilityHelper::GetInstance().GetEventType() = {}; + MMI::MockInputManager::ClearTouchActions(); + + std::vector points = {}; + MMI::PointerEvent::PointerItem point1 = {}; + TouchExplorationPointSet(point1, 0, 100, 100); + MMI::PointerEvent::PointerItem point2 = {}; + TouchExplorationPointSet(point2, 1, 100, 200); + MMI::PointerEvent::PointerItem point3 = {}; + TouchExplorationPointSet(point3, 2, 100, 300); + MMI::PointerEvent::PointerItem point4 = {}; + TouchExplorationPointSet(point4, 3, 100, 400); + std::vector pointStartVec{point1, point2, point3, point4}; + + MMI::PointerEvent::PointerItem point11 = {}; + TouchExplorationPointSet(point11, 0, 600, 100); + MMI::PointerEvent::PointerItem point22 = {}; + TouchExplorationPointSet(point22, 1, 600, 200); + MMI::PointerEvent::PointerItem point33 = {}; + TouchExplorationPointSet(point33, 2, 600, 300); + MMI::PointerEvent::PointerItem point44 = {}; + TouchExplorationPointSet(point44, 3, 600, 400); + std::vector pointEndVec{point11, point22, point33, point44}; + + bool eventProduceRst = MultiFingerTapAndMoveEventProduce(points, pointStartVec, pointEndVec); + if (!eventProduceRst) { + GTEST_LOG_(INFO) << "AamsTouchExplorationTest OnPointerEvent0037 inputEventConsumer is null"; + return; + } + + sleep(1); + + // gestureId + EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), + static_cast(GestureType::GESTURE_FOUR_FINGER_SWIPE_RIGHT)); + + GTEST_LOG_(INFO) << "AamsTouchExplorationTest AamsTouchExplorationTest_Moduletest_OnPointerEvent037 ends"; } } // namespace Accessibility } // namespace OHOS \ No newline at end of file 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 deleted file mode 100755 index 2305b04c..00000000 --- a/services/test/moduletest/aamstest/aams_accessibility_touch_guider_test/aams_accessibility_touch_guider_test.cpp +++ /dev/null @@ -1,3558 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include "accessibility_touch_guider.h" -#include "accessibility_account_data.h" -#include "accessibility_common_helper.h" -#include "accessibility_display_manager.h" -#include "accessibility_element_operator_stub.h" -#include "accessibility_input_interceptor.h" -#include "accessibility_mt_helper.h" -#include "accessible_ability_channel.h" -#include "accessible_ability_connection.h" -#include "accessible_ability_manager_service.h" -#include "iservice_registry.h" -#include "mock_accessibility_element_operator_callback.h" -#include "mock_accessibility_element_operator_impl.h" -#include "mock_accessibility_element_operator_proxy.h" -#include "mock_input_manager.h" - -using namespace testing; -using namespace testing::ext; - -namespace OHOS { -namespace Accessibility { -namespace { - constexpr int32_t POINT_ID_0 = 0; - constexpr int32_t POINT_ID_1 = 1; - constexpr int32_t POINT_ID_2 = 2; - const int32_t SLEEP_TIME_3 = 3; - const int32_t TAP_TIMES_1 = 1; - const int32_t TAP_TIMES_2 = 2; - const int32_t TAP_TIMES_3 = 3; - const int64_t TAP_TIME_INTERVAL = 100000; - const int32_t POINTER_ACTION_INVALID = -1; -} // namespace - -class AamsTouchGuideTest : public testing::Test { -public: - AamsTouchGuideTest() - {} - ~AamsTouchGuideTest() - {} - static void SetUpTestCase(); - static void TearDownTestCase(); - static void TouchGuiderPointSet(MMI::PointerEvent::PointerItem &point, int id, int x, int y); - bool OnPointerEventOnePointsTest1(std::vector &points, - MMI::PointerEvent::PointerItem point1, MMI::PointerEvent::PointerItem point2, - MMI::PointerEvent::PointerItem point3, MMI::PointerEvent::PointerItem point4); - bool OnPointerEventOnePointsTest3(std::vector &point, - MMI::PointerEvent::PointerItem point1, MMI::PointerEvent::PointerItem point2, - MMI::PointerEvent::PointerItem point3, MMI::PointerEvent::PointerItem point4); - bool OnPointerEventOnePointsTest7(std::vector &points, - MMI::PointerEvent::PointerItem point1, MMI::PointerEvent::PointerItem point2, - MMI::PointerEvent::PointerItem point3); - bool TwoFingerTapEventProduce(std::vector &points, - MMI::PointerEvent::PointerItem point1, MMI::PointerEvent::PointerItem point2, int32_t tapTimes, - bool holdFlag); - bool TwoFingerMoveEventProduce(std::vector &points, - MMI::PointerEvent::PointerItem point1, MMI::PointerEvent::PointerItem point2, - MMI::PointerEvent::PointerItem point3, MMI::PointerEvent::PointerItem point4); - bool OneFingerTapAndTwoFingerTapEventProduce(std::vector &points, - 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(); - -protected: - std::shared_ptr CreateMoveEvent(int32_t pointerCount, int32_t pointId); - std::shared_ptr CreateTouchEvent(int32_t action, int32_t pointId); - std::shared_ptr CreateTouchEvent(int32_t action, - std::vector &point, int64_t occurredTime, int64_t startTime, - int32_t pointId); - - sptr aastub_ = nullptr; - std::shared_ptr interceptorId_ = nullptr; - void WritefileAll(const char* fname, const char* data); - void AddAccessibilityWindowConnection(); -}; - -bool AamsTouchGuideTest::OnPointerEventOnePointsTest1(std::vector &points, - MMI::PointerEvent::PointerItem point1, MMI::PointerEvent::PointerItem point2, - MMI::PointerEvent::PointerItem point3, MMI::PointerEvent::PointerItem point4) -{ - points.emplace_back(point1); - std::shared_ptr event = - CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, 0, 0, 1); - auto inputEventConsumer = MMI::MockInputManager::GetInputEventConsumer(); - if (!inputEventConsumer) { - return false; - } - inputEventConsumer->OnInputEvent(event); - - points.emplace_back(point2); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, 0, 0, POINT_ID_2); - inputEventConsumer->OnInputEvent(event); - - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, points, 0, 0, 1); - inputEventConsumer->OnInputEvent(event); - - points.clear(); - points.emplace_back(point3); - points.emplace_back(point4); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, points, 0, 0, POINT_ID_2); - inputEventConsumer->OnInputEvent(event); - - points.clear(); - points.emplace_back(point3); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, 0, 0, 1); - inputEventConsumer->OnInputEvent(event); - - points.clear(); - points.emplace_back(point4); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, 0, 0, POINT_ID_2); - inputEventConsumer->OnInputEvent(event); - return true; -} - -bool AamsTouchGuideTest::OnPointerEventOnePointsTest3(std::vector &point, - MMI::PointerEvent::PointerItem point1, MMI::PointerEvent::PointerItem point2, - MMI::PointerEvent::PointerItem point3, MMI::PointerEvent::PointerItem point4) -{ - point.emplace_back(point1); - std::shared_ptr event = - CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, point, 0, 0, 1); - auto inputEventConsumer = MMI::MockInputManager::GetInputEventConsumer(); - if (!inputEventConsumer) { - // GTEST_LOG_(INFO) << "AamsTouchGuideTest OnPointerEvent003 inputEventConsumer is null"; - return false; - } - inputEventConsumer->OnInputEvent(event); - - point.clear(); - point.emplace_back(point2); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, point, 0, 0, 1); - inputEventConsumer->OnInputEvent(event); - - point.clear(); - point.emplace_back(point3); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, point, 0, 0, 1); - inputEventConsumer->OnInputEvent(event); - - point.clear(); - point.emplace_back(point4); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, point, 0, 0, 1); - inputEventConsumer->OnInputEvent(event); - - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, point, 0, 0, 1); - inputEventConsumer->OnInputEvent(event); - return true; -} - -bool AamsTouchGuideTest::OnPointerEventOnePointsTest7(std::vector &points, - MMI::PointerEvent::PointerItem point1, MMI::PointerEvent::PointerItem point2, - MMI::PointerEvent::PointerItem point3) -{ - points.emplace_back(point1); - std::shared_ptr event = - CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, 0, 0, 1); - auto inputEventConsumer = MMI::MockInputManager::GetInputEventConsumer(); - if (!inputEventConsumer) { - return false; - } - inputEventConsumer->OnInputEvent(event); - - points.clear(); - points.emplace_back(point2); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, points, 0, 0, 1); - inputEventConsumer->OnInputEvent(event); - - points.clear(); - points.emplace_back(point3); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, points, 0, 0, 1); - inputEventConsumer->OnInputEvent(event); - - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, 0, 0, 1); - inputEventConsumer->OnInputEvent(event); - return true; -} - -bool AamsTouchGuideTest::TwoFingerTapEventProduce(std::vector &points, - MMI::PointerEvent::PointerItem point1, MMI::PointerEvent::PointerItem point2, int32_t tapTimes, bool holdFlag) -{ - auto inputEventConsumer = MMI::MockInputManager::GetInputEventConsumer(); - if (!inputEventConsumer) { - GTEST_LOG_(INFO) << "AamsTouchGuideTest TwoFingerTapEventProduce inputEventConsumer is nullptr"; - return false; - } - - std::shared_ptr event; - int64_t occurredTime = 0; - for (int32_t tapIndex = 1; tapIndex <= tapTimes; tapIndex++) { - points.clear(); - points.emplace_back(point1); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, occurredTime, 0, POINT_ID_0); - inputEventConsumer->OnInputEvent(event); - - points.emplace_back(point2); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, occurredTime, 0, POINT_ID_1); - 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); - } - - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, 0, 0, POINT_ID_0); - inputEventConsumer->OnInputEvent(event); - - points.clear(); - points.emplace_back(point2); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, 0, 0, POINT_ID_1); - inputEventConsumer->OnInputEvent(event); - - occurredTime += TAP_TIME_INTERVAL; - } - return true; -} - -bool AamsTouchGuideTest::TwoFingerMoveEventProduce(std::vector &points, - MMI::PointerEvent::PointerItem point1, MMI::PointerEvent::PointerItem point2, - MMI::PointerEvent::PointerItem point3, MMI::PointerEvent::PointerItem point4) -{ - auto inputEventConsumer = MMI::MockInputManager::GetInputEventConsumer(); - if (!inputEventConsumer) { - GTEST_LOG_(INFO) << "AamsTouchGuideTest TwoFingerMoveEventProduce inputEventConsumer is null"; - return false; - } - - std::shared_ptr event; - points.clear(); - points.emplace_back(point1); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, 0, 0, POINT_ID_0); - inputEventConsumer->OnInputEvent(event); - - points.emplace_back(point2); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, 0, 0, POINT_ID_1); - inputEventConsumer->OnInputEvent(event); - - points.clear(); - points.emplace_back(point3); - points.emplace_back(point4); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, points, 0, 0, POINT_ID_0); - inputEventConsumer->OnInputEvent(event); - - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, points, 0, 0, POINT_ID_1); - inputEventConsumer->OnInputEvent(event); - - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, 0, 0, POINT_ID_0); - inputEventConsumer->OnInputEvent(event); - - points.clear(); - points.emplace_back(point4); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, 0, 0, POINT_ID_1); - inputEventConsumer->OnInputEvent(event); - - return true; -} - -bool AamsTouchGuideTest::OneFingerTapAndTwoFingerTapEventProduce(std::vector &points, - MMI::PointerEvent::PointerItem point1, MMI::PointerEvent::PointerItem point2, bool isSeparateFlag) -{ - auto inputEventConsumer = MMI::MockInputManager::GetInputEventConsumer(); - if (!inputEventConsumer) { - GTEST_LOG_(INFO) << "AamsTouchGuideTest OneFingerTapAndTwoFingerTapEventProduce inputEventConsumer is null"; - return false; - } - - std::shared_ptr event; - // one finger event start - points.clear(); - points.emplace_back(point1); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, 0, 0, POINT_ID_0); - inputEventConsumer->OnInputEvent(event); - - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, 0, 0, POINT_ID_0); - inputEventConsumer->OnInputEvent(event); - - if (isSeparateFlag) { - sleep(1); - } - // two finger event start - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, TAP_TIME_INTERVAL, 0, POINT_ID_0); - inputEventConsumer->OnInputEvent(event); - - points.emplace_back(point2); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, TAP_TIME_INTERVAL, 0, POINT_ID_1); - inputEventConsumer->OnInputEvent(event); - - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, points, 0, 0, POINT_ID_0); - inputEventConsumer->OnInputEvent(event); - - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, 0, 0, POINT_ID_0); - inputEventConsumer->OnInputEvent(event); - - points.clear(); - points.emplace_back(point2); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, 0, 0, POINT_ID_1); - inputEventConsumer->OnInputEvent(event); - - return true; -} - -bool AamsTouchGuideTest::TwoFingerTapAndOneFingerTapEventProduce(std::vector &points, - MMI::PointerEvent::PointerItem point1, MMI::PointerEvent::PointerItem point2) -{ - auto inputEventConsumer = MMI::MockInputManager::GetInputEventConsumer(); - if (!inputEventConsumer) { - GTEST_LOG_(INFO) << "AamsTouchGuideTest TwoFingerTapAndOneFingerTapEventProduce inputEventConsumer is null"; - return false; - } - - std::shared_ptr event; - // two finger event start - points.clear(); - points.emplace_back(point1); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, 0, 0, POINT_ID_0); - inputEventConsumer->OnInputEvent(event); - - points.emplace_back(point2); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, 0, 0, POINT_ID_1); - inputEventConsumer->OnInputEvent(event); - - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, points, 0, 0, POINT_ID_0); - inputEventConsumer->OnInputEvent(event); - - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, 0, 0, POINT_ID_0); - inputEventConsumer->OnInputEvent(event); - - points.clear(); - points.emplace_back(point2); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, 0, 0, POINT_ID_1); - - // one finger event start - points.clear(); - points.emplace_back(point1); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, TAP_TIME_INTERVAL, 0, POINT_ID_0); - inputEventConsumer->OnInputEvent(event); - - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_MOVE, points, 0, 0, POINT_ID_0); - inputEventConsumer->OnInputEvent(event); - - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, 0, 0, POINT_ID_0); - inputEventConsumer->OnInputEvent(event); - - return true; -} - -bool AamsTouchGuideTest::MultiFingerTapEventProduce(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); - point.SetDisplayX(x); - point.SetDisplayY(y); -} - -void AamsTouchGuideTest::WritefileAll(const char* fname, const char* data) -{ - FILE* fp = nullptr; - if (!(fp = fopen(fname, "w"))) { - printf("open file %s fail \n", fname); - return; - } - - (void)fprintf(fp, "%s", data); - (void)fclose(fp); -} - -void AamsTouchGuideTest::SetUpTestCase() -{ - GTEST_LOG_(INFO) << "AamsTouchGuideTest SetUpTestCase"; - Singleton::GetInstance().OnStart(); - AccessibilityCommonHelper::GetInstance().WaitForServicePublish(); - Singleton::GetInstance().SwitchedUser(AccessibilityHelper::accountId_); - GTEST_LOG_(INFO) << "AccessibleAbilityManagerService is published"; -} - -void AamsTouchGuideTest::TearDownTestCase() -{ - GTEST_LOG_(INFO) << "AamsTouchGuideTest TearDownTestCase"; - AccessibilityHelper::GetInstance().SetGestureId(0); - AccessibilityHelper::GetInstance().GetEventType().clear(); - Singleton::GetInstance().OnStop(); -} - -void AamsTouchGuideTest::SetUp() -{ - GTEST_LOG_(INFO) << "AamsTouchGuideTest SetUp"; - - interceptorId_ = std::make_shared(); - MMI::InputManager::GetInstance()->AddInterceptor(interceptorId_); - - // add an ability connection client - AccessibilityAbilityInitParams initParams; - std::shared_ptr abilityInfo = std::make_shared(initParams); - abilityInfo->SetAccessibilityAbilityType(AccessibilityAbilityTypes::ACCESSIBILITY_ABILITY_TYPE_ALL); - abilityInfo->SetCapabilityValues(Capability::CAPABILITY_TOUCH_GUIDE); - AppExecFwk::ElementName elementName("deviceId", "bundleName", "name"); - auto accountData = Singleton::GetInstance().GetCurrentAccountData(); - accountData->AddInstalledAbility(*abilityInfo); - sleep(1); - sptr connection = - new AccessibleAbilityConnection(accountData->GetAccountId(), 0, *abilityInfo); - aastub_ = new AccessibleAbilityChannel(accountData->GetAccountId(), abilityInfo->GetId()); - connection->OnAbilityConnectDoneSync(elementName, aastub_); - - AddAccessibilityWindowConnection(); -} - -void AamsTouchGuideTest::TearDown() -{ - GTEST_LOG_(INFO) << "AamsTouchGuideTest TearDown"; - - Singleton::GetInstance().DeregisterElementOperator(0); - sleep(SLEEP_TIME_3); - aastub_ = nullptr; - interceptorId_ = nullptr; - AccessibilityHelper::GetInstance().SetGestureId(0); - AccessibilityHelper::GetInstance().GetEventType().clear(); - MMI::MockInputManager::ClearTouchActions(); -} - -std::shared_ptr AamsTouchGuideTest::CreateTouchEvent(int32_t action, int32_t pointId) -{ - std::shared_ptr touchEvent = MMI::PointerEvent::Create(); - MMI::PointerEvent::PointerItem item = {}; - - item.SetPointerId(1); - item.SetPressed(action == MMI::PointerEvent::POINTER_ACTION_UP ? false : true); - touchEvent->AddPointerItem(item); - touchEvent->SetSourceType(MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN); - touchEvent->SetPointerAction(action); - touchEvent->SetPointerId(pointId); - - return touchEvent; -} - -std::shared_ptr AamsTouchGuideTest::CreateMoveEvent(int32_t pointerCount, int32_t pointId) -{ - std::shared_ptr touchEvent = MMI::PointerEvent::Create(); - MMI::PointerEvent::PointerItem item = {}; - - for (int32_t i = 0; i < pointerCount; i++) { - item.SetPointerId(i + 1); - item.SetPressed(true); - touchEvent->AddPointerItem(item); - } - touchEvent->SetSourceType(MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN); - touchEvent->SetPointerAction(MMI::PointerEvent::POINTER_ACTION_MOVE); - touchEvent->SetPointerId(pointId); - - return touchEvent; -} - -std::shared_ptr AamsTouchGuideTest::CreateTouchEvent(int32_t action, - std::vector &points, int64_t occurredTime, int64_t startTime, - int32_t pointId) -{ - std::shared_ptr pointerEvent = MMI::PointerEvent::Create(); - - for (auto &point : points) { - if (point.GetPointerId() == pointId) { - point.SetPressed(action == MMI::PointerEvent::POINTER_ACTION_UP ? false : true); - } else { - point.SetPressed(true); - } - pointerEvent->AddPointerItem(point); - } - pointerEvent->SetPointerId(pointId); - pointerEvent->SetSourceType(MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN); - pointerEvent->SetPointerAction(action); - pointerEvent->SetActionStartTime(startTime); - pointerEvent->SetActionTime(occurredTime); - - return pointerEvent; -} - -void AamsTouchGuideTest::AddAccessibilityWindowConnection() -{ - GTEST_LOG_(INFO) << "aamsAccessibleAbilityChannelTest AddAccessibilityWindowConnection"; - // accessibility interaction connection - int32_t windowId = 0; - std::shared_ptr mockCallback = - std::make_shared(); - sptr stub = - new MockAccessibilityElementOperatorImpl(windowId, nullptr, *mockCallback); - sptr proxy = new MockAccessibilityElementOperatorProxy(stub); - GTEST_LOG_(INFO) << "aams RegisterElementOperator"; - Singleton::GetInstance().RegisterElementOperator(windowId, proxy, true); -} - -/** - * @tc.number: OnPointerEvent001 - * @tc.name:OnPointerEvent - * @tc.desc: Check the event that two fingers moving in same directions in dragging state. - */ -HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent001 starts"; - sleep(SLEEP_TIME_3); - - AccessibilityHelper::GetInstance().GetEventType() = {}; - MMI::MockInputManager::ClearTouchActions(); - std::vector points = {}; - MMI::PointerEvent::PointerItem point1 = {}; - TouchGuiderPointSet(point1, 1, 500, 500); - MMI::PointerEvent::PointerItem point2 = {}; - TouchGuiderPointSet(point2, 2, 1000, 500); - MMI::PointerEvent::PointerItem point3 = {}; - TouchGuiderPointSet(point3, 1, 2000, 500); - MMI::PointerEvent::PointerItem point4 = {}; - TouchGuiderPointSet(point4, 1, 2500, 500); - - bool flag = OnPointerEventOnePointsTest1(points, point1, point2, point3, point4); - if (!flag) { - GTEST_LOG_(INFO) << "AamsTouchGuideTest OnPointerEvent001 inputEventConsumer is null"; - return; - } - - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - sleep(1); - int32_t eventTypeSize = - static_cast(AccessibilityHelper::GetInstance().GetEventType().size()); - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(eventTypeSize - 1) == - EventType::TYPE_TOUCH_GUIDE_GESTURE_END) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(ret); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN); - - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (MMI::MockInputManager::GetTouchActionOfTargetIndex(2) == MMI::PointerEvent::POINTER_ACTION_UP) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(0), MMI::PointerEvent::POINTER_ACTION_DOWN); - EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(1), MMI::PointerEvent::POINTER_ACTION_MOVE); - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent001 ENDs"; -} - -/** - * @tc.number: OnPointerEvent002 - * @tc.name:OnPointerEvent - * @tc.desc: Check the event that move slowly with one finger. - */ -HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent002, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent002 starts"; - - AccessibilityHelper::GetInstance().GetEventType() = {}; - MMI::MockInputManager::ClearTouchActions(); - std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, 1); - auto inputEventConsumer = MMI::MockInputManager::GetInputEventConsumer(); - if (!inputEventConsumer) { - GTEST_LOG_(INFO) << "AamsTouchGuideTest OnPointerEvent002 inputEventConsumer is null"; - return; - } - inputEventConsumer->OnInputEvent(event); - bool retOnPointerEvent2 = - AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1) == - EventType::TYPE_TOUCH_GUIDE_BEGIN) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent2); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN); - - event = CreateMoveEvent(1, 1); - inputEventConsumer->OnInputEvent(event); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, 1); - inputEventConsumer->OnInputEvent(event); - retOnPointerEvent2 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3) == - EventType::TYPE_TOUCH_GUIDE_END) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent2); - EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(0), MMI::PointerEvent::POINTER_ACTION_HOVER_ENTER); - EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(1), MMI::PointerEvent::POINTER_ACTION_HOVER_MOVE); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), EventType::TYPE_TOUCH_END); - - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent002 ENDs"; -} - -/** - * @tc.number: OnPointerEvent003 - * @tc.name:OnPointerEvent - * @tc.desc: Check the GESTURE_SWIPE_LEFT_THEN_RIGHT gesture. - */ -HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent003, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent003 starts"; - - AccessibilityHelper::GetInstance().GetEventType() = {}; - MMI::MockInputManager::ClearTouchActions(); - std::vector points = {}; - MMI::PointerEvent::PointerItem point1 = {}; - TouchGuiderPointSet(point1, 1, 2500, 2500); - MMI::PointerEvent::PointerItem point2 = {}; - TouchGuiderPointSet(point2, 1, 1500, 2500); - MMI::PointerEvent::PointerItem point3 = {}; - TouchGuiderPointSet(point3, 1, 0, 2500); - MMI::PointerEvent::PointerItem point4 = {}; - TouchGuiderPointSet(point4, 1, 2500, 2250); - - OnPointerEventOnePointsTest3(points, point1, point2, point3, point4); - - // Determine event type - bool retOnPointerEvent3 = - AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == - EventType::TYPE_TOUCH_END) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent3); - 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(3), - EventType::TYPE_TOUCH_GUIDE_GESTURE_END); - // Determine action - 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() == - static_cast(GestureType::GESTURE_SWIPE_LEFT_THEN_RIGHT)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent3); - - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent003 ENDs"; -} - -/** - * @tc.number: OnPointerEvent004 - * @tc.name:OnPointerEvent - * @tc.desc: Check the GESTURE_SWIPE_DOWN_THEN_UP gesture. - */ -HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent004, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent004 starts"; - - AccessibilityHelper::GetInstance().GetEventType() = {}; - MMI::MockInputManager::ClearTouchActions(); - std::vector points = {}; - MMI::PointerEvent::PointerItem point1 = {}; - TouchGuiderPointSet(point1, 1, 2500, 2500); - MMI::PointerEvent::PointerItem point2 = {}; - TouchGuiderPointSet(point2, 1, 2500, 3500); - MMI::PointerEvent::PointerItem point3 = {}; - TouchGuiderPointSet(point3, 1, 2500, 5000); - MMI::PointerEvent::PointerItem point4 = {}; - TouchGuiderPointSet(point4, 1, 2250, 2500); - - bool flag = OnPointerEventOnePointsTest3(points, point1, point2, point3, point4); - if (!flag) { - GTEST_LOG_(INFO) << "AamsTouchGuideTest OnPointerEvent003 inputEventConsumer is null"; - return; - } - - // Determine event type - bool retOnPointerEvent4 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == - EventType::TYPE_TOUCH_END) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent4); - 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(3), - EventType::TYPE_TOUCH_GUIDE_GESTURE_END); - // Determine action - 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() == - static_cast(GestureType::GESTURE_SWIPE_DOWN_THEN_UP)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent4); - - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent004 ENDs"; -} - -/** - * @tc.number: OnPointerEvent005 - * @tc.name:OnPointerEvent - * @tc.desc: Check the GESTURE_SWIPE_RIGHT_THEN_LEFT gesture. - */ -HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent005, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent005 starts"; - - AccessibilityHelper::GetInstance().GetEventType() = {}; - MMI::MockInputManager::ClearTouchActions(); - std::vector points = {}; - MMI::PointerEvent::PointerItem point1 = {}; - TouchGuiderPointSet(point1, 1, 2500, 2500); - MMI::PointerEvent::PointerItem point2 = {}; - TouchGuiderPointSet(point2, 1, 3500, 2500); - MMI::PointerEvent::PointerItem point3 = {}; - TouchGuiderPointSet(point3, 1, 5000, 2500); - MMI::PointerEvent::PointerItem point4 = {}; - TouchGuiderPointSet(point4, 1, 2500, 2250); - - bool flag = OnPointerEventOnePointsTest3(points, point1, point2, point3, point4); - if (!flag) { - GTEST_LOG_(INFO) << "AamsTouchGuideTest OnPointerEvent005 inputEventConsumer is null"; - return; - } - - // Determine event type - bool retOnPointerEvent5 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == - EventType::TYPE_TOUCH_END) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent5); - 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(3), - EventType::TYPE_TOUCH_GUIDE_GESTURE_END); - // Determine action - 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() == - static_cast(GestureType::GESTURE_SWIPE_RIGHT_THEN_LEFT)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent5); - - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent005 ENDs"; -} - -/** - * @tc.number: OnPointerEvent006 - * @tc.name:OnPointerEvent - * @tc.desc: Check the GESTURE_SWIPE_UP_THEN_DOWN gesture. - */ -HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent006, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent006 starts"; - - AccessibilityHelper::GetInstance().GetEventType() = {}; - MMI::MockInputManager::ClearTouchActions(); - std::vector points = {}; - MMI::PointerEvent::PointerItem point1 = {}; - TouchGuiderPointSet(point1, 1, 2500, 2500); - MMI::PointerEvent::PointerItem point2 = {}; - TouchGuiderPointSet(point2, 1, 2500, 1500); - MMI::PointerEvent::PointerItem point3 = {}; - TouchGuiderPointSet(point3, 1, 2500, 0); - MMI::PointerEvent::PointerItem point4 = {}; - TouchGuiderPointSet(point4, 1, 2250, 2500); - - bool flag = OnPointerEventOnePointsTest3(points, point1, point2, point3, point4); - if (!flag) { - GTEST_LOG_(INFO) << "AamsTouchGuideTest OnPointerEvent006 inputEventConsumer is null"; - return; - } - - // Determine event type - bool retOnPointerEvent6 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == - EventType::TYPE_TOUCH_END) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent6); - 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(3), - EventType::TYPE_TOUCH_GUIDE_GESTURE_END); - // Determine action - 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() == - static_cast(GestureType::GESTURE_SWIPE_UP_THEN_DOWN)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent6); - - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent006 ENDs"; -} - -/** - * @tc.number: OnPointerEvent007 - * @tc.name:OnPointerEvent - * @tc.desc: Check the UP gesture. - */ -HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent007, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent007 starts"; - - AccessibilityHelper::GetInstance().GetEventType() = {}; - MMI::MockInputManager::ClearTouchActions(); - std::vector points = {}; - MMI::PointerEvent::PointerItem point1 = {}; - TouchGuiderPointSet(point1, 1, 2500, 2500); - MMI::PointerEvent::PointerItem point2 = {}; - TouchGuiderPointSet(point2, 1, 2500, 1500); - MMI::PointerEvent::PointerItem point3 = {}; - TouchGuiderPointSet(point3, 1, 2500, 0); - - bool flag = OnPointerEventOnePointsTest7(points, point1, point2, point3); - if (!flag) { - GTEST_LOG_(INFO) << "AamsTouchGuideTest OnPointerEvent007 inputEventConsumer is null"; - return; - } - - // Determine event type - bool retOnPointerEvent7 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == - EventType::TYPE_TOUCH_END) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent7); - 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(3), - EventType::TYPE_TOUCH_GUIDE_GESTURE_END); - // Determine action - 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)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent7); - - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent007 ENDs"; -} - -/** - * @tc.number: OnPointerEvent008 - * @tc.name:OnPointerEvent - * @tc.desc: Check the single tap event. - */ -HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent008, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent008 starts"; - - AccessibilityHelper::GetInstance().GetEventType() = {}; - MMI::MockInputManager::ClearTouchActions(); - std::shared_ptr event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, 1); - auto inputEventConsumer = MMI::MockInputManager::GetInputEventConsumer(); - if (!inputEventConsumer) { - GTEST_LOG_(INFO) << "AamsTouchGuideTest OnPointerEvent009 inputEventConsumer is null"; - return; - } - inputEventConsumer->OnInputEvent(event); - - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, 1); - inputEventConsumer->OnInputEvent(event); - // Determine event type - bool retOnPointerEvent8 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3) == - EventType::TYPE_TOUCH_GUIDE_END) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent8); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), - EventType::TYPE_TOUCH_END); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), - EventType::TYPE_TOUCH_GUIDE_BEGIN); - // Determine action - EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(0), MMI::PointerEvent::POINTER_ACTION_HOVER_ENTER); - EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(1), MMI::PointerEvent::POINTER_ACTION_HOVER_EXIT); - - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent008 ends"; -} - -/** - * @tc.number: OnPointerEvent009 - * @tc.name:OnPointerEvent - * @tc.desc: Check the double tap and long press event. - */ -HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent009, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent009 starts"; - - AccessibilityHelper::GetInstance().GetEventType() = {}; - MMI::MockInputManager::ClearTouchActions(); - std::vector points = {}; - MMI::PointerEvent::PointerItem point1 = {}; - point1.SetDisplayX(300); - point1.SetDisplayY(500); - point1.SetPointerId(1); - - points.emplace_back(point1); - std::shared_ptr event = - CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, 0, 0, 1); - auto inputEventConsumer = MMI::MockInputManager::GetInputEventConsumer(); - if (!inputEventConsumer) { - GTEST_LOG_(INFO) << "AamsTouchGuideTest OnPointerEvent009 inputEventConsumer is null"; - return; - } - inputEventConsumer->OnInputEvent(event); - sleep(1); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, 40, 0, 1); - inputEventConsumer->OnInputEvent(event); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, 200, 0, 1); - inputEventConsumer->OnInputEvent(event); - sleep(SLEEP_TIME_3); - - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, 0, 0, 1); - inputEventConsumer->OnInputEvent(event); - // Determine event type - bool retOnPointerEvent9 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(6) == - EventType::TYPE_TOUCH_END) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent9); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), EventType::TYPE_TOUCH_GUIDE_BEGIN); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), EventType::TYPE_TOUCH_END); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3), EventType::TYPE_TOUCH_BEGIN); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(4), EventType::TYPE_TOUCH_GUIDE_END); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(5), EventType::TYPE_TOUCH_GUIDE_BEGIN); - // Determine action - EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(0), MMI::PointerEvent::POINTER_ACTION_HOVER_ENTER); - - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent009 ends"; -} - -/** - * @tc.number: OnPointerEvent010 - * @tc.name:OnPointerEvent - * @tc.desc: Check the double-tap event. - */ -HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent010, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent010 starts"; - - AccessibilityHelper::GetInstance().GetEventType() = {}; - MMI::MockInputManager::ClearTouchActions(); - std::vector points = {}; - MMI::PointerEvent::PointerItem point1 = {}; - point1.SetDisplayX(300); - point1.SetDisplayY(500); - point1.SetPointerId(1); - - points.emplace_back(point1); - std::shared_ptr event = - CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, 0, 0, 1); - auto inputEventConsumer = MMI::MockInputManager::GetInputEventConsumer(); - if (!inputEventConsumer) { - GTEST_LOG_(INFO) << "AamsTouchGuideTest OnPointerEvent010 inputEventConsumer is null"; - return; - } - inputEventConsumer->OnInputEvent(event); - sleep(1); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, 0, 0, 1); - inputEventConsumer->OnInputEvent(event); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_DOWN, points, 100, 0, 1); - inputEventConsumer->OnInputEvent(event); - event = CreateTouchEvent(MMI::PointerEvent::POINTER_ACTION_UP, points, 0, 0, 1); - inputEventConsumer->OnInputEvent(event); - - // Determine event type - bool retOnPointerEvent10 = - AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(5) == - EventType::TYPE_TOUCH_END) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent10); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), EventType::TYPE_TOUCH_GUIDE_BEGIN); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2), EventType::TYPE_TOUCH_END); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(3), EventType::TYPE_TOUCH_BEGIN); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(4), EventType::TYPE_TOUCH_GUIDE_END); - // Determine action - EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(0), POINTER_ACTION_INVALID); - - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent010 ends"; -} - -/** - * @tc.number: OnPointerEvent011 - * @tc.name:OnPointerEvent - * @tc.desc: Check the two finger tap event. - */ -HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent011, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent011 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); - - bool eventProduceRst = TwoFingerTapEventProduce(points, point1, point2, TAP_TIMES_1, false); - if (!eventProduceRst) { - GTEST_LOG_(INFO) << "AamsTouchGuideTest OnPointerEvent0011 inputEventConsumer is null"; - return; - } - - sleep(1); - - // eventType - bool retOnPointerEvent11 = - AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == - EventType::TYPE_TOUCH_END) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent11); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), - EventType::TYPE_TOUCH_BEGIN); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), - EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN); - - // gestureId - EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), 25); - - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent011 ends"; -} - -/** - * @tc.number: OnPointerEvent012 - * @tc.name:OnPointerEvent - * @tc.desc: Check the two finger double tap event. - */ -HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent012, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent012 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); - - bool eventProduceRst = TwoFingerTapEventProduce(points, point1, point2, TAP_TIMES_2, false); - if (!eventProduceRst) { - GTEST_LOG_(INFO) << "AamsTouchGuideTest OnPointerEvent0011 inputEventConsumer is null"; - return; - } - - sleep(1); - - // eventType - bool retOnPointerEvent12 = - AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(4) == - EventType::TYPE_TOUCH_END) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent12); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), - EventType::TYPE_TOUCH_BEGIN); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), - EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN); - - // gestureId - EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), - static_cast(GestureType::GESTURE_TWO_FINGER_DOUBLE_TAP)); - - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent012 ends"; -} - -/** - * @tc.number: OnPointerEvent013 - * @tc.name:OnPointerEvent - * @tc.desc: Check the two finger triple tap event. - */ -HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent013, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent013 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); - - bool eventProduceRst = TwoFingerTapEventProduce(points, point1, point2, TAP_TIMES_3, false); - if (!eventProduceRst) { - GTEST_LOG_(INFO) << "AamsTouchGuideTest OnPointerEvent0011 inputEventConsumer is null"; - return; - } - - sleep(1); - - // eventType - bool retOnPointerEvent13 = - AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(6) == - EventType::TYPE_TOUCH_END) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent13); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), - EventType::TYPE_TOUCH_BEGIN); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1), - EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN); - - // gestureId - EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), - static_cast(GestureType::GESTURE_TWO_FINGER_TRIPLE_TAP)); - - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent013 ends"; -} - -/** - * @tc.number: OnPointerEvent014 - * @tc.name:OnPointerEvent - * @tc.desc: Check the two finger double tap and hold event. - */ -HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent014, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent014 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); - - bool eventProduceRst = TwoFingerTapEventProduce(points, point1, point2, TAP_TIMES_2, true); - if (!eventProduceRst) { - GTEST_LOG_(INFO) << "AamsTouchGuideTest OnPointerEvent0014 inputEventConsumer is null"; - return; - } - - sleep(1); - - // eventType - bool retOnPointerEvent14 = - AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == - EventType::TYPE_TOUCH_END) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent14); - 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(4), - EventType::TYPE_TOUCH_GUIDE_GESTURE_END); - - // gestureId - EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), - static_cast(GestureType::GESTURE_TWO_FINGER_DOUBLE_TAP_AND_HOLD)); - - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent014 ends"; -} - -/** - * @tc.number: OnPointerEvent015 - * @tc.name:OnPointerEvent - * @tc.desc: Check the two finger triple tap and hold event. - */ -HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent015, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent015 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); - - bool eventProduceRst = TwoFingerTapEventProduce(points, point1, point2, TAP_TIMES_3, true); - if (!eventProduceRst) { - GTEST_LOG_(INFO) << "AamsTouchGuideTest OnPointerEvent0015 inputEventConsumer is null"; - return; - } - - sleep(1); - - // eventType - bool retOnPointerEvent15 = - AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == - EventType::TYPE_TOUCH_END) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent15); - 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(6), - EventType::TYPE_TOUCH_GUIDE_GESTURE_END); - - // gestureId - EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), - static_cast(GestureType::GESTURE_TWO_FINGER_TRIPLE_TAP_AND_HOLD)); - - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent015 ends"; -} - -/** - * @tc.number: OnPointerEvent016 - * @tc.name:OnPointerEvent - * @tc.desc: Check the two finger move event. - */ -HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent016, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent016 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, 0, 100, 400); - MMI::PointerEvent::PointerItem point4 = {}; - TouchGuiderPointSet(point4, 1, 200, 400); - - bool eventProduceRst = TwoFingerMoveEventProduce(points, point1, point2, point3, point4); - if (!eventProduceRst) { - GTEST_LOG_(INFO) << "AamsTouchGuideTest OnPointerEvent0016 inputEventConsumer is null"; - return; - } - - // eventType - bool retOnPointerEvent15 = - 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(retOnPointerEvent15); - 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); - - EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(0), MMI::PointerEvent::POINTER_ACTION_DOWN); - EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(1), MMI::PointerEvent::POINTER_ACTION_MOVE); - EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(2), MMI::PointerEvent::POINTER_ACTION_UP); - - // gestureId - EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), static_cast(GestureType::GESTURE_INVALID)); - - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent016 ends"; -} - -/** - * @tc.number: OnPointerEvent017 - * @tc.name:OnPointerEvent - * @tc.desc: Check the one finger tap and then two finger tap event, expect do not recognize as any gesture. - */ -HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent017, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent017 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); - - bool eventProduceRst = OneFingerTapAndTwoFingerTapEventProduce(points, point1, point2, false); - if (!eventProduceRst) { - GTEST_LOG_(INFO) << "AamsTouchGuideTest OnPointerEvent0017 inputEventConsumer is null"; - return; - } - - // eventType - bool retOnPointerEvent15 = - AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(1) == - EventType::TYPE_TOUCH_END) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent15); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN); - - // gestureId - EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), static_cast(GestureType::GESTURE_INVALID)); - - // touch action to multimode - EXPECT_EQ(static_cast(MMI::MockInputManager::GetTouchActions().size()), 0); - - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent017 ends"; -} - -/** - * @tc.number: OnPointerEvent018 - * @tc.name:OnPointerEvent - * @tc.desc: Check the two finger tap and then one finger tap event, expect do not recognize as any gesture. - */ -HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent018, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent018 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); - - bool eventProduceRst = TwoFingerTapAndOneFingerTapEventProduce(points, point1, point2); - if (!eventProduceRst) { - GTEST_LOG_(INFO) << "AamsTouchGuideTest OnPointerEvent0018 inputEventConsumer is null"; - return; - } - - // eventType - bool retOnPointerEvent15 = - AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(4) == - EventType::TYPE_TOUCH_END) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent15); - 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(3), - EventType::TYPE_TOUCH_GUIDE_GESTURE_END); - - // gestureId - EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), static_cast(GestureType::GESTURE_INVALID)); - - // touch action to multimode - EXPECT_EQ(static_cast(MMI::MockInputManager::GetTouchActions().size()), 0); - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent018 ends"; -} - -/** - * @tc.number: OnPointerEvent019 - * @tc.name:OnPointerEvent - * @tc.desc: Check the one finger tap and then two finger tap event, interval > 300ms, expect two gesture event. - */ -HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent019, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent019 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); - - bool eventProduceRst = OneFingerTapAndTwoFingerTapEventProduce(points, point1, point2, true); - if (!eventProduceRst) { - GTEST_LOG_(INFO) << "AamsTouchGuideTest OnPointerEvent0019 inputEventConsumer is null"; - return; - } - - sleep(1); - - // eventType - bool retOnPointerEvent15 = - AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(5) == - EventType::TYPE_TOUCH_GUIDE_GESTURE_END) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent15); - - // gestureId - EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), 25); - - 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; - } - - sleep(1); - - // eventType - bool ret = - AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == - 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(3), - 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; - } - - sleep(1); - - // eventType - bool ret = - AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == - 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(3), - 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; - } - - sleep(1); - - // eventType - bool ret = - AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(4) == - 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(5), - 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; - } - - sleep(1); - - // eventType - bool ret = - AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == - 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(4), - 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; - } - - sleep(1); - - // eventType - bool ret = - AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(6) == - 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(7), - 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; - } - - sleep(1); - - // eventType - bool ret = - AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == - 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(6), - 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; - } - - sleep(1); - - // eventType - bool ret = - AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(4) == - 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(5), - 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; - } - - sleep(1); - - // eventType - bool ret = - AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == - 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(4), - 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; - } - - sleep(1); - - // eventType - bool ret = - AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(6) == - 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(7), - EventType::TYPE_TOUCH_GUIDE_GESTURE_END); - - // gestureId - EXPECT_LE(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 triple 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; - } - - sleep(1); - - // eventType - bool ret = - AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == - 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(6), - 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(2) == - 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(3), - 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(2) == - 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(3), - 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"; -} - -/** - * @tc.number: OnPointerEvent032 - * @tc.name:OnPointerEvent - * @tc.desc: Check the three finger swipe up. - */ -HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent032, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent032 starts"; - - AccessibilityHelper::GetInstance().GetEventType() = {}; - MMI::MockInputManager::ClearTouchActions(); - - std::vector points = {}; - MMI::PointerEvent::PointerItem point1 = {}; - TouchGuiderPointSet(point1, 0, 100, 800); - MMI::PointerEvent::PointerItem point2 = {}; - TouchGuiderPointSet(point2, 1, 200, 800); - MMI::PointerEvent::PointerItem point3 = {}; - TouchGuiderPointSet(point3, 2, 300, 800); - std::vector pointStartVec{point1, point2, point3}; - - MMI::PointerEvent::PointerItem point11 = {}; - TouchGuiderPointSet(point11, 0, 100, 100); - MMI::PointerEvent::PointerItem point22 = {}; - TouchGuiderPointSet(point22, 1, 200, 100); - MMI::PointerEvent::PointerItem point33 = {}; - TouchGuiderPointSet(point33, 2, 300, 100); - std::vector pointEndVec{point11, point22, point33}; - - bool eventProduceRst = MultiFingerTapAndMoveEventProduce(points, pointStartVec, pointEndVec); - if (!eventProduceRst) { - GTEST_LOG_(INFO) << "AamsTouchGuideTest OnPointerEvent0032 inputEventConsumer is null"; - return; - } - - // eventType - bool ret = - AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == - 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(3), - EventType::TYPE_TOUCH_GUIDE_GESTURE_END); - - // gestureId - EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), - static_cast(GestureType::GESTURE_THREE_FINGER_SWIPE_UP)); - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent032 ends"; -} - -/** - * @tc.number: OnPointerEvent033 - * @tc.name:OnPointerEvent - * @tc.desc: Check the three finger swipe left. - */ -HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent033, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent033 starts"; - - AccessibilityHelper::GetInstance().GetEventType() = {}; - MMI::MockInputManager::ClearTouchActions(); - - std::vector points = {}; - MMI::PointerEvent::PointerItem point1 = {}; - TouchGuiderPointSet(point1, 0, 600, 100); - MMI::PointerEvent::PointerItem point2 = {}; - TouchGuiderPointSet(point2, 1, 600, 200); - MMI::PointerEvent::PointerItem point3 = {}; - TouchGuiderPointSet(point3, 2, 600, 300); - std::vector pointStartVec{point1, point2, point3}; - - MMI::PointerEvent::PointerItem point11 = {}; - TouchGuiderPointSet(point11, 0, 100, 100); - MMI::PointerEvent::PointerItem point22 = {}; - TouchGuiderPointSet(point22, 1, 100, 200); - MMI::PointerEvent::PointerItem point33 = {}; - TouchGuiderPointSet(point33, 2, 100, 300); - std::vector pointEndVec{point11, point22, point33}; - - bool eventProduceRst = MultiFingerTapAndMoveEventProduce(points, pointStartVec, pointEndVec); - if (!eventProduceRst) { - GTEST_LOG_(INFO) << "AamsTouchGuideTest OnPointerEvent0033 inputEventConsumer is null"; - return; - } - - // eventType - bool ret = - AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == - 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(3), - EventType::TYPE_TOUCH_GUIDE_GESTURE_END); - - // gestureId - EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), - static_cast(GestureType::GESTURE_THREE_FINGER_SWIPE_LEFT)); - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent033 ends"; -} - -/** - * @tc.number: OnPointerEvent034 - * @tc.name:OnPointerEvent - * @tc.desc: Check the three finger swipe right. - */ -HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent034, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent034 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, 100, 200); - MMI::PointerEvent::PointerItem point3 = {}; - TouchGuiderPointSet(point3, 2, 100, 300); - std::vector pointStartVec{point1, point2, point3}; - - MMI::PointerEvent::PointerItem point11 = {}; - TouchGuiderPointSet(point11, 0, 600, 100); - MMI::PointerEvent::PointerItem point22 = {}; - TouchGuiderPointSet(point22, 1, 600, 200); - MMI::PointerEvent::PointerItem point33 = {}; - TouchGuiderPointSet(point33, 2, 600, 300); - std::vector pointEndVec{point11, point22, point33}; - - bool eventProduceRst = MultiFingerTapAndMoveEventProduce(points, pointStartVec, pointEndVec); - if (!eventProduceRst) { - GTEST_LOG_(INFO) << "AamsTouchGuideTest OnPointerEvent0034 inputEventConsumer is null"; - return; - } - - // eventType - bool ret = - AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == - 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(3), - EventType::TYPE_TOUCH_GUIDE_GESTURE_END); - - // gestureId - EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), - static_cast(GestureType::GESTURE_THREE_FINGER_SWIPE_RIGHT)); - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent034 ends"; -} - -/** - * @tc.number: OnPointerEvent035 - * @tc.name:OnPointerEvent - * @tc.desc: Check the four finger swipe up. - */ -HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent035, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent035 starts"; - - AccessibilityHelper::GetInstance().GetEventType() = {}; - MMI::MockInputManager::ClearTouchActions(); - - std::vector points = {}; - MMI::PointerEvent::PointerItem point1 = {}; - TouchGuiderPointSet(point1, 0, 100, 800); - MMI::PointerEvent::PointerItem point2 = {}; - TouchGuiderPointSet(point2, 1, 200, 800); - MMI::PointerEvent::PointerItem point3 = {}; - TouchGuiderPointSet(point3, 2, 300, 800); - MMI::PointerEvent::PointerItem point4 = {}; - TouchGuiderPointSet(point4, 3, 400, 800); - std::vector pointStartVec{point1, point2, point3, point4}; - - MMI::PointerEvent::PointerItem point11 = {}; - TouchGuiderPointSet(point11, 0, 100, 100); - MMI::PointerEvent::PointerItem point22 = {}; - TouchGuiderPointSet(point22, 1, 200, 100); - MMI::PointerEvent::PointerItem point33 = {}; - TouchGuiderPointSet(point33, 2, 300, 100); - MMI::PointerEvent::PointerItem point44 = {}; - TouchGuiderPointSet(point44, 3, 400, 100); - std::vector pointEndVec{point11, point22, point33, point44}; - - bool eventProduceRst = MultiFingerTapAndMoveEventProduce(points, pointStartVec, pointEndVec); - if (!eventProduceRst) { - GTEST_LOG_(INFO) << "AamsTouchGuideTest OnPointerEvent0035 inputEventConsumer is null"; - return; - } - - // eventType - bool ret = - AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == - 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(3), - EventType::TYPE_TOUCH_GUIDE_GESTURE_END); - - // gestureId - EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), - static_cast(GestureType::GESTURE_FOUR_FINGER_SWIPE_UP)); - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent035 ends"; -} - -/** - * @tc.number: OnPointerEvent036 - * @tc.name:OnPointerEvent - * @tc.desc: Check the four finger swipe left. - */ -HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent036, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent036 starts"; - - AccessibilityHelper::GetInstance().GetEventType() = {}; - MMI::MockInputManager::ClearTouchActions(); - - std::vector points = {}; - MMI::PointerEvent::PointerItem point1 = {}; - TouchGuiderPointSet(point1, 0, 600, 100); - MMI::PointerEvent::PointerItem point2 = {}; - TouchGuiderPointSet(point2, 1, 600, 200); - MMI::PointerEvent::PointerItem point3 = {}; - TouchGuiderPointSet(point3, 2, 600, 300); - MMI::PointerEvent::PointerItem point4 = {}; - TouchGuiderPointSet(point4, 3, 600, 400); - std::vector pointStartVec{point1, point2, point3, point4}; - - MMI::PointerEvent::PointerItem point11 = {}; - TouchGuiderPointSet(point11, 0, 100, 100); - MMI::PointerEvent::PointerItem point22 = {}; - TouchGuiderPointSet(point22, 1, 100, 200); - MMI::PointerEvent::PointerItem point33 = {}; - TouchGuiderPointSet(point33, 2, 100, 300); - MMI::PointerEvent::PointerItem point44 = {}; - TouchGuiderPointSet(point44, 3, 100, 400); - std::vector pointEndVec{point11, point22, point33, point44}; - - bool eventProduceRst = MultiFingerTapAndMoveEventProduce(points, pointStartVec, pointEndVec); - if (!eventProduceRst) { - GTEST_LOG_(INFO) << "AamsTouchGuideTest OnPointerEvent0036 inputEventConsumer is null"; - return; - } - - // eventType - bool ret = - AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == - 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(3), - EventType::TYPE_TOUCH_GUIDE_GESTURE_END); - - // gestureId - EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), - static_cast(GestureType::GESTURE_FOUR_FINGER_SWIPE_LEFT)); - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent036 ends"; -} - -/** - * @tc.number: OnPointerEvent037 - * @tc.name:OnPointerEvent - * @tc.desc: Check the four finger swipe right. - */ -HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent037, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent037 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, 100, 200); - MMI::PointerEvent::PointerItem point3 = {}; - TouchGuiderPointSet(point3, 2, 100, 300); - MMI::PointerEvent::PointerItem point4 = {}; - TouchGuiderPointSet(point4, 3, 100, 400); - std::vector pointStartVec{point1, point2, point3, point4}; - - MMI::PointerEvent::PointerItem point11 = {}; - TouchGuiderPointSet(point11, 0, 600, 100); - MMI::PointerEvent::PointerItem point22 = {}; - TouchGuiderPointSet(point22, 1, 600, 200); - MMI::PointerEvent::PointerItem point33 = {}; - TouchGuiderPointSet(point33, 2, 600, 300); - MMI::PointerEvent::PointerItem point44 = {}; - TouchGuiderPointSet(point44, 3, 600, 400); - std::vector pointEndVec{point11, point22, point33, point44}; - - bool eventProduceRst = MultiFingerTapAndMoveEventProduce(points, pointStartVec, pointEndVec); - if (!eventProduceRst) { - GTEST_LOG_(INFO) << "AamsTouchGuideTest OnPointerEvent0037 inputEventConsumer is null"; - return; - } - - // eventType - bool ret = - AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == - 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(3), - EventType::TYPE_TOUCH_GUIDE_GESTURE_END); - - // gestureId - EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), - static_cast(GestureType::GESTURE_FOUR_FINGER_SWIPE_RIGHT)); - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent037 ends"; -} - -/** - * @tc.number: OnPointerEvent038 - * @tc.name:OnPointerEvent - * @tc.desc: Check the event that two fingers moving in down directions in dragging state. - */ -HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent038, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent038 starts"; - sleep(SLEEP_TIME_3); - - AccessibilityHelper::GetInstance().GetEventType() = {}; - MMI::MockInputManager::ClearTouchActions(); - std::vector points = {}; - MMI::PointerEvent::PointerItem point1 = {}; - TouchGuiderPointSet(point1, 1, 500, 500); - MMI::PointerEvent::PointerItem point2 = {}; - TouchGuiderPointSet(point2, 2, 1000, 500); - MMI::PointerEvent::PointerItem point3 = {}; - TouchGuiderPointSet(point3, 1, 500, 1000); - MMI::PointerEvent::PointerItem point4 = {}; - TouchGuiderPointSet(point4, 1, 1000, 1000); - - bool flag = OnPointerEventOnePointsTest1(points, point1, point2, point3, point4); - if (!flag) { - GTEST_LOG_(INFO) << "AamsTouchGuideTest OnPointerEvent038 inputEventConsumer is null"; - return; - } - - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - sleep(1); - int32_t eventTypeSize = - static_cast(AccessibilityHelper::GetInstance().GetEventType().size()); - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(eventTypeSize - 1) == - EventType::TYPE_TOUCH_GUIDE_GESTURE_END) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(ret); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN); - - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (MMI::MockInputManager::GetTouchActionOfTargetIndex(2) == MMI::PointerEvent::POINTER_ACTION_UP) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(0), MMI::PointerEvent::POINTER_ACTION_DOWN); - EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(1), MMI::PointerEvent::POINTER_ACTION_MOVE); - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent038 ENDs"; -} - -/** - * @tc.number: OnPointerEvent039 - * @tc.name:OnPointerEvent - * @tc.desc: Check the event that two fingers moving in right and down directions in dragging state. - */ -HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent039, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent039 starts"; - sleep(SLEEP_TIME_3); - - AccessibilityHelper::GetInstance().GetEventType() = {}; - MMI::MockInputManager::ClearTouchActions(); - std::vector points = {}; - MMI::PointerEvent::PointerItem point1 = {}; - TouchGuiderPointSet(point1, 1, 500, 500); - MMI::PointerEvent::PointerItem point2 = {}; - TouchGuiderPointSet(point2, 2, 1000, 500); - MMI::PointerEvent::PointerItem point3 = {}; - TouchGuiderPointSet(point3, 1, 1000, 1000); - MMI::PointerEvent::PointerItem point4 = {}; - TouchGuiderPointSet(point4, 1, 1500, 1000); - - bool flag = OnPointerEventOnePointsTest1(points, point1, point2, point3, point4); - if (!flag) { - GTEST_LOG_(INFO) << "AamsTouchGuideTest OnPointerEvent039 inputEventConsumer is null"; - return; - } - - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - sleep(1); - int32_t eventTypeSize = - static_cast(AccessibilityHelper::GetInstance().GetEventType().size()); - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(eventTypeSize - 1) == - EventType::TYPE_TOUCH_GUIDE_GESTURE_END) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(ret); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN); - - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (MMI::MockInputManager::GetTouchActionOfTargetIndex(2) == MMI::PointerEvent::POINTER_ACTION_UP) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(0), MMI::PointerEvent::POINTER_ACTION_DOWN); - EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(1), MMI::PointerEvent::POINTER_ACTION_MOVE); - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent039 ENDs"; -} - -/** - * @tc.number: OnPointerEvent040 - * @tc.name:OnPointerEvent - * @tc.desc: Check the event that two fingers zoom moving in right and down directions in dragging state. - */ -HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent040, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent040 starts"; - sleep(SLEEP_TIME_3); - - AccessibilityHelper::GetInstance().GetEventType() = {}; - MMI::MockInputManager::ClearTouchActions(); - std::vector points = {}; - MMI::PointerEvent::PointerItem point1 = {}; - TouchGuiderPointSet(point1, 1, 500, 500); - MMI::PointerEvent::PointerItem point2 = {}; - TouchGuiderPointSet(point2, 2, 1000, 500); - MMI::PointerEvent::PointerItem point3 = {}; - TouchGuiderPointSet(point3, 1, 2000, 1500); - MMI::PointerEvent::PointerItem point4 = {}; - TouchGuiderPointSet(point4, 1, 2500, 1000); - - bool flag = OnPointerEventOnePointsTest1(points, point1, point2, point3, point4); - if (!flag) { - GTEST_LOG_(INFO) << "AamsTouchGuideTest OnPointerEvent040 inputEventConsumer is null"; - return; - } - - bool ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - sleep(1); - int32_t eventTypeSize = - static_cast(AccessibilityHelper::GetInstance().GetEventType().size()); - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(eventTypeSize - 1) == - EventType::TYPE_TOUCH_GUIDE_GESTURE_END) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(ret); - EXPECT_EQ(AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(0), EventType::TYPE_TOUCH_BEGIN); - - ret = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (MMI::MockInputManager::GetTouchActionOfTargetIndex(2) == MMI::PointerEvent::POINTER_ACTION_UP) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(ret); - EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(0), MMI::PointerEvent::POINTER_ACTION_DOWN); - EXPECT_EQ(MMI::MockInputManager::GetTouchActionOfTargetIndex(1), MMI::PointerEvent::POINTER_ACTION_MOVE); - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent040 ENDs"; -} - -/** - * @tc.number: OnPointerEvent041 - * @tc.name:OnPointerEvent - * @tc.desc: Check the GESTURE_SWIPE_LEFT_THEN_RIGHT gesture. - */ -HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent041, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent041 starts"; - - AccessibilityHelper::GetInstance().GetEventType() = {}; - MMI::MockInputManager::ClearTouchActions(); - std::vector points = {}; - MMI::PointerEvent::PointerItem point1 = {}; - TouchGuiderPointSet(point1, 1, 2500, 2500); - MMI::PointerEvent::PointerItem point2 = {}; - TouchGuiderPointSet(point2, 1, 1500, 2200); - MMI::PointerEvent::PointerItem point3 = {}; - TouchGuiderPointSet(point3, 1, 0, 2200); - MMI::PointerEvent::PointerItem point4 = {}; - TouchGuiderPointSet(point4, 1, 2100, 2500); - - OnPointerEventOnePointsTest3(points, point1, point2, point3, point4); - - // Determine event type - bool retOnPointerEvent16 = - AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == - EventType::TYPE_TOUCH_END) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent16); - 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(3), - EventType::TYPE_TOUCH_GUIDE_GESTURE_END); - // Determine action - 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 - retOnPointerEvent16 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetGestureId() == - static_cast(GestureType::GESTURE_SWIPE_LEFT_THEN_RIGHT)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent16); - - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent041 ENDs"; -} - -/** - * @tc.number: OnPointerEvent042 - * @tc.name:OnPointerEvent - * @tc.desc: Check the GESTURE_SWIPE_DOWN_THEN_UP gesture. - */ -HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent042, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent042 starts"; - - AccessibilityHelper::GetInstance().GetEventType() = {}; - MMI::MockInputManager::ClearTouchActions(); - std::vector points = {}; - MMI::PointerEvent::PointerItem point1 = {}; - TouchGuiderPointSet(point1, 1, 1500, 2500); - MMI::PointerEvent::PointerItem point2 = {}; - TouchGuiderPointSet(point2, 1, 1500, 3500); - MMI::PointerEvent::PointerItem point3 = {}; - TouchGuiderPointSet(point3, 1, 1200, 5000); - MMI::PointerEvent::PointerItem point4 = {}; - TouchGuiderPointSet(point4, 1, 1250, 2500); - - bool flag = OnPointerEventOnePointsTest3(points, point1, point2, point3, point4); - if (!flag) { - GTEST_LOG_(INFO) << "AamsTouchGuideTest OnPointerEvent042 inputEventConsumer is null"; - return; - } - - // Determine event type - bool retOnPointerEvent17 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == - EventType::TYPE_TOUCH_END) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent17); - 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(3), - EventType::TYPE_TOUCH_GUIDE_GESTURE_END); - // Determine action - 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 - retOnPointerEvent17 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetGestureId() == - static_cast(GestureType::GESTURE_SWIPE_DOWN_THEN_UP)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent17); - - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent042 ENDs"; -} - -/** - * @tc.number: OnPointerEvent043 - * @tc.name:OnPointerEvent - * @tc.desc: Check the GESTURE_SWIPE_RIGHT_THEN_LEFT gesture. - */ -HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent043, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent043 starts"; - - AccessibilityHelper::GetInstance().GetEventType() = {}; - MMI::MockInputManager::ClearTouchActions(); - std::vector points = {}; - MMI::PointerEvent::PointerItem point1 = {}; - TouchGuiderPointSet(point1, 1, 2500, 1500); - MMI::PointerEvent::PointerItem point2 = {}; - TouchGuiderPointSet(point2, 1, 3500, 1500); - MMI::PointerEvent::PointerItem point3 = {}; - TouchGuiderPointSet(point3, 1, 5000, 1500); - MMI::PointerEvent::PointerItem point4 = {}; - TouchGuiderPointSet(point4, 1, 2500, 1250); - - bool flag = OnPointerEventOnePointsTest3(points, point1, point2, point3, point4); - if (!flag) { - GTEST_LOG_(INFO) << "AamsTouchGuideTest OnPointerEvent043 inputEventConsumer is null"; - return; - } - - // Determine event type - bool retOnPointerEvent18 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == - EventType::TYPE_TOUCH_END) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent18); - 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(3), - EventType::TYPE_TOUCH_GUIDE_GESTURE_END); - // Determine action - 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 - retOnPointerEvent18 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetGestureId() == - static_cast(GestureType::GESTURE_SWIPE_RIGHT_THEN_LEFT)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent18); - - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent043 ENDs"; -} - -/** - * @tc.number: OnPointerEvent044 - * @tc.name:OnPointerEvent - * @tc.desc: Check the GESTURE_SWIPE_UP_THEN_DOWN gesture. - */ -HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent044, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent044 starts"; - - AccessibilityHelper::GetInstance().GetEventType() = {}; - MMI::MockInputManager::ClearTouchActions(); - std::vector points = {}; - MMI::PointerEvent::PointerItem point1 = {}; - TouchGuiderPointSet(point1, 1, 1500, 2500); - MMI::PointerEvent::PointerItem point2 = {}; - TouchGuiderPointSet(point2, 1, 1500, 1500); - MMI::PointerEvent::PointerItem point3 = {}; - TouchGuiderPointSet(point3, 1, 1500, 0); - MMI::PointerEvent::PointerItem point4 = {}; - TouchGuiderPointSet(point4, 1, 1250, 2500); - - bool flag = OnPointerEventOnePointsTest3(points, point1, point2, point3, point4); - if (!flag) { - GTEST_LOG_(INFO) << "AamsTouchGuideTest OnPointerEvent044 inputEventConsumer is null"; - return; - } - - // Determine event type - bool retOnPointerEvent19 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == - EventType::TYPE_TOUCH_END) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent19); - 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(3), - EventType::TYPE_TOUCH_GUIDE_GESTURE_END); - // Determine action - 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 - retOnPointerEvent19 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetGestureId() == - static_cast(GestureType::GESTURE_SWIPE_UP_THEN_DOWN)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent19); - - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent044 ENDs"; -} - -/** - * @tc.number: OnPointerEvent045 - * @tc.name:OnPointerEvent - * @tc.desc: Check the UP gesture. - */ -HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent045, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent045 starts"; - - AccessibilityHelper::GetInstance().GetEventType() = {}; - MMI::MockInputManager::ClearTouchActions(); - std::vector points = {}; - MMI::PointerEvent::PointerItem point1 = {}; - TouchGuiderPointSet(point1, 1, 1500, 1500); - MMI::PointerEvent::PointerItem point2 = {}; - TouchGuiderPointSet(point2, 1, 1500, 500); - MMI::PointerEvent::PointerItem point3 = {}; - TouchGuiderPointSet(point3, 1, 1500, 0); - - bool flag = OnPointerEventOnePointsTest7(points, point1, point2, point3); - if (!flag) { - GTEST_LOG_(INFO) << "AamsTouchGuideTest OnPointerEvent045 inputEventConsumer is null"; - return; - } - - // Determine event type - bool retOnPointerEvent20 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == - EventType::TYPE_TOUCH_END) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent20); - 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(3), - EventType::TYPE_TOUCH_GUIDE_GESTURE_END); - // Determine action - 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 - retOnPointerEvent20 = AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetGestureId() == static_cast(GestureType::GESTURE_SWIPE_UP)) { - return true; - } else { - return false; - } - }), SLEEP_TIME_3); - EXPECT_TRUE(retOnPointerEvent20); - - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent045 ENDs"; -} - -/** - * @tc.number: OnPointerEvent046 - * @tc.name:OnPointerEvent - * @tc.desc: Check the three finger swipe down. - */ -HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent046, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent046 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, 200, 800); - MMI::PointerEvent::PointerItem point22 = {}; - TouchGuiderPointSet(point22, 1, 250, 800); - MMI::PointerEvent::PointerItem point33 = {}; - TouchGuiderPointSet(point33, 2, 360, 800); - std::vector pointEndVec{point11, point22, point33}; - - bool eventProduceRst = MultiFingerTapAndMoveEventProduce(points, pointStartVec, pointEndVec); - if (!eventProduceRst) { - GTEST_LOG_(INFO) << "AamsTouchGuideTest OnPointerEvent046 inputEventConsumer is null"; - return; - } - - // eventType - bool ret = - AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == - 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(3), - 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_OnPointerEvent046 ends"; -} - -/** - * @tc.number: OnPointerEvent047 - * @tc.name:OnPointerEvent - * @tc.desc: Check the four finger swipe down. - */ -HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent047, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent047 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, 120, 800); - MMI::PointerEvent::PointerItem point22 = {}; - TouchGuiderPointSet(point22, 1, 240, 800); - MMI::PointerEvent::PointerItem point33 = {}; - TouchGuiderPointSet(point33, 2, 350, 800); - MMI::PointerEvent::PointerItem point44 = {}; - TouchGuiderPointSet(point44, 3, 460, 800); - std::vector pointEndVec{point11, point22, point33, point44}; - - bool eventProduceRst = MultiFingerTapAndMoveEventProduce(points, pointStartVec, pointEndVec); - if (!eventProduceRst) { - GTEST_LOG_(INFO) << "AamsTouchGuideTest OnPointerEvent047 inputEventConsumer is null"; - return; - } - - // eventType - bool ret = - AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == - 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(3), - 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_OnPointerEvent047 ends"; -} - -/** - * @tc.number: OnPointerEvent048 - * @tc.name:OnPointerEvent - * @tc.desc: Check the three finger swipe up. - */ -HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent048, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent048 starts"; - - AccessibilityHelper::GetInstance().GetEventType() = {}; - MMI::MockInputManager::ClearTouchActions(); - - std::vector points = {}; - MMI::PointerEvent::PointerItem point1 = {}; - TouchGuiderPointSet(point1, 0, 100, 800); - MMI::PointerEvent::PointerItem point2 = {}; - TouchGuiderPointSet(point2, 1, 200, 800); - MMI::PointerEvent::PointerItem point3 = {}; - TouchGuiderPointSet(point3, 2, 300, 800); - std::vector pointStartVec{point1, point2, point3}; - - MMI::PointerEvent::PointerItem point11 = {}; - TouchGuiderPointSet(point11, 0, 140, 100); - MMI::PointerEvent::PointerItem point22 = {}; - TouchGuiderPointSet(point22, 1, 260, 100); - MMI::PointerEvent::PointerItem point33 = {}; - TouchGuiderPointSet(point33, 2, 330, 100); - std::vector pointEndVec{point11, point22, point33}; - - bool eventProduceRst = MultiFingerTapAndMoveEventProduce(points, pointStartVec, pointEndVec); - if (!eventProduceRst) { - GTEST_LOG_(INFO) << "AamsTouchGuideTest OnPointerEvent048 inputEventConsumer is null"; - return; - } - - // eventType - bool ret = - AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == - 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(3), - EventType::TYPE_TOUCH_GUIDE_GESTURE_END); - - // gestureId - EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), - static_cast(GestureType::GESTURE_THREE_FINGER_SWIPE_UP)); - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent048 ends"; -} - -/** - * @tc.number: OnPointerEvent049 - * @tc.name:OnPointerEvent - * @tc.desc: Check the three finger swipe left. - */ -HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent049, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent049 starts"; - - AccessibilityHelper::GetInstance().GetEventType() = {}; - MMI::MockInputManager::ClearTouchActions(); - - std::vector points = {}; - MMI::PointerEvent::PointerItem point1 = {}; - TouchGuiderPointSet(point1, 0, 600, 100); - MMI::PointerEvent::PointerItem point2 = {}; - TouchGuiderPointSet(point2, 1, 600, 200); - MMI::PointerEvent::PointerItem point3 = {}; - TouchGuiderPointSet(point3, 2, 600, 300); - std::vector pointStartVec{point1, point2, point3}; - - MMI::PointerEvent::PointerItem point11 = {}; - TouchGuiderPointSet(point11, 0, 100, 120); - MMI::PointerEvent::PointerItem point22 = {}; - TouchGuiderPointSet(point22, 1, 100, 280); - MMI::PointerEvent::PointerItem point33 = {}; - TouchGuiderPointSet(point33, 2, 100, 300); - std::vector pointEndVec{point11, point22, point33}; - - bool eventProduceRst = MultiFingerTapAndMoveEventProduce(points, pointStartVec, pointEndVec); - if (!eventProduceRst) { - GTEST_LOG_(INFO) << "AamsTouchGuideTest OnPointerEvent049 inputEventConsumer is null"; - return; - } - - // eventType - bool ret = - AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == - 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(3), - EventType::TYPE_TOUCH_GUIDE_GESTURE_END); - - // gestureId - EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), - static_cast(GestureType::GESTURE_THREE_FINGER_SWIPE_LEFT)); - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent049 ends"; -} - -/** - * @tc.number: OnPointerEvent050 - * @tc.name:OnPointerEvent - * @tc.desc: Check the three finger swipe right. - */ -HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent050, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent050 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, 100, 200); - MMI::PointerEvent::PointerItem point3 = {}; - TouchGuiderPointSet(point3, 2, 100, 300); - std::vector pointStartVec{point1, point2, point3}; - - MMI::PointerEvent::PointerItem point11 = {}; - TouchGuiderPointSet(point11, 0, 600, 120); - MMI::PointerEvent::PointerItem point22 = {}; - TouchGuiderPointSet(point22, 1, 600, 240); - MMI::PointerEvent::PointerItem point33 = {}; - TouchGuiderPointSet(point33, 2, 600, 280); - std::vector pointEndVec{point11, point22, point33}; - - bool eventProduceRst = MultiFingerTapAndMoveEventProduce(points, pointStartVec, pointEndVec); - if (!eventProduceRst) { - GTEST_LOG_(INFO) << "AamsTouchGuideTest OnPointerEvent050 inputEventConsumer is null"; - return; - } - - // eventType - bool ret = - AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == - 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(3), - EventType::TYPE_TOUCH_GUIDE_GESTURE_END); - - // gestureId - EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), - static_cast(GestureType::GESTURE_THREE_FINGER_SWIPE_RIGHT)); - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent050 ends"; -} - -/** - * @tc.number: OnPointerEvent051 - * @tc.name:OnPointerEvent - * @tc.desc: Check the four finger swipe up. - */ -HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent051, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent051 starts"; - - AccessibilityHelper::GetInstance().GetEventType() = {}; - MMI::MockInputManager::ClearTouchActions(); - - std::vector points = {}; - MMI::PointerEvent::PointerItem point1 = {}; - TouchGuiderPointSet(point1, 0, 100, 800); - MMI::PointerEvent::PointerItem point2 = {}; - TouchGuiderPointSet(point2, 1, 200, 800); - MMI::PointerEvent::PointerItem point3 = {}; - TouchGuiderPointSet(point3, 2, 300, 800); - MMI::PointerEvent::PointerItem point4 = {}; - TouchGuiderPointSet(point4, 3, 400, 800); - std::vector pointStartVec{point1, point2, point3, point4}; - - MMI::PointerEvent::PointerItem point11 = {}; - TouchGuiderPointSet(point11, 0, 100, 140); - MMI::PointerEvent::PointerItem point22 = {}; - TouchGuiderPointSet(point22, 1, 200, 120); - MMI::PointerEvent::PointerItem point33 = {}; - TouchGuiderPointSet(point33, 2, 300, 100); - MMI::PointerEvent::PointerItem point44 = {}; - TouchGuiderPointSet(point44, 3, 400, 100); - std::vector pointEndVec{point11, point22, point33, point44}; - - bool eventProduceRst = MultiFingerTapAndMoveEventProduce(points, pointStartVec, pointEndVec); - if (!eventProduceRst) { - GTEST_LOG_(INFO) << "AamsTouchGuideTest OnPointerEvent0051 inputEventConsumer is null"; - return; - } - - // eventType - bool ret = - AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == - 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(3), - EventType::TYPE_TOUCH_GUIDE_GESTURE_END); - - // gestureId - EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), - static_cast(GestureType::GESTURE_FOUR_FINGER_SWIPE_UP)); - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent051 ends"; -} - -/** - * @tc.number: OnPointerEvent052 - * @tc.name:OnPointerEvent - * @tc.desc: Check the four finger swipe left. - */ -HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent052, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent052 starts"; - - AccessibilityHelper::GetInstance().GetEventType() = {}; - MMI::MockInputManager::ClearTouchActions(); - - std::vector points = {}; - MMI::PointerEvent::PointerItem point1 = {}; - TouchGuiderPointSet(point1, 0, 600, 100); - MMI::PointerEvent::PointerItem point2 = {}; - TouchGuiderPointSet(point2, 1, 600, 200); - MMI::PointerEvent::PointerItem point3 = {}; - TouchGuiderPointSet(point3, 2, 600, 300); - MMI::PointerEvent::PointerItem point4 = {}; - TouchGuiderPointSet(point4, 3, 600, 400); - std::vector pointStartVec{point1, point2, point3, point4}; - - MMI::PointerEvent::PointerItem point11 = {}; - TouchGuiderPointSet(point11, 0, 100, 120); - MMI::PointerEvent::PointerItem point22 = {}; - TouchGuiderPointSet(point22, 1, 100, 230); - MMI::PointerEvent::PointerItem point33 = {}; - TouchGuiderPointSet(point33, 2, 100, 280); - MMI::PointerEvent::PointerItem point44 = {}; - TouchGuiderPointSet(point44, 3, 100, 410); - std::vector pointEndVec{point11, point22, point33, point44}; - - bool eventProduceRst = MultiFingerTapAndMoveEventProduce(points, pointStartVec, pointEndVec); - if (!eventProduceRst) { - GTEST_LOG_(INFO) << "AamsTouchGuideTest OnPointerEvent0052 inputEventConsumer is null"; - return; - } - - // eventType - bool ret = - AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == - 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(3), - EventType::TYPE_TOUCH_GUIDE_GESTURE_END); - - // gestureId - EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), - static_cast(GestureType::GESTURE_FOUR_FINGER_SWIPE_LEFT)); - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent052 ends"; -} - -/** - * @tc.number: OnPointerEvent053 - * @tc.name:OnPointerEvent - * @tc.desc: Check the four finger swipe right. - */ -HWTEST_F(AamsTouchGuideTest, AamsTouchGuideTest_Moduletest_OnPointerEvent053, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent053 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, 100, 200); - MMI::PointerEvent::PointerItem point3 = {}; - TouchGuiderPointSet(point3, 2, 100, 300); - MMI::PointerEvent::PointerItem point4 = {}; - TouchGuiderPointSet(point4, 3, 100, 400); - std::vector pointStartVec{point1, point2, point3, point4}; - - MMI::PointerEvent::PointerItem point11 = {}; - TouchGuiderPointSet(point11, 0, 600, 120); - MMI::PointerEvent::PointerItem point22 = {}; - TouchGuiderPointSet(point22, 1, 600, 210); - MMI::PointerEvent::PointerItem point33 = {}; - TouchGuiderPointSet(point33, 2, 600, 350); - MMI::PointerEvent::PointerItem point44 = {}; - TouchGuiderPointSet(point44, 3, 600, 420); - std::vector pointEndVec{point11, point22, point33, point44}; - - bool eventProduceRst = MultiFingerTapAndMoveEventProduce(points, pointStartVec, pointEndVec); - if (!eventProduceRst) { - GTEST_LOG_(INFO) << "AamsTouchGuideTest OnPointerEvent053 inputEventConsumer is null"; - return; - } - - // eventType - bool ret = - AccessibilityCommonHelper::GetInstance().WaitForLoop(std::bind([]() -> bool { - if (AccessibilityHelper::GetInstance().GetEventTypeOfTargetIndex(2) == - 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(3), - EventType::TYPE_TOUCH_GUIDE_GESTURE_END); - - // gestureId - EXPECT_EQ(AccessibilityHelper::GetInstance().GetGestureId(), - static_cast(GestureType::GESTURE_FOUR_FINGER_SWIPE_RIGHT)); - GTEST_LOG_(INFO) << "AamsTouchGuideTest AamsTouchGuideTest_Moduletest_OnPointerEvent053 ends"; -} -} // namespace Accessibility -} // namespace OHOS \ No newline at end of file