diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2016-05-24 13:38:10 +0200 |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2016-05-25 08:07:03 +0000 |
commit | 441baca74eba3cfcb6a63b0a63be54e6a038fba7 (patch) | |
tree | 0ca6126e99659f156a1a224929efeedc82082aa8 | |
parent | ba87f2a375b33564ea2b6484d2c22a37ff979804 (diff) |
Fix tst_qquicktext::lineLaidOutRelayout() with > 1 font
When more than one font is needed to display the text in the layout,
then the line height of the layout may not be constant. This rewrites
the test to properly handle this case.
Task-number: QTBUG-51934
Change-Id: I0e0cdfdc06b4a39684b33d10efdd58f98dea06b8
Reviewed-by: Tony Sarajärvi <tony.sarajarvi@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
-rw-r--r-- | tests/auto/quick/qquicktext/tst_qquicktext.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/tests/auto/quick/qquicktext/tst_qquicktext.cpp b/tests/auto/quick/qquicktext/tst_qquicktext.cpp index 0e8811bb17..50c75046a6 100644 --- a/tests/auto/quick/qquicktext/tst_qquicktext.cpp +++ b/tests/auto/quick/qquicktext/tst_qquicktext.cpp @@ -2772,18 +2772,19 @@ void tst_qquicktext::lineLaidOutRelayout() QVERIFY(!textPrivate->extra.isAllocated()); - qreal maxH = 0; + qreal y = 0.0; for (int i = 0; i < textPrivate->layout.lineCount(); ++i) { QTextLine line = textPrivate->layout.lineAt(i); const QRectF r = line.rect(); - const qreal h = line.height(); if (r.x() == 0) { - QCOMPARE(r.y(), i * h); - maxH = qMax(maxH, r.y() + h); + QCOMPARE(r.y(), y); } else { + if (qFuzzyIsNull(r.y())) + y = 0.0; QCOMPARE(r.x(), myText->width() / 2); - QCOMPARE(r.y(), i * h - maxH); + QCOMPARE(r.y(), y); } + y += line.height(); } delete window; |