diff options
Diffstat (limited to 'tests/auto/cursor/tst_cursor.cpp')
-rw-r--r-- | tests/auto/cursor/tst_cursor.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/auto/cursor/tst_cursor.cpp b/tests/auto/cursor/tst_cursor.cpp index 0f24a29e..d59e7091 100644 --- a/tests/auto/cursor/tst_cursor.cpp +++ b/tests/auto/cursor/tst_cursor.cpp @@ -44,6 +44,11 @@ #include <QtQuickTemplates2/private/qquickscrollbar_p.h> #include <QtQuickTemplates2/private/qquicktextarea_p.h> +#if QT_CONFIG(cursor) +# include <QtGui/qscreen.h> +# include <QtGui/qcursor.h> +#endif + using namespace QQuickVisualTestUtil; class tst_cursor : public QQmlDataTest @@ -51,6 +56,7 @@ class tst_cursor : public QQmlDataTest Q_OBJECT private slots: + void init(); void controls_data(); void controls(); void editable(); @@ -58,6 +64,17 @@ private slots: void scrollBar(); }; +void tst_cursor::init() +{ +#if QT_CONFIG(cursor) + // Ensure mouse cursor was not left by previous tests where widgets + // will appear, as it could cause events and interfere with the tests. + const QScreen *screen = QGuiApplication::primaryScreen(); + const QRect availableGeometry = screen->availableGeometry(); + QCursor::setPos(availableGeometry.topLeft()); +#endif +} + void tst_cursor::controls_data() { QTest::addColumn<QString>("testFile"); |