mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 16:09:42 +00:00
Merge "Ignore meta sensor events when checking values" into oreo-vts-dev
This commit is contained in:
@@ -911,6 +911,7 @@ void SensorsHidlTest::testStreamingOperation(SensorType type,
|
|||||||
std::chrono::seconds duration,
|
std::chrono::seconds duration,
|
||||||
const SensorEventsChecker &checker) {
|
const SensorEventsChecker &checker) {
|
||||||
std::vector<Event> events;
|
std::vector<Event> events;
|
||||||
|
std::vector<Event> sensorEvents;
|
||||||
|
|
||||||
const int64_t samplingPeriodInNs = samplingPeriod.count();
|
const int64_t samplingPeriodInNs = samplingPeriod.count();
|
||||||
const int64_t batchingPeriodInNs = 0; // no batching
|
const int64_t batchingPeriodInNs = 0; // no batching
|
||||||
@@ -940,7 +941,6 @@ void SensorsHidlTest::testStreamingOperation(SensorType type,
|
|||||||
|
|
||||||
ASSERT_GT(events.size(), 0u);
|
ASSERT_GT(events.size(), 0u);
|
||||||
|
|
||||||
size_t nRealEvent = 0;
|
|
||||||
bool handleMismatchReported = false;
|
bool handleMismatchReported = false;
|
||||||
bool metaSensorTypeErrorReported = false;
|
bool metaSensorTypeErrorReported = false;
|
||||||
for (auto & e : events) {
|
for (auto & e : events) {
|
||||||
@@ -951,7 +951,7 @@ void SensorsHidlTest::testStreamingOperation(SensorType type,
|
|||||||
<< (handleMismatchReported = true,
|
<< (handleMismatchReported = true,
|
||||||
"Event of the same type must come from the sensor registered");
|
"Event of the same type must come from the sensor registered");
|
||||||
}
|
}
|
||||||
++ nRealEvent;
|
sensorEvents.push_back(e);
|
||||||
} else {
|
} else {
|
||||||
// avoid generating hundreds of error
|
// avoid generating hundreds of error
|
||||||
if (!metaSensorTypeErrorReported) {
|
if (!metaSensorTypeErrorReported) {
|
||||||
@@ -963,9 +963,10 @@ void SensorsHidlTest::testStreamingOperation(SensorType type,
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string s;
|
std::string s;
|
||||||
EXPECT_TRUE(checker.check(events, &s)) << s;
|
EXPECT_TRUE(checker.check(sensorEvents, &s)) << s;
|
||||||
|
|
||||||
EXPECT_GE(nRealEvent, minNEvent / 2); // make sure returned events are not all meta
|
EXPECT_GE(sensorEvents.size(),
|
||||||
|
minNEvent / 2); // make sure returned events are not all meta
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test if sensor hal can do UI speed accelerometer streaming properly
|
// Test if sensor hal can do UI speed accelerometer streaming properly
|
||||||
@@ -1305,16 +1306,24 @@ void SensorsHidlTest::testDirectReportOperation(
|
|||||||
bool typeErrorReported = false;
|
bool typeErrorReported = false;
|
||||||
bool tokenErrorReported = false;
|
bool tokenErrorReported = false;
|
||||||
bool timestampErrorReported = false;
|
bool timestampErrorReported = false;
|
||||||
|
std::vector<Event> sensorEvents;
|
||||||
for (auto &e : events) {
|
for (auto &e : events) {
|
||||||
if (!typeErrorReported) {
|
|
||||||
EXPECT_EQ(type, e.sensorType)
|
|
||||||
<< (typeErrorReported = true, "Type in event does not match type of sensor registered.");
|
|
||||||
}
|
|
||||||
if (!tokenErrorReported) {
|
if (!tokenErrorReported) {
|
||||||
EXPECT_EQ(eventToken, e.sensorHandle)
|
EXPECT_EQ(eventToken, e.sensorHandle)
|
||||||
<< (tokenErrorReported = true,
|
<< (tokenErrorReported = true,
|
||||||
"Event token does not match that retured from configDirectReport");
|
"Event token does not match that retured from configDirectReport");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isMetaSensorType(e.sensorType)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
sensorEvents.push_back(e);
|
||||||
|
|
||||||
|
if (!typeErrorReported) {
|
||||||
|
EXPECT_EQ(type, e.sensorType)
|
||||||
|
<< (typeErrorReported = true,
|
||||||
|
"Type in event does not match type of sensor registered.");
|
||||||
|
}
|
||||||
if (!timestampErrorReported) {
|
if (!timestampErrorReported) {
|
||||||
EXPECT_GT(e.timestamp, lastTimestamp)
|
EXPECT_GT(e.timestamp, lastTimestamp)
|
||||||
<< (timestampErrorReported = true, "Timestamp not monotonically increasing");
|
<< (timestampErrorReported = true, "Timestamp not monotonically increasing");
|
||||||
@@ -1323,7 +1332,7 @@ void SensorsHidlTest::testDirectReportOperation(
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string s;
|
std::string s;
|
||||||
EXPECT_TRUE(checker.check(events, &s)) << s;
|
EXPECT_TRUE(checker.check(sensorEvents, &s)) << s;
|
||||||
|
|
||||||
// stop sensor and unregister channel
|
// stop sensor and unregister channel
|
||||||
configDirectReport(sensor.sensorHandle, channelHandle, RateLevel::STOP,
|
configDirectReport(sensor.sensorHandle, channelHandle, RateLevel::STOP,
|
||||||
|
|||||||
Reference in New Issue
Block a user