• 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_COMMON_TEST_NG_H
17 #define TEST_UNITTEST_CORE_EVENT_DRAG_EVENT_COMMON_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_interaction_interface.h"
27 #include "test/mock/core/common/mock_theme_manager.h"
28 #include "test/mock/core/pipeline/mock_pipeline_context.h"
29 #include "test/mock/core/render/mock_render_context.h"
30 
31 #include "base/memory/ace_type.h"
32 #include "base/memory/referenced.h"
33 #include "core/components/theme/blur_style_theme.h"
34 #include "core/components/theme/shadow_theme.h"
35 #include "core/components_ng/event/drag_event.h"
36 #include "core/components_ng/event/event_hub.h"
37 #include "core/components_ng/manager/drag_drop/drag_drop_global_controller.h"
38 #include "core/components_ng/pattern/text/text_pattern.h"
39 #include "core/components_ng/pattern/stack/stack_pattern.h"
40 #include "core/components_ng/pattern/grid/grid_item_pattern.h"
41 #include "core/components_ng/pattern/list/list_item_pattern.h"
42 #include "core/components_ng/pattern/grid/grid_pattern.h"
43 #include "core/components_ng/pattern/list/list_pattern.h"
44 #include "core/components_ng/pattern/text_drag/text_drag_pattern.h"
45 #include "core/event/touch_event.h"
46 
47 namespace OHOS::Ace::NG {
48 namespace {
49 constexpr float DISTANCE = 10.5f;
50 constexpr float WIDTH = 400.0f;
51 constexpr float HEIGHT = 400.0f;
52 constexpr int32_t FINGERS_NUMBER = 1;
53 const OffsetF COORDINATE_OFFSET(WIDTH, HEIGHT);
54 const PanDirection DRAG_DIRECTION = { PanDirection::LEFT };
55 const TouchRestrict DRAG_TOUCH_RESTRICT = { TouchRestrict::CLICK };
56 const TouchRestrict DRAG_TOUCH_RESTRICT_MOUSE = {
57     .forbiddenType = TouchRestrict::CLICK,
58     .sourceType = SourceType::MOUSE
59 };
60 } // namespace
61 
62 struct DragInfo {
63     bool isDragForbidden = false;
64     bool isDraggable = false;
65     bool isCustomerSet = false;
66     bool textIsSelected = false;
DragInfoDragInfo67     DragInfo(bool isDragForbidden, bool isDraggable, bool isCustomerSet, bool textIsSelected)
68         : isDragForbidden(isDragForbidden), isDraggable(isDraggable), isCustomerSet(isCustomerSet),
69           textIsSelected(textIsSelected)
70     {}
71 };
72 
73 struct GlobalDraggingInfo {
74     bool isDragging = false;
75     bool isMSDPDragging = false;
GlobalDraggingInfoGlobalDraggingInfo76     GlobalDraggingInfo(bool isDragging, bool isMSDPDragging) : isDragging(isDragging), isMSDPDragging(isMSDPDragging) {}
77 };
78 
79 struct MultiDragInfo {
80     bool isMultiSelectionEnabled = false;
81     bool isAllowDrag = false;
82     bool isFrameNodeAcceptedMultiDrag = false;
MultiDragInfoMultiDragInfo83     MultiDragInfo(bool isMultiSelectionEnabled, bool isAllowDrag, bool isFrameNodeAcceptedMultiDrag)
84         : isMultiSelectionEnabled(isMultiSelectionEnabled), isAllowDrag(isAllowDrag),
85           isFrameNodeAcceptedMultiDrag(isFrameNodeAcceptedMultiDrag)
86     {}
87 };
88 
89 
90 class DragEventCommonTestNg : public testing::Test {
91 };
92 } // namespace OHOS::Ace::NG
93 
94 #endif //TEST_UNITTEST_CORE_EVENT_DRAG_EVENT_COMMON_TEST_NG_H