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

Commit fb59ad7e authored by Yu Shan's avatar Yu Shan Committed by Automerger Merge Worker
Browse files

Allow CDD required properties to be absent in VTS. am: da7a4dda am: 7473a3f1

parents 29161eeb 7473a3f1
Loading
Loading
Loading
Loading
+50 −23
Original line number Original line Diff line number Diff line
@@ -112,6 +112,9 @@ class VtsVehicleCallback final : public ISubscriptionCallback {
};
};


class VtsHalAutomotiveVehicleTargetTest : public testing::TestWithParam<ServiceDescriptor> {
class VtsHalAutomotiveVehicleTargetTest : public testing::TestWithParam<ServiceDescriptor> {
protected:
  bool checkIsSupported(int32_t propertyId);

public:
public:
  virtual void SetUp() override {
  virtual void SetUp() override {
      auto descriptor = GetParam();
      auto descriptor = GetParam();
@@ -149,7 +152,7 @@ TEST_P(VtsHalAutomotiveVehicleTargetTest, useHidlBackend) {
    }
    }
}
}


// Test getAllPropConfig() returns at least 4 property configs.
// Test getAllPropConfigs() returns at least 1 property configs.
TEST_P(VtsHalAutomotiveVehicleTargetTest, getAllPropConfigs) {
TEST_P(VtsHalAutomotiveVehicleTargetTest, getAllPropConfigs) {
    ALOGD("VtsHalAutomotiveVehicleTargetTest::getAllPropConfigs");
    ALOGD("VtsHalAutomotiveVehicleTargetTest::getAllPropConfigs");


@@ -157,25 +160,31 @@ TEST_P(VtsHalAutomotiveVehicleTargetTest, getAllPropConfigs) {


    ASSERT_TRUE(result.ok()) << "Failed to get all property configs, error: "
    ASSERT_TRUE(result.ok()) << "Failed to get all property configs, error: "
                             << result.error().message();
                             << result.error().message();
    ASSERT_GE(result.value().size(), 4u) << StringPrintf(
    ASSERT_GE(result.value().size(), 1u)
            "Expect to get at least 4 property configs, got %zu", result.value().size());
          << StringPrintf("Expect to get at least 1 property config, got %zu",
                          result.value().size());
}
}


// Test getPropConfigs() can query all properties listed in CDD.
// Test getPropConfigs() can query properties returned by getAllPropConfigs.
TEST_P(VtsHalAutomotiveVehicleTargetTest, getRequiredPropConfigs) {
TEST_P(VtsHalAutomotiveVehicleTargetTest, getPropConfigsWithValidProps) {
    ALOGD("VtsHalAutomotiveVehicleTargetTest::getRequiredPropConfigs");
    ALOGD("VtsHalAutomotiveVehicleTargetTest::getRequiredPropConfigs");


    // Check the properties listed in CDD
    std::vector<int32_t> properties;
    std::vector<int32_t> properties = {
    auto result = mVhalClient->getAllPropConfigs();
            toInt(VehicleProperty::GEAR_SELECTION), toInt(VehicleProperty::NIGHT_MODE),

            toInt(VehicleProperty::PARKING_BRAKE_ON), toInt(VehicleProperty::PERF_VEHICLE_SPEED)};
    ASSERT_TRUE(result.ok()) << "Failed to get all property configs, error: "
                             << result.error().message();
    for (const auto& cfgPtr : result.value()) {
        properties.push_back(cfgPtr->getPropId());
    }


    auto result = mVhalClient->getPropConfigs(properties);
    result = mVhalClient->getPropConfigs(properties);


    ASSERT_TRUE(result.ok()) << "Failed to get required property config, error: "
    ASSERT_TRUE(result.ok()) << "Failed to get required property config, error: "
                             << result.error().message();
                             << result.error().message();
    ASSERT_EQ(result.value().size(), 4u)
    ASSERT_EQ(result.value().size(), properties.size())
            << StringPrintf("Expect to get exactly 4 configs, got %zu", result.value().size());
          << StringPrintf("Expect to get exactly %zu configs, got %zu",
                          properties.size(), result.value().size());
}
}


// Test getPropConfig() with an invalid propertyId returns an error code.
// Test getPropConfig() with an invalid propertyId returns an error code.
@@ -194,6 +203,9 @@ TEST_P(VtsHalAutomotiveVehicleTargetTest, get) {
    ALOGD("VtsHalAutomotiveVehicleTargetTest::get");
    ALOGD("VtsHalAutomotiveVehicleTargetTest::get");


    int32_t propId = toInt(VehicleProperty::PERF_VEHICLE_SPEED);
    int32_t propId = toInt(VehicleProperty::PERF_VEHICLE_SPEED);
    if (!checkIsSupported(propId)) {
        GTEST_SKIP() << "Property: " << propId << " is not supported, skip the test";
    }
    auto result = mVhalClient->getValueSync(*mVhalClient->createHalPropValue(propId));
    auto result = mVhalClient->getValueSync(*mVhalClient->createHalPropValue(propId));


    ASSERT_TRUE(result.ok()) << StringPrintf("Failed to get value for property: %" PRId32
    ASSERT_TRUE(result.ok()) << StringPrintf("Failed to get value for property: %" PRId32
@@ -279,6 +291,10 @@ TEST_P(VtsHalAutomotiveVehicleTargetTest, setNotWritableProp) {
    ALOGD("VtsHalAutomotiveVehicleTargetTest::setNotWritableProp");
    ALOGD("VtsHalAutomotiveVehicleTargetTest::setNotWritableProp");


    int32_t propId = toInt(VehicleProperty::PERF_VEHICLE_SPEED);
    int32_t propId = toInt(VehicleProperty::PERF_VEHICLE_SPEED);
    if (!checkIsSupported(propId)) {
        GTEST_SKIP() << "Property: " << propId << " is not supported, skip the test";
    }

    auto getValueResult = mVhalClient->getValueSync(*mVhalClient->createHalPropValue(propId));
    auto getValueResult = mVhalClient->getValueSync(*mVhalClient->createHalPropValue(propId));
    ASSERT_TRUE(getValueResult.ok())
    ASSERT_TRUE(getValueResult.ok())
            << StringPrintf("Failed to get value for property: %" PRId32 ", error: %s", propId,
            << StringPrintf("Failed to get value for property: %" PRId32 ", error: %s", propId,
@@ -295,6 +311,9 @@ TEST_P(VtsHalAutomotiveVehicleTargetTest, subscribeAndUnsubscribe) {
    ALOGD("VtsHalAutomotiveVehicleTargetTest::subscribeAndUnsubscribe");
    ALOGD("VtsHalAutomotiveVehicleTargetTest::subscribeAndUnsubscribe");


    int32_t propId = toInt(VehicleProperty::PERF_VEHICLE_SPEED);
    int32_t propId = toInt(VehicleProperty::PERF_VEHICLE_SPEED);
    if (!checkIsSupported(propId)) {
        GTEST_SKIP() << "Property: " << propId << " is not supported, skip the test";
    }


    auto propConfigsResult = mVhalClient->getPropConfigs({propId});
    auto propConfigsResult = mVhalClient->getPropConfigs({propId});


@@ -384,6 +403,9 @@ TEST_P(VtsHalAutomotiveVehicleTargetTest, testGetValuesTimestampAIDL) {
    }
    }


    int32_t propId = toInt(VehicleProperty::PARKING_BRAKE_ON);
    int32_t propId = toInt(VehicleProperty::PARKING_BRAKE_ON);
    if (!checkIsSupported(propId)) {
        GTEST_SKIP() << "Property: " << propId << " is not supported, skip the test";
    }
    auto prop = mVhalClient->createHalPropValue(propId);
    auto prop = mVhalClient->createHalPropValue(propId);


    auto result = mVhalClient->getValueSync(*prop);
    auto result = mVhalClient->getValueSync(*prop);
@@ -419,6 +441,11 @@ TEST_P(VtsHalAutomotiveVehicleTargetTest, testGetValuesTimestampAIDL) {
    }
    }
}
}


bool VtsHalAutomotiveVehicleTargetTest::checkIsSupported(int32_t propertyId) {
  auto result = mVhalClient->getPropConfigs({propertyId});
  return result.ok();
}

std::vector<ServiceDescriptor> getDescriptors() {
std::vector<ServiceDescriptor> getDescriptors() {
    std::vector<ServiceDescriptor> descriptors;
    std::vector<ServiceDescriptor> descriptors;
    for (std::string name : getAidlHalInstanceNames(IVehicle::descriptor)) {
    for (std::string name : getAidlHalInstanceNames(IVehicle::descriptor)) {