summaryrefslogtreecommitdiffstats
path: root/src/testlib/qtestmouse.h
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.p.agocs@nokia.com>2012-03-12 10:48:08 +0200
committerQt by Nokia <qt-info@nokia.com>2012-03-13 21:11:55 +0100
commit268f41ec70fd70d4aa44a5043d1a4e678df4c5b5 (patch)
tree034661d6812acc191b4618eb065b1e871c0ce273 /src/testlib/qtestmouse.h
parent02d75eaaf9f2e4984f39b1e081e841966d1dde0c (diff)
Deliver events in qtestmouse
Not waiting until the QPA event queue is processed after handleMouseEvent() is wrong. Unlike the synchronous sendEvent() calls these tests most likely utilized earlier, many of the QWindowSystemInterace functions are asynchronous in the sense that they just queue the event, delivery will happen when the event dispatcher on the main thread gets there. Change-Id: I8197d2dc4805cda684a8279ceb8d4b317f19aba7 Reviewed-by: Michael Brasser <michael.brasser@nokia.com> Reviewed-by: Jason McDonald <jason.mcdonald@nokia.com>
Diffstat (limited to 'src/testlib/qtestmouse.h')
-rw-r--r--src/testlib/qtestmouse.h17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/testlib/qtestmouse.h b/src/testlib/qtestmouse.h
index 593e164b01..441cfa1f65 100644
--- a/src/testlib/qtestmouse.h
+++ b/src/testlib/qtestmouse.h
@@ -70,6 +70,15 @@ namespace QTest
{
enum MouseAction { MousePress, MouseRelease, MouseClick, MouseDClick, MouseMove };
+ static void waitForEvents()
+ {
+#ifdef Q_OS_MAC
+ QTest::qWait(20);
+#else
+ qApp->processEvents();
+#endif
+ }
+
static void mouseEvent(MouseAction action, QWindow *window, Qt::MouseButton button,
Qt::KeyboardModifiers stateKey, QPoint pos, int delay=-1)
{
@@ -119,15 +128,11 @@ namespace QTest
case MouseMove:
QWindowSystemInterface::handleMouseEvent(window,pos,window->mapToGlobal(pos),lastButton,stateKey);
//QCursor::setPos(window->mapToGlobal(pos));
-#ifdef Q_OS_MAC
- QTest::qWait(20);
-#else
- qApp->processEvents();
-#endif
- return;
+ break;
default:
QTEST_ASSERT(false);
}
+ waitForEvents();
}
inline void mousePress(QWindow *window, Qt::MouseButton button, Qt::KeyboardModifiers stateKey = 0,