From 9de3b15d07dcf1be5ff7b26e2e7987ed8e91a0ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Vr=C3=A1til?= Date: Mon, 7 Nov 2016 09:40:34 +0100 Subject: QLabel: take DPR of QMovie in account when calculating sizeHint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Morten Johan Sørvig --- tests/auto/widgets/widgets/qlabel/red@2x.png | Bin 0 -> 105 bytes tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp | 24 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 tests/auto/widgets/widgets/qlabel/red@2x.png (limited to 'tests/auto/widgets') 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 Binary files /dev/null and b/tests/auto/widgets/widgets/qlabel/red@2x.png 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 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" -- cgit v1.2.3 From d91bf00c43736940e4139357e288df6432775a3d Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 8 Jun 2016 12:06:29 +0200 Subject: tst_QFileSystemModel::specialFiles(): Remove Windows parts The test created a Windows shortcut (.lnk) and checked on its existence. It was not found in the first test since QFileSystemModel returned the resolved file name (linktarget.txt). When fixing this by querying QFileSystemModel::fileInfo()::fileName(), the 2nd test failed since shortcut files are not considered system files. Amends change 3b093034b638a69b4dc91212d1743638864a1337. Task-number: QTBUG-53890 Task-number: QTBUG-20968 Task-number: QTBUG-29403 Change-Id: Iec58b52532b44d12759eaa6c8d63a8a4dc8d1bc3 Reviewed-by: Joerg Bornemann --- .../dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) (limited to 'tests/auto/widgets') diff --git a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp index af92f0735d..cb0f0b040a 100644 --- a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp +++ b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp @@ -1097,6 +1097,10 @@ static QSet fileListUnderIndex(const QFileSystemModel *model, const QMo void tst_QFileSystemModel::specialFiles() { +#ifndef Q_OS_UNIX + QSKIP("Not implemented"); +#endif + QFileSystemModel model; model.setFilter(QDir::AllEntries | QDir::System | QDir::Hidden); @@ -1105,23 +1109,8 @@ void tst_QFileSystemModel::specialFiles() // as it will always return a valid index for existing files, // even if the file is not visible with the given filter. -#if defined(Q_OS_UNIX) const QModelIndex rootIndex = model.setRootPath(QStringLiteral("/dev/")); const QString testFileName = QStringLiteral("null"); -#elif defined(Q_OS_WIN) - const QModelIndex rootIndex = model.setRootPath(flatDirTestPath); - - const QString testFileName = QStringLiteral("linkSource.lnk"); - - QFile file(flatDirTestPath + QLatin1String("/linkTarget.txt")); - QVERIFY(file.open(QIODevice::WriteOnly)); - file.close(); - QVERIFY(file.link(flatDirTestPath + '/' + testFileName)); -#else - QSKIP("Not implemented"); - QModelIndex rootIndex; - QString testFileName; -#endif QTRY_VERIFY(fileListUnderIndex(&model, rootIndex).contains(testFileName)); -- cgit v1.2.3