blob: 4747f9c259ab691ccafc7fa5d8832605103d5041 [file] [log] [blame]
Yu Shan726d51a2022-02-22 17:37:21 -08001/*
2 * Copyright (C) 2022 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#define LOG_TAG "VtsHalAutomotiveVehicle"
18
19#include <IVhalClient.h>
20#include <VehicleHalTypes.h>
21#include <VehicleUtils.h>
22#include <aidl/Gtest.h>
23#include <aidl/Vintf.h>
24#include <aidl/android/hardware/automotive/vehicle/IVehicle.h>
25#include <android-base/stringprintf.h>
26#include <android-base/thread_annotations.h>
27#include <android/binder_process.h>
28#include <gtest/gtest.h>
29#include <hidl/GtestPrinter.h>
30#include <hidl/ServiceManagement.h>
31#include <inttypes.h>
32#include <utils/Log.h>
Yu Shan4569ef52022-03-18 14:34:25 -070033#include <utils/SystemClock.h>
Yu Shan726d51a2022-02-22 17:37:21 -080034
35#include <chrono>
36#include <mutex>
Yu Shan1837df02024-01-24 16:14:21 -080037#include <thread>
Yu Shan726d51a2022-02-22 17:37:21 -080038#include <unordered_map>
39#include <unordered_set>
40#include <vector>
41
42using ::aidl::android::hardware::automotive::vehicle::IVehicle;
Yu Shan726d51a2022-02-22 17:37:21 -080043using ::aidl::android::hardware::automotive::vehicle::SubscribeOptions;
44using ::aidl::android::hardware::automotive::vehicle::VehicleArea;
45using ::aidl::android::hardware::automotive::vehicle::VehicleProperty;
46using ::aidl::android::hardware::automotive::vehicle::VehiclePropertyAccess;
Aaqib Ismail20486702022-10-27 16:58:50 -070047using ::aidl::android::hardware::automotive::vehicle::VehiclePropertyChangeMode;
48using ::aidl::android::hardware::automotive::vehicle::VehiclePropertyGroup;
Yu Shan1837df02024-01-24 16:14:21 -080049using ::aidl::android::hardware::automotive::vehicle::VehiclePropertyStatus;
Yu Shan726d51a2022-02-22 17:37:21 -080050using ::aidl::android::hardware::automotive::vehicle::VehiclePropertyType;
51using ::android::getAidlHalInstanceNames;
Yu Shan1837df02024-01-24 16:14:21 -080052using ::android::uptimeMillis;
Yu Shan726d51a2022-02-22 17:37:21 -080053using ::android::base::ScopedLockAssertion;
54using ::android::base::StringPrintf;
Chen Chengfaf9adc2022-06-22 23:09:09 +000055using ::android::frameworks::automotive::vhal::ErrorCode;
Yu Shan726d51a2022-02-22 17:37:21 -080056using ::android::frameworks::automotive::vhal::HalPropError;
57using ::android::frameworks::automotive::vhal::IHalPropConfig;
58using ::android::frameworks::automotive::vhal::IHalPropValue;
59using ::android::frameworks::automotive::vhal::ISubscriptionCallback;
60using ::android::frameworks::automotive::vhal::IVhalClient;
Yu Shan1837df02024-01-24 16:14:21 -080061using ::android::frameworks::automotive::vhal::VhalClientResult;
Yu Shan726d51a2022-02-22 17:37:21 -080062using ::android::hardware::getAllHalInstanceNames;
63using ::android::hardware::Sanitize;
64using ::android::hardware::automotive::vehicle::toInt;
65
66constexpr int32_t kInvalidProp = 0x31600207;
Yu Shan1837df02024-01-24 16:14:21 -080067// The timeout for retrying getting prop value after setting prop value.
68constexpr int64_t kRetryGetPropAfterSetPropTimeoutMillis = 10'000;
Yu Shan726d51a2022-02-22 17:37:21 -080069
70struct ServiceDescriptor {
71 std::string name;
72 bool isAidlService;
73};
74
75class VtsVehicleCallback final : public ISubscriptionCallback {
76 private:
77 std::mutex mLock;
78 std::unordered_map<int32_t, size_t> mEventsCount GUARDED_BY(mLock);
Yu Shan4569ef52022-03-18 14:34:25 -070079 std::unordered_map<int32_t, std::vector<int64_t>> mEventTimestamps GUARDED_BY(mLock);
Yu Shan726d51a2022-02-22 17:37:21 -080080 std::condition_variable mEventCond;
81
82 public:
83 void onPropertyEvent(const std::vector<std::unique_ptr<IHalPropValue>>& values) override {
84 {
85 std::lock_guard<std::mutex> lockGuard(mLock);
86 for (auto& value : values) {
Yu Shan4569ef52022-03-18 14:34:25 -070087 int32_t propId = value->getPropId();
88 mEventsCount[propId] += 1;
89 mEventTimestamps[propId].push_back(value->getTimestamp());
Yu Shan726d51a2022-02-22 17:37:21 -080090 }
91 }
92 mEventCond.notify_one();
93 }
94
95 void onPropertySetError([[maybe_unused]] const std::vector<HalPropError>& errors) override {
96 // Do nothing.
97 }
98
99 template <class Rep, class Period>
100 bool waitForExpectedEvents(int32_t propId, size_t expectedEvents,
101 const std::chrono::duration<Rep, Period>& timeout) {
102 std::unique_lock<std::mutex> uniqueLock(mLock);
103 return mEventCond.wait_for(uniqueLock, timeout, [this, propId, expectedEvents] {
104 ScopedLockAssertion lockAssertion(mLock);
105 return mEventsCount[propId] >= expectedEvents;
106 });
107 }
108
Yu Shan4569ef52022-03-18 14:34:25 -0700109 std::vector<int64_t> getEventTimestamps(int32_t propId) {
110 {
111 std::lock_guard<std::mutex> lockGuard(mLock);
112 return mEventTimestamps[propId];
113 }
114 }
115
Yu Shan726d51a2022-02-22 17:37:21 -0800116 void reset() {
117 std::lock_guard<std::mutex> lockGuard(mLock);
118 mEventsCount.clear();
119 }
120};
121
122class VtsHalAutomotiveVehicleTargetTest : public testing::TestWithParam<ServiceDescriptor> {
Yu Shan076976e2023-10-09 14:43:36 -0700123 protected:
124 bool checkIsSupported(int32_t propertyId);
Yu Shan1837df02024-01-24 16:14:21 -0800125 VehiclePropertyStatus getStatus(const IHalPropValue& halPropValue);
126 bool isUnavailable(const VhalClientResult<std::unique_ptr<IHalPropValue>>& result);
127 bool isResultOkayWithValue(const VhalClientResult<std::unique_ptr<IHalPropValue>>& result,
128 int32_t value);
Yu Shan076976e2023-10-09 14:43:36 -0700129
Yu Shan726d51a2022-02-22 17:37:21 -0800130 public:
Aaqib Ismail20486702022-10-27 16:58:50 -0700131 void verifyProperty(VehicleProperty propId, VehiclePropertyAccess access,
132 VehiclePropertyChangeMode changeMode, VehiclePropertyGroup group,
133 VehicleArea area, VehiclePropertyType propertyType);
Yu Shan726d51a2022-02-22 17:37:21 -0800134 virtual void SetUp() override {
135 auto descriptor = GetParam();
136 if (descriptor.isAidlService) {
137 mVhalClient = IVhalClient::tryCreateAidlClient(descriptor.name.c_str());
138 } else {
139 mVhalClient = IVhalClient::tryCreateHidlClient(descriptor.name.c_str());
140 }
141
142 ASSERT_NE(mVhalClient, nullptr) << "Failed to connect to VHAL";
143
144 mCallback = std::make_shared<VtsVehicleCallback>();
145 }
146
147 static bool isBooleanGlobalProp(int32_t property) {
148 return (property & toInt(VehiclePropertyType::MASK)) ==
149 toInt(VehiclePropertyType::BOOLEAN) &&
150 (property & toInt(VehicleArea::MASK)) == toInt(VehicleArea::GLOBAL);
151 }
152
153 protected:
154 std::shared_ptr<IVhalClient> mVhalClient;
155 std::shared_ptr<VtsVehicleCallback> mCallback;
156};
157
158TEST_P(VtsHalAutomotiveVehicleTargetTest, useAidlBackend) {
159 if (!mVhalClient->isAidlVhal()) {
160 GTEST_SKIP() << "AIDL backend is not available, HIDL backend is used instead";
161 }
162}
163
164TEST_P(VtsHalAutomotiveVehicleTargetTest, useHidlBackend) {
165 if (mVhalClient->isAidlVhal()) {
166 GTEST_SKIP() << "AIDL backend is available, HIDL backend is not used";
167 }
168}
169
Yu Shan076976e2023-10-09 14:43:36 -0700170// Test getAllPropConfigs() returns at least 1 property configs.
Yu Shan726d51a2022-02-22 17:37:21 -0800171TEST_P(VtsHalAutomotiveVehicleTargetTest, getAllPropConfigs) {
172 ALOGD("VtsHalAutomotiveVehicleTargetTest::getAllPropConfigs");
173
174 auto result = mVhalClient->getAllPropConfigs();
175
176 ASSERT_TRUE(result.ok()) << "Failed to get all property configs, error: "
177 << result.error().message();
Yu Shan076976e2023-10-09 14:43:36 -0700178 ASSERT_GE(result.value().size(), 1u)
179 << StringPrintf("Expect to get at least 1 property config, got %zu",
180 result.value().size());
Yu Shan726d51a2022-02-22 17:37:21 -0800181}
182
Yu Shan076976e2023-10-09 14:43:36 -0700183// Test getPropConfigs() can query properties returned by getAllPropConfigs.
184TEST_P(VtsHalAutomotiveVehicleTargetTest, getPropConfigsWithValidProps) {
Yu Shan726d51a2022-02-22 17:37:21 -0800185 ALOGD("VtsHalAutomotiveVehicleTargetTest::getRequiredPropConfigs");
186
Yu Shan076976e2023-10-09 14:43:36 -0700187 std::vector<int32_t> properties;
188 auto result = mVhalClient->getAllPropConfigs();
Yu Shan726d51a2022-02-22 17:37:21 -0800189
Yu Shan076976e2023-10-09 14:43:36 -0700190 ASSERT_TRUE(result.ok()) << "Failed to get all property configs, error: "
191 << result.error().message();
192 for (const auto& cfgPtr : result.value()) {
193 properties.push_back(cfgPtr->getPropId());
194 }
195
196 result = mVhalClient->getPropConfigs(properties);
Yu Shan726d51a2022-02-22 17:37:21 -0800197
198 ASSERT_TRUE(result.ok()) << "Failed to get required property config, error: "
199 << result.error().message();
Yu Shan076976e2023-10-09 14:43:36 -0700200 ASSERT_EQ(result.value().size(), properties.size())
201 << StringPrintf("Expect to get exactly %zu configs, got %zu",
202 properties.size(), result.value().size());
Yu Shan726d51a2022-02-22 17:37:21 -0800203}
204
205// Test getPropConfig() with an invalid propertyId returns an error code.
206TEST_P(VtsHalAutomotiveVehicleTargetTest, getPropConfigsWithInvalidProp) {
207 ALOGD("VtsHalAutomotiveVehicleTargetTest::getPropConfigsWithInvalidProp");
208
209 auto result = mVhalClient->getPropConfigs({kInvalidProp});
210
211 ASSERT_FALSE(result.ok()) << StringPrintf(
212 "Expect failure to get prop configs for invalid prop: %" PRId32, kInvalidProp);
213 ASSERT_NE(result.error().message(), "") << "Expect error message not to be empty";
214}
215
216// Test get() return current value for properties.
217TEST_P(VtsHalAutomotiveVehicleTargetTest, get) {
218 ALOGD("VtsHalAutomotiveVehicleTargetTest::get");
219
220 int32_t propId = toInt(VehicleProperty::PERF_VEHICLE_SPEED);
Yu Shan076976e2023-10-09 14:43:36 -0700221 if (!checkIsSupported(propId)) {
222 GTEST_SKIP() << "Property: " << propId << " is not supported, skip the test";
223 }
Yu Shan726d51a2022-02-22 17:37:21 -0800224 auto result = mVhalClient->getValueSync(*mVhalClient->createHalPropValue(propId));
225
226 ASSERT_TRUE(result.ok()) << StringPrintf("Failed to get value for property: %" PRId32
227 ", error: %s",
228 propId, result.error().message().c_str());
229 ASSERT_NE(result.value(), nullptr) << "Result value must not be null";
230}
231
232// Test get() with an invalid propertyId return an error codes.
233TEST_P(VtsHalAutomotiveVehicleTargetTest, getInvalidProp) {
234 ALOGD("VtsHalAutomotiveVehicleTargetTest::getInvalidProp");
235
236 auto result = mVhalClient->getValueSync(*mVhalClient->createHalPropValue(kInvalidProp));
237
238 ASSERT_FALSE(result.ok()) << StringPrintf(
239 "Expect failure to get property for invalid prop: %" PRId32, kInvalidProp);
240}
241
Yu Shan1837df02024-01-24 16:14:21 -0800242VehiclePropertyStatus VtsHalAutomotiveVehicleTargetTest::getStatus(
243 const IHalPropValue& halPropValue) {
244 if (mVhalClient->isAidlVhal()) {
245 return reinterpret_cast<
246 const aidl::android::hardware::automotive::vehicle::VehiclePropValue*>(
247 halPropValue.toVehiclePropValue())
248 ->status;
249 }
250 return static_cast<VehiclePropertyStatus>(
251 reinterpret_cast<const android::hardware::automotive::vehicle::V2_0::VehiclePropValue*>(
252 halPropValue.toVehiclePropValue())
253 ->status);
254}
255
256bool VtsHalAutomotiveVehicleTargetTest::isResultOkayWithValue(
257 const VhalClientResult<std::unique_ptr<IHalPropValue>>& result, int32_t value) {
258 return result.ok() && result.value() != nullptr &&
259 getStatus(*(result.value())) == VehiclePropertyStatus::AVAILABLE &&
260 result.value()->getInt32Values().size() == 1 &&
261 result.value()->getInt32Values()[0] == value;
262}
263
264bool VtsHalAutomotiveVehicleTargetTest::isUnavailable(
265 const VhalClientResult<std::unique_ptr<IHalPropValue>>& result) {
266 if (!result.ok()) {
267 return result.error().code() == ErrorCode::NOT_AVAILABLE_FROM_VHAL;
268 }
269 if (result.value() != nullptr &&
270 getStatus(*(result.value())) == VehiclePropertyStatus::UNAVAILABLE) {
271 return true;
272 }
273
274 return false;
275}
276
Yu Shan726d51a2022-02-22 17:37:21 -0800277// Test set() on read_write properties.
278TEST_P(VtsHalAutomotiveVehicleTargetTest, setProp) {
279 ALOGD("VtsHalAutomotiveVehicleTargetTest::setProp");
280
281 // skip hvac related properties
282 std::unordered_set<int32_t> hvacProps = {toInt(VehicleProperty::HVAC_DEFROSTER),
283 toInt(VehicleProperty::HVAC_AC_ON),
284 toInt(VehicleProperty::HVAC_MAX_AC_ON),
285 toInt(VehicleProperty::HVAC_MAX_DEFROST_ON),
286 toInt(VehicleProperty::HVAC_RECIRC_ON),
287 toInt(VehicleProperty::HVAC_DUAL_ON),
288 toInt(VehicleProperty::HVAC_AUTO_ON),
289 toInt(VehicleProperty::HVAC_POWER_ON),
290 toInt(VehicleProperty::HVAC_AUTO_RECIRC_ON),
291 toInt(VehicleProperty::HVAC_ELECTRIC_DEFROSTER_ON)};
292 auto result = mVhalClient->getAllPropConfigs();
293 ASSERT_TRUE(result.ok());
294
295 for (const auto& cfgPtr : result.value()) {
296 const IHalPropConfig& cfg = *cfgPtr;
297 int32_t propId = cfg.getPropId();
298 // test on boolean and writable property
299 if (cfg.getAccess() == toInt(VehiclePropertyAccess::READ_WRITE) &&
300 isBooleanGlobalProp(propId) && !hvacProps.count(propId)) {
301 auto propToGet = mVhalClient->createHalPropValue(propId);
302 auto getValueResult = mVhalClient->getValueSync(*propToGet);
303
Yu Shan1837df02024-01-24 16:14:21 -0800304 if (isUnavailable(getValueResult)) {
305 ALOGW("getProperty for %" PRId32
306 " returns NOT_AVAILABLE, "
307 "skip testing setProp",
308 propId);
309 return;
310 }
311
Yu Shan726d51a2022-02-22 17:37:21 -0800312 ASSERT_TRUE(getValueResult.ok())
313 << StringPrintf("Failed to get value for property: %" PRId32 ", error: %s",
314 propId, getValueResult.error().message().c_str());
315 ASSERT_NE(getValueResult.value(), nullptr)
316 << StringPrintf("Result value must not be null for property: %" PRId32, propId);
317
318 const IHalPropValue& value = *getValueResult.value();
319 size_t intValueSize = value.getInt32Values().size();
320 ASSERT_EQ(intValueSize, 1u) << StringPrintf(
321 "Expect exactly 1 int value for boolean property: %" PRId32 ", got %zu", propId,
322 intValueSize);
323
Yu Shan1837df02024-01-24 16:14:21 -0800324 int32_t setValue = value.getInt32Values()[0] == 1 ? 0 : 1;
Yu Shan726d51a2022-02-22 17:37:21 -0800325 auto propToSet = mVhalClient->createHalPropValue(propId);
326 propToSet->setInt32Values({setValue});
327 auto setValueResult = mVhalClient->setValueSync(*propToSet);
328
Yu Shan1837df02024-01-24 16:14:21 -0800329 if (!setValueResult.ok() &&
330 setValueResult.error().code() == ErrorCode::NOT_AVAILABLE_FROM_VHAL) {
331 ALOGW("setProperty for %" PRId32
332 " returns NOT_AVAILABLE, "
333 "skip verifying getProperty returns the same value",
334 propId);
335 return;
336 }
337
Yu Shan726d51a2022-02-22 17:37:21 -0800338 ASSERT_TRUE(setValueResult.ok())
339 << StringPrintf("Failed to set value for property: %" PRId32 ", error: %s",
340 propId, setValueResult.error().message().c_str());
Yu Shan1837df02024-01-24 16:14:21 -0800341 // Retry getting the value until we pass the timeout. getValue might not return
342 // the expected value immediately since setValue is async.
343 auto timeoutMillis = uptimeMillis() + kRetryGetPropAfterSetPropTimeoutMillis;
Yu Shan726d51a2022-02-22 17:37:21 -0800344
Yu Shan1837df02024-01-24 16:14:21 -0800345 while (true) {
346 getValueResult = mVhalClient->getValueSync(*propToGet);
347 if (isResultOkayWithValue(getValueResult, setValue)) {
348 break;
349 }
350 if (uptimeMillis() >= timeoutMillis) {
351 // Reach timeout, the following assert should fail.
352 break;
353 }
354 // Sleep for 100ms between each getValueSync retry.
355 std::this_thread::sleep_for(std::chrono::milliseconds(100));
356 }
357
358 if (isUnavailable(getValueResult)) {
359 ALOGW("getProperty for %" PRId32
360 " returns NOT_AVAILABLE, "
361 "skip verifying the return value",
362 propId);
363 return;
364 }
365
Yu Shan726d51a2022-02-22 17:37:21 -0800366 ASSERT_TRUE(getValueResult.ok())
367 << StringPrintf("Failed to get value for property: %" PRId32 ", error: %s",
368 propId, getValueResult.error().message().c_str());
369 ASSERT_NE(getValueResult.value(), nullptr)
370 << StringPrintf("Result value must not be null for property: %" PRId32, propId);
371 ASSERT_EQ(getValueResult.value()->getInt32Values(), std::vector<int32_t>({setValue}))
372 << StringPrintf("Boolean value not updated after set for property: %" PRId32,
373 propId);
374 }
375 }
376}
377
378// Test set() on an read_only property.
379TEST_P(VtsHalAutomotiveVehicleTargetTest, setNotWritableProp) {
380 ALOGD("VtsHalAutomotiveVehicleTargetTest::setNotWritableProp");
381
382 int32_t propId = toInt(VehicleProperty::PERF_VEHICLE_SPEED);
Yu Shan076976e2023-10-09 14:43:36 -0700383 if (!checkIsSupported(propId)) {
384 GTEST_SKIP() << "Property: " << propId << " is not supported, skip the test";
385 }
386
Yu Shan726d51a2022-02-22 17:37:21 -0800387 auto getValueResult = mVhalClient->getValueSync(*mVhalClient->createHalPropValue(propId));
388 ASSERT_TRUE(getValueResult.ok())
389 << StringPrintf("Failed to get value for property: %" PRId32 ", error: %s", propId,
390 getValueResult.error().message().c_str());
391
392 auto setValueResult = mVhalClient->setValueSync(*getValueResult.value());
393
394 ASSERT_FALSE(setValueResult.ok()) << "Expect set a read-only value to fail";
Chen Chengfaf9adc2022-06-22 23:09:09 +0000395 ASSERT_EQ(setValueResult.error().code(), ErrorCode::ACCESS_DENIED_FROM_VHAL);
Yu Shan726d51a2022-02-22 17:37:21 -0800396}
397
shrikar8a140232023-03-07 16:57:59 +0000398// Test get(), set() and getAllPropConfigs() on VehicleProperty::INVALID.
399TEST_P(VtsHalAutomotiveVehicleTargetTest, getSetPropertyIdInvalid) {
400 ALOGD("VtsHalAutomotiveVehicleTargetTest::getSetPropertyIdInvalid");
401
402 int32_t propId = toInt(VehicleProperty::INVALID);
403 auto getValueResult = mVhalClient->getValueSync(*mVhalClient->createHalPropValue(propId));
404 ASSERT_FALSE(getValueResult.ok()) << "Expect get on VehicleProperty::INVALID to fail";
405 ASSERT_EQ(getValueResult.error().code(), ErrorCode::INVALID_ARG);
406
407 auto propToSet = mVhalClient->createHalPropValue(propId);
408 propToSet->setInt32Values({0});
409 auto setValueResult = mVhalClient->setValueSync(*propToSet);
410 ASSERT_FALSE(setValueResult.ok()) << "Expect set on VehicleProperty::INVALID to fail";
411 ASSERT_EQ(setValueResult.error().code(), ErrorCode::INVALID_ARG);
412
413 auto result = mVhalClient->getAllPropConfigs();
414 ASSERT_TRUE(result.ok());
415 for (const auto& cfgPtr : result.value()) {
416 const IHalPropConfig& cfg = *cfgPtr;
417 ASSERT_FALSE(cfg.getPropId() == propId) << "Expect VehicleProperty::INVALID to not be "
418 "included in propConfigs";
419 }
420}
421
Yu Shan726d51a2022-02-22 17:37:21 -0800422// Test subscribe() and unsubscribe().
423TEST_P(VtsHalAutomotiveVehicleTargetTest, subscribeAndUnsubscribe) {
424 ALOGD("VtsHalAutomotiveVehicleTargetTest::subscribeAndUnsubscribe");
425
426 int32_t propId = toInt(VehicleProperty::PERF_VEHICLE_SPEED);
Yu Shan076976e2023-10-09 14:43:36 -0700427 if (!checkIsSupported(propId)) {
428 GTEST_SKIP() << "Property: " << propId << " is not supported, skip the test";
429 }
Yu Shan726d51a2022-02-22 17:37:21 -0800430
Yu Shan4569ef52022-03-18 14:34:25 -0700431 auto propConfigsResult = mVhalClient->getPropConfigs({propId});
432
433 ASSERT_TRUE(propConfigsResult.ok()) << "Failed to get property config for PERF_VEHICLE_SPEED: "
434 << "error: " << propConfigsResult.error().message();
435 ASSERT_EQ(propConfigsResult.value().size(), 1u)
436 << "Expect to return 1 config for PERF_VEHICLE_SPEED";
437 auto& propConfig = propConfigsResult.value()[0];
438 float minSampleRate = propConfig->getMinSampleRate();
439 float maxSampleRate = propConfig->getMaxSampleRate();
440
441 if (minSampleRate < 1) {
442 GTEST_SKIP() << "Sample rate for vehicle speed < 1 times/sec, skip test since it would "
443 "take too long";
444 }
Yu Shan726d51a2022-02-22 17:37:21 -0800445
446 auto client = mVhalClient->getSubscriptionClient(mCallback);
447 ASSERT_NE(client, nullptr) << "Failed to get subscription client";
448
Yu Shan4569ef52022-03-18 14:34:25 -0700449 auto result = client->subscribe({{.propId = propId, .sampleRate = minSampleRate}});
Yu Shan726d51a2022-02-22 17:37:21 -0800450
451 ASSERT_TRUE(result.ok()) << StringPrintf("Failed to subscribe to property: %" PRId32
452 ", error: %s",
453 propId, result.error().message().c_str());
Yu Shan4569ef52022-03-18 14:34:25 -0700454
455 if (mVhalClient->isAidlVhal()) {
456 // Skip checking timestamp for HIDL because the behavior for sample rate and timestamp is
457 // only specified clearly for AIDL.
458
459 // Timeout is 2 seconds, which gives a 1 second buffer.
460 ASSERT_TRUE(mCallback->waitForExpectedEvents(propId, std::floor(minSampleRate),
461 std::chrono::seconds(2)))
462 << "Didn't get enough events for subscribing to minSampleRate";
463 }
464
465 result = client->subscribe({{.propId = propId, .sampleRate = maxSampleRate}});
466
467 ASSERT_TRUE(result.ok()) << StringPrintf("Failed to subscribe to property: %" PRId32
468 ", error: %s",
469 propId, result.error().message().c_str());
470
471 if (mVhalClient->isAidlVhal()) {
472 ASSERT_TRUE(mCallback->waitForExpectedEvents(propId, std::floor(maxSampleRate),
473 std::chrono::seconds(2)))
474 << "Didn't get enough events for subscribing to maxSampleRate";
475
476 std::unordered_set<int64_t> timestamps;
477 // Event event should have a different timestamp.
478 for (const int64_t& eventTimestamp : mCallback->getEventTimestamps(propId)) {
479 ASSERT_TRUE(timestamps.find(eventTimestamp) == timestamps.end())
480 << "two events for the same property must not have the same timestamp";
481 timestamps.insert(eventTimestamp);
482 }
483 }
Yu Shan726d51a2022-02-22 17:37:21 -0800484
485 result = client->unsubscribe({propId});
486 ASSERT_TRUE(result.ok()) << StringPrintf("Failed to unsubscribe to property: %" PRId32
487 ", error: %s",
488 propId, result.error().message().c_str());
489
490 mCallback->reset();
491 ASSERT_FALSE(mCallback->waitForExpectedEvents(propId, 10, std::chrono::seconds(1)))
492 << "Expect not to get events after unsubscription";
493}
494
495// Test subscribe() with an invalid property.
496TEST_P(VtsHalAutomotiveVehicleTargetTest, subscribeInvalidProp) {
497 ALOGD("VtsHalAutomotiveVehicleTargetTest::subscribeInvalidProp");
498
499 std::vector<SubscribeOptions> options = {
500 SubscribeOptions{.propId = kInvalidProp, .sampleRate = 10.0}};
501
502 auto client = mVhalClient->getSubscriptionClient(mCallback);
503 ASSERT_NE(client, nullptr) << "Failed to get subscription client";
504
505 auto result = client->subscribe(options);
506
507 ASSERT_FALSE(result.ok()) << StringPrintf("Expect subscribing to property: %" PRId32 " to fail",
508 kInvalidProp);
509}
510
Yu Shan4569ef52022-03-18 14:34:25 -0700511// Test the timestamp returned in GetValues results is the timestamp when the value is retrieved.
512TEST_P(VtsHalAutomotiveVehicleTargetTest, testGetValuesTimestampAIDL) {
513 if (!mVhalClient->isAidlVhal()) {
514 GTEST_SKIP() << "Skip checking timestamp for HIDL because the behavior is only specified "
515 "for AIDL";
516 }
517
518 int32_t propId = toInt(VehicleProperty::PARKING_BRAKE_ON);
Yu Shan076976e2023-10-09 14:43:36 -0700519 if (!checkIsSupported(propId)) {
520 GTEST_SKIP() << "Property: " << propId << " is not supported, skip the test";
521 }
Yu Shan4569ef52022-03-18 14:34:25 -0700522 auto prop = mVhalClient->createHalPropValue(propId);
523
524 auto result = mVhalClient->getValueSync(*prop);
525
526 ASSERT_TRUE(result.ok()) << StringPrintf("Failed to get value for property: %" PRId32
527 ", error: %s",
528 propId, result.error().message().c_str());
529 ASSERT_NE(result.value(), nullptr) << "Result value must not be null";
530 ASSERT_EQ(result.value()->getInt32Values().size(), 1u) << "Result must contain 1 int value";
531
532 bool parkBrakeOnValue1 = (result.value()->getInt32Values()[0] == 1);
533 int64_t timestampValue1 = result.value()->getTimestamp();
534
535 result = mVhalClient->getValueSync(*prop);
536
537 ASSERT_TRUE(result.ok()) << StringPrintf("Failed to get value for property: %" PRId32
538 ", error: %s",
539 propId, result.error().message().c_str());
540 ASSERT_NE(result.value(), nullptr) << "Result value must not be null";
541 ASSERT_EQ(result.value()->getInt32Values().size(), 1u) << "Result must contain 1 int value";
542
543 bool parkBarkeOnValue2 = (result.value()->getInt32Values()[0] == 1);
544 int64_t timestampValue2 = result.value()->getTimestamp();
545
546 if (parkBarkeOnValue2 == parkBrakeOnValue1) {
547 ASSERT_EQ(timestampValue2, timestampValue1)
548 << "getValue result must contain a timestamp updated when the value was updated, if"
549 "the value does not change, expect the same timestamp";
550 } else {
551 ASSERT_GT(timestampValue2, timestampValue1)
552 << "getValue result must contain a timestamp updated when the value was updated, if"
553 "the value changes, expect the newer value has a larger timestamp";
554 }
555}
556
Aaqib Ismail20486702022-10-27 16:58:50 -0700557// Helper function to compare actual vs expected property config
558void VtsHalAutomotiveVehicleTargetTest::verifyProperty(VehicleProperty propId,
559 VehiclePropertyAccess access,
560 VehiclePropertyChangeMode changeMode,
561 VehiclePropertyGroup group, VehicleArea area,
562 VehiclePropertyType propertyType) {
563 int expectedPropId = toInt(propId);
564 int expectedAccess = toInt(access);
565 int expectedChangeMode = toInt(changeMode);
566 int expectedGroup = toInt(group);
567 int expectedArea = toInt(area);
568 int expectedPropertyType = toInt(propertyType);
569
Eva Chen17bc5782023-01-06 22:59:58 -0800570 auto result = mVhalClient->getAllPropConfigs();
571 ASSERT_TRUE(result.ok()) << "Failed to get all property configs, error: "
572 << result.error().message();
573
574 // Check if property is implemented by getting all configs and looking to see if the expected
575 // property id is in that list.
576 bool isExpectedPropIdImplemented = false;
577 for (const auto& cfgPtr : result.value()) {
578 const IHalPropConfig& cfg = *cfgPtr;
579 if (expectedPropId == cfg.getPropId()) {
580 isExpectedPropIdImplemented = true;
581 break;
582 }
583 }
584
585 if (!isExpectedPropIdImplemented) {
586 GTEST_SKIP() << StringPrintf("Property %" PRId32 " has not been implemented",
587 expectedPropId);
588 }
589
590 result = mVhalClient->getPropConfigs({expectedPropId});
Aaqib Ismail20486702022-10-27 16:58:50 -0700591 ASSERT_TRUE(result.ok()) << "Failed to get required property config, error: "
592 << result.error().message();
593
Aaqib Ismail20486702022-10-27 16:58:50 -0700594 ASSERT_EQ(result.value().size(), 1u)
595 << StringPrintf("Expect to get exactly 1 config, got %zu", result.value().size());
596
597 const auto& config = result.value().at(0);
598 int actualPropId = config->getPropId();
599 int actualAccess = config->getAccess();
600 int actualChangeMode = config->getChangeMode();
601 int actualGroup = actualPropId & toInt(VehiclePropertyGroup::MASK);
602 int actualArea = actualPropId & toInt(VehicleArea::MASK);
603 int actualPropertyType = actualPropId & toInt(VehiclePropertyType::MASK);
604
605 ASSERT_EQ(actualPropId, expectedPropId)
606 << StringPrintf("Expect to get property ID: %i, got %i", expectedPropId, actualPropId);
607
608 if (expectedAccess == toInt(VehiclePropertyAccess::READ_WRITE)) {
609 ASSERT_TRUE(actualAccess == expectedAccess ||
610 actualAccess == toInt(VehiclePropertyAccess::READ))
611 << StringPrintf("Expect to get VehiclePropertyAccess: %i or %i, got %i",
612 expectedAccess, toInt(VehiclePropertyAccess::READ), actualAccess);
613 } else {
614 ASSERT_EQ(actualAccess, expectedAccess) << StringPrintf(
615 "Expect to get VehiclePropertyAccess: %i, got %i", expectedAccess, actualAccess);
616 }
617
618 ASSERT_EQ(actualChangeMode, expectedChangeMode)
619 << StringPrintf("Expect to get VehiclePropertyChangeMode: %i, got %i",
620 expectedChangeMode, actualChangeMode);
621 ASSERT_EQ(actualGroup, expectedGroup) << StringPrintf(
622 "Expect to get VehiclePropertyGroup: %i, got %i", expectedGroup, actualGroup);
623 ASSERT_EQ(actualArea, expectedArea)
624 << StringPrintf("Expect to get VehicleArea: %i, got %i", expectedArea, actualArea);
625 ASSERT_EQ(actualPropertyType, expectedPropertyType)
626 << StringPrintf("Expect to get VehiclePropertyType: %i, got %i", expectedPropertyType,
627 actualPropertyType);
628}
629
shrikar34563642023-02-14 02:57:17 +0000630TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyLocationCharacterizationConfig) {
631 verifyProperty(VehicleProperty::LOCATION_CHARACTERIZATION, VehiclePropertyAccess::READ,
632 VehiclePropertyChangeMode::STATIC, VehiclePropertyGroup::SYSTEM,
633 VehicleArea::GLOBAL, VehiclePropertyType::INT32);
634}
635
shrikar668df362022-12-20 22:08:17 +0000636TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyEmergencyLaneKeepAssistEnabledConfig) {
637 verifyProperty(VehicleProperty::EMERGENCY_LANE_KEEP_ASSIST_ENABLED,
638 VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
639 VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
640}
641
shrikar80cc0c52023-01-30 16:56:53 +0000642TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyEmergencyLaneKeepAssistStateConfig) {
643 verifyProperty(VehicleProperty::EMERGENCY_LANE_KEEP_ASSIST_STATE, VehiclePropertyAccess::READ,
644 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
645 VehicleArea::GLOBAL, VehiclePropertyType::INT32);
646}
647
shrikar5d1b8162023-01-25 19:31:23 +0000648TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyCruiseControlEnabledConfig) {
649 verifyProperty(VehicleProperty::CRUISE_CONTROL_ENABLED, VehiclePropertyAccess::READ_WRITE,
650 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
651 VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
shrikar808a2942022-12-21 17:07:32 +0000652}
653
shrikard440ed42023-01-31 00:25:14 +0000654TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyCruiseControlTypeConfig) {
655 verifyProperty(VehicleProperty::CRUISE_CONTROL_TYPE, VehiclePropertyAccess::READ_WRITE,
656 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
657 VehicleArea::GLOBAL, VehiclePropertyType::INT32);
658}
659
shrikar2753b9e2023-01-31 00:25:14 +0000660TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyCruiseControlStateConfig) {
661 verifyProperty(VehicleProperty::CRUISE_CONTROL_STATE, VehiclePropertyAccess::READ,
662 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
663 VehicleArea::GLOBAL, VehiclePropertyType::INT32);
664}
665
shrikar5df0f952023-02-02 00:15:39 +0000666TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyCruiseControlCommandConfig) {
667 verifyProperty(VehicleProperty::CRUISE_CONTROL_COMMAND, VehiclePropertyAccess::WRITE,
668 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
669 VehicleArea::GLOBAL, VehiclePropertyType::INT32);
670}
671
shrikarfde8c242023-02-02 01:10:33 +0000672TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyCruiseControlTargetSpeedConfig) {
673 verifyProperty(VehicleProperty::CRUISE_CONTROL_TARGET_SPEED, VehiclePropertyAccess::READ,
674 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
675 VehicleArea::GLOBAL, VehiclePropertyType::FLOAT);
676}
677
shrikarb9661d32023-02-02 19:22:50 +0000678TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyAdaptiveCruiseControlTargetTimeGapConfig) {
679 verifyProperty(VehicleProperty::ADAPTIVE_CRUISE_CONTROL_TARGET_TIME_GAP,
680 VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
681 VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::INT32);
682}
683
shrikarf62d7472023-02-03 00:20:04 +0000684TEST_P(VtsHalAutomotiveVehicleTargetTest,
685 verifyAdaptiveCruiseControlLeadVehicleMeasuredDistanceConfig) {
686 verifyProperty(VehicleProperty::ADAPTIVE_CRUISE_CONTROL_LEAD_VEHICLE_MEASURED_DISTANCE,
687 VehiclePropertyAccess::READ, VehiclePropertyChangeMode::CONTINUOUS,
688 VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::INT32);
689}
690
shrikar37833e12022-12-15 20:13:14 +0000691TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyHandsOnDetectionEnabledConfig) {
692 verifyProperty(VehicleProperty::HANDS_ON_DETECTION_ENABLED, VehiclePropertyAccess::READ_WRITE,
693 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
694 VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
695}
696
shrikar6d88bf52023-01-17 17:04:21 +0000697TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyHandsOnDetectionDriverStateConfig) {
698 verifyProperty(VehicleProperty::HANDS_ON_DETECTION_DRIVER_STATE, VehiclePropertyAccess::READ,
699 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
700 VehicleArea::GLOBAL, VehiclePropertyType::INT32);
701}
702
shrikara6785992023-01-18 23:07:06 +0000703TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyHandsOnDetectionWarningConfig) {
704 verifyProperty(VehicleProperty::HANDS_ON_DETECTION_WARNING, VehiclePropertyAccess::READ,
705 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
706 VehicleArea::GLOBAL, VehiclePropertyType::INT32);
707}
708
Aaqib Ismailc69e9682022-11-22 12:50:00 -0800709TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyEvBrakeRegenerationLevelConfig) {
710 verifyProperty(VehicleProperty::EV_BRAKE_REGENERATION_LEVEL,
711 VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
712 VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::INT32);
713}
714
shrikar2dae80f2022-12-21 23:50:17 +0000715TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyEvStoppingModeConfig) {
716 verifyProperty(VehicleProperty::EV_STOPPING_MODE, VehiclePropertyAccess::READ_WRITE,
717 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
718 VehicleArea::GLOBAL, VehiclePropertyType::INT32);
719}
720
Aaqib Ismailaec678a2022-12-07 16:22:42 -0800721TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyEvCurrentBatteryCapacityConfig) {
722 verifyProperty(VehicleProperty::EV_CURRENT_BATTERY_CAPACITY, VehiclePropertyAccess::READ,
723 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
724 VehicleArea::GLOBAL, VehiclePropertyType::FLOAT);
725}
726
shrikar83914472022-12-16 20:28:47 +0000727TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyEngineIdleAutoStopEnabledConfig) {
728 verifyProperty(VehicleProperty::ENGINE_IDLE_AUTO_STOP_ENABLED,
729 VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
730 VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
731}
732
Aaqib Ismail20486702022-10-27 16:58:50 -0700733TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyDoorChildLockEnabledConfig) {
734 verifyProperty(VehicleProperty::DOOR_CHILD_LOCK_ENABLED, VehiclePropertyAccess::READ_WRITE,
735 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
736 VehicleArea::DOOR, VehiclePropertyType::BOOLEAN);
737}
738
Aaqib Ismail63d52d12023-01-30 12:35:10 -0800739TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyWindshieldWipersPeriodConfig) {
740 verifyProperty(VehicleProperty::WINDSHIELD_WIPERS_PERIOD, VehiclePropertyAccess::READ,
741 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
742 VehicleArea::WINDOW, VehiclePropertyType::INT32);
743}
744
Aaqib Ismail732a1d72023-01-31 10:25:45 -0800745TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyWindshieldWipersStateConfig) {
746 verifyProperty(VehicleProperty::WINDSHIELD_WIPERS_STATE, VehiclePropertyAccess::READ,
747 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
748 VehicleArea::WINDOW, VehiclePropertyType::INT32);
749}
750
Aaqib Ismailc37a2112023-02-02 11:30:08 -0800751TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyWindshieldWipersSwitchConfig) {
752 verifyProperty(VehicleProperty::WINDSHIELD_WIPERS_SWITCH, VehiclePropertyAccess::READ_WRITE,
753 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
754 VehicleArea::WINDOW, VehiclePropertyType::INT32);
755}
756
Aaqib Ismail7f941b42022-11-04 14:55:13 -0700757TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySteeringWheelDepthPosConfig) {
758 verifyProperty(VehicleProperty::STEERING_WHEEL_DEPTH_POS, VehiclePropertyAccess::READ_WRITE,
759 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
760 VehicleArea::GLOBAL, VehiclePropertyType::INT32);
761}
762
Aaqib Ismail34fe92f2022-11-04 21:41:23 -0700763TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySteeringWheelDepthMoveConfig) {
764 verifyProperty(VehicleProperty::STEERING_WHEEL_DEPTH_MOVE, VehiclePropertyAccess::READ_WRITE,
765 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
766 VehicleArea::GLOBAL, VehiclePropertyType::INT32);
767}
768
Aaqib Ismail53b81c92022-11-07 17:47:04 -0800769TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySteeringWheelHeightPosConfig) {
770 verifyProperty(VehicleProperty::STEERING_WHEEL_HEIGHT_POS, VehiclePropertyAccess::READ_WRITE,
771 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
772 VehicleArea::GLOBAL, VehiclePropertyType::INT32);
773}
774
Aaqib Ismail6c4bf192022-11-08 15:00:32 -0800775TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySteeringWheelHeightMoveConfig) {
776 verifyProperty(VehicleProperty::STEERING_WHEEL_HEIGHT_MOVE, VehiclePropertyAccess::READ_WRITE,
777 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
778 VehicleArea::GLOBAL, VehiclePropertyType::INT32);
779}
780
Aaqib Ismail8d051182022-11-09 13:28:48 -0800781TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySteeringWheelTheftLockEnabledConfig) {
782 verifyProperty(VehicleProperty::STEERING_WHEEL_THEFT_LOCK_ENABLED,
783 VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
784 VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
785}
786
Aaqib Ismail68d3f122022-11-09 14:43:32 -0800787TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySteeringWheelLockedConfig) {
788 verifyProperty(VehicleProperty::STEERING_WHEEL_LOCKED, VehiclePropertyAccess::READ_WRITE,
789 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
790 VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
791}
792
Aaqib Ismaild4d6adf2022-11-09 16:59:47 -0800793TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySteeringWheelEasyAccessEnabledConfig) {
794 verifyProperty(VehicleProperty::STEERING_WHEEL_EASY_ACCESS_ENABLED,
795 VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
796 VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
797}
798
Aaqib Ismail0dc7ba02022-11-10 14:28:09 -0800799TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySteeringWheelLightsStateConfig) {
800 verifyProperty(VehicleProperty::STEERING_WHEEL_LIGHTS_STATE, VehiclePropertyAccess::READ,
801 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
802 VehicleArea::GLOBAL, VehiclePropertyType::INT32);
803}
804
Aaqib Ismail4b8688f2022-11-15 15:13:35 -0800805TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySteeringWheelLightsSwitchConfig) {
806 verifyProperty(VehicleProperty::STEERING_WHEEL_LIGHTS_SWITCH, VehiclePropertyAccess::READ_WRITE,
807 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
808 VehicleArea::GLOBAL, VehiclePropertyType::INT32);
809}
810
Arati Gerdesd86c7fd2022-12-19 12:32:29 -0800811TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyGloveBoxDoorPosConfig) {
812 verifyProperty(VehicleProperty::GLOVE_BOX_DOOR_POS, VehiclePropertyAccess::READ_WRITE,
813 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
814 VehicleArea::SEAT, VehiclePropertyType::INT32);
815}
816
Aaqib Ismail57be4032023-02-02 14:15:03 -0800817TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyGloveBoxLockedConfig) {
818 verifyProperty(VehicleProperty::GLOVE_BOX_LOCKED, VehiclePropertyAccess::READ_WRITE,
819 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
820 VehicleArea::SEAT, VehiclePropertyType::BOOLEAN);
821}
822
shrikara1367212022-11-02 16:07:35 +0000823TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyMirrorAutoFoldEnabledConfig) {
824 verifyProperty(VehicleProperty::MIRROR_AUTO_FOLD_ENABLED, VehiclePropertyAccess::READ_WRITE,
825 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
826 VehicleArea::MIRROR, VehiclePropertyType::BOOLEAN);
827}
828
829TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyMirrorAutoTiltEnabledConfig) {
830 verifyProperty(VehicleProperty::MIRROR_AUTO_TILT_ENABLED, VehiclePropertyAccess::READ_WRITE,
831 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
832 VehicleArea::MIRROR, VehiclePropertyType::BOOLEAN);
833}
834
Aaqib Ismail4e6144c2022-12-15 15:32:18 -0800835TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySeatHeadrestHeightPosV2Config) {
836 verifyProperty(VehicleProperty::SEAT_HEADREST_HEIGHT_POS_V2, VehiclePropertyAccess::READ_WRITE,
837 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
838 VehicleArea::SEAT, VehiclePropertyType::INT32);
839}
840
shrikar6ae79162022-12-16 03:03:25 +0000841TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySeatWalkInPosConfig) {
842 verifyProperty(VehicleProperty::SEAT_WALK_IN_POS, VehiclePropertyAccess::READ_WRITE,
843 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
844 VehicleArea::SEAT, VehiclePropertyType::INT32);
845}
846
shrikarfb65ae52022-11-03 23:12:51 +0000847TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySeatFootwellLightsStateConfig) {
848 verifyProperty(VehicleProperty::SEAT_FOOTWELL_LIGHTS_STATE, VehiclePropertyAccess::READ,
849 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
850 VehicleArea::SEAT, VehiclePropertyType::INT32);
851}
852
shrikar93cf1be2022-11-30 15:00:52 -0800853TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySeatFootwellLightsSwitchConfig) {
854 verifyProperty(VehicleProperty::SEAT_FOOTWELL_LIGHTS_SWITCH, VehiclePropertyAccess::READ_WRITE,
855 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
856 VehicleArea::SEAT, VehiclePropertyType::INT32);
857}
858
shrikar3326de02022-11-07 23:51:20 +0000859TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySeatEasyAccessEnabledConfig) {
860 verifyProperty(VehicleProperty::SEAT_EASY_ACCESS_ENABLED, VehiclePropertyAccess::READ_WRITE,
861 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
862 VehicleArea::SEAT, VehiclePropertyType::BOOLEAN);
863}
864
shrikarb96e3762022-11-08 16:49:58 -0800865TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySeatAirbagEnabledConfig) {
866 verifyProperty(VehicleProperty::SEAT_AIRBAG_ENABLED, VehiclePropertyAccess::READ_WRITE,
867 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
868 VehicleArea::SEAT, VehiclePropertyType::BOOLEAN);
869}
870
shrikar802ecb52022-11-09 18:27:06 +0000871TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySeatCushionSideSupportPosConfig) {
872 verifyProperty(VehicleProperty::SEAT_CUSHION_SIDE_SUPPORT_POS,
873 VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
874 VehiclePropertyGroup::SYSTEM, VehicleArea::SEAT, VehiclePropertyType::INT32);
875}
876
shrikar1f0ce0d2022-11-11 17:46:06 +0000877TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySeatCushionSideSupportMoveConfig) {
878 verifyProperty(VehicleProperty::SEAT_CUSHION_SIDE_SUPPORT_MOVE,
879 VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
880 VehiclePropertyGroup::SYSTEM, VehicleArea::SEAT, VehiclePropertyType::INT32);
881}
882
shrikareff71b22022-11-11 11:02:43 -0800883TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySeatLumbarVerticalPosConfig) {
884 verifyProperty(VehicleProperty::SEAT_LUMBAR_VERTICAL_POS, VehiclePropertyAccess::READ_WRITE,
885 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
886 VehicleArea::SEAT, VehiclePropertyType::INT32);
887}
888
shrikar2a081c52022-11-11 16:49:58 -0800889TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySeatLumbarVerticalMoveConfig) {
890 verifyProperty(VehicleProperty::SEAT_LUMBAR_VERTICAL_MOVE, VehiclePropertyAccess::READ_WRITE,
891 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
892 VehicleArea::SEAT, VehiclePropertyType::INT32);
893}
894
Aaqib Ismail5d53aa32022-12-13 22:30:23 +0000895TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyAutomaticEmergencyBrakingEnabledConfig) {
896 verifyProperty(VehicleProperty::AUTOMATIC_EMERGENCY_BRAKING_ENABLED,
897 VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
898 VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
899}
900
Aaqib Ismail28ee23c2023-01-04 23:04:46 -0800901TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyAutomaticEmergencyBrakingStateConfig) {
902 verifyProperty(VehicleProperty::AUTOMATIC_EMERGENCY_BRAKING_STATE, VehiclePropertyAccess::READ,
903 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
904 VehicleArea::GLOBAL, VehiclePropertyType::INT32);
905}
906
Aaqib Ismaila2513672022-12-15 00:55:27 +0000907TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyForwardCollisionWarningEnabledConfig) {
908 verifyProperty(VehicleProperty::FORWARD_COLLISION_WARNING_ENABLED,
909 VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
910 VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
911}
912
Aaqib Ismail0a1ab292023-01-19 21:33:56 +0000913TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyForwardCollisionWarningStateConfig) {
914 verifyProperty(VehicleProperty::FORWARD_COLLISION_WARNING_STATE, VehiclePropertyAccess::READ,
915 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
916 VehicleArea::GLOBAL, VehiclePropertyType::INT32);
917}
918
Aaqib Ismail3f7177a2022-12-17 09:20:00 -0800919TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyBlindSpotWarningEnabledConfig) {
920 verifyProperty(VehicleProperty::BLIND_SPOT_WARNING_ENABLED, VehiclePropertyAccess::READ_WRITE,
921 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
922 VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
923}
924
Aaqib Ismail5fc97bb2023-01-10 17:07:47 -0800925TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyBlindSpotWarningStateConfig) {
926 verifyProperty(VehicleProperty::BLIND_SPOT_WARNING_STATE, VehiclePropertyAccess::READ,
927 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
928 VehicleArea::MIRROR, VehiclePropertyType::INT32);
929}
930
Aaqib Ismail7a46cef2022-12-17 10:00:59 -0800931TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyLaneDepartureWarningEnabledConfig) {
932 verifyProperty(VehicleProperty::LANE_DEPARTURE_WARNING_ENABLED,
933 VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
934 VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
935}
936
Aaqib Ismail8462db52023-01-27 19:59:49 -0800937TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyLaneDepartureWarningStateConfig) {
938 verifyProperty(VehicleProperty::LANE_DEPARTURE_WARNING_STATE, VehiclePropertyAccess::READ,
939 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
940 VehicleArea::GLOBAL, VehiclePropertyType::INT32);
941}
942
Aaqib Ismail20cc66a2022-12-22 05:38:28 -0800943TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyLaneKeepAssistEnabledConfig) {
944 verifyProperty(VehicleProperty::LANE_KEEP_ASSIST_ENABLED, VehiclePropertyAccess::READ_WRITE,
945 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
946 VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
947}
948
Aaqib Ismail78db2ca2023-01-10 17:34:28 -0800949TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyLaneKeepAssistStateConfig) {
950 verifyProperty(VehicleProperty::LANE_KEEP_ASSIST_STATE, VehiclePropertyAccess::READ,
951 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
952 VehicleArea::GLOBAL, VehiclePropertyType::INT32);
953}
954
Aaqib Ismailb1680a72022-12-14 23:28:49 +0000955TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyLaneCenteringAssistEnabledConfig) {
956 verifyProperty(VehicleProperty::LANE_CENTERING_ASSIST_ENABLED,
957 VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
958 VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
959}
960
Aaqib Ismail0ffd39c2023-01-11 12:19:10 -0800961TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyLaneCenteringAssistCommandConfig) {
962 verifyProperty(VehicleProperty::LANE_CENTERING_ASSIST_COMMAND, VehiclePropertyAccess::WRITE,
963 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
964 VehicleArea::GLOBAL, VehiclePropertyType::INT32);
965}
966
Aaqib Ismaildb034442023-01-10 18:14:28 -0800967TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyLaneCenteringAssistStateConfig) {
968 verifyProperty(VehicleProperty::LANE_CENTERING_ASSIST_STATE, VehiclePropertyAccess::READ,
969 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
970 VehicleArea::GLOBAL, VehiclePropertyType::INT32);
971}
972
Yu Shan076976e2023-10-09 14:43:36 -0700973bool VtsHalAutomotiveVehicleTargetTest::checkIsSupported(int32_t propertyId) {
974 auto result = mVhalClient->getPropConfigs({propertyId});
975 return result.ok();
976}
977
Yu Shan726d51a2022-02-22 17:37:21 -0800978std::vector<ServiceDescriptor> getDescriptors() {
979 std::vector<ServiceDescriptor> descriptors;
980 for (std::string name : getAidlHalInstanceNames(IVehicle::descriptor)) {
981 descriptors.push_back({
982 .name = name,
983 .isAidlService = true,
984 });
985 }
986 for (std::string name : getAllHalInstanceNames(IVehicle::descriptor)) {
987 descriptors.push_back({
988 .name = name,
989 .isAidlService = false,
990 });
991 }
992 return descriptors;
993}
994
995GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(VtsHalAutomotiveVehicleTargetTest);
996
997INSTANTIATE_TEST_SUITE_P(PerInstance, VtsHalAutomotiveVehicleTargetTest,
998 testing::ValuesIn(getDescriptors()),
999 [](const testing::TestParamInfo<ServiceDescriptor>& info) {
1000 std::string name = "";
1001 if (info.param.isAidlService) {
1002 name += "aidl_";
1003 } else {
1004 name += "hidl_";
1005 }
1006 name += info.param.name;
1007 return Sanitize(name);
1008 });
1009
1010int main(int argc, char** argv) {
1011 ::testing::InitGoogleTest(&argc, argv);
1012 ABinderProcess_setThreadPoolMaxThreadCount(1);
1013 return RUN_ALL_TESTS();
1014}