From c4ef0b92d5fb2c621e880347bd48d01b6f31eb24 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 19 Mar 2020 14:24:41 +0100 Subject: [PATCH] Expect failure in QLabel test for certain condition While investigating QTBUG-80554, it was discovered that a small mismatch in how heights are calculated in QTextDocument and QPainter will cause the tst_QLabel::sizeHint() autotest to fail if ceil(ascent+descent+leading) is higher than ceil(ascent+descent). This is currently blocking the fix for QTBUG-80554, because this exposes the bug by detecting the correct leading for a font where we previously ignored it. Task-number: QTBUG-82954 Change-Id: I99323c8e1a0fa281aa8d754ba71432468fcb2d4c Reviewed-by: Qt CI Bot Reviewed-by: Lars Knoll --- tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp b/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp index 7760e12cca..eb34a5ad4e 100644 --- a/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp +++ b/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp @@ -38,6 +38,8 @@ #include #include #include +#include +#include #include class Widget : public QWidget @@ -373,8 +375,16 @@ void tst_QLabel::sizeHint() l1.setAlignment(Qt::AlignVCenter); l1.setTextInteractionFlags(Qt::TextSelectableByMouse); // will now use qtextcontrol int h1 = l1.sizeHint().height(); - QCOMPARE(h1, h); + QFontMetricsF fontMetrics(QApplication::font()); + qreal leading = fontMetrics.leading(); + qreal ascent = fontMetrics.ascent(); + qreal descent = fontMetrics.descent(); + + bool leadingOverflow = qCeil(ascent + descent) < qCeil(ascent + descent + leading); + if (leadingOverflow) + QEXPECT_FAIL("", "See QTBUG-82954", Continue); + QCOMPARE(h1, h); } void tst_QLabel::task226479_movieResize()