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