diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2018-11-23 16:57:39 +0100 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2018-12-07 20:45:41 +0000 |
commit | be3772725cec64e533d35a38376077363af01ede (patch) | |
tree | f6d664d3b4dc36edb9cf73ba4b64bd80e36a548e /tests/auto | |
parent | ee2ac69595d3f854f7bf7158e600091f2675fa18 (diff) |
Ensure that each Event Handler has an Item parent rather than asserting
QQuickItemPrivate::data_append() was already getting called, but the
assert (that the parent was already an Item) was failing in case a
handler was declared inside a Window or a Dialog.
Fixes: QTBUG-71317
Change-Id: Ia497182e3b4a9722eee97a375f9ee5d4151108e6
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/quick/pointerhandlers/qquickpointerhandler/data/handlerInWindow.qml | 14 | ||||
-rw-r--r-- | tests/auto/quick/pointerhandlers/qquickpointerhandler/tst_qquickpointerhandler.cpp | 25 |
2 files changed, 39 insertions, 0 deletions
diff --git a/tests/auto/quick/pointerhandlers/qquickpointerhandler/data/handlerInWindow.qml b/tests/auto/quick/pointerhandlers/qquickpointerhandler/data/handlerInWindow.qml new file mode 100644 index 0000000000..49ec9be4a7 --- /dev/null +++ b/tests/auto/quick/pointerhandlers/qquickpointerhandler/data/handlerInWindow.qml @@ -0,0 +1,14 @@ +import QtQuick 2.12 +import QtQuick.Window 2.12 +import Qt.test 1.0 + +Window { + id: root + objectName: "root Window" + width: 320 + height: 480 + + EventHandler { + objectName: "eventHandler" + } +} diff --git a/tests/auto/quick/pointerhandlers/qquickpointerhandler/tst_qquickpointerhandler.cpp b/tests/auto/quick/pointerhandlers/qquickpointerhandler/tst_qquickpointerhandler.cpp index 906cbf63e4..feb356a7d5 100644 --- a/tests/auto/quick/pointerhandlers/qquickpointerhandler/tst_qquickpointerhandler.cpp +++ b/tests/auto/quick/pointerhandlers/qquickpointerhandler/tst_qquickpointerhandler.cpp @@ -238,6 +238,7 @@ private slots: void touchReleaseOutside_data(); void touchReleaseOutside(); void dynamicCreation(); + void handlerInWindow(); void dynamicCreationInWindow(); protected: @@ -626,6 +627,30 @@ void tst_PointerHandlers::dynamicCreation() QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, p1); } +void tst_PointerHandlers::handlerInWindow() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.loadUrl(testFileUrl("handlerInWindow.qml")); + QQuickWindow *window = qobject_cast<QQuickWindow*>(component.create()); + QScopedPointer<QQuickWindow> cleanup(window); + QVERIFY(window); + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window)); + + EventHandler *handler = window->contentItem()->findChild<EventHandler*>("eventHandler"); + QVERIFY(handler); + + QCOMPARE(handler->parentItem(), window->contentItem()); + QCOMPARE(handler->target(), window->contentItem()); + + QPoint p1(20, 20); + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, p1); + QTRY_COMPARE(handler->eventCount, 1); + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, p1); + QTRY_COMPARE(handler->eventCount, 2); +} + void tst_PointerHandlers::dynamicCreationInWindow() { QQmlEngine engine; |