• 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 
RegisterNetSupplier(NetBearType bearerType,const std::string & ident,const std::set<NetCap> & netCaps,uint32_t & supplierId)46     int32_t RegisterNetSupplier(NetBearType bearerType, const std::string &ident, const std::set<NetCap> &netCaps,
47         uint32_t &supplierId) override
48     {
49         return 0;
50     }
51 
UnregisterNetSupplier(uint32_t supplierId)52     int32_t UnregisterNetSupplier(uint32_t supplierId) override
53     {
54         return 0;
55     }
56 
RegisterNetSupplierCallback(uint32_t supplierId,const sptr<INetSupplierCallback> & callback)57     int32_t RegisterNetSupplierCallback(uint32_t supplierId, const sptr<INetSupplierCallback> &callback) override
58     {
59         return 0;
60     }
61 
RegisterNetConnCallback(const sptr<INetConnCallback> callback)62     int32_t RegisterNetConnCallback(const sptr<INetConnCallback> callback) override
63     {
64         return 0;
65     }
66 
RegisterNetConnCallback(const sptr<NetSpecifier> & netSpecifier,const sptr<INetConnCallback> callback,const uint32_t & timeoutMS)67     int32_t RegisterNetConnCallback(const sptr<NetSpecifier> &netSpecifier, const sptr<INetConnCallback> callback,
68         const uint32_t &timeoutMS) override
69     {
70         return 0;
71     }
72 
RequestNetConnection(const sptr<NetSpecifier> netSpecifier,const sptr<INetConnCallback> callback,const uint32_t timeoutMS)73     int32_t RequestNetConnection(const sptr<NetSpecifier> netSpecifier,
74         const sptr<INetConnCallback> callback, const uint32_t timeoutMS) override
75     {
76         return 0;
77     }
78 
UnregisterNetConnCallback(const sptr<INetConnCallback> & callback)79     int32_t UnregisterNetConnCallback(const sptr<INetConnCallback> &callback) override
80     {
81         return 0;
82     }
83 
UpdateNetStateForTest(const sptr<NetSpecifier> & netSpecifier,int32_t netState)84     int32_t UpdateNetStateForTest(const sptr<NetSpecifier> &netSpecifier, int32_t netState) override
85     {
86         return 0;
87     }
88 
UpdateNetSupplierInfo(uint32_t supplierId,const sptr<NetSupplierInfo> & netSupplierInfo)89     int32_t UpdateNetSupplierInfo(uint32_t supplierId, const sptr<NetSupplierInfo> &netSupplierInfo) override
90     {
91         return 0;
92     }
93 
UpdateNetLinkInfo(uint32_t supplierId,const sptr<NetLinkInfo> & netLinkInfo)94     int32_t UpdateNetLinkInfo(uint32_t supplierId, const sptr<NetLinkInfo> &netLinkInfo) override
95     {
96         return 0;
97     }
98 
GetDefaultNet(int32_t & netId)99     int32_t GetDefaultNet(int32_t &netId) override
100     {
101         return 0;
102     }
103 
HasDefaultNet(bool & flag)104     int32_t HasDefaultNet(bool &flag) override
105     {
106         return 0;
107     }
108 
GetIfaceNames(NetBearType bearerType,std::list<std::string> & ifaceNames)109     int32_t GetIfaceNames(NetBearType bearerType, std::list<std::string> &ifaceNames) override
110     {
111         return 0;
112     }
113 
GetIfaceNameByType(NetBearType bearerType,const std::string & ident,std::string & ifaceName)114     int32_t GetIfaceNameByType(NetBearType bearerType, const std::string &ident, std::string &ifaceName) override
115     {
116         return 0;
117     }
118 
RegisterNetDetectionCallback(int32_t netId,const sptr<INetDetectionCallback> & callback)119     int32_t RegisterNetDetectionCallback(int32_t netId, const sptr<INetDetectionCallback> &callback) override
120     {
121         return 0;
122     }
123 
UnRegisterNetDetectionCallback(int32_t netId,const sptr<INetDetectionCallback> & callback)124     int32_t UnRegisterNetDetectionCallback(int32_t netId, const sptr<INetDetectionCallback> &callback) override
125     {
126         return 0;
127     }
128 
NetDetection(int32_t netId)129     int32_t NetDetection(int32_t netId) override
130     {
131         return 0;
132     }
133 
GetAddressesByName(const std::string & host,int32_t netId,std::vector<INetAddr> & addrList)134     int32_t GetAddressesByName(const std::string &host, int32_t netId, std::vector<INetAddr> &addrList) override
135     {
136         return 0;
137     }
138 
GetAddressByName(const std::string & host,int32_t netId,INetAddr & addr)139     int32_t GetAddressByName(const std::string &host, int32_t netId, INetAddr &addr) override
140     {
141         return 0;
142     }
143 
GetIfaceNameIdentMaps(NetBearType bearerType,SafeMap<std::string,std::string> & ifaceNameIdentMaps)144     int32_t GetIfaceNameIdentMaps(NetBearType bearerType,
145                                   SafeMap<std::string, std::string> &ifaceNameIdentMaps) override
146     {
147         return 0;
148     }
149 
GetSpecificNet(NetBearType bearerType,std::list<int32_t> & netIdList)150     int32_t GetSpecificNet(NetBearType bearerType, std::list<int32_t> &netIdList) override
151     {
152         return 0;
153     }
154 
GetAllNets(std::list<int32_t> & netIdList)155     int32_t GetAllNets(std::list<int32_t> &netIdList) override
156     {
157         return 0;
158     }
159 
GetSpecificUidNet(int32_t uid,int32_t & netId)160     int32_t GetSpecificUidNet(int32_t uid, int32_t &netId) override
161     {
162         return 0;
163     }
164 
GetConnectionProperties(int32_t netId,NetLinkInfo & info)165     int32_t GetConnectionProperties(int32_t netId, NetLinkInfo &info) override
166     {
167         return 0;
168     }
169 
GetNetCapabilities(int32_t netId,NetAllCapabilities & netAllCap)170     int32_t GetNetCapabilities(int32_t netId, NetAllCapabilities &netAllCap) override
171     {
172         return 0;
173     }
174 
BindSocket(int32_t socketFd,int32_t netId)175     int32_t BindSocket(int32_t socketFd, int32_t netId) override
176     {
177         return 0;
178     }
179 
SetAirplaneMode(bool state)180     int32_t SetAirplaneMode(bool state) override
181     {
182         return 0;
183     }
184 
IsDefaultNetMetered(bool & isMetered)185     int32_t IsDefaultNetMetered(bool &isMetered) override
186     {
187         return 0;
188     }
189 
SetGlobalHttpProxy(const HttpProxy & httpProxy)190     int32_t SetGlobalHttpProxy(const HttpProxy &httpProxy) override
191     {
192         return 0;
193     }
194 
GetGlobalHttpProxy(HttpProxy & httpProxy)195     int32_t GetGlobalHttpProxy(HttpProxy &httpProxy) override
196     {
197         return 0;
198     }
199 
GetDefaultHttpProxy(int32_t bindNetId,HttpProxy & httpProxy)200     int32_t GetDefaultHttpProxy(int32_t bindNetId, HttpProxy &httpProxy) override
201     {
202         return 0;
203     }
204 
GetNetIdByIdentifier(const std::string & ident,std::list<int32_t> & netIdList)205     int32_t GetNetIdByIdentifier(const std::string &ident, std::list<int32_t> &netIdList) override
206     {
207         return 0;
208     }
209 
SetAppNet(int32_t netId)210     int32_t SetAppNet(int32_t netId) override
211     {
212         return 0;
213     }
214 
RegisterNetInterfaceCallback(const sptr<INetInterfaceStateCallback> & callback)215     int32_t RegisterNetInterfaceCallback(const sptr<INetInterfaceStateCallback> &callback) override
216     {
217         return 0;
218     }
219 
GetNetInterfaceConfiguration(const std::string & iface,NetInterfaceConfiguration & config)220     int32_t GetNetInterfaceConfiguration(const std::string &iface, NetInterfaceConfiguration &config) override
221     {
222         return 0;
223     }
224 
AddNetworkRoute(int32_t netId,const std::string & ifName,const std::string & destination,const std::string & nextHop)225     int32_t AddNetworkRoute(
226         int32_t netId, const std::string &ifName, const std::string &destination, const std::string &nextHop) override
227     {
228         return 0;
229     }
230 
RemoveNetworkRoute(int32_t netId,const std::string & ifName,const std::string & destination,const std::string & nextHop)231     int32_t RemoveNetworkRoute(
232         int32_t netId, const std::string &ifName, const std::string &destination, const std::string &nextHop) override
233     {
234         return 0;
235     }
236 
AddInterfaceAddress(const std::string & ifName,const std::string & ipAddr,int32_t prefixLength)237     int32_t AddInterfaceAddress(const std::string &ifName, const std::string &ipAddr, int32_t prefixLength) override
238     {
239         return 0;
240     }
241 
DelInterfaceAddress(const std::string & ifName,const std::string & ipAddr,int32_t prefixLength)242     int32_t DelInterfaceAddress(const std::string &ifName, const std::string &ipAddr, int32_t prefixLength) override
243     {
244         return 0;
245     }
246 
AddStaticArp(const std::string & ipAddr,const std::string & macAddr,const std::string & ifName)247     int32_t AddStaticArp(const std::string &ipAddr, const std::string &macAddr, const std::string &ifName) override
248     {
249         return 0;
250     }
251 
DelStaticArp(const std::string & ipAddr,const std::string & macAddr,const std::string & ifName)252     int32_t DelStaticArp(const std::string &ipAddr, const std::string &macAddr, const std::string &ifName) override
253     {
254         return 0;
255     }
256 
RegisterSlotType(uint32_t supplierId,int32_t type)257     int32_t RegisterSlotType(uint32_t supplierId, int32_t type) override
258     {
259         return 0;
260     }
261 
GetSlotType(std::string & type)262     int32_t GetSlotType(std::string &type) override
263     {
264         return 0;
265     }
266 
FactoryResetNetwork()267     int32_t FactoryResetNetwork() override
268     {
269         return 0;
270     }
271 
RegisterNetFactoryResetCallback(const sptr<INetFactoryResetCallback> & callback)272     int32_t RegisterNetFactoryResetCallback(const sptr<INetFactoryResetCallback> &callback) override
273     {
274         return 0;
275     }
276 
IsPreferCellularUrl(const std::string & url,bool & preferCellular)277     int32_t IsPreferCellularUrl(const std::string &url, bool &preferCellular) override
278     {
279         return 0;
280     }
281 
RegisterPreAirplaneCallback(const sptr<IPreAirplaneCallback> callback)282     int32_t RegisterPreAirplaneCallback(const sptr<IPreAirplaneCallback> callback) override
283     {
284         return 0;
285     }
286 
UnregisterPreAirplaneCallback(const sptr<IPreAirplaneCallback> callback)287     int32_t UnregisterPreAirplaneCallback(const sptr<IPreAirplaneCallback> callback) override
288     {
289         return 0;
290     }
291 
UpdateSupplierScore(NetBearType bearerType,uint32_t detectionStatus,uint32_t & supplierId)292     int32_t UpdateSupplierScore(NetBearType bearerType, uint32_t detectionStatus, uint32_t& supplierId) override
293     {
294         return 0;
295     }
296 
EnableVnicNetwork(const sptr<NetLinkInfo> & netLinkInfo,const std::set<int32_t> & uids)297     int32_t EnableVnicNetwork(const sptr<NetLinkInfo> &netLinkInfo, const std::set<int32_t> &uids) override
298     {
299         return 0;
300     }
301 
DisableVnicNetwork()302     int32_t DisableVnicNetwork() override
303     {
304         return 0;
305     }
306 
SetPacUrl(const std::string & pacUrl)307     int32_t SetPacUrl(const std::string &pacUrl) override
308     {
309         return 0;
310     }
311 
GetPacUrl(std::string & pacUrl)312     int32_t GetPacUrl(std::string &pacUrl) override
313     {
314         return 0;
315     }
316 };
317 } // namespace NetManagerStandard
318 } // namespace OHOS
319 #endif // NET_CONN_SERVICE_STUB_TEST_H
320