1094332d3Sopenharmony_ci/*
2094332d3Sopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd.
3094332d3Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4094332d3Sopenharmony_ci * you may not use this file except in compliance with the License.
5094332d3Sopenharmony_ci * You may obtain a copy of the License at
6094332d3Sopenharmony_ci *
7094332d3Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8094332d3Sopenharmony_ci *
9094332d3Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10094332d3Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11094332d3Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12094332d3Sopenharmony_ci * See the License for the specific language governing permissions and
13094332d3Sopenharmony_ci * limitations under the License.
14094332d3Sopenharmony_ci */
15094332d3Sopenharmony_ci#include <gtest/gtest.h>
16094332d3Sopenharmony_ci#include <servmgr_hdi.h>
17094332d3Sopenharmony_ci#include "v1_3/iwlan_interface.h"
18094332d3Sopenharmony_ci#include "wlan_callback_impl.h"
19094332d3Sopenharmony_ci#include "securec.h"
20094332d3Sopenharmony_ci#include "wlan_hdi_types.h"
21094332d3Sopenharmony_ci
22094332d3Sopenharmony_ci#define HDF_LOG_TAG service_manager_test
23094332d3Sopenharmony_ciusing namespace testing::ext;
24094332d3Sopenharmony_ci
25094332d3Sopenharmony_cinamespace HdiDirectTest {
26094332d3Sopenharmony_ciconst int32_t DEFAULT_COMBO_SIZE = 6;
27094332d3Sopenharmony_ciconst int32_t WLAN_MAX_NUM_STA_WITH_AP = 4;
28094332d3Sopenharmony_ciconst int32_t WLAN_FREQ_MAX_NUM = 35;
29094332d3Sopenharmony_ciconst int32_t WLAN_TX_POWER = 160;
30094332d3Sopenharmony_ciconst char *WLAN_SERVICE_NAME = "wlan_interface_service";
31094332d3Sopenharmony_ci
32094332d3Sopenharmony_ciclass HdfWifiDirectTest : public testing::Test {
33094332d3Sopenharmony_cipublic:
34094332d3Sopenharmony_ci    static void SetUpTestCase();
35094332d3Sopenharmony_ci    static void TearDownTestCase();
36094332d3Sopenharmony_ci    void SetUp();
37094332d3Sopenharmony_ci    void TearDown();
38094332d3Sopenharmony_ci};
39094332d3Sopenharmony_ci
40094332d3Sopenharmony_cistatic struct IWlanInterface *g_wlanObj = nullptr;
41094332d3Sopenharmony_cistruct IWlanCallback *g_wlanCallbackObj = nullptr;
42094332d3Sopenharmony_civoid HdfWifiDirectTest::SetUpTestCase()
43094332d3Sopenharmony_ci{
44094332d3Sopenharmony_ci    g_wlanObj = IWlanInterfaceGetInstance(WLAN_SERVICE_NAME, true);
45094332d3Sopenharmony_ci    g_wlanCallbackObj = WlanCallbackServiceGet();
46094332d3Sopenharmony_ci    ASSERT_TRUE(g_wlanObj != nullptr);
47094332d3Sopenharmony_ci    ASSERT_TRUE(g_wlanCallbackObj != nullptr);
48094332d3Sopenharmony_ci}
49094332d3Sopenharmony_ci
50094332d3Sopenharmony_civoid HdfWifiDirectTest::TearDownTestCase()
51094332d3Sopenharmony_ci{
52094332d3Sopenharmony_ci    IWlanInterfaceReleaseInstance(WLAN_SERVICE_NAME, g_wlanObj, true);
53094332d3Sopenharmony_ci    WlanCallbackServiceRelease(g_wlanCallbackObj);
54094332d3Sopenharmony_ci}
55094332d3Sopenharmony_ci
56094332d3Sopenharmony_civoid HdfWifiDirectTest::SetUp()
57094332d3Sopenharmony_ci{
58094332d3Sopenharmony_ci}
59094332d3Sopenharmony_ci
60094332d3Sopenharmony_civoid HdfWifiDirectTest::TearDown()
61094332d3Sopenharmony_ci{
62094332d3Sopenharmony_ci}
63094332d3Sopenharmony_ci
64094332d3Sopenharmony_ci/**
65094332d3Sopenharmony_ci * @tc.name: GetSupportFeatureTest_001
66094332d3Sopenharmony_ci * @tc.desc: Wifi hdi get support feature function test
67094332d3Sopenharmony_ci * @tc.type: FUNC
68094332d3Sopenharmony_ci * @tc.require:
69094332d3Sopenharmony_ci */
70094332d3Sopenharmony_ciHWTEST_F(HdfWifiDirectTest, GetSupportFeatureTest_001, TestSize.Level1)
71094332d3Sopenharmony_ci{
72094332d3Sopenharmony_ci    uint8_t supType[PROTOCOL_80211_IFTYPE_NUM + 1] = {0};
73094332d3Sopenharmony_ci    uint32_t supTypeLenInvalid = 6;
74094332d3Sopenharmony_ci
75094332d3Sopenharmony_ci    int32_t rc = g_wlanObj->GetSupportFeature(g_wlanObj, nullptr, &supTypeLenInvalid);
76094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
77094332d3Sopenharmony_ci    rc = g_wlanObj->GetSupportFeature(g_wlanObj, supType, nullptr);
78094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
79094332d3Sopenharmony_ci    rc = g_wlanObj->GetSupportFeature(g_wlanObj, supType, &supTypeLenInvalid);
80094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
81094332d3Sopenharmony_ci}
82094332d3Sopenharmony_ci
83094332d3Sopenharmony_ci/**
84094332d3Sopenharmony_ci * @tc.name: GetSupportComboTest_002
85094332d3Sopenharmony_ci * @tc.desc: Wifi hdi get support combo function test
86094332d3Sopenharmony_ci * @tc.type: FUNC
87094332d3Sopenharmony_ci * @tc.require:
88094332d3Sopenharmony_ci */
89094332d3Sopenharmony_ciHWTEST_F(HdfWifiDirectTest, GetSupportComboTest_002, TestSize.Level1)
90094332d3Sopenharmony_ci{
91094332d3Sopenharmony_ci    uint64_t combo[DEFAULT_COMBO_SIZE] = {0};
92094332d3Sopenharmony_ci
93094332d3Sopenharmony_ci    int32_t rc = g_wlanObj->GetSupportCombo(g_wlanObj, nullptr);
94094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
95094332d3Sopenharmony_ci    rc = g_wlanObj->GetSupportCombo(g_wlanObj, combo);
96094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
97094332d3Sopenharmony_ci}
98094332d3Sopenharmony_ci
99094332d3Sopenharmony_ci/**
100094332d3Sopenharmony_ci * @tc.name: CreateFeatureTest_003
101094332d3Sopenharmony_ci * @tc.desc: Wifi hdi create feature function test
102094332d3Sopenharmony_ci * @tc.type: FUNC
103094332d3Sopenharmony_ci * @tc.require:
104094332d3Sopenharmony_ci */
105094332d3Sopenharmony_ciHWTEST_F(HdfWifiDirectTest, CreateFeatureTest_003, TestSize.Level1)
106094332d3Sopenharmony_ci{
107094332d3Sopenharmony_ci    struct HdfFeatureInfo ifeature;
108094332d3Sopenharmony_ci    int32_t wlanType = PROTOCOL_80211_IFTYPE_AP;
109094332d3Sopenharmony_ci
110094332d3Sopenharmony_ci    (void)memset_s(&ifeature, sizeof(struct HdfFeatureInfo), 0, sizeof(struct HdfFeatureInfo));
111094332d3Sopenharmony_ci    int32_t rc = g_wlanObj->CreateFeature(g_wlanObj, wlanType, nullptr);
112094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
113094332d3Sopenharmony_ci    rc = g_wlanObj->CreateFeature(g_wlanObj, wlanType, &ifeature);
114094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
115094332d3Sopenharmony_ci
116094332d3Sopenharmony_ci    wlanType = PROTOCOL_80211_IFTYPE_STATION;
117094332d3Sopenharmony_ci    rc = g_wlanObj->CreateFeature(g_wlanObj, wlanType, &ifeature);
118094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
119094332d3Sopenharmony_ci
120094332d3Sopenharmony_ci    wlanType = PROTOCOL_80211_IFTYPE_P2P_DEVICE;
121094332d3Sopenharmony_ci    rc = g_wlanObj->CreateFeature(g_wlanObj, wlanType, &ifeature);
122094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
123094332d3Sopenharmony_ci}
124094332d3Sopenharmony_ci
125094332d3Sopenharmony_ci/**
126094332d3Sopenharmony_ci * @tc.name: DestroyFeatureTest_004
127094332d3Sopenharmony_ci * @tc.desc: Wifi hdi destroy feature function test
128094332d3Sopenharmony_ci * @tc.type: FUNC
129094332d3Sopenharmony_ci * @tc.require:
130094332d3Sopenharmony_ci */
131094332d3Sopenharmony_ciHWTEST_F(HdfWifiDirectTest, DestroyFeatureTest_004, TestSize.Level1)
132094332d3Sopenharmony_ci{
133094332d3Sopenharmony_ci    struct HdfFeatureInfo ifeature;
134094332d3Sopenharmony_ci    string ifName = "wlan0";
135094332d3Sopenharmony_ci
136094332d3Sopenharmony_ci    (void)memset_s(&ifeature, sizeof(struct HdfFeatureInfo), 0, sizeof(struct HdfFeatureInfo));
137094332d3Sopenharmony_ci    int32_t rc = g_wlanObj->DestroyFeature(g_wlanObj, nullptr);
138094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
139094332d3Sopenharmony_ci    ifeature.ifName = nullptr;
140094332d3Sopenharmony_ci    rc = g_wlanObj->DestroyFeature(g_wlanObj, &ifeature);
141094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
142094332d3Sopenharmony_ci    ifeature.ifName = const_cast<char*>(ifName.c_str());
143094332d3Sopenharmony_ci    ifeature.type = PROTOCOL_80211_IFTYPE_AP;
144094332d3Sopenharmony_ci    rc = g_wlanObj->DestroyFeature(g_wlanObj, &ifeature);
145094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
146094332d3Sopenharmony_ci    ifeature.type = PROTOCOL_80211_IFTYPE_STATION;
147094332d3Sopenharmony_ci    rc = g_wlanObj->DestroyFeature(g_wlanObj, &ifeature);
148094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
149094332d3Sopenharmony_ci    ifeature.type = PROTOCOL_80211_IFTYPE_P2P_DEVICE;
150094332d3Sopenharmony_ci    rc = g_wlanObj->DestroyFeature(g_wlanObj, &ifeature);
151094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
152094332d3Sopenharmony_ci}
153094332d3Sopenharmony_ci
154094332d3Sopenharmony_ci/**
155094332d3Sopenharmony_ci * @tc.name: GetAssociatedStasTest_005
156094332d3Sopenharmony_ci * @tc.desc: Wifi hdi get associated stas function test
157094332d3Sopenharmony_ci * @tc.type: FUNC
158094332d3Sopenharmony_ci * @tc.require:
159094332d3Sopenharmony_ci */
160094332d3Sopenharmony_ciHWTEST_F(HdfWifiDirectTest, GetAssociatedStasTest_005, TestSize.Level1)
161094332d3Sopenharmony_ci{
162094332d3Sopenharmony_ci    struct HdfFeatureInfo ifeature;
163094332d3Sopenharmony_ci    struct HdfStaInfo staInfo[WLAN_MAX_NUM_STA_WITH_AP] = {{0}};
164094332d3Sopenharmony_ci    uint32_t staInfoLen = WLAN_MAX_NUM_STA_WITH_AP;
165094332d3Sopenharmony_ci    uint32_t num = 0;
166094332d3Sopenharmony_ci    string ifName = "wlan0";
167094332d3Sopenharmony_ci
168094332d3Sopenharmony_ci    (void)memset_s(&ifeature, sizeof(struct HdfFeatureInfo), 0, sizeof(struct HdfFeatureInfo));
169094332d3Sopenharmony_ci    int32_t rc = g_wlanObj->GetAssociatedStas(g_wlanObj, nullptr, staInfo, &staInfoLen, &num);
170094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
171094332d3Sopenharmony_ci    ifeature.ifName = nullptr;
172094332d3Sopenharmony_ci    rc = g_wlanObj->GetAssociatedStas(g_wlanObj, &ifeature, staInfo, &staInfoLen, &num);
173094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
174094332d3Sopenharmony_ci    ifeature.ifName = const_cast<char*>(ifName.c_str());
175094332d3Sopenharmony_ci    rc = g_wlanObj->GetAssociatedStas(g_wlanObj, &ifeature, nullptr, &staInfoLen, &num);
176094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
177094332d3Sopenharmony_ci    rc = g_wlanObj->GetAssociatedStas(g_wlanObj, &ifeature, staInfo, nullptr, &num);
178094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
179094332d3Sopenharmony_ci    rc = g_wlanObj->GetAssociatedStas(g_wlanObj, &ifeature, staInfo, &staInfoLen, nullptr);
180094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
181094332d3Sopenharmony_ci    rc = g_wlanObj->GetAssociatedStas(g_wlanObj, &ifeature, staInfo, &staInfoLen, &num);
182094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
183094332d3Sopenharmony_ci}
184094332d3Sopenharmony_ci
185094332d3Sopenharmony_ci/**
186094332d3Sopenharmony_ci * @tc.name: GetChipIdTest_006
187094332d3Sopenharmony_ci * @tc.desc: Wifi hdi get chip id function test
188094332d3Sopenharmony_ci * @tc.type: FUNC
189094332d3Sopenharmony_ci * @tc.require:
190094332d3Sopenharmony_ci */
191094332d3Sopenharmony_ciHWTEST_F(HdfWifiDirectTest, GetChipIdTest_006, TestSize.Level1)
192094332d3Sopenharmony_ci{
193094332d3Sopenharmony_ci    struct HdfFeatureInfo ifeature;
194094332d3Sopenharmony_ci    uint8_t chipId = 0;
195094332d3Sopenharmony_ci    string ifName = "wlan0";
196094332d3Sopenharmony_ci
197094332d3Sopenharmony_ci    (void)memset_s(&ifeature, sizeof(struct HdfFeatureInfo), 0, sizeof(struct HdfFeatureInfo));
198094332d3Sopenharmony_ci    int32_t rc = g_wlanObj->GetChipId(g_wlanObj, nullptr, &chipId);
199094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
200094332d3Sopenharmony_ci    ifeature.ifName = nullptr;
201094332d3Sopenharmony_ci    rc = g_wlanObj->GetChipId(g_wlanObj, &ifeature, &chipId);
202094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
203094332d3Sopenharmony_ci    ifeature.ifName = const_cast<char*>(ifName.c_str());
204094332d3Sopenharmony_ci    rc = g_wlanObj->GetChipId(g_wlanObj, &ifeature, nullptr);
205094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
206094332d3Sopenharmony_ci    rc = g_wlanObj->GetChipId(g_wlanObj, &ifeature, &chipId);
207094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
208094332d3Sopenharmony_ci}
209094332d3Sopenharmony_ci
210094332d3Sopenharmony_ci/**
211094332d3Sopenharmony_ci * @tc.name: GetDeviceMacAddressTest_007
212094332d3Sopenharmony_ci * @tc.desc: Wifi hdi get device mac addr function test on STA feature
213094332d3Sopenharmony_ci * @tc.type: FUNC
214094332d3Sopenharmony_ci * @tc.require:
215094332d3Sopenharmony_ci */
216094332d3Sopenharmony_ciHWTEST_F(HdfWifiDirectTest, GetDeviceMacAddressTest_007, TestSize.Level1)
217094332d3Sopenharmony_ci{
218094332d3Sopenharmony_ci    struct HdfFeatureInfo ifeature;
219094332d3Sopenharmony_ci    uint8_t mac[ETH_ADDR_LEN] = {0};
220094332d3Sopenharmony_ci    uint32_t macLen = ETH_ADDR_LEN;
221094332d3Sopenharmony_ci    string ifName = "wlan0";
222094332d3Sopenharmony_ci
223094332d3Sopenharmony_ci    (void)memset_s(&ifeature, sizeof(struct HdfFeatureInfo), 0, sizeof(struct HdfFeatureInfo));
224094332d3Sopenharmony_ci    int32_t rc = g_wlanObj->GetDeviceMacAddress(g_wlanObj, nullptr, mac, &macLen, ETH_ADDR_LEN);
225094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
226094332d3Sopenharmony_ci    ifeature.ifName = nullptr;
227094332d3Sopenharmony_ci    rc = g_wlanObj->GetDeviceMacAddress(g_wlanObj, &ifeature, mac, &macLen, ETH_ADDR_LEN);
228094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
229094332d3Sopenharmony_ci    ifeature.ifName = const_cast<char*>(ifName.c_str());
230094332d3Sopenharmony_ci    rc = g_wlanObj->GetDeviceMacAddress(g_wlanObj, &ifeature, nullptr, &macLen, ETH_ADDR_LEN);
231094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
232094332d3Sopenharmony_ci    rc = g_wlanObj->GetDeviceMacAddress(g_wlanObj, &ifeature, mac, nullptr, ETH_ADDR_LEN);
233094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
234094332d3Sopenharmony_ci    rc = g_wlanObj->GetDeviceMacAddress(g_wlanObj, &ifeature, mac, &macLen, ETH_ADDR_LEN);
235094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
236094332d3Sopenharmony_ci}
237094332d3Sopenharmony_ci
238094332d3Sopenharmony_ci/**
239094332d3Sopenharmony_ci * @tc.name: GetFeatureByIfNameTest_008
240094332d3Sopenharmony_ci * @tc.desc: Wifi hdi get feature by ifname function test
241094332d3Sopenharmony_ci * @tc.type: FUNC
242094332d3Sopenharmony_ci * @tc.require: AR000H603L
243094332d3Sopenharmony_ci */
244094332d3Sopenharmony_ciHWTEST_F(HdfWifiDirectTest, GetFeatureByIfNameTest_008, TestSize.Level1)
245094332d3Sopenharmony_ci{
246094332d3Sopenharmony_ci    struct HdfFeatureInfo ifeature;
247094332d3Sopenharmony_ci    const char *ifName = "wlan0";
248094332d3Sopenharmony_ci
249094332d3Sopenharmony_ci    (void)memset_s(&ifeature, sizeof(struct HdfFeatureInfo), 0, sizeof(struct HdfFeatureInfo));
250094332d3Sopenharmony_ci    int32_t rc = g_wlanObj->GetFeatureByIfName(g_wlanObj, nullptr, &ifeature);
251094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
252094332d3Sopenharmony_ci    rc = g_wlanObj->GetFeatureByIfName(g_wlanObj, ifName, nullptr);
253094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
254094332d3Sopenharmony_ci    rc = g_wlanObj->GetFeatureByIfName(g_wlanObj, ifName, &ifeature);
255094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
256094332d3Sopenharmony_ci}
257094332d3Sopenharmony_ci
258094332d3Sopenharmony_ci/**
259094332d3Sopenharmony_ci * @tc.name: GetFeatureTypeTest_009
260094332d3Sopenharmony_ci * @tc.desc: Wifi hdi get feature type function test on STA feature
261094332d3Sopenharmony_ci * @tc.type: FUNC
262094332d3Sopenharmony_ci * @tc.require:
263094332d3Sopenharmony_ci */
264094332d3Sopenharmony_ciHWTEST_F(HdfWifiDirectTest, GetFeatureTypeTest_009, TestSize.Level1)
265094332d3Sopenharmony_ci{
266094332d3Sopenharmony_ci    struct HdfFeatureInfo ifeature;
267094332d3Sopenharmony_ci    int32_t featureType;
268094332d3Sopenharmony_ci
269094332d3Sopenharmony_ci    (void)memset_s(&ifeature, sizeof(struct HdfFeatureInfo), 0, sizeof(struct HdfFeatureInfo));
270094332d3Sopenharmony_ci    int32_t rc = g_wlanObj->GetFeatureType(g_wlanObj, nullptr, &featureType);
271094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
272094332d3Sopenharmony_ci    rc = g_wlanObj->GetFeatureType(g_wlanObj, &ifeature, nullptr);
273094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
274094332d3Sopenharmony_ci    rc = g_wlanObj->GetFeatureType(g_wlanObj, &ifeature, &featureType);
275094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
276094332d3Sopenharmony_ci}
277094332d3Sopenharmony_ci
278094332d3Sopenharmony_ci/**
279094332d3Sopenharmony_ci * @tc.name: GetFreqsWithBandTest_010
280094332d3Sopenharmony_ci * @tc.desc: Wifi hdi get freqs function test on STA feature
281094332d3Sopenharmony_ci * @tc.type: FUNC
282094332d3Sopenharmony_ci * @tc.require:
283094332d3Sopenharmony_ci */
284094332d3Sopenharmony_ciHWTEST_F(HdfWifiDirectTest, GetFreqsWithBandTest_010, TestSize.Level1)
285094332d3Sopenharmony_ci{
286094332d3Sopenharmony_ci    struct HdfFeatureInfo ifeature;
287094332d3Sopenharmony_ci    struct HdfWifiInfo wifiInfo;
288094332d3Sopenharmony_ci    int32_t freq[WLAN_FREQ_MAX_NUM] = {0};
289094332d3Sopenharmony_ci    uint32_t freqLen = WLAN_FREQ_MAX_NUM;
290094332d3Sopenharmony_ci    wifiInfo.band = IEEE80211_BAND_2GHZ;
291094332d3Sopenharmony_ci    wifiInfo.size = WLAN_FREQ_MAX_NUM;
292094332d3Sopenharmony_ci    string ifName = "wlan0";
293094332d3Sopenharmony_ci
294094332d3Sopenharmony_ci    (void)memset_s(&ifeature, sizeof(struct HdfFeatureInfo), 0, sizeof(struct HdfFeatureInfo));
295094332d3Sopenharmony_ci    int32_t rc = g_wlanObj->GetFreqsWithBand(g_wlanObj, nullptr, &wifiInfo, freq, &freqLen);
296094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
297094332d3Sopenharmony_ci    ifeature.ifName = nullptr;
298094332d3Sopenharmony_ci    rc = g_wlanObj->GetFreqsWithBand(g_wlanObj, &ifeature, &wifiInfo, freq, &freqLen);
299094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
300094332d3Sopenharmony_ci    ifeature.ifName = const_cast<char*>(ifName.c_str());
301094332d3Sopenharmony_ci    rc = g_wlanObj->GetFreqsWithBand(g_wlanObj, &ifeature, nullptr, freq, &freqLen);
302094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
303094332d3Sopenharmony_ci    rc = g_wlanObj->GetFreqsWithBand(g_wlanObj, &ifeature, &wifiInfo, nullptr, &freqLen);
304094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
305094332d3Sopenharmony_ci    rc = g_wlanObj->GetFreqsWithBand(g_wlanObj, &ifeature, &wifiInfo, freq, nullptr);
306094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
307094332d3Sopenharmony_ci    rc = g_wlanObj->GetFreqsWithBand(g_wlanObj, &ifeature, &wifiInfo, freq, &freqLen);
308094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
309094332d3Sopenharmony_ci}
310094332d3Sopenharmony_ci
311094332d3Sopenharmony_ci/**
312094332d3Sopenharmony_ci * @tc.name: GetChipIdTest_011
313094332d3Sopenharmony_ci * @tc.desc: Wifi hdi get chip id function test on STA feature
314094332d3Sopenharmony_ci * @tc.type: FUNC
315094332d3Sopenharmony_ci * @tc.require:
316094332d3Sopenharmony_ci */
317094332d3Sopenharmony_ciHWTEST_F(HdfWifiDirectTest, GetChipIdTest_011, TestSize.Level1)
318094332d3Sopenharmony_ci{
319094332d3Sopenharmony_ci    uint8_t chipId = 0;
320094332d3Sopenharmony_ci    uint32_t num = 0;
321094332d3Sopenharmony_ci    char ifNames[IFNAMSIZ] = {0};
322094332d3Sopenharmony_ci
323094332d3Sopenharmony_ci    int32_t rc = g_wlanObj->GetIfNamesByChipId(g_wlanObj, chipId, nullptr, IFNAMSIZ, &num);
324094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
325094332d3Sopenharmony_ci    rc = g_wlanObj->GetIfNamesByChipId(g_wlanObj, chipId, ifNames, IFNAMSIZ, nullptr);
326094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
327094332d3Sopenharmony_ci    rc = g_wlanObj->GetIfNamesByChipId(g_wlanObj, chipId, ifNames, IFNAMSIZ, &num);
328094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
329094332d3Sopenharmony_ci}
330094332d3Sopenharmony_ci
331094332d3Sopenharmony_ci/**
332094332d3Sopenharmony_ci * @tc.name: GetNetworkIfaceNameTest_012
333094332d3Sopenharmony_ci * @tc.desc: Wifi hdi get network interface name function test on STA feature
334094332d3Sopenharmony_ci * @tc.type: FUNC
335094332d3Sopenharmony_ci * @tc.require:
336094332d3Sopenharmony_ci */
337094332d3Sopenharmony_ciHWTEST_F(HdfWifiDirectTest, GetNetworkIfaceNameTest_012, TestSize.Level1)
338094332d3Sopenharmony_ci{
339094332d3Sopenharmony_ci    struct HdfFeatureInfo ifeature;
340094332d3Sopenharmony_ci    char ifNames[IFNAMSIZ] = {0};
341094332d3Sopenharmony_ci    string ifName = "wlan0";
342094332d3Sopenharmony_ci
343094332d3Sopenharmony_ci    (void)memset_s(&ifeature, sizeof(struct HdfFeatureInfo), 0, sizeof(struct HdfFeatureInfo));
344094332d3Sopenharmony_ci    int32_t rc = g_wlanObj->GetNetworkIfaceName(g_wlanObj, nullptr, ifNames, IFNAMSIZ);
345094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
346094332d3Sopenharmony_ci    ifeature.ifName = nullptr;
347094332d3Sopenharmony_ci    rc = g_wlanObj->GetNetworkIfaceName(g_wlanObj, &ifeature, ifNames, IFNAMSIZ);
348094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
349094332d3Sopenharmony_ci    ifeature.ifName = const_cast<char*>(ifName.c_str());
350094332d3Sopenharmony_ci    rc = g_wlanObj->GetNetworkIfaceName(g_wlanObj, &ifeature, nullptr, IFNAMSIZ);
351094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
352094332d3Sopenharmony_ci    rc = g_wlanObj->GetNetworkIfaceName(g_wlanObj, &ifeature, ifNames, IFNAMSIZ);
353094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
354094332d3Sopenharmony_ci}
355094332d3Sopenharmony_ci
356094332d3Sopenharmony_ci/**
357094332d3Sopenharmony_ci * @tc.name: RegisterEventCallbackTest_013
358094332d3Sopenharmony_ci * @tc.desc: Wifi hdi register event call back function test
359094332d3Sopenharmony_ci * @tc.type: FUNC
360094332d3Sopenharmony_ci * @tc.require:
361094332d3Sopenharmony_ci */
362094332d3Sopenharmony_ciHWTEST_F(HdfWifiDirectTest, RegisterEventCallbackTest_013, TestSize.Level1)
363094332d3Sopenharmony_ci{
364094332d3Sopenharmony_ci    const char *ifName = "wlan0";
365094332d3Sopenharmony_ci
366094332d3Sopenharmony_ci    int32_t rc = g_wlanObj->RegisterEventCallback(g_wlanObj, nullptr, ifName);
367094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
368094332d3Sopenharmony_ci    rc = g_wlanObj->RegisterEventCallback(g_wlanObj, g_wlanCallbackObj, nullptr);
369094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
370094332d3Sopenharmony_ci    rc = g_wlanObj->RegisterEventCallback(g_wlanObj, g_wlanCallbackObj, ifName);
371094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
372094332d3Sopenharmony_ci}
373094332d3Sopenharmony_ci
374094332d3Sopenharmony_ci/**
375094332d3Sopenharmony_ci * @tc.name: ResetDriverTest_014
376094332d3Sopenharmony_ci * @tc.desc: Wifi hdi reset driver function test
377094332d3Sopenharmony_ci * @tc.type: FUNC
378094332d3Sopenharmony_ci * @tc.require:
379094332d3Sopenharmony_ci */
380094332d3Sopenharmony_ciHWTEST_F(HdfWifiDirectTest, ResetDriverTest_014, TestSize.Level1)
381094332d3Sopenharmony_ci{
382094332d3Sopenharmony_ci    const char *ifName = "wlan0";
383094332d3Sopenharmony_ci    uint8_t chipId = 0;
384094332d3Sopenharmony_ci
385094332d3Sopenharmony_ci    int32_t rc = g_wlanObj->ResetDriver(g_wlanObj, chipId, nullptr);
386094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
387094332d3Sopenharmony_ci    rc = g_wlanObj->ResetDriver(g_wlanObj, chipId, ifName);
388094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
389094332d3Sopenharmony_ci}
390094332d3Sopenharmony_ci
391094332d3Sopenharmony_ci/**
392094332d3Sopenharmony_ci * @tc.name: StartScanTest_015
393094332d3Sopenharmony_ci * @tc.desc: Wifi hdi start scan function test
394094332d3Sopenharmony_ci * @tc.type: FUNC
395094332d3Sopenharmony_ci * @tc.require:
396094332d3Sopenharmony_ci */
397094332d3Sopenharmony_ciHWTEST_F(HdfWifiDirectTest, StartScanTest_015, TestSize.Level1)
398094332d3Sopenharmony_ci{
399094332d3Sopenharmony_ci    struct HdfFeatureInfo ifeature;
400094332d3Sopenharmony_ci    struct HdfWifiScan scan = {0};
401094332d3Sopenharmony_ci    string ifName = "wlan0";
402094332d3Sopenharmony_ci
403094332d3Sopenharmony_ci    (void)memset_s(&ifeature, sizeof(struct HdfFeatureInfo), 0, sizeof(struct HdfFeatureInfo));
404094332d3Sopenharmony_ci    int32_t rc = g_wlanObj->StartScan(g_wlanObj, nullptr, &scan);
405094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
406094332d3Sopenharmony_ci    ifeature.ifName = nullptr;
407094332d3Sopenharmony_ci    rc = g_wlanObj->StartScan(g_wlanObj, &ifeature, &scan);
408094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
409094332d3Sopenharmony_ci    ifeature.ifName = const_cast<char*>(ifName.c_str());
410094332d3Sopenharmony_ci    rc = g_wlanObj->StartScan(g_wlanObj, &ifeature, nullptr);
411094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
412094332d3Sopenharmony_ci    rc = g_wlanObj->StartScan(g_wlanObj, &ifeature, &scan);
413094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
414094332d3Sopenharmony_ci}
415094332d3Sopenharmony_ci
416094332d3Sopenharmony_ci/**
417094332d3Sopenharmony_ci * @tc.name: UnregisterEventCallbackTest_016
418094332d3Sopenharmony_ci * @tc.desc: Wifi hdi unreister event call back function test
419094332d3Sopenharmony_ci * @tc.type: FUNC
420094332d3Sopenharmony_ci * @tc.require:
421094332d3Sopenharmony_ci */
422094332d3Sopenharmony_ciHWTEST_F(HdfWifiDirectTest, UnregisterEventCallbackTest_016, TestSize.Level1)
423094332d3Sopenharmony_ci{
424094332d3Sopenharmony_ci    const char *ifName = "wlan0";
425094332d3Sopenharmony_ci
426094332d3Sopenharmony_ci    int32_t rc = g_wlanObj->UnregisterEventCallback(g_wlanObj, nullptr, ifName);
427094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
428094332d3Sopenharmony_ci    rc = g_wlanObj->UnregisterEventCallback(g_wlanObj, g_wlanCallbackObj, nullptr);
429094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
430094332d3Sopenharmony_ci    rc = g_wlanObj->UnregisterEventCallback(g_wlanObj, g_wlanCallbackObj, ifName);
431094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
432094332d3Sopenharmony_ci}
433094332d3Sopenharmony_ci
434094332d3Sopenharmony_ci/**
435094332d3Sopenharmony_ci * @tc.name: SetCountryCodeTest_017
436094332d3Sopenharmony_ci * @tc.desc: Wifi hdi set country code function test
437094332d3Sopenharmony_ci * @tc.type: FUNC
438094332d3Sopenharmony_ci * @tc.require:
439094332d3Sopenharmony_ci */
440094332d3Sopenharmony_ciHWTEST_F(HdfWifiDirectTest, SetCountryCodeTest_017, TestSize.Level1)
441094332d3Sopenharmony_ci{
442094332d3Sopenharmony_ci    const char *code = "CN";
443094332d3Sopenharmony_ci    struct HdfFeatureInfo ifeature;
444094332d3Sopenharmony_ci    const char *codeDigital = "99";
445094332d3Sopenharmony_ci    uint32_t size = 2;
446094332d3Sopenharmony_ci    string ifName = "wlan0";
447094332d3Sopenharmony_ci
448094332d3Sopenharmony_ci    (void)memset_s(&ifeature, sizeof(struct HdfFeatureInfo), 0, sizeof(struct HdfFeatureInfo));
449094332d3Sopenharmony_ci    int32_t rc = g_wlanObj->SetCountryCode(g_wlanObj, nullptr, codeDigital, size);
450094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
451094332d3Sopenharmony_ci    ifeature.ifName = nullptr;
452094332d3Sopenharmony_ci    rc = g_wlanObj->SetCountryCode(g_wlanObj, &ifeature, code, size);
453094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
454094332d3Sopenharmony_ci    ifeature.ifName = const_cast<char*>(ifName.c_str());
455094332d3Sopenharmony_ci    rc = g_wlanObj->SetCountryCode(g_wlanObj, &ifeature, nullptr, size);
456094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
457094332d3Sopenharmony_ci    rc = g_wlanObj->SetCountryCode(g_wlanObj, &ifeature, code, size);
458094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
459094332d3Sopenharmony_ci}
460094332d3Sopenharmony_ci
461094332d3Sopenharmony_ci/**
462094332d3Sopenharmony_ci * @tc.name: SetMacAddressTest_018
463094332d3Sopenharmony_ci * @tc.desc: Wifi hdi set mac addr function test on STA feature
464094332d3Sopenharmony_ci * @tc.type: FUNC
465094332d3Sopenharmony_ci * @tc.require:
466094332d3Sopenharmony_ci */
467094332d3Sopenharmony_ciHWTEST_F(HdfWifiDirectTest, SetMacAddressTest_018, TestSize.Level1)
468094332d3Sopenharmony_ci{
469094332d3Sopenharmony_ci    uint8_t mac[ETH_ADDR_LEN] = {0x12, 0x34, 0x56, 0x78, 0xab, 0xcd};
470094332d3Sopenharmony_ci    struct HdfFeatureInfo ifeature;
471094332d3Sopenharmony_ci    uint32_t macLen = ETH_ADDR_LEN;
472094332d3Sopenharmony_ci    string ifName = "wlan0";
473094332d3Sopenharmony_ci
474094332d3Sopenharmony_ci    (void)memset_s(&ifeature, sizeof(struct HdfFeatureInfo), 0, sizeof(struct HdfFeatureInfo));
475094332d3Sopenharmony_ci    int32_t rc = g_wlanObj->SetMacAddress(g_wlanObj, nullptr, mac, macLen);
476094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
477094332d3Sopenharmony_ci    ifeature.ifName = nullptr;
478094332d3Sopenharmony_ci    rc = g_wlanObj->SetMacAddress(g_wlanObj, &ifeature, mac, macLen);
479094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
480094332d3Sopenharmony_ci    ifeature.ifName = const_cast<char*>(ifName.c_str());
481094332d3Sopenharmony_ci    rc = g_wlanObj->SetMacAddress(g_wlanObj, &ifeature, nullptr, macLen);
482094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
483094332d3Sopenharmony_ci    rc = g_wlanObj->SetMacAddress(g_wlanObj, &ifeature, mac, macLen);
484094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
485094332d3Sopenharmony_ci}
486094332d3Sopenharmony_ci
487094332d3Sopenharmony_ci/**
488094332d3Sopenharmony_ci * @tc.name: SetScanningMacAddressTest_019
489094332d3Sopenharmony_ci * @tc.desc: Wifi hdi set scanning mac addr function test
490094332d3Sopenharmony_ci * @tc.type: FUNC
491094332d3Sopenharmony_ci * @tc.require:
492094332d3Sopenharmony_ci */
493094332d3Sopenharmony_ciHWTEST_F(HdfWifiDirectTest, SetScanningMacAddressTest_019, TestSize.Level1)
494094332d3Sopenharmony_ci{
495094332d3Sopenharmony_ci    struct HdfFeatureInfo ifeature;
496094332d3Sopenharmony_ci    uint8_t scanMac[ETH_ADDR_LEN] = {0x12, 0x34, 0x56, 0x78, 0xab, 0xcd};
497094332d3Sopenharmony_ci    uint32_t macLen = ETH_ADDR_LEN;
498094332d3Sopenharmony_ci    string ifName = "wlan0";
499094332d3Sopenharmony_ci
500094332d3Sopenharmony_ci    (void)memset_s(&ifeature, sizeof(struct HdfFeatureInfo), 0, sizeof(struct HdfFeatureInfo));
501094332d3Sopenharmony_ci    int32_t rc = g_wlanObj->SetScanningMacAddress(g_wlanObj, nullptr, scanMac, macLen);
502094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
503094332d3Sopenharmony_ci    ifeature.ifName = nullptr;
504094332d3Sopenharmony_ci    rc = g_wlanObj->SetScanningMacAddress(g_wlanObj, &ifeature, scanMac, macLen);
505094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
506094332d3Sopenharmony_ci    ifeature.ifName = const_cast<char*>(ifName.c_str());
507094332d3Sopenharmony_ci    rc = g_wlanObj->SetScanningMacAddress(g_wlanObj, &ifeature, nullptr, macLen);
508094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
509094332d3Sopenharmony_ci    rc = g_wlanObj->SetScanningMacAddress(g_wlanObj, &ifeature, scanMac, macLen);
510094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
511094332d3Sopenharmony_ci}
512094332d3Sopenharmony_ci
513094332d3Sopenharmony_ci/**
514094332d3Sopenharmony_ci * @tc.name: SetTxPowerTest_020
515094332d3Sopenharmony_ci * @tc.desc: Wifi hdi set tx power function test on STA feature
516094332d3Sopenharmony_ci * @tc.type: FUNC
517094332d3Sopenharmony_ci * @tc.require:
518094332d3Sopenharmony_ci */
519094332d3Sopenharmony_ciHWTEST_F(HdfWifiDirectTest, SetTxPowerTest_020, TestSize.Level1)
520094332d3Sopenharmony_ci{
521094332d3Sopenharmony_ci    struct HdfFeatureInfo ifeature;
522094332d3Sopenharmony_ci    int32_t power = WLAN_TX_POWER;
523094332d3Sopenharmony_ci    string ifName = "wlan0";
524094332d3Sopenharmony_ci
525094332d3Sopenharmony_ci    (void)memset_s(&ifeature, sizeof(struct HdfFeatureInfo), 0, sizeof(struct HdfFeatureInfo));
526094332d3Sopenharmony_ci    int32_t rc = g_wlanObj->SetTxPower(g_wlanObj, nullptr, power);
527094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
528094332d3Sopenharmony_ci    ifeature.ifName = nullptr;
529094332d3Sopenharmony_ci    rc = g_wlanObj->SetTxPower(g_wlanObj, &ifeature, power);
530094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
531094332d3Sopenharmony_ci    ifeature.ifName = const_cast<char*>(ifName.c_str());
532094332d3Sopenharmony_ci    rc = g_wlanObj->SetTxPower(g_wlanObj, &ifeature, power);
533094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
534094332d3Sopenharmony_ci}
535094332d3Sopenharmony_ci
536094332d3Sopenharmony_ci/**
537094332d3Sopenharmony_ci * @tc.name: GetNetdevInfoTest_021
538094332d3Sopenharmony_ci * @tc.desc: Wifi hdi get netdev info function test
539094332d3Sopenharmony_ci * @tc.type: FUNC
540094332d3Sopenharmony_ci * @tc.require:
541094332d3Sopenharmony_ci */
542094332d3Sopenharmony_ciHWTEST_F(HdfWifiDirectTest, GetNetdevInfoTest_021, TestSize.Level1)
543094332d3Sopenharmony_ci{
544094332d3Sopenharmony_ci    int32_t rc;
545094332d3Sopenharmony_ci    struct HdfNetDeviceInfoResult netDeviceInfoResult;
546094332d3Sopenharmony_ci
547094332d3Sopenharmony_ci    (void)memset_s(
548094332d3Sopenharmony_ci        &netDeviceInfoResult, sizeof(struct HdfNetDeviceInfoResult), 0, sizeof(struct HdfNetDeviceInfoResult));
549094332d3Sopenharmony_ci    rc = g_wlanObj->GetNetDevInfo(g_wlanObj, (struct HdfNetDeviceInfoResult *)&netDeviceInfoResult);
550094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
551094332d3Sopenharmony_ci    rc = g_wlanObj->GetNetDevInfo(g_wlanObj, nullptr);
552094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
553094332d3Sopenharmony_ci}
554094332d3Sopenharmony_ci
555094332d3Sopenharmony_ci/**
556094332d3Sopenharmony_ci * @tc.name: GetPowerModeTest_022
557094332d3Sopenharmony_ci * @tc.desc: Wifi hdi get power mode function test
558094332d3Sopenharmony_ci * @tc.type: FUNC
559094332d3Sopenharmony_ci * @tc.require:
560094332d3Sopenharmony_ci */
561094332d3Sopenharmony_ciHWTEST_F(HdfWifiDirectTest, GetPowerModeTest_022, TestSize.Level1)
562094332d3Sopenharmony_ci{
563094332d3Sopenharmony_ci    struct HdfFeatureInfo ifeature;
564094332d3Sopenharmony_ci    uint8_t mode = 0;
565094332d3Sopenharmony_ci    string ifName = "wlan0";
566094332d3Sopenharmony_ci
567094332d3Sopenharmony_ci    (void)memset_s(&ifeature, sizeof(struct HdfFeatureInfo), 0, sizeof(struct HdfFeatureInfo));
568094332d3Sopenharmony_ci    int32_t rc = g_wlanObj->GetPowerMode(g_wlanObj, nullptr, &mode);
569094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
570094332d3Sopenharmony_ci    ifeature.ifName = nullptr;
571094332d3Sopenharmony_ci    rc = g_wlanObj->GetPowerMode(g_wlanObj, &ifeature, &mode);
572094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
573094332d3Sopenharmony_ci    ifeature.ifName = const_cast<char*>(ifName.c_str());
574094332d3Sopenharmony_ci    rc = g_wlanObj->GetPowerMode(g_wlanObj, &ifeature, nullptr);
575094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
576094332d3Sopenharmony_ci    rc = g_wlanObj->GetPowerMode(g_wlanObj, &ifeature, &mode);
577094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
578094332d3Sopenharmony_ci}
579094332d3Sopenharmony_ci
580094332d3Sopenharmony_ci/**
581094332d3Sopenharmony_ci * @tc.name: SetPowerModeTest_023
582094332d3Sopenharmony_ci * @tc.desc: Wifi hdi set power mode function test
583094332d3Sopenharmony_ci * @tc.type: FUNC
584094332d3Sopenharmony_ci * @tc.require:
585094332d3Sopenharmony_ci */
586094332d3Sopenharmony_ciHWTEST_F(HdfWifiDirectTest, SetPowerModeTest_023, TestSize.Level1)
587094332d3Sopenharmony_ci{
588094332d3Sopenharmony_ci    struct HdfFeatureInfo ifeature;
589094332d3Sopenharmony_ci    uint8_t mode = WIFI_POWER_MODE_SLEEPING;
590094332d3Sopenharmony_ci    string ifName = "wlan0";
591094332d3Sopenharmony_ci
592094332d3Sopenharmony_ci    (void)memset_s(&ifeature, sizeof(struct HdfFeatureInfo), 0, sizeof(struct HdfFeatureInfo));
593094332d3Sopenharmony_ci    int32_t rc = g_wlanObj->SetPowerMode(g_wlanObj, nullptr, mode);
594094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
595094332d3Sopenharmony_ci    ifeature.ifName = nullptr;
596094332d3Sopenharmony_ci    rc = g_wlanObj->SetPowerMode(g_wlanObj, &ifeature, mode);
597094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
598094332d3Sopenharmony_ci    ifeature.ifName = const_cast<char*>(ifName.c_str());
599094332d3Sopenharmony_ci    rc = g_wlanObj->SetPowerMode(g_wlanObj, &ifeature, mode);
600094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
601094332d3Sopenharmony_ci}
602094332d3Sopenharmony_ci
603094332d3Sopenharmony_ci/**
604094332d3Sopenharmony_ci * @tc.name: SetProjectionScreenParam_024
605094332d3Sopenharmony_ci * @tc.desc: Wifi hdi set paramters to optimize projectino screen function test
606094332d3Sopenharmony_ci * @tc.type: FUNC
607094332d3Sopenharmony_ci * @tc.require:
608094332d3Sopenharmony_ci */
609094332d3Sopenharmony_ciHWTEST_F(HdfWifiDirectTest, SetProjectionScreenParam_024, TestSize.Level1)
610094332d3Sopenharmony_ci{
611094332d3Sopenharmony_ci    const char *ifName = "wlan0";
612094332d3Sopenharmony_ci    int32_t rc;
613094332d3Sopenharmony_ci    struct ProjectionScreenCmdParam param;
614094332d3Sopenharmony_ci
615094332d3Sopenharmony_ci    (void)memset_s(&param, sizeof(struct ProjectionScreenCmdParam), 0, sizeof(struct ProjectionScreenCmdParam));
616094332d3Sopenharmony_ci    rc = g_wlanObj->SetProjectionScreenParam(g_wlanObj, nullptr, &param);
617094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
618094332d3Sopenharmony_ci    rc = g_wlanObj->SetProjectionScreenParam(g_wlanObj, ifName, nullptr);
619094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
620094332d3Sopenharmony_ci    rc = g_wlanObj->SetProjectionScreenParam(g_wlanObj, ifName, &param);
621094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
622094332d3Sopenharmony_ci}
623094332d3Sopenharmony_ci
624094332d3Sopenharmony_ci/**
625094332d3Sopenharmony_ci * @tc.name: GetStaInfo_025
626094332d3Sopenharmony_ci * @tc.desc: Wifi hdi get station information function test
627094332d3Sopenharmony_ci * @tc.type: FUNC
628094332d3Sopenharmony_ci * @tc.require:
629094332d3Sopenharmony_ci */
630094332d3Sopenharmony_ciHWTEST_F(HdfWifiDirectTest, GetStaInfo_025, TestSize.Level1)
631094332d3Sopenharmony_ci{
632094332d3Sopenharmony_ci    const char *ifName = "wlan0";
633094332d3Sopenharmony_ci    int32_t rc;
634094332d3Sopenharmony_ci    struct WifiStationInfo info;
635094332d3Sopenharmony_ci    uint8_t mac[ETH_ADDR_LEN] = {0};
636094332d3Sopenharmony_ci
637094332d3Sopenharmony_ci    (void)memset_s(&info, sizeof(struct WifiStationInfo), 0, sizeof(struct WifiStationInfo));
638094332d3Sopenharmony_ci    rc = g_wlanObj->GetStaInfo(g_wlanObj, nullptr, &info, mac, ETH_ADDR_LEN);
639094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
640094332d3Sopenharmony_ci    rc = g_wlanObj->GetStaInfo(g_wlanObj, ifName, nullptr, mac, ETH_ADDR_LEN);
641094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
642094332d3Sopenharmony_ci    rc = g_wlanObj->GetStaInfo(g_wlanObj, ifName, &info, nullptr, ETH_ADDR_LEN);
643094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
644094332d3Sopenharmony_ci    rc = g_wlanObj->GetStaInfo(g_wlanObj, ifName, &info, mac, ETH_ADDR_LEN);
645094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
646094332d3Sopenharmony_ci}
647094332d3Sopenharmony_ci
648094332d3Sopenharmony_ci/**
649094332d3Sopenharmony_ci * @tc.name: GetApBandwidthTest_026
650094332d3Sopenharmony_ci * @tc.desc: Wifi hdi get ap bandwidth info function test
651094332d3Sopenharmony_ci * @tc.type: FUNC
652094332d3Sopenharmony_ci * @tc.require:
653094332d3Sopenharmony_ci */
654094332d3Sopenharmony_ciHWTEST_F(HdfWifiDirectTest, GetApBandwidthTest_026, TestSize.Level1)
655094332d3Sopenharmony_ci{
656094332d3Sopenharmony_ci    int32_t rc;
657094332d3Sopenharmony_ci    uint8_t bandwidth = 0;
658094332d3Sopenharmony_ci    const char *ifName = "wlan0";
659094332d3Sopenharmony_ci
660094332d3Sopenharmony_ci    rc = g_wlanObj->GetApBandwidth(g_wlanObj, nullptr, &bandwidth);
661094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
662094332d3Sopenharmony_ci    rc = g_wlanObj->GetApBandwidth(g_wlanObj, ifName, nullptr);
663094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
664094332d3Sopenharmony_ci    rc = g_wlanObj->GetApBandwidth(g_wlanObj, ifName, &bandwidth);
665094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
666094332d3Sopenharmony_ci}
667094332d3Sopenharmony_ci
668094332d3Sopenharmony_ci/**
669094332d3Sopenharmony_ci * @tc.name: ResetToFactoryMacAddressTest_027
670094332d3Sopenharmony_ci * @tc.desc: Wifi hdi reset mac address function test
671094332d3Sopenharmony_ci * @tc.type: FUNC
672094332d3Sopenharmony_ci * @tc.require:
673094332d3Sopenharmony_ci */
674094332d3Sopenharmony_ciHWTEST_F(HdfWifiDirectTest, ResetToFactoryMacAddressTest_027, TestSize.Level1)
675094332d3Sopenharmony_ci{
676094332d3Sopenharmony_ci    int32_t rc;
677094332d3Sopenharmony_ci    const char *ifName = "wlan0";
678094332d3Sopenharmony_ci
679094332d3Sopenharmony_ci    rc = g_wlanObj->ResetToFactoryMacAddress(g_wlanObj, nullptr);
680094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
681094332d3Sopenharmony_ci    rc = g_wlanObj->ResetToFactoryMacAddress(g_wlanObj, ifName);
682094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
683094332d3Sopenharmony_ci}
684094332d3Sopenharmony_ci
685094332d3Sopenharmony_ci
686094332d3Sopenharmony_ci/**
687094332d3Sopenharmony_ci * @tc.name: SendActionFrameTest_028
688094332d3Sopenharmony_ci * @tc.desc: Wifi hdi send action frame function test
689094332d3Sopenharmony_ci * @tc.type: FUNC
690094332d3Sopenharmony_ci * @tc.require:
691094332d3Sopenharmony_ci */
692094332d3Sopenharmony_ciHWTEST_F(HdfWifiDirectTest, SendActionFrameTest_028, TestSize.Level1)
693094332d3Sopenharmony_ci{
694094332d3Sopenharmony_ci    int32_t freq = WLAN_TX_POWER;
695094332d3Sopenharmony_ci    uint32_t frameDataLen = DEFAULT_COMBO_SIZE;
696094332d3Sopenharmony_ci    uint8_t frameData[ETH_ADDR_LEN] = {0x12, 0x34, 0x56, 0x78, 0xab, 0xcd};
697094332d3Sopenharmony_ci    const char *ifName = "wlan0";
698094332d3Sopenharmony_ci
699094332d3Sopenharmony_ci    int32_t rc = g_wlanObj->SendActionFrame(g_wlanObj, nullptr, freq, frameData, frameDataLen);
700094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
701094332d3Sopenharmony_ci    rc = g_wlanObj->SendActionFrame(g_wlanObj, ifName, 0, frameData, frameDataLen);
702094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
703094332d3Sopenharmony_ci    rc = g_wlanObj->SendActionFrame(g_wlanObj, ifName, freq, nullptr, frameDataLen);
704094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
705094332d3Sopenharmony_ci    rc = g_wlanObj->SendActionFrame(g_wlanObj, ifName, freq, frameData, 0);
706094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
707094332d3Sopenharmony_ci    rc = g_wlanObj->SendActionFrame(g_wlanObj, ifName, freq, frameData, frameDataLen);
708094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
709094332d3Sopenharmony_ci}
710094332d3Sopenharmony_ci
711094332d3Sopenharmony_ci/**
712094332d3Sopenharmony_ci * @tc.name: RegisterActionFrameReceiverTest_029
713094332d3Sopenharmony_ci * @tc.desc: Wifi hdi reset mac address function test
714094332d3Sopenharmony_ci * @tc.type: FUNC
715094332d3Sopenharmony_ci * @tc.require:
716094332d3Sopenharmony_ci */
717094332d3Sopenharmony_ciHWTEST_F(HdfWifiDirectTest, RegisterActionFrameReceiverTest_029, TestSize.Level1)
718094332d3Sopenharmony_ci{
719094332d3Sopenharmony_ci    int32_t rc;
720094332d3Sopenharmony_ci    uint8_t match [ETH_ADDR_LEN] = {0x12, 0x34, 0x56, 0x78, 0xab, 0xcd};
721094332d3Sopenharmony_ci    uint32_t matchLen = DEFAULT_COMBO_SIZE;
722094332d3Sopenharmony_ci    const char *ifName = "wlan0";
723094332d3Sopenharmony_ci
724094332d3Sopenharmony_ci    rc = g_wlanObj->RegisterActionFrameReceiver(g_wlanObj, nullptr, match, matchLen);
725094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
726094332d3Sopenharmony_ci    rc = g_wlanObj->RegisterActionFrameReceiver(g_wlanObj, ifName, nullptr, matchLen);
727094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
728094332d3Sopenharmony_ci    rc = g_wlanObj->RegisterActionFrameReceiver(g_wlanObj, ifName, match, 0);
729094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
730094332d3Sopenharmony_ci    rc = g_wlanObj->RegisterActionFrameReceiver(g_wlanObj, ifName, match, matchLen);
731094332d3Sopenharmony_ci    ASSERT_EQ(rc, HDF_FAILURE);
732094332d3Sopenharmony_ci}
733094332d3Sopenharmony_ci};
734