From 908e4479dd97482e839763eaf874a25c03f9fd08 Mon Sep 17 00:00:00 2001 From: Anthony Stange Date: Mon, 4 May 2020 13:46:07 -0400 Subject: [PATCH] Fix Sensors VTS asserts for sensor type strings Private sensors are the only sensor types that must define a type string. For public sensors, a type string can be left empty as it will be overridden by the sensors frameork. Bug: 155514483 Test: atest VtsHalSensorsV2_0Target Change-Id: Ib5f8fd513313670e88c2b973c1ff724658914eb2 --- sensors/common/vts/2_X/VtsHalSensorsV2_XTargetTest.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/sensors/common/vts/2_X/VtsHalSensorsV2_XTargetTest.h b/sensors/common/vts/2_X/VtsHalSensorsV2_XTargetTest.h index 75f2c28eaf..1db667f2a9 100644 --- a/sensors/common/vts/2_X/VtsHalSensorsV2_XTargetTest.h +++ b/sensors/common/vts/2_X/VtsHalSensorsV2_XTargetTest.h @@ -367,11 +367,13 @@ TEST_P(SensorsHidlTest, SensorListValid) { << s.sensorHandle << std::dec << " type=" << static_cast(s.type) << " name=" << s.name); - // Test non-empty type string - EXPECT_FALSE(s.typeAsString.empty()); - - // Test defined type matches defined string type - EXPECT_NO_FATAL_FAILURE(assertTypeMatchStringType(s.type, s.typeAsString)); + // Test type string non-empty only for private sensor types. + if (s.type >= SensorTypeVersion::DEVICE_PRIVATE_BASE) { + EXPECT_FALSE(s.typeAsString.empty()); + } else if (!s.typeAsString.empty()) { + // Test type string matches framework string if specified for non-private types. + EXPECT_NO_FATAL_FAILURE(assertTypeMatchStringType(s.type, s.typeAsString)); + } // Test if all sensor has name and vendor EXPECT_FALSE(s.name.empty());