summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/kernel
diff options
context:
space:
mode:
authorAxel Spoerl <axel.spoerl@qt.io>2022-11-29 16:37:11 +0100
committerAxel Spoerl <axel.spoerl@qt.io>2022-11-30 14:48:51 +0100
commit58b1984efc99d96a56f97bb9156a8c0f245b71ca (patch)
tree824a2790f7aac5327db771d80c8dc408aa6e0f89 /tests/auto/widgets/kernel
parent8071e3c2af77dbf77dd316e9b13b739f3835c3c4 (diff)
Stabilize tst_QWidgetRepaintManager on XCB platforms
When a widget's palette has different brushes in Active / Inactive color groups, or it is pixmap based, multiple paint events are triggered. This leads to unpredictable, double entries in QWidgetRepaintManager::dirtyWidgetList(). This patch overrides event() of all test widgets and ignores activation / deactivation events in order to make the entries of QWidgetRepaintManager::dirtyWidgetList() predictable. Pick-to: 6.4 Change-Id: I164d7ab4148551590ac3c50fcc3b9f98c5ac0535 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'tests/auto/widgets/kernel')
-rw-r--r--tests/auto/widgets/kernel/qwidgetrepaintmanager/tst_qwidgetrepaintmanager.cpp41
1 files changed, 37 insertions, 4 deletions
diff --git a/tests/auto/widgets/kernel/qwidgetrepaintmanager/tst_qwidgetrepaintmanager.cpp b/tests/auto/widgets/kernel/qwidgetrepaintmanager/tst_qwidgetrepaintmanager.cpp
index 93da87c4df..f53d5aeb05 100644
--- a/tests/auto/widgets/kernel/qwidgetrepaintmanager/tst_qwidgetrepaintmanager.cpp
+++ b/tests/auto/widgets/kernel/qwidgetrepaintmanager/tst_qwidgetrepaintmanager.cpp
@@ -70,6 +70,14 @@ public:
}
QRegion paintedRegions;
+ bool event(QEvent *event) override
+ {
+ const auto type = event->type();
+ if (type == QEvent::WindowActivate || type == QEvent::WindowDeactivate)
+ return true;
+ return QWidget::event(event);
+ }
+
protected:
void paintEvent(QPaintEvent *event) override
{
@@ -90,6 +98,14 @@ public:
setAttribute(Qt::WA_OpaquePaintEvent);
}
+ bool event(QEvent *event) override
+ {
+ const auto type = event->type();
+ if (type == QEvent::WindowActivate || type == QEvent::WindowDeactivate)
+ return true;
+ return QWidget::event(event);
+ }
+
protected:
void paintEvent(QPaintEvent *e) override
{
@@ -205,6 +221,14 @@ public:
QSize sizeHint() const override { return QSize(400, 400); }
+ bool event(QEvent *event) override
+ {
+ const auto type = event->type();
+ if (type == QEvent::WindowActivate || type == QEvent::WindowDeactivate)
+ return true;
+ return QWidget::event(event);
+ }
+
protected:
void resizeEvent(QResizeEvent *) override
{
@@ -245,13 +269,14 @@ protected:
*/
bool compareWidget(QWidget *w)
{
+ QBackingStore *backingStore = w->window()->backingStore();
+ Q_ASSERT(backingStore && backingStore->handle());
+ QPlatformBackingStore *platformBackingStore = backingStore->handle();
+
if (!waitForFlush(w)) {
qWarning() << "Widget" << w << "failed to flush";
return false;
}
- QBackingStore *backingStore = w->window()->backingStore();
- Q_ASSERT(backingStore && backingStore->handle());
- QPlatformBackingStore *platformBackingStore = backingStore->handle();
QImage backingstoreContent = platformBackingStore->toImage();
if (!w->isWindow()) {
@@ -278,7 +303,14 @@ protected:
}
bool waitForFlush(QWidget *widget) const
{
+ if (!widget)
+ return true;
+
auto *repaintManager = QWidgetPrivate::get(widget->window())->maybeRepaintManager();
+
+ if (!repaintManager)
+ return true;
+
return QTest::qWaitFor([repaintManager]{ return !repaintManager->isDirty(); } );
};
#endif // QT_BUILD_INTERNAL
@@ -301,7 +333,7 @@ void tst_QWidgetRepaintManager::initTestCase()
QVERIFY(QTest::qWaitForWindowExposed(&widget));
m_implementsScroll = widget.backingStore()->handle()->scroll(QRegion(widget.rect()), 1, 1);
- qDebug() << QGuiApplication::platformName() << "QPA backend implements scroll:" << m_implementsScroll;
+ qInfo() << QGuiApplication::platformName() << "QPA backend implements scroll:" << m_implementsScroll;
}
void tst_QWidgetRepaintManager::cleanup()
@@ -614,6 +646,7 @@ void tst_QWidgetRepaintManager::fastMove()
QCOMPARE(dirtyRegion(scene.yellowChild), QRect(0, 0, 100, 100));
}
QCOMPARE(dirtyRegion(&scene), QRect(0, 0, 25, 100));
+ QTRY_VERIFY(dirtyRegion(&scene).isEmpty());
QVERIFY(compareWidget(&scene));
}