summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLincoln Ramsay <lincoln.ramsay@nokia.com>2011-11-24 15:46:22 +1000
committerQt by Nokia <qt-info@nokia.com>2011-11-29 00:03:01 +0100
commit7de0c48d3e97172ccd31b9062308d7809f41d274 (patch)
treea43b3a69c6367bc7ec29e66989e5e5736c205f09 /tests
parent69ab2608873461d2840ee1b9eb08ad9be7dcd65c (diff)
downloadqtsensors-7de0c48d3e97172ccd31b9062308d7809f41d274.tar.gz
Clean up the sensor gestures unit test.
QTRY_ instead of custom waiting functions. Do the thread test properly. Since it can't possibly work anyway, remove the qt_metacast() function. Change-Id: I139ab29bc0785bee49a22fa20d10f2970cbac367 Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Lorn Potter <lorn.potter@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qsensorgestures/qsensorgestures.pro1
-rw-r--r--tests/auto/qsensorgestures/tst_qsensorgesturetest.cpp308
2 files changed, 124 insertions, 185 deletions
diff --git a/tests/auto/qsensorgestures/qsensorgestures.pro b/tests/auto/qsensorgestures/qsensorgestures.pro
index a29e3c4..5bccd76 100644
--- a/tests/auto/qsensorgestures/qsensorgestures.pro
+++ b/tests/auto/qsensorgestures/qsensorgestures.pro
@@ -6,7 +6,6 @@ QT += core testlib sensors
QT -= gui
SOURCES += tst_qsensorgesturetest.cpp
-DEFINES += QT_NO_QOBJECT_CHECK
PLUGIN_1_HEADERS = \
diff --git a/tests/auto/qsensorgestures/tst_qsensorgesturetest.cpp b/tests/auto/qsensorgestures/tst_qsensorgesturetest.cpp
index b5f4a0f..b1ff19b 100644
--- a/tests/auto/qsensorgestures/tst_qsensorgesturetest.cpp
+++ b/tests/auto/qsensorgestures/tst_qsensorgesturetest.cpp
@@ -51,21 +51,34 @@
#include <qsensorgesturerecognizer.h>
#include <qsensorgestureplugininterface.h>
-static bool waitForSignal(QObject *obj, const char *signal, int timeout = 0)
+static QString removeParens(const QString &arg)
{
- QEventLoop loop;
- QObject::connect(obj, signal, &loop, SLOT(quit()));
- QTimer timer;
- QSignalSpy timeoutSpy(&timer, SIGNAL(timeout()));
- if (timeout > 0) {
- QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
- timer.setSingleShot(true);
- timer.start(timeout);
- }
- loop.exec();
- return timeoutSpy.isEmpty();
+ return arg.left(arg.indexOf("("));
}
+class QSensorGestureWithSlots : public QObject
+{
+ Q_OBJECT
+public:
+ QSensorGestureWithSlots(const QStringList &ids)
+ : gesture(new QSensorGesture(ids, this))
+ {
+ }
+
+ QSensorGesture *gesture;
+
+public slots:
+ void startDetection()
+ {
+ gesture->startDetection();
+ }
+
+ void stopDetection()
+ {
+ gesture->stopDetection();
+ }
+};
+
class QTest3Recognizer : public QSensorGestureRecognizer
{
Q_OBJECT
@@ -100,26 +113,6 @@ void QTest3Recognizer::changeId(const QString &id)
}
-class GestureThread : public QThread
-{
- Q_OBJECT
-public:
- GestureThread(const QStringList &name) { ids = name;}
- ~GestureThread() { delete gesture; }
- void run()
- {
- gesture = new QSensorGesture(ids, this);
- QObject::connect(gesture,SIGNAL(detected(QString)),this,SIGNAL(detected(QString)));
- gesture->startDetection();
- }
-
- QSensorGesture *gesture;
- QStringList ids;
-
-Q_SIGNALS:
- void detected(const QString &);
-};
-
class Tst_qsensorgestureTest : public QObject
{
Q_OBJECT
@@ -141,7 +134,6 @@ private Q_SLOTS:
void tst_sensor_gesture_threaded();
void tst_sensor_gesture();
- void tst_sensor_gesture_metacast();
void tst_recognizer();
@@ -176,23 +168,21 @@ void Tst_qsensorgestureTest::tst_recognizer_dup()
QVERIFY(!recognizerSignalsList.contains("QtSensors.test2"));
}
- QSensorGesture *sensorGesture = new QSensorGesture(idList, this);
+ QScopedPointer<QSensorGesture> sensorGesture(new QSensorGesture(idList));
QVERIFY(sensorGesture->validIds().contains("QtSensors.test2"));
QVERIFY(sensorGesture->validIds().contains("QtSensors.test"));
QVERIFY(sensorGesture->validIds().contains("QtSensors.test.dup"));
- delete sensorGesture;
}
- QSensorGesture *thisGesture;
+ QScopedPointer<QSensorGesture> thisGesture;
QString plugin;
plugin = "QtSensors.test2";
- thisGesture = new QSensorGesture(QStringList() << plugin, this);
+ thisGesture.reset(new QSensorGesture(QStringList() << plugin));
QVERIFY(thisGesture->validIds().contains("QtSensors.test2"));
plugin = "QtSensors.test.dup";
- thisGesture = new QSensorGesture(QStringList() << plugin, this);
+ thisGesture.reset(new QSensorGesture(QStringList() << plugin));
QVERIFY(!thisGesture->validIds().contains("QtSensors.test2"));
- delete thisGesture;
}
void Tst_qsensorgestureTest::tst_manager()
@@ -205,50 +195,46 @@ void Tst_qsensorgestureTest::tst_manager()
void Tst_qsensorgestureTest::tst_manager_gestureids()
{
- {
- QStringList idList;
- QSensorGestureManager manager;
- idList = manager.gestureIds();
+ QStringList idList;
+ QSensorGestureManager manager;
+ idList = manager.gestureIds();
- QVERIFY(idList.count() > 0);
+ QVERIFY(idList.count() > 0);
- QVERIFY(idList.contains("QtSensors.test"));
- QVERIFY(idList.contains("QtSensors.test2"));
- QVERIFY(idList.contains("QtSensors.test.dup"));
- }
+ QVERIFY(idList.contains("QtSensors.test"));
+ QVERIFY(idList.contains("QtSensors.test2"));
+ QVERIFY(idList.contains("QtSensors.test.dup"));
}
void Tst_qsensorgestureTest::tst_manager_recognizerSignals()
{
- {
- QStringList idList;
+ QStringList idList;
- QSensorGestureManager manager;
- idList = manager.gestureIds();
+ QSensorGestureManager manager;
+ idList = manager.gestureIds();
- idList.removeOne("QtSensors.test.dup");
+ idList.removeOne("QtSensors.test.dup");
- for (int i = 0; i < idList.count(); i++) {
+ for (int i = 0; i < idList.count(); i++) {
- QStringList recognizerSignalsList = manager.recognizerSignals(idList.at(i));
+ QStringList recognizerSignalsList = manager.recognizerSignals(idList.at(i));
- if (idList.at(i) == "QtSensors.test") {
- QStringList signalList;
- signalList << "detected(QString)";
- signalList << "tested()";
- QVERIFY(recognizerSignalsList.count() == 2);
+ if (idList.at(i) == "QtSensors.test") {
+ QStringList signalList;
+ signalList << "detected(QString)";
+ signalList << "tested()";
+ QCOMPARE(recognizerSignalsList.count(), 2);
- QVERIFY(recognizerSignalsList == signalList);
+ QCOMPARE(recognizerSignalsList, signalList);
- } else if (idList.at(i) == "QtSensors.test2") {
- QStringList signalList;
- signalList << "detected(QString)";
- signalList << "test2()";
- signalList << "test3(bool)";
+ } else if (idList.at(i) == "QtSensors.test2") {
+ QStringList signalList;
+ signalList << "detected(QString)";
+ signalList << "test2()";
+ signalList << "test3(bool)";
- QVERIFY(recognizerSignalsList.count() == 3);
- QVERIFY(recognizerSignalsList == signalList);
- }
+ QCOMPARE(recognizerSignalsList.count(), 3);
+ QCOMPARE(recognizerSignalsList, signalList);
}
}
}
@@ -260,13 +246,13 @@ void Tst_qsensorgestureTest::tst_manager_registerSensorGestureRecognizer()
QSensorGestureRecognizer *recognizer = new QTest3Recognizer;
bool ok = manager.registerSensorGestureRecognizer(recognizer);
QCOMPARE(ok, true);
- QVERIFY(num+1 == manager.gestureIds().count());
+ QCOMPARE(num+1, manager.gestureIds().count());
recognizer = new QTest3Recognizer;
QTest::ignoreMessage(QtWarningMsg, "\"QtSensors/test3\" is already known ");
ok = manager.registerSensorGestureRecognizer(recognizer);
QCOMPARE(ok, false);
- QVERIFY(num+1 == manager.gestureIds().count());
+ QCOMPARE(num+1, manager.gestureIds().count());
}
void Tst_qsensorgestureTest::tst_manager__newSensorAvailable()
@@ -296,8 +282,8 @@ void Tst_qsensorgestureTest::tst_manager__newSensorAvailable()
QCOMPARE(spy_manager_available.count(),1);
QCOMPARE(spy_manager2_available.count(),1);
- QSensorGesture *test4sg;
- test4sg = new QSensorGesture(QStringList() << "QtSensors.test4",this);
+ QScopedPointer<QSensorGesture> test4sg;
+ test4sg.reset(new QSensorGesture(QStringList() << "QtSensors.test4"));
QVERIFY(!test4sg->validIds().isEmpty());
QVERIFY(test4sg->invalidIds().isEmpty());
}
@@ -311,38 +297,32 @@ void Tst_qsensorgestureTest::tst_sensor_gesture_signals()
Q_FOREACH (const QString &plugin, testidList) {
- QSensorGesture *thisGesture;
- thisGesture = new QSensorGesture(QStringList() << plugin, this);
+ QScopedPointer<QSensorGesture> thisGesture(new QSensorGesture(QStringList() << plugin));
- QSignalSpy spy_gesture_detected(thisGesture, SIGNAL(detected(QString)));
-
- QSignalSpy *spy_gesture_tested;
- QSignalSpy *spy_gesture_test2;
+ QSignalSpy spy_gesture_detected(thisGesture.data(), SIGNAL(detected(QString)));
+ QScopedPointer<QSignalSpy> spy_gesture_tested(0);
if (plugin == "QtSensors.test") {
QStringList signalList;
signalList << "detected(QString)";
signalList << "tested()";
- QVERIFY(thisGesture->gestureSignals().count() == 2);
- QVERIFY(thisGesture->gestureSignals() == signalList);
-
- QVERIFY(thisGesture->gestureSignals().at(1) == "tested()");
+ QCOMPARE(thisGesture->gestureSignals().count(), 2);
+ QCOMPARE(thisGesture->gestureSignals(), signalList);
- spy_gesture_tested = new QSignalSpy(thisGesture, SIGNAL(tested()));
- }
+ QCOMPARE(thisGesture->gestureSignals().at(1), QString("tested()"));
- if (plugin == "QtSensors.test2") {
+ spy_gesture_tested.reset(new QSignalSpy(thisGesture.data(), SIGNAL(tested())));
+ } else if (plugin == "QtSensors.test2") {
QStringList signalList;
signalList << "detected(QString)";
signalList << "test2()";
signalList << "test3(bool)";
- QVERIFY(thisGesture->gestureSignals().count() == 3);
- QVERIFY(thisGesture->gestureSignals() == signalList);
+ QCOMPARE(thisGesture->gestureSignals().count(), 3);
+ QCOMPARE(thisGesture->gestureSignals(), signalList);
QCOMPARE(thisGesture->gestureSignals().at(1), QString("test2()"));
- spy_gesture_test2 = new QSignalSpy(thisGesture, SIGNAL(test2()));
-
+ spy_gesture_tested.reset(new QSignalSpy(thisGesture.data(), SIGNAL(test2())));
}
QVERIFY(!thisGesture->validIds().isEmpty());
@@ -354,15 +334,10 @@ void Tst_qsensorgestureTest::tst_sensor_gesture_signals()
QCOMPARE(spy_gesture_tested->count(),1);
QList<QVariant> arguments ;
arguments = spy_gesture_detected.takeFirst(); // take the first signal
- QCOMPARE(arguments.at(0),QVariant("tested"));
- }
-
- if (plugin == "QtSensors.test2") {
- QCOMPARE(spy_gesture_test2->count(),1);
+ QCOMPARE(arguments.at(0).toString(), QString("tested"));
+ } else if (plugin == "QtSensors.test2") {
+ QCOMPARE(spy_gesture_tested->count(),1);
}
-
- delete thisGesture;
- thisGesture = 0;
}
}
@@ -371,14 +346,16 @@ void Tst_qsensorgestureTest::tst_sensor_gesture_signals()
void Tst_qsensorgestureTest::tst_sensor_gesture_threaded()
{
- QSensorGesture *gesture = new QSensorGesture(QStringList() << "QtSensors.test", this);
+ QScopedPointer<QSensorGesture> gesture(new QSensorGesture(QStringList() << "QtSensors.test"));
- GestureThread *thread = new GestureThread( QStringList() << "QtSensors.test");
+ QScopedPointer<QThread> thread(new QThread);
+ QScopedPointer<QSensorGestureWithSlots> t_gesture(new QSensorGestureWithSlots(QStringList() << "QtSensors.test"));
+ t_gesture->moveToThread(thread.data());
- currentSignal = gesture->gestureSignals().at(0).left(gesture->gestureSignals().at(0).indexOf("("));
+ currentSignal = removeParens(gesture->gestureSignals().at(0));
- QSignalSpy thread_gesture(thread, SIGNAL(detected(QString)));
- QSignalSpy spy_gesture2(gesture, SIGNAL(detected(QString)));
+ QSignalSpy thread_gesture(t_gesture->gesture, SIGNAL(detected(QString)));
+ QSignalSpy spy_gesture2(gesture.data(), SIGNAL(detected(QString)));
QCOMPARE(gesture->isActive(),false);
gesture->startDetection();
@@ -388,49 +365,49 @@ void Tst_qsensorgestureTest::tst_sensor_gesture_threaded()
QCOMPARE(gesture->isActive(),true);
- thread->run();
- QCOMPARE(thread->gesture->isActive(),true);
+ thread->start();
+ QTimer::singleShot(0, t_gesture.data(), SLOT(startDetection())); // Delivered on the thread
- QVERIFY(::waitForSignal(thread, SIGNAL(detected(QString)), 60 * 1000));
+ QTRY_COMPARE(t_gesture->gesture->isActive(),true);
- QVERIFY(::waitForSignal(gesture, SIGNAL(detected(QString)), 60 * 1000));
+ QTRY_VERIFY(thread_gesture.count() > 0);
+ spy_gesture2.clear();
+ QTRY_VERIFY(spy_gesture2.count() > 0);
- thread->gesture->stopDetection();
+ QTimer::singleShot(0, t_gesture.data(), SLOT(stopDetection())); // Delivered on the thread
- QCOMPARE(thread->gesture->isActive(),false);
+ QTRY_COMPARE(t_gesture->gesture->isActive(),false);
QCOMPARE(gesture->isActive(),true);
- delete gesture;
- gesture = 0;
- delete thread;
- thread = 0;
+ thread->quit();
+ thread->wait();
}
void Tst_qsensorgestureTest::tst_sensor_gesture()
{
- QSensorGesture *gesture = new QSensorGesture(QStringList() << "QtSensors.test", this);
+ QScopedPointer<QSensorGesture> gesture(new QSensorGesture(QStringList() << "QtSensors.test"));
- QSensorGesture *gesture2 = new QSensorGesture(QStringList() << "QtSensors.test2", this);
- QSensorGesture *gesture3 = new QSensorGesture(QStringList() << "QtSensors.test2", this);
+ QScopedPointer<QSensorGesture> gesture2(new QSensorGesture(QStringList() << "QtSensors.test2"));
+ QScopedPointer<QSensorGesture> gesture3(new QSensorGesture(QStringList() << "QtSensors.test2"));
QCOMPARE(gesture->validIds(),QStringList() << "QtSensors.test");
- QCOMPARE(gesture->gestureSignals().at(1).left(gesture->gestureSignals().at(1).indexOf("(")),QString("tested"));
+ QCOMPARE(gesture->gestureSignals().at(1), QString("tested()"));
QVERIFY(gesture->invalidIds().isEmpty());
QVERIFY(gesture2->invalidIds().isEmpty());
QVERIFY(gesture3->invalidIds().isEmpty());
- currentSignal = gesture->gestureSignals().at(1).left(gesture->gestureSignals().at(1).indexOf("("));
+ currentSignal = removeParens(gesture->gestureSignals().at(1));
- QSignalSpy spy_gesture(gesture, SIGNAL(detected(QString)));
+ QSignalSpy spy_gesture(gesture.data(), SIGNAL(detected(QString)));
- QSignalSpy spy_gesture2(gesture2, SIGNAL(detected(QString)));
+ QSignalSpy spy_gesture2(gesture2.data(), SIGNAL(detected(QString)));
- QSignalSpy spy_gesture3_detected(gesture3, SIGNAL(detected(QString)));
+ QSignalSpy spy_gesture3_detected(gesture3.data(), SIGNAL(detected(QString)));
- QSignalSpy spy_gesture4_test2(gesture3, SIGNAL(test2()));
- QSignalSpy spy_gesture5_test3(gesture3, SIGNAL(test3(bool)));
+ QSignalSpy spy_gesture4_test2(gesture3.data(), SIGNAL(test2()));
+ QSignalSpy spy_gesture5_test3(gesture3.data(), SIGNAL(test3(bool)));
QCOMPARE(gesture->isActive(),false);
@@ -440,10 +417,10 @@ void Tst_qsensorgestureTest::tst_sensor_gesture()
QCOMPARE(gesture->isActive(),true);
QCOMPARE(gesture2->validIds(),QStringList() <<"QtSensors.test2");
- QCOMPARE(gesture2->gestureSignals().at(1).left(gesture2->gestureSignals().at(1).indexOf("(")),QString("test2"));
- currentSignal = gesture2->gestureSignals().at(1).left(gesture2->gestureSignals().at(1).indexOf("("));
+ QCOMPARE(gesture2->gestureSignals().at(1), QString("test2()"));
+ currentSignal = removeParens(gesture2->gestureSignals().at(1));
- connect(gesture2,SIGNAL(detected(QString)),
+ connect(gesture2.data(),SIGNAL(detected(QString)),
this,SLOT(shakeDetected(QString)));
QCOMPARE(gesture2->isActive(),false);
@@ -478,49 +455,21 @@ void Tst_qsensorgestureTest::tst_sensor_gesture()
QCOMPARE(spy_gesture5_test3.count(),1);
QList<QVariant> arguments2 = spy_gesture5_test3.takeFirst();
- QVERIFY(arguments2.at(0).type() == QVariant::Bool);
- QVERIFY(arguments2.at(0) == true);
-
- delete gesture;
- gesture = 0;
- delete gesture2;
- gesture2 = 0;
- delete gesture3;
- gesture3 = 0;
+ QCOMPARE(arguments2.at(0).toBool(), true);
}
-void Tst_qsensorgestureTest::tst_sensor_gesture_metacast()
-{
- QSensorGesture *gesture = new QSensorGesture(QStringList() << "QtSensors.test", this);
- // exercise qt_metacast
- QVERIFY(!gesture->inherits(""));
- QVERIFY(gesture->inherits("QObject"));
-
-#if defined(QT_NO_QOBJECT_CHECK)
- QObject *o = qobject_cast<QObject *>(gesture);
- QVERIFY(o);
-
- // this will fail in the compile time check for
- // the Q_OBJECT macro in qobjectdefs.h unless QT_NO_QOBJECT_CHECK is defined,
- QSensorGesture *gest = qobject_cast<QSensorGesture *>(o);
- QVERIFY(!gest->gestureSignals().isEmpty());
-#endif
- delete gesture;
-}
-
-
void Tst_qsensorgestureTest::tst_recognizer()
{
- QSensorGesture *gesture = new QSensorGesture(QStringList() << "QtSensors.test", this);
- QSensorGesture *gesture2 = new QSensorGesture(QStringList() << "QtSensors.test", this);
+ QScopedPointer<QSensorGesture> gesture(new QSensorGesture(QStringList() << "QtSensors.test"));
+ QScopedPointer<QSensorGesture> gesture2(new QSensorGesture(QStringList() << "QtSensors.test"));
- QSignalSpy spy_gesture(gesture, SIGNAL(detected(QString)));
- QSignalSpy spy_gesture2(gesture2, SIGNAL(detected(QString)));
+ QSignalSpy spy_gesture(gesture.data(), SIGNAL(detected(QString)));
+ QSignalSpy spy_gesture2(gesture2.data(), SIGNAL(detected(QString)));
QCOMPARE(gesture->isActive(),false);
QCOMPARE(gesture2->isActive(),false);
- currentSignal = gesture2->gestureSignals().at(0).left(gesture2->gestureSignals().at(0).indexOf("("));
+ currentSignal = removeParens(gesture2->gestureSignals().at(0));
gesture2->startDetection();//activate 2
@@ -532,7 +481,7 @@ void Tst_qsensorgestureTest::tst_recognizer()
QCOMPARE(spy_gesture2.count(),1);
QList<QVariant> arguments = spy_gesture2.takeFirst();
- QVERIFY(arguments.at(0) == "tested");
+ QCOMPARE(arguments.at(0).toString(), QString("tested"));
QCOMPARE(spy_gesture2.count(),0);
@@ -541,13 +490,12 @@ void Tst_qsensorgestureTest::tst_recognizer()
QCOMPARE(gesture->isActive(),true);
QCOMPARE(gesture2->isActive(),true);
- QVERIFY(::waitForSignal(gesture, SIGNAL(detected(QString)), 5 * 1000));
- QCOMPARE(spy_gesture.count(),1);
+ QTRY_COMPARE(spy_gesture.count(),1);
QCOMPARE(spy_gesture2.count(),1);
arguments = spy_gesture.takeFirst(); // take the first signal
- QVERIFY(arguments.at(0) == "tested");
+ QCOMPARE(arguments.at(0).toString(), QString("tested"));
spy_gesture2.removeFirst();
gesture->stopDetection(); //stop 1 gesture object
@@ -555,6 +503,7 @@ void Tst_qsensorgestureTest::tst_recognizer()
QCOMPARE(gesture->isActive(),false);
QCOMPARE(gesture2->isActive(),true);
+ spy_gesture2.clear();
gesture2->startDetection();
QCOMPARE(gesture->isActive(),false);
@@ -562,23 +511,18 @@ void Tst_qsensorgestureTest::tst_recognizer()
QCOMPARE(gesture2->isActive(),true);
- QVERIFY(::waitForSignal(gesture2, SIGNAL(detected(QString)), 60 * 1000));
-
- delete gesture;
- gesture = 0;
- delete gesture2;
- gesture2 = 0;
+ QTRY_COMPARE(spy_gesture2.count(), 1);
}
void Tst_qsensorgestureTest::tst_sensorgesture_noid()
{
- QSensorGesture *gesture = new QSensorGesture(QStringList() << "QtSensors.noid", this);
+ QScopedPointer<QSensorGesture> gesture(new QSensorGesture(QStringList() << "QtSensors.noid"));
QVERIFY(gesture->validIds().isEmpty());
QCOMPARE(gesture->invalidIds(), QStringList() << "QtSensors.noid");
QTest::ignoreMessage(QtWarningMsg, "QSignalSpy: No such signal: 'detected(QString)'");
- QSignalSpy spy_gesture(gesture, SIGNAL(detected(QString)));
+ QSignalSpy spy_gesture(gesture.data(), SIGNAL(detected(QString)));
QCOMPARE(spy_gesture.count(),0);
@@ -602,9 +546,6 @@ void Tst_qsensorgestureTest::tst_sensorgesture_noid()
QSensorGestureRecognizer *fakeRecognizer = manager.sensorGestureRecognizer("QtSensors.noid");
QVERIFY(!fakeRecognizer);
-
- delete gesture;
- gesture = 0;
}
void Tst_qsensorgestureTest::tst_sensor_gesture_multi()
@@ -615,31 +556,30 @@ void Tst_qsensorgestureTest::tst_sensor_gesture_multi()
ids <<"QtSensors.test2";
ids << "QtSensors.bogus";
- QSensorGesture *gesture = new QSensorGesture(ids,this);
+ QScopedPointer<QSensorGesture> gesture(new QSensorGesture(ids));
QStringList gestureSignals = gesture->gestureSignals();
gestureSignals.removeDuplicates() ;
- QVERIFY(gestureSignals == gesture->gestureSignals());
+ QCOMPARE(gestureSignals, gesture->gestureSignals());
- QVERIFY(gesture->gestureSignals().count() == 4);
+ QCOMPARE(gesture->gestureSignals().count(), 4);
QCOMPARE(gesture->invalidIds(), QStringList() << "QtSensors.bogus");
QCOMPARE(gesture->isActive(),false);
- QSignalSpy spy_gesture_detected(gesture, SIGNAL(detected(QString)));
+ QSignalSpy spy_gesture_detected(gesture.data(), SIGNAL(detected(QString)));
gesture->startDetection();
QCOMPARE(gesture->isActive(),true);
QCOMPARE(spy_gesture_detected.count(),2);
QList<QVariant> arguments ;
arguments = spy_gesture_detected.takeAt(0);
- QVERIFY(arguments.at(0) == "tested");
+ QCOMPARE(arguments.at(0).toString(), QString("tested"));
arguments = spy_gesture_detected.takeAt(0);
- QVERIFY(arguments.at(0) == "test2");
+ QCOMPARE(arguments.at(0).toString(), QString("test2"));
- QVERIFY(::waitForSignal(gesture, SIGNAL(detected(QString)), 60 * 1000));
- QCOMPARE(spy_gesture_detected.count(),1);
+ QTRY_COMPARE(spy_gesture_detected.count(),1);
gesture->stopDetection();
@@ -649,7 +589,7 @@ void Tst_qsensorgestureTest::tst_sensor_gesture_multi()
QSensorGestureManager manager;
QVERIFY(!manager.gestureIds().contains("QtSensors.bogus"));
QSensorGestureRecognizer *recognizer = manager.sensorGestureRecognizer("QtSensors.bogus");
- QVERIFY(recognizer == NULL);
+ QVERIFY(recognizer == 0);
}
}