diff options
author | Doris Verria <doris.verria@qt.io> | 2022-07-21 17:44:03 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-08-03 20:58:57 +0000 |
commit | 45d5e964bad98793fe3d23bb400de6705a65a67b (patch) | |
tree | 9b6fbbbc4dc54c433a900de45f67e2b2c6cb385b | |
parent | 5cdd324456061860b24e9f63a9ee2945711d577f (diff) |
tst_qquickmenu: Unblacklist some test cases on macOS
- SKIP instead of blacklist the popup test on macOS as the cursor
position can't be controlled on this platform.
- Use the TRY variant with isOpened() instead of isVisible() in order
to make sure that all enter/exit transitions are finished before
interacting with the menu. Otherwise, the test can be flaky.
- The subMenuDisabledMouse test expects currentIndex to be set on
mainMenu when the click happens. As we set the currentIndex on a
hover or keyboard navigation event, explicitly generate a hover event
with mouseMove before clicking.
Change-Id: I7eba20a6b25f2e48a66145774539523def7142e6
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
(cherry picked from commit d223f1e3a887f7b953b23b6c911ef6028755c935)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | tests/auto/quickcontrols2/qquickmenu/BLACKLIST | 7 | ||||
-rw-r--r-- | tests/auto/quickcontrols2/qquickmenu/tst_qquickmenu.cpp | 21 |
2 files changed, 17 insertions, 11 deletions
diff --git a/tests/auto/quickcontrols2/qquickmenu/BLACKLIST b/tests/auto/quickcontrols2/qquickmenu/BLACKLIST index 5f81f90cd3..fed4c6e561 100644 --- a/tests/auto/quickcontrols2/qquickmenu/BLACKLIST +++ b/tests/auto/quickcontrols2/qquickmenu/BLACKLIST @@ -1,10 +1,3 @@ -[popup] -macos # Can't control cursor (QTBUG-76312) - -# QTBUG-87018 -[subMenuDisabledMouse] -macos - # QTBUG-98491 [disableWhenTriggered] macos diff --git a/tests/auto/quickcontrols2/qquickmenu/tst_qquickmenu.cpp b/tests/auto/quickcontrols2/qquickmenu/tst_qquickmenu.cpp index 5b2b88eb2b..fc5ea55b9b 100644 --- a/tests/auto/quickcontrols2/qquickmenu/tst_qquickmenu.cpp +++ b/tests/auto/quickcontrols2/qquickmenu/tst_qquickmenu.cpp @@ -801,6 +801,13 @@ void tst_QQuickMenu::popup() if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"))) QSKIP("Setting cursor position is not supported on Wayland"); + // Try moving the cursor from the current position + // Skip if it fails since the test relies on moving the cursor + const QPoint point = QCursor::pos() + QPoint(1, 1); + QCursor::setPos(point); + if (!QTest::qWaitFor([point]{ return QCursor::pos() == point; })) + QSKIP("Setting cursor position is not supported on this platform"); + QQuickControlsApplicationHelper helper(this, QLatin1String("popup.qml")); QVERIFY2(helper.ready, helper.failureMessage()); QQuickApplicationWindow *window = helper.appWindow; @@ -1276,16 +1283,22 @@ void tst_QQuickMenu::subMenuDisabledMouse() QVERIFY(subMenu); mainMenu->open(); - QVERIFY(mainMenu->isVisible()); + QTRY_VERIFY(mainMenu->isOpened()); QVERIFY(!menuItem1->isHighlighted()); QVERIFY(!subMenu->isVisible()); + // Hover-highlighting does not work on Android +#ifndef Q_OS_ANDROID + // Generate a hover event to set the current index + QTest::mouseMove(window, menuItem1->mapToScene(QPoint(2, 2)).toPoint()); + QTRY_VERIFY(menuItem1->isHighlighted()); +#endif // Open the sub-menu with a mouse click. QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, menuItem1->mapToScene(QPoint(1, 1)).toPoint()); - // Need to use the TRY variant here when cascade is false, - // as e.g. Material style menus have transitions and don't close immediately. + // Need to use the TRY variant here, + // as e.g. Material, iOS style menus have transitions and don't open/close immediately. QTRY_COMPARE(mainMenu->isVisible(), cascade); - QVERIFY(subMenu->isVisible()); + QTRY_VERIFY(subMenu->isOpened()); QTRY_VERIFY(menuItem1->isHighlighted()); // Now the sub-menu is open. The current behavior is that the first menu item // in the new menu is highlighted; make sure that we choose the next item if |