19762338dSopenharmony_ci/*
29762338dSopenharmony_ci * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
39762338dSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
49762338dSopenharmony_ci * you may not use this file except in compliance with the License.
59762338dSopenharmony_ci * You may obtain a copy of the License at
69762338dSopenharmony_ci *
79762338dSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0
89762338dSopenharmony_ci *
99762338dSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
109762338dSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
119762338dSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
129762338dSopenharmony_ci * See the License for the specific language governing permissions and
139762338dSopenharmony_ci * limitations under the License.
149762338dSopenharmony_ci */
159762338dSopenharmony_ci#include <gtest/gtest.h>
169762338dSopenharmony_ci#include <osal_mem.h>
179762338dSopenharmony_ci#include "hdf_base.h"
189762338dSopenharmony_ci#include "hdf_sbuf.h"
199762338dSopenharmony_ci#include "wifi_hal.h"
209762338dSopenharmony_ci#include "wifi_hal_ap_feature.h"
219762338dSopenharmony_ci#include "wifi_hal_base_feature.h"
229762338dSopenharmony_ci#include "wifi_hal_sta_feature.h"
239762338dSopenharmony_ci#include "securec.h"
249762338dSopenharmony_ci
259762338dSopenharmony_ciusing namespace testing::ext;
269762338dSopenharmony_ci
279762338dSopenharmony_cinamespace HalTest {
289762338dSopenharmony_cistruct IWiFi *g_wifi = nullptr;
299762338dSopenharmony_ciclass WifiHalTest : public testing::Test {
309762338dSopenharmony_cipublic:
319762338dSopenharmony_ci    static void SetUpTestCase();
329762338dSopenharmony_ci    static void TearDownTestCase();
339762338dSopenharmony_ci    void SetUp();
349762338dSopenharmony_ci    void TearDown();
359762338dSopenharmony_ci};
369762338dSopenharmony_ci
379762338dSopenharmony_civoid WifiHalTest::SetUpTestCase()
389762338dSopenharmony_ci{
399762338dSopenharmony_ci    int ret;
409762338dSopenharmony_ci
419762338dSopenharmony_ci    ret = WifiConstruct(&g_wifi);
429762338dSopenharmony_ci    ASSERT_EQ(HDF_SUCCESS, ret);
439762338dSopenharmony_ci}
449762338dSopenharmony_ci
459762338dSopenharmony_civoid WifiHalTest::TearDownTestCase()
469762338dSopenharmony_ci{
479762338dSopenharmony_ci    int ret;
489762338dSopenharmony_ci
499762338dSopenharmony_ci    ret = WifiDestruct(&g_wifi);
509762338dSopenharmony_ci    ASSERT_EQ(HDF_SUCCESS, ret);
519762338dSopenharmony_ci}
529762338dSopenharmony_ci
539762338dSopenharmony_civoid WifiHalTest::SetUp() {}
549762338dSopenharmony_ci
559762338dSopenharmony_civoid WifiHalTest::TearDown() {}
569762338dSopenharmony_ci
579762338dSopenharmony_ci/**
589762338dSopenharmony_ci * @tc.name: WifiHalStartAndStop001
599762338dSopenharmony_ci * @tc.desc: Wifi hal start and stop g_wifi test
609762338dSopenharmony_ci * @tc.type: FUNC
619762338dSopenharmony_ci */
629762338dSopenharmony_ciHWTEST_F(WifiHalTest, SUB_WLAN_HDI_StartAndStop_0001, Function | MediumTest | Level1)
639762338dSopenharmony_ci{
649762338dSopenharmony_ci    int ret1, ret2;
659762338dSopenharmony_ci    ret1 = g_wifi->start(nullptr);
669762338dSopenharmony_ci    ASSERT_EQ(HDF_ERR_INVALID_PARAM, ret1);
679762338dSopenharmony_ci    ret1 = g_wifi->start(g_wifi);
689762338dSopenharmony_ci    ASSERT_EQ(HDF_SUCCESS, ret1);
699762338dSopenharmony_ci    ret2 = g_wifi->stop(nullptr);
709762338dSopenharmony_ci    ASSERT_EQ(HDF_ERR_INVALID_PARAM, ret2);
719762338dSopenharmony_ci    ret2 = g_wifi->stop(g_wifi);
729762338dSopenharmony_ci    ASSERT_EQ(HDF_SUCCESS, ret2);
739762338dSopenharmony_ci}
749762338dSopenharmony_ci
759762338dSopenharmony_ci/**
769762338dSopenharmony_ci * @tc.name: WifiHalStart001
779762338dSopenharmony_ci * @tc.desc: Wifi hal start g_wifi test
789762338dSopenharmony_ci * @tc.type: FUNC
799762338dSopenharmony_ci */
809762338dSopenharmony_ciHWTEST_F(WifiHalTest, SUB_WLAN_HDI_Start_0001, Function | MediumTest | Level1)
819762338dSopenharmony_ci{
829762338dSopenharmony_ci    int ret;
839762338dSopenharmony_ci    ret = g_wifi->start(nullptr);
849762338dSopenharmony_ci    ASSERT_NE(HDF_SUCCESS, ret);
859762338dSopenharmony_ci}
869762338dSopenharmony_ci
879762338dSopenharmony_ci/**
889762338dSopenharmony_ci * @tc.name: WifiHalStop001
899762338dSopenharmony_ci * @tc.desc: Wifi hal stop g_wifi test
909762338dSopenharmony_ci * @tc.type: FUNC
919762338dSopenharmony_ci */
929762338dSopenharmony_ciHWTEST_F(WifiHalTest, SUB_WLAN_HDI_Stop_0001, Function | MediumTest | Level1)
939762338dSopenharmony_ci{
949762338dSopenharmony_ci    int ret;
959762338dSopenharmony_ci    ret = g_wifi->stop(nullptr);
969762338dSopenharmony_ci    ASSERT_NE(HDF_SUCCESS, ret);
979762338dSopenharmony_ci}
989762338dSopenharmony_ci};