1 /* 2 * Copyright (c) 2024-2025 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 LNN_SYNC_INFO_MANAGER_MOCK_H 17 #define LNN_SYNC_INFO_MANAGER_MOCK_H 18 19 #include <gmock/gmock.h> 20 21 #include "auth_manager.h" 22 #include "lnn_distributed_net_ledger.h" 23 #include "softbus_adapter_json.h" 24 25 namespace OHOS { 26 class LnnSyncInfoManagerInterface { 27 public: 28 virtual JsonObj *JSON_CreateObject() = 0; 29 virtual bool JSON_AddInt64ToObject(JsonObj *obj, const char *key, int64_t value) = 0; 30 virtual bool JSON_AddInt32ToObject(JsonObj *obj, const char *key, int32_t value) = 0; 31 virtual void JSON_Delete(JsonObj *obj) = 0; 32 virtual char *JSON_PrintUnformatted(const JsonObj *obj) = 0; 33 virtual JsonObj *JSON_Parse(const char *str, uint32_t len) = 0; 34 virtual bool JSON_GetInt64FromOject(const JsonObj *obj, const char *key, int64_t *value) = 0; 35 virtual int32_t ConvertBytesToHexString( 36 char *outBuf, uint32_t outBufLen, const unsigned char *inBuf, uint32_t inLen); 37 virtual bool JSON_GetInt32FromOject(const JsonObj *obj, const char *key, int32_t *value) = 0; 38 virtual bool JSON_GetStringFromObject(const JsonObj *obj, const char *key, char *value, uint32_t size) = 0; 39 virtual AuthManager *GetAuthManagerByAuthId(int64_t authId) = 0; 40 virtual void DelAuthManager(AuthManager *auth, int32_t type) = 0; 41 virtual int32_t LnnGetNetworkIdByUdid(const char *udid, char *buf, uint32_t len); 42 virtual int32_t AuthPostTransData(AuthHandle authHandle, const AuthTransData *dataInfo) = 0; 43 virtual int32_t GetHmlOrP2pAuthHandle(AuthHandle **authHandle, int32_t *num) = 0; 44 virtual bool JSON_AddStringToObject(JsonObj *obj, const char *key, const char *value) = 0; 45 virtual void DelDupAuthManager(AuthManager *auth); 46 }; 47 48 class LnnSyncInfoManagerInterfaceMock : public LnnSyncInfoManagerInterface { 49 public: 50 LnnSyncInfoManagerInterfaceMock(); 51 ~LnnSyncInfoManagerInterfaceMock(); 52 MOCK_METHOD0(JSON_CreateObject, JsonObj *()); 53 MOCK_METHOD3(JSON_AddInt64ToObject, bool(JsonObj *obj, const char *key, int64_t value)); 54 MOCK_METHOD3(JSON_AddInt32ToObject, bool(JsonObj *obj, const char *key, int32_t value)); 55 MOCK_METHOD1(JSON_Delete, void(JsonObj *obj)); 56 MOCK_METHOD1(JSON_PrintUnformatted, char *(const JsonObj *obj)); 57 MOCK_METHOD2(JSON_Parse, JsonObj *(const char *str, uint32_t len)); 58 MOCK_METHOD3(JSON_GetInt64FromOject, bool(const JsonObj *obj, const char *key, int64_t *value)); 59 MOCK_METHOD4( 60 ConvertBytesToHexString, int32_t(char *outBuf, uint32_t outBufLen, const unsigned char *inBuf, uint32_t inLen)); 61 MOCK_METHOD3(JSON_GetInt32FromOject, bool(const JsonObj *obj, const char *key, int32_t *value)); 62 MOCK_METHOD4(JSON_GetStringFromObject, bool(const JsonObj *obj, const char *key, char *value, uint32_t size)); 63 MOCK_METHOD1(GetAuthManagerByAuthId, AuthManager *(int64_t authId)); 64 MOCK_METHOD2(DelAuthManager, void(AuthManager *auth, int32_t type)); 65 MOCK_METHOD3(LnnGetNetworkIdByUdid, int32_t(const char *, char *, uint32_t)); 66 MOCK_METHOD2(AuthPostTransData, int32_t(AuthHandle authHandle, const AuthTransData *dataInfo)); 67 MOCK_METHOD2(GetHmlOrP2pAuthHandle, int32_t(AuthHandle **authHandle, int32_t *num)); 68 MOCK_METHOD3(JSON_AddStringToObject, bool(JsonObj *obj, const char *key, const char *value)); 69 MOCK_METHOD1(DelDupAuthManager, void(AuthManager *auth)); 70 }; 71 } // namespace OHOS 72 73 #endif