1 /*
2 * Copyright (c) 2021-2022 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 <osal_mem.h>
17 #include "hdf_base.h"
18 #include "hdf_sbuf.h"
19 #include "wifi_hal.h"
20 #include "wifi_hal_ap_feature.h"
21 #include "wifi_hal_base_feature.h"
22 #include "wifi_hal_sta_feature.h"
23 #include "securec.h"
24
25 using namespace testing::ext;
26
27 namespace HalTest {
28 struct IWiFi *g_wifi = nullptr;
29 class WifiHalTest : public testing::Test {
30 public:
31 static void SetUpTestCase();
32 static void TearDownTestCase();
33 void SetUp();
34 void TearDown();
35 };
36
SetUpTestCase()37 void WifiHalTest::SetUpTestCase()
38 {
39 int ret;
40
41 ret = WifiConstruct(&g_wifi);
42 ASSERT_EQ(HDF_SUCCESS, ret);
43 }
44
TearDownTestCase()45 void WifiHalTest::TearDownTestCase()
46 {
47 int ret;
48
49 ret = WifiDestruct(&g_wifi);
50 ASSERT_EQ(HDF_SUCCESS, ret);
51 }
52
SetUp()53 void WifiHalTest::SetUp() {}
54
TearDown()55 void WifiHalTest::TearDown() {}
56
57 /**
58 * @tc.name: WifiHalStartAndStop001
59 * @tc.desc: Wifi hal start and stop g_wifi test
60 * @tc.type: FUNC
61 */
62 HWTEST_F(WifiHalTest, SUB_WLAN_HDI_StartAndStop_0001, Function | MediumTest | Level1)
63 {
64 int ret1, ret2;
65 ret1 = g_wifi->start(nullptr);
66 ASSERT_EQ(HDF_ERR_INVALID_PARAM, ret1);
67 ret1 = g_wifi->start(g_wifi);
68 ASSERT_EQ(HDF_SUCCESS, ret1);
69 ret2 = g_wifi->stop(nullptr);
70 ASSERT_EQ(HDF_ERR_INVALID_PARAM, ret2);
71 ret2 = g_wifi->stop(g_wifi);
72 ASSERT_EQ(HDF_SUCCESS, ret2);
73 }
74
75 /**
76 * @tc.name: WifiHalStart001
77 * @tc.desc: Wifi hal start g_wifi test
78 * @tc.type: FUNC
79 */
80 HWTEST_F(WifiHalTest, SUB_WLAN_HDI_Start_0001, Function | MediumTest | Level1)
81 {
82 int ret;
83 ret = g_wifi->start(nullptr);
84 ASSERT_NE(HDF_SUCCESS, ret);
85 }
86
87 /**
88 * @tc.name: WifiHalStop001
89 * @tc.desc: Wifi hal stop g_wifi test
90 * @tc.type: FUNC
91 */
92 HWTEST_F(WifiHalTest, SUB_WLAN_HDI_Stop_0001, Function | MediumTest | Level1)
93 {
94 int ret;
95 ret = g_wifi->stop(nullptr);
96 ASSERT_NE(HDF_SUCCESS, ret);
97 }
98 };