diff options
author | Lincoln Ramsay <lincoln.ramsay@nokia.com> | 2011-12-20 19:01:11 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-01-13 03:24:35 +0100 |
commit | 4187d0baa96c4731abfcddfe2c24cf4ef4e72ac5 (patch) | |
tree | 0a03175f0057ad1b79d827d577a891367989e7fe /tests | |
parent | a7d8eb61cf25a583c7f3925843d3232ce691db93 (diff) | |
download | qtsensors-4187d0baa96c4731abfcddfe2c24cf4ef4e72ac5.tar.gz |
alwaysOn for legacy QML elements
You must use QtMobility.sensors 1.3 to get alwaysOn
Use apprpriate namespacing to avoid collisions with the QtSensors 5 elements.
Change-Id: If0f6dfff116d7de8a6de403b2d7c75ffd48b03b8
Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Zsolt Simon <zsolt.simon@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/legacy_sensors/legacy_sensors.pro | 2 | ||||
-rw-r--r-- | tests/auto/legacy_sensors/tst_legacy_sensors.cpp | 64 |
2 files changed, 65 insertions, 1 deletions
diff --git a/tests/auto/legacy_sensors/legacy_sensors.pro b/tests/auto/legacy_sensors/legacy_sensors.pro index 0597a7f..a9b1531 100644 --- a/tests/auto/legacy_sensors/legacy_sensors.pro +++ b/tests/auto/legacy_sensors/legacy_sensors.pro @@ -1,6 +1,6 @@ TEMPLATE=app TARGET=tst_legacy_sensors !no_system_tests:CONFIG += testcase -QT = core testlib gui declarative +QT = core testlib gui declarative sensors SOURCES += tst_legacy_sensors.cpp diff --git a/tests/auto/legacy_sensors/tst_legacy_sensors.cpp b/tests/auto/legacy_sensors/tst_legacy_sensors.cpp index 2a1b5c7..dd7ae29 100644 --- a/tests/auto/legacy_sensors/tst_legacy_sensors.cpp +++ b/tests/auto/legacy_sensors/tst_legacy_sensors.cpp @@ -42,6 +42,7 @@ #include <QtTest/QtTest> #include <QDeclarativeEngine> #include <QDeclarativeComponent> +#include <QSensor> class tst_legacy_sensors : public QObject { @@ -193,6 +194,69 @@ private slots: QCOMPARE(expected, actual); } } + + void alwaysOn_data() + { + QTest::addColumn<QString>("version"); + QTest::addColumn<QString>("element"); + QTest::addColumn<bool>("validSyntax"); + + QTest::newRow("") << "1.1" << "Accelerometer" << false; + QTest::newRow("") << "1.1" << "AmbientLightSensor" << false; + QTest::newRow("") << "1.1" << "Compass" << false; + QTest::newRow("") << "1.1" << "Magnetometer" << false; + QTest::newRow("") << "1.1" << "OrientationSensor" << false; + QTest::newRow("") << "1.1" << "ProximitySensor" << false; + QTest::newRow("") << "1.1" << "RotationSensor" << false; + QTest::newRow("") << "1.1" << "TapSensor" << false; + + QTest::newRow("") << "1.2" << "Accelerometer" << false; + QTest::newRow("") << "1.2" << "AmbientLightSensor" << false; + QTest::newRow("") << "1.2" << "Compass" << false; + QTest::newRow("") << "1.2" << "Magnetometer" << false; + QTest::newRow("") << "1.2" << "OrientationSensor" << false; + QTest::newRow("") << "1.2" << "ProximitySensor" << false; + QTest::newRow("") << "1.2" << "RotationSensor" << false; + QTest::newRow("") << "1.2" << "TapSensor" << false; + QTest::newRow("") << "1.2" << "LightSensor" << false; + QTest::newRow("") << "1.2" << "Gyroscope" << false; + + QTest::newRow("") << "1.3" << "Accelerometer" << true; + QTest::newRow("") << "1.3" << "AmbientLightSensor" << true; + QTest::newRow("") << "1.3" << "Compass" << true; + QTest::newRow("") << "1.3" << "Magnetometer" << true; + QTest::newRow("") << "1.3" << "OrientationSensor" << true; + QTest::newRow("") << "1.3" << "ProximitySensor" << true; + QTest::newRow("") << "1.3" << "RotationSensor" << true; + QTest::newRow("") << "1.3" << "TapSensor" << true; + QTest::newRow("") << "1.3" << "LightSensor" << true; + QTest::newRow("") << "1.3" << "Gyroscope" << true; + QTest::newRow("") << "1.3" << "IRProximitySensor" << true; + } + + void alwaysOn() + { + QFETCH(QString, version); + QFETCH(QString, element); + QFETCH(bool, validSyntax); + + QDeclarativeEngine engine; + QString qml = QString("import QtQuick 2.0\nimport QtMobility.sensors %1\n%2 {\nalwaysOn: true\n}").arg(version).arg(element); + QDeclarativeComponent c(&engine); + if (!validSyntax) + QTest::ignoreMessage(QtWarningMsg, "QDeclarativeComponent: Component is not ready"); + c.setData(qml.toLocal8Bit(), QUrl::fromLocalFile(QDir::currentPath())); + QObject *obj = c.create(); + if (validSyntax) { + QVERIFY(obj); + QSensor *sensor = qobject_cast<QSensor*>(obj); + QVERIFY(sensor); + QCOMPARE(sensor->isAlwaysOn(), true); + delete obj; + } else { + QCOMPARE(obj, static_cast<QObject*>(0)); + } + } }; QTEST_MAIN(tst_legacy_sensors) |