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

Commit 2df8266c authored by Yu Shan's avatar Yu Shan
Browse files

Generate cpp header file for supported enums.

Auto generate cpp header files for getting supported enum values
for property ID and use this in VTS test to verify the
supportedEnumValues are populated correctly.

Flag: EXEMPT VTS
Test: atest VehiclePropertyAnnotationCppTest \
VtsHalAutomotiveVehicle_TargetTest
Bug: 381123190

Change-Id: I55fa28b75e2e2c668a5f53d1fffcc8fb74c10de5
parent a1b3730a
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ cc_test {
    srcs: ["VehiclePropertyAnnotationCppTest.cpp"],
    header_libs: ["IVehicleGeneratedHeaders-V4"],
    static_libs: [
        "VehicleHalUtils",
        "libgtest",
        "libgmock",
    ],
+15 −0
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@
#include <AccessForVehicleProperty.h>
#include <AnnotationsForVehicleProperty.h>
#include <ChangeModeForVehicleProperty.h>
#include <EnumForVehicleProperty.h>
#include <VehicleHalTypes.h>

#include <aidl/android/hardware/automotive/vehicle/VehicleProperty.h>
#include <gmock/gmock.h>
@@ -73,3 +75,16 @@ TEST(VehiclePropertyAnnotationCppTest, testAnnotations) {
                << " must not be empty";
    }
}

TEST(VehiclePropertyAnnotationCppTest, testSupportedEnums) {
    auto supportedEnums =
            aidl_vehicle::getSupportedEnumValuesForProperty(VehicleProperty::INFO_FUEL_TYPE);
    // We only listed part of the fuel type values here. This is enough to verify that the
    // generated code is correct.
    ASSERT_THAT(supportedEnums,
                ::testing::IsSupersetOf(
                        {static_cast<int64_t>(aidl_vehicle::FuelType::FUEL_TYPE_UNLEADED),
                         static_cast<int64_t>(aidl_vehicle::FuelType::FUEL_TYPE_LEADED),
                         static_cast<int64_t>(aidl_vehicle::FuelType::FUEL_TYPE_DIESEL_1),
                         static_cast<int64_t>(aidl_vehicle::FuelType::FUEL_TYPE_DIESEL_2)}));
}
+1 −1
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 The Android Open Source Project
 * Copyright (C) 2025 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.
+1 −1
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 The Android Open Source Project
 * Copyright (C) 2025 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.
+1 −1
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 The Android Open Source Project
 * Copyright (C) 2025 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.
Loading