diff options
author | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2009-10-12 14:54:52 (GMT) |
---|---|---|
committer | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2009-10-22 14:59:18 (GMT) |
commit | 1b154ddf00473700d697411304804ac065ef32ac (patch) | |
tree | 04c2a6d39ef18716cba61022df5e423e2761d0c1 | |
parent | 8a64af9c24c5c275cba22240760d9239d4b3fd6f (diff) | |
download | Qt-1b154ddf00473700d697411304804ac065ef32ac.zip Qt-1b154ddf00473700d697411304804ac065ef32ac.tar.gz Qt-1b154ddf00473700d697411304804ac065ef32ac.tar.bz2 |
Extended an autotest for gestures.
Make sure that when a gesture recognizer explicitely sets the
targetObject to a QGraphicsObject, we deliver it only to the object and
will not try to propagate.
Reviewed-by: trustme
-rw-r--r-- | tests/auto/gestures/tst_gestures.cpp | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/auto/gestures/tst_gestures.cpp b/tests/auto/gestures/tst_gestures.cpp index 46ed45e..baf90fa 100644 --- a/tests/auto/gestures/tst_gestures.cpp +++ b/tests/auto/gestures/tst_gestures.cpp @@ -241,6 +241,16 @@ static void sendCustomGesture(QObject *object) QApplication::sendEvent(object, &ev); } } +static void sendCustomGesture(QObject *object, QObject *target) +{ + CustomEvent ev; + ev.targetObject = target; + for (int i = CustomGesture::SerialMaybeThreshold; + i <= CustomGesture::SerialFinishedThreshold; ++i) { + ev.serial = i; + QApplication::sendEvent(object, &ev); + } +} class tst_Gestures : public QObject { @@ -265,6 +275,7 @@ private slots: void finishedWithoutStarted(); void unknownGesture(); void graphicsItemGesture(); + void explicitGraphicsObjectTarget(); }; tst_Gestures::tst_Gestures() @@ -624,5 +635,50 @@ void tst_Gestures::graphicsItemGesture() QCOMPARE(item->events.canceled.size(), 0); } +void tst_Gestures::explicitGraphicsObjectTarget() +{ + QGraphicsScene scene; + QGraphicsView view(&scene); + + GestureItem *item1 = new GestureItem; + scene.addItem(item1); + item1->setPos(100, 100); + item1->grabGesture(CustomGesture::GestureType); + + GestureItem *item2 = new GestureItem; + scene.addItem(item2); + item2->setPos(100, 100); + item2->grabGesture(CustomGesture::GestureType); + + GestureItem *item3 = new GestureItem; + scene.addItem(item3); + item3->setParentItem(item2); + item3->setPos(0, 0); + item3->grabGesture(CustomGesture::GestureType); + + // sending events to item1, but the targetObject for the gesture is item2. + sendCustomGesture(item1, item3); + + static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1; + static const int TotalCustomEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialMaybeThreshold + 1; + + QCOMPARE(item1->customEventsReceived, TotalCustomEventsCount); + QCOMPARE(item1->gestureEventsReceived, 0); + QCOMPARE(item1->gestureOverrideEventsReceived, 0); + QCOMPARE(item3->customEventsReceived, 0); + QCOMPARE(item3->gestureEventsReceived, TotalGestureEventsCount); + QCOMPARE(item3->gestureOverrideEventsReceived, 0); + QCOMPARE(item3->events.all.size(), TotalGestureEventsCount); + for(int i = 0; i < item3->events.all.size(); ++i) + QCOMPARE(item3->events.all.at(i), CustomGesture::GestureType); + QCOMPARE(item3->events.started.size(), 1); + QCOMPARE(item3->events.updated.size(), TotalGestureEventsCount - 2); + QCOMPARE(item3->events.finished.size(), 1); + QCOMPARE(item3->events.canceled.size(), 0); + QCOMPARE(item2->customEventsReceived, 0); + QCOMPARE(item2->gestureEventsReceived, 0); + QCOMPARE(item2->gestureOverrideEventsReceived, 0); +} + QTEST_MAIN(tst_Gestures) #include "tst_gestures.moc" |