• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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>
33 #include <utils/SystemClock.h>
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;
47 using ::aidl::android::hardware::automotive::vehicle::VehiclePropertyChangeMode;
48 using ::aidl::android::hardware::automotive::vehicle::VehiclePropertyGroup;
49 using ::aidl::android::hardware::automotive::vehicle::VehiclePropertyType;
50 using ::android::getAidlHalInstanceNames;
51 using ::android::base::ScopedLockAssertion;
52 using ::android::base::StringPrintf;
53 using ::android::frameworks::automotive::vhal::ErrorCode;
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);
74     std::unordered_map<int32_t, std::vector<int64_t>> mEventTimestamps GUARDED_BY(mLock);
75     std::condition_variable mEventCond;
76 
77   public:
onPropertyEvent(const std::vector<std::unique_ptr<IHalPropValue>> & values)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) {
82                 int32_t propId = value->getPropId();
83                 mEventsCount[propId] += 1;
84                 mEventTimestamps[propId].push_back(value->getTimestamp());
85             }
86         }
87         mEventCond.notify_one();
88     }
89 
onPropertySetError(const std::vector<HalPropError> & errors)90     void onPropertySetError([[maybe_unused]] const std::vector<HalPropError>& errors) override {
91         // Do nothing.
92     }
93 
94     template <class Rep, class Period>
waitForExpectedEvents(int32_t propId,size_t expectedEvents,const std::chrono::duration<Rep,Period> & timeout)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 
getEventTimestamps(int32_t propId)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 
reset()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   protected:
119     bool checkIsSupported(int32_t propertyId);
120 
121   public:
122     void verifyProperty(VehicleProperty propId, VehiclePropertyAccess access,
123                         VehiclePropertyChangeMode changeMode, VehiclePropertyGroup group,
124                         VehicleArea area, VehiclePropertyType propertyType);
SetUp()125     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 
isBooleanGlobalProp(int32_t property)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 
TEST_P(VtsHalAutomotiveVehicleTargetTest,useAidlBackend)149 TEST_P(VtsHalAutomotiveVehicleTargetTest, useAidlBackend) {
150     if (!mVhalClient->isAidlVhal()) {
151         GTEST_SKIP() << "AIDL backend is not available, HIDL backend is used instead";
152     }
153 }
154 
TEST_P(VtsHalAutomotiveVehicleTargetTest,useHidlBackend)155 TEST_P(VtsHalAutomotiveVehicleTargetTest, useHidlBackend) {
156     if (mVhalClient->isAidlVhal()) {
157         GTEST_SKIP() << "AIDL backend is available, HIDL backend is not used";
158     }
159 }
160 
161 // Test getAllPropConfigs() returns at least 1 property configs.
TEST_P(VtsHalAutomotiveVehicleTargetTest,getAllPropConfigs)162 TEST_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();
169     ASSERT_GE(result.value().size(), 1u)
170           << StringPrintf("Expect to get at least 1 property config, got %zu",
171                           result.value().size());
172 }
173 
174 // Test getPropConfigs() can query properties returned by getAllPropConfigs.
TEST_P(VtsHalAutomotiveVehicleTargetTest,getPropConfigsWithValidProps)175 TEST_P(VtsHalAutomotiveVehicleTargetTest, getPropConfigsWithValidProps) {
176     ALOGD("VtsHalAutomotiveVehicleTargetTest::getRequiredPropConfigs");
177 
178     std::vector<int32_t> properties;
179     auto result = mVhalClient->getAllPropConfigs();
180 
181     ASSERT_TRUE(result.ok()) << "Failed to get all property configs, error: "
182                              << result.error().message();
183     for (const auto& cfgPtr : result.value()) {
184         properties.push_back(cfgPtr->getPropId());
185     }
186 
187     result = mVhalClient->getPropConfigs(properties);
188 
189     ASSERT_TRUE(result.ok()) << "Failed to get required property config, error: "
190                              << result.error().message();
191     ASSERT_EQ(result.value().size(), properties.size())
192           << StringPrintf("Expect to get exactly %zu configs, got %zu",
193                           properties.size(), result.value().size());
194 }
195 
196 // Test getPropConfig() with an invalid propertyId returns an error code.
TEST_P(VtsHalAutomotiveVehicleTargetTest,getPropConfigsWithInvalidProp)197 TEST_P(VtsHalAutomotiveVehicleTargetTest, getPropConfigsWithInvalidProp) {
198     ALOGD("VtsHalAutomotiveVehicleTargetTest::getPropConfigsWithInvalidProp");
199 
200     auto result = mVhalClient->getPropConfigs({kInvalidProp});
201 
202     ASSERT_FALSE(result.ok()) << StringPrintf(
203             "Expect failure to get prop configs for invalid prop: %" PRId32, kInvalidProp);
204     ASSERT_NE(result.error().message(), "") << "Expect error message not to be empty";
205 }
206 
207 // Test get() return current value for properties.
TEST_P(VtsHalAutomotiveVehicleTargetTest,get)208 TEST_P(VtsHalAutomotiveVehicleTargetTest, get) {
209     ALOGD("VtsHalAutomotiveVehicleTargetTest::get");
210 
211     int32_t propId = toInt(VehicleProperty::PERF_VEHICLE_SPEED);
212     if (!checkIsSupported(propId)) {
213         GTEST_SKIP() << "Property: " << propId << " is not supported, skip the test";
214     }
215     auto result = mVhalClient->getValueSync(*mVhalClient->createHalPropValue(propId));
216 
217     ASSERT_TRUE(result.ok()) << StringPrintf("Failed to get value for property: %" PRId32
218                                              ", error: %s",
219                                              propId, result.error().message().c_str());
220     ASSERT_NE(result.value(), nullptr) << "Result value must not be null";
221 }
222 
223 // Test get() with an invalid propertyId return an error codes.
TEST_P(VtsHalAutomotiveVehicleTargetTest,getInvalidProp)224 TEST_P(VtsHalAutomotiveVehicleTargetTest, getInvalidProp) {
225     ALOGD("VtsHalAutomotiveVehicleTargetTest::getInvalidProp");
226 
227     auto result = mVhalClient->getValueSync(*mVhalClient->createHalPropValue(kInvalidProp));
228 
229     ASSERT_FALSE(result.ok()) << StringPrintf(
230             "Expect failure to get property for invalid prop: %" PRId32, kInvalidProp);
231 }
232 
233 // Test set() on read_write properties.
TEST_P(VtsHalAutomotiveVehicleTargetTest,setProp)234 TEST_P(VtsHalAutomotiveVehicleTargetTest, setProp) {
235     ALOGD("VtsHalAutomotiveVehicleTargetTest::setProp");
236 
237     // skip hvac related properties
238     std::unordered_set<int32_t> hvacProps = {toInt(VehicleProperty::HVAC_DEFROSTER),
239                                              toInt(VehicleProperty::HVAC_AC_ON),
240                                              toInt(VehicleProperty::HVAC_MAX_AC_ON),
241                                              toInt(VehicleProperty::HVAC_MAX_DEFROST_ON),
242                                              toInt(VehicleProperty::HVAC_RECIRC_ON),
243                                              toInt(VehicleProperty::HVAC_DUAL_ON),
244                                              toInt(VehicleProperty::HVAC_AUTO_ON),
245                                              toInt(VehicleProperty::HVAC_POWER_ON),
246                                              toInt(VehicleProperty::HVAC_AUTO_RECIRC_ON),
247                                              toInt(VehicleProperty::HVAC_ELECTRIC_DEFROSTER_ON)};
248     auto result = mVhalClient->getAllPropConfigs();
249     ASSERT_TRUE(result.ok());
250 
251     for (const auto& cfgPtr : result.value()) {
252         const IHalPropConfig& cfg = *cfgPtr;
253         int32_t propId = cfg.getPropId();
254         // test on boolean and writable property
255         if (cfg.getAccess() == toInt(VehiclePropertyAccess::READ_WRITE) &&
256             isBooleanGlobalProp(propId) && !hvacProps.count(propId)) {
257             auto propToGet = mVhalClient->createHalPropValue(propId);
258             auto getValueResult = mVhalClient->getValueSync(*propToGet);
259 
260             ASSERT_TRUE(getValueResult.ok())
261                     << StringPrintf("Failed to get value for property: %" PRId32 ", error: %s",
262                                     propId, getValueResult.error().message().c_str());
263             ASSERT_NE(getValueResult.value(), nullptr)
264                     << StringPrintf("Result value must not be null for property: %" PRId32, propId);
265 
266             const IHalPropValue& value = *getValueResult.value();
267             size_t intValueSize = value.getInt32Values().size();
268             ASSERT_EQ(intValueSize, 1u) << StringPrintf(
269                     "Expect exactly 1 int value for boolean property: %" PRId32 ", got %zu", propId,
270                     intValueSize);
271 
272             int setValue = value.getInt32Values()[0] == 1 ? 0 : 1;
273             auto propToSet = mVhalClient->createHalPropValue(propId);
274             propToSet->setInt32Values({setValue});
275             auto setValueResult = mVhalClient->setValueSync(*propToSet);
276 
277             ASSERT_TRUE(setValueResult.ok())
278                     << StringPrintf("Failed to set value for property: %" PRId32 ", error: %s",
279                                     propId, setValueResult.error().message().c_str());
280 
281             // check set success
282             getValueResult = mVhalClient->getValueSync(*propToGet);
283             ASSERT_TRUE(getValueResult.ok())
284                     << StringPrintf("Failed to get value for property: %" PRId32 ", error: %s",
285                                     propId, getValueResult.error().message().c_str());
286             ASSERT_NE(getValueResult.value(), nullptr)
287                     << StringPrintf("Result value must not be null for property: %" PRId32, propId);
288             ASSERT_EQ(getValueResult.value()->getInt32Values(), std::vector<int32_t>({setValue}))
289                     << StringPrintf("Boolean value not updated after set for property: %" PRId32,
290                                     propId);
291         }
292     }
293 }
294 
295 // Test set() on an read_only property.
TEST_P(VtsHalAutomotiveVehicleTargetTest,setNotWritableProp)296 TEST_P(VtsHalAutomotiveVehicleTargetTest, setNotWritableProp) {
297     ALOGD("VtsHalAutomotiveVehicleTargetTest::setNotWritableProp");
298 
299     int32_t propId = toInt(VehicleProperty::PERF_VEHICLE_SPEED);
300     if (!checkIsSupported(propId)) {
301         GTEST_SKIP() << "Property: " << propId << " is not supported, skip the test";
302     }
303 
304     auto getValueResult = mVhalClient->getValueSync(*mVhalClient->createHalPropValue(propId));
305     ASSERT_TRUE(getValueResult.ok())
306             << StringPrintf("Failed to get value for property: %" PRId32 ", error: %s", propId,
307                             getValueResult.error().message().c_str());
308 
309     auto setValueResult = mVhalClient->setValueSync(*getValueResult.value());
310 
311     ASSERT_FALSE(setValueResult.ok()) << "Expect set a read-only value to fail";
312     ASSERT_EQ(setValueResult.error().code(), ErrorCode::ACCESS_DENIED_FROM_VHAL);
313 }
314 
315 // Test get(), set() and getAllPropConfigs() on VehicleProperty::INVALID.
TEST_P(VtsHalAutomotiveVehicleTargetTest,getSetPropertyIdInvalid)316 TEST_P(VtsHalAutomotiveVehicleTargetTest, getSetPropertyIdInvalid) {
317     ALOGD("VtsHalAutomotiveVehicleTargetTest::getSetPropertyIdInvalid");
318 
319     int32_t propId = toInt(VehicleProperty::INVALID);
320     auto getValueResult = mVhalClient->getValueSync(*mVhalClient->createHalPropValue(propId));
321     ASSERT_FALSE(getValueResult.ok()) << "Expect get on VehicleProperty::INVALID to fail";
322     ASSERT_EQ(getValueResult.error().code(), ErrorCode::INVALID_ARG);
323 
324     auto propToSet = mVhalClient->createHalPropValue(propId);
325     propToSet->setInt32Values({0});
326     auto setValueResult = mVhalClient->setValueSync(*propToSet);
327     ASSERT_FALSE(setValueResult.ok()) << "Expect set on VehicleProperty::INVALID to fail";
328     ASSERT_EQ(setValueResult.error().code(), ErrorCode::INVALID_ARG);
329 
330     auto result = mVhalClient->getAllPropConfigs();
331     ASSERT_TRUE(result.ok());
332     for (const auto& cfgPtr : result.value()) {
333         const IHalPropConfig& cfg = *cfgPtr;
334         ASSERT_FALSE(cfg.getPropId() == propId) << "Expect VehicleProperty::INVALID to not be "
335                                                    "included in propConfigs";
336     }
337 }
338 
339 // Test subscribe() and unsubscribe().
TEST_P(VtsHalAutomotiveVehicleTargetTest,subscribeAndUnsubscribe)340 TEST_P(VtsHalAutomotiveVehicleTargetTest, subscribeAndUnsubscribe) {
341     ALOGD("VtsHalAutomotiveVehicleTargetTest::subscribeAndUnsubscribe");
342 
343     int32_t propId = toInt(VehicleProperty::PERF_VEHICLE_SPEED);
344     if (!checkIsSupported(propId)) {
345         GTEST_SKIP() << "Property: " << propId << " is not supported, skip the test";
346     }
347 
348     auto propConfigsResult = mVhalClient->getPropConfigs({propId});
349 
350     ASSERT_TRUE(propConfigsResult.ok()) << "Failed to get property config for PERF_VEHICLE_SPEED: "
351                                         << "error: " << propConfigsResult.error().message();
352     ASSERT_EQ(propConfigsResult.value().size(), 1u)
353             << "Expect to return 1 config for PERF_VEHICLE_SPEED";
354     auto& propConfig = propConfigsResult.value()[0];
355     float minSampleRate = propConfig->getMinSampleRate();
356     float maxSampleRate = propConfig->getMaxSampleRate();
357 
358     if (minSampleRate < 1) {
359         GTEST_SKIP() << "Sample rate for vehicle speed < 1 times/sec, skip test since it would "
360                         "take too long";
361     }
362 
363     auto client = mVhalClient->getSubscriptionClient(mCallback);
364     ASSERT_NE(client, nullptr) << "Failed to get subscription client";
365 
366     auto result = client->subscribe({{.propId = propId, .sampleRate = minSampleRate}});
367 
368     ASSERT_TRUE(result.ok()) << StringPrintf("Failed to subscribe to property: %" PRId32
369                                              ", error: %s",
370                                              propId, result.error().message().c_str());
371 
372     if (mVhalClient->isAidlVhal()) {
373         // Skip checking timestamp for HIDL because the behavior for sample rate and timestamp is
374         // only specified clearly for AIDL.
375 
376         // Timeout is 2 seconds, which gives a 1 second buffer.
377         ASSERT_TRUE(mCallback->waitForExpectedEvents(propId, std::floor(minSampleRate),
378                                                      std::chrono::seconds(2)))
379                 << "Didn't get enough events for subscribing to minSampleRate";
380     }
381 
382     result = client->subscribe({{.propId = propId, .sampleRate = maxSampleRate}});
383 
384     ASSERT_TRUE(result.ok()) << StringPrintf("Failed to subscribe to property: %" PRId32
385                                              ", error: %s",
386                                              propId, result.error().message().c_str());
387 
388     if (mVhalClient->isAidlVhal()) {
389         ASSERT_TRUE(mCallback->waitForExpectedEvents(propId, std::floor(maxSampleRate),
390                                                      std::chrono::seconds(2)))
391                 << "Didn't get enough events for subscribing to maxSampleRate";
392 
393         std::unordered_set<int64_t> timestamps;
394         // Event event should have a different timestamp.
395         for (const int64_t& eventTimestamp : mCallback->getEventTimestamps(propId)) {
396             ASSERT_TRUE(timestamps.find(eventTimestamp) == timestamps.end())
397                     << "two events for the same property must not have the same timestamp";
398             timestamps.insert(eventTimestamp);
399         }
400     }
401 
402     result = client->unsubscribe({propId});
403     ASSERT_TRUE(result.ok()) << StringPrintf("Failed to unsubscribe to property: %" PRId32
404                                              ", error: %s",
405                                              propId, result.error().message().c_str());
406 
407     mCallback->reset();
408     ASSERT_FALSE(mCallback->waitForExpectedEvents(propId, 10, std::chrono::seconds(1)))
409             << "Expect not to get events after unsubscription";
410 }
411 
412 // Test subscribe() with an invalid property.
TEST_P(VtsHalAutomotiveVehicleTargetTest,subscribeInvalidProp)413 TEST_P(VtsHalAutomotiveVehicleTargetTest, subscribeInvalidProp) {
414     ALOGD("VtsHalAutomotiveVehicleTargetTest::subscribeInvalidProp");
415 
416     std::vector<SubscribeOptions> options = {
417             SubscribeOptions{.propId = kInvalidProp, .sampleRate = 10.0}};
418 
419     auto client = mVhalClient->getSubscriptionClient(mCallback);
420     ASSERT_NE(client, nullptr) << "Failed to get subscription client";
421 
422     auto result = client->subscribe(options);
423 
424     ASSERT_FALSE(result.ok()) << StringPrintf("Expect subscribing to property: %" PRId32 " to fail",
425                                               kInvalidProp);
426 }
427 
428 // Test the timestamp returned in GetValues results is the timestamp when the value is retrieved.
TEST_P(VtsHalAutomotiveVehicleTargetTest,testGetValuesTimestampAIDL)429 TEST_P(VtsHalAutomotiveVehicleTargetTest, testGetValuesTimestampAIDL) {
430     if (!mVhalClient->isAidlVhal()) {
431         GTEST_SKIP() << "Skip checking timestamp for HIDL because the behavior is only specified "
432                         "for AIDL";
433     }
434 
435     int32_t propId = toInt(VehicleProperty::PARKING_BRAKE_ON);
436     if (!checkIsSupported(propId)) {
437         GTEST_SKIP() << "Property: " << propId << " is not supported, skip the test";
438     }
439     auto prop = mVhalClient->createHalPropValue(propId);
440 
441     auto result = mVhalClient->getValueSync(*prop);
442 
443     ASSERT_TRUE(result.ok()) << StringPrintf("Failed to get value for property: %" PRId32
444                                              ", error: %s",
445                                              propId, result.error().message().c_str());
446     ASSERT_NE(result.value(), nullptr) << "Result value must not be null";
447     ASSERT_EQ(result.value()->getInt32Values().size(), 1u) << "Result must contain 1 int value";
448 
449     bool parkBrakeOnValue1 = (result.value()->getInt32Values()[0] == 1);
450     int64_t timestampValue1 = result.value()->getTimestamp();
451 
452     result = mVhalClient->getValueSync(*prop);
453 
454     ASSERT_TRUE(result.ok()) << StringPrintf("Failed to get value for property: %" PRId32
455                                              ", error: %s",
456                                              propId, result.error().message().c_str());
457     ASSERT_NE(result.value(), nullptr) << "Result value must not be null";
458     ASSERT_EQ(result.value()->getInt32Values().size(), 1u) << "Result must contain 1 int value";
459 
460     bool parkBarkeOnValue2 = (result.value()->getInt32Values()[0] == 1);
461     int64_t timestampValue2 = result.value()->getTimestamp();
462 
463     if (parkBarkeOnValue2 == parkBrakeOnValue1) {
464         ASSERT_EQ(timestampValue2, timestampValue1)
465                 << "getValue result must contain a timestamp updated when the value was updated, if"
466                    "the value does not change, expect the same timestamp";
467     } else {
468         ASSERT_GT(timestampValue2, timestampValue1)
469                 << "getValue result must contain a timestamp updated when the value was updated, if"
470                    "the value changes, expect the newer value has a larger timestamp";
471     }
472 }
473 
474 // Helper function to compare actual vs expected property config
verifyProperty(VehicleProperty propId,VehiclePropertyAccess access,VehiclePropertyChangeMode changeMode,VehiclePropertyGroup group,VehicleArea area,VehiclePropertyType propertyType)475 void VtsHalAutomotiveVehicleTargetTest::verifyProperty(VehicleProperty propId,
476                                                        VehiclePropertyAccess access,
477                                                        VehiclePropertyChangeMode changeMode,
478                                                        VehiclePropertyGroup group, VehicleArea area,
479                                                        VehiclePropertyType propertyType) {
480     int expectedPropId = toInt(propId);
481     int expectedAccess = toInt(access);
482     int expectedChangeMode = toInt(changeMode);
483     int expectedGroup = toInt(group);
484     int expectedArea = toInt(area);
485     int expectedPropertyType = toInt(propertyType);
486 
487     auto result = mVhalClient->getAllPropConfigs();
488     ASSERT_TRUE(result.ok()) << "Failed to get all property configs, error: "
489                              << result.error().message();
490 
491     // Check if property is implemented by getting all configs and looking to see if the expected
492     // property id is in that list.
493     bool isExpectedPropIdImplemented = false;
494     for (const auto& cfgPtr : result.value()) {
495         const IHalPropConfig& cfg = *cfgPtr;
496         if (expectedPropId == cfg.getPropId()) {
497             isExpectedPropIdImplemented = true;
498             break;
499         }
500     }
501 
502     if (!isExpectedPropIdImplemented) {
503         GTEST_SKIP() << StringPrintf("Property %" PRId32 " has not been implemented",
504                                      expectedPropId);
505     }
506 
507     result = mVhalClient->getPropConfigs({expectedPropId});
508     ASSERT_TRUE(result.ok()) << "Failed to get required property config, error: "
509                              << result.error().message();
510 
511     ASSERT_EQ(result.value().size(), 1u)
512             << StringPrintf("Expect to get exactly 1 config, got %zu", result.value().size());
513 
514     const auto& config = result.value().at(0);
515     int actualPropId = config->getPropId();
516     int actualAccess = config->getAccess();
517     int actualChangeMode = config->getChangeMode();
518     int actualGroup = actualPropId & toInt(VehiclePropertyGroup::MASK);
519     int actualArea = actualPropId & toInt(VehicleArea::MASK);
520     int actualPropertyType = actualPropId & toInt(VehiclePropertyType::MASK);
521 
522     ASSERT_EQ(actualPropId, expectedPropId)
523             << StringPrintf("Expect to get property ID: %i, got %i", expectedPropId, actualPropId);
524 
525     if (expectedAccess == toInt(VehiclePropertyAccess::READ_WRITE)) {
526         ASSERT_TRUE(actualAccess == expectedAccess ||
527                     actualAccess == toInt(VehiclePropertyAccess::READ))
528                 << StringPrintf("Expect to get VehiclePropertyAccess: %i or %i, got %i",
529                                 expectedAccess, toInt(VehiclePropertyAccess::READ), actualAccess);
530     } else {
531         ASSERT_EQ(actualAccess, expectedAccess) << StringPrintf(
532                 "Expect to get VehiclePropertyAccess: %i, got %i", expectedAccess, actualAccess);
533     }
534 
535     ASSERT_EQ(actualChangeMode, expectedChangeMode)
536             << StringPrintf("Expect to get VehiclePropertyChangeMode: %i, got %i",
537                             expectedChangeMode, actualChangeMode);
538     ASSERT_EQ(actualGroup, expectedGroup) << StringPrintf(
539             "Expect to get VehiclePropertyGroup: %i, got %i", expectedGroup, actualGroup);
540     ASSERT_EQ(actualArea, expectedArea)
541             << StringPrintf("Expect to get VehicleArea: %i, got %i", expectedArea, actualArea);
542     ASSERT_EQ(actualPropertyType, expectedPropertyType)
543             << StringPrintf("Expect to get VehiclePropertyType: %i, got %i", expectedPropertyType,
544                             actualPropertyType);
545 }
546 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyLocationCharacterizationConfig)547 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyLocationCharacterizationConfig) {
548     verifyProperty(VehicleProperty::LOCATION_CHARACTERIZATION, VehiclePropertyAccess::READ,
549                    VehiclePropertyChangeMode::STATIC, VehiclePropertyGroup::SYSTEM,
550                    VehicleArea::GLOBAL, VehiclePropertyType::INT32);
551 }
552 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyEmergencyLaneKeepAssistEnabledConfig)553 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyEmergencyLaneKeepAssistEnabledConfig) {
554     verifyProperty(VehicleProperty::EMERGENCY_LANE_KEEP_ASSIST_ENABLED,
555                    VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
556                    VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
557 }
558 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyEmergencyLaneKeepAssistStateConfig)559 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyEmergencyLaneKeepAssistStateConfig) {
560     verifyProperty(VehicleProperty::EMERGENCY_LANE_KEEP_ASSIST_STATE, VehiclePropertyAccess::READ,
561                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
562                    VehicleArea::GLOBAL, VehiclePropertyType::INT32);
563 }
564 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyCruiseControlEnabledConfig)565 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyCruiseControlEnabledConfig) {
566     verifyProperty(VehicleProperty::CRUISE_CONTROL_ENABLED, VehiclePropertyAccess::READ_WRITE,
567                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
568                    VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
569 }
570 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyCruiseControlTypeConfig)571 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyCruiseControlTypeConfig) {
572     verifyProperty(VehicleProperty::CRUISE_CONTROL_TYPE, VehiclePropertyAccess::READ_WRITE,
573                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
574                    VehicleArea::GLOBAL, VehiclePropertyType::INT32);
575 }
576 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyCruiseControlStateConfig)577 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyCruiseControlStateConfig) {
578     verifyProperty(VehicleProperty::CRUISE_CONTROL_STATE, VehiclePropertyAccess::READ,
579                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
580                    VehicleArea::GLOBAL, VehiclePropertyType::INT32);
581 }
582 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyCruiseControlCommandConfig)583 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyCruiseControlCommandConfig) {
584     verifyProperty(VehicleProperty::CRUISE_CONTROL_COMMAND, VehiclePropertyAccess::WRITE,
585                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
586                    VehicleArea::GLOBAL, VehiclePropertyType::INT32);
587 }
588 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyCruiseControlTargetSpeedConfig)589 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyCruiseControlTargetSpeedConfig) {
590     verifyProperty(VehicleProperty::CRUISE_CONTROL_TARGET_SPEED, VehiclePropertyAccess::READ,
591                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
592                    VehicleArea::GLOBAL, VehiclePropertyType::FLOAT);
593 }
594 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyAdaptiveCruiseControlTargetTimeGapConfig)595 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyAdaptiveCruiseControlTargetTimeGapConfig) {
596     verifyProperty(VehicleProperty::ADAPTIVE_CRUISE_CONTROL_TARGET_TIME_GAP,
597                    VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
598                    VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::INT32);
599 }
600 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyAdaptiveCruiseControlLeadVehicleMeasuredDistanceConfig)601 TEST_P(VtsHalAutomotiveVehicleTargetTest,
602        verifyAdaptiveCruiseControlLeadVehicleMeasuredDistanceConfig) {
603     verifyProperty(VehicleProperty::ADAPTIVE_CRUISE_CONTROL_LEAD_VEHICLE_MEASURED_DISTANCE,
604                    VehiclePropertyAccess::READ, VehiclePropertyChangeMode::CONTINUOUS,
605                    VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::INT32);
606 }
607 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyHandsOnDetectionEnabledConfig)608 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyHandsOnDetectionEnabledConfig) {
609     verifyProperty(VehicleProperty::HANDS_ON_DETECTION_ENABLED, VehiclePropertyAccess::READ_WRITE,
610                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
611                    VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
612 }
613 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyHandsOnDetectionDriverStateConfig)614 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyHandsOnDetectionDriverStateConfig) {
615     verifyProperty(VehicleProperty::HANDS_ON_DETECTION_DRIVER_STATE, VehiclePropertyAccess::READ,
616                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
617                    VehicleArea::GLOBAL, VehiclePropertyType::INT32);
618 }
619 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyHandsOnDetectionWarningConfig)620 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyHandsOnDetectionWarningConfig) {
621     verifyProperty(VehicleProperty::HANDS_ON_DETECTION_WARNING, VehiclePropertyAccess::READ,
622                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
623                    VehicleArea::GLOBAL, VehiclePropertyType::INT32);
624 }
625 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyEvBrakeRegenerationLevelConfig)626 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyEvBrakeRegenerationLevelConfig) {
627     verifyProperty(VehicleProperty::EV_BRAKE_REGENERATION_LEVEL,
628                    VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
629                    VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::INT32);
630 }
631 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyEvStoppingModeConfig)632 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyEvStoppingModeConfig) {
633     verifyProperty(VehicleProperty::EV_STOPPING_MODE, VehiclePropertyAccess::READ_WRITE,
634                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
635                    VehicleArea::GLOBAL, VehiclePropertyType::INT32);
636 }
637 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyEvCurrentBatteryCapacityConfig)638 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyEvCurrentBatteryCapacityConfig) {
639     verifyProperty(VehicleProperty::EV_CURRENT_BATTERY_CAPACITY, VehiclePropertyAccess::READ,
640                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
641                    VehicleArea::GLOBAL, VehiclePropertyType::FLOAT);
642 }
643 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyEngineIdleAutoStopEnabledConfig)644 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyEngineIdleAutoStopEnabledConfig) {
645     verifyProperty(VehicleProperty::ENGINE_IDLE_AUTO_STOP_ENABLED,
646                    VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
647                    VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
648 }
649 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyDoorChildLockEnabledConfig)650 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyDoorChildLockEnabledConfig) {
651     verifyProperty(VehicleProperty::DOOR_CHILD_LOCK_ENABLED, VehiclePropertyAccess::READ_WRITE,
652                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
653                    VehicleArea::DOOR, VehiclePropertyType::BOOLEAN);
654 }
655 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyWindshieldWipersPeriodConfig)656 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyWindshieldWipersPeriodConfig) {
657     verifyProperty(VehicleProperty::WINDSHIELD_WIPERS_PERIOD, VehiclePropertyAccess::READ,
658                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
659                    VehicleArea::WINDOW, VehiclePropertyType::INT32);
660 }
661 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyWindshieldWipersStateConfig)662 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyWindshieldWipersStateConfig) {
663     verifyProperty(VehicleProperty::WINDSHIELD_WIPERS_STATE, VehiclePropertyAccess::READ,
664                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
665                    VehicleArea::WINDOW, VehiclePropertyType::INT32);
666 }
667 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyWindshieldWipersSwitchConfig)668 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyWindshieldWipersSwitchConfig) {
669     verifyProperty(VehicleProperty::WINDSHIELD_WIPERS_SWITCH, VehiclePropertyAccess::READ_WRITE,
670                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
671                    VehicleArea::WINDOW, VehiclePropertyType::INT32);
672 }
673 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifySteeringWheelDepthPosConfig)674 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySteeringWheelDepthPosConfig) {
675     verifyProperty(VehicleProperty::STEERING_WHEEL_DEPTH_POS, VehiclePropertyAccess::READ_WRITE,
676                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
677                    VehicleArea::GLOBAL, VehiclePropertyType::INT32);
678 }
679 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifySteeringWheelDepthMoveConfig)680 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySteeringWheelDepthMoveConfig) {
681     verifyProperty(VehicleProperty::STEERING_WHEEL_DEPTH_MOVE, VehiclePropertyAccess::READ_WRITE,
682                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
683                    VehicleArea::GLOBAL, VehiclePropertyType::INT32);
684 }
685 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifySteeringWheelHeightPosConfig)686 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySteeringWheelHeightPosConfig) {
687     verifyProperty(VehicleProperty::STEERING_WHEEL_HEIGHT_POS, VehiclePropertyAccess::READ_WRITE,
688                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
689                    VehicleArea::GLOBAL, VehiclePropertyType::INT32);
690 }
691 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifySteeringWheelHeightMoveConfig)692 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySteeringWheelHeightMoveConfig) {
693     verifyProperty(VehicleProperty::STEERING_WHEEL_HEIGHT_MOVE, VehiclePropertyAccess::READ_WRITE,
694                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
695                    VehicleArea::GLOBAL, VehiclePropertyType::INT32);
696 }
697 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifySteeringWheelTheftLockEnabledConfig)698 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySteeringWheelTheftLockEnabledConfig) {
699     verifyProperty(VehicleProperty::STEERING_WHEEL_THEFT_LOCK_ENABLED,
700                    VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
701                    VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
702 }
703 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifySteeringWheelLockedConfig)704 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySteeringWheelLockedConfig) {
705     verifyProperty(VehicleProperty::STEERING_WHEEL_LOCKED, VehiclePropertyAccess::READ_WRITE,
706                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
707                    VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
708 }
709 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifySteeringWheelEasyAccessEnabledConfig)710 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySteeringWheelEasyAccessEnabledConfig) {
711     verifyProperty(VehicleProperty::STEERING_WHEEL_EASY_ACCESS_ENABLED,
712                    VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
713                    VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
714 }
715 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifySteeringWheelLightsStateConfig)716 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySteeringWheelLightsStateConfig) {
717     verifyProperty(VehicleProperty::STEERING_WHEEL_LIGHTS_STATE, VehiclePropertyAccess::READ,
718                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
719                    VehicleArea::GLOBAL, VehiclePropertyType::INT32);
720 }
721 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifySteeringWheelLightsSwitchConfig)722 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySteeringWheelLightsSwitchConfig) {
723     verifyProperty(VehicleProperty::STEERING_WHEEL_LIGHTS_SWITCH, VehiclePropertyAccess::READ_WRITE,
724                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
725                    VehicleArea::GLOBAL, VehiclePropertyType::INT32);
726 }
727 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyGloveBoxDoorPosConfig)728 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyGloveBoxDoorPosConfig) {
729     verifyProperty(VehicleProperty::GLOVE_BOX_DOOR_POS, VehiclePropertyAccess::READ_WRITE,
730                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
731                    VehicleArea::SEAT, VehiclePropertyType::INT32);
732 }
733 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyGloveBoxLockedConfig)734 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyGloveBoxLockedConfig) {
735     verifyProperty(VehicleProperty::GLOVE_BOX_LOCKED, VehiclePropertyAccess::READ_WRITE,
736                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
737                    VehicleArea::SEAT, VehiclePropertyType::BOOLEAN);
738 }
739 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyMirrorAutoFoldEnabledConfig)740 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyMirrorAutoFoldEnabledConfig) {
741     verifyProperty(VehicleProperty::MIRROR_AUTO_FOLD_ENABLED, VehiclePropertyAccess::READ_WRITE,
742                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
743                    VehicleArea::MIRROR, VehiclePropertyType::BOOLEAN);
744 }
745 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyMirrorAutoTiltEnabledConfig)746 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyMirrorAutoTiltEnabledConfig) {
747     verifyProperty(VehicleProperty::MIRROR_AUTO_TILT_ENABLED, VehiclePropertyAccess::READ_WRITE,
748                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
749                    VehicleArea::MIRROR, VehiclePropertyType::BOOLEAN);
750 }
751 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifySeatHeadrestHeightPosV2Config)752 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySeatHeadrestHeightPosV2Config) {
753     verifyProperty(VehicleProperty::SEAT_HEADREST_HEIGHT_POS_V2, VehiclePropertyAccess::READ_WRITE,
754                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
755                    VehicleArea::SEAT, VehiclePropertyType::INT32);
756 }
757 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifySeatWalkInPosConfig)758 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySeatWalkInPosConfig) {
759     verifyProperty(VehicleProperty::SEAT_WALK_IN_POS, VehiclePropertyAccess::READ_WRITE,
760                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
761                    VehicleArea::SEAT, VehiclePropertyType::INT32);
762 }
763 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifySeatFootwellLightsStateConfig)764 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySeatFootwellLightsStateConfig) {
765     verifyProperty(VehicleProperty::SEAT_FOOTWELL_LIGHTS_STATE, VehiclePropertyAccess::READ,
766                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
767                    VehicleArea::SEAT, VehiclePropertyType::INT32);
768 }
769 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifySeatFootwellLightsSwitchConfig)770 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySeatFootwellLightsSwitchConfig) {
771     verifyProperty(VehicleProperty::SEAT_FOOTWELL_LIGHTS_SWITCH, VehiclePropertyAccess::READ_WRITE,
772                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
773                    VehicleArea::SEAT, VehiclePropertyType::INT32);
774 }
775 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifySeatEasyAccessEnabledConfig)776 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySeatEasyAccessEnabledConfig) {
777     verifyProperty(VehicleProperty::SEAT_EASY_ACCESS_ENABLED, VehiclePropertyAccess::READ_WRITE,
778                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
779                    VehicleArea::SEAT, VehiclePropertyType::BOOLEAN);
780 }
781 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifySeatAirbagEnabledConfig)782 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySeatAirbagEnabledConfig) {
783     verifyProperty(VehicleProperty::SEAT_AIRBAG_ENABLED, VehiclePropertyAccess::READ_WRITE,
784                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
785                    VehicleArea::SEAT, VehiclePropertyType::BOOLEAN);
786 }
787 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifySeatCushionSideSupportPosConfig)788 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySeatCushionSideSupportPosConfig) {
789     verifyProperty(VehicleProperty::SEAT_CUSHION_SIDE_SUPPORT_POS,
790                    VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
791                    VehiclePropertyGroup::SYSTEM, VehicleArea::SEAT, VehiclePropertyType::INT32);
792 }
793 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifySeatCushionSideSupportMoveConfig)794 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySeatCushionSideSupportMoveConfig) {
795     verifyProperty(VehicleProperty::SEAT_CUSHION_SIDE_SUPPORT_MOVE,
796                    VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
797                    VehiclePropertyGroup::SYSTEM, VehicleArea::SEAT, VehiclePropertyType::INT32);
798 }
799 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifySeatLumbarVerticalPosConfig)800 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySeatLumbarVerticalPosConfig) {
801     verifyProperty(VehicleProperty::SEAT_LUMBAR_VERTICAL_POS, VehiclePropertyAccess::READ_WRITE,
802                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
803                    VehicleArea::SEAT, VehiclePropertyType::INT32);
804 }
805 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifySeatLumbarVerticalMoveConfig)806 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySeatLumbarVerticalMoveConfig) {
807     verifyProperty(VehicleProperty::SEAT_LUMBAR_VERTICAL_MOVE, VehiclePropertyAccess::READ_WRITE,
808                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
809                    VehicleArea::SEAT, VehiclePropertyType::INT32);
810 }
811 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyAutomaticEmergencyBrakingEnabledConfig)812 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyAutomaticEmergencyBrakingEnabledConfig) {
813     verifyProperty(VehicleProperty::AUTOMATIC_EMERGENCY_BRAKING_ENABLED,
814                    VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
815                    VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
816 }
817 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyAutomaticEmergencyBrakingStateConfig)818 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyAutomaticEmergencyBrakingStateConfig) {
819     verifyProperty(VehicleProperty::AUTOMATIC_EMERGENCY_BRAKING_STATE, VehiclePropertyAccess::READ,
820                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
821                    VehicleArea::GLOBAL, VehiclePropertyType::INT32);
822 }
823 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyForwardCollisionWarningEnabledConfig)824 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyForwardCollisionWarningEnabledConfig) {
825     verifyProperty(VehicleProperty::FORWARD_COLLISION_WARNING_ENABLED,
826                    VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
827                    VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
828 }
829 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyForwardCollisionWarningStateConfig)830 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyForwardCollisionWarningStateConfig) {
831     verifyProperty(VehicleProperty::FORWARD_COLLISION_WARNING_STATE, VehiclePropertyAccess::READ,
832                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
833                    VehicleArea::GLOBAL, VehiclePropertyType::INT32);
834 }
835 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyBlindSpotWarningEnabledConfig)836 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyBlindSpotWarningEnabledConfig) {
837     verifyProperty(VehicleProperty::BLIND_SPOT_WARNING_ENABLED, VehiclePropertyAccess::READ_WRITE,
838                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
839                    VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
840 }
841 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyBlindSpotWarningStateConfig)842 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyBlindSpotWarningStateConfig) {
843     verifyProperty(VehicleProperty::BLIND_SPOT_WARNING_STATE, VehiclePropertyAccess::READ,
844                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
845                    VehicleArea::MIRROR, VehiclePropertyType::INT32);
846 }
847 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyLaneDepartureWarningEnabledConfig)848 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyLaneDepartureWarningEnabledConfig) {
849     verifyProperty(VehicleProperty::LANE_DEPARTURE_WARNING_ENABLED,
850                    VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
851                    VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
852 }
853 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyLaneDepartureWarningStateConfig)854 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyLaneDepartureWarningStateConfig) {
855     verifyProperty(VehicleProperty::LANE_DEPARTURE_WARNING_STATE, VehiclePropertyAccess::READ,
856                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
857                    VehicleArea::GLOBAL, VehiclePropertyType::INT32);
858 }
859 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyLaneKeepAssistEnabledConfig)860 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyLaneKeepAssistEnabledConfig) {
861     verifyProperty(VehicleProperty::LANE_KEEP_ASSIST_ENABLED, VehiclePropertyAccess::READ_WRITE,
862                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
863                    VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
864 }
865 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyLaneKeepAssistStateConfig)866 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyLaneKeepAssistStateConfig) {
867     verifyProperty(VehicleProperty::LANE_KEEP_ASSIST_STATE, VehiclePropertyAccess::READ,
868                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
869                    VehicleArea::GLOBAL, VehiclePropertyType::INT32);
870 }
871 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyLaneCenteringAssistEnabledConfig)872 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyLaneCenteringAssistEnabledConfig) {
873     verifyProperty(VehicleProperty::LANE_CENTERING_ASSIST_ENABLED,
874                    VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
875                    VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
876 }
877 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyLaneCenteringAssistCommandConfig)878 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyLaneCenteringAssistCommandConfig) {
879     verifyProperty(VehicleProperty::LANE_CENTERING_ASSIST_COMMAND, VehiclePropertyAccess::WRITE,
880                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
881                    VehicleArea::GLOBAL, VehiclePropertyType::INT32);
882 }
883 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyLaneCenteringAssistStateConfig)884 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyLaneCenteringAssistStateConfig) {
885     verifyProperty(VehicleProperty::LANE_CENTERING_ASSIST_STATE, VehiclePropertyAccess::READ,
886                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
887                    VehicleArea::GLOBAL, VehiclePropertyType::INT32);
888 }
889 
checkIsSupported(int32_t propertyId)890 bool VtsHalAutomotiveVehicleTargetTest::checkIsSupported(int32_t propertyId) {
891   auto result = mVhalClient->getPropConfigs({propertyId});
892   return result.ok();
893 }
894 
getDescriptors()895 std::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 
912 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(VtsHalAutomotiveVehicleTargetTest);
913 
914 INSTANTIATE_TEST_SUITE_P(PerInstance, VtsHalAutomotiveVehicleTargetTest,
915                          testing::ValuesIn(getDescriptors()),
__anon62aea6d80202(const testing::TestParamInfo<ServiceDescriptor>& info) 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 
main(int argc,char ** argv)927 int main(int argc, char** argv) {
928     ::testing::InitGoogleTest(&argc, argv);
929     ABinderProcess_setThreadPoolMaxThreadCount(1);
930     return RUN_ALL_TESTS();
931 }
932