diff options
Diffstat (limited to 'tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp')
-rw-r--r-- | tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp index 5844720aa4..54a29dbc7f 100644 --- a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp +++ b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp @@ -307,7 +307,7 @@ void tst_QQuickMouseArea::resetDrag() { QQuickView window; QByteArray errorMessage; - window.rootContext()->setContextProperty("haveTarget", QVariant(true)); + window.setInitialProperties({{"haveTarget", true}}); QVERIFY2(QQuickTest::initView(window, testFileUrl("dragreset.qml"), true, &errorMessage), errorMessage.constData()); window.show(); QVERIFY(QTest::qWaitForWindowExposed(&window)); @@ -326,7 +326,9 @@ void tst_QQuickMouseArea::resetDrag() QVERIFY(rootItem != nullptr); QSignalSpy targetSpy(drag, SIGNAL(targetChanged())); QVERIFY(drag->target() != nullptr); - window.rootContext()->setContextProperty("haveTarget", QVariant(false)); + auto root = window.rootObject(); + QQmlProperty haveTarget {root, "haveTarget"}; + haveTarget.write(false); QCOMPARE(targetSpy.count(),1); QVERIFY(!drag->target()); } @@ -1359,6 +1361,34 @@ void tst_QQuickMouseArea::hoverVisible() QCOMPARE(enteredSpy.count(), 1); QCOMPARE(QPointF(mouseTracker->mouseX(), mouseTracker->mouseY()), QPointF(11,33)); + + // QTBUG-77983 + mouseTracker->setVisible(false); + mouseTracker->setEnabled(false); + + QCOMPARE(mouseTracker->hovered(), false); + mouseTracker->setVisible(true); + // if the enabled property is false, the containsMouse property shouldn't become true + // when an invisible mousearea become visible + QCOMPARE(mouseTracker->hovered(), false); + + mouseTracker->parentItem()->setEnabled(false); + mouseTracker->setVisible(false); + mouseTracker->setEnabled(true); + + QCOMPARE(mouseTracker->hovered(), false); + mouseTracker->setVisible(true); + // if the parent item is not enabled, the containsMouse property will be false, even if + // the mousearea is enabled + QCOMPARE(mouseTracker->hovered(), false); + + mouseTracker->parentItem()->setEnabled(true); + mouseTracker->setVisible(false); + mouseTracker->setEnabled(true); + + QCOMPARE(mouseTracker->hovered(), false); + mouseTracker->setVisible(true); + QCOMPARE(mouseTracker->hovered(), true); } void tst_QQuickMouseArea::hoverAfterPress() |