summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui/image/qimage
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@digia.com>2015-02-20 14:54:34 +0100
committerMorten Johan Sørvig <morten.sorvig@theqtcompany.com>2015-03-24 11:22:36 +0000
commit72854081b2e3831ab6619a9c2e7f4ba0a6a1d316 (patch)
treea7dd2ac06a07acaf7cfe4fbd6e1cd51e6912fc2b /tests/auto/gui/image/qimage
parent1e8f50a8d069c97ea6a4f00d664c12e594884f54 (diff)
Add tests for detach on setDevicePixelRatio()
Change-Id: I414ff0b794e0202a7f8c931b59b973cb1e7dc148 Reviewed-by: Paul Olav Tvete <paul.tvete@theqtcompany.com>
Diffstat (limited to 'tests/auto/gui/image/qimage')
-rw-r--r--tests/auto/gui/image/qimage/tst_qimage.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp
index decd4ef931..0f9bdc7a1a 100644
--- a/tests/auto/gui/image/qimage/tst_qimage.cpp
+++ b/tests/auto/gui/image/qimage/tst_qimage.cpp
@@ -178,6 +178,8 @@ private slots:
void cleanupFunctions();
+ void devicePixelRatio();
+
private:
const QString m_prefix;
};
@@ -2730,5 +2732,32 @@ void tst_QImage::cleanupFunctions()
}
+// test image devicePixelRatio setting and detaching
+void tst_QImage::devicePixelRatio()
+{
+ // create image
+ QImage a(64, 64, QImage::Format_ARGB32);
+ a.fill(Qt::white);
+ QCOMPARE(a.devicePixelRatio(), qreal(1.0));
+ QCOMPARE(a.isDetached(), true);
+
+ // copy image
+ QImage b = a;
+ QCOMPARE(b.devicePixelRatio(), qreal(1.0));
+ QCOMPARE(a.isDetached(), false);
+ QCOMPARE(b.isDetached(), false);
+
+ // set devicePixelRatio to the current value: does not detach
+ a.setDevicePixelRatio(qreal(1.0));
+ QCOMPARE(a.isDetached(), false);
+ QCOMPARE(b.isDetached(), false);
+
+ // set devicePixelRatio to a new value: may detach (currently
+ // does, but we may want to avoid the data copy the future)
+ a.setDevicePixelRatio(qreal(2.0));
+ QCOMPARE(a.devicePixelRatio(), qreal(2.0));
+ QCOMPARE(b.devicePixelRatio(), qreal(1.0));
+}
+
QTEST_GUILESS_MAIN(tst_QImage)
#include "tst_qimage.moc"