mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 16:50:18 +00:00
Merge "Convert VtsHalSensorsV*_0TargetTest to be parameterized."
am: c81f9c9958
Change-Id: Ice980ef12d9233974107165a1eb2fc14f4cd1dc9
This commit is contained in:
@@ -31,6 +31,6 @@ cc_test {
|
||||
"android.hardware.sensors@1.0",
|
||||
"VtsHalSensorsTargetTestUtils",
|
||||
],
|
||||
test_suites: ["general-tests"],
|
||||
test_suites: ["general-tests", "vts-core"],
|
||||
}
|
||||
|
||||
|
||||
39
sensors/1.0/vts/functional/AndroidTest.xml
Normal file
39
sensors/1.0/vts/functional/AndroidTest.xml
Normal file
@@ -0,0 +1,39 @@
|
||||
<?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>
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
SensorsHidlEnvironmentV1_0(const std::string& service_name)
|
||||
: SensorsHidlEnvironmentBase(service_name) {}
|
||||
|
||||
virtual void registerTestServices() override {
|
||||
registerTestService<android::hardware::sensors::V1_0::ISensors>();
|
||||
}
|
||||
|
||||
private:
|
||||
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);
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -33,7 +35,17 @@ using namespace ::android::hardware::sensors::V1_0;
|
||||
// The main test class for SENSORS HIDL HAL.
|
||||
|
||||
class SensorsHidlTest : public SensorsHidlTestBase {
|
||||
protected:
|
||||
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();
|
||||
// implementation wrapper
|
||||
@@ -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) {
|
||||
@@ -133,55 +147,52 @@ 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 << ": "
|
||||
<< " handle=0x" << std::hex << std::setw(8) << std::setfill('0')
|
||||
<< s.sensorHandle << std::dec
|
||||
<< " type=" << static_cast<int>(s.type)
|
||||
<< " name=" << s.name);
|
||||
const auto& s = list[i];
|
||||
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)
|
||||
<< " name=" << s.name);
|
||||
|
||||
// Test non-empty type string
|
||||
EXPECT_FALSE(s.typeAsString.empty());
|
||||
// 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 defined type matches defined string type
|
||||
EXPECT_NO_FATAL_FAILURE(assertTypeMatchStringType(s.type, s.typeAsString));
|
||||
|
||||
// Test if all sensor has name and vendor
|
||||
EXPECT_FALSE(s.name.empty());
|
||||
EXPECT_FALSE(s.vendor.empty());
|
||||
// Test if all sensor has name and vendor
|
||||
EXPECT_FALSE(s.name.empty());
|
||||
EXPECT_FALSE(s.vendor.empty());
|
||||
|
||||
// Test power > 0, maxRange > 0
|
||||
EXPECT_LE(0, s.power);
|
||||
EXPECT_LT(0, s.maxRange);
|
||||
// Test power > 0, maxRange > 0
|
||||
EXPECT_LE(0, s.power);
|
||||
EXPECT_LT(0, s.maxRange);
|
||||
|
||||
// Info type, should have no sensor
|
||||
EXPECT_FALSE(
|
||||
s.type == SensorType::ADDITIONAL_INFO
|
||||
|| s.type == SensorType::META_DATA);
|
||||
// Info type, should have no sensor
|
||||
EXPECT_FALSE(s.type == SensorType::ADDITIONAL_INFO || s.type == SensorType::META_DATA);
|
||||
|
||||
// Test fifoMax >= fifoReserved
|
||||
EXPECT_GE(s.fifoMaxEventCount, s.fifoReservedEventCount)
|
||||
<< "max=" << s.fifoMaxEventCount << " reserved=" << s.fifoReservedEventCount;
|
||||
// Test fifoMax >= fifoReserved
|
||||
EXPECT_GE(s.fifoMaxEventCount, s.fifoReservedEventCount)
|
||||
<< "max=" << s.fifoMaxEventCount << " reserved=" << s.fifoReservedEventCount;
|
||||
|
||||
// Test Reporting mode valid
|
||||
EXPECT_NO_FATAL_FAILURE(assertTypeMatchReportMode(s.type, extractReportMode(s.flags)));
|
||||
// Test Reporting mode valid
|
||||
EXPECT_NO_FATAL_FAILURE(assertTypeMatchReportMode(s.type, extractReportMode(s.flags)));
|
||||
|
||||
// Test min max are in the right order
|
||||
EXPECT_LE(s.minDelay, s.maxDelay);
|
||||
// Test min/max delay matches reporting mode
|
||||
EXPECT_NO_FATAL_FAILURE(
|
||||
assertDelayMatchReportMode(s.minDelay, s.maxDelay, extractReportMode(s.flags)));
|
||||
// Test min max are in the right order
|
||||
EXPECT_LE(s.minDelay, s.maxDelay);
|
||||
// Test min/max delay matches reporting mode
|
||||
EXPECT_NO_FATAL_FAILURE(
|
||||
assertDelayMatchReportMode(s.minDelay, s.maxDelay, extractReportMode(s.flags)));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Test if sensor list returned is valid
|
||||
TEST_F(SensorsHidlTest, SetOperationMode) {
|
||||
TEST_P(SensorsHidlTest, SetOperationMode) {
|
||||
std::vector<SensorInfo> sensorList = getSensorsList();
|
||||
|
||||
bool needOperationModeSupport =
|
||||
@@ -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;
|
||||
|
||||
@@ -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) {
|
||||
testSamplingRateHotSwitchOperation(SensorType::ACCELEROMETER);
|
||||
testSamplingRateHotSwitchOperation(SensorType::ACCELEROMETER, false /*fastToSlow*/);
|
||||
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) {
|
||||
testSamplingRateHotSwitchOperation(SensorType::GYROSCOPE);
|
||||
testSamplingRateHotSwitchOperation(SensorType::GYROSCOPE, false /*fastToSlow*/);
|
||||
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) {
|
||||
testSamplingRateHotSwitchOperation(SensorType::MAGNETIC_FIELD);
|
||||
testSamplingRateHotSwitchOperation(SensorType::MAGNETIC_FIELD, false /*fastToSlow*/);
|
||||
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) {
|
||||
testBatchingOperation(SensorType::ACCELEROMETER);
|
||||
TEST_P(SensorsHidlTest, AccelerometerBatchingOperation) {
|
||||
testBatchingOperation(SensorType::ACCELEROMETER);
|
||||
}
|
||||
|
||||
// Test if sensor hal can do gyroscope batching properly
|
||||
TEST_F(SensorsHidlTest, GyroscopeBatchingOperation) {
|
||||
testBatchingOperation(SensorType::GYROSCOPE);
|
||||
TEST_P(SensorsHidlTest, GyroscopeBatchingOperation) {
|
||||
testBatchingOperation(SensorType::GYROSCOPE);
|
||||
}
|
||||
|
||||
// Test if sensor hal can do magnetometer batching properly
|
||||
TEST_F(SensorsHidlTest, MagnetometerBatchingOperation) {
|
||||
testBatchingOperation(SensorType::MAGNETIC_FIELD);
|
||||
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) {
|
||||
testDirectReportOperation(SensorType::ACCELEROMETER, SharedMemType::ASHMEM, RateLevel::NORMAL,
|
||||
sAccelNormChecker);
|
||||
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) {
|
||||
testDirectReportOperation(SensorType::ACCELEROMETER, SharedMemType::ASHMEM, RateLevel::FAST,
|
||||
sAccelNormChecker);
|
||||
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) {
|
||||
testDirectReportOperation(SensorType::GYROSCOPE, SharedMemType::ASHMEM, RateLevel::NORMAL,
|
||||
sGyroNormChecker);
|
||||
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) {
|
||||
testDirectReportOperation(SensorType::GYROSCOPE, SharedMemType::ASHMEM, RateLevel::FAST,
|
||||
sGyroNormChecker);
|
||||
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) {
|
||||
testDirectReportOperation(SensorType::GYROSCOPE, SharedMemType::ASHMEM, RateLevel::VERY_FAST,
|
||||
sGyroNormChecker);
|
||||
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) {
|
||||
testDirectReportOperation(SensorType::MAGNETIC_FIELD, SharedMemType::ASHMEM, RateLevel::NORMAL,
|
||||
NullChecker());
|
||||
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) {
|
||||
testDirectReportOperation(SensorType::MAGNETIC_FIELD, SharedMemType::ASHMEM, RateLevel::FAST,
|
||||
NullChecker());
|
||||
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) {
|
||||
testDirectReportOperation(SensorType::ACCELEROMETER, SharedMemType::GRALLOC, RateLevel::NORMAL,
|
||||
sAccelNormChecker);
|
||||
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) {
|
||||
testDirectReportOperation(SensorType::ACCELEROMETER, SharedMemType::GRALLOC, RateLevel::FAST,
|
||||
sAccelNormChecker);
|
||||
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) {
|
||||
testDirectReportOperation(SensorType::GYROSCOPE, SharedMemType::GRALLOC, RateLevel::NORMAL,
|
||||
sGyroNormChecker);
|
||||
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) {
|
||||
testDirectReportOperation(SensorType::GYROSCOPE, SharedMemType::GRALLOC, RateLevel::FAST,
|
||||
sGyroNormChecker);
|
||||
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) {
|
||||
testDirectReportOperation(SensorType::GYROSCOPE, SharedMemType::GRALLOC, RateLevel::VERY_FAST,
|
||||
sGyroNormChecker);
|
||||
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) {
|
||||
testDirectReportOperation(SensorType::MAGNETIC_FIELD, SharedMemType::GRALLOC, RateLevel::NORMAL,
|
||||
NullChecker());
|
||||
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) {
|
||||
testDirectReportOperation(SensorType::MAGNETIC_FIELD, SharedMemType::GRALLOC, RateLevel::FAST,
|
||||
NullChecker());
|
||||
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
|
||||
|
||||
39
sensors/2.0/vts/functional/AndroidTest.xml
Normal file
39
sensors/2.0/vts/functional/AndroidTest.xml
Normal file
@@ -0,0 +1,39 @@
|
||||
<?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 VtsHalSensorsV2_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="VtsHalSensorsV2_0TargetTest->/data/local/tmp/VtsHalSensorsV2_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="VtsHalSensorsV2_0TargetTest" />
|
||||
</test>
|
||||
</configuration>
|
||||
@@ -58,8 +58,7 @@ struct SensorsCallback : ISensorsCallback {
|
||||
bool SensorsHidlEnvironmentV2_0::resetHal() {
|
||||
bool succeed = false;
|
||||
do {
|
||||
mSensors = ISensors::getService(
|
||||
SensorsHidlEnvironmentV2_0::Instance()->getServiceName<ISensors>());
|
||||
mSensors = ISensors::getService(mServiceName);
|
||||
if (mSensors == nullptr) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -42,22 +42,12 @@ class SensorsHalDeathRecipient : public ::android::hardware::hidl_death_recipien
|
||||
class SensorsHidlEnvironmentV2_0 : public SensorsHidlEnvironmentBase {
|
||||
public:
|
||||
using Event = ::android::hardware::sensors::V1_0::Event;
|
||||
// get the test environment singleton
|
||||
static SensorsHidlEnvironmentV2_0* Instance() {
|
||||
static SensorsHidlEnvironmentV2_0* instance = new SensorsHidlEnvironmentV2_0();
|
||||
return instance;
|
||||
}
|
||||
|
||||
virtual void registerTestServices() override {
|
||||
registerTestService<android::hardware::sensors::V2_0::ISensors>();
|
||||
}
|
||||
|
||||
virtual void HidlTearDown() override;
|
||||
|
||||
protected:
|
||||
friend SensorsHidlTest;
|
||||
|
||||
SensorsHidlEnvironmentV2_0() : mEventQueueFlag(nullptr) {}
|
||||
SensorsHidlEnvironmentV2_0(const std::string& service_name)
|
||||
: SensorsHidlEnvironmentBase(service_name), mEventQueueFlag(nullptr) {}
|
||||
|
||||
/**
|
||||
* Resets the HAL with new FMQs and a new Event Flag
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
|
||||
#include <android/hardware/sensors/2.0/ISensors.h>
|
||||
#include <android/hardware/sensors/2.0/types.h>
|
||||
#include <hidl/GtestPrinter.h>
|
||||
#include <hidl/ServiceManagement.h>
|
||||
#include <log/log.h>
|
||||
#include <utils/SystemClock.h>
|
||||
|
||||
@@ -120,10 +122,14 @@ class EventCallback : public IEventCallback {
|
||||
class SensorsHidlTest : public SensorsHidlTestBase {
|
||||
public:
|
||||
virtual void SetUp() override {
|
||||
mEnvironment = new SensorsHidlEnvironmentV2_0(GetParam());
|
||||
mEnvironment->HidlSetUp();
|
||||
// Ensure that we have a valid environment before performing tests
|
||||
ASSERT_NE(getSensors(), nullptr);
|
||||
}
|
||||
|
||||
virtual void TearDown() override { mEnvironment->HidlTearDown(); }
|
||||
|
||||
protected:
|
||||
SensorInfo defaultSensorByType(SensorType type) override;
|
||||
std::vector<SensorInfo> getSensorsList();
|
||||
@@ -160,12 +166,10 @@ class SensorsHidlTest : public SensorsHidlTestBase {
|
||||
}
|
||||
|
||||
inline sp<::android::hardware::sensors::V2_0::ISensors>& getSensors() {
|
||||
return SensorsHidlEnvironmentV2_0::Instance()->mSensors;
|
||||
return mEnvironment->mSensors;
|
||||
}
|
||||
|
||||
SensorsHidlEnvironmentBase* getEnvironment() override {
|
||||
return SensorsHidlEnvironmentV2_0::Instance();
|
||||
}
|
||||
SensorsHidlEnvironmentBase* getEnvironment() override { return mEnvironment; }
|
||||
|
||||
// Test helpers
|
||||
void runSingleFlushTest(const std::vector<SensorInfo>& sensors, bool activateSensor,
|
||||
@@ -191,6 +195,10 @@ class SensorsHidlTest : public SensorsHidlTestBase {
|
||||
void checkRateLevel(const SensorInfo& sensor, int32_t directChannelHandle, RateLevel rateLevel);
|
||||
void queryDirectChannelSupport(SharedMemType memType, bool* supportsSharedMemType,
|
||||
bool* supportsAnyDirectChannel);
|
||||
|
||||
private:
|
||||
// Test environment for sensors HAL.
|
||||
SensorsHidlEnvironmentV2_0* mEnvironment;
|
||||
};
|
||||
|
||||
Return<Result> SensorsHidlTest::activate(int32_t sensorHandle, bool enabled) {
|
||||
@@ -301,7 +309,7 @@ int32_t SensorsHidlTest::getInvalidSensorHandle() {
|
||||
}
|
||||
|
||||
// Test if sensor list returned is valid
|
||||
TEST_F(SensorsHidlTest, SensorListValid) {
|
||||
TEST_P(SensorsHidlTest, SensorListValid) {
|
||||
getSensors()->getSensorsList([&](const auto& list) {
|
||||
const size_t count = list.size();
|
||||
for (size_t i = 0; i < count; ++i) {
|
||||
@@ -346,7 +354,7 @@ TEST_F(SensorsHidlTest, SensorListValid) {
|
||||
}
|
||||
|
||||
// Test that SetOperationMode returns the expected value
|
||||
TEST_F(SensorsHidlTest, SetOperationMode) {
|
||||
TEST_P(SensorsHidlTest, SetOperationMode) {
|
||||
std::vector<SensorInfo> sensors = getInjectEventSensors();
|
||||
if (getInjectEventSensors().size() > 0) {
|
||||
ASSERT_EQ(Result::OK, getSensors()->setOperationMode(OperationMode::NORMAL));
|
||||
@@ -358,7 +366,7 @@ TEST_F(SensorsHidlTest, SetOperationMode) {
|
||||
}
|
||||
|
||||
// Test that an injected event is written back to the Event FMQ
|
||||
TEST_F(SensorsHidlTest, InjectSensorEventData) {
|
||||
TEST_P(SensorsHidlTest, InjectSensorEventData) {
|
||||
std::vector<SensorInfo> sensors = getInjectEventSensors();
|
||||
if (sensors.size() == 0) {
|
||||
return;
|
||||
@@ -414,196 +422,196 @@ TEST_F(SensorsHidlTest, InjectSensorEventData) {
|
||||
}
|
||||
|
||||
// Test if sensor hal can do UI speed accelerometer streaming properly
|
||||
TEST_F(SensorsHidlTest, AccelerometerStreamingOperationSlow) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
TEST_P(SensorsHidlTest, MagnetometerGrallocDirectReportOperationVeryFast) {
|
||||
testDirectReportOperation(SensorType::MAGNETIC_FIELD, SharedMemType::GRALLOC,
|
||||
RateLevel::VERY_FAST, NullChecker());
|
||||
}
|
||||
@@ -619,9 +627,13 @@ void SensorsHidlTest::activateAllSensors(bool enable) {
|
||||
|
||||
// Test that if initialize is called twice, then the HAL writes events to the FMQs from the second
|
||||
// call to the function.
|
||||
TEST_F(SensorsHidlTest, CallInitializeTwice) {
|
||||
TEST_P(SensorsHidlTest, CallInitializeTwice) {
|
||||
// Create a helper class so that a second environment is able to be instantiated
|
||||
class SensorsHidlEnvironmentTest : public SensorsHidlEnvironmentV2_0 {};
|
||||
class SensorsHidlEnvironmentTest : public SensorsHidlEnvironmentV2_0 {
|
||||
public:
|
||||
SensorsHidlEnvironmentTest(const std::string& service_name)
|
||||
: SensorsHidlEnvironmentV2_0(service_name) {}
|
||||
};
|
||||
|
||||
if (getSensorsList().size() == 0) {
|
||||
// No sensors
|
||||
@@ -633,7 +645,7 @@ TEST_F(SensorsHidlTest, CallInitializeTwice) {
|
||||
|
||||
// Create a new environment that calls initialize()
|
||||
std::unique_ptr<SensorsHidlEnvironmentTest> newEnv =
|
||||
std::make_unique<SensorsHidlEnvironmentTest>();
|
||||
std::make_unique<SensorsHidlEnvironmentTest>(GetParam());
|
||||
newEnv->HidlSetUp();
|
||||
if (HasFatalFailure()) {
|
||||
return; // Exit early if setting up the new environment failed
|
||||
@@ -662,7 +674,7 @@ TEST_F(SensorsHidlTest, CallInitializeTwice) {
|
||||
activateAllSensors(false);
|
||||
}
|
||||
|
||||
TEST_F(SensorsHidlTest, CleanupConnectionsOnInitialize) {
|
||||
TEST_P(SensorsHidlTest, CleanupConnectionsOnInitialize) {
|
||||
activateAllSensors(true);
|
||||
|
||||
// Verify that events are received
|
||||
@@ -731,7 +743,7 @@ void SensorsHidlTest::runFlushTest(const std::vector<SensorInfo>& sensors, bool
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(SensorsHidlTest, FlushSensor) {
|
||||
TEST_P(SensorsHidlTest, FlushSensor) {
|
||||
// Find a sensor that is not a one-shot sensor
|
||||
std::vector<SensorInfo> sensors = getNonOneShotSensors();
|
||||
if (sensors.size() == 0) {
|
||||
@@ -743,7 +755,7 @@ TEST_F(SensorsHidlTest, FlushSensor) {
|
||||
runFlushTest(sensors, true /* activateSensor */, kFlushes, kFlushes, Result::OK);
|
||||
}
|
||||
|
||||
TEST_F(SensorsHidlTest, FlushOneShotSensor) {
|
||||
TEST_P(SensorsHidlTest, FlushOneShotSensor) {
|
||||
// Find a sensor that is a one-shot sensor
|
||||
std::vector<SensorInfo> sensors = getOneShotSensors();
|
||||
if (sensors.size() == 0) {
|
||||
@@ -754,7 +766,7 @@ TEST_F(SensorsHidlTest, FlushOneShotSensor) {
|
||||
Result::BAD_VALUE);
|
||||
}
|
||||
|
||||
TEST_F(SensorsHidlTest, FlushInactiveSensor) {
|
||||
TEST_P(SensorsHidlTest, FlushInactiveSensor) {
|
||||
// Attempt to find a non-one shot sensor, then a one-shot sensor if necessary
|
||||
std::vector<SensorInfo> sensors = getNonOneShotSensors();
|
||||
if (sensors.size() == 0) {
|
||||
@@ -768,7 +780,7 @@ TEST_F(SensorsHidlTest, FlushInactiveSensor) {
|
||||
Result::BAD_VALUE);
|
||||
}
|
||||
|
||||
TEST_F(SensorsHidlTest, FlushNonexistentSensor) {
|
||||
TEST_P(SensorsHidlTest, FlushNonexistentSensor) {
|
||||
SensorInfo sensor;
|
||||
std::vector<SensorInfo> sensors = getNonOneShotSensors();
|
||||
if (sensors.size() == 0) {
|
||||
@@ -783,7 +795,7 @@ TEST_F(SensorsHidlTest, FlushNonexistentSensor) {
|
||||
0 /* expectedFlushCount */, Result::BAD_VALUE);
|
||||
}
|
||||
|
||||
TEST_F(SensorsHidlTest, Batch) {
|
||||
TEST_P(SensorsHidlTest, Batch) {
|
||||
if (getSensorsList().size() == 0) {
|
||||
return;
|
||||
}
|
||||
@@ -815,7 +827,7 @@ TEST_F(SensorsHidlTest, Batch) {
|
||||
Result::BAD_VALUE);
|
||||
}
|
||||
|
||||
TEST_F(SensorsHidlTest, Activate) {
|
||||
TEST_P(SensorsHidlTest, Activate) {
|
||||
if (getSensorsList().size() == 0) {
|
||||
return;
|
||||
}
|
||||
@@ -841,7 +853,7 @@ TEST_F(SensorsHidlTest, Activate) {
|
||||
ASSERT_EQ(activate(invalidHandle, false), Result::BAD_VALUE);
|
||||
}
|
||||
|
||||
TEST_F(SensorsHidlTest, NoStaleEvents) {
|
||||
TEST_P(SensorsHidlTest, NoStaleEvents) {
|
||||
constexpr milliseconds kFiveHundredMs(500);
|
||||
constexpr milliseconds kOneSecond(1000);
|
||||
|
||||
@@ -1021,11 +1033,11 @@ void SensorsHidlTest::verifyDirectChannel(SharedMemType memType) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(SensorsHidlTest, DirectChannelAshmem) {
|
||||
TEST_P(SensorsHidlTest, DirectChannelAshmem) {
|
||||
verifyDirectChannel(SharedMemType::ASHMEM);
|
||||
}
|
||||
|
||||
TEST_F(SensorsHidlTest, DirectChannelGralloc) {
|
||||
TEST_P(SensorsHidlTest, DirectChannelGralloc) {
|
||||
verifyDirectChannel(SharedMemType::GRALLOC);
|
||||
}
|
||||
|
||||
@@ -1064,7 +1076,7 @@ bool SensorsHidlTest::getDirectChannelSensor(SensorInfo* sensor, SharedMemType*
|
||||
return found;
|
||||
}
|
||||
|
||||
TEST_F(SensorsHidlTest, ConfigureDirectChannelWithInvalidHandle) {
|
||||
TEST_P(SensorsHidlTest, ConfigureDirectChannelWithInvalidHandle) {
|
||||
SensorInfo sensor;
|
||||
SharedMemType memType;
|
||||
RateLevel rate;
|
||||
@@ -1078,7 +1090,7 @@ TEST_F(SensorsHidlTest, ConfigureDirectChannelWithInvalidHandle) {
|
||||
});
|
||||
}
|
||||
|
||||
TEST_F(SensorsHidlTest, CleanupDirectConnectionOnInitialize) {
|
||||
TEST_P(SensorsHidlTest, CleanupDirectConnectionOnInitialize) {
|
||||
constexpr size_t kNumEvents = 1;
|
||||
constexpr size_t kMemSize = kNumEvents * kEventSize;
|
||||
|
||||
@@ -1124,12 +1136,8 @@ TEST_F(SensorsHidlTest, CleanupDirectConnectionOnInitialize) {
|
||||
mDirectChannelHandles = handles;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
::testing::AddGlobalTestEnvironment(SensorsHidlEnvironmentV2_0::Instance());
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
SensorsHidlEnvironmentV2_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(
|
||||
android::hardware::sensors::V2_0::ISensors::descriptor)),
|
||||
android::hardware::PrintInstanceNameToString);
|
||||
// vim: set ts=2 sw=2
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
cc_library_static {
|
||||
name: "VtsHalSensorsTargetTestUtils",
|
||||
defaults: ["VtsHalTargetTestDefaults"],
|
||||
cflags: ["-DLOG_TAG=\"sensors_hidl_hal_test\""],
|
||||
srcs: [
|
||||
"GrallocWrapper.cpp",
|
||||
@@ -36,6 +37,5 @@ cc_library_static {
|
||||
"android.hardware.graphics.mapper@2.1",
|
||||
"android.hardware.graphics.mapper@3.0",
|
||||
"android.hardware.sensors@1.0",
|
||||
"VtsHalHidlTargetTestBase",
|
||||
],
|
||||
}
|
||||
|
||||
@@ -17,9 +17,8 @@
|
||||
#ifndef ANDROID_SENSORS_HIDL_ENVIRONMENT_BASE_H
|
||||
#define ANDROID_SENSORS_HIDL_ENVIRONMENT_BASE_H
|
||||
|
||||
#include <VtsHalHidlTargetTestEnvBase.h>
|
||||
|
||||
#include <android/hardware/sensors/1.0/types.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
@@ -33,11 +32,11 @@ class IEventCallback {
|
||||
virtual void onEvent(const ::android::hardware::sensors::V1_0::Event& event) = 0;
|
||||
};
|
||||
|
||||
class SensorsHidlEnvironmentBase : public ::testing::VtsHalHidlTargetTestEnvBase {
|
||||
public:
|
||||
class SensorsHidlEnvironmentBase {
|
||||
public:
|
||||
using Event = ::android::hardware::sensors::V1_0::Event;
|
||||
virtual void HidlSetUp() override;
|
||||
virtual void HidlTearDown() override;
|
||||
virtual void HidlSetUp();
|
||||
virtual void HidlTearDown();
|
||||
|
||||
// Get and clear all events collected so far (like "cat" shell command).
|
||||
// If output is nullptr, it clears all collected events.
|
||||
@@ -50,22 +49,27 @@ class SensorsHidlEnvironmentBase : public ::testing::VtsHalHidlTargetTestEnvBase
|
||||
void unregisterCallback();
|
||||
|
||||
protected:
|
||||
SensorsHidlEnvironmentBase() : mCollectionEnabled(false), mCallback(nullptr) {}
|
||||
SensorsHidlEnvironmentBase(const std::string& service_name)
|
||||
: mCollectionEnabled(false), mCallback(nullptr) {
|
||||
mServiceName = service_name;
|
||||
}
|
||||
virtual ~SensorsHidlEnvironmentBase(){};
|
||||
|
||||
void addEvent(const Event& ev);
|
||||
void addEvent(const Event& ev);
|
||||
|
||||
virtual void startPollingThread() = 0;
|
||||
virtual bool resetHal() = 0;
|
||||
virtual void startPollingThread() = 0;
|
||||
virtual bool resetHal() = 0;
|
||||
|
||||
bool mCollectionEnabled;
|
||||
std::atomic_bool mStopThread;
|
||||
std::thread mPollThread;
|
||||
std::vector<Event> mEvents;
|
||||
std::mutex mEventsMutex;
|
||||
std::string mServiceName;
|
||||
bool mCollectionEnabled;
|
||||
std::atomic_bool mStopThread;
|
||||
std::thread mPollThread;
|
||||
std::vector<Event> mEvents;
|
||||
std::mutex mEventsMutex;
|
||||
|
||||
IEventCallback* mCallback;
|
||||
IEventCallback* mCallback;
|
||||
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(SensorsHidlEnvironmentBase);
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(SensorsHidlEnvironmentBase);
|
||||
};
|
||||
|
||||
#endif // ANDROID_SENSORS_HIDL_ENVIRONMENT_BASE_H
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <VtsHalHidlTargetTestBase.h>
|
||||
#include <android/hardware/sensors/1.0/ISensors.h>
|
||||
#include <android/hardware/sensors/1.0/types.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
@@ -44,8 +45,8 @@ using ::android::hardware::sensors::V1_0::SensorType;
|
||||
using ::android::hardware::sensors::V1_0::SharedMemInfo;
|
||||
using ::android::hardware::sensors::V1_0::SharedMemType;
|
||||
|
||||
class SensorsHidlTestBase : public ::testing::VtsHalHidlTargetTestBase {
|
||||
public:
|
||||
class SensorsHidlTestBase : public testing::TestWithParam<std::string> {
|
||||
public:
|
||||
virtual SensorsHidlEnvironmentBase* getEnvironment() = 0;
|
||||
virtual void SetUp() override {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user