From 441baca74eba3cfcb6a63b0a63be54e6a038fba7 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 24 May 2016 13:38:10 +0200 Subject: Fix tst_qquicktext::lineLaidOutRelayout() with > 1 font MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Simon Hausmann --- tests/auto/quick/qquicktext/tst_qquicktext.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'tests/auto/quick/qquicktext/tst_qquicktext.cpp') 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; -- cgit v1.2.3