• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023-2025 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 <securec.h>
18 
19 #include "lnn_async_callback_utils.h"
20 #include "securec.h"
21 #include "softbus_adapter_mem.h"
22 #include "softbus_adapter_wlan_extend.h"
23 #include "softbus_def.h"
24 #include "softbus_error_code.h"
25 
26 #define WLAN_SERVICE_NAME        "wlan_interface_service"
27 #define WLAN_IFNAME              "wlan0"
28 #define MEAS_TIME_PER_CHAN_MS    (15)
29 #define GET_MEAS_RESULT_DELAY_MS (1000)
30 
31 static struct IWlanInterface *g_wlanObj = nullptr;
32 static WlanChannelInfoCb *g_wlanChannelInfoCb = nullptr;
33 
34 namespace OHOS {
35 using namespace testing::ext;
36 
37 class AdapterWlanExtendTest : public testing::Test {
38 public:
39     static void SetUpTestCase();
40     static void TearDownTestCase();
41     void SetUp();
42     void TearDown();
43 };
44 
SetUpTestCase()45 void AdapterWlanExtendTest::SetUpTestCase() { }
46 
TearDownTestCase()47 void AdapterWlanExtendTest::TearDownTestCase() { }
48 
SetUp()49 void AdapterWlanExtendTest::SetUp() { }
50 
TearDown()51 void AdapterWlanExtendTest::TearDown() { }
52 
53 /*
54  * @tc.name: Wlan_Extend_Test_001
55  * @tc.desc: apply SoftBusRegWlanChannelInfoCb test
56  * @tc.type: FUNC
57  * @tc.require:
58  */
59 HWTEST_F(AdapterWlanExtendTest, Wlan_Extend_Test_001, TestSize.Level0)
60 {
61     g_wlanChannelInfoCb = nullptr;
62     WlanChannelInfoCb *g_wlanChannelInfoCbInit = new WlanChannelInfoCb();
63     int32_t laneReqId = 0;
64 
65     laneReqId = SoftBusRegWlanChannelInfoCb(g_wlanChannelInfoCb);
66     EXPECT_TRUE(laneReqId == SOFTBUS_INVALID_PARAM);
67     laneReqId = SoftBusRegWlanChannelInfoCb(g_wlanChannelInfoCbInit);
68     delete g_wlanChannelInfoCbInit;
69     EXPECT_TRUE(laneReqId == SOFTBUS_OK);
70 }
71 
72 /*
73  * @tc.name: Wlan_Extend_Test_002
74  * @tc.desc: apply SoftBusRequestWlanChannelInfo test
75  * @tc.type: FUNC
76  * @tc.require:
77  */
78 HWTEST_F(AdapterWlanExtendTest, Wlan_Extend_Test_002, TestSize.Level0)
79 {
80     int32_t *channelId = nullptr;
81     int32_t value = 1;
82     uint32_t num = 0;
83     int32_t laneReqId = 0;
84 
85     laneReqId = SoftBusRequestWlanChannelInfo(channelId, num);
86     EXPECT_TRUE(laneReqId == SOFTBUS_INVALID_PARAM);
87     channelId = &value;
88     laneReqId = SoftBusRequestWlanChannelInfo(channelId, num);
89     EXPECT_TRUE(laneReqId == SOFTBUS_INVALID_PARAM);
90     num = 1;
91     g_wlanObj = nullptr;
92     laneReqId = SoftBusRequestWlanChannelInfo(channelId, num);
93     EXPECT_TRUE(laneReqId == SOFTBUS_OK);
94 }
95 
96 } // namespace OHOS
97