summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorAxel Spoerl <axel.spoerl@qt.io>2022-10-18 09:09:31 +0200
committerAxel Spoerl <axel.spoerl@qt.io>2022-10-18 11:31:25 +0000
commitb1054d45e996065ea8d8738a2ec862b98e1aae2b (patch)
tree31def7d086ca491430391e9d65b8a27a3ee84992 /tests/auto
parent2937cf91c74b6562bf56e8872dfd2bfaafebb3cc (diff)
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 <paul.wicking@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp b/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp
index 7f6328d1c5..b8b793eada 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()));