diff options
Diffstat (limited to 'sensors/1.0/vts/functional/VtsHalSensorsV1_0TargetTest.cpp')
-rw-r--r-- | sensors/1.0/vts/functional/VtsHalSensorsV1_0TargetTest.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/sensors/1.0/vts/functional/VtsHalSensorsV1_0TargetTest.cpp b/sensors/1.0/vts/functional/VtsHalSensorsV1_0TargetTest.cpp index 1f579ba61e..d46cf5a490 100644 --- a/sensors/1.0/vts/functional/VtsHalSensorsV1_0TargetTest.cpp +++ b/sensors/1.0/vts/functional/VtsHalSensorsV1_0TargetTest.cpp @@ -24,7 +24,9 @@ #include <log/log.h> #include <utils/SystemClock.h> +#include <algorithm> #include <cinttypes> +#include <unordered_map> #include <vector> using ::android::hardware::Return; @@ -149,6 +151,7 @@ std::vector<SensorInfo> SensorsHidlTest::getSensorsList() { TEST_P(SensorsHidlTest, SensorListValid) { S()->getSensorsList([&](const auto& list) { const size_t count = list.size(); + std::unordered_map<int32_t, std::vector<std::string>> sensorTypeNameMap; for (size_t i = 0; i < count; ++i) { const auto& s = list[i]; SCOPED_TRACE(::testing::Message() @@ -167,6 +170,14 @@ TEST_P(SensorsHidlTest, SensorListValid) { EXPECT_FALSE(s.name.empty()); EXPECT_FALSE(s.vendor.empty()); + // Make sure that sensors of the same type have a unique name. + std::vector<std::string>& v = sensorTypeNameMap[static_cast<int32_t>(s.type)]; + bool isUniqueName = std::find(v.begin(), v.end(), s.name) == v.end(); + EXPECT_TRUE(isUniqueName) << "Duplicate sensor Name: " << s.name; + if (isUniqueName) { + v.push_back(s.name); + } + // Test power > 0, maxRange > 0 EXPECT_LE(0, s.power); EXPECT_LT(0, s.maxRange); |