diff options
author | Peng Xu <pengxu@google.com> | 2018-04-10 14:41:34 -0700 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2018-04-10 14:41:34 -0700 |
commit | f183230f4630e780180e4783f038c3133856d22e (patch) | |
tree | e63267974b8f4221e88ad047df396d815c3370a9 /sensors/1.0/vts/functional/VtsHalSensorsV1_0TargetTest.cpp | |
parent | 0477651e7f4ad74ff87fe89c285a01894c255548 (diff) | |
parent | 5b2f3f3c7cee0cb71b5e8074ce0f8eb58d0fbec1 (diff) | |
download | android_hardware_interfaces-f183230f4630e780180e4783f038c3133856d22e.tar.gz android_hardware_interfaces-f183230f4630e780180e4783f038c3133856d22e.tar.bz2 android_hardware_interfaces-f183230f4630e780180e4783f038c3133856d22e.zip |
Merge "Ignore meta sensor events when checking values" into oreo-vts-dev am: d09fdd6ca1 am: bfc5b817e7
am: 5b2f3f3c7c
Change-Id: Ic1d04b1a252274715b4f9a7168ffaf141e305c5b
Diffstat (limited to 'sensors/1.0/vts/functional/VtsHalSensorsV1_0TargetTest.cpp')
-rw-r--r-- | sensors/1.0/vts/functional/VtsHalSensorsV1_0TargetTest.cpp | 27 |
1 files 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 24b58a785..c18eedd17 100644 --- a/sensors/1.0/vts/functional/VtsHalSensorsV1_0TargetTest.cpp +++ b/sensors/1.0/vts/functional/VtsHalSensorsV1_0TargetTest.cpp @@ -956,6 +956,7 @@ void SensorsHidlTest::testStreamingOperation(SensorType type, std::chrono::seconds duration, const SensorEventsChecker &checker) { std::vector<Event> events; + std::vector<Event> sensorEvents; const int64_t samplingPeriodInNs = samplingPeriod.count(); const int64_t batchingPeriodInNs = 0; // no batching @@ -985,7 +986,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) { @@ -996,7 +996,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) { @@ -1008,9 +1008,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 @@ -1367,16 +1368,24 @@ void SensorsHidlTest::testDirectReportOperation( bool typeErrorReported = false; bool tokenErrorReported = false; bool timestampErrorReported = false; + std::vector<Event> 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"); @@ -1385,7 +1394,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, |