summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp')
-rw-r--r--tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp21
1 files changed, 18 insertions, 3 deletions
diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
index 1a9d7ec4d2..3183fc7375 100644
--- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
+++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
@@ -3030,8 +3030,23 @@ protected:
QSize sizeHint() const { return QSize(500, 500); }
};
+// Scale to remove devicePixelRatio should scaling be active.
+static QPixmap grabFromWidget(QWidget *w, const QRect &rect)
+{
+ QPixmap pixmap = w->grab(rect);
+ const qreal devicePixelRatio = pixmap.devicePixelRatioF();
+ if (!qFuzzyCompare(devicePixelRatio, qreal(1))) {
+ pixmap = pixmap.scaled((QSizeF(pixmap.size()) / devicePixelRatio).toSize(),
+ Qt::KeepAspectRatio, Qt::SmoothTransformation);
+ pixmap.setDevicePixelRatio(1);
+ }
+ return pixmap;
+}
+
void tst_QWidget::testContentsPropagation()
{
+ if (!qFuzzyCompare(qApp->devicePixelRatio(), qreal(1)))
+ QSKIP("This test does not work with scaling.");
ContentsPropagationWidget widget;
widget.setFixedSize(500, 500);
widget.setContentsPropagation(false);
@@ -9203,7 +9218,7 @@ void tst_QWidget::rectOutsideCoordinatesLimit_task144779()
QPixmap correct(main.size());
correct.fill(Qt::green);
- const QPixmap mainPixmap = main.grab(QRect(QPoint(0, 0), QSize(-1, -1)));
+ const QPixmap mainPixmap = grabFromWidget(&main, QRect(QPoint(0, 0), QSize(-1, -1)));
QTRY_COMPARE(mainPixmap.toImage().convertToFormat(QImage::Format_RGB32),
correct.toImage().convertToFormat(QImage::Format_RGB32));
@@ -9667,10 +9682,10 @@ void tst_QWidget::grab()
p.drawTiledPixmap(0, 0, 128, 128, pal.brush(QPalette::Window).texture(), 0, 0);
p.end();
- QPixmap actual = widget.grab(QRect(64, 64, 64, 64));
+ QPixmap actual = grabFromWidget(&widget, QRect(64, 64, 64, 64));
QVERIFY(lenientCompare(actual, expected));
- actual = widget.grab(QRect(64, 64, -1, -1));
+ actual = grabFromWidget(&widget, QRect(64, 64, -1, -1));
QVERIFY(lenientCompare(actual, expected));
// Make sure a widget that is not yet shown is grabbed correctly.