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 BUS_CENTER_UTILS_MOCK_H 17 #define BUS_CENTER_UTILS_MOCK_H 18 19 #include <gmock/gmock.h> 20 21 #include "lnn_file_utils.h" 22 #include "softbus_adapter_file.h" 23 #include "softbus_adapter_crypto.h" 24 25 namespace OHOS { 26 class BusCenterUtilsInterface { 27 public: BusCenterUtilsInterface()28 BusCenterUtilsInterface() {}; ~BusCenterUtilsInterface()29 virtual ~BusCenterUtilsInterface() {}; 30 31 virtual int32_t LnnGetFullStoragePath(LnnFileId id, char *path, uint32_t len) = 0; 32 virtual int32_t SoftBusReadFullFile(const char *fileName, char *readBuf, uint32_t maxLen) = 0; 33 virtual int32_t GenerateRandomStr(char *str, uint32_t size) = 0; 34 virtual int32_t SoftBusWriteFile(const char *fileName, const char *writeBuf, uint32_t len) = 0; 35 virtual int32_t SoftBusGenerateRandomArray(unsigned char *randStr, uint32_t len) = 0; 36 virtual int32_t SoftBusDecryptData(AesGcmCipherKey *key, const unsigned char *input, uint32_t inLen, 37 unsigned char *decryptData, uint32_t *decryptLen) = 0; 38 }; 39 class BusCenterUtilsInterfaceMock : public BusCenterUtilsInterface { 40 public: 41 BusCenterUtilsInterfaceMock(); 42 ~BusCenterUtilsInterfaceMock() override; 43 44 MOCK_METHOD3(LnnGetFullStoragePath, int32_t (LnnFileId, char *, uint32_t)); 45 MOCK_METHOD3(SoftBusReadFullFile, int32_t (const char *, char *, uint32_t)); 46 MOCK_METHOD2(GenerateRandomStr, int32_t (char *, uint32_t)); 47 MOCK_METHOD3(SoftBusWriteFile, int32_t (const char *, const char *, uint32_t)); 48 MOCK_METHOD2(SoftBusGenerateRandomArray, int32_t (unsigned char*, uint32_t)); 49 MOCK_METHOD5( 50 SoftBusDecryptData, int32_t (AesGcmCipherKey *, const unsigned char *, uint32_t, unsigned char *, uint32_t *)); 51 }; 52 } // namespace OHOS 53 #endif // BUS_CENTER_UTILS_MOCK_H