diff options
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/quick/qquicklistview/data/clickHeaderAndFooterWhenClip.qml | 60 | ||||
-rw-r--r-- | tests/auto/quick/qquicklistview/tst_qquicklistview.cpp | 27 |
2 files changed, 87 insertions, 0 deletions
diff --git a/tests/auto/quick/qquicklistview/data/clickHeaderAndFooterWhenClip.qml b/tests/auto/quick/qquicklistview/data/clickHeaderAndFooterWhenClip.qml new file mode 100644 index 0000000000..c48e2d47d1 --- /dev/null +++ b/tests/auto/quick/qquicklistview/data/clickHeaderAndFooterWhenClip.qml @@ -0,0 +1,60 @@ +import QtQuick 2.9 +import QtQuick.Window 2.15 + +ListView { + id: list + anchors.fill: parent + property bool headerPressed: false + property bool footerPressed: false + model: ListModel { + ListElement { + name: "Element 1" + } + ListElement { + name: "Element 2" + } + ListElement { + name: "Element 3" + } + ListElement { + name: "Element 4" + } + ListElement { + name: "Element 5" + } + ListElement { + name: "Element 6" + } + } + clip: true + headerPositioning: ListView.OverlayHeader + footerPositioning: ListView.OverlayHeader + + delegate: Text { + height: 100 + text: name + } + + header: Rectangle { + width: parent.width + height: 50 + z: 2 + color: "blue" + MouseArea { + objectName: "header" + anchors.fill: parent + onClicked: list.headerPressed = true + } + } + footer: Rectangle { + width: parent.width + height: 50 + color: "red" + z: 2 + MouseArea { + objectName: "footer" + anchors.fill: parent + onClicked: list.footerPressed = true + } + } +} diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp index f63793ca80..2af6b084fb 100644 --- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp @@ -297,6 +297,7 @@ private slots: void objectModelCulling(); void requiredObjectListModel(); + void clickHeaderAndFooterWhenClip(); private: template <class T> void items(const QUrl &source); @@ -10067,6 +10068,32 @@ void tst_QQuickListView::requiredObjectListModel() } } +void tst_QQuickListView::clickHeaderAndFooterWhenClip() // QTBUG-85302 +{ + QScopedPointer<QQuickView> window(createView()); + window->setSource(testFileUrl("clickHeaderAndFooterWhenClip.qml")); + window->resize(640, 480); + window->show(); + + QVERIFY(QTest::qWaitForWindowExposed(window.data())); + auto *root = window->rootObject(); + QVERIFY(root); + + auto *header = root->findChild<QQuickItem *>("header"); + QVERIFY(header); + + auto *footer = root->findChild<QQuickItem *>("footer"); + QVERIFY(footer); + + QVERIFY(root->property("headerPressed").isValid() && root->property("headerPressed").canConvert<bool>() && !root->property("headerPressed").toBool()); + QTest::mouseClick(window.data(), Qt::LeftButton, Qt::NoModifier, header->mapToItem(root, QPoint(header->width() / 2, header->height() / 2)).toPoint()); + QVERIFY(root->property("headerPressed").toBool()); + + QVERIFY(root->property("footerPressed").isValid() && root->property("footerPressed").canConvert<bool>() && !root->property("footerPressed").toBool()); + QTest::mouseClick(window.data(), Qt::LeftButton, Qt::NoModifier, footer->mapToItem(root, QPoint(footer->width() / 2, footer->height() / 2)).toPoint()); + QVERIFY(root->property("footerPressed").toBool()); +} + QTEST_MAIN(tst_QQuickListView) #include "tst_qquicklistview.moc" |