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 "wifi_mock.h"
17 #include "softbus_error_code.h"
18
19 using namespace testing;
20 using namespace testing::ext;
21
22 namespace OHOS {
23 void *g_wifiInterface;
24
WifiInterfaceMock()25 WifiInterfaceMock::WifiInterfaceMock()
26 {
27 g_wifiInterface = reinterpret_cast<void *>(this);
28 }
29
~WifiInterfaceMock()30 WifiInterfaceMock::~WifiInterfaceMock()
31 {
32 g_wifiInterface = nullptr;
33 }
34
GetWifiInterface()35 static WifiInterface *GetWifiInterface()
36 {
37 return reinterpret_cast<WifiInterfaceMock *>(g_wifiInterface);
38 }
39
40 extern "C" {
GetDeviceConfigs(WifiDeviceConfig * result,unsigned int * size)41 WifiErrorCode GetDeviceConfigs(WifiDeviceConfig *result, unsigned int *size)
42 {
43 return GetWifiInterface()->GetDeviceConfigs(result, size);
44 }
45
ConnectToDevice(const WifiDeviceConfig * config)46 WifiErrorCode ConnectToDevice(const WifiDeviceConfig *config)
47 {
48 return GetWifiInterface()->ConnectToDevice(config);
49 }
50
Scan(void)51 WifiErrorCode Scan(void)
52 {
53 return GetWifiInterface()->Scan();
54 }
55
RegisterWifiEvent(WifiEvent * event)56 WifiErrorCode RegisterWifiEvent(WifiEvent *event)
57 {
58 return GetWifiInterface()->RegisterWifiEvent(event);
59 }
60
GetScanInfoList(WifiScanInfo * result,unsigned int * size)61 WifiErrorCode GetScanInfoList(WifiScanInfo *result, unsigned int *size)
62 {
63 return GetWifiInterface()->GetScanInfoList(result, size);
64 }
65
UnRegisterWifiEvent(WifiEvent * event)66 WifiErrorCode UnRegisterWifiEvent(WifiEvent *event)
67 {
68 return GetWifiInterface()->UnRegisterWifiEvent(event);
69 }
70
Hid2dGetChannelListFor5G(int * chanList,int len)71 WifiErrorCode Hid2dGetChannelListFor5G(int *chanList, int len)
72 {
73 return GetWifiInterface()->Hid2dGetChannelListFor5G(chanList, len);
74 }
75
GetLinkedInfo(WifiLinkedInfo * info)76 WifiErrorCode GetLinkedInfo(WifiLinkedInfo *info)
77 {
78 return GetWifiInterface()->GetLinkedInfo(info);
79 }
80
GetCurrentGroup(WifiP2pGroupInfo * groupInfo)81 WifiErrorCode GetCurrentGroup(WifiP2pGroupInfo* groupInfo)
82 {
83 return GetWifiInterface()->GetCurrentGroup(groupInfo);
84 }
85
IsWifiActive(void)86 int IsWifiActive(void)
87 {
88 return GetWifiInterface()->IsWifiActive();
89 }
90
GetWifiDetailState(WifiDetailState * state)91 WifiErrorCode GetWifiDetailState(WifiDetailState *state)
92 {
93 return GetWifiInterface()->GetWifiDetailState(state);
94 }
95
GetP2pEnableStatus(P2pState * state)96 WifiErrorCode GetP2pEnableStatus(P2pState *state)
97 {
98 return GetWifiInterface()->GetP2pEnableStatus(state);
99 }
100 }
101 } // namespace OHOS