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

Commit b0034bf5 authored by Sooraj Sasindran's avatar Sooraj Sasindran Committed by android-build-merger
Browse files

Merge "vts test for 1.2"

am: 55e77745

Change-Id: I1c45e47a0fc14bb9f15f3f998c5a3419f5be69fb
parents dd5206c5 55e77745
Loading
Loading
Loading
Loading

radio/1.2/vts/OWNERS

0 → 100644
+9 −0
Original line number Diff line number Diff line
# Telephony team
amitmahajan@google.com
sanketpadawe@google.com
shuoq@google.com
sasindran@google.com

# VTS team
yuexima@google.com
yim@google.com
+33 −0
Original line number Diff line number Diff line
//
// Copyright (C) 2017 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

cc_test {
    name: "VtsHalRadioV1_2TargetTest",
    defaults: ["VtsHalTargetTestDefaults"],
    srcs: [
        "radio_hidl_hal_api.cpp",
        "radio_hidl_hal_test.cpp",
        "radio_response.cpp",
        "radio_indication.cpp",
    ],
    static_libs: [
        "RadioVtsTestUtilBase",
        "android.hardware.radio@1.2",
        "android.hardware.radio@1.1",
        "android.hardware.radio@1.0",
    ],
    header_libs: ["radio.util.header@1.0"],
}
+395 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <radio_hidl_hal_utils_v1_2.h>
#include <vector>

#define ASSERT_OK(ret) ASSERT_TRUE(ret.isOk())

/*
 * Test IRadio.startNetworkScan() for the response returned.
 */
TEST_F(RadioHidlTest_v1_2, startNetworkScan) {
    const int serial = GetRandomSerialNumber();

    RadioAccessSpecifier specifier = {
        .radioAccessNetwork = RadioAccessNetworks::GERAN,
        .geranBands = {GeranBands::BAND_450, GeranBands::BAND_480},
        .channels = {1,2}};

    V1_2::NetworkScanRequest request = {
        .type = ScanType::ONE_SHOT,
        .interval = 60,
        .specifiers = {specifier}};

    Return<void> res = radio_v1_2->startNetworkScan_1_2(serial, request);
    ASSERT_OK(res);
    EXPECT_EQ(std::cv_status::no_timeout, wait());
    EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_2->rspInfo.type);
    EXPECT_EQ(serial, radioRsp_v1_2->rspInfo.serial);

    ALOGI("startNetworkScan, rspInfo.error = %s\n", toString(radioRsp_v1_2->rspInfo.error).c_str());
    if (cardStatus.cardState == CardState::ABSENT) {
        ASSERT_TRUE(radioRsp_v1_2->rspInfo.error == RadioError::SIM_ABSENT ||
                    radioRsp_v1_2->rspInfo.error == RadioError::REQUEST_NOT_SUPPORTED ||
                    radioRsp_v1_2->rspInfo.error == RadioError::OPERATION_NOT_ALLOWED);
    } else if (cardStatus.cardState == CardState::PRESENT) {
        ASSERT_TRUE(radioRsp_v1_2->rspInfo.error == RadioError::NONE ||
                    radioRsp_v1_2->rspInfo.error == RadioError::REQUEST_NOT_SUPPORTED ||
                    radioRsp_v1_2->rspInfo.error == RadioError::OPERATION_NOT_ALLOWED);
    }
}

/*
 * Test IRadio.startNetworkScan() with invalid specifier.
 */
TEST_F(RadioHidlTest_v1_2, startNetworkScan_InvalidArgument) {
    const int serial = GetRandomSerialNumber();

    V1_2::NetworkScanRequest request = {
        .type = ScanType::ONE_SHOT,
        .interval = 60};

    Return<void> res = radio_v1_2->startNetworkScan_1_2(serial, request);
    ASSERT_OK(res);
    EXPECT_EQ(std::cv_status::no_timeout, wait());
    EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_2->rspInfo.type);
    EXPECT_EQ(serial, radioRsp_v1_2->rspInfo.serial);

    ALOGI("startNetworkScan_InvalidArgument, rspInfo.error = %s\n",
          toString(radioRsp_v1_2->rspInfo.error).c_str());
    if (cardStatus.cardState == CardState::ABSENT) {
        ASSERT_TRUE(radioRsp_v1_2->rspInfo.error == RadioError::INVALID_ARGUMENTS ||
                    radioRsp_v1_2->rspInfo.error == RadioError::SIM_ABSENT ||
                    radioRsp_v1_2->rspInfo.error == RadioError::REQUEST_NOT_SUPPORTED);
    } else if (cardStatus.cardState == CardState::PRESENT) {
        ASSERT_TRUE(radioRsp_v1_2->rspInfo.error == RadioError::INVALID_ARGUMENTS ||
                    radioRsp_v1_2->rspInfo.error == RadioError::REQUEST_NOT_SUPPORTED);
    }
}

/*
 * Test IRadio.startNetworkScan() with invalid interval (lower boundary).
 */
TEST_F(RadioHidlTest_v1_2, startNetworkScan_InvalidInterval1) {
    const int serial = GetRandomSerialNumber();

    RadioAccessSpecifier specifier = {
        .radioAccessNetwork = RadioAccessNetworks::GERAN,
        .geranBands = {GeranBands::BAND_450, GeranBands::BAND_480},
        .channels = {1,2}};

    V1_2::NetworkScanRequest request = {
        .type = ScanType::ONE_SHOT,
        .interval = 4,
        .specifiers = {specifier},
        .maxSearchTime = 60,
        .incrementalResults = false,
        .incrementalResultsPeriodicity = 1};

    Return<void> res = radio_v1_2->startNetworkScan_1_2(serial, request);
    ASSERT_OK(res);
    EXPECT_EQ(std::cv_status::no_timeout, wait());
    EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_2->rspInfo.type);
    EXPECT_EQ(serial, radioRsp_v1_2->rspInfo.serial);

    ALOGI("startNetworkScan_InvalidInterval1, rspInfo.error = %s\n",
          toString(radioRsp_v1_2->rspInfo.error).c_str());
    if (cardStatus.cardState == CardState::ABSENT) {
        ASSERT_TRUE(radioRsp_v1_2->rspInfo.error == RadioError::INVALID_ARGUMENTS ||
                    radioRsp_v1_2->rspInfo.error == RadioError::SIM_ABSENT ||
                    radioRsp_v1_2->rspInfo.error == RadioError::OPERATION_NOT_ALLOWED ||
                    radioRsp_v1_2->rspInfo.error == RadioError::REQUEST_NOT_SUPPORTED);
    } else if (cardStatus.cardState == CardState::PRESENT) {
        ASSERT_TRUE(radioRsp_v1_2->rspInfo.error == RadioError::INVALID_ARGUMENTS ||
                    radioRsp_v1_2->rspInfo.error == RadioError::OPERATION_NOT_ALLOWED ||
                    radioRsp_v1_2->rspInfo.error == RadioError::REQUEST_NOT_SUPPORTED);
    }
}

/*
 * Test IRadio.startNetworkScan() with invalid interval (upper boundary).
 */
TEST_F(RadioHidlTest_v1_2, startNetworkScan_InvalidInterval2) {
    const int serial = GetRandomSerialNumber();

    RadioAccessSpecifier specifier = {
        .radioAccessNetwork = RadioAccessNetworks::GERAN,
        .geranBands = {GeranBands::BAND_450, GeranBands::BAND_480},
        .channels = {1,2}};

    V1_2::NetworkScanRequest request = {
        .type = ScanType::ONE_SHOT,
        .interval = 301,
        .specifiers = {specifier},
        .maxSearchTime = 60,
        .incrementalResults = false,
        .incrementalResultsPeriodicity = 1};

    Return<void> res = radio_v1_2->startNetworkScan_1_2(serial, request);
    ASSERT_OK(res);
    EXPECT_EQ(std::cv_status::no_timeout, wait());
    EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_2->rspInfo.type);
    EXPECT_EQ(serial, radioRsp_v1_2->rspInfo.serial);

    ALOGI("startNetworkScan_InvalidInterval2, rspInfo.error = %s\n",
          toString(radioRsp_v1_2->rspInfo.error).c_str());
    if (cardStatus.cardState == CardState::ABSENT) {
        ASSERT_TRUE(radioRsp_v1_2->rspInfo.error == RadioError::INVALID_ARGUMENTS ||
                    radioRsp_v1_2->rspInfo.error == RadioError::SIM_ABSENT ||
                    radioRsp_v1_2->rspInfo.error == RadioError::OPERATION_NOT_ALLOWED ||
                    radioRsp_v1_2->rspInfo.error == RadioError::REQUEST_NOT_SUPPORTED);
    } else if (cardStatus.cardState == CardState::PRESENT) {
        ASSERT_TRUE(radioRsp_v1_2->rspInfo.error == RadioError::INVALID_ARGUMENTS ||
                    radioRsp_v1_2->rspInfo.error == RadioError::OPERATION_NOT_ALLOWED ||
                    radioRsp_v1_2->rspInfo.error == RadioError::REQUEST_NOT_SUPPORTED);
    }
}

/*
 * Test IRadio.startNetworkScan() with invalid max search time (lower boundary).
 */
TEST_F(RadioHidlTest_v1_2, startNetworkScan_InvalidMaxSearchTime1) {
    const int serial = GetRandomSerialNumber();

    RadioAccessSpecifier specifier = {
        .radioAccessNetwork = RadioAccessNetworks::GERAN,
        .geranBands = {GeranBands::BAND_450, GeranBands::BAND_480},
        .channels = {1,2}};

    V1_2::NetworkScanRequest request = {
        .type = ScanType::ONE_SHOT,
        .interval = 60,
        .specifiers = {specifier},
        .maxSearchTime = 59,
        .incrementalResults = false,
        .incrementalResultsPeriodicity = 1};

    Return<void> res = radio_v1_2->startNetworkScan_1_2(serial, request);
    ASSERT_OK(res);
    EXPECT_EQ(std::cv_status::no_timeout, wait());
    EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_2->rspInfo.type);
    EXPECT_EQ(serial, radioRsp_v1_2->rspInfo.serial);

    ALOGI("startNetworkScan_InvalidMaxSearchTime1, rspInfo.error = %s\n",
          toString(radioRsp_v1_2->rspInfo.error).c_str());
    if (cardStatus.cardState == CardState::ABSENT) {
        ASSERT_TRUE(radioRsp_v1_2->rspInfo.error == RadioError::INVALID_ARGUMENTS ||
                    radioRsp_v1_2->rspInfo.error == RadioError::SIM_ABSENT ||
                    radioRsp_v1_2->rspInfo.error == RadioError::OPERATION_NOT_ALLOWED ||
                    radioRsp_v1_2->rspInfo.error == RadioError::REQUEST_NOT_SUPPORTED);
    } else if (cardStatus.cardState == CardState::PRESENT) {
        ASSERT_TRUE(radioRsp_v1_2->rspInfo.error == RadioError::INVALID_ARGUMENTS ||
                    radioRsp_v1_2->rspInfo.error == RadioError::OPERATION_NOT_ALLOWED ||
                    radioRsp_v1_2->rspInfo.error == RadioError::REQUEST_NOT_SUPPORTED);
    }
}

/*
 * Test IRadio.startNetworkScan() with invalid max search time (upper boundary).
 */
TEST_F(RadioHidlTest_v1_2, startNetworkScan_InvalidMaxSearchTime2) {
    const int serial = GetRandomSerialNumber();

    RadioAccessSpecifier specifier = {
        .radioAccessNetwork = RadioAccessNetworks::GERAN,
        .geranBands = {GeranBands::BAND_450, GeranBands::BAND_480},
        .channels = {1,2}};

    V1_2::NetworkScanRequest request = {
        .type = ScanType::ONE_SHOT,
        .interval = 60,
        .specifiers = {specifier},
        .maxSearchTime = 3601,
        .incrementalResults = false,
        .incrementalResultsPeriodicity = 1};

    Return<void> res = radio_v1_2->startNetworkScan_1_2(serial, request);
    ASSERT_OK(res);
    EXPECT_EQ(std::cv_status::no_timeout, wait());
    EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_2->rspInfo.type);
    EXPECT_EQ(serial, radioRsp_v1_2->rspInfo.serial);

    ALOGI("startNetworkScan_InvalidMaxSearchTime2, rspInfo.error = %s\n",
          toString(radioRsp_v1_2->rspInfo.error).c_str());
    if (cardStatus.cardState == CardState::ABSENT) {
        ASSERT_TRUE(radioRsp_v1_2->rspInfo.error == RadioError::INVALID_ARGUMENTS ||
                    radioRsp_v1_2->rspInfo.error == RadioError::SIM_ABSENT ||
                    radioRsp_v1_2->rspInfo.error == RadioError::OPERATION_NOT_ALLOWED ||
                    radioRsp_v1_2->rspInfo.error == RadioError::REQUEST_NOT_SUPPORTED);
    } else if (cardStatus.cardState == CardState::PRESENT) {
        ASSERT_TRUE(radioRsp_v1_2->rspInfo.error == RadioError::INVALID_ARGUMENTS ||
                    radioRsp_v1_2->rspInfo.error == RadioError::OPERATION_NOT_ALLOWED ||
                    radioRsp_v1_2->rspInfo.error == RadioError::REQUEST_NOT_SUPPORTED);
    }
}

/*
 * Test IRadio.startNetworkScan() with invalid periodicity (lower boundary).
 */
TEST_F(RadioHidlTest_v1_2, startNetworkScan_InvalidPeriodicity1) {
    const int serial = GetRandomSerialNumber();

    RadioAccessSpecifier specifier = {
        .radioAccessNetwork = RadioAccessNetworks::GERAN,
        .geranBands = {GeranBands::BAND_450, GeranBands::BAND_480},
        .channels = {1,2}};

    V1_2::NetworkScanRequest request = {
        .type = ScanType::ONE_SHOT,
        .interval = 60,
        .specifiers = {specifier},
        .maxSearchTime = 600,
        .incrementalResults = false,
        .incrementalResultsPeriodicity = 0};

    Return<void> res = radio_v1_2->startNetworkScan_1_2(serial, request);
    ASSERT_OK(res);
    EXPECT_EQ(std::cv_status::no_timeout, wait());
    EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_2->rspInfo.type);
    EXPECT_EQ(serial, radioRsp_v1_2->rspInfo.serial);

    ALOGI("startNetworkScan_InvalidPeriodicity1, rspInfo.error = %s\n",
          toString(radioRsp_v1_2->rspInfo.error).c_str());
    if (cardStatus.cardState == CardState::ABSENT) {
        ASSERT_TRUE(radioRsp_v1_2->rspInfo.error == RadioError::INVALID_ARGUMENTS ||
                    radioRsp_v1_2->rspInfo.error == RadioError::SIM_ABSENT ||
                    radioRsp_v1_2->rspInfo.error == RadioError::OPERATION_NOT_ALLOWED ||
                    radioRsp_v1_2->rspInfo.error == RadioError::REQUEST_NOT_SUPPORTED);
    } else if (cardStatus.cardState == CardState::PRESENT) {
        ASSERT_TRUE(radioRsp_v1_2->rspInfo.error == RadioError::INVALID_ARGUMENTS ||
                    radioRsp_v1_2->rspInfo.error == RadioError::OPERATION_NOT_ALLOWED ||
                    radioRsp_v1_2->rspInfo.error == RadioError::REQUEST_NOT_SUPPORTED);
    }
}

/*
 * Test IRadio.startNetworkScan() with invalid periodicity (upper boundary).
 */
TEST_F(RadioHidlTest_v1_2, startNetworkScan_InvalidPeriodicity2) {
    const int serial = GetRandomSerialNumber();

    RadioAccessSpecifier specifier = {
        .radioAccessNetwork = RadioAccessNetworks::GERAN,
        .geranBands = {GeranBands::BAND_450, GeranBands::BAND_480},
        .channels = {1,2}};

    V1_2::NetworkScanRequest request = {
        .type = ScanType::ONE_SHOT,
        .interval = 60,
        .specifiers = {specifier},
        .maxSearchTime = 600,
        .incrementalResults = false,
        .incrementalResultsPeriodicity = 11};

    Return<void> res = radio_v1_2->startNetworkScan_1_2(serial, request);
    ASSERT_OK(res);
    EXPECT_EQ(std::cv_status::no_timeout, wait());
    EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_2->rspInfo.type);
    EXPECT_EQ(serial, radioRsp_v1_2->rspInfo.serial);

    ALOGI("startNetworkScan_InvalidPeriodicity2, rspInfo.error = %s\n",
          toString(radioRsp_v1_2->rspInfo.error).c_str());
    if (cardStatus.cardState == CardState::ABSENT) {
        ASSERT_TRUE(radioRsp_v1_2->rspInfo.error == RadioError::INVALID_ARGUMENTS ||
                    radioRsp_v1_2->rspInfo.error == RadioError::SIM_ABSENT ||
                    radioRsp_v1_2->rspInfo.error == RadioError::OPERATION_NOT_ALLOWED ||
                    radioRsp_v1_2->rspInfo.error == RadioError::REQUEST_NOT_SUPPORTED);
    } else if (cardStatus.cardState == CardState::PRESENT) {
        ASSERT_TRUE(radioRsp_v1_2->rspInfo.error == RadioError::INVALID_ARGUMENTS ||
                    radioRsp_v1_2->rspInfo.error == RadioError::OPERATION_NOT_ALLOWED ||
                    radioRsp_v1_2->rspInfo.error == RadioError::REQUEST_NOT_SUPPORTED);
    }
}

/*
 * Test IRadio.startNetworkScan() with valid periodicity
 */
TEST_F(RadioHidlTest_v1_2, startNetworkScan_GoodRequest1) {
    const int serial = GetRandomSerialNumber();

    RadioAccessSpecifier specifier = {
        .radioAccessNetwork = RadioAccessNetworks::GERAN,
        .geranBands = {GeranBands::BAND_450, GeranBands::BAND_480},
        .channels = {1,2}};

    V1_2::NetworkScanRequest request = {
        .type = ScanType::ONE_SHOT,
        .interval = 60,
        .specifiers = {specifier},
        .maxSearchTime = 600,
        .incrementalResults = false,
        .incrementalResultsPeriodicity = 10};

    Return<void> res = radio_v1_2->startNetworkScan_1_2(serial, request);
    ASSERT_OK(res);
    EXPECT_EQ(std::cv_status::no_timeout, wait());
    EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_2->rspInfo.type);
    EXPECT_EQ(serial, radioRsp_v1_2->rspInfo.serial);

    ALOGI("startNetworkScan_InvalidArgument, rspInfo.error = %s\n",
          toString(radioRsp_v1_2->rspInfo.error).c_str());
    if (cardStatus.cardState == CardState::ABSENT) {
        ASSERT_TRUE(radioRsp_v1_2->rspInfo.error == RadioError::NONE ||
                    radioRsp_v1_2->rspInfo.error == RadioError::SIM_ABSENT ||
                    radioRsp_v1_2->rspInfo.error == RadioError::OPERATION_NOT_ALLOWED ||
                    radioRsp_v1_2->rspInfo.error == RadioError::REQUEST_NOT_SUPPORTED);
    } else if (cardStatus.cardState == CardState::PRESENT) {
        ASSERT_TRUE(radioRsp_v1_2->rspInfo.error == RadioError::NONE ||
                    radioRsp_v1_2->rspInfo.error == RadioError::OPERATION_NOT_ALLOWED ||
                    radioRsp_v1_2->rspInfo.error == RadioError::REQUEST_NOT_SUPPORTED);
    }
}

/*
 * Test IRadio.startNetworkScan() with valid periodicity and plmns
 */
TEST_F(RadioHidlTest_v1_2, startNetworkScan_GoodRequest2) {
    const int serial = GetRandomSerialNumber();

    RadioAccessSpecifier specifier = {
        .radioAccessNetwork = RadioAccessNetworks::GERAN,
        .geranBands = {GeranBands::BAND_450, GeranBands::BAND_480},
        .channels = {1,2}};

    V1_2::NetworkScanRequest request = {
        .type = ScanType::ONE_SHOT,
        .interval = 60,
        .specifiers = {specifier},
        .maxSearchTime = 600,
        .incrementalResults = false,
        .incrementalResultsPeriodicity = 10,
        .mccMncs = {"310410"}};

    Return<void> res = radio_v1_2->startNetworkScan_1_2(serial, request);
    ASSERT_OK(res);
    EXPECT_EQ(std::cv_status::no_timeout, wait());
    EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_2->rspInfo.type);
    EXPECT_EQ(serial, radioRsp_v1_2->rspInfo.serial);

    ALOGI("startNetworkScan_InvalidArgument, rspInfo.error = %s\n",
          toString(radioRsp_v1_2->rspInfo.error).c_str());
    if (cardStatus.cardState == CardState::ABSENT) {
        ASSERT_TRUE(radioRsp_v1_2->rspInfo.error == RadioError::NONE ||
                    radioRsp_v1_2->rspInfo.error == RadioError::SIM_ABSENT ||
                    radioRsp_v1_2->rspInfo.error == RadioError::OPERATION_NOT_ALLOWED ||
                    radioRsp_v1_2->rspInfo.error == RadioError::REQUEST_NOT_SUPPORTED);
    } else if (cardStatus.cardState == CardState::PRESENT) {
        ASSERT_TRUE(radioRsp_v1_2->rspInfo.error == RadioError::NONE ||
                    radioRsp_v1_2->rspInfo.error == RadioError::OPERATION_NOT_ALLOWED ||
                    radioRsp_v1_2->rspInfo.error == RadioError::REQUEST_NOT_SUPPORTED);
    }
}
+67 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <radio_hidl_hal_utils_v1_2.h>

void RadioHidlTest_v1_2::SetUp() {
    radio_v1_2 = ::testing::VtsHalHidlTargetTestBase::getService<V1_2::IRadio>(
        hidl_string(RADIO_SERVICE_NAME));
    ASSERT_NE(nullptr, radio_v1_2.get());

    radioRsp_v1_2 = new (std::nothrow) RadioResponse_v1_2(*this);
    ASSERT_NE(nullptr, radioRsp_v1_2.get());

    count_ = 0;

    radioInd_v1_2 = new (std::nothrow) RadioIndication_v1_2(*this);
    ASSERT_NE(nullptr, radioInd_v1_2.get());

    radio_v1_2->setResponseFunctions(radioRsp_v1_2, radioInd_v1_2);

    int serial = GetRandomSerialNumber();
    radio_v1_2->getIccCardStatus(serial);
    EXPECT_EQ(std::cv_status::no_timeout, wait());
    EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_2->rspInfo.type);
    EXPECT_EQ(serial, radioRsp_v1_2->rspInfo.serial);
    EXPECT_EQ(RadioError::NONE, radioRsp_v1_2->rspInfo.error);
}

/*
 * Notify that the response message is received.
 */
void RadioHidlTest_v1_2::notify() {
    std::unique_lock<std::mutex> lock(mtx_);
    count_++;
    cv_.notify_one();
}

/*
 * Wait till the response message is notified or till TIMEOUT_PERIOD.
 */
std::cv_status RadioHidlTest_v1_2::wait() {
    std::unique_lock<std::mutex> lock(mtx_);

    std::cv_status status = std::cv_status::no_timeout;
    auto now = std::chrono::system_clock::now();
    while (count_ == 0) {
        status = cv_.wait_until(lock, now + std::chrono::seconds(TIMEOUT_PERIOD));
        if (status == std::cv_status::timeout) {
            return status;
        }
    }
    count_--;
    return status;
}
+552 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading