1/* 2 * Copyright (c) 2024 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 <hdf_log.h> 18#include "../../../chip/hdi_service/wifi.h" 19 20using namespace testing::ext; 21using namespace OHOS::HDI::Wlan::Chip::V1_0; 22 23namespace WifiTest { 24class WifiTest : public testing::Test { 25public: 26 static void SetUpTestCase() {} 27 static void TearDownTestCase() {} 28 void SetUp() 29 { 30 wifiTest = std::make_shared<Wifi>(); 31 } 32 void TearDown() 33 { 34 wifiTest.reset(); 35 } 36 37public: 38 std::shared_ptr<Wifi> wifiTest; 39}; 40 41/** 42 * @tc.name: IsInitTest 43 * @tc.desc: IsInit 44 * @tc.type: FUNC 45 * @tc.require: 46 */ 47HWTEST_F(WifiTest, IsInitTest, TestSize.Level1) 48{ 49 HDF_LOGI("IsInitTest started"); 50 if (wifiTest == nullptr) { 51 HDF_LOGE("wifiTest is null"); 52 return; 53 } 54 bool inited = true; 55 wifiTest->IsInit(inited); 56 EXPECT_FALSE(inited); 57 wifiTest->Init(); 58 wifiTest->IsInit(inited); 59 EXPECT_TRUE(inited); 60} 61 62/** 63 * @tc.name: GetAvailableChipsTest 64 * @tc.desc: GetAvailableChips 65 * @tc.type: FUNC 66 * @tc.require: 67 */ 68HWTEST_F(WifiTest, GetAvailableChipsTest, TestSize.Level1) 69{ 70 HDF_LOGI("GetAvailableChipsTest started"); 71 if (wifiTest == nullptr) { 72 HDF_LOGE("wifiTest is null"); 73 return; 74 } 75 std::vector<uint32_t> chipIds; 76 EXPECT_TRUE(wifiTest->GetAvailableChips(chipIds) == HDF_SUCCESS); 77} 78 79/** 80 * @tc.name: IsInitTest 81 * @tc.desc: IsInit 82 * @tc.type: FUNC 83 * @tc.require: 84 */ 85HWTEST_F(WifiTest, ReleaseTest, TestSize.Level1) 86{ 87 HDF_LOGI("ReleaseTest started"); 88 if (wifiTest == nullptr) { 89 HDF_LOGE("wifiTest is null"); 90 return; 91 } 92 EXPECT_TRUE(wifiTest->Release() == HDF_SUCCESS); 93} 94}