diff options
author | Martin Jones <martin.jones@nokia.com> | 2011-03-21 06:27:45 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2011-03-21 22:34:49 (GMT) |
commit | b888c9cca5ba2994344533c7602d22e1bc8e5db3 (patch) | |
tree | 576508bb9cf7865ea31fc8c2b9d5a5d4d0c42f28 /tests | |
parent | 521a13e3f0a66c31bbf95304de3c7384042a39aa (diff) | |
download | Qt-b888c9cca5ba2994344533c7602d22e1bc8e5db3.zip Qt-b888c9cca5ba2994344533c7602d22e1bc8e5db3.tar.gz Qt-b888c9cca5ba2994344533c7602d22e1bc8e5db3.tar.bz2 |
Text bounding rect calculated incorrectly if non-top aligned.
QRect::setY() affects the size of the rectangle, so the height of
the bounding rect was too small. Use moveTop() instead, which does
not affect the size of the rectangle.
Change-Id: If41ba6a28c9a7370f054dab20995a198f822ae2b
Task-number: QTBUG-18194
Reviewed-by: Bea Lam
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp index 581b58c..ca6e87a 100644 --- a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp +++ b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp @@ -658,6 +658,24 @@ void tst_qdeclarativetext::verticalAlignment() } } + //confirm that bounding rect is correctly positioned. + QString componentStr = "import QtQuick 1.0\nText { height: 80; text: \"Hello\" }"; + QDeclarativeComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create()); + QVERIFY(textObject != 0); + QRectF br = textObject->boundingRect(); + QVERIFY(br.y() == 0); + + textObject->setVAlign(QDeclarativeText::AlignVCenter); + br = textObject->boundingRect(); + QCOMPARE(qFloor(br.y()), qFloor((80.0 - br.height())/2)); + + textObject->setVAlign(QDeclarativeText::AlignBottom); + br = textObject->boundingRect(); + QCOMPARE(qFloor(br.y()), qFloor(80.0 - br.height())); + + delete textObject; } void tst_qdeclarativetext::font() |