summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets
diff options
context:
space:
mode:
authorDaniel Vrátil <daniel.vratil@kdab.com>2016-11-07 09:40:34 +0100
committerDaniel Vrátil <daniel.vratil@kdab.com>2016-11-09 09:09:26 +0000
commit9de3b15d07dcf1be5ff7b26e2e7987ed8e91a0ce (patch)
tree56c996c7866752e1cc438819dfbab1eacc6cbad2 /tests/auto/widgets
parentc83ba01f7bc542368973f3f24dfb59c6052dd78a (diff)
QLabel: take DPR of QMovie in account when calculating sizeHint
QLabel already does that for QPixmap, so just do the same for QMovie's current pixmap. Task-number: QTBUG-48157 Change-Id: I7b26460f778e56ff017a5efd433f8929f30e4b41 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Diffstat (limited to 'tests/auto/widgets')
-rw-r--r--tests/auto/widgets/widgets/qlabel/red@2x.pngbin0 -> 105 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp24
2 files changed, 24 insertions, 0 deletions
diff --git a/tests/auto/widgets/widgets/qlabel/red@2x.png b/tests/auto/widgets/widgets/qlabel/red@2x.png
new file mode 100644
index 0000000000..4a843e744f
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/red@2x.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp b/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp
index d76dbf6b46..2b2756fef3 100644
--- a/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp
+++ b/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp
@@ -101,6 +101,9 @@ private Q_SLOTS:
void taskQTBUG_7902_contextMenuCrash();
#endif
+ void taskQTBUG_48157_dprPixmap();
+ void taskQTBUG_48157_dprMovie();
+
private:
QLabel *testWidget;
QPointer<Widget> test_box;
@@ -546,5 +549,26 @@ void tst_QLabel::taskQTBUG_7902_contextMenuCrash()
}
#endif
+void tst_QLabel::taskQTBUG_48157_dprPixmap()
+{
+ QLabel label;
+ QPixmap pixmap;
+ pixmap.load(QFINDTESTDATA(QStringLiteral("red@2x.png")));
+ QCOMPARE(pixmap.devicePixelRatio(), 2.0);
+ label.setPixmap(pixmap);
+ QCOMPARE(label.sizeHint(), pixmap.rect().size() / pixmap.devicePixelRatio());
+}
+
+void tst_QLabel::taskQTBUG_48157_dprMovie()
+{
+ QLabel label;
+ QMovie movie;
+ movie.setFileName(QFINDTESTDATA(QStringLiteral("red@2x.png")));
+ movie.start();
+ QCOMPARE(movie.currentPixmap().devicePixelRatio(), 2.0);
+ label.setMovie(&movie);
+ QCOMPARE(label.sizeHint(), movie.currentPixmap().size() / movie.currentPixmap().devicePixelRatio());
+}
+
QTEST_MAIN(tst_QLabel)
#include "tst_qlabel.moc"