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 #ifndef OHOS_SOFTBUS_LISTENER_MOCK_H 16 #define OHOS_SOFTBUS_LISTENER_MOCK_H 17 18 #include <string> 19 #include <gmock/gmock.h> 20 21 #include "softbus_listener.h" 22 23 namespace OHOS { 24 namespace DistributedHardware { 25 class DmSoftbusListener { 26 public: 27 virtual ~DmSoftbusListener() = default; 28 public: 29 virtual int32_t ShiftLNNGear(bool isWakeUp, const std::string &callerId) = 0; 30 virtual int32_t GetUdidByNetworkId(const char *networkId, std::string &udid) = 0; 31 virtual int32_t GetDeviceSecurityLevel(const char *networkId, int32_t &securityLevel) = 0; 32 virtual int32_t GetDeviceInfo(const std::string &networkId, DmDeviceInfo &info) = 0; 33 virtual int32_t GetUuidByNetworkId(const char *networkId, std::string &uuid) = 0; 34 virtual int32_t GetTargetInfoFromCache(const std::string &deviceId, PeerTargetId &targetId, 35 ConnectionAddrType &addrType) = 0; 36 virtual int32_t GetTrustedDeviceList(std::vector<DmDeviceInfo> &deviceInfoList) = 0; 37 virtual int32_t GetLocalDeviceInfo(DmDeviceInfo &deviceInfo) = 0; 38 virtual int32_t GetDeviceScreenStatus(const char *networkId, int32_t &screenStatus) = 0; 39 virtual int32_t GetIPAddrTypeFromCache(const std::string &deviceId, const std::string &ip, 40 ConnectionAddrType &addrType) = 0; 41 virtual int32_t GetNetworkTypeByNetworkId(const char *networkId, int32_t &networkType) = 0; 42 virtual int32_t SetLocalDisplayName(const std::string &displayName) = 0; 43 virtual int32_t GetUdidFromDp(const std::string &udidHash, std::string &udid) = 0; 44 virtual int32_t GetAllTrustedDeviceList(const std::string &pkgName, const std::string &extra, 45 std::vector<DmDeviceInfo> &deviceList) = 0; 46 virtual int32_t StopRefreshSoftbusLNN(uint16_t subscribeId) = 0; 47 virtual void SendAclChangedBroadcast(const std::string &msg) = 0; 48 public: 49 static inline std::shared_ptr<DmSoftbusListener> dmSoftbusListener = nullptr; 50 }; 51 52 class SoftbusListenerMock : public DmSoftbusListener { 53 public: 54 MOCK_METHOD(int32_t, ShiftLNNGear, (bool, const std::string &)); 55 MOCK_METHOD(int32_t, GetUdidByNetworkId, (const char *, std::string &)); 56 MOCK_METHOD(int32_t, GetDeviceSecurityLevel, (const char *, int32_t &)); 57 MOCK_METHOD(int32_t, GetDeviceInfo, (const std::string &, DmDeviceInfo &)); 58 MOCK_METHOD(int32_t, GetUuidByNetworkId, (const char *, std::string &)); 59 MOCK_METHOD(int32_t, GetTargetInfoFromCache, (const std::string &, PeerTargetId &, ConnectionAddrType &addrType)); 60 MOCK_METHOD(int32_t, GetTrustedDeviceList, (std::vector<DmDeviceInfo> &)); 61 MOCK_METHOD(int32_t, GetLocalDeviceInfo, (DmDeviceInfo &)); 62 MOCK_METHOD(int32_t, GetDeviceScreenStatus, (const char *, int32_t &)); 63 MOCK_METHOD(int32_t, GetIPAddrTypeFromCache, (const std::string &, const std::string &, ConnectionAddrType &)); 64 MOCK_METHOD(int32_t, GetNetworkTypeByNetworkId, (const char *, int32_t &)); 65 MOCK_METHOD(int32_t, SetLocalDisplayName, (const std::string &)); 66 MOCK_METHOD(int32_t, GetUdidFromDp, (const std::string &, std::string &)); 67 MOCK_METHOD(int32_t, GetAllTrustedDeviceList, (const std::string &, const std::string &, 68 std::vector<DmDeviceInfo> &)); 69 MOCK_METHOD(int32_t, StopRefreshSoftbusLNN, (uint16_t)); 70 MOCK_METHOD(void, SendAclChangedBroadcast, (const std::string &msg)); 71 }; 72 } 73 } 74 #endif 75