summaryrefslogtreecommitdiffstats
path: root/sensors/common
diff options
context:
space:
mode:
authorBrian Stack <bstack@google.com>2018-10-16 11:04:16 -0700
committerBrian Stack <bstack@google.com>2018-10-19 15:18:28 -0700
commit1d329e633a317bb02f95c37516c722b15c582270 (patch)
tree340df5f8a6a6c67147be829ded567c611abc5213 /sensors/common
parentc3c937e3c39d17cf917b72f4ddae1db1be8f713e (diff)
downloadplatform_hardware_interfaces-1d329e633a317bb02f95c37516c722b15c582270.tar.gz
platform_hardware_interfaces-1d329e633a317bb02f95c37516c722b15c582270.tar.bz2
platform_hardware_interfaces-1d329e633a317bb02f95c37516c722b15c582270.zip
Add CallInitializeTwice Test
Adds a test to Sensors 2.0 to ensure that if the initialize function is called twice, then the FMQs used in the second call receive events. Bug: 115969174 Test: New test passes (SensorsHidlTest#CallInitializeTwice) Change-Id: I21a9307397eca1f2be93a826db89d24002e848c0
Diffstat (limited to 'sensors/common')
-rw-r--r--sensors/common/vts/utils/SensorsHidlTestBase.cpp16
-rw-r--r--sensors/common/vts/utils/include/sensors-vts-utils/SensorsHidlTestBase.h4
2 files changed, 16 insertions, 4 deletions
diff --git a/sensors/common/vts/utils/SensorsHidlTestBase.cpp b/sensors/common/vts/utils/SensorsHidlTestBase.cpp
index b72fdfd535..18549dfb17 100644
--- a/sensors/common/vts/utils/SensorsHidlTestBase.cpp
+++ b/sensors/common/vts/utils/SensorsHidlTestBase.cpp
@@ -40,6 +40,14 @@ const Vec3NormChecker SensorsHidlTestBase::sGyroNormChecker(
std::vector<Event> SensorsHidlTestBase::collectEvents(useconds_t timeLimitUs, size_t nEventLimit,
bool clearBeforeStart,
bool changeCollection) {
+ return collectEvents(timeLimitUs, nEventLimit, getEnvironment(), clearBeforeStart,
+ changeCollection);
+}
+
+std::vector<Event> SensorsHidlTestBase::collectEvents(useconds_t timeLimitUs, size_t nEventLimit,
+ SensorsHidlEnvironmentBase* environment,
+ bool clearBeforeStart,
+ bool changeCollection) {
std::vector<Event> events;
constexpr useconds_t SLEEP_GRANULARITY = 100 * 1000; // granularity 100 ms
@@ -47,10 +55,10 @@ std::vector<Event> SensorsHidlTestBase::collectEvents(useconds_t timeLimitUs, si
clearBeforeStart);
if (changeCollection) {
- getEnvironment()->setCollection(true);
+ environment->setCollection(true);
}
if (clearBeforeStart) {
- getEnvironment()->catEvents(nullptr);
+ environment->catEvents(nullptr);
}
while (timeLimitUs > 0) {
@@ -58,7 +66,7 @@ std::vector<Event> SensorsHidlTestBase::collectEvents(useconds_t timeLimitUs, si
usleep(duration);
timeLimitUs -= duration;
- getEnvironment()->catEvents(&events);
+ environment->catEvents(&events);
if (events.size() >= nEventLimit) {
break;
}
@@ -67,7 +75,7 @@ std::vector<Event> SensorsHidlTestBase::collectEvents(useconds_t timeLimitUs, si
}
if (changeCollection) {
- getEnvironment()->setCollection(false);
+ environment->setCollection(false);
}
return events;
}
diff --git a/sensors/common/vts/utils/include/sensors-vts-utils/SensorsHidlTestBase.h b/sensors/common/vts/utils/include/sensors-vts-utils/SensorsHidlTestBase.h
index f4b259f629..6fd9a2b5de 100644
--- a/sensors/common/vts/utils/include/sensors-vts-utils/SensorsHidlTestBase.h
+++ b/sensors/common/vts/utils/include/sensors-vts-utils/SensorsHidlTestBase.h
@@ -85,6 +85,10 @@ class SensorsHidlTestBase : public ::testing::VtsHalHidlTargetTestBase {
std::vector<Event> collectEvents(useconds_t timeLimitUs, size_t nEventLimit,
bool clearBeforeStart = true, bool changeCollection = true);
+ static std::vector<Event> collectEvents(useconds_t timeLimitUs, size_t nEventLimit,
+ SensorsHidlEnvironmentBase* environment,
+ bool clearBeforeStart = true,
+ bool changeCollection = true);
inline static SensorFlagBits extractReportMode(uint64_t flag) {
return (SensorFlagBits)(flag & ((uint64_t)SensorFlagBits::CONTINUOUS_MODE |