From d20bacbb4cedf012566ce0020f9e53a7c1ecbe5f Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 12 Sep 2019 09:12:17 +0200 Subject: [PATCH] tst_QWidget::translucentWidget(): Pass with High DPI scaling enabled Since 9c8d1ca18b48dbcc89dda1b9bacdf7d49c7fc754, the test would fail when High DPI scaling is enabled: FAIL! : tst_QWidget::translucentWidget() Compared QImages differ in device pixel ratio. Actual (actual): 2 Expected (expected): 1 .\tst_qwidget.cpp(8913) : failure location Set the device pixel ratio on the expected pixmap to fix this. Change-Id: I517495931c2c6b1f49125bb4b5836e304bdbf545 Reviewed-by: Oliver Wolff --- tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 1724d3ce8c..3e372b76f5 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -8906,7 +8906,8 @@ void tst_QWidget::translucentWidget() widgetSnapshot = label.grab(QRect(QPoint(0, 0), label.size())); #endif const QImage actual = widgetSnapshot.toImage().convertToFormat(QImage::Format_RGB32); - const QImage expected = pm.toImage().scaled(label.devicePixelRatioF() * pm.size()); + QImage expected = pm.toImage().scaled(label.devicePixelRatioF() * pm.size()); + expected.setDevicePixelRatio(label.devicePixelRatioF()); if (m_platform == QStringLiteral("winrt")) QEXPECT_FAIL("", "WinRT: This fails. QTBUG-68297.", Abort); QCOMPARE(actual.size(),expected.size());