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 FILEMANAGEMENT_DFS_SERVICE_DEVICE_MANAGER_AGENT_MOCK_H 17 #define FILEMANAGEMENT_DFS_SERVICE_DEVICE_MANAGER_AGENT_MOCK_H 18 19 #include <gmock/gmock.h> 20 #include "device/device_manager_agent.h" 21 22 namespace OHOS { 23 namespace Storage { 24 namespace DistributedFile { 25 class IDeviceManagerAgentMock { 26 public: 27 IDeviceManagerAgentMock() = default; 28 virtual ~IDeviceManagerAgentMock() = default; 29 virtual int32_t IsSupportedDevice(const DistributedHardware::DmDeviceInfo &deviceInfo) = 0; 30 virtual int32_t OnDeviceP2POnline(const DistributedHardware::DmDeviceInfo &deviceInfo) = 0; 31 virtual int32_t OnDeviceP2POffline(const DistributedHardware::DmDeviceInfo &deviceInfo) = 0; 32 virtual int32_t AddRemoteReverseObj(uint32_t callingTokenId, sptr<IFileDfsListener> remoteReverseObj) = 0; 33 virtual int32_t RemoveRemoteReverseObj(bool clear, uint32_t callingTokenId) = 0; 34 virtual int32_t FindListenerByObject(const wptr<IRemoteObject> &remote, uint32_t &tokenId, 35 sptr<IFileDfsListener> &listener) = 0; 36 virtual std::string GetDeviceIdByNetworkId(const std::string &networkId) = 0; 37 virtual int32_t MountDfsDocs(const std::string &networkId, const std::string &deviceId) = 0; 38 virtual int32_t UMountDfsDocs(const std::string &networkId, const std::string &deviceId, bool needClear) = 0; 39 virtual std::unordered_set<std::string> GetNetworkIds(uint32_t tokenId) = 0; 40 virtual DeviceInfo &GetLocalDeviceInfo() = 0; 41 virtual std::vector<DeviceInfo> GetRemoteDevicesInfo() = 0; 42 virtual sptr<IFileDfsListener> GetDfsListener() = 0; 43 44 public: 45 static inline std::shared_ptr<IDeviceManagerAgentMock> iDeviceManagerAgentMock_ = nullptr; 46 }; 47 48 class DeviceManagerAgentMock : public IDeviceManagerAgentMock { 49 public: 50 MOCK_METHOD1(IsSupportedDevice, int32_t(const DistributedHardware::DmDeviceInfo &deviceInfo)); 51 MOCK_METHOD1(OnDeviceP2POnline, int32_t(const DistributedHardware::DmDeviceInfo &deviceInfo)); 52 MOCK_METHOD1(OnDeviceP2POffline, int32_t(const DistributedHardware::DmDeviceInfo &deviceInfo)); 53 MOCK_METHOD2(AddRemoteReverseObj, int32_t(uint32_t callingTokenId, sptr<IFileDfsListener> remoteReverseObj)); 54 MOCK_METHOD2(RemoveRemoteReverseObj, int32_t(bool clear, uint32_t callingTokenId)); 55 MOCK_METHOD3(FindListenerByObject, int32_t(const wptr<IRemoteObject> &remote, uint32_t &tokenId, 56 sptr<IFileDfsListener>& listener)); 57 MOCK_METHOD1(GetDeviceIdByNetworkId, std::string(const std::string &networkId)); 58 MOCK_METHOD2(MountDfsDocs, int32_t(const std::string &networkId, const std::string &deviceId)); 59 MOCK_METHOD3(UMountDfsDocs, int32_t(const std::string &networkId, const std::string &deviceId, bool needClear)); 60 MOCK_METHOD1(GetNetworkIds, std::unordered_set<std::string>(uint32_t tokenId)); 61 MOCK_METHOD0(GetLocalDeviceInfo, DeviceInfo &()); 62 MOCK_METHOD0(GetRemoteDevicesInfo, std::vector<DeviceInfo>()); 63 MOCK_METHOD0(GetDfsListener, sptr<IFileDfsListener>()); 64 }; 65 } // namespace DistributedFile 66 } // namespace Storage 67 } // namespace OHOS 68 #endif // FILEMANAGEMENT_DFS_SERVICE_DEVICE_MANAGER_AGENT_MOCK_H 69