aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2011-11-28 15:32:31 +1000
committerQt by Nokia <qt-info@nokia.com>2011-11-28 07:45:43 +0100
commit7d4a187bc7537b1f6d441aabc1bbcffafd7017e7 (patch)
treeb83e4b2c78e5cc4bfe7795245e21ee6d56423752 /tests
parentfb237da846785b72df25c3c9e7e25d377ea308e0 (diff)
Fix multiline eliding and support eliding when height is set.
Task-number: QTBUG-22920, QTBUG-22116 Change-Id: Ibe78ce1b0b438eec32955b986a8740f173cd082f Reviewed-by: Yann Bodson <yann.bodson@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/qquicktext/data/multilineelide.qml10
-rw-r--r--tests/auto/declarative/qquicktext/tst_qquicktext.cpp44
2 files changed, 54 insertions, 0 deletions
diff --git a/tests/auto/declarative/qquicktext/data/multilineelide.qml b/tests/auto/declarative/qquicktext/data/multilineelide.qml
new file mode 100644
index 0000000000..23398a84a1
--- /dev/null
+++ b/tests/auto/declarative/qquicktext/data/multilineelide.qml
@@ -0,0 +1,10 @@
+import QtQuick 2.0
+
+Text {
+ width: 200; height: 200
+ wrapMode: Text.WordWrap
+ elide: Text.ElideRight
+ maximumLineCount: 3
+ text: "the quick brown fox jumped over the lazy dog the quick brown fox jumped over the lazy dog"
+}
+
diff --git a/tests/auto/declarative/qquicktext/tst_qquicktext.cpp b/tests/auto/declarative/qquicktext/tst_qquicktext.cpp
index 88ac3126d3..fb37357608 100644
--- a/tests/auto/declarative/qquicktext/tst_qquicktext.cpp
+++ b/tests/auto/declarative/qquicktext/tst_qquicktext.cpp
@@ -70,6 +70,7 @@ private slots:
void width();
void wrap();
void elide();
+ void multilineElide();
void textFormat();
void alignments_data();
@@ -448,6 +449,49 @@ void tst_qquicktext::elide()
}
}
+void tst_qquicktext::multilineElide()
+{
+ QQuickView *canvas = createView(TESTDATA("multilineelide.qml"));
+
+ QQuickText *myText = qobject_cast<QQuickText*>(canvas->rootObject());
+ QVERIFY(myText != 0);
+
+ QCOMPARE(myText->lineCount(), 3);
+ QCOMPARE(myText->truncated(), true);
+
+ qreal lineHeight = myText->paintedHeight() / 3.;
+
+ // reduce size and ensure fewer lines are drawn
+ myText->setHeight(lineHeight * 2);
+ QCOMPARE(myText->lineCount(), 2);
+
+ myText->setHeight(lineHeight);
+ QCOMPARE(myText->lineCount(), 1);
+
+ myText->setHeight(5);
+ QCOMPARE(myText->lineCount(), 1);
+
+ myText->setHeight(lineHeight * 3);
+ QCOMPARE(myText->lineCount(), 3);
+
+ // remove max count and show all lines.
+ myText->setHeight(1000);
+ myText->resetMaximumLineCount();
+
+ QCOMPARE(myText->truncated(), false);
+
+ // reduce size again
+ myText->setHeight(lineHeight * 2);
+ QCOMPARE(myText->lineCount(), 2);
+ QCOMPARE(myText->truncated(), true);
+
+ // change line height
+ myText->setLineHeight(1.1);
+ QCOMPARE(myText->lineCount(), 1);
+
+ delete canvas;
+}
+
void tst_qquicktext::textFormat()
{
{