1 /* 2 * Copyright (C) 2016, The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 #include <gtest/gtest.h> 17 18 #include <android-base/logging.h> 19 #include "offload_hal_test_utils.h" 20 21 namespace android { 22 namespace hardware { 23 namespace wifi { 24 namespace offload { 25 namespace V1_0 { 26 namespace implementation { 27 28 using namespace offload_hal_test_constants; 29 30 class OffloadUtilsTest : public ::testing::Test { 31 protected: 32 virtual void SetUp() { 33 } 34 35 void TearDown() override { 36 } 37 }; 38 39 TEST_F(OffloadUtilsTest, ConvertScanResultToHidlTest) { 40 std::vector<ScanResult> hidlScanResultsTest; 41 std::vector<wifi_offload::ScanResult> chreScanResultsTest; 42 offload_hal_test_utils::createChreScanResultsForTest(&chreScanResultsTest); 43 EXPECT_TRUE(offload_utils::ToHidlScanResults(chreScanResultsTest, &hidlScanResultsTest)); 44 EXPECT_TRUE( 45 offload_hal_test_utils::validateScanResult(hidlScanResultsTest, chreScanResultsTest)); 46 } 47 48 TEST_F(OffloadUtilsTest, ConvertScanStatsToHidlTest) { 49 ScanStats hidlScanStatsTest; 50 wifi_offload::ScanStats chreScanStatsTest; 51 offload_hal_test_utils::createChreScanStatsForTest(&chreScanStatsTest); 52 EXPECT_TRUE(offload_utils::ToHidlScanStats(chreScanStatsTest, &hidlScanStatsTest)); 53 EXPECT_TRUE(offload_hal_test_utils::validateScanStats(hidlScanStatsTest, chreScanStatsTest)); 54 } 55 56 TEST_F(OffloadUtilsTest, ConvertScanConfigToChreTest) { 57 wifi_offload::ScanConfig scanConfigTest; 58 wifi_offload::ScanConfig scanConfig; 59 ScanParam scanParamTest; 60 ScanFilter scanFilterTest; 61 offload_hal_test_utils::createHidlScanParamForTest(&scanParamTest); 62 offload_hal_test_utils::createHidlScanFilterForTest(&scanFilterTest); 63 offload_hal_test_utils::createChreScanConfigForTest(&scanConfig); 64 EXPECT_TRUE(offload_utils::ToChreScanConfig(scanParamTest, scanFilterTest, &scanConfigTest)); 65 EXPECT_TRUE(scanConfig == scanConfigTest); 66 } 67 68 } // namespace implementation 69 } // namespace V1_0 70 } // namespace offload 71 } // namespace wifi 72 } // namespace hardware 73 } // namespace android 74