diff options
| author | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2025-12-15 16:14:22 +0200 |
|---|---|---|
| committer | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2025-12-15 16:14:22 +0200 |
| commit | b58ec3b086518da5aa573f99426235854c23e35f (patch) | |
| tree | 861a9935d8f1cdba2fdca546836a351736dbddbf /tests/auto/quickcontrols | |
| parent | 4826f86e274f1b29bd769e6790824f9e62a40f62 (diff) | |
| parent | 22032227d16c39211e2ebceef97d21f4d89c7c87 (diff) | |
Merge tag 'v6.5.8-lts-lgpl' into 6.56.5
Qt 6.5.8-lts-lgpl release
Diffstat (limited to 'tests/auto/quickcontrols')
7 files changed, 246 insertions, 2 deletions
diff --git a/tests/auto/quickcontrols/controls/data/tst_swipeview.qml b/tests/auto/quickcontrols/controls/data/tst_swipeview.qml index 694741ce45..69226e57c4 100644 --- a/tests/auto/quickcontrols/controls/data/tst_swipeview.qml +++ b/tests/auto/quickcontrols/controls/data/tst_swipeview.qml @@ -4,6 +4,7 @@ import QtQuick import QtTest import QtQuick.Controls +import QtQuick.Layouts TestCase { id: testCase @@ -694,4 +695,62 @@ TestCase { compare(page4.width, control.contentItem.width) compare(page4.height, control.contentItem.height) } + + Component { + id: zeroSizeSwipeViewWithRepeatersComponent + + Item { + objectName: "rootItem" + anchors.fill: parent + + property alias swipeView: swipeView + property int d + + Timer { + interval: 2 + running: true + repeat: false + onTriggered: d = 2 + } + + SwipeView { + id: swipeView + contentItem.objectName: "swipeViewListView" + + Repeater { + objectName: "swipeViewContentItemRepeater" + model: [ + { + title: d + } + ] + + delegate: GridLayout { + objectName: "gridLayoutDelegate" + + Repeater { + id: repeater + objectName: "delegateRepeater" + model: d + delegate: Item { + objectName: "delegate" + index + + required property int index + } + } + } + } + } + } + } + + // QTBUG-129622 + function test_zeroSizeSwipeViewWithRepeaters() { + let root = createTemporaryObject(zeroSizeSwipeViewWithRepeatersComponent, testCase) + verify(root) + + let swipeView = root.swipeView + tryCompare(root, "d", 2) + // Shouldn't crash when the model is changed. + } } diff --git a/tests/auto/quickcontrols/controls/material/CMakeLists.txt b/tests/auto/quickcontrols/controls/material/CMakeLists.txt index 506509c774..2f14b5253d 100644 --- a/tests/auto/quickcontrols/controls/material/CMakeLists.txt +++ b/tests/auto/quickcontrols/controls/material/CMakeLists.txt @@ -6,7 +6,8 @@ if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) cmake_minimum_required(VERSION 3.16) project(tst_material LANGUAGES C CXX ASM) - find_package(Qt6BuildInternals REQUIRED COMPONENTS ShaderTools STANDALONE_TEST) + find_package(Qt6 REQUIRED COMPONENTS ShaderTools) + find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) endif() ##################################################################### diff --git a/tests/auto/quickcontrols/qquickmaterialstyle/data/tst_material.qml b/tests/auto/quickcontrols/qquickmaterialstyle/data/tst_material.qml index f3dfca54f4..69a2d95ab3 100644 --- a/tests/auto/quickcontrols/qquickmaterialstyle/data/tst_material.qml +++ b/tests/auto/quickcontrols/qquickmaterialstyle/data/tst_material.qml @@ -1314,4 +1314,15 @@ TestCase { let headerItem = window.listView.headerItem compare(headerItem.Material.theme, Material.Dark) } + + // QTBUG-85860 + function test_busyIndicatorRunningChangedQuickly() { + let busyIndicator = createTemporaryObject(busyIndicatorComponent, testCase) + verify(busyIndicator) + + busyIndicator.running = false + busyIndicator.running = true + + tryCompare(busyIndicator.contentItem, "visible", true) + } } diff --git a/tests/auto/quickcontrols/qquickmenu/data/mousePropagationWithinPopup.qml b/tests/auto/quickcontrols/qquickmenu/data/mousePropagationWithinPopup.qml new file mode 100644 index 0000000000..9e419fbf87 --- /dev/null +++ b/tests/auto/quickcontrols/qquickmenu/data/mousePropagationWithinPopup.qml @@ -0,0 +1,33 @@ +import QtQuick +import QtQuick.Controls + +ApplicationWindow { + width: 360 + height: 360 + + property alias popup: popup + property alias nestedMenu: nestedMenu + property alias mouseArea: mouseArea + + Popup { + id: popup + width: 200 + height: 200 + MouseArea { + id: mouseArea + anchors.fill: parent + } + Menu { + id: nestedMenu + width: 100 + height: 100 + MenuItem { + text: "Menu item 1" + } + MenuItem { + text: "Menu item 2" + enabled: false + } + } + } +} diff --git a/tests/auto/quickcontrols/qquickmenu/tst_qquickmenu.cpp b/tests/auto/quickcontrols/qquickmenu/tst_qquickmenu.cpp index f54678b686..bec3a1f27c 100644 --- a/tests/auto/quickcontrols/qquickmenu/tst_qquickmenu.cpp +++ b/tests/auto/quickcontrols/qquickmenu/tst_qquickmenu.cpp @@ -15,6 +15,9 @@ #include <QtQml/qqmlcontext.h> #include <QtQuick/qquickview.h> #include <QtQuick/private/qquickitem_p.h> +#include <QtQuick/private/qquickmousearea_p.h> +#include <QtQuick/private/qquickrectangle_p.h> +#include <QtQuickTest/quicktest.h> #include <QtQuickTestUtils/private/qmlutils_p.h> #include <QtQuickTestUtils/private/visualtestutils_p.h> #include <QtQuickControlsTestUtils/private/controlstestutils_p.h> @@ -91,6 +94,7 @@ private slots: void customMenuCullItems(); void customMenuUseRepeaterAsTheContentItem(); void invalidUrlInImgTag(); + void mousePropagationWithinPopup(); }; tst_QQuickMenu::tst_QQuickMenu() @@ -2322,6 +2326,54 @@ void tst_QQuickMenu::invalidUrlInImgTag() QVERIFY(menuItemFirst); } +void tst_QQuickMenu::mousePropagationWithinPopup() +{ + QQuickControlsApplicationHelper helper(this, QLatin1String("mousePropagationWithinPopup.qml")); + QVERIFY2(helper.ready, helper.failureMessage()); + + QQuickApplicationWindow *window = helper.appWindow; + centerOnScreen(window); + window->show(); + QVERIFY(QTest::qWaitForWindowActive(window)); + + QQuickPopup *popup = window->property("popup").value<QQuickPopup*>(); + QVERIFY(popup); + popup->open(); + QTRY_VERIFY(popup->isOpened()); + + QQuickMenu *nestedMenu = window->property("nestedMenu").value<QQuickMenu*>(); + QVERIFY(nestedMenu); + nestedMenu->open(); + QTRY_VERIFY(nestedMenu->isOpened()); + + QQuickMouseArea *mouseArea = window->property("mouseArea").value<QQuickMouseArea *>(); + QVERIFY(mouseArea); + + QSignalSpy clickedSpy(mouseArea, &QQuickMouseArea::clicked); + QQuickMenuItem *menuItem2 = qobject_cast<QQuickMenuItem *>(nestedMenu->itemAt(1)); + QVERIFY(menuItem2); + QVERIFY(!menuItem2->isEnabled()); + + QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, mapCenterToWindow(menuItem2)); + QCOMPARE(clickedSpy.size(), 0); + + // Check on the gap area between menu and its item + // Note: Skip verifying this case for the styles (such as Imagine) that doesn't have gap + // between menu and its item + const auto menuItem1 = qobject_cast<QQuickMenuItem *>(nestedMenu->itemAt(0)); + QVERIFY(menuItem1); + const QPointF point = menuItem1->mapToItem(nestedMenu->background(), QPointF(0, 0)); + const bool xAxis = (point.x() + nestedMenu->leftInset()) > 0; + const bool yAxis = (point.y() + nestedMenu->topInset()) > 0; + if (xAxis || yAxis) { + const auto menuItem1Pos = mapCenterToWindow(menuItem1); + QPoint gapPoint(xAxis ? menuItem1Pos.x() - menuItem1->width() / 2 - 1 : menuItem1Pos.x(), + yAxis ? menuItem1Pos.y() : menuItem1Pos.y() - menuItem1->height() / 2 - 1); + QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, gapPoint); + QCOMPARE(clickedSpy.size(), 0); + } +} + QTEST_QUICKCONTROLS_MAIN(tst_QQuickMenu) #include "tst_qquickmenu.moc" diff --git a/tests/auto/quickcontrols/qquickpopup/data/parentToOverlay.qml b/tests/auto/quickcontrols/qquickpopup/data/parentToOverlay.qml new file mode 100644 index 0000000000..a5767cfed4 --- /dev/null +++ b/tests/auto/quickcontrols/qquickpopup/data/parentToOverlay.qml @@ -0,0 +1,41 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQuick +import QtQuick.Controls + +ApplicationWindow { + width: 600 + height: 600 + + property alias button: buttonInPopup + property alias lowerMouseArea: lowerMA + property alias upperMouseArea: upperMA + + MouseArea { + id: lowerMA + anchors.fill: parent + } + + Popup { + anchors.centerIn: Overlay.overlay + width: 400 + height: 400 + modal: true + dim: true + + Button { + id: buttonInPopup + anchors.centerIn: parent + text: "click me" + } + } + + MouseArea { + id: upperMA + parent: Overlay.overlay + anchors.fill: parent + z: 1 + } +} + diff --git a/tests/auto/quickcontrols/qquickpopup/tst_qquickpopup.cpp b/tests/auto/quickcontrols/qquickpopup/tst_qquickpopup.cpp index ee535caa8e..b046be8d44 100644 --- a/tests/auto/quickcontrols/qquickpopup/tst_qquickpopup.cpp +++ b/tests/auto/quickcontrols/qquickpopup/tst_qquickpopup.cpp @@ -103,6 +103,7 @@ private slots: void focusMultiplePopup(); void contentChildrenChange(); void doubleClickInMouseArea(); + void pointerEventsNotBlockedForNonPopupChildrenOfOverlayWithHigherZ(); void resetHoveredStateForItemsWithinPopup(); private: @@ -1282,7 +1283,7 @@ void tst_QQuickPopup::modelessOnModalOnModeless() QQuickPopup *modalPopup = window->property("modalPopup").value<QQuickPopup *>(); QVERIFY(modalPopup); QQuickPopup *tooltip = window->property("tooltip").value<QQuickPopup *>(); - QVERIFY(modalPopup); + QVERIFY(tooltip); modelessPopup->open(); QCOMPARE(modelessPopup->isVisible(), true); @@ -2314,6 +2315,52 @@ void tst_QQuickPopup::doubleClickInMouseArea() QCOMPARE(longPressSpy.count(), 0); } +// The test verifies that press and release events for items that are ancestors of the overlay, +// but not a popup item, are not filtered by modal popups. +void tst_QQuickPopup::pointerEventsNotBlockedForNonPopupChildrenOfOverlayWithHigherZ() +{ + QQuickApplicationHelper helper(this, "parentToOverlay.qml"); + QVERIFY2(helper.ready, helper.failureMessage()); + + QQuickWindow *window = helper.window; + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window)); + + auto *popup = window->contentItem()->findChild<QQuickPopup *>(); + QVERIFY(popup); + QQuickMouseArea *lowerMouseArea = window->property("lowerMouseArea").value<QQuickMouseArea *>(); + QVERIFY(lowerMouseArea); + QQuickMouseArea *upperMouseArea = window->property("upperMouseArea").value<QQuickMouseArea *>(); + QVERIFY(upperMouseArea); + QQuickAbstractButton *button = window->property("button").value<QQuickAbstractButton *>(); + QVERIFY(button); + + QSignalSpy lowerMouseAreaSpy(lowerMouseArea, &QQuickMouseArea::clicked); + QSignalSpy upperMouseAreaSpy(upperMouseArea, &QQuickMouseArea::clicked); + QSignalSpy buttonSpy(button, &QQuickAbstractButton::clicked); + + popup->open(); + QTRY_VERIFY(popup->isOpened()); + + QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, button->mapToScene(button->boundingRect().center()).toPoint()); + + // The event should have been consumed by the upperMouseArea, + // since it's in the same hierarchy as the popup item, with a higher z. + QTRY_COMPARE(upperMouseAreaSpy.count(), 1); + QCOMPARE(lowerMouseAreaSpy.count(), 0); + QCOMPARE(buttonSpy.count(), 0); + + upperMouseArea->setEnabled(false); + + QVERIFY(clickButton(button)); + // Since the upperMouseArea is disabled, the event should be sent to the button inside the popup. + QCOMPARE(buttonSpy.count(), 1); + QCOMPARE(lowerMouseAreaSpy.count(), 0); + QCOMPARE(upperMouseAreaSpy.count(), 1); + + popup->close(); +} + void tst_QQuickPopup::resetHoveredStateForItemsWithinPopup() { QQuickControlsApplicationHelper helper(this, "resetHoveredForItemsWithinOverlay.qml"); |
