diff options
Diffstat (limited to 'tests/auto/quickcontrols')
65 files changed, 528 insertions, 49 deletions
diff --git a/tests/auto/quickcontrols/accessibility/data/accessibleName/button.qml b/tests/auto/quickcontrols/accessibility/data/accessibleName/button.qml new file mode 100644 index 0000000000..c985e72b78 --- /dev/null +++ b/tests/auto/quickcontrols/accessibility/data/accessibleName/button.qml @@ -0,0 +1,10 @@ +// Copyright (C) 2025 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQuick +import QtQuick.Controls + +Button { + text: "Hello world" + id: button +} diff --git a/tests/auto/quickcontrols/accessibility/data/accessibleName/button2.qml b/tests/auto/quickcontrols/accessibility/data/accessibleName/button2.qml new file mode 100644 index 0000000000..5f1ceabea2 --- /dev/null +++ b/tests/auto/quickcontrols/accessibility/data/accessibleName/button2.qml @@ -0,0 +1,10 @@ +// Copyright (C) 2025 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQuick +import QtQuick.Controls + +Button { + text: "Th&is && that" + id: button +} diff --git a/tests/auto/quickcontrols/accessibility/data/accessibleName/button3.qml b/tests/auto/quickcontrols/accessibility/data/accessibleName/button3.qml new file mode 100644 index 0000000000..d41d2ee1eb --- /dev/null +++ b/tests/auto/quickcontrols/accessibility/data/accessibleName/button3.qml @@ -0,0 +1,11 @@ +// Copyright (C) 2025 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQuick +import QtQuick.Controls + +Button { + text: "Hello world" + Accessible.name: "Explicitly set accessible name" + id: button +} diff --git a/tests/auto/quickcontrols/accessibility/tst_accessibility.cpp b/tests/auto/quickcontrols/accessibility/tst_accessibility.cpp index 40ee98691d..3aa6b63d06 100644 --- a/tests/auto/quickcontrols/accessibility/tst_accessibility.cpp +++ b/tests/auto/quickcontrols/accessibility/tst_accessibility.cpp @@ -31,6 +31,8 @@ private slots: void override(); void ordering(); + + void accessibleName(); private: QQmlEngine engine; }; @@ -274,6 +276,45 @@ void tst_accessibility::ordering() #endif } +void tst_accessibility::accessibleName() +{ +#if QT_CONFIG(accessibility) + if (!QAccessible::isActive()) { + QPlatformAccessibility *accessibility = platformAccessibility(); + if (!accessibility) + QSKIP("No QPlatformAccessibility available."); + accessibility->setActive(true); + } + + QQmlComponent component(&engine); + + // verify that accessible name matches the button text if none was set explicitly + component.loadUrl(testFileUrl("accessibleName/button.qml")); + QScopedPointer<QObject> object(component.create()); + QVERIFY2(!object.isNull(), qPrintable(component.errorString())); + QAccessibleInterface *buttonAcc = QAccessible::queryAccessibleInterface(object.get()); + QVERIFY(buttonAcc); + QCOMPARE(buttonAcc->text(QAccessible::Name), "Hello world"); + + // verify that ampersand ('&') for mnemonic and to escape literal ampersand in button + // text are not contained in accessible name + component.loadUrl(testFileUrl("accessibleName/button2.qml")); + QScopedPointer<QObject> object2(component.create()); + QVERIFY2(!object.isNull(), qPrintable(component.errorString())); + QAccessibleInterface *button2Acc = QAccessible::queryAccessibleInterface(object2.get()); + QVERIFY(button2Acc); + QCOMPARE(button2Acc->text(QAccessible::Name), "This & that"); + + // verify that explicitly set accesible name is used + component.loadUrl(testFileUrl("accessibleName/button3.qml")); + QScopedPointer<QObject> object3(component.create()); + QVERIFY2(!object.isNull(), qPrintable(component.errorString())); + QAccessibleInterface *button3Acc = QAccessible::queryAccessibleInterface(object3.get()); + QVERIFY(button3Acc); + QCOMPARE(button3Acc->text(QAccessible::Name), "Explicitly set accessible name"); +#endif +} + QTEST_MAIN(tst_accessibility) #include "tst_accessibility.moc" diff --git a/tests/auto/quickcontrols/controls/basic/CMakeLists.txt b/tests/auto/quickcontrols/controls/basic/CMakeLists.txt index 74bbf2954e..bf61a4fc7d 100644 --- a/tests/auto/quickcontrols/controls/basic/CMakeLists.txt +++ b/tests/auto/quickcontrols/controls/basic/CMakeLists.txt @@ -5,7 +5,7 @@ if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) cmake_minimum_required(VERSION 3.16) - project(tst_basic LANGUAGES C CXX ASM) + project(tst_basic LANGUAGES C CXX) find_package(Qt6BuildInternals COMPONENTS STANDALONE_TEST) endif() diff --git a/tests/auto/quickcontrols/controls/fusion/CMakeLists.txt b/tests/auto/quickcontrols/controls/fusion/CMakeLists.txt index e3d38e1cf3..95c6d9f540 100644 --- a/tests/auto/quickcontrols/controls/fusion/CMakeLists.txt +++ b/tests/auto/quickcontrols/controls/fusion/CMakeLists.txt @@ -5,7 +5,7 @@ if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) cmake_minimum_required(VERSION 3.16) - project(tst_fusion LANGUAGES C CXX ASM) + project(tst_fusion LANGUAGES C CXX) find_package(Qt6BuildInternals COMPONENTS STANDALONE_TEST) endif() diff --git a/tests/auto/quickcontrols/controls/imagine/CMakeLists.txt b/tests/auto/quickcontrols/controls/imagine/CMakeLists.txt index c296a5b1a4..67560bf225 100644 --- a/tests/auto/quickcontrols/controls/imagine/CMakeLists.txt +++ b/tests/auto/quickcontrols/controls/imagine/CMakeLists.txt @@ -5,7 +5,7 @@ if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) cmake_minimum_required(VERSION 3.16) - project(tst_imagine LANGUAGES C CXX ASM) + project(tst_imagine LANGUAGES C CXX) find_package(Qt6BuildInternals COMPONENTS STANDALONE_TEST) endif() diff --git a/tests/auto/quickcontrols/controls/ios/CMakeLists.txt b/tests/auto/quickcontrols/controls/ios/CMakeLists.txt index 4e0cb72e68..55c16a2735 100644 --- a/tests/auto/quickcontrols/controls/ios/CMakeLists.txt +++ b/tests/auto/quickcontrols/controls/ios/CMakeLists.txt @@ -3,7 +3,7 @@ if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) cmake_minimum_required(VERSION 3.16) - project(tst_ios LANGUAGES C CXX ASM) + project(tst_ios LANGUAGES C CXX) find_package(Qt6BuildInternals COMPONENTS STANDALONE_TEST) endif() diff --git a/tests/auto/quickcontrols/controls/macos/CMakeLists.txt b/tests/auto/quickcontrols/controls/macos/CMakeLists.txt index 3202601316..f33ef26c78 100644 --- a/tests/auto/quickcontrols/controls/macos/CMakeLists.txt +++ b/tests/auto/quickcontrols/controls/macos/CMakeLists.txt @@ -3,7 +3,7 @@ if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) cmake_minimum_required(VERSION 3.16) - project(tst_macos LANGUAGES C CXX ASM) + project(tst_macos LANGUAGES C CXX) find_package(Qt6BuildInternals COMPONENTS STANDALONE_TEST) endif() diff --git a/tests/auto/quickcontrols/controls/material/CMakeLists.txt b/tests/auto/quickcontrols/controls/material/CMakeLists.txt index 2f14b5253d..f59a1a09e8 100644 --- a/tests/auto/quickcontrols/controls/material/CMakeLists.txt +++ b/tests/auto/quickcontrols/controls/material/CMakeLists.txt @@ -5,7 +5,7 @@ if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) cmake_minimum_required(VERSION 3.16) - project(tst_material LANGUAGES C CXX ASM) + project(tst_material LANGUAGES C CXX) find_package(Qt6 REQUIRED COMPONENTS ShaderTools) find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) endif() diff --git a/tests/auto/quickcontrols/controls/universal/CMakeLists.txt b/tests/auto/quickcontrols/controls/universal/CMakeLists.txt index f39975ab15..2ac791ccb9 100644 --- a/tests/auto/quickcontrols/controls/universal/CMakeLists.txt +++ b/tests/auto/quickcontrols/controls/universal/CMakeLists.txt @@ -5,7 +5,7 @@ if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) cmake_minimum_required(VERSION 3.16) - project(tst_universal LANGUAGES C CXX ASM) + project(tst_universal LANGUAGES C CXX) find_package(Qt6BuildInternals COMPONENTS STANDALONE_TEST) endif() diff --git a/tests/auto/quickcontrols/controls/windows/CMakeLists.txt b/tests/auto/quickcontrols/controls/windows/CMakeLists.txt index 1d6ab1fc57..f1c1a4d1d7 100644 --- a/tests/auto/quickcontrols/controls/windows/CMakeLists.txt +++ b/tests/auto/quickcontrols/controls/windows/CMakeLists.txt @@ -3,7 +3,7 @@ if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) cmake_minimum_required(VERSION 3.16) - project(tst_windows LANGUAGES C CXX ASM) + project(tst_windows LANGUAGES C CXX) find_package(Qt6BuildInternals COMPONENTS STANDALONE_TEST) endif() diff --git a/tests/auto/quickcontrols/cursor/CMakeLists.txt b/tests/auto/quickcontrols/cursor/CMakeLists.txt index 6d0fa9eed6..85f39ba90a 100644 --- a/tests/auto/quickcontrols/cursor/CMakeLists.txt +++ b/tests/auto/quickcontrols/cursor/CMakeLists.txt @@ -5,7 +5,7 @@ if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) cmake_minimum_required(VERSION 3.16) - project(tst_cursor LANGUAGES C CXX ASM) + project(tst_cursor LANGUAGES C CXX) find_package(Qt6BuildInternals COMPONENTS STANDALONE_TEST) endif() diff --git a/tests/auto/quickcontrols/customization/CMakeLists.txt b/tests/auto/quickcontrols/customization/CMakeLists.txt index 79dd408257..cca6dfe5a5 100644 --- a/tests/auto/quickcontrols/customization/CMakeLists.txt +++ b/tests/auto/quickcontrols/customization/CMakeLists.txt @@ -5,7 +5,7 @@ if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) cmake_minimum_required(VERSION 3.16) - project(tst_customization LANGUAGES C CXX ASM) + project(tst_customization LANGUAGES C CXX) find_package(Qt6BuildInternals COMPONENTS STANDALONE_TEST) endif() diff --git a/tests/auto/quickcontrols/designer/CMakeLists.txt b/tests/auto/quickcontrols/designer/CMakeLists.txt index 9ad0512f80..3457961f54 100644 --- a/tests/auto/quickcontrols/designer/CMakeLists.txt +++ b/tests/auto/quickcontrols/designer/CMakeLists.txt @@ -5,7 +5,7 @@ if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) cmake_minimum_required(VERSION 3.16) - project(tst_designer LANGUAGES C CXX ASM) + project(tst_designer LANGUAGES C CXX) find_package(Qt6BuildInternals COMPONENTS STANDALONE_TEST) endif() diff --git a/tests/auto/quickcontrols/focus/CMakeLists.txt b/tests/auto/quickcontrols/focus/CMakeLists.txt index 87200bf05c..9db0b48bd6 100644 --- a/tests/auto/quickcontrols/focus/CMakeLists.txt +++ b/tests/auto/quickcontrols/focus/CMakeLists.txt @@ -5,7 +5,7 @@ if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) cmake_minimum_required(VERSION 3.16) - project(tst_focus LANGUAGES C CXX ASM) + project(tst_focus LANGUAGES C CXX) find_package(Qt6BuildInternals COMPONENTS STANDALONE_TEST) endif() diff --git a/tests/auto/quickcontrols/font/CMakeLists.txt b/tests/auto/quickcontrols/font/CMakeLists.txt index 9eaee341d0..4266cfc756 100644 --- a/tests/auto/quickcontrols/font/CMakeLists.txt +++ b/tests/auto/quickcontrols/font/CMakeLists.txt @@ -5,7 +5,7 @@ if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) cmake_minimum_required(VERSION 3.16) - project(tst_font LANGUAGES C CXX ASM) + project(tst_font LANGUAGES C CXX) find_package(Qt6BuildInternals COMPONENTS STANDALONE_TEST) endif() diff --git a/tests/auto/quickcontrols/palette/CMakeLists.txt b/tests/auto/quickcontrols/palette/CMakeLists.txt index fd4ee2d680..747ea76226 100644 --- a/tests/auto/quickcontrols/palette/CMakeLists.txt +++ b/tests/auto/quickcontrols/palette/CMakeLists.txt @@ -5,7 +5,7 @@ if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) cmake_minimum_required(VERSION 3.16) - project(tst_palette LANGUAGES C CXX ASM) + project(tst_palette LANGUAGES C CXX) find_package(Qt6BuildInternals COMPONENTS STANDALONE_TEST) endif() diff --git a/tests/auto/quickcontrols/platform/CMakeLists.txt b/tests/auto/quickcontrols/platform/CMakeLists.txt index a2f77fdd9c..5f6d64491f 100644 --- a/tests/auto/quickcontrols/platform/CMakeLists.txt +++ b/tests/auto/quickcontrols/platform/CMakeLists.txt @@ -5,7 +5,7 @@ if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) cmake_minimum_required(VERSION 3.16) - project(tst_platform LANGUAGES C CXX ASM) + project(tst_platform LANGUAGES C CXX) find_package(Qt6BuildInternals COMPONENTS STANDALONE_TEST) endif() diff --git a/tests/auto/quickcontrols/pointerhandlers/CMakeLists.txt b/tests/auto/quickcontrols/pointerhandlers/CMakeLists.txt index 8bc7b26b31..cf73a05132 100644 --- a/tests/auto/quickcontrols/pointerhandlers/CMakeLists.txt +++ b/tests/auto/quickcontrols/pointerhandlers/CMakeLists.txt @@ -3,7 +3,7 @@ if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) cmake_minimum_required(VERSION 3.16) - project(tst_pointerhandlers LANGUAGES C CXX ASM) + project(tst_pointerhandlers LANGUAGES C CXX) find_package(Qt6BuildInternals COMPONENTS STANDALONE_TEST) endif() diff --git a/tests/auto/quickcontrols/pressandhold/CMakeLists.txt b/tests/auto/quickcontrols/pressandhold/CMakeLists.txt index 8d8c967a56..9f4a889916 100644 --- a/tests/auto/quickcontrols/pressandhold/CMakeLists.txt +++ b/tests/auto/quickcontrols/pressandhold/CMakeLists.txt @@ -5,7 +5,7 @@ if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) cmake_minimum_required(VERSION 3.16) - project(tst_pressandhold LANGUAGES C CXX ASM) + project(tst_pressandhold LANGUAGES C CXX) find_package(Qt6BuildInternals COMPONENTS STANDALONE_TEST) endif() diff --git a/tests/auto/quickcontrols/qquickapplicationwindow/CMakeLists.txt b/tests/auto/quickcontrols/qquickapplicationwindow/CMakeLists.txt index a24d019827..4e40383d9c 100644 --- a/tests/auto/quickcontrols/qquickapplicationwindow/CMakeLists.txt +++ b/tests/auto/quickcontrols/qquickapplicationwindow/CMakeLists.txt @@ -5,7 +5,7 @@ if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) cmake_minimum_required(VERSION 3.16) - project(tst_qquickapplicationwindow LANGUAGES C CXX ASM) + project(tst_qquickapplicationwindow LANGUAGES C CXX) find_package(Qt6BuildInternals COMPONENTS STANDALONE_TEST) endif() diff --git a/tests/auto/quickcontrols/qquickapplicationwindow/tst_qquickapplicationwindow.cpp b/tests/auto/quickcontrols/qquickapplicationwindow/tst_qquickapplicationwindow.cpp index a02ab9c595..8ef7122d29 100644 --- a/tests/auto/quickcontrols/qquickapplicationwindow/tst_qquickapplicationwindow.cpp +++ b/tests/auto/quickcontrols/qquickapplicationwindow/tst_qquickapplicationwindow.cpp @@ -891,7 +891,7 @@ void tst_QQuickApplicationWindow::layoutLayout() QCOMPARE(headerChild->width(), qreal(window->width())); QVERIFY(header->height() > 0); - QQuickItem *footerChild = header->findChild<QQuickItem*>(); + QQuickItem *footerChild = footer->findChild<QQuickItem*>(); QVERIFY(footerChild); QCOMPARE(footer->x(), 0.0); QCOMPARE(footer->y(), content->height()); diff --git a/tests/auto/quickcontrols/qquickcolor/CMakeLists.txt b/tests/auto/quickcontrols/qquickcolor/CMakeLists.txt index efd06f15ff..4bbed44111 100644 --- a/tests/auto/quickcontrols/qquickcolor/CMakeLists.txt +++ b/tests/auto/quickcontrols/qquickcolor/CMakeLists.txt @@ -5,7 +5,7 @@ if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) cmake_minimum_required(VERSION 3.16) - project(tst_qquickcolor LANGUAGES C CXX ASM) + project(tst_qquickcolor LANGUAGES C CXX) find_package(Qt6BuildInternals COMPONENTS STANDALONE_TEST) endif() diff --git a/tests/auto/quickcontrols/qquickcontainer/CMakeLists.txt b/tests/auto/quickcontrols/qquickcontainer/CMakeLists.txt index c79e508cd1..c04b31a415 100644 --- a/tests/auto/quickcontrols/qquickcontainer/CMakeLists.txt +++ b/tests/auto/quickcontrols/qquickcontainer/CMakeLists.txt @@ -3,7 +3,7 @@ if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) cmake_minimum_required(VERSION 3.16) - project(tst_qquickcontainer LANGUAGES C CXX ASM) + project(tst_qquickcontainer LANGUAGES C CXX) find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) endif() diff --git a/tests/auto/quickcontrols/qquickcontainer/data/skipReorderContentModelItem.qml b/tests/auto/quickcontrols/qquickcontainer/data/skipReorderContentModelItem.qml new file mode 100644 index 0000000000..9074904026 --- /dev/null +++ b/tests/auto/quickcontrols/qquickcontainer/data/skipReorderContentModelItem.qml @@ -0,0 +1,57 @@ +// Copyright (C) 2025 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQuick +import QtQuick.Controls +import QtQml.Models + +Window { + width: 640 + height: 480 + + property alias navigationBar: navigationbar + + component NavigationBar: Container { + id: container + + property alias model: repeater.model + property alias listView: list + + implicitHeight: 20 + + contentItem: Item { + width: parent.width + height: parent.height + + ListView { + id: list + model: container.contentModel + snapMode: ListView.SnapToItem + orientation: ListView.Horizontal + interactive: width < contentWidth + clip: interactive + spacing: 20 + + anchors { + right: parent.right + top: parent.top + bottom: parent.bottom + left: parent.left + } + } + } + + Repeater { + id: repeater + delegate: Text { + text: modelData + } + } + } + + NavigationBar { + id: navigationbar + width: 100 + model: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"] + } +} diff --git a/tests/auto/quickcontrols/qquickcontainer/tst_qquickcontainer.cpp b/tests/auto/quickcontrols/qquickcontainer/tst_qquickcontainer.cpp index ce95f2cc37..b61717e4c9 100644 --- a/tests/auto/quickcontrols/qquickcontainer/tst_qquickcontainer.cpp +++ b/tests/auto/quickcontrols/qquickcontainer/tst_qquickcontainer.cpp @@ -8,6 +8,8 @@ #include <QtQuickTestUtils/private/qmlutils_p.h> #include <QtQuickTestUtils/private/visualtestutils_p.h> #include <QtQuickControlsTestUtils/private/controlstestutils_p.h> +#include <QtQuick/private/qquicklistview_p.h> +#include <QtQmlModels/private/qqmlobjectmodel_p.h> using namespace QQuickVisualTestUtils; using namespace QQuickControlsTestUtils; @@ -22,6 +24,7 @@ public: private slots: void zeroSize_data(); void zeroSize(); + void skipReorderContentModelItem(); }; tst_qquickcontainer::tst_qquickcontainer() @@ -102,6 +105,34 @@ void tst_qquickcontainer::zeroSize() QCOMPARE(QQuickItemPrivate::get(text4)->culled, isItemView); } +void tst_qquickcontainer::skipReorderContentModelItem() +{ + QQuickControlsApplicationHelper helper(this, "skipReorderContentModelItem.qml"); + QVERIFY2(helper.ready, helper.failureMessage()); + centerOnScreen(helper.window); + helper.window->show(); + QVERIFY(QTest::qWaitForWindowExposed(helper.window)); + + const auto *container = helper.window->property("navigationBar").value<QQuickContainer *>(); + QVERIFY(container); + const auto *listView = container->property("listView").value<QQuickListView *>(); + QVERIFY(listView); + const auto *contentModel = container->property("contentModel").value<QQmlObjectModel *>(); + QVERIFY(contentModel); + + QCOMPARE(listView->count(), contentModel->count()); + + int totalWidth = listView->spacing() * (contentModel->count() - 1); + for (int index = 0; index < contentModel->count(); index++) + totalWidth += qobject_cast<QQuickText *>(listView->itemAtIndex(index))->width(); + QVERIFY(totalWidth > listView->width()); + + for (int index = 0; index < listView->count(); index++) { + const auto *textItem = qobject_cast<QQuickText *>(listView->itemAtIndex(index)); + QCOMPARE(textItem->text().toInt(), index + 1); + } +} + QTEST_MAIN(tst_qquickcontainer) #include "tst_qquickcontainer.moc" diff --git a/tests/auto/quickcontrols/qquickcontrol/CMakeLists.txt b/tests/auto/quickcontrols/qquickcontrol/CMakeLists.txt index a43b14f1fa..51686657ca 100644 --- a/tests/auto/quickcontrols/qquickcontrol/CMakeLists.txt +++ b/tests/auto/quickcontrols/qquickcontrol/CMakeLists.txt @@ -5,7 +5,7 @@ if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) cmake_minimum_required(VERSION 3.16) - project(tst_qquickcontrol LANGUAGES C CXX ASM) + project(tst_qquickcontrol LANGUAGES C CXX) find_package(Qt6BuildInternals COMPONENTS STANDALONE_TEST) endif() diff --git a/tests/auto/quickcontrols/qquickdrawer/CMakeLists.txt b/tests/auto/quickcontrols/qquickdrawer/CMakeLists.txt index 2515a8d30e..bb78889d4f 100644 --- a/tests/auto/quickcontrols/qquickdrawer/CMakeLists.txt +++ b/tests/auto/quickcontrols/qquickdrawer/CMakeLists.txt @@ -5,7 +5,7 @@ if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) cmake_minimum_required(VERSION 3.16) - project(tst_qquickdrawer LANGUAGES C CXX ASM) + project(tst_qquickdrawer LANGUAGES C CXX) find_package(Qt6BuildInternals COMPONENTS STANDALONE_TEST) endif() diff --git a/tests/auto/quickcontrols/qquickheaderview/CMakeLists.txt b/tests/auto/quickcontrols/qquickheaderview/CMakeLists.txt index 1925c85dc8..2f0c1c2285 100644 --- a/tests/auto/quickcontrols/qquickheaderview/CMakeLists.txt +++ b/tests/auto/quickcontrols/qquickheaderview/CMakeLists.txt @@ -5,7 +5,7 @@ if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) cmake_minimum_required(VERSION 3.16) - project(tst_qquickheaderview LANGUAGES C CXX ASM) + project(tst_qquickheaderview LANGUAGES C CXX) find_package(Qt6BuildInternals COMPONENTS STANDALONE_TEST) endif() diff --git a/tests/auto/quickcontrols/qquickiconimage/CMakeLists.txt b/tests/auto/quickcontrols/qquickiconimage/CMakeLists.txt index 58f8a8f6f5..0620eaa28e 100644 --- a/tests/auto/quickcontrols/qquickiconimage/CMakeLists.txt +++ b/tests/auto/quickcontrols/qquickiconimage/CMakeLists.txt @@ -5,7 +5,7 @@ if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) cmake_minimum_required(VERSION 3.16) - project(tst_qquickiconimage LANGUAGES C CXX ASM) + project(tst_qquickiconimage LANGUAGES C CXX) find_package(Qt6BuildInternals COMPONENTS STANDALONE_TEST) endif() diff --git a/tests/auto/quickcontrols/qquickiconlabel/CMakeLists.txt b/tests/auto/quickcontrols/qquickiconlabel/CMakeLists.txt index 48ede72c13..63ee07ca02 100644 --- a/tests/auto/quickcontrols/qquickiconlabel/CMakeLists.txt +++ b/tests/auto/quickcontrols/qquickiconlabel/CMakeLists.txt @@ -5,7 +5,7 @@ if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) cmake_minimum_required(VERSION 3.16) - project(tst_qquickiconlabel LANGUAGES C CXX ASM) + project(tst_qquickiconlabel LANGUAGES C CXX) find_package(Qt6BuildInternals COMPONENTS STANDALONE_TEST) endif() diff --git a/tests/auto/quickcontrols/qquickiconlabel/data/childPaintOrder.qml b/tests/auto/quickcontrols/qquickiconlabel/data/childPaintOrder.qml new file mode 100644 index 0000000000..b26d36fac6 --- /dev/null +++ b/tests/auto/quickcontrols/qquickiconlabel/data/childPaintOrder.qml @@ -0,0 +1,32 @@ +// Copyright (C) 2025 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQuick +import QtQuick.Controls +import QtQuick.Controls.impl + +AbstractButton { + id: control + width: 200 + height: 200 + text: "Button" + icon.source: "qrc:/qt-project.org/imports/QtQuick/Controls/Basic/images/check.png" + icon.color: enabled ? "transparent" : "red" + + contentItem: IconLabel { + id: iconLabel + objectName: "iconLabel" + display: control.display + icon: control.icon + text: control.text + font: control.font + + Text { + objectName: "childText" + color: "red" + anchors.centerIn: parent + text: "Should be in front" + font.bold: true + } + } +} diff --git a/tests/auto/quickcontrols/qquickiconlabel/tst_qquickiconlabel.cpp b/tests/auto/quickcontrols/qquickiconlabel/tst_qquickiconlabel.cpp index 8d42cf5faf..cc11acee1d 100644 --- a/tests/auto/quickcontrols/qquickiconlabel/tst_qquickiconlabel.cpp +++ b/tests/auto/quickcontrols/qquickiconlabel/tst_qquickiconlabel.cpp @@ -12,13 +12,16 @@ #include <QtQuick/private/qquicktext_p.h> #include <QtQuick/private/qquickimage_p_p.h> #include <QtQuickTestUtils/private/qmlutils_p.h> +#include <QtQuickTestUtils/private/viewtestutils_p.h> #include <QtQuickTestUtils/private/visualtestutils_p.h> #include <QtQuickTemplates2/private/qquickabstractbutton_p.h> #include <QtQuickTemplates2/private/qquickicon_p.h> #include <QtQuickControls2Impl/private/qquickiconimage_p.h> #include <QtQuickControls2Impl/private/qquickiconlabel_p.h> #include <QtQuickControls2Impl/private/qquickiconlabel_p_p.h> +#include <QtQuickControls2Impl/private/qquickmnemoniclabel_p.h> +using namespace QQuickViewTestUtils; using namespace QQuickVisualTestUtils; class tst_qquickiconlabel : public QQmlDataTest @@ -35,6 +38,7 @@ private slots: void emptyIconSource(); void colorChanges(); void iconSourceContext(); + void childPaintOrder(); }; tst_qquickiconlabel::tst_qquickiconlabel() @@ -340,6 +344,22 @@ void tst_qquickiconlabel::iconSourceContext() } +// QTBUG-133924: check that items declared as children of us are rendered on top of the label and icon image. +void tst_qquickiconlabel::childPaintOrder() +{ + QQuickView window; + QVERIFY(QQuickTest::showView(window, testFileUrl("childPaintOrder.qml"))); + + auto *iconLabel = window.findChild<QQuickItem *>("iconLabel"); + QVERIFY(iconLabel); + auto *iconLabelPrivate = static_cast<QQuickIconLabelPrivate *>(QQuickItemPrivate::get(iconLabel)); + + auto *childText = window.findChild<QQuickItem *>("childText"); + QVERIFY(childText); + const QList<QQuickItem *> expectedPaintOrder = { iconLabelPrivate->label, iconLabelPrivate->image, childText }; + QCOMPARE(iconLabelPrivate->paintOrderChildItems(), expectedPaintOrder); +} + QTEST_MAIN(tst_qquickiconlabel) #include "tst_qquickiconlabel.moc" diff --git a/tests/auto/quickcontrols/qquickimaginestyle/CMakeLists.txt b/tests/auto/quickcontrols/qquickimaginestyle/CMakeLists.txt index 1985784386..d1b8f8b16e 100644 --- a/tests/auto/quickcontrols/qquickimaginestyle/CMakeLists.txt +++ b/tests/auto/quickcontrols/qquickimaginestyle/CMakeLists.txt @@ -5,7 +5,7 @@ if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) cmake_minimum_required(VERSION 3.16) - project(tst_qquickimaginestyle LANGUAGES C CXX ASM) + project(tst_qquickimaginestyle LANGUAGES C CXX) find_package(Qt6BuildInternals COMPONENTS STANDALONE_TEST) endif() diff --git a/tests/auto/quickcontrols/qquickmaterialstyle/CMakeLists.txt b/tests/auto/quickcontrols/qquickmaterialstyle/CMakeLists.txt index 0afeaf2fb3..a74a9d1a54 100644 --- a/tests/auto/quickcontrols/qquickmaterialstyle/CMakeLists.txt +++ b/tests/auto/quickcontrols/qquickmaterialstyle/CMakeLists.txt @@ -5,7 +5,7 @@ if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) cmake_minimum_required(VERSION 3.16) - project(tst_qquickmaterialstyle LANGUAGES C CXX ASM) + project(tst_qquickmaterialstyle LANGUAGES C CXX) find_package(Qt6BuildInternals 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 69a2d95ab3..862aa15488 100644 --- a/tests/auto/quickcontrols/qquickmaterialstyle/data/tst_material.qml +++ b/tests/auto/quickcontrols/qquickmaterialstyle/data/tst_material.qml @@ -1325,4 +1325,33 @@ TestCase { tryCompare(busyIndicator.contentItem, "visible", true) } + + Component { + id: labelInPopupComponent + + Popup { + id: popupInstance + + property alias label: label + + Material.theme: Material.Dark + + Label { + id: label + text: "Should have a dark theme" + } + } + } + + function test_popupPropagatesToChildItem() { + let popup = createTemporaryObject(labelInPopupComponent, testCase) + verify(popup) + + compare(popup.Material.theme, Material.Dark) + compare(popup.label.Material.theme, Material.Dark) + + popup.Material.theme = Material.Light + compare(popup.Material.theme, Material.Light) + compare(popup.label.Material.theme, Material.Light) + } } diff --git a/tests/auto/quickcontrols/qquickmaterialstyleconf/CMakeLists.txt b/tests/auto/quickcontrols/qquickmaterialstyleconf/CMakeLists.txt index 36c518aa9c..56364c5a63 100644 --- a/tests/auto/quickcontrols/qquickmaterialstyleconf/CMakeLists.txt +++ b/tests/auto/quickcontrols/qquickmaterialstyleconf/CMakeLists.txt @@ -5,7 +5,7 @@ if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) cmake_minimum_required(VERSION 3.16) - project(tst_qquickmaterialstyleconf LANGUAGES C CXX ASM) + project(tst_qquickmaterialstyleconf LANGUAGES C CXX) find_package(Qt6BuildInternals COMPONENTS STANDALONE_TEST) endif() diff --git a/tests/auto/quickcontrols/qquickmenu/CMakeLists.txt b/tests/auto/quickcontrols/qquickmenu/CMakeLists.txt index 0277c88446..4b4e89d545 100644 --- a/tests/auto/quickcontrols/qquickmenu/CMakeLists.txt +++ b/tests/auto/quickcontrols/qquickmenu/CMakeLists.txt @@ -5,7 +5,7 @@ if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) cmake_minimum_required(VERSION 3.16) - project(tst_qquickmenu LANGUAGES C CXX ASM) + project(tst_qquickmenu LANGUAGES C CXX) find_package(Qt6BuildInternals COMPONENTS STANDALONE_TEST) endif() diff --git a/tests/auto/quickcontrols/qquickmenu/data/animationOnHeight.qml b/tests/auto/quickcontrols/qquickmenu/data/animationOnHeight.qml new file mode 100644 index 0000000000..e01e764efd --- /dev/null +++ b/tests/auto/quickcontrols/qquickmenu/data/animationOnHeight.qml @@ -0,0 +1,70 @@ +import QtQuick +import QtQuick.Controls +import QtQuick.Templates as T + +ApplicationWindow { + width: 600 + height: 400 + + Action { + id: copyAction + text: "Copy" + } + + // Based on FluentWinUI3's Menu. + T.Menu { + id: menu + + implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, + implicitContentWidth + leftPadding + rightPadding) + implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, + implicitContentHeight + topPadding + bottomPadding) + + delegate: MenuItem { } + + contentItem: ListView { + implicitHeight: contentHeight + model: menu.contentModel + interactive: Window.window + ? contentHeight + menu.topPadding + menu.bottomPadding > menu.height + : false + currentIndex: menu.currentIndex + spacing: 4 + clip: true + + ScrollIndicator.vertical: ScrollIndicator {} + } + + enter: Transition { + NumberAnimation { + property: "height" + from: menu.implicitHeight * 0.33 + to: menu.implicitHeight + easing.type: Easing.OutCubic + duration: 1 + } + } + + background: Rectangle { + implicitWidth: 200 + implicitHeight: 30 + border.width: 1 + } + + T.Overlay.modal: Rectangle { + color: "transparent" + } + + T.Overlay.modeless: Rectangle { + color: "transparent" + } + + Action { + text: "Cut" + } + } + + Component.onCompleted: { + menu.addAction(copyAction) + } +} diff --git a/tests/auto/quickcontrols/qquickmenu/data/customMenuUseRepeaterAsTheContentItem.qml b/tests/auto/quickcontrols/qquickmenu/data/customMenuUseRepeaterAsTheContentItem.qml index bfa8f66be5..ebd0ab26b3 100644 --- a/tests/auto/quickcontrols/qquickmenu/data/customMenuUseRepeaterAsTheContentItem.qml +++ b/tests/auto/quickcontrols/qquickmenu/data/customMenuUseRepeaterAsTheContentItem.qml @@ -9,7 +9,6 @@ ApplicationWindow { Menu { id: menu - visible: true contentItem: FocusScope { implicitHeight: flickable.height diff --git a/tests/auto/quickcontrols/qquickmenu/data/scrollableWithFixedHeight.qml b/tests/auto/quickcontrols/qquickmenu/data/scrollableWithFixedHeight.qml index 1156d30aef..9299edb77d 100644 --- a/tests/auto/quickcontrols/qquickmenu/data/scrollableWithFixedHeight.qml +++ b/tests/auto/quickcontrols/qquickmenu/data/scrollableWithFixedHeight.qml @@ -15,7 +15,7 @@ Window { id: menu anchors.centerIn: parent height: 100 - visible: true + Repeater { model: 10 delegate: MenuItem { diff --git a/tests/auto/quickcontrols/qquickmenu/data/shortcutInNestedSubMenuAction.qml b/tests/auto/quickcontrols/qquickmenu/data/shortcutInNestedSubMenuAction.qml new file mode 100644 index 0000000000..02cb7d15c4 --- /dev/null +++ b/tests/auto/quickcontrols/qquickmenu/data/shortcutInNestedSubMenuAction.qml @@ -0,0 +1,30 @@ +// Copyright (C) 2025 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQuick +import QtQuick.Controls + +ApplicationWindow { + id: root + width: 400 + height: 400 + + property int triggeredCount + + Menu { + objectName: "topLevelMenu" + + Menu { + objectName: "subMenu" + + Menu { + objectName: "subSubMenu" + + Action { + shortcut: StandardKey.Copy + onTriggered: ++root.triggeredCount + } + } + } + } +} diff --git a/tests/auto/quickcontrols/qquickmenu/tst_qquickmenu.cpp b/tests/auto/quickcontrols/qquickmenu/tst_qquickmenu.cpp index 041c3d7ab9..578d5e84b4 100644 --- a/tests/auto/quickcontrols/qquickmenu/tst_qquickmenu.cpp +++ b/tests/auto/quickcontrols/qquickmenu/tst_qquickmenu.cpp @@ -15,6 +15,7 @@ #include <QtQml/qqmlcontext.h> #include <QtQuick/qquickview.h> #include <QtQuick/private/qquickitem_p.h> +#include <QtQuick/private/qquicklistview_p.h> #include <QtQuick/private/qquickmousearea_p.h> #include <QtQuick/private/qquickrectangle_p.h> #include <QtQuickTest/quicktest.h> @@ -95,6 +96,8 @@ private slots: void customMenuUseRepeaterAsTheContentItem(); void invalidUrlInImgTag(); void mousePropagationWithinPopup(); + void shortcutInNestedSubMenuAction(); + void animationOnHeight(); }; tst_QQuickMenu::tst_QQuickMenu() @@ -2365,6 +2368,41 @@ void tst_QQuickMenu::mousePropagationWithinPopup() } } +void tst_QQuickMenu::shortcutInNestedSubMenuAction() +{ + QQuickControlsApplicationHelper helper(this, QLatin1String("shortcutInNestedSubMenuAction.qml")); + QVERIFY2(helper.ready, helper.failureMessage()); + QQuickApplicationWindow *window = helper.appWindow; + window->show(); + window->requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(window)); + + // Shouldn't result in an infinite loop. + QTest::keyClick(window, Qt::Key_C, Qt::ControlModifier); + QCOMPARE(window->property("triggeredCount").value<int>(), 1); +} + +void tst_QQuickMenu::animationOnHeight() +{ + QQuickControlsApplicationHelper helper(this, QLatin1String("animationOnHeight.qml")); + QVERIFY2(helper.ready, helper.failureMessage()); + QQuickApplicationWindow *window = helper.appWindow; + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window)); + + auto *menu = window->findChild<QQuickMenu *>(); + QVERIFY(menu); + menu->popup(QPointF(100, 100)); + QTRY_VERIFY(menu->isOpened()); + + // After adding the Action, the contentHeight of the Menu's ListView should + // be not be greater than its height; it shouldn't be possible to scroll. + auto *listView = qobject_cast<QQuickListView *>(menu->contentItem()); + const qreal itemHeight = menu->itemAt(0)->height(); + QCOMPARE(listView->contentHeight(), itemHeight * 2 + listView->spacing()); + QCOMPARE_GE(listView->height(), listView->contentHeight()); +} + QTEST_QUICKCONTROLS_MAIN(tst_QQuickMenu) #include "tst_qquickmenu.moc" diff --git a/tests/auto/quickcontrols/qquickmenubar/CMakeLists.txt b/tests/auto/quickcontrols/qquickmenubar/CMakeLists.txt index cee75be2f9..0796160031 100644 --- a/tests/auto/quickcontrols/qquickmenubar/CMakeLists.txt +++ b/tests/auto/quickcontrols/qquickmenubar/CMakeLists.txt @@ -5,7 +5,7 @@ if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) cmake_minimum_required(VERSION 3.16) - project(tst_qquickmenubar LANGUAGES C CXX ASM) + project(tst_qquickmenubar LANGUAGES C CXX) find_package(Qt6BuildInternals COMPONENTS STANDALONE_TEST) endif() diff --git a/tests/auto/quickcontrols/qquickmenubar/data/clearMenus.qml b/tests/auto/quickcontrols/qquickmenubar/data/clearMenus.qml new file mode 100644 index 0000000000..6844902fb6 --- /dev/null +++ b/tests/auto/quickcontrols/qquickmenubar/data/clearMenus.qml @@ -0,0 +1,35 @@ +import QtQuick +import QtQuick.Templates + +Item { + property int v: 0 + + MenuBar { + id: menuBar + Menu {} + } + + Instantiator { + id: instantiator + + delegate: Menu {} + + onObjectAdded: (index, object) => { + menuBar.menus.push(object) + } + + onObjectRemoved: (index, object) => { + menuBar.menus.length = 0; + } + } + + Timer { + running: v < 2 + interval: 1 + repeat: true + + onTriggered: { + instantiator.model = (++v % 2) ? 0 : 2 + } + } +} diff --git a/tests/auto/quickcontrols/qquickmenubar/tst_qquickmenubar.cpp b/tests/auto/quickcontrols/qquickmenubar/tst_qquickmenubar.cpp index ee593e1701..7cb842d5a7 100644 --- a/tests/auto/quickcontrols/qquickmenubar/tst_qquickmenubar.cpp +++ b/tests/auto/quickcontrols/qquickmenubar/tst_qquickmenubar.cpp @@ -36,6 +36,7 @@ private slots: void altNavigation(); void addRemove(); void checkHighlightWhenMenuDismissed(); + void clearMenus(); private: QScopedPointer<QPointingDevice> touchScreen = QScopedPointer<QPointingDevice>(QTest::createTouchDevice()); @@ -771,6 +772,16 @@ void tst_qquickmenubar::checkHighlightWhenMenuDismissed() QVERIFY(!dynamicMenuBarItem->isHighlighted()); } +void tst_qquickmenubar::clearMenus() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("clearMenus.qml")); + QVERIFY2(c.isReady(), qPrintable(c.errorString())); + QScopedPointer<QObject> o(c.create()); + QVERIFY(!o.isNull()); + QTRY_COMPARE(o->property("v").toInt(), 2); +} + QTEST_QUICKCONTROLS_MAIN(tst_qquickmenubar) #include "tst_qquickmenubar.moc" diff --git a/tests/auto/quickcontrols/qquickninepatchimage/CMakeLists.txt b/tests/auto/quickcontrols/qquickninepatchimage/CMakeLists.txt index e8a4e733b8..43ac4fca05 100644 --- a/tests/auto/quickcontrols/qquickninepatchimage/CMakeLists.txt +++ b/tests/auto/quickcontrols/qquickninepatchimage/CMakeLists.txt @@ -5,7 +5,7 @@ if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) cmake_minimum_required(VERSION 3.16) - project(tst_qquickninepatchimage LANGUAGES C CXX ASM) + project(tst_qquickninepatchimage LANGUAGES C CXX) find_package(Qt6BuildInternals COMPONENTS STANDALONE_TEST) endif() diff --git a/tests/auto/quickcontrols/qquickoverlay/CMakeLists.txt b/tests/auto/quickcontrols/qquickoverlay/CMakeLists.txt index e5d9da4dc9..969604455c 100644 --- a/tests/auto/quickcontrols/qquickoverlay/CMakeLists.txt +++ b/tests/auto/quickcontrols/qquickoverlay/CMakeLists.txt @@ -3,7 +3,7 @@ if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) cmake_minimum_required(VERSION 3.16) - project(tst_qquickpopup LANGUAGES C CXX ASM) + project(tst_qquickpopup LANGUAGES C CXX) find_package(Qt6BuildInternals COMPONENTS STANDALONE_TEST) endif() diff --git a/tests/auto/quickcontrols/qquickpopup/CMakeLists.txt b/tests/auto/quickcontrols/qquickpopup/CMakeLists.txt index 81eb78c906..a0f9d12503 100644 --- a/tests/auto/quickcontrols/qquickpopup/CMakeLists.txt +++ b/tests/auto/quickcontrols/qquickpopup/CMakeLists.txt @@ -5,7 +5,7 @@ if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) cmake_minimum_required(VERSION 3.16) - project(tst_qquickpopup LANGUAGES C CXX ASM) + project(tst_qquickpopup LANGUAGES C CXX) find_package(Qt6BuildInternals COMPONENTS STANDALONE_TEST) endif() diff --git a/tests/auto/quickcontrols/qquickpopup/data/propagateTouchEvents.qml b/tests/auto/quickcontrols/qquickpopup/data/propagateTouchEvents.qml new file mode 100644 index 0000000000..01c7fe39de --- /dev/null +++ b/tests/auto/quickcontrols/qquickpopup/data/propagateTouchEvents.qml @@ -0,0 +1,17 @@ +import QtQuick +import QtQuick.Controls + +Window { + id: rootItem + width: 100 + height: 100 + + property alias tapHandler: tHandler + + Popup { + id: popupItem + width: 50 + height: 50 + background: Item { TapHandler { id: tHandler } } + } +} diff --git a/tests/auto/quickcontrols/qquickpopup/tst_qquickpopup.cpp b/tests/auto/quickcontrols/qquickpopup/tst_qquickpopup.cpp index 966f908e80..6dc260faea 100644 --- a/tests/auto/quickcontrols/qquickpopup/tst_qquickpopup.cpp +++ b/tests/auto/quickcontrols/qquickpopup/tst_qquickpopup.cpp @@ -30,6 +30,7 @@ #include <QtQuickTemplates2/private/qquickdrawer_p.h> #include <QtQuick/private/qquicklistview_p.h> #include <QtQuick/private/qquicktextedit_p.h> +#include <QtQuick/private/qquicktaphandler_p.h> #include <QtQuick/private/qquickdroparea_p.h> #include <QtQuickControlsTestUtils/private/controlstestutils_p.h> #include <QtQuickControlsTestUtils/private/qtest_quickcontrols_p.h> @@ -105,6 +106,7 @@ private slots: void doubleClickInMouseArea(); void pointerEventsNotBlockedForNonPopupChildrenOfOverlayWithHigherZ(); void resetHoveredStateForItemsWithinPopup(); + void propagateTouchEvents(); private: QScopedPointer<QPointingDevice> touchScreen = QScopedPointer<QPointingDevice>(QTest::createTouchDevice()); @@ -2364,6 +2366,14 @@ void tst_QQuickPopup::pointerEventsNotBlockedForNonPopupChildrenOfOverlayWithHig QCOMPARE(lowerMouseAreaSpy.count(), 0); QCOMPARE(upperMouseAreaSpy.count(), 1); + // Verify that the upper mouse area is hovered, even when a mouse press happens on top of a modal dialog + upperMouseArea->setHoverEnabled(true); + QTest::mouseMove(window, button->mapToScene(button->boundingRect().center() - QPoint(1,1)).toPoint()); + QVERIFY(!upperMouseArea->hovered()); + upperMouseArea->setEnabled(true); + QTest::mouseMove(window, button->mapToScene(button->boundingRect().center() + QPoint(1,1)).toPoint()); + QVERIFY(upperMouseArea->hovered()); + popup->close(); } @@ -2401,6 +2411,34 @@ void tst_QQuickPopup::resetHoveredStateForItemsWithinPopup() QTRY_VERIFY(!controlItem->isHovered()); } +void tst_QQuickPopup::propagateTouchEvents() +{ + QQuickApplicationHelper helper(this, "propagateTouchEvents.qml"); + QVERIFY2(helper.ready, helper.failureMessage()); + QQuickWindow *window = helper.window; + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window)); + + auto *popup = window->contentItem()->findChild<QQuickPopup *>(); + popup->open(); + QTRY_VERIFY(popup->isOpened()); + + auto *tapHandler = window->property("tapHandler").value<QQuickTapHandler *>(); + QVERIFY(tapHandler); + QSignalSpy tapSpy(tapHandler, &QQuickTapHandler::tapped); + // check for the item within the popup for touch events + QTest::touchEvent(window, touchScreen.data()).press(0, QPoint(10, 10)); + QTest::touchEvent(window, touchScreen.data()).release(0, QPoint(10, 10)); + QCOMPARE(tapSpy.count(), 1); + + // touch outside to close the popup window + QTest::touchEvent(window, touchScreen.data()).press(0, QPoint(90, 90)); + QTest::touchEvent(window, touchScreen.data()).release(0, QPoint(90, 90)); + QCOMPARE(tapSpy.count(), 1); + + QTRY_VERIFY(!popup->isOpened()); +} + QTEST_QUICKCONTROLS_MAIN(tst_QQuickPopup) #include "tst_qquickpopup.moc" diff --git a/tests/auto/quickcontrols/qquickstyle/CMakeLists.txt b/tests/auto/quickcontrols/qquickstyle/CMakeLists.txt index 4255850e30..525f56bdea 100644 --- a/tests/auto/quickcontrols/qquickstyle/CMakeLists.txt +++ b/tests/auto/quickcontrols/qquickstyle/CMakeLists.txt @@ -5,7 +5,7 @@ if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) cmake_minimum_required(VERSION 3.16) - project(tst_qquickstyle LANGUAGES C CXX ASM) + project(tst_qquickstyle LANGUAGES C CXX) find_package(Qt6BuildInternals COMPONENTS STANDALONE_TEST) endif() diff --git a/tests/auto/quickcontrols/qquicktextarea/CMakeLists.txt b/tests/auto/quickcontrols/qquicktextarea/CMakeLists.txt index f64b896e5c..01dcd5b942 100644 --- a/tests/auto/quickcontrols/qquicktextarea/CMakeLists.txt +++ b/tests/auto/quickcontrols/qquicktextarea/CMakeLists.txt @@ -3,7 +3,7 @@ if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) cmake_minimum_required(VERSION 3.16) - project(tst_qquicktextarea LANGUAGES C CXX ASM) + project(tst_qquicktextarea LANGUAGES C CXX) find_package(Qt6BuildInternals COMPONENTS STANDALONE_TEST) endif() diff --git a/tests/auto/quickcontrols/qquicktextfield/CMakeLists.txt b/tests/auto/quickcontrols/qquicktextfield/CMakeLists.txt index 50755b7f1c..7f4cac7f34 100644 --- a/tests/auto/quickcontrols/qquicktextfield/CMakeLists.txt +++ b/tests/auto/quickcontrols/qquicktextfield/CMakeLists.txt @@ -3,7 +3,7 @@ if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) cmake_minimum_required(VERSION 3.16) - project(tst_qquicktextfield LANGUAGES C CXX ASM) + project(tst_qquicktextfield LANGUAGES C CXX) find_package(Qt6BuildInternals COMPONENTS STANDALONE_TEST) endif() diff --git a/tests/auto/quickcontrols/qquicktreeviewdelegate/CMakeLists.txt b/tests/auto/quickcontrols/qquicktreeviewdelegate/CMakeLists.txt index 94d4096586..063a90a358 100644 --- a/tests/auto/quickcontrols/qquicktreeviewdelegate/CMakeLists.txt +++ b/tests/auto/quickcontrols/qquicktreeviewdelegate/CMakeLists.txt @@ -3,7 +3,7 @@ if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) cmake_minimum_required(VERSION 3.16) - project(tst_qquicktreeviewdelegate LANGUAGES C CXX ASM) + project(tst_qquicktreeviewdelegate LANGUAGES C CXX) find_package(Qt6BuildInternals COMPONENTS STANDALONE_TEST) endif() diff --git a/tests/auto/quickcontrols/qquickuniversalstyle/CMakeLists.txt b/tests/auto/quickcontrols/qquickuniversalstyle/CMakeLists.txt index a7f8ebfd6f..2122fac1db 100644 --- a/tests/auto/quickcontrols/qquickuniversalstyle/CMakeLists.txt +++ b/tests/auto/quickcontrols/qquickuniversalstyle/CMakeLists.txt @@ -5,7 +5,7 @@ if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) cmake_minimum_required(VERSION 3.16) - project(tst_qquickuniversalstyle LANGUAGES C CXX ASM) + project(tst_qquickuniversalstyle LANGUAGES C CXX) find_package(Qt6BuildInternals COMPONENTS STANDALONE_TEST) endif() diff --git a/tests/auto/quickcontrols/qquickuniversalstyleconf/CMakeLists.txt b/tests/auto/quickcontrols/qquickuniversalstyleconf/CMakeLists.txt index cfe781950d..86d100b1be 100644 --- a/tests/auto/quickcontrols/qquickuniversalstyleconf/CMakeLists.txt +++ b/tests/auto/quickcontrols/qquickuniversalstyleconf/CMakeLists.txt @@ -5,7 +5,7 @@ if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) cmake_minimum_required(VERSION 3.16) - project(tst_qquickuniversalstyleconf LANGUAGES C CXX ASM) + project(tst_qquickuniversalstyleconf LANGUAGES C CXX) find_package(Qt6BuildInternals COMPONENTS STANDALONE_TEST) endif() diff --git a/tests/auto/quickcontrols/revisions/CMakeLists.txt b/tests/auto/quickcontrols/revisions/CMakeLists.txt index 8c51f85d20..46f0734f68 100644 --- a/tests/auto/quickcontrols/revisions/CMakeLists.txt +++ b/tests/auto/quickcontrols/revisions/CMakeLists.txt @@ -5,7 +5,7 @@ if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) cmake_minimum_required(VERSION 3.16) - project(tst_revisions LANGUAGES C CXX ASM) + project(tst_revisions LANGUAGES C CXX) find_package(Qt6BuildInternals COMPONENTS STANDALONE_TEST) endif() diff --git a/tests/auto/quickcontrols/sanity/CMakeLists.txt b/tests/auto/quickcontrols/sanity/CMakeLists.txt index 6c99b5b7c7..e301e72d44 100644 --- a/tests/auto/quickcontrols/sanity/CMakeLists.txt +++ b/tests/auto/quickcontrols/sanity/CMakeLists.txt @@ -5,7 +5,7 @@ if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) cmake_minimum_required(VERSION 3.16) - project(tst_sanity LANGUAGES C CXX ASM) + project(tst_sanity LANGUAGES C CXX) find_package(Qt6BuildInternals COMPONENTS STANDALONE_TEST) endif() diff --git a/tests/auto/quickcontrols/snippets/CMakeLists.txt b/tests/auto/quickcontrols/snippets/CMakeLists.txt index cfb2fb4560..08b55c2645 100644 --- a/tests/auto/quickcontrols/snippets/CMakeLists.txt +++ b/tests/auto/quickcontrols/snippets/CMakeLists.txt @@ -5,7 +5,7 @@ if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) cmake_minimum_required(VERSION 3.16) - project(tst_snippets LANGUAGES C CXX ASM) + project(tst_snippets LANGUAGES C CXX) find_package(Qt6BuildInternals COMPONENTS STANDALONE_TEST) endif() diff --git a/tests/auto/quickcontrols/styleimports/CMakeLists.txt b/tests/auto/quickcontrols/styleimports/CMakeLists.txt index 4d19521f2e..e2f4e8d7a9 100644 --- a/tests/auto/quickcontrols/styleimports/CMakeLists.txt +++ b/tests/auto/quickcontrols/styleimports/CMakeLists.txt @@ -5,7 +5,7 @@ if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) cmake_minimum_required(VERSION 3.16) - project(tst_styleimports LANGUAGES C CXX ASM) + project(tst_styleimports LANGUAGES C CXX) find_package(Qt6BuildInternals COMPONENTS STANDALONE_TEST) endif() diff --git a/tests/auto/quickcontrols/styleimportscompiletimematerial/CMakeLists.txt b/tests/auto/quickcontrols/styleimportscompiletimematerial/CMakeLists.txt index 6e7f22da64..adec66b532 100644 --- a/tests/auto/quickcontrols/styleimportscompiletimematerial/CMakeLists.txt +++ b/tests/auto/quickcontrols/styleimportscompiletimematerial/CMakeLists.txt @@ -5,7 +5,7 @@ if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) cmake_minimum_required(VERSION 3.16) - project(tst_styleimportscompiletimematerial LANGUAGES C CXX ASM) + project(tst_styleimportscompiletimematerial LANGUAGES C CXX) find_package(Qt6BuildInternals COMPONENTS STANDALONE_TEST) endif() diff --git a/tests/auto/quickcontrols/styleimportscompiletimeqmlonly/CMakeLists.txt b/tests/auto/quickcontrols/styleimportscompiletimeqmlonly/CMakeLists.txt index 6e56e6a96e..ddb9a64413 100644 --- a/tests/auto/quickcontrols/styleimportscompiletimeqmlonly/CMakeLists.txt +++ b/tests/auto/quickcontrols/styleimportscompiletimeqmlonly/CMakeLists.txt @@ -5,7 +5,7 @@ if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) cmake_minimum_required(VERSION 3.16) - project(tst_styleimportscompiletimeqmlonly LANGUAGES C CXX ASM) + project(tst_styleimportscompiletimeqmlonly LANGUAGES C CXX) find_package(Qt6BuildInternals COMPONENTS STANDALONE_TEST) endif() diff --git a/tests/auto/quickcontrols/translation/CMakeLists.txt b/tests/auto/quickcontrols/translation/CMakeLists.txt index 745262cdcc..228fdf25e2 100644 --- a/tests/auto/quickcontrols/translation/CMakeLists.txt +++ b/tests/auto/quickcontrols/translation/CMakeLists.txt @@ -5,7 +5,7 @@ if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) cmake_minimum_required(VERSION 3.16) - project(tst_translation LANGUAGES C CXX ASM) + project(tst_translation LANGUAGES C CXX) find_package(Qt6BuildInternals COMPONENTS STANDALONE_TEST) endif() |
