diff options
-rw-r--r-- | tests/auto/quickcontrols2/qquickpopup/tst_qquickpopup.cpp | 84 |
1 files changed, 65 insertions, 19 deletions
diff --git a/tests/auto/quickcontrols2/qquickpopup/tst_qquickpopup.cpp b/tests/auto/quickcontrols2/qquickpopup/tst_qquickpopup.cpp index 6583f2601e..d86344e3ae 100644 --- a/tests/auto/quickcontrols2/qquickpopup/tst_qquickpopup.cpp +++ b/tests/auto/quickcontrols2/qquickpopup/tst_qquickpopup.cpp @@ -6,6 +6,8 @@ #include <QtCore/qoperatingsystemversion.h> #include <QtGui/qpa/qwindowsysteminterface.h> +#include <QtGui/qpa/qplatformintegration.h> +#include <QtGui/private/qguiapplication_p.h> #include <QtQuick/qquickview.h> #include <QtQuick/private/qquickpalette_p.h> #include <QtQuickTestUtils/private/qmlutils_p.h> @@ -85,6 +87,9 @@ private slots: void dimmerContainmentMask(); void shrinkPopupThatWasLargerThanWindow_data(); void shrinkPopupThatWasLargerThanWindow(); + +private: + static bool hasWindowActivation(); }; tst_QQuickPopup::tst_QQuickPopup() @@ -105,6 +110,11 @@ void tst_QQuickPopup::visible_data() QTest::newRow("ApplicationWindow") << "applicationwindow.qml"; } +bool tst_QQuickPopup::hasWindowActivation() +{ + return (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)); +} + void tst_QQuickPopup::visible() { QFETCH(QString, source); @@ -113,8 +123,7 @@ void tst_QQuickPopup::visible() QQuickWindow *window = helper.window; window->show(); - window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window)); + QVERIFY(QTest::qWaitForWindowExposed(window)); QQuickPopup *popup = window->property("popup").value<QQuickPopup*>(); QVERIFY(popup); @@ -210,8 +219,7 @@ void tst_QQuickPopup::overlay() QQuickWindow *window = helper.window; window->show(); - window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window)); + QVERIFY(QTest::qWaitForWindowExposed(window)); QQuickOverlay *overlay = QQuickOverlay::overlay(window); QVERIFY(overlay); @@ -362,8 +370,7 @@ void tst_QQuickPopup::zOrder() QQuickWindow *window = helper.window; window->show(); - window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window)); + QVERIFY(QTest::qWaitForWindowExposed(window)); QQuickPopup *popup = window->property("popup").value<QQuickPopup*>(); QVERIFY(popup); @@ -464,6 +471,9 @@ void tst_QQuickPopup::closePolicy_data() void tst_QQuickPopup::closePolicy() { + if (!hasWindowActivation()) + QSKIP("Window activation is not supported"); + QFETCH(QString, source); QFETCH(QQuickPopup::ClosePolicy, closePolicy); @@ -575,8 +585,7 @@ void tst_QQuickPopup::closePolicy_grabberInside() QQuickWindow *window = helper.window; window->show(); - window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window)); + QVERIFY(QTest::qWaitForWindowExposed(window)); QQuickPopup *popup = window->property("popup3").value<QQuickPopup*>(); QVERIFY(popup); @@ -585,7 +594,6 @@ void tst_QQuickPopup::closePolicy_grabberInside() QVERIFY(slider); popup->setModal(true); - popup->setFocus(true); popup->setClosePolicy(closePolicy); popup->open(); @@ -603,6 +611,9 @@ void tst_QQuickPopup::closePolicy_grabberInside() void tst_QQuickPopup::activeFocusOnClose1() { + if (!hasWindowActivation()) + QSKIP("Window activation is not supported"); + // Test that a popup that never sets focus: true (e.g. ToolTip) doesn't affect // the active focus item when it closes. QQuickControlsApplicationHelper helper(this, QStringLiteral("activeFocusOnClose1.qml")); @@ -646,6 +657,9 @@ void tst_QQuickPopup::activeFocusOnClose1() void tst_QQuickPopup::activeFocusOnClose2() { + if (!hasWindowActivation()) + QSKIP("Window activation is not supported"); + // Test that a popup that sets focus: true but relinquishes focus (e.g. by // calling forceActiveFocus() on another item) before it closes doesn't // affect the active focus item when it closes. @@ -685,6 +699,9 @@ void tst_QQuickPopup::activeFocusOnClose2() void tst_QQuickPopup::activeFocusOnClose3() { + if (!hasWindowActivation()) + QSKIP("Window activation is not supported"); + // Test that a closing popup that had focus doesn't steal focus from // another popup that the focus was transferred to. QQuickControlsApplicationHelper helper(this, QStringLiteral("activeFocusOnClose3.qml")); @@ -718,6 +735,9 @@ void tst_QQuickPopup::activeFocusOnClose3() void tst_QQuickPopup::activeFocusOnClosingSeveralPopups() { + if (!hasWindowActivation()) + QSKIP("Window activation is not supported"); + // Test that active focus isn't lost when multiple popup closing simultaneously QQuickControlsApplicationHelper helper(this, QStringLiteral("activeFocusOnClosingSeveralPopups.qml")); QVERIFY2(helper.ready, helper.failureMessage()); @@ -767,6 +787,9 @@ void tst_QQuickPopup::activeFocusOnClosingSeveralPopups() void tst_QQuickPopup::activeFocusAfterExit() { + if (!hasWindowActivation()) + QSKIP("Window activation is not supported"); + // Test that after closing a popup the highest one in z-order receives it instead. QQuickControlsApplicationHelper helper(this, QStringLiteral("activeFocusAfterExit.qml")); QVERIFY2(helper.ready, helper.failureMessage()); @@ -816,6 +839,9 @@ void tst_QQuickPopup::activeFocusAfterExit() void tst_QQuickPopup::activeFocusOnDelayedEnter() { + if (!hasWindowActivation()) + QSKIP("Window activation is not supported"); + // Test that after opening two popups, first of which has an animation, does not cause // the first one to receive focus after the animation stops. QQuickControlsApplicationHelper helper(this, QStringLiteral("activeFocusOnDelayedEnter.qml")); @@ -842,6 +868,9 @@ void tst_QQuickPopup::activeFocusOnDelayedEnter() // key events due to having active focus. void tst_QQuickPopup::activeFocusDespiteLowerStackingOrder() { + if (!hasWindowActivation()) + QSKIP("Window activation is not supported"); + QQuickControlsApplicationHelper helper(this, QStringLiteral("activeFocusOnClose3.qml")); QVERIFY2(helper.ready, helper.failureMessage()); QQuickApplicationWindow *window = helper.appWindow; @@ -899,8 +928,7 @@ void tst_QQuickPopup::hover() QVERIFY2(helper.ready, helper.failureMessage()); QQuickWindow *window = helper.window; window->show(); - window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window)); + QVERIFY(QTest::qWaitForWindowExposed(window)); QQuickPopup *popup = window->property("popup").value<QQuickPopup*>(); QVERIFY(popup); @@ -1225,13 +1253,16 @@ void tst_QQuickPopup::componentComplete() void tst_QQuickPopup::closeOnEscapeWithNestedPopups() { + if (!hasWindowActivation()) + QSKIP("Window activation is not supported"); + // Tests the scenario in the Gallery example, where there are nested popups that should // close in the correct order when the Escape key is pressed. QQuickControlsApplicationHelper helper(this, QStringLiteral("closeOnEscapeWithNestedPopups.qml")); QVERIFY2(helper.ready, helper.failureMessage()); QQuickApplicationWindow *window = helper.appWindow; window->show(); - QVERIFY(QTest::qWaitForWindowExposed(window)); + QVERIFY(QTest::qWaitForWindowActive(window)); // The stack view should have two items, and it should pop the second when escape is pressed // and it has focus. @@ -1291,6 +1322,9 @@ void tst_QQuickPopup::closeOnEscapeWithNestedPopups() void tst_QQuickPopup::closeOnEscapeWithVisiblePopup() { + if (!hasWindowActivation()) + QSKIP("Window activation is not supported"); + QQuickControlsApplicationHelper helper(this, QStringLiteral("closeOnEscapeWithVisiblePopup.qml")); QVERIFY2(helper.ready, helper.failureMessage()); QQuickWindow *window = helper.window; @@ -1382,7 +1416,7 @@ void tst_QQuickPopup::orientation() QQuickWindow *window = helper.window; window->reportContentOrientationChange(orientation); window->show(); - QVERIFY(QTest::qWaitForWindowActive(window)); + QVERIFY(QTest::qWaitForWindowExposed(window)); QQuickPopup *popup = window->property("popup").value<QQuickPopup*>(); QVERIFY(popup); @@ -1416,6 +1450,9 @@ void tst_QQuickPopup::qquickview() // QTBUG-73447 void tst_QQuickPopup::disabledPalette() { + if (!hasWindowActivation()) + QSKIP("Window activation is not supported"); + QQuickControlsApplicationHelper helper(this, "disabledPalette.qml"); QVERIFY2(helper.ready, helper.failureMessage()); @@ -1453,6 +1490,9 @@ void tst_QQuickPopup::disabledPalette() void tst_QQuickPopup::disabledParentPalette() { + if (!hasWindowActivation()) + QSKIP("Window activation is not supported"); + QQuickControlsApplicationHelper helper(this, "disabledPalette.qml"); QVERIFY2(helper.ready, helper.failureMessage()); @@ -1504,7 +1544,7 @@ void tst_QQuickPopup::countChanged() QQuickWindow *window = helper.window; window->show(); - QVERIFY(QTest::qWaitForWindowActive(window)); + QVERIFY(QTest::qWaitForWindowExposed(window)); QQuickComboBox *comboBox = window->property("comboBox").value<QQuickComboBox*>(); QVERIFY(comboBox); @@ -1525,7 +1565,7 @@ void tst_QQuickPopup::toolTipCrashOnClose() QQuickWindow *window = helper.window; window->show(); - QVERIFY(QTest::qWaitForWindowActive(window)); + QVERIFY(QTest::qWaitForWindowExposed(window)); QTest::mouseMove(window, QPoint(window->width() / 2, window->height() / 2)); QTRY_VERIFY(window->property("toolTipOpened").toBool()); @@ -1546,7 +1586,7 @@ void tst_QQuickPopup::setOverlayParentToNull() centerOnScreen(window); moveMouseAway(window); window->show(); - QVERIFY(QTest::qWaitForWindowActive(window)); + QVERIFY(QTest::qWaitForWindowExposed(window)); QVERIFY(QMetaObject::invokeMethod(window, "nullifyOverlayParent")); @@ -1559,6 +1599,9 @@ void tst_QQuickPopup::setOverlayParentToNull() void tst_QQuickPopup::tabFence() { + if (!hasWindowActivation()) + QSKIP("Window activation is not supported"); + if (QGuiApplication::styleHints()->tabFocusBehavior() != Qt::TabFocusAllControls) QSKIP("This platform only allows tab focus for text controls"); @@ -1624,7 +1667,7 @@ void tst_QQuickPopup::invisibleToolTipOpen() centerOnScreen(window); moveMouseAway(window); window->show(); - QVERIFY(QTest::qWaitForWindowActive(window)); + QVERIFY(QTest::qWaitForWindowExposed(window)); QQuickItem *mouseArea = qvariant_cast<QQuickItem *>(window->property("mouseArea")); QVERIFY(mouseArea); @@ -1669,6 +1712,9 @@ void tst_QQuickPopup::centerInOverlayWithinStackViewItem() void tst_QQuickPopup::destroyDuringExitTransition() { + if (!hasWindowActivation()) + QSKIP("Window activation is not supported"); + QQuickControlsApplicationHelper helper(this, "destroyDuringExitTransition.qml"); QVERIFY2(helper.ready, helper.failureMessage()); @@ -1706,7 +1752,7 @@ void tst_QQuickPopup::releaseAfterExitTransition() QQuickWindow *window = helper.window; window->show(); - QVERIFY(QTest::qWaitForWindowActive(window)); + QVERIFY(QTest::qWaitForWindowExposed(window)); QQuickOverlay *overlay = QQuickOverlay::overlay(window); QQuickPopup *modalPopup = window->property("modalPopup").value<QQuickPopup *>(); @@ -1756,7 +1802,7 @@ void tst_QQuickPopup::dimmerContainmentMask() QQuickWindow *window = helper.window; window->show(); QCOMPARE(window->property("clickCount").toInt(), expectedClickCount); - QVERIFY(QTest::qWaitForWindowActive(window)); + QVERIFY(QTest::qWaitForWindowExposed(window)); QQuickOverlay *overlay = QQuickOverlay::overlay(window); QQuickPopup *modalPopup = window->property("modalPopup").value<QQuickPopup *>(); |