diff options
author | Juha Vuolle <juha.vuolle@insta.fi> | 2021-01-05 14:27:16 +0200 |
---|---|---|
committer | Juha Vuolle <juha.vuolle@insta.fi> | 2021-04-19 13:29:44 +0300 |
commit | 5a8aa096dc61336ac95734e8cc61f106e359c865 (patch) | |
tree | 20b1c3f3932b48bb6020a3d40d0dacf1abc6be2d /tests/auto | |
parent | 7dbb79c428f813e32986ccfe09a42f7d61a4c005 (diff) |
Base commit to make QtSensors runnable on Windows
Fair amount of work remains after the commit still, but this should
allow further development as a compilable baseline: code compiles,
autotests pass, and most example applications at least start.
The changes:
-Change examples to use QtQuickControls 2 as per removal of v1
-Fix ambiguous conditional expression compilation error
-Link against runtimeobject library (previously part of winrt QPA?)
-Change the .pro file rule to win32 as winrt moniker does not exist anymore
-Remove references to deleted winrt event dispatcher
-Fix error handling: getdefault may be successful even if there is no default sensor
-Fix QCOMPARE failure output (toString has changed in Qt6)
-Remove qtimestamp alias which was deprecated already in Qt5
-Remove unit test hook that does not seem to be used anywhere
-From typedef to ‘using’ for readability
-Q_ENUMS -> Q_ENUM as the former has been obsoleted by the latter
-Add qt6 changes qdoc page
Task-number: QTBUG-88616
Change-Id: I92c168228ba76106b2c636c88f54331c76c3d2e6
Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/qsensor/test_sensorimpl.cpp | 2 | ||||
-rw-r--r-- | tests/auto/qsensor/tst_qsensor.cpp | 48 |
2 files changed, 18 insertions, 32 deletions
diff --git a/tests/auto/qsensor/test_sensorimpl.cpp b/tests/auto/qsensor/test_sensorimpl.cpp index c9a1fe63..bbf4e59d 100644 --- a/tests/auto/qsensor/test_sensorimpl.cpp +++ b/tests/auto/qsensor/test_sensorimpl.cpp @@ -106,6 +106,6 @@ void testsensorimpl::stop() bool testsensorimpl::isFeatureSupported(QSensor::Feature feature) const { - return (feature == QSensor::AlwaysOn || feature == QSensor::GeoValues); + return (feature == QSensor::Feature::AlwaysOn || feature == QSensor::Feature::GeoValues); } diff --git a/tests/auto/qsensor/tst_qsensor.cpp b/tests/auto/qsensor/tst_qsensor.cpp index 8e027971..b12b1a73 100644 --- a/tests/auto/qsensor/tst_qsensor.cpp +++ b/tests/auto/qsensor/tst_qsensor.cpp @@ -43,9 +43,6 @@ QT_BEGIN_NAMESPACE -// The unit test needs to change the behaviour of the library. It does this -// through an exported but undocumented function. -Q_SENSORS_EXPORT void sensors_unit_test_hook(int index); bool operator==(const qoutputrange &orl1, const qoutputrange &orl2) { return (orl1.minimum == orl2.minimum && @@ -54,27 +51,16 @@ bool operator==(const qoutputrange &orl1, const qoutputrange &orl2) } namespace QTest { - template<> char *toString(const qoutputrangelist &orl) + // QCOMPARE calls this upon failure (and if a list of these elements is compared, + // it will call this individually for each element) + template<> char* toString(const qoutputrange& range) { - QStringList list; - foreach (const qoutputrange &item, orl) { - list << QString("%1-%2%3%4").arg(item.minimum).arg(item.maximum).arg(QString::fromWCharArray(L"\u00B1")).arg(item.accuracy); - } - QString ret = QString("qoutputrangelist: (%1)").arg(list.join("), (")); - return qstrdup(ret.toLatin1().data()); - } - template<> char *toString(const QList<QByteArray> &data) - { - QStringList list; - foreach (const QByteArray &str, data) { - list << QString::fromLatin1(str); - } - QString ret = QString("QList<QByteArray>: (%1)").arg(list.join("), (")); + QString ret = QString("%1-%2%3%4").arg(range.minimum).arg(range.maximum) + .arg(QString::fromWCharArray(L"\u00B1")).arg(range.accuracy); return qstrdup(ret.toLatin1().data()); } } - class MyFilter : public TestSensorFilter { bool filter(TestSensorReading *) override { return false; } }; class ModFilter : public TestSensorFilter @@ -241,9 +227,9 @@ private slots: sensor.connectToBackend(); QVERIFY(sensor.reading() != 0); quint64 timestamp = sensor.reading()->timestamp(); - qtimestamp timestamp2 = sensor.reading()->timestamp(); + quint64 timestamp2 = sensor.reading()->timestamp(); QVERIFY(timestamp == quint64()); - QVERIFY(timestamp2 == qtimestamp()); + QVERIFY(timestamp2 == quint64()); sensor.setProperty("doThis", "setOne"); sensor.start(); timestamp = sensor.reading()->timestamp(); @@ -959,21 +945,21 @@ private slots: // 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)); - QVERIFY(!sensor.isFeatureSupported(QSensor::AccelerationMode)); + QVERIFY(!sensor.isFeatureSupported(QSensor::Feature::AlwaysOn)); + QVERIFY(!sensor.isFeatureSupported(QSensor::Feature::Buffering)); + QVERIFY(!sensor.isFeatureSupported(QSensor::Feature::GeoValues)); + QVERIFY(!sensor.isFeatureSupported(QSensor::Feature::FieldOfView)); + QVERIFY(!sensor.isFeatureSupported(QSensor::Feature::AccelerationMode)); // 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)); - QVERIFY(!sensor.isFeatureSupported(QSensor::AccelerationMode)); + QVERIFY(sensor.isFeatureSupported(QSensor::Feature::AlwaysOn)); + QVERIFY(!sensor.isFeatureSupported(QSensor::Feature::Buffering)); + QVERIFY(sensor.isFeatureSupported(QSensor::Feature::GeoValues)); + QVERIFY(!sensor.isFeatureSupported(QSensor::Feature::FieldOfView)); + QVERIFY(!sensor.isFeatureSupported(QSensor::Feature::AccelerationMode)); } }; |