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 <VersionForVehicleProperty.h>
23 #include <aidl/Gtest.h>
24 #include <aidl/Vintf.h>
25 #include <aidl/android/hardware/automotive/vehicle/IVehicle.h>
26 #include <android-base/stringprintf.h>
27 #include <android-base/thread_annotations.h>
28 #include <android/binder_process.h>
29 #include <android/hardware/automotive/vehicle/2.0/IVehicle.h>
30 #include <gmock/gmock.h>
31 #include <gtest/gtest.h>
32 #include <hidl/GtestPrinter.h>
33 #include <hidl/ServiceManagement.h>
34 #include <inttypes.h>
35 #include <utils/Log.h>
36 #include <utils/SystemClock.h>
37 
38 #include <chrono>
39 #include <mutex>
40 #include <thread>
41 #include <unordered_map>
42 #include <unordered_set>
43 #include <vector>
44 
45 using ::aidl::android::hardware::automotive::vehicle::IVehicle;
46 using ::aidl::android::hardware::automotive::vehicle::StatusCode;
47 using ::aidl::android::hardware::automotive::vehicle::SubscribeOptions;
48 using ::aidl::android::hardware::automotive::vehicle::VehicleArea;
49 using ::aidl::android::hardware::automotive::vehicle::VehicleProperty;
50 using ::aidl::android::hardware::automotive::vehicle::VehiclePropertyAccess;
51 using ::aidl::android::hardware::automotive::vehicle::VehiclePropertyChangeMode;
52 using ::aidl::android::hardware::automotive::vehicle::VehiclePropertyGroup;
53 using ::aidl::android::hardware::automotive::vehicle::VehiclePropertyStatus;
54 using ::aidl::android::hardware::automotive::vehicle::VehiclePropertyType;
55 using ::aidl::android::hardware::automotive::vehicle::VersionForVehicleProperty;
56 using ::android::getAidlHalInstanceNames;
57 using ::android::uptimeMillis;
58 using ::android::base::ScopedLockAssertion;
59 using ::android::base::StringPrintf;
60 using ::android::frameworks::automotive::vhal::ErrorCode;
61 using ::android::frameworks::automotive::vhal::HalPropError;
62 using ::android::frameworks::automotive::vhal::IHalAreaConfig;
63 using ::android::frameworks::automotive::vhal::IHalPropConfig;
64 using ::android::frameworks::automotive::vhal::IHalPropValue;
65 using ::android::frameworks::automotive::vhal::ISubscriptionCallback;
66 using ::android::frameworks::automotive::vhal::IVhalClient;
67 using ::android::frameworks::automotive::vhal::SubscribeOptionsBuilder;
68 using ::android::frameworks::automotive::vhal::VhalClientResult;
69 using ::android::hardware::getAllHalInstanceNames;
70 using ::android::hardware::Sanitize;
71 using ::android::hardware::automotive::vehicle::isSystemProp;
72 using ::android::hardware::automotive::vehicle::propIdToString;
73 using ::android::hardware::automotive::vehicle::toInt;
74 using ::testing::Ge;
75 
76 constexpr int32_t kInvalidProp = 0x31600207;
77 // The timeout for retrying getting prop value after setting prop value.
78 constexpr int64_t kRetryGetPropAfterSetPropTimeoutMillis = 10'000;
79 
80 struct ServiceDescriptor {
81     std::string name;
82     bool isAidlService;
83 };
84 
85 class VtsVehicleCallback final : public ISubscriptionCallback {
86   private:
87     std::mutex mLock;
88     std::unordered_map<int32_t, std::vector<std::unique_ptr<IHalPropValue>>> mEvents
89             GUARDED_BY(mLock);
90     std::condition_variable mEventCond;
91 
92   public:
onPropertyEvent(const std::vector<std::unique_ptr<IHalPropValue>> & values)93     void onPropertyEvent(const std::vector<std::unique_ptr<IHalPropValue>>& values) override {
94         {
95             std::lock_guard<std::mutex> lockGuard(mLock);
96             for (auto& value : values) {
97                 int32_t propId = value->getPropId();
98                 mEvents[propId].push_back(std::move(value->clone()));
99             }
100         }
101         mEventCond.notify_one();
102     }
103 
onPropertySetError(const std::vector<HalPropError> & errors)104     void onPropertySetError([[maybe_unused]] const std::vector<HalPropError>& errors) override {
105         // Do nothing.
106     }
107 
108     template <class Rep, class Period>
waitForExpectedEvents(int32_t propId,size_t expectedEvents,const std::chrono::duration<Rep,Period> & timeout)109     bool waitForExpectedEvents(int32_t propId, size_t expectedEvents,
110                                const std::chrono::duration<Rep, Period>& timeout) {
111         std::unique_lock<std::mutex> uniqueLock(mLock);
112         return mEventCond.wait_for(uniqueLock, timeout, [this, propId, expectedEvents] {
113             ScopedLockAssertion lockAssertion(mLock);
114             return mEvents[propId].size() >= expectedEvents;
115         });
116     }
117 
getEvents(int32_t propId)118     std::vector<std::unique_ptr<IHalPropValue>> getEvents(int32_t propId) {
119         std::lock_guard<std::mutex> lockGuard(mLock);
120         std::vector<std::unique_ptr<IHalPropValue>> events;
121         if (mEvents.find(propId) == mEvents.end()) {
122             return events;
123         }
124         for (const auto& eventPtr : mEvents[propId]) {
125             events.push_back(std::move(eventPtr->clone()));
126         }
127         return events;
128     }
129 
getEventTimestamps(int32_t propId)130     std::vector<int64_t> getEventTimestamps(int32_t propId) {
131         std::lock_guard<std::mutex> lockGuard(mLock);
132         std::vector<int64_t> timestamps;
133         if (mEvents.find(propId) == mEvents.end()) {
134             return timestamps;
135         }
136         for (const auto& valuePtr : mEvents[propId]) {
137             timestamps.push_back(valuePtr->getTimestamp());
138         }
139         return timestamps;
140     }
141 
reset()142     void reset() {
143         std::lock_guard<std::mutex> lockGuard(mLock);
144         mEvents.clear();
145     }
146 };
147 
148 class VtsHalAutomotiveVehicleTargetTest : public testing::TestWithParam<ServiceDescriptor> {
149   protected:
150     bool checkIsSupported(int32_t propertyId);
151 
152     static bool isUnavailable(const VhalClientResult<std::unique_ptr<IHalPropValue>>& result);
153     static bool isResultOkayWithValue(
154             const VhalClientResult<std::unique_ptr<IHalPropValue>>& result, int32_t value);
155 
156   public:
157     void verifyAccessMode(int actualAccess, int expectedAccess);
158     void verifyGlobalAccessIsMaximalAreaAccessSubset(
159             int propertyLevelAccess,
160             const std::vector<std::unique_ptr<IHalAreaConfig>>& areaConfigs) const;
161     void verifyProperty(VehicleProperty propId, VehiclePropertyAccess access,
162                         VehiclePropertyChangeMode changeMode, VehiclePropertyGroup group,
163                         VehicleArea area, VehiclePropertyType propertyType);
SetUp()164     virtual void SetUp() override {
165         auto descriptor = GetParam();
166         if (descriptor.isAidlService) {
167             mVhalClient = IVhalClient::tryCreateAidlClient(descriptor.name.c_str());
168         } else {
169             mVhalClient = IVhalClient::tryCreateHidlClient(descriptor.name.c_str());
170         }
171 
172         ASSERT_NE(mVhalClient, nullptr) << "Failed to connect to VHAL";
173 
174         mCallback = std::make_shared<VtsVehicleCallback>();
175     }
176 
isBooleanGlobalProp(int32_t property)177     static bool isBooleanGlobalProp(int32_t property) {
178         return (property & toInt(VehiclePropertyType::MASK)) ==
179                        toInt(VehiclePropertyType::BOOLEAN) &&
180                (property & toInt(VehicleArea::MASK)) == toInt(VehicleArea::GLOBAL);
181     }
182 
183   protected:
184     std::shared_ptr<IVhalClient> mVhalClient;
185     std::shared_ptr<VtsVehicleCallback> mCallback;
186 };
187 
TEST_P(VtsHalAutomotiveVehicleTargetTest,useAidlBackend)188 TEST_P(VtsHalAutomotiveVehicleTargetTest, useAidlBackend) {
189     if (!mVhalClient->isAidlVhal()) {
190         GTEST_SKIP() << "AIDL backend is not available, HIDL backend is used instead";
191     }
192 }
193 
TEST_P(VtsHalAutomotiveVehicleTargetTest,useHidlBackend)194 TEST_P(VtsHalAutomotiveVehicleTargetTest, useHidlBackend) {
195     if (mVhalClient->isAidlVhal()) {
196         GTEST_SKIP() << "AIDL backend is available, HIDL backend is not used";
197     }
198 }
199 
200 // Test getAllPropConfigs() returns at least 1 property configs.
TEST_P(VtsHalAutomotiveVehicleTargetTest,getAllPropConfigs)201 TEST_P(VtsHalAutomotiveVehicleTargetTest, getAllPropConfigs) {
202     ALOGD("VtsHalAutomotiveVehicleTargetTest::getAllPropConfigs");
203 
204     auto result = mVhalClient->getAllPropConfigs();
205 
206     ASSERT_TRUE(result.ok()) << "Failed to get all property configs, error: "
207                              << result.error().message();
208     ASSERT_GE(result.value().size(), 1u) << StringPrintf(
209             "Expect to get at least 1 property config, got %zu", result.value().size());
210 }
211 
212 // Test getPropConfigs() can query properties returned by getAllPropConfigs.
TEST_P(VtsHalAutomotiveVehicleTargetTest,getPropConfigsWithValidProps)213 TEST_P(VtsHalAutomotiveVehicleTargetTest, getPropConfigsWithValidProps) {
214     ALOGD("VtsHalAutomotiveVehicleTargetTest::getRequiredPropConfigs");
215 
216     std::vector<int32_t> properties;
217     auto result = mVhalClient->getAllPropConfigs();
218 
219     ASSERT_TRUE(result.ok()) << "Failed to get all property configs, error: "
220                              << result.error().message();
221     for (const auto& cfgPtr : result.value()) {
222         properties.push_back(cfgPtr->getPropId());
223     }
224 
225     result = mVhalClient->getPropConfigs(properties);
226 
227     ASSERT_TRUE(result.ok()) << "Failed to get required property config, error: "
228                              << result.error().message();
229     ASSERT_EQ(result.value().size(), properties.size()) << StringPrintf(
230             "Expect to get exactly %zu configs, got %zu", properties.size(), result.value().size());
231 }
232 
233 // Test getPropConfig() with an invalid propertyId returns an error code.
TEST_P(VtsHalAutomotiveVehicleTargetTest,getPropConfigsWithInvalidProp)234 TEST_P(VtsHalAutomotiveVehicleTargetTest, getPropConfigsWithInvalidProp) {
235     ALOGD("VtsHalAutomotiveVehicleTargetTest::getPropConfigsWithInvalidProp");
236 
237     auto result = mVhalClient->getPropConfigs({kInvalidProp});
238 
239     ASSERT_FALSE(result.ok()) << StringPrintf(
240             "Expect failure to get prop configs for invalid prop: %" PRId32, kInvalidProp);
241     ASSERT_NE(result.error().message(), "") << "Expect error message not to be empty";
242 }
243 
244 // Test system property IDs returned by getPropConfigs() are defined in the VHAL property interface.
TEST_P(VtsHalAutomotiveVehicleTargetTest,testPropConfigs_onlyDefinedSystemPropertyIdsReturned)245 TEST_P(VtsHalAutomotiveVehicleTargetTest, testPropConfigs_onlyDefinedSystemPropertyIdsReturned) {
246     if (!mVhalClient->isAidlVhal()) {
247         GTEST_SKIP() << "Skip for HIDL VHAL because HAL interface run-time version is only"
248                      << "introduced for AIDL";
249     }
250 
251     auto result = mVhalClient->getAllPropConfigs();
252     ASSERT_TRUE(result.ok()) << "Failed to get all property configs, error: "
253                              << result.error().message();
254 
255     int32_t vhalVersion = mVhalClient->getRemoteInterfaceVersion();
256     const auto& configs = result.value();
257     for (size_t i = 0; i < configs.size(); i++) {
258         int32_t propId = configs[i]->getPropId();
259         if (!isSystemProp(propId)) {
260             continue;
261         }
262 
263         std::string propName = propIdToString(propId);
264         auto it = VersionForVehicleProperty.find(static_cast<VehicleProperty>(propId));
265         bool found = (it != VersionForVehicleProperty.end());
266         EXPECT_TRUE(found) << "System Property: " << propName
267                            << " is not defined in VHAL property interface";
268         if (!found) {
269             continue;
270         }
271         int32_t requiredVersion = it->second;
272         EXPECT_THAT(vhalVersion, Ge(requiredVersion))
273                 << "System Property: " << propName << " requires VHAL version: " << requiredVersion
274                 << ", but the current VHAL version"
275                 << " is " << vhalVersion << ", must not be supported";
276     }
277 }
278 
TEST_P(VtsHalAutomotiveVehicleTargetTest,testPropConfigs_globalAccessIsMaximalAreaAccessSubset)279 TEST_P(VtsHalAutomotiveVehicleTargetTest, testPropConfigs_globalAccessIsMaximalAreaAccessSubset) {
280     if (!mVhalClient->isAidlVhal()) {
281         GTEST_SKIP() << "Skip for HIDL VHAL because HAL interface run-time version is only"
282                      << "introduced for AIDL";
283     }
284 
285     auto result = mVhalClient->getAllPropConfigs();
286     ASSERT_TRUE(result.ok()) << "Failed to get all property configs, error: "
287                              << result.error().message();
288 
289     const auto& configs = result.value();
290     for (size_t i = 0; i < configs.size(); i++) {
291         verifyGlobalAccessIsMaximalAreaAccessSubset(configs[i]->getAccess(),
292                                                     configs[i]->getAreaConfigs());
293     }
294 }
295 
296 // Test get() return current value for properties.
TEST_P(VtsHalAutomotiveVehicleTargetTest,get)297 TEST_P(VtsHalAutomotiveVehicleTargetTest, get) {
298     ALOGD("VtsHalAutomotiveVehicleTargetTest::get");
299 
300     int32_t propId = toInt(VehicleProperty::PERF_VEHICLE_SPEED);
301     if (!checkIsSupported(propId)) {
302         GTEST_SKIP() << "Property: " << propId << " is not supported, skip the test";
303     }
304     auto result = mVhalClient->getValueSync(*mVhalClient->createHalPropValue(propId));
305 
306     ASSERT_TRUE(result.ok()) << StringPrintf("Failed to get value for property: %" PRId32
307                                              ", error: %s",
308                                              propId, result.error().message().c_str());
309     ASSERT_NE(result.value(), nullptr) << "Result value must not be null";
310 }
311 
312 // Test get() with an invalid propertyId return an error codes.
TEST_P(VtsHalAutomotiveVehicleTargetTest,getInvalidProp)313 TEST_P(VtsHalAutomotiveVehicleTargetTest, getInvalidProp) {
314     ALOGD("VtsHalAutomotiveVehicleTargetTest::getInvalidProp");
315 
316     auto result = mVhalClient->getValueSync(*mVhalClient->createHalPropValue(kInvalidProp));
317 
318     ASSERT_FALSE(result.ok()) << StringPrintf(
319             "Expect failure to get property for invalid prop: %" PRId32, kInvalidProp);
320 }
321 
isResultOkayWithValue(const VhalClientResult<std::unique_ptr<IHalPropValue>> & result,int32_t value)322 bool VtsHalAutomotiveVehicleTargetTest::isResultOkayWithValue(
323         const VhalClientResult<std::unique_ptr<IHalPropValue>>& result, int32_t value) {
324     return result.ok() && result.value() != nullptr &&
325            result.value()->getStatus() == VehiclePropertyStatus::AVAILABLE &&
326            result.value()->getInt32Values().size() == 1 &&
327            result.value()->getInt32Values()[0] == value;
328 }
329 
isUnavailable(const VhalClientResult<std::unique_ptr<IHalPropValue>> & result)330 bool VtsHalAutomotiveVehicleTargetTest::isUnavailable(
331         const VhalClientResult<std::unique_ptr<IHalPropValue>>& result) {
332     if (!result.ok()) {
333         return result.error().code() == ErrorCode::NOT_AVAILABLE_FROM_VHAL;
334     }
335     if (result.value() != nullptr &&
336         result.value()->getStatus() == VehiclePropertyStatus::UNAVAILABLE) {
337         return true;
338     }
339 
340     return false;
341 }
342 
343 // Test set() on read_write properties.
TEST_P(VtsHalAutomotiveVehicleTargetTest,setProp)344 TEST_P(VtsHalAutomotiveVehicleTargetTest, setProp) {
345     ALOGD("VtsHalAutomotiveVehicleTargetTest::setProp");
346 
347     // skip hvac related properties
348     std::unordered_set<int32_t> hvacProps = {toInt(VehicleProperty::HVAC_DEFROSTER),
349                                              toInt(VehicleProperty::HVAC_AC_ON),
350                                              toInt(VehicleProperty::HVAC_MAX_AC_ON),
351                                              toInt(VehicleProperty::HVAC_MAX_DEFROST_ON),
352                                              toInt(VehicleProperty::HVAC_RECIRC_ON),
353                                              toInt(VehicleProperty::HVAC_DUAL_ON),
354                                              toInt(VehicleProperty::HVAC_AUTO_ON),
355                                              toInt(VehicleProperty::HVAC_POWER_ON),
356                                              toInt(VehicleProperty::HVAC_AUTO_RECIRC_ON),
357                                              toInt(VehicleProperty::HVAC_ELECTRIC_DEFROSTER_ON)};
358     auto result = mVhalClient->getAllPropConfigs();
359     ASSERT_TRUE(result.ok());
360 
361     for (const auto& cfgPtr : result.value()) {
362         const IHalPropConfig& cfg = *cfgPtr;
363         int32_t propId = cfg.getPropId();
364         // test on boolean and writable property
365         bool isReadWrite = (cfg.getAccess() == toInt(VehiclePropertyAccess::READ_WRITE));
366         if (cfg.getAreaConfigSize() != 0 &&
367             cfg.getAreaConfigs()[0]->getAccess() != toInt(VehiclePropertyAccess::NONE)) {
368             isReadWrite = (cfg.getAreaConfigs()[0]->getAccess() ==
369                            toInt(VehiclePropertyAccess::READ_WRITE));
370         }
371         if (isReadWrite && isBooleanGlobalProp(propId) && !hvacProps.count(propId)) {
372             auto propToGet = mVhalClient->createHalPropValue(propId);
373             auto getValueResult = mVhalClient->getValueSync(*propToGet);
374 
375             if (isUnavailable(getValueResult)) {
376                 ALOGW("getProperty for %" PRId32
377                       " returns NOT_AVAILABLE, "
378                       "skip testing setProp",
379                       propId);
380                 return;
381             }
382 
383             ASSERT_TRUE(getValueResult.ok())
384                     << StringPrintf("Failed to get value for property: %" PRId32 ", error: %s",
385                                     propId, getValueResult.error().message().c_str());
386             ASSERT_NE(getValueResult.value(), nullptr)
387                     << StringPrintf("Result value must not be null for property: %" PRId32, propId);
388 
389             const IHalPropValue& value = *getValueResult.value();
390             size_t intValueSize = value.getInt32Values().size();
391             ASSERT_EQ(intValueSize, 1u) << StringPrintf(
392                     "Expect exactly 1 int value for boolean property: %" PRId32 ", got %zu", propId,
393                     intValueSize);
394 
395             int32_t setValue = value.getInt32Values()[0] == 1 ? 0 : 1;
396             auto propToSet = mVhalClient->createHalPropValue(propId);
397             propToSet->setInt32Values({setValue});
398             auto setValueResult = mVhalClient->setValueSync(*propToSet);
399 
400             if (!setValueResult.ok() &&
401                 setValueResult.error().code() == ErrorCode::NOT_AVAILABLE_FROM_VHAL) {
402                 ALOGW("setProperty for %" PRId32
403                       " returns NOT_AVAILABLE, "
404                       "skip verifying getProperty returns the same value",
405                       propId);
406                 return;
407             }
408 
409             ASSERT_TRUE(setValueResult.ok())
410                     << StringPrintf("Failed to set value for property: %" PRId32 ", error: %s",
411                                     propId, setValueResult.error().message().c_str());
412             // Retry getting the value until we pass the timeout. getValue might not return
413             // the expected value immediately since setValue is async.
414             auto timeoutMillis = uptimeMillis() + kRetryGetPropAfterSetPropTimeoutMillis;
415 
416             while (true) {
417                 getValueResult = mVhalClient->getValueSync(*propToGet);
418                 if (isResultOkayWithValue(getValueResult, setValue)) {
419                     break;
420                 }
421                 if (uptimeMillis() >= timeoutMillis) {
422                     // Reach timeout, the following assert should fail.
423                     break;
424                 }
425                 // Sleep for 100ms between each getValueSync retry.
426                 std::this_thread::sleep_for(std::chrono::milliseconds(100));
427             }
428 
429             if (isUnavailable(getValueResult)) {
430                 ALOGW("getProperty for %" PRId32
431                       " returns NOT_AVAILABLE, "
432                       "skip verifying the return value",
433                       propId);
434                 return;
435             }
436 
437             ASSERT_TRUE(getValueResult.ok())
438                     << StringPrintf("Failed to get value for property: %" PRId32 ", error: %s",
439                                     propId, getValueResult.error().message().c_str());
440             ASSERT_NE(getValueResult.value(), nullptr)
441                     << StringPrintf("Result value must not be null for property: %" PRId32, propId);
442             ASSERT_EQ(getValueResult.value()->getInt32Values(), std::vector<int32_t>({setValue}))
443                     << StringPrintf("Boolean value not updated after set for property: %" PRId32,
444                                     propId);
445         }
446     }
447 }
448 
449 // Test set() on an read_only property.
TEST_P(VtsHalAutomotiveVehicleTargetTest,setNotWritableProp)450 TEST_P(VtsHalAutomotiveVehicleTargetTest, setNotWritableProp) {
451     ALOGD("VtsHalAutomotiveVehicleTargetTest::setNotWritableProp");
452 
453     int32_t propId = toInt(VehicleProperty::PERF_VEHICLE_SPEED);
454     if (!checkIsSupported(propId)) {
455         GTEST_SKIP() << "Property: " << propId << " is not supported, skip the test";
456     }
457 
458     auto getValueResult = mVhalClient->getValueSync(*mVhalClient->createHalPropValue(propId));
459     ASSERT_TRUE(getValueResult.ok())
460             << StringPrintf("Failed to get value for property: %" PRId32 ", error: %s", propId,
461                             getValueResult.error().message().c_str());
462 
463     auto setValueResult = mVhalClient->setValueSync(*getValueResult.value());
464 
465     ASSERT_FALSE(setValueResult.ok()) << "Expect set a read-only value to fail";
466     ASSERT_EQ(setValueResult.error().code(), ErrorCode::ACCESS_DENIED_FROM_VHAL);
467 }
468 
469 // Test get(), set() and getAllPropConfigs() on VehicleProperty::INVALID.
TEST_P(VtsHalAutomotiveVehicleTargetTest,getSetPropertyIdInvalid)470 TEST_P(VtsHalAutomotiveVehicleTargetTest, getSetPropertyIdInvalid) {
471     ALOGD("VtsHalAutomotiveVehicleTargetTest::getSetPropertyIdInvalid");
472 
473     int32_t propId = toInt(VehicleProperty::INVALID);
474     auto getValueResult = mVhalClient->getValueSync(*mVhalClient->createHalPropValue(propId));
475     ASSERT_FALSE(getValueResult.ok()) << "Expect get on VehicleProperty::INVALID to fail";
476     ASSERT_EQ(getValueResult.error().code(), ErrorCode::INVALID_ARG);
477 
478     auto propToSet = mVhalClient->createHalPropValue(propId);
479     propToSet->setInt32Values({0});
480     auto setValueResult = mVhalClient->setValueSync(*propToSet);
481     ASSERT_FALSE(setValueResult.ok()) << "Expect set on VehicleProperty::INVALID to fail";
482     ASSERT_EQ(setValueResult.error().code(), ErrorCode::INVALID_ARG);
483 
484     auto result = mVhalClient->getAllPropConfigs();
485     ASSERT_TRUE(result.ok());
486     for (const auto& cfgPtr : result.value()) {
487         const IHalPropConfig& cfg = *cfgPtr;
488         ASSERT_FALSE(cfg.getPropId() == propId) << "Expect VehicleProperty::INVALID to not be "
489                                                    "included in propConfigs";
490     }
491 }
492 
493 // Test subscribe() and unsubscribe().
TEST_P(VtsHalAutomotiveVehicleTargetTest,subscribeAndUnsubscribe)494 TEST_P(VtsHalAutomotiveVehicleTargetTest, subscribeAndUnsubscribe) {
495     ALOGD("VtsHalAutomotiveVehicleTargetTest::subscribeAndUnsubscribe");
496 
497     int32_t propId = toInt(VehicleProperty::PERF_VEHICLE_SPEED);
498     if (!checkIsSupported(propId)) {
499         GTEST_SKIP() << "Property: " << propId << " is not supported, skip the test";
500     }
501 
502     auto propConfigsResult = mVhalClient->getPropConfigs({propId});
503 
504     ASSERT_TRUE(propConfigsResult.ok()) << "Failed to get property config for PERF_VEHICLE_SPEED: "
505                                         << "error: " << propConfigsResult.error().message();
506     ASSERT_EQ(propConfigsResult.value().size(), 1u)
507             << "Expect to return 1 config for PERF_VEHICLE_SPEED";
508     auto& propConfig = propConfigsResult.value()[0];
509     float minSampleRate = propConfig->getMinSampleRate();
510     float maxSampleRate = propConfig->getMaxSampleRate();
511 
512     if (minSampleRate < 1) {
513         GTEST_SKIP() << "Sample rate for vehicle speed < 1 times/sec, skip test since it would "
514                         "take too long";
515     }
516 
517     auto client = mVhalClient->getSubscriptionClient(mCallback);
518     ASSERT_NE(client, nullptr) << "Failed to get subscription client";
519 
520     auto result = client->subscribe({{.propId = propId, .sampleRate = minSampleRate}});
521 
522     ASSERT_TRUE(result.ok()) << StringPrintf("Failed to subscribe to property: %" PRId32
523                                              ", error: %s",
524                                              propId, result.error().message().c_str());
525 
526     if (mVhalClient->isAidlVhal()) {
527         // Skip checking timestamp for HIDL because the behavior for sample rate and timestamp is
528         // only specified clearly for AIDL.
529 
530         // Timeout is 2 seconds, which gives a 1 second buffer.
531         ASSERT_TRUE(mCallback->waitForExpectedEvents(propId, std::floor(minSampleRate),
532                                                      std::chrono::seconds(2)))
533                 << "Didn't get enough events for subscribing to minSampleRate";
534     }
535 
536     result = client->subscribe({{.propId = propId, .sampleRate = maxSampleRate}});
537 
538     ASSERT_TRUE(result.ok()) << StringPrintf("Failed to subscribe to property: %" PRId32
539                                              ", error: %s",
540                                              propId, result.error().message().c_str());
541 
542     if (mVhalClient->isAidlVhal()) {
543         ASSERT_TRUE(mCallback->waitForExpectedEvents(propId, std::floor(maxSampleRate),
544                                                      std::chrono::seconds(2)))
545                 << "Didn't get enough events for subscribing to maxSampleRate";
546 
547         std::unordered_set<int64_t> timestamps;
548         // Event event should have a different timestamp.
549         for (const int64_t& eventTimestamp : mCallback->getEventTimestamps(propId)) {
550             ASSERT_TRUE(timestamps.find(eventTimestamp) == timestamps.end())
551                     << "two events for the same property must not have the same timestamp";
552             timestamps.insert(eventTimestamp);
553         }
554     }
555 
556     result = client->unsubscribe({propId});
557     ASSERT_TRUE(result.ok()) << StringPrintf("Failed to unsubscribe to property: %" PRId32
558                                              ", error: %s",
559                                              propId, result.error().message().c_str());
560 
561     mCallback->reset();
562     ASSERT_FALSE(mCallback->waitForExpectedEvents(propId, 10, std::chrono::seconds(1)))
563             << "Expect not to get events after unsubscription";
564 }
565 
isVariableUpdateRateSupported(const std::unique_ptr<IHalPropConfig> & config,int32_t areaId)566 bool isVariableUpdateRateSupported(const std::unique_ptr<IHalPropConfig>& config, int32_t areaId) {
567     for (const auto& areaConfigPtr : config->getAreaConfigs()) {
568         if (areaConfigPtr->getAreaId() == areaId &&
569             areaConfigPtr->isVariableUpdateRateSupported()) {
570             return true;
571         }
572     }
573     return false;
574 }
575 
576 // Test subscribe with variable update rate enabled if supported.
TEST_P(VtsHalAutomotiveVehicleTargetTest,subscribe_enableVurIfSupported)577 TEST_P(VtsHalAutomotiveVehicleTargetTest, subscribe_enableVurIfSupported) {
578     ALOGD("VtsHalAutomotiveVehicleTargetTest::subscribe_enableVurIfSupported");
579 
580     int32_t propId = toInt(VehicleProperty::PERF_VEHICLE_SPEED);
581     if (!checkIsSupported(propId)) {
582         GTEST_SKIP() << "Property: " << propId << " is not supported, skip the test";
583     }
584     if (!mVhalClient->isAidlVhal()) {
585         GTEST_SKIP() << "Variable update rate is only supported by AIDL VHAL";
586     }
587 
588     auto propConfigsResult = mVhalClient->getPropConfigs({propId});
589 
590     ASSERT_TRUE(propConfigsResult.ok()) << "Failed to get property config for PERF_VEHICLE_SPEED: "
591                                         << "error: " << propConfigsResult.error().message();
592     ASSERT_EQ(propConfigsResult.value().size(), 1u)
593             << "Expect to return 1 config for PERF_VEHICLE_SPEED";
594     auto& propConfig = propConfigsResult.value()[0];
595     float maxSampleRate = propConfig->getMaxSampleRate();
596     if (maxSampleRate < 1) {
597         GTEST_SKIP() << "Sample rate for vehicle speed < 1 times/sec, skip test since it would "
598                         "take too long";
599     }
600     // PERF_VEHICLE_SPEED is a global property, so areaId is 0.
601     if (!isVariableUpdateRateSupported(propConfig, /* areaId= */ 0)) {
602         GTEST_SKIP() << "Variable update rate is not supported for PERF_VEHICLE_SPEED, "
603                      << "skip testing";
604     }
605 
606     // Subscribe to PERF_VEHICLE_SPEED using the max sample rate.
607     auto client = mVhalClient->getSubscriptionClient(mCallback);
608     ASSERT_NE(client, nullptr) << "Failed to get subscription client";
609     SubscribeOptionsBuilder builder(propId);
610     // By default variable update rate is true.
611     builder.setSampleRate(maxSampleRate);
612     auto option = builder.build();
613 
614     auto result = client->subscribe({option});
615 
616     ASSERT_TRUE(result.ok()) << StringPrintf("Failed to subscribe to property: %" PRId32
617                                              ", error: %s",
618                                              propId, result.error().message().c_str());
619 
620     // Sleep for 1 seconds to wait for more possible events to arrive.
621     std::this_thread::sleep_for(std::chrono::seconds(1));
622 
623     client->unsubscribe({propId});
624 
625     auto events = mCallback->getEvents(propId);
626     if (events.size() <= 1) {
627         // We received 0 or 1 event, the value is not changing so nothing to check here.
628         // If all VHAL clients are subscribing to PERF_VEHICLE_SPEED with VUR on, then we
629         // will receive 0 event. If there are other VHAL clients subscribing to PERF_VEHICLE_SPEED
630         // with VUR off, then we will receive 1 event which is the initial value.
631         return;
632     }
633 
634     // Sort the values by the timestamp.
635     std::map<int64_t, float> valuesByTimestamp;
636     for (size_t i = 0; i < events.size(); i++) {
637         valuesByTimestamp[events[i]->getTimestamp()] = events[i]->getFloatValues()[0];
638     }
639 
640     size_t i = 0;
641     float previousValue;
642     for (const auto& [_, value] : valuesByTimestamp) {
643         if (i != 0) {
644             ASSERT_FALSE(value != previousValue) << "received duplicate value: " << value
645                                                  << " when variable update rate is true";
646         }
647         previousValue = value;
648         i++;
649     }
650 }
651 
652 // Test subscribe() with an invalid property.
TEST_P(VtsHalAutomotiveVehicleTargetTest,subscribeInvalidProp)653 TEST_P(VtsHalAutomotiveVehicleTargetTest, subscribeInvalidProp) {
654     ALOGD("VtsHalAutomotiveVehicleTargetTest::subscribeInvalidProp");
655 
656     std::vector<SubscribeOptions> options = {
657             SubscribeOptions{.propId = kInvalidProp, .sampleRate = 10.0}};
658 
659     auto client = mVhalClient->getSubscriptionClient(mCallback);
660     ASSERT_NE(client, nullptr) << "Failed to get subscription client";
661 
662     auto result = client->subscribe(options);
663 
664     ASSERT_FALSE(result.ok()) << StringPrintf("Expect subscribing to property: %" PRId32 " to fail",
665                                               kInvalidProp);
666 }
667 
668 // Test the timestamp returned in GetValues results is the timestamp when the value is retrieved.
TEST_P(VtsHalAutomotiveVehicleTargetTest,testGetValuesTimestampAIDL)669 TEST_P(VtsHalAutomotiveVehicleTargetTest, testGetValuesTimestampAIDL) {
670     if (!mVhalClient->isAidlVhal()) {
671         GTEST_SKIP() << "Skip checking timestamp for HIDL because the behavior is only specified "
672                         "for AIDL";
673     }
674 
675     int32_t propId = toInt(VehicleProperty::PARKING_BRAKE_ON);
676     if (!checkIsSupported(propId)) {
677         GTEST_SKIP() << "Property: " << propId << " is not supported, skip the test";
678     }
679     auto prop = mVhalClient->createHalPropValue(propId);
680 
681     auto result = mVhalClient->getValueSync(*prop);
682 
683     ASSERT_TRUE(result.ok()) << StringPrintf("Failed to get value for property: %" PRId32
684                                              ", error: %s",
685                                              propId, result.error().message().c_str());
686     ASSERT_NE(result.value(), nullptr) << "Result value must not be null";
687     ASSERT_EQ(result.value()->getInt32Values().size(), 1u) << "Result must contain 1 int value";
688 
689     bool parkBrakeOnValue1 = (result.value()->getInt32Values()[0] == 1);
690     int64_t timestampValue1 = result.value()->getTimestamp();
691 
692     result = mVhalClient->getValueSync(*prop);
693 
694     ASSERT_TRUE(result.ok()) << StringPrintf("Failed to get value for property: %" PRId32
695                                              ", error: %s",
696                                              propId, result.error().message().c_str());
697     ASSERT_NE(result.value(), nullptr) << "Result value must not be null";
698     ASSERT_EQ(result.value()->getInt32Values().size(), 1u) << "Result must contain 1 int value";
699 
700     bool parkBarkeOnValue2 = (result.value()->getInt32Values()[0] == 1);
701     int64_t timestampValue2 = result.value()->getTimestamp();
702 
703     if (parkBarkeOnValue2 == parkBrakeOnValue1) {
704         ASSERT_EQ(timestampValue2, timestampValue1)
705                 << "getValue result must contain a timestamp updated when the value was updated, if"
706                    "the value does not change, expect the same timestamp";
707     } else {
708         ASSERT_GT(timestampValue2, timestampValue1)
709                 << "getValue result must contain a timestamp updated when the value was updated, if"
710                    "the value changes, expect the newer value has a larger timestamp";
711     }
712 }
713 
verifyAccessMode(int actualAccess,int expectedAccess)714 void VtsHalAutomotiveVehicleTargetTest::verifyAccessMode(int actualAccess, int expectedAccess) {
715     if (actualAccess == toInt(VehiclePropertyAccess::NONE)) {
716         return;
717     }
718     if (expectedAccess == toInt(VehiclePropertyAccess::READ_WRITE)) {
719         ASSERT_TRUE(actualAccess == expectedAccess ||
720                     actualAccess == toInt(VehiclePropertyAccess::READ))
721                 << StringPrintf("Expect to get VehiclePropertyAccess: %i or %i, got %i",
722                                 expectedAccess, toInt(VehiclePropertyAccess::READ), actualAccess);
723         return;
724     }
725     ASSERT_EQ(actualAccess, expectedAccess) << StringPrintf(
726             "Expect to get VehiclePropertyAccess: %i, got %i", expectedAccess, actualAccess);
727 }
728 
verifyGlobalAccessIsMaximalAreaAccessSubset(int propertyLevelAccess,const std::vector<std::unique_ptr<IHalAreaConfig>> & areaConfigs) const729 void VtsHalAutomotiveVehicleTargetTest::verifyGlobalAccessIsMaximalAreaAccessSubset(
730         int propertyLevelAccess,
731         const std::vector<std::unique_ptr<IHalAreaConfig>>& areaConfigs) const {
732     bool readOnlyPresent = false;
733     bool writeOnlyPresent = false;
734     bool readWritePresent = false;
735     int maximalAreaAccessSubset = toInt(VehiclePropertyAccess::NONE);
736     for (size_t i = 0; i < areaConfigs.size(); i++) {
737         int access = areaConfigs[i]->getAccess();
738         switch (access) {
739             case toInt(VehiclePropertyAccess::READ):
740                 readOnlyPresent = true;
741                 break;
742             case toInt(VehiclePropertyAccess::WRITE):
743                 writeOnlyPresent = true;
744                 break;
745             case toInt(VehiclePropertyAccess::READ_WRITE):
746                 readWritePresent = true;
747                 break;
748             default:
749                 ASSERT_EQ(access, toInt(VehiclePropertyAccess::NONE)) << StringPrintf(
750                         "Area access can be NONE only if global property access is also NONE");
751                 return;
752         }
753     }
754 
755     if (readOnlyPresent) {
756         ASSERT_FALSE(writeOnlyPresent) << StringPrintf(
757                 "Found both READ_ONLY and WRITE_ONLY access modes in area configs, which is not "
758                 "supported");
759         maximalAreaAccessSubset = toInt(VehiclePropertyAccess::READ);
760     } else if (writeOnlyPresent) {
761         ASSERT_FALSE(readWritePresent) << StringPrintf(
762                 "Found both WRITE_ONLY and READ_WRITE access modes in area configs, which is not "
763                 "supported");
764         maximalAreaAccessSubset = toInt(VehiclePropertyAccess::WRITE);
765     } else if (readWritePresent) {
766         maximalAreaAccessSubset = toInt(VehiclePropertyAccess::READ_WRITE);
767     }
768     ASSERT_EQ(propertyLevelAccess, maximalAreaAccessSubset) << StringPrintf(
769             "Expected global access to be equal to maximal area access subset %d, Instead got %d",
770             maximalAreaAccessSubset, propertyLevelAccess);
771 }
772 
773 // Helper function to compare actual vs expected property config
verifyProperty(VehicleProperty propId,VehiclePropertyAccess access,VehiclePropertyChangeMode changeMode,VehiclePropertyGroup group,VehicleArea area,VehiclePropertyType propertyType)774 void VtsHalAutomotiveVehicleTargetTest::verifyProperty(VehicleProperty propId,
775                                                        VehiclePropertyAccess access,
776                                                        VehiclePropertyChangeMode changeMode,
777                                                        VehiclePropertyGroup group, VehicleArea area,
778                                                        VehiclePropertyType propertyType) {
779     int expectedPropId = toInt(propId);
780     int expectedAccess = toInt(access);
781     int expectedChangeMode = toInt(changeMode);
782     int expectedGroup = toInt(group);
783     int expectedArea = toInt(area);
784     int expectedPropertyType = toInt(propertyType);
785 
786     auto result = mVhalClient->getAllPropConfigs();
787     ASSERT_TRUE(result.ok()) << "Failed to get all property configs, error: "
788                              << result.error().message();
789 
790     // Check if property is implemented by getting all configs and looking to see if the expected
791     // property id is in that list.
792     bool isExpectedPropIdImplemented = false;
793     for (const auto& cfgPtr : result.value()) {
794         const IHalPropConfig& cfg = *cfgPtr;
795         if (expectedPropId == cfg.getPropId()) {
796             isExpectedPropIdImplemented = true;
797             break;
798         }
799     }
800 
801     if (!isExpectedPropIdImplemented) {
802         GTEST_SKIP() << StringPrintf("Property %" PRId32 " has not been implemented",
803                                      expectedPropId);
804     }
805 
806     result = mVhalClient->getPropConfigs({expectedPropId});
807     ASSERT_TRUE(result.ok()) << "Failed to get required property config, error: "
808                              << result.error().message();
809 
810     ASSERT_EQ(result.value().size(), 1u)
811             << StringPrintf("Expect to get exactly 1 config, got %zu", result.value().size());
812 
813     const auto& config = result.value().at(0);
814     int actualPropId = config->getPropId();
815     int actualChangeMode = config->getChangeMode();
816     int actualGroup = actualPropId & toInt(VehiclePropertyGroup::MASK);
817     int actualArea = actualPropId & toInt(VehicleArea::MASK);
818     int actualPropertyType = actualPropId & toInt(VehiclePropertyType::MASK);
819 
820     ASSERT_EQ(actualPropId, expectedPropId)
821             << StringPrintf("Expect to get property ID: %i, got %i", expectedPropId, actualPropId);
822 
823     int globalAccess = config->getAccess();
824     if (config->getAreaConfigSize() == 0) {
825         verifyAccessMode(globalAccess, expectedAccess);
826     } else {
827         for (const auto& areaConfig : config->getAreaConfigs()) {
828             int areaConfigAccess = areaConfig->getAccess();
829             int actualAccess = (areaConfigAccess != toInt(VehiclePropertyAccess::NONE))
830                                        ? areaConfigAccess
831                                        : globalAccess;
832             verifyAccessMode(actualAccess, expectedAccess);
833         }
834     }
835 
836     ASSERT_EQ(actualChangeMode, expectedChangeMode)
837             << StringPrintf("Expect to get VehiclePropertyChangeMode: %i, got %i",
838                             expectedChangeMode, actualChangeMode);
839     ASSERT_EQ(actualGroup, expectedGroup) << StringPrintf(
840             "Expect to get VehiclePropertyGroup: %i, got %i", expectedGroup, actualGroup);
841     ASSERT_EQ(actualArea, expectedArea)
842             << StringPrintf("Expect to get VehicleArea: %i, got %i", expectedArea, actualArea);
843     ASSERT_EQ(actualPropertyType, expectedPropertyType)
844             << StringPrintf("Expect to get VehiclePropertyType: %i, got %i", expectedPropertyType,
845                             actualPropertyType);
846 }
847 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyLocationCharacterizationConfig)848 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyLocationCharacterizationConfig) {
849     verifyProperty(VehicleProperty::LOCATION_CHARACTERIZATION, VehiclePropertyAccess::READ,
850                    VehiclePropertyChangeMode::STATIC, VehiclePropertyGroup::SYSTEM,
851                    VehicleArea::GLOBAL, VehiclePropertyType::INT32);
852 }
853 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyUltrasonicsSensorPositionConfig)854 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyUltrasonicsSensorPositionConfig) {
855     verifyProperty(VehicleProperty::ULTRASONICS_SENSOR_POSITION, VehiclePropertyAccess::READ,
856                    VehiclePropertyChangeMode::STATIC, VehiclePropertyGroup::SYSTEM,
857                    VehicleArea::VENDOR, VehiclePropertyType::INT32_VEC);
858 }
859 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyUltrasonicsSensorOrientationConfig)860 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyUltrasonicsSensorOrientationConfig) {
861     verifyProperty(VehicleProperty::ULTRASONICS_SENSOR_ORIENTATION, VehiclePropertyAccess::READ,
862                    VehiclePropertyChangeMode::STATIC, VehiclePropertyGroup::SYSTEM,
863                    VehicleArea::VENDOR, VehiclePropertyType::FLOAT_VEC);
864 }
865 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyUltrasonicsSensorFieldOfViewConfig)866 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyUltrasonicsSensorFieldOfViewConfig) {
867     verifyProperty(VehicleProperty::ULTRASONICS_SENSOR_FIELD_OF_VIEW, VehiclePropertyAccess::READ,
868                    VehiclePropertyChangeMode::STATIC, VehiclePropertyGroup::SYSTEM,
869                    VehicleArea::VENDOR, VehiclePropertyType::INT32_VEC);
870 }
871 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyUltrasonicsSensorDetectionRangeConfig)872 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyUltrasonicsSensorDetectionRangeConfig) {
873     verifyProperty(VehicleProperty::ULTRASONICS_SENSOR_DETECTION_RANGE, VehiclePropertyAccess::READ,
874                    VehiclePropertyChangeMode::STATIC, VehiclePropertyGroup::SYSTEM,
875                    VehicleArea::VENDOR, VehiclePropertyType::INT32_VEC);
876 }
877 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyUltrasonicsSensorSupportedRangesConfig)878 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyUltrasonicsSensorSupportedRangesConfig) {
879     verifyProperty(VehicleProperty::ULTRASONICS_SENSOR_SUPPORTED_RANGES,
880                    VehiclePropertyAccess::READ, VehiclePropertyChangeMode::STATIC,
881                    VehiclePropertyGroup::SYSTEM, VehicleArea::VENDOR,
882                    VehiclePropertyType::INT32_VEC);
883 }
884 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyUltrasonicsSensorMeasuredDistanceConfig)885 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyUltrasonicsSensorMeasuredDistanceConfig) {
886     verifyProperty(VehicleProperty::ULTRASONICS_SENSOR_MEASURED_DISTANCE,
887                    VehiclePropertyAccess::READ, VehiclePropertyChangeMode::CONTINUOUS,
888                    VehiclePropertyGroup::SYSTEM, VehicleArea::VENDOR,
889                    VehiclePropertyType::INT32_VEC);
890 }
891 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyEmergencyLaneKeepAssistEnabledConfig)892 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyEmergencyLaneKeepAssistEnabledConfig) {
893     verifyProperty(VehicleProperty::EMERGENCY_LANE_KEEP_ASSIST_ENABLED,
894                    VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
895                    VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
896 }
897 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyEmergencyLaneKeepAssistStateConfig)898 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyEmergencyLaneKeepAssistStateConfig) {
899     verifyProperty(VehicleProperty::EMERGENCY_LANE_KEEP_ASSIST_STATE, VehiclePropertyAccess::READ,
900                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
901                    VehicleArea::GLOBAL, VehiclePropertyType::INT32);
902 }
903 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyCruiseControlEnabledConfig)904 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyCruiseControlEnabledConfig) {
905     verifyProperty(VehicleProperty::CRUISE_CONTROL_ENABLED, VehiclePropertyAccess::READ_WRITE,
906                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
907                    VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
908 }
909 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyCruiseControlTypeConfig)910 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyCruiseControlTypeConfig) {
911     verifyProperty(VehicleProperty::CRUISE_CONTROL_TYPE, VehiclePropertyAccess::READ_WRITE,
912                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
913                    VehicleArea::GLOBAL, VehiclePropertyType::INT32);
914 }
915 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyCruiseControlStateConfig)916 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyCruiseControlStateConfig) {
917     verifyProperty(VehicleProperty::CRUISE_CONTROL_STATE, VehiclePropertyAccess::READ,
918                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
919                    VehicleArea::GLOBAL, VehiclePropertyType::INT32);
920 }
921 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyCruiseControlCommandConfig)922 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyCruiseControlCommandConfig) {
923     verifyProperty(VehicleProperty::CRUISE_CONTROL_COMMAND, VehiclePropertyAccess::WRITE,
924                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
925                    VehicleArea::GLOBAL, VehiclePropertyType::INT32);
926 }
927 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyCruiseControlTargetSpeedConfig)928 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyCruiseControlTargetSpeedConfig) {
929     verifyProperty(VehicleProperty::CRUISE_CONTROL_TARGET_SPEED, VehiclePropertyAccess::READ,
930                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
931                    VehicleArea::GLOBAL, VehiclePropertyType::FLOAT);
932 }
933 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyAdaptiveCruiseControlTargetTimeGapConfig)934 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyAdaptiveCruiseControlTargetTimeGapConfig) {
935     verifyProperty(VehicleProperty::ADAPTIVE_CRUISE_CONTROL_TARGET_TIME_GAP,
936                    VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
937                    VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::INT32);
938 }
939 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyAdaptiveCruiseControlLeadVehicleMeasuredDistanceConfig)940 TEST_P(VtsHalAutomotiveVehicleTargetTest,
941        verifyAdaptiveCruiseControlLeadVehicleMeasuredDistanceConfig) {
942     verifyProperty(VehicleProperty::ADAPTIVE_CRUISE_CONTROL_LEAD_VEHICLE_MEASURED_DISTANCE,
943                    VehiclePropertyAccess::READ, VehiclePropertyChangeMode::CONTINUOUS,
944                    VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::INT32);
945 }
946 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyHandsOnDetectionEnabledConfig)947 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyHandsOnDetectionEnabledConfig) {
948     verifyProperty(VehicleProperty::HANDS_ON_DETECTION_ENABLED, VehiclePropertyAccess::READ_WRITE,
949                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
950                    VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
951 }
952 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyHandsOnDetectionDriverStateConfig)953 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyHandsOnDetectionDriverStateConfig) {
954     verifyProperty(VehicleProperty::HANDS_ON_DETECTION_DRIVER_STATE, VehiclePropertyAccess::READ,
955                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
956                    VehicleArea::GLOBAL, VehiclePropertyType::INT32);
957 }
958 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyHandsOnDetectionWarningConfig)959 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyHandsOnDetectionWarningConfig) {
960     verifyProperty(VehicleProperty::HANDS_ON_DETECTION_WARNING, VehiclePropertyAccess::READ,
961                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
962                    VehicleArea::GLOBAL, VehiclePropertyType::INT32);
963 }
964 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyDriverDrowsinessAttentionSystemEnabledConfig)965 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyDriverDrowsinessAttentionSystemEnabledConfig) {
966     verifyProperty(VehicleProperty::DRIVER_DROWSINESS_ATTENTION_SYSTEM_ENABLED,
967                    VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
968                    VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
969 }
970 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyDriverDrowsinessAttentionStateConfig)971 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyDriverDrowsinessAttentionStateConfig) {
972     verifyProperty(VehicleProperty::DRIVER_DROWSINESS_ATTENTION_STATE, VehiclePropertyAccess::READ,
973                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
974                    VehicleArea::GLOBAL, VehiclePropertyType::INT32);
975 }
976 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyDriverDrowsinessAttentionWarningEnabledConfig)977 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyDriverDrowsinessAttentionWarningEnabledConfig) {
978     verifyProperty(VehicleProperty::DRIVER_DROWSINESS_ATTENTION_WARNING_ENABLED,
979                    VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
980                    VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
981 }
982 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyDriverDrowsinessAttentionWarningConfig)983 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyDriverDrowsinessAttentionWarningConfig) {
984     verifyProperty(VehicleProperty::DRIVER_DROWSINESS_ATTENTION_WARNING,
985                    VehiclePropertyAccess::READ, VehiclePropertyChangeMode::ON_CHANGE,
986                    VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::INT32);
987 }
988 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyDriverDistractionSystemEnabledConfig)989 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyDriverDistractionSystemEnabledConfig) {
990     verifyProperty(VehicleProperty::DRIVER_DISTRACTION_SYSTEM_ENABLED,
991                    VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
992                    VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
993 }
994 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyDriverDistractionStateConfig)995 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyDriverDistractionStateConfig) {
996     verifyProperty(VehicleProperty::DRIVER_DISTRACTION_STATE, VehiclePropertyAccess::READ,
997                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
998                    VehicleArea::GLOBAL, VehiclePropertyType::INT32);
999 }
1000 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyDriverDistractionWarningEnabledConfig)1001 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyDriverDistractionWarningEnabledConfig) {
1002     verifyProperty(VehicleProperty::DRIVER_DISTRACTION_WARNING_ENABLED,
1003                    VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
1004                    VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
1005 }
1006 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyDriverDistractionWarningConfig)1007 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyDriverDistractionWarningConfig) {
1008     verifyProperty(VehicleProperty::DRIVER_DISTRACTION_WARNING, VehiclePropertyAccess::READ,
1009                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
1010                    VehicleArea::GLOBAL, VehiclePropertyType::INT32);
1011 }
1012 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyEvBrakeRegenerationLevelConfig)1013 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyEvBrakeRegenerationLevelConfig) {
1014     verifyProperty(VehicleProperty::EV_BRAKE_REGENERATION_LEVEL,
1015                    VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
1016                    VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::INT32);
1017 }
1018 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyEvStoppingModeConfig)1019 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyEvStoppingModeConfig) {
1020     verifyProperty(VehicleProperty::EV_STOPPING_MODE, VehiclePropertyAccess::READ_WRITE,
1021                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
1022                    VehicleArea::GLOBAL, VehiclePropertyType::INT32);
1023 }
1024 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyEvCurrentBatteryCapacityConfig)1025 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyEvCurrentBatteryCapacityConfig) {
1026     verifyProperty(VehicleProperty::EV_CURRENT_BATTERY_CAPACITY, VehiclePropertyAccess::READ,
1027                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
1028                    VehicleArea::GLOBAL, VehiclePropertyType::FLOAT);
1029 }
1030 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyEngineIdleAutoStopEnabledConfig)1031 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyEngineIdleAutoStopEnabledConfig) {
1032     verifyProperty(VehicleProperty::ENGINE_IDLE_AUTO_STOP_ENABLED,
1033                    VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
1034                    VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
1035 }
1036 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyDoorChildLockEnabledConfig)1037 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyDoorChildLockEnabledConfig) {
1038     verifyProperty(VehicleProperty::DOOR_CHILD_LOCK_ENABLED, VehiclePropertyAccess::READ_WRITE,
1039                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
1040                    VehicleArea::DOOR, VehiclePropertyType::BOOLEAN);
1041 }
1042 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyWindshieldWipersPeriodConfig)1043 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyWindshieldWipersPeriodConfig) {
1044     verifyProperty(VehicleProperty::WINDSHIELD_WIPERS_PERIOD, VehiclePropertyAccess::READ,
1045                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
1046                    VehicleArea::WINDOW, VehiclePropertyType::INT32);
1047 }
1048 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyWindshieldWipersStateConfig)1049 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyWindshieldWipersStateConfig) {
1050     verifyProperty(VehicleProperty::WINDSHIELD_WIPERS_STATE, VehiclePropertyAccess::READ,
1051                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
1052                    VehicleArea::WINDOW, VehiclePropertyType::INT32);
1053 }
1054 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyWindshieldWipersSwitchConfig)1055 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyWindshieldWipersSwitchConfig) {
1056     verifyProperty(VehicleProperty::WINDSHIELD_WIPERS_SWITCH, VehiclePropertyAccess::READ_WRITE,
1057                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
1058                    VehicleArea::WINDOW, VehiclePropertyType::INT32);
1059 }
1060 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifySteeringWheelDepthPosConfig)1061 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySteeringWheelDepthPosConfig) {
1062     verifyProperty(VehicleProperty::STEERING_WHEEL_DEPTH_POS, VehiclePropertyAccess::READ_WRITE,
1063                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
1064                    VehicleArea::GLOBAL, VehiclePropertyType::INT32);
1065 }
1066 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifySteeringWheelDepthMoveConfig)1067 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySteeringWheelDepthMoveConfig) {
1068     verifyProperty(VehicleProperty::STEERING_WHEEL_DEPTH_MOVE, VehiclePropertyAccess::READ_WRITE,
1069                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
1070                    VehicleArea::GLOBAL, VehiclePropertyType::INT32);
1071 }
1072 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifySteeringWheelHeightPosConfig)1073 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySteeringWheelHeightPosConfig) {
1074     verifyProperty(VehicleProperty::STEERING_WHEEL_HEIGHT_POS, VehiclePropertyAccess::READ_WRITE,
1075                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
1076                    VehicleArea::GLOBAL, VehiclePropertyType::INT32);
1077 }
1078 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifySteeringWheelHeightMoveConfig)1079 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySteeringWheelHeightMoveConfig) {
1080     verifyProperty(VehicleProperty::STEERING_WHEEL_HEIGHT_MOVE, VehiclePropertyAccess::READ_WRITE,
1081                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
1082                    VehicleArea::GLOBAL, VehiclePropertyType::INT32);
1083 }
1084 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifySteeringWheelTheftLockEnabledConfig)1085 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySteeringWheelTheftLockEnabledConfig) {
1086     verifyProperty(VehicleProperty::STEERING_WHEEL_THEFT_LOCK_ENABLED,
1087                    VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
1088                    VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
1089 }
1090 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifySteeringWheelLockedConfig)1091 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySteeringWheelLockedConfig) {
1092     verifyProperty(VehicleProperty::STEERING_WHEEL_LOCKED, VehiclePropertyAccess::READ_WRITE,
1093                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
1094                    VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
1095 }
1096 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifySteeringWheelEasyAccessEnabledConfig)1097 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySteeringWheelEasyAccessEnabledConfig) {
1098     verifyProperty(VehicleProperty::STEERING_WHEEL_EASY_ACCESS_ENABLED,
1099                    VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
1100                    VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
1101 }
1102 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifySteeringWheelLightsStateConfig)1103 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySteeringWheelLightsStateConfig) {
1104     verifyProperty(VehicleProperty::STEERING_WHEEL_LIGHTS_STATE, VehiclePropertyAccess::READ,
1105                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
1106                    VehicleArea::GLOBAL, VehiclePropertyType::INT32);
1107 }
1108 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifySteeringWheelLightsSwitchConfig)1109 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySteeringWheelLightsSwitchConfig) {
1110     verifyProperty(VehicleProperty::STEERING_WHEEL_LIGHTS_SWITCH, VehiclePropertyAccess::READ_WRITE,
1111                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
1112                    VehicleArea::GLOBAL, VehiclePropertyType::INT32);
1113 }
1114 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyGloveBoxDoorPosConfig)1115 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyGloveBoxDoorPosConfig) {
1116     verifyProperty(VehicleProperty::GLOVE_BOX_DOOR_POS, VehiclePropertyAccess::READ_WRITE,
1117                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
1118                    VehicleArea::SEAT, VehiclePropertyType::INT32);
1119 }
1120 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyGloveBoxLockedConfig)1121 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyGloveBoxLockedConfig) {
1122     verifyProperty(VehicleProperty::GLOVE_BOX_LOCKED, VehiclePropertyAccess::READ_WRITE,
1123                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
1124                    VehicleArea::SEAT, VehiclePropertyType::BOOLEAN);
1125 }
1126 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyMirrorAutoFoldEnabledConfig)1127 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyMirrorAutoFoldEnabledConfig) {
1128     verifyProperty(VehicleProperty::MIRROR_AUTO_FOLD_ENABLED, VehiclePropertyAccess::READ_WRITE,
1129                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
1130                    VehicleArea::MIRROR, VehiclePropertyType::BOOLEAN);
1131 }
1132 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyMirrorAutoTiltEnabledConfig)1133 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyMirrorAutoTiltEnabledConfig) {
1134     verifyProperty(VehicleProperty::MIRROR_AUTO_TILT_ENABLED, VehiclePropertyAccess::READ_WRITE,
1135                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
1136                    VehicleArea::MIRROR, VehiclePropertyType::BOOLEAN);
1137 }
1138 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifySeatHeadrestHeightPosV2Config)1139 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySeatHeadrestHeightPosV2Config) {
1140     verifyProperty(VehicleProperty::SEAT_HEADREST_HEIGHT_POS_V2, VehiclePropertyAccess::READ_WRITE,
1141                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
1142                    VehicleArea::SEAT, VehiclePropertyType::INT32);
1143 }
1144 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifySeatWalkInPosConfig)1145 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySeatWalkInPosConfig) {
1146     verifyProperty(VehicleProperty::SEAT_WALK_IN_POS, VehiclePropertyAccess::READ_WRITE,
1147                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
1148                    VehicleArea::SEAT, VehiclePropertyType::INT32);
1149 }
1150 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifySeatFootwellLightsStateConfig)1151 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySeatFootwellLightsStateConfig) {
1152     verifyProperty(VehicleProperty::SEAT_FOOTWELL_LIGHTS_STATE, VehiclePropertyAccess::READ,
1153                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
1154                    VehicleArea::SEAT, VehiclePropertyType::INT32);
1155 }
1156 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifySeatFootwellLightsSwitchConfig)1157 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySeatFootwellLightsSwitchConfig) {
1158     verifyProperty(VehicleProperty::SEAT_FOOTWELL_LIGHTS_SWITCH, VehiclePropertyAccess::READ_WRITE,
1159                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
1160                    VehicleArea::SEAT, VehiclePropertyType::INT32);
1161 }
1162 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifySeatEasyAccessEnabledConfig)1163 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySeatEasyAccessEnabledConfig) {
1164     verifyProperty(VehicleProperty::SEAT_EASY_ACCESS_ENABLED, VehiclePropertyAccess::READ_WRITE,
1165                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
1166                    VehicleArea::SEAT, VehiclePropertyType::BOOLEAN);
1167 }
1168 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifySeatAirbagEnabledConfig)1169 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySeatAirbagEnabledConfig) {
1170     verifyProperty(VehicleProperty::SEAT_AIRBAG_ENABLED, VehiclePropertyAccess::READ_WRITE,
1171                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
1172                    VehicleArea::SEAT, VehiclePropertyType::BOOLEAN);
1173 }
1174 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifySeatCushionSideSupportPosConfig)1175 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySeatCushionSideSupportPosConfig) {
1176     verifyProperty(VehicleProperty::SEAT_CUSHION_SIDE_SUPPORT_POS,
1177                    VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
1178                    VehiclePropertyGroup::SYSTEM, VehicleArea::SEAT, VehiclePropertyType::INT32);
1179 }
1180 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifySeatCushionSideSupportMoveConfig)1181 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySeatCushionSideSupportMoveConfig) {
1182     verifyProperty(VehicleProperty::SEAT_CUSHION_SIDE_SUPPORT_MOVE,
1183                    VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
1184                    VehiclePropertyGroup::SYSTEM, VehicleArea::SEAT, VehiclePropertyType::INT32);
1185 }
1186 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifySeatLumbarVerticalPosConfig)1187 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySeatLumbarVerticalPosConfig) {
1188     verifyProperty(VehicleProperty::SEAT_LUMBAR_VERTICAL_POS, VehiclePropertyAccess::READ_WRITE,
1189                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
1190                    VehicleArea::SEAT, VehiclePropertyType::INT32);
1191 }
1192 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifySeatLumbarVerticalMoveConfig)1193 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySeatLumbarVerticalMoveConfig) {
1194     verifyProperty(VehicleProperty::SEAT_LUMBAR_VERTICAL_MOVE, VehiclePropertyAccess::READ_WRITE,
1195                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
1196                    VehicleArea::SEAT, VehiclePropertyType::INT32);
1197 }
1198 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyAutomaticEmergencyBrakingEnabledConfig)1199 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyAutomaticEmergencyBrakingEnabledConfig) {
1200     verifyProperty(VehicleProperty::AUTOMATIC_EMERGENCY_BRAKING_ENABLED,
1201                    VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
1202                    VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
1203 }
1204 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyAutomaticEmergencyBrakingStateConfig)1205 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyAutomaticEmergencyBrakingStateConfig) {
1206     verifyProperty(VehicleProperty::AUTOMATIC_EMERGENCY_BRAKING_STATE, VehiclePropertyAccess::READ,
1207                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
1208                    VehicleArea::GLOBAL, VehiclePropertyType::INT32);
1209 }
1210 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyForwardCollisionWarningEnabledConfig)1211 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyForwardCollisionWarningEnabledConfig) {
1212     verifyProperty(VehicleProperty::FORWARD_COLLISION_WARNING_ENABLED,
1213                    VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
1214                    VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
1215 }
1216 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyForwardCollisionWarningStateConfig)1217 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyForwardCollisionWarningStateConfig) {
1218     verifyProperty(VehicleProperty::FORWARD_COLLISION_WARNING_STATE, VehiclePropertyAccess::READ,
1219                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
1220                    VehicleArea::GLOBAL, VehiclePropertyType::INT32);
1221 }
1222 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyBlindSpotWarningEnabledConfig)1223 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyBlindSpotWarningEnabledConfig) {
1224     verifyProperty(VehicleProperty::BLIND_SPOT_WARNING_ENABLED, VehiclePropertyAccess::READ_WRITE,
1225                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
1226                    VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
1227 }
1228 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyBlindSpotWarningStateConfig)1229 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyBlindSpotWarningStateConfig) {
1230     verifyProperty(VehicleProperty::BLIND_SPOT_WARNING_STATE, VehiclePropertyAccess::READ,
1231                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
1232                    VehicleArea::MIRROR, VehiclePropertyType::INT32);
1233 }
1234 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyLaneDepartureWarningEnabledConfig)1235 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyLaneDepartureWarningEnabledConfig) {
1236     verifyProperty(VehicleProperty::LANE_DEPARTURE_WARNING_ENABLED,
1237                    VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
1238                    VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
1239 }
1240 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyLaneDepartureWarningStateConfig)1241 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyLaneDepartureWarningStateConfig) {
1242     verifyProperty(VehicleProperty::LANE_DEPARTURE_WARNING_STATE, VehiclePropertyAccess::READ,
1243                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
1244                    VehicleArea::GLOBAL, VehiclePropertyType::INT32);
1245 }
1246 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyLaneKeepAssistEnabledConfig)1247 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyLaneKeepAssistEnabledConfig) {
1248     verifyProperty(VehicleProperty::LANE_KEEP_ASSIST_ENABLED, VehiclePropertyAccess::READ_WRITE,
1249                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
1250                    VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
1251 }
1252 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyLaneKeepAssistStateConfig)1253 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyLaneKeepAssistStateConfig) {
1254     verifyProperty(VehicleProperty::LANE_KEEP_ASSIST_STATE, VehiclePropertyAccess::READ,
1255                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
1256                    VehicleArea::GLOBAL, VehiclePropertyType::INT32);
1257 }
1258 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyLaneCenteringAssistEnabledConfig)1259 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyLaneCenteringAssistEnabledConfig) {
1260     verifyProperty(VehicleProperty::LANE_CENTERING_ASSIST_ENABLED,
1261                    VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
1262                    VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
1263 }
1264 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyLaneCenteringAssistCommandConfig)1265 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyLaneCenteringAssistCommandConfig) {
1266     verifyProperty(VehicleProperty::LANE_CENTERING_ASSIST_COMMAND, VehiclePropertyAccess::WRITE,
1267                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
1268                    VehicleArea::GLOBAL, VehiclePropertyType::INT32);
1269 }
1270 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyLaneCenteringAssistStateConfig)1271 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyLaneCenteringAssistStateConfig) {
1272     verifyProperty(VehicleProperty::LANE_CENTERING_ASSIST_STATE, VehiclePropertyAccess::READ,
1273                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
1274                    VehicleArea::GLOBAL, VehiclePropertyType::INT32);
1275 }
1276 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyClusterHeartbeatConfig)1277 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyClusterHeartbeatConfig) {
1278     verifyProperty(VehicleProperty::CLUSTER_HEARTBEAT, VehiclePropertyAccess::WRITE,
1279                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
1280                    VehicleArea::GLOBAL, VehiclePropertyType::MIXED);
1281 }
1282 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyVehicleDrivingAutomationCurrentLevelConfig)1283 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyVehicleDrivingAutomationCurrentLevelConfig) {
1284     verifyProperty(VehicleProperty::VEHICLE_DRIVING_AUTOMATION_CURRENT_LEVEL,
1285                    VehiclePropertyAccess::READ, VehiclePropertyChangeMode::ON_CHANGE,
1286                    VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::INT32);
1287 }
1288 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyCameraServiceCurrentStateConfig)1289 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyCameraServiceCurrentStateConfig) {
1290     verifyProperty(VehicleProperty::CAMERA_SERVICE_CURRENT_STATE, VehiclePropertyAccess::WRITE,
1291                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
1292                    VehicleArea::GLOBAL, VehiclePropertyType::INT32_VEC);
1293 }
1294 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifySeatAirbagsDeployedConfig)1295 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySeatAirbagsDeployedConfig) {
1296     verifyProperty(VehicleProperty::SEAT_AIRBAGS_DEPLOYED, VehiclePropertyAccess::READ,
1297                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
1298                    VehicleArea::SEAT, VehiclePropertyType::INT32);
1299 }
1300 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifySeatBeltPretensionerDeployedConfig)1301 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySeatBeltPretensionerDeployedConfig) {
1302     verifyProperty(VehicleProperty::SEAT_BELT_PRETENSIONER_DEPLOYED, VehiclePropertyAccess::READ,
1303                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
1304                    VehicleArea::SEAT, VehiclePropertyType::BOOLEAN);
1305 }
1306 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyImpactDetectedConfig)1307 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyImpactDetectedConfig) {
1308     verifyProperty(VehicleProperty::IMPACT_DETECTED, VehiclePropertyAccess::READ,
1309                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
1310                    VehicleArea::GLOBAL, VehiclePropertyType::INT32);
1311 }
1312 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyEvBatteryAverageTemperatureConfig)1313 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyEvBatteryAverageTemperatureConfig) {
1314     verifyProperty(VehicleProperty::EV_BATTERY_AVERAGE_TEMPERATURE, VehiclePropertyAccess::READ,
1315                    VehiclePropertyChangeMode::CONTINUOUS, VehiclePropertyGroup::SYSTEM,
1316                    VehicleArea::GLOBAL, VehiclePropertyType::FLOAT);
1317 }
1318 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyLowSpeedCollisionWarningEnabledConfig)1319 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyLowSpeedCollisionWarningEnabledConfig) {
1320     verifyProperty(VehicleProperty::LOW_SPEED_COLLISION_WARNING_ENABLED,
1321                    VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
1322                    VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
1323 }
1324 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyLowSpeedCollisionWarningStateConfig)1325 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyLowSpeedCollisionWarningStateConfig) {
1326     verifyProperty(VehicleProperty::LOW_SPEED_COLLISION_WARNING_STATE, VehiclePropertyAccess::READ,
1327                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
1328                    VehicleArea::GLOBAL, VehiclePropertyType::INT32);
1329 }
1330 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyValetModeEnabledConfig)1331 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyValetModeEnabledConfig) {
1332     verifyProperty(VehicleProperty::VALET_MODE_ENABLED, VehiclePropertyAccess::READ_WRITE,
1333                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
1334                    VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
1335 }
1336 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyElectronicStabilityControlEnabledConfig)1337 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyElectronicStabilityControlEnabledConfig) {
1338     verifyProperty(VehicleProperty::ELECTRONIC_STABILITY_CONTROL_ENABLED,
1339                    VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
1340                    VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
1341 }
1342 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyElectronicStabilityControlStateConfig)1343 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyElectronicStabilityControlStateConfig) {
1344     verifyProperty(VehicleProperty::ELECTRONIC_STABILITY_CONTROL_STATE, VehiclePropertyAccess::READ,
1345                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
1346                    VehicleArea::GLOBAL, VehiclePropertyType::INT32);
1347 }
1348 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyCrossTrafficMonitoringEnabledConfig)1349 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyCrossTrafficMonitoringEnabledConfig) {
1350     verifyProperty(VehicleProperty::CROSS_TRAFFIC_MONITORING_ENABLED,
1351                    VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
1352                    VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
1353 }
1354 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyCrossTrafficMonitoringWarningStateConfig)1355 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyCrossTrafficMonitoringWarningStateConfig) {
1356     verifyProperty(VehicleProperty::CROSS_TRAFFIC_MONITORING_WARNING_STATE,
1357                    VehiclePropertyAccess::READ, VehiclePropertyChangeMode::ON_CHANGE,
1358                    VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::INT32);
1359 }
1360 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyHeadUpDisplayEnabledConfig)1361 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyHeadUpDisplayEnabledConfig) {
1362     verifyProperty(VehicleProperty::HEAD_UP_DISPLAY_ENABLED, VehiclePropertyAccess::READ_WRITE,
1363                    VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
1364                    VehicleArea::SEAT, VehiclePropertyType::BOOLEAN);
1365 }
1366 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyLowSpeedAutomaticEmergencyBrakingEnabledConfig)1367 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyLowSpeedAutomaticEmergencyBrakingEnabledConfig) {
1368     verifyProperty(VehicleProperty::LOW_SPEED_AUTOMATIC_EMERGENCY_BRAKING_ENABLED,
1369                    VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
1370                    VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
1371 }
1372 
TEST_P(VtsHalAutomotiveVehicleTargetTest,verifyLowSpeedAutomaticEmergencyBrakingStateConfig)1373 TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyLowSpeedAutomaticEmergencyBrakingStateConfig) {
1374     verifyProperty(VehicleProperty::LOW_SPEED_AUTOMATIC_EMERGENCY_BRAKING_STATE,
1375                    VehiclePropertyAccess::READ, VehiclePropertyChangeMode::ON_CHANGE,
1376                    VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::INT32);
1377 }
1378 
checkIsSupported(int32_t propertyId)1379 bool VtsHalAutomotiveVehicleTargetTest::checkIsSupported(int32_t propertyId) {
1380     auto result = mVhalClient->getPropConfigs({propertyId});
1381     return result.ok();
1382 }
1383 
getDescriptors()1384 std::vector<ServiceDescriptor> getDescriptors() {
1385     std::vector<ServiceDescriptor> descriptors;
1386     for (std::string name : getAidlHalInstanceNames(IVehicle::descriptor)) {
1387         descriptors.push_back({
1388                 .name = name,
1389                 .isAidlService = true,
1390         });
1391     }
1392     for (std::string name : getAllHalInstanceNames(
1393                  android::hardware::automotive::vehicle::V2_0::IVehicle::descriptor)) {
1394         descriptors.push_back({
1395                 .name = name,
1396                 .isAidlService = false,
1397         });
1398     }
1399     return descriptors;
1400 }
1401 
1402 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(VtsHalAutomotiveVehicleTargetTest);
1403 
1404 INSTANTIATE_TEST_SUITE_P(PerInstance, VtsHalAutomotiveVehicleTargetTest,
1405                          testing::ValuesIn(getDescriptors()),
__anon6b60a7330202(const testing::TestParamInfo<ServiceDescriptor>& info) 1406                          [](const testing::TestParamInfo<ServiceDescriptor>& info) {
1407                              std::string name = "";
1408                              if (info.param.isAidlService) {
1409                                  name += "aidl_";
1410                              } else {
1411                                  name += "hidl_";
1412                              }
1413                              name += info.param.name;
1414                              return Sanitize(name);
1415                          });
1416 
main(int argc,char ** argv)1417 int main(int argc, char** argv) {
1418     ::testing::InitGoogleTest(&argc, argv);
1419     ABinderProcess_setThreadPoolMaxThreadCount(1);
1420     return RUN_ALL_TESTS();
1421 }
1422