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

Commit 912bdf34 authored by Sarah Chin's avatar Sarah Chin
Browse files

Add all prior VTS tests

Test: atest VtsHalRadioTargetTest
Bug: 210712359
Change-Id: Ib7ace442ee2bf8d203df9899d8e8331b26af74ad
parent 1aab61da
Loading
Loading
Loading
Loading
+16 −7
Original line number Diff line number Diff line
@@ -19,12 +19,15 @@
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;
    parent_config.notify(info.serial);
    return ndk::ScopedAStatus::ok();
}

ndk::ScopedAStatus RadioConfigResponse::setSimSlotsMappingResponse(
        const RadioResponseInfo& /* info */) {
ndk::ScopedAStatus RadioConfigResponse::setSimSlotsMappingResponse(const RadioResponseInfo& info) {
    rspInfo = info;
    parent_config.notify(info.serial);
    return ndk::ScopedAStatus::ok();
}

@@ -37,22 +40,28 @@ ndk::ScopedAStatus RadioConfigResponse::getPhoneCapabilityResponse(
}

ndk::ScopedAStatus RadioConfigResponse::setPreferredDataModemResponse(
        const RadioResponseInfo& /* info */) {
        const RadioResponseInfo& info) {
    rspInfo = info;
    parent_config.notify(info.serial);
    return ndk::ScopedAStatus::ok();
}

ndk::ScopedAStatus RadioConfigResponse::getNumOfLiveModemsResponse(
        const RadioResponseInfo& /* info */, const int8_t /* numOfLiveModems */) {
        const RadioResponseInfo& info, const int8_t /* numOfLiveModems */) {
    rspInfo = info;
    parent_config.notify(info.serial);
    return ndk::ScopedAStatus::ok();
}

ndk::ScopedAStatus RadioConfigResponse::setNumOfLiveModemsResponse(
        const RadioResponseInfo& /* info */) {
ndk::ScopedAStatus RadioConfigResponse::setNumOfLiveModemsResponse(const RadioResponseInfo& info) {
    rspInfo = info;
    parent_config.notify(info.serial);
    return ndk::ScopedAStatus::ok();
}

ndk::ScopedAStatus RadioConfigResponse::getHalDeviceCapabilitiesResponse(
        const RadioResponseInfo& info, bool modemReducedFeatures) {
    rspInfo = info;
    modemReducedFeatureSet1 = modemReducedFeatures;
    parent_config.notify(info.serial);
    return ndk::ScopedAStatus::ok();
+99 −0
Original line number Diff line number Diff line
@@ -54,3 +54,102 @@ TEST_P(RadioConfigTest, getHalDeviceCapabilities) {
    ALOGI("getHalDeviceCapabilities, rspInfo.error = %s\n",
          toString(radioRsp_config->rspInfo.error).c_str());
}

/*
 * Test IRadioConfig.getSimSlotsStatus() for the response returned.
 */
TEST_P(RadioConfigTest, getSimSlotsStatus) {
    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());
}

/*
 * Test IRadioConfig.getPhoneCapability() for the response returned.
 */
TEST_P(RadioConfigTest, getPhoneCapability) {
    serial = GetRandomSerialNumber();
    ndk::ScopedAStatus res = radio_config->getPhoneCapability(serial);
    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("getPhoneCapability, rspInfo.error = %s\n",
          toString(radioRsp_config->rspInfo.error).c_str());

    ASSERT_TRUE(CheckAnyOfErrors(
            radioRsp_config->rspInfo.error,
            {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, RadioError::INTERNAL_ERR}));

    if (radioRsp_config->rspInfo.error == RadioError ::NONE) {
        // maxActiveData should be greater than or equal to maxActiveInternetData.
        EXPECT_GE(radioRsp_config->phoneCap.maxActiveData,
                  radioRsp_config->phoneCap.maxActiveInternetData);
        // maxActiveData and maxActiveInternetData should be 0 or positive numbers.
        EXPECT_GE(radioRsp_config->phoneCap.maxActiveInternetData, 0);
    }
}

/*
 * Test IRadioConfig.setPreferredDataModem() for the response returned.
 */
TEST_P(RadioConfigTest, setPreferredDataModem) {
    serial = GetRandomSerialNumber();
    ndk::ScopedAStatus res = radio_config->getPhoneCapability(serial);
    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("getPhoneCapability, rspInfo.error = %s\n",
          toString(radioRsp_config->rspInfo.error).c_str());

    ASSERT_TRUE(CheckAnyOfErrors(
            radioRsp_config->rspInfo.error,
            {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, RadioError::INTERNAL_ERR}));

    if (radioRsp_config->rspInfo.error != RadioError ::NONE) {
        return;
    }

    if (radioRsp_config->phoneCap.logicalModemIds.size() == 0) {
        return;
    }

    // We get phoneCapability. Send setPreferredDataModem command
    serial = GetRandomSerialNumber();
    uint8_t modemId = radioRsp_config->phoneCap.logicalModemIds[0];
    res = radio_config->setPreferredDataModem(serial, modemId);

    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("setPreferredDataModem, rspInfo.error = %s\n",
          toString(radioRsp_config->rspInfo.error).c_str());

    ASSERT_TRUE(CheckAnyOfErrors(
            radioRsp_config->rspInfo.error,
            {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, RadioError::INTERNAL_ERR}));
}

/*
 * Test IRadioConfig.setPreferredDataModem() with invalid arguments.
 */
TEST_P(RadioConfigTest, setPreferredDataModem_invalidArgument) {
    serial = GetRandomSerialNumber();
    uint8_t modemId = -1;
    ndk::ScopedAStatus res = radio_config->setPreferredDataModem(serial, modemId);

    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("setPreferredDataModem, rspInfo.error = %s\n",
          toString(radioRsp_config->rspInfo.error).c_str());

    ASSERT_TRUE(CheckAnyOfErrors(radioRsp_config->rspInfo.error,
                                 {RadioError::INVALID_ARGUMENTS, RadioError::RADIO_NOT_AVAILABLE,
                                  RadioError::INTERNAL_ERR}));
}
+18 −8
Original line number Diff line number Diff line
@@ -36,8 +36,9 @@ ndk::ScopedAStatus RadioDataResponse::cancelHandoverResponse(const RadioResponse
    return ndk::ScopedAStatus::ok();
}

ndk::ScopedAStatus RadioDataResponse::deactivateDataCallResponse(
        const RadioResponseInfo& /*info*/) {
ndk::ScopedAStatus RadioDataResponse::deactivateDataCallResponse(const RadioResponseInfo& info) {
    rspInfo = info;
    parent_data.notify(info.serial);
    return ndk::ScopedAStatus::ok();
}

@@ -61,11 +62,15 @@ ndk::ScopedAStatus RadioDataResponse::releasePduSessionIdResponse(const RadioRes
    return ndk::ScopedAStatus::ok();
}

ndk::ScopedAStatus RadioDataResponse::setDataAllowedResponse(const RadioResponseInfo& /*info*/) {
ndk::ScopedAStatus RadioDataResponse::setDataAllowedResponse(const RadioResponseInfo& info) {
    rspInfo = info;
    parent_data.notify(info.serial);
    return ndk::ScopedAStatus::ok();
}

ndk::ScopedAStatus RadioDataResponse::setDataProfileResponse(const RadioResponseInfo& /*info*/) {
ndk::ScopedAStatus RadioDataResponse::setDataProfileResponse(const RadioResponseInfo& info) {
    rspInfo = info;
    parent_data.notify(info.serial);
    return ndk::ScopedAStatus::ok();
}

@@ -75,8 +80,9 @@ ndk::ScopedAStatus RadioDataResponse::setDataThrottlingResponse(const RadioRespo
    return ndk::ScopedAStatus::ok();
}

ndk::ScopedAStatus RadioDataResponse::setInitialAttachApnResponse(
        const RadioResponseInfo& /*info*/) {
ndk::ScopedAStatus RadioDataResponse::setInitialAttachApnResponse(const RadioResponseInfo& info) {
    rspInfo = info;
    parent_data.notify(info.serial);
    return ndk::ScopedAStatus::ok();
}

@@ -94,11 +100,15 @@ ndk::ScopedAStatus RadioDataResponse::startHandoverResponse(const RadioResponseI
    return ndk::ScopedAStatus::ok();
}

ndk::ScopedAStatus RadioDataResponse::startKeepaliveResponse(const RadioResponseInfo& /*info*/,
ndk::ScopedAStatus RadioDataResponse::startKeepaliveResponse(const RadioResponseInfo& info,
                                                             const KeepaliveStatus& /*status*/) {
    rspInfo = info;
    parent_data.notify(info.serial);
    return ndk::ScopedAStatus::ok();
}

ndk::ScopedAStatus RadioDataResponse::stopKeepaliveResponse(const RadioResponseInfo& /*info*/) {
ndk::ScopedAStatus RadioDataResponse::stopKeepaliveResponse(const RadioResponseInfo& info) {
    rspInfo = info;
    parent_data.notify(info.serial);
    return ndk::ScopedAStatus::ok();
}
+277 −0
Original line number Diff line number Diff line
@@ -309,3 +309,280 @@ TEST_P(RadioDataTest, setDataThrottling) {

    sleep(1);
}

/*
 * Test IRadioData.setInitialAttachApn() for the response returned.
 */
TEST_P(RadioDataTest, setInitialAttachApn) {
    serial = GetRandomSerialNumber();

    // Create a dataProfileInfo
    DataProfileInfo dataProfileInfo;
    memset(&dataProfileInfo, 0, sizeof(dataProfileInfo));
    dataProfileInfo.profileId = DataProfileInfo::ID_DEFAULT;
    dataProfileInfo.apn = std::string("internet");
    dataProfileInfo.protocol = PdpProtocolType::IPV4V6;
    dataProfileInfo.roamingProtocol = PdpProtocolType::IPV4V6;
    dataProfileInfo.authType = ApnAuthType::NO_PAP_NO_CHAP;
    dataProfileInfo.user = std::string("username");
    dataProfileInfo.password = std::string("password");
    dataProfileInfo.type = DataProfileInfo::TYPE_THREE_GPP;
    dataProfileInfo.maxConnsTime = 300;
    dataProfileInfo.maxConns = 20;
    dataProfileInfo.waitTime = 0;
    dataProfileInfo.enabled = true;
    dataProfileInfo.supportedApnTypesBitmap = 320;
    dataProfileInfo.bearerBitmap = 161543;
    dataProfileInfo.mtuV4 = 0;
    dataProfileInfo.mtuV6 = 0;
    dataProfileInfo.preferred = true;
    dataProfileInfo.persistent = false;

    radio_data->setInitialAttachApn(serial, dataProfileInfo);

    EXPECT_EQ(std::cv_status::no_timeout, wait());
    EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type);
    EXPECT_EQ(serial, radioRsp_data->rspInfo.serial);

    if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
        ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error,
                                     {RadioError::SIM_ABSENT, RadioError::RADIO_NOT_AVAILABLE}));
    } else if (cardStatus.cardState == CardStatus::STATE_PRESENT) {
        ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error,
                                     {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE}));
    }
}

/*
 * Test IRadioData.setDataProfile() for the response returned.
 */
TEST_P(RadioDataTest, setDataProfile) {
    serial = GetRandomSerialNumber();

    // Create a dataProfileInfo
    DataProfileInfo dataProfileInfo;
    memset(&dataProfileInfo, 0, sizeof(dataProfileInfo));
    dataProfileInfo.profileId = DataProfileInfo::ID_DEFAULT;
    dataProfileInfo.apn = std::string("internet");
    dataProfileInfo.protocol = PdpProtocolType::IPV4V6;
    dataProfileInfo.roamingProtocol = PdpProtocolType::IPV4V6;
    dataProfileInfo.authType = ApnAuthType::NO_PAP_NO_CHAP;
    dataProfileInfo.user = std::string("username");
    dataProfileInfo.password = std::string("password");
    dataProfileInfo.type = DataProfileInfo::TYPE_THREE_GPP;
    dataProfileInfo.maxConnsTime = 300;
    dataProfileInfo.maxConns = 20;
    dataProfileInfo.waitTime = 0;
    dataProfileInfo.enabled = true;
    dataProfileInfo.supportedApnTypesBitmap = 320;
    dataProfileInfo.bearerBitmap = 161543;
    dataProfileInfo.mtuV4 = 0;
    dataProfileInfo.mtuV6 = 0;
    dataProfileInfo.preferred = true;
    dataProfileInfo.persistent = true;

    // Create a dataProfileInfoList
    std::vector<DataProfileInfo> dataProfileInfoList = {dataProfileInfo};

    radio_data->setDataProfile(serial, dataProfileInfoList);

    EXPECT_EQ(std::cv_status::no_timeout, wait());
    EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type);
    EXPECT_EQ(serial, radioRsp_data->rspInfo.serial);

    if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
        ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error,
                                     {RadioError::SIM_ABSENT, RadioError::RADIO_NOT_AVAILABLE}));
    } else if (cardStatus.cardState == CardStatus::STATE_PRESENT) {
        ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error,
                                     {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE}));
    }
}

/*
 * Test IRadioData.deactivateDataCall() for the response returned.
 */
TEST_P(RadioDataTest, deactivateDataCall) {
    serial = GetRandomSerialNumber();
    int cid = 1;
    DataRequestReason reason = DataRequestReason::NORMAL;

    ndk::ScopedAStatus res = radio_data->deactivateDataCall(serial, cid, reason);
    ASSERT_OK(res);

    EXPECT_EQ(std::cv_status::no_timeout, wait());
    EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type);
    EXPECT_EQ(serial, radioRsp_data->rspInfo.serial);

    if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
        ASSERT_TRUE(
                CheckAnyOfErrors(radioRsp_data->rspInfo.error,
                                 {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE,
                                  RadioError::INVALID_CALL_ID, RadioError::INVALID_STATE,
                                  RadioError::INVALID_ARGUMENTS, RadioError::REQUEST_NOT_SUPPORTED,
                                  RadioError::CANCELLED, RadioError::SIM_ABSENT}));
    } else if (cardStatus.cardState == CardStatus::STATE_PRESENT) {
        ASSERT_TRUE(CheckAnyOfErrors(
                radioRsp_data->rspInfo.error,
                {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, RadioError::INVALID_CALL_ID,
                 RadioError::INVALID_STATE, RadioError::INVALID_ARGUMENTS,
                 RadioError::REQUEST_NOT_SUPPORTED, RadioError::CANCELLED}));
    }
}

/*
 * Test IRadioData.startKeepalive() for the response returned.
 */
TEST_P(RadioDataTest, startKeepalive) {
    std::vector<KeepaliveRequest> requests = {
            {
                    // Invalid IPv4 source address
                    KeepaliveRequest::TYPE_NATT_IPV4,
                    {192, 168, 0 /*, 100*/},
                    1234,
                    {8, 8, 4, 4},
                    4500,
                    20000,
                    0xBAD,
            },
            {
                    // Invalid IPv4 destination address
                    KeepaliveRequest::TYPE_NATT_IPV4,
                    {192, 168, 0, 100},
                    1234,
                    {8, 8, 4, 4, 1, 2, 3, 4},
                    4500,
                    20000,
                    0xBAD,
            },
            {
                    // Invalid Keepalive Type
                    -1,
                    {192, 168, 0, 100},
                    1234,
                    {8, 8, 4, 4},
                    4500,
                    20000,
                    0xBAD,
            },
            {
                    // Invalid IPv6 source address
                    KeepaliveRequest::TYPE_NATT_IPV6,
                    {0xDE, 0xAD, 0xBE, 0xEF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE,
                     0xED, 0xBE, 0xEF, 0xBD},
                    1234,
                    {0x20, 0x01, 0x48, 0x60, 0x48, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                     0x00, 0x88, 0x44},
                    4500,
                    20000,
                    0xBAD,
            },
            {
                    // Invalid IPv6 destination address
                    KeepaliveRequest::TYPE_NATT_IPV6,
                    {0xDE, 0xAD, 0xBE, 0xEF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE,
                     0xED, 0xBE, 0xEF},
                    1234,
                    {0x20, 0x01, 0x48, 0x60, 0x48, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                     0x00, 0x88,
                     /*0x44*/},
                    4500,
                    20000,
                    0xBAD,
            },
            {
                    // Invalid Context ID (cid), this should survive the initial
                    // range checking and fail in the modem data layer
                    KeepaliveRequest::TYPE_NATT_IPV4,
                    {192, 168, 0, 100},
                    1234,
                    {8, 8, 4, 4},
                    4500,
                    20000,
                    0xBAD,
            },
            {
                    // Invalid Context ID (cid), this should survive the initial
                    // range checking and fail in the modem data layer
                    KeepaliveRequest::TYPE_NATT_IPV6,
                    {0xDE, 0xAD, 0xBE, 0xEF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE,
                     0xED, 0xBE, 0xEF},
                    1234,
                    {0x20, 0x01, 0x48, 0x60, 0x48, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                     0x00, 0x88, 0x44},
                    4500,
                    20000,
                    0xBAD,
            }};

    for (auto req = requests.begin(); req != requests.end(); req++) {
        serial = GetRandomSerialNumber();
        radio_data->startKeepalive(serial, *req);
        EXPECT_EQ(std::cv_status::no_timeout, wait());
        EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type);
        EXPECT_EQ(serial, radioRsp_data->rspInfo.serial);

        ASSERT_TRUE(CheckAnyOfErrors(
                radioRsp_data->rspInfo.error,
                {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, RadioError::INVALID_ARGUMENTS,
                 RadioError::REQUEST_NOT_SUPPORTED}));
    }
}

/*
 * Test IRadioData.stopKeepalive() for the response returned.
 */
TEST_P(RadioDataTest, stopKeepalive) {
    serial = GetRandomSerialNumber();

    radio_data->stopKeepalive(serial, 0xBAD);
    EXPECT_EQ(std::cv_status::no_timeout, wait());
    EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type);
    EXPECT_EQ(serial, radioRsp_data->rspInfo.serial);

    ASSERT_TRUE(
            CheckAnyOfErrors(radioRsp_data->rspInfo.error,
                             {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE,
                              RadioError::INVALID_ARGUMENTS, RadioError::REQUEST_NOT_SUPPORTED}));
}

/*
 * Test IRadioData.getDataCallList() for the response returned.
 */
TEST_P(RadioDataTest, getDataCallList) {
    LOG(DEBUG) << "getDataCallList";
    serial = GetRandomSerialNumber();

    radio_data->getDataCallList(serial);

    EXPECT_EQ(std::cv_status::no_timeout, wait());
    EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type);
    EXPECT_EQ(serial, radioRsp_data->rspInfo.serial);

    if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
        ASSERT_TRUE(CheckAnyOfErrors(
                radioRsp_data->rspInfo.error,
                {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, RadioError::SIM_ABSENT}));
    }
    LOG(DEBUG) << "getDataCallList finished";
}

/*
 * Test IRadioData.setDataAllowed() for the response returned.
 */
TEST_P(RadioDataTest, setDataAllowed) {
    LOG(DEBUG) << "setDataAllowed";
    serial = GetRandomSerialNumber();
    bool allow = true;

    radio_data->setDataAllowed(serial, allow);

    EXPECT_EQ(std::cv_status::no_timeout, wait());
    EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type);
    EXPECT_EQ(serial, radioRsp_data->rspInfo.serial);

    if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
        EXPECT_EQ(RadioError::NONE, radioRsp_data->rspInfo.error);
    }
    LOG(DEBUG) << "setDataAllowed finished";
}
+57 −24

File changed.

Preview size limit exceeded, changes collapsed.

Loading