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