blob: 01fc1de3db25b24b9b7126163ce24d46172c07a2 [file] [log] [blame]
Yu Shan726d51a2022-02-22 17:37:21 -08001/*
2 * Copyright (C) 2022 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#define LOG_TAG "VtsHalAutomotiveVehicle"
18
19#include <IVhalClient.h>
20#include <VehicleHalTypes.h>
21#include <VehicleUtils.h>
22#include <aidl/Gtest.h>
23#include <aidl/Vintf.h>
24#include <aidl/android/hardware/automotive/vehicle/IVehicle.h>
25#include <android-base/stringprintf.h>
26#include <android-base/thread_annotations.h>
27#include <android/binder_process.h>
28#include <gtest/gtest.h>
29#include <hidl/GtestPrinter.h>
30#include <hidl/ServiceManagement.h>
31#include <inttypes.h>
32#include <utils/Log.h>
Yu Shan4569ef52022-03-18 14:34:25 -070033#include <utils/SystemClock.h>
Yu Shan726d51a2022-02-22 17:37:21 -080034
35#include <chrono>
36#include <mutex>
37#include <unordered_map>
38#include <unordered_set>
39#include <vector>
40
41using ::aidl::android::hardware::automotive::vehicle::IVehicle;
42using ::aidl::android::hardware::automotive::vehicle::StatusCode;
43using ::aidl::android::hardware::automotive::vehicle::SubscribeOptions;
44using ::aidl::android::hardware::automotive::vehicle::VehicleArea;
45using ::aidl::android::hardware::automotive::vehicle::VehicleProperty;
46using ::aidl::android::hardware::automotive::vehicle::VehiclePropertyAccess;
Aaqib Ismail20486702022-10-27 16:58:50 -070047using ::aidl::android::hardware::automotive::vehicle::VehiclePropertyChangeMode;
48using ::aidl::android::hardware::automotive::vehicle::VehiclePropertyGroup;
Yu Shan726d51a2022-02-22 17:37:21 -080049using ::aidl::android::hardware::automotive::vehicle::VehiclePropertyType;
50using ::android::getAidlHalInstanceNames;
51using ::android::base::ScopedLockAssertion;
52using ::android::base::StringPrintf;
Chen Chengfaf9adc2022-06-22 23:09:09 +000053using ::android::frameworks::automotive::vhal::ErrorCode;
Yu Shan726d51a2022-02-22 17:37:21 -080054using ::android::frameworks::automotive::vhal::HalPropError;
55using ::android::frameworks::automotive::vhal::IHalPropConfig;
56using ::android::frameworks::automotive::vhal::IHalPropValue;
57using ::android::frameworks::automotive::vhal::ISubscriptionCallback;
58using ::android::frameworks::automotive::vhal::IVhalClient;
59using ::android::hardware::getAllHalInstanceNames;
60using ::android::hardware::Sanitize;
61using ::android::hardware::automotive::vehicle::toInt;
62
63constexpr int32_t kInvalidProp = 0x31600207;
64
65struct ServiceDescriptor {
66 std::string name;
67 bool isAidlService;
68};
69
70class VtsVehicleCallback final : public ISubscriptionCallback {
71 private:
72 std::mutex mLock;
73 std::unordered_map<int32_t, size_t> mEventsCount GUARDED_BY(mLock);
Yu Shan4569ef52022-03-18 14:34:25 -070074 std::unordered_map<int32_t, std::vector<int64_t>> mEventTimestamps GUARDED_BY(mLock);
Yu Shan726d51a2022-02-22 17:37:21 -080075 std::condition_variable mEventCond;
76
77 public:
78 void onPropertyEvent(const std::vector<std::unique_ptr<IHalPropValue>>& values) override {
79 {
80 std::lock_guard<std::mutex> lockGuard(mLock);
81 for (auto& value : values) {
Yu Shan4569ef52022-03-18 14:34:25 -070082 int32_t propId = value->getPropId();
83 mEventsCount[propId] += 1;
84 mEventTimestamps[propId].push_back(value->getTimestamp());
Yu Shan726d51a2022-02-22 17:37:21 -080085 }
86 }
87 mEventCond.notify_one();
88 }
89
90 void onPropertySetError([[maybe_unused]] const std::vector<HalPropError>& errors) override {
91 // Do nothing.
92 }
93
94 template <class Rep, class Period>
95 bool waitForExpectedEvents(int32_t propId, size_t expectedEvents,
96 const std::chrono::duration<Rep, Period>& timeout) {
97 std::unique_lock<std::mutex> uniqueLock(mLock);
98 return mEventCond.wait_for(uniqueLock, timeout, [this, propId, expectedEvents] {
99 ScopedLockAssertion lockAssertion(mLock);
100 return mEventsCount[propId] >= expectedEvents;
101 });
102 }
103
Yu Shan4569ef52022-03-18 14:34:25 -0700104 std::vector<int64_t> getEventTimestamps(int32_t propId) {
105 {
106 std::lock_guard<std::mutex> lockGuard(mLock);
107 return mEventTimestamps[propId];
108 }
109 }
110
Yu Shan726d51a2022-02-22 17:37:21 -0800111 void reset() {
112 std::lock_guard<std::mutex> lockGuard(mLock);
113 mEventsCount.clear();
114 }
115};
116
117class VtsHalAutomotiveVehicleTargetTest : public testing::TestWithParam<ServiceDescriptor> {
118 public:
Aaqib Ismail20486702022-10-27 16:58:50 -0700119 void verifyProperty(VehicleProperty propId, VehiclePropertyAccess access,
120 VehiclePropertyChangeMode changeMode, VehiclePropertyGroup group,
121 VehicleArea area, VehiclePropertyType propertyType);
Yu Shan726d51a2022-02-22 17:37:21 -0800122 virtual void SetUp() override {
123 auto descriptor = GetParam();
124 if (descriptor.isAidlService) {
125 mVhalClient = IVhalClient::tryCreateAidlClient(descriptor.name.c_str());
126 } else {
127 mVhalClient = IVhalClient::tryCreateHidlClient(descriptor.name.c_str());
128 }
129
130 ASSERT_NE(mVhalClient, nullptr) << "Failed to connect to VHAL";
131
132 mCallback = std::make_shared<VtsVehicleCallback>();
133 }
134
135 static bool isBooleanGlobalProp(int32_t property) {
136 return (property & toInt(VehiclePropertyType::MASK)) ==
137 toInt(VehiclePropertyType::BOOLEAN) &&
138 (property & toInt(VehicleArea::MASK)) == toInt(VehicleArea::GLOBAL);
139 }
140
141 protected:
142 std::shared_ptr<IVhalClient> mVhalClient;
143 std::shared_ptr<VtsVehicleCallback> mCallback;
144};
145
146TEST_P(VtsHalAutomotiveVehicleTargetTest, useAidlBackend) {
147 if (!mVhalClient->isAidlVhal()) {
148 GTEST_SKIP() << "AIDL backend is not available, HIDL backend is used instead";
149 }
150}
151
152TEST_P(VtsHalAutomotiveVehicleTargetTest, useHidlBackend) {
153 if (mVhalClient->isAidlVhal()) {
154 GTEST_SKIP() << "AIDL backend is available, HIDL backend is not used";
155 }
156}
157
158// Test getAllPropConfig() returns at least 4 property configs.
159TEST_P(VtsHalAutomotiveVehicleTargetTest, getAllPropConfigs) {
160 ALOGD("VtsHalAutomotiveVehicleTargetTest::getAllPropConfigs");
161
162 auto result = mVhalClient->getAllPropConfigs();
163
164 ASSERT_TRUE(result.ok()) << "Failed to get all property configs, error: "
165 << result.error().message();
166 ASSERT_GE(result.value().size(), 4u) << StringPrintf(
167 "Expect to get at least 4 property configs, got %zu", result.value().size());
168}
169
170// Test getPropConfigs() can query all properties listed in CDD.
171TEST_P(VtsHalAutomotiveVehicleTargetTest, getRequiredPropConfigs) {
172 ALOGD("VtsHalAutomotiveVehicleTargetTest::getRequiredPropConfigs");
173
174 // Check the properties listed in CDD
175 std::vector<int32_t> properties = {
176 toInt(VehicleProperty::GEAR_SELECTION), toInt(VehicleProperty::NIGHT_MODE),
177 toInt(VehicleProperty::PARKING_BRAKE_ON), toInt(VehicleProperty::PERF_VEHICLE_SPEED)};
178
179 auto result = mVhalClient->getPropConfigs(properties);
180
181 ASSERT_TRUE(result.ok()) << "Failed to get required property config, error: "
182 << result.error().message();
183 ASSERT_EQ(result.value().size(), 4u)
184 << StringPrintf("Expect to get exactly 4 configs, got %zu", result.value().size());
185}
186
187// Test getPropConfig() with an invalid propertyId returns an error code.
188TEST_P(VtsHalAutomotiveVehicleTargetTest, getPropConfigsWithInvalidProp) {
189 ALOGD("VtsHalAutomotiveVehicleTargetTest::getPropConfigsWithInvalidProp");
190
191 auto result = mVhalClient->getPropConfigs({kInvalidProp});
192
193 ASSERT_FALSE(result.ok()) << StringPrintf(
194 "Expect failure to get prop configs for invalid prop: %" PRId32, kInvalidProp);
195 ASSERT_NE(result.error().message(), "") << "Expect error message not to be empty";
196}
197
198// Test get() return current value for properties.
199TEST_P(VtsHalAutomotiveVehicleTargetTest, get) {
200 ALOGD("VtsHalAutomotiveVehicleTargetTest::get");
201
202 int32_t propId = toInt(VehicleProperty::PERF_VEHICLE_SPEED);
203 auto result = mVhalClient->getValueSync(*mVhalClient->createHalPropValue(propId));
204
205 ASSERT_TRUE(result.ok()) << StringPrintf("Failed to get value for property: %" PRId32
206 ", error: %s",
207 propId, result.error().message().c_str());
208 ASSERT_NE(result.value(), nullptr) << "Result value must not be null";
209}
210
211// Test get() with an invalid propertyId return an error codes.
212TEST_P(VtsHalAutomotiveVehicleTargetTest, getInvalidProp) {
213 ALOGD("VtsHalAutomotiveVehicleTargetTest::getInvalidProp");
214
215 auto result = mVhalClient->getValueSync(*mVhalClient->createHalPropValue(kInvalidProp));
216
217 ASSERT_FALSE(result.ok()) << StringPrintf(
218 "Expect failure to get property for invalid prop: %" PRId32, kInvalidProp);
219}
220
221// Test set() on read_write properties.
222TEST_P(VtsHalAutomotiveVehicleTargetTest, setProp) {
223 ALOGD("VtsHalAutomotiveVehicleTargetTest::setProp");
224
225 // skip hvac related properties
226 std::unordered_set<int32_t> hvacProps = {toInt(VehicleProperty::HVAC_DEFROSTER),
227 toInt(VehicleProperty::HVAC_AC_ON),
228 toInt(VehicleProperty::HVAC_MAX_AC_ON),
229 toInt(VehicleProperty::HVAC_MAX_DEFROST_ON),
230 toInt(VehicleProperty::HVAC_RECIRC_ON),
231 toInt(VehicleProperty::HVAC_DUAL_ON),
232 toInt(VehicleProperty::HVAC_AUTO_ON),
233 toInt(VehicleProperty::HVAC_POWER_ON),
234 toInt(VehicleProperty::HVAC_AUTO_RECIRC_ON),
235 toInt(VehicleProperty::HVAC_ELECTRIC_DEFROSTER_ON)};
236 auto result = mVhalClient->getAllPropConfigs();
237 ASSERT_TRUE(result.ok());
238
239 for (const auto& cfgPtr : result.value()) {
240 const IHalPropConfig& cfg = *cfgPtr;
241 int32_t propId = cfg.getPropId();
242 // test on boolean and writable property
243 if (cfg.getAccess() == toInt(VehiclePropertyAccess::READ_WRITE) &&
244 isBooleanGlobalProp(propId) && !hvacProps.count(propId)) {
245 auto propToGet = mVhalClient->createHalPropValue(propId);
246 auto getValueResult = mVhalClient->getValueSync(*propToGet);
247
248 ASSERT_TRUE(getValueResult.ok())
249 << StringPrintf("Failed to get value for property: %" PRId32 ", error: %s",
250 propId, getValueResult.error().message().c_str());
251 ASSERT_NE(getValueResult.value(), nullptr)
252 << StringPrintf("Result value must not be null for property: %" PRId32, propId);
253
254 const IHalPropValue& value = *getValueResult.value();
255 size_t intValueSize = value.getInt32Values().size();
256 ASSERT_EQ(intValueSize, 1u) << StringPrintf(
257 "Expect exactly 1 int value for boolean property: %" PRId32 ", got %zu", propId,
258 intValueSize);
259
260 int setValue = value.getInt32Values()[0] == 1 ? 0 : 1;
261 auto propToSet = mVhalClient->createHalPropValue(propId);
262 propToSet->setInt32Values({setValue});
263 auto setValueResult = mVhalClient->setValueSync(*propToSet);
264
265 ASSERT_TRUE(setValueResult.ok())
266 << StringPrintf("Failed to set value for property: %" PRId32 ", error: %s",
267 propId, setValueResult.error().message().c_str());
268
269 // check set success
270 getValueResult = mVhalClient->getValueSync(*propToGet);
271 ASSERT_TRUE(getValueResult.ok())
272 << StringPrintf("Failed to get value for property: %" PRId32 ", error: %s",
273 propId, getValueResult.error().message().c_str());
274 ASSERT_NE(getValueResult.value(), nullptr)
275 << StringPrintf("Result value must not be null for property: %" PRId32, propId);
276 ASSERT_EQ(getValueResult.value()->getInt32Values(), std::vector<int32_t>({setValue}))
277 << StringPrintf("Boolean value not updated after set for property: %" PRId32,
278 propId);
279 }
280 }
281}
282
283// Test set() on an read_only property.
284TEST_P(VtsHalAutomotiveVehicleTargetTest, setNotWritableProp) {
285 ALOGD("VtsHalAutomotiveVehicleTargetTest::setNotWritableProp");
286
287 int32_t propId = toInt(VehicleProperty::PERF_VEHICLE_SPEED);
288 auto getValueResult = mVhalClient->getValueSync(*mVhalClient->createHalPropValue(propId));
289 ASSERT_TRUE(getValueResult.ok())
290 << StringPrintf("Failed to get value for property: %" PRId32 ", error: %s", propId,
291 getValueResult.error().message().c_str());
292
293 auto setValueResult = mVhalClient->setValueSync(*getValueResult.value());
294
295 ASSERT_FALSE(setValueResult.ok()) << "Expect set a read-only value to fail";
Chen Chengfaf9adc2022-06-22 23:09:09 +0000296 ASSERT_EQ(setValueResult.error().code(), ErrorCode::ACCESS_DENIED_FROM_VHAL);
Yu Shan726d51a2022-02-22 17:37:21 -0800297}
298
299// Test subscribe() and unsubscribe().
300TEST_P(VtsHalAutomotiveVehicleTargetTest, subscribeAndUnsubscribe) {
301 ALOGD("VtsHalAutomotiveVehicleTargetTest::subscribeAndUnsubscribe");
302
303 int32_t propId = toInt(VehicleProperty::PERF_VEHICLE_SPEED);
304
Yu Shan4569ef52022-03-18 14:34:25 -0700305 auto propConfigsResult = mVhalClient->getPropConfigs({propId});
306
307 ASSERT_TRUE(propConfigsResult.ok()) << "Failed to get property config for PERF_VEHICLE_SPEED: "
308 << "error: " << propConfigsResult.error().message();
309 ASSERT_EQ(propConfigsResult.value().size(), 1u)
310 << "Expect to return 1 config for PERF_VEHICLE_SPEED";
311 auto& propConfig = propConfigsResult.value()[0];
312 float minSampleRate = propConfig->getMinSampleRate();
313 float maxSampleRate = propConfig->getMaxSampleRate();
314
315 if (minSampleRate < 1) {
316 GTEST_SKIP() << "Sample rate for vehicle speed < 1 times/sec, skip test since it would "
317 "take too long";
318 }
Yu Shan726d51a2022-02-22 17:37:21 -0800319
320 auto client = mVhalClient->getSubscriptionClient(mCallback);
321 ASSERT_NE(client, nullptr) << "Failed to get subscription client";
322
Yu Shan4569ef52022-03-18 14:34:25 -0700323 auto result = client->subscribe({{.propId = propId, .sampleRate = minSampleRate}});
Yu Shan726d51a2022-02-22 17:37:21 -0800324
325 ASSERT_TRUE(result.ok()) << StringPrintf("Failed to subscribe to property: %" PRId32
326 ", error: %s",
327 propId, result.error().message().c_str());
Yu Shan4569ef52022-03-18 14:34:25 -0700328
329 if (mVhalClient->isAidlVhal()) {
330 // Skip checking timestamp for HIDL because the behavior for sample rate and timestamp is
331 // only specified clearly for AIDL.
332
333 // Timeout is 2 seconds, which gives a 1 second buffer.
334 ASSERT_TRUE(mCallback->waitForExpectedEvents(propId, std::floor(minSampleRate),
335 std::chrono::seconds(2)))
336 << "Didn't get enough events for subscribing to minSampleRate";
337 }
338
339 result = client->subscribe({{.propId = propId, .sampleRate = maxSampleRate}});
340
341 ASSERT_TRUE(result.ok()) << StringPrintf("Failed to subscribe to property: %" PRId32
342 ", error: %s",
343 propId, result.error().message().c_str());
344
345 if (mVhalClient->isAidlVhal()) {
346 ASSERT_TRUE(mCallback->waitForExpectedEvents(propId, std::floor(maxSampleRate),
347 std::chrono::seconds(2)))
348 << "Didn't get enough events for subscribing to maxSampleRate";
349
350 std::unordered_set<int64_t> timestamps;
351 // Event event should have a different timestamp.
352 for (const int64_t& eventTimestamp : mCallback->getEventTimestamps(propId)) {
353 ASSERT_TRUE(timestamps.find(eventTimestamp) == timestamps.end())
354 << "two events for the same property must not have the same timestamp";
355 timestamps.insert(eventTimestamp);
356 }
357 }
Yu Shan726d51a2022-02-22 17:37:21 -0800358
359 result = client->unsubscribe({propId});
360 ASSERT_TRUE(result.ok()) << StringPrintf("Failed to unsubscribe to property: %" PRId32
361 ", error: %s",
362 propId, result.error().message().c_str());
363
364 mCallback->reset();
365 ASSERT_FALSE(mCallback->waitForExpectedEvents(propId, 10, std::chrono::seconds(1)))
366 << "Expect not to get events after unsubscription";
367}
368
369// Test subscribe() with an invalid property.
370TEST_P(VtsHalAutomotiveVehicleTargetTest, subscribeInvalidProp) {
371 ALOGD("VtsHalAutomotiveVehicleTargetTest::subscribeInvalidProp");
372
373 std::vector<SubscribeOptions> options = {
374 SubscribeOptions{.propId = kInvalidProp, .sampleRate = 10.0}};
375
376 auto client = mVhalClient->getSubscriptionClient(mCallback);
377 ASSERT_NE(client, nullptr) << "Failed to get subscription client";
378
379 auto result = client->subscribe(options);
380
381 ASSERT_FALSE(result.ok()) << StringPrintf("Expect subscribing to property: %" PRId32 " to fail",
382 kInvalidProp);
383}
384
Yu Shan4569ef52022-03-18 14:34:25 -0700385// Test the timestamp returned in GetValues results is the timestamp when the value is retrieved.
386TEST_P(VtsHalAutomotiveVehicleTargetTest, testGetValuesTimestampAIDL) {
387 if (!mVhalClient->isAidlVhal()) {
388 GTEST_SKIP() << "Skip checking timestamp for HIDL because the behavior is only specified "
389 "for AIDL";
390 }
391
392 int32_t propId = toInt(VehicleProperty::PARKING_BRAKE_ON);
393 auto prop = mVhalClient->createHalPropValue(propId);
394
395 auto result = mVhalClient->getValueSync(*prop);
396
397 ASSERT_TRUE(result.ok()) << StringPrintf("Failed to get value for property: %" PRId32
398 ", error: %s",
399 propId, result.error().message().c_str());
400 ASSERT_NE(result.value(), nullptr) << "Result value must not be null";
401 ASSERT_EQ(result.value()->getInt32Values().size(), 1u) << "Result must contain 1 int value";
402
403 bool parkBrakeOnValue1 = (result.value()->getInt32Values()[0] == 1);
404 int64_t timestampValue1 = result.value()->getTimestamp();
405
406 result = mVhalClient->getValueSync(*prop);
407
408 ASSERT_TRUE(result.ok()) << StringPrintf("Failed to get value for property: %" PRId32
409 ", error: %s",
410 propId, result.error().message().c_str());
411 ASSERT_NE(result.value(), nullptr) << "Result value must not be null";
412 ASSERT_EQ(result.value()->getInt32Values().size(), 1u) << "Result must contain 1 int value";
413
414 bool parkBarkeOnValue2 = (result.value()->getInt32Values()[0] == 1);
415 int64_t timestampValue2 = result.value()->getTimestamp();
416
417 if (parkBarkeOnValue2 == parkBrakeOnValue1) {
418 ASSERT_EQ(timestampValue2, timestampValue1)
419 << "getValue result must contain a timestamp updated when the value was updated, if"
420 "the value does not change, expect the same timestamp";
421 } else {
422 ASSERT_GT(timestampValue2, timestampValue1)
423 << "getValue result must contain a timestamp updated when the value was updated, if"
424 "the value changes, expect the newer value has a larger timestamp";
425 }
426}
427
Aaqib Ismail20486702022-10-27 16:58:50 -0700428// Helper function to compare actual vs expected property config
429void VtsHalAutomotiveVehicleTargetTest::verifyProperty(VehicleProperty propId,
430 VehiclePropertyAccess access,
431 VehiclePropertyChangeMode changeMode,
432 VehiclePropertyGroup group, VehicleArea area,
433 VehiclePropertyType propertyType) {
434 int expectedPropId = toInt(propId);
435 int expectedAccess = toInt(access);
436 int expectedChangeMode = toInt(changeMode);
437 int expectedGroup = toInt(group);
438 int expectedArea = toInt(area);
439 int expectedPropertyType = toInt(propertyType);
440
441 auto result = mVhalClient->getPropConfigs({expectedPropId});
442 ASSERT_TRUE(result.ok()) << "Failed to get required property config, error: "
443 << result.error().message();
444
445 if (result.value().size() == 0) {
446 GTEST_SKIP() << "Property has not been implemented";
447 }
448 ASSERT_EQ(result.value().size(), 1u)
449 << StringPrintf("Expect to get exactly 1 config, got %zu", result.value().size());
450
451 const auto& config = result.value().at(0);
452 int actualPropId = config->getPropId();
453 int actualAccess = config->getAccess();
454 int actualChangeMode = config->getChangeMode();
455 int actualGroup = actualPropId & toInt(VehiclePropertyGroup::MASK);
456 int actualArea = actualPropId & toInt(VehicleArea::MASK);
457 int actualPropertyType = actualPropId & toInt(VehiclePropertyType::MASK);
458
459 ASSERT_EQ(actualPropId, expectedPropId)
460 << StringPrintf("Expect to get property ID: %i, got %i", expectedPropId, actualPropId);
461
462 if (expectedAccess == toInt(VehiclePropertyAccess::READ_WRITE)) {
463 ASSERT_TRUE(actualAccess == expectedAccess ||
464 actualAccess == toInt(VehiclePropertyAccess::READ))
465 << StringPrintf("Expect to get VehiclePropertyAccess: %i or %i, got %i",
466 expectedAccess, toInt(VehiclePropertyAccess::READ), actualAccess);
467 } else {
468 ASSERT_EQ(actualAccess, expectedAccess) << StringPrintf(
469 "Expect to get VehiclePropertyAccess: %i, got %i", expectedAccess, actualAccess);
470 }
471
472 ASSERT_EQ(actualChangeMode, expectedChangeMode)
473 << StringPrintf("Expect to get VehiclePropertyChangeMode: %i, got %i",
474 expectedChangeMode, actualChangeMode);
475 ASSERT_EQ(actualGroup, expectedGroup) << StringPrintf(
476 "Expect to get VehiclePropertyGroup: %i, got %i", expectedGroup, actualGroup);
477 ASSERT_EQ(actualArea, expectedArea)
478 << StringPrintf("Expect to get VehicleArea: %i, got %i", expectedArea, actualArea);
479 ASSERT_EQ(actualPropertyType, expectedPropertyType)
480 << StringPrintf("Expect to get VehiclePropertyType: %i, got %i", expectedPropertyType,
481 actualPropertyType);
482}
483
Aaqib Ismailc69e9682022-11-22 12:50:00 -0800484TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyEvBrakeRegenerationLevelConfig) {
485 verifyProperty(VehicleProperty::EV_BRAKE_REGENERATION_LEVEL,
486 VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
487 VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::INT32);
488}
489
Aaqib Ismailaec678a2022-12-07 16:22:42 -0800490TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyEvCurrentBatteryCapacityConfig) {
491 verifyProperty(VehicleProperty::EV_CURRENT_BATTERY_CAPACITY, VehiclePropertyAccess::READ,
492 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
493 VehicleArea::GLOBAL, VehiclePropertyType::FLOAT);
494}
495
shrikar83914472022-12-16 20:28:47 +0000496TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyEngineIdleAutoStopEnabledConfig) {
497 verifyProperty(VehicleProperty::ENGINE_IDLE_AUTO_STOP_ENABLED,
498 VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
499 VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
500}
501
Aaqib Ismail20486702022-10-27 16:58:50 -0700502TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyDoorChildLockEnabledConfig) {
503 verifyProperty(VehicleProperty::DOOR_CHILD_LOCK_ENABLED, VehiclePropertyAccess::READ_WRITE,
504 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
505 VehicleArea::DOOR, VehiclePropertyType::BOOLEAN);
506}
507
Aaqib Ismail7f941b42022-11-04 14:55:13 -0700508TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySteeringWheelDepthPosConfig) {
509 verifyProperty(VehicleProperty::STEERING_WHEEL_DEPTH_POS, VehiclePropertyAccess::READ_WRITE,
510 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
511 VehicleArea::GLOBAL, VehiclePropertyType::INT32);
512}
513
Aaqib Ismail34fe92f2022-11-04 21:41:23 -0700514TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySteeringWheelDepthMoveConfig) {
515 verifyProperty(VehicleProperty::STEERING_WHEEL_DEPTH_MOVE, VehiclePropertyAccess::READ_WRITE,
516 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
517 VehicleArea::GLOBAL, VehiclePropertyType::INT32);
518}
519
Aaqib Ismail53b81c92022-11-07 17:47:04 -0800520TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySteeringWheelHeightPosConfig) {
521 verifyProperty(VehicleProperty::STEERING_WHEEL_HEIGHT_POS, VehiclePropertyAccess::READ_WRITE,
522 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
523 VehicleArea::GLOBAL, VehiclePropertyType::INT32);
524}
525
Aaqib Ismail6c4bf192022-11-08 15:00:32 -0800526TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySteeringWheelHeightMoveConfig) {
527 verifyProperty(VehicleProperty::STEERING_WHEEL_HEIGHT_MOVE, VehiclePropertyAccess::READ_WRITE,
528 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
529 VehicleArea::GLOBAL, VehiclePropertyType::INT32);
530}
531
Aaqib Ismail8d051182022-11-09 13:28:48 -0800532TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySteeringWheelTheftLockEnabledConfig) {
533 verifyProperty(VehicleProperty::STEERING_WHEEL_THEFT_LOCK_ENABLED,
534 VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
535 VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
536}
537
Aaqib Ismail68d3f122022-11-09 14:43:32 -0800538TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySteeringWheelLockedConfig) {
539 verifyProperty(VehicleProperty::STEERING_WHEEL_LOCKED, VehiclePropertyAccess::READ_WRITE,
540 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
541 VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
542}
543
Aaqib Ismaild4d6adf2022-11-09 16:59:47 -0800544TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySteeringWheelEasyAccessEnabledConfig) {
545 verifyProperty(VehicleProperty::STEERING_WHEEL_EASY_ACCESS_ENABLED,
546 VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
547 VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
548}
549
shrikara1367212022-11-02 16:07:35 +0000550TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyMirrorAutoFoldEnabledConfig) {
551 verifyProperty(VehicleProperty::MIRROR_AUTO_FOLD_ENABLED, VehiclePropertyAccess::READ_WRITE,
552 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
553 VehicleArea::MIRROR, VehiclePropertyType::BOOLEAN);
554}
555
556TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyMirrorAutoTiltEnabledConfig) {
557 verifyProperty(VehicleProperty::MIRROR_AUTO_TILT_ENABLED, VehiclePropertyAccess::READ_WRITE,
558 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
559 VehicleArea::MIRROR, VehiclePropertyType::BOOLEAN);
560}
561
shrikar6ae79162022-12-16 03:03:25 +0000562TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySeatWalkInPosConfig) {
563 verifyProperty(VehicleProperty::SEAT_WALK_IN_POS, VehiclePropertyAccess::READ_WRITE,
564 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
565 VehicleArea::SEAT, VehiclePropertyType::INT32);
566}
567
shrikar3326de02022-11-07 23:51:20 +0000568TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySeatEasyAccessEnabledConfig) {
569 verifyProperty(VehicleProperty::SEAT_EASY_ACCESS_ENABLED, VehiclePropertyAccess::READ_WRITE,
570 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
571 VehicleArea::SEAT, VehiclePropertyType::BOOLEAN);
572}
573
shrikarb96e3762022-11-08 16:49:58 -0800574TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySeatAirbagEnabledConfig) {
575 verifyProperty(VehicleProperty::SEAT_AIRBAG_ENABLED, VehiclePropertyAccess::READ_WRITE,
576 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
577 VehicleArea::SEAT, VehiclePropertyType::BOOLEAN);
578}
579
shrikar802ecb52022-11-09 18:27:06 +0000580TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySeatCushionSideSupportPosConfig) {
581 verifyProperty(VehicleProperty::SEAT_CUSHION_SIDE_SUPPORT_POS,
582 VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
583 VehiclePropertyGroup::SYSTEM, VehicleArea::SEAT, VehiclePropertyType::INT32);
584}
585
shrikar1f0ce0d2022-11-11 17:46:06 +0000586TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySeatCushionSideSupportMoveConfig) {
587 verifyProperty(VehicleProperty::SEAT_CUSHION_SIDE_SUPPORT_MOVE,
588 VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
589 VehiclePropertyGroup::SYSTEM, VehicleArea::SEAT, VehiclePropertyType::INT32);
590}
591
shrikareff71b22022-11-11 11:02:43 -0800592TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySeatLumbarVerticalPosConfig) {
593 verifyProperty(VehicleProperty::SEAT_LUMBAR_VERTICAL_POS, VehiclePropertyAccess::READ_WRITE,
594 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
595 VehicleArea::SEAT, VehiclePropertyType::INT32);
596}
597
shrikar2a081c52022-11-11 16:49:58 -0800598TEST_P(VtsHalAutomotiveVehicleTargetTest, verifySeatLumbarVerticalMoveConfig) {
599 verifyProperty(VehicleProperty::SEAT_LUMBAR_VERTICAL_MOVE, VehiclePropertyAccess::READ_WRITE,
600 VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
601 VehicleArea::SEAT, VehiclePropertyType::INT32);
602}
603
Aaqib Ismail5d53aa32022-12-13 22:30:23 +0000604TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyAutomaticEmergencyBrakingEnabledConfig) {
605 verifyProperty(VehicleProperty::AUTOMATIC_EMERGENCY_BRAKING_ENABLED,
606 VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
607 VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
608}
609
Aaqib Ismailb1680a72022-12-14 23:28:49 +0000610TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyLaneCenteringAssistEnabledConfig) {
611 verifyProperty(VehicleProperty::LANE_CENTERING_ASSIST_ENABLED,
612 VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
613 VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
614}
615
Yu Shan726d51a2022-02-22 17:37:21 -0800616std::vector<ServiceDescriptor> getDescriptors() {
617 std::vector<ServiceDescriptor> descriptors;
618 for (std::string name : getAidlHalInstanceNames(IVehicle::descriptor)) {
619 descriptors.push_back({
620 .name = name,
621 .isAidlService = true,
622 });
623 }
624 for (std::string name : getAllHalInstanceNames(IVehicle::descriptor)) {
625 descriptors.push_back({
626 .name = name,
627 .isAidlService = false,
628 });
629 }
630 return descriptors;
631}
632
633GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(VtsHalAutomotiveVehicleTargetTest);
634
635INSTANTIATE_TEST_SUITE_P(PerInstance, VtsHalAutomotiveVehicleTargetTest,
636 testing::ValuesIn(getDescriptors()),
637 [](const testing::TestParamInfo<ServiceDescriptor>& info) {
638 std::string name = "";
639 if (info.param.isAidlService) {
640 name += "aidl_";
641 } else {
642 name += "hidl_";
643 }
644 name += info.param.name;
645 return Sanitize(name);
646 });
647
648int main(int argc, char** argv) {
649 ::testing::InitGoogleTest(&argc, argv);
650 ABinderProcess_setThreadPoolMaxThreadCount(1);
651 return RUN_ALL_TESTS();
652}