Fix tst_QWindow::requestUpdate on Wayland

On Wayland there is a special case when decorations are enabled,
where we post an initial update request to ensure widgets are
redrawn after the buffer is recreated (see
af7b60ade5c4be81cbc58eb18307c017d5594071 in qtwayland). To
make sure the test behaves the same on Wayland as on other
platforms, we disable client-side decorations when running
these tests.

The flag is primarily required for the requestUpdate() test
at the moment, but it is only queried once per application
run, so it has to be set before any tests are run.

Pick-to: 6.4
Fixes: QTBUG-100889
Change-Id: Ica6d744083ecae4a3722b6d04b956e7615f0dfe5
Reviewed-by: Inho Lee <inho.lee@qt.io>
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
This commit is contained in:
Eskil Abrahamsen Blomfeldt 2022-06-28 09:29:13 +02:00
parent bf3500a631
commit 20d23f7003

View File

@ -97,6 +97,11 @@ private:
QInputDevice::Capability::Position | QInputDevice::Capability::MouseEmulation);
};
static bool isPlatformWayland()
{
return QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive);
}
void tst_QWindow::initTestCase()
{
// Size of reference window, 200 for < 2000, scale up for larger screens
@ -108,6 +113,10 @@ void tst_QWindow::initTestCase()
if (screenWidth > 2000)
width = 100 * ((screenWidth + 500) / 1000);
m_testWindowSize = QSize(width, width);
// Make sure test runs consistently on all compositors by force-disabling window decorations
if (isPlatformWayland())
qputenv("QT_WAYLAND_DISABLE_WINDOWDECORATION", "1");
}
void tst_QWindow::cleanup()
@ -486,11 +495,6 @@ static QString msgRectMismatch(const QRect &r1, const QRect &r2)
return result;
}
static bool isPlatformWayland()
{
return QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive);
}
void tst_QWindow::positioning()
{
#ifdef Q_OS_ANDROID
@ -2538,8 +2542,6 @@ void tst_QWindow::requestUpdate()
QCoreApplication::processEvents();
QTRY_VERIFY(window.isExposed());
if (isPlatformWayland())
QEXPECT_FAIL("", "Wayland: This fails. See QTBUG-100889.", Abort);
QCOMPARE(window.received(QEvent::UpdateRequest), 0);
window.requestUpdate();