blob: bc9a527c407e2973a8abe83e4b3b0f06c4e01fd8 [file] [log] [blame]
Yu Shan726d51a2022-02-22 17:37:21 -08001/*
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 Shan4569ef52022-03-18 14:34:25 -070033#include <utils/SystemClock.h>
Yu Shan726d51a2022-02-22 17:37:21 -080034
35#include <chrono>
36#include <mutex>
37#include <unordered_map>
38#include <unordered_set>
39#include <vector>
40
41using ::aidl::android::hardware::automotive::vehicle::IVehicle;
42using ::aidl::android::hardware::automotive::vehicle::StatusCode;
43using ::aidl::android::hardware::automotive::vehicle::SubscribeOptions;
44using ::aidl::android::hardware::automotive::vehicle::VehicleArea;
45using ::aidl::android::hardware::automotive::vehicle::VehicleProperty;
46using ::aidl::android::hardware::automotive::vehicle::VehiclePropertyAccess;
Aaqib Ismail20486702022-10-27 16:58:50 -070047using ::aidl::android::hardware::automotive::vehicle::VehiclePropertyChangeMode;
48using ::aidl::android::hardware::automotive::vehicle::VehiclePropertyGroup;
Yu Shan726d51a2022-02-22 17:37:21 -080049using ::aidl::android::hardware::automotive::vehicle::VehiclePropertyType;
50using ::android::getAidlHalInstanceNames;
51using ::android::base::ScopedLockAssertion;
52using ::android::base::StringPrintf;
Chen Chengfaf9adc2022-06-22 23:09:09 +000053using ::android::frameworks::automotive::vhal::ErrorCode;
Yu Shan726d51a2022-02-22 17:37:21 -080054using ::android::frameworks::automotive::vhal::HalPropError;
55using ::android::frameworks::automotive::vhal::IHalPropConfig;
56using ::android::frameworks::automotive::vhal::IHalPropValue;
57using ::android::frameworks::automotive::vhal::ISubscriptionCallback;
58using ::android::frameworks::automotive::vhal::IVhalClient;
59using ::android::hardware::getAllHalInstanceNames;
60using ::android::hardware::Sanitize;
61using ::android::hardware::automotive::vehicle::toInt;
62
63constexpr int32_t kInvalidProp = 0x31600207;
64
65struct ServiceDescriptor {
66 std::string name;
67 bool isAidlService;
68};
69
70class VtsVehicleCallback final : public ISubscriptionCallback {
71 private:
72 std::mutex mLock;
73 std::unordered_map<int32_t, size_t> mEventsCount GUARDED_BY(mLock);
Yu Shan4569ef52022-03-18 14:34:25 -070074 std::unordered_map<int32_t, std::vector<int64_t>> mEventTimestamps GUARDED_BY(mLock);
Yu Shan726d51a2022-02-22 17:37:21 -080075 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 Shan4569ef52022-03-18 14:34:25 -070082 int32_t propId = value->getPropId();
83 mEventsCount[propId] += 1;
84 mEventTimestamps[propId].push_back(value->getTimestamp());
Yu Shan726d51a2022-02-22 17:37:21 -080085 }
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 Shan4569ef52022-03-18 14:34:25 -0700104 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 Shan726d51a2022-02-22 17:37:21 -0800111 void reset() {
112 std::lock_guard<std::mutex> lockGuard(mLock);
113 mEventsCount.clear();
114 }
115};
116
117class VtsHalAutomotiveVehicleTargetTest : public testing::TestWithParam<ServiceDescriptor> {
Yu Shanec5d5b02023-10-09 14:43:36 -0700118 protected:
119 void checkIsSupported(int32_t propertyId);
120
Yu Shan726d51a2022-02-22 17:37:21 -0800121 public:
Aaqib Ismail20486702022-10-27 16:58:50 -0700122 void verifyProperty(VehicleProperty propId, VehiclePropertyAccess access,
123 VehiclePropertyChangeMode changeMode, VehiclePropertyGroup group,
124 VehicleArea area, VehiclePropertyType propertyType);
Yu Shan726d51a2022-02-22 17:37:21 -0800125 virtual void SetUp() override {
126 auto descriptor = GetParam();
127 if (descriptor.isAidlService) {
128 mVhalClient = IVhalClient::tryCreateAidlClient(descriptor.name.c_str());
129 } else {
130 mVhalClient = IVhalClient::tryCreateHidlClient(descriptor.name.c_str());
131 }
132
133 ASSERT_NE(mVhalClient, nullptr) << "Failed to connect to VHAL";
134
135 mCallback = std::make_shared<VtsVehicleCallback>();
136 }
137
138 static bool isBooleanGlobalProp(int32_t property) {
139 return (property & toInt(VehiclePropertyType::MASK)) ==
140 toInt(VehiclePropertyType::BOOLEAN) &&
141 (property & toInt(VehicleArea::MASK)) == toInt(VehicleArea::GLOBAL);
142 }
143
144 protected:
145 std::shared_ptr<IVhalClient> mVhalClient;
146 std::shared_ptr<VtsVehicleCallback> mCallback;
147};
148
149TEST_P(VtsHalAutomotiveVehicleTargetTest, useAidlBackend) {
150 if (!mVhalClient->isAidlVhal()) {
151 GTEST_SKIP() << "AIDL backend is not available, HIDL backend is used instead";
152 }
153}
154
155TEST_P(VtsHalAutomotiveVehicleTargetTest, useHidlBackend) {
156 if (mVhalClient->isAidlVhal()) {
157 GTEST_SKIP() << "AIDL backend is available, HIDL backend is not used";
158 }
159}
160
Yu Shanec5d5b02023-10-09 14:43:36 -0700161// Test getAllPropConfigs() returns at least 1 property configs.
Yu Shan726d51a2022-02-22 17:37:21 -0800162TEST_P(VtsHalAutomotiveVehicleTargetTest, getAllPropConfigs) {
163 ALOGD("VtsHalAutomotiveVehicleTargetTest::getAllPropConfigs");
164
165 auto result = mVhalClient->getAllPropConfigs();
166
167 ASSERT_TRUE(result.ok()) << "Failed to get all property configs, error: "
168 << result.error().message();
Yu Shanec5d5b02023-10-09 14:43:36 -0700169 ASSERT_GE(result.value().size(), 1u) << StringPrintf(
170 "Expect to get at least 1 property config, got %zu", result.value().size());
Yu Shan726d51a2022-02-22 17:37:21 -0800171}
172
Yu Shanec5d5b02023-10-09 14:43:36 -0700173// Test getPropConfigs() can query properties returned by getAllPropConfigs.
174TEST_P(VtsHalAutomotiveVehicleTargetTest, getPropConfigsWithValidProps) {
Yu Shan726d51a2022-02-22 17:37:21 -0800175 ALOGD("VtsHalAutomotiveVehicleTargetTest::getRequiredPropConfigs");
176
Yu Shanec5d5b02023-10-09 14:43:36 -0700177 std::vector<int32_t> properties;
178 auto result = mVhalClient->getAllPropConfigs();
Yu Shan726d51a2022-02-22 17:37:21 -0800179
Yu Shanec5d5b02023-10-09 14:43:36 -0700180 ASSERT_TRUE(result.ok()) << "Failed to get all property configs, error: "
181 << result.error().message();
182 for (const auto& cfgPtr : result.value()) {
183 properties.push_back(cfgPtr->getPropId());
184 }
185
186 result = mVhalClient->getPropConfigs(properties);
Yu Shan726d51a2022-02-22 17:37:21 -0800187
188 ASSERT_TRUE(result.ok()) << "Failed to get required property config, error: "
189 << result.error().message();
Yu Shanec5d5b02023-10-09 14:43:36 -0700190 ASSERT_EQ(result.value().size(), properties.size()) << StringPrintf(
191 "Expect to get exactly %zu configs, got %zu", properties.size(), result.value().size());
Yu Shan726d51a2022-02-22 17:37:21 -0800192}
193
194// Test getPropConfig() with an invalid propertyId returns an error code.
195TEST_P(VtsHalAutomotiveVehicleTargetTest, getPropConfigsWithInvalidProp) {
196 ALOGD("VtsHalAutomotiveVehicleTargetTest::getPropConfigsWithInvalidProp");
197
198 auto result = mVhalClient->getPropConfigs({kInvalidProp});
199
200 ASSERT_FALSE(result.ok()) << StringPrintf(
201 "Expect failure to get prop configs for invalid prop: %" PRId32, kInvalidProp);
202 ASSERT_NE(result.error().message(), "") << "Expect error message not to be empty";
203}
204
205// Test get() return current value for properties.
206TEST_P(VtsHalAutomotiveVehicleTargetTest, get) {
207 ALOGD("VtsHalAutomotiveVehicleTargetTest::get");
208
209 int32_t propId = toInt(VehicleProperty::PERF_VEHICLE_SPEED);
Yu Shanec5d5b02023-10-09 14:43:36 -0700210 checkIsSupported(propId);
Yu Shan726d51a2022-02-22 17:37:21 -0800211 auto result = mVhalClient->getValueSync(*mVhalClient->createHalPropValue(propId));
212
213 ASSERT_TRUE(result.ok()) << StringPrintf("Failed to get value for property: %" PRId32
214 ", error: %s",
215 propId, result.error().message().c_str());
216 ASSERT_NE(result.value(), nullptr) << "Result value must not be null";
217}
218
219// Test get() with an invalid propertyId return an error codes.
220TEST_P(VtsHalAutomotiveVehicleTargetTest, getInvalidProp) {
221 ALOGD("VtsHalAutomotiveVehicleTargetTest::getInvalidProp");
222
223 auto result = mVhalClient->getValueSync(*mVhalClient->createHalPropValue(kInvalidProp));
224
225 ASSERT_FALSE(result.ok()) << StringPrintf(
226 "Expect failure to get property for invalid prop: %" PRId32, kInvalidProp);
227}
228
229// Test set() on read_write properties.
230TEST_P(VtsHalAutomotiveVehicleTargetTest, setProp) {
231 ALOGD("VtsHalAutomotiveVehicleTargetTest::setProp");
232
233 // skip hvac related properties
234 std::unordered_set<int32_t> hvacProps = {toInt(VehicleProperty::HVAC_DEFROSTER),
235 toInt(VehicleProperty::HVAC_AC_ON),
236 toInt(VehicleProperty::HVAC_MAX_AC_ON),
237 toInt(VehicleProperty::HVAC_MAX_DEFROST_ON),
238 toInt(VehicleProperty::HVAC_RECIRC_ON),
239 toInt(VehicleProperty::HVAC_DUAL_ON),
240 toInt(VehicleProperty::HVAC_AUTO_ON),
241 toInt(VehicleProperty::HVAC_POWER_ON),
242 toInt(VehicleProperty::HVAC_AUTO_RECIRC_ON),
243 toInt(VehicleProperty::HVAC_ELECTRIC_DEFROSTER_ON)};
244 auto result = mVhalClient->getAllPropConfigs();
245 ASSERT_TRUE(result.ok());
246
247 for (const auto& cfgPtr : result.value()) {
248 const IHalPropConfig& cfg = *cfgPtr;
249 int32_t propId = cfg.getPropId();
250 // test on boolean and writable property
251 if (cfg.getAccess() == toInt(VehiclePropertyAccess::READ_WRITE) &&
252 isBooleanGlobalProp(propId) && !hvacProps.count(propId)) {
253 auto propToGet = mVhalClient->createHalPropValue(propId);
254 auto getValueResult = mVhalClient->getValueSync(*propToGet);
255
256 ASSERT_TRUE(getValueResult.ok())
257 << StringPrintf("Failed to get value for property: %" PRId32 ", error: %s",
258 propId, getValueResult.error().message().c_str());
259 ASSERT_NE(getValueResult.value(), nullptr)
260 << StringPrintf("Result value must not be null for property: %" PRId32, propId);
261
262 const IHalPropValue& value = *getValueResult.value();
263 size_t intValueSize = value.getInt32Values().size();
264 ASSERT_EQ(intValueSize, 1u) << StringPrintf(
265 "Expect exactly 1 int value for boolean property: %" PRId32 ", got %zu", propId,
266 intValueSize);
267
268 int setValue = value.getInt32Values()[0] == 1 ? 0 : 1;
269 auto propToSet = mVhalClient->createHalPropValue(propId);
270 propToSet->setInt32Values({setValue});
271 auto setValueResult = mVhalClient->setValueSync(*propToSet);
272
273 ASSERT_TRUE(setValueResult.ok())
274 << StringPrintf("Failed to set value for property: %" PRId32 ", error: %s",
275 propId, setValueResult.error().message().c_str());
276
277 // check set success
278 getValueResult = mVhalClient->getValueSync(*propToGet);
279 ASSERT_TRUE(getValueResult.ok())
280 << StringPrintf("Failed to get value for property: %" PRId32 ", error: %s",
281 propId, getValueResult.error().message().c_str());
282 ASSERT_NE(getValueResult.value(), nullptr)
283 << StringPrintf("Result value must not be null for property: %" PRId32, propId);
284 ASSERT_EQ(getValueResult.value()->getInt32Values(), std::vector<int32_t>({setValue}))
285 << StringPrintf("Boolean value not updated after set for property: %" PRId32,
286 propId);
287 }
288 }
289}
290
291// Test set() on an read_only property.
292TEST_P(VtsHalAutomotiveVehicleTargetTest, setNotWritableProp) {
293 ALOGD("VtsHalAutomotiveVehicleTargetTest::setNotWritableProp");
294
295 int32_t propId = toInt(VehicleProperty::PERF_VEHICLE_SPEED);
Yu Shanec5d5b02023-10-09 14:43:36 -0700296 checkIsSupported(propId);
297
Yu Shan726d51a2022-02-22 17:37:21 -0800298 auto getValueResult = mVhalClient->getValueSync(*mVhalClient->createHalPropValue(propId));
299 ASSERT_TRUE(getValueResult.ok())
300 << StringPrintf("Failed to get value for property: %" PRId32 ", error: %s", propId,
301 getValueResult.error().message().c_str());
302
303 auto setValueResult = mVhalClient->setValueSync(*getValueResult.value());
304
305 ASSERT_FALSE(setValueResult.ok()) << "Expect set a read-only value to fail";
Chen Chengfaf9adc2022-06-22 23:09:09 +0000306 ASSERT_EQ(setValueResult.error().code(), ErrorCode::ACCESS_DENIED_FROM_VHAL);
Yu Shan726d51a2022-02-22 17:37:21 -0800307}
308
shrikar8a140232023-03-07 16:57:59 +0000309// Test get(), set() and getAllPropConfigs() on VehicleProperty::INVALID.
310TEST_P(VtsHalAutomotiveVehicleTargetTest, getSetPropertyIdInvalid) {
311 ALOGD("VtsHalAutomotiveVehicleTargetTest::getSetPropertyIdInvalid");
312
313 int32_t propId = toInt(VehicleProperty::INVALID);
314 auto getValueResult = mVhalClient->getValueSync(*mVhalClient->createHalPropValue(propId));
315 ASSERT_FALSE(getValueResult.ok()) << "Expect get on VehicleProperty::INVALID to fail";
316 ASSERT_EQ(getValueResult.error().code(), ErrorCode::INVALID_ARG);
317
318 auto propToSet = mVhalClient->createHalPropValue(propId);
319 propToSet->setInt32Values({0});
320 auto setValueResult = mVhalClient->setValueSync(*propToSet);
321 ASSERT_FALSE(setValueResult.ok()) << "Expect set on VehicleProperty::INVALID to fail";
322 ASSERT_EQ(setValueResult.error().code(), ErrorCode::INVALID_ARG);
323
324 auto result = mVhalClient->getAllPropConfigs();
325 ASSERT_TRUE(result.ok());
326 for (const auto& cfgPtr : result.value()) {
327 const IHalPropConfig& cfg = *cfgPtr;
328 ASSERT_FALSE(cfg.getPropId() == propId) << "Expect VehicleProperty::INVALID to not be "
329 "included in propConfigs";
330 }
331}
332
Yu Shan726d51a2022-02-22 17:37:21 -0800333// Test subscribe() and unsubscribe().
334TEST_P(VtsHalAutomotiveVehicleTargetTest, subscribeAndUnsubscribe) {
335 ALOGD("VtsHalAutomotiveVehicleTargetTest::subscribeAndUnsubscribe");
336
337 int32_t propId = toInt(VehicleProperty::PERF_VEHICLE_SPEED);
Yu Shanec5d5b02023-10-09 14:43:36 -0700338 checkIsSupported(propId);
Yu Shan726d51a2022-02-22 17:37:21 -0800339
Yu Shan4569ef52022-03-18 14:34:25 -0700340 auto propConfigsResult = mVhalClient->getPropConfigs({propId});
341
342 ASSERT_TRUE(propConfigsResult.ok()) << "Failed to get property config for PERF_VEHICLE_SPEED: "
343 << "error: " << propConfigsResult.error().message();
344 ASSERT_EQ(propConfigsResult.value().size(), 1u)
345 << "Expect to return 1 config for PERF_VEHICLE_SPEED";
346 auto& propConfig = propConfigsResult.value()[0];
347 float minSampleRate = propConfig->getMinSampleRate();
348 float maxSampleRate = propConfig->getMaxSampleRate();
349
350 if (minSampleRate < 1) {
351 GTEST_SKIP() << "Sample rate for vehicle speed < 1 times/sec, skip test since it would "
352 "take too long";
353 }
Yu Shan726d51a2022-02-22 17:37:21 -0800354
355 auto client = mVhalClient->getSubscriptionClient(mCallback);
356 ASSERT_NE(client, nullptr) << "Failed to get subscription client";
357
Yu Shan4569ef52022-03-18 14:34:25 -0700358 auto result = client->subscribe({{.propId = propId, .sampleRate = minSampleRate}});
Yu Shan726d51a2022-02-22 17:37:21 -0800359
360 ASSERT_TRUE(result.ok()) << StringPrintf("Failed to subscribe to property: %" PRId32
361 ", error: %s",
362 propId, result.error().message().c_str());
Yu Shan4569ef52022-03-18 14:34:25 -0700363
364 if (mVhalClient->isAidlVhal()) {
365 // Skip checking timestamp for HIDL because the behavior for sample rate and timestamp is
366 // only specified clearly for AIDL.
367
368 // Timeout is 2 seconds, which gives a 1 second buffer.
369 ASSERT_TRUE(mCallback->waitForExpectedEvents(propId, std::floor(minSampleRate),
370 std::chrono::seconds(2)))
371 << "Didn't get enough events for subscribing to minSampleRate";
372 }
373
374 result = client->subscribe({{.propId = propId, .sampleRate = maxSampleRate}});
375
376 ASSERT_TRUE(result.ok()) << StringPrintf("Failed to subscribe to property: %" PRId32
377 ", error: %s",
378 propId, result.error().message().c_str());
379
380 if (mVhalClient->isAidlVhal()) {
381 ASSERT_TRUE(mCallback->waitForExpectedEvents(propId, std::floor(maxSampleRate),
382 std::chrono::seconds(2)))
383 << "Didn't get enough events for subscribing to maxSampleRate";
384
385 std::unordered_set<int64_t> timestamps;
386 // Event event should have a different timestamp.
387 for (const int64_t& eventTimestamp : mCallback->getEventTimestamps(propId)) {
388 ASSERT_TRUE(timestamps.find(eventTimestamp) == timestamps.end())
389 << "two events for the same property must not have the same timestamp";
390 timestamps.insert(eventTimestamp);
391 }
392 }
Yu Shan726d51a2022-02-22 17:37:21 -0800393
394 result = client->unsubscribe({propId});
395 ASSERT_TRUE(result.ok()) << StringPrintf("Failed to unsubscribe to property: %" PRId32
396 ", error: %s",
397 propId, result.error().message().c_str());
398
399 mCallback->reset();
400 ASSERT_FALSE(mCallback->waitForExpectedEvents(propId, 10, std::chrono::seconds(1)))
401 << "Expect not to get events after unsubscription";
402}
403
404// Test subscribe() with an invalid property.
405TEST_P(VtsHalAutomotiveVehicleTargetTest, subscribeInvalidProp) {
406 ALOGD("VtsHalAutomotiveVehicleTargetTest::subscribeInvalidProp");
407
408 std::vector<SubscribeOptions> options = {
409 SubscribeOptions{.propId = kInvalidProp, .sampleRate = 10.0}};
410
411 auto client = mVhalClient->getSubscriptionClient(mCallback);
412 ASSERT_NE(client, nullptr) << "Failed to get subscription client";
413
414 auto result = client->subscribe(options);
415
416 ASSERT_FALSE(result.ok()) << StringPrintf("Expect subscribing to property: %" PRId32 " to fail",
417 kInvalidProp);
418}
419
Yu Shan4569ef52022-03-18 14:34:25 -0700420// Test the timestamp returned in GetValues results is the timestamp when the value is retrieved.
421TEST_P(VtsHalAutomotiveVehicleTargetTest, testGetValuesTimestampAIDL) {
422 if (!mVhalClient->isAidlVhal()) {
423 GTEST_SKIP() << "Skip checking timestamp for HIDL because the behavior is only specified "
424 "for AIDL";
425 }
426
427 int32_t propId = toInt(VehicleProperty::PARKING_BRAKE_ON);
Yu Shanec5d5b02023-10-09 14:43:36 -0700428 checkIsSupported(propId);
Yu Shan4569ef52022-03-18 14:34:25 -0700429 auto prop = mVhalClient->createHalPropValue(propId);
430
431 auto result = mVhalClient->getValueSync(*prop);
432
433 ASSERT_TRUE(result.ok()) << StringPrintf("Failed to get value for property: %" PRId32
434 ", error: %s",
435 propId, result.error().message().c_str());
436 ASSERT_NE(result.value(), nullptr) << "Result value must not be null";
437 ASSERT_EQ(result.value()->getInt32Values().size(), 1u) << "Result must contain 1 int value";
438
439 bool parkBrakeOnValue1 = (result.value()->getInt32Values()[0] == 1);
440 int64_t timestampValue1 = result.value()->getTimestamp();
441
442 result = mVhalClient->getValueSync(*prop);
443
444 ASSERT_TRUE(result.ok()) << StringPrintf("Failed to get value for property: %" PRId32
445 ", error: %s",
446 propId, result.error().message().c_str());
447 ASSERT_NE(result.value(), nullptr) << "Result value must not be null";
448 ASSERT_EQ(result.value()->getInt32Values().size(), 1u) << "Result must contain 1 int value";
449
450 bool parkBarkeOnValue2 = (result.value()->getInt32Values()[0] == 1);
451 int64_t timestampValue2 = result.value()->getTimestamp();
452
453 if (parkBarkeOnValue2 == parkBrakeOnValue1) {
454 ASSERT_EQ(timestampValue2, timestampValue1)
455 << "getValue result must contain a timestamp updated when the value was updated, if"
456 "the value does not change, expect the same timestamp";
457 } else {
458 ASSERT_GT(timestampValue2, timestampValue1)
459 << "getValue result must contain a timestamp updated when the value was updated, if"
460 "the value changes, expect the newer value has a larger timestamp";
461 }
462}
463
Aaqib Ismail20486702022-10-27 16:58:50 -0700464// Helper function to compare actual vs expected property config
465void VtsHalAutomotiveVehicleTargetTest::verifyProperty(VehicleProperty propId,
466 VehiclePropertyAccess access,
467 VehiclePropertyChangeMode changeMode,
468 VehiclePropertyGroup group, VehicleArea area,
469 VehiclePropertyType propertyType) {
470 int expectedPropId = toInt(propId);
471 int expectedAccess = toInt(access);
472 int expectedChangeMode = toInt(changeMode);
473 int expectedGroup = toInt(group);
474 int expectedArea = toInt(area);
475 int expectedPropertyType = toInt(propertyType);
476
Eva Chen17bc5782023-01-06 22:59:58 -0800477 auto result = mVhalClient->getAllPropConfigs();
478 ASSERT_TRUE(result.ok()) << "Failed to get all property configs, error: "
479 << result.error().message();
480
481 // Check if property is implemented by getting all configs and looking to see if the expected
482 // property id is in that list.
483 bool isExpectedPropIdImplemented = false;
484 for (const auto& cfgPtr : result.value()) {
485 const IHalPropConfig& cfg = *cfgPtr;
486 if (expectedPropId == cfg.getPropId()) {
487 isExpectedPropIdImplemented = true;
488 break;
489 }
490 }
491
492 if (!isExpectedPropIdImplemented) {
493 GTEST_SKIP() << StringPrintf("Property %" PRId32 " has not been implemented",
494 expectedPropId);
495 }
496
497 result = mVhalClient->getPropConfigs({expectedPropId});
Aaqib Ismail20486702022-10-27 16:58:50 -0700498 ASSERT_TRUE(result.ok()) << "Failed to get required property config, error: "
499 << result.error().message();
500
Aaqib Ismail20486702022-10-27 16:58:50 -0700501 ASSERT_EQ(result.value().size(), 1u)
502 << StringPrintf("Expect to get exactly 1 config, got %zu", result.value().size());
503
504 const auto& config = result.value().at(0);
505 int actualPropId = config->getPropId();
506 int actualAccess = config->getAccess();
507 int actualChangeMode = config->getChangeMode();
508 int actualGroup = actualPropId & toInt(VehiclePropertyGroup::MASK);
509 int actualArea = actualPropId & toInt(VehicleArea::MASK);
510 int actualPropertyType = actualPropId & toInt(VehiclePropertyType::MASK);
511
512 ASSERT_EQ(actualPropId, expectedPropId)
513 << StringPrintf("Expect to get property ID: %i, got %i", expectedPropId, actualPropId);
514
515 if (expectedAccess == toInt(VehiclePropertyAccess::READ_WRITE)) {
516 ASSERT_TRUE(actualAccess == expectedAccess ||
517 actualAccess == toInt(VehiclePropertyAccess::READ))
518 << StringPrintf("Expect to get VehiclePropertyAccess: %i or %i, got %i",
519 expectedAccess, toInt(VehiclePropertyAccess::READ), actualAccess);
520 } else {
521 ASSERT_EQ(actualAccess, expectedAccess) << StringPrintf(
522 "Expect to get VehiclePropertyAccess: %i, got %i", expectedAccess, actualAccess);
523 }
524
525 ASSERT_EQ(actualChangeMode, expectedChangeMode)
526 << StringPrintf("Expect to get VehiclePropertyChangeMode: %i, got %i",
527 expectedChangeMode, actualChangeMode);
528 ASSERT_EQ(actualGroup, expectedGroup) << StringPrintf(
529 "Expect to get VehiclePropertyGroup: %i, got %i", expectedGroup, actualGroup);
530 ASSERT_EQ(actualArea, expectedArea)
531 << StringPrintf("Expect to get VehicleArea: %i, got %i", expectedArea, actualArea);
532 ASSERT_EQ(actualPropertyType, expectedPropertyType)
533 << StringPrintf("Expect to get VehiclePropertyType: %i, got %i", expectedPropertyType,
534 actualPropertyType);
535}
536
shrikar34563642023-02-14 02:57:17 +0000537TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyLocationCharacterizationConfig) {
538 verifyProperty(VehicleProperty::LOCATION_CHARACTERIZATION, VehiclePropertyAccess::READ,
539 VehiclePropertyChangeMode::STATIC, VehiclePropertyGroup::SYSTEM,
540 VehicleArea::GLOBAL, VehiclePropertyType::INT32);
541}
542
shrikar668df362022-12-20 22:08:17 +0000543TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyEmergencyLaneKeepAssistEnabledConfig) {
544 verifyProperty(VehicleProperty::EMERGENCY_LANE_KEEP_ASSIST_ENABLED,
545 VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
546 VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
547}
548
shrikar80cc0c52023-01-30 16:56:53 +0000549TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyEmergencyLaneKeepAssistStateConfig) {
550 verifyProperty(VehicleProperty::EMERGENCY_LANE_KEEP_ASSIST_STATE, VehiclePropertyAccess::READ,
551 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
552 VehicleArea::GLOBAL, VehiclePropertyType::INT32);
553}
554
shrikar5d1b8162023-01-25 19:31:23 +0000555TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyCruiseControlEnabledConfig) {
556 verifyProperty(VehicleProperty::CRUISE_CONTROL_ENABLED, VehiclePropertyAccess::READ_WRITE,
557 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
558 VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
shrikar808a2942022-12-21 17:07:32 +0000559}
560
shrikard440ed42023-01-31 00:25:14 +0000561TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyCruiseControlTypeConfig) {
562 verifyProperty(VehicleProperty::CRUISE_CONTROL_TYPE, VehiclePropertyAccess::READ_WRITE,
563 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
564 VehicleArea::GLOBAL, VehiclePropertyType::INT32);
565}
566
shrikar2753b9e2023-01-31 00:25:14 +0000567TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyCruiseControlStateConfig) {
568 verifyProperty(VehicleProperty::CRUISE_CONTROL_STATE, VehiclePropertyAccess::READ,
569 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
570 VehicleArea::GLOBAL, VehiclePropertyType::INT32);
571}
572
shrikar5df0f952023-02-02 00:15:39 +0000573TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyCruiseControlCommandConfig) {
574 verifyProperty(VehicleProperty::CRUISE_CONTROL_COMMAND, VehiclePropertyAccess::WRITE,
575 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
576 VehicleArea::GLOBAL, VehiclePropertyType::INT32);
577}
578
shrikarfde8c242023-02-02 01:10:33 +0000579TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyCruiseControlTargetSpeedConfig) {
580 verifyProperty(VehicleProperty::CRUISE_CONTROL_TARGET_SPEED, VehiclePropertyAccess::READ,
581 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
582 VehicleArea::GLOBAL, VehiclePropertyType::FLOAT);
583}
584
shrikarb9661d32023-02-02 19:22:50 +0000585TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyAdaptiveCruiseControlTargetTimeGapConfig) {
586 verifyProperty(VehicleProperty::ADAPTIVE_CRUISE_CONTROL_TARGET_TIME_GAP,
587 VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
588 VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::INT32);
589}
590
shrikarf62d7472023-02-03 00:20:04 +0000591TEST_P(VtsHalAutomotiveVehicleTargetTest,
592 verifyAdaptiveCruiseControlLeadVehicleMeasuredDistanceConfig) {
593 verifyProperty(VehicleProperty::ADAPTIVE_CRUISE_CONTROL_LEAD_VEHICLE_MEASURED_DISTANCE,
594 VehiclePropertyAccess::READ, VehiclePropertyChangeMode::CONTINUOUS,
595 VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::INT32);
596}
597
shrikar37833e12022-12-15 20:13:14 +0000598TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyHandsOnDetectionEnabledConfig) {
599 verifyProperty(VehicleProperty::HANDS_ON_DETECTION_ENABLED, VehiclePropertyAccess::READ_WRITE,
600 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
601 VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
602}
603
shrikar6d88bf52023-01-17 17:04:21 +0000604TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyHandsOnDetectionDriverStateConfig) {
605 verifyProperty(VehicleProperty::HANDS_ON_DETECTION_DRIVER_STATE, VehiclePropertyAccess::READ,
606 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
607 VehicleArea::GLOBAL, VehiclePropertyType::INT32);
608}
609
shrikara6785992023-01-18 23:07:06 +0000610TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyHandsOnDetectionWarningConfig) {
611 verifyProperty(VehicleProperty::HANDS_ON_DETECTION_WARNING, VehiclePropertyAccess::READ,
612 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
613 VehicleArea::GLOBAL, VehiclePropertyType::INT32);
614}
615
Aaqib Ismailc69e9682022-11-22 12:50:00 -0800616TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyEvBrakeRegenerationLevelConfig) {
617 verifyProperty(VehicleProperty::EV_BRAKE_REGENERATION_LEVEL,
618 VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
619 VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::INT32);
620}
621
shrikar2dae80f2022-12-21 23:50:17 +0000622TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyEvStoppingModeConfig) {
623 verifyProperty(VehicleProperty::EV_STOPPING_MODE, VehiclePropertyAccess::READ_WRITE,
624 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
625 VehicleArea::GLOBAL, VehiclePropertyType::INT32);
626}
627
Aaqib Ismailaec678a2022-12-07 16:22:42 -0800628TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyEvCurrentBatteryCapacityConfig) {
629 verifyProperty(VehicleProperty::EV_CURRENT_BATTERY_CAPACITY, VehiclePropertyAccess::READ,
630 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
631 VehicleArea::GLOBAL, VehiclePropertyType::FLOAT);
632}
633
shrikar83914472022-12-16 20:28:47 +0000634TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyEngineIdleAutoStopEnabledConfig) {
635 verifyProperty(VehicleProperty::ENGINE_IDLE_AUTO_STOP_ENABLED,
636 VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
637 VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
638}
639
Aaqib Ismail20486702022-10-27 16:58:50 -0700640TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyDoorChildLockEnabledConfig) {
641 verifyProperty(VehicleProperty::DOOR_CHILD_LOCK_ENABLED, VehiclePropertyAccess::READ_WRITE,
642 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
643 VehicleArea::DOOR, VehiclePropertyType::BOOLEAN);
644}
645
Aaqib Ismail63d52d12023-01-30 12:35:10 -0800646TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyWindshieldWipersPeriodConfig) {
647 verifyProperty(VehicleProperty::WINDSHIELD_WIPERS_PERIOD, VehiclePropertyAccess::READ,
648 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
649 VehicleArea::WINDOW, VehiclePropertyType::INT32);
650}
651
Aaqib Ismail732a1d72023-01-31 10:25:45 -0800652TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyWindshieldWipersStateConfig) {
653 verifyProperty(VehicleProperty::WINDSHIELD_WIPERS_STATE, VehiclePropertyAccess::READ,
654 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
655 VehicleArea::WINDOW, VehiclePropertyType::INT32);
656}
657
Aaqib Ismailc37a2112023-02-02 11:30:08 -0800658TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyWindshieldWipersSwitchConfig) {
659 verifyProperty(VehicleProperty::WINDSHIELD_WIPERS_SWITCH, VehiclePropertyAccess::READ_WRITE,
660 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
661 VehicleArea::WINDOW, VehiclePropertyType::INT32);
662}
663
Aaqib Ismail7f941b42022-11-04 14:55:13 -0700664TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySteeringWheelDepthPosConfig) {
665 verifyProperty(VehicleProperty::STEERING_WHEEL_DEPTH_POS, VehiclePropertyAccess::READ_WRITE,
666 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
667 VehicleArea::GLOBAL, VehiclePropertyType::INT32);
668}
669
Aaqib Ismail34fe92f2022-11-04 21:41:23 -0700670TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySteeringWheelDepthMoveConfig) {
671 verifyProperty(VehicleProperty::STEERING_WHEEL_DEPTH_MOVE, VehiclePropertyAccess::READ_WRITE,
672 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
673 VehicleArea::GLOBAL, VehiclePropertyType::INT32);
674}
675
Aaqib Ismail53b81c92022-11-07 17:47:04 -0800676TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySteeringWheelHeightPosConfig) {
677 verifyProperty(VehicleProperty::STEERING_WHEEL_HEIGHT_POS, VehiclePropertyAccess::READ_WRITE,
678 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
679 VehicleArea::GLOBAL, VehiclePropertyType::INT32);
680}
681
Aaqib Ismail6c4bf192022-11-08 15:00:32 -0800682TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySteeringWheelHeightMoveConfig) {
683 verifyProperty(VehicleProperty::STEERING_WHEEL_HEIGHT_MOVE, VehiclePropertyAccess::READ_WRITE,
684 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
685 VehicleArea::GLOBAL, VehiclePropertyType::INT32);
686}
687
Aaqib Ismail8d051182022-11-09 13:28:48 -0800688TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySteeringWheelTheftLockEnabledConfig) {
689 verifyProperty(VehicleProperty::STEERING_WHEEL_THEFT_LOCK_ENABLED,
690 VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
691 VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
692}
693
Aaqib Ismail68d3f122022-11-09 14:43:32 -0800694TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySteeringWheelLockedConfig) {
695 verifyProperty(VehicleProperty::STEERING_WHEEL_LOCKED, VehiclePropertyAccess::READ_WRITE,
696 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
697 VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
698}
699
Aaqib Ismaild4d6adf2022-11-09 16:59:47 -0800700TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySteeringWheelEasyAccessEnabledConfig) {
701 verifyProperty(VehicleProperty::STEERING_WHEEL_EASY_ACCESS_ENABLED,
702 VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
703 VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
704}
705
Aaqib Ismail0dc7ba02022-11-10 14:28:09 -0800706TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySteeringWheelLightsStateConfig) {
707 verifyProperty(VehicleProperty::STEERING_WHEEL_LIGHTS_STATE, VehiclePropertyAccess::READ,
708 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
709 VehicleArea::GLOBAL, VehiclePropertyType::INT32);
710}
711
Aaqib Ismail4b8688f2022-11-15 15:13:35 -0800712TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySteeringWheelLightsSwitchConfig) {
713 verifyProperty(VehicleProperty::STEERING_WHEEL_LIGHTS_SWITCH, VehiclePropertyAccess::READ_WRITE,
714 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
715 VehicleArea::GLOBAL, VehiclePropertyType::INT32);
716}
717
Arati Gerdesd86c7fd2022-12-19 12:32:29 -0800718TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyGloveBoxDoorPosConfig) {
719 verifyProperty(VehicleProperty::GLOVE_BOX_DOOR_POS, VehiclePropertyAccess::READ_WRITE,
720 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
721 VehicleArea::SEAT, VehiclePropertyType::INT32);
722}
723
Aaqib Ismail57be4032023-02-02 14:15:03 -0800724TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyGloveBoxLockedConfig) {
725 verifyProperty(VehicleProperty::GLOVE_BOX_LOCKED, VehiclePropertyAccess::READ_WRITE,
726 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
727 VehicleArea::SEAT, VehiclePropertyType::BOOLEAN);
728}
729
shrikara1367212022-11-02 16:07:35 +0000730TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyMirrorAutoFoldEnabledConfig) {
731 verifyProperty(VehicleProperty::MIRROR_AUTO_FOLD_ENABLED, VehiclePropertyAccess::READ_WRITE,
732 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
733 VehicleArea::MIRROR, VehiclePropertyType::BOOLEAN);
734}
735
736TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyMirrorAutoTiltEnabledConfig) {
737 verifyProperty(VehicleProperty::MIRROR_AUTO_TILT_ENABLED, VehiclePropertyAccess::READ_WRITE,
738 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
739 VehicleArea::MIRROR, VehiclePropertyType::BOOLEAN);
740}
741
Aaqib Ismail4e6144c2022-12-15 15:32:18 -0800742TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySeatHeadrestHeightPosV2Config) {
743 verifyProperty(VehicleProperty::SEAT_HEADREST_HEIGHT_POS_V2, VehiclePropertyAccess::READ_WRITE,
744 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
745 VehicleArea::SEAT, VehiclePropertyType::INT32);
746}
747
shrikar6ae79162022-12-16 03:03:25 +0000748TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySeatWalkInPosConfig) {
749 verifyProperty(VehicleProperty::SEAT_WALK_IN_POS, VehiclePropertyAccess::READ_WRITE,
750 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
751 VehicleArea::SEAT, VehiclePropertyType::INT32);
752}
753
shrikarfb65ae52022-11-03 23:12:51 +0000754TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySeatFootwellLightsStateConfig) {
755 verifyProperty(VehicleProperty::SEAT_FOOTWELL_LIGHTS_STATE, VehiclePropertyAccess::READ,
756 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
757 VehicleArea::SEAT, VehiclePropertyType::INT32);
758}
759
shrikar93cf1be2022-11-30 15:00:52 -0800760TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySeatFootwellLightsSwitchConfig) {
761 verifyProperty(VehicleProperty::SEAT_FOOTWELL_LIGHTS_SWITCH, VehiclePropertyAccess::READ_WRITE,
762 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
763 VehicleArea::SEAT, VehiclePropertyType::INT32);
764}
765
shrikar3326de02022-11-07 23:51:20 +0000766TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySeatEasyAccessEnabledConfig) {
767 verifyProperty(VehicleProperty::SEAT_EASY_ACCESS_ENABLED, VehiclePropertyAccess::READ_WRITE,
768 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
769 VehicleArea::SEAT, VehiclePropertyType::BOOLEAN);
770}
771
shrikarb96e3762022-11-08 16:49:58 -0800772TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySeatAirbagEnabledConfig) {
773 verifyProperty(VehicleProperty::SEAT_AIRBAG_ENABLED, VehiclePropertyAccess::READ_WRITE,
774 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
775 VehicleArea::SEAT, VehiclePropertyType::BOOLEAN);
776}
777
shrikar802ecb52022-11-09 18:27:06 +0000778TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySeatCushionSideSupportPosConfig) {
779 verifyProperty(VehicleProperty::SEAT_CUSHION_SIDE_SUPPORT_POS,
780 VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
781 VehiclePropertyGroup::SYSTEM, VehicleArea::SEAT, VehiclePropertyType::INT32);
782}
783
shrikar1f0ce0d2022-11-11 17:46:06 +0000784TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySeatCushionSideSupportMoveConfig) {
785 verifyProperty(VehicleProperty::SEAT_CUSHION_SIDE_SUPPORT_MOVE,
786 VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
787 VehiclePropertyGroup::SYSTEM, VehicleArea::SEAT, VehiclePropertyType::INT32);
788}
789
shrikareff71b22022-11-11 11:02:43 -0800790TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySeatLumbarVerticalPosConfig) {
791 verifyProperty(VehicleProperty::SEAT_LUMBAR_VERTICAL_POS, VehiclePropertyAccess::READ_WRITE,
792 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
793 VehicleArea::SEAT, VehiclePropertyType::INT32);
794}
795
shrikar2a081c52022-11-11 16:49:58 -0800796TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySeatLumbarVerticalMoveConfig) {
797 verifyProperty(VehicleProperty::SEAT_LUMBAR_VERTICAL_MOVE, VehiclePropertyAccess::READ_WRITE,
798 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
799 VehicleArea::SEAT, VehiclePropertyType::INT32);
800}
801
Aaqib Ismail5d53aa32022-12-13 22:30:23 +0000802TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyAutomaticEmergencyBrakingEnabledConfig) {
803 verifyProperty(VehicleProperty::AUTOMATIC_EMERGENCY_BRAKING_ENABLED,
804 VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
805 VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
806}
807
Aaqib Ismail28ee23c2023-01-04 23:04:46 -0800808TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyAutomaticEmergencyBrakingStateConfig) {
809 verifyProperty(VehicleProperty::AUTOMATIC_EMERGENCY_BRAKING_STATE, VehiclePropertyAccess::READ,
810 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
811 VehicleArea::GLOBAL, VehiclePropertyType::INT32);
812}
813
Aaqib Ismaila2513672022-12-15 00:55:27 +0000814TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyForwardCollisionWarningEnabledConfig) {
815 verifyProperty(VehicleProperty::FORWARD_COLLISION_WARNING_ENABLED,
816 VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
817 VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
818}
819
Aaqib Ismail0a1ab292023-01-19 21:33:56 +0000820TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyForwardCollisionWarningStateConfig) {
821 verifyProperty(VehicleProperty::FORWARD_COLLISION_WARNING_STATE, VehiclePropertyAccess::READ,
822 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
823 VehicleArea::GLOBAL, VehiclePropertyType::INT32);
824}
825
Aaqib Ismail3f7177a2022-12-17 09:20:00 -0800826TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyBlindSpotWarningEnabledConfig) {
827 verifyProperty(VehicleProperty::BLIND_SPOT_WARNING_ENABLED, VehiclePropertyAccess::READ_WRITE,
828 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
829 VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
830}
831
Aaqib Ismail5fc97bb2023-01-10 17:07:47 -0800832TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyBlindSpotWarningStateConfig) {
833 verifyProperty(VehicleProperty::BLIND_SPOT_WARNING_STATE, VehiclePropertyAccess::READ,
834 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
835 VehicleArea::MIRROR, VehiclePropertyType::INT32);
836}
837
Aaqib Ismail7a46cef2022-12-17 10:00:59 -0800838TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyLaneDepartureWarningEnabledConfig) {
839 verifyProperty(VehicleProperty::LANE_DEPARTURE_WARNING_ENABLED,
840 VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
841 VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
842}
843
Aaqib Ismail8462db52023-01-27 19:59:49 -0800844TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyLaneDepartureWarningStateConfig) {
845 verifyProperty(VehicleProperty::LANE_DEPARTURE_WARNING_STATE, VehiclePropertyAccess::READ,
846 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
847 VehicleArea::GLOBAL, VehiclePropertyType::INT32);
848}
849
Aaqib Ismail20cc66a2022-12-22 05:38:28 -0800850TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyLaneKeepAssistEnabledConfig) {
851 verifyProperty(VehicleProperty::LANE_KEEP_ASSIST_ENABLED, VehiclePropertyAccess::READ_WRITE,
852 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
853 VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
854}
855
Aaqib Ismail78db2ca2023-01-10 17:34:28 -0800856TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyLaneKeepAssistStateConfig) {
857 verifyProperty(VehicleProperty::LANE_KEEP_ASSIST_STATE, VehiclePropertyAccess::READ,
858 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
859 VehicleArea::GLOBAL, VehiclePropertyType::INT32);
860}
861
Aaqib Ismailb1680a72022-12-14 23:28:49 +0000862TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyLaneCenteringAssistEnabledConfig) {
863 verifyProperty(VehicleProperty::LANE_CENTERING_ASSIST_ENABLED,
864 VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
865 VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
866}
867
Aaqib Ismail0ffd39c2023-01-11 12:19:10 -0800868TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyLaneCenteringAssistCommandConfig) {
869 verifyProperty(VehicleProperty::LANE_CENTERING_ASSIST_COMMAND, VehiclePropertyAccess::WRITE,
870 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
871 VehicleArea::GLOBAL, VehiclePropertyType::INT32);
872}
873
Aaqib Ismaildb034442023-01-10 18:14:28 -0800874TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyLaneCenteringAssistStateConfig) {
875 verifyProperty(VehicleProperty::LANE_CENTERING_ASSIST_STATE, VehiclePropertyAccess::READ,
876 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
877 VehicleArea::GLOBAL, VehiclePropertyType::INT32);
878}
879
Yuncheol Heo8fbbfd12023-09-27 15:43:59 -0700880TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyClusterHeartbeatConfig) {
881 verifyProperty(VehicleProperty::CLUSTER_HEARTBEAT, VehiclePropertyAccess::WRITE,
882 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
883 VehicleArea::GLOBAL, VehiclePropertyType::MIXED);
884}
885
Yu Shanec5d5b02023-10-09 14:43:36 -0700886void VtsHalAutomotiveVehicleTargetTest::checkIsSupported(int32_t propertyId) {
887 auto result = mVhalClient->getPropConfigs({propertyId});
888 ASSERT_TRUE(result.ok()) << "Failed to get required property config, error: "
889 << result.error().message();
890 if (result.value().size() == 0) {
891 GTEST_SKIP() << "Property: " << propertyId << " is not supported, skip the test";
892 }
893}
894
Yu Shan726d51a2022-02-22 17:37:21 -0800895std::vector<ServiceDescriptor> getDescriptors() {
896 std::vector<ServiceDescriptor> descriptors;
897 for (std::string name : getAidlHalInstanceNames(IVehicle::descriptor)) {
898 descriptors.push_back({
899 .name = name,
900 .isAidlService = true,
901 });
902 }
903 for (std::string name : getAllHalInstanceNames(IVehicle::descriptor)) {
904 descriptors.push_back({
905 .name = name,
906 .isAidlService = false,
907 });
908 }
909 return descriptors;
910}
911
912GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(VtsHalAutomotiveVehicleTargetTest);
913
914INSTANTIATE_TEST_SUITE_P(PerInstance, VtsHalAutomotiveVehicleTargetTest,
915 testing::ValuesIn(getDescriptors()),
916 [](const testing::TestParamInfo<ServiceDescriptor>& info) {
917 std::string name = "";
918 if (info.param.isAidlService) {
919 name += "aidl_";
920 } else {
921 name += "hidl_";
922 }
923 name += info.param.name;
924 return Sanitize(name);
925 });
926
927int main(int argc, char** argv) {
928 ::testing::InitGoogleTest(&argc, argv);
929 ABinderProcess_setThreadPoolMaxThreadCount(1);
930 return RUN_ALL_TESTS();
931}