aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickmousearea
diff options
context:
space:
mode:
authorJan Arve Saether <jan-arve.saether@qt.io>2016-08-12 13:38:54 +0200
committerLiang Qi <liang.qi@qt.io>2016-08-12 14:03:14 +0000
commit9010dd0e767c407f107aacfe6be145229e3ba793 (patch)
treec2fc468c0067f7aa023c4ba3aa456d6df90ba26d /tests/auto/quick/qquickmousearea
parent273e5b0bdc1239df77e2e5694fdd5ad068595be3 (diff)
Fix test failure: wait between mouse events the proper way
Apparently, QTest::mouseEvent() disregards the wall time for the time stamps for events, but synthesizes the timestamps instead. The proper way is to specify the waiting time in the delay argument. This will adjust both the timestamp and perform a qWait() before the event handler is called. Without this patch, the qWait(doubleClickInterval) was disregarded, which lead to that a doubleclick event was generated, and it failed with the following message: Actual (((window->rootObject()->property("doubleClicks").toInt()))): 2 Expected (1) : 1 tst_qquickmousearea.cpp(1105) : failure location Change-Id: Ieda3b670d3cda0bd522db2f9677dad5745c88a21 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'tests/auto/quick/qquickmousearea')
-rw-r--r--tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp31
1 files changed, 12 insertions, 19 deletions
diff --git a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp
index 9cdfd21f9c..d51c228b7c 100644
--- a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp
+++ b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp
@@ -1032,17 +1032,17 @@ void tst_QQuickMouseArea::clickThrough()
QVERIFY(QTest::qWaitForWindowExposed(window.data()));
QVERIFY(window->rootObject() != 0);
+ // to avoid generating a double click.
+ const int doubleClickInterval = qApp->styleHints()->mouseDoubleClickInterval() + 10;
+
QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(100,100));
QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(100,100));
QTRY_COMPARE(window->rootObject()->property("presses").toInt(), 0);
QTRY_COMPARE(window->rootObject()->property("clicks").toInt(), 1);
- // to avoid generating a double click.
- int doubleClickInterval = qApp->styleHints()->mouseDoubleClickInterval() + 10;
- QTest::qWait(doubleClickInterval);
-
- QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(100,100));
+ QCOMPARE(window->rootObject()->property("doubleClicks").toInt(), 0);
+ QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(100,100), doubleClickInterval);
QTest::qWait(1000);
QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(100,100));
@@ -1072,9 +1072,7 @@ void tst_QQuickMouseArea::clickThrough()
QCOMPARE(window->rootObject()->property("presses").toInt(), 0);
QCOMPARE(window->rootObject()->property("clicks").toInt(), 0);
- QTest::qWait(doubleClickInterval); // to avoid generating a double click.
-
- QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(100,100));
+ QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(100,100), doubleClickInterval);
QTest::qWait(1000);
QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(100,100));
QTest::qWait(100);
@@ -1093,15 +1091,13 @@ void tst_QQuickMouseArea::clickThrough()
window->rootObject()->setProperty("letThrough", QVariant(true));
- QTest::qWait(doubleClickInterval); // to avoid generating a double click.
- QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(100,100));
+ QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(100,100), doubleClickInterval);
QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(100,100));
QCOMPARE(window->rootObject()->property("presses").toInt(), 0);
QTRY_COMPARE(window->rootObject()->property("clicks").toInt(), 1);
- QTest::qWait(doubleClickInterval); // to avoid generating a double click.
- QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(100,100));
+ QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(100,100), doubleClickInterval);
QTest::qWait(1000);
QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(100,100));
QTest::qWait(100);
@@ -1120,12 +1116,10 @@ void tst_QQuickMouseArea::clickThrough()
window->rootObject()->setProperty("noPropagation", QVariant(true));
- QTest::qWait(doubleClickInterval); // to avoid generating a double click.
- QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(100,100));
+ QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(100,100), doubleClickInterval);
QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(100,100));
- QTest::qWait(doubleClickInterval); // to avoid generating a double click.
- QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(100,100));
+ QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(100,100), doubleClickInterval);
QTest::qWait(1000);
QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(100,100));
QTest::qWait(100);
@@ -1146,7 +1140,7 @@ void tst_QQuickMouseArea::clickThrough()
QVERIFY(QTest::qWaitForWindowExposed(window.data()));
QVERIFY(window->rootObject() != 0);
- QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(100,100));
+ QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(100,100), doubleClickInterval);
QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(100,100));
QCOMPARE(window->rootObject()->property("clicksEnabled").toInt(), 1);
@@ -1154,8 +1148,7 @@ void tst_QQuickMouseArea::clickThrough()
window->rootObject()->setProperty("disableLower", QVariant(true));
- QTest::qWait(doubleClickInterval); // to avoid generating a double click.
- QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(100,100));
+ QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(100,100), doubleClickInterval);
QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(100,100));
QCOMPARE(window->rootObject()->property("clicksEnabled").toInt(), 2);