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 #include "connection_br_mock.h"
17
18 using namespace testing;
19 using namespace testing::ext;
20
21 namespace OHOS {
22 void *g_connectionBrInterface;
ConnectionBrInterfaceMock()23 ConnectionBrInterfaceMock::ConnectionBrInterfaceMock()
24 {
25 g_connectionBrInterface = reinterpret_cast<void *>(this);
26 }
27
~ConnectionBrInterfaceMock()28 ConnectionBrInterfaceMock::~ConnectionBrInterfaceMock()
29 {
30 g_connectionBrInterface = nullptr;
31 }
32
GetConnectionBrInterface()33 static ConnectionBrInterface *GetConnectionBrInterface()
34 {
35 return reinterpret_cast<ConnectionBrInterface *>(g_connectionBrInterface);
36 }
37
38 extern "C" {
GetJsonObjectSignedNumberItem(const cJSON * json,const char * const string,int * target)39 bool GetJsonObjectSignedNumberItem(const cJSON *json, const char * const string, int *target)
40 {
41 return GetConnectionBrInterface()->GetJsonObjectSignedNumberItem(json, string, target);
42 }
43
GetJsonObjectNumber64Item(const cJSON * json,const char * const string,int64_t * target)44 bool GetJsonObjectNumber64Item(const cJSON *json, const char * const string, int64_t *target)
45 {
46 return GetConnectionBrInterface()->GetJsonObjectNumber64Item(json, string, target);
47 }
48
AddNumberToJsonObject(cJSON * json,const char * const string,int num)49 bool AddNumberToJsonObject(cJSON *json, const char * const string, int num)
50 {
51 return GetConnectionBrInterface()->AddNumberToJsonObject(json, string, num);
52 }
53
AddNumber64ToJsonObject(cJSON * json,const char * const string,int64_t num)54 bool AddNumber64ToJsonObject(cJSON *json, const char * const string, int64_t num)
55 {
56 return GetConnectionBrInterface()->AddNumber64ToJsonObject(json, string, num);
57 }
58
cJSON_ParseWithLength(const char * value,size_t buffer_length)59 cJSON *cJSON_ParseWithLength(const char *value, size_t buffer_length)
60 {
61 return GetConnectionBrInterface()->cJSON_ParseWithLength(value, buffer_length);
62 }
63
GetJsonObjectNumberItem(const cJSON * json,const char * const string,int * target)64 bool GetJsonObjectNumberItem(const cJSON *json, const char * const string, int *target)
65 {
66 return GetConnectionBrInterface()->GetJsonObjectNumberItem(json, string, target);
67 }
68
SoftBusGetBtMacAddr(SoftBusBtAddr * mac)69 int SoftBusGetBtMacAddr(SoftBusBtAddr *mac)
70 {
71 return GetConnectionBrInterface()->SoftBusGetBtMacAddr(mac);
72 }
73 }
74 }
75