From 1e99cb6e809ff0c8647c5017c11ead68ae1a591d Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Tue, 3 Sep 2019 13:20:29 +0200 Subject: Fix flakiness in tst_qquickdrawer tests Although it's not ideal to add arbitrary delays to tests, it does reflect a more realistic testing environment, and more importantly, seems to fix the flakiness on OpenSUSE. (cherry picked from commit 97fc102cd079f32cc1a4f00a764ceea981699fc0) Fixes: QTBUG-77946 Change-Id: I2998611759106386091d7375b31e56523c95371f Reviewed-by: Mitch Curtis Reviewed-by: Liang Qi --- tests/auto/qquickdrawer/tst_qquickdrawer.cpp | 6 ++++-- tests/auto/qquickpopup/tst_qquickpopup.cpp | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/auto/qquickdrawer/tst_qquickdrawer.cpp b/tests/auto/qquickdrawer/tst_qquickdrawer.cpp index 816f9b67..4cf0dabe 100644 --- a/tests/auto/qquickdrawer/tst_qquickdrawer.cpp +++ b/tests/auto/qquickdrawer/tst_qquickdrawer.cpp @@ -350,7 +350,8 @@ void tst_QQuickDrawer::position() QVERIFY(drawer); drawer->setEdge(edge); - QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, press); + // Give it some time (50 ms) before the press to avoid flakiness on OpenSUSE: QTBUG-77946 + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, press, 50); QTest::mouseMove(window, from); QTest::mouseMove(window, to); QCOMPARE(drawer->position(), position); @@ -403,7 +404,8 @@ void tst_QQuickDrawer::dragMargin() int leftX = qMax(0, dragMargin); int leftDistance = startDragDistance + drawer->width() * 0.45; QVERIFY(leftDistance > QGuiApplication::styleHints()->startDragDistance()); - QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(leftX, drawer->height() / 2)); + // Give it some time (50 ms) before the press to avoid flakiness on OpenSUSE: QTBUG-77946 + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(leftX, drawer->height() / 2), 50); QTest::mouseMove(window, QPoint(leftX + startDragDistance, drawer->height() / 2)); QTest::mouseMove(window, QPoint(leftX + leftDistance, drawer->height() / 2)); QCOMPARE(drawer->position(), dragFromLeft); diff --git a/tests/auto/qquickpopup/tst_qquickpopup.cpp b/tests/auto/qquickpopup/tst_qquickpopup.cpp index 81b2d583..4046bd3d 100644 --- a/tests/auto/qquickpopup/tst_qquickpopup.cpp +++ b/tests/auto/qquickpopup/tst_qquickpopup.cpp @@ -493,7 +493,7 @@ void tst_QQuickPopup::closePolicy() QTRY_VERIFY(popup->isOpened()); // press outside popup and its parent - QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1)); + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1), 50); if (closePolicy.testFlag(QQuickPopup::CloseOnPressOutside) || closePolicy.testFlag(QQuickPopup::CloseOnPressOutsideParent)) QTRY_VERIFY(!popup->isVisible()); else -- cgit v1.2.3