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

Commit 9df12155 authored by Yu Shan's avatar Yu Shan
Browse files

Generate Java/Cpp files for VehicleProperty annotations.

Extract annotations for each property and put them into a map.

We need to use these generated files in car service code and VTS
code.

Flag: EXEMPT internal change
Test: atest VehiclePropertyAnnotationCppTest \
VehiclePropertyAnnotationJavaTest
Bug: 388603905

Change-Id: Iadea6b4de182afaf006d9d9603d014e84e307fd9
parent 7044769e
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -43,6 +43,10 @@ cc_test {
    team: "trendy_team_aaos_carframework_triage",
    srcs: ["VehiclePropertyAnnotationCppTest.cpp"],
    header_libs: ["IVehicleGeneratedHeaders-V4"],
    static_libs: [
        "libgtest",
        "libgmock",
    ],
    defaults: ["VehicleHalInterfaceDefaults"],
    test_suites: ["general-tests"],
}
+12 −0
Original line number Diff line number Diff line
@@ -15,16 +15,20 @@
 */

#include <AccessForVehicleProperty.h>
#include <AnnotationsForVehicleProperty.h>
#include <ChangeModeForVehicleProperty.h>

#include <aidl/android/hardware/automotive/vehicle/VehicleProperty.h>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <unordered_set>

namespace aidl_vehicle = ::aidl::android::hardware::automotive::vehicle;
using aidl_vehicle::AccessForVehicleProperty;
using aidl_vehicle::AnnotationsForVehicleProperty;
using aidl_vehicle::ChangeModeForVehicleProperty;
using aidl_vehicle::VehicleProperty;
using testing::IsEmpty;

namespace {
    template<class T>
@@ -54,3 +58,11 @@ TEST(VehiclePropertyAnnotationCppTest, testAccess) {
            << "Outdated annotation-generated AIDL files. Please run "
            << "generate_annotation_enums.py to update.";
}

TEST(VehiclePropertyAnnotationCppTest, testAnnotations) {
    for (const auto& [propertyId, annotations] : AnnotationsForVehicleProperty) {
        ASSERT_THAT(annotations, Not(IsEmpty()))
                << "annotations set for property: " << aidl_vehicle::toString(propertyId)
                << " must not be empty";
    }
}
+11 −0
Original line number Diff line number Diff line
@@ -57,4 +57,15 @@ public class VehiclePropertyAnnotationJavaTest {
                .that(doesAnnotationMapContainsAllProps(AccessForVehicleProperty.values))
                .isTrue();
    }

    @Test
    @SmallTest
    public void testAnnotations() {
        for (int propertyId : AnnotationsForVehicleProperty.values.keySet()) {
            assertWithMessage("annotations set for property: "
                    + VehicleProperty.$.toString(propertyId) + " must not be empty")
                    .that(AnnotationsForVehicleProperty.values.get(propertyId))
                    .isNotEmpty();
        }
    }
}
 No newline at end of file
+327 −0

File added.

Preview size limit exceeded, changes collapsed.

+315 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading