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
16 #include <securec.h>
17 #include "gtest/gtest.h"
18
19 #include "softbus_adapter_wlan_extend.h"
20 #include "lnn_async_callback_utils.h"
21 #include "securec.h"
22 #include "softbus_adapter_mem.h"
23 #include "softbus_def.h"
24 #include "softbus_errcode.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 static struct IWlanInterface *g_wlanObj = NULL;
31 static WlanChannelInfoCb *g_wlanChannelInfoCb = NULL;
32
33 namespace OHOS {
34 using namespace testing::ext;
35
36 class AdapterWlanExtendTest : public testing::Test {
37 public:
38 static void SetUpTestCase();
39 static void TearDownTestCase();
40 void SetUp();
41 void TearDown();
42 };
43
SetUpTestCase()44 void AdapterWlanExtendTest::SetUpTestCase()
45 {
46 }
47
TearDownTestCase()48 void AdapterWlanExtendTest::TearDownTestCase()
49 {
50 }
51
SetUp()52 void AdapterWlanExtendTest::SetUp()
53 {
54 }
55
TearDown()56 void AdapterWlanExtendTest::TearDown()
57 {
58 }
59
60 /*
61 * @tc.name: Wlan_Extend_Test_001
62 * @tc.desc: apply SoftBusRegWlanChannelInfoCb test
63 * @tc.type: FUNC
64 * @tc.require:
65 */
66 HWTEST_F(AdapterWlanExtendTest, Wlan_Extend_Test_001, TestSize.Level0)
67 {
68 g_wlanChannelInfoCb = NULL;
69 WlanChannelInfoCb *g_wlanChannelInfoCbInit = new WlanChannelInfoCb();
70 int32_t laneReqId = 0;
71
72 laneReqId = SoftBusRegWlanChannelInfoCb(g_wlanChannelInfoCb);
73 EXPECT_TRUE(laneReqId == SOFTBUS_INVALID_PARAM);
74 laneReqId = SoftBusRegWlanChannelInfoCb(g_wlanChannelInfoCbInit);
75 delete g_wlanChannelInfoCbInit;
76 EXPECT_TRUE(laneReqId == SOFTBUS_OK);
77 }
78
79 /*
80 * @tc.name: Wlan_Extend_Test_002
81 * @tc.desc: apply SoftBusRequestWlanChannelInfo test
82 * @tc.type: FUNC
83 * @tc.require:
84 */
85 HWTEST_F(AdapterWlanExtendTest, Wlan_Extend_Test_002, TestSize.Level0)
86 {
87 int32_t *channelId = nullptr;
88 int32_t value = 1;
89 uint32_t num = 0;
90 int32_t laneReqId = 0;
91
92 laneReqId = SoftBusRequestWlanChannelInfo(channelId, num);
93 EXPECT_TRUE(laneReqId == SOFTBUS_INVALID_PARAM);
94 channelId = &value;
95 laneReqId = SoftBusRequestWlanChannelInfo(channelId, num);
96 EXPECT_TRUE(laneReqId == SOFTBUS_INVALID_PARAM);
97 num = 1;
98 g_wlanObj = NULL;
99 laneReqId = SoftBusRequestWlanChannelInfo(channelId, num);
100 EXPECT_TRUE(laneReqId == SOFTBUS_OK);
101 }
102
103 } // namespace OHOS
104