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 CONNECTION_BR_MOCK_H 17 #define CONNECTION_BR_MOCK_H 18 19 #include <gmock/gmock.h> 20 #include <mutex> 21 #include "cJSON.h" 22 23 #include "conn_log.h" 24 #include "disc_interface.h" 25 #include "message_handler.h" 26 #include "softbus_adapter_bt_common.h" 27 #include "softbus_common.h" 28 #include "softbus_config_type.h" 29 #include "softbus_conn_ble_connection.h" 30 #include "ohos_bt_def.h" 31 32 33 namespace OHOS { 34 class ConnectionBleInterface { 35 public: ConnectionBleInterface()36 ConnectionBleInterface() {}; ~ConnectionBleInterface()37 virtual ~ConnectionBleInterface() {}; 38 virtual bool AddNumberToJsonObject(cJSON *json, const char * const string, int num) = 0; 39 virtual int32_t ConvertBtMacToBinary(const char *strMac, uint32_t strMacLen, uint8_t *binMac, 40 uint32_t binMacLen) = 0; 41 virtual int32_t SoftbusGattcConnect(int32_t clientId, SoftBusBtAddr *addr) = 0; 42 virtual int BleGattcDisconnect(int clientId) = 0; 43 virtual int SoftBusGattsAddService(SoftBusBtUuid srvcUuid, bool isPrimary, int number) = 0; 44 virtual int SoftBusGattsStopService(int srvcHandle) = 0; 45 virtual int SoftBusGattsDisconnect(SoftBusBtAddr btAddr, int connId) = 0; 46 virtual int32_t SoftbusGattcRefreshServices(int32_t clientId) = 0; 47 virtual int32_t SoftbusGattcSearchServices(int32_t clientId) = 0; 48 virtual bool GetJsonObjectSignedNumberItem(const cJSON *json, const char * const string, int *target) = 0; 49 virtual int BleGattsAddService(int serverId, BtUuid srvcUuid, bool isPrimary, int number) = 0; 50 virtual int BleGattcUnRegister(int clientId) = 0; 51 }; 52 53 class ConnectionBleInterfaceMock : public ConnectionBleInterface { 54 public: 55 ConnectionBleInterfaceMock(); 56 ~ConnectionBleInterfaceMock() override; 57 MOCK_METHOD3(AddNumberToJsonObject, bool (cJSON *, const char * const, int)); 58 MOCK_METHOD4(ConvertBtMacToBinary, int32_t (const char *, uint32_t, uint8_t *, uint32_t)); 59 MOCK_METHOD2(SoftbusGattcConnect, int32_t (int32_t, SoftBusBtAddr *)); 60 MOCK_METHOD1(BleGattcDisconnect, int (int)); 61 MOCK_METHOD3(SoftBusGattsAddService, int (SoftBusBtUuid, bool, int)); 62 MOCK_METHOD1(SoftBusGattsStopService, int (int)); 63 MOCK_METHOD2(SoftBusGattsDisconnect, int (SoftBusBtAddr, int)); 64 MOCK_METHOD1(SoftbusGattcRefreshServices, int32_t (int32_t)); 65 MOCK_METHOD1(SoftbusGattcSearchServices, int32_t (int32_t)); 66 MOCK_METHOD3(GetJsonObjectSignedNumberItem, bool (const cJSON *, const char * const, int *)); 67 MOCK_METHOD(int, BleGattsAddService, (int, BtUuid, bool, int), (override)); 68 MOCK_METHOD(int, BleGattcUnRegister, (int), (override)); 69 }; 70 } // namespace OHOS 71 #endif // CONNECTION_BLE_MOCK_H