tst_QWidgetRepaintManager::staticContents: Trigger resize via QWindow

QWidgetPrivate::setGeometry_sys wrongly triggers full update, which is
why the test was QEXPECT_FAIL, even on Windows, which does implement
static contents.

We can test the behavior without involving the broken QWidget behavior
by resizing the QWindow instead, which triggers a resize of the platform
window and will be fed back through QWSI, similar to when the user
resizes the window via the window frame.

The QEXPECT_FAIL message for the QWidget resize has been updated to
reflect why it's expected to fail.

tst_QWidget::optimizedResize_topLevel() has similar issues to this
test, and solves it by using Window specific platform code. For now
this test has been left alone, as there are a lot more going on in
that test in terms of workarounds and blacklistings, so it needs
further investigations.

Change-Id: I28a55c0723b3e7f16b362d1ebc369e038d5a7ac4
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit ea0cf4a9a2535110d6cf325e75537b4618a7374f)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Tor Arne Vestbø 2024-02-12 11:33:10 +01:00 committed by Qt Cherry-pick Bot
parent cb1f28aef3
commit 6ff8306403

View File

@ -433,12 +433,18 @@ void tst_QWidgetRepaintManager::staticContents()
widget.setAttribute(Qt::WA_StaticContents);
widget.initialShow();
const QSize oldSize = widget.size();
widget.resize(widget.width() + 10, widget.height());
// Trigger resize via QWindow (similar to QWSI code path)
QVERIFY(widget.windowHandle());
QSize oldSize = widget.size();
widget.windowHandle()->resize(widget.width(), widget.height() + 10);
QVERIFY(widget.waitForPainted());
QEXPECT_FAIL("", "This should just repaint the newly exposed region", Continue);
QCOMPARE(widget.takePaintedRegions(), QRegion(0, oldSize.width(), widget.width(), 10));
// Trigger resize via QWidget
oldSize = widget.size();
widget.resize(widget.width() + 10, widget.height());
QVERIFY(widget.waitForPainted());
QEXPECT_FAIL("", "QWidgetPrivate::setGeometry_sys wrongly triggers full update", Continue);
QCOMPARE(widget.takePaintedRegions(), QRegion(oldSize.width(), 0, 10, widget.height()));
}