tst_QWidget::translucentWidget(): Pass with High DPI scaling enabled

Since 9c8d1ca18b, 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 <oliver.wolff@qt.io>
This commit is contained in:
Friedemann Kleint 2019-09-12 09:12:17 +02:00
parent 9c76b82885
commit d20bacbb4c

View File

@ -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());