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 #include <gtest/gtest.h> 16 #include <gmock/gmock.h> 17 #include <cstddef> 18 #include <cstdint> 19 #include "securec.h" 20 #include "inner_api/wifi_msg.h" 21 #include "inner_api/wifi_scan.h" 22 #include "wifi_logger.h" 23 24 using ::testing::_; 25 using ::testing::AtLeast; 26 using ::testing::DoAll; 27 using ::testing::Eq; 28 using ::testing::Ref; 29 using ::testing::Return; 30 using ::testing::SetArgReferee; 31 using ::testing::StrEq; 32 using ::testing::TypedEq; 33 using ::testing::ext::TestSize; 34 DEFINE_WIFILOG_LABEL("WifiInnerScanTest"); 35 36 namespace OHOS { 37 namespace Wifi { 38 static std::shared_ptr<WifiScan> devicePtr = WifiScan::GetInstance(WIFI_SCAN_ABILITY_ID); 39 40 class WifiInnerScanTest : public testing::Test { 41 public: SetUpTestCase()42 static void SetUpTestCase() {} TearDownTestCase()43 static void TearDownTestCase() {} SetUp()44 virtual void SetUp() {} TearDown()45 virtual void TearDown() {} 46 }; 47 48 HWTEST_F(WifiInnerScanTest, SetScanControlInfoTest, TestSize.Level1) 49 { 50 WIFI_LOGE("SetScanControlInfoTest enter!"); 51 EXPECT_TRUE(devicePtr != nullptr); 52 ScanControlInfo info; 53 ErrCode result = devicePtr->SetScanControlInfo(info); 54 WIFI_LOGE("SetScanControlInfoTest result(0x%{public}x)", result); 55 EXPECT_GE(result, WIFI_OPT_SUCCESS); 56 } 57 58 HWTEST_F(WifiInnerScanTest, GetSupportedFeaturesTest, TestSize.Level1) 59 { 60 WIFI_LOGE("GetSupportedFeaturesTest enter!"); 61 EXPECT_TRUE(devicePtr != nullptr); 62 long features; 63 ErrCode result = devicePtr->GetSupportedFeatures(features); 64 WIFI_LOGE("GetSupportedFeaturesTest result(0x%{public}x)", result); 65 EXPECT_GE(result, WIFI_OPT_SUCCESS); 66 } 67 68 HWTEST_F(WifiInnerScanTest, SetScanOnlyAvailableTest, TestSize.Level1) 69 { 70 WIFI_LOGE("SetScanOnlyAvailableTest enter!"); 71 EXPECT_TRUE(devicePtr != nullptr); 72 ErrCode result = devicePtr->SetScanOnlyAvailable(true); 73 WIFI_LOGE("SetScanOnlyAvailableTest result(0x%{public}x)", result); 74 EXPECT_GE(result, WIFI_OPT_SUCCESS); 75 } 76 77 HWTEST_F(WifiInnerScanTest, GetScanOnlyAvailableTest, TestSize.Level1) 78 { 79 WIFI_LOGE("GetScanOnlyAvailableTest enter!"); 80 EXPECT_TRUE(devicePtr != nullptr); 81 bool bScanOnlyAvailable = false; 82 ErrCode result = devicePtr->GetScanOnlyAvailable(bScanOnlyAvailable); 83 WIFI_LOGE("GetScanOnlyAvailableTest result(0x%{public}x)", result); 84 EXPECT_GE(result, WIFI_OPT_SUCCESS); 85 } 86 } // namespace Wifi 87 } // namespace OHOS