From b1054d45e996065ea8d8738a2ec862b98e1aae2b Mon Sep 17 00:00:00 2001 From: Axel Spoerl Date: Tue, 18 Oct 2022 09:09:31 +0200 Subject: [PATCH] Fix flakiness in tst_QDoubleSpinBox / editingFinished setFocus() was called on a double spinbox without calling show() first. That causes flakiness on XCB when checking focus afterwards. The test can still fail, when focus is acquired by e.g. a system popup. This patch adds a show() call before setFocus() to stabilize normal behavior. In case the double spin box is shown, but cannot acquire focus, the test is skipped. Fixes: QTBUG-70088 Change-Id: If02e88800a31b09a1da63dcc074eb8bb1b0df391 Reviewed-by: Paul Wicking --- .../widgets/qdoublespinbox/tst_qdoublespinbox.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp b/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp index 7f6328d1c57..b8b793eada0 100644 --- a/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp +++ b/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp @@ -857,8 +857,15 @@ void tst_QDoubleSpinBox::editingFinished() testFocusWidget.show(); testFocusWidget.activateWindow(); QVERIFY(QTest::qWaitForWindowActive(&testFocusWidget)); + + box->show(); + QVERIFY(QTest::qWaitForWindowExposed(box)); box->setFocus(); - QTRY_VERIFY(box->hasFocus()); + + // Box may fail to acquire focus due to a system popup + // it is fair in that case to skip the test + if (!QTest::qWaitForWindowActive(box)) + QSKIP("Focus acquisition failed."); QSignalSpy editingFinishedSpy1(box, SIGNAL(editingFinished())); QSignalSpy editingFinishedSpy2(box2, SIGNAL(editingFinished()));