summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Lefebvre <[email protected]>2025-05-13 10:29:50 +0200
committerFrederic Lefebvre <[email protected]>2025-07-08 16:23:00 +0000
commitec715356ded1419d05a903996120e1f1cdf3418e (patch)
treef281f3519036798095446a0161828b984d31becb
parente0a44e10380d99fc9d8e1775aec52060961c6d6a (diff)
Fix flaky tst_qMenuBar::taskQTBUG11823_crashwithInvisibleActionsHEADdev
tst_qMenuBar::taskQTBUG11823_crashwithInvisibleActions is flaky on openSUSE where setActiveAction is called before the resize events had time to finish processing. Wait for 2 resize events to have been processed while on openSUSE calling setActiveAction. The resize events caused the active action to be removed. Their asynchronicity randomized their handling before or after the active action was verified. Pick-to: 6.10 6.9 6.8 6.5 Change-Id: I6be81781bf9be0ed522af3ba3f1aee9a665af97d Reviewed-by: Axel Spoerl <[email protected]>
-rw-r--r--tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
index 609a0847862..f4baf6b1714 100644
--- a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
+++ b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
@@ -1233,12 +1233,41 @@ void tst_QMenuBar::taskQTBUG4965_escapeEaten()
}
#endif
+#ifdef Q_OS_LINUX
+class ResizeCounter : public QObject
+{
+public:
+ explicit ResizeCounter(QMenuBar *bar)
+ {
+ Q_ASSERT(bar);
+ bar->installEventFilter(this);
+ }
+
+ int resizeCount() const { return m_resizeCount; }
+
+protected:
+ bool eventFilter(QObject *o, QEvent *event) override
+ {
+ Q_UNUSED(o);
+ if (event->type() == QEvent::Resize)
+ ++m_resizeCount;
+ return false;
+ }
+
+private:
+ int m_resizeCount = 0;
+};
+#endif
+
void tst_QMenuBar::taskQTBUG11823_crashwithInvisibleActions()
{
if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive))
QSKIP("Wayland: This fails. Figure out why.");
QMenuBar menubar;
+#ifdef Q_OS_LINUX
+ ResizeCounter counter(&menubar);
+#endif
menubar.setNativeMenuBar(false); //we can't check the geometry of native menubars
QAction * m = menubar.addAction( "&m" );
@@ -1247,6 +1276,12 @@ void tst_QMenuBar::taskQTBUG11823_crashwithInvisibleActions()
centerOnScreen(&menubar);
menubar.show();
QVERIFY(QTest::qWaitForWindowActive(&menubar));
+
+#ifdef Q_OS_LINUX
+ if (QSysInfo::productType().contains("opensuse"))
+ QVERIFY(QTest::qWaitFor([&]{ return counter.resizeCount() == 2;}));
+#endif
+
menubar.setActiveAction(m);
QCOMPARE(menubar.activeAction(), m);
QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Right);