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, UpdateNetStateForTest, (const sptr<NetSpecifier> &netSpecifier, int32_t netState)); 46 MOCK_METHOD(int32_t, UpdateNetSupplierInfo, (uint32_t supplierId, const sptr<NetSupplierInfo> &netSupplierInfo)); 47 MOCK_METHOD(int32_t, UpdateNetLinkInfo, (uint32_t supplierId, const sptr<NetLinkInfo> &netLinkInfo)); 48 MOCK_METHOD(int32_t, GetIfaceNames, (NetBearType bearerType, std::list<std::string> &ifaceNames)); 49 MOCK_METHOD( 50 int32_t, GetIfaceNameByType, (NetBearType bearerType, const std::string &ident, std::string &ifaceName)); 51 MOCK_METHOD(int32_t, GetIfaceNameIdentMaps, 52 (NetBearType bearerType, (SafeMap<std::string, std::string> & ifaceNameIdentMaps))); 53 MOCK_METHOD(int32_t, RegisterNetDetectionCallback, (int32_t netId, const sptr<INetDetectionCallback> &callback)); 54 MOCK_METHOD(int32_t, UnRegisterNetDetectionCallback, (int32_t netId, const sptr<INetDetectionCallback> &callback)); 55 MOCK_METHOD(int32_t, NetDetection, (int32_t netId)); 56 MOCK_METHOD(int32_t, GetDefaultNet, (int32_t & netId)); 57 MOCK_METHOD(int32_t, HasDefaultNet, (bool &flag)); 58 MOCK_METHOD(int32_t, GetAddressesByName, (const std::string &host, int32_t netId, std::vector<INetAddr> &addrList)); 59 MOCK_METHOD(int32_t, GetAddressByName, (const std::string &host, int32_t netId, INetAddr &addr)); 60 MOCK_METHOD(int32_t, GetSpecificNet, (NetBearType bearerType, std::list<int32_t> &netIdList)); 61 MOCK_METHOD(int32_t, GetAllNets, (std::list<int32_t> & netIdList)); 62 MOCK_METHOD(int32_t, GetSpecificUidNet, (int32_t uid, int32_t &netId)); 63 MOCK_METHOD(int32_t, GetConnectionProperties, (int32_t netId, NetLinkInfo &info)); 64 MOCK_METHOD(int32_t, GetNetCapabilities, (int32_t netId, NetManagerStandard::NetAllCapabilities &netAllCap)); 65 MOCK_METHOD(int32_t, BindSocket, (int32_t socketFd, int32_t netId)); 66 MOCK_METHOD(int32_t, SetAirplaneMode, (bool state)); 67 MOCK_METHOD(int32_t, IsDefaultNetMetered, (bool &isMetered)); 68 MOCK_METHOD(int32_t, SetGlobalHttpProxy, (const HttpProxy &httpProxy)); 69 MOCK_METHOD(int32_t, GetGlobalHttpProxy, (HttpProxy & httpProxy)); 70 MOCK_METHOD(int32_t, GetDefaultHttpProxy, (int32_t bindNetId, HttpProxy &httpProxy)); 71 MOCK_METHOD(int32_t, GetNetIdByIdentifier, (const std::string &ident, std::list<int32_t> &netIdList)); 72 MOCK_METHOD(int32_t, SetAppNet, (int32_t netId)); 73 MOCK_METHOD(int32_t, RegisterNetInterfaceCallback, (const sptr<INetInterfaceStateCallback> &callback)); 74 MOCK_METHOD(int32_t, GetNetInterfaceConfiguration, 75 (const std::string &iface, NetManagerStandard::NetInterfaceConfiguration &config)); 76 MOCK_METHOD(int32_t, AddNetworkRoute, 77 (int32_t netId, const std::string &ifName, const std::string &destination, const std::string &nextHop)); 78 MOCK_METHOD(int32_t, RemoveNetworkRoute, 79 (int32_t netId, const std::string &ifName, const std::string &destination, const std::string &nextHop)); 80 MOCK_METHOD( 81 int32_t, AddInterfaceAddress, (const std::string &ifName, const std::string &ipAddr, int32_t prefixLength)); 82 MOCK_METHOD( 83 int32_t, DelInterfaceAddress, (const std::string &ifName, const std::string &ipAddr, int32_t prefixLength)); 84 MOCK_METHOD( 85 int32_t, AddStaticArp, (const std::string &ipAddr, const std::string &macAddr, const std::string &ifName)); 86 MOCK_METHOD( 87 int32_t, DelStaticArp, (const std::string &ipAddr, const std::string &macAddr, const std::string &ifName)); 88 MOCK_METHOD(int32_t, RegisterSlotType, (uint32_t supplierId, int32_t type)); 89 MOCK_METHOD(int32_t, GetSlotType, (std::string & type)); 90 MOCK_METHOD(int32_t, FactoryResetNetwork, ()); 91 MOCK_METHOD(int32_t, RegisterNetFactoryResetCallback, (const sptr<INetFactoryResetCallback> &callback)); 92 MOCK_METHOD(int32_t, IsPreferCellularUrl, (const std::string &url, bool &preferCellular)); 93 MOCK_METHOD(int32_t, RegisterPreAirplaneCallback, (const sptr<IPreAirplaneCallback> callback)); 94 MOCK_METHOD(int32_t, UnregisterPreAirplaneCallback, (const sptr<IPreAirplaneCallback> callback)); 95 MOCK_METHOD(int32_t, UpdateSupplierScore, (NetBearType bearerType, uint32_t detectionStatus, uint32_t &supplierId)); 96 MOCK_METHOD(int32_t, EnableVnicNetwork, (const sptr<NetLinkInfo> &netLinkInfo, const std::set<int32_t> &uids)); 97 MOCK_METHOD(int32_t, DisableVnicNetwork, ()); 98 MOCK_METHOD(int32_t, EnableDistributedClientNet, (const std::string &virnicAddr, const std::string &iif)); 99 MOCK_METHOD(int32_t, EnableDistributedServerNet, 100 (const std::string &iif, const std::string &devIface, const std::string &dstAddr)); 101 MOCK_METHOD(int32_t, DisableDistributedNet, (bool isServer)); 102 MOCK_METHOD(int32_t, CloseSocketsUid, (int32_t netId, uint32_t uid)); 103 }; 104 105 } // namespace NetManagerStandard 106 } // namespace OHOS 107 #endif // MOCK_NET_CONN_SERVICE_H