summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qtsensors5/tst_qtsensors5.cpp92
-rw-r--r--tests/auto/sensors2qmlapi/qbackends.h106
-rw-r--r--tests/auto/sensors2qmlapi/qdeclaccelerometer.h84
-rw-r--r--tests/auto/sensors2qmlapi/qdeclambientlightsensor.h79
-rw-r--r--tests/auto/sensors2qmlapi/qdeclproximitysensor.h78
-rw-r--r--tests/auto/sensors2qmlapi/sensors2qmlapi.pro17
-rw-r--r--tests/auto/sensors2qmlapi/tst_sensors2qmlapi.cpp369
7 files changed, 7 insertions, 818 deletions
diff --git a/tests/auto/qtsensors5/tst_qtsensors5.cpp b/tests/auto/qtsensors5/tst_qtsensors5.cpp
index 92b89c92..719876fd 100644
--- a/tests/auto/qtsensors5/tst_qtsensors5.cpp
+++ b/tests/auto/qtsensors5/tst_qtsensors5.cpp
@@ -60,98 +60,6 @@ private slots:
void cleanupTestCase()
{
}
-
- void versions_data()
- {
- QTest::addColumn<QString>("version");
- QTest::addColumn<bool>("exists");
-
- QTest::newRow("5.0") << "5.0" << true;
- }
-
- void versions()
- {
- QFETCH(QString, version);
- QFETCH(bool, exists);
-
- QQmlEngine engine;
- QString qml = QString("import QtQuick 2.0\nimport QtSensors %1\nItem {}").arg(version);
- QQmlComponent c(&engine);
- c.setData(qml.toLocal8Bit(), QUrl::fromLocalFile(QDir::currentPath()));
- if (!exists)
- QTest::ignoreMessage(QtWarningMsg, "QQmlComponent: Component is not ready");
- QObject *obj = c.create();
- QCOMPARE(exists, (obj != 0));
- delete obj;
- QList<QQmlError> errors = c.errors();
- if (exists) {
- QCOMPARE(errors.count(), 0);
- } else {
- QCOMPARE(errors.count(), 1);
- QString expected = QString("module \"QtSensors\" version %1 is not installed").arg(version);
- QString actual = errors.first().description();
- QCOMPARE(expected, actual);
- }
- }
-
- void elements_data()
- {
- QTest::addColumn<QString>("version");
- QTest::addColumn<QString>("element");
- QTest::addColumn<bool>("exists");
-
- QTest::newRow("5.0 AmbientLightSensor") << "5.0" << "AmbientLightSensor" << true;
- QTest::newRow("5.0 ProximitySensor") << "5.0" << "ProximitySensor" << true;
- QTest::newRow("5.0 TiltSensor") << "5.0" << "TiltSensor" << true;
- QTest::newRow("5.0 SensorGesture") << "5.0" << "SensorGesture" << true;
- }
-
- void elements()
- {
- QFETCH(QString, version);
- QFETCH(QString, element);
- QFETCH(bool, exists);
-
- QQmlEngine engine;
- QString qml = QString("import QtQuick 2.0\nimport QtSensors %1\n%2 {}").arg(version).arg(element);
- QQmlComponent c(&engine);
- c.setData(qml.toLocal8Bit(), QUrl::fromLocalFile(QDir::currentPath()));
- if (!exists)
- QTest::ignoreMessage(QtWarningMsg, "QQmlComponent: Component is not ready");
- QObject *obj = c.create();
- QCOMPARE(exists, (obj != 0));
- delete obj;
- QList<QQmlError> errors = c.errors();
- QCOMPARE(errors.count(), 0);
- }
-
- void uncreatable_elements_data()
- {
- QTest::addColumn<QString>("version");
- QTest::addColumn<QString>("element");
-
- QTest::newRow("5.0 Sensor") << "5.0" << "Sensor";
- }
-
- void uncreatable_elements()
- {
- QFETCH(QString, version);
- QFETCH(QString, element);
-
- QQmlEngine engine;
- QString qml = QString("import QtQuick 2.0\nimport QtSensors %1\n%2 {}").arg(version).arg(element);
- QQmlComponent c(&engine);
- c.setData(qml.toLocal8Bit(), QUrl::fromLocalFile(QDir::currentPath()));
- //QTest::ignoreMessage(QtWarningMsg, "QQmlComponent: Component is not ready");
- QObject *obj = c.create();
- QCOMPARE(obj, static_cast<QObject*>(0));
- delete obj;
- QList<QQmlError> errors = c.errors();
- QCOMPARE(errors.count(), 1);
- QString expected = QString("Cannot create %1").arg(element);
- QString actual = errors.first().description();
- QCOMPARE(expected, actual);
- }
};
QTEST_MAIN(tst_qtsensors5)
diff --git a/tests/auto/sensors2qmlapi/qbackends.h b/tests/auto/sensors2qmlapi/qbackends.h
deleted file mode 100644
index 020a1c03..00000000
--- a/tests/auto/sensors2qmlapi/qbackends.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtSensors module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef BACKENDS_H
-#define BACKENDS_H
-
-#include "qdeclaccelerometer.h"
-#include "qdeclambientlightsensor.h"
-#include "qdeclproximitysensor.h"
-#include <qsensorplugin.h>
-#include <QtCore/QDebug>
-
-
-class TestSensorPlugin : public QObject,
- public QSensorPluginInterface,
- public QSensorChangesInterface,
- public QSensorBackendFactory
-{
- Q_OBJECT
- //Q_PLUGIN_METADATA(IID "com.nokia.Qt.QSensorPluginInterface/1.0" FILE "plugin.json")
- Q_INTERFACES(QSensorPluginInterface QSensorChangesInterface)
-public:
- void registerSensors()
- {
- QSensorManager::registerBackend("QAccelerometer", "QAccelerometer", this);
- QSensorManager::registerBackend("QAmbientLightSensor", "QAmbientLightSensor", this);
- QSensorManager::registerBackend("QProximitySensor", "QProximitySensor", this);
- }
-
- void sensorsChanged()
- {
- }
-
- QSensorBackend *createBackend(QSensor *sensor)
- {
- if (sensor->identifier() == "QAccelerometer") {
- if (TestSensorPlugin::stAccel != 0)
- return TestSensorPlugin::stAccel;
- else
- TestSensorPlugin::stAccel = new QDeclAccelerometer(sensor);
- return createBackend(sensor);
- }
- else if (sensor->identifier() == "QAmbientLightSensor") {
- if (TestSensorPlugin::stAbl != 0)
- return TestSensorPlugin::stAbl;
- else
- TestSensorPlugin::stAbl = new QDeclAmbientLightSensor(sensor);
- return createBackend(sensor);
- }
- else if (sensor->identifier() == "QProximitySensor") {
- if (TestSensorPlugin::stProxi != 0)
- return TestSensorPlugin::stProxi;
- else
- TestSensorPlugin::stProxi = new QDeclProximitySensor(sensor);
- return createBackend(sensor);
- }
-
- qWarning() << "Can't create backend" << sensor->identifier();
- return 0;
- }
-public:
- static QDeclAccelerometer* stAccel;
- static QDeclAmbientLightSensor* stAbl;
- static QDeclProximitySensor* stProxi;
-};
-
-#endif
-
diff --git a/tests/auto/sensors2qmlapi/qdeclaccelerometer.h b/tests/auto/sensors2qmlapi/qdeclaccelerometer.h
deleted file mode 100644
index 56040ecc..00000000
--- a/tests/auto/sensors2qmlapi/qdeclaccelerometer.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtSensors module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLACCELEROMETER_H
-#define QDECLACCELEROMETER_H
-
-#include <qsensorbackend.h>
-#include "qaccelerometer.h"
-
-class QDeclAccelerometer : public QSensorBackend
-{
- Q_OBJECT
-public:
- explicit QDeclAccelerometer(QSensor *sensor)
- : QSensorBackend(sensor)
- , _active(false)
- , _sensor(sensor)
- {
- }
- virtual ~QDeclAccelerometer() {}
-
- void start() { _active = true; }
- void stop()
- {
- _sensor->stop();
- _active = false;
- }
- bool isActive() { return _active; }
-
- void test(qreal x, qreal y, qreal z)
- {
- if (sensor()->filters().count() > 0){
- QAccelerometerFilter* af = (QAccelerometerFilter*)sensor()->filters().at(0);
- reader.setX(x);
- reader.setY(y);
- reader.setZ(z);
- af->filter(&reader);
- }
- }
-private:
- bool _active;
- QSensor* _sensor;
- QAccelerometerReading reader;
-};
-#endif
-
diff --git a/tests/auto/sensors2qmlapi/qdeclambientlightsensor.h b/tests/auto/sensors2qmlapi/qdeclambientlightsensor.h
deleted file mode 100644
index 6c0b56ca..00000000
--- a/tests/auto/sensors2qmlapi/qdeclambientlightsensor.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtSensors module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLAMBIENTLIGHTSENSOR_H
-#define QDECLAMBIENTLIGHTSENSOR_H
-
-#include <qsensorbackend.h>
-#include "./../../../src/imports/sensors2/qsensor2ambientlight.h"
-
-class QDeclAmbientLightSensor : public QSensorBackend
-{
- Q_OBJECT
-public:
- explicit QDeclAmbientLightSensor(QSensor *sensor)
- : QSensorBackend(sensor)
- , _active(false)
- , _sensor(sensor)
- {
- }
- virtual ~QDeclAmbientLightSensor() {}
-
- void start() { _active = true; }
- void stop() { _active = false; }
- bool isActive() { return _active; }
-
- void test(QSensor2AmbientLight::LightLevel lv)
- {
- if (sensor()->filters().count() > 0){
- QAmbientLightFilter* af = (QAmbientLightFilter*)sensor()->filters().at(0);
- reader.setLightLevel((QAmbientLightReading::LightLevel)lv);
- af->filter(&reader);
- }
- }
-private:
- bool _active;
- QSensor* _sensor;
- QAmbientLightReading reader;
-};
-
-#endif
-
diff --git a/tests/auto/sensors2qmlapi/qdeclproximitysensor.h b/tests/auto/sensors2qmlapi/qdeclproximitysensor.h
deleted file mode 100644
index 6ccdb307..00000000
--- a/tests/auto/sensors2qmlapi/qdeclproximitysensor.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtSensors module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLPROXIMITYSENSOR_H
-#define QDECLPROXIMITYSENSOR_H
-
-#include <qsensorbackend.h>
-#include "qproximitysensor.h"
-
-class QDeclProximitySensor : public QSensorBackend
-{
- Q_OBJECT
-public:
- explicit QDeclProximitySensor(QSensor *sensor)
- : QSensorBackend(sensor)
- , _active(false)
- , _sensor(sensor)
- {
- }
- virtual ~QDeclProximitySensor() {}
-
- void start() { _active = true; }
- void stop() { _active = false; }
- bool isActive() { return _active; }
-
- void test(bool val)
- {
- if (sensor()->filters().count() > 0){
- QProximityFilter* af = (QProximityFilter*)sensor()->filters().at(0);
- reader.setClose(val);
- af->filter(&reader);
- }
- }
-private:
- bool _active;
- QSensor* _sensor;
- QProximityReading reader;
-};
-#endif
-
diff --git a/tests/auto/sensors2qmlapi/sensors2qmlapi.pro b/tests/auto/sensors2qmlapi/sensors2qmlapi.pro
index 8344710a..faa0c337 100644
--- a/tests/auto/sensors2qmlapi/sensors2qmlapi.pro
+++ b/tests/auto/sensors2qmlapi/sensors2qmlapi.pro
@@ -5,23 +5,12 @@ CONFIG += testcase
QT = core testlib sensors-private qml
SOURCES += tst_sensors2qmlapi.cpp \
- ./../../../src/imports/sensors2/qsensor2ambientlight.cpp \
- ./../../../src/imports/sensors2/qsensor2proximity.cpp \
- ./../../../src/imports/sensors2/qsensor2tilt.cpp \
- ./../../../src/imports/sensors2/qsensor2gesture.cpp \
- ./../../../src/imports/sensors2/qsensor2common.cpp \
+ ./../../../src/imports/sensors/qmlsensorgesture.cpp \
qtemplategestureplugin.cpp \
qtemplaterecognizer.cpp
-HEADERS += qdeclaccelerometer.h \
- qdeclambientlightsensor.h \
- qdeclproximitysensor.h \
- qbackends.h \
- ./../../../src/imports/sensors2/qsensor2ambientlight.h \
- ./../../../src/imports/sensors2/qsensor2proximity.h \
- ./../../../src/imports/sensors2/qsensor2tilt.h \
- ./../../../src/imports/sensors2/qsensor2gesture.h \
- ./../../../src/imports/sensors2/qsensor2common.h \
+HEADERS += \
+ ./../../../src/imports/sensors/qmlsensorgesture.h \
qtemplategestureplugin.h \
qtemplaterecognizer.h
diff --git a/tests/auto/sensors2qmlapi/tst_sensors2qmlapi.cpp b/tests/auto/sensors2qmlapi/tst_sensors2qmlapi.cpp
index 42ef629b..5573dd41 100644
--- a/tests/auto/sensors2qmlapi/tst_sensors2qmlapi.cpp
+++ b/tests/auto/sensors2qmlapi/tst_sensors2qmlapi.cpp
@@ -42,20 +42,13 @@
#include <QtTest/QtTest>
#include <QtTest/QSignalSpy>
#include <QtCore/QDebug>
-#include "../../../src/imports/sensors2/qsensor2ambientlight.h"
-#include "../../../src/imports/sensors2/qsensor2proximity.h"
-#include "../../../src/imports/sensors2/qsensor2tilt.h"
-#include "../../../src/imports/sensors2/qsensor2gesture.h"
+#include "../../../src/imports/sensors/qmlsensorgesture.h"
#include "qtemplategestureplugin.h"
#include "qtemplaterecognizer.h"
#include <qsensorgesturemanager.h>
-#include "qbackends.h"
#include "qsensormanager.h"
QT_USE_NAMESPACE
-QDeclAccelerometer* TestSensorPlugin::stAccel = 0;
-QDeclAmbientLightSensor* TestSensorPlugin::stAbl = 0;
-QDeclProximitySensor* TestSensorPlugin::stProxi = 0;
QT_BEGIN_NAMESPACE
@@ -65,366 +58,12 @@ class tst_Sensors2QMLAPI : public QObject
private slots:
void initTestCase();
- void testTilt_data();
- void testTilt();
- void testTilt_receivedSignalsCount();
- void testTiltSettings();
- void testTiltCalibration();
- void testTiltRunningMode();
- void testProximity();
- void testAmbientLight();
void testGesture();
-
-protected:
- TestSensorPlugin _plugin;
- QSensor2Tilt* _tilt;
};
void tst_Sensors2QMLAPI::initTestCase()
{
qputenv("QT_SENSORS_LOAD_PLUGINS", "0"); // Do not load plugins
- _plugin.registerSensors();
- _tilt = 0;
-}
-
-void tst_Sensors2QMLAPI::testProximity()
-{
- QSensor2Proximity prox;
- QSignalSpy spy(&prox, SIGNAL(enabledChanged()));
- prox.setProperty("enabled", true);
- QCOMPARE(spy.count() , 1);
-
- spy.clear();
- prox.setProperty("enabled", true);
- QCOMPARE(spy.count() , 0);
-
- TestSensorPlugin plugin;
- QDeclProximitySensor* proxi = plugin.stProxi;
-
- proxi->test(true);
- bool expected = true;
- bool actual = prox.property("near").toBool();
- QCOMPARE(expected, actual);
-
- QSignalSpy spy1(&prox, SIGNAL(nearChanged()));
- proxi->test(false);
- QCOMPARE(spy1.count() , 1);
- expected = false;
- actual = prox.property("near").toBool();
- QCOMPARE(expected, actual);
-
- spy1.clear();
- proxi->test(false);
- QCOMPARE(spy1.count() , 0);
- prox.setProperty("enabled", false);
-}
-
-void tst_Sensors2QMLAPI::testAmbientLight()
-{
- QSensor2AmbientLight als;
- QSignalSpy spy(&als, SIGNAL(enabledChanged()));
- als.setProperty("enabled", true);
- QCOMPARE(spy.count() , 1);
-
- spy.clear();
- als.setProperty("enabled", true);
- QCOMPARE(spy.count() , 0);
-
- TestSensorPlugin plugin;
- QDeclAmbientLightSensor* abl = plugin.stAbl;
-
- for (int en = 5; en >= 0; en--){
- QSignalSpy spy1(&als, SIGNAL(lightLevelChanged()));
- abl->test(static_cast<QSensor2AmbientLight::LightLevel>(en));
- QCOMPARE(spy1.count() , 1);
- int expected = en;
- int actual = als.property("lightLevel").toInt();
- if (expected != actual)
- QCOMPARE(expected, actual);
-
- spy1.clear();
- abl->test(static_cast<QSensor2AmbientLight::LightLevel>(en));
- QCOMPARE(spy1.count() , 0);
- }
- als.setProperty("enabled", false);
-}
-
-void tst_Sensors2QMLAPI::testTilt_data()
-{
- QTest::addColumn<float>("pitch");
- QTest::addColumn<float>("roll");
- QTest::addColumn<int>("x");
- QTest::addColumn<int>("y");
- QTest::addColumn<int>("z");
- QTest::addColumn<int>("xRotation");
- QTest::addColumn<int>("yRotation");
-
- //Face up
- // Pitch Roll x y z xRot yRot
- QTest::newRow("FaceUp1") << 0.0f << 0.0f << 0 << 0 << 1 << 0 << 0;
- QTest::newRow("FaceUp2") << 0.0f << 0.0f << 0 << 1 << 0 << 90 << 0;
- QTest::newRow("FaceUp3") << 0.0f << 0.0f << 1 << 0 << 0 << 0 << -90;
- QTest::newRow("FaceUp4") << 0.0f << 0.0f << 1 << 0 << 1 << 0 << -45;
- QTest::newRow("FaceUp5") << 0.0f << 0.0f << 1 << 1 << 0 << 45 << -45;
- QTest::newRow("FaceUp6") << 0.0f << 0.0f << 0 << 1 << 1 << 45 << 0;
-
- //top up roll = 90
- // Pitch Roll x y z xRot yRot
- QTest::newRow("TopUp1") << 0.0f << 90.0f << 0 << 0 << 1 << -90 << 0;
- QTest::newRow("TopUp2") << 0.0f << 90.0f << 0 << 1 << 0 << 0 << 0;
- QTest::newRow("TopUp3") << 0.0f << 90.0f << 1 << 0 << 0 << -90 << -90;
- QTest::newRow("TopUp4") << 0.0f << 90.0f << 1 << 0 << 1 << -90 << -45;
- QTest::newRow("TopUp5") << 0.0f << 90.0f << 1 << 1 << 0 << -45 << -45;
- QTest::newRow("TopUp6") << 0.0f << 90.0f << 0 << 1 << 1 << -45 << 0;
-
- //top down roll = -90
- // Pitch Roll x y z xRot yRot
- QTest::newRow("TopDown1") << 0.0f <<-90.0f << 0 << 0 << 1 << 90 << 0;
- QTest::newRow("TopDown2") << 0.0f <<-90.0f << 0 << 1 << 0 << 0 << 0;
- QTest::newRow("TopDown3") << 0.0f <<-90.0f << 1 << 0 << 0 << 90 << -90;
- QTest::newRow("TopDown4") << 0.0f <<-90.0f << 1 << 0 << 1 << 90 << -45;
- QTest::newRow("TopDown5") << 0.0f <<-90.0f << 1 << 1 << 0 << 45 << -45;
- QTest::newRow("TopDown6") << 0.0f <<-90.0f << 0 << 1 << 1 << 45 << 0;
-
- //Left up Pitch = -90 Roll = 90
- // Pitch Roll x y z xRot yRot
- QTest::newRow("LeftUp1") <<-90.0f << 90.0f << 0 << 0 << 1 << -90 << 90;
- QTest::newRow("LeftUp2") <<-90.0f << 90.0f << 0 << 1 << 0 << 0 << 90;
- QTest::newRow("LeftUp3") <<-90.0f << 90.0f << 1 << 0 << 0 << -90 << 0;
- QTest::newRow("LeftUp4") <<-90.0f << 90.0f << 1 << 0 << 1 << -90 << 45;
- QTest::newRow("LeftUp5") <<-90.0f << 90.0f << 1 << 1 << 0 << -45 << 45;
- QTest::newRow("LeftUp6") <<-90.0f << 90.0f << 0 << 1 << 1 << -45 << 90;
-
- //Right up Pitch = -90 Roll = 90
- // Pitch Roll x y z xRot yRot
- QTest::newRow("RightUp1") << 90.0f << 90.0f << 0 << 0 << 1 << -90 << -90;
- QTest::newRow("RightUp2") << 90.0f << 90.0f << 0 << 1 << 0 << 0 << -90;
- QTest::newRow("RightUp3") << 90.0f << 90.0f << 1 << 0 << 0 << -90 << 0;
- QTest::newRow("RightUp4") << 90.0f << 90.0f << 1 << 0 << 1 << -90 << -45;
- QTest::newRow("RightUp5") << 90.0f << 90.0f << 1 << 1 << 0 << -45 << -45;
- QTest::newRow("RightUp6") << 90.0f << 90.0f << 0 << 1 << 1 << -45 << -90;
-
- //Face Down Pitch = -180 Roll = -180
- // Pitch Roll x y z xRot yRot
- QTest::newRow("FaceDown1") <<-180.0f<<-180.0f<< 0 << 0 << 1 << 0 << 0;
- QTest::newRow("FaceDown2") <<-180.0f<<-180.0f<< 0 << 1 << 0 << -90 << 0;
- QTest::newRow("FaceDown3") <<-180.0f<<-180.0f<< 1 << 0 << 0 << 0 << 90;
- QTest::newRow("FaceDown4") <<-180.0f<<-180.0f<< 1 << 0 << 1 << 0 << 45;
- QTest::newRow("FaceDown5") <<-180.0f<<-180.0f<< 1 << 1 << 0 << -45 << 45;
- QTest::newRow("FaceDown6") <<-180.0f<<-180.0f<< 0 << 1 << 1 << -45 << 0;
-}
-
-int xrotch = 0;
-int yrotch = 0;
-void tst_Sensors2QMLAPI::testTilt()
-{
- QFETCH(float, pitch);
- QFETCH(float, roll);
- QFETCH(int, x);
- QFETCH(int, y);
- QFETCH(int, z);
- QFETCH(int, xRotation);
- QFETCH(int, yRotation);
-
- if (!_tilt)
- _tilt = new QSensor2Tilt(this);
-
- QSignalSpy spy(_tilt, SIGNAL(enabledChanged()));
- _tilt->setProperty("enabled", true);
- QCOMPARE(spy.count() , 1);
-
- spy.clear();
- _tilt->setProperty("enabled", true);
- QCOMPARE(spy.count() , 0);
-
- QByteArray settings;
- settings.append(QString::number(-5.0));
- settings.append(";");
- settings.append(QString::number(-5.0));
- _tilt->setProperty("settings", settings);
-
- QByteArray settings1;
- settings1.append(QString::number(pitch * M_PI / 180.0, 'g', 20));
- settings1.append(";");
- settings1.append(QString::number(roll * M_PI / 180.0, 'g', 20));
- _tilt->setProperty("settings", settings1);
-
- QDeclAccelerometer* accel = _plugin.stAccel;
-
- QSignalSpy spyxrot(_tilt, SIGNAL(xRotationChanged()));
- QSignalSpy spyyrot(_tilt, SIGNAL(yRotationChanged()));
- accel->test(x,y,z);
- xrotch += spyxrot.count();
- yrotch += spyyrot.count();
-
- QCOMPARE(xRotation, _tilt->property("xRotation").toInt());
- QCOMPARE(yRotation, _tilt->property("yRotation").toInt());
-
- spy.clear();
- _tilt->setProperty("enabled", false);
- QCOMPARE(spy.count() , 1);
-
- spy.clear();
- _tilt->setProperty("enabled", false);
- QCOMPARE(spy.count() , 0);
-}
-
-void tst_Sensors2QMLAPI::testTiltSettings()
-{
- if (!_tilt)
- _tilt = new QSensor2Tilt(this);
-
- QByteArray settings;
- settings.append(QString::number(-5.0));
- settings.append(";");
- settings.append(QString::number(-5.0));
- _tilt->setProperty("settings", settings);
- QByteArray val = _tilt->property("settings").toByteArray();
- QCOMPARE(settings, val);
-
- QByteArray settings1;
- settings1.append(QString::number(-6.0));
- settings1.append(":");
- settings1.append(QString::number(3.0));
- _tilt->setProperty("settings", settings1);
- val = _tilt->property("settings").toByteArray();
- QCOMPARE(settings, val);
-
- settings1.clear();
- settings1.append(":");
- _tilt->setProperty("settings", settings1);
- val = _tilt->property("settings").toByteArray();
- QCOMPARE(settings, val);
-
- settings1.clear();
- settings1.append("1;2;3");
- _tilt->setProperty("settings", settings1);
- val = _tilt->property("settings").toByteArray();
- QCOMPARE(settings, val);
-}
-
-void tst_Sensors2QMLAPI::testTilt_receivedSignalsCount()
-{
- QCOMPARE(xrotch , 23);
- QCOMPARE(yrotch , 21);
-}
-
-void tst_Sensors2QMLAPI::testTiltCalibration()
-{
- if (!_tilt)
- _tilt = new QSensor2Tilt(this);
-
- QByteArray settings;
- settings.append(QString::number(0.0));
- settings.append(";");
- settings.append(QString::number(0.0));
- _tilt->setProperty("settings", settings);
- _tilt->setProperty("enabled", true);
-
- QDeclAccelerometer* accel = _plugin.stAccel;
-
- //be sure we set rotation to 0
- accel->test(-3.59904, 5.52114, 7.07059);
- _tilt->calibrate();
- accel->test(-3.59904, 5.52114, 7.07059);
- float xRotation = _tilt->property("xRotation").toFloat();
- float yRotation = _tilt->property("yRotation").toFloat();
- if (xRotation < 0.0) xRotation = -xRotation;
- if (yRotation < 0.0) yRotation = -yRotation;
- QVERIFY(xRotation < 0.001);
- QVERIFY(yRotation < 0.001);
-
- accel->test(0.519752, 6.82543, 7.06079);
- _tilt->calibrate();
- accel->test(0.539366, 6.79601, 7.0804);
- xRotation = _tilt->property("xRotation").toFloat();
- yRotation = _tilt->property("yRotation").toFloat();
- if (xRotation < 0.0) xRotation = -xRotation;
- if (yRotation < 0.0) yRotation = -yRotation;
- QVERIFY(xRotation < 0.25);
- QVERIFY(yRotation < 0.12);
- _tilt->setProperty("enabled", false);
-}
-
-void tst_Sensors2QMLAPI::testTiltRunningMode()
-{
- if (!_tilt)
- _tilt = new QSensor2Tilt(this);
- QDeclAccelerometer* accel = _plugin.stAccel;
- QCOMPARE(_tilt->dataRate().count(), 0);
- accel->addDataRate(13, 15);
- _tilt->createRunModeDataRateMap();
- QCOMPARE(_tilt->dataRate().value(QSensor2Tilt::Slow), 13);
- QCOMPARE(_tilt->dataRate().value(QSensor2Tilt::Medium), 13);
- QCOMPARE(_tilt->dataRate().value(QSensor2Tilt::Fast), 15);
-
- accel->addDataRate(1, 8);
- _tilt->createRunModeDataRateMap();
- QCOMPARE(_tilt->dataRate().value(QSensor2Tilt::Slow), 2);
- QCOMPARE(_tilt->dataRate().value(QSensor2Tilt::Medium), 8);
- QCOMPARE(_tilt->dataRate().value(QSensor2Tilt::Fast), 15);
-
- accel->addDataRate(11, 12);
- _tilt->createRunModeDataRateMap();
- QCOMPARE(_tilt->dataRate().value(QSensor2Tilt::Slow), 2);
- QCOMPARE(_tilt->dataRate().value(QSensor2Tilt::Medium), 11);
- QCOMPARE(_tilt->dataRate().value(QSensor2Tilt::Fast), 15);
-
- accel->addDataRate(13, 18);
- _tilt->createRunModeDataRateMap();
- QCOMPARE(_tilt->dataRate().value(QSensor2Tilt::Slow), 2);
- QCOMPARE(_tilt->dataRate().value(QSensor2Tilt::Medium), 11);
- QCOMPARE(_tilt->dataRate().value(QSensor2Tilt::Fast), 18);
-
- accel->addDataRate(21, 31);
- _tilt->createRunModeDataRateMap();
- QCOMPARE(_tilt->dataRate().value(QSensor2Tilt::Slow), 2);
- QCOMPARE(_tilt->dataRate().value(QSensor2Tilt::Medium), 11);
- QCOMPARE(_tilt->dataRate().value(QSensor2Tilt::Fast), 21);
-
- accel->addDataRate(19, 20);
- _tilt->createRunModeDataRateMap();
- QCOMPARE(_tilt->dataRate().value(QSensor2Tilt::Slow), 2);
- QCOMPARE(_tilt->dataRate().value(QSensor2Tilt::Medium), 11);
- QCOMPARE(_tilt->dataRate().value(QSensor2Tilt::Fast), 20);
-
- accel->addDataRate(9, 10);
- _tilt->createRunModeDataRateMap();
- QCOMPARE(_tilt->dataRate().value(QSensor2Tilt::Slow), 2);
- QCOMPARE(_tilt->dataRate().value(QSensor2Tilt::Medium), 10);
- QCOMPARE(_tilt->dataRate().value(QSensor2Tilt::Fast), 20);
-
- QSensor2Tilt::Speed speed = static_cast<QSensor2Tilt::Speed>(_tilt->property("speed").toInt());
- QCOMPARE(speed, QSensor2Tilt::Slow);
- _tilt->setProperty("speed", QSensor2Tilt::Slow);
-
- QSignalSpy spymode(_tilt, SIGNAL(speedChanged()));
- _tilt->setProperty("speed", QSensor2Tilt::Slow);
- QCOMPARE(spymode.count() , 0);
- speed = static_cast<QSensor2Tilt::Speed>(_tilt->property("speed").toInt());
- QCOMPARE(speed, QSensor2Tilt::Slow);
-
- _tilt->setProperty("speed", QSensor2Tilt::Medium);
- QCOMPARE(spymode.count() , 1);
- spymode.clear();
- speed = static_cast<QSensor2Tilt::Speed>(_tilt->property("speed").toInt());
- QCOMPARE(speed, QSensor2Tilt::Medium);
-
- _tilt->setProperty("speed", QSensor2Tilt::Medium);
- QCOMPARE(spymode.count() , 0);
- speed = static_cast<QSensor2Tilt::Speed>(_tilt->property("speed").toInt());
- QCOMPARE(speed, QSensor2Tilt::Medium);
-
- _tilt->setProperty("speed", QSensor2Tilt::Fast);
- QCOMPARE(spymode.count() , 1);
- spymode.clear();
- speed = static_cast<QSensor2Tilt::Speed>(_tilt->property("speed").toInt());
- QCOMPARE(speed, QSensor2Tilt::Fast);
-
- _tilt->setProperty("speed", QSensor2Tilt::Fast);
- QCOMPARE(spymode.count() , 0);
- speed = static_cast<QSensor2Tilt::Speed>(_tilt->property("speed").toInt());
- QCOMPARE(speed, QSensor2Tilt::Fast);
}
void tst_Sensors2QMLAPI::testGesture()
@@ -433,7 +72,7 @@ void tst_Sensors2QMLAPI::testGesture()
QList <QSensorGestureRecognizer *> recognizers = plugin->createRecognizers();
QSensorGestureManager manager;
- QSensor2Gesture* gs = new QSensor2Gesture(this);
+ QmlSensorGesture* gs = new QmlSensorGesture(this);
gs->componentComplete();
QSignalSpy spy_availableGesturesChanged(gs, SIGNAL(availableGesturesChanged()));
QSignalSpy spy_detected(gs, SIGNAL(detected(QString)));
@@ -482,7 +121,7 @@ void tst_Sensors2QMLAPI::testGesture()
gs->setEnabled(false);
- QSensor2Gesture* gs1 = new QSensor2Gesture(this);
+ QmlSensorGesture* gs1 = new QmlSensorGesture(this);
QSignalSpy spy1_detected(gs1, SIGNAL(detected(QString)));
QSignalSpy spy1_gesturesChanged(gs1, SIGNAL(gesturesChanged()));
QSignalSpy spy1_validGesturesChanged(gs1, SIGNAL(validGesturesChanged()));
@@ -534,7 +173,7 @@ void tst_Sensors2QMLAPI::testGesture()
gs1->setEnabled(false);
//check sensor shouldn't run until the componentComplete gets called
- QSensor2Gesture* gs2 = new QSensor2Gesture(this);
+ QmlSensorGesture* gs2 = new QmlSensorGesture(this);
QSignalSpy spy2_detected(gs2, SIGNAL(detected(QString)));
gs2->setGestures(QStringList() << "QtSensors.template");
gs2->setEnabled(true);