diff options
author | Andrew den Exter <andrew.den-exter@nokia.com> | 2012-07-03 12:29:57 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-07-04 02:45:03 +0200 |
commit | 9bf96613c1be7d4df7132a9c3c9ac1a8740f698f (patch) | |
tree | 351c19417586bf5ec688af3f8b40f91c9f1d1a5e /tests | |
parent | fc909a49d3e8fa2132bf0951499a1d5cb1d541ca (diff) |
Allow mouse interaction with 0 opacity items.
Don't filter event delivery to items with 0 opacity, and update the
documentation the for opacity, visible and enabled properties and how
each affects event delivery.
Task-number: QTBUG-19193
Change-Id: Id48e4af763c9a7bbcc13b303342d303155dcadc9
Reviewed-by: Jan-Arve Sæther <jan-arve.saether@nokia.com>
Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/quick/qquickcanvas/tst_qquickcanvas.cpp | 22 | ||||
-rw-r--r-- | tests/auto/quick/qquickdrag/tst_qquickdrag.cpp | 6 |
2 files changed, 14 insertions, 14 deletions
diff --git a/tests/auto/quick/qquickcanvas/tst_qquickcanvas.cpp b/tests/auto/quick/qquickcanvas/tst_qquickcanvas.cpp index 83c5b62ef8..badec53aee 100644 --- a/tests/auto/quick/qquickcanvas/tst_qquickcanvas.cpp +++ b/tests/auto/quick/qquickcanvas/tst_qquickcanvas.cpp @@ -157,7 +157,7 @@ public: void reset() { acceptTouchEvents = acceptMouseEvents = true; setEnabled(true); - setOpacity(1.0); + setVisible(true); lastEvent = makeTouchData(QEvent::None, canvas(), 0, QList<QTouchEvent::TouchPoint>());//CHECK_VALID @@ -456,7 +456,7 @@ void tst_qquickcanvas::touchEvent_propagation() QFETCH(bool, acceptTouchEvents); QFETCH(bool, acceptMouseEvents); QFETCH(bool, enableItem); - QFETCH(qreal, itemOpacity); + QFETCH(bool, showItem); QQuickCanvas *canvas = new QQuickCanvas; canvas->resize(250, 250); @@ -487,7 +487,7 @@ void tst_qquickcanvas::touchEvent_propagation() topItem->acceptTouchEvents = acceptTouchEvents; topItem->acceptMouseEvents = acceptMouseEvents; topItem->setEnabled(enableItem); - topItem->setOpacity(itemOpacity); + topItem->setVisible(showItem); // single touch to top item, should be received by middle item QTest::touchEvent(canvas, touchDevice).press(0, pointInTopItem, canvas); @@ -514,7 +514,7 @@ void tst_qquickcanvas::touchEvent_propagation() middleItem->acceptTouchEvents = acceptTouchEvents; middleItem->acceptMouseEvents = acceptMouseEvents; middleItem->setEnabled(enableItem); - middleItem->setOpacity(itemOpacity); + middleItem->setVisible(showItem); // touch top and middle items, bottom item should get all events QTest::touchEvent(canvas, touchDevice).press(0, pointInTopItem, canvas) @@ -531,7 +531,7 @@ void tst_qquickcanvas::touchEvent_propagation() // disable bottom item as well bottomItem->acceptTouchEvents = acceptTouchEvents; bottomItem->setEnabled(enableItem); - bottomItem->setOpacity(itemOpacity); + bottomItem->setVisible(showItem); // no events should be received QTest::touchEvent(canvas, touchDevice).press(0, pointInTopItem, canvas) @@ -549,10 +549,10 @@ void tst_qquickcanvas::touchEvent_propagation() // disable middle item, touch on top item middleItem->acceptTouchEvents = acceptTouchEvents; middleItem->setEnabled(enableItem); - middleItem->setOpacity(itemOpacity); + middleItem->setVisible(showItem); QTest::touchEvent(canvas, touchDevice).press(0, pointInTopItem, canvas); QTest::qWait(50); - if (!enableItem || itemOpacity == 0) { + if (!enableItem || !showItem) { // middle item is disabled or has 0 opacity, bottom item receives the event QVERIFY(topItem->lastEvent.touchPoints.isEmpty()); QVERIFY(middleItem->lastEvent.touchPoints.isEmpty()); @@ -579,11 +579,11 @@ void tst_qquickcanvas::touchEvent_propagation_data() QTest::addColumn<bool>("acceptTouchEvents"); QTest::addColumn<bool>("acceptMouseEvents"); QTest::addColumn<bool>("enableItem"); - QTest::addColumn<qreal>("itemOpacity"); + QTest::addColumn<bool>("showItem"); - QTest::newRow("disable events") << false << false << true << 1.0; - QTest::newRow("disable item") << true << true << false << 1.0; - QTest::newRow("opacity of 0") << true << true << true << 0.0; + QTest::newRow("disable events") << false << false << true << true; + QTest::newRow("disable item") << true << true << false << true; + QTest::newRow("hide item") << true << true << true << false; } void tst_qquickcanvas::touchEvent_cancel() diff --git a/tests/auto/quick/qquickdrag/tst_qquickdrag.cpp b/tests/auto/quick/qquickdrag/tst_qquickdrag.cpp index 0ebfa81201..12c1a03b3e 100644 --- a/tests/auto/quick/qquickdrag/tst_qquickdrag.cpp +++ b/tests/auto/quick/qquickdrag/tst_qquickdrag.cpp @@ -345,9 +345,9 @@ void tst_QQuickDrag::active() evaluate<void>(item, "Drag.active = true"); QCOMPARE(evaluate<bool>(item, "Drag.active"), true); QCOMPARE(evaluate<bool>(item, "dragActive"), true); - QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0)); - QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0)); - QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 0); + QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&dropTarget)); + QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&dropTarget)); + QCOMPARE(dropTarget.enterEvents, 1); QCOMPARE(dropTarget.leaveEvents, 0); evaluate<void>(item, "Drag.active = false"); dropTarget.setOpacity(1.0); |