summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2019-05-14 14:20:08 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2019-05-29 12:52:51 +0200
commit15d73a9f479e88af85944119e79d88ed26d4f346 (patch)
tree2821659f7d8c277edd8b92dd9d1f2e163c994aa6 /tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp
parent9a47768b46f5e5eed407b70dfa9183fa1d21e242 (diff)
Qt Widgets: Make tests pass on High DPI screens and scaling
Use the comparison helpers to do fuzzy checking of geometries. Change-Id: I00f4403f3bca2e8a3996e938a85ba799e083058c Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp')
-rw-r--r--tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp b/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp
index aa11ed709f..961c8aa4ad 100644
--- a/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp
+++ b/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp
@@ -26,6 +26,7 @@
**
****************************************************************************/
+#include "../../../shared/highdpi.h"
#include <QtTest/QtTest>
@@ -51,6 +52,8 @@
#include <QPlainTextEdit>
#include <QDialog>
+#include <qscreen.h>
+
#include <QtWidgets/private/qabstractitemdelegate_p.h>
Q_DECLARE_METATYPE(QAbstractItemDelegate::EndEditHint)
@@ -223,8 +226,8 @@ private slots:
void dateTextForRole_data();
void dateTextForRole();
-#ifdef QT_BUILD_INTERNAL
private:
+#ifdef QT_BUILD_INTERNAL
struct RoleDelegate : public QItemDelegate
{
QString textForRole(Qt::ItemDataRole role, const QVariant &value, const QLocale &locale)
@@ -234,6 +237,8 @@ private:
}
};
#endif
+
+ const int m_fuzz = int(QGuiApplication::primaryScreen()->devicePixelRatio());
};
@@ -286,8 +291,8 @@ void tst_QItemDelegate::textRectangle()
QFont font;
TestItemDelegate delegate;
QRect result = delegate.textRectangle(0, rect, font, text);
-
- QCOMPARE(result, expected);
+ QVERIFY2(HighDpi::fuzzyCompare(result, expected, m_fuzz),
+ HighDpi::msgRectMismatch(result, expected).constData());
}
void tst_QItemDelegate::sizeHint_data()