From 268f41ec70fd70d4aa44a5043d1a4e678df4c5b5 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 12 Mar 2012 10:48:08 +0200 Subject: 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 Reviewed-by: Jason McDonald --- src/testlib/qtestmouse.h | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src') 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, -- cgit v1.2.3