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

Commit 7b8c1f81 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Clean up VtsHalRadioTargetTest" into udc-dev

parents b4507146 bb35a437
Loading
Loading
Loading
Loading
+15 −2
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@
#define LOG_TAG "RadioTest"

#include "radio_aidl_hal_utils.h"
#include <iostream>
#include "VtsCoreUtil.h"
#include "radio_config_utils.h"
#include "radio_sim_utils.h"
@@ -144,11 +143,25 @@ bool isServiceValidForDeviceConfiguration(std::string& serviceName) {
    return true;
}

void RadioServiceTest::SetUp() {
    ALOGD("BEGIN %s#%s", ::testing::UnitTest::GetInstance()->current_test_info()->test_suite_name(),
          ::testing::UnitTest::GetInstance()->current_test_info()->name());
    count_ = 0;
    serial = -1;
}

void RadioServiceTest::TearDown() {
    count_ = 0;
    serial = -1;
    ALOGD("END %s#%s", ::testing::UnitTest::GetInstance()->current_test_info()->test_suite_name(),
          ::testing::UnitTest::GetInstance()->current_test_info()->name());
}

/*
 * Notify that the response message is received.
 */
void RadioServiceTest::notify(int receivedSerial) {
    std::unique_lock<std::mutex> lock(mtx_);
    std::lock_guard<std::mutex> lock(mtx_);
    if (serial == receivedSerial) {
        count_++;
        cv_.notify_one();
+8 −4
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@
#include <aidl/android/hardware/radio/sim/CardStatus.h>
#include <aidl/android/hardware/radio/sim/IRadioSim.h>
#include <utils/Log.h>
#include <vector>

using namespace aidl::android::hardware::radio;
using aidl::android::hardware::radio::config::SimSlotStatus;
@@ -133,14 +132,15 @@ bool isServiceValidForDeviceConfiguration(std::string& serviceName);
/**
 * RadioServiceTest base class
 */
class RadioServiceTest {
class RadioServiceTest : public ::testing::TestWithParam<std::string> {
  protected:
    std::mutex mtx_;
    std::condition_variable cv_;
    std::shared_ptr<config::IRadioConfig> radio_config;
    std::shared_ptr<sim::IRadioSim> radio_sim;

  public:
    void SetUp() override;
    void TearDown() override;

    /* Used as a mechanism to inform the test about data/event callback */
    void notify(int receivedSerial);

@@ -155,4 +155,8 @@ class RadioServiceTest {

    /* Update SIM slot status */
    void updateSimSlotStatus(int physicalSlotId);

  private:
    std::mutex mtx_;
    std::condition_variable cv_;
};
+1 −3
Original line number Diff line number Diff line
@@ -14,7 +14,6 @@
 * limitations under the License.
 */

#include <android-base/logging.h>
#include <android/binder_manager.h>

#include "radio_config_utils.h"
@@ -22,6 +21,7 @@
#define ASSERT_OK(ret) ASSERT_TRUE(ret.isOk())

void RadioConfigTest::SetUp() {
    RadioServiceTest::SetUp();
    std::string serviceName = GetParam();

    radio_config = IRadioConfig::fromBinder(
@@ -31,8 +31,6 @@ void RadioConfigTest::SetUp() {
    radioRsp_config = ndk::SharedRefBase::make<RadioConfigResponse>(*this);
    ASSERT_NE(nullptr, radioRsp_config.get());

    count_ = 0;

    radioInd_config = ndk::SharedRefBase::make<RadioConfigIndication>(*this);
    ASSERT_NE(nullptr, radioInd_config.get());

+3 −2
Original line number Diff line number Diff line
@@ -74,9 +74,10 @@ class RadioConfigIndication : public BnRadioConfigIndication {
};

// The main test class for Radio AIDL Config.
class RadioConfigTest : public ::testing::TestWithParam<std::string>, public RadioServiceTest {
class RadioConfigTest : public RadioServiceTest {
  public:
    virtual void SetUp() override;
    void SetUp() override;

    ndk::ScopedAStatus updateSimCardStatus();
    /* Override updateSimSlotStatus in RadioServiceTest to not call setResponseFunctions */
    void updateSimSlotStatus();
+1 −7
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
#include <aidl/android/hardware/radio/RadioAccessFamily.h>
#include <aidl/android/hardware/radio/config/IRadioConfig.h>
#include <aidl/android/hardware/radio/data/ApnTypes.h>
#include <android-base/logging.h>
#include <android/binder_manager.h>

#include "radio_data_utils.h"
@@ -25,6 +24,7 @@
#define ASSERT_OK(ret) ASSERT_TRUE(ret.isOk())

void RadioDataTest::SetUp() {
    RadioServiceTest::SetUp();
    std::string serviceName = GetParam();

    if (!isServiceValidForDeviceConfiguration(serviceName)) {
@@ -39,8 +39,6 @@ void RadioDataTest::SetUp() {
    radioRsp_data = ndk::SharedRefBase::make<RadioDataResponse>(*this);
    ASSERT_NE(nullptr, radioRsp_data.get());

    count_ = 0;

    radioInd_data = ndk::SharedRefBase::make<RadioDataIndication>(*this);
    ASSERT_NE(nullptr, radioInd_data.get());

@@ -555,7 +553,6 @@ TEST_P(RadioDataTest, stopKeepalive) {
 * Test IRadioData.getDataCallList() for the response returned.
 */
TEST_P(RadioDataTest, getDataCallList) {
    LOG(DEBUG) << "getDataCallList";
    serial = GetRandomSerialNumber();

    radio_data->getDataCallList(serial);
@@ -569,14 +566,12 @@ TEST_P(RadioDataTest, getDataCallList) {
                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;

@@ -589,5 +584,4 @@ TEST_P(RadioDataTest, setDataAllowed) {
    if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
        EXPECT_EQ(RadioError::NONE, radioRsp_data->rspInfo.error);
    }
    LOG(DEBUG) << "setDataAllowed finished";
}
Loading