summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Volkov <a.volkov@rusbitech.ru>2017-10-12 14:35:16 (GMT)
committerLiang Qi <liang.qi@qt.io>2018-01-24 08:07:11 (GMT)
commit8f89e12e90d3f13f243c8dc51442f50e91446371 (patch)
tree742423c8fe6fa0483259db714f30767823f1beb9
parenta5881f10e0ba6ba283b1215a5342056196661414 (diff)
downloadqtsensors-8f89e12e90d3f13f243c8dc51442f50e91446371.tar.gz
testSingleGestures: Fix for case of multiple gestures
This test fails sometimes for the twist gesture data, because it contains 3 gestures. QTRY_COMPARE_WITH_TIMEOUT usually stops comparison after recognition of the first gesture, but it may make the first comparison after more than one gesture has been recognized and thus fail the test. Add a new column to the test data with a list of gestures that should be recognized and use the list in QTRY_COMPARE_WITH_TIMEOUT. It will make the error message more informative if the test will fail, and should make the test pass on all configurations. Task-number: QTBUG-65861 Change-Id: Icfd86831b527da4933da2a20f45ccf9617862eac Reviewed-by: Lorn Potter <lorn.potter@gmail.com> (cherry picked from commit e3b6a54a75482c5ddd91dab50a86629053c69a2e)
-rw-r--r--tests/auto/qsensorgestures_gestures/tst_sensorgestures_gestures.cpp31
1 files changed, 21 insertions, 10 deletions
diff --git a/tests/auto/qsensorgestures_gestures/tst_sensorgestures_gestures.cpp b/tests/auto/qsensorgestures_gestures/tst_sensorgestures_gestures.cpp
index ee24210..69dcce9 100644
--- a/tests/auto/qsensorgestures_gestures/tst_sensorgestures_gestures.cpp
+++ b/tests/auto/qsensorgestures_gestures/tst_sensorgestures_gestures.cpp
@@ -87,6 +87,7 @@ void tst_sensorgestures_gestures::initTestCase()
void tst_sensorgestures_gestures::testSingleGestures()
{
QFETCH(QString, gestureId);
+ QFETCH(QStringList, gestureSignals);
QString name = "mock_data/sensordata_" + gestureId + ".dat";
@@ -105,21 +106,31 @@ void tst_sensorgestures_gestures::testSingleGestures()
gesture.data()->startDetection();
QCOMPARE(gesture->isActive(),true);
- QTRY_COMPARE_WITH_TIMEOUT(spy_gesture.count(),1, 7000);
+ auto toStringList = [](const QList<QList<QVariant>> list) {
+ QStringList result;
+ for (const QList<QVariant> &item: list) {
+ if (!item.isEmpty())
+ result << item.first().toString();
+ }
+ return result;
+ };
+
+ QTRY_COMPARE_WITH_TIMEOUT(toStringList(spy_gesture), gestureSignals, 7000);
}
void tst_sensorgestures_gestures::testSingleGestures_data()
{
QTest::addColumn<QString>("gestureId");
- QTest::newRow("cover") << "cover";
- QTest::newRow("doubletap") << "doubletap";
- QTest::newRow("hover") << "hover";
- QTest::newRow("pickup") << "pickup";
- QTest::newRow("shake2") << "shake2"; //multi?
- QTest::newRow("slam") << "slam";
- QTest::newRow("turnover") << "turnover";
- QTest::newRow("twist") << "twist"; //multi?
- QTest::newRow("whip") << "whip";
+ QTest::addColumn<QStringList>("gestureSignals");
+ QTest::newRow("cover") << "cover" << QStringList({ "cover"});
+ QTest::newRow("doubletap") << "doubletap" << QStringList({ "doubletap" });
+ QTest::newRow("hover") << "hover" << QStringList({ "hover" });
+ QTest::newRow("pickup") << "pickup" << QStringList({ "pickup" });
+ QTest::newRow("shake2") << "shake2" << QStringList({ "shakeRight" });
+ QTest::newRow("slam") << "slam" << QStringList({ "slam" });
+ QTest::newRow("turnover") << "turnover" << QStringList({ "turnover" });
+ QTest::newRow("twist") << "twist" << QStringList({ "twistLeft", "twistLeft", "twistRight" });
+ QTest::newRow("whip") << "whip" << QStringList({ "whip" });
}
void tst_sensorgestures_gestures::testSingleDataset2Gestures()