• 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 MOCK_NET_CONN_SERVICE_H
17 #define MOCK_NET_CONN_SERVICE_H
18 
19 #include <gmock/gmock.h>
20 #include "i_net_conn_service.h"
21 #include "net_all_capabilities.h"
22 
23 namespace OHOS {
24 namespace NetManagerStandard {
25 
26 class MockINetConnService : public INetConnService {
27 public:
28     MockINetConnService() = default;
29     ~MockINetConnService() = default;
30 
31     MOCK_METHOD(sptr<IRemoteObject>, AsObject, ());
32     MOCK_METHOD(int32_t, SystemReady, ());
33     MOCK_METHOD(int32_t, SetInternetPermission, (uint32_t uid, uint8_t allow));
34     MOCK_METHOD(int32_t, RegisterNetSupplier,
35         (NetBearType bearerType, const std::string &ident, const std::set<NetCap> &netCaps, uint32_t &supplierId));
36     MOCK_METHOD(int32_t, UnregisterNetSupplier, (uint32_t supplierId));
37     MOCK_METHOD(
38         int32_t, RegisterNetSupplierCallback, (uint32_t supplierId, const sptr<INetSupplierCallback> &callback));
39     MOCK_METHOD(int32_t, RegisterNetConnCallback, (const sptr<INetConnCallback> callback));
40     MOCK_METHOD(int32_t, RegisterNetConnCallback,
41         (const sptr<NetSpecifier> &netSpecifier, const sptr<INetConnCallback> callback, const uint32_t &timeoutMS));
42     MOCK_METHOD(int32_t, RequestNetConnection,
43         (const sptr<NetSpecifier> netSpecifier, const sptr<INetConnCallback> callback, const uint32_t timeoutMS));
44     MOCK_METHOD(int32_t, UnregisterNetConnCallback, (const sptr<INetConnCallback> &callback));
45     MOCK_METHOD(int32_t, UpdateNetCaps, (const std::set<NetCap> &netCaps, const uint32_t supplierId));
46     MOCK_METHOD(int32_t, UpdateNetStateForTest, (const sptr<NetSpecifier> &netSpecifier, int32_t netState));
47     MOCK_METHOD(int32_t, UpdateNetSupplierInfo, (uint32_t supplierId, const sptr<NetSupplierInfo> &netSupplierInfo));
48     MOCK_METHOD(int32_t, UpdateNetLinkInfo, (uint32_t supplierId, const sptr<NetLinkInfo> &netLinkInfo));
49     MOCK_METHOD(int32_t, SetReuseSupplierId, (uint32_t supplierId, uint32_t reuseSupplierId, bool isReused));
50     MOCK_METHOD(int32_t, GetIfaceNames, (NetBearType bearerType, std::list<std::string> &ifaceNames));
51     MOCK_METHOD(
52         int32_t, GetIfaceNameByType, (NetBearType bearerType, const std::string &ident, std::string &ifaceName));
53     MOCK_METHOD(int32_t, GetIfaceNameIdentMaps,
54         (NetBearType bearerType, (SafeMap<std::string, std::string> & ifaceNameIdentMaps)));
55     MOCK_METHOD(int32_t, RegisterNetDetectionCallback, (int32_t netId, const sptr<INetDetectionCallback> &callback));
56     MOCK_METHOD(int32_t, UnRegisterNetDetectionCallback, (int32_t netId, const sptr<INetDetectionCallback> &callback));
57     MOCK_METHOD(int32_t, NetDetection, (int32_t netId));
58     MOCK_METHOD(int32_t, GetDefaultNet, (int32_t & netId));
59     MOCK_METHOD(int32_t, HasDefaultNet, (bool &flag));
60     MOCK_METHOD(int32_t, GetAddressesByName, (const std::string &host, int32_t netId, std::vector<INetAddr> &addrList));
61     MOCK_METHOD(int32_t, GetAddressByName, (const std::string &host, int32_t netId, INetAddr &addr));
62     MOCK_METHOD(int32_t, GetSpecificNet, (NetBearType bearerType, std::list<int32_t> &netIdList));
63     MOCK_METHOD(int32_t, GetSpecificNetByIdent,
64         (NetBearType bearerType, const std::string &ident, std::list<int32_t> &netIdList));
65     MOCK_METHOD(int32_t, GetAllNets, (std::list<int32_t> & netIdList));
66     MOCK_METHOD(int32_t, GetSpecificUidNet, (int32_t uid, int32_t &netId));
67     MOCK_METHOD(int32_t, GetConnectionProperties, (int32_t netId, NetLinkInfo &info));
68     MOCK_METHOD(int32_t, GetNetCapabilities, (int32_t netId, NetManagerStandard::NetAllCapabilities &netAllCap));
69     MOCK_METHOD(int32_t, BindSocket, (int32_t socketFd, int32_t netId));
70     MOCK_METHOD(int32_t, SetAirplaneMode, (bool state));
71     MOCK_METHOD(int32_t, IsDefaultNetMetered, (bool &isMetered));
72     MOCK_METHOD(int32_t, SetGlobalHttpProxy, (const HttpProxy &httpProxy));
73     MOCK_METHOD(int32_t, GetGlobalHttpProxy, (HttpProxy & httpProxy));
74     MOCK_METHOD(int32_t, GetDefaultHttpProxy, (int32_t bindNetId, HttpProxy &httpProxy));
75     MOCK_METHOD(int32_t, GetNetIdByIdentifier, (const std::string &ident, std::list<int32_t> &netIdList));
76     MOCK_METHOD(int32_t, SetAppNet, (int32_t netId));
77     MOCK_METHOD(int32_t, RegisterNetInterfaceCallback, (const sptr<INetInterfaceStateCallback> &callback));
78     MOCK_METHOD(int32_t, GetNetInterfaceConfiguration,
79         (const std::string &iface, NetManagerStandard::NetInterfaceConfiguration &config));
80     MOCK_METHOD(int32_t, AddNetworkRoute,
81         (int32_t netId, const std::string &ifName, const std::string &destination, const std::string &nextHop));
82     MOCK_METHOD(int32_t, RemoveNetworkRoute,
83         (int32_t netId, const std::string &ifName, const std::string &destination, const std::string &nextHop));
84     MOCK_METHOD(
85         int32_t, AddInterfaceAddress, (const std::string &ifName, const std::string &ipAddr, int32_t prefixLength));
86     MOCK_METHOD(
87         int32_t, DelInterfaceAddress, (const std::string &ifName, const std::string &ipAddr, int32_t prefixLength));
88     MOCK_METHOD(
89         int32_t, AddStaticArp, (const std::string &ipAddr, const std::string &macAddr, const std::string &ifName));
90     MOCK_METHOD(
91         int32_t, DelStaticArp, (const std::string &ipAddr, const std::string &macAddr, const std::string &ifName));
92     MOCK_METHOD(int32_t, RegisterSlotType, (uint32_t supplierId, int32_t type));
93     MOCK_METHOD(int32_t, GetSlotType, (std::string & type));
94     MOCK_METHOD(int32_t, FactoryResetNetwork, ());
95     MOCK_METHOD(int32_t, RegisterNetFactoryResetCallback, (const sptr<INetFactoryResetCallback> &callback));
96     MOCK_METHOD(int32_t, IsPreferCellularUrl, (const std::string &url, bool &preferCellular));
97     MOCK_METHOD(int32_t, RegisterPreAirplaneCallback, (const sptr<IPreAirplaneCallback> callback));
98     MOCK_METHOD(int32_t, UnregisterPreAirplaneCallback, (const sptr<IPreAirplaneCallback> callback));
99     MOCK_METHOD(
100         int32_t, GetDefaultSupplierId, (NetBearType bearerType, const std::string &ident, uint32_t &supplierId));
101     MOCK_METHOD(int32_t, UpdateSupplierScore, (uint32_t supplierId, uint32_t detectionStatus));
102     MOCK_METHOD(int32_t, EnableVnicNetwork, (const sptr<NetLinkInfo> &netLinkInfo, const std::set<int32_t> &uids));
103     MOCK_METHOD(int32_t, DisableVnicNetwork, ());
104     MOCK_METHOD(int32_t, EnableDistributedClientNet, (const std::string &virnicAddr, const std::string &iif));
105     MOCK_METHOD(int32_t, EnableDistributedServerNet,
106         (const std::string &iif, const std::string &devIface, const std::string &dstAddr));
107     MOCK_METHOD(int32_t, DisableDistributedNet, (bool isServer));
108     MOCK_METHOD(int32_t, CloseSocketsUid, (int32_t netId, uint32_t uid));
109     MOCK_METHOD(int32_t, SetNetInterfaceIpAddress, (const std::string &iface, const std::string &ipAddress));
110     MOCK_METHOD(int32_t, UnregisterNetInterfaceCallback, (const sptr<INetInterfaceStateCallback> &callback));
111     MOCK_METHOD(int32_t, SetInterfaceUp, (const std::string &iface));
112     MOCK_METHOD(int32_t, SetInterfaceDown, (const std::string &iface));
113     MOCK_METHOD(int32_t, SetPacUrl, (const std::string &pacUrl));
114     MOCK_METHOD(int32_t, GetPacUrl, (std::string &pacUrl));
115     MOCK_METHOD(int32_t, SetAppIsFrozened, (uint32_t uid, bool isFrozened));
116     MOCK_METHOD(int32_t, EnableAppFrozenedCallbackLimitation, (bool flag));
117     MOCK_METHOD(int32_t, SetNetExtAttribute, (int32_t netId, const std::string &netExtAttribute));
118     MOCK_METHOD(int32_t, GetNetExtAttribute, (int32_t netId, std::string &netExtAttribute));
119     MOCK_METHOD(int32_t, AddStaticIpv6Addr, (const std::string &ipAddr, const std::string &macAddr,
120         const std::string &ifName));
121     MOCK_METHOD(int32_t, DelStaticIpv6Addr, (const std::string &ipAddr, const std::string &macAddr,
122         const std::string &ifName));
123     MOCK_METHOD(int32_t, QueryTraceRoute, (const std::string &destination, int32_t maxJumpNumber,
124         int32_t packetsType, std::string &traceRouteInfo));
125     MOCK_METHOD(int32_t, SetPacFileUrl, (const std::string &pacUrl));
126     MOCK_METHOD(int32_t, SetProxyMode, (const OHOS::NetManagerStandard::ProxyModeType mode));
127     MOCK_METHOD(int32_t, GetProxyMode, (OHOS::NetManagerStandard::ProxyModeType &mode));
128     MOCK_METHOD(int32_t, GetPacFileUrl, (std::string &pacUrl));
129     MOCK_METHOD(int32_t, FindProxyForURL, (const std::string &url, const std::string &host, std::string &proxy));
130 };
131 
132 }  // namespace NetManagerStandard
133 }  // namespace OHOS
134 #endif  // MOCK_NET_CONN_SERVICE_H