summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorThomas McGuire <thomas.mcguire.qnx@kdab.com>2012-07-09 10:54:25 +0200
committerQt by Nokia <qt-info@nokia.com>2012-07-23 00:18:31 +0200
commit505dbc8230414a31cd3def9f2d8b144b0e9444f4 (patch)
treeefaeb8654cab5e748ab94111ab8c560cf6a55b00 /tests
parent10218b43c4fa89aad8336bc7f35163723c05304b (diff)
downloadqtsensors-505dbc8230414a31cd3def9f2d8b144b0e9444f4.tar.gz
Add QSensor::isFeatureSupported()
Now it is possible to check if a backend supports a specific feature. During reviews of features like acceleration mode or duplicate skipping, the issue was raised how to check if these features are actually supported. The same is true for existing features like QMagnetometer::returnGeoValues. Change-Id: I47115d6c487bbcbb668a9021cdc7085e6780a67c Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Lorn Potter <lorn.potter@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qsensor/test_sensorimpl.cpp5
-rw-r--r--tests/auto/qsensor/test_sensorimpl.h1
-rw-r--r--tests/auto/qsensor/tst_qsensor.cpp21
3 files changed, 27 insertions, 0 deletions
diff --git a/tests/auto/qsensor/test_sensorimpl.cpp b/tests/auto/qsensor/test_sensorimpl.cpp
index 5b52d94..72a0dbd 100644
--- a/tests/auto/qsensor/test_sensorimpl.cpp
+++ b/tests/auto/qsensor/test_sensorimpl.cpp
@@ -117,3 +117,8 @@ void testsensorimpl::stop()
}
}
+bool testsensorimpl::isFeatureSupported(QSensor::Feature feature) const
+{
+ return (feature == QSensor::AlwaysOn || feature == QSensor::GeoValues);
+}
+
diff --git a/tests/auto/qsensor/test_sensorimpl.h b/tests/auto/qsensor/test_sensorimpl.h
index 37ccc13..1462ccb 100644
--- a/tests/auto/qsensor/test_sensorimpl.h
+++ b/tests/auto/qsensor/test_sensorimpl.h
@@ -56,6 +56,7 @@ public:
void start();
void stop();
+ bool isFeatureSupported(QSensor::Feature feature) const Q_DECL_OVERRIDE;
signals:
void emitBusyChanged();
diff --git a/tests/auto/qsensor/tst_qsensor.cpp b/tests/auto/qsensor/tst_qsensor.cpp
index 8025ab2..38c32e7 100644
--- a/tests/auto/qsensor/tst_qsensor.cpp
+++ b/tests/auto/qsensor/tst_qsensor.cpp
@@ -946,6 +946,27 @@ private slots:
sensor2.start();
QVERIFY(sensor2.isActive());
}
+
+ void testSupportedFeatures()
+ {
+ TestSensor sensor;
+
+ // Not connected to backend - should report false for any feature
+ QVERIFY(!sensor.isConnectedToBackend());
+ QVERIFY(!sensor.isFeatureSupported(QSensor::AlwaysOn));
+ QVERIFY(!sensor.isFeatureSupported(QSensor::Buffering));
+ QVERIFY(!sensor.isFeatureSupported(QSensor::GeoValues));
+ QVERIFY(!sensor.isFeatureSupported(QSensor::FieldOfView));
+
+ // Connect to backend - according to the testsensorimpl implementation, AlwaysOn and
+ // GeoValues should be supported afterwards
+ QVERIFY(sensor.connectToBackend());
+
+ QVERIFY(sensor.isFeatureSupported(QSensor::AlwaysOn));
+ QVERIFY(!sensor.isFeatureSupported(QSensor::Buffering));
+ QVERIFY(sensor.isFeatureSupported(QSensor::GeoValues));
+ QVERIFY(!sensor.isFeatureSupported(QSensor::FieldOfView));
+ }
};
QT_END_NAMESPACE