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_SOFTBUS_HANDLER_ASSET_MOCK_H 17 #define FILEMANAGEMENT_DFS_SERVICE_SOFTBUS_HANDLER_ASSET_MOCK_H 18 19 #include <gmock/gmock.h> 20 #include "network/softbus/softbus_handler_asset.h" 21 22 namespace OHOS { 23 namespace Storage { 24 namespace DistributedFile { 25 class ISoftBusHandlerAssetMock { 26 public: 27 ISoftBusHandlerAssetMock() = default; 28 virtual ~ISoftBusHandlerAssetMock() = default; 29 30 virtual int32_t AssetBind(const std::string &dstNetworkId, int32_t &socketId) = 0; 31 virtual int32_t AssetSendFile(int32_t socketId, const std::string &sendFile, bool isSingleFile) = 0; 32 virtual std::string GetClientInfo(int32_t socketId) = 0; 33 virtual sptr<AssetObj> GetAssetObj(int32_t socketId) = 0; 34 virtual int32_t GenerateAssetObjInfo(int32_t socketId, 35 const std::string &fileName, 36 const sptr<AssetObj> &assetObj) = 0; 37 virtual std::vector<std::string> GenerateUris(const std::vector<std::string> &fileList, 38 const std::string &dstBundleName, 39 bool isSingleFile) = 0; 40 virtual int32_t CompressFile(const std::vector<std::string> &fileList, 41 const std::string &relativePath, 42 const std::string &zipFileName) = 0; 43 virtual std::vector<std::string> DecompressFile(const std::string &unZipFileName, 44 const std::string &relativePath) = 0; 45 virtual bool MkDirRecurse(const std::string &path, mode_t mode) = 0; 46 47 public: 48 static inline std::shared_ptr<ISoftBusHandlerAssetMock> iSoftBusHandlerAssetMock_ = nullptr; 49 }; 50 51 class SoftBusHandlerAssetMock : public ISoftBusHandlerAssetMock { 52 public: 53 MOCK_METHOD2(AssetBind, int32_t(const std::string &dstNetworkId, int32_t &socketId)); 54 MOCK_METHOD3(AssetSendFile, int32_t(int32_t socketId, const std::string& sendFile, bool isSingleFile)); 55 MOCK_METHOD1(GetClientInfo, std::string(int32_t socketId)); 56 MOCK_METHOD1(GetAssetObj, sptr<AssetObj>(int32_t socketId)); 57 MOCK_METHOD3(GenerateAssetObjInfo, int32_t(int32_t socketId, 58 const std::string &fileName, 59 const sptr<AssetObj> &assetObj)); 60 MOCK_METHOD3(GenerateUris, std::vector<std::string>(const std::vector<std::string> &fileList, 61 const std::string &dstBundleName, 62 bool isSingleFile)); 63 MOCK_METHOD3(CompressFile, int32_t(const std::vector<std::string> &fileList, 64 const std::string &relativePath, 65 const std::string &zipFileName)); 66 MOCK_METHOD2(DecompressFile, std::vector<std::string>(const std::string &unZipFileName, 67 const std::string &relativePath)); 68 MOCK_METHOD2(MkDirRecurse, bool(const std::string& path, mode_t mode)); 69 }; 70 } // namespace DistributedFile 71 } // namespace Storage 72 } // namespace OHOS 73 #endif // FILEMANAGEMENT_DFS_SERVICE_SOFTBUS_HANDLER_ASSET_MOCK_H 74