• 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 NET_CONN_SERVICE_STUB_TEST_H
17 #define NET_CONN_SERVICE_STUB_TEST_H
18 
19 #include <gtest/gtest.h>
20 
21 #ifdef GTEST_API_
22 #define private public
23 #define protected public
24 #endif
25 
26 #include "i_net_conn_service.h"
27 #include "net_conn_service_stub.h"
28 
29 namespace OHOS {
30 namespace NetManagerStandard {
31 class MockNetConnServiceStub : public NetConnServiceStub {
32 public:
33     MockNetConnServiceStub() = default;
~MockNetConnServiceStub()34     ~MockNetConnServiceStub() override {};
35 
SystemReady()36     int32_t SystemReady() override
37     {
38         return 0;
39     }
40 
SetInternetPermission(uint32_t uid,uint8_t allow)41     int32_t SetInternetPermission(uint32_t uid, uint8_t allow) override
42     {
43         return 0;
44     }
45 
SetProxyMode(const OHOS::NetManagerStandard::ProxyModeType mode)46     int32_t SetProxyMode(const OHOS::NetManagerStandard::ProxyModeType mode) override
47     {
48         return 0;
49     }
50 
GetProxyMode(OHOS::NetManagerStandard::ProxyModeType & mode)51     int32_t GetProxyMode(OHOS::NetManagerStandard::ProxyModeType &mode) override
52     {
53         return 0;
54     }
55 
RegisterNetSupplier(NetBearType bearerType,const std::string & ident,const std::set<NetCap> & netCaps,uint32_t & supplierId)56     int32_t RegisterNetSupplier(NetBearType bearerType, const std::string &ident, const std::set<NetCap> &netCaps,
57         uint32_t &supplierId) override
58     {
59         return 0;
60     }
61 
UnregisterNetSupplier(uint32_t supplierId)62     int32_t UnregisterNetSupplier(uint32_t supplierId) override
63     {
64         return 0;
65     }
66 
RegisterNetSupplierCallback(uint32_t supplierId,const sptr<INetSupplierCallback> & callback)67     int32_t RegisterNetSupplierCallback(uint32_t supplierId, const sptr<INetSupplierCallback> &callback) override
68     {
69         return 0;
70     }
71 
RegisterNetConnCallback(const sptr<INetConnCallback> callback)72     int32_t RegisterNetConnCallback(const sptr<INetConnCallback> callback) override
73     {
74         return 0;
75     }
76 
RegisterNetConnCallback(const sptr<NetSpecifier> & netSpecifier,const sptr<INetConnCallback> callback,const uint32_t & timeoutMS)77     int32_t RegisterNetConnCallback(const sptr<NetSpecifier> &netSpecifier, const sptr<INetConnCallback> callback,
78         const uint32_t &timeoutMS) override
79     {
80         return 0;
81     }
82 
RequestNetConnection(const sptr<NetSpecifier> netSpecifier,const sptr<INetConnCallback> callback,const uint32_t timeoutMS)83     int32_t RequestNetConnection(const sptr<NetSpecifier> netSpecifier,
84         const sptr<INetConnCallback> callback, const uint32_t timeoutMS) override
85     {
86         return 0;
87     }
88 
UnregisterNetConnCallback(const sptr<INetConnCallback> & callback)89     int32_t UnregisterNetConnCallback(const sptr<INetConnCallback> &callback) override
90     {
91         return 0;
92     }
93 
UpdateNetCaps(const std::set<NetCap> & netCaps,const uint32_t supplierId)94     int32_t UpdateNetCaps(const std::set<NetCap> &netCaps, const uint32_t supplierId) override
95     {
96         return 0;
97     }
98 
UpdateNetStateForTest(const sptr<NetSpecifier> & netSpecifier,int32_t netState)99     int32_t UpdateNetStateForTest(const sptr<NetSpecifier> &netSpecifier, int32_t netState) override
100     {
101         return 0;
102     }
103 
UpdateNetSupplierInfo(uint32_t supplierId,const sptr<NetSupplierInfo> & netSupplierInfo)104     int32_t UpdateNetSupplierInfo(uint32_t supplierId, const sptr<NetSupplierInfo> &netSupplierInfo) override
105     {
106         return 0;
107     }
108 
UpdateNetLinkInfo(uint32_t supplierId,const sptr<NetLinkInfo> & netLinkInfo)109     int32_t UpdateNetLinkInfo(uint32_t supplierId, const sptr<NetLinkInfo> &netLinkInfo) override
110     {
111         return 0;
112     }
113 
SetReuseSupplierId(uint32_t supplierId,uint32_t reuseSupplierId,bool isReused)114     int32_t SetReuseSupplierId(uint32_t supplierId, uint32_t reuseSupplierId, bool isReused) override
115     {
116         return 0;
117     }
118 
GetDefaultNet(int32_t & netId)119     int32_t GetDefaultNet(int32_t &netId) override
120     {
121         return 0;
122     }
123 
HasDefaultNet(bool & flag)124     int32_t HasDefaultNet(bool &flag) override
125     {
126         return 0;
127     }
128 
GetIfaceNames(NetBearType bearerType,std::list<std::string> & ifaceNames)129     int32_t GetIfaceNames(NetBearType bearerType, std::list<std::string> &ifaceNames) override
130     {
131         return 0;
132     }
133 
GetIfaceNameByType(NetBearType bearerType,const std::string & ident,std::string & ifaceName)134     int32_t GetIfaceNameByType(NetBearType bearerType, const std::string &ident, std::string &ifaceName) override
135     {
136         return 0;
137     }
138 
RegisterNetDetectionCallback(int32_t netId,const sptr<INetDetectionCallback> & callback)139     int32_t RegisterNetDetectionCallback(int32_t netId, const sptr<INetDetectionCallback> &callback) override
140     {
141         return 0;
142     }
143 
UnRegisterNetDetectionCallback(int32_t netId,const sptr<INetDetectionCallback> & callback)144     int32_t UnRegisterNetDetectionCallback(int32_t netId, const sptr<INetDetectionCallback> &callback) override
145     {
146         return 0;
147     }
148 
NetDetection(int32_t netId)149     int32_t NetDetection(int32_t netId) override
150     {
151         return 0;
152     }
153 
GetAddressesByName(const std::string & host,int32_t netId,std::vector<INetAddr> & addrList)154     int32_t GetAddressesByName(const std::string &host, int32_t netId, std::vector<INetAddr> &addrList) override
155     {
156         return 0;
157     }
158 
GetAddressByName(const std::string & host,int32_t netId,INetAddr & addr)159     int32_t GetAddressByName(const std::string &host, int32_t netId, INetAddr &addr) override
160     {
161         return 0;
162     }
163 
GetIfaceNameIdentMaps(NetBearType bearerType,SafeMap<std::string,std::string> & ifaceNameIdentMaps)164     int32_t GetIfaceNameIdentMaps(NetBearType bearerType,
165                                   SafeMap<std::string, std::string> &ifaceNameIdentMaps) override
166     {
167         return 0;
168     }
169 
GetSpecificNet(NetBearType bearerType,std::list<int32_t> & netIdList)170     int32_t GetSpecificNet(NetBearType bearerType, std::list<int32_t> &netIdList) override
171     {
172         return 0;
173     }
174 
GetSpecificNetByIdent(NetBearType bearerType,const std::string & ident,std::list<int32_t> & netIdList)175     int32_t GetSpecificNetByIdent(NetBearType bearerType,
176         const std::string &ident, std::list<int32_t> &netIdList) override
177     {
178         return 0;
179     }
180 
GetAllNets(std::list<int32_t> & netIdList)181     int32_t GetAllNets(std::list<int32_t> &netIdList) override
182     {
183         return 0;
184     }
185 
GetSpecificUidNet(int32_t uid,int32_t & netId)186     int32_t GetSpecificUidNet(int32_t uid, int32_t &netId) override
187     {
188         return 0;
189     }
190 
GetConnectionProperties(int32_t netId,NetLinkInfo & info)191     int32_t GetConnectionProperties(int32_t netId, NetLinkInfo &info) override
192     {
193         return 0;
194     }
195 
GetNetCapabilities(int32_t netId,NetAllCapabilities & netAllCap)196     int32_t GetNetCapabilities(int32_t netId, NetAllCapabilities &netAllCap) override
197     {
198         return 0;
199     }
200 
BindSocket(int32_t socketFd,int32_t netId)201     int32_t BindSocket(int32_t socketFd, int32_t netId) override
202     {
203         return 0;
204     }
205 
SetAirplaneMode(bool state)206     int32_t SetAirplaneMode(bool state) override
207     {
208         return 0;
209     }
210 
IsDefaultNetMetered(bool & isMetered)211     int32_t IsDefaultNetMetered(bool &isMetered) override
212     {
213         return 0;
214     }
215 
SetGlobalHttpProxy(const HttpProxy & httpProxy)216     int32_t SetGlobalHttpProxy(const HttpProxy &httpProxy) override
217     {
218         return 0;
219     }
220 
GetGlobalHttpProxy(HttpProxy & httpProxy)221     int32_t GetGlobalHttpProxy(HttpProxy &httpProxy) override
222     {
223         return 0;
224     }
225 
GetDefaultHttpProxy(int32_t bindNetId,HttpProxy & httpProxy)226     int32_t GetDefaultHttpProxy(int32_t bindNetId, HttpProxy &httpProxy) override
227     {
228         return 0;
229     }
230 
GetNetIdByIdentifier(const std::string & ident,std::list<int32_t> & netIdList)231     int32_t GetNetIdByIdentifier(const std::string &ident, std::list<int32_t> &netIdList) override
232     {
233         return 0;
234     }
235 
SetAppNet(int32_t netId)236     int32_t SetAppNet(int32_t netId) override
237     {
238         return 0;
239     }
240 
RegisterNetInterfaceCallback(const sptr<INetInterfaceStateCallback> & callback)241     int32_t RegisterNetInterfaceCallback(const sptr<INetInterfaceStateCallback> &callback) override
242     {
243         return 0;
244     }
245 
GetNetInterfaceConfiguration(const std::string & iface,NetInterfaceConfiguration & config)246     int32_t GetNetInterfaceConfiguration(const std::string &iface, NetInterfaceConfiguration &config) override
247     {
248         return 0;
249     }
250 
AddNetworkRoute(int32_t netId,const std::string & ifName,const std::string & destination,const std::string & nextHop)251     int32_t AddNetworkRoute(
252         int32_t netId, const std::string &ifName, const std::string &destination, const std::string &nextHop) override
253     {
254         return 0;
255     }
256 
RemoveNetworkRoute(int32_t netId,const std::string & ifName,const std::string & destination,const std::string & nextHop)257     int32_t RemoveNetworkRoute(
258         int32_t netId, const std::string &ifName, const std::string &destination, const std::string &nextHop) override
259     {
260         return 0;
261     }
262 
AddInterfaceAddress(const std::string & ifName,const std::string & ipAddr,int32_t prefixLength)263     int32_t AddInterfaceAddress(const std::string &ifName, const std::string &ipAddr, int32_t prefixLength) override
264     {
265         return 0;
266     }
267 
DelInterfaceAddress(const std::string & ifName,const std::string & ipAddr,int32_t prefixLength)268     int32_t DelInterfaceAddress(const std::string &ifName, const std::string &ipAddr, int32_t prefixLength) override
269     {
270         return 0;
271     }
272 
AddStaticArp(const std::string & ipAddr,const std::string & macAddr,const std::string & ifName)273     int32_t AddStaticArp(const std::string &ipAddr, const std::string &macAddr, const std::string &ifName) override
274     {
275         return 0;
276     }
277 
DelStaticArp(const std::string & ipAddr,const std::string & macAddr,const std::string & ifName)278     int32_t DelStaticArp(const std::string &ipAddr, const std::string &macAddr, const std::string &ifName) override
279     {
280         return 0;
281     }
282 
AddStaticIpv6Addr(const std::string & ipAddr,const std::string & macAddr,const std::string & ifName)283     int32_t AddStaticIpv6Addr(const std::string &ipAddr, const std::string &macAddr, const std::string &ifName) override
284     {
285         return 0;
286     }
287 
DelStaticIpv6Addr(const std::string & ipAddr,const std::string & macAddr,const std::string & ifName)288     int32_t DelStaticIpv6Addr(const std::string &ipAddr, const std::string &macAddr, const std::string &ifName) override
289     {
290         return 0;
291     }
292 
RegisterSlotType(uint32_t supplierId,int32_t type)293     int32_t RegisterSlotType(uint32_t supplierId, int32_t type) override
294     {
295         return 0;
296     }
297 
GetSlotType(std::string & type)298     int32_t GetSlotType(std::string &type) override
299     {
300         return 0;
301     }
302 
FactoryResetNetwork()303     int32_t FactoryResetNetwork() override
304     {
305         return 0;
306     }
307 
RegisterNetFactoryResetCallback(const sptr<INetFactoryResetCallback> & callback)308     int32_t RegisterNetFactoryResetCallback(const sptr<INetFactoryResetCallback> &callback) override
309     {
310         return 0;
311     }
312 
IsPreferCellularUrl(const std::string & url,bool & preferCellular)313     int32_t IsPreferCellularUrl(const std::string &url, bool &preferCellular) override
314     {
315         return 0;
316     }
317 
RegisterPreAirplaneCallback(const sptr<IPreAirplaneCallback> callback)318     int32_t RegisterPreAirplaneCallback(const sptr<IPreAirplaneCallback> callback) override
319     {
320         return 0;
321     }
322 
UnregisterPreAirplaneCallback(const sptr<IPreAirplaneCallback> callback)323     int32_t UnregisterPreAirplaneCallback(const sptr<IPreAirplaneCallback> callback) override
324     {
325         return 0;
326     }
327 
UpdateSupplierScore(uint32_t supplierId,uint32_t detectionStatus)328     int32_t UpdateSupplierScore(uint32_t supplierId, uint32_t detectionStatus) override
329     {
330         return 0;
331     }
332 
GetDefaultSupplierId(NetBearType bearerType,const std::string & ident,uint32_t & supplierId)333     int32_t GetDefaultSupplierId(NetBearType bearerType, const std::string &ident, uint32_t& supplierId) override
334     {
335         return 0;
336     }
337 
EnableVnicNetwork(const sptr<NetLinkInfo> & netLinkInfo,const std::set<int32_t> & uids)338     int32_t EnableVnicNetwork(const sptr<NetLinkInfo> &netLinkInfo, const std::set<int32_t> &uids) override
339     {
340         return 0;
341     }
342 
DisableVnicNetwork()343     int32_t DisableVnicNetwork() override
344     {
345         return 0;
346     }
347 
EnableDistributedClientNet(const std::string & virnicAddr,const std::string & iif)348     int32_t EnableDistributedClientNet(const std::string &virnicAddr, const std::string &iif) override
349     {
350         return 0;
351     }
352 
EnableDistributedServerNet(const std::string & iif,const std::string & devIface,const std::string & dstAddr)353     int32_t EnableDistributedServerNet(const std::string &iif, const std::string &devIface,
354                                        const std::string &dstAddr) override
355     {
356         return 0;
357     }
358 
DisableDistributedNet(bool isServer)359     int32_t DisableDistributedNet(bool isServer) override
360     {
361         return 0;
362     }
363 
CloseSocketsUid(int32_t netId,uint32_t uid)364     int32_t CloseSocketsUid(int32_t netId, uint32_t uid) override
365     {
366         return 0;
367     }
368 
UnregisterNetInterfaceCallback(const sptr<INetInterfaceStateCallback> & callback)369     int32_t UnregisterNetInterfaceCallback(const sptr<INetInterfaceStateCallback> &callback) override
370     {
371         return 0;
372     }
373 
SetInterfaceUp(const std::string & iface)374     int32_t SetInterfaceUp(const std::string &iface) override
375     {
376         return 0;
377     }
378 
SetInterfaceDown(const std::string & iface)379     int32_t SetInterfaceDown(const std::string &iface) override
380     {
381         return 0;
382     }
383 
SetNetInterfaceIpAddress(const std::string & iface,const std::string & ipAddress)384     int32_t SetNetInterfaceIpAddress(const std::string &iface, const std::string &ipAddress) override
385     {
386         return 0;
387     }
388 
SetPacUrl(const std::string & pacUrl)389     int32_t SetPacUrl(const std::string &pacUrl) override
390     {
391         return 0;
392     }
393 
QueryTraceRoute(const std::string & destination,int32_t maxJumpNumber,int32_t packetsType,std::string & traceRouteInfo)394     int32_t QueryTraceRoute(const std::string &destination, int32_t maxJumpNumber, int32_t packetsType,
395         std::string &traceRouteInfo) override
396     {
397         return 0;
398     }
399 
GetPacUrl(std::string & pacUrl)400     int32_t GetPacUrl(std::string &pacUrl) override
401     {
402         return 0;
403     }
404 
GetPacFileUrl(std::string & pacUrl)405     int32_t GetPacFileUrl(std::string &pacUrl) override
406     {
407         return 0;
408     }
409 
SetPacFileUrl(const std::string & pacUrl)410     int32_t SetPacFileUrl(const std::string &pacUrl) override
411     {
412         return 0;
413     }
414 
FindProxyForURL(const std::string & url,const std::string & host,std::string & proxy)415     int32_t FindProxyForURL(const std::string &url, const std::string &host, std::string &proxy) override
416     {
417         return 0;
418     }
419 
SetAppIsFrozened(uint32_t uid,bool isFrozened)420     int32_t SetAppIsFrozened(uint32_t uid, bool isFrozened) override
421     {
422         return 0;
423     }
424 
EnableAppFrozenedCallbackLimitation(bool flag)425     int32_t EnableAppFrozenedCallbackLimitation(bool flag) override
426     {
427         return 0;
428     }
429 
SetNetExtAttribute(int32_t netId,const std::string & netExtAttribute)430     int32_t SetNetExtAttribute(int32_t netId, const std::string &netExtAttribute) override
431     {
432         return 0;
433     }
434 
GetNetExtAttribute(int32_t netId,std::string & netExtAttribute)435     int32_t GetNetExtAttribute(int32_t netId, std::string &netExtAttribute) override
436     {
437         return 0;
438     }
439 };
440 } // namespace NetManagerStandard
441 } // namespace OHOS
442 #endif // NET_CONN_SERVICE_STUB_TEST_H
443