summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorYann Bodson <yann.bodson@nokia.com>2011-01-28 01:58:10 (GMT)
committerYann Bodson <yann.bodson@nokia.com>2011-01-28 04:12:00 (GMT)
commit7c1ab9b6a8e1b3d64c08a4f5067448884b068945 (patch)
tree2b3d3f787f42e2558e8f26475c2114e6d4b28704 /tests/auto
parent64c0ee4e5f1f05105ab6168ebb4cb188e8fd838f (diff)
downloadQt-7c1ab9b6a8e1b3d64c08a4f5067448884b068945.zip
Qt-7c1ab9b6a8e1b3d64c08a4f5067448884b068945.tar.gz
Qt-7c1ab9b6a8e1b3d64c08a4f5067448884b068945.tar.bz2
Add support for line spacing in Text element.
This change adds the lineHeight and lineHeightMode properties. Task-number: QTBUG-14296 Reviewed-by: Martin Jones
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/declarative/qdeclarativetext/data/lineHeight.qml15
-rw-r--r--tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp32
2 files changed, 47 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativetext/data/lineHeight.qml b/tests/auto/declarative/qdeclarativetext/data/lineHeight.qml
new file mode 100644
index 0000000..851d871
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetext/data/lineHeight.qml
@@ -0,0 +1,15 @@
+import QtQuick 1.1
+
+Item {
+ width: 200
+ height: 200
+
+ Text {
+ id: myText
+ objectName: "myText"
+ width: 200
+ wrapMode: Text.WordWrap
+ font.pixelSize: 13
+ text: "Lorem ipsum sit amet, consectetur adipiscing elit. Integer felis nisl, varius in pretium nec, venenatis non erat. Proin lobortis interdum dictum."
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp
index c9b5295..b96fbff 100644
--- a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp
+++ b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp
@@ -81,6 +81,7 @@ private slots:
void embeddedImages();
void lineCount();
+ void lineHeight();
// ### these tests may be trivial
void horizontalAlignment();
@@ -1082,6 +1083,37 @@ void tst_qdeclarativetext::lineCount()
QCOMPARE(myText->maximumLineCount(), 2);
}
+void tst_qdeclarativetext::lineHeight()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/lineHeight.qml");
+
+ QDeclarativeText *myText = canvas->rootObject()->findChild<QDeclarativeText*>("myText");
+ QVERIFY(myText != 0);
+
+ QVERIFY(myText->lineHeight() == 1);
+ QVERIFY(myText->lineHeightMode() == QDeclarativeText::MultiplyHeight);
+
+ qreal h = myText->height();
+ myText->setLineHeight(1.5);
+ QVERIFY(myText->height() == h * 1.5);
+
+ myText->setLineHeightMode(QDeclarativeText::PixelHeight);
+ myText->setLineHeight(20);
+ QCOMPARE(myText->height(), 120.0);
+
+ myText->setText("Lorem ipsum sit <b>amet</b>, consectetur adipiscing elit. Integer felis nisl, varius in pretium nec, venenatis non erat. Proin lobortis interdum dictum.");
+ myText->setLineHeightMode(QDeclarativeText::MultiplyHeight);
+ myText->setLineHeight(1);
+
+ qreal h2 = myText->height();
+ myText->setLineHeight(1.25);
+ QVERIFY(myText->height() == h2 * 1.25);
+
+ myText->setLineHeightMode(QDeclarativeText::PixelHeight);
+ myText->setLineHeight(10);
+ QCOMPARE(myText->height(), 60.0);
+}
+
void tst_qdeclarativetext::implicitSize_data()
{
QTest::addColumn<QString>("text");