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. Pick-to: 6.2 6.3 6.4 Change-Id: I7eba20a6b25f2e48a66145774539523def7142e6 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
parent
4a6e7cec99
commit
d223f1e3a8
|
@ -1,10 +1,3 @@
|
|||
[popup]
|
||||
macos # Can't control cursor (QTBUG-76312)
|
||||
|
||||
# QTBUG-87018
|
||||
[subMenuDisabledMouse]
|
||||
macos
|
||||
|
||||
# QTBUG-98491
|
||||
[disableWhenTriggered]
|
||||
macos
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue