Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 36defb37 authored by Ahmed ElArabawy's avatar Ahmed ElArabawy
Browse files

Wifi: Fix VTS tests

This commit fixes VTS tests resulting from upgrading APIs and stopping
support for old APIs.

Bug: 144926452
Test: atest VtsHalWifiV1_0TargetTest
Test: atest VtsHalWifiV1_3TargetTest
Change-Id: I73140be1dfb969da24c802e658e97d4040837243
parent 5a3e81c7
Loading
Loading
Loading
Loading
+7 −3
Original line number Original line Diff line number Diff line
@@ -543,9 +543,13 @@ TEST_P(WifiChipHidlTest, CreateRttController) {


    const auto& status_and_rtt_controller =
    const auto& status_and_rtt_controller =
        HIDL_INVOKE(wifi_chip_, createRttController, iface);
        HIDL_INVOKE(wifi_chip_, createRttController, iface);
    EXPECT_EQ(WifiStatusCode::SUCCESS, status_and_rtt_controller.first.code);
    if (status_and_rtt_controller.first.code !=
        WifiStatusCode::ERROR_NOT_SUPPORTED) {
        EXPECT_EQ(WifiStatusCode::SUCCESS,
                  status_and_rtt_controller.first.code);
        EXPECT_NE(nullptr, status_and_rtt_controller.second.get());
        EXPECT_NE(nullptr, status_and_rtt_controller.second.get());
    }
    }
}


INSTANTIATE_TEST_SUITE_P(
INSTANTIATE_TEST_SUITE_P(
    PerInstance, WifiChipHidlTest,
    PerInstance, WifiChipHidlTest,
+0 −17
Original line number Original line Diff line number Diff line
@@ -209,23 +209,6 @@ sp<IWifiStaIface> getWifiStaIface(const std::string& instance_name) {
    return status_and_iface.second;
    return status_and_iface.second;
}
}


sp<IWifiRttController> getWifiRttController(const std::string& instance_name) {
    sp<IWifiChip> wifi_chip = getWifiChip(instance_name);
    if (!wifi_chip.get()) {
        return nullptr;
    }
    sp<IWifiStaIface> wifi_sta_iface = getWifiStaIface(instance_name);
    if (!wifi_sta_iface.get()) {
        return nullptr;
    }
    const auto& status_and_controller =
        HIDL_INVOKE(wifi_chip, createRttController, wifi_sta_iface);
    if (status_and_controller.first.code != WifiStatusCode::SUCCESS) {
        return nullptr;
    }
    return status_and_controller.second;
}

bool configureChipToSupportIfaceType(const sp<IWifiChip>& wifi_chip,
bool configureChipToSupportIfaceType(const sp<IWifiChip>& wifi_chip,
                                     IfaceType type,
                                     IfaceType type,
                                     ChipModeId* configured_mode_id) {
                                     ChipModeId* configured_mode_id) {
+0 −2
Original line number Original line Diff line number Diff line
@@ -44,8 +44,6 @@ android::sp<android::hardware::wifi::V1_0::IWifiP2pIface> getWifiP2pIface(
    const std::string& instance_name = "");
    const std::string& instance_name = "");
android::sp<android::hardware::wifi::V1_0::IWifiStaIface> getWifiStaIface(
android::sp<android::hardware::wifi::V1_0::IWifiStaIface> getWifiStaIface(
    const std::string& instance_name = "");
    const std::string& instance_name = "");
android::sp<android::hardware::wifi::V1_0::IWifiRttController>
getWifiRttController(const std::string& instance_name = "");
// Configure the chip in a mode to support the creation of the provided
// Configure the chip in a mode to support the creation of the provided
// iface type.
// iface type.
bool configureChipToSupportIfaceType(
bool configureChipToSupportIfaceType(
+21 −2
Original line number Original line Diff line number Diff line
@@ -22,11 +22,15 @@
#include <hidl/GtestPrinter.h>
#include <hidl/GtestPrinter.h>
#include <hidl/ServiceManagement.h>
#include <hidl/ServiceManagement.h>


#include "wifi_hidl_call_util.h"
#include "wifi_hidl_test_utils.h"
#include "wifi_hidl_test_utils.h"


using ::android::sp;
using ::android::sp;
using ::android::hardware::wifi::V1_0::IWifi;
using ::android::hardware::wifi::V1_0::IWifi;
using ::android::hardware::wifi::V1_0::IWifiChip;
using ::android::hardware::wifi::V1_0::IWifiRttController;
using ::android::hardware::wifi::V1_0::IWifiRttController;
using ::android::hardware::wifi::V1_0::IWifiStaIface;
using ::android::hardware::wifi::V1_0::WifiStatusCode;


/**
/**
 * Fixture to use for all RTT controller HIDL interface tests.
 * Fixture to use for all RTT controller HIDL interface tests.
@@ -48,7 +52,22 @@ class WifiRttControllerHidlTest : public ::testing::TestWithParam<std::string> {
 */
 */
TEST_P(WifiRttControllerHidlTest, Create) {
TEST_P(WifiRttControllerHidlTest, Create) {
    stopWifi(GetInstanceName());
    stopWifi(GetInstanceName());
    EXPECT_NE(nullptr, getWifiRttController(GetInstanceName()).get());

    const std::string& instance_name = GetInstanceName();

    sp<IWifiChip> wifi_chip = getWifiChip(instance_name);
    EXPECT_NE(nullptr, wifi_chip.get());

    sp<IWifiStaIface> wifi_sta_iface = getWifiStaIface(instance_name);
    EXPECT_NE(nullptr, wifi_sta_iface.get());

    const auto& status_and_controller =
        HIDL_INVOKE(wifi_chip, createRttController, wifi_sta_iface);
    if (status_and_controller.first.code !=
        WifiStatusCode::ERROR_NOT_SUPPORTED) {
        EXPECT_EQ(WifiStatusCode::SUCCESS, status_and_controller.first.code);
        EXPECT_NE(nullptr, status_and_controller.second.get());
    }
}
}


INSTANTIATE_TEST_SUITE_P(
INSTANTIATE_TEST_SUITE_P(
+1 −1
Original line number Original line Diff line number Diff line
@@ -992,7 +992,7 @@ WifiStatus WifiChip::removeStaIfaceInternal(const std::string& ifname) {
std::pair<WifiStatus, sp<V1_0::IWifiRttController>>
std::pair<WifiStatus, sp<V1_0::IWifiRttController>>
WifiChip::createRttControllerInternal(const sp<IWifiIface>& /*bound_iface*/) {
WifiChip::createRttControllerInternal(const sp<IWifiIface>& /*bound_iface*/) {
    LOG(ERROR) << "createRttController is not supported on this HAL";
    LOG(ERROR) << "createRttController is not supported on this HAL";
    return {createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE), {}};
    return {createWifiStatus(WifiStatusCode::ERROR_NOT_SUPPORTED), {}};
}
}


std::pair<WifiStatus, std::vector<WifiDebugRingBufferStatus>>
std::pair<WifiStatus, std::vector<WifiDebugRingBufferStatus>>