diff options
author | Ulf Hermann <ulf.hermann@digia.com> | 2015-05-28 13:02:54 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2015-06-05 05:51:17 +0000 |
commit | ddd546d53cc4caf41c6cf34f8295b61af0aa8df3 (patch) | |
tree | b31233cfd79ff72c2893614ab006e49a612786a4 /tests/auto/quick/shared | |
parent | dd5bf45db6521743c07a1593511ac51ec6e05945 (diff) |
Fix flickable autotest
* Make sure we always wait for window activation, not only exposal.
* When clicking or releasing, first move the mouse to the right place.
* In returnToBounds() show() the window before we rely on its event
loop.
* In rebound() reduce the delays as mouse events get delivered
earlier now and the movement might stop and restart if we wait for
too long between subsequent mouse moves.
Most of these problems have been exposed by commit
66050f2ac875d451bec31e0d8ff507795b5b18d6 in qtbase.
Change-Id: I5a3bc1e4ba92362d69180c8fde33eca47b4b9375
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'tests/auto/quick/shared')
-rw-r--r-- | tests/auto/quick/shared/viewtestutil.cpp | 16 | ||||
-rw-r--r-- | tests/auto/quick/shared/viewtestutil.h | 2 |
2 files changed, 16 insertions, 2 deletions
diff --git a/tests/auto/quick/shared/viewtestutil.cpp b/tests/auto/quick/shared/viewtestutil.cpp index 5b9111d448..86d61a0c23 100644 --- a/tests/auto/quick/shared/viewtestutil.cpp +++ b/tests/auto/quick/shared/viewtestutil.cpp @@ -72,18 +72,30 @@ void QQuickViewTestUtil::moveMouseAway(QQuickView *window) #endif } +void QQuickViewTestUtil::moveAndRelease(QQuickView *window, const QPoint &position) +{ + QTest::mouseMove(window, position); + QTest::mouseRelease(window, Qt::LeftButton, 0, position); +} + +void QQuickViewTestUtil::moveAndPress(QQuickView *window, const QPoint &position) +{ + QTest::mouseMove(window, position); + QTest::mousePress(window, Qt::LeftButton, 0, position); +} + void QQuickViewTestUtil::flick(QQuickView *window, const QPoint &from, const QPoint &to, int duration) { const int pointCount = 5; QPoint diff = to - from; // send press, five equally spaced moves, and release. - QTest::mousePress(window, Qt::LeftButton, 0, from); + moveAndPress(window, from); for (int i = 0; i < pointCount; ++i) QTest::mouseMove(window, from + (i+1)*diff/pointCount, duration / pointCount); - QTest::mouseRelease(window, Qt::LeftButton, 0, to); + moveAndRelease(window, to); QTest::qWait(50); } diff --git a/tests/auto/quick/shared/viewtestutil.h b/tests/auto/quick/shared/viewtestutil.h index 8c5f5c54e6..1643eca979 100644 --- a/tests/auto/quick/shared/viewtestutil.h +++ b/tests/auto/quick/shared/viewtestutil.h @@ -48,6 +48,8 @@ namespace QQuickViewTestUtil void centerOnScreen(QQuickView *window, const QSize &size); void centerOnScreen(QQuickView *window); void moveMouseAway(QQuickView *window); + void moveAndPress(QQuickView *window, const QPoint &position); + void moveAndRelease(QQuickView *window, const QPoint &position); QList<int> adjustIndexesForAddDisplaced(const QList<int> &indexes, int index, int count); QList<int> adjustIndexesForMove(const QList<int> &indexes, int from, int to, int count); |