aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2017-07-06 14:51:52 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2017-07-21 07:34:50 +0000
commitfe99ec537d0d247f8a4150341a25a54ec89353ef (patch)
tree379f8e11fd35c6ddc62e05b885ae508b6302d348 /tests
parentef63be14186607c2b806f45d257d8aba6e9a6472 (diff)
Auto tests: incorporate the QEvent::Leave trick to moveMouseAway()
6f1eba89 used QEvent::Leave to make QQuickWindow clear its last known mouse position, which ensures that QQuickWindow won't send unexpected hover events from flushFrameSynchronousEvents(). The same hover events are causing trouble in tst_qquickmenubar too, so incorporate the leave event trick to moveMouseAway() to benefit from it in other tests too. Change-Id: I25a285d008d1cb639c7be09d714e482d472b4e50 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/menu/tst_menu.cpp5
-rw-r--r--tests/auto/shared/visualtestutil.cpp8
2 files changed, 7 insertions, 6 deletions
diff --git a/tests/auto/menu/tst_menu.cpp b/tests/auto/menu/tst_menu.cpp
index 0fa3a9e8..36c143c9 100644
--- a/tests/auto/menu/tst_menu.cpp
+++ b/tests/auto/menu/tst_menu.cpp
@@ -522,10 +522,7 @@ void tst_menu::menuSeparator()
saveMenuItem->mapToScene(QPointF(saveMenuItem->width() / 2, saveMenuItem->height() / 2)).toPoint());
QTRY_VERIFY(!menu->isVisible());
- // make sure hover events from QQuickWindowPrivate::flushFrameSynchronousEvents()
- // do not interfere with the key navigation tests below
- QEvent leave(QEvent::Leave);
- QCoreApplication::sendEvent(window, &leave);
+ moveMouseAway(window);
menu->open();
QVERIFY(menu->isVisible());
diff --git a/tests/auto/shared/visualtestutil.cpp b/tests/auto/shared/visualtestutil.cpp
index 5e44f5e7..47cfd74f 100644
--- a/tests/auto/shared/visualtestutil.cpp
+++ b/tests/auto/shared/visualtestutil.cpp
@@ -39,6 +39,7 @@
#include <QtQuick/QQuickItem>
#include <QtCore/QDebug>
#include <QtGui/QCursor>
+#include <QtCore/QCoreApplication>
bool QQuickVisualTestUtil::delegateVisible(QQuickItem *item)
{
@@ -74,7 +75,10 @@ void QQuickVisualTestUtil::moveMouseAway(QQuickWindow *window)
{
#if QT_CONFIG(cursor) // Get the cursor out of the way.
QCursor::setPos(window->geometry().topRight() + QPoint(100, 100));
-#else
- Q_UNUSED(window)
#endif
+
+ // make sure hover events from QQuickWindowPrivate::flushFrameSynchronousEvents()
+ // do not interfere with the tests
+ QEvent leave(QEvent::Leave);
+ QCoreApplication::sendEvent(window, &leave);
}