Fix testcase that fails when run individually

Executing the tst_qgraphicsitem::sorting() testcase individually always
fails on my KDE/X11 desktop. The window never seems to have focus and
the call to qWaitForWindowActive() returns error after a few seconds.

It seems qApp->setActiveWindow(&view) never succeeds in giving focus to
the window containing the widget.

Fixes: QTBUG-105221
Task-number: QTBUG-74760
Change-Id: I148dab09d0fb592376b3902e4ed10799f9a52274
Done-with: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
This commit is contained in:
Dimitrios Apostolou 2022-07-27 17:41:57 +02:00
parent 1022922037
commit dff9fa2ee1

View File

@ -8222,7 +8222,7 @@ void tst_QGraphicsItem::sorting()
view.setFrameStyle(0);
view.show();
if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) {
qApp->setActiveWindow(&view);
view.window()->activateWindow();
QVERIFY(QTest::qWaitForWindowActive(&view));
}
QVERIFY(QTest::qWaitForWindowExposed(&view));