• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-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 
16 #include <gtest/gtest.h>
17 #include <osal_mem.h>
18 #include "wifi_driver_client.h"
19  #ifdef OHOS_ARCH_LITE
20 #include "hostapd_client.h"
21 #include "wpa_client.h"
22 #endif
23 #include "securec.h"
24 
25 using namespace testing::ext;
26 
27 namespace ClientTest {
28 const uint32_t DEFAULT_COMBO_SIZE = 10;
29 const char *WLAN_IFNAME = "wlan0";
30 const uint32_t RESET_TIME = 3;
31 class WifiClientTest : public testing::Test {
32 public:
33     static void SetUpTestCase();
34     static void TearDownTestCase();
35     void SetUp();
36     void TearDown();
37 };
38 
SetUpTestCase()39 void WifiClientTest::SetUpTestCase()
40 {
41 }
42 
TearDownTestCase()43 void WifiClientTest::TearDownTestCase()
44 {
45 }
46 
SetUp()47 void WifiClientTest::SetUp()
48 {
49     WifiDriverClientInit();
50 }
51 
TearDown()52 void WifiClientTest::TearDown()
53 {
54     WifiDriverClientDeinit();
55 }
56 
Hid2dFunCb(const uint8_t * recvMsg,uint32_t recvMsgLen)57 static int32_t Hid2dFunCb(const uint8_t *recvMsg, uint32_t recvMsgLen)
58 {
59     (void)recvMsg;
60     (void)recvMsgLen;
61     return RET_CODE_SUCCESS;
62 }
63 
Hid2dFunCb2(uint32_t event,void * data,const char * ifName)64 static int32_t Hid2dFunCb2(uint32_t event, void *data, const char *ifName)
65 {
66     (void)event;
67     (void)data;
68     (void)ifName;
69     return RET_CODE_SUCCESS;
70 }
71 
72 /**
73  * @tc.name: WifiClientSetResetDriver001
74  * @tc.desc: Wifi client reset driver function test
75  * @tc.type: FUNC
76  * @tc.require:
77  */
78 HWTEST_F(WifiClientTest, WifiClientSetResetDriver001, TestSize.Level1)
79 {
80     int32_t ret;
81     uint8_t chipId = 0;
82 
83     ret = AcquireChipId(WLAN_IFNAME, &chipId);
84     ASSERT_TRUE(chipId < MAX_WLAN_DEVICE);
85     EXPECT_EQ(RET_CODE_SUCCESS, ret);
86 
87     ret = SetResetDriver(chipId, WLAN_IFNAME);
88     EXPECT_EQ(RET_CODE_SUCCESS, ret);
89     sleep(RESET_TIME);
90 }
91 
92 /**
93  * @tc.name: WifiClientSetCountryCode001
94  * @tc.desc: Wifi client set country code function test
95  * @tc.type: FUNC
96  * @tc.require: AR000FRMJC
97  */
98 HWTEST_F(WifiClientTest, WifiClientSetCountryCode001, TestSize.Level1)
99 {
100     int32_t ret;
101     const char *code = "CN";
102     const char *codeDigital = "99";
103     const char *ifNameInvalid = "wlanTest";
104     uint32_t len = 2;
105 
106     ret = WifiSetCountryCode(ifNameInvalid, code, len);
107     EXPECT_EQ(RET_CODE_FAILURE, ret);
108     ret = WifiSetCountryCode(WLAN_IFNAME, code, len);
109     EXPECT_EQ(RET_CODE_SUCCESS, ret);
110     ret = WifiSetCountryCode(WLAN_IFNAME, codeDigital, len);
111     bool flag = (ret == HDF_SUCCESS || ret == HDF_ERR_NOT_SUPPORT);
112     ASSERT_TRUE(flag);
113 }
114 
115 /**
116  * @tc.name: WifiClientGetUsableNetworkInfo001
117  * @tc.desc: Wifi client get usable networkInfo function test
118  * @tc.type: FUNC
119  * @tc.require: AR000FRMJC
120  */
121 HWTEST_F(WifiClientTest, WifiClientGetUsableNetworkInfo001, TestSize.Level1)
122 {
123     int32_t ret;
124     struct NetworkInfoResult networkInfo;
125 
126     ret = GetUsableNetworkInfo(&networkInfo);
127     EXPECT_EQ(RET_CODE_SUCCESS, ret);
128 }
129 
130 /**
131  * @tc.name: WifiClientIsSupportCombo001
132  * @tc.desc: Wifi client is support combo function test
133  * @tc.type: FUNC
134  * @tc.require: AR000FRMJC
135  */
136 HWTEST_F(WifiClientTest, WifiClientIsSupportCombo001, TestSize.Level1)
137 {
138     int32_t ret;
139     uint8_t isSupportCombo;
140 
141     ret = IsSupportCombo(&isSupportCombo);
142     EXPECT_EQ(RET_CODE_SUCCESS, ret);
143 }
144 
145 /**
146  * @tc.name: WifiClientGetComboInfo001
147  * @tc.desc: Wifi client get combo info function test
148  * @tc.type: FUNC
149  * @tc.require: AR000FRMJC
150  */
151 HWTEST_F(WifiClientTest, WifiClientGetComboInfo001, TestSize.Level1)
152 {
153     int32_t ret;
154     uint64_t comboInfo[DEFAULT_COMBO_SIZE] = {};
155 
156     ret = GetComboInfo(comboInfo, DEFAULT_COMBO_SIZE);
157     bool flag = (ret == RET_CODE_SUCCESS || ret == RET_CODE_NOT_SUPPORT);
158     ASSERT_TRUE(flag);
159 }
160 
161 /**
162  * @tc.name: WifiClientSetMacAddr001
163  * @tc.desc: Wifi client set mac addr function test
164  * @tc.type: FUNC
165  * @tc.require: AR000FRMJC
166  */
167 HWTEST_F(WifiClientTest, WifiClientSetMacAddr001, TestSize.Level1)
168 {
169     int32_t ret;
170     const char *ifNameInvalid = "wlanTest";
171     unsigned char mac[ETH_ADDR_LEN] = {0x12, 0x34, 0x56, 0x78, 0xab, 0xcd};
172     unsigned char errorMac[ETH_ADDR_LEN] = {0x11, 0x34, 0x56, 0x78, 0xab, 0xcd};
173 
174     ret = SetMacAddr(WLAN_IFNAME, mac, ETH_ADDR_LEN);
175     bool flag = (ret == HDF_SUCCESS || ret == HDF_ERR_NOT_SUPPORT || ret == HDF_ERR_DEVICE_BUSY);
176     ASSERT_TRUE(flag);
177     ret = SetMacAddr(WLAN_IFNAME, errorMac, ETH_ADDR_LEN);
178     EXPECT_NE(RET_CODE_SUCCESS, ret);
179     ret = SetMacAddr(ifNameInvalid, mac, ETH_ADDR_LEN);
180     EXPECT_NE(RET_CODE_SUCCESS, ret);
181 }
182 
183 /**
184  * @tc.name: WifiClientGetDevMacAddr001
185  * @tc.desc: Wifi client get mac addr function test
186  * @tc.type: FUNC
187  * @tc.require: AR000FRMJC
188  */
189 HWTEST_F(WifiClientTest, WifiClientGetDevMacAddr001, TestSize.Level1)
190 {
191     int32_t ret;
192     unsigned char mac[ETH_ADDR_LEN] = {};
193     int32_t type = WIFI_IFTYPE_STATION;
194     const char *ifNameInvalid = "wlanTest";
195 
196     ret = GetDevMacAddr(WLAN_IFNAME, type, mac, ETH_ADDR_LEN);
197     EXPECT_NE(RET_CODE_FAILURE, ret);
198     ret = GetDevMacAddr(ifNameInvalid, type, mac, ETH_ADDR_LEN);
199     EXPECT_NE(RET_CODE_SUCCESS, ret);
200 }
201 
202 /**
203  * @tc.name: WifiClientGetDevMacAddr002
204  * @tc.desc: Wifi client get mac addr function test
205  * @tc.type: FUNC
206  * @tc.require: AR000H603L
207  */
208 HWTEST_F(WifiClientTest, WifiClientGetDevMacAddr002, TestSize.Level1)
209 {
210     int32_t ret;
211     unsigned char mac[ETH_ADDR_LEN] = {};
212     int32_t type = WIFI_IFTYPE_AP;
213 
214     ret = GetDevMacAddr(WLAN_IFNAME, type, mac, ETH_ADDR_LEN);
215     EXPECT_NE(RET_CODE_FAILURE, ret);
216 }
217 
218 /**
219  * @tc.name: WifiClientGetValidFreqByBand001
220  * @tc.desc: Wifi client get valid freq function test
221  * @tc.type: FUNC
222  * @tc.require: AR000FRMJC
223  */
224 HWTEST_F(WifiClientTest, WifiClientGetValidFreqByBand001, TestSize.Level1)
225 {
226     int32_t ret;
227     int32_t band = IEEE80211_BAND_2GHZ;
228     int32_t bandNotSupport = IEEE80211_NUM_BANDS;
229     struct FreqInfoResult result;
230     uint32_t size = 14;
231     uint32_t i;
232     const char *ifNameInvalid = "wlanTest";
233 
234     result.freqs = (uint32_t *)OsalMemCalloc(35 * sizeof(uint32_t));
235     if (result.freqs == NULL) {
236         printf("%s: OsalMemCalloc failed", __FUNCTION__);
237         return;
238     }
239 
240     result.txPower = (uint32_t *)OsalMemCalloc(35 * sizeof(uint32_t));
241     if (result.txPower == NULL) {
242         printf("%s: OsalMemCalloc failed", __FUNCTION__);
243         OsalMemFree(result.freqs);
244         return;
245     }
246 
247     ret = GetValidFreqByBand(WLAN_IFNAME, bandNotSupport, &result, size);
248     EXPECT_NE(RET_CODE_SUCCESS, ret);
249     ret = GetValidFreqByBand(WLAN_IFNAME, band, nullptr, size);
250     EXPECT_NE(RET_CODE_SUCCESS, ret);
251     ret = GetValidFreqByBand(ifNameInvalid, band, &result, size);
252     EXPECT_NE(RET_CODE_SUCCESS, ret);
253     ret = GetValidFreqByBand(WLAN_IFNAME, band, &result, size);
254     EXPECT_EQ(RET_CODE_SUCCESS, ret);
255     if (ret == RET_CODE_SUCCESS) {
256         printf("%s: num = %u\n", __func__, result.nums);
257         for (i = 0; i < result.nums; i++) {
258             printf("%s: freq[%d] = %d\n", __func__, i, result.freqs[i]);
259         }
260     }
261 
262     OsalMemFree(result.txPower);
263     OsalMemFree(result.freqs);
264 }
265 
266 /**
267  * @tc.name: WifiClientSetTxPower001
268  * @tc.desc: Wifi client set tx power function test
269  * @tc.type: FUNC
270  * @tc.require: AR000FRMJC
271  */
272 HWTEST_F(WifiClientTest, WifiClientSetTxPower001, TestSize.Level1)
273 {
274     int32_t ret;
275     int32_t power = 10;
276     const char *ifNameInvalid = "wlanTest";
277 
278     ret = SetTxPower(ifNameInvalid, power);
279     EXPECT_NE(RET_CODE_SUCCESS, ret);
280     ret = SetTxPower(WLAN_IFNAME, power);
281     EXPECT_EQ(RET_CODE_FAILURE, ret);
282 }
283 
284 /**
285  * @tc.name: WifiClientGetAssociatedStas001
286  * @tc.desc: Wifi client get associated status function test
287  * @tc.type: FUNC
288  * @tc.require: AR000H603L
289  */
290 HWTEST_F(WifiClientTest, WifiClientGetAssociatedStas001, TestSize.Level1)
291 {
292     int32_t ret;
293     struct AssocStaInfoResult result;
294 
295     ret = GetAssociatedStas(WLAN_IFNAME, &result);
296     EXPECT_EQ(RET_CODE_SUCCESS, ret);
297 }
298 
299 /**
300  * @tc.name: WifiClientSetScanMacAddr001
301  * @tc.desc: Wifi client set scan MAC address function test
302  * @tc.type: FUNC
303  * @tc.require: AR000H603L
304  */
305 HWTEST_F(WifiClientTest, WifiClientSetScanMacAddr001, TestSize.Level1)
306 {
307     int32_t ret;
308     const char *ifNameInvalid = "wlanTest";
309     unsigned char scanMac[ETH_ADDR_LEN] = {0x12, 0x34, 0x56, 0x78, 0xab, 0xcd};
310 
311     ret = SetScanMacAddr(ifNameInvalid, scanMac, ETH_ADDR_LEN);
312     EXPECT_EQ(RET_CODE_FAILURE, ret);
313     ret = SetScanMacAddr(WLAN_IFNAME, scanMac, ETH_ADDR_LEN);
314     bool flag = (ret == RET_CODE_SUCCESS || ret == RET_CODE_NOT_SUPPORT);
315     ASSERT_TRUE(flag);
316 }
317 
318 /**
319  * @tc.name: WifiClientAcquireChipId001
320  * @tc.desc: Wifi client get chipId function test
321  * @tc.type: FUNC
322  * @tc.require: AR000H603L
323  */
324 HWTEST_F(WifiClientTest, WifiClientAcquireChipId001, TestSize.Level1)
325 {
326     int32_t ret;
327     const char *ifNameInvalid = "wlanTest";
328     uint8_t chipId = 0;
329 
330     ret = AcquireChipId(nullptr, &chipId);
331     EXPECT_EQ(RET_CODE_INVALID_PARAM, ret);
332     ret = AcquireChipId(WLAN_IFNAME, nullptr);
333     EXPECT_EQ(RET_CODE_INVALID_PARAM, ret);
334     ret = AcquireChipId(ifNameInvalid, &chipId);
335     EXPECT_NE(RET_CODE_SUCCESS, ret);
336     ret = AcquireChipId(WLAN_IFNAME, &chipId);
337     ASSERT_TRUE(chipId < MAX_WLAN_DEVICE);
338     EXPECT_EQ(RET_CODE_SUCCESS, ret);
339 }
340 
341 /**
342  * @tc.name: WifiClientGetIfNamesByChipId001
343  * @tc.desc: Wifi client get ifName by chipId function test
344  * @tc.type: FUNC
345  * @tc.require: AR000H603L
346  */
347 HWTEST_F(WifiClientTest, WifiClientGetIfNamesByChipId001, TestSize.Level1)
348 {
349     int32_t ret;
350     uint8_t chipId = 0;
351     uint8_t chipIdInvalid = 100;
352     char *ifNames = nullptr;
353     uint32_t num = 0;
354 
355     ret = AcquireChipId(WLAN_IFNAME, &chipId);
356     ASSERT_TRUE(chipId < MAX_WLAN_DEVICE);
357     EXPECT_EQ(RET_CODE_SUCCESS, ret);
358     ret = GetIfNamesByChipId(chipIdInvalid, &ifNames, &num);
359     EXPECT_NE(RET_CODE_SUCCESS, ret);
360     ret = GetIfNamesByChipId(chipId, &ifNames, &num);
361     EXPECT_NE(ifNames, nullptr);
362     EXPECT_EQ(RET_CODE_SUCCESS, ret);
363     ret = GetIfNamesByChipId(chipId, &ifNames, nullptr);
364     EXPECT_EQ(RET_CODE_INVALID_PARAM, ret);
365     ret = GetIfNamesByChipId(chipId, nullptr, &num);
366     EXPECT_EQ(RET_CODE_INVALID_PARAM, ret);
367     free(ifNames);
368 }
369 
370 /**
371  * @tc.name: WifiClientGetNetDeviceInfo001
372  * @tc.desc: Wifi client get netDevice information function test
373  * @tc.type: FUNC
374  * @tc.require: AR000H603L
375  */
376 HWTEST_F(WifiClientTest, WifiClientGetNetDeviceInfo001, TestSize.Level1)
377 {
378     int32_t ret;
379     struct NetDeviceInfoResult netDeviceInfoResult;
380 
381     ret = GetNetDeviceInfo(&netDeviceInfoResult);
382     EXPECT_EQ(RET_CODE_SUCCESS, ret);
383 }
384 
385 /**
386  * @tc.name: WifiClientGetCurrentPowerMode001
387  * @tc.desc: Wifi client get current power mode function test
388  * @tc.type: FUNC
389  * @tc.require: AR000H603L
390  */
391 HWTEST_F(WifiClientTest, WifiClientGetCurrentPowerMode001, TestSize.Level1)
392 {
393     int32_t ret;
394     uint8_t mode = 0;
395     const char *ifNameInvalid = "wlanTest";
396 
397     ret = GetCurrentPowerMode(ifNameInvalid, &mode);
398     EXPECT_NE(RET_CODE_SUCCESS, ret);
399     ret = GetCurrentPowerMode(WLAN_IFNAME, &mode);
400     bool flag = (ret == RET_CODE_SUCCESS || ret == RET_CODE_NOT_SUPPORT);
401     ASSERT_TRUE(flag);
402 }
403 
404 /**
405  * @tc.name: WifiClientSetPowerMode001
406  * @tc.desc: Wifi client set power mode function test
407  * @tc.type: FUNC
408  * @tc.require: AR000H603L
409  */
410 HWTEST_F(WifiClientTest, WifiClientSetPowerMode001, TestSize.Level1)
411 {
412     int32_t ret;
413     const char *ifNameInvalid = "wlanTest";
414 
415     ret = SetPowerMode(ifNameInvalid, WIFI_POWER_MODE_SLEEPING);
416     EXPECT_NE(RET_CODE_SUCCESS, ret);
417     ret = SetPowerMode(WLAN_IFNAME, WIFI_POWER_MODE_SLEEPING);
418     bool flag = (ret == RET_CODE_SUCCESS || ret == RET_CODE_NOT_SUPPORT);
419     ASSERT_TRUE(flag);
420 }
421 
422 /**
423  * @tc.name: WifiClientSetPowerMode002
424  * @tc.desc: Wifi client set power mode function test
425  * @tc.type: FUNC
426  * @tc.require: AR000H603L
427  */
428 HWTEST_F(WifiClientTest, WifiClientSetPowerMode002, TestSize.Level1)
429 {
430     int32_t ret;
431 
432     ret = SetPowerMode(WLAN_IFNAME, WIFI_POWER_MODE_GENERAL);
433     bool flag = (ret == RET_CODE_SUCCESS || ret == RET_CODE_NOT_SUPPORT);
434     ASSERT_TRUE(flag);
435 }
436 
437 /**
438  * @tc.name: WifiClientSetPowerMode003
439  * @tc.desc: Wifi client set power mode function test
440  * @tc.type: FUNC
441  * @tc.require: AR000H603L
442  */
443 HWTEST_F(WifiClientTest, WifiClientSetPowerMode003, TestSize.Level1)
444 {
445     int32_t ret;
446 
447     ret = SetPowerMode(WLAN_IFNAME, WIFI_POWER_MODE_THROUGH_WALL);
448     bool flag = (ret == RET_CODE_SUCCESS || ret == RET_CODE_NOT_SUPPORT);
449     ASSERT_TRUE(flag);
450 }
451 
452 /**
453  * @tc.name: WifiClientSetPowerMode004
454  * @tc.desc: Wifi client set power mode function test
455  * @tc.type: FUNC
456  * @tc.require: AR000H603L
457  */
458 HWTEST_F(WifiClientTest, WifiClientSetPowerMode004, TestSize.Level1)
459 {
460     int32_t ret;
461 
462     ret = SetPowerMode(WLAN_IFNAME, WIFI_POWER_MODE_NUM);
463     EXPECT_NE(RET_CODE_SUCCESS, ret);
464 }
465 
466 /**
467  * @tc.name: WifiRegisterHid2dCallback001
468  * @tc.desc: Wifi register hid2d callback function test
469  * @tc.type: FUNC
470  * @tc.require:
471  */
472 HWTEST_F(WifiClientTest, WifiRegisterHid2dCallback001, TestSize.Level1)
473 {
474     int32_t ret;
475 
476     ret = WifiRegisterHid2dCallback(nullptr, WLAN_IFNAME);
477     EXPECT_EQ(RET_CODE_INVALID_PARAM, ret);
478     ret = WifiRegisterHid2dCallback(Hid2dFunCb, nullptr);
479     EXPECT_EQ(RET_CODE_INVALID_PARAM, ret);
480     ret = WifiRegisterHid2dCallback(Hid2dFunCb, WLAN_IFNAME);
481     EXPECT_EQ(RET_CODE_SUCCESS, ret);
482     WifiUnregisterHid2dCallback(nullptr, WLAN_IFNAME);
483     WifiUnregisterHid2dCallback(Hid2dFunCb, nullptr);
484 }
485 
486 /**
487  * @tc.name: WifiGetSignalPollInfo001
488  * @tc.desc: Wifi get signal poll info function test
489  * @tc.type: FUNC
490  * @tc.require:
491  */
492 HWTEST_F(WifiClientTest, WifiGetSignalPollInfo001, TestSize.Level1)
493 {
494     int32_t ret;
495     const char *ifNameInvalid = "wlanTest";
496     struct SignalResult signalResult;
497     (void)memset_s(&signalResult, sizeof(signalResult), 0, sizeof(signalResult));
498 
499     ret = WifiGetSignalPollInfo(nullptr, &signalResult);
500     EXPECT_EQ(RET_CODE_FAILURE, ret);
501     ret = WifiGetSignalPollInfo(ifNameInvalid, nullptr);
502     EXPECT_EQ(RET_CODE_FAILURE, ret);
503     ret = WifiGetSignalPollInfo(ifNameInvalid, &signalResult);
504     EXPECT_EQ(RET_CODE_FAILURE, ret);
505 }
506 
WifiEventCb(uint32_t event,void * respData,const char * ifName)507 static int32_t WifiEventCb(uint32_t event, void *respData, const char *ifName)
508 {
509     (void)event;
510     (void)respData;
511     (void)ifName;
512     return RET_CODE_SUCCESS;
513 }
514 
515 /**
516  * @tc.name: WifiRegisterEventCallback001
517  * @tc.desc: Wifi register event callback function test
518  * @tc.type: FUNC
519  * @tc.require:
520  */
521 HWTEST_F(WifiClientTest, WifiRegisterEventCallback001, TestSize.Level1)
522 {
523     int32_t ret;
524 
525     ret = WifiRegisterEventCallback(nullptr, WIFI_KERNEL_TO_HAL_CLIENT, WLAN_IFNAME);
526     EXPECT_EQ(RET_CODE_INVALID_PARAM, ret);
527     ret = WifiRegisterEventCallback(WifiEventCb, WIFI_KERNEL_TO_HAL_CLIENT, nullptr);
528     EXPECT_EQ(RET_CODE_INVALID_PARAM, ret);
529     WifiUnregisterEventCallback(nullptr, WIFI_KERNEL_TO_HAL_CLIENT, WLAN_IFNAME);
530     WifiUnregisterEventCallback(WifiEventCb, WIFI_KERNEL_TO_HAL_CLIENT, nullptr);
531 }
532 
533 /**
534  * @tc.name: WifiRegisterActionFrameReceiver001
535  * @tc.desc: Wifi register action frame function test
536  * @tc.type: FUNC
537  * @tc.require:
538  */
539 HWTEST_F(WifiClientTest, WifiRegisterActionFrameReceiver001, TestSize.Level1)
540 {
541     int32_t ret;
542     const char *ifNameInvalid = "wlanTest";
543     uint8_t mastch = 0;
544     uint32_t matchLen = RESET_TIME;
545 
546     ret = WifiRegisterActionFrameReceiver(nullptr, &mastch, matchLen);
547     EXPECT_EQ(RET_CODE_FAILURE, ret);
548     ret = WifiRegisterActionFrameReceiver(ifNameInvalid, 0, matchLen);
549     EXPECT_EQ(RET_CODE_FAILURE, ret);
550     ret = WifiRegisterActionFrameReceiver(ifNameInvalid, &mastch, 0);
551     EXPECT_EQ(RET_CODE_FAILURE, ret);
552     ret = WifiRegisterActionFrameReceiver(ifNameInvalid, &mastch, matchLen);
553     EXPECT_EQ(RET_CODE_FAILURE, ret);
554 }
555 
556 /**
557  * @tc.name: WifiSendActionFrame001
558  * @tc.desc: Wifi send action frame function test
559  * @tc.type: FUNC
560  * @tc.require:
561  */
562 HWTEST_F(WifiClientTest, WifiSendActionFrame001, TestSize.Level1)
563 {
564     int32_t ret;
565     const char *ifNameInvalid = "wlanTest";
566     uint8_t frameData = 0;
567     uint32_t freq = RESET_TIME;
568     uint32_t frameDataLen = RESET_TIME;
569 
570     ret = WifiSendActionFrame(nullptr, freq, &frameData, frameDataLen);
571     EXPECT_EQ(RET_CODE_FAILURE, ret);
572     ret = WifiSendActionFrame(ifNameInvalid, 0, &frameData, frameDataLen);
573     EXPECT_EQ(RET_CODE_FAILURE, ret);
574     ret = WifiSendActionFrame(ifNameInvalid, freq, &frameData, frameDataLen);
575     EXPECT_EQ(RET_CODE_FAILURE, ret);
576     ret = WifiSendActionFrame(ifNameInvalid, freq, &frameData, 0);
577     EXPECT_EQ(RET_CODE_FAILURE, ret);
578     ret = WifiSendActionFrame(ifNameInvalid, freq, &frameData, frameDataLen);
579     EXPECT_EQ(RET_CODE_FAILURE, ret);
580 }
581 
582 /**
583  * @tc.name: ClientGetApBandwidth001
584  * @tc.desc: client get ap bandwidth function test
585  * @tc.type: FUNC
586  * @tc.require:
587  */
588 HWTEST_F(WifiClientTest, ClientGetApBandwidth001, TestSize.Level1)
589 {
590     int32_t ret;
591     const char *ifNameInvalid = "wlanTest";
592     uint8_t bandwidth = 0;
593 
594     ret = ClientGetApBandwidth(nullptr, &bandwidth);
595     EXPECT_EQ(RET_CODE_FAILURE, ret);
596     ret = ClientGetApBandwidth(ifNameInvalid, nullptr);
597     EXPECT_EQ(RET_CODE_FAILURE, ret);
598     ret = ClientGetApBandwidth(ifNameInvalid, &bandwidth);
599     EXPECT_EQ(RET_CODE_FAILURE, ret);
600 }
601 
602 /**
603  * @tc.name: SetProjectionScreenParam001
604  * @tc.desc: set rx remain On channel test
605  * @tc.type: FUNC
606  * @tc.require:
607  */
608 HWTEST_F(WifiClientTest, SetProjectionScreenParam001, TestSize.Level1)
609 {
610     int32_t ret;
611     const char *ifNameInvalid = "wlanTest";
612     ProjectionScreenParam *param = nullptr;
613     param->cmdId = CMD_ID_RX_REMAIN_ON_CHANNEL;
614     param->buf[0] = 0;
615     param->bufLen = 40;
616     ret = SetProjectionScreenParam(ifNameInvalid, param);
617     EXPECT_EQ(RET_CODE_FAILURE, ret);
618 }
619 
620 /**
621  * @tc.name: SetProjectionScreenParam001
622  * @tc.desc: set rx remain On channel test
623  * @tc.type: FUNC
624  * @tc.require:
625  */
626 HWTEST_F(WifiClientTest, SetProjectionScreenParam002, TestSize.Level1)
627 {
628     int32_t ret;
629     const char *ifNameInvalid = "wlanTest";
630     ProjectionScreenParam *param = nullptr;
631     param->cmdId = CMD_ID_RX_REMAIN_ON_CHANNEL;
632     param->buf[0] = 0;
633     param->bufLen = 1;
634     ret = SetProjectionScreenParam(ifNameInvalid, param);
635     EXPECT_EQ(RET_CODE_FAILURE, ret);
636 }
637 /**
638  * @tc.name: WifiEapolPacketSend001
639  * @tc.desc: set rx remain On channel test
640  * @tc.type: FUNC
641  * @tc.require:
642  */
643 HWTEST_F(WifiClientTest, WifiEapolPacketSend001, TestSize.Level1)
644 {
645     int32_t ret;
646     int32_t length = 0;
647     const char *ifNameInvalid = "wlanTest";
648     uint8_t srcAddr = 0;
649     uint8_t dstAddr = 0;
650     uint8_t buf = 0;
651     ret = WifiEapolPacketSend(NULL, &srcAddr, &dstAddr, &buf, length);
652     EXPECT_EQ(RET_CODE_INVALID_PARAM, ret);
653     WifiEapolPacketSend(ifNameInvalid, &srcAddr, &dstAddr, &buf, length);
654 }
655 /**
656  * @tc.name: WifiEapolPacketReceive002
657  * @tc.desc: set rx remain On channel test
658  * @tc.type: FUNC
659  * @tc.require:
660  */
661 HWTEST_F(WifiClientTest, WifiEapolPacketReceive002, TestSize.Level1)
662 {
663     int32_t ret;
664     const char *ifNameInvalid = "wlanTest";
665     WifiRxEapol *rxEapol = NULL;
666     ret = WifiEapolPacketReceive(NULL, rxEapol);
667     EXPECT_EQ(RET_CODE_INVALID_PARAM, ret);
668     ret = WifiEapolPacketReceive(ifNameInvalid, rxEapol);
669     EXPECT_EQ(RET_CODE_INVALID_PARAM, ret);
670 }
671 /**
672  * @tc.name: WifiEapolEnable003
673  * @tc.desc: set rx remain On channel test
674  * @tc.type: FUNC
675  * @tc.require:
676  */
677 HWTEST_F(WifiClientTest, WifiEapolEnable003, TestSize.Level1)
678 {
679     int32_t ret;
680     const char *ifNameInvalid = "wlanTest";
681     ret = WifiEapolEnable(NULL);
682     EXPECT_EQ(RET_CODE_INVALID_PARAM, ret);
683     WifiEapolEnable(ifNameInvalid);
684 }
685 /**
686  * @tc.name: WifiEapolDisable004
687  * @tc.desc: set rx remain On channel test
688  * @tc.type: FUNC
689  * @tc.require:
690  */
691 HWTEST_F(WifiClientTest, WifiEapolDisable004, TestSize.Level1)
692 {
693     int32_t ret;
694     const char *ifNameInvalid = "wlanTest";
695     ret = WifiEapolDisable(NULL);
696     EXPECT_EQ(RET_CODE_INVALID_PARAM, ret);
697     WifiEapolDisable(ifNameInvalid);
698 }
699 /**
700  * @tc.name: WifiCmdSetAp005
701  * @tc.desc: set rx remain On channel test
702  * @tc.type: FUNC
703  * @tc.require:
704  */
705 HWTEST_F(WifiClientTest, WifiCmdSetAp005, TestSize.Level1)
706 {
707     int32_t ret;
708     const char *ifNameInvalid = "wlanTest";
709     WifiApSetting *apsettings = NULL;
710     ret = WifiCmdSetAp(NULL, apsettings);
711     EXPECT_EQ(RET_CODE_INVALID_PARAM, ret);
712     ret = WifiCmdSetAp(ifNameInvalid, apsettings);
713     EXPECT_EQ(RET_CODE_INVALID_PARAM, ret);
714 }
715 /**
716  * @tc.name: WifiCmdChangeBeacon006
717  * @tc.desc: set rx remain On channel test
718  * @tc.type: FUNC
719  * @tc.require:
720  */
721 HWTEST_F(WifiClientTest, WifiCmdChangeBeacon006, TestSize.Level1)
722 {
723     int32_t ret;
724     const char *ifNameInvalid = "wlanTest";
725     WifiApSetting *apsettings = NULL;
726     ret = WifiCmdChangeBeacon(NULL, apsettings);
727     EXPECT_EQ(RET_CODE_INVALID_PARAM, ret);
728     ret = WifiCmdChangeBeacon(ifNameInvalid, apsettings);
729     EXPECT_EQ(RET_CODE_INVALID_PARAM, ret);
730 }
731 /**
732  * @tc.name: WifiCmdSendMlme007
733  * @tc.desc: set rx remain On channel test
734  * @tc.type: FUNC
735  * @tc.require:
736  */
737 HWTEST_F(WifiClientTest, WifiCmdSendMlme007, TestSize.Level1)
738 {
739     int32_t ret;
740     const char *ifNameInvalid = "wlanTest";
741     WifiMlmeData *mlme = NULL;
742     ret = WifiCmdSendMlme(NULL, mlme);
743     EXPECT_EQ(RET_CODE_INVALID_PARAM, ret);
744     ret = WifiCmdSendMlme(ifNameInvalid, mlme);
745     EXPECT_EQ(RET_CODE_INVALID_PARAM, ret);
746 }
747 /**
748  * @tc.name: WifiCmdDelKey008
749  * @tc.desc: set rx remain On channel test
750  * @tc.type: FUNC
751  * @tc.require:
752  */
753 HWTEST_F(WifiClientTest, WifiCmdDelKey008, TestSize.Level1)
754 {
755     int32_t ret;
756     const char *ifNameInvalid = "wlanTest";
757     WifiKeyExt *keyExt = NULL;
758     ret = WifiCmdDelKey(NULL, keyExt);
759     EXPECT_EQ(RET_CODE_INVALID_PARAM, ret);
760     ret = WifiCmdDelKey(ifNameInvalid, keyExt);
761     EXPECT_EQ(RET_CODE_INVALID_PARAM, ret);
762 }
763 /**
764  * @tc.name: WifiCmdNewKey009
765  * @tc.desc: set rx remain On channel test
766  * @tc.type: FUNC
767  * @tc.require:
768  */
769 HWTEST_F(WifiClientTest, WifiCmdNewKey009, TestSize.Level1)
770 {
771     const char *ifNameInvalid = "wlanTest";
772     WifiKeyExt keyExt;
773     WifiCmdNewKey(ifNameInvalid, &keyExt);
774 }
775 /**
776  * @tc.name: WifiCmdSetKey0010
777  * @tc.desc: set rx remain On channel test
778  * @tc.type: FUNC
779  * @tc.require:
780  */
781 HWTEST_F(WifiClientTest, WifiCmdSetKey0010, TestSize.Level1)
782 {
783     const char *ifNameInvalid = "wlanTest";
784     WifiKeyExt keyExt;
785     WifiCmdSetKey(ifNameInvalid, &keyExt);
786 }
787 /**
788  * @tc.name: WifiCmdGetOwnMac0011
789  * @tc.desc: set rx remain On channel test
790  * @tc.type: FUNC
791  * @tc.require:
792  */
793 HWTEST_F(WifiClientTest, WifiCmdGetOwnMac0011, TestSize.Level1)
794 {
795     int32_t ret;
796     const char *ifNameInvalid = "wlanTest";
797     uint32_t len = 0;
798     ret = WifiCmdGetOwnMac(NULL, NULL, len);
799     EXPECT_EQ(RET_CODE_INVALID_PARAM, ret);
800     ret = WifiCmdGetOwnMac(ifNameInvalid, NULL, len);
801     EXPECT_EQ(RET_CODE_INVALID_PARAM, ret);
802     WifiCmdGetOwnMac(ifNameInvalid, NULL, len);
803 }
804 /**
805  * @tc.name: WifiCmdSetMode0012
806  * @tc.desc: set rx remain On channel test
807  * @tc.type: FUNC
808  * @tc.require:
809  */
810 HWTEST_F(WifiClientTest, WifiCmdSetMode0012, TestSize.Level1)
811 {
812     int32_t ret;
813     const char *ifNameInvalid = "wlanTest";
814     WifiSetMode *setMode = NULL;
815     ret = WifiCmdSetMode(NULL, setMode);
816     EXPECT_EQ(RET_CODE_INVALID_PARAM, ret);
817     ret = WifiCmdSetMode(ifNameInvalid, setMode);
818     EXPECT_EQ(RET_CODE_INVALID_PARAM, ret);
819 }
820 /**
821  * @tc.name: WifiCmdGetHwFeature0013
822  * @tc.desc: set rx remain On channel test
823  * @tc.type: FUNC
824  * @tc.require:
825  */
826 HWTEST_F(WifiClientTest, WifiCmdGetHwFeature0013, TestSize.Level1)
827 {
828     int32_t ret;
829     const char *ifNameInvalid = "wlanTest";
830     WifiHwFeatureData hwFeatureData;
831     ret = WifiCmdGetHwFeature(NULL, &hwFeatureData);
832     EXPECT_EQ(RET_CODE_INVALID_PARAM, ret);
833     WifiCmdGetHwFeature(ifNameInvalid, &hwFeatureData);
834 }
835 /**
836  * @tc.name: WifiCmdDisconnet0014
837  * @tc.desc: set rx remain On channel test
838  * @tc.type: FUNC
839  * @tc.require:
840  */
841 HWTEST_F(WifiClientTest, WifiCmdDisconnet0014, TestSize.Level1)
842 {
843     int32_t ret;
844     const char *ifNameInvalid = "wlanTest";
845     int32_t reasonCode = 0;
846     ret = WifiCmdDisconnet(NULL, reasonCode);
847     EXPECT_EQ(RET_CODE_INVALID_PARAM, ret);
848     WifiCmdDisconnet(ifNameInvalid, reasonCode);
849 }
850 /**
851  * @tc.name: WifiCmdAssoc0016
852  * @tc.desc: set rx remain On channel test
853  * @tc.type: FUNC
854  * @tc.require:
855  */
856 HWTEST_F(WifiClientTest, WifiCmdAssoc0016, TestSize.Level1)
857 {
858     int32_t ret;
859     const char *ifNameInvalid = "wlanTest";
860     WifiAssociateParams assocParams;
861     ret = WifiCmdAssoc(NULL, &assocParams);
862     EXPECT_EQ(RET_CODE_INVALID_PARAM, ret);
863     WifiCmdAssoc(ifNameInvalid, &assocParams);
864 }
865 /**
866  * @tc.name: WifiCmdSetNetdev0017
867  * @tc.desc: set rx remain On channel test
868  * @tc.type: FUNC
869  * @tc.require:
870  */
871 HWTEST_F(WifiClientTest, WifiCmdSetNetdev0017, TestSize.Level1)
872 {
873     int32_t ret;
874     const char *ifNameInvalid = "wlanTest";
875     WifiSetNewDev info;
876     ret = WifiCmdSetNetdev(NULL, &info);
877     EXPECT_EQ(RET_CODE_INVALID_PARAM, ret);
878     WifiCmdSetNetdev(ifNameInvalid, &info);
879 }
880 /**
881  * @tc.name: WifiCmdStaRemove0018
882  * @tc.desc: set rx remain On channel test
883  * @tc.type: FUNC
884  * @tc.require:
885  */
886 HWTEST_F(WifiClientTest, WifiCmdStaRemove0018, TestSize.Level1)
887 {
888     int32_t ret;
889     const char *ifNameInvalid = "wlanTest";
890     uint8_t *addr = NULL;
891     uint32_t addrLen = 0;
892     ret = WifiCmdStaRemove(NULL, addr, addrLen);
893     EXPECT_EQ(RET_CODE_INVALID_PARAM, ret);
894     WifiCmdStaRemove(ifNameInvalid, addr, addrLen);
895 }
896 /**
897  * @tc.name: WifiCmdSendAction0019
898  * @tc.desc: set rx remain On channel test
899  * @tc.type: FUNC
900  * @tc.require:
901  */
902 HWTEST_F(WifiClientTest, WifiCmdSendAction0019, TestSize.Level1)
903 {
904     int32_t ret;
905     const char *ifNameInvalid = "wlanTest";
906     WifiActionData actionData;
907     ret = WifiCmdSendAction(NULL, &actionData);
908     EXPECT_EQ(RET_CODE_INVALID_PARAM, ret);
909     WifiCmdSendAction(ifNameInvalid, &actionData);
910 }
911 /**
912  * @tc.name: WifiCmdSetClient0020
913  * @tc.desc: set rx remain On channel test
914  * @tc.type: FUNC
915  * @tc.require:
916  */
917 HWTEST_F(WifiClientTest, WifiCmdSetClient0020, TestSize.Level1)
918 {
919     uint32_t clientNum = 0;
920     WifiCmdSetClient(clientNum);
921 }
922 /**
923  * @tc.name: WifiCmdProbeReqReport0021
924  * @tc.desc: set rx remain On channel test
925  * @tc.type: FUNC
926  * @tc.require:
927  */
928 HWTEST_F(WifiClientTest, WifiCmdProbeReqReport0021, TestSize.Level1)
929 {
930     int32_t ret;
931     const char *ifNameInvalid = "wlanTest";
932     int32_t *report = NULL;
933     ret = WifiCmdProbeReqReport(NULL, report);
934     EXPECT_EQ(RET_CODE_INVALID_PARAM, ret);
935     WifiCmdProbeReqReport(ifNameInvalid, report);
936 }
937 /**
938  * @tc.name: WifiCmdRemainOnChannel0022
939  * @tc.desc: set rx remain On channel test
940  * @tc.type: FUNC
941  * @tc.require:
942  */
943 HWTEST_F(WifiClientTest, WifiCmdRemainOnChannel0022, TestSize.Level1)
944 {
945     int32_t ret;
946     const char *ifNameInvalid = "wlanTest";
947     WifiOnChannel onChannel;
948     ret = WifiCmdRemainOnChannel(NULL, &onChannel);
949     EXPECT_EQ(RET_CODE_INVALID_PARAM, ret);
950     WifiCmdRemainOnChannel(ifNameInvalid, &onChannel);
951 }
952 /**
953  * @tc.name: WifiCmdCancelRemainOnChannel0023
954  * @tc.desc: set rx remain On channel test
955  * @tc.type: FUNC
956  * @tc.require:
957  */
958 HWTEST_F(WifiClientTest, WifiCmdCancelRemainOnChannel0023, TestSize.Level1)
959 {
960     int32_t ret;
961     const char *ifNameInvalid = "wlanTest";
962     ret = WifiCmdCancelRemainOnChannel(NULL);
963     EXPECT_EQ(RET_CODE_INVALID_PARAM, ret);
964     WifiCmdCancelRemainOnChannel(ifNameInvalid);
965 }
966 /**
967  * @tc.name: WifiCmdAddIf024
968  * @tc.desc: set rx remain On channel test
969  * @tc.type: FUNC
970  * @tc.require:
971  */
972 HWTEST_F(WifiClientTest, WifiCmdAddIf024, TestSize.Level1)
973 {
974     int32_t ret;
975     const char *ifNameInvalid = "wlanTest";
976     WifiIfAdd ifAdd;
977     ret = WifiCmdAddIf(NULL, &ifAdd);
978     EXPECT_EQ(RET_CODE_INVALID_PARAM, ret);
979     WifiCmdAddIf(ifNameInvalid, &ifAdd);
980 }
981 /**
982  * @tc.name: WifiCmdRemoveIf025
983  * @tc.desc: set rx remain On channel test
984  * @tc.type: FUNC
985  * @tc.require:
986  */
987 HWTEST_F(WifiClientTest, WifiCmdRemoveIf025, TestSize.Level1)
988 {
989     int32_t ret;
990     const char *ifNameInvalid = "wlanTest";
991     WifiIfRemove ifRemove;
992     ret = WifiCmdRemoveIf(NULL, &ifRemove);
993     EXPECT_EQ(RET_CODE_INVALID_PARAM, ret);
994     WifiCmdRemoveIf(ifNameInvalid, &ifRemove);
995 }
996 /**
997  * @tc.name: WifiCmdSetApWpsP2pIe026
998  * @tc.desc: set rx remain On channel test
999  * @tc.type: FUNC
1000  * @tc.require:
1001  */
1002 HWTEST_F(WifiClientTest, WifiCmdSetApWpsP2pIe026, TestSize.Level1)
1003 {
1004     int32_t ret;
1005     const char *ifNameInvalid = "wlanTest";
1006     WifiAppIe appIe;
1007     ret = WifiCmdSetApWpsP2pIe(NULL, &appIe);
1008     EXPECT_EQ(RET_CODE_INVALID_PARAM, ret);
1009     WifiCmdSetApWpsP2pIe(ifNameInvalid, &appIe);
1010 }
1011 /**
1012  * @tc.name: WifiCmdGetDrvFlags027
1013  * @tc.desc: set rx remain On channel test
1014  * @tc.type: FUNC
1015  * @tc.require:
1016  */
1017 HWTEST_F(WifiClientTest, WifiCmdGetDrvFlags027, TestSize.Level1)
1018 {
1019     int32_t ret;
1020     const char *ifNameInvalid = "wlanTest";
1021     WifiGetDrvFlags params;
1022     ret = WifiCmdGetDrvFlags(NULL, &params);
1023     EXPECT_EQ(RET_CODE_INVALID_PARAM, ret);
1024     WifiCmdGetDrvFlags(ifNameInvalid, &params);
1025 }
1026 /**
1027  * @tc.name: WifiSetDpiMarkRule028
1028  * @tc.desc: set rx remain On channel test
1029  * @tc.type: FUNC
1030  * @tc.require:
1031  */
1032 HWTEST_F(WifiClientTest, WifiSetDpiMarkRule028, TestSize.Level1)
1033 {
1034     int32_t srcAddr = 0;
1035     int32_t dstAddr = 0;
1036     int32_t buf = 0;
1037     WifiSetDpiMarkRule(srcAddr, dstAddr, buf);
1038 }
1039 /**
1040  * @tc.name: WpaEventReport
1041  * @tc.desc: set rx remain On channel test
1042  * @tc.type: FUNC
1043  * @tc.require:
1044  */
1045 #ifdef OHOS_ARCH_LITE
1046 HWTEST_F(WifiClientTest, WpaEventReport, TestSize.Level1)
1047 {
1048     int32_t dstAddr = 0;
1049     void *data = NULL;
1050     const char *ifNameInvalid = "wlanTest";
1051     WpaEventReport(ifNameInvalid, dstAddr, data);
1052 }
1053 /**
1054  * @tc.name: WpaEventReport
1055  * @tc.desc: set rx remain On channel test
1056  * @tc.type: FUNC
1057  * @tc.require:
1058  */
1059 HWTEST_F(WifiClientTest, WpaRegisterEventCallback, TestSize.Level1)
1060 {
1061     int32_t dstAddr = 0;
1062     const char *ifNameInvalid = "wlanTest";
1063     WpaRegisterEventCallback(Hid2dFunCb2, dstAddr, ifNameInvalid);
1064 }
1065 /**
1066  * @tc.name: WpaUnregisterEventCallback
1067  * @tc.desc: set rx remain On channel test
1068  * @tc.type: FUNC
1069  * @tc.require:
1070  */
1071 HWTEST_F(WifiClientTest, WpaUnregisterEventCallback, TestSize.Level1)
1072 {
1073     int32_t dstAddr = 0;
1074     const char *ifNameInvalid = "wlanTest";
1075     WpaUnregisterEventCallback(Hid2dFunCb2, dstAddr, ifNameInvalid);
1076 }
1077 /**
1078  * @tc.name: HostapdEventReport
1079  * @tc.desc: set rx remain On channel test
1080  * @tc.type: FUNC
1081  * @tc.require:
1082  */
1083 HWTEST_F(WifiClientTest, HostapdEventReport, TestSize.Level1)
1084 {
1085     int32_t dstAddr = 0;
1086     void *data = NULL;
1087     const char *ifNameInvalid = "wlanTest";
1088     HostapdEventReport(ifNameInvalid, dstAddr, data);
1089 }
1090 /**
1091  * @tc.name: HostapdRegisterEventCallback
1092  * @tc.desc: set rx remain On channel test
1093  * @tc.type: FUNC
1094  * @tc.require:
1095  */
1096 HWTEST_F(WifiClientTest, HostapdRegisterEventCallback, TestSize.Level1)
1097 {
1098     int32_t dstAddr = 0;
1099     const char *ifNameInvalid = "wlanTest";
1100     HostapdRegisterEventCallback(Hid2dFunCb2, dstAddr, ifNameInvalid);
1101 }
1102 /**
1103  * @tc.name: HostapdUnregisterEventCallback
1104  * @tc.desc: set rx remain On channel test
1105  * @tc.type: FUNC
1106  * @tc.require:
1107  */
1108 HWTEST_F(WifiClientTest, HostapdUnregisterEventCallback, TestSize.Level1)
1109 {
1110     int32_t dstAddr = 0;
1111     const char *ifNameInvalid = "wlanTest";
1112     HostapdUnregisterEventCallback(Hid2dFunCb2, dstAddr, ifNameInvalid);
1113 }
1114 }
1115 }
1116 #endif
1117 };