summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDenis Dzyubenko <denis.dzyubenko@nokia.com>2010-06-04 08:28:11 (GMT)
committerDenis Dzyubenko <denis.dzyubenko@nokia.com>2010-06-07 16:09:31 (GMT)
commitd0a27b157c6a5d3cf4b75c6b1b71de399733f553 (patch)
tree8710d36dbf6326b36ce06d94cb8913d6c6fb37e6 /tests
parent4ebe96275944643a06ac4119ef707e1436df5781 (diff)
downloadQt-d0a27b157c6a5d3cf4b75c6b1b71de399733f553.zip
Qt-d0a27b157c6a5d3cf4b75c6b1b71de399733f553.tar.gz
Qt-d0a27b157c6a5d3cf4b75c6b1b71de399733f553.tar.bz2
Fixed GestureOverride event delivery in GraphicsView.
GestureOverride event was not respected when delivering to items in GraphicsView. Task-number: QTBUG-10745 Reviewed-by: Thomas Zander
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/gestures/tst_gestures.cpp66
1 files changed, 66 insertions, 0 deletions
diff --git a/tests/auto/gestures/tst_gestures.cpp b/tests/auto/gestures/tst_gestures.cpp
index 4a9f1d1..644a9b3 100644
--- a/tests/auto/gestures/tst_gestures.cpp
+++ b/tests/auto/gestures/tst_gestures.cpp
@@ -333,6 +333,7 @@ private slots:
void gestureOverChild();
void multipleWidgetOnlyGestureInTree();
void conflictingGestures();
+ void conflictingGesturesInGraphicsView();
void finishedWithoutStarted();
void unknownGesture();
void graphicsItemGesture();
@@ -2069,5 +2070,70 @@ void tst_Gestures::testQGestureRecognizerCleanup()
delete w;
}
+void tst_Gestures::conflictingGesturesInGraphicsView()
+{
+ QGraphicsScene scene;
+ GraphicsView view(&scene);
+ view.setWindowFlags(Qt::X11BypassWindowManagerHint);
+
+ GestureItem *item1 = new GestureItem("item1");
+ item1->grabGesture(CustomGesture::GestureType);
+ item1->size = QRectF(0, 0, 100, 100);
+ item1->setZValue(2);
+ scene.addItem(item1);
+
+ GestureItem *item2 = new GestureItem("item2");
+ item2->grabGesture(CustomGesture::GestureType);
+ item2->size = QRectF(0, 0, 100, 100);
+ item2->setZValue(5);
+ scene.addItem(item2);
+
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+ view.ensureVisible(scene.sceneRect());
+
+ static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1;
+
+ CustomEvent event;
+
+ // nobody accepts override
+ item1->acceptGestureOverride = false;
+ item2->acceptGestureOverride = false;
+ event.hotSpot = mapToGlobal(item2->boundingRect().center(), item2, &view);
+ event.hasHotSpot = true;
+ sendCustomGesture(&event, item2, &scene);
+ QCOMPARE(item2->gestureOverrideEventsReceived, 1);
+ QCOMPARE(item2->gestureEventsReceived, TotalGestureEventsCount);
+ QCOMPARE(item1->gestureOverrideEventsReceived, 1);
+ QCOMPARE(item1->gestureEventsReceived, 0);
+
+ item1->reset(); item2->reset();
+
+ // the original target accepts override
+ item1->acceptGestureOverride = false;
+ item2->acceptGestureOverride = true;
+ event.hotSpot = mapToGlobal(item2->boundingRect().center(), item2, &view);
+ event.hasHotSpot = true;
+ sendCustomGesture(&event, item2, &scene);
+ QCOMPARE(item2->gestureOverrideEventsReceived, 1);
+ QCOMPARE(item2->gestureEventsReceived, TotalGestureEventsCount);
+ QCOMPARE(item1->gestureOverrideEventsReceived, 0);
+ QCOMPARE(item1->gestureEventsReceived, 0);
+
+ item1->reset(); item2->reset();
+
+ // the item behind accepts override
+ item1->acceptGestureOverride = true;
+ item2->acceptGestureOverride = false;
+ event.hotSpot = mapToGlobal(item2->boundingRect().center(), item2, &view);
+ event.hasHotSpot = true;
+ sendCustomGesture(&event, item2, &scene);
+
+ QCOMPARE(item2->gestureOverrideEventsReceived, 1);
+ QCOMPARE(item2->gestureEventsReceived, 0);
+ QCOMPARE(item1->gestureOverrideEventsReceived, 1);
+ QCOMPARE(item1->gestureEventsReceived, TotalGestureEventsCount);
+}
+
QTEST_MAIN(tst_Gestures)
#include "tst_gestures.moc"