diff options
Diffstat (limited to 'tests/auto/qsensor')
-rw-r--r-- | tests/auto/qsensor/CMakeLists.txt | 22 | ||||
-rw-r--r-- | tests/auto/qsensor/qsensor.pro | 27 | ||||
-rw-r--r-- | tests/auto/qsensor/test_backends.cpp | 82 | ||||
-rw-r--r-- | tests/auto/qsensor/test_backends.h | 155 | ||||
-rw-r--r-- | tests/auto/qsensor/test_sensor.cpp | 31 | ||||
-rw-r--r-- | tests/auto/qsensor/test_sensor.h | 33 | ||||
-rw-r--r-- | tests/auto/qsensor/test_sensor2.cpp | 53 | ||||
-rw-r--r-- | tests/auto/qsensor/test_sensor2.h | 65 | ||||
-rw-r--r-- | tests/auto/qsensor/test_sensor2_p.h | 29 | ||||
-rw-r--r-- | tests/auto/qsensor/test_sensor2impl.cpp | 29 | ||||
-rw-r--r-- | tests/auto/qsensor/test_sensor2impl.h | 29 | ||||
-rw-r--r-- | tests/auto/qsensor/test_sensor_p.h | 29 | ||||
-rw-r--r-- | tests/auto/qsensor/test_sensorimpl.cpp | 31 | ||||
-rw-r--r-- | tests/auto/qsensor/test_sensorimpl.h | 29 | ||||
-rw-r--r-- | tests/auto/qsensor/test_sensorplugin.cpp | 41 | ||||
-rw-r--r-- | tests/auto/qsensor/tst_qsensor.cpp | 179 |
16 files changed, 144 insertions, 720 deletions
diff --git a/tests/auto/qsensor/CMakeLists.txt b/tests/auto/qsensor/CMakeLists.txt new file mode 100644 index 00000000..43f0d054 --- /dev/null +++ b/tests/auto/qsensor/CMakeLists.txt @@ -0,0 +1,22 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +##################################################################### +## tst_qsensor Test: +##################################################################### + +qt_internal_add_test(tst_qsensor + SOURCES + ../common/test_backends.cpp ../common/test_backends.h + test_sensor.cpp test_sensor.h test_sensor_p.h + test_sensor2.cpp test_sensor2.h test_sensor2_p.h + test_sensor2impl.cpp test_sensor2impl.h + test_sensorimpl.cpp test_sensorimpl.h + test_sensorplugin.cpp + tst_qsensor.cpp + DEFINES + QT_STATICPLUGIN + LIBRARIES + Qt::CorePrivate + Qt::SensorsPrivate +) diff --git a/tests/auto/qsensor/qsensor.pro b/tests/auto/qsensor/qsensor.pro deleted file mode 100644 index 1366a5df..00000000 --- a/tests/auto/qsensor/qsensor.pro +++ /dev/null @@ -1,27 +0,0 @@ -TEMPLATE = app -TARGET = tst_qsensor - -CONFIG += testcase -QT = core-private testlib sensors-private -DEFINES += QT_STATICPLUGIN - -SOURCES += \ - tst_qsensor.cpp - -HEADERS += \ - test_sensor.h\ - test_sensor_p.h\ - test_sensorimpl.h\ - test_sensor2.h\ - test_sensor2_p.h\ - test_sensor2impl.h\ - test_backends.h - -SOURCES += \ - test_sensor.cpp\ - test_sensorimpl.cpp\ - test_sensor2.cpp\ - test_sensor2impl.cpp\ - test_sensorplugin.cpp\ - test_backends.cpp - diff --git a/tests/auto/qsensor/test_backends.cpp b/tests/auto/qsensor/test_backends.cpp deleted file mode 100644 index 4dde98fe..00000000 --- a/tests/auto/qsensor/test_backends.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QList> - -#include "qsensorbackend.h" - -typedef QSensorBackend* (*CreateFunc) (QSensor *sensor); -class Record -{ -public: - QByteArray type; - CreateFunc func; -}; -static QList<Record> records; - -static bool registerTestBackend(const char *className, CreateFunc func) -{ - Record record; - record.type = className; - record.func = func; - records << record; - return true; -} - -#define REGISTER_TOO -#include "test_backends.h" -#include <QDebug> - -class BackendFactory : public QSensorBackendFactory -{ - QSensorBackend *createBackend(QSensor *sensor) override - { - foreach (const Record &record, records) { - if (sensor->identifier() == record.type) { - return record.func(sensor); - } - } - return 0; - }; -}; -static BackendFactory factory; - -void register_test_backends() -{ - foreach (const Record &record, records) { - QSensorManager::registerBackend(record.type, record.type, &factory); - } -} - -void unregister_test_backends() -{ - foreach (const Record &record, records) { - QSensorManager::unregisterBackend(record.type, record.type); - } -} - diff --git a/tests/auto/qsensor/test_backends.h b/tests/auto/qsensor/test_backends.h deleted file mode 100644 index aba0b2f2..00000000 --- a/tests/auto/qsensor/test_backends.h +++ /dev/null @@ -1,155 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef TEST_BACKENDS_H -#define TEST_BACKENDS_H - -#include <qsensorbackend.h> - -void register_test_backends(); -void unregister_test_backends(); - -#include <qaccelerometer.h> -#include <qaltimeter.h> -#include <qambientlightsensor.h> -#include <qambienttemperaturesensor.h> -#include <qcompass.h> -#include <qgyroscope.h> -#include <qholstersensor.h> -#include <qlightsensor.h> -#include <qmagnetometer.h> -#include <qorientationsensor.h> -#include <qpressuresensor.h> -#include <qproximitysensor.h> -#include <qrotationsensor.h> -#include <qtapsensor.h> -#include <qirproximitysensor.h> -#include <qtiltsensor.h> - -#define PREPARE_SENSORINTERFACE_DECLS(SensorClass, ReadingClass, FilterClass, readingcode)\ - class SensorClass ## _impl : public QSensorBackend\ - {\ - public:\ - SensorClass ## _impl(QSensor *sensor);\ - void start() override;\ - void stop() override;\ - };\ - class SensorClass ## _testfilter : public FilterClass { bool filter(ReadingClass *) override; }; - -#define PREPARE_SENSORINTERFACE_IMPLS(SensorClass, ReadingClass, FilterClass, readingcode)\ - SensorClass ## _impl::SensorClass ##_impl(QSensor *sensor) : QSensorBackend(sensor) {}\ - void SensorClass ## _impl::start() {\ - ReadingClass *reading = setReading<ReadingClass>(0);\ - readingcode\ - newReadingAvailable();\ - }\ - void SensorClass ##_impl::stop() {}\ - bool SensorClass ## _testfilter::filter(ReadingClass *) { return true; }\ - static QSensorBackend *create_ ## SensorClass ## _impl(QSensor *sensor) { return new SensorClass ## _impl(sensor); }\ - static bool registered_ ## SensorClass = registerTestBackend(#SensorClass, create_ ## SensorClass ## _impl); - -#ifdef REGISTER_TOO -#define PREPARE_SENSORINTERFACE(SensorClass, ReadingClass, FilterClass, readingcode)\ - PREPARE_SENSORINTERFACE_DECLS(SensorClass, ReadingClass, FilterClass, readingcode)\ - PREPARE_SENSORINTERFACE_IMPLS(SensorClass, ReadingClass, FilterClass, readingcode) -#else -#define PREPARE_SENSORINTERFACE(SensorClass, ReadingClass, FilterClass, readingcode)\ - PREPARE_SENSORINTERFACE_DECLS(SensorClass, ReadingClass, FilterClass, readingcode) -#endif - -PREPARE_SENSORINTERFACE(QAccelerometer, QAccelerometerReading, QAccelerometerFilter, { - reading->setX(1.0); - reading->setY(1.0); - reading->setZ(1.0); -}) -PREPARE_SENSORINTERFACE(QAltimeter, QAltimeterReading, QAltimeterFilter, { - reading->setAltitude(8848); -}) -PREPARE_SENSORINTERFACE(QAmbientLightSensor, QAmbientLightReading, QAmbientLightFilter, { - reading->setLightLevel(QAmbientLightReading::Twilight); -}) -PREPARE_SENSORINTERFACE(QAmbientTemperatureSensor, QAmbientTemperatureReading, QAmbientTemperatureFilter, { - reading->setTemperature(30); -}) -PREPARE_SENSORINTERFACE(QCompass, QCompassReading, QCompassFilter, { - reading->setAzimuth(1.0); - reading->setCalibrationLevel(1.0); -}) -PREPARE_SENSORINTERFACE(QGyroscope, QGyroscopeReading, QGyroscopeFilter, { - reading->setX(1.0); - reading->setY(1.0); - reading->setZ(1.0); -}) -PREPARE_SENSORINTERFACE(QHolsterSensor, QHolsterReading, QHolsterFilter, { - reading->setHolstered(true); -}) -PREPARE_SENSORINTERFACE(QLightSensor, QLightReading, QLightFilter, { - reading->setLux(1.0); -}) -PREPARE_SENSORINTERFACE(QMagnetometer, QMagnetometerReading, QMagnetometerFilter, { - reading->setX(1.0); - reading->setY(1.0); - reading->setZ(1.0); - reading->setCalibrationLevel(1.0); -}) -PREPARE_SENSORINTERFACE(QOrientationSensor, QOrientationReading, QOrientationFilter, { - reading->setOrientation(QOrientationReading::LeftUp); -}) -PREPARE_SENSORINTERFACE(QPressureSensor, QPressureReading, QPressureFilter, { - reading->setPressure(1.0); - reading->setTemperature(1.0); -}) -PREPARE_SENSORINTERFACE(QProximitySensor, QProximityReading, QProximityFilter, { - reading->setClose(true); -}) -PREPARE_SENSORINTERFACE(QRotationSensor, QRotationReading, QRotationFilter, { - reading->setFromEuler(1.0, 1.0, 1.0); -}) -PREPARE_SENSORINTERFACE(QTapSensor, QTapReading, QTapFilter, { - reading->setTapDirection(QTapReading::Z_Both); - reading->setDoubleTap(true); -}) -PREPARE_SENSORINTERFACE(QIRProximitySensor, QIRProximityReading, QIRProximityFilter, { - reading->setReflectance(0.5); -}) -PREPARE_SENSORINTERFACE(QTiltSensor, QTiltReading, QTiltFilter, { - reading->setYRotation(1.0); - reading->setXRotation(1.0); -}) - -#define TEST_SENSORINTERFACE(SensorClass, ReadingClass, readingcode)\ - do {\ - SensorClass sensor;\ - SensorClass ## _testfilter filter;\ - sensor.addFilter(&filter);\ - sensor.start();\ - ReadingClass *reading = sensor.reading();\ - readingcode\ - } while (0); - -#endif diff --git a/tests/auto/qsensor/test_sensor.cpp b/tests/auto/qsensor/test_sensor.cpp index 1a1af962..3c36b595 100644 --- a/tests/auto/qsensor/test_sensor.cpp +++ b/tests/auto/qsensor/test_sensor.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "test_sensor.h" #include "test_sensor_p.h" @@ -43,6 +18,6 @@ void TestSensorReading::setTest(int test) // ===================================================================== -const char *TestSensor::type("test sensor"); +const char *TestSensor::sensorType("test sensor"); #include "moc_test_sensor.cpp" diff --git a/tests/auto/qsensor/test_sensor.h b/tests/auto/qsensor/test_sensor.h index 1adb06a6..f75db083 100644 --- a/tests/auto/qsensor/test_sensor.h +++ b/tests/auto/qsensor/test_sensor.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef TEST_SENSOR_H #define TEST_SENSOR_H @@ -56,14 +31,14 @@ class TestSensor : public QSensor Q_OBJECT public: explicit TestSensor(QObject *parent = 0) - : QSensor(TestSensor::type, parent) + : QSensor(TestSensor::sensorType, parent) , sensorsChangedEmitted(0) { connect(this, SIGNAL(availableSensorsChanged()), this, SLOT(s_availableSensorsChanged())); } virtual ~TestSensor() {} TestSensorReading *reading() const { return static_cast<TestSensorReading*>(QSensor::reading()); } - static const char *type; + static const char *sensorType; // used by the testSensorsChangedSignal test function int sensorsChangedEmitted; diff --git a/tests/auto/qsensor/test_sensor2.cpp b/tests/auto/qsensor/test_sensor2.cpp index 22074470..e72c62d2 100644 --- a/tests/auto/qsensor/test_sensor2.cpp +++ b/tests/auto/qsensor/test_sensor2.cpp @@ -1,56 +1,9 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "test_sensor2.h" #include "test_sensor2_p.h" -#undef IMPLEMENT_READING -#undef IMPLEMENT_READING_D - -#define IMPLEMENT_READING(classname)\ - IMPLEMENT_READING_D(classname, classname ## Private) - -#define IMPLEMENT_READING_D(classname, pclassname)\ - classname::classname(QObject *parent)\ - : QSensorReading(parent, new pclassname)\ - , d(d_ptr())\ - {}\ - classname::~classname() {}\ - void classname::copyValuesFrom(QSensorReading *_other)\ - {\ - /* No need to verify types, only called by QSensorBackend */\ - classname *other = static_cast<classname *>(_other);\ - pclassname *my_ptr = static_cast<pclassname*>(d_ptr()->data());\ - pclassname *other_ptr = static_cast<pclassname*>(other->d_ptr()->data());\ - /* Do a direct copy of the private class */\ - *(my_ptr) = *(other_ptr);\ - } - IMPLEMENT_READING(TestSensor2Reading) int TestSensor2Reading::test() const @@ -65,6 +18,6 @@ void TestSensor2Reading::setTest(int test) // ===================================================================== -char const * const TestSensor2::type("test sensor 2"); +char const * const TestSensor2::sensorType("test sensor 2"); #include "moc_test_sensor2.cpp" diff --git a/tests/auto/qsensor/test_sensor2.h b/tests/auto/qsensor/test_sensor2.h index 69050f7c..c5716001 100644 --- a/tests/auto/qsensor/test_sensor2.h +++ b/tests/auto/qsensor/test_sensor2.h @@ -1,68 +1,11 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef TEST_SENSOR2_H #define TEST_SENSOR2_H #include "qsensor.h" -#undef DECLARE_READING -#undef DECLARE_READING_D - -template <typename T> -class qTypedWrapper -{ -public: - qTypedWrapper(QScopedPointer<QSensorReadingPrivate> *_ptr) - : ptr(_ptr) - { - } - - T *operator->() const - { - return static_cast<T*>(ptr->data()); - } - -private: - QScopedPointer<QSensorReadingPrivate> *ptr; -}; - -#define DECLARE_READING(classname)\ - DECLARE_READING_D(classname, classname ## Private) - -#define DECLARE_READING_D(classname, pclassname)\ - public:\ - classname(QObject *parent = 0);\ - virtual ~classname();\ - void copyValuesFrom(QSensorReading *other) override;\ - private:\ - qTypedWrapper<pclassname> d; - class TestSensor2ReadingPrivate; class TestSensor2Reading : public QSensorReading @@ -87,10 +30,10 @@ class TestSensor2 : public QSensor { Q_OBJECT public: - explicit TestSensor2(QObject *parent = 0) : QSensor(TestSensor2::type, parent) {} + explicit TestSensor2(QObject *parent = 0) : QSensor(TestSensor2::sensorType, parent) {} virtual ~TestSensor2() {} TestSensor2Reading *reading() const { return static_cast<TestSensor2Reading*>(QSensor::reading()); } - static char const * const type; + static char const * const sensorType; }; #endif diff --git a/tests/auto/qsensor/test_sensor2_p.h b/tests/auto/qsensor/test_sensor2_p.h index 365b6b24..8ad4e495 100644 --- a/tests/auto/qsensor/test_sensor2_p.h +++ b/tests/auto/qsensor/test_sensor2_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef TEST_SENSOR2_P_H #define TEST_SENSOR2_P_H diff --git a/tests/auto/qsensor/test_sensor2impl.cpp b/tests/auto/qsensor/test_sensor2impl.cpp index caf6688a..795b1a00 100644 --- a/tests/auto/qsensor/test_sensor2impl.cpp +++ b/tests/auto/qsensor/test_sensor2impl.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "test_sensor2impl.h" #include <qaccelerometer.h> diff --git a/tests/auto/qsensor/test_sensor2impl.h b/tests/auto/qsensor/test_sensor2impl.h index 30e03f9e..269d1184 100644 --- a/tests/auto/qsensor/test_sensor2impl.h +++ b/tests/auto/qsensor/test_sensor2impl.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef TEST_SENSOR2IMPL_H #define TEST_SENSOR2IMPL_H diff --git a/tests/auto/qsensor/test_sensor_p.h b/tests/auto/qsensor/test_sensor_p.h index aa4e17a0..9737e292 100644 --- a/tests/auto/qsensor/test_sensor_p.h +++ b/tests/auto/qsensor/test_sensor_p.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef TEST_SENSOR_P_H #define TEST_SENSOR_P_H diff --git a/tests/auto/qsensor/test_sensorimpl.cpp b/tests/auto/qsensor/test_sensorimpl.cpp index c9a1fe63..206b1786 100644 --- a/tests/auto/qsensor/test_sensorimpl.cpp +++ b/tests/auto/qsensor/test_sensorimpl.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "test_sensorimpl.h" #include <QDebug> @@ -106,6 +81,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/test_sensorimpl.h b/tests/auto/qsensor/test_sensorimpl.h index 42b2e09a..9d52e33f 100644 --- a/tests/auto/qsensor/test_sensorimpl.h +++ b/tests/auto/qsensor/test_sensorimpl.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef TEST_SENSORIMPL_H #define TEST_SENSORIMPL_H diff --git a/tests/auto/qsensor/test_sensorplugin.cpp b/tests/auto/qsensor/test_sensorplugin.cpp index a48428b3..1734d3a9 100644 --- a/tests/auto/qsensor/test_sensorplugin.cpp +++ b/tests/auto/qsensor/test_sensorplugin.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "test_sensorimpl.h" #include "test_sensor2impl.h" @@ -55,19 +30,19 @@ public: // This is bad code. It caused a crash due to recursively calling // loadPlugins() in qsensormanager.cpp (because loadPlugins() did // not set the pluginsLoaded flag soon enough). - (void)QSensor::defaultSensorForType(TestSensor::type); + (void)QSensor::defaultSensorForType(TestSensor::sensorType); - QSensorManager::registerBackend(TestSensor::type, testsensorimpl::id, this); - QSensorManager::registerBackend(TestSensor::type, "test sensor 2", this); - QSensorManager::registerBackend(TestSensor2::type, testsensor2impl::id, this); + QSensorManager::registerBackend(TestSensor::sensorType, testsensorimpl::id, this); + QSensorManager::registerBackend(TestSensor::sensorType, "test sensor 2", this); + QSensorManager::registerBackend(TestSensor2::sensorType, testsensor2impl::id, this); } void sensorsChanged() override { // Register a new type on initial load // This is testing the "don't emit availableSensorsChanged() too many times" functionality. - if (!QSensorManager::isBackendRegistered(TestSensor::type, "test sensor 3")) - QSensorManager::registerBackend(TestSensor::type, "test sensor 3", this); + if (!QSensorManager::isBackendRegistered(TestSensor::sensorType, "test sensor 3")) + QSensorManager::registerBackend(TestSensor::sensorType, "test sensor 3", this); // When a sensor of type "a random type" is registered, register another sensor. // This is testing the "don't emit availableSensorsChanged() too many times" functionality. diff --git a/tests/auto/qsensor/tst_qsensor.cpp b/tests/auto/qsensor/tst_qsensor.cpp index 911e9c2c..261f81f9 100644 --- a/tests/auto/qsensor/tst_qsensor.cpp +++ b/tests/auto/qsensor/tst_qsensor.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only //TESTED_COMPONENT=src/sensors @@ -39,13 +14,10 @@ #include "test_sensor.h" #include "test_sensor2.h" #include "test_sensorimpl.h" -#include "test_backends.h" +#include "../common/test_backends.h" 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 +26,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 @@ -136,42 +97,40 @@ private slots: void testTypeRegistered() { - QList<QByteArray> expected; - expected << TestSensor::type << TestSensor2::type; - QList<QByteArray> actual = QSensor::sensorTypes(); - qSort(actual); // 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() { QList<QByteArray> expected; expected << "test sensor 2" << "test sensor 3" << testsensorimpl::id; - QList<QByteArray> actual = QSensor::sensorsForType(TestSensor::type); - qSort(actual); // The actual list is not in a defined order + QList<QByteArray> actual = QSensor::sensorsForType(TestSensor::sensorType); + std::sort(actual.begin(), actual.end()); // The actual list is not in a defined order QCOMPARE(actual, expected); } void testSensorDefault() { QByteArray expected = testsensorimpl::id; - QByteArray actual = QSensor::defaultSensorForType(TestSensor::type); + QByteArray actual = QSensor::defaultSensorForType(TestSensor::sensorType); QCOMPARE(actual, expected); } void testBadDefaultFromConfig() { - QSensorManager::setDefaultBackend(QByteArray(TestSensor::type), QByteArray("bogus id")); + QSensorManager::setDefaultBackend(QByteArray(TestSensor::sensorType), QByteArray("bogus id")); QByteArray expected = testsensorimpl::id; - QByteArray actual = QSensor::defaultSensorForType(TestSensor::type); + QByteArray actual = QSensor::defaultSensorForType(TestSensor::sensorType); QCOMPARE(actual, expected); } void testGoodDefaultFromConfig() { - QSensorManager::setDefaultBackend(QByteArray(TestSensor::type), QByteArray(testsensorimpl::id)); + QSensorManager::setDefaultBackend(QByteArray(TestSensor::sensorType), QByteArray(testsensorimpl::id)); QByteArray expected = testsensorimpl::id; - QByteArray actual = QSensor::defaultSensorForType(TestSensor::type); + QByteArray actual = QSensor::defaultSensorForType(TestSensor::sensorType); QCOMPARE(actual, expected); } @@ -217,7 +176,7 @@ private slots: void testBadDefaultCreation() { - QSensorManager::setDefaultBackend(QByteArray(TestSensor::type), QByteArray("test sensor 2")); + QSensorManager::setDefaultBackend(QByteArray(TestSensor::sensorType), QByteArray("test sensor 2")); TestSensor sensor; QTest::ignoreMessage(QtWarningMsg, "Can't create backend \"test sensor 2\""); sensor.connectToBackend(); @@ -241,9 +200,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(); @@ -464,20 +423,20 @@ private slots: sensor.setProperty("doThis", "setOne"); QSignalSpy spy(&sensor, SIGNAL(readingChanged())); sensor.start(); - QCOMPARE(spy.count(), 1); // reading changes + QCOMPARE(spy.size(), 1); // reading changes sensor.stop(); TestSensorFilter *filter2 = new MyFilter; sensor.addFilter(filter2); sensor.start(); - QCOMPARE(spy.count(), 1); // filter suppresses reading so it does not change + QCOMPARE(spy.size(), 1); // filter suppresses reading so it does not change sensor.stop(); delete filter2; TestSensorFilter *filter1 = new ModFilter; sensor.addFilter(filter1); sensor.start(); - QCOMPARE(spy.count(), 2); // filter does not suppress reading + QCOMPARE(spy.size(), 2); // filter does not suppress reading sensor.stop(); delete filter1; } @@ -763,7 +722,7 @@ private slots: // Unregister an unknown identifier sensor.sensorsChangedEmitted = 0; QTest::ignoreMessage(QtWarningMsg, "Identifier \"a random id\" is not registered"); - QSensorManager::unregisterBackend(TestSensor::type, "a random id"); + QSensorManager::unregisterBackend(TestSensor::sensorType, "a random id"); QCOMPARE(sensor.sensorsChangedEmitted, 0); // Unregister for an unknown type @@ -773,11 +732,9 @@ private slots: QCOMPARE(sensor.sensorsChangedEmitted, 0); // Make sure we've cleaned up the list of available types - QList<QByteArray> expected; - expected << TestSensor::type << TestSensor2::type; - QList<QByteArray> actual = QSensor::sensorTypes(); - qSort(actual); // 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() @@ -812,11 +769,11 @@ private slots: bool actual; expected = true; - actual = QSensorManager::isBackendRegistered(TestSensor::type, testsensorimpl::id); + actual = QSensorManager::isBackendRegistered(TestSensor::sensorType, testsensorimpl::id); QCOMPARE(expected, actual); expected = false; - actual = QSensorManager::isBackendRegistered(TestSensor::type, "random"); + actual = QSensorManager::isBackendRegistered(TestSensor::sensorType, "random"); QCOMPARE(expected, actual); expected = false; @@ -834,10 +791,6 @@ private slots: QCOMPARE(reading->z(), 1.0); }) - TEST_SENSORINTERFACE(QAltimeter, QAltimeterReading, { - QCOMPARE(reading->altitude(), 8848.0); - }) - TEST_SENSORINTERFACE(QAmbientLightSensor, QAmbientLightReading, { QCOMPARE(reading->lightLevel(), QAmbientLightReading::Twilight); }) @@ -857,10 +810,6 @@ private slots: QCOMPARE(reading->z(), 1.0); }) - TEST_SENSORINTERFACE(QHolsterSensor, QHolsterReading, { - QCOMPARE(reading->holstered(), true); - }) - TEST_SENSORINTERFACE(QLightSensor, QLightReading, { QCOMPARE(reading->lux(), 1.0); }) @@ -946,11 +895,57 @@ private slots: // Stopping the first instance causes the busyChanged signal to be emitted from the second instance QSignalSpy spy(&sensor2, SIGNAL(busyChanged())); sensor1.stop(); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); // Now we can start the second instance sensor2.start(); QVERIFY(sensor2.isActive()); + + // test 'busy' going back and forth and verify indication to frontend + register_test_backends(); + QAccelerometer accelerometer; + accelerometer.setIdentifier("QAccelerometer"); + QSignalSpy busySpy(&accelerometer, SIGNAL(busyChanged())); + QVERIFY(accelerometer.connectToBackend()); + QVERIFY(!accelerometer.isBusy()); + QCOMPARE(busySpy.size(), 0); + + set_test_backend_busy(&accelerometer, true); + QCOMPARE(busySpy.size(), 1); + QVERIFY(accelerometer.isBusy()); + + set_test_backend_busy(&accelerometer, false); + QCOMPARE(busySpy.size(), 2); + QVERIFY(!accelerometer.isBusy()); + unregister_test_backends(); + } + + void testIdenfifierChanged() + { + TestSensor sensor; + QSignalSpy spy(&sensor, SIGNAL(identifierChanged())); + QCOMPARE(sensor.identifier(), ""); + + // Change id and verify change + sensor.setIdentifier("a"); + QCOMPARE(sensor.identifier(), "a"); + QCOMPARE(spy.size(), 1); + + // Set same id and verify that no changes + sensor.setIdentifier("a"); + QCOMPARE(sensor.identifier(), "a"); + QCOMPARE(spy.size(), 1); + + // Change id and verify change + sensor.setIdentifier(testsensorimpl::id); + QCOMPARE(sensor.identifier(), testsensorimpl::id); + QCOMPARE(spy.size(), 2); + + // Identifier cant be changed after connected to backend + QVERIFY(sensor.connectToBackend()); + sensor.setIdentifier("c"); + QCOMPARE(sensor.identifier(), testsensorimpl::id); + QCOMPARE(spy.size(), 2); } void testSupportedFeatures() @@ -959,21 +954,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)); } }; |