Loading sensors/1.0/vts/functional/Android.bp +1 −1 Original line number Diff line number Diff line Loading @@ -31,6 +31,6 @@ cc_test { "android.hardware.sensors@1.0", "VtsHalSensorsTargetTestUtils", ], test_suites: ["general-tests"], test_suites: ["general-tests", "vts-core"], } sensors/1.0/vts/functional/AndroidTest.xml 0 → 100644 +39 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2019 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <configuration description="Runs VtsHalSensorsV1_0TargetTest."> <option name="test-suite-tag" value="apct" /> <option name="test-suite-tag" value="apct-native" /> <target_preparer class="com.android.tradefed.targetprep.RootTargetPreparer"> </target_preparer> <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer"> <option name="run-command" value="stop"/> <option name="teardown-command" value="start"/> </target_preparer> <target_preparer class="com.android.tradefed.targetprep.PushFilePreparer"> <option name="cleanup" value="true" /> <option name="push" value="VtsHalSensorsV1_0TargetTest->/data/local/tmp/VtsHalSensorsV1_0TargetTest" /> </target_preparer> <test class="com.android.tradefed.testtype.GTest" > <option name="native-test-timeout" value="900000" /> <option name="runtime-hint" value="300000"/> <option name="native-test-device-path" value="/data/local/tmp" /> <option name="module-name" value="VtsHalSensorsV1_0TargetTest" /> </test> </configuration> No newline at end of file sensors/1.0/vts/functional/SensorsHidlEnvironmentV1_0.cpp +1 −2 Original line number Diff line number Diff line Loading @@ -35,8 +35,7 @@ bool SensorsHidlEnvironmentV1_0::resetHal() { // this do ... while is for easy error handling do { step = "getService()"; sensors = ISensors::getService( SensorsHidlEnvironmentV1_0::Instance()->getServiceName<ISensors>()); sensors = ISensors::getService(mServiceName); if (sensors == nullptr) { break; } Loading sensors/1.0/vts/functional/SensorsHidlEnvironmentV1_0.h +3 −12 Original line number Diff line number Diff line Loading @@ -32,23 +32,14 @@ class SensorsHidlTest; class SensorsHidlEnvironmentV1_0 : public SensorsHidlEnvironmentBase { public: using Event = ::android::hardware::sensors::V1_0::Event; // get the test environment singleton static SensorsHidlEnvironmentV1_0* Instance() { static SensorsHidlEnvironmentV1_0* instance = new SensorsHidlEnvironmentV1_0(); return instance; } virtual void registerTestServices() override { registerTestService<android::hardware::sensors::V1_0::ISensors>(); } SensorsHidlEnvironmentV1_0(const std::string& service_name) : SensorsHidlEnvironmentBase(service_name) {} private: friend SensorsHidlTest; // sensors hidl service sp<android::hardware::sensors::V1_0::ISensors> sensors; SensorsHidlEnvironmentV1_0() {} bool resetHal() override; void startPollingThread() override; static void pollingThread(SensorsHidlEnvironmentV1_0* env, std::atomic_bool& stop); Loading sensors/1.0/vts/functional/VtsHalSensorsV1_0TargetTest.cpp +160 −171 Original line number Diff line number Diff line Loading @@ -19,6 +19,8 @@ #include <android/hardware/sensors/1.0/ISensors.h> #include <android/hardware/sensors/1.0/types.h> #include <hidl/GtestPrinter.h> #include <hidl/ServiceManagement.h> #include <log/log.h> #include <utils/SystemClock.h> Loading @@ -33,6 +35,16 @@ using namespace ::android::hardware::sensors::V1_0; // The main test class for SENSORS HIDL HAL. class SensorsHidlTest : public SensorsHidlTestBase { public: virtual void SetUp() override { mEnvironment = new SensorsHidlEnvironmentV1_0(GetParam()); mEnvironment->HidlSetUp(); // Ensure that we have a valid environment before performing tests ASSERT_NE(S(), nullptr); } virtual void TearDown() override { mEnvironment->HidlTearDown(); } protected: SensorInfo defaultSensorByType(SensorType type) override; std::vector<SensorInfo> getSensorsList(); Loading Loading @@ -66,11 +78,13 @@ class SensorsHidlTest : public SensorsHidlTestBase { return S()->configDirectReport(sensorHandle, channelHandle, rate, _hidl_cb); } inline sp<ISensors>& S() { return SensorsHidlEnvironmentV1_0::Instance()->sensors; } inline sp<ISensors>& S() { return mEnvironment->sensors; } SensorsHidlEnvironmentBase* getEnvironment() override { return SensorsHidlEnvironmentV1_0::Instance(); } SensorsHidlEnvironmentBase* getEnvironment() override { return mEnvironment; } private: // Test environment for sensors HAL. SensorsHidlEnvironmentV1_0* mEnvironment; }; Return<Result> SensorsHidlTest::activate(int32_t sensorHandle, bool enabled) { Loading Loading @@ -133,16 +147,15 @@ std::vector<SensorInfo> SensorsHidlTest::getSensorsList() { } // Test if sensor list returned is valid TEST_F(SensorsHidlTest, SensorListValid) { S()->getSensorsList( [&] (const auto &list) { TEST_P(SensorsHidlTest, SensorListValid) { S()->getSensorsList([&](const auto& list) { const size_t count = list.size(); for (size_t i = 0; i < count; ++i) { const auto& s = list[i]; SCOPED_TRACE(::testing::Message() << i << "/" << count << ": " SCOPED_TRACE(::testing::Message() << i << "/" << count << ": " << " handle=0x" << std::hex << std::setw(8) << std::setfill('0') << s.sensorHandle << std::dec << " type=" << static_cast<int>(s.type) << s.sensorHandle << std::dec << " type=" << static_cast<int>(s.type) << " name=" << s.name); // Test non-empty type string Loading @@ -160,9 +173,7 @@ TEST_F(SensorsHidlTest, SensorListValid) { EXPECT_LT(0, s.maxRange); // Info type, should have no sensor EXPECT_FALSE( s.type == SensorType::ADDITIONAL_INFO || s.type == SensorType::META_DATA); EXPECT_FALSE(s.type == SensorType::ADDITIONAL_INFO || s.type == SensorType::META_DATA); // Test fifoMax >= fifoReserved EXPECT_GE(s.fifoMaxEventCount, s.fifoReservedEventCount) Loading @@ -181,7 +192,7 @@ TEST_F(SensorsHidlTest, SensorListValid) { } // Test if sensor list returned is valid TEST_F(SensorsHidlTest, SetOperationMode) { TEST_P(SensorsHidlTest, SetOperationMode) { std::vector<SensorInfo> sensorList = getSensorsList(); bool needOperationModeSupport = Loading @@ -199,7 +210,7 @@ TEST_F(SensorsHidlTest, SetOperationMode) { } // Test if sensor list returned is valid TEST_F(SensorsHidlTest, InjectSensorEventData) { TEST_P(SensorsHidlTest, InjectSensorEventData) { std::vector<SensorInfo> sensorList = getSensorsList(); std::vector<SensorInfo> sensorSupportInjection; Loading Loading @@ -244,224 +255,202 @@ TEST_F(SensorsHidlTest, InjectSensorEventData) { } // Test if sensor hal can do UI speed accelerometer streaming properly TEST_F(SensorsHidlTest, AccelerometerStreamingOperationSlow) { testStreamingOperation(SensorType::ACCELEROMETER, std::chrono::milliseconds(200), std::chrono::seconds(5), sAccelNormChecker); TEST_P(SensorsHidlTest, AccelerometerStreamingOperationSlow) { testStreamingOperation(SensorType::ACCELEROMETER, std::chrono::milliseconds(200), std::chrono::seconds(5), sAccelNormChecker); } // Test if sensor hal can do normal speed accelerometer streaming properly TEST_F(SensorsHidlTest, AccelerometerStreamingOperationNormal) { testStreamingOperation(SensorType::ACCELEROMETER, std::chrono::milliseconds(20), std::chrono::seconds(5), sAccelNormChecker); TEST_P(SensorsHidlTest, AccelerometerStreamingOperationNormal) { testStreamingOperation(SensorType::ACCELEROMETER, std::chrono::milliseconds(20), std::chrono::seconds(5), sAccelNormChecker); } // Test if sensor hal can do game speed accelerometer streaming properly TEST_F(SensorsHidlTest, AccelerometerStreamingOperationFast) { testStreamingOperation(SensorType::ACCELEROMETER, std::chrono::milliseconds(5), std::chrono::seconds(5), sAccelNormChecker); TEST_P(SensorsHidlTest, AccelerometerStreamingOperationFast) { testStreamingOperation(SensorType::ACCELEROMETER, std::chrono::milliseconds(5), std::chrono::seconds(5), sAccelNormChecker); } // Test if sensor hal can do UI speed gyroscope streaming properly TEST_F(SensorsHidlTest, GyroscopeStreamingOperationSlow) { testStreamingOperation(SensorType::GYROSCOPE, std::chrono::milliseconds(200), std::chrono::seconds(5), sGyroNormChecker); TEST_P(SensorsHidlTest, GyroscopeStreamingOperationSlow) { testStreamingOperation(SensorType::GYROSCOPE, std::chrono::milliseconds(200), std::chrono::seconds(5), sGyroNormChecker); } // Test if sensor hal can do normal speed gyroscope streaming properly TEST_F(SensorsHidlTest, GyroscopeStreamingOperationNormal) { testStreamingOperation(SensorType::GYROSCOPE, std::chrono::milliseconds(20), std::chrono::seconds(5), sGyroNormChecker); TEST_P(SensorsHidlTest, GyroscopeStreamingOperationNormal) { testStreamingOperation(SensorType::GYROSCOPE, std::chrono::milliseconds(20), std::chrono::seconds(5), sGyroNormChecker); } // Test if sensor hal can do game speed gyroscope streaming properly TEST_F(SensorsHidlTest, GyroscopeStreamingOperationFast) { testStreamingOperation(SensorType::GYROSCOPE, std::chrono::milliseconds(5), std::chrono::seconds(5), sGyroNormChecker); TEST_P(SensorsHidlTest, GyroscopeStreamingOperationFast) { testStreamingOperation(SensorType::GYROSCOPE, std::chrono::milliseconds(5), std::chrono::seconds(5), sGyroNormChecker); } // Test if sensor hal can do UI speed magnetometer streaming properly TEST_F(SensorsHidlTest, MagnetometerStreamingOperationSlow) { testStreamingOperation(SensorType::MAGNETIC_FIELD, std::chrono::milliseconds(200), std::chrono::seconds(5), NullChecker()); TEST_P(SensorsHidlTest, MagnetometerStreamingOperationSlow) { testStreamingOperation(SensorType::MAGNETIC_FIELD, std::chrono::milliseconds(200), std::chrono::seconds(5), NullChecker()); } // Test if sensor hal can do normal speed magnetometer streaming properly TEST_F(SensorsHidlTest, MagnetometerStreamingOperationNormal) { testStreamingOperation(SensorType::MAGNETIC_FIELD, std::chrono::milliseconds(20), std::chrono::seconds(5), NullChecker()); TEST_P(SensorsHidlTest, MagnetometerStreamingOperationNormal) { testStreamingOperation(SensorType::MAGNETIC_FIELD, std::chrono::milliseconds(20), std::chrono::seconds(5), NullChecker()); } // Test if sensor hal can do game speed magnetometer streaming properly TEST_F(SensorsHidlTest, MagnetometerStreamingOperationFast) { testStreamingOperation(SensorType::MAGNETIC_FIELD, std::chrono::milliseconds(5), std::chrono::seconds(5), NullChecker()); TEST_P(SensorsHidlTest, MagnetometerStreamingOperationFast) { testStreamingOperation(SensorType::MAGNETIC_FIELD, std::chrono::milliseconds(5), std::chrono::seconds(5), NullChecker()); } // Test if sensor hal can do accelerometer sampling rate switch properly when sensor is active TEST_F(SensorsHidlTest, AccelerometerSamplingPeriodHotSwitchOperation) { TEST_P(SensorsHidlTest, AccelerometerSamplingPeriodHotSwitchOperation) { testSamplingRateHotSwitchOperation(SensorType::ACCELEROMETER); testSamplingRateHotSwitchOperation(SensorType::ACCELEROMETER, false /*fastToSlow*/); } // Test if sensor hal can do gyroscope sampling rate switch properly when sensor is active TEST_F(SensorsHidlTest, GyroscopeSamplingPeriodHotSwitchOperation) { TEST_P(SensorsHidlTest, GyroscopeSamplingPeriodHotSwitchOperation) { testSamplingRateHotSwitchOperation(SensorType::GYROSCOPE); testSamplingRateHotSwitchOperation(SensorType::GYROSCOPE, false /*fastToSlow*/); } // Test if sensor hal can do magnetometer sampling rate switch properly when sensor is active TEST_F(SensorsHidlTest, MagnetometerSamplingPeriodHotSwitchOperation) { TEST_P(SensorsHidlTest, MagnetometerSamplingPeriodHotSwitchOperation) { testSamplingRateHotSwitchOperation(SensorType::MAGNETIC_FIELD); testSamplingRateHotSwitchOperation(SensorType::MAGNETIC_FIELD, false /*fastToSlow*/); } // Test if sensor hal can do accelerometer batching properly TEST_F(SensorsHidlTest, AccelerometerBatchingOperation) { TEST_P(SensorsHidlTest, AccelerometerBatchingOperation) { testBatchingOperation(SensorType::ACCELEROMETER); } // Test if sensor hal can do gyroscope batching properly TEST_F(SensorsHidlTest, GyroscopeBatchingOperation) { TEST_P(SensorsHidlTest, GyroscopeBatchingOperation) { testBatchingOperation(SensorType::GYROSCOPE); } // Test if sensor hal can do magnetometer batching properly TEST_F(SensorsHidlTest, MagnetometerBatchingOperation) { TEST_P(SensorsHidlTest, MagnetometerBatchingOperation) { testBatchingOperation(SensorType::MAGNETIC_FIELD); } // Test sensor event direct report with ashmem for accel sensor at normal rate TEST_F(SensorsHidlTest, AccelerometerAshmemDirectReportOperationNormal) { TEST_P(SensorsHidlTest, AccelerometerAshmemDirectReportOperationNormal) { testDirectReportOperation(SensorType::ACCELEROMETER, SharedMemType::ASHMEM, RateLevel::NORMAL, sAccelNormChecker); } // Test sensor event direct report with ashmem for accel sensor at fast rate TEST_F(SensorsHidlTest, AccelerometerAshmemDirectReportOperationFast) { TEST_P(SensorsHidlTest, AccelerometerAshmemDirectReportOperationFast) { testDirectReportOperation(SensorType::ACCELEROMETER, SharedMemType::ASHMEM, RateLevel::FAST, sAccelNormChecker); } // Test sensor event direct report with ashmem for accel sensor at very fast rate TEST_F(SensorsHidlTest, AccelerometerAshmemDirectReportOperationVeryFast) { testDirectReportOperation(SensorType::ACCELEROMETER, SharedMemType::ASHMEM, RateLevel::VERY_FAST, sAccelNormChecker); TEST_P(SensorsHidlTest, AccelerometerAshmemDirectReportOperationVeryFast) { testDirectReportOperation(SensorType::ACCELEROMETER, SharedMemType::ASHMEM, RateLevel::VERY_FAST, sAccelNormChecker); } // Test sensor event direct report with ashmem for gyro sensor at normal rate TEST_F(SensorsHidlTest, GyroscopeAshmemDirectReportOperationNormal) { TEST_P(SensorsHidlTest, GyroscopeAshmemDirectReportOperationNormal) { testDirectReportOperation(SensorType::GYROSCOPE, SharedMemType::ASHMEM, RateLevel::NORMAL, sGyroNormChecker); } // Test sensor event direct report with ashmem for gyro sensor at fast rate TEST_F(SensorsHidlTest, GyroscopeAshmemDirectReportOperationFast) { TEST_P(SensorsHidlTest, GyroscopeAshmemDirectReportOperationFast) { testDirectReportOperation(SensorType::GYROSCOPE, SharedMemType::ASHMEM, RateLevel::FAST, sGyroNormChecker); } // Test sensor event direct report with ashmem for gyro sensor at very fast rate TEST_F(SensorsHidlTest, GyroscopeAshmemDirectReportOperationVeryFast) { TEST_P(SensorsHidlTest, GyroscopeAshmemDirectReportOperationVeryFast) { testDirectReportOperation(SensorType::GYROSCOPE, SharedMemType::ASHMEM, RateLevel::VERY_FAST, sGyroNormChecker); } // Test sensor event direct report with ashmem for mag sensor at normal rate TEST_F(SensorsHidlTest, MagnetometerAshmemDirectReportOperationNormal) { TEST_P(SensorsHidlTest, MagnetometerAshmemDirectReportOperationNormal) { testDirectReportOperation(SensorType::MAGNETIC_FIELD, SharedMemType::ASHMEM, RateLevel::NORMAL, NullChecker()); } // Test sensor event direct report with ashmem for mag sensor at fast rate TEST_F(SensorsHidlTest, MagnetometerAshmemDirectReportOperationFast) { TEST_P(SensorsHidlTest, MagnetometerAshmemDirectReportOperationFast) { testDirectReportOperation(SensorType::MAGNETIC_FIELD, SharedMemType::ASHMEM, RateLevel::FAST, NullChecker()); } // Test sensor event direct report with ashmem for mag sensor at very fast rate TEST_F(SensorsHidlTest, MagnetometerAshmemDirectReportOperationVeryFast) { testDirectReportOperation( SensorType::MAGNETIC_FIELD, SharedMemType::ASHMEM, RateLevel::VERY_FAST, NullChecker()); TEST_P(SensorsHidlTest, MagnetometerAshmemDirectReportOperationVeryFast) { testDirectReportOperation(SensorType::MAGNETIC_FIELD, SharedMemType::ASHMEM, RateLevel::VERY_FAST, NullChecker()); } // Test sensor event direct report with gralloc for accel sensor at normal rate TEST_F(SensorsHidlTest, AccelerometerGrallocDirectReportOperationNormal) { TEST_P(SensorsHidlTest, AccelerometerGrallocDirectReportOperationNormal) { testDirectReportOperation(SensorType::ACCELEROMETER, SharedMemType::GRALLOC, RateLevel::NORMAL, sAccelNormChecker); } // Test sensor event direct report with gralloc for accel sensor at fast rate TEST_F(SensorsHidlTest, AccelerometerGrallocDirectReportOperationFast) { TEST_P(SensorsHidlTest, AccelerometerGrallocDirectReportOperationFast) { testDirectReportOperation(SensorType::ACCELEROMETER, SharedMemType::GRALLOC, RateLevel::FAST, sAccelNormChecker); } // Test sensor event direct report with gralloc for accel sensor at very fast rate TEST_F(SensorsHidlTest, AccelerometerGrallocDirectReportOperationVeryFast) { testDirectReportOperation(SensorType::ACCELEROMETER, SharedMemType::GRALLOC, RateLevel::VERY_FAST, sAccelNormChecker); TEST_P(SensorsHidlTest, AccelerometerGrallocDirectReportOperationVeryFast) { testDirectReportOperation(SensorType::ACCELEROMETER, SharedMemType::GRALLOC, RateLevel::VERY_FAST, sAccelNormChecker); } // Test sensor event direct report with gralloc for gyro sensor at normal rate TEST_F(SensorsHidlTest, GyroscopeGrallocDirectReportOperationNormal) { TEST_P(SensorsHidlTest, GyroscopeGrallocDirectReportOperationNormal) { testDirectReportOperation(SensorType::GYROSCOPE, SharedMemType::GRALLOC, RateLevel::NORMAL, sGyroNormChecker); } // Test sensor event direct report with gralloc for gyro sensor at fast rate TEST_F(SensorsHidlTest, GyroscopeGrallocDirectReportOperationFast) { TEST_P(SensorsHidlTest, GyroscopeGrallocDirectReportOperationFast) { testDirectReportOperation(SensorType::GYROSCOPE, SharedMemType::GRALLOC, RateLevel::FAST, sGyroNormChecker); } // Test sensor event direct report with gralloc for gyro sensor at very fast rate TEST_F(SensorsHidlTest, GyroscopeGrallocDirectReportOperationVeryFast) { TEST_P(SensorsHidlTest, GyroscopeGrallocDirectReportOperationVeryFast) { testDirectReportOperation(SensorType::GYROSCOPE, SharedMemType::GRALLOC, RateLevel::VERY_FAST, sGyroNormChecker); } // Test sensor event direct report with gralloc for mag sensor at normal rate TEST_F(SensorsHidlTest, MagnetometerGrallocDirectReportOperationNormal) { TEST_P(SensorsHidlTest, MagnetometerGrallocDirectReportOperationNormal) { testDirectReportOperation(SensorType::MAGNETIC_FIELD, SharedMemType::GRALLOC, RateLevel::NORMAL, NullChecker()); } // Test sensor event direct report with gralloc for mag sensor at fast rate TEST_F(SensorsHidlTest, MagnetometerGrallocDirectReportOperationFast) { TEST_P(SensorsHidlTest, MagnetometerGrallocDirectReportOperationFast) { testDirectReportOperation(SensorType::MAGNETIC_FIELD, SharedMemType::GRALLOC, RateLevel::FAST, NullChecker()); } // Test sensor event direct report with gralloc for mag sensor at very fast rate TEST_F(SensorsHidlTest, MagnetometerGrallocDirectReportOperationVeryFast) { testDirectReportOperation( SensorType::MAGNETIC_FIELD, SharedMemType::GRALLOC, RateLevel::VERY_FAST, NullChecker()); TEST_P(SensorsHidlTest, MagnetometerGrallocDirectReportOperationVeryFast) { testDirectReportOperation(SensorType::MAGNETIC_FIELD, SharedMemType::GRALLOC, RateLevel::VERY_FAST, NullChecker()); } int main(int argc, char **argv) { ::testing::AddGlobalTestEnvironment(SensorsHidlEnvironmentV1_0::Instance()); ::testing::InitGoogleTest(&argc, argv); SensorsHidlEnvironmentV1_0::Instance()->init(&argc, argv); int status = RUN_ALL_TESTS(); ALOGI("Test result = %d", status); return status; } INSTANTIATE_TEST_SUITE_P( PerInstance, SensorsHidlTest, testing::ValuesIn(android::hardware::getAllHalInstanceNames(ISensors::descriptor)), android::hardware::PrintInstanceNameToString); // vim: set ts=2 sw=2 Loading
sensors/1.0/vts/functional/Android.bp +1 −1 Original line number Diff line number Diff line Loading @@ -31,6 +31,6 @@ cc_test { "android.hardware.sensors@1.0", "VtsHalSensorsTargetTestUtils", ], test_suites: ["general-tests"], test_suites: ["general-tests", "vts-core"], }
sensors/1.0/vts/functional/AndroidTest.xml 0 → 100644 +39 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2019 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <configuration description="Runs VtsHalSensorsV1_0TargetTest."> <option name="test-suite-tag" value="apct" /> <option name="test-suite-tag" value="apct-native" /> <target_preparer class="com.android.tradefed.targetprep.RootTargetPreparer"> </target_preparer> <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer"> <option name="run-command" value="stop"/> <option name="teardown-command" value="start"/> </target_preparer> <target_preparer class="com.android.tradefed.targetprep.PushFilePreparer"> <option name="cleanup" value="true" /> <option name="push" value="VtsHalSensorsV1_0TargetTest->/data/local/tmp/VtsHalSensorsV1_0TargetTest" /> </target_preparer> <test class="com.android.tradefed.testtype.GTest" > <option name="native-test-timeout" value="900000" /> <option name="runtime-hint" value="300000"/> <option name="native-test-device-path" value="/data/local/tmp" /> <option name="module-name" value="VtsHalSensorsV1_0TargetTest" /> </test> </configuration> No newline at end of file
sensors/1.0/vts/functional/SensorsHidlEnvironmentV1_0.cpp +1 −2 Original line number Diff line number Diff line Loading @@ -35,8 +35,7 @@ bool SensorsHidlEnvironmentV1_0::resetHal() { // this do ... while is for easy error handling do { step = "getService()"; sensors = ISensors::getService( SensorsHidlEnvironmentV1_0::Instance()->getServiceName<ISensors>()); sensors = ISensors::getService(mServiceName); if (sensors == nullptr) { break; } Loading
sensors/1.0/vts/functional/SensorsHidlEnvironmentV1_0.h +3 −12 Original line number Diff line number Diff line Loading @@ -32,23 +32,14 @@ class SensorsHidlTest; class SensorsHidlEnvironmentV1_0 : public SensorsHidlEnvironmentBase { public: using Event = ::android::hardware::sensors::V1_0::Event; // get the test environment singleton static SensorsHidlEnvironmentV1_0* Instance() { static SensorsHidlEnvironmentV1_0* instance = new SensorsHidlEnvironmentV1_0(); return instance; } virtual void registerTestServices() override { registerTestService<android::hardware::sensors::V1_0::ISensors>(); } SensorsHidlEnvironmentV1_0(const std::string& service_name) : SensorsHidlEnvironmentBase(service_name) {} private: friend SensorsHidlTest; // sensors hidl service sp<android::hardware::sensors::V1_0::ISensors> sensors; SensorsHidlEnvironmentV1_0() {} bool resetHal() override; void startPollingThread() override; static void pollingThread(SensorsHidlEnvironmentV1_0* env, std::atomic_bool& stop); Loading
sensors/1.0/vts/functional/VtsHalSensorsV1_0TargetTest.cpp +160 −171 Original line number Diff line number Diff line Loading @@ -19,6 +19,8 @@ #include <android/hardware/sensors/1.0/ISensors.h> #include <android/hardware/sensors/1.0/types.h> #include <hidl/GtestPrinter.h> #include <hidl/ServiceManagement.h> #include <log/log.h> #include <utils/SystemClock.h> Loading @@ -33,6 +35,16 @@ using namespace ::android::hardware::sensors::V1_0; // The main test class for SENSORS HIDL HAL. class SensorsHidlTest : public SensorsHidlTestBase { public: virtual void SetUp() override { mEnvironment = new SensorsHidlEnvironmentV1_0(GetParam()); mEnvironment->HidlSetUp(); // Ensure that we have a valid environment before performing tests ASSERT_NE(S(), nullptr); } virtual void TearDown() override { mEnvironment->HidlTearDown(); } protected: SensorInfo defaultSensorByType(SensorType type) override; std::vector<SensorInfo> getSensorsList(); Loading Loading @@ -66,11 +78,13 @@ class SensorsHidlTest : public SensorsHidlTestBase { return S()->configDirectReport(sensorHandle, channelHandle, rate, _hidl_cb); } inline sp<ISensors>& S() { return SensorsHidlEnvironmentV1_0::Instance()->sensors; } inline sp<ISensors>& S() { return mEnvironment->sensors; } SensorsHidlEnvironmentBase* getEnvironment() override { return SensorsHidlEnvironmentV1_0::Instance(); } SensorsHidlEnvironmentBase* getEnvironment() override { return mEnvironment; } private: // Test environment for sensors HAL. SensorsHidlEnvironmentV1_0* mEnvironment; }; Return<Result> SensorsHidlTest::activate(int32_t sensorHandle, bool enabled) { Loading Loading @@ -133,16 +147,15 @@ std::vector<SensorInfo> SensorsHidlTest::getSensorsList() { } // Test if sensor list returned is valid TEST_F(SensorsHidlTest, SensorListValid) { S()->getSensorsList( [&] (const auto &list) { TEST_P(SensorsHidlTest, SensorListValid) { S()->getSensorsList([&](const auto& list) { const size_t count = list.size(); for (size_t i = 0; i < count; ++i) { const auto& s = list[i]; SCOPED_TRACE(::testing::Message() << i << "/" << count << ": " SCOPED_TRACE(::testing::Message() << i << "/" << count << ": " << " handle=0x" << std::hex << std::setw(8) << std::setfill('0') << s.sensorHandle << std::dec << " type=" << static_cast<int>(s.type) << s.sensorHandle << std::dec << " type=" << static_cast<int>(s.type) << " name=" << s.name); // Test non-empty type string Loading @@ -160,9 +173,7 @@ TEST_F(SensorsHidlTest, SensorListValid) { EXPECT_LT(0, s.maxRange); // Info type, should have no sensor EXPECT_FALSE( s.type == SensorType::ADDITIONAL_INFO || s.type == SensorType::META_DATA); EXPECT_FALSE(s.type == SensorType::ADDITIONAL_INFO || s.type == SensorType::META_DATA); // Test fifoMax >= fifoReserved EXPECT_GE(s.fifoMaxEventCount, s.fifoReservedEventCount) Loading @@ -181,7 +192,7 @@ TEST_F(SensorsHidlTest, SensorListValid) { } // Test if sensor list returned is valid TEST_F(SensorsHidlTest, SetOperationMode) { TEST_P(SensorsHidlTest, SetOperationMode) { std::vector<SensorInfo> sensorList = getSensorsList(); bool needOperationModeSupport = Loading @@ -199,7 +210,7 @@ TEST_F(SensorsHidlTest, SetOperationMode) { } // Test if sensor list returned is valid TEST_F(SensorsHidlTest, InjectSensorEventData) { TEST_P(SensorsHidlTest, InjectSensorEventData) { std::vector<SensorInfo> sensorList = getSensorsList(); std::vector<SensorInfo> sensorSupportInjection; Loading Loading @@ -244,224 +255,202 @@ TEST_F(SensorsHidlTest, InjectSensorEventData) { } // Test if sensor hal can do UI speed accelerometer streaming properly TEST_F(SensorsHidlTest, AccelerometerStreamingOperationSlow) { testStreamingOperation(SensorType::ACCELEROMETER, std::chrono::milliseconds(200), std::chrono::seconds(5), sAccelNormChecker); TEST_P(SensorsHidlTest, AccelerometerStreamingOperationSlow) { testStreamingOperation(SensorType::ACCELEROMETER, std::chrono::milliseconds(200), std::chrono::seconds(5), sAccelNormChecker); } // Test if sensor hal can do normal speed accelerometer streaming properly TEST_F(SensorsHidlTest, AccelerometerStreamingOperationNormal) { testStreamingOperation(SensorType::ACCELEROMETER, std::chrono::milliseconds(20), std::chrono::seconds(5), sAccelNormChecker); TEST_P(SensorsHidlTest, AccelerometerStreamingOperationNormal) { testStreamingOperation(SensorType::ACCELEROMETER, std::chrono::milliseconds(20), std::chrono::seconds(5), sAccelNormChecker); } // Test if sensor hal can do game speed accelerometer streaming properly TEST_F(SensorsHidlTest, AccelerometerStreamingOperationFast) { testStreamingOperation(SensorType::ACCELEROMETER, std::chrono::milliseconds(5), std::chrono::seconds(5), sAccelNormChecker); TEST_P(SensorsHidlTest, AccelerometerStreamingOperationFast) { testStreamingOperation(SensorType::ACCELEROMETER, std::chrono::milliseconds(5), std::chrono::seconds(5), sAccelNormChecker); } // Test if sensor hal can do UI speed gyroscope streaming properly TEST_F(SensorsHidlTest, GyroscopeStreamingOperationSlow) { testStreamingOperation(SensorType::GYROSCOPE, std::chrono::milliseconds(200), std::chrono::seconds(5), sGyroNormChecker); TEST_P(SensorsHidlTest, GyroscopeStreamingOperationSlow) { testStreamingOperation(SensorType::GYROSCOPE, std::chrono::milliseconds(200), std::chrono::seconds(5), sGyroNormChecker); } // Test if sensor hal can do normal speed gyroscope streaming properly TEST_F(SensorsHidlTest, GyroscopeStreamingOperationNormal) { testStreamingOperation(SensorType::GYROSCOPE, std::chrono::milliseconds(20), std::chrono::seconds(5), sGyroNormChecker); TEST_P(SensorsHidlTest, GyroscopeStreamingOperationNormal) { testStreamingOperation(SensorType::GYROSCOPE, std::chrono::milliseconds(20), std::chrono::seconds(5), sGyroNormChecker); } // Test if sensor hal can do game speed gyroscope streaming properly TEST_F(SensorsHidlTest, GyroscopeStreamingOperationFast) { testStreamingOperation(SensorType::GYROSCOPE, std::chrono::milliseconds(5), std::chrono::seconds(5), sGyroNormChecker); TEST_P(SensorsHidlTest, GyroscopeStreamingOperationFast) { testStreamingOperation(SensorType::GYROSCOPE, std::chrono::milliseconds(5), std::chrono::seconds(5), sGyroNormChecker); } // Test if sensor hal can do UI speed magnetometer streaming properly TEST_F(SensorsHidlTest, MagnetometerStreamingOperationSlow) { testStreamingOperation(SensorType::MAGNETIC_FIELD, std::chrono::milliseconds(200), std::chrono::seconds(5), NullChecker()); TEST_P(SensorsHidlTest, MagnetometerStreamingOperationSlow) { testStreamingOperation(SensorType::MAGNETIC_FIELD, std::chrono::milliseconds(200), std::chrono::seconds(5), NullChecker()); } // Test if sensor hal can do normal speed magnetometer streaming properly TEST_F(SensorsHidlTest, MagnetometerStreamingOperationNormal) { testStreamingOperation(SensorType::MAGNETIC_FIELD, std::chrono::milliseconds(20), std::chrono::seconds(5), NullChecker()); TEST_P(SensorsHidlTest, MagnetometerStreamingOperationNormal) { testStreamingOperation(SensorType::MAGNETIC_FIELD, std::chrono::milliseconds(20), std::chrono::seconds(5), NullChecker()); } // Test if sensor hal can do game speed magnetometer streaming properly TEST_F(SensorsHidlTest, MagnetometerStreamingOperationFast) { testStreamingOperation(SensorType::MAGNETIC_FIELD, std::chrono::milliseconds(5), std::chrono::seconds(5), NullChecker()); TEST_P(SensorsHidlTest, MagnetometerStreamingOperationFast) { testStreamingOperation(SensorType::MAGNETIC_FIELD, std::chrono::milliseconds(5), std::chrono::seconds(5), NullChecker()); } // Test if sensor hal can do accelerometer sampling rate switch properly when sensor is active TEST_F(SensorsHidlTest, AccelerometerSamplingPeriodHotSwitchOperation) { TEST_P(SensorsHidlTest, AccelerometerSamplingPeriodHotSwitchOperation) { testSamplingRateHotSwitchOperation(SensorType::ACCELEROMETER); testSamplingRateHotSwitchOperation(SensorType::ACCELEROMETER, false /*fastToSlow*/); } // Test if sensor hal can do gyroscope sampling rate switch properly when sensor is active TEST_F(SensorsHidlTest, GyroscopeSamplingPeriodHotSwitchOperation) { TEST_P(SensorsHidlTest, GyroscopeSamplingPeriodHotSwitchOperation) { testSamplingRateHotSwitchOperation(SensorType::GYROSCOPE); testSamplingRateHotSwitchOperation(SensorType::GYROSCOPE, false /*fastToSlow*/); } // Test if sensor hal can do magnetometer sampling rate switch properly when sensor is active TEST_F(SensorsHidlTest, MagnetometerSamplingPeriodHotSwitchOperation) { TEST_P(SensorsHidlTest, MagnetometerSamplingPeriodHotSwitchOperation) { testSamplingRateHotSwitchOperation(SensorType::MAGNETIC_FIELD); testSamplingRateHotSwitchOperation(SensorType::MAGNETIC_FIELD, false /*fastToSlow*/); } // Test if sensor hal can do accelerometer batching properly TEST_F(SensorsHidlTest, AccelerometerBatchingOperation) { TEST_P(SensorsHidlTest, AccelerometerBatchingOperation) { testBatchingOperation(SensorType::ACCELEROMETER); } // Test if sensor hal can do gyroscope batching properly TEST_F(SensorsHidlTest, GyroscopeBatchingOperation) { TEST_P(SensorsHidlTest, GyroscopeBatchingOperation) { testBatchingOperation(SensorType::GYROSCOPE); } // Test if sensor hal can do magnetometer batching properly TEST_F(SensorsHidlTest, MagnetometerBatchingOperation) { TEST_P(SensorsHidlTest, MagnetometerBatchingOperation) { testBatchingOperation(SensorType::MAGNETIC_FIELD); } // Test sensor event direct report with ashmem for accel sensor at normal rate TEST_F(SensorsHidlTest, AccelerometerAshmemDirectReportOperationNormal) { TEST_P(SensorsHidlTest, AccelerometerAshmemDirectReportOperationNormal) { testDirectReportOperation(SensorType::ACCELEROMETER, SharedMemType::ASHMEM, RateLevel::NORMAL, sAccelNormChecker); } // Test sensor event direct report with ashmem for accel sensor at fast rate TEST_F(SensorsHidlTest, AccelerometerAshmemDirectReportOperationFast) { TEST_P(SensorsHidlTest, AccelerometerAshmemDirectReportOperationFast) { testDirectReportOperation(SensorType::ACCELEROMETER, SharedMemType::ASHMEM, RateLevel::FAST, sAccelNormChecker); } // Test sensor event direct report with ashmem for accel sensor at very fast rate TEST_F(SensorsHidlTest, AccelerometerAshmemDirectReportOperationVeryFast) { testDirectReportOperation(SensorType::ACCELEROMETER, SharedMemType::ASHMEM, RateLevel::VERY_FAST, sAccelNormChecker); TEST_P(SensorsHidlTest, AccelerometerAshmemDirectReportOperationVeryFast) { testDirectReportOperation(SensorType::ACCELEROMETER, SharedMemType::ASHMEM, RateLevel::VERY_FAST, sAccelNormChecker); } // Test sensor event direct report with ashmem for gyro sensor at normal rate TEST_F(SensorsHidlTest, GyroscopeAshmemDirectReportOperationNormal) { TEST_P(SensorsHidlTest, GyroscopeAshmemDirectReportOperationNormal) { testDirectReportOperation(SensorType::GYROSCOPE, SharedMemType::ASHMEM, RateLevel::NORMAL, sGyroNormChecker); } // Test sensor event direct report with ashmem for gyro sensor at fast rate TEST_F(SensorsHidlTest, GyroscopeAshmemDirectReportOperationFast) { TEST_P(SensorsHidlTest, GyroscopeAshmemDirectReportOperationFast) { testDirectReportOperation(SensorType::GYROSCOPE, SharedMemType::ASHMEM, RateLevel::FAST, sGyroNormChecker); } // Test sensor event direct report with ashmem for gyro sensor at very fast rate TEST_F(SensorsHidlTest, GyroscopeAshmemDirectReportOperationVeryFast) { TEST_P(SensorsHidlTest, GyroscopeAshmemDirectReportOperationVeryFast) { testDirectReportOperation(SensorType::GYROSCOPE, SharedMemType::ASHMEM, RateLevel::VERY_FAST, sGyroNormChecker); } // Test sensor event direct report with ashmem for mag sensor at normal rate TEST_F(SensorsHidlTest, MagnetometerAshmemDirectReportOperationNormal) { TEST_P(SensorsHidlTest, MagnetometerAshmemDirectReportOperationNormal) { testDirectReportOperation(SensorType::MAGNETIC_FIELD, SharedMemType::ASHMEM, RateLevel::NORMAL, NullChecker()); } // Test sensor event direct report with ashmem for mag sensor at fast rate TEST_F(SensorsHidlTest, MagnetometerAshmemDirectReportOperationFast) { TEST_P(SensorsHidlTest, MagnetometerAshmemDirectReportOperationFast) { testDirectReportOperation(SensorType::MAGNETIC_FIELD, SharedMemType::ASHMEM, RateLevel::FAST, NullChecker()); } // Test sensor event direct report with ashmem for mag sensor at very fast rate TEST_F(SensorsHidlTest, MagnetometerAshmemDirectReportOperationVeryFast) { testDirectReportOperation( SensorType::MAGNETIC_FIELD, SharedMemType::ASHMEM, RateLevel::VERY_FAST, NullChecker()); TEST_P(SensorsHidlTest, MagnetometerAshmemDirectReportOperationVeryFast) { testDirectReportOperation(SensorType::MAGNETIC_FIELD, SharedMemType::ASHMEM, RateLevel::VERY_FAST, NullChecker()); } // Test sensor event direct report with gralloc for accel sensor at normal rate TEST_F(SensorsHidlTest, AccelerometerGrallocDirectReportOperationNormal) { TEST_P(SensorsHidlTest, AccelerometerGrallocDirectReportOperationNormal) { testDirectReportOperation(SensorType::ACCELEROMETER, SharedMemType::GRALLOC, RateLevel::NORMAL, sAccelNormChecker); } // Test sensor event direct report with gralloc for accel sensor at fast rate TEST_F(SensorsHidlTest, AccelerometerGrallocDirectReportOperationFast) { TEST_P(SensorsHidlTest, AccelerometerGrallocDirectReportOperationFast) { testDirectReportOperation(SensorType::ACCELEROMETER, SharedMemType::GRALLOC, RateLevel::FAST, sAccelNormChecker); } // Test sensor event direct report with gralloc for accel sensor at very fast rate TEST_F(SensorsHidlTest, AccelerometerGrallocDirectReportOperationVeryFast) { testDirectReportOperation(SensorType::ACCELEROMETER, SharedMemType::GRALLOC, RateLevel::VERY_FAST, sAccelNormChecker); TEST_P(SensorsHidlTest, AccelerometerGrallocDirectReportOperationVeryFast) { testDirectReportOperation(SensorType::ACCELEROMETER, SharedMemType::GRALLOC, RateLevel::VERY_FAST, sAccelNormChecker); } // Test sensor event direct report with gralloc for gyro sensor at normal rate TEST_F(SensorsHidlTest, GyroscopeGrallocDirectReportOperationNormal) { TEST_P(SensorsHidlTest, GyroscopeGrallocDirectReportOperationNormal) { testDirectReportOperation(SensorType::GYROSCOPE, SharedMemType::GRALLOC, RateLevel::NORMAL, sGyroNormChecker); } // Test sensor event direct report with gralloc for gyro sensor at fast rate TEST_F(SensorsHidlTest, GyroscopeGrallocDirectReportOperationFast) { TEST_P(SensorsHidlTest, GyroscopeGrallocDirectReportOperationFast) { testDirectReportOperation(SensorType::GYROSCOPE, SharedMemType::GRALLOC, RateLevel::FAST, sGyroNormChecker); } // Test sensor event direct report with gralloc for gyro sensor at very fast rate TEST_F(SensorsHidlTest, GyroscopeGrallocDirectReportOperationVeryFast) { TEST_P(SensorsHidlTest, GyroscopeGrallocDirectReportOperationVeryFast) { testDirectReportOperation(SensorType::GYROSCOPE, SharedMemType::GRALLOC, RateLevel::VERY_FAST, sGyroNormChecker); } // Test sensor event direct report with gralloc for mag sensor at normal rate TEST_F(SensorsHidlTest, MagnetometerGrallocDirectReportOperationNormal) { TEST_P(SensorsHidlTest, MagnetometerGrallocDirectReportOperationNormal) { testDirectReportOperation(SensorType::MAGNETIC_FIELD, SharedMemType::GRALLOC, RateLevel::NORMAL, NullChecker()); } // Test sensor event direct report with gralloc for mag sensor at fast rate TEST_F(SensorsHidlTest, MagnetometerGrallocDirectReportOperationFast) { TEST_P(SensorsHidlTest, MagnetometerGrallocDirectReportOperationFast) { testDirectReportOperation(SensorType::MAGNETIC_FIELD, SharedMemType::GRALLOC, RateLevel::FAST, NullChecker()); } // Test sensor event direct report with gralloc for mag sensor at very fast rate TEST_F(SensorsHidlTest, MagnetometerGrallocDirectReportOperationVeryFast) { testDirectReportOperation( SensorType::MAGNETIC_FIELD, SharedMemType::GRALLOC, RateLevel::VERY_FAST, NullChecker()); TEST_P(SensorsHidlTest, MagnetometerGrallocDirectReportOperationVeryFast) { testDirectReportOperation(SensorType::MAGNETIC_FIELD, SharedMemType::GRALLOC, RateLevel::VERY_FAST, NullChecker()); } int main(int argc, char **argv) { ::testing::AddGlobalTestEnvironment(SensorsHidlEnvironmentV1_0::Instance()); ::testing::InitGoogleTest(&argc, argv); SensorsHidlEnvironmentV1_0::Instance()->init(&argc, argv); int status = RUN_ALL_TESTS(); ALOGI("Test result = %d", status); return status; } INSTANTIATE_TEST_SUITE_P( PerInstance, SensorsHidlTest, testing::ValuesIn(android::hardware::getAllHalInstanceNames(ISensors::descriptor)), android::hardware::PrintInstanceNameToString); // vim: set ts=2 sw=2