summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp')
-rw-r--r--tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp
index 43aec651fe..f5d9433f70 100644
--- a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp
+++ b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp
@@ -33,6 +33,7 @@
#include <QMetaObject>
#include <private/qstylesheetstyle_p.h>
+#include <private/qhighdpiscaling_p.h>
#include <QtTest/private/qtesthelpers_p.h>
using namespace QTestPrivate;
@@ -101,6 +102,9 @@ private slots:
void styleSheetTargetAttribute();
void unpolish();
+ void highdpiImages_data();
+ void highdpiImages();
+
private:
QColor COLOR(const QWidget& w) {
w.ensurePolished();
@@ -2066,6 +2070,35 @@ void tst_QStyleSheetStyle::unpolish()
QCOMPARE(w.minimumWidth(), 0);
}
+void tst_QStyleSheetStyle::highdpiImages_data()
+{
+ QTest::addColumn<qreal>("screenFactor");
+ QTest::addColumn<QColor>("color");
+
+ QTest::newRow("highdpi") << 2.0 << QColor(0x00, 0xFF, 0x00);
+ QTest::newRow("lowdpi") << 1.0 << QColor(0xFF, 0x00, 0x00);
+}
+
+void tst_QStyleSheetStyle::highdpiImages()
+{
+ QFETCH(qreal, screenFactor);
+ QFETCH(QColor, color);
+
+ QWidget w;
+ QScreen *screen = QGuiApplication::screenAt(w.pos());
+ QHighDpiScaling::setScreenFactor(screen, screenFactor);
+ w.setStyleSheet("QWidget { background-image: url(\":/images/testimage.png\"); }");
+ w.show();
+
+ QVERIFY(QTest::qWaitForWindowExposed(&w));
+ QImage image(w.size(), QImage::Format_ARGB32);
+ w.render(&image);
+ QVERIFY(testForColors(image, color));
+
+ QHighDpiScaling::setScreenFactor(screen, 1.0);
+ QHighDpiScaling::updateHighDpiScaling(); // reset to normal
+}
+
QTEST_MAIN(tst_QStyleSheetStyle)
#include "tst_qstylesheetstyle.moc"