diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2020-03-19 14:24:41 +0100 |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2020-03-24 08:19:11 +0100 |
commit | c4ef0b92d5fb2c621e880347bd48d01b6f31eb24 (patch) | |
tree | d4efd97767d4c4e1a41ab0765bbdc7efacdbde10 /tests/auto/widgets/widgets | |
parent | 7c3700c070822674ffc61b080e43fbe956cf439b (diff) |
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 <qt_ci_bot@qt-project.org>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'tests/auto/widgets/widgets')
-rw-r--r-- | tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
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 <qmovie.h> #include <qpicture.h> #include <qmessagebox.h> +#include <qfontmetrics.h> +#include <qmath.h> #include <private/qlabel_p.h> 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() |