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
diff --git a/automotive/vehicle/aidl/aidl_test/Android.bp b/automotive/vehicle/aidl/aidl_test/Android.bp
index a87af02..d3ce307 100644
--- a/automotive/vehicle/aidl/aidl_test/Android.bp
+++ b/automotive/vehicle/aidl/aidl_test/Android.bp
@@ -43,6 +43,10 @@
team: "trendy_team_aaos_carframework_triage",
srcs: ["VehiclePropertyAnnotationCppTest.cpp"],
header_libs: ["IVehicleGeneratedHeaders-V4"],
+ static_libs: [
+ "libgtest",
+ "libgmock",
+ ],
defaults: ["VehicleHalInterfaceDefaults"],
test_suites: ["general-tests"],
}
diff --git a/automotive/vehicle/aidl/aidl_test/VehiclePropertyAnnotationCppTest.cpp b/automotive/vehicle/aidl/aidl_test/VehiclePropertyAnnotationCppTest.cpp
index a4bbbe8..2aad2b6 100644
--- a/automotive/vehicle/aidl/aidl_test/VehiclePropertyAnnotationCppTest.cpp
+++ b/automotive/vehicle/aidl/aidl_test/VehiclePropertyAnnotationCppTest.cpp
@@ -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 @@
<< "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";
+ }
+}
diff --git a/automotive/vehicle/aidl/aidl_test/VehiclePropertyAnnotationJavaTest.java b/automotive/vehicle/aidl/aidl_test/VehiclePropertyAnnotationJavaTest.java
index ef49299..8aab7ad 100644
--- a/automotive/vehicle/aidl/aidl_test/VehiclePropertyAnnotationJavaTest.java
+++ b/automotive/vehicle/aidl/aidl_test/VehiclePropertyAnnotationJavaTest.java
@@ -57,4 +57,15 @@
.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