summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@digia.com>2014-03-13 09:10:47 +0100
committerUlf Hermann <ulf.hermann@qt.io>2018-10-04 07:01:05 +0000
commitd7e274a44621a4c1bb1ede66c00ee1d1e3f7bd13 (patch)
treeeb5d6d64eaad5bf400477e360a49f5cafef9f6b3 /tests
parent0cae5a4c4b3c508463580ba740df95e92d2fc9c0 (diff)
StyleSheetStyle: Load @Nx images
Perform a @Nx image file lookup when loading pixmaps. Make drawBackgroundImage() handle high-dpi pixmaps, here the layout calculations needs to be in device- independent pixels Fixes: QTBUG-36825 Change-Id: I61e6f53c59f61f3bd88c34a036349e51e8c8ad92 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/widgets/styles/qstylesheetstyle/images/testimage.pngbin299 -> 300 bytes
-rw-r--r--tests/auto/widgets/styles/qstylesheetstyle/images/testimage@2x.pngbin0 -> 318 bytes
-rw-r--r--tests/auto/widgets/styles/qstylesheetstyle/resources.qrc1
-rw-r--r--tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp33
4 files changed, 34 insertions, 0 deletions
diff --git a/tests/auto/widgets/styles/qstylesheetstyle/images/testimage.png b/tests/auto/widgets/styles/qstylesheetstyle/images/testimage.png
index 06fb34f0d6..a4adc7a47f 100644
--- a/tests/auto/widgets/styles/qstylesheetstyle/images/testimage.png
+++ b/tests/auto/widgets/styles/qstylesheetstyle/images/testimage.png
Binary files differ
diff --git a/tests/auto/widgets/styles/qstylesheetstyle/images/testimage@2x.png b/tests/auto/widgets/styles/qstylesheetstyle/images/testimage@2x.png
new file mode 100644
index 0000000000..d55f0c507b
--- /dev/null
+++ b/tests/auto/widgets/styles/qstylesheetstyle/images/testimage@2x.png
Binary files differ
diff --git a/tests/auto/widgets/styles/qstylesheetstyle/resources.qrc b/tests/auto/widgets/styles/qstylesheetstyle/resources.qrc
index 248bf80f50..f523070073 100644
--- a/tests/auto/widgets/styles/qstylesheetstyle/resources.qrc
+++ b/tests/auto/widgets/styles/qstylesheetstyle/resources.qrc
@@ -2,5 +2,6 @@
<RCC version="1.0">
<qresource>
<file>images/testimage.png</file>
+ <file>images/testimage@2x.png</file>
</qresource>
</RCC> \ No newline at end of file
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"