summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAlexander Volkov <a.volkov@rusbitech.ru>2019-03-28 16:49:57 +0300
committerAlexander Volkov <a.volkov@rusbitech.ru>2019-04-01 15:21:18 +0000
commit685b8db13aa19e734f239678bae23607fcededbd (patch)
tree0883b9f72f93b6ec2dca9d3f678fdedaa2eecb44 /tests
parent954b73445cfbfef01207d51d1b986c6dd796c6d0 (diff)
Forward devicePixelRatio in QPixmap::mask()
Also add a test checking that devicePixelRatio is forwarded to derivatives of QPixmap. Change-Id: Idb2b3f033ccc0fd49bf54b11f5dffbce5a19b006 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/gui/image/qpixmap/tst_qpixmap.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp
index 9a338ad55a..4d31d80246 100644
--- a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp
+++ b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp
@@ -121,6 +121,7 @@ private slots:
void copy();
void deepCopyPreservesDpr();
+ void dprPassthrough();
void depthOfNullObjects();
void transformed();
@@ -1169,6 +1170,39 @@ void tst_QPixmap::deepCopyPreservesDpr()
QCOMPARE(dest.devicePixelRatio(), dpr);
}
+void tst_QPixmap::dprPassthrough()
+{
+ const qreal dpr = 2;
+ QPixmap src(32, 32);
+ src.setDevicePixelRatio(dpr);
+ src.fill(Qt::transparent);
+ QCOMPARE(src.devicePixelRatio(), dpr);
+
+ QImage img = src.toImage();
+ QCOMPARE(img.devicePixelRatio(), dpr);
+
+ QPixmap pm(1, 1);
+ pm.convertFromImage(img);
+ QCOMPARE(pm.devicePixelRatio(), dpr);
+
+ QBitmap heuristicMask = src.createHeuristicMask();
+ QCOMPARE(heuristicMask.devicePixelRatio(), dpr);
+
+ QBitmap maskFromColor = src.createMaskFromColor(Qt::white);
+ QCOMPARE(maskFromColor.devicePixelRatio(), dpr);
+
+ QBitmap mask = src.mask();
+ QCOMPARE(mask.devicePixelRatio(), dpr);
+
+ QPixmap scaled = src.scaled(16, 16);
+ QCOMPARE(scaled.devicePixelRatio(), dpr);
+
+ QTransform t;
+ t.rotate(90);
+ QPixmap transformed = src.transformed(t);
+ QCOMPARE(transformed.devicePixelRatio(), dpr);
+}
+
void tst_QPixmap::depthOfNullObjects()
{
QBitmap b1;