1 /* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef TEST_UNITTEST_CORE_EVENT_GESTURE_EVENT_HUB_TEST_NG_H 17 #define TEST_UNITTEST_CORE_EVENT_GESTURE_EVENT_HUB_TEST_NG_H 18 #include "gtest/gtest.h" 19 20 #define private public 21 #define protected public 22 #undef SECURITY_COMPONENT_ENABLE 23 24 #include "test/mock/base/mock_pixel_map.h" 25 #include "test/mock/base/mock_task_executor.h" 26 #include "test/mock/core/common/mock_udmf.h" 27 #include "test/mock/core/pipeline/mock_pipeline_context.h" 28 29 #include "base/geometry/axis.h" 30 #include "base/geometry/ng/offset_t.h" 31 #include "base/memory/ace_type.h" 32 #include "base/memory/referenced.h" 33 #include "core/components_ng/base/frame_node.h" 34 #include "core/components_ng/event/gesture_event_hub.h" 35 #include "core/components_ng/event/pan_event.h" 36 #include "core/components_ng/event/touch_event.h" 37 #include "core/components_ng/gestures/long_press_gesture.h" 38 #include "core/components_ng/gestures/pan_gesture.h" 39 #include "core/components_ng/gestures/recognizers/click_recognizer.h" 40 #include "core/components_ng/gestures/tap_gesture.h" 41 #include "core/components_ng/manager/drag_drop/drag_drop_proxy.h" 42 #include "core/components_ng/pattern/pattern.h" 43 #include "core/components_v2/inspector/inspector_constants.h" 44 #include "frameworks/core/common/event_manager.h" 45 #include "frameworks/core/components_ng/pattern/text_drag/text_drag_base.h" 46 47 namespace OHOS::Ace::NG { 48 namespace { 49 const std::string NODE_TAG("node"); 50 const OffsetF COORDINATE_OFFSET(20.0f, 20.0f); 51 constexpr int32_t TOUCH_ID = 0; 52 const Axis AXIS_VERTICAL = Axis::VERTICAL; 53 const PanDirection PAN_DIRECTION_ALL; 54 constexpr int32_t FINGERS = 1; 55 constexpr int32_t DOUBLE_FINGERS = 2; 56 constexpr int32_t CLICK_COUNTS = 2; 57 constexpr Dimension DISTANCE = 10.0_vp; 58 const std::string CHECK_TAG_1("HELLO"); 59 const std::string CHECK_TAG_2("WORLD"); 60 const PointF GLOBAL_POINT { 20.0f, 20.0f }; 61 const PointF LOCAL_POINT { 15.0f, 15.0f }; 62 RefPtr<DragWindow> MOCK_DRAG_WINDOW; 63 constexpr int32_t GESTURES_COUNTS = 2; 64 RefPtr<MockTaskExecutor> MOCK_TASK_EXECUTOR; 65 constexpr float DRAG_DISTANCE = 10.5f; 66 const PanDirection DRAG_DIRECTION = { PanDirection::LEFT }; 67 constexpr int32_t FINGERS_NUMBER = 2; 68 constexpr int32_t PARALLEL_INDEX_1 = 2; 69 constexpr int32_t PARALLEL_INDEX_2 = 0; 70 constexpr float PREVIEW_DOWN_SCALE = 0.8f; 71 constexpr float PREVIEW_UP_SCALE = 1.2f; 72 constexpr float EXPECT_SCALE = 1.0f; 73 constexpr float PREVIEW_NEGA_SCALE = -1.0f; 74 constexpr int32_t PIXELMAP_WIDTH_LARGE = 200; 75 constexpr int32_t PIXELMAP_WIDTH = 100; 76 constexpr int32_t PIXELMAP_HEIGHT = 200; 77 constexpr int32_t INSTANCE_ID = 123; 78 constexpr float SIZE_X = 100.0f; 79 constexpr float SIZE_Y = 100.0f; 80 constexpr float INIT_MOVE_X = 50.0f; 81 constexpr float INIT_MOVE_Y = 50.0f; 82 constexpr float LAST_MOVE_X = 30.0f; 83 constexpr float LAST_MOVE_Y = 30.0f; 84 constexpr float TOTAL_MOVE_X = 20.0f; 85 constexpr float TOTAL_MOVE_Y = 20.0f; 86 constexpr float SIZE_ZERO = 0.0f; 87 constexpr float DEFAULT_SCALE = 1.0f; 88 constexpr float FRAME_OFFSET_X = 30.0f; 89 constexpr float FRAME_OFFSET_Y = 40.0f; 90 constexpr float FRAME_WIDTH = 30.0f; 91 constexpr float FRAME_HEIGHT = 60.0f; 92 constexpr float MOVE_OFFSET_X = 10.0f; 93 constexpr float MOVE_OFFSET_Y = 10.0f; 94 constexpr float GESTURE_GLOBAL_X = 10.0f; 95 constexpr float GESTURE_GLOBAL_Y = 20.0f; 96 constexpr float INNER_OFFSET_X = 5.0f; 97 constexpr float INNER_OFFSET_Y = 10.0f; 98 constexpr float DRAG_OFFSET_X = 40.0f; 99 constexpr float DRAG_OFFSET_Y = 40.0f; 100 } // namespace 101 102 class GestureEventHubTestNg : public testing::Test { 103 public: 104 static void SetUpTestSuite(); 105 static void TearDownTestSuite(); 106 }; 107 class GestureEventHubTestCoverageNg : public testing::Test { 108 public: 109 static void SetUpTestSuite(); 110 static void TearDownTestSuite(); 111 }; 112 } // namespace OHOS::Ace::NG 113 114 #endif //TEST_UNITTEST_CORE_EVENT_GESTURE_EVENT_HUB_TEST_NG_H