Merge "Add VHAL_SUPPORTED_PROPERTY_IDS to ref VHAL." into tm-qpr-dev

This commit is contained in:
Yu Shan
2022-09-14 18:49:56 +00:00
committed by Android (Google) Code Review
4 changed files with 120 additions and 2 deletions

View File

@@ -84,7 +84,10 @@ cc_library_static {
name: "android.hardware.automotive.vehicle@2.0-default-impl-lib",
vendor: true,
defaults: ["vhal_v2_0_target_defaults"],
cflags: ["-DENABLE_VENDOR_CLUSTER_PROPERTY_FOR_TESTING"],
cflags: [
"-DENABLE_VENDOR_CLUSTER_PROPERTY_FOR_TESTING",
"-DENABLE_GET_PROP_CONFIGS_BY_MULTIPLE_REQUESTS",
],
srcs: [
"impl/vhal_v2_0/DefaultVehicleHal.cpp",
"impl/vhal_v2_0/VehicleHalClient.cpp",
@@ -225,6 +228,25 @@ cc_test {
test_suites: ["general-tests"],
}
cc_test {
name: "android.hardware.automotive.vehicle@2.0-default-config-test",
vendor: true,
defaults: ["vhal_v2_0_target_defaults"],
srcs: [
"impl/vhal_v2_0/tests/DefaultConfigSupportedPropertyIds_test.cpp",
],
cflags: [
"-DENABLE_VENDOR_CLUSTER_PROPERTY_FOR_TESTING",
"-DENABLE_GET_PROP_CONFIGS_BY_MULTIPLE_REQUESTS",
],
static_libs: [
"android.hardware.automotive.vehicle@2.0-default-impl-lib",
"libgtest",
"libgmock",
],
test_suites: ["general-tests"],
}
cc_binary {
name: "android.hardware.automotive.vehicle@2.0-default-service",
defaults: ["vhal_v2_0_target_defaults"],

View File

@@ -1170,6 +1170,46 @@ const ConfigDeclaration kVehicleProperties[]{
},
},
#endif // ENABLE_VENDOR_CLUSTER_PROPERTY_FOR_TESTING
#ifdef ENABLE_GET_PROP_CONFIGS_BY_MULTIPLE_REQUESTS
{
.config =
{
// VHAL_SUPPORTED_PROPERTY_IDS
.prop = 289476424,
.access = VehiclePropertyAccess::READ,
.changeMode = VehiclePropertyChangeMode::STATIC,
// Fetch 100 configs in one request. This number is just arbitrarily
// chosen here. But some HAL impl with bigger config data may need a
// smaller number.
.configArray = {100},
},
// All supported property IDs. This list is checked by
// DefaultConfigSupportedPropertyIds_test.
.initialValue =
{.int32Values =
{291504388, 289472773, 291504390, 289472775, 289407240, 289407241,
289472780, 286261505, 286261506, 289407235, 289472779, 291504647,
289408517, 356518832, 356516106, 291504644, 291504649, 291504656,
291504901, 291504903, 287310600, 291504905, 287310602, 287310603,
291504908, 291504904, 392168201, 392168202, 289408514, 289408001,
287310850, 287310851, 287310853, 289475088, 289475104, 289475120,
354419984, 320865540, 320865556, 354419975, 354419976, 354419986,
354419973, 354419974, 354419978, 354419977, 356517120, 356517121,
356582673, 356517139, 289408269, 356517131, 358614275, 291570965,
291505923, 289408270, 289408512, 287310855, 289408000, 289408008,
289408009, 289407747, 291504900, 568332561, 371198722, 373295872,
320867268, 322964416, 290521862, 287310858, 287310859, 289475072,
289475073, 289409539, 299896064, 299896065, 299896066, 299896067,
289410560, 289410561, 289410562, 289410563, 289410576, 289410577,
289410578, 289410579, 289476368, 299895808, 639631617, 627048706,
591397123, 554696964, 289410873, 289410874, 287313669, 299896583,
299896584, 299896585, 299896586, 299896587, 286265121, 286265122,
286265123, 290457094, 290459441, 299896626, 290459443, 289410868,
289476405, 299896630, 289410871, 292556600, 557853201, 559950353,
555756049, 554707473, 289410887, 557846324, 557911861, 568332086,
557846327, 560992056, 289476424}},
},
#endif // ENABLE_GET_PROP_CONFIGS_BY_MULTIPLE_REQUESTS
};
} // impl

View File

@@ -0,0 +1,56 @@
/*
* Copyright (C) 2022 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <vector>
#include "vhal_v2_0/DefaultConfig.h"
namespace android {
namespace hardware {
namespace automotive {
namespace vehicle {
namespace V2_0 {
namespace impl {
using ::testing::ElementsAreArray;
// Test that VHAL_SUPPORTED_PROPERTY_IDS contains all supported property IDs.
TEST(DefaultConfigSupportedPropertyIdsTest, testIncludeAllSupportedIds) {
const int32_t vhalSupportedPropertyIdsPropId = 289476424;
std::vector<int32_t> allSupportedIds;
std::vector<int32_t> configuredSupportedIds;
for (const auto& property : impl::kVehicleProperties) {
int propId = property.config.prop;
allSupportedIds.push_back(propId);
if (propId == vhalSupportedPropertyIdsPropId) {
configuredSupportedIds = property.initialValue.int32Values;
}
}
ASSERT_THAT(allSupportedIds, ElementsAreArray(configuredSupportedIds));
}
} // namespace impl
} // namespace V2_0
} // namespace vehicle
} // namespace automotive
} // namespace hardware
} // namespace android

View File

@@ -141,7 +141,7 @@ class DefaultVhalImplTest : public ::testing::Test {
TEST_F(DefaultVhalImplTest, testListProperties) {
std::vector<VehiclePropConfig> configs = mHal->listProperties();
EXPECT_EQ((size_t)122, configs.size());
EXPECT_EQ((size_t)123, configs.size());
}
TEST_F(DefaultVhalImplTest, testGetDefaultPropertyFloat) {