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 "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 static struct IWlanInterface *g_wlanObj = nullptr;
31 static WlanChannelInfoCb *g_wlanChannelInfoCb = nullptr;
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
TearDownTestCase()46 void AdapterWlanExtendTest::TearDownTestCase() { }
47
SetUp()48 void AdapterWlanExtendTest::SetUp() { }
49
TearDown()50 void AdapterWlanExtendTest::TearDown() { }
51
52 /*
53 * @tc.name: Wlan_Extend_Test_001
54 * @tc.desc: apply SoftBusRegWlanChannelInfoCb test
55 * @tc.type: FUNC
56 * @tc.require:
57 */
58 HWTEST_F(AdapterWlanExtendTest, Wlan_Extend_Test_001, TestSize.Level0)
59 {
60 g_wlanChannelInfoCb = nullptr;
61 WlanChannelInfoCb *g_wlanChannelInfoCbInit = new WlanChannelInfoCb();
62 int32_t laneReqId = 0;
63
64 laneReqId = SoftBusRegWlanChannelInfoCb(g_wlanChannelInfoCb);
65 EXPECT_TRUE(laneReqId == SOFTBUS_INVALID_PARAM);
66 laneReqId = SoftBusRegWlanChannelInfoCb(g_wlanChannelInfoCbInit);
67 delete g_wlanChannelInfoCbInit;
68 EXPECT_TRUE(laneReqId == SOFTBUS_OK);
69 }
70
71 /*
72 * @tc.name: Wlan_Extend_Test_002
73 * @tc.desc: apply SoftBusRequestWlanChannelInfo test
74 * @tc.type: FUNC
75 * @tc.require:
76 */
77 HWTEST_F(AdapterWlanExtendTest, Wlan_Extend_Test_002, TestSize.Level0)
78 {
79 int32_t *channelId = nullptr;
80 int32_t value = 1;
81 uint32_t num = 0;
82 int32_t laneReqId = 0;
83
84 laneReqId = SoftBusRequestWlanChannelInfo(channelId, num);
85 EXPECT_TRUE(laneReqId == SOFTBUS_INVALID_PARAM);
86 channelId = &value;
87 laneReqId = SoftBusRequestWlanChannelInfo(channelId, num);
88 EXPECT_TRUE(laneReqId == SOFTBUS_INVALID_PARAM);
89 num = 1;
90 g_wlanObj = nullptr;
91 laneReqId = SoftBusRequestWlanChannelInfo(channelId, num);
92 EXPECT_TRUE(laneReqId == SOFTBUS_OK);
93 }
94
95 } // namespace OHOS
96