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_BLE_TRANS_MOCK_H
17 #define CONNECTION_BLE_TRANS_MOCK_H
18 
19 #include <gmock/gmock.h>
20 #include "conn_log.h"
21 #include "softbus_conn_ble_connection.h"
22 
23 namespace OHOS {
24 class ConnectionBleTransInterface {
25 public:
ConnectionBleTransInterface()26     ConnectionBleTransInterface(){};
~ConnectionBleTransInterface()27     virtual ~ConnectionBleTransInterface(){};
28 
29     virtual ConnBleConnection *ConnBleGetConnectionById(uint32_t connectionId) = 0;
30     virtual int32_t ConnBleSend(
31         ConnBleConnection *connection, const uint8_t *data, uint32_t dataLen, int32_t module) = 0;
32     virtual bool AddNumberToJsonObject(cJSON *json, const char *const string, int32_t num) = 0;
33     virtual cJSON *cJSON_CreateObject() = 0;
34     virtual bool AddNumber16ToJsonObject(cJSON *json, const char *const string, uint16_t num) = 0;
35     virtual char *cJSON_PrintUnformatted(const cJSON *json) = 0;
36 };
37 
38 class ConnectionBleTransInterfaceMock : public ConnectionBleTransInterface {
39 public:
40     ConnectionBleTransInterfaceMock();
41     ~ConnectionBleTransInterfaceMock() override;
42 
43     MOCK_METHOD(ConnBleConnection *, ConnBleGetConnectionById, (uint32_t), (override));
44     MOCK_METHOD(int32_t, ConnBleSend, (ConnBleConnection *, const uint8_t *, uint32_t, int32_t), (override));
45     MOCK_METHOD(bool, AddNumberToJsonObject, (cJSON *, const char *const, int32_t), (override));
46     MOCK_METHOD(cJSON *, cJSON_CreateObject, (), (override));
47     MOCK_METHOD(bool, AddNumber16ToJsonObject, (cJSON *, const char *const, uint16_t), (override));
48     MOCK_METHOD(char *, cJSON_PrintUnformatted, (const cJSON *), (override));
49 };
50 } // namespace OHOS
51 #endif // CONNECTION_BLE_TRANS_MOCK_H