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 #ifndef DISTRIBUTE_NET_LEDGER_MOCK_H
17 #define DISTRIBUTE_NET_LEDGER_MOCK_H
18 
19 #include "kits/c/wifi_device.h"
20 #include "kits/c/wifi_error_code.h"
21 #include "kits/c/wifi_hid2d.h"
22 #include "kits/c/wifi_p2p.h"
23 #include "kits/c/wifi_scan_info.h"
24 #include <gmock/gmock.h>
25 #include <mutex>
26 
27 namespace OHOS {
28 class WifiInterface {
29 public:
WifiInterface()30     WifiInterface() {};
~WifiInterface()31     virtual ~WifiInterface() {};
32 
33     virtual WifiErrorCode GetDeviceConfigs(WifiDeviceConfig *result, unsigned int *size) = 0;
34     virtual WifiErrorCode ConnectToDevice(const WifiDeviceConfig *config) = 0;
35     virtual WifiErrorCode Scan(void) = 0;
36     virtual WifiErrorCode RegisterWifiEvent(WifiEvent *event) = 0;
37     virtual WifiErrorCode GetScanInfoList(WifiScanInfo *result, unsigned int *size) = 0;
38     virtual WifiErrorCode UnRegisterWifiEvent(WifiEvent *event) = 0;
39     virtual WifiErrorCode Hid2dGetChannelListFor5G(int *chanList, int len) = 0;
40     virtual WifiErrorCode GetLinkedInfo(WifiLinkedInfo *info) = 0;
41     virtual WifiErrorCode GetCurrentGroup(WifiP2pGroupInfo* groupInfo) = 0;
42     virtual int IsWifiActive(void) = 0;
43     virtual WifiErrorCode GetWifiDetailState(WifiDetailState *state) = 0;
44     virtual WifiErrorCode GetP2pEnableStatus(P2pState *state) = 0;
45 };
46 class WifiInterfaceMock : public WifiInterface {
47 public:
48     WifiInterfaceMock();
49     ~WifiInterfaceMock() override;
50 
51     MOCK_METHOD2(GetDeviceConfigs, WifiErrorCode(WifiDeviceConfig *, unsigned int *));
52     MOCK_METHOD1(ConnectToDevice, WifiErrorCode(const WifiDeviceConfig *));
53     MOCK_METHOD0(Scan, WifiErrorCode(void));
54     MOCK_METHOD1(RegisterWifiEvent, WifiErrorCode(WifiEvent *));
55     MOCK_METHOD2(GetScanInfoList, WifiErrorCode(WifiScanInfo *, unsigned int *));
56     MOCK_METHOD1(UnRegisterWifiEvent, WifiErrorCode(WifiEvent *));
57     MOCK_METHOD2(Hid2dGetChannelListFor5G, WifiErrorCode(int *, int));
58     MOCK_METHOD1(GetLinkedInfo, WifiErrorCode(WifiLinkedInfo *));
59     MOCK_METHOD1(GetCurrentGroup, WifiErrorCode(WifiP2pGroupInfo*));
60     MOCK_METHOD0(IsWifiActive, int(void));
61     MOCK_METHOD1(GetWifiDetailState, WifiErrorCode(WifiDetailState *));
62     MOCK_METHOD1(GetP2pEnableStatus, WifiErrorCode(P2pState *));
63 };
64 } // namespace OHOS
65 #endif // AUTH_CONNECTION_MOCK_H