• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 using namespace testing;
19 using namespace testing::ext;
20 
21 namespace OHOS {
22 void *g_connInterface;
AuthConnectInterfaceMock()23 AuthConnectInterfaceMock::AuthConnectInterfaceMock()
24 {
25     g_connInterface = reinterpret_cast<void *>(this);
26 }
27 
~AuthConnectInterfaceMock()28 AuthConnectInterfaceMock::~AuthConnectInterfaceMock()
29 {
30     g_connInterface = nullptr;
31 }
32 
GetConnInterface()33 static AuthConnectInterface *GetConnInterface()
34 {
35     return reinterpret_cast<AuthConnectInterfaceMock *>(g_connInterface);
36 }
37 
38 extern "C" {
ConnGetConnectionInfo(uint32_t connectionId,ConnectionInfo * info)39 int32_t ConnGetConnectionInfo(uint32_t connectionId, ConnectionInfo *info)
40 {
41     return GetConnInterface()->ConnGetConnectionInfo(connectionId, info);
42 }
43 
ConnSetConnectCallback(ConnModule moduleId,const ConnectCallback * callback)44 int32_t ConnSetConnectCallback(ConnModule moduleId, const ConnectCallback *callback)
45 {
46     return GetConnInterface()->ConnSetConnectCallback(moduleId, callback);
47 }
48 
ConnUnSetConnectCallback(ConnModule moduleId)49 void ConnUnSetConnectCallback(ConnModule moduleId)
50 {
51     GetConnInterface()->ConnUnSetConnectCallback(moduleId);
52 }
53 
ConnConnectDevice(const ConnectOption * option,uint32_t requestId,const ConnectResult * result)54 int32_t ConnConnectDevice(const ConnectOption *option, uint32_t requestId, const ConnectResult *result)
55 {
56     return GetConnInterface()->ConnConnectDevice(option, requestId, result);
57 }
58 
ConnDisconnectDevice(uint32_t connectionId)59 int32_t ConnDisconnectDevice(uint32_t connectionId)
60 {
61     return GetConnInterface()->ConnDisconnectDevice(connectionId);
62 }
63 
ConnGetHeadSize(void)64 uint32_t ConnGetHeadSize(void)
65 {
66     return GetConnInterface()->ConnGetHeadSize();
67 }
68 
ConnPostBytes(uint32_t connectionId,ConnPostData * data)69 int32_t ConnPostBytes(uint32_t connectionId, ConnPostData *data)
70 {
71     return GetConnInterface()->ConnPostBytes(connectionId, data);
72 }
73 
CheckActiveConnection(const ConnectOption * option)74 bool CheckActiveConnection(const ConnectOption *option)
75 {
76     return GetConnInterface()->CheckActiveConnection(option);
77 }
78 
ConnStartLocalListening(const LocalListenerInfo * info)79 int32_t ConnStartLocalListening(const LocalListenerInfo *info)
80 {
81     return GetConnInterface()->ConnStartLocalListening(info);
82 }
83 
ConnStopLocalListening(const LocalListenerInfo * info)84 int32_t ConnStopLocalListening(const LocalListenerInfo *info)
85 {
86     return GetConnInterface()->ConnStopLocalListening(info);
87 }
88 
ConnGetNewRequestId(ConnModule moduleId)89 uint32_t ConnGetNewRequestId(ConnModule moduleId)
90 {
91     return GetConnInterface()->ConnGetNewRequestId(moduleId);
92 }
93 
ConnUpdateConnection(uint32_t connectionId,UpdateOption * option)94 int32_t ConnUpdateConnection(uint32_t connectionId, UpdateOption *option)
95 {
96     return GetConnInterface()->ConnUpdateConnection(connectionId, option);
97 }
98 
99 }
100 }