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>
This commit is contained in:
parent
ef63be1418
commit
fe99ec537d
|
@ -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());
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue