1 /*
2 * Copyright (c) 2025 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 "auth_connection_mock.h"
17
18 namespace OHOS {
19 using namespace testing;
20 using namespace testing::ext;
21 void *g_connInterface;
AuthConnectionInterfaceMock()22 AuthConnectionInterfaceMock::AuthConnectionInterfaceMock()
23 {
24 g_connInterface = reinterpret_cast<void *>(this);
25 }
26
~AuthConnectionInterfaceMock()27 AuthConnectionInterfaceMock::~AuthConnectionInterfaceMock()
28 {
29 g_connInterface = nullptr;
30 }
31
GetCommonInterface()32 static AuthConnectionInterfaceMock *GetCommonInterface()
33 {
34 return reinterpret_cast<AuthConnectionInterfaceMock *>(g_connInterface);
35 }
36
37 extern "C" {
SoftBusGetBtState(void)38 int32_t SoftBusGetBtState(void)
39 {
40 return GetCommonInterface()->SoftBusGetBtState();
41 }
42
PostAuthEvent(EventType event,EventHandler handler,const void * obj,uint32_t size,uint64_t delayMs)43 int32_t PostAuthEvent(EventType event, EventHandler handler, const void *obj, uint32_t size, uint64_t delayMs)
44 {
45 return GetCommonInterface()->PostAuthEvent(event, handler, obj, size, delayMs);
46 }
47
IsHaveAuthIdByConnId(uint64_t connId)48 bool IsHaveAuthIdByConnId(uint64_t connId)
49 {
50 return GetCommonInterface()->IsHaveAuthIdByConnId(connId);
51 }
52
FindAuthPreLinkNodeById(uint32_t requestId,AuthPreLinkNode * reuseNode)53 int32_t FindAuthPreLinkNodeById(uint32_t requestId, AuthPreLinkNode *reuseNode)
54 {
55 return GetCommonInterface()->FindAuthPreLinkNodeById(requestId, reuseNode);
56 }
57
SocketSetDevice(int32_t fd,bool isBlockMode)58 int32_t SocketSetDevice(int32_t fd, bool isBlockMode)
59 {
60 return GetCommonInterface()->SocketSetDevice(fd, isBlockMode);
61 }
62
DelAuthPreLinkById(uint32_t requestId)63 void DelAuthPreLinkById(uint32_t requestId)
64 {
65 return GetCommonInterface()->DelAuthPreLinkById(requestId);
66 }
67
SocketPostBytes(int32_t fd,const AuthDataHead * head,const uint8_t * data)68 int32_t SocketPostBytes(int32_t fd, const AuthDataHead *head, const uint8_t *data)
69 {
70 return GetCommonInterface()->SocketPostBytes(fd, head, data);
71 }
72
StartSocketListening(ListenerModule module,const LocalListenerInfo * info)73 int32_t StartSocketListening(ListenerModule module, const LocalListenerInfo *info)
74 {
75 return GetCommonInterface()->StartSocketListening(module, info);
76 }
77 }
78 }
79