1 /* 2 * Copyright (c) 2023 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 "cJSON.h" 21 22 #include "softbus_adapter_thread.h" 23 #include "softbus_config_type.h" 24 #include "softbus_def.h" 25 #include "softbus_adapter_bt_common.h" 26 27 namespace OHOS { 28 class ConnectionBrInterface { 29 public: ConnectionBrInterface()30 ConnectionBrInterface() {}; ~ConnectionBrInterface()31 virtual ~ConnectionBrInterface() {}; 32 virtual bool GetJsonObjectSignedNumberItem(const cJSON *json, const char * const string, int *target) = 0; 33 virtual bool GetJsonObjectNumber64Item(const cJSON *json, const char * const string, int64_t *target) = 0; 34 virtual bool AddNumberToJsonObject(cJSON *json, const char * const string, int num) = 0; 35 virtual bool AddNumber64ToJsonObject(cJSON *json, const char * const string, int64_t num) = 0; 36 virtual cJSON *cJSON_ParseWithLength(const char *value, size_t buffer_length) = 0; 37 virtual bool GetJsonObjectNumberItem(const cJSON *json, const char * const string, int *target) = 0; 38 virtual int SoftBusGetBtMacAddr(SoftBusBtAddr *mac) = 0; 39 }; 40 41 class ConnectionBrInterfaceMock : public ConnectionBrInterface { 42 public: 43 ConnectionBrInterfaceMock(); 44 ~ConnectionBrInterfaceMock() override; 45 MOCK_METHOD3(GetJsonObjectSignedNumberItem, bool (const cJSON *, const char * const, int *)); 46 MOCK_METHOD3(GetJsonObjectNumber64Item, bool (const cJSON *, const char * const, int64_t *)); 47 MOCK_METHOD3(AddNumberToJsonObject, bool (cJSON *, const char * const, int)); 48 MOCK_METHOD3(AddNumber64ToJsonObject, bool (cJSON *, const char * const, int64_t)); 49 MOCK_METHOD2(cJSON_ParseWithLength, cJSON* (const char *, size_t)); 50 MOCK_METHOD3(GetJsonObjectNumberItem, bool (const cJSON *, const char * const, int *)); 51 MOCK_METHOD1(SoftBusGetBtMacAddr, int (SoftBusBtAddr *)); 52 }; 53 } // namespace OHOS 54 #endif // CONNECTION_BR_MOCK_H 55