summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGatis Paeglis <gatis.paeglis@qt.io>2017-11-22 12:11:03 +0100
committerGatis Paeglis <gatis.paeglis@qt.io>2017-11-30 15:05:40 +0000
commit75e583b3fcbdbbb999633eb5f2267720dd695cfa (patch)
tree4c8ecc462589c60322aa6cdf45cc79ac70ba4d22
parent2bb443557d35ae748f7bfc9a3bcf711f1ca96048 (diff)
qtestmouse: do not qWait for mocked events on macOS
This logic initially was copied from QTest::mouse* widget overload (by d130382776e8b9db491385a0db45a3daaa79890c) which uses QCursor::setPos() to generate mouse move events via the windowing system. The QCursor API was later removed by 1762bf3394219db3a7a9cc99306f4111e6cb8492, but now the redundant qWait logic remained. Later this stray qWait was incorrectly moved to apply for all mouse event types (by 268f41ec70fd70d4aa44a5043d1a4e678df4c5b5), when originally it was needed (arguably) only for mouse move events due to usage of QCursor. This patch also removes the waitForEvents() function as it is not a documented qtestlib API (in qtestlib only the documented functions should be considered public API, no matter what you can find in the header files). Removal does not affect binary compatibility as this is not an exported symbol. And if somebody has used this non public API, updating code is trivial. Change-Id: Id1dec10f5cf276cee1ac0e8c8f8ba2edc493b667 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
-rw-r--r--src/testlib/qtestcase.qdoc4
-rw-r--r--src/testlib/qtestmouse.h18
2 files changed, 7 insertions, 15 deletions
diff --git a/src/testlib/qtestcase.qdoc b/src/testlib/qtestcase.qdoc
index 5b90419e28..24bb1c3a97 100644
--- a/src/testlib/qtestcase.qdoc
+++ b/src/testlib/qtestcase.qdoc
@@ -1327,10 +1327,6 @@
// Internals of qtestmouse.h:
-/*! \fn void QTest::waitForEvents()
- \internal
-*/
-
/*! \fn void QTest::mouseEvent(MouseAction action, QWidget *widget, Qt::MouseButton button, Qt::KeyboardModifiers stateKey, QPoint pos, int delay=-1)
\internal
*/
diff --git a/src/testlib/qtestmouse.h b/src/testlib/qtestmouse.h
index 55f8baa003..fa524fd8ca 100644
--- a/src/testlib/qtestmouse.h
+++ b/src/testlib/qtestmouse.h
@@ -80,15 +80,13 @@ namespace QTest
// to depend on platform themes.
static const int mouseDoubleClickInterval = 500;
- static void waitForEvents()
- {
-#ifdef Q_OS_MAC
- QTest::qWait(20);
-#else
- qApp->processEvents();
-#endif
- }
+/*! \internal
+ This function mocks all mouse events by bypassing the windowing system. The
+ result is that the mouse events do not come from the system via Qt platform
+ plugins, but are created on the spot and immediately available for processing
+ by Qt.
+*/
static void mouseEvent(MouseAction action, QWindow *window, Qt::MouseButton button,
Qt::KeyboardModifiers stateKey, QPoint pos, int delay=-1)
{
@@ -144,13 +142,11 @@ namespace QTest
case MouseMove:
qt_handleMouseEvent(w, pos, global, lastMouseButton, Qt::NoButton, QEvent::MouseMove,
stateKey, ++lastMouseTimestamp);
- // No QCursor::setPos() call here. That could potentially result in mouse events sent by the windowing system
- // which is highly undesired here. Tests must avoid relying on QCursor.
break;
default:
QTEST_ASSERT(false);
}
- waitForEvents();
+ qApp->processEvents();
}
inline void mousePress(QWindow *window, Qt::MouseButton button,