From 8ab752617f51d297b62d27849a5a459c4c84c9a2 Mon Sep 17 00:00:00 2001 From: Denis Ciocca Date: Sun, 3 May 2020 19:15:26 -0700 Subject: [PATCH] sensors:2.0:vts fix functional test for typeAsString field For sensors of known type defined in SensorType (value < DEVICE_PRIVATE_BASE), typeAsString field can be an empty string since framework overrides it anyways. The empty string test should fails only if type is >= DEVICE_PRIVATE_BASE. The matching type with typeAsString test is instead executed only if the string is not empty (if it's not an empty string let's check that at least is set to the right value). Bug: 155514483 Test: atest VtsHalSensorsV2_0TargetTest Signed-off-by: Denis Ciocca Merged-In: Ib5f8fd513313670e88c2b973c1ff724658914eb2 Change-Id: I4267ff6a158a571ff43122bdb7a38c9fa38f5900 --- .../vts/functional/VtsHalSensorsV2_0TargetTest.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/sensors/2.0/vts/functional/VtsHalSensorsV2_0TargetTest.cpp b/sensors/2.0/vts/functional/VtsHalSensorsV2_0TargetTest.cpp index d0ebe4d36f..e46f034d24 100644 --- a/sensors/2.0/vts/functional/VtsHalSensorsV2_0TargetTest.cpp +++ b/sensors/2.0/vts/functional/VtsHalSensorsV2_0TargetTest.cpp @@ -320,11 +320,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 >= SensorType::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());