aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquicktext
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2020-04-28 13:34:16 +0200
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2020-04-29 07:56:57 +0200
commitee91c7c23781e4f771c2e8975481420e873386fe (patch)
tree5db5754eb6b994b32fbb43262a5d5beef7ee40f0 /tests/auto/quick/qquicktext
parentac844bb630f6624861d26f650b12d61523c9a985 (diff)
Fix font-related test failures triggered by Qt Base update
Change f761ad3cd9ad1252f24b76ae413298dc7bed8af3 in qtbase exposes a pre-existing difference in measuring the height of QTextLayouts versus QTextDocuments when the leading is large enough to impact the font height. See QTBUG-82954 for details on this. Since the two were assumed to be the same, this change causes a test failure with certain fonts. To work around it, we expect the test failure for the case where the text format is RichText (and QTextDocument is going to be used internally), and we detect that the font exhibits the problem. For TextEdits, QTextDocument is always used, so we also expect failure there. Note that this is equivalent to the fix for the same issue in the QLabel test: c4ef0b92d5fb2c621e880347bd48d01b6f31eb24 Fixes: QTBUG-83839 Task-number: QTBUG-82954 Change-Id: Ic32e0d835480b42b68bb452301ec4bfa6ce30d3a Reviewed-by: Liang Qi <liang.qi@qt.io>
Diffstat (limited to 'tests/auto/quick/qquicktext')
-rw-r--r--tests/auto/quick/qquicktext/tst_qquicktext.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/auto/quick/qquicktext/tst_qquicktext.cpp b/tests/auto/quick/qquicktext/tst_qquicktext.cpp
index 1f132ee266..24c85931ca 100644
--- a/tests/auto/quick/qquicktext/tst_qquicktext.cpp
+++ b/tests/auto/quick/qquicktext/tst_qquicktext.cpp
@@ -2763,6 +2763,15 @@ void tst_qquicktext::boundingRect()
QCOMPARE(text->boundingRect().x(), qreal(0));
QCOMPARE(text->boundingRect().y(), qreal(0));
QCOMPARE(text->boundingRect().width(), line.naturalTextWidth());
+
+ QFontMetricsF fontMetrics(QGuiApplication::font());
+ qreal leading = fontMetrics.leading();
+ qreal ascent = fontMetrics.ascent();
+ qreal descent = fontMetrics.descent();
+
+ bool leadingOverflow = text->textFormat() == QQuickText::RichText && qCeil(ascent + descent) < qCeil(ascent + descent + leading);
+ if (leadingOverflow)
+ QEXPECT_FAIL("", "See QTBUG-82954", Continue);
QCOMPARE(text->boundingRect().height(), line.height());
// the size of the bounding rect shouldn't be bounded by the size of item.
@@ -2770,30 +2779,45 @@ void tst_qquicktext::boundingRect()
QCOMPARE(text->boundingRect().x(), qreal(0));
QCOMPARE(text->boundingRect().y(), qreal(0));
QCOMPARE(text->boundingRect().width(), line.naturalTextWidth());
+
+ if (leadingOverflow)
+ QEXPECT_FAIL("", "See QTBUG-82954", Continue);
QCOMPARE(text->boundingRect().height(), line.height());
text->setHeight(text->height() * 2);
QCOMPARE(text->boundingRect().x(), qreal(0));
QCOMPARE(text->boundingRect().y(), qreal(0));
QCOMPARE(text->boundingRect().width(), line.naturalTextWidth());
+
+ if (leadingOverflow)
+ QEXPECT_FAIL("", "See QTBUG-82954", Continue);
QCOMPARE(text->boundingRect().height(), line.height());
text->setHAlign(QQuickText::AlignRight);
QCOMPARE(text->boundingRect().x(), text->width() - line.naturalTextWidth());
QCOMPARE(text->boundingRect().y(), qreal(0));
QCOMPARE(text->boundingRect().width(), line.naturalTextWidth());
+
+ if (leadingOverflow)
+ QEXPECT_FAIL("", "See QTBUG-82954", Continue);
QCOMPARE(text->boundingRect().height(), line.height());
QQuickItemPrivate::get(text)->setLayoutMirror(true);
QCOMPARE(text->boundingRect().x(), qreal(0));
QCOMPARE(text->boundingRect().y(), qreal(0));
QCOMPARE(text->boundingRect().width(), line.naturalTextWidth());
+
+ if (leadingOverflow)
+ QEXPECT_FAIL("", "See QTBUG-82954", Continue);
QCOMPARE(text->boundingRect().height(), line.height());
text->setHAlign(QQuickText::AlignLeft);
QCOMPARE(text->boundingRect().x(), text->width() - line.naturalTextWidth());
QCOMPARE(text->boundingRect().y(), qreal(0));
QCOMPARE(text->boundingRect().width(), line.naturalTextWidth());
+
+ if (leadingOverflow)
+ QEXPECT_FAIL("", "See QTBUG-82954", Continue);
QCOMPARE(text->boundingRect().height(), line.height());
text->setWrapMode(QQuickText::Wrap);