From 23c91a2b545f3f191a5cb4e4c4b0acea8a1505f2 Mon Sep 17 00:00:00 2001 From: Peng Xu Date: Wed, 29 Nov 2017 21:28:12 -0800 Subject: [PATCH] Ignore meta sensor events when checking values Bug: 68729931 Test: verified by vendor, see b/68729931#comment5 Change-Id: I0f729c33409e409f0a64d9d4f609215cffde71f5 --- .../VtsHalSensorsV1_0TargetTest.cpp | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/sensors/1.0/vts/functional/VtsHalSensorsV1_0TargetTest.cpp b/sensors/1.0/vts/functional/VtsHalSensorsV1_0TargetTest.cpp index e4736bcd0e..3bb31a763e 100644 --- a/sensors/1.0/vts/functional/VtsHalSensorsV1_0TargetTest.cpp +++ b/sensors/1.0/vts/functional/VtsHalSensorsV1_0TargetTest.cpp @@ -911,6 +911,7 @@ void SensorsHidlTest::testStreamingOperation(SensorType type, std::chrono::seconds duration, const SensorEventsChecker &checker) { std::vector events; + std::vector sensorEvents; const int64_t samplingPeriodInNs = samplingPeriod.count(); const int64_t batchingPeriodInNs = 0; // no batching @@ -940,7 +941,6 @@ void SensorsHidlTest::testStreamingOperation(SensorType type, ASSERT_GT(events.size(), 0u); - size_t nRealEvent = 0; bool handleMismatchReported = false; bool metaSensorTypeErrorReported = false; for (auto & e : events) { @@ -951,7 +951,7 @@ void SensorsHidlTest::testStreamingOperation(SensorType type, << (handleMismatchReported = true, "Event of the same type must come from the sensor registered"); } - ++ nRealEvent; + sensorEvents.push_back(e); } else { // avoid generating hundreds of error if (!metaSensorTypeErrorReported) { @@ -963,9 +963,10 @@ void SensorsHidlTest::testStreamingOperation(SensorType type, } 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 @@ -1305,16 +1306,24 @@ void SensorsHidlTest::testDirectReportOperation( bool typeErrorReported = false; bool tokenErrorReported = false; bool timestampErrorReported = false; + std::vector sensorEvents; 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) { EXPECT_EQ(eventToken, e.sensorHandle) << (tokenErrorReported = true, "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) { EXPECT_GT(e.timestamp, lastTimestamp) << (timestampErrorReported = true, "Timestamp not monotonically increasing"); @@ -1323,7 +1332,7 @@ void SensorsHidlTest::testDirectReportOperation( } std::string s; - EXPECT_TRUE(checker.check(events, &s)) << s; + EXPECT_TRUE(checker.check(sensorEvents, &s)) << s; // stop sensor and unregister channel configDirectReport(sensor.sensorHandle, channelHandle, RateLevel::STOP,