• 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 #include "test_context.h"
17 
18 #include "ddm_adapter.h"
19 #include "dsoftbus_adapter.h"
20 #include "fi_log.h"
21 #include "plugin_manager.h"
22 
23 #undef LOG_TAG
24 #define LOG_TAG "IntentionServiceTest"
25 
26 namespace OHOS {
27 namespace Msdp {
28 namespace DeviceStatus {
29 
PostSyncTask(DTaskCallback callback)30 int32_t MockDelegateTasks::PostSyncTask(DTaskCallback callback)
31 {
32     return callback();
33 }
34 
PostAsyncTask(DTaskCallback callback)35 int32_t MockDelegateTasks::PostAsyncTask(DTaskCallback callback)
36 {
37     return callback();
38 }
39 
AddMonitor(std::function<void (std::shared_ptr<MMI::PointerEvent>)> callback)40 int32_t MockInputAdapter::AddMonitor(std::function<void(std::shared_ptr<MMI::PointerEvent>)> callback)
41 {
42     return RET_OK;
43 }
44 
AddMonitor(std::function<void (std::shared_ptr<MMI::KeyEvent>)> callback)45 int32_t MockInputAdapter::AddMonitor(std::function<void(std::shared_ptr<MMI::KeyEvent>)> callback)
46 {
47     return RET_OK;
48 }
49 
AddMonitor(std::function<void (std::shared_ptr<MMI::PointerEvent>)> pointerCallback,std::function<void (std::shared_ptr<MMI::KeyEvent>)> keyCallback,MMI::HandleEventType eventType)50 int32_t MockInputAdapter::AddMonitor(std::function<void(std::shared_ptr<MMI::PointerEvent>)> pointerCallback,
51     std::function<void(std::shared_ptr<MMI::KeyEvent>)> keyCallback, MMI::HandleEventType eventType)
52 {
53     return RET_OK;
54 }
55 
RemoveMonitor(int32_t monitorId)56 void MockInputAdapter::RemoveMonitor(int32_t monitorId)
57 {}
58 
AddInterceptor(std::function<void (std::shared_ptr<MMI::PointerEvent>)> pointCallback)59 int32_t MockInputAdapter::AddInterceptor(std::function<void(std::shared_ptr<MMI::PointerEvent>)> pointCallback)
60 {
61     return RET_OK;
62 }
63 
AddInterceptor(std::function<void (std::shared_ptr<MMI::KeyEvent>)> keyCallback)64 int32_t MockInputAdapter::AddInterceptor(std::function<void(std::shared_ptr<MMI::KeyEvent>)> keyCallback)
65 {
66     return RET_OK;
67 }
68 
AddInterceptor(std::function<void (std::shared_ptr<MMI::PointerEvent>)> pointCallback,std::function<void (std::shared_ptr<MMI::KeyEvent>)> keyCallback)69 int32_t MockInputAdapter::AddInterceptor(std::function<void(std::shared_ptr<MMI::PointerEvent>)> pointCallback,
70     std::function<void(std::shared_ptr<MMI::KeyEvent>)> keyCallback)
71 {
72     return RET_OK;
73 }
74 
RemoveInterceptor(int32_t interceptorId)75 void MockInputAdapter::RemoveInterceptor(int32_t interceptorId)
76 {}
77 
AddFilter(std::function<bool (std::shared_ptr<MMI::PointerEvent>)> callback)78 int32_t MockInputAdapter::AddFilter(std::function<bool(std::shared_ptr<MMI::PointerEvent>)> callback)
79 {
80     return RET_OK;
81 }
82 
RemoveFilter(int32_t filterId)83 void MockInputAdapter::RemoveFilter(int32_t filterId)
84 {}
85 
SetPointerVisibility(bool visible,int32_t priority)86 int32_t MockInputAdapter::SetPointerVisibility(bool visible, int32_t priority)
87 {
88     return RET_OK;
89 }
90 
SetPointerLocation(int32_t x,int32_t y,int32_t displayId)91 int32_t MockInputAdapter::SetPointerLocation(int32_t x, int32_t y, int32_t displayId)
92 {
93     return RET_OK;
94 }
95 
EnableInputDevice(bool enable)96 int32_t MockInputAdapter::EnableInputDevice(bool enable)
97 {
98     return RET_OK;
99 }
100 
SimulateInputEvent(std::shared_ptr<MMI::PointerEvent> pointerEvent)101 void MockInputAdapter::SimulateInputEvent(std::shared_ptr<MMI::PointerEvent> pointerEvent)
102 {}
103 
SimulateInputEvent(std::shared_ptr<MMI::KeyEvent> keyEvent)104 void MockInputAdapter::SimulateInputEvent(std::shared_ptr<MMI::KeyEvent> keyEvent)
105 {}
106 
AddVirtualInputDevice(std::shared_ptr<MMI::InputDevice> device,int32_t & deviceId)107 int32_t MockInputAdapter::AddVirtualInputDevice(std::shared_ptr<MMI::InputDevice> device, int32_t &deviceId)
108 {
109     return RET_OK;
110 }
111 
RemoveVirtualInputDevice(int32_t deviceId)112 int32_t MockInputAdapter::RemoveVirtualInputDevice(int32_t deviceId)
113 {
114     return RET_OK;
115 }
116 
GetPointerSpeed(int32_t & speed)117 int32_t MockInputAdapter::GetPointerSpeed(int32_t &speed)
118 {
119     return RET_OK;
120 }
121 
SetPointerSpeed(int32_t speed)122 int32_t MockInputAdapter::SetPointerSpeed(int32_t speed)
123 {
124     return RET_OK;
125 }
126 
GetTouchPadSpeed(int32_t & speed)127 int32_t MockInputAdapter::GetTouchPadSpeed(int32_t &speed)
128 {
129     return RET_OK;
130 }
131 
SetTouchPadSpeed(int32_t speed)132 int32_t MockInputAdapter::SetTouchPadSpeed(int32_t speed)
133 {
134     return RET_OK;
135 }
136 
HasLocalPointerDevice()137 bool MockInputAdapter::HasLocalPointerDevice()
138 {
139     return true;
140 }
141 
MockPluginManager(IContext * context)142 MockPluginManager::MockPluginManager(IContext *context)
143 {
144     pluginMgr_ = std::make_unique<PluginManager>(context);
145 }
146 
LoadCooperate()147 ICooperate* MockPluginManager::LoadCooperate()
148 {
149     return pluginMgr_->LoadCooperate();
150 }
151 
UnloadCooperate()152 void MockPluginManager::UnloadCooperate()
153 {
154     pluginMgr_->UnloadCooperate();
155 }
156 
LoadMotionDrag()157 IMotionDrag* MockPluginManager::LoadMotionDrag()
158 {
159     return nullptr;
160 }
161 
UnloadMotionDrag()162 void MockPluginManager::UnloadMotionDrag()
163 {}
164 
TestContext()165 TestContext::TestContext()
166 {
167     ddm_ = std::make_unique<DDMAdapter>();
168     input_ = std::make_unique<MockInputAdapter>();
169     pluginMgr_ = std::make_unique<MockPluginManager>(this);
170     dsoftbus_ = std::make_unique<DSoftbusAdapter>();
171 }
172 
GetDelegateTasks()173 IDelegateTasks& TestContext::GetDelegateTasks()
174 {
175     return delegateTasks_;
176 }
177 
GetDeviceManager()178 IDeviceManager& TestContext::GetDeviceManager()
179 {
180     return devMgr_;
181 }
182 
GetTimerManager()183 ITimerManager& TestContext::GetTimerManager()
184 {
185     return timerMgr_;
186 }
187 
GetDragManager()188 IDragManager& TestContext::GetDragManager()
189 {
190     return dragMgr_;
191 }
192 
GetSocketSessionManager()193 ISocketSessionManager& TestContext::GetSocketSessionManager()
194 {
195     return socketSessionMgr_;
196 }
197 
GetDDM()198 IDDMAdapter& TestContext::GetDDM()
199 {
200     return *ddm_;
201 }
202 
GetPluginManager()203 IPluginManager& TestContext::GetPluginManager()
204 {
205     return *pluginMgr_;
206 }
207 
GetInput()208 IInputAdapter& TestContext::GetInput()
209 {
210     return *input_;
211 }
212 
GetDSoftbus()213 IDSoftbusAdapter& TestContext::GetDSoftbus()
214 {
215     return *dsoftbus_;
216 }
217 } // namespace DeviceStatus
218 } // namespace Msdp
219 } // namespace OHOS
220