• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 #include <gtest/gtest.h>
16 #include <servmgr_hdi.h>
17 #include "v1_2/iwlan_interface.h"
18 #include "wlan_callback_impl.h"
19 #include "securec.h"
20 #include "wlan_hdi_types.h"
21 
22 #define HDF_LOG_TAG service_manager_test
23 using namespace testing::ext;
24 
25 namespace HdiDirectTest {
26 const int32_t DEFAULT_COMBO_SIZE = 6;
27 const int32_t WLAN_MAX_NUM_STA_WITH_AP = 4;
28 const int32_t WLAN_FREQ_MAX_NUM = 35;
29 const int32_t WLAN_TX_POWER = 160;
30 const char *WLAN_SERVICE_NAME = "wlan_interface_service";
31 
32 class HdfWifiDirectTest : public testing::Test {
33 public:
34     static void SetUpTestCase();
35     static void TearDownTestCase();
36     void SetUp();
37     void TearDown();
38 };
39 
40 static struct IWlanInterface *g_wlanObj = nullptr;
41 struct IWlanCallback *g_wlanCallbackObj = nullptr;
SetUpTestCase()42 void HdfWifiDirectTest::SetUpTestCase()
43 {
44     g_wlanObj = IWlanInterfaceGetInstance(WLAN_SERVICE_NAME, true);
45     g_wlanCallbackObj = WlanCallbackServiceGet();
46     ASSERT_TRUE(g_wlanObj != nullptr);
47     ASSERT_TRUE(g_wlanCallbackObj != nullptr);
48 }
49 
TearDownTestCase()50 void HdfWifiDirectTest::TearDownTestCase()
51 {
52     IWlanInterfaceReleaseInstance(WLAN_SERVICE_NAME, g_wlanObj, true);
53     WlanCallbackServiceRelease(g_wlanCallbackObj);
54 }
55 
SetUp()56 void HdfWifiDirectTest::SetUp()
57 {
58 }
59 
TearDown()60 void HdfWifiDirectTest::TearDown()
61 {
62 }
63 
64 /**
65  * @tc.name: GetSupportFeatureTest_001
66  * @tc.desc: Wifi hdi get support feature function test
67  * @tc.type: FUNC
68  * @tc.require:
69  */
70 HWTEST_F(HdfWifiDirectTest, GetSupportFeatureTest_001, TestSize.Level1)
71 {
72     uint8_t supType[PROTOCOL_80211_IFTYPE_NUM + 1] = {0};
73     uint32_t supTypeLenInvalid = 6;
74 
75     int32_t rc = g_wlanObj->GetSupportFeature(g_wlanObj, nullptr, &supTypeLenInvalid);
76     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
77     rc = g_wlanObj->GetSupportFeature(g_wlanObj, supType, nullptr);
78     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
79     rc = g_wlanObj->GetSupportFeature(g_wlanObj, supType, &supTypeLenInvalid);
80     ASSERT_EQ(rc, HDF_FAILURE);
81 }
82 
83 /**
84  * @tc.name: GetSupportComboTest_002
85  * @tc.desc: Wifi hdi get support combo function test
86  * @tc.type: FUNC
87  * @tc.require:
88  */
89 HWTEST_F(HdfWifiDirectTest, GetSupportComboTest_002, TestSize.Level1)
90 {
91     uint64_t combo[DEFAULT_COMBO_SIZE] = {0};
92 
93     int32_t rc = g_wlanObj->GetSupportCombo(g_wlanObj, nullptr);
94     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
95     rc = g_wlanObj->GetSupportCombo(g_wlanObj, combo);
96     ASSERT_EQ(rc, HDF_FAILURE);
97 }
98 
99 /**
100  * @tc.name: CreateFeatureTest_003
101  * @tc.desc: Wifi hdi create feature function test
102  * @tc.type: FUNC
103  * @tc.require:
104  */
105 HWTEST_F(HdfWifiDirectTest, CreateFeatureTest_003, TestSize.Level1)
106 {
107     struct HdfFeatureInfo ifeature;
108     const int32_t wlanType = PROTOCOL_80211_IFTYPE_AP;
109 
110     (void)memset_s(&ifeature, sizeof(struct HdfFeatureInfo), 0, sizeof(struct HdfFeatureInfo));
111     int32_t rc = g_wlanObj->CreateFeature(g_wlanObj, wlanType, nullptr);
112     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
113     rc = g_wlanObj->CreateFeature(g_wlanObj, wlanType, &ifeature);
114     ASSERT_EQ(rc, HDF_FAILURE);
115 }
116 
117 /**
118  * @tc.name: DestroyFeatureTest_004
119  * @tc.desc: Wifi hdi destroy feature function test
120  * @tc.type: FUNC
121  * @tc.require:
122  */
123 HWTEST_F(HdfWifiDirectTest, DestroyFeatureTest_004, TestSize.Level1)
124 {
125     struct HdfFeatureInfo ifeature;
126     string ifName = "wlan0";
127 
128     (void)memset_s(&ifeature, sizeof(struct HdfFeatureInfo), 0, sizeof(struct HdfFeatureInfo));
129     int32_t rc = g_wlanObj->DestroyFeature(g_wlanObj, nullptr);
130     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
131     ifeature.ifName = nullptr;
132     rc = g_wlanObj->DestroyFeature(g_wlanObj, &ifeature);
133     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
134     ifeature.ifName = const_cast<char*>(ifName.c_str());
135     rc = g_wlanObj->DestroyFeature(g_wlanObj, &ifeature);
136     ASSERT_EQ(rc, HDF_FAILURE);
137 }
138 
139 /**
140  * @tc.name: GetAssociatedStasTest_005
141  * @tc.desc: Wifi hdi get associated stas function test
142  * @tc.type: FUNC
143  * @tc.require:
144  */
145 HWTEST_F(HdfWifiDirectTest, GetAssociatedStasTest_005, TestSize.Level1)
146 {
147     struct HdfFeatureInfo ifeature;
148     struct HdfStaInfo staInfo[WLAN_MAX_NUM_STA_WITH_AP] = {{0}};
149     uint32_t staInfoLen = WLAN_MAX_NUM_STA_WITH_AP;
150     uint32_t num = 0;
151     string ifName = "wlan0";
152 
153     (void)memset_s(&ifeature, sizeof(struct HdfFeatureInfo), 0, sizeof(struct HdfFeatureInfo));
154     int32_t rc = g_wlanObj->GetAssociatedStas(g_wlanObj, nullptr, staInfo, &staInfoLen, &num);
155     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
156     ifeature.ifName = nullptr;
157     rc = g_wlanObj->GetAssociatedStas(g_wlanObj, &ifeature, staInfo, &staInfoLen, &num);
158     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
159     ifeature.ifName = const_cast<char*>(ifName.c_str());
160     rc = g_wlanObj->GetAssociatedStas(g_wlanObj, &ifeature, nullptr, &staInfoLen, &num);
161     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
162     rc = g_wlanObj->GetAssociatedStas(g_wlanObj, &ifeature, staInfo, nullptr, &num);
163     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
164     rc = g_wlanObj->GetAssociatedStas(g_wlanObj, &ifeature, staInfo, &staInfoLen, nullptr);
165     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
166     rc = g_wlanObj->GetAssociatedStas(g_wlanObj, &ifeature, staInfo, &staInfoLen, &num);
167     ASSERT_EQ(rc, HDF_FAILURE);
168 }
169 
170 /**
171  * @tc.name: GetChipIdTest_006
172  * @tc.desc: Wifi hdi get chip id function test
173  * @tc.type: FUNC
174  * @tc.require:
175  */
176 HWTEST_F(HdfWifiDirectTest, GetChipIdTest_006, TestSize.Level1)
177 {
178     struct HdfFeatureInfo ifeature;
179     uint8_t chipId = 0;
180     string ifName = "wlan0";
181 
182     (void)memset_s(&ifeature, sizeof(struct HdfFeatureInfo), 0, sizeof(struct HdfFeatureInfo));
183     int32_t rc = g_wlanObj->GetChipId(g_wlanObj, nullptr, &chipId);
184     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
185     ifeature.ifName = nullptr;
186     rc = g_wlanObj->GetChipId(g_wlanObj, &ifeature, &chipId);
187     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
188     ifeature.ifName = const_cast<char*>(ifName.c_str());
189     rc = g_wlanObj->GetChipId(g_wlanObj, &ifeature, nullptr);
190     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
191     rc = g_wlanObj->GetChipId(g_wlanObj, &ifeature, &chipId);
192     ASSERT_EQ(rc, HDF_FAILURE);
193 }
194 
195 /**
196  * @tc.name: GetDeviceMacAddressTest_007
197  * @tc.desc: Wifi hdi get device mac addr function test on STA feature
198  * @tc.type: FUNC
199  * @tc.require:
200  */
201 HWTEST_F(HdfWifiDirectTest, GetDeviceMacAddressTest_007, TestSize.Level1)
202 {
203     struct HdfFeatureInfo ifeature;
204     uint8_t mac[ETH_ADDR_LEN] = {0};
205     uint32_t macLen = ETH_ADDR_LEN;
206     string ifName = "wlan0";
207 
208     (void)memset_s(&ifeature, sizeof(struct HdfFeatureInfo), 0, sizeof(struct HdfFeatureInfo));
209     int32_t rc = g_wlanObj->GetDeviceMacAddress(g_wlanObj, nullptr, mac, &macLen, ETH_ADDR_LEN);
210     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
211     ifeature.ifName = nullptr;
212     rc = g_wlanObj->GetDeviceMacAddress(g_wlanObj, &ifeature, mac, &macLen, ETH_ADDR_LEN);
213     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
214     ifeature.ifName = const_cast<char*>(ifName.c_str());
215     rc = g_wlanObj->GetDeviceMacAddress(g_wlanObj, &ifeature, nullptr, &macLen, ETH_ADDR_LEN);
216     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
217     rc = g_wlanObj->GetDeviceMacAddress(g_wlanObj, &ifeature, mac, nullptr, ETH_ADDR_LEN);
218     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
219     rc = g_wlanObj->GetDeviceMacAddress(g_wlanObj, &ifeature, mac, &macLen, ETH_ADDR_LEN);
220     ASSERT_EQ(rc, HDF_FAILURE);
221 }
222 
223 /**
224  * @tc.name: GetFeatureByIfNameTest_008
225  * @tc.desc: Wifi hdi get feature by ifname function test
226  * @tc.type: FUNC
227  * @tc.require: AR000H603L
228  */
229 HWTEST_F(HdfWifiDirectTest, GetFeatureByIfNameTest_008, TestSize.Level1)
230 {
231     struct HdfFeatureInfo ifeature;
232     const char *ifName = "wlan0";
233 
234     (void)memset_s(&ifeature, sizeof(struct HdfFeatureInfo), 0, sizeof(struct HdfFeatureInfo));
235     int32_t rc = g_wlanObj->GetFeatureByIfName(g_wlanObj, nullptr, &ifeature);
236     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
237     rc = g_wlanObj->GetFeatureByIfName(g_wlanObj, ifName, nullptr);
238     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
239     rc = g_wlanObj->GetFeatureByIfName(g_wlanObj, ifName, &ifeature);
240     ASSERT_EQ(rc, HDF_FAILURE);
241 }
242 
243 /**
244  * @tc.name: GetFeatureTypeTest_009
245  * @tc.desc: Wifi hdi get feature type function test on STA feature
246  * @tc.type: FUNC
247  * @tc.require:
248  */
249 HWTEST_F(HdfWifiDirectTest, GetFeatureTypeTest_009, TestSize.Level1)
250 {
251     struct HdfFeatureInfo ifeature;
252     int32_t featureType;
253 
254     (void)memset_s(&ifeature, sizeof(struct HdfFeatureInfo), 0, sizeof(struct HdfFeatureInfo));
255     int32_t rc = g_wlanObj->GetFeatureType(g_wlanObj, nullptr, &featureType);
256     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
257     rc = g_wlanObj->GetFeatureType(g_wlanObj, &ifeature, nullptr);
258     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
259     rc = g_wlanObj->GetFeatureType(g_wlanObj, &ifeature, &featureType);
260     ASSERT_EQ(rc, HDF_FAILURE);
261 }
262 
263 /**
264  * @tc.name: GetFreqsWithBandTest_010
265  * @tc.desc: Wifi hdi get freqs function test on STA feature
266  * @tc.type: FUNC
267  * @tc.require:
268  */
269 HWTEST_F(HdfWifiDirectTest, GetFreqsWithBandTest_010, TestSize.Level1)
270 {
271     struct HdfFeatureInfo ifeature;
272     struct HdfWifiInfo wifiInfo;
273     int32_t freq[WLAN_FREQ_MAX_NUM] = {0};
274     uint32_t freqLen = WLAN_FREQ_MAX_NUM;
275     wifiInfo.band = IEEE80211_BAND_2GHZ;
276     wifiInfo.size = WLAN_FREQ_MAX_NUM;
277     string ifName = "wlan0";
278 
279     (void)memset_s(&ifeature, sizeof(struct HdfFeatureInfo), 0, sizeof(struct HdfFeatureInfo));
280     int32_t rc = g_wlanObj->GetFreqsWithBand(g_wlanObj, nullptr, &wifiInfo, freq, &freqLen);
281     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
282     ifeature.ifName = nullptr;
283     rc = g_wlanObj->GetFreqsWithBand(g_wlanObj, &ifeature, &wifiInfo, freq, &freqLen);
284     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
285     ifeature.ifName = const_cast<char*>(ifName.c_str());
286     rc = g_wlanObj->GetFreqsWithBand(g_wlanObj, &ifeature, nullptr, freq, &freqLen);
287     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
288     rc = g_wlanObj->GetFreqsWithBand(g_wlanObj, &ifeature, &wifiInfo, nullptr, &freqLen);
289     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
290     rc = g_wlanObj->GetFreqsWithBand(g_wlanObj, &ifeature, &wifiInfo, freq, nullptr);
291     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
292     rc = g_wlanObj->GetFreqsWithBand(g_wlanObj, &ifeature, &wifiInfo, freq, &freqLen);
293     ASSERT_EQ(rc, HDF_FAILURE);
294 }
295 
296 /**
297  * @tc.name: GetChipIdTest_011
298  * @tc.desc: Wifi hdi get chip id function test on STA feature
299  * @tc.type: FUNC
300  * @tc.require:
301  */
302 HWTEST_F(HdfWifiDirectTest, GetChipIdTest_011, TestSize.Level1)
303 {
304     uint8_t chipId = 0;
305     uint32_t num = 0;
306     char ifNames[IFNAMSIZ] = {0};
307 
308     int32_t rc = g_wlanObj->GetIfNamesByChipId(g_wlanObj, chipId, nullptr, IFNAMSIZ, &num);
309     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
310     rc = g_wlanObj->GetIfNamesByChipId(g_wlanObj, chipId, ifNames, IFNAMSIZ, nullptr);
311     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
312     rc = g_wlanObj->GetIfNamesByChipId(g_wlanObj, chipId, ifNames, IFNAMSIZ, &num);
313     ASSERT_EQ(rc, HDF_FAILURE);
314 }
315 
316 /**
317  * @tc.name: GetNetworkIfaceNameTest_012
318  * @tc.desc: Wifi hdi get network interface name function test on STA feature
319  * @tc.type: FUNC
320  * @tc.require:
321  */
322 HWTEST_F(HdfWifiDirectTest, GetNetworkIfaceNameTest_012, TestSize.Level1)
323 {
324     struct HdfFeatureInfo ifeature;
325     char ifNames[IFNAMSIZ] = {0};
326     string ifName = "wlan0";
327 
328     (void)memset_s(&ifeature, sizeof(struct HdfFeatureInfo), 0, sizeof(struct HdfFeatureInfo));
329     int32_t rc = g_wlanObj->GetNetworkIfaceName(g_wlanObj, nullptr, ifNames, IFNAMSIZ);
330     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
331     ifeature.ifName = nullptr;
332     rc = g_wlanObj->GetNetworkIfaceName(g_wlanObj, &ifeature, ifNames, IFNAMSIZ);
333     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
334     ifeature.ifName = const_cast<char*>(ifName.c_str());
335     rc = g_wlanObj->GetNetworkIfaceName(g_wlanObj, &ifeature, nullptr, IFNAMSIZ);
336     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
337     rc = g_wlanObj->GetNetworkIfaceName(g_wlanObj, &ifeature, ifNames, IFNAMSIZ);
338     ASSERT_EQ(rc, HDF_FAILURE);
339 }
340 
341 /**
342  * @tc.name: RegisterEventCallbackTest_013
343  * @tc.desc: Wifi hdi register event call back function test
344  * @tc.type: FUNC
345  * @tc.require:
346  */
347 HWTEST_F(HdfWifiDirectTest, RegisterEventCallbackTest_013, TestSize.Level1)
348 {
349     const char *ifName = "wlan0";
350 
351     int32_t rc = g_wlanObj->RegisterEventCallback(g_wlanObj, nullptr, ifName);
352     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
353     rc = g_wlanObj->RegisterEventCallback(g_wlanObj, g_wlanCallbackObj, nullptr);
354     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
355     rc = g_wlanObj->RegisterEventCallback(g_wlanObj, g_wlanCallbackObj, ifName);
356     ASSERT_EQ(rc, HDF_FAILURE);
357 }
358 
359 /**
360  * @tc.name: ResetDriverTest_014
361  * @tc.desc: Wifi hdi reset driver function test
362  * @tc.type: FUNC
363  * @tc.require:
364  */
365 HWTEST_F(HdfWifiDirectTest, ResetDriverTest_014, TestSize.Level1)
366 {
367     const char *ifName = "wlan0";
368     uint8_t chipId = 0;
369 
370     int32_t rc = g_wlanObj->ResetDriver(g_wlanObj, chipId, nullptr);
371     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
372     rc = g_wlanObj->ResetDriver(g_wlanObj, chipId, ifName);
373     ASSERT_EQ(rc, HDF_FAILURE);
374 }
375 
376 /**
377  * @tc.name: StartScanTest_015
378  * @tc.desc: Wifi hdi start scan function test
379  * @tc.type: FUNC
380  * @tc.require:
381  */
382 HWTEST_F(HdfWifiDirectTest, StartScanTest_015, TestSize.Level1)
383 {
384     struct HdfFeatureInfo ifeature;
385     struct HdfWifiScan scan = {0};
386     string ifName = "wlan0";
387 
388     (void)memset_s(&ifeature, sizeof(struct HdfFeatureInfo), 0, sizeof(struct HdfFeatureInfo));
389     int32_t rc = g_wlanObj->StartScan(g_wlanObj, nullptr, &scan);
390     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
391     ifeature.ifName = nullptr;
392     rc = g_wlanObj->StartScan(g_wlanObj, &ifeature, &scan);
393     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
394     ifeature.ifName = const_cast<char*>(ifName.c_str());
395     rc = g_wlanObj->StartScan(g_wlanObj, &ifeature, nullptr);
396     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
397     rc = g_wlanObj->StartScan(g_wlanObj, &ifeature, &scan);
398     ASSERT_EQ(rc, HDF_FAILURE);
399 }
400 
401 /**
402  * @tc.name: UnregisterEventCallbackTest_016
403  * @tc.desc: Wifi hdi unreister event call back function test
404  * @tc.type: FUNC
405  * @tc.require:
406  */
407 HWTEST_F(HdfWifiDirectTest, UnregisterEventCallbackTest_016, TestSize.Level1)
408 {
409     const char *ifName = "wlan0";
410 
411     int32_t rc = g_wlanObj->UnregisterEventCallback(g_wlanObj, nullptr, ifName);
412     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
413     rc = g_wlanObj->UnregisterEventCallback(g_wlanObj, g_wlanCallbackObj, nullptr);
414     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
415     rc = g_wlanObj->UnregisterEventCallback(g_wlanObj, g_wlanCallbackObj, ifName);
416     ASSERT_EQ(rc, HDF_FAILURE);
417 }
418 
419 /**
420  * @tc.name: SetCountryCodeTest_017
421  * @tc.desc: Wifi hdi set country code function test
422  * @tc.type: FUNC
423  * @tc.require:
424  */
425 HWTEST_F(HdfWifiDirectTest, SetCountryCodeTest_017, TestSize.Level1)
426 {
427     const char *code = "CN";
428     struct HdfFeatureInfo ifeature;
429     const char *codeDigital = "99";
430     uint32_t size = 2;
431     string ifName = "wlan0";
432 
433     (void)memset_s(&ifeature, sizeof(struct HdfFeatureInfo), 0, sizeof(struct HdfFeatureInfo));
434     int32_t rc = g_wlanObj->SetCountryCode(g_wlanObj, nullptr, codeDigital, size);
435     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
436     ifeature.ifName = nullptr;
437     rc = g_wlanObj->SetCountryCode(g_wlanObj, &ifeature, code, size);
438     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
439     ifeature.ifName = const_cast<char*>(ifName.c_str());
440     rc = g_wlanObj->SetCountryCode(g_wlanObj, &ifeature, nullptr, size);
441     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
442     rc = g_wlanObj->SetCountryCode(g_wlanObj, &ifeature, code, size);
443     ASSERT_EQ(rc, HDF_FAILURE);
444 }
445 
446 /**
447  * @tc.name: SetMacAddressTest_018
448  * @tc.desc: Wifi hdi set mac addr function test on STA feature
449  * @tc.type: FUNC
450  * @tc.require:
451  */
452 HWTEST_F(HdfWifiDirectTest, SetMacAddressTest_018, TestSize.Level1)
453 {
454     uint8_t mac[ETH_ADDR_LEN] = {0x12, 0x34, 0x56, 0x78, 0xab, 0xcd};
455     struct HdfFeatureInfo ifeature;
456     uint32_t macLen = ETH_ADDR_LEN;
457     string ifName = "wlan0";
458 
459     (void)memset_s(&ifeature, sizeof(struct HdfFeatureInfo), 0, sizeof(struct HdfFeatureInfo));
460     int32_t rc = g_wlanObj->SetMacAddress(g_wlanObj, nullptr, mac, macLen);
461     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
462     ifeature.ifName = nullptr;
463     rc = g_wlanObj->SetMacAddress(g_wlanObj, &ifeature, mac, macLen);
464     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
465     ifeature.ifName = const_cast<char*>(ifName.c_str());
466     rc = g_wlanObj->SetMacAddress(g_wlanObj, &ifeature, nullptr, macLen);
467     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
468     rc = g_wlanObj->SetMacAddress(g_wlanObj, &ifeature, mac, macLen);
469     ASSERT_EQ(rc, HDF_FAILURE);
470 }
471 
472 /**
473  * @tc.name: SetScanningMacAddressTest_019
474  * @tc.desc: Wifi hdi set scanning mac addr function test
475  * @tc.type: FUNC
476  * @tc.require:
477  */
478 HWTEST_F(HdfWifiDirectTest, SetScanningMacAddressTest_019, TestSize.Level1)
479 {
480     struct HdfFeatureInfo ifeature;
481     uint8_t scanMac[ETH_ADDR_LEN] = {0x12, 0x34, 0x56, 0x78, 0xab, 0xcd};
482     uint32_t macLen = ETH_ADDR_LEN;
483     string ifName = "wlan0";
484 
485     (void)memset_s(&ifeature, sizeof(struct HdfFeatureInfo), 0, sizeof(struct HdfFeatureInfo));
486     int32_t rc = g_wlanObj->SetScanningMacAddress(g_wlanObj, nullptr, scanMac, macLen);
487     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
488     ifeature.ifName = nullptr;
489     rc = g_wlanObj->SetScanningMacAddress(g_wlanObj, &ifeature, scanMac, macLen);
490     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
491     ifeature.ifName = const_cast<char*>(ifName.c_str());
492     rc = g_wlanObj->SetScanningMacAddress(g_wlanObj, &ifeature, nullptr, macLen);
493     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
494     rc = g_wlanObj->SetScanningMacAddress(g_wlanObj, &ifeature, scanMac, macLen);
495     ASSERT_EQ(rc, HDF_FAILURE);
496 }
497 
498 /**
499  * @tc.name: SetTxPowerTest_020
500  * @tc.desc: Wifi hdi set tx power function test on STA feature
501  * @tc.type: FUNC
502  * @tc.require:
503  */
504 HWTEST_F(HdfWifiDirectTest, SetTxPowerTest_020, TestSize.Level1)
505 {
506     struct HdfFeatureInfo ifeature;
507     int32_t power = WLAN_TX_POWER;
508     string ifName = "wlan0";
509 
510     (void)memset_s(&ifeature, sizeof(struct HdfFeatureInfo), 0, sizeof(struct HdfFeatureInfo));
511     int32_t rc = g_wlanObj->SetTxPower(g_wlanObj, nullptr, power);
512     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
513     ifeature.ifName = nullptr;
514     rc = g_wlanObj->SetTxPower(g_wlanObj, &ifeature, power);
515     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
516     ifeature.ifName = const_cast<char*>(ifName.c_str());
517     rc = g_wlanObj->SetTxPower(g_wlanObj, &ifeature, power);
518     ASSERT_EQ(rc, HDF_FAILURE);
519 }
520 
521 /**
522  * @tc.name: GetNetdevInfoTest_021
523  * @tc.desc: Wifi hdi get netdev info function test
524  * @tc.type: FUNC
525  * @tc.require:
526  */
527 HWTEST_F(HdfWifiDirectTest, GetNetdevInfoTest_021, TestSize.Level1)
528 {
529     int32_t rc;
530     struct HdfNetDeviceInfoResult netDeviceInfoResult;
531 
532     (void)memset_s(
533         &netDeviceInfoResult, sizeof(struct HdfNetDeviceInfoResult), 0, sizeof(struct HdfNetDeviceInfoResult));
534     rc = g_wlanObj->GetNetDevInfo(g_wlanObj, (struct HdfNetDeviceInfoResult *)&netDeviceInfoResult);
535     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
536     rc = g_wlanObj->GetNetDevInfo(g_wlanObj, nullptr);
537     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
538 }
539 
540 /**
541  * @tc.name: GetPowerModeTest_022
542  * @tc.desc: Wifi hdi get power mode function test
543  * @tc.type: FUNC
544  * @tc.require:
545  */
546 HWTEST_F(HdfWifiDirectTest, GetPowerModeTest_022, TestSize.Level1)
547 {
548     struct HdfFeatureInfo ifeature;
549     uint8_t mode = 0;
550     string ifName = "wlan0";
551 
552     (void)memset_s(&ifeature, sizeof(struct HdfFeatureInfo), 0, sizeof(struct HdfFeatureInfo));
553     int32_t rc = g_wlanObj->GetPowerMode(g_wlanObj, nullptr, &mode);
554     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
555     ifeature.ifName = nullptr;
556     rc = g_wlanObj->GetPowerMode(g_wlanObj, &ifeature, &mode);
557     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
558     ifeature.ifName = const_cast<char*>(ifName.c_str());
559     rc = g_wlanObj->GetPowerMode(g_wlanObj, &ifeature, nullptr);
560     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
561     rc = g_wlanObj->GetPowerMode(g_wlanObj, &ifeature, &mode);
562     ASSERT_EQ(rc, HDF_FAILURE);
563 }
564 
565 /**
566  * @tc.name: SetPowerModeTest_023
567  * @tc.desc: Wifi hdi set power mode function test
568  * @tc.type: FUNC
569  * @tc.require:
570  */
571 HWTEST_F(HdfWifiDirectTest, SetPowerModeTest_023, TestSize.Level1)
572 {
573     struct HdfFeatureInfo ifeature;
574     uint8_t mode = WIFI_POWER_MODE_SLEEPING;
575     string ifName = "wlan0";
576 
577     (void)memset_s(&ifeature, sizeof(struct HdfFeatureInfo), 0, sizeof(struct HdfFeatureInfo));
578     int32_t rc = g_wlanObj->SetPowerMode(g_wlanObj, nullptr, mode);
579     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
580     ifeature.ifName = nullptr;
581     rc = g_wlanObj->SetPowerMode(g_wlanObj, &ifeature, mode);
582     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
583     ifeature.ifName = const_cast<char*>(ifName.c_str());
584     rc = g_wlanObj->SetPowerMode(g_wlanObj, &ifeature, mode);
585     ASSERT_EQ(rc, HDF_FAILURE);
586 }
587 
588 /**
589  * @tc.name: SetProjectionScreenParam_024
590  * @tc.desc: Wifi hdi set paramters to optimize projectino screen function test
591  * @tc.type: FUNC
592  * @tc.require:
593  */
594 HWTEST_F(HdfWifiDirectTest, SetProjectionScreenParam_024, TestSize.Level1)
595 {
596     const char *ifName = "wlan0";
597     int32_t rc;
598     struct ProjectionScreenCmdParam param;
599 
600     (void)memset_s(&param, sizeof(struct ProjectionScreenCmdParam), 0, sizeof(struct ProjectionScreenCmdParam));
601     rc = g_wlanObj->SetProjectionScreenParam(g_wlanObj, nullptr, &param);
602     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
603     rc = g_wlanObj->SetProjectionScreenParam(g_wlanObj, ifName, nullptr);
604     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
605     rc = g_wlanObj->SetProjectionScreenParam(g_wlanObj, ifName, &param);
606     ASSERT_EQ(rc, HDF_FAILURE);
607 }
608 
609 /**
610  * @tc.name: GetStaInfo_025
611  * @tc.desc: Wifi hdi get station information function test
612  * @tc.type: FUNC
613  * @tc.require:
614  */
615 HWTEST_F(HdfWifiDirectTest, GetStaInfo_025, TestSize.Level1)
616 {
617     const char *ifName = "wlan0";
618     int32_t rc;
619     struct WifiStationInfo info;
620     uint8_t mac[ETH_ADDR_LEN] = {0};
621 
622     (void)memset_s(&info, sizeof(struct WifiStationInfo), 0, sizeof(struct WifiStationInfo));
623     rc = g_wlanObj->GetStaInfo(g_wlanObj, nullptr, &info, mac, ETH_ADDR_LEN);
624     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
625     rc = g_wlanObj->GetStaInfo(g_wlanObj, ifName, nullptr, mac, ETH_ADDR_LEN);
626     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
627     rc = g_wlanObj->GetStaInfo(g_wlanObj, ifName, &info, nullptr, ETH_ADDR_LEN);
628     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
629     rc = g_wlanObj->GetStaInfo(g_wlanObj, ifName, &info, mac, ETH_ADDR_LEN);
630     ASSERT_EQ(rc, HDF_FAILURE);
631 }
632 };
633