tst_Gestures::conflictingGesturesInGraphicsView(): use dynamic size

The test function assigns a hard coded rectangle to gestures and uses
the default size of a graphics view at the same time.
The leads to flakiness, where the gestures can't be delivered when their
size is out of bounds of the view's geometry.

Assign size size dynamically, according to the view's geometry.

Task-number: QTBUG-130811
Pick-to: 6.8 6.5
Change-Id: If75f59d15f84e610b4ec987daa2a06ce62539228
Reviewed-by: Frederic Lefebvre <frederic.lefebvre@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Axel Spoerl 2024-11-10 18:25:11 +01:00
parent 3045a08e5e
commit 6995709992

View File

@ -2286,22 +2286,23 @@ void tst_Gestures::conflictingGesturesInGraphicsView()
GraphicsView view(&scene);
view.setWindowFlags(Qt::X11BypassWindowManagerHint);
view.show();
QVERIFY(QTest::qWaitForWindowExposed(&view));
view.ensureVisible(scene.sceneRect());
const QRectF gestureRect(0, 0, view.width() * 0.9, view.height() * 0.9);
GestureItem *item1 = new GestureItem("item1");
item1->grabGesture(CustomGesture::GestureType);
item1->size = QRectF(0, 0, 100, 100);
item1->size = gestureRect;
item1->setZValue(2);
scene.addItem(item1);
GestureItem *item2 = new GestureItem("item2");
item2->grabGesture(CustomGesture::GestureType);
item2->size = QRectF(0, 0, 100, 100);
item2->size = gestureRect;
item2->setZValue(5);
scene.addItem(item2);
view.show();
QVERIFY(QTest::qWaitForWindowExposed(&view));
view.ensureVisible(scene.sceneRect());
static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1;
CustomEvent event;