summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJuha Vuolle <juha.vuolle@insta.fi>2021-06-02 14:24:35 +0300
committerJuha Vuolle <juha.vuolle@insta.fi>2021-06-03 10:36:33 +0300
commit530e6856a9345c87def7147be4d727aec26ec2fa (patch)
tree83c219f05ffda39cc1c9194883579a0e017a11aa /tests
parent28de5efc978ac772a877a82fe787e1ff109d414c (diff)
Fix tst_qsensor autotestcase to pass on android device
The main issue with running the autotests on an Android device is that the device has real sensors too and the test case is not prepared for that. This commit addresses this by allowing additional available sensors as well as specifying more specifically which sensor IDs to use for testing. Task-number: QTBUG-73617 Task-number: QTBUG-92513 Change-Id: I92180df6f5e8361d39134567616b21a3a51b636c Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alex Blasche <alexander.blasche@qt.io> Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qsensor/test_backends.h1
-rw-r--r--tests/auto/qsensor/tst_qsensor.cpp16
2 files changed, 7 insertions, 10 deletions
diff --git a/tests/auto/qsensor/test_backends.h b/tests/auto/qsensor/test_backends.h
index aba0b2f2..11dbe102 100644
--- a/tests/auto/qsensor/test_backends.h
+++ b/tests/auto/qsensor/test_backends.h
@@ -145,6 +145,7 @@ PREPARE_SENSORINTERFACE(QTiltSensor, QTiltReading, QTiltFilter, {
#define TEST_SENSORINTERFACE(SensorClass, ReadingClass, readingcode)\
do {\
SensorClass sensor;\
+ sensor.setIdentifier(#SensorClass); \
SensorClass ## _testfilter filter;\
sensor.addFilter(&filter);\
sensor.start();\
diff --git a/tests/auto/qsensor/tst_qsensor.cpp b/tests/auto/qsensor/tst_qsensor.cpp
index 34f44013..9b3e33b2 100644
--- a/tests/auto/qsensor/tst_qsensor.cpp
+++ b/tests/auto/qsensor/tst_qsensor.cpp
@@ -122,11 +122,9 @@ private slots:
void testTypeRegistered()
{
- QList<QByteArray> expected;
- expected << TestSensor::sensorType << TestSensor2::sensorType;
- QList<QByteArray> actual = QSensor::sensorTypes();
- std::sort(actual.begin(), actual.end()); // The actual list is not in a defined order
- QCOMPARE(actual, expected);
+ // Verify type registrations done by the test_sensorplugin
+ QVERIFY(QSensor::sensorTypes().contains(TestSensor::sensorType));
+ QVERIFY(QSensor::sensorTypes().contains(TestSensor2::sensorType));
}
void testSensorRegistered()
@@ -759,11 +757,9 @@ private slots:
QCOMPARE(sensor.sensorsChangedEmitted, 0);
// Make sure we've cleaned up the list of available types
- QList<QByteArray> expected;
- expected << TestSensor::sensorType << TestSensor2::sensorType;
- QList<QByteArray> actual = QSensor::sensorTypes();
- std::sort(actual.begin(), actual.end()); // The actual list is not in a defined order
- QCOMPARE(actual, expected);
+ QVERIFY(!QSensor::sensorTypes().contains("a random type"));
+ QVERIFY(QSensor::sensorTypes().contains(TestSensor::sensorType));
+ QVERIFY(QSensor::sensorTypes().contains(TestSensor2::sensorType));
}
void testSetActive()