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

Commit 8110a43c authored by Yu Shan's avatar Yu Shan Committed by Android (Google) Code Review
Browse files

Merge "Test only defined system propIds are supported." into main

parents c4069e8c f3698fd0
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ cc_test {
    ],
    static_libs: [
        "libgtest",
        "libgmock",
        "libvhalclient",
    ],
    shared_libs: [
@@ -41,6 +42,9 @@ cc_test {
        "use_libaidlvintf_gtest_helper_static",
        "vhalclient_defaults",
    ],
    header_libs: [
        "IVehicleGeneratedHeaders",
    ],
    test_suites: [
        "general-tests",
        "vts",
+41 −0
Original line number Diff line number Diff line
@@ -19,12 +19,14 @@
#include <IVhalClient.h>
#include <VehicleHalTypes.h>
#include <VehicleUtils.h>
#include <VersionForVehicleProperty.h>
#include <aidl/Gtest.h>
#include <aidl/Vintf.h>
#include <aidl/android/hardware/automotive/vehicle/IVehicle.h>
#include <android-base/stringprintf.h>
#include <android-base/thread_annotations.h>
#include <android/binder_process.h>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <hidl/GtestPrinter.h>
#include <hidl/ServiceManagement.h>
@@ -47,6 +49,7 @@ using ::aidl::android::hardware::automotive::vehicle::VehiclePropertyAccess;
using ::aidl::android::hardware::automotive::vehicle::VehiclePropertyChangeMode;
using ::aidl::android::hardware::automotive::vehicle::VehiclePropertyGroup;
using ::aidl::android::hardware::automotive::vehicle::VehiclePropertyType;
using ::aidl::android::hardware::automotive::vehicle::VersionForVehicleProperty;
using ::android::getAidlHalInstanceNames;
using ::android::base::ScopedLockAssertion;
using ::android::base::StringPrintf;
@@ -58,7 +61,10 @@ using ::android::frameworks::automotive::vhal::ISubscriptionCallback;
using ::android::frameworks::automotive::vhal::IVhalClient;
using ::android::hardware::getAllHalInstanceNames;
using ::android::hardware::Sanitize;
using ::android::hardware::automotive::vehicle::isSystemProp;
using ::android::hardware::automotive::vehicle::propIdToString;
using ::android::hardware::automotive::vehicle::toInt;
using ::testing::Ge;

constexpr int32_t kInvalidProp = 0x31600207;

@@ -202,6 +208,41 @@ TEST_P(VtsHalAutomotiveVehicleTargetTest, getPropConfigsWithInvalidProp) {
    ASSERT_NE(result.error().message(), "") << "Expect error message not to be empty";
}

// Test system property IDs returned by getPropConfigs() are defined in the VHAL property interface.
TEST_P(VtsHalAutomotiveVehicleTargetTest, testPropConfigs_onlyDefinedSystemPropertyIdsReturned) {
    if (!mVhalClient->isAidlVhal()) {
        GTEST_SKIP() << "Skip for HIDL VHAL because HAL interface run-time version is only"
                     << "introduced for AIDL";
    }

    auto result = mVhalClient->getAllPropConfigs();
    ASSERT_TRUE(result.ok()) << "Failed to get all property configs, error: "
                             << result.error().message();

    int32_t vhalVersion = mVhalClient->getRemoteInterfaceVersion();
    const auto& configs = result.value();
    for (size_t i = 0; i < configs.size(); i++) {
        int32_t propId = configs[i]->getPropId();
        if (!isSystemProp(propId)) {
            continue;
        }

        std::string propName = propIdToString(propId);
        auto it = VersionForVehicleProperty.find(static_cast<VehicleProperty>(propId));
        bool found = (it != VersionForVehicleProperty.end());
        EXPECT_TRUE(found) << "System Property: " << propName
                           << " is not defined in VHAL property interface";
        if (!found) {
            continue;
        }
        int32_t requiredVersion = it->second;
        EXPECT_THAT(vhalVersion, Ge(requiredVersion))
                << "System Property: " << propName << " requires VHAL version: " << requiredVersion
                << ", but the current VHAL version"
                << " is " << vhalVersion << ", must not be supported";
    }
}

// Test get() return current value for properties.
TEST_P(VtsHalAutomotiveVehicleTargetTest, get) {
    ALOGD("VtsHalAutomotiveVehicleTargetTest::get");