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_DRAG_EVENT_TEST_NG_H 17 #define TEST_UNITTEST_CORE_EVENT_DRAG_EVENT_TEST_NG_H 18 #include "gtest/gtest.h" 19 #include <string> 20 21 #define private public 22 #define protected public 23 24 #include "test/mock/core/common/mock_theme_manager.h" 25 #include "test/mock/core/pipeline/mock_pipeline_context.h" 26 #include "test/mock/core/render/mock_render_context.h" 27 28 #include "base/memory/ace_type.h" 29 #include "base/memory/referenced.h" 30 #include "core/components/theme/blur_style_theme.h" 31 #include "core/components/theme/shadow_theme.h" 32 #include "core/components_ng/event/drag_event.h" 33 #include "core/components_ng/event/event_hub.h" 34 #include "core/components_ng/pattern/text/text_pattern.h" 35 #include "core/components_ng/pattern/stack/stack_pattern.h" 36 #include "core/components_ng/pattern/grid/grid_item_pattern.h" 37 #include "core/components_ng/pattern/list/list_item_pattern.h" 38 #include "core/components_ng/pattern/grid/grid_pattern.h" 39 #include "core/components_ng/pattern/list/list_pattern.h" 40 #include "core/event/touch_event.h" 41 42 namespace OHOS::Ace::NG { 43 namespace { 44 constexpr double GESTURE_EVENT_PROPERTY_DEFAULT_VALUE = 0.0; 45 constexpr double GESTURE_EVENT_PROPERTY_VALUE = 10.0; 46 const PanDirection DRAG_DIRECTION = { PanDirection::LEFT }; 47 const TouchRestrict DRAG_TOUCH_RESTRICT = { TouchRestrict::CLICK }; 48 const TouchRestrict DRAG_TOUCH_RESTRICT_MOUSE = { 49 .forbiddenType = TouchRestrict::CLICK, 50 .sourceType = SourceType::MOUSE 51 }; 52 constexpr int32_t UNKNOWN = 1; 53 constexpr int32_t FINGERS_NUMBER = 2; 54 constexpr int32_t TOUCH_TEST_RESULT_SIZE = 1; 55 constexpr int32_t TOUCH_TEST_RESULT_SIZE_2 = 2; 56 constexpr int32_t NUMBER_BADGE_SIZE_3 = 3; 57 constexpr int32_t NUMBER_BADGE_SIZE_100 = 100; 58 constexpr float DISTANCE = 10.5f; 59 constexpr float WIDTH = 400.0f; 60 constexpr float HEIGHT = 400.0f; 61 const OffsetF COORDINATE_OFFSET(WIDTH, HEIGHT); 62 constexpr int32_t FINGERS_NUMBER_GREATER_THAN_DEFAULT = 2; 63 constexpr float DISTANCE_GREATER_THAN_DEFAULT = 6.0f; 64 constexpr float DISTANCE_EQUAL_DEFAULT = 5.0f; 65 constexpr float IMAGE_INVALID_RECT_WIDTH = 100.0f; 66 const std::string COMPONENT_ID = "id of component which you want to get screenshot from"; 67 const std::string NO_COMPONENT_ID = ""; 68 const std::string TOUCH_EVENT_INFO_TYPE = "onTouchDown"; 69 constexpr int32_t LONG_PRESS_DURATION = 500; 70 } // namespace 71 72 class DragEventTestNg : public testing::Test { 73 public: 74 static void SetUpTestSuite(); 75 static void TearDownTestSuite(); 76 void SetUp() override; 77 void TearDown() override; 78 }; 79 } // namespace OHOS::Ace::NG 80 81 #endif //TEST_UNITTEST_CORE_EVENT_DRAG_EVENT_TEST_NG_H