Yu Shan | 726d51a | 2022-02-22 17:37:21 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2022 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 | #define LOG_TAG "VtsHalAutomotiveVehicle" |
| 18 | |
| 19 | #include <IVhalClient.h> |
| 20 | #include <VehicleHalTypes.h> |
| 21 | #include <VehicleUtils.h> |
| 22 | #include <aidl/Gtest.h> |
| 23 | #include <aidl/Vintf.h> |
| 24 | #include <aidl/android/hardware/automotive/vehicle/IVehicle.h> |
| 25 | #include <android-base/stringprintf.h> |
| 26 | #include <android-base/thread_annotations.h> |
| 27 | #include <android/binder_process.h> |
| 28 | #include <gtest/gtest.h> |
| 29 | #include <hidl/GtestPrinter.h> |
| 30 | #include <hidl/ServiceManagement.h> |
| 31 | #include <inttypes.h> |
| 32 | #include <utils/Log.h> |
Yu Shan | 4569ef5 | 2022-03-18 14:34:25 -0700 | [diff] [blame] | 33 | #include <utils/SystemClock.h> |
Yu Shan | 726d51a | 2022-02-22 17:37:21 -0800 | [diff] [blame] | 34 | |
| 35 | #include <chrono> |
| 36 | #include <mutex> |
| 37 | #include <unordered_map> |
| 38 | #include <unordered_set> |
| 39 | #include <vector> |
| 40 | |
| 41 | using ::aidl::android::hardware::automotive::vehicle::IVehicle; |
| 42 | using ::aidl::android::hardware::automotive::vehicle::StatusCode; |
| 43 | using ::aidl::android::hardware::automotive::vehicle::SubscribeOptions; |
| 44 | using ::aidl::android::hardware::automotive::vehicle::VehicleArea; |
| 45 | using ::aidl::android::hardware::automotive::vehicle::VehicleProperty; |
| 46 | using ::aidl::android::hardware::automotive::vehicle::VehiclePropertyAccess; |
Aaqib Ismail | 2048670 | 2022-10-27 16:58:50 -0700 | [diff] [blame] | 47 | using ::aidl::android::hardware::automotive::vehicle::VehiclePropertyChangeMode; |
| 48 | using ::aidl::android::hardware::automotive::vehicle::VehiclePropertyGroup; |
Yu Shan | 726d51a | 2022-02-22 17:37:21 -0800 | [diff] [blame] | 49 | using ::aidl::android::hardware::automotive::vehicle::VehiclePropertyType; |
| 50 | using ::android::getAidlHalInstanceNames; |
| 51 | using ::android::base::ScopedLockAssertion; |
| 52 | using ::android::base::StringPrintf; |
Chen Cheng | faf9adc | 2022-06-22 23:09:09 +0000 | [diff] [blame] | 53 | using ::android::frameworks::automotive::vhal::ErrorCode; |
Yu Shan | 726d51a | 2022-02-22 17:37:21 -0800 | [diff] [blame] | 54 | using ::android::frameworks::automotive::vhal::HalPropError; |
| 55 | using ::android::frameworks::automotive::vhal::IHalPropConfig; |
| 56 | using ::android::frameworks::automotive::vhal::IHalPropValue; |
| 57 | using ::android::frameworks::automotive::vhal::ISubscriptionCallback; |
| 58 | using ::android::frameworks::automotive::vhal::IVhalClient; |
| 59 | using ::android::hardware::getAllHalInstanceNames; |
| 60 | using ::android::hardware::Sanitize; |
| 61 | using ::android::hardware::automotive::vehicle::toInt; |
| 62 | |
| 63 | constexpr int32_t kInvalidProp = 0x31600207; |
| 64 | |
| 65 | struct ServiceDescriptor { |
| 66 | std::string name; |
| 67 | bool isAidlService; |
| 68 | }; |
| 69 | |
| 70 | class VtsVehicleCallback final : public ISubscriptionCallback { |
| 71 | private: |
| 72 | std::mutex mLock; |
| 73 | std::unordered_map<int32_t, size_t> mEventsCount GUARDED_BY(mLock); |
Yu Shan | 4569ef5 | 2022-03-18 14:34:25 -0700 | [diff] [blame] | 74 | std::unordered_map<int32_t, std::vector<int64_t>> mEventTimestamps GUARDED_BY(mLock); |
Yu Shan | 726d51a | 2022-02-22 17:37:21 -0800 | [diff] [blame] | 75 | std::condition_variable mEventCond; |
| 76 | |
| 77 | public: |
| 78 | void onPropertyEvent(const std::vector<std::unique_ptr<IHalPropValue>>& values) override { |
| 79 | { |
| 80 | std::lock_guard<std::mutex> lockGuard(mLock); |
| 81 | for (auto& value : values) { |
Yu Shan | 4569ef5 | 2022-03-18 14:34:25 -0700 | [diff] [blame] | 82 | int32_t propId = value->getPropId(); |
| 83 | mEventsCount[propId] += 1; |
| 84 | mEventTimestamps[propId].push_back(value->getTimestamp()); |
Yu Shan | 726d51a | 2022-02-22 17:37:21 -0800 | [diff] [blame] | 85 | } |
| 86 | } |
| 87 | mEventCond.notify_one(); |
| 88 | } |
| 89 | |
| 90 | void onPropertySetError([[maybe_unused]] const std::vector<HalPropError>& errors) override { |
| 91 | // Do nothing. |
| 92 | } |
| 93 | |
| 94 | template <class Rep, class Period> |
| 95 | bool waitForExpectedEvents(int32_t propId, size_t expectedEvents, |
| 96 | const std::chrono::duration<Rep, Period>& timeout) { |
| 97 | std::unique_lock<std::mutex> uniqueLock(mLock); |
| 98 | return mEventCond.wait_for(uniqueLock, timeout, [this, propId, expectedEvents] { |
| 99 | ScopedLockAssertion lockAssertion(mLock); |
| 100 | return mEventsCount[propId] >= expectedEvents; |
| 101 | }); |
| 102 | } |
| 103 | |
Yu Shan | 4569ef5 | 2022-03-18 14:34:25 -0700 | [diff] [blame] | 104 | std::vector<int64_t> getEventTimestamps(int32_t propId) { |
| 105 | { |
| 106 | std::lock_guard<std::mutex> lockGuard(mLock); |
| 107 | return mEventTimestamps[propId]; |
| 108 | } |
| 109 | } |
| 110 | |
Yu Shan | 726d51a | 2022-02-22 17:37:21 -0800 | [diff] [blame] | 111 | void reset() { |
| 112 | std::lock_guard<std::mutex> lockGuard(mLock); |
| 113 | mEventsCount.clear(); |
| 114 | } |
| 115 | }; |
| 116 | |
| 117 | class VtsHalAutomotiveVehicleTargetTest : public testing::TestWithParam<ServiceDescriptor> { |
| 118 | public: |
Aaqib Ismail | 2048670 | 2022-10-27 16:58:50 -0700 | [diff] [blame] | 119 | void verifyProperty(VehicleProperty propId, VehiclePropertyAccess access, |
| 120 | VehiclePropertyChangeMode changeMode, VehiclePropertyGroup group, |
| 121 | VehicleArea area, VehiclePropertyType propertyType); |
Yu Shan | 726d51a | 2022-02-22 17:37:21 -0800 | [diff] [blame] | 122 | virtual void SetUp() override { |
| 123 | auto descriptor = GetParam(); |
| 124 | if (descriptor.isAidlService) { |
| 125 | mVhalClient = IVhalClient::tryCreateAidlClient(descriptor.name.c_str()); |
| 126 | } else { |
| 127 | mVhalClient = IVhalClient::tryCreateHidlClient(descriptor.name.c_str()); |
| 128 | } |
| 129 | |
| 130 | ASSERT_NE(mVhalClient, nullptr) << "Failed to connect to VHAL"; |
| 131 | |
| 132 | mCallback = std::make_shared<VtsVehicleCallback>(); |
| 133 | } |
| 134 | |
| 135 | static bool isBooleanGlobalProp(int32_t property) { |
| 136 | return (property & toInt(VehiclePropertyType::MASK)) == |
| 137 | toInt(VehiclePropertyType::BOOLEAN) && |
| 138 | (property & toInt(VehicleArea::MASK)) == toInt(VehicleArea::GLOBAL); |
| 139 | } |
| 140 | |
| 141 | protected: |
| 142 | std::shared_ptr<IVhalClient> mVhalClient; |
| 143 | std::shared_ptr<VtsVehicleCallback> mCallback; |
| 144 | }; |
| 145 | |
| 146 | TEST_P(VtsHalAutomotiveVehicleTargetTest, useAidlBackend) { |
| 147 | if (!mVhalClient->isAidlVhal()) { |
| 148 | GTEST_SKIP() << "AIDL backend is not available, HIDL backend is used instead"; |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | TEST_P(VtsHalAutomotiveVehicleTargetTest, useHidlBackend) { |
| 153 | if (mVhalClient->isAidlVhal()) { |
| 154 | GTEST_SKIP() << "AIDL backend is available, HIDL backend is not used"; |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | // Test getAllPropConfig() returns at least 4 property configs. |
| 159 | TEST_P(VtsHalAutomotiveVehicleTargetTest, getAllPropConfigs) { |
| 160 | ALOGD("VtsHalAutomotiveVehicleTargetTest::getAllPropConfigs"); |
| 161 | |
| 162 | auto result = mVhalClient->getAllPropConfigs(); |
| 163 | |
| 164 | ASSERT_TRUE(result.ok()) << "Failed to get all property configs, error: " |
| 165 | << result.error().message(); |
| 166 | ASSERT_GE(result.value().size(), 4u) << StringPrintf( |
| 167 | "Expect to get at least 4 property configs, got %zu", result.value().size()); |
| 168 | } |
| 169 | |
| 170 | // Test getPropConfigs() can query all properties listed in CDD. |
| 171 | TEST_P(VtsHalAutomotiveVehicleTargetTest, getRequiredPropConfigs) { |
| 172 | ALOGD("VtsHalAutomotiveVehicleTargetTest::getRequiredPropConfigs"); |
| 173 | |
| 174 | // Check the properties listed in CDD |
| 175 | std::vector<int32_t> properties = { |
| 176 | toInt(VehicleProperty::GEAR_SELECTION), toInt(VehicleProperty::NIGHT_MODE), |
| 177 | toInt(VehicleProperty::PARKING_BRAKE_ON), toInt(VehicleProperty::PERF_VEHICLE_SPEED)}; |
| 178 | |
| 179 | auto result = mVhalClient->getPropConfigs(properties); |
| 180 | |
| 181 | ASSERT_TRUE(result.ok()) << "Failed to get required property config, error: " |
| 182 | << result.error().message(); |
| 183 | ASSERT_EQ(result.value().size(), 4u) |
| 184 | << StringPrintf("Expect to get exactly 4 configs, got %zu", result.value().size()); |
| 185 | } |
| 186 | |
| 187 | // Test getPropConfig() with an invalid propertyId returns an error code. |
| 188 | TEST_P(VtsHalAutomotiveVehicleTargetTest, getPropConfigsWithInvalidProp) { |
| 189 | ALOGD("VtsHalAutomotiveVehicleTargetTest::getPropConfigsWithInvalidProp"); |
| 190 | |
| 191 | auto result = mVhalClient->getPropConfigs({kInvalidProp}); |
| 192 | |
| 193 | ASSERT_FALSE(result.ok()) << StringPrintf( |
| 194 | "Expect failure to get prop configs for invalid prop: %" PRId32, kInvalidProp); |
| 195 | ASSERT_NE(result.error().message(), "") << "Expect error message not to be empty"; |
| 196 | } |
| 197 | |
| 198 | // Test get() return current value for properties. |
| 199 | TEST_P(VtsHalAutomotiveVehicleTargetTest, get) { |
| 200 | ALOGD("VtsHalAutomotiveVehicleTargetTest::get"); |
| 201 | |
| 202 | int32_t propId = toInt(VehicleProperty::PERF_VEHICLE_SPEED); |
| 203 | auto result = mVhalClient->getValueSync(*mVhalClient->createHalPropValue(propId)); |
| 204 | |
| 205 | ASSERT_TRUE(result.ok()) << StringPrintf("Failed to get value for property: %" PRId32 |
| 206 | ", error: %s", |
| 207 | propId, result.error().message().c_str()); |
| 208 | ASSERT_NE(result.value(), nullptr) << "Result value must not be null"; |
| 209 | } |
| 210 | |
| 211 | // Test get() with an invalid propertyId return an error codes. |
| 212 | TEST_P(VtsHalAutomotiveVehicleTargetTest, getInvalidProp) { |
| 213 | ALOGD("VtsHalAutomotiveVehicleTargetTest::getInvalidProp"); |
| 214 | |
| 215 | auto result = mVhalClient->getValueSync(*mVhalClient->createHalPropValue(kInvalidProp)); |
| 216 | |
| 217 | ASSERT_FALSE(result.ok()) << StringPrintf( |
| 218 | "Expect failure to get property for invalid prop: %" PRId32, kInvalidProp); |
| 219 | } |
| 220 | |
| 221 | // Test set() on read_write properties. |
| 222 | TEST_P(VtsHalAutomotiveVehicleTargetTest, setProp) { |
| 223 | ALOGD("VtsHalAutomotiveVehicleTargetTest::setProp"); |
| 224 | |
| 225 | // skip hvac related properties |
| 226 | std::unordered_set<int32_t> hvacProps = {toInt(VehicleProperty::HVAC_DEFROSTER), |
| 227 | toInt(VehicleProperty::HVAC_AC_ON), |
| 228 | toInt(VehicleProperty::HVAC_MAX_AC_ON), |
| 229 | toInt(VehicleProperty::HVAC_MAX_DEFROST_ON), |
| 230 | toInt(VehicleProperty::HVAC_RECIRC_ON), |
| 231 | toInt(VehicleProperty::HVAC_DUAL_ON), |
| 232 | toInt(VehicleProperty::HVAC_AUTO_ON), |
| 233 | toInt(VehicleProperty::HVAC_POWER_ON), |
| 234 | toInt(VehicleProperty::HVAC_AUTO_RECIRC_ON), |
| 235 | toInt(VehicleProperty::HVAC_ELECTRIC_DEFROSTER_ON)}; |
| 236 | auto result = mVhalClient->getAllPropConfigs(); |
| 237 | ASSERT_TRUE(result.ok()); |
| 238 | |
| 239 | for (const auto& cfgPtr : result.value()) { |
| 240 | const IHalPropConfig& cfg = *cfgPtr; |
| 241 | int32_t propId = cfg.getPropId(); |
| 242 | // test on boolean and writable property |
| 243 | if (cfg.getAccess() == toInt(VehiclePropertyAccess::READ_WRITE) && |
| 244 | isBooleanGlobalProp(propId) && !hvacProps.count(propId)) { |
| 245 | auto propToGet = mVhalClient->createHalPropValue(propId); |
| 246 | auto getValueResult = mVhalClient->getValueSync(*propToGet); |
| 247 | |
| 248 | ASSERT_TRUE(getValueResult.ok()) |
| 249 | << StringPrintf("Failed to get value for property: %" PRId32 ", error: %s", |
| 250 | propId, getValueResult.error().message().c_str()); |
| 251 | ASSERT_NE(getValueResult.value(), nullptr) |
| 252 | << StringPrintf("Result value must not be null for property: %" PRId32, propId); |
| 253 | |
| 254 | const IHalPropValue& value = *getValueResult.value(); |
| 255 | size_t intValueSize = value.getInt32Values().size(); |
| 256 | ASSERT_EQ(intValueSize, 1u) << StringPrintf( |
| 257 | "Expect exactly 1 int value for boolean property: %" PRId32 ", got %zu", propId, |
| 258 | intValueSize); |
| 259 | |
| 260 | int setValue = value.getInt32Values()[0] == 1 ? 0 : 1; |
| 261 | auto propToSet = mVhalClient->createHalPropValue(propId); |
| 262 | propToSet->setInt32Values({setValue}); |
| 263 | auto setValueResult = mVhalClient->setValueSync(*propToSet); |
| 264 | |
| 265 | ASSERT_TRUE(setValueResult.ok()) |
| 266 | << StringPrintf("Failed to set value for property: %" PRId32 ", error: %s", |
| 267 | propId, setValueResult.error().message().c_str()); |
| 268 | |
| 269 | // check set success |
| 270 | getValueResult = mVhalClient->getValueSync(*propToGet); |
| 271 | ASSERT_TRUE(getValueResult.ok()) |
| 272 | << StringPrintf("Failed to get value for property: %" PRId32 ", error: %s", |
| 273 | propId, getValueResult.error().message().c_str()); |
| 274 | ASSERT_NE(getValueResult.value(), nullptr) |
| 275 | << StringPrintf("Result value must not be null for property: %" PRId32, propId); |
| 276 | ASSERT_EQ(getValueResult.value()->getInt32Values(), std::vector<int32_t>({setValue})) |
| 277 | << StringPrintf("Boolean value not updated after set for property: %" PRId32, |
| 278 | propId); |
| 279 | } |
| 280 | } |
| 281 | } |
| 282 | |
| 283 | // Test set() on an read_only property. |
| 284 | TEST_P(VtsHalAutomotiveVehicleTargetTest, setNotWritableProp) { |
| 285 | ALOGD("VtsHalAutomotiveVehicleTargetTest::setNotWritableProp"); |
| 286 | |
| 287 | int32_t propId = toInt(VehicleProperty::PERF_VEHICLE_SPEED); |
| 288 | auto getValueResult = mVhalClient->getValueSync(*mVhalClient->createHalPropValue(propId)); |
| 289 | ASSERT_TRUE(getValueResult.ok()) |
| 290 | << StringPrintf("Failed to get value for property: %" PRId32 ", error: %s", propId, |
| 291 | getValueResult.error().message().c_str()); |
| 292 | |
| 293 | auto setValueResult = mVhalClient->setValueSync(*getValueResult.value()); |
| 294 | |
| 295 | ASSERT_FALSE(setValueResult.ok()) << "Expect set a read-only value to fail"; |
Chen Cheng | faf9adc | 2022-06-22 23:09:09 +0000 | [diff] [blame] | 296 | ASSERT_EQ(setValueResult.error().code(), ErrorCode::ACCESS_DENIED_FROM_VHAL); |
Yu Shan | 726d51a | 2022-02-22 17:37:21 -0800 | [diff] [blame] | 297 | } |
| 298 | |
| 299 | // Test subscribe() and unsubscribe(). |
| 300 | TEST_P(VtsHalAutomotiveVehicleTargetTest, subscribeAndUnsubscribe) { |
| 301 | ALOGD("VtsHalAutomotiveVehicleTargetTest::subscribeAndUnsubscribe"); |
| 302 | |
| 303 | int32_t propId = toInt(VehicleProperty::PERF_VEHICLE_SPEED); |
| 304 | |
Yu Shan | 4569ef5 | 2022-03-18 14:34:25 -0700 | [diff] [blame] | 305 | auto propConfigsResult = mVhalClient->getPropConfigs({propId}); |
| 306 | |
| 307 | ASSERT_TRUE(propConfigsResult.ok()) << "Failed to get property config for PERF_VEHICLE_SPEED: " |
| 308 | << "error: " << propConfigsResult.error().message(); |
| 309 | ASSERT_EQ(propConfigsResult.value().size(), 1u) |
| 310 | << "Expect to return 1 config for PERF_VEHICLE_SPEED"; |
| 311 | auto& propConfig = propConfigsResult.value()[0]; |
| 312 | float minSampleRate = propConfig->getMinSampleRate(); |
| 313 | float maxSampleRate = propConfig->getMaxSampleRate(); |
| 314 | |
| 315 | if (minSampleRate < 1) { |
| 316 | GTEST_SKIP() << "Sample rate for vehicle speed < 1 times/sec, skip test since it would " |
| 317 | "take too long"; |
| 318 | } |
Yu Shan | 726d51a | 2022-02-22 17:37:21 -0800 | [diff] [blame] | 319 | |
| 320 | auto client = mVhalClient->getSubscriptionClient(mCallback); |
| 321 | ASSERT_NE(client, nullptr) << "Failed to get subscription client"; |
| 322 | |
Yu Shan | 4569ef5 | 2022-03-18 14:34:25 -0700 | [diff] [blame] | 323 | auto result = client->subscribe({{.propId = propId, .sampleRate = minSampleRate}}); |
Yu Shan | 726d51a | 2022-02-22 17:37:21 -0800 | [diff] [blame] | 324 | |
| 325 | ASSERT_TRUE(result.ok()) << StringPrintf("Failed to subscribe to property: %" PRId32 |
| 326 | ", error: %s", |
| 327 | propId, result.error().message().c_str()); |
Yu Shan | 4569ef5 | 2022-03-18 14:34:25 -0700 | [diff] [blame] | 328 | |
| 329 | if (mVhalClient->isAidlVhal()) { |
| 330 | // Skip checking timestamp for HIDL because the behavior for sample rate and timestamp is |
| 331 | // only specified clearly for AIDL. |
| 332 | |
| 333 | // Timeout is 2 seconds, which gives a 1 second buffer. |
| 334 | ASSERT_TRUE(mCallback->waitForExpectedEvents(propId, std::floor(minSampleRate), |
| 335 | std::chrono::seconds(2))) |
| 336 | << "Didn't get enough events for subscribing to minSampleRate"; |
| 337 | } |
| 338 | |
| 339 | result = client->subscribe({{.propId = propId, .sampleRate = maxSampleRate}}); |
| 340 | |
| 341 | ASSERT_TRUE(result.ok()) << StringPrintf("Failed to subscribe to property: %" PRId32 |
| 342 | ", error: %s", |
| 343 | propId, result.error().message().c_str()); |
| 344 | |
| 345 | if (mVhalClient->isAidlVhal()) { |
| 346 | ASSERT_TRUE(mCallback->waitForExpectedEvents(propId, std::floor(maxSampleRate), |
| 347 | std::chrono::seconds(2))) |
| 348 | << "Didn't get enough events for subscribing to maxSampleRate"; |
| 349 | |
| 350 | std::unordered_set<int64_t> timestamps; |
| 351 | // Event event should have a different timestamp. |
| 352 | for (const int64_t& eventTimestamp : mCallback->getEventTimestamps(propId)) { |
| 353 | ASSERT_TRUE(timestamps.find(eventTimestamp) == timestamps.end()) |
| 354 | << "two events for the same property must not have the same timestamp"; |
| 355 | timestamps.insert(eventTimestamp); |
| 356 | } |
| 357 | } |
Yu Shan | 726d51a | 2022-02-22 17:37:21 -0800 | [diff] [blame] | 358 | |
| 359 | result = client->unsubscribe({propId}); |
| 360 | ASSERT_TRUE(result.ok()) << StringPrintf("Failed to unsubscribe to property: %" PRId32 |
| 361 | ", error: %s", |
| 362 | propId, result.error().message().c_str()); |
| 363 | |
| 364 | mCallback->reset(); |
| 365 | ASSERT_FALSE(mCallback->waitForExpectedEvents(propId, 10, std::chrono::seconds(1))) |
| 366 | << "Expect not to get events after unsubscription"; |
| 367 | } |
| 368 | |
| 369 | // Test subscribe() with an invalid property. |
| 370 | TEST_P(VtsHalAutomotiveVehicleTargetTest, subscribeInvalidProp) { |
| 371 | ALOGD("VtsHalAutomotiveVehicleTargetTest::subscribeInvalidProp"); |
| 372 | |
| 373 | std::vector<SubscribeOptions> options = { |
| 374 | SubscribeOptions{.propId = kInvalidProp, .sampleRate = 10.0}}; |
| 375 | |
| 376 | auto client = mVhalClient->getSubscriptionClient(mCallback); |
| 377 | ASSERT_NE(client, nullptr) << "Failed to get subscription client"; |
| 378 | |
| 379 | auto result = client->subscribe(options); |
| 380 | |
| 381 | ASSERT_FALSE(result.ok()) << StringPrintf("Expect subscribing to property: %" PRId32 " to fail", |
| 382 | kInvalidProp); |
| 383 | } |
| 384 | |
Yu Shan | 4569ef5 | 2022-03-18 14:34:25 -0700 | [diff] [blame] | 385 | // Test the timestamp returned in GetValues results is the timestamp when the value is retrieved. |
| 386 | TEST_P(VtsHalAutomotiveVehicleTargetTest, testGetValuesTimestampAIDL) { |
| 387 | if (!mVhalClient->isAidlVhal()) { |
| 388 | GTEST_SKIP() << "Skip checking timestamp for HIDL because the behavior is only specified " |
| 389 | "for AIDL"; |
| 390 | } |
| 391 | |
| 392 | int32_t propId = toInt(VehicleProperty::PARKING_BRAKE_ON); |
| 393 | auto prop = mVhalClient->createHalPropValue(propId); |
| 394 | |
| 395 | auto result = mVhalClient->getValueSync(*prop); |
| 396 | |
| 397 | ASSERT_TRUE(result.ok()) << StringPrintf("Failed to get value for property: %" PRId32 |
| 398 | ", error: %s", |
| 399 | propId, result.error().message().c_str()); |
| 400 | ASSERT_NE(result.value(), nullptr) << "Result value must not be null"; |
| 401 | ASSERT_EQ(result.value()->getInt32Values().size(), 1u) << "Result must contain 1 int value"; |
| 402 | |
| 403 | bool parkBrakeOnValue1 = (result.value()->getInt32Values()[0] == 1); |
| 404 | int64_t timestampValue1 = result.value()->getTimestamp(); |
| 405 | |
| 406 | result = mVhalClient->getValueSync(*prop); |
| 407 | |
| 408 | ASSERT_TRUE(result.ok()) << StringPrintf("Failed to get value for property: %" PRId32 |
| 409 | ", error: %s", |
| 410 | propId, result.error().message().c_str()); |
| 411 | ASSERT_NE(result.value(), nullptr) << "Result value must not be null"; |
| 412 | ASSERT_EQ(result.value()->getInt32Values().size(), 1u) << "Result must contain 1 int value"; |
| 413 | |
| 414 | bool parkBarkeOnValue2 = (result.value()->getInt32Values()[0] == 1); |
| 415 | int64_t timestampValue2 = result.value()->getTimestamp(); |
| 416 | |
| 417 | if (parkBarkeOnValue2 == parkBrakeOnValue1) { |
| 418 | ASSERT_EQ(timestampValue2, timestampValue1) |
| 419 | << "getValue result must contain a timestamp updated when the value was updated, if" |
| 420 | "the value does not change, expect the same timestamp"; |
| 421 | } else { |
| 422 | ASSERT_GT(timestampValue2, timestampValue1) |
| 423 | << "getValue result must contain a timestamp updated when the value was updated, if" |
| 424 | "the value changes, expect the newer value has a larger timestamp"; |
| 425 | } |
| 426 | } |
| 427 | |
Aaqib Ismail | 2048670 | 2022-10-27 16:58:50 -0700 | [diff] [blame] | 428 | // Helper function to compare actual vs expected property config |
| 429 | void VtsHalAutomotiveVehicleTargetTest::verifyProperty(VehicleProperty propId, |
| 430 | VehiclePropertyAccess access, |
| 431 | VehiclePropertyChangeMode changeMode, |
| 432 | VehiclePropertyGroup group, VehicleArea area, |
| 433 | VehiclePropertyType propertyType) { |
| 434 | int expectedPropId = toInt(propId); |
| 435 | int expectedAccess = toInt(access); |
| 436 | int expectedChangeMode = toInt(changeMode); |
| 437 | int expectedGroup = toInt(group); |
| 438 | int expectedArea = toInt(area); |
| 439 | int expectedPropertyType = toInt(propertyType); |
| 440 | |
Eva Chen | 17bc578 | 2023-01-06 22:59:58 -0800 | [diff] [blame] | 441 | auto result = mVhalClient->getAllPropConfigs(); |
| 442 | ASSERT_TRUE(result.ok()) << "Failed to get all property configs, error: " |
| 443 | << result.error().message(); |
| 444 | |
| 445 | // Check if property is implemented by getting all configs and looking to see if the expected |
| 446 | // property id is in that list. |
| 447 | bool isExpectedPropIdImplemented = false; |
| 448 | for (const auto& cfgPtr : result.value()) { |
| 449 | const IHalPropConfig& cfg = *cfgPtr; |
| 450 | if (expectedPropId == cfg.getPropId()) { |
| 451 | isExpectedPropIdImplemented = true; |
| 452 | break; |
| 453 | } |
| 454 | } |
| 455 | |
| 456 | if (!isExpectedPropIdImplemented) { |
| 457 | GTEST_SKIP() << StringPrintf("Property %" PRId32 " has not been implemented", |
| 458 | expectedPropId); |
| 459 | } |
| 460 | |
| 461 | result = mVhalClient->getPropConfigs({expectedPropId}); |
Aaqib Ismail | 2048670 | 2022-10-27 16:58:50 -0700 | [diff] [blame] | 462 | ASSERT_TRUE(result.ok()) << "Failed to get required property config, error: " |
| 463 | << result.error().message(); |
| 464 | |
Aaqib Ismail | 2048670 | 2022-10-27 16:58:50 -0700 | [diff] [blame] | 465 | ASSERT_EQ(result.value().size(), 1u) |
| 466 | << StringPrintf("Expect to get exactly 1 config, got %zu", result.value().size()); |
| 467 | |
| 468 | const auto& config = result.value().at(0); |
| 469 | int actualPropId = config->getPropId(); |
| 470 | int actualAccess = config->getAccess(); |
| 471 | int actualChangeMode = config->getChangeMode(); |
| 472 | int actualGroup = actualPropId & toInt(VehiclePropertyGroup::MASK); |
| 473 | int actualArea = actualPropId & toInt(VehicleArea::MASK); |
| 474 | int actualPropertyType = actualPropId & toInt(VehiclePropertyType::MASK); |
| 475 | |
| 476 | ASSERT_EQ(actualPropId, expectedPropId) |
| 477 | << StringPrintf("Expect to get property ID: %i, got %i", expectedPropId, actualPropId); |
| 478 | |
| 479 | if (expectedAccess == toInt(VehiclePropertyAccess::READ_WRITE)) { |
| 480 | ASSERT_TRUE(actualAccess == expectedAccess || |
| 481 | actualAccess == toInt(VehiclePropertyAccess::READ)) |
| 482 | << StringPrintf("Expect to get VehiclePropertyAccess: %i or %i, got %i", |
| 483 | expectedAccess, toInt(VehiclePropertyAccess::READ), actualAccess); |
| 484 | } else { |
| 485 | ASSERT_EQ(actualAccess, expectedAccess) << StringPrintf( |
| 486 | "Expect to get VehiclePropertyAccess: %i, got %i", expectedAccess, actualAccess); |
| 487 | } |
| 488 | |
| 489 | ASSERT_EQ(actualChangeMode, expectedChangeMode) |
| 490 | << StringPrintf("Expect to get VehiclePropertyChangeMode: %i, got %i", |
| 491 | expectedChangeMode, actualChangeMode); |
| 492 | ASSERT_EQ(actualGroup, expectedGroup) << StringPrintf( |
| 493 | "Expect to get VehiclePropertyGroup: %i, got %i", expectedGroup, actualGroup); |
| 494 | ASSERT_EQ(actualArea, expectedArea) |
| 495 | << StringPrintf("Expect to get VehicleArea: %i, got %i", expectedArea, actualArea); |
| 496 | ASSERT_EQ(actualPropertyType, expectedPropertyType) |
| 497 | << StringPrintf("Expect to get VehiclePropertyType: %i, got %i", expectedPropertyType, |
| 498 | actualPropertyType); |
| 499 | } |
| 500 | |
shrikar | 668df36 | 2022-12-20 22:08:17 +0000 | [diff] [blame] | 501 | TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyEmergencyLaneKeepAssistEnabledConfig) { |
| 502 | verifyProperty(VehicleProperty::EMERGENCY_LANE_KEEP_ASSIST_ENABLED, |
| 503 | VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE, |
| 504 | VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN); |
| 505 | } |
| 506 | |
shrikar | 808a294 | 2022-12-21 17:07:32 +0000 | [diff] [blame] | 507 | TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyAdaptiveCruiseControlEnabledConfig) { |
| 508 | verifyProperty(VehicleProperty::ADAPTIVE_CRUISE_CONTROL_ENABLED, |
| 509 | VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE, |
| 510 | VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN); |
| 511 | } |
| 512 | |
shrikar | 37833e1 | 2022-12-15 20:13:14 +0000 | [diff] [blame] | 513 | TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyHandsOnDetectionEnabledConfig) { |
| 514 | verifyProperty(VehicleProperty::HANDS_ON_DETECTION_ENABLED, VehiclePropertyAccess::READ_WRITE, |
| 515 | VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM, |
| 516 | VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN); |
| 517 | } |
| 518 | |
shrikar | 2c7aaa6 | 2022-12-15 21:05:34 +0000 | [diff] [blame] | 519 | TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyDriverAttentionMonitoringEnabledConfig) { |
| 520 | verifyProperty(VehicleProperty::DRIVER_ATTENTION_MONITORING_ENABLED, |
| 521 | VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE, |
| 522 | VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN); |
| 523 | } |
| 524 | |
Aaqib Ismail | c69e968 | 2022-11-22 12:50:00 -0800 | [diff] [blame] | 525 | TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyEvBrakeRegenerationLevelConfig) { |
| 526 | verifyProperty(VehicleProperty::EV_BRAKE_REGENERATION_LEVEL, |
| 527 | VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE, |
| 528 | VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::INT32); |
| 529 | } |
| 530 | |
shrikar | 2dae80f | 2022-12-21 23:50:17 +0000 | [diff] [blame] | 531 | TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyEvStoppingModeConfig) { |
| 532 | verifyProperty(VehicleProperty::EV_STOPPING_MODE, VehiclePropertyAccess::READ_WRITE, |
| 533 | VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM, |
| 534 | VehicleArea::GLOBAL, VehiclePropertyType::INT32); |
| 535 | } |
| 536 | |
Aaqib Ismail | aec678a | 2022-12-07 16:22:42 -0800 | [diff] [blame] | 537 | TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyEvCurrentBatteryCapacityConfig) { |
| 538 | verifyProperty(VehicleProperty::EV_CURRENT_BATTERY_CAPACITY, VehiclePropertyAccess::READ, |
| 539 | VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM, |
| 540 | VehicleArea::GLOBAL, VehiclePropertyType::FLOAT); |
| 541 | } |
| 542 | |
shrikar | 8391447 | 2022-12-16 20:28:47 +0000 | [diff] [blame] | 543 | TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyEngineIdleAutoStopEnabledConfig) { |
| 544 | verifyProperty(VehicleProperty::ENGINE_IDLE_AUTO_STOP_ENABLED, |
| 545 | VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE, |
| 546 | VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN); |
| 547 | } |
| 548 | |
Aaqib Ismail | 2048670 | 2022-10-27 16:58:50 -0700 | [diff] [blame] | 549 | TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyDoorChildLockEnabledConfig) { |
| 550 | verifyProperty(VehicleProperty::DOOR_CHILD_LOCK_ENABLED, VehiclePropertyAccess::READ_WRITE, |
| 551 | VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM, |
| 552 | VehicleArea::DOOR, VehiclePropertyType::BOOLEAN); |
| 553 | } |
| 554 | |
Aaqib Ismail | 7f941b4 | 2022-11-04 14:55:13 -0700 | [diff] [blame] | 555 | TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySteeringWheelDepthPosConfig) { |
| 556 | verifyProperty(VehicleProperty::STEERING_WHEEL_DEPTH_POS, VehiclePropertyAccess::READ_WRITE, |
| 557 | VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM, |
| 558 | VehicleArea::GLOBAL, VehiclePropertyType::INT32); |
| 559 | } |
| 560 | |
Aaqib Ismail | 34fe92f | 2022-11-04 21:41:23 -0700 | [diff] [blame] | 561 | TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySteeringWheelDepthMoveConfig) { |
| 562 | verifyProperty(VehicleProperty::STEERING_WHEEL_DEPTH_MOVE, VehiclePropertyAccess::READ_WRITE, |
| 563 | VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM, |
| 564 | VehicleArea::GLOBAL, VehiclePropertyType::INT32); |
| 565 | } |
| 566 | |
Aaqib Ismail | 53b81c9 | 2022-11-07 17:47:04 -0800 | [diff] [blame] | 567 | TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySteeringWheelHeightPosConfig) { |
| 568 | verifyProperty(VehicleProperty::STEERING_WHEEL_HEIGHT_POS, VehiclePropertyAccess::READ_WRITE, |
| 569 | VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM, |
| 570 | VehicleArea::GLOBAL, VehiclePropertyType::INT32); |
| 571 | } |
| 572 | |
Aaqib Ismail | 6c4bf19 | 2022-11-08 15:00:32 -0800 | [diff] [blame] | 573 | TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySteeringWheelHeightMoveConfig) { |
| 574 | verifyProperty(VehicleProperty::STEERING_WHEEL_HEIGHT_MOVE, VehiclePropertyAccess::READ_WRITE, |
| 575 | VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM, |
| 576 | VehicleArea::GLOBAL, VehiclePropertyType::INT32); |
| 577 | } |
| 578 | |
Aaqib Ismail | 8d05118 | 2022-11-09 13:28:48 -0800 | [diff] [blame] | 579 | TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySteeringWheelTheftLockEnabledConfig) { |
| 580 | verifyProperty(VehicleProperty::STEERING_WHEEL_THEFT_LOCK_ENABLED, |
| 581 | VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE, |
| 582 | VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN); |
| 583 | } |
| 584 | |
Aaqib Ismail | 68d3f12 | 2022-11-09 14:43:32 -0800 | [diff] [blame] | 585 | TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySteeringWheelLockedConfig) { |
| 586 | verifyProperty(VehicleProperty::STEERING_WHEEL_LOCKED, VehiclePropertyAccess::READ_WRITE, |
| 587 | VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM, |
| 588 | VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN); |
| 589 | } |
| 590 | |
Aaqib Ismail | d4d6adf | 2022-11-09 16:59:47 -0800 | [diff] [blame] | 591 | TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySteeringWheelEasyAccessEnabledConfig) { |
| 592 | verifyProperty(VehicleProperty::STEERING_WHEEL_EASY_ACCESS_ENABLED, |
| 593 | VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE, |
| 594 | VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN); |
| 595 | } |
| 596 | |
Aaqib Ismail | 0dc7ba0 | 2022-11-10 14:28:09 -0800 | [diff] [blame] | 597 | TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySteeringWheelLightsStateConfig) { |
| 598 | verifyProperty(VehicleProperty::STEERING_WHEEL_LIGHTS_STATE, VehiclePropertyAccess::READ, |
| 599 | VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM, |
| 600 | VehicleArea::GLOBAL, VehiclePropertyType::INT32); |
| 601 | } |
| 602 | |
Aaqib Ismail | 4b8688f | 2022-11-15 15:13:35 -0800 | [diff] [blame] | 603 | TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySteeringWheelLightsSwitchConfig) { |
| 604 | verifyProperty(VehicleProperty::STEERING_WHEEL_LIGHTS_SWITCH, VehiclePropertyAccess::READ_WRITE, |
| 605 | VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM, |
| 606 | VehicleArea::GLOBAL, VehiclePropertyType::INT32); |
| 607 | } |
| 608 | |
shrikar | a136721 | 2022-11-02 16:07:35 +0000 | [diff] [blame] | 609 | TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyMirrorAutoFoldEnabledConfig) { |
| 610 | verifyProperty(VehicleProperty::MIRROR_AUTO_FOLD_ENABLED, VehiclePropertyAccess::READ_WRITE, |
| 611 | VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM, |
| 612 | VehicleArea::MIRROR, VehiclePropertyType::BOOLEAN); |
| 613 | } |
| 614 | |
| 615 | TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyMirrorAutoTiltEnabledConfig) { |
| 616 | verifyProperty(VehicleProperty::MIRROR_AUTO_TILT_ENABLED, VehiclePropertyAccess::READ_WRITE, |
| 617 | VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM, |
| 618 | VehicleArea::MIRROR, VehiclePropertyType::BOOLEAN); |
| 619 | } |
| 620 | |
Aaqib Ismail | 4e6144c | 2022-12-15 15:32:18 -0800 | [diff] [blame] | 621 | TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySeatHeadrestHeightPosV2Config) { |
| 622 | verifyProperty(VehicleProperty::SEAT_HEADREST_HEIGHT_POS_V2, VehiclePropertyAccess::READ_WRITE, |
| 623 | VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM, |
| 624 | VehicleArea::SEAT, VehiclePropertyType::INT32); |
| 625 | } |
| 626 | |
shrikar | 6ae7916 | 2022-12-16 03:03:25 +0000 | [diff] [blame] | 627 | TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySeatWalkInPosConfig) { |
| 628 | verifyProperty(VehicleProperty::SEAT_WALK_IN_POS, VehiclePropertyAccess::READ_WRITE, |
| 629 | VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM, |
| 630 | VehicleArea::SEAT, VehiclePropertyType::INT32); |
| 631 | } |
| 632 | |
shrikar | fb65ae5 | 2022-11-03 23:12:51 +0000 | [diff] [blame] | 633 | TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySeatFootwellLightsStateConfig) { |
| 634 | verifyProperty(VehicleProperty::SEAT_FOOTWELL_LIGHTS_STATE, VehiclePropertyAccess::READ, |
| 635 | VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM, |
| 636 | VehicleArea::SEAT, VehiclePropertyType::INT32); |
| 637 | } |
| 638 | |
shrikar | 93cf1be | 2022-11-30 15:00:52 -0800 | [diff] [blame] | 639 | TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySeatFootwellLightsSwitchConfig) { |
| 640 | verifyProperty(VehicleProperty::SEAT_FOOTWELL_LIGHTS_SWITCH, VehiclePropertyAccess::READ_WRITE, |
| 641 | VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM, |
| 642 | VehicleArea::SEAT, VehiclePropertyType::INT32); |
| 643 | } |
| 644 | |
shrikar | 3326de0 | 2022-11-07 23:51:20 +0000 | [diff] [blame] | 645 | TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySeatEasyAccessEnabledConfig) { |
| 646 | verifyProperty(VehicleProperty::SEAT_EASY_ACCESS_ENABLED, VehiclePropertyAccess::READ_WRITE, |
| 647 | VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM, |
| 648 | VehicleArea::SEAT, VehiclePropertyType::BOOLEAN); |
| 649 | } |
| 650 | |
shrikar | b96e376 | 2022-11-08 16:49:58 -0800 | [diff] [blame] | 651 | TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySeatAirbagEnabledConfig) { |
| 652 | verifyProperty(VehicleProperty::SEAT_AIRBAG_ENABLED, VehiclePropertyAccess::READ_WRITE, |
| 653 | VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM, |
| 654 | VehicleArea::SEAT, VehiclePropertyType::BOOLEAN); |
| 655 | } |
| 656 | |
shrikar | 802ecb5 | 2022-11-09 18:27:06 +0000 | [diff] [blame] | 657 | TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySeatCushionSideSupportPosConfig) { |
| 658 | verifyProperty(VehicleProperty::SEAT_CUSHION_SIDE_SUPPORT_POS, |
| 659 | VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE, |
| 660 | VehiclePropertyGroup::SYSTEM, VehicleArea::SEAT, VehiclePropertyType::INT32); |
| 661 | } |
| 662 | |
shrikar | 1f0ce0d | 2022-11-11 17:46:06 +0000 | [diff] [blame] | 663 | TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySeatCushionSideSupportMoveConfig) { |
| 664 | verifyProperty(VehicleProperty::SEAT_CUSHION_SIDE_SUPPORT_MOVE, |
| 665 | VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE, |
| 666 | VehiclePropertyGroup::SYSTEM, VehicleArea::SEAT, VehiclePropertyType::INT32); |
| 667 | } |
| 668 | |
shrikar | eff71b2 | 2022-11-11 11:02:43 -0800 | [diff] [blame] | 669 | TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySeatLumbarVerticalPosConfig) { |
| 670 | verifyProperty(VehicleProperty::SEAT_LUMBAR_VERTICAL_POS, VehiclePropertyAccess::READ_WRITE, |
| 671 | VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM, |
| 672 | VehicleArea::SEAT, VehiclePropertyType::INT32); |
| 673 | } |
| 674 | |
shrikar | 2a081c5 | 2022-11-11 16:49:58 -0800 | [diff] [blame] | 675 | TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySeatLumbarVerticalMoveConfig) { |
| 676 | verifyProperty(VehicleProperty::SEAT_LUMBAR_VERTICAL_MOVE, VehiclePropertyAccess::READ_WRITE, |
| 677 | VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM, |
| 678 | VehicleArea::SEAT, VehiclePropertyType::INT32); |
| 679 | } |
| 680 | |
Aaqib Ismail | 5d53aa3 | 2022-12-13 22:30:23 +0000 | [diff] [blame] | 681 | TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyAutomaticEmergencyBrakingEnabledConfig) { |
| 682 | verifyProperty(VehicleProperty::AUTOMATIC_EMERGENCY_BRAKING_ENABLED, |
| 683 | VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE, |
| 684 | VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN); |
| 685 | } |
| 686 | |
Aaqib Ismail | 28ee23c | 2023-01-04 23:04:46 -0800 | [diff] [blame] | 687 | TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyAutomaticEmergencyBrakingStateConfig) { |
| 688 | verifyProperty(VehicleProperty::AUTOMATIC_EMERGENCY_BRAKING_STATE, VehiclePropertyAccess::READ, |
| 689 | VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM, |
| 690 | VehicleArea::GLOBAL, VehiclePropertyType::INT32); |
| 691 | } |
| 692 | |
Aaqib Ismail | a251367 | 2022-12-15 00:55:27 +0000 | [diff] [blame] | 693 | TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyForwardCollisionWarningEnabledConfig) { |
| 694 | verifyProperty(VehicleProperty::FORWARD_COLLISION_WARNING_ENABLED, |
| 695 | VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE, |
| 696 | VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN); |
| 697 | } |
| 698 | |
Aaqib Ismail | 0a1ab29 | 2023-01-19 21:33:56 +0000 | [diff] [blame] | 699 | TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyForwardCollisionWarningStateConfig) { |
| 700 | verifyProperty(VehicleProperty::FORWARD_COLLISION_WARNING_STATE, VehiclePropertyAccess::READ, |
| 701 | VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM, |
| 702 | VehicleArea::GLOBAL, VehiclePropertyType::INT32); |
| 703 | } |
| 704 | |
Aaqib Ismail | 3f7177a | 2022-12-17 09:20:00 -0800 | [diff] [blame] | 705 | TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyBlindSpotWarningEnabledConfig) { |
| 706 | verifyProperty(VehicleProperty::BLIND_SPOT_WARNING_ENABLED, VehiclePropertyAccess::READ_WRITE, |
| 707 | VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM, |
| 708 | VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN); |
| 709 | } |
| 710 | |
Aaqib Ismail | 5fc97bb | 2023-01-10 17:07:47 -0800 | [diff] [blame] | 711 | TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyBlindSpotWarningStateConfig) { |
| 712 | verifyProperty(VehicleProperty::BLIND_SPOT_WARNING_STATE, VehiclePropertyAccess::READ, |
| 713 | VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM, |
| 714 | VehicleArea::MIRROR, VehiclePropertyType::INT32); |
| 715 | } |
| 716 | |
Aaqib Ismail | 7a46cef | 2022-12-17 10:00:59 -0800 | [diff] [blame] | 717 | TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyLaneDepartureWarningEnabledConfig) { |
| 718 | verifyProperty(VehicleProperty::LANE_DEPARTURE_WARNING_ENABLED, |
| 719 | VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE, |
| 720 | VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN); |
| 721 | } |
| 722 | |
Aaqib Ismail | 20cc66a | 2022-12-22 05:38:28 -0800 | [diff] [blame] | 723 | TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyLaneKeepAssistEnabledConfig) { |
| 724 | verifyProperty(VehicleProperty::LANE_KEEP_ASSIST_ENABLED, VehiclePropertyAccess::READ_WRITE, |
| 725 | VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM, |
| 726 | VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN); |
| 727 | } |
| 728 | |
Aaqib Ismail | 78db2ca | 2023-01-10 17:34:28 -0800 | [diff] [blame] | 729 | TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyLaneKeepAssistStateConfig) { |
| 730 | verifyProperty(VehicleProperty::LANE_KEEP_ASSIST_STATE, VehiclePropertyAccess::READ, |
| 731 | VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM, |
| 732 | VehicleArea::GLOBAL, VehiclePropertyType::INT32); |
| 733 | } |
| 734 | |
Aaqib Ismail | b1680a7 | 2022-12-14 23:28:49 +0000 | [diff] [blame] | 735 | TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyLaneCenteringAssistEnabledConfig) { |
| 736 | verifyProperty(VehicleProperty::LANE_CENTERING_ASSIST_ENABLED, |
| 737 | VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE, |
| 738 | VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN); |
| 739 | } |
| 740 | |
Yu Shan | 726d51a | 2022-02-22 17:37:21 -0800 | [diff] [blame] | 741 | std::vector<ServiceDescriptor> getDescriptors() { |
| 742 | std::vector<ServiceDescriptor> descriptors; |
| 743 | for (std::string name : getAidlHalInstanceNames(IVehicle::descriptor)) { |
| 744 | descriptors.push_back({ |
| 745 | .name = name, |
| 746 | .isAidlService = true, |
| 747 | }); |
| 748 | } |
| 749 | for (std::string name : getAllHalInstanceNames(IVehicle::descriptor)) { |
| 750 | descriptors.push_back({ |
| 751 | .name = name, |
| 752 | .isAidlService = false, |
| 753 | }); |
| 754 | } |
| 755 | return descriptors; |
| 756 | } |
| 757 | |
| 758 | GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(VtsHalAutomotiveVehicleTargetTest); |
| 759 | |
| 760 | INSTANTIATE_TEST_SUITE_P(PerInstance, VtsHalAutomotiveVehicleTargetTest, |
| 761 | testing::ValuesIn(getDescriptors()), |
| 762 | [](const testing::TestParamInfo<ServiceDescriptor>& info) { |
| 763 | std::string name = ""; |
| 764 | if (info.param.isAidlService) { |
| 765 | name += "aidl_"; |
| 766 | } else { |
| 767 | name += "hidl_"; |
| 768 | } |
| 769 | name += info.param.name; |
| 770 | return Sanitize(name); |
| 771 | }); |
| 772 | |
| 773 | int main(int argc, char** argv) { |
| 774 | ::testing::InitGoogleTest(&argc, argv); |
| 775 | ABinderProcess_setThreadPoolMaxThreadCount(1); |
| 776 | return RUN_ALL_TESTS(); |
| 777 | } |