mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 21:37:44 +00:00
Merge "VTS testcases for HAL API setSimSlotMapping"
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
#define WAIT_TIMEOUT_PERIOD 75
|
||||
|
||||
sim::CardStatus cardStatus = {};
|
||||
config::SimSlotStatus slotStatus = {};
|
||||
int serial = 0;
|
||||
int count_ = 0;
|
||||
|
||||
@@ -204,3 +205,22 @@ void RadioServiceTest::updateSimCardStatus() {
|
||||
EXPECT_EQ(serial, radioSimRsp->rspInfo.serial);
|
||||
EXPECT_EQ(RadioError::NONE, radioSimRsp->rspInfo.error);
|
||||
}
|
||||
|
||||
void RadioServiceTest::updateSimSlotStatus() {
|
||||
// Update SimSlotStatus from RadioConfig
|
||||
std::shared_ptr<RadioConfigResponse> radioConfigRsp =
|
||||
ndk::SharedRefBase::make<RadioConfigResponse>(*this);
|
||||
std::shared_ptr<RadioConfigIndication> radioConfigInd =
|
||||
ndk::SharedRefBase::make<RadioConfigIndication>(*this);
|
||||
radio_config->setResponseFunctions(radioConfigRsp, radioConfigInd);
|
||||
serial = GetRandomSerialNumber();
|
||||
radio_config->getSimSlotsStatus(serial);
|
||||
EXPECT_EQ(std::cv_status::no_timeout, wait());
|
||||
EXPECT_EQ(RadioResponseType::SOLICITED, radioConfigRsp->rspInfo.type);
|
||||
EXPECT_EQ(serial, radioConfigRsp->rspInfo.serial);
|
||||
EXPECT_EQ(RadioError::NONE, radioConfigRsp->rspInfo.error);
|
||||
// assuming only 1 slot
|
||||
for (const SimSlotStatus& slotStatusResponse : radioConfigRsp->simSlotStatus) {
|
||||
slotStatus = slotStatusResponse;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <aidl/Vintf.h>
|
||||
#include <aidl/android/hardware/radio/RadioError.h>
|
||||
#include <aidl/android/hardware/radio/config/IRadioConfig.h>
|
||||
#include <aidl/android/hardware/radio/config/SimSlotStatus.h>
|
||||
#include <aidl/android/hardware/radio/network/RegState.h>
|
||||
#include <aidl/android/hardware/radio/sim/CardStatus.h>
|
||||
#include <aidl/android/hardware/radio/sim/IRadioSim.h>
|
||||
@@ -27,10 +28,12 @@
|
||||
#include <vector>
|
||||
|
||||
using namespace aidl::android::hardware::radio;
|
||||
using aidl::android::hardware::radio::config::SimSlotStatus;
|
||||
using aidl::android::hardware::radio::network::RegState;
|
||||
using aidl::android::hardware::radio::sim::CardStatus;
|
||||
|
||||
extern CardStatus cardStatus;
|
||||
extern SimSlotStatus slotStatus;
|
||||
extern int serial;
|
||||
extern int count_;
|
||||
|
||||
@@ -141,4 +144,7 @@ class RadioServiceTest {
|
||||
|
||||
/* Update SIM card status */
|
||||
void updateSimCardStatus();
|
||||
|
||||
/* Update SIM slot status */
|
||||
void updateSimSlotStatus();
|
||||
};
|
||||
|
||||
@@ -19,8 +19,9 @@
|
||||
RadioConfigResponse::RadioConfigResponse(RadioServiceTest& parent) : parent_config(parent) {}
|
||||
|
||||
ndk::ScopedAStatus RadioConfigResponse::getSimSlotsStatusResponse(
|
||||
const RadioResponseInfo& info, const std::vector<SimSlotStatus>& /* slotStatus */) {
|
||||
const RadioResponseInfo& info, const std::vector<SimSlotStatus>& slotStatus) {
|
||||
rspInfo = info;
|
||||
simSlotStatus = slotStatus;
|
||||
parent_config.notify(info.serial);
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
@@ -39,6 +39,19 @@ void RadioConfigTest::SetUp() {
|
||||
radio_config->setResponseFunctions(radioRsp_config, radioInd_config);
|
||||
}
|
||||
|
||||
void RadioConfigTest::updateSimSlotStatus() {
|
||||
serial = GetRandomSerialNumber();
|
||||
radio_config->getSimSlotsStatus(serial);
|
||||
EXPECT_EQ(std::cv_status::no_timeout, wait());
|
||||
EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_config->rspInfo.type);
|
||||
EXPECT_EQ(serial, radioRsp_config->rspInfo.serial);
|
||||
EXPECT_EQ(RadioError::NONE, radioRsp_config->rspInfo.error);
|
||||
// assuming only 1 slot
|
||||
for (const SimSlotStatus& slotStatusResponse : radioRsp_config->simSlotStatus) {
|
||||
slotStatus = slotStatusResponse;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Test IRadioConfig.getHalDeviceCapabilities() for the response returned.
|
||||
*/
|
||||
@@ -148,3 +161,46 @@ TEST_P(RadioConfigTest, setPreferredDataModem_invalidArgument) {
|
||||
{RadioError::INVALID_ARGUMENTS, RadioError::RADIO_NOT_AVAILABLE,
|
||||
RadioError::INTERNAL_ERR}));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test IRadioConfig.setSimSlotsMapping() for the response returned.
|
||||
*/
|
||||
TEST_P(RadioConfigTest, setSimSlotsMapping) {
|
||||
serial = GetRandomSerialNumber();
|
||||
SlotPortMapping slotPortMapping;
|
||||
slotPortMapping.physicalSlotId = 0;
|
||||
slotPortMapping.portId = 0;
|
||||
std::vector<SlotPortMapping> slotPortMappingList = {slotPortMapping};
|
||||
ndk::ScopedAStatus res = radio_config->setSimSlotsMapping(serial, slotPortMappingList);
|
||||
ASSERT_OK(res);
|
||||
EXPECT_EQ(std::cv_status::no_timeout, wait());
|
||||
EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_config->rspInfo.type);
|
||||
EXPECT_EQ(serial, radioRsp_config->rspInfo.serial);
|
||||
ALOGI("setSimSlotsMapping, rspInfo.error = %s\n",
|
||||
toString(radioRsp_config->rspInfo.error).c_str());
|
||||
ASSERT_TRUE(CheckAnyOfErrors(radioRsp_config->rspInfo.error, {RadioError::NONE}));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test IRadioConfig.getSimSlotStatus() for the response returned.
|
||||
*/
|
||||
|
||||
TEST_P(RadioConfigTest, checkPortInfoExistsAndPortActive) {
|
||||
serial = GetRandomSerialNumber();
|
||||
ndk::ScopedAStatus res = radio_config->getSimSlotsStatus(serial);
|
||||
ASSERT_OK(res);
|
||||
ALOGI("getSimSlotsStatus, rspInfo.error = %s\n",
|
||||
toString(radioRsp_config->rspInfo.error).c_str());
|
||||
EXPECT_EQ(std::cv_status::no_timeout, wait());
|
||||
EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_config->rspInfo.type);
|
||||
EXPECT_EQ(serial, radioRsp_config->rspInfo.serial);
|
||||
if (radioRsp_config->rspInfo.error == RadioError::NONE) {
|
||||
// check if cardState is present, portInfo size should be more than 0
|
||||
for (const SimSlotStatus& slotStatusResponse : radioRsp_config->simSlotStatus) {
|
||||
if (slotStatusResponse.cardState == CardStatus::STATE_PRESENT) {
|
||||
ASSERT_TRUE(slotStatusResponse.portInfo.size() > 0);
|
||||
ASSERT_TRUE(slotStatusResponse.portInfo[0].portActive);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ class RadioConfigResponse : public BnRadioConfigResponse {
|
||||
RadioResponseInfo rspInfo;
|
||||
PhoneCapability phoneCap;
|
||||
bool modemReducedFeatureSet1;
|
||||
std::vector<SimSlotStatus> simSlotStatus;
|
||||
|
||||
virtual ndk::ScopedAStatus getSimSlotsStatusResponse(
|
||||
const RadioResponseInfo& info, const std::vector<SimSlotStatus>& slotStatus) override;
|
||||
@@ -77,6 +78,8 @@ class RadioConfigTest : public ::testing::TestWithParam<std::string>, public Rad
|
||||
public:
|
||||
virtual void SetUp() override;
|
||||
ndk::ScopedAStatus updateSimCardStatus();
|
||||
/* Override updateSimSlotStatus in RadioServiceTest to not call setResponseFunctions */
|
||||
void updateSimSlotStatus();
|
||||
|
||||
/* radio config service handle in RadioServiceTest */
|
||||
/* radio config response handle */
|
||||
|
||||
@@ -108,7 +108,13 @@ TEST_P(RadioSimTest, setSimCardPower) {
|
||||
// have CardStatus::STATE_PRESENT after turning the power back on
|
||||
if (radioRsp_sim->rspInfo.error == RadioError::NONE) {
|
||||
updateSimCardStatus();
|
||||
updateSimSlotStatus();
|
||||
EXPECT_EQ(CardStatus::STATE_PRESENT, cardStatus.cardState);
|
||||
EXPECT_EQ(CardStatus::STATE_PRESENT, slotStatus.cardState);
|
||||
if (CardStatus::STATE_PRESENT == slotStatus.cardState) {
|
||||
ASSERT_TRUE(slotStatus.portInfo[0].portActive);
|
||||
EXPECT_EQ(0, cardStatus.slotMap.portId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user