mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 11:36:00 +00:00
Merge "Modify VTS NoStaleEvents test to omit on-change sensors" am: f3d65e5278 am: 9d6657b109 am: aba049aa2d
Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/1465784 Change-Id: I09327472c23b727907cc1decb01916ba80b01310
This commit is contained in:
@@ -226,6 +226,7 @@ class SensorsHidlTest : public SensorsHidlTestBaseV2_X {
|
||||
void activateAllSensors(bool enable);
|
||||
std::vector<SensorInfoType> getNonOneShotSensors();
|
||||
std::vector<SensorInfoType> getNonOneShotAndNonSpecialSensors();
|
||||
std::vector<SensorInfoType> getNonOneShotAndNonOnChangeAndNonSpecialSensors();
|
||||
std::vector<SensorInfoType> getOneShotSensors();
|
||||
std::vector<SensorInfoType> getInjectEventSensors();
|
||||
int32_t getInvalidSensorHandle();
|
||||
@@ -326,6 +327,19 @@ std::vector<SensorInfoType> SensorsHidlTest::getNonOneShotAndNonSpecialSensors()
|
||||
return sensors;
|
||||
}
|
||||
|
||||
std::vector<SensorInfoType> SensorsHidlTest::getNonOneShotAndNonOnChangeAndNonSpecialSensors() {
|
||||
std::vector<SensorInfoType> sensors;
|
||||
for (const SensorInfoType& info : getSensorsList()) {
|
||||
SensorFlagBits reportMode = extractReportMode(info.flags);
|
||||
if (reportMode != SensorFlagBits::ONE_SHOT_MODE &&
|
||||
reportMode != SensorFlagBits::ON_CHANGE_MODE &&
|
||||
reportMode != SensorFlagBits::SPECIAL_REPORTING_MODE) {
|
||||
sensors.push_back(info);
|
||||
}
|
||||
}
|
||||
return sensors;
|
||||
}
|
||||
|
||||
std::vector<SensorInfoType> SensorsHidlTest::getOneShotSensors() {
|
||||
std::vector<SensorInfoType> sensors;
|
||||
for (const SensorInfoType& info : getSensorsList()) {
|
||||
@@ -726,8 +740,8 @@ TEST_P(SensorsHidlTest, NoStaleEvents) {
|
||||
EventCallback callback;
|
||||
getEnvironment()->registerCallback(&callback);
|
||||
|
||||
// This test is not valid for one-shot or special-report-mode sensors
|
||||
const std::vector<SensorInfoType> sensors = getNonOneShotAndNonSpecialSensors();
|
||||
// This test is not valid for one-shot, on-change or special-report-mode sensors
|
||||
const std::vector<SensorInfoType> sensors = getNonOneShotAndNonOnChangeAndNonSpecialSensors();
|
||||
milliseconds maxMinDelay(0);
|
||||
for (const SensorInfoType& sensor : sensors) {
|
||||
milliseconds minDelay = duration_cast<milliseconds>(microseconds(sensor.minDelay));
|
||||
@@ -750,10 +764,7 @@ TEST_P(SensorsHidlTest, NoStaleEvents) {
|
||||
<< " handle=0x" << std::hex << std::setw(8) << std::setfill('0')
|
||||
<< sensor.sensorHandle << std::dec << " type=" << static_cast<int>(sensor.type)
|
||||
<< " name=" << sensor.name);
|
||||
// Some on-change sensors may not report an event without stimulus
|
||||
if (extractReportMode(sensor.flags) != SensorFlagBits::ON_CHANGE_MODE) {
|
||||
ASSERT_GE(callback.getEvents(sensor.sensorHandle).size(), 1);
|
||||
}
|
||||
|
||||
if (callback.getEvents(sensor.sensorHandle).size() >= 1) {
|
||||
lastEventTimestampMap[sensor.sensorHandle] =
|
||||
callback.getEvents(sensor.sensorHandle).back().timestamp;
|
||||
@@ -779,10 +790,7 @@ TEST_P(SensorsHidlTest, NoStaleEvents) {
|
||||
if (lastEventTimestampMap.find(sensor.sensorHandle) == lastEventTimestampMap.end()) {
|
||||
continue;
|
||||
}
|
||||
// Skip on-change sensors that do not consistently report an initial event
|
||||
if (callback.getEvents(sensor.sensorHandle).size() < 1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Ensure that the first event received is not stale by ensuring that its timestamp is
|
||||
// sufficiently different from the previous event
|
||||
const EventType newEvent = callback.getEvents(sensor.sensorHandle).front();
|
||||
|
||||
Reference in New Issue
Block a user