From 068379a66f88b34545530a018c0826c2c09a100a Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Wed, 9 Aug 2017 12:51:40 +0200 Subject: Fix failing tests in tst_menu and tst_qquickmenubar As mentioned in the bug report for the failing tst_qquickmenubar test, the window is sometimes opened at the bottom right corner of the screen on the Ubuntu CI machines. However, even after centering the window on the screen, the old setPos() call still caused the tests to fail. So, we position the cursor past a different corner of the window, which works.. though I don't know why. Task-number: QTBUG-62363 Task-number: QTBUG-62383 Change-Id: I3649230002eaac5a6391daff24427e6f9f58cfa5 Reviewed-by: Qt CI Bot Reviewed-by: Simon Hausmann --- tests/auto/menu/BLACKLIST | 5 ----- tests/auto/menu/tst_menu.cpp | 7 +++++++ tests/auto/qquickmenubar/BLACKLIST | 5 ----- tests/auto/qquickmenubar/tst_qquickmenubar.cpp | 3 +++ tests/auto/shared/visualtestutil.cpp | 12 +++++++++++- tests/auto/shared/visualtestutil.h | 2 ++ 6 files changed, 23 insertions(+), 11 deletions(-) delete mode 100644 tests/auto/menu/BLACKLIST delete mode 100644 tests/auto/qquickmenubar/BLACKLIST (limited to 'tests/auto') diff --git a/tests/auto/menu/BLACKLIST b/tests/auto/menu/BLACKLIST deleted file mode 100644 index 868dc441..00000000 --- a/tests/auto/menu/BLACKLIST +++ /dev/null @@ -1,5 +0,0 @@ -# See qtbase/src/testlib/qtestblacklist.cpp for format - -# https://bugreports.qt.io/browse/QTBUG-62383 -[mouse] -ubuntu-16.04 ci diff --git a/tests/auto/menu/tst_menu.cpp b/tests/auto/menu/tst_menu.cpp index 36c143c9..4e96dea4 100644 --- a/tests/auto/menu/tst_menu.cpp +++ b/tests/auto/menu/tst_menu.cpp @@ -132,6 +132,7 @@ void tst_menu::mouse() QQuickApplicationWindow *window = helper.appWindow; window->show(); QVERIFY(QTest::qWaitForWindowActive(window)); + centerOnScreen(window); moveMouseAway(window); QQuickMenu *menu = window->property("menu").value(); @@ -245,6 +246,7 @@ void tst_menu::contextMenuKeyboard() window->requestActivate(); QVERIFY(QTest::qWaitForWindowActive(window)); QVERIFY(QGuiApplication::focusWindow() == window); + centerOnScreen(window); moveMouseAway(window); QQuickMenu *menu = window->property("menu").value(); @@ -485,6 +487,7 @@ void tst_menu::menuSeparator() QQuickWindow *window = helper.window; window->show(); QVERIFY(QTest::qWaitForWindowActive(window)); + centerOnScreen(window); moveMouseAway(window); QQuickMenu *menu = window->property("menu").value(); @@ -625,6 +628,7 @@ void tst_menu::popup() QQuickApplicationWindow *window = helper.appWindow; window->show(); QVERIFY(QTest::qWaitForWindowActive(window)); + centerOnScreen(window); moveMouseAway(window); QQuickMenu *menu = window->property("menu").value(); @@ -898,6 +902,7 @@ void tst_menu::subMenuMouse() QQuickApplicationWindow *window = helper.appWindow; window->show(); QVERIFY(QTest::qWaitForWindowActive(window)); + centerOnScreen(window); moveMouseAway(window); QQuickMenu *mainMenu = window->property("mainMenu").value(); @@ -1000,6 +1005,7 @@ void tst_menu::subMenuKeyboard() QQuickApplicationWindow *window = helper.appWindow; window->show(); QVERIFY(QTest::qWaitForWindowActive(window)); + centerOnScreen(window); moveMouseAway(window); if (mirrored) @@ -1139,6 +1145,7 @@ void tst_menu::subMenuPosition() window->show(); QVERIFY(QTest::qWaitForWindowActive(window)); + centerOnScreen(window); moveMouseAway(window); if (mirrored) diff --git a/tests/auto/qquickmenubar/BLACKLIST b/tests/auto/qquickmenubar/BLACKLIST deleted file mode 100644 index 5ec6525d..00000000 --- a/tests/auto/qquickmenubar/BLACKLIST +++ /dev/null @@ -1,5 +0,0 @@ -# See qtbase/src/testlib/qtestblacklist.cpp for format - -# https://bugreports.qt.io/browse/QTBUG-62363 -[mouse] -ubuntu-16.04 ci diff --git a/tests/auto/qquickmenubar/tst_qquickmenubar.cpp b/tests/auto/qquickmenubar/tst_qquickmenubar.cpp index 5e4d075e..932e13bc 100644 --- a/tests/auto/qquickmenubar/tst_qquickmenubar.cpp +++ b/tests/auto/qquickmenubar/tst_qquickmenubar.cpp @@ -83,6 +83,7 @@ void tst_qquickmenubar::mouse() QVERIFY(window); QVERIFY(QTest::qWaitForWindowActive(window.data())); + centerOnScreen(window.data()); moveMouseAway(window.data()); QQuickMenuBar *menuBar = window->property("header").value(); @@ -221,6 +222,7 @@ void tst_qquickmenubar::keys() QVERIFY(window); QVERIFY(QTest::qWaitForWindowActive(window.data())); + centerOnScreen(window.data()); moveMouseAway(window.data()); QQuickMenuBar *menuBar = window->property("header").value(); @@ -408,6 +410,7 @@ void tst_qquickmenubar::mnemonics() QVERIFY(window); QVERIFY(QTest::qWaitForWindowActive(window.data())); + centerOnScreen(window.data()); moveMouseAway(window.data()); QQuickMenuBar *menuBar = window->property("header").value(); diff --git a/tests/auto/shared/visualtestutil.cpp b/tests/auto/shared/visualtestutil.cpp index 47cfd74f..c5e69812 100644 --- a/tests/auto/shared/visualtestutil.cpp +++ b/tests/auto/shared/visualtestutil.cpp @@ -74,7 +74,10 @@ void QQuickVisualTestUtil::dumpTree(QQuickItem *parent, int depth) void QQuickVisualTestUtil::moveMouseAway(QQuickWindow *window) { #if QT_CONFIG(cursor) // Get the cursor out of the way. - QCursor::setPos(window->geometry().topRight() + QPoint(100, 100)); + // Using "bottomRight() + QPoint(100, 100)" was causing issues on Ubuntu, + // where the window was positioned at the bottom right corner of the window + // (even after centering the window on the screen), so we use another position. + QCursor::setPos(window->geometry().bottomLeft() + QPoint(0, 10)); #endif // make sure hover events from QQuickWindowPrivate::flushFrameSynchronousEvents() @@ -82,3 +85,10 @@ void QQuickVisualTestUtil::moveMouseAway(QQuickWindow *window) QEvent leave(QEvent::Leave); QCoreApplication::sendEvent(window, &leave); } + +void QQuickVisualTestUtil::centerOnScreen(QQuickWindow *window) +{ + const QRect screenGeometry = window->screen()->availableGeometry(); + const QPoint offset = QPoint(window->width() / 2, window->height() / 2); + window->setFramePosition(screenGeometry.center() - offset); +} diff --git a/tests/auto/shared/visualtestutil.h b/tests/auto/shared/visualtestutil.h index bcf45660..a6b52fef 100644 --- a/tests/auto/shared/visualtestutil.h +++ b/tests/auto/shared/visualtestutil.h @@ -54,6 +54,8 @@ namespace QQuickVisualTestUtil bool delegateVisible(QQuickItem *item); + void centerOnScreen(QQuickWindow *window); + void moveMouseAway(QQuickWindow *window); /* -- cgit v1.2.3