Merge "VTS for icc radio hal Apis (patch 2)."

am: 8d91af1096

Change-Id: Ie36b5708dadc6f81628fad15351c747a90e066c1
This commit is contained in:
Sanket Padawe 2017-03-01 18:04:04 +00:00 committed by android-build-merger
commit 5b6e1c5bec
4 changed files with 260 additions and 40 deletions

View file

@ -20,86 +20,271 @@
* Test IRadio.getIccCardStatus() for the response returned.
*/
TEST_F(RadioHidlTest, getIccCardStatus) {
radio->getIccCardStatus(1);
EXPECT_EQ(std::cv_status::no_timeout, wait());
EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
EXPECT_EQ(1, radioRsp->rspInfo.serial);
EXPECT_EQ(radioRsp->rspInfo.error, RadioError::NONE);
EXPECT_LE(radioRsp->cardStatus.applications.size(), (unsigned int) RadioConst::CARD_MAX_APPS);
EXPECT_LT(radioRsp->cardStatus.gsmUmtsSubscriptionAppIndex, (int) RadioConst::CARD_MAX_APPS);
EXPECT_LT(radioRsp->cardStatus.cdmaSubscriptionAppIndex, (int) RadioConst::CARD_MAX_APPS);
EXPECT_LT(radioRsp->cardStatus.imsSubscriptionAppIndex, (int) RadioConst::CARD_MAX_APPS);
EXPECT_LE(cardStatus.applications.size(), (unsigned int) RadioConst::CARD_MAX_APPS);
EXPECT_LT(cardStatus.gsmUmtsSubscriptionAppIndex, (int) RadioConst::CARD_MAX_APPS);
EXPECT_LT(cardStatus.cdmaSubscriptionAppIndex, (int) RadioConst::CARD_MAX_APPS);
EXPECT_LT(cardStatus.imsSubscriptionAppIndex, (int) RadioConst::CARD_MAX_APPS);
}
/*
* Test IRadio.supplyIccPinForApp() for the response returned.
* Test IRadio.supplyIccPinForApp() for the response returned
*/
TEST_F(RadioHidlTest, supplyIccPinForApp) {
radio->supplyIccPinForApp(2, hidl_string("test1"), hidl_string());
EXPECT_EQ(std::cv_status::no_timeout, wait());
EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
EXPECT_EQ(2, radioRsp->rspInfo.serial);
int serial = 1;
EXPECT_EQ(radioRsp->rspInfo.error, RadioError::PASSWORD_INCORRECT);
// Pass wrong password and check PASSWORD_INCORRECT returned for 3GPP and 3GPP2 apps only
for (int i = 0; i < (int) cardStatus.applications.size(); i++) {
if (cardStatus.applications[i].appType == AppType::SIM
|| cardStatus.applications[i].appType == AppType::USIM
|| cardStatus.applications[i].appType == AppType::RUIM
|| cardStatus.applications[i].appType == AppType::CSIM) {
radio->supplyIccPinForApp(++serial, hidl_string("test1"),
cardStatus.applications[i].aidPtr);
EXPECT_EQ(std::cv_status::no_timeout, wait());
EXPECT_EQ(serial, radioRsp->rspInfo.serial);
EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
EXPECT_EQ(RadioError::PASSWORD_INCORRECT, radioRsp->rspInfo.error);
}
}
}
/*
* Test IRadio.supplyIccPukForApp() for the response returned.
*/
TEST_F(RadioHidlTest, supplyIccPukForApp) {
radio->supplyIccPukForApp(3, hidl_string("test1"), hidl_string("test2"), hidl_string());
EXPECT_EQ(std::cv_status::no_timeout, wait());
EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
EXPECT_EQ(3, radioRsp->rspInfo.serial);
int serial = 1;
EXPECT_EQ(radioRsp->rspInfo.error, RadioError::PASSWORD_INCORRECT);
// Pass wrong password and check PASSWORD_INCORRECT returned for 3GPP and 3GPP2 apps only
for (int i = 0; i < (int) cardStatus.applications.size(); i++) {
if (cardStatus.applications[i].appType == AppType::SIM
|| cardStatus.applications[i].appType == AppType::USIM
|| cardStatus.applications[i].appType == AppType::RUIM
|| cardStatus.applications[i].appType == AppType::CSIM) {
radio->supplyIccPukForApp(++serial, hidl_string("test1"), hidl_string("test2"),
cardStatus.applications[i].aidPtr);
EXPECT_EQ(std::cv_status::no_timeout, wait());
EXPECT_EQ(serial, radioRsp->rspInfo.serial);
EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
EXPECT_EQ(RadioError::PASSWORD_INCORRECT, radioRsp->rspInfo.error);
}
}
}
/*
* Test IRadio.supplyIccPin2ForApp() for the response returned.
*/
TEST_F(RadioHidlTest, supplyIccPin2ForApp) {
radio->supplyIccPin2ForApp(4, hidl_string("test1"), hidl_string());
EXPECT_EQ(std::cv_status::no_timeout, wait());
EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
EXPECT_EQ(4, radioRsp->rspInfo.serial);
int serial = 1;
EXPECT_EQ(radioRsp->rspInfo.error, RadioError::PASSWORD_INCORRECT);
// Pass wrong password and check PASSWORD_INCORRECT returned for 3GPP and 3GPP2 apps only
for (int i = 0; i < (int) cardStatus.applications.size(); i++) {
if (cardStatus.applications[i].appType == AppType::SIM
|| cardStatus.applications[i].appType == AppType::USIM
|| cardStatus.applications[i].appType == AppType::RUIM
|| cardStatus.applications[i].appType == AppType::CSIM) {
radio->supplyIccPin2ForApp(++serial, hidl_string("test1"),
cardStatus.applications[i].aidPtr);
EXPECT_EQ(std::cv_status::no_timeout, wait());
EXPECT_EQ(serial, radioRsp->rspInfo.serial);
EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
EXPECT_EQ(RadioError::PASSWORD_INCORRECT, radioRsp->rspInfo.error);
}
}
}
/*
* Test IRadio.supplyIccPuk2ForApp() for the response returned.
*/
TEST_F(RadioHidlTest, supplyIccPuk2ForApp) {
radio->supplyIccPuk2ForApp(5, hidl_string("test1"), hidl_string("test2"), hidl_string());
EXPECT_EQ(std::cv_status::no_timeout, wait());
EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
EXPECT_EQ(5, radioRsp->rspInfo.serial);
int serial = 1;
EXPECT_EQ(radioRsp->rspInfo.error, RadioError::PASSWORD_INCORRECT);
// Pass wrong password and check PASSWORD_INCORRECT returned for 3GPP and 3GPP2 apps only
for (int i = 0; i < (int) cardStatus.applications.size(); i++) {
if (cardStatus.applications[i].appType == AppType::SIM
|| cardStatus.applications[i].appType == AppType::USIM
|| cardStatus.applications[i].appType == AppType::RUIM
|| cardStatus.applications[i].appType == AppType::CSIM) {
radio->supplyIccPuk2ForApp(++serial, hidl_string("test1"), hidl_string("test2"),
cardStatus.applications[i].aidPtr);
EXPECT_EQ(std::cv_status::no_timeout, wait());
EXPECT_EQ(serial, radioRsp->rspInfo.serial);
EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
EXPECT_EQ(RadioError::PASSWORD_INCORRECT, radioRsp->rspInfo.error);
}
}
}
/*
* Test IRadio.changeIccPinForApp() for the response returned.
*/
TEST_F(RadioHidlTest, changeIccPinForApp) {
radio->changeIccPinForApp(6, hidl_string("test1"), hidl_string("test2"), hidl_string());
EXPECT_EQ(std::cv_status::no_timeout, wait());
EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
EXPECT_EQ(6, radioRsp->rspInfo.serial);
int serial = 1;
EXPECT_EQ(radioRsp->rspInfo.error, RadioError::PASSWORD_INCORRECT);
// Pass wrong password and check PASSWORD_INCORRECT returned for 3GPP and 3GPP2 apps only
for (int i = 0; i < (int) cardStatus.applications.size(); i++) {
if (cardStatus.applications[i].appType == AppType::SIM
|| cardStatus.applications[i].appType == AppType::USIM
|| cardStatus.applications[i].appType == AppType::RUIM
|| cardStatus.applications[i].appType == AppType::CSIM) {
radio->changeIccPinForApp(++serial, hidl_string("test1"), hidl_string("test2"),
cardStatus.applications[i].aidPtr);
EXPECT_EQ(std::cv_status::no_timeout, wait());
EXPECT_EQ(serial, radioRsp->rspInfo.serial);
EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
EXPECT_EQ(RadioError::PASSWORD_INCORRECT, radioRsp->rspInfo.error);
}
}
}
/*
* Test IRadio.changeIccPin2ForApp() for the response returned.
*/
TEST_F(RadioHidlTest, changeIccPin2ForApp) {
radio->changeIccPin2ForApp(7, hidl_string("test1"), hidl_string("test2"), hidl_string());
int serial = 1;
// Pass wrong password and check PASSWORD_INCORRECT returned for 3GPP and 3GPP2 apps only
for (int i = 0; i < (int) cardStatus.applications.size(); i++) {
if (cardStatus.applications[i].appType == AppType::SIM
|| cardStatus.applications[i].appType == AppType::USIM
|| cardStatus.applications[i].appType == AppType::RUIM
|| cardStatus.applications[i].appType == AppType::CSIM) {
radio->changeIccPin2ForApp(++serial, hidl_string("test1"), hidl_string("test2"),
cardStatus.applications[i].aidPtr);
EXPECT_EQ(std::cv_status::no_timeout, wait());
EXPECT_EQ(serial, radioRsp->rspInfo.serial);
EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
EXPECT_EQ(RadioError::PASSWORD_INCORRECT, radioRsp->rspInfo.error);
}
}
}
/*
* Test IRadio.getImsiForApp() for the response returned.
*/
TEST_F(RadioHidlTest, getImsiForApp) {
int serial = 1;
// Check success returned while getting imsi for 3GPP and 3GPP2 apps only
for (int i = 0; i < (int) cardStatus.applications.size(); i++) {
if (cardStatus.applications[i].appType == AppType::SIM
|| cardStatus.applications[i].appType == AppType::USIM
|| cardStatus.applications[i].appType == AppType::RUIM
|| cardStatus.applications[i].appType == AppType::CSIM) {
radio->getImsiForApp(++serial, cardStatus.applications[i].aidPtr);
EXPECT_EQ(std::cv_status::no_timeout, wait());
EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
EXPECT_EQ(serial, radioRsp->rspInfo.serial);
EXPECT_EQ(RadioError::NONE, radioRsp->rspInfo.error);
// IMSI (MCC+MNC+MSIN) is at least 6 digits, but not more than 15
if (radioRsp->rspInfo.error == RadioError::NONE) {
EXPECT_NE(radioRsp->imsi, hidl_string());
EXPECT_GE((int) (radioRsp->imsi).size(), 6);
EXPECT_LE((int) (radioRsp->imsi).size(), 15);
}
}
}
}
/*
* Test IRadio.iccIOForApp() for the response returned.
*/
TEST_F(RadioHidlTest, iccIOForApp) {
int serial = 1;
for (int i = 0; i < (int) cardStatus.applications.size(); i++) {
IccIo iccIo;
iccIo.command = 0xc0;
iccIo.fileId = 0x6f11;
iccIo.path = hidl_string("3F007FFF");
iccIo.p1 = 0;
iccIo.p2 = 0;
iccIo.p3 = 0;
iccIo.data = hidl_string();
iccIo.pin2 = hidl_string();
iccIo.aid = cardStatus.applications[i].aidPtr;
radio->iccIOForApp(++serial, iccIo);
EXPECT_EQ(std::cv_status::no_timeout, wait());
EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
EXPECT_EQ(serial, radioRsp->rspInfo.serial);
}
}
/*
* Test IRadio.iccTransmitApduBasicChannel() for the response returned.
*/
TEST_F(RadioHidlTest, iccTransmitApduBasicChannel) {
int serial = 1;
SimApdu msg;
memset(&msg, 0, sizeof(msg));
msg.data = hidl_string();
radio->iccTransmitApduBasicChannel(serial, msg);
EXPECT_EQ(std::cv_status::no_timeout, wait());
EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
EXPECT_EQ(7, radioRsp->rspInfo.serial);
EXPECT_EQ(serial, radioRsp->rspInfo.serial);
EXPECT_EQ(radioRsp->rspInfo.error, RadioError::PASSWORD_INCORRECT);
// TODO(sanketpadawe): Add test for error code
}
/*
* Test IRadio.iccOpenLogicalChannel() for the response returned.
*/
TEST_F(RadioHidlTest, iccOpenLogicalChannel) {
int serial = 1;
for (int i = 0; i < (int) cardStatus.applications.size(); i++) {
radio->iccOpenLogicalChannel(++serial, cardStatus.applications[i].aidPtr);
EXPECT_EQ(std::cv_status::no_timeout, wait());
EXPECT_EQ(serial, radioRsp->rspInfo.serial);
EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
}
}
/*
* Test IRadio.iccCloseLogicalChannel() for the response returned.
*/
TEST_F(RadioHidlTest, iccCloseLogicalChannel) {
int serial = 1;
// Try closing invalid channel and check INVALID_ARGUMENTS returned as error
radio->iccCloseLogicalChannel(serial, 0);
EXPECT_EQ(std::cv_status::no_timeout, wait());
EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
EXPECT_EQ(serial, radioRsp->rspInfo.serial);
EXPECT_EQ(RadioError::INVALID_ARGUMENTS, radioRsp->rspInfo.error);
}
/*
* Test IRadio.iccTransmitApduLogicalChannel() for the response returned.
*/
TEST_F(RadioHidlTest, iccTransmitApduLogicalChannel) {
SimApdu msg;
memset(&msg, 0, sizeof(msg));
msg.data = hidl_string();
radio->iccTransmitApduLogicalChannel(1, msg);
EXPECT_EQ(std::cv_status::no_timeout, wait());
EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
EXPECT_EQ(1, radioRsp->rspInfo.serial);
// TODO(sanketpadawe): Add test for error code
}
/*
* Test IRadio.requestIccSimAuthentication() for the response returned.
*/
TEST_F(RadioHidlTest, requestIccSimAuthentication) {
int serial = 1;
// Pass wrong challenge string and check RadioError::INVALID_ARGUMENTS returned as error.
for (int i = 0; i < (int) cardStatus.applications.size(); i++) {
radio->requestIccSimAuthentication(++serial, 0, hidl_string("test"),
cardStatus.applications[i].aidPtr);
EXPECT_EQ(std::cv_status::no_timeout, wait());
EXPECT_EQ(serial, radioRsp->rspInfo.serial);
EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
EXPECT_EQ(RadioError::INVALID_ARGUMENTS, radioRsp->rspInfo.error);
}
}

View file

@ -27,6 +27,12 @@ void RadioHidlTest::SetUp() {
radioInd = NULL;
radio->setResponseFunctions(radioRsp, radioInd);
radio->getIccCardStatus(1);
EXPECT_EQ(std::cv_status::no_timeout, wait());
EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
EXPECT_EQ(1, radioRsp->rspInfo.serial);
EXPECT_EQ(RadioError::NONE, radioRsp->rspInfo.error);
}
void RadioHidlTest::TearDown() {

View file

@ -27,6 +27,7 @@
#include <android/hardware/radio/1.0/types.h>
using ::android::hardware::radio::V1_0::ActivityStatsInfo;
using ::android::hardware::radio::V1_0::AppType;
using ::android::hardware::radio::V1_0::CardStatus;
using ::android::hardware::radio::V1_0::Call;
using ::android::hardware::radio::V1_0::CallForwardInfo;
@ -39,6 +40,7 @@ using ::android::hardware::radio::V1_0::ClipStatus;
using ::android::hardware::radio::V1_0::DataRegStateResult;
using ::android::hardware::radio::V1_0::GsmBroadcastSmsConfigInfo;
using ::android::hardware::radio::V1_0::HardwareConfig;
using ::android::hardware::radio::V1_0::IccIo;
using ::android::hardware::radio::V1_0::IccIoResult;
using ::android::hardware::radio::V1_0::IRadio;
using ::android::hardware::radio::V1_0::IRadioResponse;
@ -60,6 +62,7 @@ using ::android::hardware::radio::V1_0::RadioTechnologyFamily;
using ::android::hardware::radio::V1_0::SendSmsResult;
using ::android::hardware::radio::V1_0::SetupDataCallResult;
using ::android::hardware::radio::V1_0::SignalStrength;
using ::android::hardware::radio::V1_0::SimApdu;
using ::android::hardware::radio::V1_0::TtyMode;
using ::android::hardware::radio::V1_0::VoiceRegStateResult;
@ -71,6 +74,7 @@ using ::android::sp;
#define TIMEOUT_PERIOD 20
class RadioHidlTest;
extern CardStatus cardStatus;
/* Callback class for radio response */
class RadioResponse : public IRadioResponse {
@ -79,7 +83,9 @@ private:
public:
RadioResponseInfo rspInfo;
CardStatus cardStatus;
hidl_string imsi;
IccIoResult iccIoResult;
int channelId;
RadioResponse(RadioHidlTest& parent);
@ -443,6 +449,7 @@ public:
sp<IRadio> radio;
sp<RadioResponse> radioRsp;
sp<IRadioIndication> radioInd;
};
// A class for test environment setup

View file

@ -16,6 +16,8 @@
#include<radio_hidl_hal_utils.h>
CardStatus cardStatus;
RadioResponse::RadioResponse(RadioHidlTest& parent) : parent(parent) {
}
@ -85,6 +87,9 @@ Return<void> RadioResponse::dialResponse(const RadioResponseInfo& info) {
Return<void> RadioResponse::getIMSIForAppResponse(
const RadioResponseInfo& info, const ::android::hardware::hidl_string& imsi) {
rspInfo = info;
this->imsi = imsi;
parent.notify();
return Void();
}
@ -170,6 +175,9 @@ Return<void> RadioResponse::setupDataCallResponse(
Return<void> RadioResponse::iccIOForAppResponse(
const RadioResponseInfo& info, const IccIoResult& iccIo) {
rspInfo = info;
this->iccIoResult = iccIo;
parent.notify();
return Void();
}
@ -543,21 +551,32 @@ Return<void> RadioResponse::sendImsSmsResponse(
Return<void> RadioResponse::iccTransmitApduBasicChannelResponse(
const RadioResponseInfo& info, const IccIoResult& result) {
rspInfo = info;
this->iccIoResult = result;
parent.notify();
return Void();
}
Return<void> RadioResponse::iccOpenLogicalChannelResponse(
const RadioResponseInfo& info, int32_t channelId,
const ::android::hardware::hidl_vec<int8_t>& selectResponse) {
rspInfo = info;
this->channelId = channelId;
parent.notify();
return Void();
}
Return<void> RadioResponse::iccCloseLogicalChannelResponse(const RadioResponseInfo& info) {
rspInfo = info;
parent.notify();
return Void();
}
Return<void> RadioResponse::iccTransmitApduLogicalChannelResponse(
const RadioResponseInfo& info, const IccIoResult& result) {
rspInfo = info;
this->iccIoResult = result;
parent.notify();
return Void();
}
@ -594,6 +613,9 @@ Return<void> RadioResponse::getHardwareConfigResponse(
Return<void> RadioResponse::requestIccSimAuthenticationResponse(
const RadioResponseInfo& info, const IccIoResult& result) {
rspInfo = info;
this->iccIoResult = result;
parent.notify();
return Void();
}