aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquicktext/tst_qquicktext.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/quick/qquicktext/tst_qquicktext.cpp')
-rw-r--r--tests/auto/quick/qquicktext/tst_qquicktext.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/tests/auto/quick/qquicktext/tst_qquicktext.cpp b/tests/auto/quick/qquicktext/tst_qquicktext.cpp
index d1716c20da..6c257e0a9d 100644
--- a/tests/auto/quick/qquicktext/tst_qquicktext.cpp
+++ b/tests/auto/quick/qquicktext/tst_qquicktext.cpp
@@ -2293,8 +2293,12 @@ void tst_qquicktext::lineHeight()
QCOMPARE(myText->lineHeightMode(), QQuickText::ProportionalHeight);
qreal h = myText->height();
+ QVERIFY(myText->lineCount() != 0);
+ const qreal h1stLine = h / myText->lineCount();
+
myText->setLineHeight(1.5);
QCOMPARE(myText->height(), qreal(qCeil(h)) * 1.5);
+ QCOMPARE(myText->contentHeight(), qreal(qCeil(h)) * 1.5);
myText->setLineHeightMode(QQuickText::FixedHeight);
myText->setLineHeight(20);
@@ -2306,11 +2310,21 @@ void tst_qquicktext::lineHeight()
qreal h2 = myText->height();
myText->setLineHeight(2.0);
- QVERIFY(myText->height() == h2 * 2.0);
+ QCOMPARE(myText->height(), h2 * 2.0);
myText->setLineHeightMode(QQuickText::FixedHeight);
myText->setLineHeight(10);
- QCOMPARE(myText->height(), myText->lineCount() * 10.0);
+ QVERIFY(myText->lineCount() > 1);
+ QCOMPARE(myText->height(), h1stLine + (myText->lineCount() - 1) * 10.0);
+ QCOMPARE(myText->contentHeight(), h1stLine + (myText->lineCount() - 1) * 10.0);
+ QCOMPARE(myText->implicitHeight(), h1stLine + (myText->lineCount() - 1) * 10.0);
+
+ myText->setLineHeightMode(QQuickText::ProportionalHeight);
+ myText->setLineHeight(0.5);
+ const qreal reducedHeight = h1stLine + (myText->lineCount() - 1) * h1stLine * 0.5;
+ QVERIFY(qAbs(myText->height() - reducedHeight) < 1.0); // allow a deviation of one pixel because the exact height depends on the font.
+ QVERIFY(qAbs(myText->contentHeight() - reducedHeight) < 1.0);
+ QVERIFY(qAbs(myText->implicitHeight() - reducedHeight) < 1.0);
}
void tst_qquicktext::implicitSize_data()