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_chip.h" 19 #include "../../../chip/hdi_service/wifi_chip_modes.h" 20 #include "../../../chip/hdi_service/iface_tool.h" 21 #include "wifi_hal_fn.h" 22 23 using namespace testing::ext; 24 using namespace OHOS::HDI::Wlan::Chip::V1_0; 25 26 namespace WifiChipModesTest { 27 class WifiChipModesTest : public testing::Test { 28 public: SetUpTestCase()29 static void SetUpTestCase() {} TearDownTestCase()30 static void TearDownTestCase() {} SetUp()31 void SetUp() 32 { 33 ifaceTool = std::make_shared<IfaceTool>(); 34 WifiHalFn fn; 35 InitWifiHalFuncTable(&fn); 36 wifiVendorHalTest = std::make_shared<WifiVendorHal>(ifaceTool, fn, true); 37 wifiChipModes = std::make_shared<WifiChipModes>(wifiVendorHalTest); 38 } TearDown()39 void TearDown() 40 { 41 wifiVendorHalTest.reset(); 42 wifiChipModes.reset(); 43 ifaceTool.reset(); 44 } 45 46 public: 47 std::shared_ptr<WifiVendorHal> wifiVendorHalTest; 48 std::shared_ptr<WifiChipModes> wifiChipModes; 49 std::shared_ptr<IfaceTool> ifaceTool; 50 }; 51 52 /** 53 * @tc.name: GetChipModesTest 54 * @tc.desc: GetChipModes 55 * @tc.type: FUNC 56 * @tc.require: 57 */ 58 HWTEST_F(WifiChipModesTest, GetChipModesTest, TestSize.Level1) 59 { 60 HDF_LOGI("GetChipModesTest started."); 61 if (wifiChipModes == nullptr) { 62 return; 63 } 64 std::vector<UsableMode> modes; 65 modes = wifiChipModes->GetChipModes(true); 66 EXPECT_TRUE(modes.size() != 0); 67 } 68 }