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