1 /*
2  * Copyright (c) 2021-2022 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 #include "test/unittest/core/pipeline/common_constants.h"
17 
18 #include "core/common/event_manager.h"
19 #include "core/components_ng/event/response_ctrl.h"
20 
21 namespace OHOS::Ace {
TouchTest(const TouchEvent & touchPoint,const RefPtr<RenderNode> & renderNode,const TouchRestrict & touchRestrict,const Offset & offset,float viewScale,bool needAppend)22 void EventManager::TouchTest(const TouchEvent& touchPoint, const RefPtr<RenderNode>& renderNode,
23     const TouchRestrict& touchRestrict, const Offset& offset, float viewScale, bool needAppend)
24 {}
25 
TouchTest(const TouchEvent & touchPoint,const RefPtr<NG::FrameNode> & frameNode,const TouchRestrict & touchRestrict,const Offset & offset,float viewScale,bool needAppend)26 void EventManager::TouchTest(const TouchEvent& touchPoint, const RefPtr<NG::FrameNode>& frameNode,
27     const TouchRestrict& touchRestrict, const Offset& offset, float viewScale, bool needAppend)
28 {}
29 
TouchTest(const AxisEvent & event,const RefPtr<NG::FrameNode> & frameNode,const TouchRestrict & touchRestrict)30 void EventManager::TouchTest(
31     const AxisEvent& event, const RefPtr<NG::FrameNode>& frameNode, const TouchRestrict& touchRestrict)
32 {
33     SetInstanceId(instanceId_ | TOUCH_TEST_FLAG);
34 }
35 
HandleGlobalEvent(const TouchEvent & touchPoint,const RefPtr<TextOverlayManager> & textOverlayManager)36 void EventManager::HandleGlobalEvent(const TouchEvent& touchPoint, const RefPtr<TextOverlayManager>& textOverlayManager)
37 {}
38 
HandleGlobalEventNG(const TouchEvent & touchPoint,const RefPtr<NG::SelectOverlayManager> & selectOverlayManager,const NG::OffsetF & rootOffset)39 void EventManager::HandleGlobalEventNG(const TouchEvent& touchPoint,
40     const RefPtr<NG::SelectOverlayManager>& selectOverlayManager, const NG::OffsetF& rootOffset)
41 {}
42 
HandleOutOfRectCallback(const Point & point,std::vector<RectCallback> & rectCallbackList)43 void EventManager::HandleOutOfRectCallback(const Point& point, std::vector<RectCallback>& rectCallbackList) {}
44 
TouchTest(const AxisEvent & event,const RefPtr<RenderNode> & renderNode,const TouchRestrict & touchRestrict)45 void EventManager::TouchTest(
46     const AxisEvent& event, const RefPtr<RenderNode>& renderNode, const TouchRestrict& touchRestrict)
47 {}
48 
FlushTouchEventsBegin(const std::list<TouchEvent> & touchEvents)49 void EventManager::FlushTouchEventsBegin(const std::list<TouchEvent>& touchEvents) {}
50 
FlushTouchEventsEnd(const std::list<TouchEvent> & touchEvents)51 void EventManager::FlushTouchEventsEnd(const std::list<TouchEvent>& touchEvents) {}
52 
DispatchTouchEvent(const TouchEvent & point)53 bool EventManager::DispatchTouchEvent(const TouchEvent& point)
54 {
55     SetInstanceId(instanceId_ | DISPATCH_TOUCH_EVENT_TOUCH_EVENT_FLAG);
56     return true;
57 }
58 
DispatchTouchEvent(const AxisEvent & event)59 bool EventManager::DispatchTouchEvent(const AxisEvent& event)
60 {
61     SetInstanceId(instanceId_ | DISPATCH_TOUCH_EVENT_AXIS_EVENT_FLAG);
62     return true;
63 }
64 
DispatchTabIndexEvent(const KeyEvent & event,const RefPtr<FocusNode> & focusNode,const RefPtr<FocusGroup> & curPage)65 bool EventManager::DispatchTabIndexEvent(
66     const KeyEvent& event, const RefPtr<FocusNode>& focusNode, const RefPtr<FocusGroup>& curPage)
67 {
68     return true;
69 }
70 
DispatchKeyEvent(const KeyEvent & event,const RefPtr<FocusNode> & focusNode)71 bool EventManager::DispatchKeyEvent(const KeyEvent& event, const RefPtr<FocusNode>& focusNode)
72 {
73     return true;
74 }
75 
DispatchTabIndexEventNG(const KeyEvent & event,const RefPtr<NG::FrameNode> & mainView)76 bool EventManager::DispatchTabIndexEventNG(
77     const KeyEvent& event, const RefPtr<NG::FrameNode>& mainView)
78 {
79     return !instanceId_;
80 }
81 
DispatchKeyEventNG(const KeyEvent & event,const RefPtr<NG::FrameNode> & focusNode)82 bool EventManager::DispatchKeyEventNG(const KeyEvent& event, const RefPtr<NG::FrameNode>& focusNode)
83 {
84     return false;
85 }
86 
MouseTest(const MouseEvent & event,const RefPtr<RenderNode> & renderNode)87 void EventManager::MouseTest(const MouseEvent& event, const RefPtr<RenderNode>& renderNode) {}
88 
DispatchMouseEvent(const MouseEvent & event)89 bool EventManager::DispatchMouseEvent(const MouseEvent& event)
90 {
91     return true;
92 }
93 
DispatchMouseHoverAnimation(const MouseEvent & event)94 void EventManager::DispatchMouseHoverAnimation(const MouseEvent& event) {}
95 
DispatchMouseHoverEvent(const MouseEvent & event)96 bool EventManager::DispatchMouseHoverEvent(const MouseEvent& event)
97 {
98     return true;
99 }
100 
MouseTest(const MouseEvent & event,const RefPtr<NG::FrameNode> & frameNode,const TouchRestrict & touchRestrict)101 void EventManager::MouseTest(
102     const MouseEvent& event, const RefPtr<NG::FrameNode>& frameNode, const TouchRestrict& touchRestrict)
103 {
104     SetInstanceId(instanceId_ | MOUSE_TEST_FLAG);
105 }
106 
DispatchMouseEventNG(const MouseEvent & event)107 bool EventManager::DispatchMouseEventNG(const MouseEvent& event)
108 {
109     SetInstanceId(instanceId_ | DISPATCH_MOUSE_EVENT_NG_FLAG);
110     return true;
111 }
112 
DispatchMouseHoverAnimationNG(const MouseEvent & event)113 void EventManager::DispatchMouseHoverAnimationNG(const MouseEvent& event)
114 {
115     SetInstanceId(instanceId_ | DISPATCH_MOUSE_HOVER_ANIMATION_NG_FLAG);
116 }
117 
DispatchMouseHoverEventNG(const MouseEvent & event)118 bool EventManager::DispatchMouseHoverEventNG(const MouseEvent& event)
119 {
120     SetInstanceId(instanceId_ | DISPATCH_MOUSE_HOVER_EVENT_NG_FLAG);
121     return true;
122 }
123 
AxisTest(const AxisEvent & event,const RefPtr<RenderNode> & renderNode)124 void EventManager::AxisTest(const AxisEvent& event, const RefPtr<RenderNode>& renderNode) {}
125 
DispatchAxisEvent(const AxisEvent & event)126 bool EventManager::DispatchAxisEvent(const AxisEvent& event)
127 {
128     SetInstanceId(instanceId_ | DISPATCH_AXIS_EVENT_FLAG);
129     return true;
130 }
131 
AxisTest(const AxisEvent & event,const RefPtr<NG::FrameNode> & frameNode)132 void EventManager::AxisTest(const AxisEvent& event, const RefPtr<NG::FrameNode>& frameNode)
133 {
134     SetInstanceId(instanceId_ | AXIS_TEST_FLAG);
135 }
136 
DispatchAxisEventNG(const AxisEvent & event)137 bool EventManager::DispatchAxisEventNG(const AxisEvent& event)
138 {
139     SetInstanceId(instanceId_ | DISPATCH_AXIS_EVENT_NG_FLAG);
140     return true;
141 }
142 
DispatchRotationEvent(const RotationEvent & event,const RefPtr<RenderNode> & renderNode,const RefPtr<RenderNode> & requestFocusNode)143 bool EventManager::DispatchRotationEvent(
144     const RotationEvent& event, const RefPtr<RenderNode>& renderNode, const RefPtr<RenderNode>& requestFocusNode)
145 {
146     return true;
147 }
148 
DispatchKeyboardShortcut(const KeyEvent & event)149 void EventManager::DispatchKeyboardShortcut(const KeyEvent& event) {}
150 
ClearResults()151 void EventManager::ClearResults() {}
152 
HasDifferentDirectionGesture()153 bool EventManager::HasDifferentDirectionGesture()
154 {
155     return false;
156 }
157 
EventManager()158 EventManager::EventManager() {}
159 
DumpEvent(NG::EventTreeType type) const160 void EventManager::DumpEvent(NG::EventTreeType type) const {}
161 
AddGestureSnapshot(int32_t finger,int32_t depth,const RefPtr<TouchEventTarget> & target,NG::EventTreeType type)162 void AddGestureSnapshot(int32_t finger, int32_t depth,  const RefPtr<TouchEventTarget>& target, NG::EventTreeType type)
163 {}
164 } // namespace OHOS::Ace
165