1 /*
2  * Copyright (C) 2021 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include <VehicleHalTypes.h>
18 #include <VehicleUtils.h>
19 
20 #include <android/binder_enums.h>
21 #include <android/hardware/automotive/vehicle/2.0/types.h>
22 #include <gtest/gtest.h>
23 #include <hidl/HidlSupport.h>
24 
25 namespace hidl_vehicle = ::android::hardware::automotive::vehicle::V2_0;
26 namespace aidl_vehicle = ::aidl::android::hardware::automotive::vehicle;
27 using ::android::hardware::hidl_enum_range;
28 using ::ndk::enum_range;
29 
TEST(AidlHidlCompatibilityTest,testHidlPropertiesDefinedInAidl)30 TEST(AidlHidlCompatibilityTest, testHidlPropertiesDefinedInAidl) {
31     for (const auto prop : hidl_enum_range<hidl_vehicle::VehicleProperty>()) {
32         int propInt = ::android::hardware::automotive::vehicle::toInt(prop);
33         auto aidlProperties = enum_range<aidl_vehicle::VehicleProperty>();
34 
35         ASSERT_NE(std::find(aidlProperties.begin(), aidlProperties.end(),
36                             static_cast<aidl_vehicle::VehicleProperty>(propInt)),
37                   aidlProperties.end())
38                 << "property: " << propInt << " defined in HIDL, but not defined in AIDL";
39     }
40 }
41