1 /*
2 * Copyright (c) 2022-2025 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 OHOS_DISTRIBUTED_HARDWARE_STUB_TEST_H
17 #define OHOS_DISTRIBUTED_HARDWARE_STUB_TEST_H
18
19 #include <gtest/gtest.h>
20
21 #include "accesstoken_kit_mock.h"
22 #include "distributed_hardware_errno.h"
23 #include "distributed_hardware_fwk_kit_paras.h"
24 #include "distributed_hardware_stub.h"
25
26 namespace OHOS {
27 namespace DistributedHardware {
28 class DistributedHardwareStubTest : public testing::Test {
29 public:
30 static void SetUpTestCase(void);
31 static void TearDownTestCase(void);
32 void SetUp();
33 void TearDown();
34 std::shared_ptr<DistributedHardwareStub> stubTest_ = nullptr;
35 std::shared_ptr<AccessTokenKitMock> token_ = nullptr;
36 };
37
38 class MockDistributedHardwareStub : public DistributedHardwareStub {
39 public:
RegisterPublisherListener(const DHTopic topic,const sptr<IPublisherListener> listener)40 int32_t RegisterPublisherListener(const DHTopic topic, const sptr<IPublisherListener> listener)
41 {
42 (void)topic;
43 (void)listener;
44 return DH_FWK_SUCCESS;
45 }
46
UnregisterPublisherListener(const DHTopic topic,const sptr<IPublisherListener> listener)47 int32_t UnregisterPublisherListener(const DHTopic topic, const sptr<IPublisherListener> listener)
48 {
49 (void)topic;
50 (void)listener;
51 return DH_FWK_SUCCESS;
52 }
53
PublishMessage(const DHTopic topic,const std::string & msg)54 int32_t PublishMessage(const DHTopic topic, const std::string &msg)
55 {
56 (void)topic;
57 (void)msg;
58 return DH_FWK_SUCCESS;
59 }
60
QueryLocalSysSpec(QueryLocalSysSpecType spec)61 std::string QueryLocalSysSpec(QueryLocalSysSpecType spec)
62 {
63 (void)spec;
64 return "";
65 }
66
InitializeAVCenter(const TransRole & transRole,int32_t & engineId)67 int32_t InitializeAVCenter(const TransRole &transRole, int32_t &engineId)
68 {
69 (void)transRole;
70 (void)engineId;
71 return DH_FWK_SUCCESS;
72 }
73
ReleaseAVCenter(int32_t engineId)74 int32_t ReleaseAVCenter(int32_t engineId)
75 {
76 (void)engineId;
77 return DH_FWK_SUCCESS;
78 }
79
CreateControlChannel(int32_t engineId,const std::string & peerDevId)80 int32_t CreateControlChannel(int32_t engineId, const std::string &peerDevId)
81 {
82 (void)engineId;
83 (void)peerDevId;
84 return DH_FWK_SUCCESS;
85 }
86
NotifyAVCenter(int32_t engineId,const AVTransEvent & event)87 int32_t NotifyAVCenter(int32_t engineId, const AVTransEvent &event)
88 {
89 (void)engineId;
90 (void)event;
91 return DH_FWK_SUCCESS;
92 }
93
RegisterCtlCenterCallback(int32_t engineId,const sptr<IAvTransControlCenterCallback> callback)94 int32_t RegisterCtlCenterCallback(int32_t engineId, const sptr<IAvTransControlCenterCallback> callback)
95 {
96 (void)engineId;
97 (void)callback;
98 return DH_FWK_SUCCESS;
99 }
100
NotifySourceRemoteSinkStarted(std::string & deviceId)101 int32_t NotifySourceRemoteSinkStarted(std::string &deviceId)
102 {
103 (void)deviceId;
104 return DH_FWK_SUCCESS;
105 }
106
PauseDistributedHardware(DHType dhType,const std::string & networkId)107 int32_t PauseDistributedHardware(DHType dhType, const std::string &networkId)
108 {
109 (void)dhType;
110 (void)networkId;
111 return DH_FWK_SUCCESS;
112 }
113
ResumeDistributedHardware(DHType dhType,const std::string & networkId)114 int32_t ResumeDistributedHardware(DHType dhType, const std::string &networkId)
115 {
116 (void)dhType;
117 (void)networkId;
118 return DH_FWK_SUCCESS;
119 }
120
StopDistributedHardware(DHType dhType,const std::string & networkId)121 int32_t StopDistributedHardware(DHType dhType, const std::string &networkId)
122 {
123 (void)dhType;
124 (void)networkId;
125 return DH_FWK_SUCCESS;
126 }
127
GetDistributedHardware(const std::string & networkId,EnableStep enableStep,const sptr<IGetDhDescriptorsCallback> callback)128 int32_t GetDistributedHardware(const std::string &networkId, EnableStep enableStep,
129 const sptr<IGetDhDescriptorsCallback> callback)
130 {
131 (void)networkId;
132 (void)enableStep;
133 (void)callback;
134 return DH_FWK_SUCCESS;
135 }
136
RegisterDHStatusListener(sptr<IHDSinkStatusListener> listener)137 int32_t RegisterDHStatusListener(sptr<IHDSinkStatusListener> listener)
138 {
139 (void)listener;
140 return DH_FWK_SUCCESS;
141 }
142
UnregisterDHStatusListener(sptr<IHDSinkStatusListener> listener)143 int32_t UnregisterDHStatusListener(sptr<IHDSinkStatusListener> listener)
144 {
145 (void)listener;
146 return DH_FWK_SUCCESS;
147 }
148
RegisterDHStatusListener(const std::string & networkId,sptr<IHDSourceStatusListener> listener)149 int32_t RegisterDHStatusListener(const std::string &networkId, sptr<IHDSourceStatusListener> listener)
150 {
151 (void)networkId;
152 (void)listener;
153 return DH_FWK_SUCCESS;
154 }
155
UnregisterDHStatusListener(const std::string & networkId,sptr<IHDSourceStatusListener> listener)156 int32_t UnregisterDHStatusListener(const std::string &networkId, sptr<IHDSourceStatusListener> listener)
157 {
158 (void)networkId;
159 (void)listener;
160 return DH_FWK_SUCCESS;
161 }
162
EnableSink(const std::vector<DHDescriptor> & descriptors)163 int32_t EnableSink(const std::vector<DHDescriptor> &descriptors)
164 {
165 (void)descriptors;
166 return DH_FWK_SUCCESS;
167 }
168
DisableSink(const std::vector<DHDescriptor> & descriptors)169 int32_t DisableSink(const std::vector<DHDescriptor> &descriptors)
170 {
171 (void)descriptors;
172 return DH_FWK_SUCCESS;
173 }
174
EnableSource(const std::string & networkId,const std::vector<DHDescriptor> & descriptors)175 int32_t EnableSource(const std::string &networkId, const std::vector<DHDescriptor> &descriptors)
176 {
177 (void)networkId;
178 (void)descriptors;
179 return DH_FWK_SUCCESS;
180 }
181
DisableSource(const std::string & networkId,const std::vector<DHDescriptor> & descriptors)182 int32_t DisableSource(const std::string &networkId, const std::vector<DHDescriptor> &descriptors)
183 {
184 (void)networkId;
185 (void)descriptors;
186 return DH_FWK_SUCCESS;
187 }
188
LoadDistributedHDF(const DHType dhType)189 int32_t LoadDistributedHDF(const DHType dhType)
190 {
191 (void)dhType;
192 return DH_FWK_SUCCESS;
193 }
194
UnLoadDistributedHDF(const DHType dhType)195 int32_t UnLoadDistributedHDF(const DHType dhType)
196 {
197 (void)dhType;
198 return DH_FWK_SUCCESS;
199 }
200 };
201
202 class MockGetDhDescriptorsCallbackStub : public IRemoteStub<IGetDhDescriptorsCallback> {
203 public:
OnSuccess(const std::string & networkId,const std::vector<DHDescriptor> & descriptors,EnableStep enableStep)204 void OnSuccess(const std::string &networkId, const std::vector<DHDescriptor> &descriptors,
205 EnableStep enableStep) override
206 {
207 (void)networkId;
208 (void)descriptors;
209 (void)enableStep;
210 }
OnError(const std::string & networkId,int32_t error)211 void OnError(const std::string &networkId, int32_t error) override
212 {
213 (void)networkId;
214 (void)error;
215 }
216 };
217
218 class MockIPublisherListener : public IRemoteStub<IPublisherListener> {
219 public:
OnMessage(const DHTopic topic,const std::string & message)220 void OnMessage(const DHTopic topic, const std::string& message)
221 {
222 (void)topic;
223 (void)message;
224 }
225 };
226
227 class MockHDSinkStatusListenerStub : public IRemoteStub<IHDSinkStatusListener> {
228 public:
OnEnable(const DHDescriptor & dhDescriptor)229 void OnEnable(const DHDescriptor &dhDescriptor) override
230 {
231 (void)dhDescriptor;
232 }
233
OnDisable(const DHDescriptor & dhDescriptor)234 void OnDisable(const DHDescriptor &dhDescriptor) override
235 {
236 (void)dhDescriptor;
237 }
238 };
239
240 class MockHDSourceStatusListenerStub : public IRemoteStub<IHDSourceStatusListener> {
241 public:
OnEnable(const std::string & networkId,const DHDescriptor & dhDescriptor)242 void OnEnable(const std::string &networkId, const DHDescriptor &dhDescriptor) override
243 {
244 (void)networkId;
245 (void)dhDescriptor;
246 }
247
OnDisable(const std::string & networkId,const DHDescriptor & dhDescriptor)248 void OnDisable(const std::string &networkId, const DHDescriptor &dhDescriptor) override
249 {
250 (void)networkId;
251 (void)dhDescriptor;
252 }
253 };
254 } // namespace DistributedHardware
255 } // namespace OHOS
256 #endif
257