diff options
author | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2009-05-22 10:21:21 (GMT) |
---|---|---|
committer | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2009-05-27 16:04:29 (GMT) |
commit | b8684b3520c561325746782952c980b168367d64 (patch) | |
tree | cdc92df09c26f160678e33addbf973c1eccd7424 /tests/auto/gestures | |
parent | 20fa050643f72b4bc91386c5fff62cdfe3b75393 (diff) | |
download | Qt-b8684b3520c561325746782952c980b168367d64.zip Qt-b8684b3520c561325746782952c980b168367d64.tar.gz Qt-b8684b3520c561325746782952c980b168367d64.tar.bz2 |
Added simple autotest for gestures when there are overlapping graphicsitems
Diffstat (limited to 'tests/auto/gestures')
-rw-r--r-- | tests/auto/gestures/tst_gestures.cpp | 62 |
1 files changed, 59 insertions, 3 deletions
diff --git a/tests/auto/gestures/tst_gestures.cpp b/tests/auto/gestures/tst_gestures.cpp index 22d16fd..5a6de13 100644 --- a/tests/auto/gestures/tst_gestures.cpp +++ b/tests/auto/gestures/tst_gestures.cpp @@ -327,20 +327,21 @@ protected: class GraphicsItem : public QGraphicsItem { public: - GraphicsItem() + GraphicsItem(int w = 100, int h = 100) + : width(w), height(h) { reset(); } QRectF boundingRect() const { - return QRectF(0, 0, 100, 100); + return QRectF(0, 0, width, height); } void paint(QPainter *painter, const QStyleOptionGraphicsItem*, QWidget*) { painter->setBrush(Qt::green); - painter->drawRect(0, 0, 100, 100); + painter->drawRect(0, 0, width, height); } void grabSingleshotGesture() @@ -365,6 +366,9 @@ public: secondFingerGestureId = -1; } + int width; + int height; + int singleshotGestureId; int pinchGestureId; int secondFingerGestureId; @@ -445,6 +449,7 @@ private slots: void simpleGraphicsView(); void simpleGraphicsItem(); + void overlappingGraphicsItems(); private: SingleshotGestureRecognizer *singleshotRecognizer; @@ -699,5 +704,56 @@ void tst_Gestures::simpleGraphicsItem() QVERIFY(mainWidget->gesture.seenGestureEvent); } +void tst_Gestures::overlappingGraphicsItems() +{ + mainWidget->grabSingleshotGesture(); + GraphicsScene scene; + QGraphicsView view(&scene); + mainWidget->layout()->addWidget(&view); + + GraphicsItem *item = new GraphicsItem(300, 100); + item->setPos(30, 50); + scene.addItem(item); + GraphicsItem *subitem1 = new GraphicsItem(50, 70); + subitem1->setPos(70, 70); + scene.addItem(subitem1); + GraphicsItem *subitem2 = new GraphicsItem(50, 70); + subitem2->setPos(250, 70); + scene.addItem(subitem2); + QApplication::processEvents(); + + item->grabSingleshotGesture(); + item->grabPinchGesture(); + item->grabSecondFingerGesture(); + subitem1->grabSingleshotGesture(); + subitem2->grabSecondFingerGesture(); + + SingleshotEvent event(100, 100); + sendSpontaneousEvent(&view, &event); + QVERIFY(subitem1->gesture.seenGestureEvent); + QVERIFY(!subitem2->gesture.seenGestureEvent); + QVERIFY(!item->gesture.seenGestureEvent); + QVERIFY(scene.gesture.seenGestureEvent); + QVERIFY(!mainWidget->gesture.seenGestureEvent); + QVERIFY(subitem1->gesture.last.singleshot.delivered); + + item->reset(); + subitem1->reset(); + subitem2->reset(); + scene.reset(); + mainWidget->reset(); + + subitem1->shouldAcceptSingleshotGesture = false; + SingleshotEvent event2(100, 100); + sendSpontaneousEvent(&view, &event2); + QVERIFY(subitem1->gesture.seenGestureEvent); + QVERIFY(!subitem2->gesture.seenGestureEvent); + QVERIFY(item->gesture.seenGestureEvent); + QVERIFY(scene.gesture.seenGestureEvent); + QVERIFY(!mainWidget->gesture.seenGestureEvent); + QVERIFY(subitem1->gesture.last.singleshot.delivered); + QVERIFY(item->gesture.last.singleshot.delivered); +} + QTEST_MAIN(tst_Gestures) #include "tst_gestures.moc" |