From e69b6d2dbc9166f07ff3ee1e588f39d244c0b692 Mon Sep 17 00:00:00 2001 From: Kari Oikarinen Date: Wed, 11 Apr 2018 09:27:32 +0300 Subject: tst_Gestures: Use QTest::qWaitForWindowExposed() Instead of a local wrapper for it. Change-Id: I0708dfad44b3db0c7a13e75ba5b4193ab50ac315 Reviewed-by: Qt CI Bot Reviewed-by: Gatis Paeglis --- tests/auto/other/gestures/tst_gestures.cpp | 56 ++++++++++-------------------- 1 file changed, 19 insertions(+), 37 deletions(-) (limited to 'tests') diff --git a/tests/auto/other/gestures/tst_gestures.cpp b/tests/auto/other/gestures/tst_gestures.cpp index d153146574..0767efb817 100644 --- a/tests/auto/other/gestures/tst_gestures.cpp +++ b/tests/auto/other/gestures/tst_gestures.cpp @@ -43,24 +43,6 @@ #include -static bool waitForWindowExposed(QWindow *window) -{ - if (!window) - return false; -#ifdef Q_OS_OSX - QTest::qWait(100); - return window->isExposed(); -#endif - return QTest::qWaitForWindowExposed(window); -} - -static bool waitForWindowExposed(QWidget *widget) -{ - if (!widget) - return false; - return waitForWindowExposed(widget->windowHandle()); -} - static QPointF mapToGlobal(const QPointF &pt, QGraphicsItem *item, QGraphicsView *view) { return view->viewport()->mapToGlobal(view->mapFromScene(item->mapToScene(pt))); @@ -376,7 +358,7 @@ void tst_Gestures::customGesture() GestureWidget widget; widget.grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren); widget.show(); - QVERIFY(waitForWindowExposed(&widget)); + QVERIFY(QTest::qWaitForWindowExposed(&widget)); CustomEvent event; event.hotSpot = widget.mapToGlobal(QPoint(5,5)); @@ -845,7 +827,7 @@ void tst_Gestures::graphicsItemGesture() item->setPos(100, 100); view.show(); - QVERIFY(waitForWindowExposed(&view)); + QVERIFY(QTest::qWaitForWindowExposed(&view)); view.ensureVisible(scene.sceneRect()); item->grabGesture(CustomGesture::GestureType); @@ -907,7 +889,7 @@ void tst_Gestures::graphicsView() item->setPos(100, 100); view.show(); - QVERIFY(waitForWindowExposed(&view)); + QVERIFY(QTest::qWaitForWindowExposed(&view)); view.ensureVisible(scene.sceneRect()); item->grabGesture(CustomGesture::GestureType); @@ -983,7 +965,7 @@ void tst_Gestures::graphicsItemTreeGesture() item1_child2->setParentItem(item1); view.show(); - QVERIFY(waitForWindowExposed(&view)); + QVERIFY(QTest::qWaitForWindowExposed(&view)); view.ensureVisible(scene.sceneRect()); item1->grabGesture(CustomGesture::GestureType); @@ -1040,7 +1022,7 @@ void tst_Gestures::explicitGraphicsObjectTarget() item2_child1->setPos(10, 10); view.show(); - QVERIFY(waitForWindowExposed(&view)); + QVERIFY(QTest::qWaitForWindowExposed(&view)); view.ensureVisible(scene.sceneRect()); item1->grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren); @@ -1099,7 +1081,7 @@ void tst_Gestures::gestureOverChildGraphicsItem() item2_child1->setPos(0, 0); view.show(); - QVERIFY(waitForWindowExposed(&view)); + QVERIFY(QTest::qWaitForWindowExposed(&view)); view.ensureVisible(scene.sceneRect()); item1->grabGesture(CustomGesture::GestureType); @@ -1397,7 +1379,7 @@ void tst_Gestures::testMapToScene() item0->setPos(14, 16); view.show(); // need to show to give it a global coordinate - QVERIFY(waitForWindowExposed(&view)); + QVERIFY(QTest::qWaitForWindowExposed(&view)); view.ensureVisible(scene.sceneRect()); QPoint origin = view.mapToGlobal(QPoint()); @@ -1523,7 +1505,7 @@ void tst_Gestures::autoCancelGestures() parent.grabGesture(CustomGesture::GestureType); child->grabGesture(secondGesture); parent.show(); - QVERIFY(waitForWindowExposed(&parent)); + QVERIFY(QTest::qWaitForWindowExposed(&parent)); /* An event is sent to both the child and the parent, when the child gets it a gesture is triggered @@ -1582,7 +1564,7 @@ void tst_Gestures::autoCancelGestures2() child->grabGesture(secondGesture); view.show(); - QVERIFY(waitForWindowExposed(&view)); + QVERIFY(QTest::qWaitForWindowExposed(&view)); view.ensureVisible(scene.sceneRect()); CustomEvent event; @@ -1628,7 +1610,7 @@ void tst_Gestures::graphicsViewParentPropagation() item1_c1_c1->setPos(0, 0); view.show(); - QVERIFY(waitForWindowExposed(&view)); + QVERIFY(QTest::qWaitForWindowExposed(&view)); view.ensureVisible(scene.sceneRect()); item0->grabGesture(CustomGesture::GestureType, Qt::ReceivePartialGestures | Qt::IgnoredGesturesPropagateToParent); @@ -1698,7 +1680,7 @@ void tst_Gestures::panelPropagation() item1_child1_child1->setZValue(10); view.show(); - QVERIFY(waitForWindowExposed(&view)); + QVERIFY(QTest::qWaitForWindowExposed(&view)); view.ensureVisible(scene.sceneRect()); static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1; @@ -1809,7 +1791,7 @@ void tst_Gestures::panelStacksBehindParent() panel->setZValue(5); view.show(); - QVERIFY(waitForWindowExposed(&view)); + QVERIFY(QTest::qWaitForWindowExposed(&view)); view.ensureVisible(scene.sceneRect()); static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1; @@ -1893,7 +1875,7 @@ void tst_Gestures::deleteGestureTargetItem() items.insert(item2->objectName(), item2); view.show(); - QVERIFY(waitForWindowExposed(&view)); + QVERIFY(QTest::qWaitForWindowExposed(&view)); view.ensureVisible(scene.sceneRect()); if (propagateUpdateGesture) @@ -1938,7 +1920,7 @@ void tst_Gestures::viewportCoordinates() scene.addItem(item1); view.show(); - QVERIFY(waitForWindowExposed(&view)); + QVERIFY(QTest::qWaitForWindowExposed(&view)); view.ensureVisible(scene.sceneRect()); CustomEvent event; @@ -1975,7 +1957,7 @@ void tst_Gestures::partialGesturePropagation() scene.addItem(item4); view.show(); - QVERIFY(waitForWindowExposed(&view)); + QVERIFY(QTest::qWaitForWindowExposed(&view)); view.ensureVisible(scene.sceneRect()); item1->ignoredUpdatedGestures << CustomGesture::GestureType; @@ -2063,7 +2045,7 @@ void tst_Gestures::testQGestureRecognizerCleanup() //QGestureRecognizer::registerRecognizer(new PanRecognizer(PanRecognizer::Custom)); w->show(); - QVERIFY(waitForWindowExposed(w)); + QVERIFY(QTest::qWaitForWindowExposed(w)); delete w; } @@ -2184,7 +2166,7 @@ void tst_Gestures::testReuseCanceledGestures() gv->viewport()->grabGesture(tapGestureTypeId); mw.show(); - QVERIFY(waitForWindowExposed(&mw)); + QVERIFY(QTest::qWaitForWindowExposed(&mw)); QPoint targetPos(gv->mapFromScene(target->mapToScene(target->rect().center()))); targetPos = gv->viewport()->mapFromParent(targetPos); @@ -2250,7 +2232,7 @@ void tst_Gestures::conflictingGesturesInGraphicsView() scene.addItem(item2); view.show(); - QVERIFY(waitForWindowExposed(&view)); + QVERIFY(QTest::qWaitForWindowExposed(&view)); view.ensureVisible(scene.sceneRect()); static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1; @@ -2315,7 +2297,7 @@ void tst_Gestures::bug_13501_gesture_not_accepted() NoConsumeWidgetBug13501 w; w.grabGesture(Qt::TapGesture); w.show(); - QVERIFY(waitForWindowExposed(&w)); + QVERIFY(QTest::qWaitForWindowExposed(&w)); //QTest::mousePress(&ignoreEvent, Qt::LeftButton); QTouchDevice *device = QTest::createTouchDevice(); QTest::touchEvent(&w, device).press(0, QPoint(10, 10), &w); -- cgit v1.2.3